@yuriai/web 0.2.40-beta.5 → 0.2.40-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/dist/assets/{AgentAvatar-B7KbxN8Y.js → AgentAvatar-XDXiFZvA.js} +1 -1
  2. package/dist/assets/AssistantConversationSurface-B59k-lXE.css +1 -0
  3. package/dist/assets/AssistantConversationSurface-CQnJaKTn.js +3 -0
  4. package/dist/assets/AssistantSessionCard-DXY8-wyP.js +2 -0
  5. package/dist/assets/{AssistantUnreadBadge-vu4ZhTft.js → AssistantUnreadBadge-B-G015yE.js} +1 -1
  6. package/dist/assets/{AssistantView-CEfEWUIr.js → AssistantView-CasyQbii.js} +1 -1
  7. package/dist/assets/{DiagramView-Dlzr08J_.js → DiagramView-DhWnsM9v.js} +1 -1
  8. package/dist/assets/{FadeInOnReveal-DMRmNsau.js → FadeInOnReveal-Ca9EVP3a.js} +1 -1
  9. package/dist/assets/{GuiPluginPage-DVug4z_p.js → GuiPluginPage-DKOsUpVL.js} +1 -1
  10. package/dist/assets/{GuiPluginSurface-L43o6Xv8.js → GuiPluginSurface-BfXMBqdD.js} +1 -1
  11. package/dist/assets/{GuiPluginWindow-tHXkS18H.js → GuiPluginWindow-Dmg2Qui6.js} +1 -1
  12. package/dist/assets/{Icon-DizeYahT.js → Icon-ChyA050P.js} +1 -1
  13. package/dist/assets/{ImageLoadingPlaceholder-BZC5m_km.js → ImageLoadingPlaceholder-C8QUF5aV.js} +1 -1
  14. package/dist/assets/{LoadingImage-Csw4L-Dr.js → LoadingImage-BxRq1dMQ.js} +1 -1
  15. package/dist/assets/{MarkdownRenderer-D_0iKhQN.js → MarkdownRenderer-CvWLikEO.js} +2 -2
  16. package/dist/assets/{MarkdownRendererImpl-BZ0XgjS0.js → MarkdownRendererImpl-CcNsQOEn.js} +1 -1
  17. package/dist/assets/{MarkstreamRendererImpl-DBd6Glg9.js → MarkstreamRendererImpl-D9W5XXPo.js} +1 -1
  18. package/dist/assets/MobileDetailNavigation-CnwIZn5g.js +1 -0
  19. package/dist/assets/{MobileResizableSheet-CQQ7O-2X.js → MobileResizableSheet-Bpp079l7.js} +1 -1
  20. package/dist/assets/{MobileShareBridge-IO45gM2G.js → MobileShareBridge-C-GpJfF6.js} +1 -1
  21. package/dist/assets/MobileSurface-CrNI8cYQ.js +2 -0
  22. package/dist/assets/{MultiRunWindow-fJ3XfntS.js → MultiRunWindow-DvywQkz9.js} +1 -1
  23. package/dist/assets/{OnboardingScreen-MJS5T5rL.js → OnboardingScreen-BvueSxVk.js} +1 -1
  24. package/dist/assets/{OverlayScrollbar-jtMYTn1y.js → OverlayScrollbar-CPaH_j8g.js} +1 -1
  25. package/dist/assets/RemoteAssistantSessionCard-CFWE00xD.js +1 -0
  26. package/dist/assets/{SettingsView-ZWFLpPSI.js → SettingsView-Df6GCFPI.js} +10 -10
  27. package/dist/assets/{SettingsWindow-DGRmrIWz.js → SettingsWindow-BpaRjeR-.js} +1 -1
  28. package/dist/assets/{SetupTourDialog-BYbAubwA.js → SetupTourDialog-DD_4qiTz.js} +1 -1
  29. package/dist/assets/{TerminalView-CoJ6_9P1.js → TerminalView-CRTtNAfA.js} +1 -1
  30. package/dist/assets/{ToolOutputDialog-5xBwOJ6a.js → ToolOutputDialog-omGmWntf.js} +1 -1
  31. package/dist/assets/{VoiceSettings-CN33koSc.js → VoiceSettings-Du-Yd5MF.js} +2 -2
  32. package/dist/assets/{YuriWordmark-DnFAS-Ko.js → YuriWordmark-B7lmpLRB.js} +1 -1
  33. package/dist/assets/{capgoAdapter-CCLtBZL1.js → capgoAdapter-CqMX4zC-.js} +1 -1
  34. package/dist/assets/{checkbox-rOV6DjeG.js → checkbox-KNAgqjPZ.js} +1 -1
  35. package/dist/assets/{client-uz8O6TPX.js → client-1Fk5IbQR.js} +3 -3
  36. package/dist/assets/{collapsible-CKswuqAw.js → collapsible-CdiLY07j.js} +1 -1
  37. package/dist/assets/{context-menu-B4njwT_M.js → context-menu-CO_VRWeV.js} +1 -1
  38. package/dist/assets/{diagram-BppQ_USn.js → diagram-9b-Aaful.js} +1 -1
  39. package/dist/assets/{dialog-Bg8MJnOV.js → dialog-8YYmYPFP.js} +1 -1
  40. package/dist/assets/{fileMentionTouchSelection-D-AdTJVr.js → fileMentionTouchSelection-CLQBqWR8.js} +1 -1
  41. package/dist/assets/{gitApi-DVx_V1x6.js → gitApi-uhoLUa-e.js} +1 -1
  42. package/dist/assets/gitApiHttp-B0FJaIhU.js +3 -0
  43. package/dist/assets/{gui-DN2sVP96.js → gui-BMN3-WPc.js} +1 -1
  44. package/dist/assets/{host-DrGjjO6K.js → host-D9EDWNmx.js} +1 -1
  45. package/dist/assets/{input-DRjuZMeA.js → input-DK8VTvJw.js} +1 -1
  46. package/dist/assets/{input-store-CjUOfpyA.js → input-store-CsY-uaSj.js} +1 -1
  47. package/dist/assets/insertionBoundaries-rYqUxuB-.js +1 -0
  48. package/dist/assets/{main-D2s9J_jN.js → main-BMx-2MjO.js} +14 -14
  49. package/dist/assets/main-DzqojuZ1.js +2 -0
  50. package/dist/assets/{markdownHeightCache-BL99DlhC.js → markdownHeightCache-DAvnT6xF.js} +1 -1
  51. package/dist/assets/{mcpQueries-HzYMEVWd.js → mcpQueries-CpH8vPf1.js} +1 -1
  52. package/dist/assets/miniChat-BTE_XpRk.js +2 -0
  53. package/dist/assets/mobile-BBZOulQ1.js +2 -0
  54. package/dist/assets/{mobileBackNavigation--ZdrI-Yj.js → mobileBackNavigation-Cq08UPxZ.js} +1 -1
  55. package/dist/assets/{mobileConnections-C3eGEOPy.js → mobileConnections-ZehAozpe.js} +2 -2
  56. package/dist/assets/{multirun-CDYNyLBH.js → multirun-Cll2Meol.js} +1 -1
  57. package/dist/assets/{native-DsqzO52u.js → native-CDqNKjmz.js} +1 -1
  58. package/dist/assets/{native-config-DOawZfln.js → native-config-DtUZFauV.js} +1 -1
  59. package/dist/assets/{navigation-Ibk_Pw-q.js → navigation-J3d8PQcs.js} +2 -2
  60. package/dist/assets/openRemoteProjectSession-oJZpCDPT.js +1 -0
  61. package/dist/assets/{projectMeta-D1Ytss9U.js → projectMeta-BBpfOmij.js} +1 -1
  62. package/dist/assets/prompt-attachment-upload-9fjmgafL.js +1 -0
  63. package/dist/assets/{pwa-CXupOTsD.js → pwa-C8B1Mf_t.js} +1 -1
  64. package/dist/assets/{queue-abort-optimistic-CQXpIlq6.js → queue-abort-optimistic-B1Uskf6F.js} +1 -1
  65. package/dist/assets/{react-CgRToPwO.js → react-45rBMaUm.js} +1 -1
  66. package/dist/assets/{readiness-BfuZm6Yw.js → readiness-CrjBrUa_.js} +2 -2
  67. package/dist/assets/reference-history-DqfMBWzF.js +1 -0
  68. package/dist/assets/{remote-input-store-BOdCWpQY.js → remote-input-store-84i8uDyM.js} +1 -1
  69. package/dist/assets/remoteProjectQueries-B6lrEDMq.js +1 -0
  70. package/dist/assets/remoteSessionReference-YiGvdabX.js +1 -0
  71. package/dist/assets/renderElectronMiniChatApp-BuHQB0V8.js +2 -0
  72. package/dist/assets/renderMobileApp-D_VswCi0.js +29 -0
  73. package/dist/assets/{runtimeConfig-tHm7o_0I.js → runtimeConfig-CMbNyYbK.js} +1 -1
  74. package/dist/assets/runtimeEndpointReset-zo-HZQgX.js +151 -0
  75. package/dist/assets/scheduledTaskNavigation-y5g8D2ee.js +1 -0
  76. package/dist/assets/{select-B1On-Y4Z.js → select-VWoGVTBZ.js} +1 -1
  77. package/dist/assets/sessionLookup-JAf5UU7-.js +1 -0
  78. package/dist/assets/{sortable-tabs-strip-nD1Me06z.js → sortable-tabs-strip-Dbt3TTAs.js} +1 -1
  79. package/dist/assets/{speechSettingsQueries-BYhNpzDJ.js → speechSettingsQueries-Bidfcv0W.js} +1 -1
  80. package/dist/assets/{terminalApi-madXrfqA.js → terminalApi-Cq0vjFe1.js} +1 -1
  81. package/dist/assets/{textarea-Qt06OhhX.js → textarea-vyMsAV5p.js} +1 -1
  82. package/dist/assets/{tooltip-D382RCy1.js → tooltip-DWqHWi4N.js} +1 -1
  83. package/dist/assets/{types-CHszLAS3.js → types-DeOkRCgE.js} +1 -1
  84. package/dist/assets/{useAppFontEffects-CqXrCJVt.js → useAppFontEffects-z382Lhm_.js} +60 -60
  85. package/dist/assets/useDesktopWindowControlsLayout-BEs7i5qj.js +1 -0
  86. package/dist/assets/{useDictation-Bs7TWO9r.js → useDictation-e68rFA6y.js} +1 -1
  87. package/dist/assets/{useEffectiveDirectory-CCKRdyK9.js → useEffectiveDirectory-CcM3S1OQ.js} +1 -1
  88. package/dist/assets/{useFontPreferences-CPrl1_3z.js → useFontPreferences-CO-L-Gd7.js} +1 -1
  89. package/dist/assets/{useMobileNavigationStore-BNtVrnSw.js → useMobileNavigationStore-BA0IaUi_.js} +9 -9
  90. package/dist/assets/{usePluginsStore-bMuGciUE.js → usePluginsStore-BG5MW5LR.js} +1 -1
  91. package/dist/assets/{useProjectRuntimeAPIs-BFCXBu2J.js → useProjectRuntimeAPIs-Be4gXG7P.js} +1 -1
  92. package/dist/assets/{useStreamingTextThrottle-C8xAqcgP.js → useStreamingTextThrottle-DylP9HFC.js} +1 -1
  93. package/dist/assets/{vendor-opencode-client-cQ47ywrT.js → vendor-opencode-client-BM2r1f0o.js} +3 -3
  94. package/dist/assets/{vendor-opencode-plugin-BmdTE4Te.js → vendor-opencode-plugin-ZhpPgHCL.js} +1 -1
  95. package/dist/assets/{vendor-solid-js-D98iXT7C.js → vendor-solid-js-BBVUd3Hw.js} +1 -1
  96. package/dist/index.html +10 -10
  97. package/dist/mini-chat.html +10 -10
  98. package/dist/mobile.html +1 -1
  99. package/package.json +1 -1
  100. package/server/index.js +1 -0
  101. package/server/lib/assistants/DOCUMENTATION.md +87 -0
  102. package/server/lib/assistants/assign.js +10 -7
  103. package/server/lib/assistants/builtin-skills.js +1 -0
  104. package/server/lib/assistants/builtin-skills.test.js +1 -1
  105. package/server/lib/assistants/cards.js +6 -1
  106. package/server/lib/assistants/contact-store.js +22 -5
  107. package/server/lib/assistants/contact-tools.js +46 -26
  108. package/server/lib/assistants/execution-target.js +136 -0
  109. package/server/lib/assistants/opencode-tools.js +22 -9
  110. package/server/lib/assistants/remote-execution.test.js +378 -0
  111. package/server/lib/assistants/remote-watch-reconciler.js +43 -0
  112. package/server/lib/assistants/remote-watch-reconciler.test.js +88 -0
  113. package/server/lib/assistants/routes.js +1 -0
  114. package/server/lib/assistants/service.js +302 -99
  115. package/server/lib/assistants/yuri-project.http.test.js +2 -2
  116. package/server/lib/gui-customization/DOCUMENTATION.md +8 -2
  117. package/server/lib/gui-customization/projects-client.mjs +10 -8
  118. package/server/lib/gui-customization/projects-remote.js +101 -0
  119. package/server/lib/gui-customization/projects-remote.test.js +125 -0
  120. package/server/lib/gui-customization/projects.js +30 -6
  121. package/server/lib/gui-customization/projects.test.js +66 -1
  122. package/server/lib/gui-customization/session-skill.js +2 -2
  123. package/server/lib/gui-customization/session-skill.test.js +4 -0
  124. package/server/lib/gui-customization/skill/SKILL.md +3 -1
  125. package/server/lib/gui-customization/skill/references/projects.md +30 -3
  126. package/server/lib/gui-customization/skill/references/remote-connections.md +2 -0
  127. package/server/lib/opencode/DOCUMENTATION.md +6 -0
  128. package/server/lib/opencode/feature-routes-runtime.js +2 -0
  129. package/server/lib/opencode/v2-client.js +9 -4
  130. package/server/lib/remote-hosts/DOCUMENTATION.md +52 -0
  131. package/server/lib/remote-hosts/gateway.js +136 -36
  132. package/server/lib/remote-hosts/json-lifecycle.test.js +35 -0
  133. package/server/lib/remote-hosts/routes.js +10 -13
  134. package/server/lib/remote-hosts/routes.test.js +251 -0
  135. package/server/lib/remote-hosts/store.js +17 -3
  136. package/server/lib/remote-hosts/store.test.js +19 -0
  137. package/server/lib/remote-hosts/task-client.js +25 -0
  138. package/server/lib/remote-hosts/task-client.test.js +60 -0
  139. package/server/lib/remote-hosts/transport.js +7 -2
  140. package/server/lib/request-cors.js +1 -1
  141. package/server/lib/request-cors.test.js +1 -0
  142. package/server/lib/scheduled-tasks/session-skill.test.js +33 -2
  143. package/dist/assets/AssistantConversationSurface-BnK_KTBO.js +0 -3
  144. package/dist/assets/AssistantConversationSurface-n9w_Av0k.css +0 -1
  145. package/dist/assets/MobileDetailNavigation-xgwvsQuR.js +0 -1
  146. package/dist/assets/MobileSurface-DmYgZONB.js +0 -2
  147. package/dist/assets/gitApiHttp-DvTBxvX8.js +0 -3
  148. package/dist/assets/insertionBoundaries-DZtQt2Ah.js +0 -1
  149. package/dist/assets/main-BMFY9mtb.js +0 -2
  150. package/dist/assets/miniChat-BbJ0GKpk.js +0 -2
  151. package/dist/assets/mobile-_zUth69Z.js +0 -2
  152. package/dist/assets/prompt-attachment-upload-BNhDXymd.js +0 -1
  153. package/dist/assets/remoteProjectQueries-CkxdZNw4.js +0 -1
  154. package/dist/assets/renderElectronMiniChatApp-pJ59iC34.js +0 -2
  155. package/dist/assets/renderMobileApp-BQFC-gOA.js +0 -29
  156. package/dist/assets/runtimeEndpointReset-BhHWFNvo.js +0 -150
  157. package/dist/assets/scheduledTaskNavigation-BIDtQ4wN.js +0 -1
  158. package/dist/assets/sessionLookup-RcyTTDOy.js +0 -1
  159. package/dist/assets/useDesktopWindowControlsLayout-KH4UP7Gj.js +0 -1
  160. /package/dist/assets/{sessionLookup-8C8nv-EP.css → reference-history-8C8nv-EP.css} +0 -0
@@ -1,3 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{C as t,D as n,k as r}from"./runtime-auth-mjIpsk3N.js";import{c as i,f as a,i as o,n as s,s as c}from"./runtime-switch-BMjl5Y5W.js";import{n as l}from"./runtime-fetch-DKZOpfzo.js";import{F as u,P as d,R as f,S as p,d as m}from"./platform-wF65ZFgV.js";import{t as h}from"./runtimeAPIRegistry-C2VogTny.js";import{a as g,i as ee,r as _}from"./vendor-zustand-Cwko4FG1.js";import{st as te}from"./vendor-base-ui-z2M4boRm.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{i as ne,n as v,t as re}from"./safeStorage-DTOhKN0V.js";import{Cr as ie,Sr as ae,n as y,wr as b,z as oe}from"./client-uz8O6TPX.js";import{A as se,B as ce,F as le,I as ue,M as de,N as fe,T as pe,f as me,g as he,h as ge,j as _e,m as ve,p as ye,x}from"./prompt-attachment-upload-BNhDXymd.js";import{n as be}from"./vendor-react-P8wFrkcT.js";import{q as xe}from"./runtime-file-resource-CuLP3xp7.js";import{_ as Se,c as Ce,l as we,r as S,v as Te}from"./useUIStore-Cfmg-aDQ.js";import{t as Ee}from"./uuid-D-SDZijH.js";var De=(e,t)=>e!==t;function Oe(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Invalid Hub project layout`);let t=e;if(typeof t.hubId!=`string`||!t.hubId.trim()||!Array.isArray(t.order)||t.order.some(e=>typeof e!=`string`||!e.trim())||!t.collapsed||typeof t.collapsed!=`object`||Array.isArray(t.collapsed)||Object.entries(t.collapsed).some(([e,t])=>!e.trim()||typeof t!=`boolean`))throw Error(`Invalid Hub project layout`);return{hubId:t.hubId,order:[...new Set(t.order)],collapsed:Object.fromEntries(Object.entries(t.collapsed))}}var ke=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/g,``).trim();if(!t)return``;let n=new TextEncoder().encode(t),r=``;for(let e of n)r+=String.fromCharCode(e);return`path_${typeof btoa==`function`?btoa(r).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``):t.replace(/[^A-Za-z0-9._-]+/g,`_`)}`},C={...x,sessionIdLength:x.sessionIDLength,visibleTextLength:1e5,canonicalOutputLength:2e5},Ae=e=>typeof e==`string`&&de(e),je=e=>e.replaceAll(`\\`,`/`).split(`/`).at(-1)?.replace(/\.md$/,``)??``,Me=e=>({trigger:`@`,icon:`chat-thread`,label:e}),Ne=(e,t)=>({trigger:`/`,icon:t,label:e}),Pe=(e,t)=>({trigger:t,icon:`book-open`,label:e}),Fe=(e,t)=>[`/`,`@`].some(n=>he(e,Pe(t,n))),Ie=(e,t)=>he(e,Pe(t,`@`))?Pe(t,`@`):Pe(t,`/`),Le={session:{kind:`session`,validatePayload:e=>Ae(e.sessionId),contributeCanonical:e=>({text:`@session:${e.sessionId}`,semantic:{type:`session`,sessionId:e.sessionId}}),contributeDirectSend:e=>{let t=Me(ye(e.display,`@`));return{text:ve(t),semantic:{type:`session`,sessionId:e.sessionId}}},decorate:e=>{let t=Me(ye(e.display,`@`));return{style:`mentionSession`,visual:ge(t,e.display)}},payloadBudget:()=>void 0,canonical:{matcher:/@session:([A-Za-z0-9_-]+)/g,resolveDisplay:(e,t)=>{let n=e.index===0?``:t.text[e.index-1],r=t.text[e.index+e[0].length]??``;return(n===``||/[\s([{]/.test(n))&&(r===``||/[\s)\]},.!?;:]/.test(r))?me(Me(t.sessionTitles.get(e[1])||e[1])):null},materialize:(e,t,n)=>({id:`session:${e[1]}:${e.index}`,kind:`session`,sessionId:e[1],display:t,start:n,end:n+t.length})}},paste:{kind:`paste`,validatePayload:e=>typeof e.text==`string`&&e.text.length<=C.pastePayloadLength&&typeof e.characterCount==`number`&&Number.isSafeInteger(e.characterCount)&&e.characterCount===ce(e.text)&&typeof e.index==`number`&&Number.isSafeInteger(e.index)&&e.index>=1,contributeCanonical:e=>({text:e.text}),contributeDirectSend:e=>({text:e.text}),decorate:()=>({style:`mentionPaste`}),payloadBudget:e=>({category:`opaque-text`,length:e.text.length})},skill:{kind:`skill`,validatePayload:e=>fe(e.skillName)&&typeof e.display==`string`&&Fe(e.display,e.skillName),contributeCanonical:e=>({text:`[skill:${e.skillName}]`}),contributeDirectSend:e=>({text:`[skill:${e.skillName}]`}),decorate:e=>({style:`mentionCommand`,skillName:e.skillName,visual:ge(Ie(e.display,e.skillName),e.display)}),payloadBudget:()=>void 0,canonical:{matcher:pe(),resolveDisplay:e=>me(Pe(e[1],`@`)),materialize:(e,t,n)=>({id:`skill:${n}`,kind:`skill`,skillName:e[1],display:t,start:n,end:n+t.length})}},command:{kind:`command`,validatePayload:e=>se(e.commandName)&&_e(e.reference)&&typeof e.display==`string`&&he(e.display,Ne(e.commandName,`command`)),contributeCanonical:e=>({text:`[command:${e.reference}]`}),contributeDirectSend:e=>({text:`[command:${e.reference}]`}),decorate:e=>({style:`mentionCommand`,visual:ge(Ne(e.commandName,`command`),e.display)}),payloadBudget:()=>void 0,canonical:{matcher:/\[command:([^\]\r\n]+)\]/g,resolveDisplay:e=>{let t=je(e[1]);return _e(e[1])&&se(t)?me(Ne(t,`command`)):null},materialize:(e,t,n)=>({id:`command:${n}`,kind:`command`,commandName:je(e[1]),reference:e[1],display:t,start:n,end:n+t.length})}}},w=e=>Le[e],Re=(e,t)=>w(e).validatePayload(t),ze=e=>w(e.kind).contributeCanonical(e),Be=e=>w(e.kind).contributeDirectSend(e),Ve=e=>w(e.kind).decorate(e),He=e=>w(e.kind).payloadBudget(e),Ue=e=>w(e.kind).describeResourceIdentity?.(e),We=Object.keys(Le),Ge=e=>typeof e==`string`&&We.includes(e),Ke=()=>We.flatMap(e=>{let t=w(e).canonical;return t?[t]:[]}),qe=e=>{if(e.type===`attachment`)return`attachment:${e.attachmentRefID}`},Je=e=>{let t=new Map;for(let n of e.references){let e=Ue(n);e&&t.set(qe(e),e)}return[...t.values()]},Ye=(e,t)=>{let n=new Map(e.map(e=>[qe(e),e])),r=new Map(t.map(e=>[qe(e),e]));return{previous:[...n.values()],next:[...r.values()],added:[...r].flatMap(([e,t])=>n.has(e)?[]:[t]),removed:[...n].flatMap(([e,t])=>r.has(e)?[]:[t])}},Xe=(e,t)=>Ye(Je(e),Je(t)),Ze=(e,t=`queue-canonical`)=>{if(e.references.length>C.referenceCount)return{ok:!1,reason:`reference-budget-exceeded`};let n=[...e.references].sort((e,t)=>e.start-t.start),r=0,i=0;for(let t of n){if(t.start<r||t.start<0||t.end<=t.start||t.end>e.text.length||e.text.slice(t.start,t.end)!==t.display)return{ok:!1,reason:`invalid-references`};r=t.end;let n=He(t);i+=n?.category===`opaque-text`?n.length:0}if(i>C.totalPastePayloadLength)return{ok:!1,reason:`reference-payload-budget-exceeded`};let a=[],o=[],s=0;for(let r of n){s<r.start&&a.push({provenance:`authored`,text:e.text.slice(s,r.start),start:s,end:r.start});let n=t===`direct-send-display`?Be(r):ze(r);n.semantic?(a.push({provenance:`generated-reference`,text:n.text,start:r.start,end:r.end,referenceId:r.id,semantic:n.semantic}),o.push(n.semantic)):a.push({provenance:`reference-payload`,text:n.text,start:r.start,end:r.end,referenceId:r.id}),s=r.end}s<e.text.length&&a.push({provenance:`authored`,text:e.text.slice(s),start:s,end:e.text.length});let c=a.map(e=>e.text).join(``);return c.length>C.canonicalOutputLength?{ok:!1,reason:`canonical-output-too-large`}:{ok:!0,plan:{chunks:a,semantics:o},text:c}},T=(e,t)=>Math.max(0,Math.min(e,t)),Qe=(e,t)=>typeof e==`string`&&e.length>0&&e.length<=t,$e=e=>{if(typeof e!=`object`||!e)return!1;let t=e;return!Qe(t.id,C.displayLength)||!Qe(t.display,C.displayLength)||!Number.isSafeInteger(t.start)||!Number.isSafeInteger(t.end)||typeof t.kind!=`string`?!1:Ge(t.kind)&&Re(t.kind,t)},E=(e,t)=>{let n=[],r=0,i=[],a=Math.min(t.length,C.referenceCount);for(let e=0;e<a;e+=1){let a=t[e];if(!$e(a)){typeof a==`object`&&a&&typeof a.id==`string`&&n.push(a.id),r+=1;continue}i.push({reference:a,index:e})}i.sort((e,t)=>e.reference.start-t.reference.start||e.index-t.index);let o=[],s=new Set,c=0,l=0,u=!1;for(let{reference:t}of i){if(s.has(t.id)||t.start<c||t.start<0||t.end<=t.start||t.end>e.length||e.slice(t.start,t.end)!==t.display){n.push(t.id),r+=1;continue}s.add(t.id),c=t.end;let i=He(t);if(l+=i?.category===`opaque-text`?i.length:0,l>x.totalPastePayloadLength){n.push(t.id),r+=1,s.delete(t.id),c=o.at(-1)?.end??0,u=!0,l-=i?.category===`opaque-text`?i.length:0;continue}o.push(t)}return r+=t.length-a,{document:{text:e,references:o},rejectedIds:n,rejectedCount:r,budgetExceeded:t.length>C.referenceCount,payloadBudgetExceeded:u}},D=e=>{let t=[...e.references].sort((e,t)=>e.start-t.start||e.end-t.end),n=[],r=new Set,i=0,a=0;for(let o of t){if(!Qe(o.id,C.idLength)||!Qe(o.display,C.displayLength)||!Ge(o.kind)||!Number.isSafeInteger(o.start)||!Number.isSafeInteger(o.end)||r.has(o.id)||o.start<i||o.start<0||o.end<=o.start||o.end>e.text.length||e.text.slice(o.start,o.end)!==o.display)continue;let t=He(o),s=t?.category===`opaque-text`?t.length:0;a+s>x.totalPastePayloadLength||(r.add(o.id),i=o.end,a+=s,n.push(o))}return{text:e.text,references:n}},et=(e,t)=>{if(t.length>x.pastePayloadLength)return!1;let n=E(e.text,e.references);return n.budgetExceeded||n.payloadBudgetExceeded?!1:n.document.references.reduce((e,t)=>{let n=He(t);return e+(n?.category===`opaque-text`?n.length:0)},0)+t.length<=x.totalPastePayloadLength},tt=(e,t,n)=>{let r=e.filter(e=>t===n?t>e.start&&t<e.end:e.start<n&&e.end>t);return r.length===0?{start:t,end:n}:{start:Math.min(t,...r.map(e=>e.start)),end:Math.max(n,...r.map(e=>e.end))}};function nt(e,t,n,r,i={}){let a=D(e);if(!Re(r.kind,r))return{document:a,caret:T(n,a.text.length),edit:{oldStart:t,oldEnd:n,newEnd:n}};let o=T(t,a.text.length),s=Math.max(o,T(n,a.text.length)),c=tt(a.references,o,s),l=a.text.slice(0,c.start),u=a.text.slice(c.end),d=!!i.padDocumentEdges&&i.padLeadingDocumentEdge!==!1,f=!!i.padDocumentEdges,p=i.inlineBoundaries&&(l.length>0||d)&&!/\s$/.test(l)?` `:``,m=i.inlineBoundaries&&(u.length>0||f)&&!/^\s/.test(u)?` `:``,h=`${l}${p}${r.display}${m}${u}`,g={...r,start:c.start+p.length,end:c.start+p.length+r.display.length},ee=p.length+r.display.length+m.length-(c.end-c.start);return{document:D({text:h,references:[...a.references.filter(e=>e.end<=c.start||e.start>=c.end).map(e=>e.start>=c.end?{...e,start:e.start+ee,end:e.end+ee}:e),g]}),caret:g.end,edit:{oldStart:c.start,oldEnd:c.end,newEnd:c.start+p.length+r.display.length+m.length}}}var rt=(e,t)=>e<=t.oldStart?e:e>=t.oldEnd?e+t.newEnd-t.oldEnd:t.newEnd,it=(e,t,n=t.length,r=n)=>{let i=D(e),a=0,o=Math.min(i.text.length,t.length);for(;a<o&&i.text[a]===t[a];)a+=1;let s=0;for(;s<i.text.length-a&&s<t.length-a&&i.text[i.text.length-s-1]===t[t.length-s-1];)s+=1;let c={oldStart:a,oldEnd:i.text.length-s,newEnd:t.length-s},l=tt(i.references,c.oldStart,c.oldEnd),u=l.start!==c.oldStart||l.end!==c.oldEnd,d=i.references.filter(e=>e.start<l.end&&e.end>l.start),f=t.slice(c.oldStart,c.newEnd),p=`${i.text.slice(0,l.start)}${f}${i.text.slice(l.end)}`,m={oldStart:l.start,oldEnd:l.end,newEnd:l.start+f.length},h=m.newEnd-m.oldEnd,g=i.references.filter(e=>e.end<=l.start||e.start>=l.end).map(e=>e.start>=l.end?{...e,start:e.start+h,end:e.end+h}:e),ee=(e,n)=>{let r=T(e,t.length),i=c.newEnd+l.end-c.oldEnd;return T(r<=l.start?r:r<c.oldStart||r===c.oldStart&&n===`start`?l.start:r<c.newEnd||r===c.newEnd&&n===`start`?l.start+r-c.oldStart:r<=i?m.newEnd:m.newEnd+r-i,p.length)},_=ee(n,`start`),te=Math.max(_,ee(r,`end`)),ne=D({text:p,references:g});return{document:ne,edit:m,requiresTextCorrection:u,selectionStart:_,selectionEnd:te,caret:te,mapCaret:e=>T(rt(e,m),ne.text.length),removedReferences:d}},at=(e,t,n)=>{let r=tt(n,e,t);return r.start===e&&r.end===t?null:r},ot=(e,t,n)=>{let r=n,i=n;if(t===`Backspace`){for(;r>0&&/\s/.test(e[r-1]);)--r;for(;r>0&&!/\s/.test(e[r-1]);)--r}else{for(;i<e.length&&/\s/.test(e[i]);)i+=1;for(;i<e.length&&!/\s/.test(e[i]);)i+=1}return{start:r,end:i}},st=(e,t)=>{let n=D(e),r=T(t.selectionStart,n.text.length),i=Math.max(r,T(t.selectionEnd,n.text.length)),a=r===i?t.altKey?ot(n.text,t.key,r):t.key===`Backspace`?{start:Math.max(0,r-1),end:r}:{start:r,end:Math.min(n.text.length,r+1)}:{start:r,end:i},o=at(a.start,a.end,n.references);if(!o)return null;let s=n.references.filter(e=>e.start<o.end&&e.end>o.start);return{document:D({text:`${n.text.slice(0,o.start)}${n.text.slice(o.end)}`,references:n.references.filter(e=>!s.includes(e)).map(e=>e.start>=o.end?{...e,start:e.start-(o.end-o.start),end:e.end-(o.end-o.start)}:e)}),caret:o.start,edit:{oldStart:o.start,oldEnd:o.end,newEnd:o.start},removedIds:s.map(e=>e.id),removedReferences:s}},ct=(e,t)=>{let n=t,r=t;for(;n>0&&/\s/.test(e[n-1]);)--n;for(;r<e.length&&/\s/.test(e[r]);)r+=1;let i=n>0&&r<e.length?` `:``;return{text:`${e.slice(0,n)}${i}${e.slice(r)}`,caret:n+i.length}},lt=(e,t=`queue-canonical`)=>{let n=E(e.text,e.references);if(n.budgetExceeded)return{ok:!1,reason:`reference-budget-exceeded`};if(n.payloadBudgetExceeded)return{ok:!1,reason:`reference-payload-budget-exceeded`};if(n.rejectedCount>0)return{ok:!1,reason:`invalid-references`};let r=Ze(n.document,t);return r.ok?{ok:!0,text:r.text,chunks:r.plan.chunks,semantics:r.plan.semantics}:r},ut=(e,t)=>e.match.index-t.match.index||e.adapterOrder-t.adapterOrder||e.matchOrder-t.matchOrder,dt=e=>{if(e.length>C.canonicalOutputLength||e.length>C.visibleTextLength)return null;let t=[],n=0;for(let[r,i]of Ke().entries()){i.matcher.lastIndex=0;let a,o=0;for(;(a=i.matcher.exec(e))!==null;){if(n+=1,n>C.referenceCount)return null;let e={codec:i,match:a,adapterOrder:r,matchOrder:o};o+=1;let s=t.findIndex(t=>ut(e,t)<0);s===-1?t.push(e):t.splice(s,0,e)}}return t},ft=(e,t)=>{let n=E(e.text,e.references).document,r=dt(n.text);if(r===null)return n;let i={text:n.text,sessionTitles:t},a=[],o=``,s=0,c=0,l=new Set(n.references.map(e=>e.id)),u=[];for(let e of r){let{match:t,codec:r}=e,a=t.index,o=a+t[0].length;if(a<c||n.references.some(e=>e.start<o&&e.end>a))continue;let s=r.resolveDisplay(t,i);if(s===null||s.length>C.displayLength)continue;let d=r.materialize(t,s,a),f=d.id;for(;l.has(f);)f=`materialized:${f}`;l.add(f),u.push({start:a,end:o,display:s,reference:{...d,id:f}}),c=o}s=0;let d=0;for(let e of u){o+=`${n.text.slice(s,e.start)}${e.display}`;let t=e.start+d;a.push({...e.reference,start:t,end:t+e.display.length}),d+=e.display.length-(e.end-e.start),s=e.end}if(o+=n.text.slice(s),o.length>C.visibleTextLength)return n;let f=n.references.map(e=>{let t=u.filter(t=>t.end<=e.start).reduce((e,t)=>e+t.display.length-(t.end-t.start),0);return{...e,start:e.start+t,end:e.end+t}});return E(o,[...f,...a]).document},pt=(e,t)=>ft({text:e,references:[]},t),mt=(e,t)=>pt(e,t),ht=(e,t,n=`
2
-
3
- `)=>{let r=E(e.text,e.references).document,i=E(t.text,t.references).document;if(r.text===i.text&&JSON.stringify(r.references)===JSON.stringify(i.references))return i;let a=new Set(r.references.map(e=>e.id)),o=e=>{let t=e;for(;a.has(t);)t=`recovered:${t}`;return a.add(t),t},s=r.text.length+n.length;return E(`${r.text}${n}${i.text}`,[...r.references,...i.references.map(e=>({...e,id:o(e.id),start:e.start+s,end:e.end+s}))]).document},gt=e=>({state:`unbound-legacy`,sessionID:e}),O=e=>e.state===`bound`?`bound:${JSON.stringify([e.transportIdentity,m(e.directory),e.sessionID,e.deliveryTarget??{kind:`primary`}])}`:`unbound-legacy:${JSON.stringify([e.sessionID])}`,_t=(e,t)=>e.queuedMessages[O(t)]??vt,vt=[],yt=3e4,bt=`queue`,xt=e=>e===`steer`||e===`queue`,St=(e,t)=>e===`immediate`?`steer`:xt(e)?e:t===!1?`steer`:`queue`,Ct=[],wt=(e,t)=>e.pendingAdmissions[O(t)]??Ct,Tt=e=>`${e}-${Ee()}`,Et=e=>typeof e==`object`&&!!e&&Object.getPrototypeOf(e)===Object.prototype,k=(e,t,n=[])=>{if(!Et(e)||!Object.keys(e).every(e=>e===`text`||e===`references`))return;let r=e;if(typeof r.text!=`string`)return;let i=le(r.text,r.references),a=i&&lt(i,`queue-canonical`);if(!a||!a.ok||a.text!==t)return;let o=new Set(n.map(e=>e.id));return Je(i).every(e=>o.has(e.attachmentRefID))?i:void 0},Dt=(e,t)=>{if(e===void 0)return[];if(!t)return;let n=ue(t.text,e);if(n)return n.some(e=>t.references.some(t=>e.range.start<t.end&&t.start<e.range.end))?void 0:n},Ot=(e,t)=>{let n=Et(e)&&typeof e.content==`string`?e:t,r=k(n.composerDocument,n.content,Array.isArray(n.attachments)?n.attachments:[]),i=Dt(n.composerMentions,r);return{content:n.content,...r?{composerDocument:r}:{},...r&&i?.length?{composerMentions:i}:{},...Array.isArray(n.attachments)?{attachments:n.attachments}:{},...Et(n.sendConfig)?{sendConfig:n.sendConfig}:{}}},kt=e=>Ot(void 0,e),At=(e,t)=>e.queueItemID===t.queueItemID&&e.operationID===t.operationID&&(!t.messageID||e.messageID===t.messageID),A=e=>e.status===`sending`||e.status===`reconciling`,jt=re(),Mt=()=>jt?.flush()??!0,Nt=`quiescing`,Pt=new Set,Ft=new Set,It=e=>{if(Nt!==e){Nt=e;for(let e of Ft)e()}},Lt=e=>{if(!(!e||Pt.has(e))){Pt.add(e);for(let e of Ft)e()}},Rt=e=>e.state===`bound`&&Pt.has(e.transportIdentity),j=e=>Nt===`open`&&(!e||!Rt(e)),zt=(e,t=Date.now())=>({reconciliationStartedAt:e.reconciliationStartedAt??t,reconciliationDeadlineAt:e.reconciliationDeadlineAt??(e.reconciliationStartedAt??t)+yt,reconciliationChecks:Math.max(0,Math.floor(e.reconciliationChecks??0))}),Bt=(e,t,n)=>{let r=t.queueItemID??(t.id||Tt(`queued`)),i=!t.owner&&(t.status===`sending`||t.status===`reconciling`),a=i?`unresolved`:t.status===`sending`?`reconciling`:t.status===`retrying`||t.status===`reconciling`||t.status===`unresolved`||t.status===`failed`?t.status:`queued`,o=typeof t.messageID==`string`&&t.messageID.startsWith(`msg_`)?t.messageID:oe(`msg`),s=k(t.composerDocument,t.content,t.attachments),c=Dt(t.composerMentions,s);return{...t,...s?{composerDocument:s}:{composerDocument:void 0},...s&&c?.length?{composerMentions:c}:{composerMentions:void 0},id:r,queueItemID:r,operationID:t.operationID??Tt(`operation`),messageID:o,owner:n,status:a,attemptCount:Math.max(0,Math.floor(t.attemptCount??0)),...t.status===`sending`||t.status===`reconciling`?zt(t):{},...i||a===`reconciling`&&t.status===`sending`?{failure:{kind:`ambiguous-dispatch`,recovery:Ot(t.failure?.recovery,t)}}:{}}},Vt=e=>{let t=e??{},n={};for(let[e,r]of Object.entries(t.queuedMessages??{})){if(!Array.isArray(r))continue;let t;if(e.startsWith(`bound:`)||e.startsWith(`unbound-legacy:`)){let n=r[0],i=e.startsWith(`unbound-legacy:`)?(()=>{try{let t=JSON.parse(e.slice(15));return Array.isArray(t)&&typeof t[0]==`string`?t[0]:e}catch{return e}})():e;t=n?.owner?.state===`bound`?n.owner:gt(n?.owner?.sessionID??i)}else t=gt(e);for(let e of r){let r=e.owner?.state===`bound`?e.owner:t,i=O(r);(n[i]??=[]).push(Bt(r.sessionID,e,r))}}return{queuedMessages:n,followUpBehavior:St(t.followUpBehavior,t.queueModeEnabled??null)}},M=(e,t,n,r)=>{if(Rt(t))return;let i=O(t);e(e=>{let t=e.queuedMessages[i],a=t?.findIndex(e=>O(e.owner)===i&&At(e,n))??-1;if(a<0||!t)return e;let o=r(t[a]);if(o===t[a])return e;let s=t.slice();return s[a]=o,{queuedMessages:{...e.queuedMessages,[i]:s}}})},Ht=g()(_(ee((e,t)=>({queuedMessages:{},followUpBehavior:bt,pendingAdmissions:{},addToQueue:(t,n)=>{if(!j(t))return{ok:!1,reason:`invalid-composer-document`};let r=k(n.composerDocument,n.content,n.attachments);if(n.composerDocument!==void 0&&!r)return{ok:!1,reason:`invalid-composer-document`};let i=Dt(n.composerMentions,r);if(n.composerMentions!==void 0&&!i)return{ok:!1,reason:`invalid-composer-mentions`};n={...n,...r?{composerDocument:r}:{},...i?.length?{composerMentions:i}:{}};let a={...n,id:Tt(`queued`),queueItemID:``,operationID:Tt(`operation`),messageID:oe(`msg`),createdAt:Date.now(),owner:t,status:`queued`,attemptCount:0};a.queueItemID=a.id;let o=O(t);return e(e=>({queuedMessages:{...e.queuedMessages,[o]:[...e.queuedMessages[o]??[],a]}})),{ok:!0,item:a}},removeFromQueue:(n,r,i)=>{if(!j(n)||!i)return!1;let a=O(n),o=t().queuedMessages[a];if(!o||o.length===0)return!0;let s=o.find(e=>(e.queueItemID===r||e.id===r)&&O(e.owner)===a);if(s&&s.operationID!==i)return!1;let c=o.find(e=>(e.queueItemID===r||e.id===r)&&e.operationID===i&&O(e.owner)===a);return!c||!A(c)&&(e(e=>{let t=e.queuedMessages[a];if(!t)return e;let n=t.filter(e=>e!==c);if(n.length===t.length)return e;if(n.length)return{queuedMessages:{...e.queuedMessages,[a]:n}};let{[a]:r,...i}=e.queuedMessages;return{queuedMessages:i}}),!_t(t(),n).some(e=>e===c||(e.queueItemID===r||e.id===r)&&e.operationID===i))},reorderQueue:(t,n,r,i)=>{if(!j(t)||!i)return;let a=O(t);e(e=>{let t=e.queuedMessages[a],o=t?.findIndex(e=>(e.id===n||e.queueItemID===n)&&e.operationID===i&&O(e.owner)===a)??-1,s=t?.findIndex(e=>(e.id===r||e.queueItemID===r)&&O(e.owner)===a)??-1;if(!t||o<0||s<0||o===s||A(t[o])||A(t[s]))return e;let c=t.slice(),[l]=c.splice(o,1);return c.splice(s,0,l),{queuedMessages:{...e.queuedMessages,[a]:c}}})},popToInput:(e,n,r)=>{if(!j(e)||!r)return null;let i=_t(t(),e).find(t=>(t.id===n||t.queueItemID===n)&&t.operationID===r&&O(t.owner)===O(e));return!i||A(i)||!t().removeFromQueue(e,i.queueItemID,i.operationID)?null:i},clearQueue:n=>{if(!j(n))return!1;let r=O(n),i=t().queuedMessages[r],a=(t().pendingAdmissions[r]??[]).length>0;return(!i||i.length===0)&&!a||!i?.some(A)&&(e(e=>{if(e.queuedMessages[r]?.some(A))return e;let t={...e.queuedMessages},n={...e.pendingAdmissions};return delete t[r],delete n[r],{queuedMessages:t,pendingAdmissions:n}}),(t().queuedMessages[r]??[]).length===0)},clearAllQueues:()=>{j()&&e(e=>{let t={},n=!1;for(let[r,i]of Object.entries(e.queuedMessages)){if(i[0]&&Rt(i[0].owner)){t[r]=i;continue}let e=i.filter(A);e.length&&(t[r]=e),e.length!==i.length&&(n=!0)}let r=Object.keys(e.pendingAdmissions).length>0;return n||r?{queuedMessages:t,pendingAdmissions:{}}:e})},setFollowUpBehavior:t=>{j()&&(e({followUpBehavior:t}),H({followUpBehavior:t}))},getQueueForScope:e=>_t(t(),e),getPendingAdmissionsForScope:e=>wt(t(),e),stageAdmission:(t,n)=>{if(!j(t)||!n.requestID||!n.queueItemID||!n.operationID||!n.messageID||typeof n.content!=`string`)return;let r=k(n.composerDocument,n.content);if(n.composerDocument!==void 0&&!r)return;let i=Dt(n.composerMentions,r);if(n.composerMentions!==void 0&&!i)return;let a=O(t),o={kind:`pending-admission`,requestID:n.requestID,queueItemID:n.queueItemID,operationID:n.operationID,messageID:n.messageID,content:n.content,createdAt:n.createdAt,phase:`admitting`,attachmentCount:Math.max(0,Math.floor(n.attachmentCount??0)),...r?{composerDocument:r}:{},...r&&i?.length?{composerMentions:i}:{}};e(e=>{let t=[...(e.pendingAdmissions[a]??[]).filter(e=>e.requestID!==o.requestID&&e.queueItemID!==o.queueItemID),o];return{pendingAdmissions:{...e.pendingAdmissions,[a]:t}}})},unstageAdmission:(t,n)=>{if(!n)return;let r=O(t);e(e=>{let t=e.pendingAdmissions[r];if(!t?.length)return e;let i=t.filter(e=>e.requestID!==n);if(i.length===t.length)return e;if(i.length)return{pendingAdmissions:{...e.pendingAdmissions,[r]:i}};let{[r]:a,...o}=e.pendingAdmissions;return{pendingAdmissions:o}})},confirmAdmission:(n,r)=>{if(!j(n)||!r.requestID||!r.sendConfig?.providerID||!r.sendConfig?.modelID)return{ok:!1,reason:`invalid-composer-document`};let i=O(n),a=(t().pendingAdmissions[i]??[]).find(e=>e.requestID===r.requestID);if(!a)return{ok:!1,reason:`invalid-composer-document`};let o=k(a.composerDocument,a.content,r.attachments);if(a.composerDocument!==void 0&&!o)return{ok:!1,reason:`invalid-composer-document`};let s=Dt(a.composerMentions,o);if(a.composerMentions!==void 0&&!s)return{ok:!1,reason:`invalid-composer-mentions`};let c={id:a.queueItemID,queueItemID:a.queueItemID,operationID:a.operationID,messageID:a.messageID,content:a.content,createdAt:a.createdAt,owner:n,status:`queued`,attemptCount:0,sendConfig:r.sendConfig,...o?{composerDocument:o}:{},...o&&s?.length?{composerMentions:s}:{},...r.attachments?.length?{attachments:r.attachments}:{}};return e(e=>{let t=(e.pendingAdmissions[i]??[]).filter(e=>e.requestID!==r.requestID);return{pendingAdmissions:t.length?{...e.pendingAdmissions,[i]:t}:(()=>{let{[i]:t,...n}=e.pendingAdmissions;return n})(),queuedMessages:{...e.queuedMessages,[i]:[...e.queuedMessages[i]??[],c]}}}),{ok:!0,item:c}},bindLegacyQueue:(t,n)=>{if(!j(t)||!j(n)||t.state!==`unbound-legacy`||n.state!==`bound`||t.sessionID!==n.sessionID)return[];let r=O(t),i=O(n),a=[];return e(e=>{let t=e.queuedMessages[r];if(!t||(a=t.filter(e=>!A(e)),a.length===0))return e;let o=t.filter(A),s={...e.queuedMessages,[i]:[...a.map(e=>({...e,owner:n})),...e.queuedMessages[i]??[]]};return o.length?s[r]=o:delete s[r],{queuedMessages:s}}),a.map(e=>({...e,owner:n}))},markQueueItemSendAttempt:(t,n)=>{j(t)&&M(e,t,n,e=>e.status===`queued`||e.status===`retrying`&&(e.nextAttemptAt??0)<=Date.now()?{...e,status:`sending`,attemptCount:e.attemptCount+1,nextAttemptAt:void 0,failure:void 0}:e)},markQueueItemPreDispatchRetry:(t,n,r,i)=>M(e,t,n,e=>e.status===`sending`?{...e,status:`retrying`,nextAttemptAt:r,failure:{kind:`pre-dispatch`,recovery:i?.recovery??kt(e)}}:e),markQueueItemReconciling:(t,n,r)=>M(e,t,n,e=>e.status===`sending`?{...e,status:`reconciling`,nextAttemptAt:void 0,...zt(e),reconciliationNextCheckAt:void 0,failure:{kind:`ambiguous-dispatch`,recovery:r?.recovery??kt(e)}}:e),recordQueueItemReconciliationCheck:(t,n)=>M(e,t,n,e=>e.status===`reconciling`&&At(e,n)?{...e,reconciliationChecks:(e.reconciliationChecks??0)+1,reconciliationNextCheckAt:Date.now()+2e3}:e),resolveQueueItemReconciliation:(t,n)=>M(e,t,n,e=>e.status===`reconciling`&&At(e,n)?{...e,status:`unresolved`,nextAttemptAt:void 0}:e),markQueueItemDefinitiveFailure:(t,n,r)=>M(e,t,n,e=>e.status===`sending`?{...e,status:`failed`,nextAttemptAt:void 0,failure:{kind:`definitive`,recovery:r?.recovery??kt(e)}}:e),resetQueueItemForDispatch:(t,n)=>{j(t)&&M(e,t,n,e=>e.status!==`failed`&&e.status!==`unresolved`&&e.status!==`retrying`?e:{...e,status:`queued`,nextAttemptAt:void 0,failure:void 0,reconciliationStartedAt:void 0,reconciliationDeadlineAt:void 0,reconciliationChecks:void 0,reconciliationNextCheckAt:void 0})},beginQueueItemDispatch:(t,n,r,i,a=Date.now())=>{if(!j(t)||!r.startsWith(`msg_`))return null;let o=O(t),s=null;return e(e=>{let t=e.queuedMessages[o],c=i?t?.findIndex(e=>O(e.owner)===o&&At(e,n))??-1:0,l=c>=0?t?.[c]:void 0,u=l?.status===`queued`||l?.status===`retrying`&&(i||(l.nextAttemptAt??0)<=a)||i&&(l?.status===`failed`||l?.status===`unresolved`);if(!l||O(l.owner)!==o||!At(l,n)||!u||t?.some(A))return e;s={...l,messageID:r,status:`sending`,attemptCount:l.attemptCount+1,nextAttemptAt:void 0,failure:void 0,reconciliationStartedAt:void 0,reconciliationDeadlineAt:void 0,reconciliationChecks:void 0,reconciliationNextCheckAt:void 0};let d=t.slice();return d.splice(c,1),d.unshift(s),{queuedMessages:{...e.queuedMessages,[o]:d}}}),s},confirmQueueItem:(t,n)=>{if(Rt(t))return;let r=O(t);e(e=>{let t=e.queuedMessages[r],i=t?.find(e=>{let t=!n.operationID||e.operationID===n.operationID,r=!n.messageID||e.messageID===n.messageID,i=!n.queueItemID||e.queueItemID===n.queueItemID;return t&&r&&i});if(!i||!n.operationID&&!n.messageID)return e;let a=t.filter(e=>e!==i);if(a.length)return{queuedMessages:{...e.queuedMessages,[r]:a}};let{[r]:o,...s}=e.queuedMessages;return{queuedMessages:s}})}}),{name:`message-queue-store`,version:4,storage:jt,partialize:e=>({queuedMessages:e.queuedMessages,followUpBehavior:e.followUpBehavior}),migrate:Vt,merge:(e,t)=>({...t,...Vt(e),pendingAdmissions:t.pendingAdmissions})}),{name:`message-queue-store`})),Ut=(e,t)=>{let n=Ht.getState().queuedMessages,r=[],i=[];for(let[a,o]of Object.entries(n)){let n=o[0]?.owner;if(!n||n.state!==`unbound-legacy`)continue;let s=t(n.sessionID);if(!s){i.push(n.sessionID);continue}r.push({sourceKey:a,target:{state:`bound`,transportIdentity:e,directory:s,sessionID:n.sessionID},items:o})}return!e||i.length?{ok:!1,unresolvedSessionIDs:i}:r.length?(Ht.setState(e=>{let t={...e.queuedMessages};for(let e of r){let n=O(e.target);t[n]=[...e.items.map(t=>({...t,owner:e.target})),...t[n]??[]],delete t[e.sourceKey]}return{queuedMessages:t}}),{ok:!0,moved:r.reduce((e,t)=>e+t.items.length,0)}):{ok:!0,moved:0}},Wt=be(),Gt=e(te(),1),Kt=`directoryTreeShowHidden`,qt=`directory-show-hidden-change`,Jt=()=>{if(typeof window>`u`)return!0;try{let e=v().getItem(Kt);return e===null||e===`true`}catch{return!0}},Yt=()=>{typeof window>`u`||window.dispatchEvent(new Event(qt))},Xt=(e,t={})=>{if(!(typeof window>`u`)){try{v().setItem(Kt,e?`true`:`false`),Yt()}catch{}t.persist!==!1&&H({directoryShowHidden:e})}},Zt=()=>{let e=(0,Wt.c)(2),[t,n]=Gt.useState(Jt),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{if(typeof window>`u`)return;let e=()=>{n(Jt())};return window.addEventListener(`storage`,e),window.addEventListener(qt,e),()=>{window.removeEventListener(`storage`,e),window.removeEventListener(qt,e)}},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Gt.useEffect(r,i),t},Qt=`filesViewShowGitignored`,$t=`files-view-show-gitignored-change`,en=()=>{if(typeof window>`u`)return!1;try{return v().getItem(Qt)===`true`}catch{return!1}},tn=()=>{typeof window>`u`||window.dispatchEvent(new Event($t))},nn=(e,t={})=>{if(!(typeof window>`u`)){try{v().setItem(Qt,e?`true`:`false`),tn()}catch{}t.persist!==!1&&H({filesViewShowGitignored:e})}},rn=()=>{let e=(0,Wt.c)(2),[t,n]=Gt.useState(en),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{if(typeof window>`u`)return;let e=()=>{n(en())};return window.addEventListener(`storage`,e),window.addEventListener($t,e),()=>{window.removeEventListener(`storage`,e),window.removeEventListener($t,e)}},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Gt.useEffect(r,i),t},an=e=>{if(!e||typeof e!=`object`)return null;let t={};return typeof e.showReasoningTraces==`boolean`&&(t.showReasoningTraces=e.showReasoningTraces),typeof e.collapsibleThinkingBlocks==`boolean`&&(t.collapsibleThinkingBlocks=e.collapsibleThinkingBlocks),Object.keys(t).length>0?t:null},on=e=>{if(!e||typeof e!=`object`)return null;let t=e;return{showReasoningTraces:t.showReasoningTraces,collapsibleThinkingBlocks:t.collapsibleThinkingBlocks}},sn=e=>{let t=S.getState();typeof e.showReasoningTraces==`boolean`&&t.setShowReasoningTraces(e.showReasoningTraces),typeof e.collapsibleThinkingBlocks==`boolean`&&t.setCollapsibleThinkingBlocks(e.collapsibleThinkingBlocks)},cn=async()=>{if(typeof window>`u`)return null;let e=localStorage.getItem(`appearance-preferences`);if(!e)return null;try{return an(on(JSON.parse(e)))}catch(e){return console.warn(`Failed to parse stored appearance preferences:`,e),null}},ln=[{name:`explore`,icon:`compass-3`,labelKey:`chat.draftPresets.explore.label`,command:`/explore`},{name:`catch-up`,icon:`history`,labelKey:`chat.draftPresets.catchup.label`,command:`/catch-up`},{name:`weigh`,icon:`scales-3`,labelKey:`chat.draftPresets.weigh.label`,command:`/weigh`},{name:`craft-goal`,icon:`target`,labelKey:`chat.draftPresets.craftGoal.label`,command:`/craft-goal`},{name:`debug`,icon:`bug`,labelKey:`chat.draftPresets.debug.label`,command:`/debug`},{name:`review`,icon:`search-eye`,labelKey:`chat.draftPresets.review.label`,command:`/workspace-review`}],un=new Map(ln.map(e=>[e.name,e])),dn=e=>un.get(e),fn=[{type:`command`,name:`explore`},{type:`command`,name:`catch-up`},{type:`command`,name:`weigh`},{type:`command`,name:`debug`},{type:`command`,name:`review`}],pn=`terminal-box`,mn=`book-open`,hn=e=>`${e.type}:${e.name}`,gn=(e,t)=>e.type===t.type&&e.name===t.name,_n=e=>{let t=e.replace(/^\//,``).replace(/[-_]+/g,` `).replace(/\s+/g,` `).trim();return t?t.charAt(0).toUpperCase()+t.slice(1):e},vn=e=>{if(!Array.isArray(e))return[];let t=[],n=new Set;for(let r of e){if(!r||typeof r!=`object`)continue;let e=r,i=e.type===`command`||e.type===`skill`?e.type:null,a=typeof e.name==`string`?e.name.trim():``;if(!i||!a)continue;let o=`${i}:${a}`;n.has(o)||(n.add(o),t.push({type:i,name:a}))}return t},yn=`yuri.rt.`,bn=e=>{try{return btoa(unescape(encodeURIComponent(e))).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}catch{return encodeURIComponent(e)}},N=(e,t=o())=>`${yn}${bn(t.trim().length>0?t.trim():`default`)}.${e}`,xn=(e,t,n=o())=>e?e===N(t,n):!1,Sn=()=>{if(typeof window>`u`)return!0;if(u())return d();let e=window.__YURI_API_BASE_URL__,t=window.__YURI_LOCAL_ORIGIN__;if(typeof e==`string`&&e.trim()&&typeof t==`string`&&t.trim())try{return new URL(e).origin===new URL(t).origin}catch{return!1}try{if(d())return!0}catch{}if(typeof e==`string`&&e.trim())try{let t=new URL(e).hostname;if(t!==`localhost`&&t!==`127.0.0.1`&&t!==`::1`)return!1}catch{return!1}return!0},Cn=(e,t)=>{let n=t?.storage??(typeof localStorage<`u`?localStorage:{getItem:()=>null}),r=t?.transport??o(),i=n.getItem(N(e,r));return i===null?Sn()?n.getItem(e):null:i},P=(e,t,n)=>{let r=n?.storage??(typeof localStorage<`u`?localStorage:{setItem:()=>void 0}),i=n?.transport??o();r.setItem(N(e,i),t)},wn=e=>{let t;try{t=ne()}catch{return}let n=t=>t===null?null:JSON.parse(t,e?.reviver),r=e=>t.getItem(e);return{getItem:e=>{let t=N(e,o()),i=r(t);if(i instanceof Promise)return i.then(t=>{if(t!==null)return n(t);if(!Sn())return null;let i=r(e);return i instanceof Promise?i.then(n):n(i)});if(i!==null)return n(i);if(!Sn())return null;let a=r(e);return a instanceof Promise?a.then(n):n(a)},setItem:(n,r)=>{let i=N(n,o());t.setItem(i,JSON.stringify(r,e?.replacer))},removeItem:e=>{let n=N(e,o());t.removeItem(n)}}},Tn=512,En=4096,Dn=64,On=2e5,kn=[`concise`,`detailed`,`mentor`,`pushback`,`noFiller`,`matchEnergy`,`warmPeer`,`custom`],An=[`defaultModel`,`defaultVariant`,`defaultAgent`,`autoCreateWorktree`,`gitmojiEnabled`,`defaultFileViewerPreview`,`zenModel`,`messageStreamTransport`,`sttProvider`,`sttServerUrl`,`sttModel`,`sttLocalModel`,`sttLanguage`,`responseStyleEnabled`,`responseStylePreset`,`responseStyleCustomInstructions`],jn=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype,F=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Mn=(e,t)=>{if(typeof e!=`string`)return;let n=e.trim();return n.length<=t?n:void 0},Nn=e=>{let t=Mn(e,En);if(t!==void 0)try{let e=new URL(t);return(e.protocol===`http:`||e.protocol===`https:`)&&!e.username&&!e.password?t:void 0}catch{return}},Pn=(e,t)=>typeof e==`string`&&t.includes(e)?e:void 0,Fn=e=>typeof e==`boolean`?e:void 0,In=(e,t)=>{let n=e[t];switch(t){case`autoCreateWorktree`:case`gitmojiEnabled`:case`defaultFileViewerPreview`:case`responseStyleEnabled`:return Fn(n);case`messageStreamTransport`:return Pn(n,[`auto`,`ws`,`sse`]);case`sttProvider`:return Pn(n,[`local`,`openai-compatible`,`volcengine`]);case`sttServerUrl`:return Nn(n);case`sttLanguage`:return Mn(n,Dn);case`responseStyleCustomInstructions`:return Mn(n,On);case`responseStylePreset`:return Pn(n,kn);default:return Mn(n,Tn)}},Ln=e=>{if(!jn(e))throw Error(`Invalid settings bootstrap response`);if(!F(e,`schemaVersion`)||e.schemaVersion!==1)throw Error(`Unsupported settings bootstrap schema version`);let t={schemaVersion:1};typeof e.hasRemoteProjects==`boolean`&&(t.hasRemoteProjects=e.hasRemoteProjects);for(let n of An){if(!F(e,n))continue;let r=In(e,n);r!==void 0&&Object.assign(t,{[n]:r})}return t},Rn=e=>{if(!jn(e))throw Error(`Invalid settings bootstrap patch`);for(let t of Object.keys(e))if(!An.includes(t))throw Error(`Invalid settings bootstrap patch`);let t=Ln({schemaVersion:1,...e}),n={};for(let r of An)if(F(e,r)){if(!F(t,r))throw Error(`Invalid settings bootstrap patch`);Object.assign(n,{[r]:t[r]})}return n},zn=e=>{if(!jn(e))return{};let t={};for(let n of An){if(!F(e,n))continue;let r=In(e,n);r!==void 0&&Object.assign(t,{[n]:r})}return t},Bn=async(e,t)=>{let n=new AbortController,r,i=new Promise((e,t)=>{r=t}),a=e=>{r(e),n.abort(e)},o=()=>a(e.reason??new DOMException(`Request aborted`,`AbortError`)),s=setTimeout(()=>a(new DOMException(`Configuration request timed out`,`TimeoutError`)),3e4);e.addEventListener(`abort`,o,{once:!0});try{return e.aborted?(o(),await i):await Promise.race([t(n.signal),i])}finally{clearTimeout(s),e.removeEventListener(`abort`,o)}},Vn=class extends Error{status;constructor(e){super(`Settings bootstrap request failed (${e})`),this.status=e,this.name=`SettingsBootstrapRequestError`}},Hn=(e=o())=>[e,`settings`,`bootstrap`],Un=(e=o())=>({queryKey:Hn(e),queryFn:({signal:e})=>Bn(e,async e=>{let t=await l(`/api/config/settings/bootstrap`,{method:`GET`,headers:{Accept:`application/json`},signal:e});if(!t.ok)throw new Vn(t.status);return Ln(await t.json())}),retry:(e,t)=>!(t instanceof Vn&&(t.status===404||t.status===501))&&e<1,staleTime:1/0,gcTime:1/0}),Wn=(e=o())=>xe.fetchQuery(Un(e)),Gn=(e=o())=>xe.getQueryData(Hn(e)),Kn=(e,t=o())=>{let n=Rn(e),r=Hn(t),i=Ln({schemaVersion:1,...xe.getQueryData(r),...n});return xe.setQueryData(r,i),i},qn=e=>{if(!(typeof window>`u`)&&!(typeof window.__YURI_HOME__==`string`&&window.__YURI_HOME__.length>0))try{window.__YURI_HOME__=e}catch{}},Jn=e=>{if(!(typeof window>`u`)){if(e.themeId&&P(`selectedThemeId`,e.themeId),e.themeVariant&&P(`selectedThemeVariant`,e.themeVariant),e.lightThemeId&&P(`lightThemeId`,e.lightThemeId),e.darkThemeId&&P(`darkThemeId`,e.darkThemeId),typeof e.useSystemTheme==`boolean`&&(P(`useSystemTheme`,String(e.useSystemTheme)),P(`themeMode`,e.useSystemTheme?`system`:e.themeVariant===`dark`||e.themeVariant===`light`?e.themeVariant:`system`)),e.lastDirectory&&b(`lastDirectory`,e.lastDirectory),e.homeDirectory&&(b(`homeDirectory`,e.homeDirectory),qn(e.homeDirectory)),Array.isArray(e.projects)&&e.projects.length>0?b(`projects`,JSON.stringify(e.projects)):ie(`projects`),e.activeProjectId?b(`activeProjectId`,e.activeProjectId):ie(`activeProjectId`),Array.isArray(e.pinnedDirectories)&&e.pinnedDirectories.length>0?b(`pinnedDirectories`,JSON.stringify(e.pinnedDirectories)):ie(`pinnedDirectories`),Array.isArray(e.projects)&&e.projects.length>0){let t=e.projects.filter(e=>e.sidebarCollapsed===!0).map(e=>e.id).filter(e=>typeof e==`string`&&e.length>0);t.length>0?b(`yuri.sessions.projectCollapse`,JSON.stringify(t)):ie(`yuri.sessions.projectCollapse`)}if(typeof e.gitmojiEnabled==`boolean`?localStorage.setItem(`gitmojiEnabled`,String(e.gitmojiEnabled)):localStorage.removeItem(`gitmojiEnabled`),typeof e.directoryShowHidden==`boolean`&&localStorage.setItem(`directoryTreeShowHidden`,e.directoryShowHidden?`true`:`false`),typeof e.filesViewShowGitignored==`boolean`&&localStorage.setItem(`filesViewShowGitignored`,e.filesViewShowGitignored?`true`:`false`),typeof e.openInAppId==`string`&&e.openInAppId.length>0&&localStorage.setItem(`openInAppId`,e.openInAppId),typeof e.pwaAppName==`string`){let t=e.pwaAppName.trim().replace(/\s+/g,` `).slice(0,64);t.length>0?localStorage.setItem(`yuri.pwaName`,t):localStorage.removeItem(`yuri.pwaName`)}if(typeof e.mobileKeyboardMode==`string`&&we(e.mobileKeyboardMode),typeof e.openCodeUpdateToastDismissedVersion==`string`){let t=e.openCodeUpdateToastDismissedVersion.trim();t?localStorage.setItem(`opencode-update-toast-dismissed-version`,t):localStorage.removeItem(`opencode-update-toast-dismissed-version`)}}},Yn=e=>{typeof window>`u`||window.dispatchEvent(new CustomEvent(`yuri:settings-synced`,{detail:e}))},Xn=e=>{if(!Array.isArray(e))return;let t=[],n=new Set;for(let r of e){if(!r||typeof r!=`object`)continue;let e=r,i=typeof e.id==`string`?e.id.trim():``,a=typeof e.label==`string`?e.label.trim():``,o=typeof e.source==`string`?e.source.trim():``,s=typeof e.subpath==`string`?e.subpath.trim():``,c=typeof e.gitIdentityId==`string`?e.gitIdentityId.trim():``;!i||!a||!o||n.has(i)||(n.add(i),t.push({id:i,label:a,source:o,...s?{subpath:s}:{},...c?{gitIdentityId:c}:{}}))}return t},Zn=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return;let t={};for(let[n,r]of Object.entries(e)){let e=typeof n==`string`?n.trim():``,i=typeof r==`string`?r.trim():``;!e||!i||(t[e]=i)}return t},Qn=(e,t)=>{let n=Object.entries(e),r=Object.entries(t);return n.length===r.length&&n.every(([e,n])=>t[e]===n)},$n=(e,t)=>e.length===t.length&&e.every((e,n)=>e.providerID===t[n]?.providerID&&e.modelID===t[n]?.modelID&&e.variant===t[n]?.variant),er=(e,t)=>{if(t.length===0)return t;let n=new Map;for(let t of e)typeof t.variant==`string`&&t.variant.length>0&&n.set(`${t.providerID}/${t.modelID}`,t.variant);return t.map(e=>{if(typeof e.variant==`string`&&e.variant.length>0)return e;let t=n.get(`${e.providerID}/${e.modelID}`);return t?{providerID:e.providerID,modelID:e.modelID,variant:t}:e})},tr=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),nr=e=>{if(Array.isArray(e))return Array.from(new Set(e.filter(e=>typeof e==`string`&&e.length>0)))},rr=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return;let t={};for(let[n,r]of Object.entries(e)){if(!n||!Array.isArray(r))continue;let e=nr(r);e&&e.length>0&&(t[n]=e.slice(0,5))}return Object.keys(t).length>0?t:void 0},ir=(e,t)=>{let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Array.isArray(t[n])&&tr(e[n],t[n]))},ar=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,or=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t&&ar.test(t)?t.toLowerCase():null},sr=e=>{if(!Array.isArray(e))return;let t=[],n=new Set,r=new Set;for(let i of e){if(!i||typeof i!=`object`)continue;let e=i,a=typeof e.path==`string`?e.path.trim():``;if(!a)continue;let o=a===`/`?a:a.replace(/\\/g,`/`).replace(/\/+$/,``);if(!o)continue;let s=ke(o);if(!s||n.has(s)||r.has(o))continue;n.add(s),r.add(o);let c={id:s,path:o};if(typeof e.label==`string`&&e.label.trim().length>0&&(c.label=e.label.trim()),typeof e.icon==`string`&&e.icon.trim().length>0&&(c.icon=e.icon.trim()),e.iconImage===null)c.iconImage=null;else if(e.iconImage&&typeof e.iconImage==`object`){let t=e.iconImage,n=typeof t.mime==`string`?t.mime.trim():``,r=typeof t.updatedAt==`number`&&Number.isFinite(t.updatedAt)?Math.max(0,Math.round(t.updatedAt)):0,i=t.source===`custom`||t.source===`auto`?t.source:null;n&&r>0&&i&&(c.iconImage={mime:n,updatedAt:r,source:i})}if(typeof e.color==`string`&&e.color.trim().length>0&&(c.color=e.color.trim()),e.iconBackground===null)c.iconBackground=null;else{let t=or(e.iconBackground);t&&(c.iconBackground=t)}typeof e.addedAt==`number`&&Number.isFinite(e.addedAt)&&e.addedAt>=0&&(c.addedAt=e.addedAt),typeof e.lastOpenedAt==`number`&&Number.isFinite(e.lastOpenedAt)&&e.lastOpenedAt>=0&&(c.lastOpenedAt=e.lastOpenedAt),typeof e.sidebarCollapsed==`boolean`&&(c.sidebarCollapsed=e.sidebarCollapsed),t.push(c)}return t.length>0?t:void 0},cr=(e,t,n)=>{if(!Array.isArray(e))return;let r=[],i=new Set,a=n?.preserveVariant===!0;for(let n of e){if(!n||typeof n!=`object`)continue;let e=n,o=typeof e.providerID==`string`?e.providerID.trim():``,s=typeof e.modelID==`string`?e.modelID.trim():``;if(!o||!s)continue;let c=`${o}/${s}`;if(!i.has(c)&&(i.add(c),a&&typeof e.variant==`string`&&e.variant.trim().length>0?r.push({providerID:o,modelID:s,variant:e.variant.trim()}):r.push({providerID:o,modelID:s}),r.length>=t))break}return r},lr=()=>{let e=S.persist;if(e&&typeof e==`object`)return e},ur=()=>h()?.settings??null,dr=(e,t,n)=>{let r={...zn(t),...zn(e)};if(Object.keys(r).length!==0)try{Kn(r,n)}catch(e){console.warn(`Failed to patch settings bootstrap cache:`,e)}},fr=e=>{let t=S.getState(),n=typeof window<`u`?window.__zustand_config_store__?.getState?.()??null:null,r=Ht.getState();if(typeof e.showReasoningTraces==`boolean`&&e.showReasoningTraces!==t.showReasoningTraces&&t.setShowReasoningTraces(e.showReasoningTraces),typeof e.sessionTitleRefreshEnabled==`boolean`&&e.sessionTitleRefreshEnabled!==t.sessionTitleRefreshEnabled&&t.setSessionTitleRefreshEnabled(e.sessionTitleRefreshEnabled),typeof e.sessionGoalEnabled==`boolean`&&e.sessionGoalEnabled!==t.sessionGoalEnabled&&t.setSessionGoalEnabled(e.sessionGoalEnabled),typeof e.collapsibleThinkingBlocks==`boolean`&&e.collapsibleThinkingBlocks!==t.collapsibleThinkingBlocks&&t.setCollapsibleThinkingBlocks(e.collapsibleThinkingBlocks),typeof e.autoDeleteEnabled==`boolean`&&e.autoDeleteEnabled!==t.autoDeleteEnabled&&t.setAutoDeleteEnabled(e.autoDeleteEnabled),typeof e.autoDeleteAfterDays==`number`&&Number.isFinite(e.autoDeleteAfterDays)){let n=Math.max(1,Math.min(365,e.autoDeleteAfterDays));n!==t.autoDeleteAfterDays&&t.setAutoDeleteAfterDays(n)}(e.sessionRetentionAction===`archive`||e.sessionRetentionAction===`delete`)&&e.sessionRetentionAction!==t.sessionRetentionAction&&t.setSessionRetentionAction(e.sessionRetentionAction);let i=null;if(xt(e.followUpBehavior)?i=e.followUpBehavior:typeof e.queueModeEnabled==`boolean`&&(i=St(void 0,e.queueModeEnabled)),i&&i!==r.followUpBehavior&&r.setFollowUpBehavior(i),typeof e.showDeletionDialog==`boolean`&&e.showDeletionDialog!==t.showDeletionDialog&&t.setShowDeletionDialog(e.showDeletionDialog),typeof e.nativeNotificationsEnabled==`boolean`&&e.nativeNotificationsEnabled!==t.nativeNotificationsEnabled&&t.setNativeNotificationsEnabled(e.nativeNotificationsEnabled),typeof e.notificationMode==`string`&&(e.notificationMode===`always`||e.notificationMode===`hidden-only`)&&e.notificationMode!==t.notificationMode&&t.setNotificationMode(e.notificationMode),typeof e.notifyOnSubtasks==`boolean`&&e.notifyOnSubtasks!==t.notifyOnSubtasks&&t.setNotifyOnSubtasks(e.notifyOnSubtasks),typeof e.notifyOnCompletion==`boolean`&&e.notifyOnCompletion!==t.notifyOnCompletion&&t.setNotifyOnCompletion(e.notifyOnCompletion),typeof e.notifyOnError==`boolean`&&e.notifyOnError!==t.notifyOnError&&t.setNotifyOnError(e.notifyOnError),typeof e.notifyOnQuestion==`boolean`&&e.notifyOnQuestion!==t.notifyOnQuestion&&t.setNotifyOnQuestion(e.notifyOnQuestion),typeof e.notifyOnPermission==`boolean`&&e.notifyOnPermission!==t.notifyOnPermission&&t.setNotifyOnPermission(e.notifyOnPermission),typeof e.notifyOnScheduledTasks==`boolean`&&e.notifyOnScheduledTasks!==t.notifyOnScheduledTasks&&t.setNotifyOnScheduledTasks(e.notifyOnScheduledTasks),typeof e.notifyOnAssistants==`boolean`&&e.notifyOnAssistants!==t.notifyOnAssistants&&t.setNotifyOnAssistants(e.notifyOnAssistants),typeof e.notifyOnGoals==`boolean`&&e.notifyOnGoals!==t.notifyOnGoals&&t.setNotifyOnGoals(e.notifyOnGoals),e.notificationTemplates&&typeof e.notificationTemplates==`object`&&t.setNotificationTemplates(e.notificationTemplates),typeof e.summarizeLastMessage==`boolean`&&e.summarizeLastMessage!==t.summarizeLastMessage&&t.setSummarizeLastMessage(e.summarizeLastMessage),typeof e.summaryThreshold==`number`&&Number.isFinite(e.summaryThreshold)&&t.setSummaryThreshold(e.summaryThreshold),typeof e.summaryLength==`number`&&Number.isFinite(e.summaryLength)&&t.setSummaryLength(e.summaryLength),typeof e.maxLastMessageLength==`number`&&Number.isFinite(e.maxLastMessageLength)&&t.setMaxLastMessageLength(e.maxLastMessageLength),typeof e.inputSpellcheckEnabled==`boolean`&&e.inputSpellcheckEnabled!==t.inputSpellcheckEnabled&&t.setInputSpellcheckEnabled(e.inputSpellcheckEnabled),typeof e.showOpenCodeUpdateNotifications==`boolean`&&e.showOpenCodeUpdateNotifications!==t.showOpenCodeUpdateNotifications&&t.setShowOpenCodeUpdateNotifications(e.showOpenCodeUpdateNotifications),typeof e.showToolFileIcons==`boolean`&&e.showToolFileIcons!==t.showToolFileIcons&&t.setShowToolFileIcons(e.showToolFileIcons),typeof e.showTurnChangedFiles==`boolean`&&e.showTurnChangedFiles!==t.showTurnChangedFiles&&t.setShowTurnChangedFiles(e.showTurnChangedFiles),typeof e.showExpandedBashTools==`boolean`&&e.showExpandedBashTools!==t.showExpandedBashTools&&t.setShowExpandedBashTools(e.showExpandedBashTools),typeof e.showSubagentTaskDetails==`boolean`&&e.showSubagentTaskDetails!==t.showSubagentTaskDetails&&t.setShowSubagentTaskDetails(e.showSubagentTaskDetails),typeof e.timeFormatPreference==`string`&&(e.timeFormatPreference===`auto`||e.timeFormatPreference===`12h`||e.timeFormatPreference===`24h`)&&e.timeFormatPreference!==t.timeFormatPreference&&t.setTimeFormatPreference(e.timeFormatPreference),typeof e.weekStartPreference==`string`&&(e.weekStartPreference===`auto`||e.weekStartPreference===`sunday`||e.weekStartPreference===`monday`)&&e.weekStartPreference!==t.weekStartPreference&&t.setWeekStartPreference(e.weekStartPreference),typeof e.desktopWindowControlsPosition==`string`&&(e.desktopWindowControlsPosition===`auto`||e.desktopWindowControlsPosition===`left`||e.desktopWindowControlsPosition===`right`)&&e.desktopWindowControlsPosition!==t.desktopWindowControlsPosition&&t.setDesktopWindowControlsPosition(e.desktopWindowControlsPosition),typeof e.chatRenderMode==`string`&&(e.chatRenderMode===`sorted`||e.chatRenderMode===`live`)&&e.chatRenderMode!==t.chatRenderMode&&t.setChatRenderMode(e.chatRenderMode),typeof e.activityRenderMode==`string`&&(e.activityRenderMode===`collapsed`||e.activityRenderMode===`summary`)&&e.activityRenderMode!==t.activityRenderMode&&t.setActivityRenderMode(e.activityRenderMode),typeof e.collapsibleUserMessages==`boolean`&&e.collapsibleUserMessages!==t.collapsibleUserMessages&&t.setCollapsibleUserMessages(e.collapsibleUserMessages),typeof e.messageStreamTransport==`string`&&(e.messageStreamTransport===`auto`||e.messageStreamTransport===`ws`||e.messageStreamTransport===`sse`)&&n&&e.messageStreamTransport!==n.settingsMessageStreamTransport&&n.setSettingsMessageStreamTransport(e.messageStreamTransport),typeof e.promptNavigatorEnabled==`boolean`&&e.promptNavigatorEnabled!==t.promptNavigatorEnabled&&t.setPromptNavigatorEnabled(e.promptNavigatorEnabled),typeof e.showSplitAssistantMessageActions==`boolean`&&e.showSplitAssistantMessageActions!==t.showSplitAssistantMessageActions&&t.setShowSplitAssistantMessageActions(e.showSplitAssistantMessageActions),typeof e.showAssistantTps==`boolean`&&e.showAssistantTps!==t.showAssistantTps&&t.setShowAssistantTps(e.showAssistantTps),typeof e.reportUsage==`boolean`&&e.reportUsage!==t.reportUsage&&t.setReportUsage(e.reportUsage),typeof e.fontSize==`number`&&Number.isFinite(e.fontSize)&&e.fontSize!==t.fontSize&&t.setFontSize(e.fontSize),Array.isArray(e.draftStarters)){let n=vn(e.draftStarters);JSON.stringify(t.globalDraftStarters)!==JSON.stringify(n)&&t.setGlobalDraftStarters(n)}if(typeof e.terminalFontSize==`number`&&Number.isFinite(e.terminalFontSize)&&e.terminalFontSize!==t.terminalFontSize&&t.setTerminalFontSize(e.terminalFontSize),typeof e.editorFontSize==`number`&&Number.isFinite(e.editorFontSize)&&e.editorFontSize!==t.editorFontSize&&t.setEditorFontSize(e.editorFontSize),Te(e.uiFont)&&e.uiFont!==t.uiFont&&t.setUiFont(e.uiFont),Se(e.monoFont)&&e.monoFont!==t.monoFont&&t.setMonoFont(e.monoFont),typeof e.padding==`number`&&Number.isFinite(e.padding)&&e.padding!==t.padding&&t.setPadding(e.padding),typeof e.cornerRadius==`number`&&Number.isFinite(e.cornerRadius)&&e.cornerRadius!==t.cornerRadius&&t.setCornerRadius(e.cornerRadius),typeof e.inputBarOffset==`number`&&Number.isFinite(e.inputBarOffset)&&e.inputBarOffset!==t.inputBarOffset&&t.setInputBarOffset(e.inputBarOffset),e.shortcutOverrides&&!Qn(e.shortcutOverrides,t.shortcutOverrides)&&S.setState({shortcutOverrides:e.shortcutOverrides}),typeof e.mobileKeyboardMode==`string`){let n=Ce(e.mobileKeyboardMode,t.mobileKeyboardMode);n!==t.mobileKeyboardMode&&t.setMobileKeyboardMode(n)}if(Array.isArray(e.favoriteModels)){let n=t.favoriteModels,r=er(n,e.favoriteModels);$n(n,r)||S.setState({favoriteModels:r})}if(Array.isArray(e.hiddenModels)){let n=t.hiddenModels,r=e.hiddenModels;$n(n,r)||S.setState({hiddenModels:r})}if(Array.isArray(e.collapsedModelProviders)){let n=t.collapsedModelProviders,r=e.collapsedModelProviders;tr(n,r)||S.setState({collapsedModelProviders:r})}if(Array.isArray(e.recentModels)){let n=t.recentModels,r=er(n,e.recentModels);$n(n,r)||S.setState({recentModels:r})}if(Array.isArray(e.recentAgents)){let n=t.recentAgents,r=e.recentAgents;tr(n,r)||S.setState({recentAgents:r})}if(e.recentEfforts&&typeof e.recentEfforts==`object`){let n=t.recentEfforts,r=e.recentEfforts;ir(n,r)||S.setState({recentEfforts:r})}typeof e.diffLayoutPreference==`string`&&(e.diffLayoutPreference===`dynamic`||e.diffLayoutPreference===`inline`||e.diffLayoutPreference===`side-by-side`)&&e.diffLayoutPreference!==t.diffLayoutPreference&&t.setDiffLayoutPreference(e.diffLayoutPreference),typeof e.gitChangesViewMode==`string`&&(e.gitChangesViewMode===`flat`||e.gitChangesViewMode===`tree`)&&e.gitChangesViewMode!==t.gitChangesViewMode&&t.setGitChangesViewMode(e.gitChangesViewMode),typeof e.directoryShowHidden==`boolean`&&Xt(e.directoryShowHidden,{persist:!1}),typeof e.filesViewShowGitignored==`boolean`&&nn(e.filesViewShowGitignored,{persist:!1})},pr=e=>{if(!e||typeof e!=`object`)return null;let t=e,n={};if(typeof t.hasRemoteProjects==`boolean`&&(n.hasRemoteProjects=t.hasRemoteProjects),t.hubProjectLayout!==void 0&&(n.hubProjectLayout=Oe(t.hubProjectLayout)),typeof t.themeId==`string`&&t.themeId.length>0&&(n.themeId=t.themeId),(t.useSystemTheme===!0||t.useSystemTheme===!1)&&(n.useSystemTheme=t.useSystemTheme),typeof t.themeVariant==`string`&&(t.themeVariant===`light`||t.themeVariant===`dark`)&&(n.themeVariant=t.themeVariant),typeof t.lightThemeId==`string`&&t.lightThemeId.length>0&&(n.lightThemeId=t.lightThemeId),typeof t.darkThemeId==`string`&&t.darkThemeId.length>0&&(n.darkThemeId=t.darkThemeId),typeof t.lastDirectory==`string`&&t.lastDirectory.length>0&&(n.lastDirectory=t.lastDirectory),typeof t.homeDirectory==`string`&&t.homeDirectory.length>0&&(n.homeDirectory=t.homeDirectory),typeof t.opencodeBinary==`string`){let e=t.opencodeBinary.trim();n.opencodeBinary=e.length>0?e:void 0}typeof t.desktopLanAccessEnabled==`boolean`&&(n.desktopLanAccessEnabled=t.desktopLanAccessEnabled),typeof t.desktopKeepAwakeEnabled==`boolean`&&(n.desktopKeepAwakeEnabled=t.desktopKeepAwakeEnabled),typeof t.desktopMinimizeToTrayEnabled==`boolean`&&(n.desktopMinimizeToTrayEnabled=t.desktopMinimizeToTrayEnabled);let r=sr(t.projects);if([`manual`,`a-z`,`z-a`,`date-added`,`recent`].includes(t.projectSortOrder)&&(n.projectSortOrder=t.projectSortOrder),r&&(n.projects=r),typeof t.activeProjectId==`string`&&t.activeProjectId.length>0&&(n.activeProjectId=t.activeProjectId),Array.isArray(t.securityScopedBookmarks)&&(n.securityScopedBookmarks=t.securityScopedBookmarks.filter(e=>typeof e==`string`&&e.length>0)),Array.isArray(t.pinnedDirectories)&&(n.pinnedDirectories=Array.from(new Set(t.pinnedDirectories.filter(e=>typeof e==`string`&&e.length>0)))),Array.isArray(t.draftStarters)&&(n.draftStarters=vn(t.draftStarters)),typeof t.draftStartersCraftGoalAdded==`boolean`&&(n.draftStartersCraftGoalAdded=t.draftStartersCraftGoalAdded),typeof t.showReasoningTraces==`boolean`&&(n.showReasoningTraces=t.showReasoningTraces),typeof t.sessionTitleRefreshEnabled==`boolean`&&(n.sessionTitleRefreshEnabled=t.sessionTitleRefreshEnabled),typeof t.sessionGoalEnabled==`boolean`&&(n.sessionGoalEnabled=t.sessionGoalEnabled),typeof t.collapsibleThinkingBlocks==`boolean`&&(n.collapsibleThinkingBlocks=t.collapsibleThinkingBlocks),typeof t.autoDeleteEnabled==`boolean`&&(n.autoDeleteEnabled=t.autoDeleteEnabled),typeof t.autoDeleteAfterDays==`number`&&Number.isFinite(t.autoDeleteAfterDays)&&(n.autoDeleteAfterDays=t.autoDeleteAfterDays),(t.sessionRetentionAction===`archive`||t.sessionRetentionAction===`delete`)&&(n.sessionRetentionAction=t.sessionRetentionAction),typeof t.defaultModel==`string`&&t.defaultModel.length>0&&(n.defaultModel=t.defaultModel),typeof t.defaultVariant==`string`&&t.defaultVariant.length>0&&(n.defaultVariant=t.defaultVariant),typeof t.defaultAgent==`string`&&t.defaultAgent.length>0&&(n.defaultAgent=t.defaultAgent),typeof t.smallModelUseDefault==`boolean`&&(n.smallModelUseDefault=t.smallModelUseDefault),typeof t.smallModelOverride==`string`&&t.smallModelOverride.length>0&&(n.smallModelOverride=t.smallModelOverride),(t.summaryModelMode===`provider`||t.summaryModelMode===`custom`)&&(n.summaryModelMode=t.summaryModelMode),typeof t.summaryProviderID==`string`&&t.summaryProviderID.length>0&&(n.summaryProviderID=t.summaryProviderID),typeof t.summaryModelID==`string`&&t.summaryModelID.length>0&&(n.summaryModelID=t.summaryModelID),typeof t.summaryCustomModelID==`string`&&t.summaryCustomModelID.length>0&&(n.summaryCustomModelID=t.summaryCustomModelID),typeof t.summaryCustomBaseURL==`string`&&(n.summaryCustomBaseURL=t.summaryCustomBaseURL),typeof t.hasSummaryCustomAPIToken==`boolean`&&(n.hasSummaryCustomAPIToken=t.hasSummaryCustomAPIToken),typeof t.summaryCommitPrompt==`string`&&(n.summaryCommitPrompt=t.summaryCommitPrompt),typeof t.summarySessionTitlePrompt==`string`&&(n.summarySessionTitlePrompt=t.summarySessionTitlePrompt),typeof t.autoCreateWorktree==`boolean`&&(n.autoCreateWorktree=t.autoCreateWorktree),typeof t.gitmojiEnabled==`boolean`&&(n.gitmojiEnabled=t.gitmojiEnabled),xt(t.followUpBehavior)?n.followUpBehavior=t.followUpBehavior:typeof t.queueModeEnabled==`boolean`&&(n.followUpBehavior=St(void 0,t.queueModeEnabled)),typeof t.showDeletionDialog==`boolean`&&(n.showDeletionDialog=t.showDeletionDialog),typeof t.nativeNotificationsEnabled==`boolean`&&(n.nativeNotificationsEnabled=t.nativeNotificationsEnabled),typeof t.notificationMode==`string`&&(t.notificationMode===`always`||t.notificationMode===`hidden-only`)&&(n.notificationMode=t.notificationMode),typeof t.notifyOnSubtasks==`boolean`&&(n.notifyOnSubtasks=t.notifyOnSubtasks),typeof t.notifyOnCompletion==`boolean`&&(n.notifyOnCompletion=t.notifyOnCompletion),typeof t.notifyOnError==`boolean`&&(n.notifyOnError=t.notifyOnError),typeof t.notifyOnQuestion==`boolean`&&(n.notifyOnQuestion=t.notifyOnQuestion),typeof t.notifyOnPermission==`boolean`&&(n.notifyOnPermission=t.notifyOnPermission),typeof t.notifyOnScheduledTasks==`boolean`&&(n.notifyOnScheduledTasks=t.notifyOnScheduledTasks),typeof t.notifyOnAssistants==`boolean`&&(n.notifyOnAssistants=t.notifyOnAssistants),typeof t.notifyOnGoals==`boolean`&&(n.notifyOnGoals=t.notifyOnGoals),t.notificationTemplates&&typeof t.notificationTemplates==`object`){let e=t.notificationTemplates,r=t=>{let n=e[t];if(!n||typeof n!=`object`)return;let r=n;return{title:typeof r.title==`string`?r.title:``,message:typeof r.message==`string`?r.message:``}},i=r(`completion`),a=r(`error`),o=r(`question`),s=r(`subtask`);(i||a||o||s)&&(n.notificationTemplates={completion:i??{title:`Task Complete`,message:`Your task has finished.`},error:a??{title:`Error Occurred`,message:`An error occurred while processing your task.`},question:o??{title:`Input Needed`,message:`Please provide input to continue.`},subtask:s??{title:`Subtask Complete`,message:`A subtask has finished.`}})}if(typeof t.summarizeLastMessage==`boolean`&&(n.summarizeLastMessage=t.summarizeLastMessage),typeof t.summaryThreshold==`number`&&Number.isFinite(t.summaryThreshold)&&(n.summaryThreshold=Math.max(0,Math.round(t.summaryThreshold))),typeof t.summaryLength==`number`&&Number.isFinite(t.summaryLength)&&(n.summaryLength=Math.max(10,Math.round(t.summaryLength))),typeof t.maxLastMessageLength==`number`&&Number.isFinite(t.maxLastMessageLength)&&(n.maxLastMessageLength=Math.max(10,Math.round(t.maxLastMessageLength))),typeof t.usageAutoRefresh==`boolean`&&(n.usageAutoRefresh=t.usageAutoRefresh),typeof t.usageRefreshIntervalMs==`number`&&Number.isFinite(t.usageRefreshIntervalMs)&&(n.usageRefreshIntervalMs=t.usageRefreshIntervalMs),(t.usageDisplayMode===`usage`||t.usageDisplayMode===`remaining`)&&(n.usageDisplayMode=t.usageDisplayMode),typeof t.usageShowPredValues==`boolean`&&(n.usageShowPredValues=t.usageShowPredValues),Array.isArray(t.usageDropdownProviders)&&(n.usageDropdownProviders=t.usageDropdownProviders.filter(e=>typeof e==`string`&&e.length>0)),typeof t.magpieUsageUrl==`string`&&(n.magpieUsageUrl=t.magpieUsageUrl),Array.isArray(t.magpieHiddenProviders)&&(n.magpieHiddenProviders=t.magpieHiddenProviders.filter(e=>typeof e==`string`&&e.startsWith(`magpie:`))),t.usageSelectedModels&&typeof t.usageSelectedModels==`object`){let e={};for(let[n,r]of Object.entries(t.usageSelectedModels))Array.isArray(r)&&(e[n]=r.filter(e=>typeof e==`string`));Object.keys(e).length>0&&(n.usageSelectedModels=e)}if(t.usageCollapsedFamilies&&typeof t.usageCollapsedFamilies==`object`){let e={};for(let[n,r]of Object.entries(t.usageCollapsedFamilies))Array.isArray(r)&&(e[n]=r.filter(e=>typeof e==`string`));Object.keys(e).length>0&&(n.usageCollapsedFamilies=e)}if(t.usageExpandedFamilies&&typeof t.usageExpandedFamilies==`object`){let e={};for(let[n,r]of Object.entries(t.usageExpandedFamilies))Array.isArray(r)&&(e[n]=r.filter(e=>typeof e==`string`));Object.keys(e).length>0&&(n.usageExpandedFamilies=e)}if(t.usageModelGroups&&typeof t.usageModelGroups==`object`){let e={};for(let[n,r]of Object.entries(t.usageModelGroups))if(r&&typeof r==`object`){let t=r,i={};Array.isArray(t.customGroups)&&(i.customGroups=t.customGroups.filter(e=>e&&typeof e==`object`).map(e=>({id:String(e.id??``),label:String(e.label??``),models:Array.isArray(e.models)?e.models.filter(e=>typeof e==`string`):[],order:typeof e.order==`number`?e.order:0}))),t.modelAssignments&&typeof t.modelAssignments==`object`&&(i.modelAssignments=Object.fromEntries(Object.entries(t.modelAssignments).filter(([,e])=>typeof e==`string`).map(([e,t])=>[e,String(t)]))),t.renamedGroups&&typeof t.renamedGroups==`object`&&(i.renamedGroups=Object.fromEntries(Object.entries(t.renamedGroups).filter(([,e])=>typeof e==`string`).map(([e,t])=>[e,String(t)]))),Object.keys(i).length>0&&(e[n]=i)}Object.keys(e).length>0&&(n.usageModelGroups=e)}typeof t.inputSpellcheckEnabled==`boolean`&&(n.inputSpellcheckEnabled=t.inputSpellcheckEnabled),typeof t.showOpenCodeUpdateNotifications==`boolean`&&(n.showOpenCodeUpdateNotifications=t.showOpenCodeUpdateNotifications),typeof t.openCodeUpdateToastDismissedVersion==`string`&&(n.openCodeUpdateToastDismissedVersion=t.openCodeUpdateToastDismissedVersion.trim().slice(0,128)),typeof t.showToolFileIcons==`boolean`&&(n.showToolFileIcons=t.showToolFileIcons),typeof t.showTurnChangedFiles==`boolean`&&(n.showTurnChangedFiles=t.showTurnChangedFiles),typeof t.showExpandedBashTools==`boolean`&&(n.showExpandedBashTools=t.showExpandedBashTools),typeof t.showSubagentTaskDetails==`boolean`&&(n.showSubagentTaskDetails=t.showSubagentTaskDetails),typeof t.timeFormatPreference==`string`&&(t.timeFormatPreference===`auto`||t.timeFormatPreference===`12h`||t.timeFormatPreference===`24h`)&&(n.timeFormatPreference=t.timeFormatPreference),typeof t.weekStartPreference==`string`&&(t.weekStartPreference===`auto`||t.weekStartPreference===`sunday`||t.weekStartPreference===`monday`)&&(n.weekStartPreference=t.weekStartPreference),typeof t.desktopWindowControlsPosition==`string`&&(t.desktopWindowControlsPosition===`auto`||t.desktopWindowControlsPosition===`left`||t.desktopWindowControlsPosition===`right`)&&(n.desktopWindowControlsPosition=t.desktopWindowControlsPosition),typeof t.chatRenderMode==`string`&&(t.chatRenderMode===`sorted`||t.chatRenderMode===`live`)&&(n.chatRenderMode=t.chatRenderMode),typeof t.messageStreamTransport==`string`&&(t.messageStreamTransport===`auto`||t.messageStreamTransport===`ws`||t.messageStreamTransport===`sse`)&&(n.messageStreamTransport=t.messageStreamTransport),typeof t.activityRenderMode==`string`&&(t.activityRenderMode===`collapsed`||t.activityRenderMode===`summary`)&&(n.activityRenderMode=t.activityRenderMode),typeof t.collapsibleUserMessages==`boolean`&&(n.collapsibleUserMessages=t.collapsibleUserMessages),typeof t.showSplitAssistantMessageActions==`boolean`&&(n.showSplitAssistantMessageActions=t.showSplitAssistantMessageActions),typeof t.showAssistantTps==`boolean`&&(n.showAssistantTps=t.showAssistantTps),typeof t.fontSize==`number`&&Number.isFinite(t.fontSize)&&(n.fontSize=t.fontSize),typeof t.terminalFontSize==`number`&&Number.isFinite(t.terminalFontSize)&&(n.terminalFontSize=t.terminalFontSize),typeof t.editorFontSize==`number`&&Number.isFinite(t.editorFontSize)&&(n.editorFontSize=t.editorFontSize),Te(t.uiFont)&&(n.uiFont=t.uiFont),Se(t.monoFont)&&(n.monoFont=t.monoFont),typeof t.padding==`number`&&Number.isFinite(t.padding)&&(n.padding=t.padding),typeof t.cornerRadius==`number`&&Number.isFinite(t.cornerRadius)&&(n.cornerRadius=t.cornerRadius),typeof t.inputBarOffset==`number`&&Number.isFinite(t.inputBarOffset)&&(n.inputBarOffset=t.inputBarOffset);let i=Zn(t.shortcutOverrides);i&&(n.shortcutOverrides=i),typeof t.mobileKeyboardMode==`string`&&(t.mobileKeyboardMode===`native`||t.mobileKeyboardMode===`resize-content`)&&(n.mobileKeyboardMode=t.mobileKeyboardMode);let a=cr(t.favoriteModels,64,{preserveVariant:!0});a&&(n.favoriteModels=a);let o=cr(t.hiddenModels,1024);o&&(n.hiddenModels=o);let s=nr(t.collapsedModelProviders);s&&(n.collapsedModelProviders=s);let c=cr(t.recentModels,16,{preserveVariant:!0});c&&(n.recentModels=c);let l=nr(t.recentAgents);l&&(n.recentAgents=l);let u=rr(t.recentEfforts);if(u&&(n.recentEfforts=u),typeof t.diffLayoutPreference==`string`&&(t.diffLayoutPreference===`dynamic`||t.diffLayoutPreference===`inline`||t.diffLayoutPreference===`side-by-side`)&&(n.diffLayoutPreference=t.diffLayoutPreference),typeof t.gitChangesViewMode==`string`&&(t.gitChangesViewMode===`flat`||t.gitChangesViewMode===`tree`)&&(n.gitChangesViewMode=t.gitChangesViewMode),typeof t.directoryShowHidden==`boolean`&&(n.directoryShowHidden=t.directoryShowHidden),typeof t.filesViewShowGitignored==`boolean`&&(n.filesViewShowGitignored=t.filesViewShowGitignored),typeof t.openInAppId==`string`&&t.openInAppId.length>0&&(n.openInAppId=t.openInAppId),typeof t.pwaAppName==`string`){let e=t.pwaAppName.trim().replace(/\s+/g,` `).slice(0,64);n.pwaAppName=e.length>0?e:``}let d=Xn(t.skillCatalogs);return d&&(n.skillCatalogs=d),typeof t.reportUsage==`boolean`&&(n.reportUsage=t.reportUsage),typeof t.globalBehaviorPrompt==`string`&&(n.globalBehaviorPrompt=t.globalBehaviorPrompt),typeof t.responseStyleEnabled==`boolean`&&(n.responseStyleEnabled=t.responseStyleEnabled),typeof t.responseStylePreset==`string`&&(t.responseStylePreset===`concise`||t.responseStylePreset===`detailed`||t.responseStylePreset===`mentor`||t.responseStylePreset===`pushback`||t.responseStylePreset===`noFiller`||t.responseStylePreset===`matchEnergy`||t.responseStylePreset===`warmPeer`||t.responseStylePreset===`custom`)&&(n.responseStylePreset=t.responseStylePreset),typeof t.responseStyleCustomInstructions==`string`&&(n.responseStyleCustomInstructions=t.responseStyleCustomInstructions),typeof t.dictationEnabled==`boolean`&&(n.dictationEnabled=t.dictationEnabled),t.sttProvider===`local`||t.sttProvider===`openai-compatible`||t.sttProvider===`volcengine`?n.sttProvider=t.sttProvider:t.sttProvider===`server`?n.sttProvider=`openai-compatible`:(t.sttProvider===`browser`||t.sttProvider===`wasm`)&&(n.sttProvider=`local`),typeof t.sttServerUrl==`string`&&(n.sttServerUrl=t.sttServerUrl.trim()),typeof t.sttModel==`string`&&(n.sttModel=t.sttModel.trim()),typeof t.sttLocalModel==`string`&&(n.sttLocalModel=t.sttLocalModel.trim()),typeof t.sttLanguage==`string`&&(n.sttLanguage=t.sttLanguage.trim()),n},I=new Map,mr=new Map,hr=2e3,gr=async e=>{let t=I.get(e);if(t&&Date.now()-t.at<hr)return t.value;let n=mr.get(e);if(n)return n;let r=(async()=>{if(o()!==e)return null;let t=ur();if(t)try{let n=pr((await t.load()).settings);return I.set(e,{value:n,at:Date.now()}),n}catch(e){console.warn(`Failed to load shared settings from runtime settings API:`,e)}if(o()!==e)return null;try{let t=await l(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(!t.ok)return null;let n=pr(await t.json().catch(()=>null));return I.set(e,{value:n,at:Date.now()}),n}catch(e){return console.warn(`Failed to load shared settings from server:`,e),null}})();mr.set(e,r);try{return await r}finally{mr.get(e)===r&&mr.delete(e)}},_r=(e=o())=>{I.delete(e)},vr=async()=>{if(typeof window>`u`)return;let e=o(),t=lr(),n=()=>!t?.hasHydrated||t.hasHydrated()||!t.onFinishHydration?Promise.resolve():new Promise(e=>{let n=!1,r=()=>{n||(n=!0,e())},i=t.onFinishHydration(()=>{i?.(),r()});t.hasHydrated?.()&&r()}),r=async t=>{if(await n(),o()===e){try{Jn(t)}catch(e){console.warn(`persistToLocalStorage failed:`,e)}try{fr(t)}catch(e){console.warn(`applyDesktopUiPreferences failed:`,e)}Yn(t)}};try{let t=await gr(e);t&&o()===e&&await r(t)}catch(e){console.warn(`Failed to synchronise settings:`,e)}},L=null,R=null,z=null,B=[],yr=200,V=new Map,br=async e=>{for(;V.get(e)?.size;)await Promise.all([...V.get(e)])},xr=async()=>{let e=L,t=R,n=B;if(L=null,R=null,z=null,B=[],!e||!t||Object.keys(e).length===0){n.forEach(e=>e());return}if(o()!==t){n.forEach(e=>e());return}let r=()=>o()===t,i=ur();if(i){try{let a=await i.save(e);dr(a,e,t),a&&r()&&(Jn(a),fr(a),Yn(a),I.set(t,{value:pr(a),at:Date.now()})),n.forEach(e=>e());return}catch(e){console.warn(`Failed to update settings via runtime settings API:`,e)}if(!r()){n.forEach(e=>e());return}}try{let n=await l(`/api/config/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)});if(!n.ok){console.warn(`Failed to update shared settings via API:`,n.status,n.statusText);return}let i=await n.json().catch(()=>null);dr(i,e,t),i&&r()&&(Jn(i),fr(i),Yn(i),I.set(t,{value:pr(i),at:Date.now()}))}catch(e){console.warn(`Failed to update shared settings via API:`,e)}finally{n.forEach(e=>e())}},H=async e=>{if(typeof window>`u`)return;let t=o();if(R&&R!==t){z&&=(clearTimeout(z),null),L=null,R=null;let e=B;B=[],e.forEach(e=>e())}let n={...L??{}},r=I.get(t)?.value;for(let[t,i]of Object.entries(e)){let e=r?.[t];Object.is(i,e)||i!==void 0&&e!==void 0&&JSON.stringify(i)===JSON.stringify(e)?delete n[t]:n[t]=i}if(L=n,R=t,Object.keys(n).length===0&&!z){L=null,R=null;return}z&&clearTimeout(z);let i=new Promise(e=>{B.push(e)}),a=V.get(t)??new Set;V.set(t,a),a.add(i),z=setTimeout(()=>void xr(),yr);try{await i}finally{a.delete(i),a.size===0&&V.get(t)===a&&V.delete(t)}},Sr=async()=>{if(typeof window>`u`)return;let e=lr();try{let t=await cn();if(!t)return;let n=()=>sn(t);if(e?.hasHydrated?.()){n();return}if(n(),e?.onFinishHydration){let t=e.onFinishHydration(()=>{t?.(),n()})}}catch(e){console.warn(`Failed to load appearance preferences:`,e)}},Cr=3e4,wr=40,Tr=60,Er=(e,t,n,r,i,a)=>{let o=e.trim(),s=t.trim().toLowerCase();return JSON.stringify([o,s,n,r,i,a])},Dr=(e,t)=>{try{let n=JSON.parse(e);return Array.isArray(n)&&n[0]===t}catch{return!1}},Or=g()(_((e,t)=>({cache:{},cacheKeys:[],inFlight:{},async searchFiles(n,r,i=Tr,a){if(!n||n.trim().length===0)return[];let o=n.trim(),s=typeof r==`string`?r.trim():``,c=!!a?.includeHidden,l=a?.respectGitignore??!0,u=a?.type===`directory`?`directory`:`file`,d=Er(o,s,i,c,l,u),f=Date.now(),p=t().cache[d];if(p&&f-p.timestamp<Cr)return p.files;let m=t().inFlight[d];if(m)return m;let h=y.searchFiles(s,{directory:o,limit:i,includeHidden:c,respectGitignore:l,dirs:u!==`file`,type:u}).then(t=>(e(e=>{if(e.inFlight[d]!==h)return e;let n={...e.cache,[d]:{files:t,timestamp:Date.now()}},r=e.cacheKeys.filter(e=>e!==d);for(r.push(d);r.length>wr;){let e=r.shift();e&&delete n[e]}return{cache:n,cacheKeys:r}}),t)).finally(()=>{e(e=>{if(e.inFlight[d]!==h)return e;let t={...e.inFlight};return delete t[d],{inFlight:t}})});return e(e=>({inFlight:{...e.inFlight,[d]:h}})),h},invalidateDirectory(t){if(!t||t.trim().length===0){e({cache:{},cacheKeys:[],inFlight:{}});return}let n=t.trim();e(e=>{let t={...e.cache},r=e.cacheKeys.filter(e=>!Dr(e,n)||(delete t[e],!1)),i=Object.entries(e.inFlight).filter(([e])=>!Dr(e,n));return{cache:t,cacheKeys:r,inFlight:Object.fromEntries(i)}})}}),{name:`file-search-store`})),kr=()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(`yuri_stream_debug`)===`1`}catch{return!1}},Ar=`yuri_stream_perf`,jr=()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(Ar)===`1`}catch{return!1}},Mr=()=>typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now(),Nr=()=>{if(!jr()||typeof window>`u`)return null;if(!window.__yuriStreamPerfState){let e=Date.now();window.__yuriStreamPerfState={counters:new Map,startedAt:e,lastUpdatedAt:e}}return window.__yuriStreamPerfState},Pr=e=>Array.from(e.entries()).map(([e,t])=>({metric:e,count:t.count,avg:t.count>0?Number((t.total/t.count).toFixed(3)):0,max:Number(t.max.toFixed(3)),total:Number(t.total.toFixed(3)),last:Number(t.last.toFixed(3))})).sort((e,t)=>t.total-e.total||t.count-e.count),Fr=(e,t)=>{let n=Nr();if(!n)return;let r=n.counters.get(e)??{count:0,total:0,max:0,last:0};r.count+=1,r.total+=t,r.max=Math.max(r.max,t),r.last=t,n.counters.set(e,r),n.lastUpdatedAt=Date.now()},Ir=e=>{if(!(typeof window>`u`))try{if(e){window.localStorage.setItem(Ar,`1`),window.__yuriStreamPerfState={counters:new Map,startedAt:Date.now(),lastUpdatedAt:Date.now()};return}window.localStorage.removeItem(Ar),delete window.__yuriStreamPerfState,delete window.__yuriVsCodeStreamPerfState}catch{}},Lr=()=>{typeof window>`u`||(jr()&&(window.__yuriStreamPerfState={counters:new Map,startedAt:Date.now(),lastUpdatedAt:Date.now()}),window.__yuriVsCodeStreamPerfState&&(window.__yuriVsCodeStreamPerfState={...window.__yuriVsCodeStreamPerfState,counters:new Map,startedAt:Date.now(),lastUpdatedAt:Date.now()}))},Rr=()=>{if(typeof window>`u`)return{enabled:!1,startedAt:null,lastUpdatedAt:null,durationMs:0,entries:[]};let e=window.__yuriStreamPerfState;return!jr()||!e?{enabled:!1,startedAt:null,lastUpdatedAt:null,durationMs:0,entries:[]}:{enabled:!0,startedAt:e.startedAt,lastUpdatedAt:e.lastUpdatedAt,durationMs:Math.max(0,Date.now()-e.startedAt),entries:Pr(e.counters)}},zr=()=>{if(typeof window>`u`)return{enabled:!1,startedAt:null,lastUpdatedAt:null,durationMs:0,entries:[]};let e=window.__yuriVsCodeStreamPerfState;if(!jr()||!e)return{enabled:!1,startedAt:null,lastUpdatedAt:null,durationMs:0,entries:[]};let t=typeof e.startedAt==`number`?e.startedAt:null;return{enabled:!0,startedAt:t,lastUpdatedAt:typeof e.lastUpdatedAt==`number`?e.lastUpdatedAt:null,durationMs:t?Math.max(0,Date.now()-t):0,entries:Pr(e.counters)}},Br=(e,t=1)=>{Fr(e,t)},Vr=(e,t)=>{Fr(e,t)},Hr=(e,t)=>{if(!jr())return t();let n=Mr();try{return t()}finally{Fr(e,Mr()-n)}},U=null,Ur=0,W=v(),Wr=ae(`lastDirectory`,{storage:W}),Gr=typeof Wr==`string`&&Wr.length>0,Kr=e=>{try{Or.getState().invalidateDirectory(e)}catch(e){console.warn(`Failed to invalidate file search cache:`,e)}},G=e=>{let t=e.trim();if(!t)return t;let n=t.replace(/\\/g,`/`).replace(/^([a-z]):/,(e,t)=>t.toUpperCase()+`:`);return n.length>1?n.replace(/\/+$/,``):n},qr=(e,t)=>{let n=e.trim();return n.startsWith(`~`)?n===`~`?t||n:(n.startsWith(`~/`)||n.startsWith(`~\\`))&&t?`${t}${n.slice(1)}`:n:n},Jr=(e,t)=>G(qr(e,t)),Yr=()=>{let e=ae(`homeDirectory`,{storage:W});if(typeof e!=`string`||e.trim().length===0)return null;let t=G(e);return t.length>0?t:null},Xr=()=>{let e=ae(`lastDirectory`,{storage:W});if(typeof e!=`string`||e.trim().length===0)return null;let t=G(e);return t.length>0?t:null},Zr=()=>{if(typeof process>`u`)return null;let e={},t=e?.HOME||e?.USERPROFILE||(e?.HOMEDRIVE&&e?.HOMEPATH?`${e.HOMEDRIVE}${e.HOMEPATH}`:void 0);if(typeof t==`string`&&t.trim().length>0){let e=G(t);return e.length>0?e:null}let n=process?.cwd?.();if(typeof n==`string`&&n.trim().length>0){let e=G(n);return e.length>0?e:null}return null},Qr=()=>{if(typeof window<`u`){if(U)return U;let e=typeof window.__YURI_HOME__==`string`&&window.__YURI_HOME__.length>0?window.__YURI_HOME__:null;if(e&&e.length>0)return U=e,b(`homeDirectory`,e,{storage:W}),e;let t=Yr();if(t&&!f())return U=t,t}return Zr()||`/`},$r=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;let n=t.replace(/\\/g,`/`);if(n.length>1){let e=n.replace(/\/+$/,``);if(e&&e.length>0)return e===`/`?null:e}return n===`/`||n.length===0?null:n},ei=e=>(U=e,typeof window<`u`&&b(`homeDirectory`,e,{storage:W}),H({homeDirectory:e}),e),ti=async()=>{let e=e=>{let t=$r(e);return t?ei(t):null};try{let t=e(await y.getFilesystemHome());if(t)return t}catch(e){console.warn(`Failed to obtain filesystem home directory:`,e)}try{let t=e((await y.getSystemInfo())?.homeDirectory);if(t)return t}catch(e){console.warn(`Failed to get home directory from system info:`,e)}try{let t=e(await p());if(t)return t}catch(e){console.warn(`Failed to obtain desktop-integrated home directory:`,e)}let t=Qr();return e(t)||t},ni=(()=>{if(!f())return null;let e=window.__VSCODE_CONFIG__?.workspaceFolder;if(typeof e!=`string`||e.trim().length===0)return null;let t=G(e);return t.length>0?t:null})()||Qr(),ri=(()=>{let e=Xr();return e&&!f()?Jr(e,ni):ni})();ri&&y.setDirectory(ri);var ii=!!(ni&&ni!==`/`),ai=g()(_((e,t)=>({currentDirectory:ri,directoryHistory:[ri],historyIndex:0,homeDirectory:ni,hasPersistedDirectory:Gr,isHomeReady:ii,isSwitchingDirectory:!1,setDirectory:(n,r)=>{let i=Jr(n,U||t().homeDirectory||ae(`homeDirectory`,{storage:W}));kr(),De(t().currentDirectory,i)&&(y.setDirectory(i),Kr(),e(e=>{let t=[...e.directoryHistory.slice(0,e.historyIndex+1),i];return b(`lastDirectory`,i,{storage:W}),H({lastDirectory:i}),{currentDirectory:i,directoryHistory:t,historyIndex:t.length-1,hasPersistedDirectory:!0,isHomeReady:!0,isSwitchingDirectory:!1}}))},goBack:()=>{let n=t();if(n.historyIndex>0){let t=n.historyIndex-1,r=n.directoryHistory[t];y.setDirectory(r),Kr(),b(`lastDirectory`,r,{storage:W}),H({lastDirectory:r}),e({currentDirectory:r,historyIndex:t,hasPersistedDirectory:!0,isHomeReady:!0,isSwitchingDirectory:!1})}},goForward:()=>{let n=t();if(n.historyIndex<n.directoryHistory.length-1){let t=n.historyIndex+1,r=n.directoryHistory[t];y.setDirectory(r),Kr(),b(`lastDirectory`,r,{storage:W}),H({lastDirectory:r}),e({currentDirectory:r,historyIndex:t,hasPersistedDirectory:!0,isHomeReady:!0,isSwitchingDirectory:!1})}},goToParent:()=>{let{currentDirectory:e,setDirectory:n}=t();if(e===(U||t().homeDirectory||Qr())||e===`/`)return;let r=e.endsWith(`/`)?e.slice(0,-1):e,i=r.lastIndexOf(`/`);n(i===-1?U||Qr():i===0?`/`:r.substring(0,i))},goHome:async()=>{let e=U||t().homeDirectory||await ti();t().setDirectory(e)},synchronizeHomeDirectory:n=>{let r=t(),i=n;U=i;let a=r.homeDirectory!==i,o=ae(`lastDirectory`,{storage:W}),s=typeof o==`string`&&o.length>0,c=!s&&(r.currentDirectory===`/`||r.currentDirectory===r.homeDirectory||!r.currentDirectory);if(!a&&!c){r.isHomeReady||e({isHomeReady:!0});return}let l=typeof i==`string`&&i!==``&&i!==`/`,u=r.currentDirectory?Jr(r.currentDirectory,i):r.currentDirectory,d=r.directoryHistory.map(e=>Jr(e,i)),f=d.some((e,t)=>e!==r.directoryHistory[t]),p=!!(u&&u!==r.currentDirectory),m={homeDirectory:i,hasPersistedDirectory:s,isHomeReady:l};if(c?(m.currentDirectory=i,m.directoryHistory=[i],m.historyIndex=0,m.isSwitchingDirectory=!1):(p||f)&&(m.currentDirectory=u,m.directoryHistory=d,m.historyIndex=Math.min(r.historyIndex,d.length-1),m.isSwitchingDirectory=!1),e(()=>m),(c||p)&&l){let e=c?i:u;y.setDirectory(e),Kr(),b(`lastDirectory`,e,{storage:W}),H({lastDirectory:e})}H({homeDirectory:i})}}),{name:`directory-store`}));typeof window<`u`&&(ti().then(e=>{ai.getState().synchronizeHomeDirectory(e)}),i(e=>{U=null;let t=++Ur;if(c(e)){let e=Yr(),t=Xr(),n=e||`/`,r=t||n;U=e,ai.setState({currentDirectory:r,directoryHistory:[r],historyIndex:0,homeDirectory:n,hasPersistedDirectory:!!t,isHomeReady:!!(e&&e!==`/`),isSwitchingDirectory:!1}),r&&(y.setDirectory(r),Kr())}ti().then(e=>{t===Ur&&ai.getState().synchronizeHomeDirectory(e)})}));var oi=(e,i)=>{let a=t();return a?a.openWebSocket(r(e),i):n(i?new WebSocket(e,i):new WebSocket(e))},K=`/api/git`,si=1200,ci=5e3,li=2,ui=5e3,di=`${K}/worktrees/queue-activation`,fi=`message_queue_activation_pending`,pi=`worktree_lifecycle_busy`,mi=`worktree_activation_stale`,hi=5e3,gi=3e4,_i=[0,500,1e3,2e3,4e3,8e3,14e3],vi=new Map,q=new Map,yi=new Map,bi=new Map,xi=new Map,Si=new Map,J=new Map,Ci=new Map,wi=new Map,Y=new Map,Ti=new Map,Ei=new Set,Di=0,Oi=[],ki=()=>Di<li?(Di+=1,Promise.resolve()):new Promise(e=>{Oi.push(e)}),Ai=()=>{let e=Oi.shift();if(e){e();return}Di=Math.max(0,Di-1)},ji=async e=>{await ki();try{return await e()}finally{Ai()}},Mi=Symbol.for(`yuri.git.discoveryGated`),Ni=e=>(Object.defineProperty(e,Mi,{value:!0,configurable:!0}),e),Pi=e=>typeof e==`function`&&e[Mi]===!0,X=e=>e.trim(),Fi=``,Z=e=>{let t=`${s()}\u0000${o()}`;return t!==Fi&&(Fi=t,J.clear(),Ci.clear(),wi.clear(),Y.clear(),Ti.clear()),`${t}\u0000${X(e)}`},Ii=(e,t)=>t===`light`?`${X(e)}::light`:X(e),Li=e=>yi.get(X(e))??0,Q=e=>{let t=X(e);yi.set(t,Li(e)+1);for(let e of Array.from(bi.keys()))(e===t||e.startsWith(`${t}::`))&&bi.delete(e);for(let e of Array.from(vi.keys()))(e===t||e.startsWith(`${t}::`))&&vi.delete(e);for(let e of Array.from(q.keys()))(e===t||e.startsWith(`${t}::`))&&q.delete(e)},Ri=e=>Ti.get(Z(e))??0,zi=e=>{let t=Z(e);t&&(Ti.set(t,Ri(e)+1),wi.delete(t),Y.delete(t))};function $(e,t,n){let r={...n};return t&&(r.directory=t),a().api(e,r)}var Bi=(e,t,n)=>{let r=X(e);if(!r)return;let i=Date.now()+ui;xi.set(r,{value:t,expiresAt:i}),typeof n==`string`&&n?J.set(Z(e),{value:{root:n},expiresAt:i}):J.delete(Z(e))};async function Vi(e){let t=Array.from(new Set(e.map(e=>X(e)).filter(Boolean))),n=new Map,r=s();if(t.length===0)return n;let i=Date.now(),o=[];for(let e of t){let t=xi.get(e),r=J.get(Z(e));if(t&&t.expiresAt>i&&r&&r.expiresAt>i){n.set(e,{isGitRepository:t.value,primaryRoot:r.value.root});continue}o.push(e)}if(o.length===0)return n;let c=e=>{for(let t of e){let e=typeof t.directory==`string`?X(t.directory):``;if(!e)continue;let i=!!t.isGitRepository,a=typeof t.primaryRoot==`string`&&t.primaryRoot?t.primaryRoot:null;r===s()&&Bi(e,i,a),n.set(e,{isGitRepository:i,primaryRoot:a})}},u=async e=>{await Promise.all(e.map(async e=>{try{let[t,i]=await Promise.all([Hi(e),Wi(e).then(e=>e.root).catch(()=>e)]);r===s()&&Bi(e,t,t?i:null),n.set(e,{isGitRepository:t,primaryRoot:t?i:null})}catch{r===s()&&Bi(e,!1,null),n.set(e,{isGitRepository:!1,primaryRoot:null})}}))};try{await ji(async()=>{let e=new URLSearchParams;for(let t of o)e.append(`directories`,t);let t=a().api(`${K}/discover`),n=e.toString(),r=n?t.includes(`?`)?`${t}&${n}`:`${t}?${n}`:t,i=await l(r);if(i.status===501||!i.ok)throw Error(`Batch git discover unavailable: ${i.status} ${i.statusText}`);let s=await i.json().catch(()=>null),u=Array.isArray(s)?s:[];if(u.length===0&&o.length>0)throw Error(`Batch git discover returned empty payload`);c(u)})}catch{}let d=o.filter(e=>!n.has(e));return d.length>0&&await u(d),n}async function Hi(e){let t=X(e),n=Date.now(),r=xi.get(t);if(r&&r.expiresAt>n)return r.value;let i=Si.get(t);if(i)return i;let a=(async()=>{let n=await l($(`${K}/check`,e));if(!n.ok)throw Error(`Failed to check git repository: ${n.statusText}`);let r=!!(await n.json()).isGitRepository;return xi.set(t,{value:r,expiresAt:Date.now()+ci}),r})();Si.set(t,a);try{return await a}finally{Si.get(t)===a&&Si.delete(t)}}async function Ui(e,t){let n=t?.mode,r=Ii(e,n),i=Date.now(),a=vi.get(r);if(a&&a.expiresAt>i)return a.value;let s=q.get(r);if(s)return s;let c=(async()=>{let t=Li(e),i=o(),a=bi.get(r),s=a&&a.transport===i&&a.cacheVersion===t?a:null,c=await l($(`${K}/status`,e,{...n?{mode:n}:{},...s?{since:s.revision}:{}}));if(!c.ok)throw Error(`Failed to get git status: ${c.statusText}`);let u=await c.json(),d;if(`unchanged`in u&&u.unchanged===!0){if(!s||u.revision!==s.revision)throw Error(`Failed to get git status: unexpected unchanged response`);d=s.value}else{let{revision:n,...a}=u;d=a,typeof n==`string`&&Li(e)===t&&bi.set(r,{revision:n,value:d,transport:i,cacheVersion:t})}return Li(e)===t&&vi.set(r,{value:d,expiresAt:Date.now()+si}),d})();q.set(r,c);try{return await c}finally{q.get(r)===c&&q.delete(r)}}async function Wi(e){let t=Z(e),n=s(),r=Date.now(),i=J.get(t);if(i&&i.expiresAt>r)return i.value;let a=Ci.get(t);if(a)return a;let o=ji(async()=>{let r=await l($(`${K}/primary-root`,e));if(!r.ok)throw Error(`Failed to resolve git primary root: ${r.statusText}`);let i=await r.json().catch(()=>({}));if(typeof i.root!=`string`||!i.root.trim())throw Error(`Invalid git primary root response`);let a={root:i.root};return n===s()&&J.set(t,{value:a,expiresAt:Date.now()+ui}),a});Ci.set(t,o);try{return await o}finally{Ci.get(t)===o&&Ci.delete(t)}}async function Gi(e){let t=await l($(`${K}/toplevel`,e));if(!t.ok)throw Error(`Failed to resolve git toplevel: ${t.statusText}`);let n=await t.json().catch(()=>({}));return{root:typeof n.root==`string`&&n.root?n.root:e}}async function Ki(e,t){let n=await l($(`${K}/commit-summaries`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({shas:t})});if(!n.ok)throw Error(`Failed to get git commit summaries: ${n.statusText}`);let r=await n.json().catch(()=>({}));return{commits:Array.isArray(r.commits)?r.commits.map(e=>({sha:typeof e.sha==`string`?e.sha:``,short:typeof e.short==`string`?e.short:``,subject:typeof e.subject==`string`?e.subject:``})).filter(e=>e.sha&&e.short):[]}}async function qi(e,t){let{path:n,staged:r,contextLines:i}=t;if(!n)throw Error(`path is required to fetch git diff`);let a=await l($(`${K}/diff`,e,{path:n,staged:r?`true`:void 0,context:i}));if(!a.ok)throw Error(`Failed to get git diff: ${a.statusText}`);return a.json()}async function Ji(e,t){let{path:n,staged:r}=t;if(!n)throw Error(`path is required to fetch git file diff`);let i=await l($(`${K}/file-diff`,e,{path:n,staged:r?`true`:void 0}));if(!i.ok)throw Error(`Failed to get git file diff: ${i.statusText}`);return i.json()}async function Yi(e,t,n){if(!t)throw Error(`path is required to revert git changes`);let r=await l($(`${K}/revert`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:t,scope:n?.scope})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to revert git changes`)}Q(e)}async function Xi(e,t){await Zi(e,[t])}async function Zi(e,t){let n=t.map(e=>e.trim()).filter(Boolean);if(n.length===0)throw Error(`path is required to stage git changes`);let r=await l($(`${K}/stage`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({paths:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to stage git changes`)}Q(e)}async function Qi(e,t){await $i(e,[t])}async function $i(e,t){let n=t.map(e=>e.trim()).filter(Boolean);if(n.length===0)throw Error(`path is required to unstage git changes`);let r=await l($(`${K}/unstage`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({paths:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to unstage git changes`)}Q(e)}async function ea(e,t,n){await ra(e,t,n,`stage`)}async function ta(e,t,n){await ra(e,t,n,`unstage`)}async function na(e,t,n){await ra(e,t,n,`discard`)}async function ra(e,t,n,r){if(!t)throw Error(`path is required to apply a git hunk`);if(typeof n!=`string`||!n.trim())throw Error(`patch is required to apply a git hunk`);let i=await l($(`${K}/apply-hunk`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:t,patch:n,action:r})});if(!i.ok){let e=await i.json().catch(()=>({error:i.statusText}));throw Error(e.error||`Failed to apply git hunk`)}Q(e)}async function ia(e){if(!e)return!1;let t=await l($(`${K}/worktree-type`,e));if(!t.ok)throw Error(`Failed to detect worktree type: ${t.statusText}`);return!!(await t.json()).linked}async function aa(e,t){let n=await l($(`${K}/branches`,e),{signal:t?.signal});if(!n.ok)throw Error(`Failed to get branches: ${n.statusText}`);return n.json()}async function oa(e,t){if(!t?.branch)throw Error(`branch is required to delete a branch`);let n=await l($(`${K}/branches`,e),{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to delete branch`)}return n.json()}async function sa(e,t){if(!t?.branch)throw Error(`branch is required to delete remote branch`);let n=await l($(`${K}/remote-branches`,e),{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to delete remote branch`)}return n.json()}async function ca(e,t){let n=t?.remote?.trim();if(!n)throw Error(`remote is required to remove a remote`);let r=await l($(`${K}/remotes`,e),{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({remote:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to remove remote`)}return r.json()}async function la(e,t,n){if(!Array.isArray(t)||t.length===0)throw Error(`No files provided to generate commit message`);let r={files:t};n?.zenModel&&(r.zenModel=n.zenModel),n?.providerId&&(r.providerId=n.providerId),n?.modelId&&(r.modelId=n.modelId);let i=await l($(`${K}/commit-message`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)});if(!i.ok){let e=await i.json().catch(()=>({error:i.statusText}));console.error(`[git-generation][browser] http error`,{status:i.status,statusText:i.statusText,error:e});let t=typeof e?.traceId==`string`&&e.traceId?` (traceId: ${e.traceId})`:``;throw Error(`${e.error||`Failed to generate commit message`}${t}`)}let a=await i.json();if(!a?.message||typeof a.message!=`object`)throw Error(`Malformed commit generation response`);return{message:{subject:typeof a.message.subject==`string`&&a.message.subject.trim().length>0?a.message.subject.trim():``,highlights:Array.isArray(a.message.highlights)?a.message.highlights.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()):[]}}}async function ua(e,t){let{base:n,head:r,context:i,zenModel:a,providerId:o,modelId:s}=t;if(!n||!r)throw Error(`base and head are required`);let c={base:n,head:r};i?.trim()&&(c.context=i.trim()),a&&(c.zenModel=a),o&&(c.providerId=o),s&&(c.modelId=s);let u=await l($(`${K}/pr-description`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(c)});if(!u.ok){let e=await u.json().catch(()=>({error:u.statusText}));throw Error(e.error||`Failed to generate PR description`)}let d=await u.json().catch(()=>null),f=typeof d?.title==`string`?d.title:``,p=typeof d?.body==`string`?d.body:``;if(!f&&!p)throw Error(`Malformed PR description response`);return{title:f,body:p}}async function da(e){let t=Z(e),n=s(),r=Date.now(),i=wi.get(t);if(i&&i.expiresAt>r)return i.value;let a=Y.get(t);if(a)return a;let o=Ri(e),c=ji(async()=>{let r=await l($(`${K}/worktrees`,e));if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to list worktrees`)}let i=await r.json();return n===s()&&o===Ri(e)&&wi.set(t,{value:i,expiresAt:Date.now()+ui}),i});Y.set(t,c);try{return await c}finally{Y.get(t)===c&&Y.delete(t)}}Ni(da);async function fa(e,t){let n=await l($(`${K}/worktrees/validate`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to validate worktree`)}return n.json()}async function pa(e){let t=await l($(`${K}/worktrees/bootstrap-status`,e));if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to get worktree bootstrap status`)}return t.json()}async function ma(e,t){let n=await l($(`${K}/worktrees/preview`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to preview worktree`)}return n.json()}var ha=e=>typeof e==`string`&&e.length>0,ga=e=>{if(!e||typeof e!=`object`)return null;let t=e;if(!ha(t.name)||!ha(t.path))return null;let n={head:typeof t.head==`string`?t.head:``,name:t.name,branch:typeof t.branch==`string`?t.branch:``,path:t.path};return t.directoryCreated===!0&&(n.directoryCreated=!0),t.bootstrapStatus&&typeof t.bootstrapStatus==`object`&&(n.bootstrapStatus=t.bootstrapStatus),n},_a=(e,t,n)=>{if(e!==503||!t||typeof t!=`object`)return null;let r=t;if(r.code!==fi)return null;let i=ga(r.worktree);if(!i)return null;let a=r.repair;if(!a||typeof a!=`object`)return null;let o=a;if(o.method!==`POST`||o.path!==di)return null;let s=o.body;if(!s||typeof s!=`object`)return null;let c=s;return c.projectDirectory!==n||c.directory!==i.path?null:i},va=(e,t,n,r)=>`${e}\u0000${t}\u0000${n}\u0000${r}`,ya=e=>new Promise(t=>{setTimeout(t,e)}),ba=async e=>{if(e.status===409){let t=await e.json().catch(()=>null);return t?.code===pi||t?.code===mi}return e.status===503&&(await e.json().catch(()=>null))?.code===fi},xa=e=>e===400||e===401||e===403||e===501,Sa=(e,t)=>{let n=o(),r=s(),i=va(n,r,e,t);if(Ei.has(i))return;Ei.add(i);let a=()=>o()===n&&s()===r;(async()=>{let n=Date.now(),r=0;for(;Date.now()-n<gi;){if(!a())return;let i=_i[Math.min(r,_i.length-1)]??0;if(i>0){let e=gi-(Date.now()-n);if(e<=0||(await ya(Math.min(i,e)),!a()))return}let o=new AbortController,s=setTimeout(()=>o.abort(),hi);try{let n=await l($(di,void 0),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({projectDirectory:e,directory:t}),signal:o.signal});if(n.ok||xa(n.status))return;if(await ba(n)){r+=1;continue}return}catch{r+=1}finally{clearTimeout(s)}}})().catch(()=>{}).finally(()=>{Ei.delete(i)})};async function Ca(e,t){let n=await l($(`${K}/worktrees`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})}),r=await n.json().catch(()=>null);if(n.ok){let t=ga(r);if(t)return zi(e),t;if(r&&typeof r==`object`)return zi(e),r;throw Error(`Failed to create worktree`)}let i=_a(n.status,r,e);if(i)return zi(e),Sa(e,i.path),i;let a=r&&typeof r==`object`?r:{error:n.statusText};throw Error(a.error||`Failed to create worktree`)}async function wa(e,t){let n=await l($(`${K}/worktrees`,e),{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to delete worktree`)}let r=await n.json();return zi(e),r}async function Ta(e,t,n={}){let r=await l($(`${K}/commit`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:t,addAll:n.addAll??!1,files:n.files,stageFiles:n.stageFiles})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to create commit`)}let i=await r.json();return Q(e),i}async function Ea(e,t={}){let n=await l($(`${K}/push`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to push`)}let r=await n.json();return Q(e),r}async function Da(e,t={}){let n=await l($(`${K}/pull`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to pull`)}let r=await n.json();return Q(e),r}async function Oa(e,t={}){let n=await l($(`${K}/fetch`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to fetch`)}let r=await n.json();return Q(e),r}async function ka(e){let t=await l($(`${K}/stashes`,e));if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to list stashes`)}return t.json()}async function Aa(e,t){let n=await l($(`${K}/stashes/file-counts`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({refs:t})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to count stash files`)}return n.json()}async function ja(e,t={}){let n=await l($(`${K}/stash`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to stash changes`)}return n.json()}var Ma=async(e,t,n)=>{let r=await l($(`${K}/${t}`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to ${t}`)}return r.json()},Na=(e,t)=>Ma(e,`stash/apply`,t),Pa=(e,t)=>Ma(e,`stash/pop`,t),Fa=(e,t)=>Ma(e,`stash/drop`,t);async function Ia(e,t){let n=await l($(`${K}/checkout`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({branch:t})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to checkout branch`)}return n.json()}async function La(e,t,n){let r=await l($(`${K}/branches`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:t,startPoint:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to create branch`)}return r.json()}async function Ra(e,t,n){let r=await l($(`${K}/branches/rename`,e),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({oldName:t,newName:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to rename branch`)}return r.json()}async function za(e,t={}){let n=await l($(`${K}/log`,e,{maxCount:t.maxCount,from:t.from,to:t.to,file:t.file,all:t.all?`true`:void 0}));if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(`Failed to get git log: ${e.error||n.statusText}`)}return n.json()}async function Ba(e,t){let n=await l($(`${K}/commit-files`,e,{hash:t}));if(!n.ok)throw Error(`Failed to get commit files: ${n.statusText}`);return n.json()}async function Va(e,t,n,r){let i=await l($(`${K}/commit-file-diff`,e,{hash:t,path:n,binary:r?`true`:void 0}));if(!i.ok)throw Error(`Failed to get commit file diff: ${i.statusText}`);return i.json()}async function Ha(){let e=await l($(`${K}/identities`,void 0));if(!e.ok)throw Error(`Failed to get git identities: ${e.statusText}`);return e.json()}async function Ua(e){let t=await l($(`${K}/identities`,void 0),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to create git identity`)}return t.json()}async function Wa(e,t){let n=await l($(`${K}/identities/${e}`,void 0),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to update git identity`)}return n.json()}async function Ga(e){let t=await l($(`${K}/identities/${e}`,void 0),{method:`DELETE`});if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to delete git identity`)}}async function Ka(e){if(!e)return null;let t=await l($(`${K}/current-identity`,e));if(!t.ok)throw Error(`Failed to get current git identity: ${t.statusText}`);let n=await t.json();return n?{userName:n.userName??null,userEmail:n.userEmail??null,sshCommand:n.sshCommand??null}:null}async function qa(e){if(!e)return!1;let t=await l($(`${K}/has-local-identity`,e));if(!t.ok)throw Error(`Failed to check local identity: ${t.statusText}`);return(await t.json().catch(()=>null))?.hasLocalIdentity===!0}async function Ja(){let e=await l($(`${K}/global-identity`,void 0));if(!e.ok)throw Error(`Failed to get global git identity: ${e.statusText}`);let t=await e.json();return!t||!t.userName&&!t.userEmail?null:{userName:t.userName??null,userEmail:t.userEmail??null,sshCommand:t.sshCommand??null}}async function Ya(e,t){let n=await l($(`${K}/set-identity`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({profileId:t})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to set git identity`)}return n.json()}async function Xa(){let e=await l($(`${K}/discover-credentials`,void 0));if(!e.ok)throw Error(`Failed to discover git credentials: ${e.statusText}`);return e.json()}async function Za(e,t){if(!e)return null;let n=await l($(`${K}/remote-url`,e,{remote:t}));return n.ok?(await n.json()).url??null:null}async function Qa(e,t){let n=await l($(`${K}/remotes`,e),{signal:t?.signal});if(!n.ok)throw Error(`Failed to get remotes: ${n.statusText}`);return n.json()}async function $a(e,t){let n=await l($(`${K}/rebase`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to rebase`)}return n.json()}async function eo(e){let t=await l($(`${K}/rebase/abort`,e),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to abort rebase`)}return t.json()}async function to(e,t){let n=await l($(`${K}/merge`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to merge`)}return n.json()}async function no(e,t){let n=await l($(`${K}/checkout-commit`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({hash:t})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to checkout commit`)}return n.json()}async function ro(e,t){let n=await l($(`${K}/cherry-pick`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({hash:t})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to cherry-pick`)}return n.json()}async function io(e,t){let n=await l($(`${K}/revert-commit`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({hash:t})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to revert commit`)}return n.json()}async function ao(e,t,n,r){let i=await l($(`${K}/reset-to-commit`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({hash:t,mode:n,force:r})});if(!i.ok){let e=await i.json().catch(()=>({error:i.statusText}));throw Error(e.error||`Failed to reset`)}return i.json()}async function oo(e){let t=await l($(`${K}/merge/abort`,e),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to abort merge`)}return t.json()}async function so(e){let t=await l($(`${K}/rebase/continue`,e),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to continue rebase`)}return t.json()}async function co(e){let t=await l($(`${K}/merge/continue`,e),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to continue merge`)}return t.json()}async function lo(e,t){return await ja(e,{message:t?.message}),{success:!0}}async function uo(e){return await Pa(e,{ref:`stash@{0}`}),{success:!0}}async function fo(e){let t=await l($(`${K}/conflict-details`,e));if(!t.ok)throw Error(`Failed to get conflict details: ${t.statusText}`);return t.json()}async function po(e,t){let n=await l(`${K}/validate-directory`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({directory:e,worktreeRoot:t})});if(!n.ok)throw Error(`Failed to validate worktree directory: ${n.statusText}`);return n.json()}async function mo(e){let t=await l(`${K}/canonicalize-worktree-state`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({directory:e})});if(!t.ok)throw Error(`Failed to canonicalize worktree state: ${t.statusText}`);return t.json()}export{ca as $,dn as $t,Ki as A,Xe as An,Vr as At,Oa as B,Un as Bt,la as C,ct as Cn,Rr as Ct,fo as D,E as Dn,kr as Dt,Ba as E,lt as En,Ir as Et,Ui as F,H as Ft,Pi as G,Sn as Gt,Ea as H,zn as Ht,pa as I,br as It,da as J,P as Jt,ia as K,Cn as Kt,Ja as L,Wn as Lt,Ji as M,Oe as Mn,Sr as Mt,Ha as N,_r as Nt,Ka as O,Ve as On,Br as Ot,za as P,vr as Pt,$a as Q,mn as Qt,Za as R,Kn as Rt,Fa as S,ht as Sn,ai as St,Va as T,st as Tn,Lr as Tt,qa as U,wn as Ut,Da as V,Bn as Vt,zi as W,xn as Wt,Pa as X,pn as Xt,to as Y,ln as Yt,ma as Z,fn as Zt,Ga as _,at as _n,Wa as _t,Hi as a,rn as an,Yi as at,Xa as b,pt as bn,ji as bt,ro as c,wt as cn,Xi as ct,Aa as d,Lt as dn,lo as dt,_n as en,Ra as et,La as f,Ut as fn,ja as ft,oa as g,et as gn,ta as gt,Ca as h,Ht as hn,$i as ht,mo as i,nn as in,io as it,qi as j,ke as jn,Or as jt,aa as k,Je as kn,Hr as kt,co as l,_t as ln,Zi as lt,Ua as m,It as mn,Qi as mt,eo as n,vn as nn,Wi as nt,Ia as o,Zt as on,na as ot,Ta as p,O as pn,uo as pt,ka as q,N as qt,Na as r,hn as rn,Gi as rt,no as s,Mt as sn,Ya as st,oo as t,gn as tn,ao as tt,so as u,gt as un,ea as ut,wa as v,nt as vn,fa as vt,ua as w,it as wn,zr as wt,Vi as x,mt as xn,oi as xt,sa as y,ft as yn,po as yt,Qa as z,Gn as zt};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n}from"./runtime-switch-BMjl5Y5W.js";import{R as r,l as i,u as a}from"./platform-wF65ZFgV.js";import{a as o,i as s,r as c}from"./vendor-zustand-Cwko4FG1.js";import{ot as l,st as u}from"./vendor-base-ui-z2M4boRm.js";import{St as d,an as f,jt as p,on as m}from"./gitApiHttp-DvTBxvX8.js";import{t as h}from"./safeStorage-DTOhKN0V.js";import{n as g}from"./vendor-react-P8wFrkcT.js";import{r as _}from"./vendor-reactuses-core-Dyjw5sZR.js";import{r as ee}from"./useUIStore-Cfmg-aDQ.js";import{t as te}from"./i18n-RH7UieOS.js";import{Ba as v,Gn as y,Jn as b,R as x,Rn as S,Xi as ne,Xn as C,da as re,di as ie,lt as ae,p as w,v as T,vi as E,x as D,xa as oe,yt as O,za as se}from"./useMobileNavigationStore-BNtVrnSw.js";import{a as ce,g as k,o as le,p as A,s as j}from"./fileMentionAutocompleteState-BZJqfgae.js";import{t as ue}from"./AgentAvatar-B7KbxN8Y.js";import{n as M}from"./Icon-DizeYahT.js";import{l as de,s as fe}from"./gitApi-DVx_V1x6.js";import{c as pe,d as me,l as N,n as he,r as ge,t as _e}from"./fileMentionTouchSelection-D-AdTJVr.js";import{n as ve}from"./textarea-Qt06OhhX.js";import{f as ye,o as be}from"./projectMeta-D1Ytss9U.js";var P=(e,t)=>{let n=t.trim();if(!n)return[...e].sort((e,t)=>e.isBuiltIn===t.isBuiltIn?e.name.localeCompare(t.name):e.isBuiltIn?-1:1);let r=k([...e],n,e=>[e.name,e.description??``]);return r.sort((e,t)=>e.score===t.score?e.item.isBuiltIn===t.item.isBuiltIn?e.item.name.localeCompare(t.item.name):e.item.isBuiltIn?-1:1:e.score-t.score),r.map(e=>e.item)},F=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>{let r=t[n];return r!=null&&e.id===r.id&&e.title===r.title&&(e.subtitle??``)===(r.subtitle??``)&&(e.badge??``)===(r.badge??``)&&e.iconName===r.iconName&&e.agentName===r.agentName}),I=(e,t)=>e.highlightedIndex===t.highlightedIndex&&F(e.rows,t.rows),xe=(e,t)=>F(e,t)?e:t.slice(),Se=(e,t,n)=>{e&&(t.current&&I(t.current,n)||(t.current=n,e(n)))},Ce=(e,t)=>{t.current=null,e?.({rows:[],highlightedIndex:0})},L=e(u(),1),R=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+/g,`/`);n&&!r.startsWith(`//`)&&(r=`/${r}`);let i=r===`/`,a=/^[A-Za-z]:\/$/.test(r);return!i&&!a&&(r=r.replace(/\/+$/,``)),r},z=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,B=e=>e.startsWith(`yuri-remote-location:`)?i(e):R(e),V=(e,t)=>{let n=R(a(t,`local`).directory),r=R(e);if(!n||!r)return!1;let i=z(n),o=z(r);return o===i||o.startsWith(i.endsWith(`/`)?i:`${i}/`)},we=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t;try{t=B(e)}catch{continue}if(!t||!r||typeof r!=`object`)continue;let i=r,a=Array.isArray(i.openPaths)?Array.from(new Set(i.openPaths.filter(e=>typeof e==`string`).map(e=>R(e)).filter(e=>V(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>R(e)).filter(e=>V(e,t)))):[],s=typeof i.selectedPath==`string`?R(i.selectedPath):null,c=s&&V(s,t)?s:a[0]??null,l=typeof i.touchedAt==`number`&&Number.isFinite(i.touchedAt)?i.touchedAt:Date.now(),u=n[t];if(u){let e=Array.from(new Set([...u.openPaths,...a])),r=Array.from(new Set([...u.expandedPaths,...o])),i=u.selectedPath??c??e[0]??null;n[t]={openPaths:e,selectedPath:i,expandedPaths:r,touchedAt:Math.max(u.touchedAt,l)};continue}n[t]={openPaths:a,selectedPath:c,expandedPaths:o,touchedAt:l}}return n},H=(e,t)=>{let n=Object.entries(e);if(n.length<=t)return e;n.sort((e,t)=>(t[1]?.touchedAt??0)-(e[1]?.touchedAt??0));let r={};for(let[e,i]of n.slice(0,t))r[e]=i;return r},U=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},Te=o()(c(s((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=B((t||``).trim()),a=R((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!V(a,i)||e(e=>{let t=e.byRoot[i],n=U(t),r=n.openPaths.includes(a),o=r?n.openPaths:[...n.openPaths,a],s=n.selectedPath??a;return t&&r&&t.selectedPath===s?e:{byRoot:H({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=B((t||``).trim()),i=R((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=z(i),a=e=>z(e)===n,o=t.selectedPath?a(t.selectedPath):!1;if(!t.openPaths.some(a)&&!o)return e;let s=t.openPaths.filter(e=>!a(e)),c=o?s[0]??null:t.selectedPath;return{byRoot:H({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=B((t||``).trim()),i=R((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=z(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=z(e);return t===n||t.startsWith(a)},s=t.openPaths.filter(e=>!o(e));if(s.length===t.openPaths.length)return e;let c=t.selectedPath&&o(t.selectedPath)?s[0]??null:t.selectedPath;return{byRoot:H({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=B((t||``).trim()),i=R((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=z(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=z(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:H({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=B((t||``).trim()),a=n?R(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!V(a,i)||e(e=>{let t=e.byRoot[i],n=U(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:H({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=B((e||``).trim());if(!n)return;let r=t().byRoot[n];if(!r||r.selectedPath)return;let i=r.openPaths[0]??null;i&&t().setSelectedPath(n,i)},toggleExpandedPath:(t,n)=>{let r=B((t||``).trim()),i=R((n||``).trim());!r||!i||!V(i,r)||e(e=>{let t=e.byRoot[r],n=U(t),a=n.expandedPaths.includes(i)?n.expandedPaths.filter(e=>e!==i):[...n.expandedPaths,i];return t&&t.expandedPaths===a&&t.selectedPath===n.selectedPath&&t.openPaths===n.openPaths?e:{byRoot:H({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=B((t||``).trim()),i=R((n||``).trim());!r||!i||!V(i,r)||e(e=>{let t=e.byRoot[r],n=U(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:H({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=B((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>R((e||``).trim())).filter(e=>e&&V(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=U(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:H({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:h(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:we(t)}},merge:(e,t)=>({...t,byRoot:we(e&&typeof e==`object`?e.byRoot:void 0)}),partialize:e=>({byRoot:we(e.byRoot)})}),{name:`files-view-tabs-store`})),W=g(),Ee=(e,t)=>{let n=(0,W.c)(4),r=t===void 0?200:t,[i,a]=L.useState(e),o,s;return n[0]!==r||n[1]!==e?(o=()=>{let t=window.setTimeout(()=>{a(e)},r);return()=>{window.clearTimeout(t)}},s=[e,r],n[0]=r,n[1]=e,n[2]=o,n[3]=s):(o=n[2],s=n[3]),L.useEffect(o,s),i},De=()=>{let e=(0,W.c)(17),t=w(Oe),n=O(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=D(r),a=w(ke),o=w(Ae),s=v(G),c=v(K),l=d(q);if(t){let r;e[2]===i?r=e[3]:(r=T(i),e[2]=i,e[3]=r);let o=r;if(o)return o;let s;e[4]!==t||e[5]!==a?(s=a.get(t),e[4]=t,e[5]=a,e[6]=s):s=e[6];let c=s;if(c?.path)return c.path;let l;if(e[7]!==t||e[8]!==n){let r;e[10]===t?r=e[11]:(r=e=>e.id===t,e[10]=t,e[11]=r),l=n.find(r),e[7]=t,e[8]=n,e[9]=l}else l=e[9];let u=l;if(u?.directory)return u.directory}if(o?.open&&(o.bootstrapPendingDirectory||o.directoryOverride))return(o.bootstrapPendingDirectory||o.directoryOverride)??void 0;if(s){let t;if(e[12]!==s||e[13]!==c){let n;e[15]===s?n=e[16]:(n=e=>e.id===s,e[15]=s,e[16]=n),t=c.find(n),e[12]=s,e[13]=c,e[14]=t}else t=e[14];let n=t;if(n?.path)return n.path}return l??void 0};function Oe(e){return e.currentSessionId}function ke(e){return e.worktreeMetadata}function Ae(e){return e.newSessionDraft}function G(e){return e.activeProjectId}function K(e){return e.projects}function q(e){return e.currentDirectory}var J=l(),je=`bg-transparent font-[inherit] text-[var(--primary-base)]`,Me=(e,t)=>{let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase();if(!r.includes(n))return e;let i=[],a=0,o=r.indexOf(n);for(;o!==-1;)o>a&&i.push(e.slice(a,o)),i.push((0,J.jsx)(`mark`,{className:je,children:e.slice(o,o+n.length)},`${o}-${n}`)),a=o+n.length,o=r.indexOf(n,a);return a<e.length&&i.push(e.slice(a)),i},Ne=L.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSkillSelect:r,onSessionSelect:i,onClose:a,style:o,onRowsChange:s},c)=>{let{t:l}=te(),u=De()??``,d=w(e=>e.currentSessionId),h=E(e=>e.activeSessions),g=x({enabled:!!i}),b=v(e=>e.activeProjectId),C=v(e=>e.projects),ae=L.useMemo(()=>C.find(e=>e.id===b)?.path??null,[b,C]),T=L.useMemo(()=>{let e=ae||u;return e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null},[ae,u]),D=Te(e=>T?e.byRoot[T]:void 0),O=ne(e=>e.agents),se=p(e=>e.searchFiles),k=Ee(e,180),de=m(),fe=f(),[me,N]=L.useState([]),[ye,be]=L.useState(!1),[P,F]=L.useState(0),I=L.useRef(0),xe=L.useRef({query:e,directory:u,ids:[]}),[R,z]=L.useState(360),[B,V]=L.useState({}),[we,H]=L.useState({}),U=L.useRef([]),W=L.useRef([]),Oe=L.useRef([]),ke=L.useRef(null),Ae=L.useRef(null),G=L.useRef(null);G.current||=_e();let K=ee(e=>e.isMobile),q=(e??``).trim(),je=oe({directory:u||null}),Ne=L.useMemo(()=>r?je.data??[]:[],[r,je.data]),Pe=L.useMemo(()=>{if(!T||!D)return[];let e=[D.selectedPath,...D.openPaths.slice().reverse()].filter(e=>typeof e==`string`&&e.length>0),t=new Set,n=[];for(let r of e){if(t.has(r))continue;t.add(r);let e=r.replace(/\\/g,`/`),i=e.split(`/`).filter(Boolean).pop()||e,a=e.startsWith(`${T}/`)?e.slice(T.length+1):e;n.push({name:i,path:e,relativePath:a,extension:i.includes(`.`)?i.split(`.`).pop()?.toLowerCase():void 0})}return j(n,q,{limit:6})},[q,T,D]),Y=L.useMemo(()=>n?re(O).filter(e=>e.mode!==`primary`):[],[O,n]),Fe=L.useMemo(()=>i?ce({sessions:ie(h,g),currentSessionId:d,searchQuery:q}):[],[h,d,g,q,i]),Ie=Pe,Le=me,X=L.useMemo(()=>pe({skills:Ne,agents:Y,sessions:Fe,recentFiles:Ie,pathHits:Le,searchQuery:q,untitledSession:l(`chat.fileMentionAutocomplete.untitledSession`),sessionBadge:l(`chat.fileMentionAutocomplete.sessionType`),skillBadge:l(`chat.commandAutocomplete.badge.skill`)}),[Ne,Y,Fe,Ie,Le,q,l]);L.useEffect(()=>{let e=e=>{let t=e.target;!t||!ke.current||ke.current.contains(t)||a()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[a]),L.useEffect(()=>{if(!u){N([]);return}let e=(k??``).trim(),t=A(e);if(!t){N([]);return}let n=!1;be(!0);let r={includeHidden:de,respectGitignore:!fe};return Promise.all([se(u,t,80,{...r,type:`file`}),se(u,t,40,{...r,type:`directory`})]).then(([t,r])=>{if(n)return;let i=new Set(Pe.map(e=>e.path));N(le({files:t,directories:r,query:e,excludePaths:i,limit:20}))}).catch(()=>{n||N([])}).finally(()=>{n||be(!1)}),()=>{n=!0}},[u,k,Pe,se,de,fe]),L.useLayoutEffect(()=>{let t=xe.current,n=t.ids[I.current],r=t.query===e&&t.directory===u?Math.max(0,X.findIndex(e=>e.id===n)):0;xe.current={query:e,directory:u,ids:X.map(e=>e.id)},I.current=r,F(r)},[X,e,u]),L.useEffect(()=>{V({}),H({})},[X]),L.useEffect(()=>{U.current[P]?.scrollIntoView({block:`nearest`})},[P]),L.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};W.current.forEach((n,r)=>{if(!n)return;let i=Oe.current[r]?.offsetWidth??n.scrollWidth,a=Math.max(0,i-n.clientWidth),o=a>8;if(e[r]=o,o){let e=Math.max(.6,a/110);t[r]=e}}),V(e),H(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[X]),L.useEffect(()=>{let e=W.current[P];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&z(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[P]);let Re=_(e=>{t(e)}),ze=_(e=>{n?.(e)}),Be=_(e=>{i?.(e)}),Ve=_(e=>{r?.(e)}),He=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&G.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&G.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(G.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>G.current?.pointerCancel(),onClick:()=>{G.current?.click(t)},onMouseMove:()=>{I.current=e,F(e)}}),Ue=e=>{let t=X.length;if(t===0)return;let n=(e%t+t)%t,r=X[n];if(r.agentName!==void 0){ze(r.agentName);return}if(r.id.startsWith(`skill:`)){let e=Ne.find(e=>r.id===`skill:${e.name}-${e.scope}`);e&&Ve(e);return}if(r.id.startsWith(`session:`)){let e=Fe.find(e=>r.id===`session:${e.id}`);e&&Be(e);return}let i=r.id.startsWith(`recent:`)?Ie.find(e=>r.id===`recent:${e.path}`):Le.find(e=>r.id===`file:${e.path}`);i&&Re(i)};L.useEffect(()=>{Se(s,Ae,{rows:X,highlightedIndex:P})},[s,P,X]);let We=L.useRef(s);return We.current=s,L.useEffect(()=>()=>{Ce(We.current,Ae)},[]),L.useImperativeHandle(c,()=>({acceptIndex:e=>{Ue(e)},handleKeyDown:e=>{if(e===`Escape`){a();return}let t=X.length;if(t!==0){if(e===`ArrowDown`){I.current=(I.current+1)%t,F(I.current);return}if(e===`ArrowUp`){I.current=(I.current-1+t)%t,F(I.current);return}(e===`Enter`||e===`Tab`)&&Ue(I.current)}}})),(0,J.jsxs)(he,{ref:ke,isMobile:K,className:`max-w-[640px] max-h-64`,style:o,children:[(0,J.jsx)(ve,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,J.jsxs)(`div`,{className:`py-1`,children:[X.map((e,t)=>{let n=e.id.startsWith(`file:`)||e.id.startsWith(`recent:`),r=n?y(e.title,{maxLength:60}):e.title,i=P===t,a=B[t]??!1,o=we[t]??2.6;return(0,J.jsxs)(`div`,{"data-mention-id":e.id,ref:e=>{U.current[t]=e},className:S(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,ge(K,i),!K&&i&&`text-interactive-selection-foreground`),...He(t,()=>Ue(t)),children:[(0,J.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center`,children:e.agentName===void 0?(0,J.jsx)(M,{name:e.iconName,className:`size-3.5 text-current`}):(0,J.jsx)(ue,{name:e.agentName,size:20})}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,J.jsxs)(`span`,{ref:e=>{W.current[t]=e},className:S(`relative block min-w-0 overflow-hidden`,n&&a&&i&&`file-mention-marquee-container`),style:i?{"--file-mention-marquee-width":`${R}px`,"--file-mention-marquee-duration":`${o}s`}:void 0,title:e.title,children:[(0,J.jsx)(`span`,{ref:e=>{Oe.current[t]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:e.title}),n&&a&&i?(0,J.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:Me(e.title,q)}):(0,J.jsx)(`span`,{className:`block truncate`,children:Me(r,q)})]}),e.trailingLabel?(0,J.jsx)(`span`,{className:S(`max-w-[40%] shrink-0 truncate text-muted-foreground`,K?`typography-micro`:`typography-meta`),children:e.trailingLabel}):null]}),e.subtitle?(0,J.jsx)(`div`,{className:S(`truncate text-muted-foreground`,K?`typography-micro`:`typography-meta`),children:Me(e.subtitle,q)}):null]})]},e.id)}),ye&&Le.length===0?(0,J.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,J.jsx)(M,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!ye&&X.length===0&&(0,J.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:l(`chat.fileMentionAutocomplete.empty`)})]})}),!K&&(0,J.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:l(`chat.autocomplete.keyboardHint`)})]})}),Pe=new Set([`new`,`fork`,`compact`,`reload`,`undo`,`redo`,`model`,`btw`]),Y=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&Pe.has(n))},Fe=(e,t)=>!e||t({name:e}),Ie=` `,Le=(e,t)=>{let n=Math.max(0,Math.min(t,e.length)),r=n;for(;r>0&&!/\s/.test(e[r-1]);)--r;return r>=2&&e[r-1]===Ie&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},X=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,Re=S(X,`bg-[color-mix(in_srgb,var(--primary-base)_12%,transparent)] text-[color-mix(in_srgb,var(--primary-base)_70%,transparent)] border-[color-mix(in_srgb,var(--primary-base)_24%,transparent)]`),ze=S(X,`bg-[color-mix(in_srgb,var(--status-success)_12%,transparent)] text-[color-mix(in_srgb,var(--status-success)_70%,transparent)] border-[color-mix(in_srgb,var(--status-success)_24%,transparent)]`),Be=S(X,`bg-[color-mix(in_srgb,var(--status-info)_12%,transparent)] text-[color-mix(in_srgb,var(--status-info)_70%,transparent)] border-[color-mix(in_srgb,var(--status-info)_24%,transparent)]`),Ve=S(X,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),He=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id&&e.description===t[n]?.description),Ue=e=>{let t=!!e.sessionID;return{hasSession:t,canStartSessionCommand:t||e.hasNewDraft}},We=L.forwardRef(({searchQuery:e,onCommandSelect:t,onClose:n,directory:i,style:a,commandPolicy:o,commandContext:s,onRowsChange:c},l)=>{let{t:u}=te(),d=ee(e=>e.isMobile),f=w(e=>e.currentSessionId),p=w(e=>!!e.newSessionDraft?.open),m=w(L.useCallback(e=>f?e.getDirectoryForSession(f):void 0,[f])),h=ae(f??``,m??void 0),g=L.useMemo(()=>s??{sessionID:f??null,hasMessages:h.length>0,hasNewDraft:p},[s,f,h.length,p]),{hasSession:_,canStartSessionCommand:v}=L.useMemo(()=>Ue(g),[g]),y=g.hasMessages,[b,x]=L.useState([]),[ne,C]=L.useState(!1),re=se({directory:i}),ie=L.useMemo(()=>re.data??[],[re.data]),T=re.isFetching,[E,D]=L.useState(0),oe=L.useRef(0),O=L.useRef(!1),ce=L.useRef([]),k=L.useRef(null),le=L.useRef(!1),A=L.useRef(null),j=L.useRef(!1),ue=L.useRef(null);L.useEffect(()=>{let e=e=>{let t=e.target;!t||!k.current||k.current.contains(t)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[n]),L.useEffect(()=>{(async()=>{C(T);try{let t=ie.flatMap((e,t)=>e.source===`skill`?[]:[{id:`opencode:${e.scope??`global`}:${e.name}:${e.agent??``}:${e.model??``}:${t}`,name:e.name,source:`opencode`,description:e.description,agent:e.agent??void 0,model:e.model??void 0,isBuiltIn:e.isBuiltIn,scope:e.scope,reference:e.reference}]),n=[{id:`yuri:new`,name:`new`,source:`yuri`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!y?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:btw`,name:`btw`,source:`yuri`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`yuri:undo`,name:`undo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`yuri:redo`,name:`redo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`yuri:fork`,name:`fork`,source:`yuri`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`yuri:timeline`,name:`timeline`,source:`yuri`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`yuri:model`,name:`model`,source:`yuri`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`yuri:compact`,name:`compact`,source:`yuri`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...r()?[{id:`yuri:reload`,name:`reload`,source:`yuri`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...v?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...v?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...v?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...v?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...v?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...v?[{id:`yuri:explore`,name:`explore`,source:`yuri`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isYuri:!0}]:[],...t],i=!y,a=P(n.filter(e=>(i||e.name!==`init`)&&(o?.(e)??!0)),e);x(e=>He(e,a)?e:a)}catch{let t=!y,n=P([{id:`yuri:new`,name:`new`,source:`yuri`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!y?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:btw`,name:`btw`,source:`yuri`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`yuri:undo`,name:`undo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`yuri:redo`,name:`redo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`yuri:fork`,name:`fork`,source:`yuri`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`yuri:timeline`,name:`timeline`,source:`yuri`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`yuri:model`,name:`model`,source:`yuri`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`yuri:compact`,name:`compact`,source:`yuri`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...r()?[{id:`yuri:reload`,name:`reload`,source:`yuri`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...v?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...v?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...v?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...v?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...v?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...v?[{id:`yuri:explore`,name:`explore`,source:`yuri`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isYuri:!0}]:[]].filter(e=>(t||e.name!==`init`)&&(o?.(e)??!0)),e);x(e=>He(e,n)?e:n)}finally{C(!1)}})()},[e,y,_,v,ie,T,u,o]),L.useEffect(()=>{D(0)},[b]),L.useEffect(()=>{oe.current=E},[E]),L.useEffect(()=>{ce.current[E]?.scrollIntoView({block:`nearest`})},[E]),L.useEffect(()=>{Se(c,ue,{rows:N(b,{skill:u(`chat.commandAutocomplete.badge.skill`),command:u(`chat.commandAutocomplete.badge.command`),system:u(`chat.commandAutocomplete.badge.system`)}),highlightedIndex:E})},[b,c,E,u]);let de=L.useRef(c);de.current=c,L.useEffect(()=>()=>{Ce(de.current,ue)},[]),L.useImperativeHandle(l,()=>({acceptIndex:(e,n=!0)=>{let r=b[e];r&&t(r,Y(r,n))},handleKeyDown:e=>{let r=b.length;if(e===`Escape`){n();return}if(r!==0){if(e===`ArrowDown`){O.current=!0,D(e=>(e+1)%r);return}if(e===`ArrowUp`){O.current=!0,D(e=>(e-1+r)%r);return}if(e===`Enter`||e===`Tab`){let n=(oe.current%r+r)%r,i=b[n];i&&t(i,Y(i,e===`Enter`))}}}}),[b,n,t]);let fe=e=>{let t=me(e);switch(e.name){case`new`:return(0,J.jsx)(M,{name:t,className:`h-3.5 w-3.5`});case`init`:return(0,J.jsx)(M,{name:t,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,J.jsx)(M,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,J.jsx)(M,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:case`reload`:return(0,J.jsx)(M,{name:t,className:`h-3.5 w-3.5`});case`compact`:return(0,J.jsx)(M,{name:t,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,J.jsx)(M,{name:t,className:`h-3.5 w-3.5`});case`review`:return(0,J.jsx)(M,{name:t,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,J.jsx)(M,{name:t,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,J.jsx)(M,{name:t,className:`h-3.5 w-3.5 text-yellow-500`}):(0,J.jsx)(M,{name:t,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,J.jsxs)(he,{ref:k,isMobile:d,className:`max-w-[450px] max-h-64`,style:a,children:[(0,J.jsx)(ve,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 py-1.5`,children:ne?(0,J.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,J.jsx)(M,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,J.jsxs)(`div`,{children:[b.map((n,r)=>{let i=n.isBuiltIn,a=n.isYuri;return(0,J.jsxs)(`div`,{ref:e=>{ce.current[r]=e},className:S(`flex gap-2 px-2 py-2 cursor-pointer rounded-lg`,d?`items-center`:`items-start`,ge(d,r===E),!d&&r===E&&`bg-interactive-selection/35`),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(A.current={x:e.clientX,y:e.clientY},j.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!A.current)return;let t=e.clientX-A.current.x,n=e.clientY-A.current.y;Math.hypot(t,n)>6&&(j.current=!0)},onPointerUp:e=>{if(e.pointerType!==`touch`)return;let r=j.current;A.current=null,j.current=!1,!r&&(e.preventDefault(),e.stopPropagation(),le.current=!0,t(n,Y(n,d)))},onPointerCancel:()=>{A.current=null,j.current=!1},onClick:()=>{if(le.current){le.current=!1;return}t(n,Y(n,d))},onMouseMove:()=>{O.current=!1,D(r)},children:[(0,J.jsx)(`div`,{className:S(!d&&`mt-0.5`),children:fe(n)}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,Me(n.name,e)]}),n.isSkill?(0,J.jsx)(`span`,{className:Re,children:u(`chat.commandAutocomplete.badge.skill`)}):(0,J.jsx)(`span`,{className:Re,children:u(`chat.commandAutocomplete.badge.command`)}),a?(0,J.jsx)(`span`,{className:Ve,children:`Yuri`}):i?(0,J.jsx)(`span`,{className:Ve,children:u(`chat.commandAutocomplete.badge.system`)}):n.scope?(0,J.jsx)(`span`,{className:n.scope===`project`?Be:ze,children:n.scope}):null,n.agent&&(0,J.jsx)(`span`,{className:Ve,children:n.agent})]}),n.description&&!d&&(0,J.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:Me(n.description,e)})]})]},n.id)}),b.length===0&&(0,J.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.commandAutocomplete.empty`)})]})}),!d&&(0,J.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})});We.displayName=`CommandAutocomplete`;var Ge=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,Ke=1e4,qe=6e4,Je=5e3,Ye=3e4,Xe=6e4,Ze=25,Qe=40,$e=2,et=15e3,tt=500,nt=30,rt=20971520,it=new Map,at=new Map,ot=new Map,st=new Map,ct=new Map,lt=new Map,ut=new WeakMap,dt=e=>{let t=ut.get(e);return t||(t=new Set(e.files.map(e=>e.path)),ut.set(e,t)),t},ft=(e,t)=>`${t}:${e}`,pt=e=>at.get(e)??0,mt=e=>{let t=pt(e)+1;return at.set(e,t),t},ht=e=>{let t=(ot.get(e)??0)+1;return ot.set(e,t),t},gt=e=>{let t=it.get(e);if(t)return t;let n=new Set;return it.set(e,n),n},Z=()=>({isGitRepo:null,status:null,branches:null,branchesTransportIdentity:null,log:null,identity:null,diffCache:new Map,indexRevision:0,lastRepoCheckAt:0,lastStatusFetch:0,lastStatusChange:0,lastLogFetch:0,lastBranchesFetch:0,lastIdentityFetch:0,logMaxCount:25,isLoadingStatus:!1,isLoadingLog:!1,isLoadingBranches:!1,isLoadingIdentity:!1}),_t=(e,t=nt,n=rt)=>{let r=0;for(let t of e.values())r+=(t.original?.length??0)+(t.modified?.length??0);if(e.size<=t&&r<=n)return e;let i=Array.from(e.entries()).sort((e,t)=>e[1].fetchedAt-t[1].fetchedAt),a=new Map,o=0;for(let e=i.length-1;e>=0;e--){let[r,s]=i[e],c=(s.original?.length??0)+(s.modified?.length??0);if(a.size>=t)break;o+c>n&&a.size>0||(a.set(r,s),o+=c)}return a},vt=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,yt=e=>{let t=e?.trim()??``;return t===`?`?``:t},bt=(e,t)=>{let n=new Set,r=!1,i=!e;e&&(i=e.ahead!==t.ahead||e.behind!==t.behind||e.current!==t.current||e.tracking!==t.tracking||e.isClean!==t.isClean||t.upstreamComparison!==void 0&&vt(e.upstreamComparison,t.upstreamComparison)||t.diffStats!==void 0&&e.diffStats===void 0);let a=new Map;for(let t of e?.files??[])a.set(t.path,t);for(let e of t.files??[]){let t=a.get(e.path);if(!t){n.add(e.path),yt(e.index)&&(r=!0);continue}a.delete(e.path),(t.index!==e.index||t.working_dir!==e.working_dir)&&n.add(e.path),!r&&yt(t.index)!==yt(e.index)&&(r=!0)}for(let[e,t]of a)n.add(e),yt(t.index)&&(r=!0);let o=t.diffStats,s=e?.diffStats;if(o!==void 0&&o!==s){let e=s??{};for(let t in o){let r=o[t],i=e[t];(!i||i.insertions!==r.insertions||i.deletions!==r.deletions)&&n.add(t)}for(let t in e)t in o||n.add(t)}return{changed:i||n.size>0,changedPaths:n,indexChanged:r}},xt=e=>!e||e.trim().length===0,St=e=>(e||``).trim()===`U`,Ct=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(St(t)||St(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},wt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(St(t)||St(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},Tt=e=>xt(e.index)&&xt(e.working_dir),Q=o()(c((e,t)=>({directories:new Map,activeDirectory:null,setActiveDirectory:n=>{let{activeDirectory:r,directories:i}=t();if(r!==n)if(r&&mt(r),n&&mt(n),n&&!i.has(n)){let t=new Map(i);t.set(n,Z()),e({activeDirectory:n,directories:t})}else e({activeDirectory:n})},getDirectoryState:e=>t().directories.get(e)??null,fetchStatus:async(n,r,i={})=>{let a=i.mode??`full`,o=ft(n,a),s=st.get(o)??(a===`light`?st.get(ft(n,`full`)):void 0);if(s)return s;let c=(async()=>{let{silent:a=!1}=i,{directories:o}=t(),s=o.get(n);if(s||=Z(),!a){let r=new Map(t().directories),i=r.get(n)??Z();r.set(n,{...i,isLoadingStatus:!0}),e({directories:r})}let c=!1;try{let a=Date.now(),o=s.isGitRepo!==!0||a-(s.lastRepoCheckAt||0)>qe,l=s.isGitRepo===!0;if(o&&(l=await r.checkIsGitRepository(n)),!l){let r=new Map(t().directories),i=r.get(n)??s;return r.set(n,{...i,isGitRepo:!1,status:null,isLoadingStatus:!1,lastRepoCheckAt:a,lastStatusFetch:a}),e({directories:r}),!1}let u=await r.getGitStatus(n,i.mode?{mode:i.mode}:void 0),d=t().directories.get(n)??Z(),f=lt.get(n),p=f?.received===u&&f.stored===d.status?null:bt(d.status,u);if(p?.changed){c=!0;let r=new Map(t().directories),i=r.get(n)??Z(),{changedPaths:s,indexChanged:l}=p,d=new Map(i.diffCache);for(let e of s)d.delete(e);let f=s.size>0;f&&mt(n);let m={...u,diffStats:u.diffStats===void 0&&i.status?.diffStats!==void 0?i.status.diffStats:u.diffStats,upstreamComparison:u.upstreamComparison===void 0?i.status?.upstreamComparison:u.upstreamComparison};r.set(n,{...i,isGitRepo:!0,status:m,diffCache:d,indexRevision:l?i.indexRevision+1:i.indexRevision,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:f?Date.now():i.lastStatusChange}),e({directories:r}),lt.set(n,{received:u,stored:m})}else{lt.set(n,{received:u,stored:d.status});let r=new Map(t().directories),i=r.get(n)??Z();r.set(n,{...i,isGitRepo:!0,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:i.lastStatusChange}),e({directories:r})}}catch(e){console.error(`Failed to fetch git status:`,e)}finally{if(!a){let r=new Map(t().directories),i=r.get(n)??Z();r.set(n,{...i,isLoadingStatus:!1}),e({directories:r})}}return c})();st.set(o,c);try{return await c}finally{st.get(o)===c&&st.delete(o)}},moveStatusPathsOptimistically:(n,r,i)=>{let a=new Set(r.map(e=>e.trim()).filter(Boolean));if(a.size===0)return null;let{directories:o}=t(),s=o.get(n),c=s?.status??null;if(!s||!c)return c;let l=!1,u=[];for(let e of c.files){if(!a.has(e.path)){u.push(e);continue}let t=i===`stage`?Ct(e):wt(e);t!==e&&(l=!0),Tt(t)?l=!0:u.push(t)}if(!l)return c;let d=new Map(o);return d.set(n,{...s,status:{...c,files:u,isClean:u.length===0},indexRevision:s.indexRevision+1,lastStatusChange:Date.now()}),e({directories:d}),c},restoreStatus:(n,r)=>{let{directories:i}=t(),a=i.get(n);if(!a)return;let o=new Map(i);o.set(n,{...a,status:r,indexRevision:a.indexRevision+1,lastStatusChange:Date.now()}),e({directories:o})},bumpIndexRevision:n=>{let{directories:r}=t(),i=r.get(n);if(!i)return;let a=new Map(r);a.set(n,{...i,indexRevision:i.indexRevision+1}),e({directories:a})},fetchBranches:async(r,i,a={})=>{let o=n(),s=ht(r);{let n=new Map(t().directories),i=n.get(r)??Z();n.set(r,{...i,isLoadingBranches:!0}),e({directories:n})}try{let c=a.force?await C(r,i,void 0,o):await b(r,i,void 0,o);if(s!==ot.get(r)||o!==n())return;let l=new Map(t().directories),u=l.get(r)??Z();l.set(r,{...u,branches:c,branchesTransportIdentity:o,isLoadingBranches:!1,lastBranchesFetch:Date.now()}),e({directories:l})}catch(i){if(Ge(i)||console.error(`Failed to fetch git branches:`,i),s!==ot.get(r)||o!==n())return;let a=new Map(t().directories),c=a.get(r)??Z();a.set(r,{...c,isLoadingBranches:!1}),e({directories:a})}},fetchLog:async(n,r,i)=>{let{directories:a}=t(),o=a.get(n),s=i??o?.logMaxCount??25;{let r=new Map(t().directories),i=r.get(n)??Z();r.set(n,{...i,isLoadingLog:!0}),e({directories:r})}try{let i=await r.getGitLog(n,{maxCount:s}),a=new Map(t().directories),o=a.get(n)??Z();a.set(n,{...o,log:i,isLoadingLog:!1,lastLogFetch:Date.now(),logMaxCount:s}),e({directories:a})}catch(r){console.error(`Failed to fetch git log:`,r);let i=new Map(t().directories),a=i.get(n)??Z();i.set(n,{...a,isLoadingLog:!1}),e({directories:i})}},fetchIdentity:async(n,r)=>{{let r=new Map(t().directories),i=r.get(n)??Z();r.set(n,{...i,isLoadingIdentity:!0}),e({directories:r})}try{let i=await r.getCurrentGitIdentity(n),a=new Map(t().directories),o=a.get(n)??Z();a.set(n,{...o,identity:i,isLoadingIdentity:!1,lastIdentityFetch:Date.now()}),e({directories:a})}catch(r){console.error(`Failed to fetch git identity:`,r);let i=new Map(t().directories),a=i.get(n)??Z();i.set(n,{...a,isLoadingIdentity:!1}),e({directories:i})}},fetchAll:async(n,r,i={})=>{let{directories:a}=t(),o=a.get(n);if(!o){o=Z();let t=new Map(a);t.set(n,o),e({directories:t})}let{force:s=!1,silentIfCached:c=!1}=i,l=Date.now();await t().fetchStatus(n,r,{silent:c&&!!o?.status});let u=t().directories.get(n);if(!u?.isGitRepo)return;await t().fetchBranches(n,r,{force:s});let d=l-(u.lastLogFetch||0);(s||d>Ke||!u.log)&&await t().fetchLog(n,r),await t().fetchIdentity(n,r)},getDiff:(e,n)=>t().directories.get(e)?.diffCache.get(n)??null,setDiff:(n,r,i)=>{let a=new Map(t().directories),o=a.get(n)??Z(),s=new Map(o.diffCache);s.set(r,{...i,fetchedAt:Date.now()});let c=_t(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{mt(n);let r=new Map(t().directories),i=r.get(n);i&&(r.set(n,{...i,diffCache:new Map}),e({directories:r}))},fetchAllDiffs:async(e,n)=>{let r=t().directories.get(e);if(!r?.status?.files||r.status.files.length===0)return;let i=r.status.files.map(e=>e.path).slice(0,Ze);await t().prefetchDiffs(e,n,i,{maxFiles:Ze})},prefetchDiffs:async(n,r,i,a={})=>{let o=t().directories.get(n);if(!o?.status?.files||o.status.files.length===0||i.length===0)return;let{maxFiles:s=Qe}=a,c=Math.min(Math.max(1,s),nt),l=dt(o.status),u=o.status.diffStats,d=gt(n),f=[],p=new Set;for(let e of i){if(p.size>=c)break;if(!e||p.has(e)||!l.has(e))continue;let t=u?.[e];t&&t.insertions+t.deletions>tt||(p.add(e),!o.diffCache.has(e)&&(d.has(e)||f.push(e)))}let m=f;if(m.length===0)return;let h=pt(n);if(typeof document<`u`&&document.hidden)return;m.forEach(e=>d.add(e));let g=0,_=[],ee=()=>{let e=g;return g+=1,e<m.length?m[e]:null},te=async e=>{let t=r.getGitFileDiff(n,{path:e}),i=new Promise((e,t)=>{setTimeout(()=>t(Error(`Timed out after ${et}ms`)),et)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},v=async()=>{for(;;){if(h!==pt(n))return;let e=ee();if(!e)return;try{_.push(await te(e))}catch{}finally{d.delete(e)}}},y=Math.min($e,m.length);if(await Promise.allSettled(Array.from({length:y},()=>v())),m.forEach(e=>d.delete(e)),h!==pt(n))return;let b=new Map(t().directories),x=b.get(n);if(!x)return;let S=new Map(x.diffCache),ne=Date.now();_.forEach(e=>{!e.diff.isBinary&&e.diff.original===``&&e.diff.modified===``||S.set(e.path,{...e.diff,fetchedAt:ne})});let C=_t(S);b.set(n,{...x,diffCache:C}),e({directories:b})},setLogMaxCount:(n,r)=>{let i=new Map(t().directories),a=i.get(n)??Z();i.set(n,{...a,logMaxCount:r}),e({directories:i})},ensureStatus:async(e,n)=>{let r=t().directories.get(e),i=Date.now();r?.status&&i-r.lastStatusFetch<Je||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=ct.get(e);if(r)return r;let i=(async()=>{let r=t().directories.get(e),i=Date.now();(!r?.status||r.status.diffStats===void 0||i-(r?.lastStatusFetch??0)>=Je)&&await t().fetchStatus(e,n,{silent:!!r?.status});let a=t().directories.get(e);if(!a?.isGitRepo)return;let o=[];(!a.branches||i-a.lastBranchesFetch>=Ye)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=Ke)&&o.push(t().fetchLog(e,n)),(!a.identity||i-a.lastIdentityFetch>=Xe)&&o.push(t().fetchIdentity(e,n)),o.length>0&&await Promise.all(o)})();return ct.set(e,i),i.finally(()=>{ct.get(e)===i&&ct.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),Et=e=>{let t=(0,W.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status??null:null,t[0]=e,t[1]=n),Q(n)},Dt=e=>{let r=(0,W.c)(3),i=L.useSyncExternalStore(t,n,n),a;return r[0]!==e||r[1]!==i?(a=t=>{if(!e)return null;let n=t.directories.get(e);return n?.branchesTransportIdentity===i?n.branches:null},r[0]=e,r[1]=i,r[2]=a):a=r[2],Q(a)},Ot=e=>{let t=(0,W.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isGitRepo??null:null,t[0]=e,t[1]=n),Q(n)},kt=e=>{let t=(0,W.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status?.current?.trim()??null:null,t[0]=e,t[1]=n),Q(n)},At=e=>{let t=(0,W.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=L.useRef(n),i;return t[1]===e?i=t[2]:(i=t=>{let n=r.current,i=n.size===e.length;if(i)for(let r of e){let e=t.directories.get(r),a=n.get(r);if(!a||(e?.isGitRepo??null)!==a.isGitRepo||(e?.status?.current??null)!==a.branch){i=!1;break}}if(i)return n;let a=new Map;for(let n of e){let e=t.directories.get(n);a.set(n,{isGitRepo:e?.isGitRepo??null,branch:e?.status?.current??null})}return r.current=a,a},t[1]=e,t[2]=i),Q(i)},jt=e=>{let t=(0,W.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingStatus??!1:!1,t[0]=e,t[1]=n),Q(n)},Mt=e=>{let t=(0,W.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingBranches??!1:!1,t[0]=e,t[1]=n),Q(n)},Nt=e=>{let t=String(e||``).trim().replace(/^remotes\//,``);if(!t)return null;let n=t.indexOf(`/`);return n<=0||n>=t.length-1?null:{remote:t.slice(0,n),branch:t.slice(n+1)}},$=e=>String(e||``).trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/^remotes\//,``),Pt=e=>e.branchName?$(e.branchName):e.mode===`existing`?$(e.existingBranch||e.preferredName||``):$(e.preferredName||``),Ft=async e=>{let t=await ye(e);try{let n=Nt((await fe(e)).branches?.[t]?.tracking||null);if(n?.remote)return n.remote}catch{}try{let t=Nt((await de(e)).tracking);if(t?.remote)return t.remote}catch{}return null},It=async(e,t)=>{let n=await Ft(e),r=$(t);return!n||!r?null:{setUpstream:!0,upstreamRemote:n,upstreamBranch:r}},Lt=async(e,t,n)=>{let r=Pt(t),i=n?.resolvedRootTrackingRemote,a=i===void 0?await It(e,r):i&&$(r)?{setUpstream:!0,upstreamRemote:i,upstreamBranch:$(r)}:null;return a?{...t,setUpstream:t.setUpstream??a.setUpstream,upstreamRemote:t.upstreamRemote||a.upstreamRemote,upstreamBranch:t.upstreamBranch||a.upstreamBranch}:t},Rt=async(e,t,n)=>{let r=await Lt(e.path,t,n);return be(e,r)},zt=`yuri:lastWorktreeSourceBranch`,Bt=({mode:e,sourceBranch:t,linkedPr:n,selectedBranch:r})=>e===`existing-branch`?r||null:n?null:t||null,Vt=({branches:e,savedSourceBranch:t,rootBranch:n})=>t&&e.includes(t)&&t?{sourceBranch:t,shouldClearSavedSourceBranch:!1}:{sourceBranch:n&&e.includes(n)?n:e.includes(`main`)?`main`:e.includes(`master`)?`master`:e[0]??``,shouldClearSavedSourceBranch:!!t},Ht=(e,t,n)=>{if(!e)return e;let r=t.length>0&&!/\s$/.test(t)&&!/^\s/.test(e)&&!/[([{]$/.test(t),i=n.length>0&&!/\s$/.test(e)&&!/^\s/.test(n)&&!/^[\])}.,;:!?]/.test(n);return`${r?` `:``}${e}${i?` `:``}`},Ut=(e,t,n)=>{let r=Ht(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},Wt=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=Ut(r,i,a),s=Math.max(0,o.indexOf(r)),c=i.length+s;return{text:`${i}${o}${a}`,caret:i.length+o.length,start:c,end:c+r.length}},Gt=(e,t)=>{let n=e=>`${e.kind}:${e.value}:${e.range.start}:${e.range.end}`;return new Set(e.map(n)).has(n(t))||e.some(e=>e.range.start<t.range.end&&t.range.start<e.range.end)?[...e]:[...e,t]},Kt=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{De as C,xe as E,Ne as S,Te as T,Q as _,zt as a,Le as b,Rt as c,kt as d,Dt as f,Et as g,At as h,Ut as i,Ft as l,jt as m,Gt as n,Vt as o,Mt as p,Wt as r,Bt as s,Kt as t,Lt as u,Ot as v,Ee as w,Fe as x,We as y};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-workbox-window-15MWHJyx.js","assets/rolldown-runtime-hePW80VL.js","assets/renderMobileApp-BQFC-gOA.js","assets/runtime-auth-mjIpsk3N.js","assets/runtime-switch-BMjl5Y5W.js","assets/runtime-fetch-DKZOpfzo.js","assets/reasoning-projection-client-BEhVknv9.js","assets/platform-wF65ZFgV.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-zustand-Cwko4FG1.js","assets/vendor-base-ui-z2M4boRm.js","assets/gitApiHttp-DvTBxvX8.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/safeStorage-DTOhKN0V.js","assets/client-uz8O6TPX.js","assets/vendor-opencode-client-cQ47ywrT.js","assets/vendor-effect-X1Hqc7ba.js","assets/prompt-attachment-upload-BNhDXymd.js","assets/runtime-file-resource-CuLP3xp7.js","assets/vendor-react-P8wFrkcT.js","assets/vendor-tanstack-query-core-BSjXNgF_.js","assets/vendor-tanstack-react-query-B-KblYBV.js","assets/path-utils-jGozTg9d.js","assets/vendor-reactuses-core-Dyjw5sZR.js","assets/vendor-lodash-es-BS45jPoZ.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/runtime-file-store-BVRgEtI-.js","assets/useUIStore-Cfmg-aDQ.js","assets/useMobileHtmlPreviewStore-EOAzZiAy.js","assets/uuid-D-SDZijH.js","assets/capgoAdapter-CCLtBZL1.js","assets/types-CHszLAS3.js","assets/vendor-pierre-diffs-tqo4Z3TC.js","assets/vendor-hast-util-to-html-Bw_SgZ1t.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-BMOrLc9L.js","assets/vendor-sonner-B5HgJenP.js","assets/i18n-RH7UieOS.js","assets/runtime-ead7P81A.js","assets/bootstrap-eLlfzqAI.js","assets/store-DunGyOfe.js","assets/tour-CQMBn8gJ.js","assets/mobileConnections-C3eGEOPy.js","assets/MobileDetailNavigation-xgwvsQuR.js","assets/useMobileNavigationStore-BNtVrnSw.js","assets/useAssistantUIStore-jOKVcBK8.js","assets/input-store-CjUOfpyA.js","assets/remoteProjectQueries-CkxdZNw4.js","assets/vendor-zod-DZzbCm1s.js","assets/vendor-opencode-schema-DWT45VBX.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/Icon-DizeYahT.js","assets/MobileShareBridge-IO45gM2G.js","assets/AgentAvatar-B7KbxN8Y.js","assets/agentColors-DWSbQXy2.js","assets/vendor-dicebear-core-CV95S5Pg.js","assets/vendor-dicebear-styles-C4OfoX7R.js","assets/dualLimitLru-D8Sphgua.js","assets/useThemeSystem-C57Z9mV2.js","assets/vendor-framer-motion-CF9BQLta.js","assets/dialog-Bg8MJnOV.js","assets/dialog-CTYD3Sbr.css","assets/rasterizePng-056Poix7.js","assets/useAppFontEffects-CqXrCJVt.js","assets/desktopHosts-135cuRCE.js","assets/desktopRelayRestore-1aUztDPU.js","assets/fileMentionAutocompleteState-BZJqfgae.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/vendor-fuzzysort-ukaRp9PC.js","assets/gitApi-DVx_V1x6.js","assets/vendor-simplewebauthn-browser-Dwhcdg_5.js","assets/checkbox-rOV6DjeG.js","assets/input-DRjuZMeA.js","assets/tooltip-D382RCy1.js","assets/pwa-CXupOTsD.js","assets/MobileResizableSheet-CQQ7O-2X.js","assets/MobileWindowStack-DGLdgoGr.js","assets/select-B1On-Y4Z.js","assets/device-QL8KNSLM.js","assets/textarea-Qt06OhhX.js","assets/OverlayScrollbar-jtMYTn1y.js","assets/dropdown-menu.styles-BDla58Rm.js","assets/projectMeta-D1Ytss9U.js","assets/vendor-dnd-kit-core-Dd5yS2-T.js","assets/vendor-dnd-kit-accessibility-gVi9ga0x.js","assets/vendor-dnd-kit-sortable-CV-SGi8y.js","assets/vendor-tanstack-react-virtual-BkuqzrEV.js","assets/YuriLogo-CvyJy_R9.js","assets/react-CgRToPwO.js","assets/themes-BgDJcxRc.js","assets/scheduledTaskNavigation-BIDtQ4wN.js","assets/theme-validation-BGYdrOu7.js","assets/MarkdownRenderer-D_0iKhQN.js","assets/useEffectiveDirectory-CCKRdyK9.js","assets/markdownHeightCache-BL99DlhC.js","assets/sessionLookup-RcyTTDOy.js","assets/useDictation-Bs7TWO9r.js","assets/LoadingImage-Csw4L-Dr.js","assets/ImageLoadingPlaceholder-BZC5m_km.js","assets/image-loading-DBqnxgDH.js","assets/image-loading-DA9JEHD8.css","assets/sessionLookup-8C8nv-EP.css","assets/fileMentionTouchSelection-D-AdTJVr.js","assets/insertionBoundaries-DZtQt2Ah.js","assets/mobileBackNavigation--ZdrI-Yj.js","assets/queue-abort-optimistic-CQXpIlq6.js","assets/toolHelpers-iEHVHQ9p.js","assets/FadeInOnReveal-DMRmNsau.js","assets/ToolOutputDialog-5xBwOJ6a.js","assets/runtime-file-download-D11Nnedg.js","assets/tap-LkQum5bB.js","assets/markdownTheme-DFDWa8Gh.js","assets/markdown-worker-oBGEB9Eg.js","assets/remote-input-store-BOdCWpQY.js","assets/vendor-cmdk-BgHvMv5l.js","assets/vendor-aria-hidden-BbL3cEyI.js","assets/vendor-motion-Dv27UnOI.js","assets/useProjectRuntimeAPIs-BFCXBu2J.js","assets/terminalApi-madXrfqA.js","assets/sortable-tabs-strip-nD1Me06z.js","assets/speechSettingsQueries-BYhNpzDJ.js","assets/vendor-marked-S3gCOYp1.js","assets/useStreamingTextThrottle-C8xAqcgP.js","assets/useFontPreferences-CPrl1_3z.js","assets/useAppFontEffects-K31q-1OV.css","assets/MobileSurface-DmYgZONB.js","assets/vendor-codemirror-autocomplete-C0FrlFqZ.js","assets/vendor-codemirror-lang-angular-Cm7vBE3E.js","assets/vendor-codemirror-lang-json-DowyFczU.js","assets/vendor-codemirror-lang-markdown-npWBZIoE.js","assets/vendor-codemirror-lang-python-OPRdU26g.js","assets/vendor-codemirror-legacy-modes-DwltVFbT.js","assets/mcpQueries-HzYMEVWd.js","assets/usePluginsStore-bMuGciUE.js","assets/collapsible-CKswuqAw.js","assets/vendor-codemirror-commands-5saeUOVY.js","assets/vendor-codemirror-search-hZY-L2l8.js","assets/vendor-replit-codemirror-vim-BmQmU1lR.js","assets/vendor-codemirror-language-data-B3pLWvv-.js","assets/AssistantConversationSurface-BnK_KTBO.js","assets/assistant-attachment-cache-D-LmCflm.js","assets/AssistantConversationSurface-n9w_Av0k.css","assets/runtimeEndpointReset-BhHWFNvo.js","assets/YuriWordmark-DnFAS-Ko.js","assets/readiness-BfuZm6Yw.js","assets/relay-preview-frame-src-BPyz3nXA.js","assets/AssistantUnreadBadge-vu4ZhTft.js","assets/context-menu-B4njwT_M.js","assets/native-errors-06if6eu-.js","assets/appearance-DFsI3pnP.js","assets/navigation-Ibk_Pw-q.js","assets/vendor-cron-parser-BmO80h0C.js","assets/runtimeEndpointReset-BUGfn7y0.css","assets/SettingsView-ZWFLpPSI.js","assets/native-config-DOawZfln.js","assets/vendor-qrcode-D7jBCyl-.js","assets/vendor-dijkstrajs-BAzPDGZM.js","assets/VoiceSettings-CN33koSc.js","assets/VoiceSettings-C0HSdVvS.css","assets/GuiPluginWindow-tHXkS18H.js","assets/vendor-yaml-C9KlJAlj.js","assets/project-preview-2H-TmJkd.js","assets/AssistantView-CEfEWUIr.js","assets/renderMobileApp-1G4-5u-t.css","assets/src-BZCFf9_1.css","assets/main-D2s9J_jN.js","assets/useDesktopWindowControlsLayout-KH4UP7Gj.js","assets/GuiPluginPage-DVug4z_p.js","assets/pages-CYkE04ml.js","assets/historyImportQueries-D_9RlrLp.js","assets/diagram-BppQ_USn.js","assets/vendor-react-drawio-CQW1YP2l.js","assets/multirun-CDYNyLBH.js","assets/projectActions-50e_f9dI.js","assets/vendor-zumer-snapdom-yq9vlCKr.js","assets/vendor-html-to-image-BDMm2v6d.js","assets/main-qSeeJRW1.css"])))=>i.map(i=>d[i]);
2
- import"./modulepreload-polyfill-P2Xu9kJm.js";import{o as e}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{n as t,t as n}from"./runtimeConfig-tHm7o_0I.js";/* empty css */var r=`true`,i=`false`,a=r===`true`,o=i===`true`;function s(t={}){let{immediate:n=!1,onNeedReload:r,onNeedRefresh:i,onOfflineReady:s,onRegistered:c,onRegisteredSW:l,onRegisterError:u}=t,d,f,p,m=async(e=!0)=>{await f,a||p?.()};async function h(){if(`serviceWorker`in navigator){if(d=await e(async()=>{let{Workbox:e}=await import(`./vendor-workbox-window-15MWHJyx.js`).then(e=>e.t);return{Workbox:e}},__vite__mapDeps([0,1])).then(({Workbox:e})=>new e(`/sw.js`,{scope:`/`,type:`classic`})).catch(e=>{u?.(e)}),!d)return;if(p=()=>{d?.messageSkipWaiting()},!o)if(a)d.addEventListener(`activated`,e=>{(e.isUpdate||e.isExternal)&&(r?r():window.location.reload())}),d.addEventListener(`installed`,e=>{e.isUpdate||s?.()});else{let e=!1,t=()=>{e=!0,d?.addEventListener(`controlling`,e=>{e.isUpdate&&(r?r():window.location.reload())}),i?.()};d.addEventListener(`installed`,n=>{n.isUpdate===void 0?n.isExternal===void 0?!e&&s?.():n.isExternal?t():!e&&s?.():n.isUpdate||s?.()}),d.addEventListener(`waiting`,t)}d.register({immediate:n}).then(e=>{l?l(`/sw.js`,e):c?.(e)}).catch(e=>{u?.(e)})}}return f=h(),m}window.__YURI_RUNTIME_APIS__=n();var c=()=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(pointer: coarse)`).matches,l=(()=>{let e=new URLSearchParams(window.location.search).get(`surface`);if(e===`mobile`)return`mobile`;if(e===`desktop`)return`desktop`;let t=Math.min(window.innerWidth||0,window.screen?.width||window.innerWidth||0),n=navigator.maxTouchPoints||0;return t>0&&t<=760&&(n>0||c())?`mobile`:`desktop`})();window.__YURI_SURFACE__=l;var u=()=>!(!(`serviceWorker`in navigator)||!window.isSecureContext||window.location.protocol!==`http:`&&window.location.protocol!==`https:`||document.prerendering||String(document.visibilityState)===`prerender`),d=e=>{let t=!1,n=()=>{t||u()&&(t=!0,e())},r=()=>{setTimeout(n,0)};document.readyState===`complete`?r():window.addEventListener(`load`,r,{once:!0}),(document.prerendering||String(document.visibilityState)===`prerender`)&&document.addEventListener(`visibilitychange`,n,{once:!0})},f=()=>{d(()=>{try{s({onRegisterError(e){console.warn(`[PWA] service worker registration skipped:`,e)}})}catch(e){console.warn(`[PWA] service worker registration skipped:`,e)}})},p=`yuri.dev.module-reload`,m=(e,t)=>{console.error(`[yuri] failed to load ${t}:`,e)};l===`mobile`?e(async()=>{let{renderMobileApp:e}=await import(`./renderMobileApp-BQFC-gOA.js`);return{renderMobileApp:e}},__vite__mapDeps([2,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174])).then(({renderMobileApp:e})=>{try{sessionStorage.removeItem(p)}catch{}e(window.__YURI_RUNTIME_APIS__??n())}).catch(e=>m(e,`renderMobileApp`)):t().then(()=>e(()=>import(`./main-D2s9J_jN.js`),__vite__mapDeps([175,1,3,4,5,6,7,8,9,74,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,128,34,48,47,136,35,36,37,38,39,40,41,42,43,44,46,49,50,52,53,45,54,55,56,57,58,59,60,61,68,69,70,71,79,73,75,76,77,78,64,67,63,65,66,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,72,115,116,117,118,119,120,121,122,123,124,125,126,127,129,130,131,132,133,134,135,137,138,139,140,141,142,143,144,145,146,147,148,176,152,153,154,155,156,157,158,159,160,161,162,177,178,179,180,181,182,183,184,185,186,174]))).then(()=>{try{sessionStorage.removeItem(p)}catch{}}).catch(e=>m(e,`desktop main`)),f();
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/renderElectronMiniChatApp-pJ59iC34.js","assets/rolldown-runtime-hePW80VL.js","assets/platform-wF65ZFgV.js","assets/runtime-auth-mjIpsk3N.js","assets/runtime-switch-BMjl5Y5W.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-base-ui-z2M4boRm.js","assets/gitApiHttp-DvTBxvX8.js","assets/runtime-fetch-DKZOpfzo.js","assets/reasoning-projection-client-BEhVknv9.js","assets/vendor-zustand-Cwko4FG1.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/safeStorage-DTOhKN0V.js","assets/client-uz8O6TPX.js","assets/vendor-opencode-client-cQ47ywrT.js","assets/vendor-effect-X1Hqc7ba.js","assets/prompt-attachment-upload-BNhDXymd.js","assets/runtime-file-resource-CuLP3xp7.js","assets/vendor-react-P8wFrkcT.js","assets/vendor-tanstack-query-core-BSjXNgF_.js","assets/vendor-tanstack-react-query-B-KblYBV.js","assets/path-utils-jGozTg9d.js","assets/vendor-reactuses-core-Dyjw5sZR.js","assets/vendor-lodash-es-BS45jPoZ.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/runtime-file-store-BVRgEtI-.js","assets/useUIStore-Cfmg-aDQ.js","assets/useMobileHtmlPreviewStore-EOAzZiAy.js","assets/uuid-D-SDZijH.js","assets/vendor-sonner-B5HgJenP.js","assets/i18n-RH7UieOS.js","assets/runtime-ead7P81A.js","assets/bootstrap-eLlfzqAI.js","assets/store-DunGyOfe.js","assets/tour-CQMBn8gJ.js","assets/MobileDetailNavigation-xgwvsQuR.js","assets/useMobileNavigationStore-BNtVrnSw.js","assets/useAssistantUIStore-jOKVcBK8.js","assets/input-store-CjUOfpyA.js","assets/remoteProjectQueries-CkxdZNw4.js","assets/vendor-zod-DZzbCm1s.js","assets/vendor-opencode-schema-DWT45VBX.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/Icon-DizeYahT.js","assets/MobileShareBridge-IO45gM2G.js","assets/mobileConnections-C3eGEOPy.js","assets/AgentAvatar-B7KbxN8Y.js","assets/agentColors-DWSbQXy2.js","assets/vendor-dicebear-core-CV95S5Pg.js","assets/vendor-dicebear-styles-C4OfoX7R.js","assets/dualLimitLru-D8Sphgua.js","assets/useThemeSystem-C57Z9mV2.js","assets/vendor-framer-motion-CF9BQLta.js","assets/dialog-Bg8MJnOV.js","assets/dialog-CTYD3Sbr.css","assets/rasterizePng-056Poix7.js","assets/useAppFontEffects-CqXrCJVt.js","assets/desktopHosts-135cuRCE.js","assets/desktopRelayRestore-1aUztDPU.js","assets/vendor-pierre-diffs-tqo4Z3TC.js","assets/vendor-hast-util-to-html-Bw_SgZ1t.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-BMOrLc9L.js","assets/fileMentionAutocompleteState-BZJqfgae.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/vendor-fuzzysort-ukaRp9PC.js","assets/gitApi-DVx_V1x6.js","assets/vendor-simplewebauthn-browser-Dwhcdg_5.js","assets/checkbox-rOV6DjeG.js","assets/input-DRjuZMeA.js","assets/tooltip-D382RCy1.js","assets/pwa-CXupOTsD.js","assets/MobileResizableSheet-CQQ7O-2X.js","assets/MobileWindowStack-DGLdgoGr.js","assets/select-B1On-Y4Z.js","assets/device-QL8KNSLM.js","assets/textarea-Qt06OhhX.js","assets/OverlayScrollbar-jtMYTn1y.js","assets/dropdown-menu.styles-BDla58Rm.js","assets/projectMeta-D1Ytss9U.js","assets/vendor-dnd-kit-core-Dd5yS2-T.js","assets/vendor-dnd-kit-accessibility-gVi9ga0x.js","assets/vendor-dnd-kit-sortable-CV-SGi8y.js","assets/vendor-tanstack-react-virtual-BkuqzrEV.js","assets/YuriLogo-CvyJy_R9.js","assets/react-CgRToPwO.js","assets/themes-BgDJcxRc.js","assets/scheduledTaskNavigation-BIDtQ4wN.js","assets/theme-validation-BGYdrOu7.js","assets/MarkdownRenderer-D_0iKhQN.js","assets/useEffectiveDirectory-CCKRdyK9.js","assets/markdownHeightCache-BL99DlhC.js","assets/sessionLookup-RcyTTDOy.js","assets/useDictation-Bs7TWO9r.js","assets/LoadingImage-Csw4L-Dr.js","assets/ImageLoadingPlaceholder-BZC5m_km.js","assets/image-loading-DBqnxgDH.js","assets/image-loading-DA9JEHD8.css","assets/sessionLookup-8C8nv-EP.css","assets/fileMentionTouchSelection-D-AdTJVr.js","assets/insertionBoundaries-DZtQt2Ah.js","assets/mobileBackNavigation--ZdrI-Yj.js","assets/queue-abort-optimistic-CQXpIlq6.js","assets/toolHelpers-iEHVHQ9p.js","assets/FadeInOnReveal-DMRmNsau.js","assets/ToolOutputDialog-5xBwOJ6a.js","assets/runtime-file-download-D11Nnedg.js","assets/tap-LkQum5bB.js","assets/markdownTheme-DFDWa8Gh.js","assets/markdown-worker-oBGEB9Eg.js","assets/remote-input-store-BOdCWpQY.js","assets/vendor-cmdk-BgHvMv5l.js","assets/vendor-aria-hidden-BbL3cEyI.js","assets/vendor-motion-Dv27UnOI.js","assets/useProjectRuntimeAPIs-BFCXBu2J.js","assets/terminalApi-madXrfqA.js","assets/sortable-tabs-strip-nD1Me06z.js","assets/speechSettingsQueries-BYhNpzDJ.js","assets/vendor-marked-S3gCOYp1.js","assets/useStreamingTextThrottle-C8xAqcgP.js","assets/useFontPreferences-CPrl1_3z.js","assets/useAppFontEffects-K31q-1OV.css","assets/useDesktopWindowControlsLayout-KH4UP7Gj.js","assets/AssistantConversationSurface-BnK_KTBO.js","assets/assistant-attachment-cache-D-LmCflm.js","assets/AssistantConversationSurface-n9w_Av0k.css","assets/src-BZCFf9_1.css"])))=>i.map(i=>d[i]);
2
- import"./modulepreload-polyfill-P2Xu9kJm.js";import{o as e}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{t}from"./runtimeConfig-tHm7o_0I.js";/* empty css */window.__YURI_RUNTIME_APIS__=t(),e(async()=>{let{renderElectronMiniChatApp:e}=await import(`./renderElectronMiniChatApp-pJ59iC34.js`);return{renderElectronMiniChatApp:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136])).then(({renderElectronMiniChatApp:e})=>{e(window.__YURI_RUNTIME_APIS__??t())});
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/runtimeConfig-tHm7o_0I.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-auth-mjIpsk3N.js","assets/runtime-switch-BMjl5Y5W.js","assets/runtime-fetch-DKZOpfzo.js","assets/reasoning-projection-client-BEhVknv9.js","assets/platform-wF65ZFgV.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/vendor-pathe-vBmvQE8f.js","assets/desktopRelayRestore-1aUztDPU.js","assets/desktopHosts-135cuRCE.js","assets/gitApiHttp-DvTBxvX8.js","assets/vendor-zustand-Cwko4FG1.js","assets/vendor-base-ui-z2M4boRm.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/safeStorage-DTOhKN0V.js","assets/client-uz8O6TPX.js","assets/vendor-opencode-client-cQ47ywrT.js","assets/vendor-effect-X1Hqc7ba.js","assets/prompt-attachment-upload-BNhDXymd.js","assets/runtime-file-resource-CuLP3xp7.js","assets/vendor-react-P8wFrkcT.js","assets/vendor-tanstack-query-core-BSjXNgF_.js","assets/vendor-tanstack-react-query-B-KblYBV.js","assets/path-utils-jGozTg9d.js","assets/vendor-reactuses-core-Dyjw5sZR.js","assets/vendor-lodash-es-BS45jPoZ.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/runtime-file-store-BVRgEtI-.js","assets/useUIStore-Cfmg-aDQ.js","assets/useMobileHtmlPreviewStore-EOAzZiAy.js","assets/uuid-D-SDZijH.js","assets/terminalApi-madXrfqA.js","assets/runtime-file-download-D11Nnedg.js","assets/types-CHszLAS3.js","assets/capgoAdapter-CCLtBZL1.js","assets/native-config-DOawZfln.js","assets/bootstrap-eLlfzqAI.js","assets/runtime-ead7P81A.js","assets/renderMobileApp-BQFC-gOA.js","assets/vendor-pierre-diffs-tqo4Z3TC.js","assets/vendor-hast-util-to-html-Bw_SgZ1t.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-BMOrLc9L.js","assets/vendor-sonner-B5HgJenP.js","assets/i18n-RH7UieOS.js","assets/store-DunGyOfe.js","assets/tour-CQMBn8gJ.js","assets/mobileConnections-C3eGEOPy.js","assets/MobileDetailNavigation-xgwvsQuR.js","assets/useMobileNavigationStore-BNtVrnSw.js","assets/useAssistantUIStore-jOKVcBK8.js","assets/input-store-CjUOfpyA.js","assets/remoteProjectQueries-CkxdZNw4.js","assets/vendor-zod-DZzbCm1s.js","assets/vendor-opencode-schema-DWT45VBX.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/Icon-DizeYahT.js","assets/MobileShareBridge-IO45gM2G.js","assets/AgentAvatar-B7KbxN8Y.js","assets/agentColors-DWSbQXy2.js","assets/vendor-dicebear-core-CV95S5Pg.js","assets/vendor-dicebear-styles-C4OfoX7R.js","assets/dualLimitLru-D8Sphgua.js","assets/useThemeSystem-C57Z9mV2.js","assets/vendor-framer-motion-CF9BQLta.js","assets/dialog-Bg8MJnOV.js","assets/dialog-CTYD3Sbr.css","assets/rasterizePng-056Poix7.js","assets/useAppFontEffects-CqXrCJVt.js","assets/fileMentionAutocompleteState-BZJqfgae.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/vendor-fuzzysort-ukaRp9PC.js","assets/gitApi-DVx_V1x6.js","assets/vendor-simplewebauthn-browser-Dwhcdg_5.js","assets/checkbox-rOV6DjeG.js","assets/input-DRjuZMeA.js","assets/tooltip-D382RCy1.js","assets/pwa-CXupOTsD.js","assets/MobileResizableSheet-CQQ7O-2X.js","assets/MobileWindowStack-DGLdgoGr.js","assets/select-B1On-Y4Z.js","assets/device-QL8KNSLM.js","assets/textarea-Qt06OhhX.js","assets/OverlayScrollbar-jtMYTn1y.js","assets/dropdown-menu.styles-BDla58Rm.js","assets/projectMeta-D1Ytss9U.js","assets/vendor-dnd-kit-core-Dd5yS2-T.js","assets/vendor-dnd-kit-accessibility-gVi9ga0x.js","assets/vendor-dnd-kit-sortable-CV-SGi8y.js","assets/vendor-tanstack-react-virtual-BkuqzrEV.js","assets/YuriLogo-CvyJy_R9.js","assets/react-CgRToPwO.js","assets/themes-BgDJcxRc.js","assets/scheduledTaskNavigation-BIDtQ4wN.js","assets/theme-validation-BGYdrOu7.js","assets/MarkdownRenderer-D_0iKhQN.js","assets/useEffectiveDirectory-CCKRdyK9.js","assets/markdownHeightCache-BL99DlhC.js","assets/sessionLookup-RcyTTDOy.js","assets/useDictation-Bs7TWO9r.js","assets/LoadingImage-Csw4L-Dr.js","assets/ImageLoadingPlaceholder-BZC5m_km.js","assets/image-loading-DBqnxgDH.js","assets/image-loading-DA9JEHD8.css","assets/sessionLookup-8C8nv-EP.css","assets/fileMentionTouchSelection-D-AdTJVr.js","assets/insertionBoundaries-DZtQt2Ah.js","assets/mobileBackNavigation--ZdrI-Yj.js","assets/queue-abort-optimistic-CQXpIlq6.js","assets/toolHelpers-iEHVHQ9p.js","assets/FadeInOnReveal-DMRmNsau.js","assets/ToolOutputDialog-5xBwOJ6a.js","assets/tap-LkQum5bB.js","assets/markdownTheme-DFDWa8Gh.js","assets/markdown-worker-oBGEB9Eg.js","assets/remote-input-store-BOdCWpQY.js","assets/vendor-cmdk-BgHvMv5l.js","assets/vendor-aria-hidden-BbL3cEyI.js","assets/vendor-motion-Dv27UnOI.js","assets/useProjectRuntimeAPIs-BFCXBu2J.js","assets/sortable-tabs-strip-nD1Me06z.js","assets/speechSettingsQueries-BYhNpzDJ.js","assets/vendor-marked-S3gCOYp1.js","assets/useStreamingTextThrottle-C8xAqcgP.js","assets/useFontPreferences-CPrl1_3z.js","assets/useAppFontEffects-K31q-1OV.css","assets/MobileSurface-DmYgZONB.js","assets/vendor-codemirror-autocomplete-C0FrlFqZ.js","assets/vendor-codemirror-lang-angular-Cm7vBE3E.js","assets/vendor-codemirror-lang-json-DowyFczU.js","assets/vendor-codemirror-lang-markdown-npWBZIoE.js","assets/vendor-codemirror-lang-python-OPRdU26g.js","assets/vendor-codemirror-legacy-modes-DwltVFbT.js","assets/mcpQueries-HzYMEVWd.js","assets/usePluginsStore-bMuGciUE.js","assets/collapsible-CKswuqAw.js","assets/vendor-codemirror-commands-5saeUOVY.js","assets/vendor-codemirror-search-hZY-L2l8.js","assets/vendor-replit-codemirror-vim-BmQmU1lR.js","assets/vendor-codemirror-language-data-B3pLWvv-.js","assets/AssistantConversationSurface-BnK_KTBO.js","assets/assistant-attachment-cache-D-LmCflm.js","assets/AssistantConversationSurface-n9w_Av0k.css","assets/runtimeEndpointReset-BhHWFNvo.js","assets/YuriWordmark-DnFAS-Ko.js","assets/readiness-BfuZm6Yw.js","assets/relay-preview-frame-src-BPyz3nXA.js","assets/AssistantUnreadBadge-vu4ZhTft.js","assets/context-menu-B4njwT_M.js","assets/native-errors-06if6eu-.js","assets/appearance-DFsI3pnP.js","assets/navigation-Ibk_Pw-q.js","assets/vendor-cron-parser-BmO80h0C.js","assets/runtimeEndpointReset-BUGfn7y0.css","assets/SettingsView-ZWFLpPSI.js","assets/vendor-qrcode-D7jBCyl-.js","assets/vendor-dijkstrajs-BAzPDGZM.js","assets/VoiceSettings-CN33koSc.js","assets/VoiceSettings-C0HSdVvS.css","assets/GuiPluginWindow-tHXkS18H.js","assets/vendor-yaml-C9KlJAlj.js","assets/project-preview-2H-TmJkd.js","assets/AssistantView-CEfEWUIr.js","assets/renderMobileApp-1G4-5u-t.css","assets/src-BZCFf9_1.css"])))=>i.map(i=>d[i]);
2
- import"./modulepreload-polyfill-P2Xu9kJm.js";import{o as e}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";/* empty css */e(async()=>{let{createConfiguredWebAPIs:e}=await import(`./runtimeConfig-tHm7o_0I.js`).then(e=>e.r);return{createConfiguredWebAPIs:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40])).then(async({createConfiguredWebAPIs:t})=>{window.__YURI_RUNTIME_APIS__=t();let{renderMobileApp:n}=await e(async()=>{let{renderMobileApp:e}=await import(`./renderMobileApp-BQFC-gOA.js`);return{renderMobileApp:e}},__vite__mapDeps([41,1,2,3,4,5,6,7,8,12,13,11,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,37,36,42,43,44,45,46,47,48,49,50,51,52,53,40,39,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,10,9,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,35,122,123,124,125,126,127,128,129,34,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,38,165,166,167,168,169,170,171,172,173,174]));n(window.__YURI_RUNTIME_APIS__)});
@@ -1 +0,0 @@
1
- import{n as e}from"./runtime-fetch-DKZOpfzo.js";import{c as t}from"./platform-wF65ZFgV.js";import{i as n}from"./vendor-pathe-vBmvQE8f.js";import{n as r,z as i}from"./runtime-file-resource-CuLP3xp7.js";var a=(e=o)=>{let t=new Map,n=0;return{countUnicodeCodePoints:r=>{let i=t.get(r);if(i!==void 0)return t.delete(r),t.set(r,i),i;let a=e(r);if(r.length>4e5)return a;for(;n+r.length>4e5&&t.size>0;){let e=t.keys().next().value;n-=e.length,t.delete(e)}return t.set(r,a),n+=r.length,a}}},o=e=>{let t=0;for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);if(r>=55296&&r<=56319&&n+1<e.length){let t=e.charCodeAt(n+1);t>=56320&&t<=57343&&(n+=1)}t+=1}return t},s=a(),c=e=>s.countUnicodeCodePoints(e),l=(e,t)=>{if(!e)throw Error(`${t} must be non-empty`);return e},u=({transportIdentity:e,location:n},r)=>({transportIdentity:l(e,`transportIdentity`),owner:{kind:`session`,ownerID:n?t(n,r):l(r,`sessionID`)}}),d=({transportIdentity:e,location:n},r)=>({transportIdentity:l(e,`transportIdentity`),owner:{kind:`draft`,ownerID:n?t(n,r):l(r,`draftID`)}}),f=e=>{let t=typeof e.projectId==`string`?e.projectId.trim():``;if(t)return`new-session:project:${t}`;let n=typeof e.directory==`string`?e.directory.trim():``;return n?`new-session:directory:${n}`:`new-session:default`},p=({transportIdentity:e,location:n},r)=>({transportIdentity:l(e,`transportIdentity`),owner:{kind:`surface`,ownerID:n?t(n,r):l(r,`surfaceID`)}}),m=8192,h=e=>{if(typeof e!=`string`||e.length===0||e.length>m)return!1;try{let t=new URL(e).protocol;return t===`http:`||t===`https:`||t===`file:`}catch{return!1}},ee=e=>JSON.stringify([e.transportIdentity,e.owner.kind,e.owner.ownerID]),te=e=>JSON.stringify([e.transportIdentity,e.owner.kind,e.owner.ownerID,e.attachmentOccurrenceRefID]),ne=e=>JSON.stringify([`root`,e]),re=(e,t)=>JSON.stringify([`part`,e,t]),g={mentionCount:1e3,valueLength:8192,pathLength:8192,labelLength:512},_={referenceCount:1e3,idLength:512,displayLength:514,sessionIDLength:128,skillNameLength:511,commandNameLength:511,commandReferenceLength:8192,pastePayloadLength:1e5,totalPastePayloadLength:2e5},v=e=>{if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},y=(e,t)=>Object.keys(e).every(e=>t.includes(e)),b=e=>typeof e==`string`&&e.length>0,ie=e=>typeof e==`string`,x=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0,S=(e,t)=>typeof e==`string`&&e.length>0&&e.length<=t,C=(e,t)=>{if(t<=0||t>=e.length)return!0;let n=e.charCodeAt(t-1),r=e.charCodeAt(t);return!(n>=55296&&n<=56319&&r>=56320&&r<=57343)},w=(e,t)=>{if(!Array.isArray(t)||t.length>g.mentionCount)return;let n=[],r=new Set,i=0;for(let a of t){if(!v(a)||!y(a,[`kind`,`value`,`path`,`label`,`range`])||a.kind!==`file`&&a.kind!==`directory`&&a.kind!==`agent`||!S(a.value,g.valueLength)||!S(a.path,g.pathLength)||!S(a.label,g.labelLength)||!v(a.range)||!y(a.range,[`start`,`end`])||!x(a.range.start)||!x(a.range.end)||a.range.end<=a.range.start||a.range.end>e.length||a.range.start<i||!C(e,a.range.start)||!C(e,a.range.end)||e.slice(a.range.start,a.range.end)!==`@${a.value}`)return;let t=JSON.stringify([a.kind,a.value,a.path,a.label,a.range.start,a.range.end]);if(r.has(t))return;r.add(t),i=a.range.end,n.push({kind:a.kind,value:a.value,path:a.path,label:a.label,range:{start:a.range.start,end:a.range.end}})}return n},T=e=>S(e,_.sessionIDLength)&&/^[A-Za-z0-9_-]+$/.test(e),E=/^[^\s/\\[\]\r\n]+$/u,D=()=>/\[skill:([^\s/\\\]\r\n]+)\]/gu,O=e=>S(e,_.skillNameLength)&&E.test(e),k=e=>S(e,_.commandNameLength)&&/^[\p{L}\p{N}._/-]+$/u.test(e),A=e=>S(e,_.commandReferenceLength)&&!/[\]\r\n]/u.test(e),ae=e=>{if(!(!v(e)||!S(e.id,_.idLength)||!S(e.display,_.displayLength)||!x(e.start)||!x(e.end)||e.end<=e.start)){if(e.kind===`session`&&y(e,[`id`,`kind`,`start`,`end`,`display`,`sessionId`])&&T(e.sessionId))return{id:e.id,kind:`session`,start:e.start,end:e.end,display:e.display,sessionId:e.sessionId};if(e.kind===`paste`&&y(e,[`id`,`kind`,`start`,`end`,`display`,`text`,`characterCount`,`index`])&&typeof e.text==`string`&&e.text.length<=_.pastePayloadLength&&x(e.characterCount)&&e.characterCount===c(e.text)&&x(e.index)&&e.index>=1)return{id:e.id,kind:`paste`,start:e.start,end:e.end,display:e.display,text:e.text,characterCount:e.characterCount,index:e.index};if(e.kind===`skill`&&y(e,[`id`,`kind`,`start`,`end`,`display`,`skillName`])&&O(e.skillName)&&(e.display===`/${e.skillName}`||e.display===`/ ${e.skillName}`||e.display===`@${e.skillName}`||e.display===`@ ${e.skillName}`))return{id:e.id,kind:`skill`,start:e.start,end:e.end,display:e.display,skillName:e.skillName};if(e.kind===`command`&&y(e,[`id`,`kind`,`start`,`end`,`display`,`commandName`,`reference`])&&k(e.commandName)&&A(e.reference)&&(e.display===`/${e.commandName}`||e.display===`/ ${e.commandName}`))return{id:e.id,kind:`command`,start:e.start,end:e.end,display:e.display,commandName:e.commandName,reference:e.reference}}},j=(e,t)=>{if(!Array.isArray(t)||t.length>_.referenceCount)return;let n=t.map(ae);if(!n.every(Boolean))return;let r=n,i=new Set,a=0,o=0;for(let t of r)if(i.has(t.id)||t.start<a||t.end>e.length||e.slice(t.start,t.end)!==t.display||(i.add(t.id),a=t.end,t.kind===`paste`&&(o+=t.text.length,o>_.totalPastePayloadLength)))return;return{text:e,references:r}},M=(e,t)=>{if(e===null||[`string`,`number`,`boolean`,`undefined`].includes(typeof e))return!0;if(typeof e!=`object`||e instanceof Blob||typeof File<`u`&&e instanceof File||!Array.isArray(e)&&!v(e)||t.has(e))return!1;t.add(e);let n=Object.values(e).every(e=>M(e,t));return t.delete(e),n},oe=e=>{if(!(!v(e)||!y(e,[`kind`,`ownerID`])||!b(e.ownerID))&&(e.kind===`session`||e.kind===`draft`||e.kind===`surface`))return{kind:e.kind,ownerID:e.ownerID}},N=e=>{if(!v(e)||!y(e,[`transportIdentity`,`owner`])||!b(e.transportIdentity))return;let t=oe(e.owner);return t?{transportIdentity:e.transportIdentity,owner:t}:void 0},P=e=>{if(!(!v(e)||!b(e.kind))){if(e.kind===`blob`&&y(e,[`kind`,`blobID`])&&b(e.blobID))return{kind:`blob`,blobID:e.blobID};if(!(e.kind!==`url`||!y(e,[`kind`,`url`])||!h(e.url)))return{kind:`url`,url:e.url}}},F=(e,t,n)=>{try{let r=JSON.parse(e);return Array.isArray(r)?n===void 0?r.length===2&&r[0]===`root`&&r[1]===t:r.length===3&&r[0]===`part`&&r[1]===n&&r[2]===t:!1}catch{return!1}},I=(e,t)=>{if(!v(e)||!y(e,[`attachmentID`,`attachmentRefID`,`filename`,`mimeType`,`size`,`locator`,`source`,`serverPath`,`vscodePath`,`vscodeSource`])||!b(e.attachmentID)||!b(e.attachmentRefID)||!F(e.attachmentRefID,e.attachmentID,t)||!b(e.filename)||!ie(e.mimeType)||!x(e.size)||e.source!==`local`&&e.source!==`vscode`&&e.source!==`server`||e.serverPath!==void 0&&!b(e.serverPath)||e.vscodePath!==void 0&&!b(e.vscodePath)||e.vscodeSource!==void 0&&e.vscodeSource!==`file`&&e.vscodeSource!==`selection`||e.source===`server`&&!b(e.serverPath)||e.source===`vscode`&&(!b(e.vscodePath)||e.vscodeSource!==`file`&&e.vscodeSource!==`selection`))return;let n=P(e.locator);if(n)return{attachmentID:e.attachmentID,attachmentRefID:e.attachmentRefID,filename:e.filename,mimeType:e.mimeType,size:e.size,locator:n,source:e.source,...e.serverPath===void 0?{}:{serverPath:e.serverPath},...e.vscodePath===void 0?{}:{vscodePath:e.vscodePath},...e.vscodeSource===void 0?{}:{vscodeSource:e.vscodeSource}}},L=e=>{if(!M(e,new Set)||!v(e)||!y(e,[`version`,`key`,`revision`,`text`,`attachments`,`syntheticParts`,`mentions`,`composerReferences`])||e.version!==1||!x(e.revision)||e.revision<1||typeof e.text!=`string`||!Array.isArray(e.attachments)||!Array.isArray(e.syntheticParts)||!Array.isArray(e.mentions))return;let t=e.text,n=N(e.key),r=e.attachments.map(e=>I(e)),i=e.syntheticParts.map(e=>{if(!v(e)||!y(e,[`partID`,`text`,`attachments`,`synthetic`])||!b(e.partID)||typeof e.text!=`string`||!Array.isArray(e.attachments)||e.synthetic!==void 0&&typeof e.synthetic!=`boolean`)return;let t=e.partID,n=e.text,r=e.attachments.map(e=>I(e,t));return r.every(Boolean)?{partID:t,text:n,attachments:r,...e.synthetic===void 0?{}:{synthetic:e.synthetic}}:void 0}),a=w(t,e.mentions),o=e.composerReferences===void 0?{text:t,references:[]}:j(t,e.composerReferences);if(!n||!r.every(Boolean)||!i.every(Boolean)||!a||!o)return;let s=r,c=i,l=new Set;for(let e of[...s,...c.flatMap(e=>e.attachments)]){if(l.has(e.attachmentRefID))return;l.add(e.attachmentRefID)}if(new Set(c.map(e=>e.partID)).size===c.length)return{version:1,key:n,revision:e.revision,text:t,attachments:s,syntheticParts:c,mentions:a,...e.composerReferences===void 0?{}:{composerReferences:o.references}}},R=e=>L(e),z=` `,B=`0.2em`,V=`size-[1em]`,H=e=>e.startsWith(z)?e.slice(z.length):e,U=e=>e.replaceAll(`/${z}`,`/`).replaceAll(`@${z}`,`@`).replaceAll(`[${z}`,`[`),W=e=>{let t=e.match(/^\s*/)?.[0].length??0,n=e.slice(t);if(!n.startsWith(`/`))return null;let r=1;n.startsWith(z,r)&&(r+=z.length);let i=n.slice(r);if(!i)return null;let a=i.search(/\s/u),o=a===-1?i:i.slice(0,a);return o?{commandName:o,argumentsText:a===-1?``:i.slice(a).trim()}:null},G=e=>q({trigger:`[`,icon:`file-image`,label:e,suffix:`]`}),K=({trigger:e,label:t,suffix:n=``})=>`${e}${t}${n}`,q=e=>`${e.trigger}${z}${e.label}${e.suffix??``}`,J=e=>K(e),se=(e,t)=>e===J(t)||e===q(t),ce=(e,t)=>{let n=t===q(e);return{trigger:n?`${e.trigger}${z}`:e.trigger,icon:e.icon,align:e.align??`end`,label:e.label,suffix:e.suffix,slot:n?`reserved`:`compact`}},le=(e,t,n=``)=>{let r=e.startsWith(t)?e.slice(t.length):e,i=r.startsWith(z)?r.slice(z.length):r;return n&&i.endsWith(n)?i.slice(0,-n.length):i},ue=(e,t)=>e===t||!!e&&!!t&&e.trigger===t.trigger&&e.icon===t.icon&&e.align===t.align&&e.label===t.label&&e.suffix===t.suffix&&e.slot===t.slot,Y=e=>e.trim().toLowerCase(),de=e=>e.source===`local`||e.source===`server`||e.source===`vscode`,X=(e,t)=>{if(!e||!e.includes(`[`)||t.length===0)return[];let n=new Set(t.map(Y)),r=[],i=0;for(;i<e.length;){let t=e.indexOf(`[`,i);if(t===-1)break;let a=e.indexOf(`]`,t+1);if(a===-1)break;if(e[a+1]!==`(`){let i=H(e.slice(t+1,a)).trim();n.has(Y(i))&&r.push({start:t,end:a+1})}i=a+1}return r},fe=(e,t)=>{let n=t.start,r=t.end;return r<e.length&&/\s/.test(e[r])?r+=1:n>0&&/\s/.test(e[n-1])&&--n,{start:n,end:r}},pe=(e,t,n,r)=>{let i=X(e,t);if(i.length===0)return{text:e,mentions:[...n],composerReferences:r===void 0?void 0:[...r],changed:!1};let a=e,o=[...n],s=r===void 0?[]:[...r];for(let e=i.length-1;e>=0;--e){let{start:t,end:n}=fe(a,i[e]),r=n-t;a=`${a.slice(0,t)}${a.slice(n)}`,o=o.flatMap(e=>e.range.end<=t?[e]:e.range.start>=n?[{...e,range:{start:e.range.start-r,end:e.range.end-r}}]:[]),s=s.flatMap(e=>e.end<=t?[e]:e.start>=n?[{...e,start:e.start-r,end:e.end-r}]:[])}return{text:a,mentions:o,composerReferences:r===void 0?void 0:s,changed:!0}},Z=class extends Error{status;code;constructor(e,t,n=`Failed to upload prompt attachment`){super(n),this.name=`PromptAttachmentUploadError`,this.status=e,this.code=t}},Q=`file://`,$=e=>{let t=e.trim();if(t.toLowerCase().startsWith(Q))return t;let r=n(t).split(`/`).map(e=>/^[A-Za-z]:$/.test(e)?e:encodeURIComponent(e)).join(`/`);return/^[A-Za-z]:/.test(r)?`${Q}/${r}`:`${Q}${r}`},me=e=>{let t=e.trim();if(!t.toLowerCase().startsWith(Q))return t;let n=t.slice(7);n.toLowerCase().startsWith(`localhost/`)&&(n=n.slice(9));let r=n.split(`/`).map(e=>{if(/^[A-Za-z]:$/.test(e))return e;try{return decodeURIComponent(e)}catch{return e}}).join(`/`);return/^\/[A-Za-z]:/.test(r)?r.slice(1):r},he=async e=>[...new Uint8Array(await crypto.subtle.digest(`SHA-256`,await e.arrayBuffer()))].map(e=>e.toString(16).padStart(2,`0`)).join(``),ge=e=>typeof e==`object`&&!!e&&!Array.isArray(e),_e=async e=>{let t;try{t=await e.json()}catch{throw new Z(e.status,`unavailable`)}if(!ge(t)||typeof t.path!=`string`||!t.path)throw new Z(e.status,`unavailable`);let n=typeof t.mime==`string`&&t.mime?t.mime:`application/octet-stream`,r=typeof t.size==`number`&&Number.isSafeInteger(t.size)?t.size:0,i=typeof t.sha256==`string`?t.sha256:``;return{path:t.path,url:$(t.path),mime:n,size:r,sha256:i}},ve=e=>{let t=typeof crypto.randomUUID==`function`?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`,n=e?.replace(/[^a-z0-9._-]+/gi,`-`).replace(/^-+|-+$/g,``).slice(0,32);return n?`att-${t}-${n}`:`att-${t}`},ye=(e,t)=>{if(!e.startsWith(`data:`))return null;let n=e.indexOf(`,`);if(n===-1)return null;let r=e.slice(5,n),i=e.slice(n+1),a=r.split(`;`,1)[0]?.trim()||t||`application/octet-stream`;try{if(r.toLowerCase().includes(`;base64`)){let e=atob(i),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return new Blob([t],{type:a})}return new Blob([decodeURIComponent(i)],{type:a})}catch{return null}},be=e=>e.startsWith(`data:`)||e.startsWith(`blob:`),xe=async t=>{let n=i(t.scope),a=t.scope?.location.hostId?void 0:r(),o=t.mime||t.body.type||`application/octet-stream`,s=t.body.type===o?t.body:new Blob([t.body],{type:o});if(!Number.isSafeInteger(s.size)||s.size<0)throw new Z(413,`too-large`);let c=await he(s);n.assertCurrent(t.signal);let l=ve(t.filename),u;try{u=await(t.scope?n.fetch:e)(`/api/fs/prompt-attachments/${encodeURIComponent(l)}?storage=temporary`,{method:`PUT`,headers:{"Content-Type":o,"Content-Length":String(s.size),"X-Yuri-Content-Length":String(s.size),"X-Yuri-Sha256":c,"X-Yuri-Mime":o,...t.scope?{"x-opencode-directory":t.scope.location.directory}:{},...t.filename?{"X-Yuri-Filename":encodeURIComponent(t.filename)}:{}},body:s,signal:t.signal})}catch{throw new Z(0,`unavailable`)}if(u.status===413)throw new Z(413,`too-large`);if(!u.ok)throw new Z(u.status,u.status>=500||u.status===0?`unavailable`:`rejected`);let d=await _e(u);if(n.assertCurrent(t.signal),d.size!==s.size||t.scope&&d.sha256!==c)throw new Z(u.status,`unavailable`);return await a?.(s,d.sha256),n.assertCurrent(t.signal),{...d,mime:o}};export{k as A,c as B,f as C,ne as D,ee as E,j as F,w as I,L,T as M,O as N,re as O,d as P,u as R,R as S,D as T,W as _,X as a,U as b,B as c,G as d,q as f,se as g,ce as h,xe as i,A as j,h as k,V as l,J as m,be as n,de as o,le as p,me as r,pe as s,ye as t,z as u,ue as v,te as w,_ as x,H as y,p as z};
@@ -1 +0,0 @@
1
- import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{i as n,n as r,r as i}from"./runtime-switch-BMjl5Y5W.js";import{n as a}from"./runtime-fetch-DKZOpfzo.js";import{F as o,R as s,a as c,n as l,o as u,s as d}from"./platform-wF65ZFgV.js";import{st as f}from"./vendor-base-ui-z2M4boRm.js";import{t as p}from"./client-uz8O6TPX.js";import{n as m}from"./vendor-react-P8wFrkcT.js";import{s as h}from"./vendor-tanstack-react-query-B-KblYBV.js";import{M as g,N as _,j as v,q as y}from"./runtime-file-resource-CuLP3xp7.js";var b=t(f(),1),x=m(),S=e=>{if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Invalid Remote Host response`);return e},C=e=>{if(typeof e!=`string`||!e.trim()||e.length>16384||Array.from(e).some(e=>e.charCodeAt(0)<32))throw Error(`Invalid Remote Host response field`);return e},w=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0?e:void 0,T=[`idle`,`connecting`,`connected`,`degraded`,`offline`,`unauthorized`,`incompatible`],E=e=>{let t=S(e);if(!T.includes(t.state)||![`ssh`,`relay`,`direct`].includes(String(t.source)))throw Error(`Invalid Remote Host state/source`);let n={id:C(t.id),name:C(t.name),source:t.source,state:t.state};if(typeof t.generation==`string`&&(n.generation=C(t.generation)),t.scopeGeneration!==void 0&&(n.scopeGeneration=C(t.scopeGeneration)),typeof t.available==`boolean`&&(n.available=t.available),w(t.lastConnectedAt)!==void 0&&(n.lastConnectedAt=w(t.lastConnectedAt)),w(t.lastSyncedAt)!==void 0&&(n.lastSyncedAt=w(t.lastSyncedAt)),typeof t.version==`string`&&(n.version=C(t.version)),t.lastError){let e=S(t.lastError);n.lastError={code:C(e.code),message:C(e.message)}}return t.capabilities&&(n.capabilities={remoteProjects:S(t.capabilities).remoteProjects===!0}),n},D=e=>{let t=S(e);if(![`ok`,`remote-removed`,`host-unavailable`].includes(String(t.remoteState)))throw Error(`Invalid Remote Project state`);let n={id:C(t.id),path:C(t.path),hostId:C(t.hostId),remoteProjectId:C(t.remoteProjectId),remoteState:t.remoteState};for(let e of[`label`,`icon`,`iconBackground`,`color`])typeof t[e]==`string`?n[e]=t[e]:e!==`label`&&t[e]===null&&(n[e]=null);if(t.iconImage===null)n.iconImage=null;else if(t.iconImage){let e=S(t.iconImage),r=w(e.updatedAt);r!==void 0&&(e.source===`custom`||e.source===`auto`)&&(n.iconImage={mime:C(e.mime),updatedAt:r,source:e.source})}return w(t.addedAt)!==void 0&&(n.addedAt=w(t.addedAt)),w(t.lastOpenedAt)!==void 0&&(n.lastOpenedAt=w(t.lastOpenedAt)),typeof t.sidebarCollapsed==`boolean`&&(n.sidebarCollapsed=t.sidebarCollapsed),n},O=e=>{let t=S(e);if(typeof t.supported!=`boolean`||!Array.isArray(t.hosts)||!Array.isArray(t.projects))throw Error(`Invalid Remote Host catalog`);if(t.hosts.length>1e3||t.projects.length>1e4)throw Error(`Remote Host catalog exceeds limits`);let n=C(t.hubId);return{supported:t.supported,hubId:n,...typeof t.reason==`string`?{reason:t.reason}:{},hosts:t.hosts.map(E),projects:t.projects.map(e=>({...D(e),hubId:n}))}},k=class{dependencies;hubId;entries=new Map;hosts=new Map;hostGenerations=new Map;retiredWireGenerations=new Map;retiredScopeGenerations=new Map;scopeAwareHosts=new Set;hostListeners=new Map;eventListeners=new Map;connections=new Map;disposed=!1;constructor(e,t){if(this.dependencies=t,!e.trim())throw Error(`A registry requires the current Hub identity`);this.hubId=e}assertCurrent(){if(this.disposed||!this.dependencies.isCurrent())throw Error(`Inactive Hub registry`)}async requestHost(e,t,n){if(this.assertCurrent(),!e||!/^(?:projects|subscriptions|connect|summaries)(?:\/[^?#]*)?$/.test(t))throw Error(`Invalid Remote Host control resource`);let r=await this.dependencies.fetch(`/api/hosts/${encodeURIComponent(e)}/${t}`,n);return this.assertCurrent(),r}resolve(e){if(this.assertCurrent(),e.hubId!==this.hubId)throw Error(`Location belongs to another Hub`);let t=d(e),n=this.captureHostFence(e.hostId),r=this.entries.get(t);if(r&&r.connectionGeneration===(n?.generation??0))return r;let i=Object.freeze({...e}),a=()=>{if(this.assertCurrent(),n&&!n.isCurrent())throw Error(`Remote Host connection changed during request`)},o=Object.freeze({location:i,key:t,cachePartition:u(i),connectionGeneration:n?.generation??0,queryScope:Object.freeze([this.dependencies.transportIdentity,this.hubId,i.hostId??``,t,n?.generation??0]),sdk:()=>(a(),this.dependencies.sdk(i,n,o)),service:()=>{if(a(),!this.dependencies.service)throw Error(`OpenCode service is not configured for this registry`);return this.dependencies.service(i,n,o)},fetch:async(e,t)=>{a();let n=await this.dependencies.fetch(c(i.hostId,e),t);return a(),n}});return this.entries.set(t,o),o}captureHostFence(e){if(!e)return;let t=this.hostGenerations.get(e)??0;return{generation:t,isCurrent:()=>!this.disposed&&this.dependencies.isCurrent()&&(this.hostGenerations.get(e)??0)===t}}applyCatalog(e){if(this.assertCurrent(),e.hubId!==this.hubId)throw Error(`Catalog belongs to another Hub`);let t=new Set;for(let n of e.hosts)t.add(n.id),this.updateHost(n);for(let e of this.hosts.keys()){if(t.has(e))continue;let n=this.hosts.get(e);n.scopeGeneration&&this.retireScope(e,n.scopeGeneration),this.hosts.delete(e),this.hostGenerations.set(e,(this.hostGenerations.get(e)??0)+1),this.notifyHost(e)}}getHost=e=>this.hosts.get(e);connectHost(e,{verify:t=!1}={}){this.assertCurrent();let n=this.connections.get(e);if(n)return n;let r=this.hosts.get(e);if(!t&&(r?.state===`connected`||r?.state===`connecting`))return Promise.resolve();if(t&&!r||r?.available===!1)return Promise.reject(Error(`Remote Host is unavailable`));let i=(async()=>{let t=await this.requestHost(e,`connect`,{method:`POST`}),n=await t.json();if(this.assertCurrent(),!t.ok){let e=n&&typeof n==`object`?n:void 0;throw Error(typeof e?.error==`string`?e.error:`Remote Host connection failed (${t.status})`)}let r=E((n&&typeof n==`object`?n:void 0)?.host);if(r.id!==e)throw Error(`Remote Host connection response identity mismatch`);if(!this.hosts.has(e)||this.hosts.get(e)?.available===!1)throw Error(`Remote Host is unavailable`);if(!this.updateHost(r))throw Error(`Stale Remote Host scope response`)})();this.connections.set(e,i);let a=()=>{this.connections.get(e)===i&&this.connections.delete(e)};return i.then(a,a),i}subscribeHost(e,t){this.assertCurrent();let n=this.hostListeners.get(e);return n||this.hostListeners.set(e,n=new Set),n.add(t),()=>{n.delete(t),n.size||this.hostListeners.delete(e)}}subscribeEvents(e,t){this.assertCurrent();let n=this.eventListeners.get(e);return n||this.eventListeners.set(e,n=new Set),n.add(t),()=>{n.delete(t),n.size||this.eventListeners.delete(e)}}ingest(e){if(this.disposed||!this.dependencies.isCurrent()||e.type!==`yuri:host-status`&&e.type!==`yuri:host-event`)return!1;let t=e.properties;if(!t||typeof t!=`object`)return!1;let n=t;if(n.hubId!==this.hubId||typeof n.hostId!=`string`)return!1;if(e.type===`yuri:host-status`){let e;try{e=E(n.host)}catch{return!1}return e.id===n.hostId&&this.updateHost(e)}let r=this.hosts.get(n.hostId);if(r?.available===!1||typeof n.generation==`string`&&this.retiredWireGenerations.get(n.hostId)?.has(n.generation))return!1;let i=r?.generation;if(r?.scopeGeneration&&i===void 0||i!==void 0&&n.generation!==i)return!1;let a=this.eventListeners.get(n.hostId);if(!a?.size)return!0;let o={...typeof n.directory==`string`?{directory:n.directory}:{},payload:n.payload};for(let e of a)e(o);return!0}retireScope(e,t){let n=this.retiredScopeGenerations.get(e);n||this.retiredScopeGenerations.set(e,n=new Set),n.add(t)}updateHost(e){let t=this.hosts.get(e.id);if(e.scopeGeneration&&this.retiredScopeGenerations.get(e.id)?.has(e.scopeGeneration)||!e.scopeGeneration&&this.scopeAwareHosts.has(e.id)&&e.available!==!1||e.generation&&this.retiredWireGenerations.get(e.id)?.has(e.generation))return!1;if(t&&t.name===e.name&&t.source===e.source&&t.state===e.state&&t.lastConnectedAt===e.lastConnectedAt&&t.lastSyncedAt===e.lastSyncedAt&&t.version===e.version&&t.available===e.available&&t.generation===e.generation&&t.scopeGeneration===e.scopeGeneration&&t.lastError?.code===e.lastError?.code&&t.lastError?.message===e.lastError?.message&&t.capabilities?.remoteProjects===e.capabilities?.remoteProjects)return!0;if(e.scopeGeneration&&this.scopeAwareHosts.add(e.id),t?.scopeGeneration&&t.scopeGeneration!==e.scopeGeneration&&this.retireScope(e.id,t.scopeGeneration),t?.generation&&t.generation!==e.generation){let n=this.retiredWireGenerations.get(e.id);n||this.retiredWireGenerations.set(e.id,n=new Set),n.add(t.generation),n.size>16&&n.delete(n.values().next().value)}let n=t?.scopeGeneration!==e.scopeGeneration,r=t&&t.available!==e.available&&(t.available===!1||e.available===!1),i=!e.scopeGeneration&&t&&(t.state!==e.state||t.available!==e.available||t.lastConnectedAt!==e.lastConnectedAt||t.generation!==e.generation);return(n||r||i)&&this.hostGenerations.set(e.id,(this.hostGenerations.get(e.id)??0)+1),this.hosts.set(e.id,e),this.notifyHost(e.id),!0}notifyHost(e){let t=this.hostListeners.get(e);if(t)for(let e of t)e()}dispose(){this.disposed=!0,this.entries.clear(),this.hosts.clear(),this.hostGenerations.clear(),this.retiredWireGenerations.clear(),this.retiredScopeGenerations.clear(),this.scopeAwareHosts.clear(),this.hostListeners.clear(),this.eventListeners.clear(),this.connections.clear()}},A=e({RemoteProjectRequestError:()=>M,createRemoteProject:()=>G,ensureRemoteHostCatalog:()=>I,ensureRemoteHostSummaries:()=>B,getHostRuntimeRegistry:()=>U,readRemoteResponse:()=>N,refreshRemoteHostSummaries:()=>V,remoteHostCatalogQueryOptions:()=>P,remoteHostSummariesQueryOptions:()=>R,remoteProjectMetadata:()=>J,removeRemoteProject:()=>Y,supportsRemoteProjects:()=>j,useRemoteHostCatalog:()=>F,useRemoteHostSummaries:()=>z,useRemoteProjectRuntime:()=>L}),j=()=>!s()&&(o()||l()),M=class extends Error{status;code;minimumVersion;constructor(e,t,n,r){super(n),this.status=e,this.code=t,this.minimumVersion=r,this.name=`RemoteProjectRequestError`}},N=async e=>{let t=await e.json();if(e.ok)return t;let n=t&&typeof t==`object`?t:{};throw new M(e.status,typeof n.code==`string`?n.code:`request_failed`,typeof n.error==`string`?n.error:e.statusText,typeof n.minimumVersion==`string`?n.minimumVersion:void 0)},P=()=>{let e=n(),t=r(),o=i();return{queryKey:[e,`remote-projects`,`catalog`],staleTime:1/0,gcTime:1/0,queryFn:async({signal:s})=>{if(!j())throw new M(501,`unsupported_client`,`Remote Projects are not supported by this client`);let c=await N(await a(`/api/hosts`,{signal:s}));if(e!==n()||t!==r()||o!==i())throw Error(`Remote Host catalog belongs to an inactive Hub`);let l=O(c);return l.supported&&U(l).applyCatalog(l),l}}},F=(e,t)=>{let n=(0,x.c)(10),i=t!==void 0&&t,a;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=P(),n[0]=a):a=n[0];let o=a,s=o.queryKey[0],c;n[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=r(),n[1]=c):c=n[1];let l=c,u,d;n[2]!==e||n[3]!==i?(u=()=>{let t=[s,`remote-projects`,`catalog`];e&&i&&j()&&y.getQueryData(t)!==void 0&&y.invalidateQueries({queryKey:t,exact:!0})},d=[e,s,l,i],n[2]=e,n[3]=i,n[4]=u,n[5]=d):(u=n[4],d=n[5]),(0,b.useEffect)(u,d);let f;n[6]===e?f=n[7]:(f=e&&j(),n[6]=e,n[7]=f);let p;return n[8]===f?p=n[9]:(p={...o,enabled:f},n[8]=f,n[9]=p),h(p,y)},I=()=>y.fetchQuery(P()),L=(e,t)=>{let n=(0,x.c)(7),r=F(e,t!==void 0&&t),i;n[0]===r.data?i=n[1]:(i=r.data?.supported?U(r.data):void 0,n[0]=r.data,n[1]=i);let a=i,o;return n[2]!==r.data||n[3]!==r.error||n[4]!==r.isPending||n[5]!==a?(o={catalog:r.data,registry:a,error:r.error,isPending:r.isPending},n[2]=r.data,n[3]=r.error,n[4]=r.isPending,n[5]=a,n[6]=o):o=n[6],o},R=(e,t)=>{let r=n();return{queryKey:_(r,e?.hubId??``,t??``),enabled:!!e&&!!t,staleTime:1/0,gcTime:1/0,queryFn:async({signal:n})=>{if(!e||!t)throw Error(`Remote summary scope is unavailable`);let r=await N(await e.requestHost(t,`summaries`,{signal:n})),i=g(r,e.hubId,t);return e.assertCurrent(),v(e).demand.topologyAvailable(t,i.worktrees),i}}},z=(e,t,n)=>{let r=(0,x.c)(11),i=n===void 0||n,a,o;r[0]!==i||r[1]!==t||r[2]!==e?(a=()=>{if(i&&e&&t)return v(e).retain()},o=[i,e,t],r[0]=i,r[1]=t,r[2]=e,r[3]=a,r[4]=o):(a=r[3],o=r[4]),(0,b.useEffect)(a,o);let s;r[5]!==t||r[6]!==e?(s=R(e,t),r[5]=t,r[6]=e,r[7]=s):s=r[7];let c=i&&!!e&&!!t,l;return r[8]!==s||r[9]!==c?(l={...s,enabled:c},r[8]=s,r[9]=c,r[10]=l):l=r[10],h(l,y)},B=(e,t)=>y.ensureQueryData(R(e,t)),V=(e,t)=>y.fetchQuery({...R(e,t),staleTime:0}),H,U=e=>{let t=i(),o=n(),s=r();return(!H||H.runtime!==t||H.transport!==o||H.generation!==s||H.registry.hubId!==e.hubId)&&(H?.registry.dispose(),H={runtime:t,transport:o,generation:s,registry:new k(e.hubId,{transportIdentity:o,isCurrent:()=>t===i()&&o===n()&&s===r(),fetch:a,sdk:(e,t,n)=>p(e,t,n).getScopedSdkClient(e.directory),service:p})},H.registry.applyCatalog(e)),H.registry},W=async(e,t)=>{let n=await N(e),r=D((n&&typeof n==`object`?n:{}).project);if(r.hostId!==t)throw Error(`Remote Project response belongs to another machine`);return r},G=async(e,t,n,r)=>{let i=await W(await e.requestHost(t,`projects`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:n,...r?{label:r}:{}})}),t);e.assertCurrent();let a={...i,hubId:e.hubId};return K(e,a),a},K=(e,t,n=!1)=>{e.assertCurrent();let r=e.resolve({hubId:e.hubId,hostId:t.hostId,directory:t.path}).queryScope[0];y.setQueryData([r,`remote-projects`,`catalog`],r=>{if(!r||r.hubId!==e.hubId)return r;let i=r.projects.findIndex(e=>e.id===t.id&&e.hostId===t.hostId);if(n&&i<0)return r;let a=[...r.projects];return n?a.splice(i,1):i<0?a.push(t):a[i]=t,{...r,projects:a}})},q=new WeakMap,J=async(e,t,n)=>{e.assertCurrent();let r=q.get(e);r||q.set(e,r=new Map);let i=JSON.stringify([t.hostId,t.id]),a={...n},o=(r.get(i)??Promise.resolve()).catch(()=>void 0).then(async()=>{let n=await W(await e.requestHost(t.hostId,`projects/${encodeURIComponent(t.id)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(a)}),t.hostId);if(e.assertCurrent(),n.id!==t.id)throw Error(`Remote Project metadata response identity mismatch`);return K(e,n),n});r.set(i,o);let s=()=>{r.get(i)===o&&r.delete(i)};return o.then(s,s),o},Y=async(e,t)=>{let n=await e.requestHost(t.hostId,`projects/${encodeURIComponent(t.id)}`,{method:`DELETE`});n.ok||await N(n),e.assertCurrent(),K(e,t,!0)};export{N as a,J as c,j as d,F as f,D as h,U as i,A as l,L as m,I as n,V as o,z as p,B as r,R as s,G as t,Y as u};