@openchambery/web 1.18.2-beta.2 → 1.18.2-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentAvatar-B2kZjgaf.js → AgentAvatar-B4fj9PIe.js} +1 -1
- package/dist/assets/{AssistantView-DvoyOGkx.js → AssistantView-C00aiEHK.js} +1 -1
- package/dist/assets/{ChatContainer-D6yfuigV.js → ChatContainer-BDFeDKu-.js} +39 -39
- package/dist/assets/{DiagramView-MGGo9iME.js → DiagramView-CUfSFI3e.js} +1 -1
- package/dist/assets/{FadeInOnReveal-aeWlaqVB.js → FadeInOnReveal-CKKU6fKI.js} +1 -1
- package/dist/assets/{Icon-AXqa-fYB.js → Icon-DiIuWOuC.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-jVOkZkyX.js → MarkdownRendererImpl-Cen6E9Lj.js} +2 -2
- package/dist/assets/{MobileDetailNavigation-Q2IzHqGA.js → MobileDetailNavigation-DILi0tN7.js} +1 -1
- package/dist/assets/{MobileShareBridge-apXM34Lb.js → MobileShareBridge-PZMRiieI.js} +1 -1
- package/dist/assets/MobileSurface-BLYcR0tO.js +2 -0
- package/dist/assets/{MultiRunWindow-B-l_O-bd.js → MultiRunWindow-D_2mWZyv.js} +1 -1
- package/dist/assets/{OnboardingScreen-CUsgwt4y.js → OnboardingScreen-CYeRZznl.js} +1 -1
- package/dist/assets/{OverlayScrollbar-D6NySAxi.js → OverlayScrollbar-BgMLtMIq.js} +1 -1
- package/dist/assets/SettingsView-CbDBfQp1.js +25 -0
- package/dist/assets/{SettingsWindow-DfVgTQ4I.js → SettingsWindow-Br7XLcSd.js} +1 -1
- package/dist/assets/{TerminalView-DNyjfkvT.js → TerminalView-CM5jRKlj.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DLG1iThm.js → ToolOutputDialog-D3U6aTZ4.js} +1 -1
- package/dist/assets/appThemeRegistry-CDxBJNNB.js +2 -0
- package/dist/assets/assistant-guide-hero-BeUHQcxE.jpg +0 -0
- package/dist/assets/{button-CDvMVaiO.js → button-DaAoVF4X.js} +1 -1
- package/dist/assets/{clipboard-BW7nk_Cx.js → clipboard-BnElHSnO.js} +1 -1
- package/dist/assets/{collapsible-C2aamDvD.js → collapsible-BmuQu0dq.js} +1 -1
- package/dist/assets/{context-menu-BaxmodD8.js → context-menu-DBOMervd.js} +1 -1
- package/dist/assets/{desktopHosts-CBoBpJ1Z.js → desktopHosts-ZK_vkdzL.js} +1 -1
- package/dist/assets/{desktopRelayRestore-l2R9muux.js → desktopRelayRestore-CewM6-g5.js} +1 -1
- package/dist/assets/{diagram-CEon0BQs.js → diagram-DAE4CZy2.js} +1 -1
- package/dist/assets/{dialog-DjYfj1Sn.js → dialog-COrLBm9O.js} +1 -1
- package/dist/assets/{es-5Lhudh0n.js → es-DIVYdoxi.js} +1 -1
- package/dist/assets/{fileQueries-CE_DaZWQ.js → fileQueries-CmWYnRVz.js} +1 -1
- package/dist/assets/{fr-Q_UhFmKT.js → fr-CNTlVypq.js} +2 -2
- package/dist/assets/{gitApi-BYxg_qGJ.js → gitApi-BQT3QXD2.js} +1 -1
- package/dist/assets/gitApiHttp-BxGAFLTf.js +2 -0
- package/dist/assets/{input-k9DGGyZ6.js → input-XiL2-2gG.js} +1 -1
- package/dist/assets/insertionBoundaries-9a0RuIDc.js +1 -0
- package/dist/assets/{ja-CzMPz7bT.js → ja-C_eW5ZM8.js} +1 -1
- package/dist/assets/{ko-B-EslUsR.js → ko-CE3cOv7v.js} +1 -1
- package/dist/assets/{main-LDphyc-v.js → main-BGfX81Y9.js} +20 -20
- package/dist/assets/{main-CO6z5yRB.js → main-CEqSDnE2.js} +2 -2
- package/dist/assets/{markdown-worker-DkeWiER6.js → markdown-worker-BDyY0vt6.js} +1 -1
- package/dist/assets/{markdownTheme-DNT93i5L.js → markdownTheme-D-aLQZaM.js} +1 -1
- package/dist/assets/{miniChat-BZQwTZpx.js → miniChat-CKucSAhg.js} +2 -2
- package/dist/assets/mobile-C4bTWKry.js +2 -0
- package/dist/assets/{multirun-ZlwlkIy5.js → multirun-DeNtSkgb.js} +1 -1
- package/dist/assets/{persistence-DPNMIbF5.js → persistence-D1lIuyqO.js} +1 -1
- package/dist/assets/{pl-Dnea6Ppc.js → pl-BZKZOE99.js} +1 -1
- package/dist/assets/projectMeta-BunN9pH5.js +3 -0
- package/dist/assets/{pt-BR-Ca6QTem7.js → pt-BR-DHDgp8S3.js} +1 -1
- package/dist/assets/{radio-CJuhbQ5a.js → radio-Bziafaje.js} +1 -1
- package/dist/assets/renderElectronMiniChatApp-D8-FDgWE.js +2 -0
- package/dist/assets/renderMobileApp-CdU0aJ-e.js +23 -0
- package/dist/assets/{runtimeConfig-BtWi74Pm.js → runtimeConfig-BXCt7ZsQ.js} +1 -1
- package/dist/assets/runtimeEndpointReset-CK1GhIsm.js +145 -0
- package/dist/assets/{sortable-tabs-strip-D8JHUI0z.js → sortable-tabs-strip-pWlBorwQ.js} +1 -1
- package/dist/assets/src-8kQFmtjw.css +2 -0
- package/dist/assets/{store-wa1ersRf.js → store-CUWqzRt7.js} +2 -2
- package/dist/assets/{terminalApi-tB3qLcfa.js → terminalApi-DpiAJlil.js} +1 -1
- package/dist/assets/{tooltip-DMNR5rN0.js → tooltip-BLugzWq-.js} +1 -1
- package/dist/assets/{uk-xGc9Pzge.js → uk-CfQK6cz1.js} +1 -1
- package/dist/assets/{url-7MqoLs9X.js → url-DMs_PgIC.js} +1 -1
- package/dist/assets/useAppFontEffects-IEUQDvE8.js +7 -0
- package/dist/assets/useDesktopWindowControlsLayout-MlqJX89k.js +1 -0
- package/dist/assets/{useEffectiveDirectory-aUC3zzl_.js → useEffectiveDirectory-GbhkdO6m.js} +1 -1
- package/dist/assets/{useFontPreferences-CIurCeNv.js → useFontPreferences-92Qg-98H.js} +1 -1
- package/dist/assets/useMobileNavigationStore-DQHF_ETu.js +476 -0
- package/dist/assets/useSessionAutoCleanup-BuU_S_Sh.js +1 -0
- package/dist/assets/{useWorkerHighlightedLines-CiYQjBe6.js → useWorkerHighlightedLines-Ca6OgNHF.js} +1 -1
- package/dist/assets/{utils-Co19EJEL.js → utils-BxJEIWv5.js} +1 -1
- package/dist/assets/{zh-CN-sL4ktGB3.js → zh-CN-DvY2fKWp.js} +1 -1
- package/dist/assets/{zh-TW-Cfxps4gq.js → zh-TW-eWe0lm3-.js} +1 -1
- package/dist/index.html +8 -8
- package/dist/mini-chat.html +8 -8
- package/dist/mobile.html +8 -8
- package/package.json +1 -1
- package/server/index.d.ts +6 -0
- package/server/index.js +13 -0
- package/server/lib/config-sync/DOCUMENTATION.md +70 -0
- package/server/lib/config-sync/config-sync.test.js +197 -0
- package/server/lib/config-sync/constants.js +39 -0
- package/server/lib/config-sync/contract.js +130 -0
- package/server/lib/config-sync/credential-auth.js +39 -0
- package/server/lib/config-sync/engine.js +108 -0
- package/server/lib/config-sync/index.js +67 -0
- package/server/lib/config-sync/local-backup.js +171 -0
- package/server/lib/config-sync/plan.js +318 -0
- package/server/lib/config-sync/receiver.js +330 -0
- package/server/lib/config-sync/routes.js +141 -0
- package/server/lib/config-sync/routes.test.js +154 -0
- package/server/lib/config-sync/scripts.js +264 -0
- package/server/lib/config-sync/selections.js +112 -0
- package/server/lib/config-sync/tar.js +35 -0
- package/server/lib/config-sync/target-id.js +24 -0
- package/server/lib/event-stream/DOCUMENTATION.md +2 -2
- package/server/lib/event-stream/diff-summary.js +39 -11
- package/server/lib/event-stream/diff-summary.test.js +73 -6
- package/server/lib/event-stream/protocol.test.js +70 -7
- package/server/lib/notifications/DOCUMENTATION.md +2 -2
- package/server/lib/notifications/runtime.js +68 -27
- package/server/lib/notifications/runtime.test.js +176 -0
- package/server/lib/opencode/DOCUMENTATION.md +4 -1
- package/server/lib/opencode/bootstrap-runtime.js +2 -0
- package/server/lib/opencode/core-routes.js +1 -0
- package/server/lib/opencode/feature-routes-runtime.test.js +10 -1
- package/server/lib/opencode/openchamber-routes.js +7 -0
- package/server/lib/opencode/settings-runtime.js +82 -51
- package/server/lib/opencode/settings-runtime.test.js +42 -0
- package/server/lib/relay/DOCUMENTATION.md +1 -1
- package/server/lib/session-index/DOCUMENTATION.md +12 -6
- package/server/lib/session-index/routes.js +34 -0
- package/server/lib/session-index/routes.test.js +76 -0
- package/server/lib/session-index/service.js +53 -4
- package/server/lib/session-index/service.test.js +72 -2
- package/server/lib/session-title/DOCUMENTATION.md +19 -14
- package/server/lib/session-title/runtime.js +8 -8
- package/server/lib/session-title/runtime.test.js +231 -0
- package/server/lib/session-turn-pages/DOCUMENTATION.md +26 -6
- package/server/lib/session-turn-pages/changes.service.js +156 -0
- package/server/lib/session-turn-pages/changes.service.test.js +188 -0
- package/server/lib/session-turn-pages/reconcile.routes.test.js +52 -0
- package/server/lib/session-turn-pages/reconcile.service.js +3 -1
- package/server/lib/session-turn-pages/reconcile.service.test.js +44 -0
- package/server/lib/session-turn-pages/routes.js +273 -12
- package/server/lib/session-turn-pages/routes.test.js +387 -0
- package/server/lib/session-turn-pages/service.js +31 -7
- package/server/lib/session-turn-pages/service.test.js +40 -0
- package/server/lib/small-model/DOCUMENTATION.md +93 -38
- package/server/lib/small-model/catalog.js +10 -2
- package/server/lib/small-model/catalog.test.js +3 -1
- package/server/lib/small-model/index.js +52 -28
- package/server/lib/small-model/opencode-session.js +339 -0
- package/server/lib/small-model/opencode-session.test.js +177 -0
- package/server/lib/small-model/resolve.js +116 -5
- package/server/lib/small-model/resolve.test.js +76 -10
- package/server/lib/small-model/summary-settings.test.js +60 -3
- package/dist/assets/MobileSurface-htGkf7Ua.js +0 -2
- package/dist/assets/SettingsView-DxMpVLlt.js +0 -25
- package/dist/assets/appThemeRegistry-CgfOR_0L.js +0 -2
- package/dist/assets/gitApiHttp-D8j1qRH4.js +0 -2
- package/dist/assets/insertionBoundaries-DzXMTleb.js +0 -1
- package/dist/assets/mobile-BktO3_4R.js +0 -2
- package/dist/assets/projectMeta-v-LP2mzz.js +0 -3
- package/dist/assets/renderElectronMiniChatApp-Db8uO-6q.js +0 -2
- package/dist/assets/renderMobileApp-BCV81Ryl.js +0 -23
- package/dist/assets/runtimeEndpointReset-Dg3DMy9v.js +0 -145
- package/dist/assets/src-oHrYIqHF.css +0 -2
- package/dist/assets/useAppFontEffects-CM0VKsdo.js +0 -7
- package/dist/assets/useDesktopWindowControlsLayout-Cq-r4Hcb.js +0 -1
- package/dist/assets/useMobileNavigationStore-DnzT4jO2.js +0 -475
- package/dist/assets/useSessionAutoCleanup-DxZeceKO.js +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownRendererImpl-jVOkZkyX.js","assets/rolldown-runtime-C0FnF6B9.js","assets/useUIStore-5agS8bsW.js","assets/vendor-zustand-B4dlGEM2.js","assets/vendor-base-ui-CnHfUmDN.js","assets/persistence-DPNMIbF5.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-react-DLPElpoQ.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/vendor-reactuses-core-DDoDDyM9.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/clipboard-BW7nk_Cx.js","assets/store-wa1ersRf.js","assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js","assets/useMobileNavigationStore-DnzT4jO2.js","assets/gitApiHttp-D8j1qRH4.js","assets/vendor-opencode-sdk-C07HQypa.js","assets/vendor-tanstack-react-query-D7pys_c9.js","assets/vendor-sonner-DVzioF3d.js","assets/useAssistantUIStore-Bq3cPj2x.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/utils-Co19EJEL.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/useThemeSystem-DMzWVJaW.js","assets/markdownTheme-DNT93i5L.js","assets/vendor-pierre-diffs-BenIz2TM.js","assets/vendor-hast-util-to-html-B0p1k5Xa.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-DpDied8H.js","assets/useRuntimeAPIs-DSLXJybW.js","assets/url-7MqoLs9X.js","assets/markdown-worker-DkeWiER6.js","assets/useEffectiveDirectory-aUC3zzl_.js","assets/FadeInOnReveal-aeWlaqVB.js","assets/vendor-morphdom-BbKiNDAu.js","assets/vendor-beautiful-mermaid-DykqIK5D.js","assets/vendor-marked-WVekxjAN.js","assets/vendor-remend-C3cXc-tf.js","assets/vendor-katex-CNGgSigB.js","assets/vendor-dompurify-CeJNOzik.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{nt as t,rt as n}from"./vendor-base-ui-CnHfUmDN.js";import{a as r,n as i,o as a}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as o}from"./vendor-react-DLPElpoQ.js";import{n as s}from"./vendor-reactuses-core-DDoDDyM9.js";import{ko as c}from"./useMobileNavigationStore-DnzT4jO2.js";import{t as l}from"./utils-Co19EJEL.js";import{a as u,c as d,i as f}from"./markdown-worker-DkeWiER6.js";import{r as p}from"./vendor-pierre-diffs-BenIz2TM.js";var m=o(),h=e(n(),1),g=`openchamber:chunk-import-reload`,_=250,v=3e4,y=[/Importing a module script failed/i,/Failed to fetch dynamically imported module/i,/error loading dynamically imported module/i,/Loading chunk \S+ failed/i,/ChunkLoadError/i];function b(e){if(e instanceof Error)return`${e.name}\n${e.message}\n${e.stack??``}`;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function x(e){let t=b(e);return y.some(e=>e.test(t))}function ee(e){return`1.18.2-beta.2:${b(e).slice(0,500)}`}function S(e){if(typeof window>`u`)return;let t=Date.now(),n=ee(e),r=null;try{let e=window.sessionStorage.getItem(g);if(e)try{r=JSON.parse(e)}catch{r=null}}catch{return}let i=typeof r?.timestamp==`number`?r.timestamp:0;if(!(r?.signature===n&&t-i<v)){try{window.sessionStorage.setItem(g,JSON.stringify({signature:n,timestamp:t}))}catch{return}console.error(`[refresh-debug] chunk-import-reload`,{error:b(e).slice(0,1e3)}),window.setTimeout(()=>{window.location.reload()},0)}}async function te(e,t={}){let n=t.retries??1,r;for(let t=0;t<=n;t+=1)try{return await e()}catch(e){if(r=e,!x(e)||t>=n)break;await new Promise(e=>setTimeout(e,_*(t+1)))}throw x(r)&&S(r),r}var C=e=>(0,h.lazy)(()=>te(e)),w=`__openchamberMobileBackRoute`,T=()=>typeof window>`u`||c()?null:{currentState:()=>window.history.state&&typeof window.history.state==`object`?window.history.state:null,pushState:e=>window.history.pushState(e,``,window.location.href),back:()=>window.history.back(),subscribe:e=>{let t=t=>e(t.state&&typeof t.state==`object`?t.state:null);return window.addEventListener(`popstate`,t),()=>window.removeEventListener(`popstate`,t)}},E=e=>{let t=e?.[w];return typeof t==`number`&&Number.isFinite(t)?t:null},D=new class{routes=[];listeners=new Set;nextToken=1;history;removeHistoryListener=null;programmaticHistoryBackToken=null;pendingHistoryRemovals=new Map;animatedBackDriver=null;presentationCancelDriver=null;constructor(e=T()){this.history=e}subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));getTopRoute=()=>this.routes.at(-1)??null;register=e=>{let t=this.pendingHistoryRemovals.get(e.id);this.pendingHistoryRemovals.delete(e.id);let n=!!(this.history&&t!==void 0&&E(this.history.currentState())===t),r={...e,token:n&&t!==void 0?t:this.nextToken++};this.routes.push(r),this.ensureHistoryListener(),this.history&&!n&&this.history.pushState({...this.history.currentState()??{},[w]:r.token}),this.notify();let i=!0;return()=>{if(!i)return;i=!1;let e=this.routes.indexOf(r);e<0||(this.routes.splice(e,1),this.history&&E(this.history.currentState())===r.token?(this.pendingHistoryRemovals.set(r.id,r.token),queueMicrotask(()=>{if(this.pendingHistoryRemovals.get(r.id)===r.token){if(this.pendingHistoryRemovals.delete(r.id),!this.history||E(this.history.currentState())!==r.token){this.routes.length===0&&this.pendingHistoryRemovals.size===0&&this.disposeHistoryListener();return}this.programmaticHistoryBackToken=r.token,this.history.back(),this.routes.length===0&&this.pendingHistoryRemovals.size===0&&this.disposeHistoryListener()}})):this.routes.length===0&&this.pendingHistoryRemovals.size===0&&this.disposeHistoryListener(),this.notify())}};backImmediately=e=>{let t=this.getTopRoute();return!t||e&&t.layer!==e?!1:t.onBack()!==!1};requestAnimatedBack=e=>{let t=this.getTopRoute();return!t||e&&t.layer!==e?!1:this.animatedBackDriver?.(t)?!0:this.backImmediately(e)};setAnimatedBackDriver=e=>(this.animatedBackDriver=e,()=>{this.animatedBackDriver===e&&(this.animatedBackDriver=null)});setPresentationCancelDriver=e=>(this.presentationCancelDriver=e,()=>{this.presentationCancelDriver===e&&(this.presentationCancelDriver=null)});cancelPresentation=()=>{this.presentationCancelDriver?.()};requestBrowserBack=()=>{let e=this.getTopRoute();return e?this.history&&E(this.history.currentState())===e.token?(this.history.back(),!0):e.onBack()!==!1:!1};ensureHistoryListener(){!this.history||this.removeHistoryListener||(this.removeHistoryListener=this.history.subscribe(e=>{if(this.programmaticHistoryBackToken!==null){this.programmaticHistoryBackToken=null;return}let t=this.getTopRoute();t&&E(e)!==t.token&&t.onBack()===!1&&this.history&&this.history.pushState({...this.history.currentState()??{},[w]:t.token})}))}disposeHistoryListener(){this.removeHistoryListener?.(),this.removeHistoryListener=null,this.programmaticHistoryBackToken=null,this.pendingHistoryRemovals.clear()}notify(){this.listeners.forEach(e=>e())}},ne=e=>{let t=(0,m.c)(8),{id:n,active:r,layer:i,onBack:a,surfaceRef:o,underlayRef:c}=e,l=i===void 0?`root`:i,u=s(a),d,f;t[0]!==r||t[1]!==u||t[2]!==n||t[3]!==l||t[4]!==o||t[5]!==c?(d=()=>{if(r)return D.register({id:n,layer:l,onBack:u,getSurface:()=>o.current,getUnderlay:()=>c?.current??null})},f=[r,u,n,l,o,c],t[0]=r,t[1]=u,t[2]=n,t[3]=l,t[4]=o,t[5]=c,t[6]=d,t[7]=f):(d=t[6],f=t[7]),h.useEffect(d,f)},O=r(`OpenChamberNavigation`),k=e=>Math.min(1,Math.max(0,Number.isFinite(e)?e:0)),A=(e,t)=>!e||!t?!1:e.onBack()!==!1,j=e=>{let t=k(e.progress),n=e.commit?1-t:t;if(n<=.001)return 0;let r=Math.max(1,e.viewportWidth??390),i=Math.abs(e.velocityX??0)/r,a=n/Math.max(e.commit?2.4:2.8,i)*1e3,o=e.commit?90:100,s=e.commit?320:260;return Math.round(Math.min(s,Math.max(o,a)))},M=e=>{let{surface:t,underlay:n,surfaceTransition:r,surfaceAnimation:i,underlayTransition:a,underlayAnimation:o}=e;t.style.removeProperty(`transform`),t.style.removeProperty(`opacity`),t.style.removeProperty(`will-change`),t.style.removeProperty(`box-shadow`),t.style.transition=r,t.style.animation=i,n&&(n.style.removeProperty(`transform`),n.style.removeProperty(`opacity`),n.style.removeProperty(`will-change`),n.style.transition=a??``,n.style.animation=o??``)},N=(e,t)=>{let n=k(t),{surface:r}=e;r.style.transform=`translate3d(${n*100}%, 0, 0)`},re=e=>!e.surfaceConnected||e.topRouteToken!==e.routeToken||e.routeSurface!==e.outgoingSurface,ie=async(e,t,n,r)=>{if(!r&&typeof e.animate==`function`){let r=e.style.transform||`translate3d(0%, 0, 0)`,i=`translate3d(${t}%, 0, 0)`,a=e.animate([{transform:r},{transform:i}],{duration:n,easing:`cubic-bezier(0.22, 1, 0.36, 1)`,fill:`forwards`}),o=!1;try{await a.finished,o=!0}catch{}finally{o&&(e.style.transform=i),a.cancel()}return}e.style.transform=`translate3d(${t}%, 0, 0)`},ae=async(e,t,n=typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches,r=j({progress:Number.parseFloat(e.style.transform.match(/translate3d\(([-\d.]+)%/)?.[1]??`0`)/100,commit:t}))=>ie(e,t?100:0,r,n),oe=class{pending=0;enqueue(){this.pending+=1}take(){return this.pending!==0&&(--this.pending,!0)}clear(){this.pending=0}},se=e=>{let t=(0,m.c)(4),{enabled:n,rootRoutesBlocked:r}=e,a,o;t[0]!==n||t[1]!==r?(a=()=>{if(!n||!c()||i.getPlatform()===`web`)return;let e=!1,t=null,a=null,o=0,s=0,l=0,u=new oe,d=[],f=e=>!!e&&(!r||e?.layer===`overlay`),p=()=>{let e=f(D.getTopRoute());O.setEnabled({enabled:e}).catch(ce)},m=()=>{if(D.cancelPresentation(),a)return;let e=D.getTopRoute();if(!f(e))return;let n=e.getSurface();if(!n)return;n.getAnimations().forEach(le),a=null;let r=e.layer===`root`?e.getUnderlay():null,i=n.style.transition,o=n.style.animation,s=r?.style.transition??null,c=r?.style.animation??null;r?.getAnimations().forEach(P),n.style.transition=`none`,n.style.animation=`none`,n.style.willChange=`transform`,r&&(r.style.removeProperty(`transform`),r.style.removeProperty(`will-change`)),l+=1,t={route:e,surface:n,underlay:r,surfaceTransition:i,surfaceAnimation:o,underlayTransition:s,underlayAnimation:c},N(t,0)},h=e=>{s=k(e),!o&&(o=window.requestAnimationFrame(()=>{o=0,t&&N(t,s)}))},g=F,_=(n,r,i)=>{if(a)return n&&f(D.getTopRoute())?(u.enqueue(),!0):!1;o&&=(window.cancelAnimationFrame(o),0),t||m(),t&&r!==void 0&&N(t,r);let c=t,d=l;if(t=null,!c){if(!n)return!1;let e=D.getTopRoute();return A(e,f(e))}a=c;let p=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1,h=j({progress:k(r??s),commit:n,velocityX:i,viewportWidth:window.innerWidth});return ae(c.surface,n,p,h).then(async()=>{d===l&&(!e&&n&&(c.route.onBack(),await g(c)),d===l&&(M(c),a===c&&(a=null),!e&&u.take()&&_(!0,0,0)))}),!0},v=D.setAnimatedBackDriver(e=>e!==D.getTopRoute()||!f(e)?!1:_(!0,0,0)),y=D.subscribe(p);return(async()=>{let t=await O.addListener(`backStarted`,m),n=await O.addListener(`backProgressed`,e=>h(e.progress??0)),r=await O.addListener(`backCancelled`,e=>_(!1,e.progress,e.velocityX)),i=await O.addListener(`backInvoked`,e=>_(!0,e.progress,e.velocityX));if(e){await Promise.all([t.remove(),n.remove(),r.remove(),i.remove()]);return}d.push(t,n,r,i),p()})().catch(I),p(),()=>{e=!0,l+=1,u.clear(),y(),v(),o&&window.cancelAnimationFrame(o),t&&M(t),a&&(a.surface.getAnimations().forEach(L),a.underlay?.getAnimations().forEach(R),M(a)),t=null,a=null,O.setEnabled({enabled:!1}).catch(z),d.forEach(B)}},o=[n,r],t[0]=n,t[1]=r,t[2]=a,t[3]=o):(a=t[2],o=t[3]),h.useEffect(a,o)};function ce(){}function le(e){return e.cancel()}function P(e){return e.cancel()}function F(e){return new Promise(t=>{let n=0,r=12,i=!1,a=()=>{i||(i=!0,c(),n&&window.cancelAnimationFrame(n),t())},o=()=>{let t=D.getTopRoute();return re({surfaceConnected:e.surface.isConnected,routeToken:e.route.token,topRouteToken:t?.token??null,routeSurface:e.route.getSurface(),outgoingSurface:e.surface})},s=()=>{if(o()||r<=0){a();return}--r,n=window.requestAnimationFrame(s)},c=D.subscribe(()=>{o()&&a()});s()})}function I(){}function L(e){return e.cancel()}function R(e){return e.cancel()}function z(){}function B(e){e.remove()}var V=null,H=()=>(V??=a(()=>import(`./MarkdownRendererImpl-jVOkZkyX.js`),__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])).catch(e=>{throw V=null,e}),V),U=()=>{H().catch(()=>void 0)},W=h.createContext(!0),G=()=>h.useContext(W),K=t(),ue=C(()=>H().then(e=>({default:e.MarkdownRenderer}))),de=C(()=>H().then(e=>({default:e.SimpleMarkdownRenderer}))),fe=e=>e===`tool`?`markdown-content markdown-tool`:e===`reasoning`?`markdown-content markdown-reasoning`:`markdown-content leading-relaxed`,q=e=>{let t=(0,m.c)(14),n=typeof e.content==`string`?e.content:``,r=typeof e.variant==`string`?e.variant:`assistant`,i;t[0]!==n||t[1]!==e.reserveMeasuredHeight||t[2]!==r?(i=e.reserveMeasuredHeight?u(f(n,r)):void 0,t[0]=n,t[1]=e.reserveMeasuredHeight,t[2]=r,t[3]=i):i=t[3];let a=i,o;t[4]!==e.className||t[5]!==e.variant?(o=l(`relative break-words w-full min-w-0`,fe(e.variant),typeof e.className==`string`?e.className:void 0),t[4]=e.className,t[5]=e.variant,t[6]=o):o=t[6];let s;t[7]!==n||t[8]!==e.animated||t[9]!==a?(s=(0,K.jsx)(d,{animated:e.animated,content:n,reservedHeight:a}),t[7]=n,t[8]=e.animated,t[9]=a,t[10]=s):s=t[10];let c;return t[11]!==o||t[12]!==s?(c=(0,K.jsx)(`div`,{className:o,"aria-busy":`true`,"data-markdown-hydration":`deferred`,children:s}),t[11]=o,t[12]=s,t[13]=c):c=t[13],c},pe=e=>{let t=(0,m.c)(4);if(!G()&&e.isStreaming!==!0){let n;return t[0]===e?n=t[1]:(n=(0,K.jsx)(q,{...e,animated:!1,reserveMeasuredHeight:!0}),t[0]=e,t[1]=n),n}let n;return t[2]===e?n=t[3]:(n=(0,K.jsx)(h.Suspense,{fallback:(0,K.jsx)(q,{...e,reserveMeasuredHeight:!0}),children:(0,K.jsx)(ue,{...e})}),t[2]=e,t[3]=n),n},me=e=>{let t=(0,m.c)(4);if(!G()){let n;return t[0]===e?n=t[1]:(n=(0,K.jsx)(q,{...e,animated:!1}),t[0]=e,t[1]=n),n}let n;return t[2]===e?n=t[3]:(n=(0,K.jsx)(h.Suspense,{fallback:(0,K.jsx)(q,{...e}),children:(0,K.jsx)(de,{...e})}),t[2]=e,t[3]=n),n},he=e=>/^#[0-9a-fA-F]{6}$/.test(e),ge=e=>/^#[0-9a-fA-F]{8}$/.test(e),_e=(e,t)=>/^[0-9a-fA-F]{2}$/.test(t)?he(e)?`${e}${t}`:ge(e)?`${e.slice(0,7)}${t}`:e:e,J=(e,t)=>typeof e==`string`&&e.trim().length>0?e:t,Y=e=>{let t=e.colors.syntax.base,n=e.colors.syntax.tokens??{},r=(e,t)=>J(n[e],t);return[{name:`plain`,scope:[`source`,`support.type.property-name.css`],settings:{foreground:t.foreground}},{name:`classes`,scope:[`entity.name.type.class`],settings:{foreground:r(`className`,r(`class`,t.function))}},{name:`interfaces`,scope:[`entity.name.type.interface`,`entity.name.type`],settings:{foreground:r(`interface`,t.type)}},{name:`structs`,scope:[`entity.name.type.struct`],settings:{foreground:r(`struct`,t.function)}},{name:`enums`,scope:[`entity.name.type.enum`],settings:{foreground:r(`enum`,t.function)}},{name:`keys`,scope:[`meta.object-literal.key`,`support.type.property-name`],settings:{foreground:r(`key`,t.function)}},{name:`methods`,scope:[`entity.name.function.method`,`meta.function.method`],settings:{foreground:r(`method`,e.colors.status.success)}},{name:`functions`,scope:[`entity.name.function`,`support.function`,`meta.function-call.generic`],settings:{foreground:t.function,fontStyle:`bold`}},{name:`variables`,scope:[`variable`,`meta.variable`,`variable.other.object.property`],settings:{foreground:t.variable}},{name:`variablesOther`,scope:[`variable.other.object`,`variable.other.readwrite.alias`],settings:{foreground:r(`variableOther`,r(`method`,e.colors.status.success))}},{name:`globalVariables`,scope:[`variable.other.global`,`variable.language.this`],settings:{foreground:r(`variableGlobal`,t.number)}},{name:`localVariables`,scope:[`variable.other.local`],settings:{foreground:r(`variableLocal`,e.colors.surface.elevated)}},{name:`parameters`,scope:[`variable.parameter`,`meta.parameter`],settings:{foreground:r(`parameter`,t.foreground)}},{name:`properties`,scope:[`variable.other.property`,`meta.property`],settings:{foreground:r(`variableProperty`,e.colors.status.info)}},{name:`strings`,scope:[`string`,`string.other.link`,`markup.inline.raw.string.markdown`],settings:{foreground:t.string}},{name:`stringEscapeSequences`,scope:[`constant.character.escape`,`constant.other.placeholder`],settings:{foreground:r(`stringEscape`,t.foreground)}},{name:`keywords`,scope:[`keyword`],settings:{foreground:t.keyword}},{name:`keywordsControl`,scope:[`keyword.control.import`,`keyword.control.from`,`keyword.import`],settings:{foreground:r(`keywordImport`,t.operator)}},{name:`storageModifiers`,scope:[`storage.modifier`,`keyword.modifier`,`storage.type`],settings:{foreground:r(`storageModifier`,t.keyword)}},{name:`comments`,scope:[`comment`,`punctuation.definition.comment`],settings:{foreground:t.comment}},{name:`docComments`,scope:[`comment.documentation`,`comment.line.documentation`],settings:{foreground:r(`commentDoc`,e.colors.surface.mutedForeground)}},{name:`numbers`,scope:[`constant.numeric`],settings:{foreground:t.number}},{name:`booleans`,scope:[`constant.language.boolean`,`constant.language.json`],settings:{foreground:r(`boolean`,t.type)}},{name:`operators`,scope:[`keyword.operator`],settings:{foreground:t.operator}},{name:`macros`,scope:[`entity.name.function.preprocessor`,`meta.preprocessor`],settings:{foreground:r(`macro`,t.keyword)}},{name:`preprocessor`,scope:[`meta.preprocessor`],settings:{foreground:r(`preprocessor`,r(`label`,t.number))}},{name:`urls`,scope:[`markup.underline.link`],settings:{foreground:r(`url`,e.colors.status.info)}},{name:`tags`,scope:[`entity.name.tag`],settings:{foreground:r(`tag`,t.keyword)}},{name:`jsxTags`,scope:[`support.class.component`],settings:{foreground:r(`jsxTag`,r(`label`,t.number))}},{name:`attributes`,scope:[`entity.other.attribute-name`,`meta.attribute`],settings:{foreground:r(`tagAttribute`,t.type)}},{name:`types`,scope:[`support.type`],settings:{foreground:t.type}},{name:`constants`,scope:[`variable.other.constant`,`variable.readonly`],settings:{foreground:r(`constant`,t.foreground)}},{name:`labels`,scope:[`entity.name.label`,`punctuation.definition.label`],settings:{foreground:r(`label`,r(`variableGlobal`,t.number))}},{name:`namespaces`,scope:[`entity.name.namespace`,`storage.modifier.namespace`,`markup.bold.markdown`],settings:{foreground:r(`namespace`,t.type)}},{name:`modules`,scope:[`entity.name.module`,`storage.modifier.module`],settings:{foreground:r(`module`,t.operator)}},{name:`typeParameters`,scope:[`variable.type.parameter`,`variable.parameter.type`],settings:{foreground:r(`typeParameter`,t.function)}},{name:`exceptions`,scope:[`keyword.control.exception`,`keyword.control.trycatch`],settings:{foreground:r(`exception`,r(`label`,t.number))}},{name:`decorators`,scope:[`meta.decorator`,`punctuation.decorator`,`entity.name.function.decorator`],settings:{foreground:r(`decorator`,t.type)}},{name:`calls`,scope:[`variable.function`],settings:{foreground:t.foreground}},{name:`punctuation`,scope:[`punctuation`,`punctuation.terminator`,`punctuation.definition.tag`,`punctuation.separator`,`punctuation.definition.string`,`punctuation.section.block`],settings:{foreground:r(`punctuation`,t.comment)}},{name:`yellow`,scope:[`storage.type.numeric.go`,`storage.type.byte.go`,`storage.type.boolean.go`,`storage.type.string.go`,`storage.type.uintptr.go`,`storage.type.error.go`,`storage.type.rune.go`,`constant.language.go`,`support.class.dart`,`keyword.other.documentation`,`storage.modifier.import.java`,`punctuation.definition.list.begin.markdown`,`punctuation.definition.quote.begin.markdown`,`meta.separator.markdown`,`entity.name.section.markdown`],settings:{foreground:t.type}},{name:`green`,scope:[],settings:{foreground:r(`method`,e.colors.status.success)}},{name:`cyan`,scope:[`markup.italic.markdown`,`support.type.python`,`variable.legacy.builtin.python`,`support.constant.property-value.css`,`storage.modifier.attribute.swift`],settings:{foreground:t.string}},{name:`blue`,scope:[],settings:{foreground:t.keyword}},{name:`purple`,scope:[`keyword.channel.go`,`keyword.other.platform.os.swift`],settings:{foreground:t.number}},{name:`magenta`,scope:[`punctuation.definition.heading.markdown`],settings:{foreground:r(`label`,r(`variableGlobal`,t.number))}},{name:`red`,scope:[],settings:{foreground:t.operator}},{name:`orange`,scope:[],settings:{foreground:t.function}}]},ve=e=>{let t=e.colors.surface,n=e.colors.interactive,r=e.colors.status,i=e.colors.syntax.base,a=e.colors.syntax.highlights??{},o=J(a.diffAddedBackground,r.successBackground),s=J(a.diffRemovedBackground,r.errorBackground);return{"editor.background":t.background,"editor.foreground":t.foreground,"editor.hoverHighlightBackground":J(n.hover,t.subtle),"editor.lineHighlightBackground":t.muted,"editor.selectionBackground":n.selection,"editor.selectionHighlightBackground":n.selection,"editor.findMatchBackground":i.type,"editor.findMatchHighlightBackground":_e(i.type,`cc`),"editor.findRangeHighlightBackground":t.muted,"editor.inactiveSelectionBackground":t.elevated,"editor.lineHighlightBorder":t.elevated,"editor.rangeHighlightBackground":J(n.active,n.borderHover),"notifications.background":t.elevated,"editorInlayHint.typeBackground":t.subtle,"editorInlayHint.typeForeground":t.foreground,"editorWhitespace.foreground":n.borderHover,"editorIndentGuide.background1":t.subtle,"editorHoverWidget.background":t.elevated,"editorLineNumber.activeForeground":J(a.lineNumberActive,t.foreground),"editorLineNumber.foreground":J(a.lineNumber,t.mutedForeground),"editorGutter.background":t.background,"editorGutter.modifiedBackground":r.info,"editorGutter.addedBackground":r.success,"editorGutter.deletedBackground":r.error,"editorBracketMatch.background":t.elevated,"editorBracketMatch.border":t.subtle,"editorError.foreground":r.error,"editorWarning.foreground":r.warning,"editorInfo.foreground":r.info,"diffEditor.insertedTextBackground":o,"diffEditor.removedTextBackground":s,"editorGroupHeader.tabsBackground":t.background,"editorGroup.border":n.border,"tab.activeBackground":t.background,"tab.inactiveBackground":t.muted,"tab.inactiveForeground":t.mutedForeground,"tab.activeForeground":t.foreground,"tab.hoverBackground":t.subtle,"tab.unfocusedHoverBackground":t.subtle,"tab.border":n.border,"tab.activeModifiedBorder":i.type,"tab.inactiveModifiedBorder":r.info,"tab.unfocusedActiveModifiedBorder":i.type,"tab.unfocusedInactiveModifiedBorder":r.info,"editorWidget.background":t.muted,"editorWidget.border":n.border,"editorSuggestWidget.background":t.background,"editorSuggestWidget.border":n.border,"editorSuggestWidget.foreground":t.foreground,"editorSuggestWidget.highlightForeground":t.mutedForeground,"editorSuggestWidget.selectedBackground":t.subtle,"peekView.border":n.border,"peekViewEditor.background":t.background,"peekViewEditor.matchHighlightBackground":t.subtle,"peekViewResult.background":t.muted,"peekViewResult.fileForeground":t.foreground,"peekViewResult.lineForeground":t.mutedForeground,"peekViewResult.matchHighlightBackground":t.subtle,"peekViewResult.selectionBackground":t.elevated,"peekViewResult.selectionForeground":t.mutedForeground,"peekViewTitle.background":t.subtle,"peekViewTitleDescription.foreground":t.mutedForeground,"peekViewTitleLabel.foreground":t.foreground,"merge.currentHeaderBackground":r.success,"merge.currentContentBackground":J(a.diffAdded,r.success),"merge.incomingHeaderBackground":r.info,"merge.incomingContentBackground":J(a.diffModified,r.info),"merge.border":n.border,"merge.commonContentBackground":t.subtle,"merge.commonHeaderBackground":t.muted,"panel.background":t.background,"panel.border":n.border,"panelTitle.activeBorder":n.borderHover,"panelTitle.activeForeground":t.foreground,"panelTitle.inactiveForeground":t.mutedForeground,"statusBar.background":t.background,"statusBar.foreground":t.foreground,"statusBar.border":n.border,"statusBar.debuggingBackground":r.error,"statusBar.debuggingForeground":r.errorForeground,"statusBar.noFolderBackground":t.subtle,"statusBar.noFolderForeground":t.mutedForeground,"titleBar.activeBackground":t.background,"titleBar.activeForeground":t.foreground,"titleBar.inactiveBackground":t.muted,"titleBar.inactiveForeground":t.mutedForeground,"titleBar.border":n.border,"menu.foreground":t.foreground,"menu.background":t.background,"menu.selectionForeground":t.foreground,"menu.selectionBackground":t.subtle,"menu.border":n.border,"editorInlayHint.foreground":t.mutedForeground,"editorInlayHint.background":t.subtle,"terminal.foreground":t.foreground,"terminal.background":t.background,"terminalCursor.foreground":t.foreground,"terminalCursor.background":t.background,"terminal.ansiRed":J(a.diffRemoved,r.error),"terminal.ansiGreen":J(a.diffAdded,r.success),"terminal.ansiYellow":r.warning,"terminal.ansiBlue":J(a.diffModified,r.info),"terminal.ansiMagenta":i.keyword,"terminal.ansiCyan":i.type,"activityBar.background":t.background,"activityBar.foreground":t.foreground,"activityBar.inactiveForeground":t.mutedForeground,"activityBar.activeBorder":t.foreground,"activityBar.border":n.border,"sideBar.background":t.background,"sideBar.foreground":t.foreground,"sideBar.border":n.border,"sideBarTitle.foreground":t.foreground,"sideBarSectionHeader.background":t.muted,"sideBarSectionHeader.foreground":t.foreground,"sideBarSectionHeader.border":n.border,"sideBar.activeBackground":t.subtle,"sideBar.activeForeground":t.foreground,"sideBar.hoverBackground":t.muted,"sideBar.hoverForeground":t.foreground,"list.warningForeground":r.warning,"list.errorForeground":r.error,"list.inactiveSelectionBackground":t.subtle,"list.activeSelectionBackground":t.elevated,"list.inactiveSelectionForeground":t.foreground,"list.activeSelectionForeground":t.foreground,"list.hoverForeground":t.foreground,"list.hoverBackground":t.muted,"input.background":t.muted,"input.foreground":t.foreground,"input.border":n.border,"input.placeholderForeground":t.mutedForeground,"inputOption.activeBorder":n.border,"inputOption.activeBackground":t.elevated,"inputOption.activeForeground":t.foreground,"inputValidation.infoBackground":r.infoBackground,"inputValidation.infoBorder":r.infoBorder,"inputValidation.warningBackground":r.warningBackground,"inputValidation.warningBorder":r.warningBorder,"inputValidation.errorBackground":r.errorBackground,"inputValidation.errorBorder":r.errorBorder,"dropdown.background":t.muted,"dropdown.foreground":t.foreground,"dropdown.border":n.border,"dropdown.listBackground":t.background,"badge.background":e.colors.primary.base,"activityBarBadge.background":e.colors.primary.base,"button.background":e.colors.primary.base,"button.foreground":J(e.colors.primary.foreground,t.background),"badge.foreground":J(e.colors.primary.foreground,t.background),"activityBarBadge.foreground":J(e.colors.primary.foreground,t.background)}};function ye(e){return{name:e.metadata.name,type:e.metadata.variant,colors:ve(e),tokenColors:Y(e)}}var be=e=>/^#[0-9a-fA-F]{8}$/.test(e),X=e=>be(e)?e.slice(0,7):e;function xe(e,t){return Object.defineProperty(e,"toString",{value:()=>t,enumerable:!1,configurable:!0}),Object.defineProperty(e,Symbol.toPrimitive,{value:()=>t,enumerable:!1,configurable:!0}),e}var Z=new Map,Q=new Set,Se=(e,t)=>{let n=e.colors?.[`editor.background`],r=e.colors?.[`editor.foreground`],i=n?X(n):void 0,a=r?X(r):void 0;if(!i||!a)throw Error(`Theme "${t}" is missing editor.background/editor.foreground`);let o=e.tokenColors??[];return xe({...e,name:t,fg:a,bg:i,settings:o},t)},Ce=e=>ye(e),$=e=>{let t=Z.get(e.metadata.id);if(t)return t;let n=Se(Ce(e),e.metadata.id);return Z.set(e.metadata.id,n),n},we=e=>{let t=e.metadata.id;if(Q.has(t))return;let n=$(e);p(t,async()=>n),Q.add(t)};export{W as a,ne as c,me as i,se as l,$ as n,U as o,pe as r,D as s,we as t,C as u};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-heic2any-CUPf3g2A.js","assets/rolldown-runtime-C0FnF6B9.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{A as t,D as n,E as r,F as i,H as a,T as o,X as s,b as c,et as l,j as u,nt as d}from"./useUIStore-5agS8bsW.js";import{$t as f,Mt as p,Pt as m,kn as h,nt as g,ot as ee,pt as te,r as _,st as v,xn as ne,zt as re}from"./persistence-DPNMIbF5.js";import{a as ie,r as ae}from"./vendor-zustand-B4dlGEM2.js";import{t as oe}from"./vendor-opencode-sdk-C07HQypa.js";import{i as se}from"./vendor-pathe-vBmvQE8f.js";import{o as ce}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";var le=(e,t)=>e!==t,ue=new Set([`image/heic`,`image/heif`]),de=!1,fe=()=>{let e=globalThis.window?.Capacitor;return e&&typeof e==`object`?e:null},pe=e=>ue.has((e.type||``).toLowerCase()),me=async e=>{let t=new Uint8Array(await e.arrayBuffer()),n=``,r=32768;for(let e=0;e<t.byteLength;e+=r){let i=t.subarray(e,Math.min(e+r,t.byteLength));n+=String.fromCharCode(...i)}return btoa(n)},he=(e,t)=>{let n=atob(e),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return new Blob([r],{type:t})},ge=async e=>{if(!pe(e)||de)return null;let t=fe();if(!t||typeof t.isNativePlatform!=`function`||!t.isNativePlatform())return null;let n=t.Plugins?.OpenChamberMedia?.transcode;if(typeof n!=`function`)return null;try{let t=await n({data:await me(e),mime:e.type.toLowerCase(),quality:.9});if(typeof t?.data!=`string`||!t.data)return null;let r=typeof t.mime==`string`&&t.mime?t.mime:`image/jpeg`;return he(t.data,r)}catch(e){return de=!0,console.warn(`Native HEIC transcode failed`,e),null}},_e=e=>e.trim().toLowerCase(),ve=e=>e.source===`local`||e.source===`server`||e.source===`vscode`,ye=(e,t)=>{if(!e||!e.includes(`[`)||t.length===0)return[];let n=new Set(t.map(_e)),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=te(e.slice(t+1,a)).trim();n.has(_e(i))&&r.push({start:t,end:a+1})}i=a+1}return r},be=(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}},xe=(e,t,n,r)=>{let i=ye(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}=be(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}},Se=new Set([`image`,`screenshot`,`screen-shot`,`clipboard`,`pasted-image`,`pastedimage`,`untitled`,`unknown`,`file`,`blob`]),Ce={"image/avif":`avif`,"image/bmp":`bmp`,"image/gif":`gif`,"image/heic":`heic`,"image/heif":`heif`,"image/jpeg":`jpg`,"image/jpg":`jpg`,"image/png":`png`,"image/svg+xml":`svg`,"image/tiff":`tiff`,"image/webp":`webp`},y=e=>e.trim().toLowerCase(),we=e=>e.charCodeAt(0)<32||`<>:"/\\|?*[]`.includes(e),Te=e=>{let t=e.replace(/\\/g,`/`).split(`/`).pop()??``;return Array.from(t).map(e=>we(e)?`-`:e).join(``).replace(/\s+/g,` `).replace(/-+/g,`-`).trim()},Ee=e=>Ce[e?.trim().toLowerCase()??``]??`png`,De=e=>{let t=Te(e.name),n=Ee(e.type),r=t.lastIndexOf(`.`);if(r>0&&r<t.length-1){let e=t.slice(r+1).toLowerCase();if(/^[a-z0-9]{1,10}$/.test(e))return{base:t.slice(0,r).trim()||`image`,ext:e}}return{base:t.trim()||`image`,ext:n}},Oe=e=>{let{base:t}=De({name:e}),n=t.trim().toLowerCase().replace(/[\s_]+/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``);if(Se.has(n))return!0;let r=n.replace(/-\(\d+\)$/g,``);return r!==n&&Se.has(r)?!0:/^(image|file|unknown|untitled|blob)-\d+$/.test(n)},b=(e,t)=>`${e}.${t}`,ke=(e,t,n)=>{let r=b(e,t);if(!n.has(y(r)))return r;for(let r=2;r<2**53-1;r+=1){let i=b(`${e}-${r}`,t);if(!n.has(y(i)))return i}return b(`${e}-${Date.now()}`,t)},Ae=(e,t)=>{for(let n=1;n<2**53-1;n+=1){let r=b(`image-${n}`,e);if(!Array.from(t).some(e=>e.startsWith(`image-${n}.`))&&!t.has(y(r)))return r}return b(`image-${Date.now()}`,e)},je=(e,t)=>{let n=new Set(t.map(y));return e.map(e=>{let{base:t,ext:r}=De(e),i=Oe(b(t,r))?Ae(r,n):ke(t,r,n);return n.add(y(i)),i})},Me=e=>e.map(e=>v(e)).join(` `),Ne=(e,t,n)=>{if(t===n)return[];let r=[];for(let i of e){let e=[v(i),`[${i}]`],a=e.some(e=>t.includes(e)),o=e.some(e=>n.includes(e));a&&!o&&r.push(i)}return r},Pe=e=>e.replaceAll(`[${ee}`,`[`),Fe=/\.(?:png|jpe?g|gif|webp|svg|avif|bmp|heic|heif|tiff?)$/i,Ie=e=>{let t=e.trim();return t.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(t)||t.startsWith(`\\\\`)},Le=(e,t)=>{let n=e;for(let e of t){let t=e.filename.trim(),r=e.path.trim();if(!t||!r||t===r||Ie(t)||!Fe.test(t)&&!Fe.test(r))continue;let i=`[${r}]`;n=n.split(v(t)).join(i).split(`[${t}]`).join(i)}return n},Re=(e,t)=>{let n=e;for(let e of t??[]){if(e.source!==`vscode`||e.vscodeSource!==`selection`||!e.vscodePath)continue;let t=e.filename.match(/:(\d+(?:-\d+)?)$/)?.[1];if(!t)continue;let r=`[${e.vscodePath}:${t}]`;n=n.split(v(e.filename)).join(r).split(`[${e.filename}]`).join(r)}return n},ze=e=>e.mime===`text/plain`&&typeof e.filename==`string`&&/:\d+(?:-\d+)?$/.test(e.filename),Be=`application/x-directory`,Ve=e=>typeof e==`string`&&e.trim().toLowerCase()===`application/x-directory`,He=e=>typeof e==`string`&&/[/\\]$/.test(e.trim()),Ue=(e,t,n)=>{if(t===`Backspace`){let t=n;for(;t>0&&/\s/.test(e[t-1]);)--t;for(;t>0&&!/\s/.test(e[t-1]);)--t;return{start:t,end:n}}let r=n;for(;r<e.length&&/\s/.test(e[r]);)r+=1;for(;r<e.length&&!/\s/.test(e[r]);)r+=1;return{start:n,end:r}},We=(e,t,n)=>{let r=Math.max(0,Math.min(n.selectionStart,e.length)),i=Math.max(r,Math.min(n.selectionEnd,e.length)),a;if(a=r===i?n.altKey?Ue(e,n.key,r):n.key===`Backspace`?{start:Math.max(0,r-1),end:r}:{start:r,end:Math.min(e.length,r+1)}:{start:r,end:i},a.start===a.end)return null;let o=ye(e,t).filter(e=>e.start<a.end&&e.end>a.start);if(o.length===0)return null;let s=Math.min(a.start,...o.map(e=>e.start)),c=Math.max(a.end,...o.map(e=>e.end));return c<e.length&&/\s/.test(e[c])&&(s===0||/\s/.test(e[s-1]))?c+=1:c===e.length&&s>0&&/\s/.test(e[s-1])&&--s,{text:`${e.slice(0,s)}${e.slice(c)}`,caret:s,removedFilenames:o.map(t=>te(e.slice(t.start+1,t.end-1)).trim())}},x=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}},S=`file://`,Ge=e=>{let t=e.trim();if(t.toLowerCase().startsWith(S))return t;let n=se(t).split(`/`).map(e=>/^[A-Za-z]:$/.test(e)?e:encodeURIComponent(e)).join(`/`);return/^[A-Za-z]:/.test(n)?`${S}/${n}`:`${S}${n}`},Ke=e=>{let t=e.trim();if(!t.toLowerCase().startsWith(S))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},qe=async e=>[...new Uint8Array(await crypto.subtle.digest(`SHA-256`,await e.arrayBuffer()))].map(e=>e.toString(16).padStart(2,`0`)).join(``),Je=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Ye=async e=>{let t;try{t=await e.json()}catch{throw new x(e.status,`unavailable`)}if(!Je(t)||typeof t.path!=`string`||!t.path)throw new x(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:Ge(t.path),mime:n,size:r,sha256:i}},Xe=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}`},Ze=(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}},Qe=e=>e.startsWith(`data:`)||e.startsWith(`blob:`),$e=async e=>{let t=e.mime||e.body.type||`application/octet-stream`,n=e.body.type===t?e.body:new Blob([e.body],{type:t});if(!Number.isSafeInteger(n.size)||n.size<0||n.size>26214400)throw new x(413,`too-large`);let r=await qe(n),i=Xe(e.filename),a;try{a=await h(`/api/fs/prompt-attachments/${encodeURIComponent(i)}`,{method:`PUT`,headers:{"Content-Type":t,"Content-Length":String(n.size),"X-OpenChamber-Content-Length":String(n.size),"X-OpenChamber-Sha256":r,"X-OpenChamber-Mime":t,...e.filename?{"X-OpenChamber-Filename":encodeURIComponent(e.filename)}:{}},body:n,signal:e.signal})}catch{throw new x(0,`unavailable`)}if(a.status===413)throw new x(413,`too-large`);if(!a.ok)throw new x(a.status,a.status>=500||a.status===0?`unavailable`:`rejected`);let o=await Ye(a);if(o.size!==n.size)throw new x(a.status,`unavailable`);return{...o,mime:t}},et=500,tt=()=>{if(typeof window>`u`)return!1;try{return new URLSearchParams(window.location.search).get(`startupTrace`)===`1`||window.localStorage?.getItem(`OPENCHAMBER_STARTUP_TRACE`)===`1`}catch{return!1}},nt=()=>tt(),C=(e,t)=>{if(!tt())return;let n=typeof performance<`u`?performance.now():Date.now();window.__OPENCHAMBER_STARTUP_TRACE_START__??=n,window.__OPENCHAMBER_STARTUP_TRACE__??=[],window.__OPENCHAMBER_STARTUP_TRACE__.push({t:Math.round(n-window.__OPENCHAMBER_STARTUP_TRACE_START__),name:e,...t?{data:t}:{}}),window.__OPENCHAMBER_STARTUP_TRACE__.length>et&&window.__OPENCHAMBER_STARTUP_TRACE__.splice(0,window.__OPENCHAMBER_STARTUP_TRACE__.length-et)};typeof window<`u`&&(window.__OPENCHAMBER_STARTUP_TRACE_SUMMARY__=()=>{let e=typeof window<`u`?window.__OPENCHAMBER_STARTUP_TRACE__??[]:[],t=e.findIndex(e=>e.name===`ModelControls:ready`),n=t>=0?Math.min(e.length,t+8):e.length;return e.slice(0,n).filter(e=>e.name.includes(`checkConnection`)||e.name.includes(`checkHealth`)||e.name.includes(`initializeApp`)||e.name.includes(`initApp`)||e.name.includes(`loadProviders`)||e.name.includes(`loadAgents`)||e.name.includes(`config.defaults`)||e.name.includes(`ModelControls`)||e.name.includes(`activateDirectory`)||e.name.includes(`opencodeClient:setDirectory`))});var rt=async(e,t,n)=>{let r=typeof performance<`u`?performance.now():Date.now();C(`${e}:start`,n);try{let n=await t(),i=typeof performance<`u`?performance.now():Date.now();return C(`${e}:end`,{durationMs:Math.round(i-r)}),n}catch(t){let n=typeof performance<`u`?performance.now():Date.now();throw C(`${e}:error`,{durationMs:Math.round(n-r),error:t instanceof Error?t.message:String(t)}),t}},it=3,at=3e4,ot=32e3,st=36e5,ct=6e5,lt=new Set([429,502,503,504]),w=new Map;function ut(){let e=Date.now();for(let[t,n]of w)n.consecutiveErrors===0&&e-n.lastErrorAt>st&&w.delete(t)}typeof setInterval<`u`&&setInterval(ut,ct).unref?.();function dt(e){let t=w.get(e);return t||(t={consecutiveErrors:0,lastErrorAt:0,circuitOpen:!1,circuitOpenAt:0,circuitCooldownMs:at},w.set(e,t)),t}function ft(e){if(!e)return;let t=w.get(e);t&&(t.consecutiveErrors=0,t.lastErrorAt=0)}function pt(e,t){if(!e)return;let n=dt(e);n.consecutiveErrors+=1,n.lastErrorAt=Date.now(),mt(t)&&n.consecutiveErrors>=it&&(n.circuitOpen=!0,n.circuitOpenAt=Date.now(),console.warn(`[provider-tracker] Circuit opened for ${e} after ${n.consecutiveErrors} consecutive errors`))}function mt(e){return e!==void 0&<.has(e)}function ht(e){let t=w.get(e);return t?.circuitOpen?Date.now()-t.circuitOpenAt>=t.circuitCooldownMs?(t.circuitOpen=!1,t.consecutiveErrors=0,t.circuitCooldownMs=Math.min(t.circuitCooldownMs*2,ot*4),!1):!0:!1}function gt(e){if(!(!e||!ht(e)))throw Error(`Provider ${e} is temporarily unavailable after repeated errors. Please retry shortly.`)}var _t=`/api`,vt=1e4,yt=4e3,bt=3e3,xt=1e3,St=12e3;function T(e){if(e instanceof Error)return e.message;if(typeof e==`string`)return e;if(e&&typeof e==`object`&&`message`in e&&typeof e.message==`string`)return e.message;try{return JSON.stringify(e)}catch{return String(e)}}function E(e,t){if(e.error){let n=e.response?.status,r=Error(`${t} failed${n?` (${n})`:``}: ${T(e.error)}`);throw n!==void 0&&(r.status=n),r}if(e.data===void 0||e.data===null)throw Error(`${t} failed: empty response`);return e.data}function D(e,t){if(e.error){let n=e.response?.status,r=Error(`${t} failed${n?` (${n})`:``}: ${T(e.error)}`);throw n!==void 0&&(r.status=n),r}return e.data}var Ct=/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//,wt=e=>{let t=typeof e==`string`&&e.trim().length>0?e.trim():`/api`;if(Ct.test(t)||typeof window>`u`)return t;let n=window.location?.href||window.location?.origin;if(!n)return t;try{return new URL(t,n).toString()}catch(e){return console.warn(`Failed to normalize OpenCode base URL:`,e),t}},Tt=()=>{try{return i().api(`/api`)}catch{return null}},Et=()=>{try{return i().api(`/`)}catch{return null}},Dt=e=>{let t=typeof AbortSignal<`u`?AbortSignal:void 0;if(typeof t?.timeout==`function`)return{signal:t.timeout(e),cleanup:()=>void 0};let n=new AbortController,r=setTimeout(()=>n.abort(),e);return{signal:n.signal,cleanup:()=>clearTimeout(r)}},Ot=e=>{let t=e.filter(e=>e!=null);if(t.length===0)return{signal:new AbortController().signal,cleanup:()=>void 0};if(t.length===1)return{signal:t[0],cleanup:()=>void 0};let n=typeof AbortSignal<`u`?AbortSignal:void 0;if(typeof n?.any==`function`)return{signal:n.any(t),cleanup:()=>void 0};let r=new AbortController,i=()=>r.abort();for(let e of t){if(e.aborted){r.abort();break}e.addEventListener(`abort`,i)}return{signal:r.signal,cleanup:()=>{for(let e of t)e.removeEventListener(`abort`,i)}}},O=e=>oe({...e,fetch:h}),kt=e=>typeof e.mime==`string`&&e.mime.startsWith(`image/`)?!0:typeof e.filename==`string`&&/\.(?:png|jpe?g|gif|webp|svg|avif|bmp|heic|heif|tiff?)$/i.test(e.filename),At=e=>{let t=[];for(let n of e){if(!kt(n))continue;let e=typeof n.filename==`string`?n.filename.trim():``,r=typeof n.url==`string`?n.url:``;if(!e||!r.toLowerCase().startsWith(`file://`))continue;let i=Ke(r).trim();i&&t.push({filename:e,path:i})}return t},jt=async(e,t)=>{let n=[],r=e.files?.length?await Promise.all(e.files.map(e=>t(e))):[],i=e.additionalParts?.length?await Promise.all(e.additionalParts.map(async e=>({text:e.text,synthetic:e.synthetic,files:e.files?.length?await Promise.all(e.files.map(e=>t(e))):[]}))):[],a=e=>Le(e,At([...r,...i.flatMap(e=>e.files)]));if(e.prefaceText&&e.prefaceText.trim()&&n.push({type:`text`,text:a(e.prefaceText),synthetic:e.prefaceTextSynthetic!==!1}),e.text&&e.text.trim()&&n.push({type:`text`,text:a(e.text)}),n.push(...r),i.length>0)for(let e of i){if(e.text&&e.text.trim()){let t={type:`text`,text:a(e.text)};e.synthetic&&(t.synthetic=!0),n.push(t)}n.push(...e.files)}if(e.agentMentions&&e.agentMentions.length>0)for(let t of e.agentMentions){if(!t?.name)continue;let e={type:`agent`,name:t.name};t.source&&(e.source=t.source),n.push(e)}if(n.length===0)throw Error(`Message must have at least one part (text or file)`);return n},k=e=>e.replace(/\\/g,`/`),Mt=400,Nt=()=>{let e=ne();return e&&e.runtime?.isDesktop&&e.files?e.files:null},A=new class{client;baseUrl;scopedClients=new Map;currentDirectory=void 0;directoryContextQueue=Promise.resolve();listDirectoryInFlight=new Map;configProvidersInFlight=new Map;listAgentsInFlight=new Map;configInFlight=new Map;configCache=new Map;configCacheGeneration=0;listDirectoryCache=new Map;healthInFlight=new Map;healthCache=new Map;healthCacheGeneration=0;constructor(e=_t){let t=Tt()||e;this.baseUrl=wt(t),this.client=O({baseUrl:this.baseUrl})}getBaseUrl(){return this.baseUrl}reconnectToRuntimeBaseUrl(){let e=wt(Tt()||_t);e!==this.baseUrl&&(this.baseUrl=e,this.client=O({baseUrl:this.baseUrl}),this.scopedClients.clear(),this.listDirectoryInFlight.clear(),this.configProvidersInFlight.clear(),this.listAgentsInFlight.clear(),this.clearConfigCache(),this.listDirectoryCache.clear(),this.clearHealthCache())}getSdkClient(){return this.client}getScopedSdkClient(e){return this.getScopedApiClient(e)}getScopedApiClient(e){let t=this.normalizeCandidatePath(e)??e,n=t||``,r=this.scopedClients.get(n);if(r)return r;let i=O({baseUrl:this.baseUrl,directory:t});return this.scopedClients.set(n,i),i}normalizeCandidatePath(e){if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;let n=t.replace(/\\/g,`/`).replace(/^([a-z]):/,(e,t)=>t.toUpperCase()+`:`);return(n.length>1?n.replace(/\/+$/,``):n)||null}deriveHomeDirectory(e){let t=e.match(/^([A-Za-z]:)(?:\/|$)/);if(t){let n=t[1],r=e.slice(n.length+ +(e.charAt(n.length)===`/`)).split(`/`).filter(Boolean);return r.length>=2?{homeDirectory:`${n}/${r[0]}/${r[1]}`,username:r[1]}:r.length===1?{homeDirectory:`${n}/${r[0]}`,username:r[0]}:{homeDirectory:n,username:void 0}}let n=e.startsWith(`/`),r=e.split(`/`).filter(Boolean);return r.length>=2&&(r[0]===`Users`||r[0]===`home`)?{homeDirectory:`${n?`/`:``}${r[0]}/${r[1]}`,username:r[1]}:n?r.length===0?{homeDirectory:`/`,username:void 0}:{homeDirectory:`/${r.join(`/`)}`,username:r[r.length-1]}:r.length>0?{homeDirectory:`/${r.join(`/`)}`,username:r[r.length-1]}:{homeDirectory:`/`,username:void 0}}setDirectory(e){let t=this.normalizeCandidatePath(e)??e;this.currentDirectory!==t&&C(`opencodeClient:setDirectory`,{previous:this.currentDirectory??null,next:t??null}),this.currentDirectory=t}getDirectory(){return this.currentDirectory}async withDirectory(e,t){let n=async()=>{if(e==null)return t();let n=this.currentDirectory,r=this.normalizeCandidatePath(e)??e;this.currentDirectory=r;try{return await t()}finally{this.currentDirectory===r&&(this.currentDirectory=n)}},r=this.directoryContextQueue.then(n,n);return this.directoryContextQueue=r.then(()=>void 0,()=>void 0),r}getApiClient(){return this.client}async getSystemInfo(){let e=new Set,t=t=>{let n=this.normalizeCandidatePath(t);n&&e.add(n)};try{let e=(await this.client.path.get(this.currentDirectory?{directory:this.currentDirectory}:void 0)).data;e&&(t(e.directory),t(e.worktree),t(e.state))}catch{}if(!e.size)try{t((await this.client.project.current(this.currentDirectory?{directory:this.currentDirectory}:void 0)).data?.worktree)}catch{}if(!e.size)try{(await this.listSessions()).forEach(e=>t(e.directory))}catch{}if(t(this.currentDirectory),typeof window<`u`)try{t(p(`lastDirectory`)),t(p(`homeDirectory`))}catch{}if(!e.size&&typeof process<`u`&&typeof process.cwd==`function`&&t(process.cwd()),!e.size)return{homeDirectory:`/`,username:void 0};let[n]=Array.from(e);return this.deriveHomeDirectory(n)}async probeDirectory(e){let t=this.normalizeCandidatePath(e);if(!t)return!1;try{let e=(await this.client.path.get({directory:t})).data,n=typeof e?.directory==`string`?e.directory:null;return!!(n&&n.trim().length>0)}catch{return!1}}async listSessions(){let e=await this.client.session.list(this.currentDirectory?{directory:this.currentDirectory}:void 0);return Array.isArray(e.data)?e.data:[]}async createSession(e,t){let n=this.normalizeCandidatePath(t)??this.currentDirectory;return E(await this.client.session.create({...n?{directory:n}:{},parentID:e?.parentID,title:e?.title,metadata:e?.metadata}),`session.create`)}async getSession(e,t){let n=this.normalizeCandidatePath(t)??this.currentDirectory;return E(await this.client.session.get({sessionID:e,...n?{directory:n}:{}}),`session.get`)}async deleteSession(e,t){let n=this.normalizeCandidatePath(t)??this.currentDirectory;return D(await this.client.session.delete({sessionID:e,...n?{directory:n}:{}}),`session.delete`)===!0}async deleteSessionMessage(e,t,n){let r=this.normalizeCandidatePath(n)??this.currentDirectory;return D(await this.client.session.deleteMessage({sessionID:e,messageID:t,...r?{directory:r}:{}}),`session.deleteMessage`)===!0}async updateSession(e,t,n){let r=this.normalizeCandidatePath(n)??this.currentDirectory,i={...t.title===void 0?{}:{title:t.title},...t.metadata===void 0?{}:{metadata:t.metadata},...t.time?.archived!==void 0&&t.time.archived!==null?{time:{archived:t.time.archived}}:{}};return E(await this.client.session.update({sessionID:e,...r?{directory:r}:{},...i}),`session.update`)}async getSessionMessages(e,t){return E(await this.client.session.messages({sessionID:e,...this.currentDirectory?{directory:this.currentDirectory}:{},...typeof t==`number`?{limit:t}:{}}),`session.messages`)}async getSessionDiff(e){let t=this.normalizeCandidatePath(e.directory)??this.currentDirectory,n=typeof e.messageID==`string`&&e.messageID.trim().length>0?e.messageID.trim():void 0;return E(await this.client.session.diff({sessionID:e.sessionID,...t?{directory:t}:{},...n?{messageID:n}:{}}),`session.diff`)}async getSessionTodos(e){try{let t=await this.client.session.todo({sessionID:e,...this.currentDirectory?{directory:this.currentDirectory}:{}});if(t.error)return[];let n=t.data;return!n||!Array.isArray(n)?[]:n}catch{return[]}}shouldNormalizeToTextPlain(e){if(!e)return!1;let t=e.toLowerCase();return t.startsWith(`text/`)&&t!==`text/plain`?!0:[`application/json`,`application/xml`,`application/javascript`,`application/typescript`,`application/x-yaml`,`application/yaml`,`application/toml`,`application/x-sh`,`application/x-shellscript`,`application/octet-stream`,`image/svg+xml`].includes(t)}isHeicMime(e){if(!e)return!1;let t=e.toLowerCase();return t===`image/heic`||t===`image/heif`}async convertHeicToJpeg(t){try{let n=Ze(t.url,t.mime);if(!n)return t;let r=await ge(n)??await(await ce(async()=>{let{default:t}=await import(`./vendor-heic2any-CUPf3g2A.js`).then(t=>e(t.t(),1));return{default:t}},__vite__mapDeps([0,1]))).default({blob:n,toType:`image/jpeg`,quality:.9}),i=await new Promise((e,t)=>{let n=new FileReader;n.onload=()=>e(n.result),n.onerror=t,n.readAsDataURL(r)}),a=t.filename;return a&&=a.replace(/\.heic$/i,`.jpg`).replace(/\.heif$/i,`.jpg`),{mime:`image/jpeg`,filename:a,url:i}}catch(e){return console.warn(`Failed to convert HEIC to JPEG:`,e),t}}async normalizeFilePart(e){if(this.isHeicMime(e.mime))return this.convertHeicToJpeg(e);if(!this.shouldNormalizeToTextPlain(e.mime))return e;let t=e.url;if(e.url.startsWith(`data:`)){let n=e.url.indexOf(`,`);if(n!==-1){let r=e.url.substring(5,n),i=e.url.substring(n);t=`data:${r.replace(/^[^;,]+/,`text/plain`)}${i}`}}return{mime:`text/plain`,filename:e.filename,url:t}}async toNormalizedFilePartInput(e){let t=await this.normalizeFilePart(e),n=t.url;if(Qe(n)){let e=Ze(n,t.mime);if(!e)throw Error(`Failed to materialize attachment bytes for ${t.filename??`file`}`);n=(await $e({body:e,mime:t.mime,filename:t.filename})).url}return{...e.id?{id:e.id}:{},type:`file`,mime:t.mime,filename:t.filename,url:n}}async buildMessageParts(e){return jt(e,e=>this.toNormalizedFilePartInput(e))}async sendMessage(e){let t=e.messageId??g(`msg`),n=await this.buildMessageParts({text:e.text,prefaceText:e.prefaceText,prefaceTextSynthetic:e.prefaceTextSynthetic,files:e.files,additionalParts:e.additionalParts,agentMentions:e.agentMentions}),r=this.normalizeCandidatePath(e.directory??null)??this.currentDirectory;e.format&&(e.id,e.providerID,e.modelID,e.agent,e.variant,this.baseUrl,e.format.type),gt(e.providerID);let i;try{let a=await this.client.session.promptAsync({sessionID:e.id,...r?{directory:r}:{},model:{providerID:e.providerID,modelID:e.modelID},agent:e.agent,variant:e.variant,messageID:t,...e.delivery?{delivery:e.delivery}:{},...e.format?{format:e.format}:{},parts:n});if(a.response instanceof Response)i=a.response;else if(a.error){let e=a.response?.status;if(!e)throw Error(`Message send transport failure: ${T(a.error)}`);i=new Response(JSON.stringify(a.error),{status:e})}else i=new Response(JSON.stringify(a.data??!0),{status:200})}catch(t){throw pt(e.providerID),t}if(i.ok)return ft(e.providerID),t;let a=``;try{a=await i.text()}catch{}let o=a&&a.trim().length>0?`: ${a.trim()}`:``,s=Error(`Failed to send message (${i.status})${o}`);throw s.status=i.status,pt(e.providerID,i.status),s}async sendCommand(e){let t=e.messageId??g(`msg`),n=[];if(e.files&&e.files.length>0)for(let t of e.files)n.push(await this.toNormalizedFilePartInput(t));let r=this.normalizeCandidatePath(e.directory??null)??this.currentDirectory;return D(await this.client.session.command({sessionID:e.id,...r?{directory:r}:{},command:e.command,arguments:e.arguments??``,model:`${e.providerID}/${e.modelID}`,agent:e.agent,variant:e.variant,...n.length>0?{parts:n}:{},messageID:t}),`session.command`),t}async abortSession(e){return!!(await this.client.session.abort({sessionID:e,...this.currentDirectory?{directory:this.currentDirectory}:{}},{throwOnError:!0})).data}async shellSession(e){let t=this.normalizeCandidatePath(e.directory??null)??this.currentDirectory;return E(await this.client.session.shell({sessionID:e.sessionId,...t?{directory:t}:{},messageID:e.messageId,agent:e.agent,model:e.model,command:e.command}),`session.shell`)}async revertSession(e,t,n,r){let i=this.normalizeCandidatePath(r)??this.currentDirectory;return E(await this.client.session.revert({sessionID:e,...i?{directory:i}:{},messageID:t,partID:n}),`session.revert`)}async summarizeSession(e,t,n,r){let i=this.normalizeCandidatePath(r)??this.currentDirectory;return D(await this.client.session.summarize({sessionID:e,...i?{directory:i}:{},providerID:t,modelID:n}),`session.summarize`)===!0}async unrevertSession(e){return E(await this.client.session.unrevert({sessionID:e,...this.currentDirectory?{directory:this.currentDirectory}:{}}),`session.unrevert`)}async forkSession(e,t,n){let r=this.normalizeCandidatePath(n)??this.currentDirectory,i=E(await this.client.session.fork({sessionID:e,...r?{directory:r}:{},messageID:t}),`session.fork`);return i.id,i}async getSessionStatus(){return await this.getSessionStatusForDirectory(this.currentDirectory??null)??{}}async getSessionStatusForDirectory(e,t){try{let n=typeof e==`string`?e.trim():``,r=await this.client.session.status(n?{directory:n}:void 0,t?{signal:t}:void 0);return r.error||!r.data||typeof r.data!=`object`?null:r.data}catch{return null}}async getSessionActive(e){try{let t=await O({baseUrl:wt(Et()||`/`)}).v2.session.active(e?{signal:e}:void 0),n=t.response?.status;if(t.error||n!==void 0&&n!==200)return n===404||n===405||n===501?{state:`unsupported`}:{state:`unknown`};let r=t.data,i=r&&typeof r==`object`&&`data`in r&&r.data!==void 0?r.data:r;if(!i||typeof i!=`object`||Array.isArray(i))return{state:`unknown`};let a={};for(let[e,t]of Object.entries(i)){if(typeof e!=`string`||e.length===0||!t||typeof t!=`object`||t.type!==`running`)return{state:`unknown`};a[e]={type:`running`}}return{state:`supported`,membership:a}}catch{return{state:`unknown`}}}async getGlobalSessionStatus(){return await this.getSessionStatusForDirectory(null)??{}}async getWebServerSessionActivity(){try{let e=await h(`/api/session-activity`,{method:`GET`,headers:{Accept:`application/json`}});if(!e.ok)return null;let t=await e.json().catch(()=>null);return!t||typeof t!=`object`?null:t}catch{return null}}async listToolIds(e){try{let t=typeof e?.directory==`string`?e.directory.trim():this.currentDirectory?this.currentDirectory.trim():``;return((await this.client.tool.ids(t?{directory:t}:void 0)).data||[]).filter(e=>typeof e==`string`&&e!==`invalid`)}catch{return[]}}async replyToPermission(e,t,n){let r=this.normalizeCandidatePath(n?.directory??null)??this.currentDirectory;return D(await this.client.permission.reply({requestID:e,...r?{directory:r}:{},reply:t,...n?.message?{message:n.message}:{}}),`permission.reply`)===!0}async createPermission(e,t,n,r){try{let i=await this.client.v2.session.permission.create({sessionID:e,action:t,resources:n,...r?.id?{id:r.id}:{},...r?.save?{save:r.save}:{},...r?.metadata?{metadata:r.metadata}:{},...r?.source?{source:r.source}:{},...r?.agent?{agent:r.agent}:{}});if(i.error!==void 0)return null;let a=i.data?.data;return a===void 0?null:{id:a.id,effect:a.effect}}catch{return null}}async fetchPermission(e,t){try{let n=await this.client.v2.session.permission.get({sessionID:e,requestID:t});if(n.error===void 0){let e=n.data?.data;if(e!==void 0)return{state:`ok`,permission:e}}return n.response?.status===404?{state:`resolved`}:{state:`unknown`}}catch{return{state:`unknown`}}}async listPendingPermissions(e){let t=[],n=async e=>{let t=typeof e==`string`?e.trim():``,n=await this.client.permission.list(t?{directory:t}:void 0);if(n.error)throw Error(`permission.list failed: ${T(n.error)}`);return n.data||[]};t.push(n(null));let r=new Set;for(let t of e?.directories??[]){let e=this.normalizeCandidatePath(t??null);e&&r.add(e)}for(let e of r)t.push(n(e));let i=await Promise.all(t),a=[],o=new Set;for(let e of i)for(let t of e){if(!t||typeof t!=`object`)continue;let e=t.id;typeof e==`string`&&e.length!==0&&(o.has(e)||(o.add(e),a.push(t)))}return a}async replyToQuestion(e,t,n){let r=!Array.isArray(t)||t.length===0?[]:Array.isArray(t[0])?t:[t],i=this.normalizeCandidatePath(n)??this.currentDirectory;return D(await this.client.question.reply({requestID:e,...i?{directory:i}:{},answers:r}),`question.reply`)===!0}async rejectQuestion(e){return D(await this.client.question.reject({requestID:e,...this.currentDirectory?{directory:this.currentDirectory}:{}}),`question.reject`)===!0}async listPendingQuestions(e){let t=[],n=async e=>{let t=typeof e==`string`?e.trim():``,n=await this.client.question.list(t?{directory:t}:void 0);if(n.error)throw Error(`question.list failed: ${T(n.error)}`);return n.data||[]};t.push(n(null));let r=new Set;for(let t of e?.directories??[]){let e=this.normalizeCandidatePath(t??null);e&&r.add(e)}for(let e of r)t.push(n(e));let i=await Promise.all(t),a=[],o=new Set;for(let e of i)for(let t of e){if(!t||typeof t!=`object`)continue;let e=t.id;typeof e==`string`&&e.length!==0&&(o.has(e)||(o.add(e),a.push(t)))}return a}clearConfigCache(){this.configCacheGeneration+=1,this.configInFlight.clear(),this.configCache.clear()}clearHealthCache(){this.healthCacheGeneration+=1,this.healthInFlight.clear(),this.healthCache.clear()}async getConfig(e){let t=this.normalizeCandidatePath(e)??e??this.currentDirectory??void 0,n=t??``,r=this.configCache.get(n);if(r&&r.expiresAt>Date.now())return C(`opencodeClient.getConfig:cacheHit`,{directory:t??null}),r.config;let i=this.configInFlight.get(n);if(i)return C(`opencodeClient.getConfig:deduped`,{directory:t??null}),i;let a=this.configCacheGeneration,o=(async()=>{C(`opencodeClient.getConfig:start`,{directory:t??null});let e=typeof performance<`u`?performance.now():Date.now(),r=await(t?this.getScopedApiClient(t):this.client).config.get();if(!r.data)throw Error(`Failed to get config`);let i=typeof performance<`u`?performance.now():Date.now();return C(`opencodeClient.getConfig:end`,{directory:t??null,durationMs:Math.round(i-e)}),a===this.configCacheGeneration&&this.configCache.set(n,{config:r.data,expiresAt:Date.now()+vt}),r.data})();this.configInFlight.set(n,o);try{return await o}finally{this.configInFlight.get(n)===o&&this.configInFlight.delete(n)}}async updateConfig(e){let t=E(await this.client.config.update({config:e}),`global.config.update`);return this.clearConfigCache(),t}async updateConfigPartial(e){let t=e(await this.getConfig());return await this.updateConfig(t)}async getProviders(){return this.getProvidersForConfig(this.currentDirectory)}async getProvidersForConfig(e){let t=e===void 0?this.currentDirectory??void 0:this.normalizeCandidatePath(e)??void 0,n=t??``,r=this.configProvidersInFlight.get(n);if(r)return r;let i=(async()=>E(await this.client.config.providers(t?{directory:t}:void 0),`config.providers`))();this.configProvidersInFlight.set(n,i);try{return await i}finally{this.configProvidersInFlight.delete(n)}}async getApp(){return{version:`0.0.3`,config:await this.getConfig()}}async initApp(){try{return await this.checkHealth()}catch{return!1}}async listAgents(e,t){let n=e===void 0?this.currentDirectory??void 0:this.normalizeCandidatePath(e)??void 0,r=n??``;if(!t){let e=this.listAgentsInFlight.get(r);if(e)return e}let i=(async()=>{let e=Dt(St),r=Ot(t?[t,e.signal]:[e.signal]);try{let e=n?{directory:n}:void 0,t=await this.client.app.agents(e,{signal:r.signal});if(!t.error&&Array.isArray(t.data)&&t.data.length>0)return t.data;let i=await h(`/api/agent`,{...n?{query:{directory:n}}:{},signal:r.signal});if(!i.ok)throw t.error?Error(`app.agents failed${t.response?.status?` (${t.response.status})`:``}: ${T(t.error)}`):Error(`agent.list failed (${i.status})`);let a=await i.json().catch(()=>null);if(!Array.isArray(a))throw Error(`agent.list failed: invalid response`);return a}finally{e.cleanup(),r.cleanup()}})();if(t)return i;this.listAgentsInFlight.set(r,i);try{return await i}finally{this.listAgentsInFlight.delete(r)}}async readFile(e){try{let t=await this.client.file.read({path:e,...this.currentDirectory?{directory:this.currentDirectory}:{}});return String(E(t,`file.read`))}catch{return`// Content of ${e}\n// This would be loaded from the server`}}async listFiles(e){try{let t=e||this.currentDirectory||`/`,n=E(await this.client.file.list({path:t,...this.currentDirectory?{directory:this.currentDirectory}:{}}),`file.list`);return Array.isArray(n)?n:[]}catch{return[]}}async listCommands(){return(E(await this.client.command.list(this.currentDirectory?{directory:this.currentDirectory}:void 0),`command.list`)||[]).map(e=>({name:e.name,description:e.description,agent:e.agent,model:e.model,source:e.source}))}async listCommandsWithDetails(){return(E(await this.client.command.list(this.currentDirectory?{directory:this.currentDirectory}:void 0),`command.list`)||[]).map(e=>({name:e.name,description:e.description,agent:e.agent,model:e.model,source:e.source,template:e.template}))}async listSkillsWithDetails(){try{let e=(await this.client.app.skills(this.currentDirectory?{directory:this.currentDirectory}:void 0)).data;if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=typeof n.name==`string`?n.name.trim():``,r=typeof n.location==`string`?n.location:``;if(!e||!r)continue;let i={name:e,location:r};typeof n.description==`string`&&(i.description=n.description),typeof n.content==`string`&&(i.content=n.content),t.push(i)}return t}catch{return[]}}async getCommandDetails(e){try{let t=await this.client.command.list(this.currentDirectory?{directory:this.currentDirectory}:void 0);if(t.data){let n=t.data.find(t=>t.name===e);if(n)return{name:n.name,template:n.template,description:n.description,agent:n.agent,model:n.model}}return null}catch{return null}}async checkHealth(){let e=r(),t=this.healthCache.get(e);if(t&&t.expiresAt>Date.now())return t.healthy;let n=this.healthInFlight.get(e);if(n)return n;let i=this.healthCacheGeneration,a=(async()=>{let t=!1;try{let e=this.baseUrl.endsWith(`/`)?this.baseUrl.replace(/\/+$/,``):this.baseUrl,n=e===`/api`||e.endsWith(`/api`)?`/api/opencode/health`:`${e}/opencode/health`;C(`opencodeClient.checkHealth:url`,{baseUrl:this.baseUrl,healthUrl:n});let r=Dt(yt),i=await h(n,{signal:r.signal}).finally(r.cleanup);if(C(`opencodeClient.checkHealth:response`,{status:i.status}),i.ok){let e=await i.json();C(`opencodeClient.checkHealth:result`,{healthy:e?.healthy}),t=e?.healthy===!0}}catch{t=!1}return i!==this.healthCacheGeneration||e!==r()?!1:(this.healthCache.set(e,{healthy:t,expiresAt:Date.now()+(t?bt:xt)}),t)})();this.healthInFlight.set(e,a);try{return await a}finally{this.healthInFlight.get(e)===a&&this.healthInFlight.delete(e)}}async createDirectory(e,t){let n=Nt();if(n?.createDirectory)try{return await n.createDirectory(e)}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(t||`Failed to create directory`)}let r={path:e,...t?.allowOutsideWorkspace?{allowOutsideWorkspace:!0}:{}},i=await h(`${this.baseUrl}/fs/mkdir`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)});if(!i.ok){let e=await i.json().catch(()=>({error:`Failed to create directory`}));throw Error(e.error||`Failed to create directory`)}return await i.json()}async cloneRepository(e){let t=await h(`${this.baseUrl}/fs/clone`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>({error:`Failed to clone repository`}));throw Error(e.error||`Failed to clone repository`)}return await t.json()}async listLocalDirectory(e,t){let n=`${typeof e==`string`?k(e.trim()):``}|${t?.respectGitignore?`1`:`0`}`,r=Date.now(),i=this.listDirectoryCache.get(n);if(i&&i.expiresAt>r)return i.entries;let a=this.listDirectoryInFlight.get(n);if(a)return a;let o=(async()=>{let r=Nt();if(r)try{let i=await r.listDirectory(e||``,t);if(!i||!Array.isArray(i.entries))return[];let a=i.entries.map(e=>({name:e.name,path:k(e.path),isDirectory:!!e.isDirectory,isFile:!e.isDirectory,isSymbolicLink:!1}));return this.listDirectoryCache.set(n,{entries:a,expiresAt:Date.now()+Mt}),a}catch(e){throw console.error(`Failed to list directory contents:`,e),e}try{let r=new URLSearchParams;e&&e.trim().length>0&&r.set(`path`,e),t?.respectGitignore&&r.set(`respectGitignore`,`true`);let i=r.toString(),a=await h(`${this.baseUrl}/fs/list${i?`?${i}`:``}`);if(!a.ok){let e=await a.json().catch(()=>({})),t=typeof e.error==`string`?e.error:`Failed to list directory`;throw Error(t)}let o=await a.json();if(!o||!Array.isArray(o.entries))return[];let s=o.entries;return this.listDirectoryCache.set(n,{entries:s,expiresAt:Date.now()+Mt}),s}catch(e){throw console.error(`Failed to list directory contents:`,e),e}})().finally(()=>{this.listDirectoryInFlight.get(n)===o&&this.listDirectoryInFlight.delete(n)});return this.listDirectoryInFlight.set(n,o),o}async searchFiles(e,t){let n=typeof t?.directory==`string`&&t.directory.trim().length>0?t.directory.trim():this.currentDirectory,r=n?k(n):null,i=n?this.getScopedApiClient(n):this.client;try{let n=await i.find.files({query:e,limit:typeof t?.limit==`number`&&Number.isFinite(t.limit)?t.limit:void 0,dirs:t?.dirs===!1||t?.type===`file`?`false`:`true`,type:t?.type});return(Array.isArray(n?.data)?n.data:[]).map(e=>{let t=k(e),n=t.split(`/`).filter(Boolean).pop()||t;return{name:n,path:k(r?`${r}/${t}`:t),relativePath:t,extension:n.includes(`.`)?n.split(`.`).pop()?.toLowerCase():void 0}})}catch(e){throw console.error(`Failed to search files:`,e),e}}async getFilesystemHome(){let e=r();if(!e||e===`local`){let e=await re();if(e)return e}try{let e=await h(`${this.baseUrl}/fs/home`,{method:`GET`,headers:{Accept:`application/json`}});if(!e.ok){let t=await e.json().catch(()=>({})),n=typeof t.error==`string`&&t.error.length>0?t.error:`Failed to resolve home directory`;throw Error(n)}let t=await e.json();return t&&typeof t.home==`string`&&t.home.length>0?t.home:null}catch(e){return console.warn(`Failed to resolve filesystem home directory:`,e),null}}async setOpenCodeWorkingDirectory(e){if(!e||typeof e!=`string`||!e.trim())return console.warn(`[OpencodeClient] setOpenCodeWorkingDirectory: invalid path`,e),null;let t=`${this.baseUrl}/opencode/directory`;try{let n=await h(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:e})}),r=await n.json().catch(()=>null);if(!n.ok){let e=r??{},t=typeof e.error==`string`&&e.error.length>0?e.error:`Failed to update OpenCode working directory`;throw Error(t)}return r&&typeof r==`object`?r:{success:!0,restarted:!1,path:e}}catch(e){throw console.warn(`Failed to update OpenCode working directory:`,e),e}}},Pt=3e4,Ft=40,It=60,Lt=(e,t,n,r,i,a)=>{let o=e.trim(),s=t.trim().toLowerCase();return JSON.stringify([o,s,n,r,i,a])},Rt=(e,t)=>{try{let n=JSON.parse(e);return Array.isArray(n)&&n[0]===t}catch{return!1}},zt=ie()(ae((e,t)=>({cache:{},cacheKeys:[],inFlight:{},async searchFiles(n,r,i=It,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=Lt(o,s,i,c,l,u),f=Date.now(),p=t().cache[d];if(p&&f-p.timestamp<Pt)return p.files;let m=t().inFlight[d];if(m)return m;let h=A.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>Ft;){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=>!Rt(e,n)||(delete t[e],!1)),i=Object.entries(e.inFlight).filter(([e])=>!Rt(e,n));return{cache:t,cacheKeys:r,inFlight:Object.fromEntries(i)}})}}),{name:`file-search-store`})),Bt=()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(`openchamber_stream_debug`)===`1`}catch{return!1}},Vt=`openchamber_stream_perf`,j=()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(Vt)===`1`}catch{return!1}},Ht=()=>typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now(),Ut=()=>{if(!j()||typeof window>`u`)return null;if(!window.__openchamberStreamPerfState){let e=Date.now();window.__openchamberStreamPerfState={counters:new Map,startedAt:e,lastUpdatedAt:e}}return window.__openchamberStreamPerfState},Wt=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),Gt=(e,t)=>{let n=Ut();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()},Kt=e=>{if(!(typeof window>`u`))try{if(e){window.localStorage.setItem(Vt,`1`),window.__openchamberStreamPerfState={counters:new Map,startedAt:Date.now(),lastUpdatedAt:Date.now()};return}window.localStorage.removeItem(Vt),delete window.__openchamberStreamPerfState,delete window.__openchamberVsCodeStreamPerfState}catch{}},qt=()=>{typeof window>`u`||(j()&&(window.__openchamberStreamPerfState={counters:new Map,startedAt:Date.now(),lastUpdatedAt:Date.now()}),window.__openchamberVsCodeStreamPerfState&&(window.__openchamberVsCodeStreamPerfState={...window.__openchamberVsCodeStreamPerfState,counters:new Map,startedAt:Date.now(),lastUpdatedAt:Date.now()}))},Jt=()=>{if(typeof window>`u`)return{enabled:!1,startedAt:null,lastUpdatedAt:null,durationMs:0,entries:[]};let e=window.__openchamberStreamPerfState;return!j()||!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:Wt(e.counters)}},Yt=()=>{if(typeof window>`u`)return{enabled:!1,startedAt:null,lastUpdatedAt:null,durationMs:0,entries:[]};let e=window.__openchamberVsCodeStreamPerfState;if(!j()||!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:Wt(e.counters)}},Xt=(e,t=1)=>{Gt(e,t)},Zt=(e,t)=>{Gt(e,t)},Qt=(e,t)=>{if(!j())return t();let n=Ht();try{return t()}finally{Gt(e,Ht()-n)}},M=null,$t=0,N=c(),en=p(`lastDirectory`,{storage:N}),tn=typeof en==`string`&&en.length>0,P=e=>{try{zt.getState().invalidateDirectory(e)}catch(e){console.warn(`Failed to invalidate file search cache:`,e)}},F=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},nn=(e,t)=>{let n=e.trim();return n.startsWith(`~`)?n===`~`?t||n:(n.startsWith(`~/`)||n.startsWith(`~\\`))&&t?`${t}${n.slice(1)}`:n:n},I=(e,t)=>F(nn(e,t)),rn=()=>{let e=p(`homeDirectory`,{storage:N});if(typeof e!=`string`||e.trim().length===0)return null;let t=F(e);return t.length>0?t:null},an=()=>{let e=p(`lastDirectory`,{storage:N});if(typeof e!=`string`||e.trim().length===0)return null;let t=F(e);return t.length>0?t:null},on=()=>{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=F(t);return e.length>0?e:null}let n=process?.cwd?.();if(typeof n==`string`&&n.trim().length>0){let e=F(n);return e.length>0?e:null}return null},L=()=>{if(typeof window<`u`){if(M)return M;let e=typeof window.__OPENCHAMBER_HOME__==`string`&&window.__OPENCHAMBER_HOME__.length>0?window.__OPENCHAMBER_HOME__:null;if(e&&e.length>0)return M=e,m(`homeDirectory`,e,{storage:N}),e;let t=rn();if(t&&!f())return M=t,t}return on()||`/`},sn=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},cn=e=>(M=e,typeof window<`u`&&m(`homeDirectory`,e,{storage:N}),_({homeDirectory:e}),e),ln=async()=>{let e=e=>{let t=sn(e);return t?cn(t):null};try{let t=e(await A.getFilesystemHome());if(t)return t}catch(e){console.warn(`Failed to obtain filesystem home directory:`,e)}try{let t=e((await A.getSystemInfo())?.homeDirectory);if(t)return t}catch(e){console.warn(`Failed to get home directory from system info:`,e)}try{let t=e(await re());if(t)return t}catch(e){console.warn(`Failed to obtain desktop-integrated home directory:`,e)}let t=L();return e(t)||t},R=(()=>{if(!f())return null;let e=window.__VSCODE_CONFIG__?.workspaceFolder;if(typeof e!=`string`||e.trim().length===0)return null;let t=F(e);return t.length>0?t:null})()||L(),z=(()=>{let e=an();return e&&!f()?I(e,R):R})();z&&A.setDirectory(z);var un=!!(R&&R!==`/`),B=ie()(ae((e,t)=>({currentDirectory:z,directoryHistory:[z],historyIndex:0,homeDirectory:R,hasPersistedDirectory:tn,isHomeReady:un,isSwitchingDirectory:!1,setDirectory:(n,r)=>{let i=I(n,M||t().homeDirectory||p(`homeDirectory`,{storage:N}));Bt(),le(t().currentDirectory,i)&&(A.setDirectory(i),P(),e(e=>{let t=[...e.directoryHistory.slice(0,e.historyIndex+1),i];return m(`lastDirectory`,i,{storage:N}),_({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];A.setDirectory(r),P(),m(`lastDirectory`,r,{storage:N}),_({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];A.setDirectory(r),P(),m(`lastDirectory`,r,{storage:N}),_({lastDirectory:r}),e({currentDirectory:r,historyIndex:t,hasPersistedDirectory:!0,isHomeReady:!0,isSwitchingDirectory:!1})}},goToParent:()=>{let{currentDirectory:e,setDirectory:n}=t();if(e===(M||t().homeDirectory||L())||e===`/`)return;let r=e.endsWith(`/`)?e.slice(0,-1):e,i=r.lastIndexOf(`/`);n(i===-1?M||L():i===0?`/`:r.substring(0,i))},goHome:async()=>{let e=M||t().homeDirectory||await ln();t().setDirectory(e)},synchronizeHomeDirectory:n=>{let r=t(),i=n;M=i;let a=r.homeDirectory!==i,o=p(`lastDirectory`,{storage:N}),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?I(r.currentDirectory,i):r.currentDirectory,d=r.directoryHistory.map(e=>I(e,i)),f=d.some((e,t)=>e!==r.directoryHistory[t]),h=!!(u&&u!==r.currentDirectory),g={homeDirectory:i,hasPersistedDirectory:s,isHomeReady:l};if(c?(g.currentDirectory=i,g.directoryHistory=[i],g.historyIndex=0,g.isSwitchingDirectory=!1):(h||f)&&(g.currentDirectory=u,g.directoryHistory=d,g.historyIndex=Math.min(r.historyIndex,d.length-1),g.isSwitchingDirectory=!1),e(()=>g),(c||h)&&l){let e=c?i:u;A.setDirectory(e),P(),m(`lastDirectory`,e,{storage:N}),_({lastDirectory:e})}_({homeDirectory:i})}}),{name:`directory-store`}));typeof window<`u`&&(ln().then(e=>{B.getState().synchronizeHomeDirectory(e)}),u(e=>{M=null;let n=++$t;if(t(e)){let e=rn(),t=an(),n=e||`/`,r=t||n;M=e,B.setState({currentDirectory:r,directoryHistory:[r],historyIndex:0,homeDirectory:n,hasPersistedDirectory:!!t,isHomeReady:!!(e&&e!==`/`),isSwitchingDirectory:!1}),r&&(A.setDirectory(r),P())}ln().then(e=>{n===$t&&B.getState().synchronizeHomeDirectory(e)})}));var dn=`x-openchamber-target-port`,fn=()=>{let e=a();for(let[t,n]of Object.entries(e)){if(t.trim().toLowerCase()!==dn)continue;let e=n.trim();return e?{[dn]:e}:void 0}},pn=(e,t)=>{let n=s();return n?n.openWebSocket(d(e),t,fn()):l(t?new WebSocket(e,t):new WebSocket(e))},V=`/api/git`,mn=1200,hn=5e3,gn=2,_n=5e3,vn=`${V}/worktrees/queue-activation`,yn=`message_queue_activation_pending`,bn=`worktree_lifecycle_busy`,xn=`worktree_activation_stale`,Sn=5e3,Cn=3e4,wn=[0,500,1e3,2e3,4e3,8e3,14e3],H=new Map,U=new Map,Tn=new Map,W=new Map,G=new Map,K=new Map,q=new Map,En=new Map,J=new Map,Dn=new Set,Y=0,On=[],kn=()=>Y<gn?(Y+=1,Promise.resolve()):new Promise(e=>{On.push(e)}),An=()=>{let e=On.shift();if(e){e();return}Y=Math.max(0,Y-1)},X=async e=>{await kn();try{return await e()}finally{An()}},jn=Symbol.for(`openchamber.git.discoveryGated`),Mn=e=>(Object.defineProperty(e,jn,{value:!0,configurable:!0}),e),Nn=e=>typeof e==`function`&&e[jn]===!0,Z=e=>e.trim(),Pn=(e,t)=>t===`light`?`${Z(e)}::light`:Z(e),Fn=e=>Tn.get(Z(e))??0,Q=e=>{let t=Z(e);Tn.set(t,Fn(e)+1);for(let e of Array.from(H.keys()))(e===t||e.startsWith(`${t}::`))&&H.delete(e);for(let e of Array.from(U.keys()))(e===t||e.startsWith(`${t}::`))&&U.delete(e)};function $(e,t,n){let r={...n};return t&&(r.directory=t),i().api(e,r)}var In=(e,t,n)=>{let r=Z(e);if(!r)return;let i=Date.now()+_n;W.set(r,{value:t,expiresAt:i});let a=typeof n==`string`&&n?n:e;K.set(r,{value:{root:a},expiresAt:i})};async function Ln(e){let t=Array.from(new Set(e.map(e=>Z(e)).filter(Boolean))),n=new Map;if(t.length===0)return n;let r=Date.now(),a=[];for(let e of t){let t=W.get(e),i=K.get(e);if(t&&t.expiresAt>r&&i&&i.expiresAt>r){n.set(e,{isGitRepository:t.value,primaryRoot:i.value.root});continue}a.push(e)}if(a.length===0)return n;let o=e=>{for(let t of e){let e=typeof t.directory==`string`?Z(t.directory):``;if(!e)continue;let r=!!t.isGitRepository,i=typeof t.primaryRoot==`string`&&t.primaryRoot?t.primaryRoot:null;In(e,r,i),n.set(e,{isGitRepository:r,primaryRoot:i})}},s=async e=>{await Promise.all(e.map(async e=>{try{let[t,r]=await Promise.all([Rn(e),Bn(e).then(e=>e.root).catch(()=>e)]);In(e,t,t?r:null),n.set(e,{isGitRepository:t,primaryRoot:t?r:null})}catch{In(e,!1,null),n.set(e,{isGitRepository:!1,primaryRoot:null})}}))};try{await X(async()=>{let e=new URLSearchParams;for(let t of a)e.append(`directories`,t);let t=i().api(`${V}/discover`),n=e.toString(),r=n?t.includes(`?`)?`${t}&${n}`:`${t}?${n}`:t,s=await h(r);if(s.status===501||!s.ok)throw Error(`Batch git discover unavailable: ${s.status} ${s.statusText}`);let c=await s.json().catch(()=>null),l=Array.isArray(c)?c:[];if(l.length===0&&a.length>0)throw Error(`Batch git discover returned empty payload`);o(l)})}catch{}let c=a.filter(e=>!n.has(e));return c.length>0&&await s(c),n}async function Rn(e){let t=Z(e),n=Date.now(),r=W.get(t);if(r&&r.expiresAt>n)return r.value;let i=G.get(t);if(i)return i;let a=(async()=>{let n=await h($(`${V}/check`,e));if(!n.ok)throw Error(`Failed to check git repository: ${n.statusText}`);let r=!!(await n.json()).isGitRepository;return W.set(t,{value:r,expiresAt:Date.now()+hn}),r})();G.set(t,a);try{return await a}finally{G.get(t)===a&&G.delete(t)}}async function zn(e,t){let n=t?.mode,r=Pn(e,n),i=Date.now(),a=H.get(r);if(a&&a.expiresAt>i)return a.value;let o=U.get(r);if(o)return o;let s=(async()=>{let t=Fn(e),i=await h($(`${V}/status`,e,n?{mode:n}:void 0));if(!i.ok)throw Error(`Failed to get git status: ${i.statusText}`);let a=await i.json();return Fn(e)===t&&H.set(r,{value:a,expiresAt:Date.now()+mn}),a})();U.set(r,s);try{return await s}finally{U.get(r)===s&&U.delete(r)}}async function Bn(e){let t=Z(e),n=Date.now(),r=K.get(t);if(r&&r.expiresAt>n)return r.value;let i=q.get(t);if(i)return i;let a=X(async()=>{let n=await h($(`${V}/primary-root`,e));if(!n.ok)throw Error(`Failed to resolve git primary root: ${n.statusText}`);let r=await n.json().catch(()=>({})),i={root:typeof r.root==`string`&&r.root?r.root:e};return K.set(t,{value:i,expiresAt:Date.now()+_n}),i});q.set(t,a);try{return await a}finally{q.get(t)===a&&q.delete(t)}}async function Vn(e){let t=await h($(`${V}/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 Hn(e,t){let{path:n,staged:r,contextLines:i}=t;if(!n)throw Error(`path is required to fetch git diff`);let a=await h($(`${V}/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 Un(e,t){let{path:n,staged:r}=t;if(!n)throw Error(`path is required to fetch git file diff`);let i=await h($(`${V}/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 Wn(e,t,n){if(!t)throw Error(`path is required to revert git changes`);let r=await h($(`${V}/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 Gn(e,t){await Kn(e,[t])}async function Kn(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 h($(`${V}/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 qn(e,t){await Jn(e,[t])}async function Jn(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 h($(`${V}/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 Yn(e,t,n){await Qn(e,t,n,`stage`)}async function Xn(e,t,n){await Qn(e,t,n,`unstage`)}async function Zn(e,t,n){await Qn(e,t,n,`discard`)}async function Qn(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 h($(`${V}/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 $n(e){if(!e)return!1;let t=await h($(`${V}/worktree-type`,e));if(!t.ok)throw Error(`Failed to detect worktree type: ${t.statusText}`);return!!(await t.json()).linked}async function er(e,t){let n=await h($(`${V}/branches`,e),{signal:t?.signal});if(!n.ok)throw Error(`Failed to get branches: ${n.statusText}`);return n.json()}async function tr(e,t){if(!t?.branch)throw Error(`branch is required to delete a branch`);let n=await h($(`${V}/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 nr(e,t){if(!t?.branch)throw Error(`branch is required to delete remote branch`);let n=await h($(`${V}/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 rr(e,t){let n=t?.remote?.trim();if(!n)throw Error(`remote is required to remove a remote`);let r=await h($(`${V}/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 ir(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 h($(`${V}/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 ar(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 l=await h($(`${V}/pr-description`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(c)});if(!l.ok){let e=await l.json().catch(()=>({error:l.statusText}));throw Error(e.error||`Failed to generate PR description`)}let u=await l.json().catch(()=>null),d=typeof u?.title==`string`?u.title:``,f=typeof u?.body==`string`?u.body:``;if(!d&&!f)throw Error(`Malformed PR description response`);return{title:d,body:f}}async function or(e){let t=Z(e),n=Date.now(),r=En.get(t);if(r&&r.expiresAt>n)return r.value;let i=J.get(t);if(i)return i;let a=X(async()=>{let n=await h($(`${V}/worktrees`,e));if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to list worktrees`)}let r=await n.json();return En.set(t,{value:r,expiresAt:Date.now()+_n}),r});J.set(t,a);try{return await a}finally{J.get(t)===a&&J.delete(t)}}Mn(or);async function sr(e,t){let n=await h($(`${V}/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 cr(e){let t=await h($(`${V}/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 lr(e,t){let n=await h($(`${V}/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 ur=e=>typeof e==`string`&&e.length>0,dr=e=>{if(!e||typeof e!=`object`)return null;let t=e;if(!ur(t.name)||!ur(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},fr=(e,t,n)=>{if(e!==503||!t||typeof t!=`object`)return null;let r=t;if(r.code!==yn)return null;let i=dr(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!==vn)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},pr=(e,t,n,r)=>`${e}\u0000${t}\u0000${n}\u0000${r}`,mr=e=>new Promise(t=>{setTimeout(t,e)}),hr=async e=>{if(e.status===409){let t=await e.json().catch(()=>null);return t?.code===bn||t?.code===xn}return e.status===503&&(await e.json().catch(()=>null))?.code===yn},gr=e=>e===400||e===401||e===403||e===501,_r=(e,t)=>{let r=n(),i=o(),a=pr(r,i,e,t);if(Dn.has(a))return;Dn.add(a);let s=()=>n()===r&&o()===i;(async()=>{let n=Date.now(),r=0;for(;Date.now()-n<Cn;){if(!s())return;let i=wn[Math.min(r,wn.length-1)]??0;if(i>0){let e=Cn-(Date.now()-n);if(e<=0||(await mr(Math.min(i,e)),!s()))return}let a=new AbortController,o=setTimeout(()=>a.abort(),Sn);try{let n=await h($(vn,void 0),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({projectDirectory:e,directory:t}),signal:a.signal});if(n.ok||gr(n.status))return;if(await hr(n)){r+=1;continue}return}catch{r+=1}finally{clearTimeout(o)}}})().catch(()=>{}).finally(()=>{Dn.delete(a)})};async function vr(e,t){let n=await h($(`${V}/worktrees`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})}),r=await n.json().catch(()=>null);if(n.ok){let e=dr(r);if(e)return e;if(r&&typeof r==`object`)return r;throw Error(`Failed to create worktree`)}let i=fr(n.status,r,e);if(i)return _r(e,i.path),i;let a=r&&typeof r==`object`?r:{error:n.statusText};throw Error(a.error||`Failed to create worktree`)}async function yr(e,t){let n=await h($(`${V}/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`)}return n.json()}async function br(e,t,n={}){let r=await h($(`${V}/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 xr(e,t={}){let n=await h($(`${V}/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 Sr(e,t={}){let n=await h($(`${V}/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 Cr(e,t={}){let n=await h($(`${V}/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 wr(e){let t=await h($(`${V}/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 Tr(e,t){let n=await h($(`${V}/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 Er(e,t={}){let n=await h($(`${V}/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 Dr=async(e,t,n)=>{let r=await h($(`${V}/${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()},Or=(e,t)=>Dr(e,`stash/apply`,t),kr=(e,t)=>Dr(e,`stash/pop`,t),Ar=(e,t)=>Dr(e,`stash/drop`,t);async function jr(e,t){let n=await h($(`${V}/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 Mr(e,t,n){let r=await h($(`${V}/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 Nr(e,t,n){let r=await h($(`${V}/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 Pr(e,t={}){let n=await h($(`${V}/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 Fr(e,t){let n=await h($(`${V}/commit-files`,e,{hash:t}));if(!n.ok)throw Error(`Failed to get commit files: ${n.statusText}`);return n.json()}async function Ir(e,t,n,r){let i=await h($(`${V}/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 Lr(){let e=await h($(`${V}/identities`,void 0));if(!e.ok)throw Error(`Failed to get git identities: ${e.statusText}`);return e.json()}async function Rr(e){let t=await h($(`${V}/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 zr(e,t){let n=await h($(`${V}/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 Br(e){let t=await h($(`${V}/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 Vr(e){if(!e)return null;let t=await h($(`${V}/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 Hr(e){if(!e)return!1;let t=await h($(`${V}/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 Ur(){let e=await h($(`${V}/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 Wr(e,t){let n=await h($(`${V}/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 Gr(){let e=await h($(`${V}/discover-credentials`,void 0));if(!e.ok)throw Error(`Failed to discover git credentials: ${e.statusText}`);return e.json()}async function Kr(e,t){let n=await h($(`${V}/remotes`,e),{signal:t?.signal});if(!n.ok)throw Error(`Failed to get remotes: ${n.statusText}`);return n.json()}async function qr(e,t){let n=await h($(`${V}/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 Jr(e){let t=await h($(`${V}/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 Yr(e,t){let n=await h($(`${V}/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 Xr(e,t){let n=await h($(`${V}/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 Zr(e,t){let n=await h($(`${V}/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 Qr(e,t){let n=await h($(`${V}/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 $r(e,t,n,r){let i=await h($(`${V}/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 ei(e){let t=await h($(`${V}/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 ti(e){let t=await h($(`${V}/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 ni(e){let t=await h($(`${V}/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 ri(e,t){return await Er(e,{message:t?.message}),{success:!0}}async function ii(e){return await kr(e,{ref:`stash@{0}`}),{success:!0}}async function ai(e){let t=await h($(`${V}/conflict-details`,e));if(!t.ok)throw Error(`Failed to get conflict details: ${t.statusText}`);return t.json()}async function oi(e,t){let n=await h(`${V}/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 si(e){let t=await h(`${V}/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{Bn as $,Hn as A,C as At,xr as B,He as Bt,ir as C,Kt as Ct,ai as D,Zt as Dt,Fr as E,Qt as Et,cr as F,Me as Ft,or as G,xe as Gt,Nn as H,Pe as Ht,Ur as I,Ne as It,lr as J,Yr as K,Kr as L,Re as Lt,Lr as M,nt as Mt,Pr as N,Be as Nt,Vr as O,zt as Ot,zn as P,je as Pt,$r as Q,Cr as R,ze as Rt,Ar as S,qt as St,Ir as T,Xt as Tt,$n as U,ye as Ut,Hr as V,We as Vt,wr as W,ve as Wt,rr as X,qr as Y,Nr as Z,Br as _,X as _t,Rn as a,Gn as at,Gr as b,Jt as bt,Zr as c,ri as ct,Tr as d,qn as dt,Vn as et,Mr as f,Jn as ft,tr as g,oi as gt,vr as h,sr as ht,si as i,Wr as it,Un as j,rt as jt,er as k,A as kt,ni as l,Er as lt,Rr as m,zr as mt,Jr as n,Wn as nt,jr as o,Kn as ot,br as p,Xn as pt,kr as q,Or as r,Zn as rt,Xr as s,Yn as st,ei as t,Qr as tt,ti as u,ii as ut,yr as v,pn as vt,ar as w,Bt as wt,Ln as x,Yt as xt,nr as y,B as yt,Sr as z,Ve as zt};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{D as t,b as n,j as r,t as i,y as a}from"./useUIStore-5agS8bsW.js";import{$t as o,D as s,d as c,k as l,u,xn as d}from"./persistence-DPNMIbF5.js";import{a as f,i as p,r as m}from"./vendor-zustand-B4dlGEM2.js";import{nt as h,rt as g}from"./vendor-base-ui-CnHfUmDN.js";import{L as _,Ot as v,k as y,yt as b}from"./gitApiHttp-D8j1qRH4.js";import{n as x}from"./vendor-react-DLPElpoQ.js";import{s as S}from"./vendor-tanstack-react-query-D7pys_c9.js";import{n as C}from"./vendor-reactuses-core-DDoDDyM9.js";import{n as ee}from"./clipboard-BW7nk_Cx.js";import{Ji as te,Za as ne,_ as re,b as ie,ct as ae,en as oe,l as w,mo as T,ot as E,po as se,st as ce,un as D,wr as O}from"./useMobileNavigationStore-DnzT4jO2.js";import{c as le,t as k}from"./utils-Co19EJEL.js";import{n as A}from"./Icon-AXqa-fYB.js";import{g as j,v as M}from"./gitApi-BYxg_qGJ.js";import{A as ue,M as N,p as P,s as F}from"./projectMeta-v-LP2mzz.js";var I=e(g(),1),L=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},R=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,z=(e,t)=>{let n=L(t),r=L(e);if(!n||!r)return!1;let i=R(n),a=R(r);return a===i||a.startsWith(`${i}/`)},de=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t=L(e);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=>L(e)).filter(e=>z(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>L(e)).filter(e=>z(e,t)))):[],s=typeof i.selectedPath==`string`?L(i.selectedPath):null,c=s&&z(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]));n[t]={openPaths:e,selectedPath:u.selectedPath??c??e[0]??null,expandedPaths:r,touchedAt:Math.max(u.touchedAt,l)};continue}n[t]={openPaths:a,selectedPath:c,expandedPaths:o,touchedAt:l}}return n},B=(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},V=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},fe=f()(m(p((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=L((t||``).trim()),a=L((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!z(a,i)||e(e=>{let t=e.byRoot[i],n=V(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:B({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=L((t||``).trim()),i=L((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=R(i),a=e=>R(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:B({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=L((t||``).trim()),i=L((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=R(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=R(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:B({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=L((t||``).trim()),i=L((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=R(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=R(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:B({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=L((t||``).trim()),a=n?L(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!z(a,i)||e(e=>{let t=e.byRoot[i],n=V(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:B({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=L((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=L((t||``).trim()),i=L((n||``).trim());!r||!i||!z(i,r)||e(e=>{let t=e.byRoot[r],n=V(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:B({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=L((t||``).trim()),i=L((n||``).trim());!r||!i||!z(i,r)||e(e=>{let t=e.byRoot[r],n=V(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:B({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=L((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>L((e||``).trim())).filter(e=>e&&z(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=V(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:B({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:a(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:de(t)}},partialize:e=>({byRoot:de(e.byRoot)})}),{name:`files-view-tabs-store`})),H=x(),pe=(e,t)=>{let n=(0,H.c)(4),r=t===void 0?200:t,[i,a]=I.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]),I.useEffect(o,s),i},me=()=>{let e=(0,H.c)(17),t=w(U),n=D(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=ie(r),a=w(W),o=w(G),s=T(K),c=T(he),l=b(ge);if(t){let r;e[2]===i?r=e[3]:(r=re(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 U(e){return e.currentSessionId}function W(e){return e.worktreeMetadata}function G(e){return e.newSessionDraft}function K(e){return e.activeProjectId}function he(e){return e.projects}function ge(e){return e.currentDirectory}var _e=.4,q=8,J=e=>{let t=e.gap??q,n=Math.max(0,e.popupBottom-e.boundaryTop-t),r=e.viewportHeight*_e,i=Math.floor(Math.min(n,r));return n>=120?Math.min(n,Math.max(120,i)):i},Y=(e,t=0)=>{let n=e.closest(`main`);if(!n)return null;let r=(e.closest(`.mobile-chat-screen__content`)?.parentElement??n.parentElement?.closest(`main`)??n).querySelector(`:scope > .oc-mobile-detail-navigation`)?.getBoundingClientRect().bottom,i=n.getBoundingClientRect().top;return Math.max(r===void 0?i:Math.max(r,i),t)},ve=(e,t)=>{let n=(0,H.c)(3),[r,i]=I.useState(void 0),a;return n[0]!==e||n[1]!==t?(a=()=>{if(!t)return;let n=()=>{let t=e.current;if(!t)return;let n=window.visualViewport,r=Y(t,n?.offsetTop??0);if(r===null)return;let a=n?.height??window.innerHeight,o=J({popupBottom:t.getBoundingClientRect().bottom,boundaryTop:r,viewportHeight:a});i(e=>e===o?e:o)};return n(),window.addEventListener(`resize`,n),window.addEventListener(`oc:keyboard-settled`,n),window.visualViewport?.addEventListener(`resize`,n),window.visualViewport?.addEventListener(`scroll`,n),()=>{window.removeEventListener(`resize`,n),window.removeEventListener(`oc:keyboard-settled`,n),window.visualViewport?.removeEventListener(`resize`,n),window.visualViewport?.removeEventListener(`scroll`,n)}},n[0]=e,n[1]=t,n[2]=a):a=n[2],I.useLayoutEffect(a),t?r:void 0},ye=()=>{let e=null,t=!1,n=!1;return{pointerDown:(n,r)=>{e={x:n,y:r},t=!1},pointerMove:(n,r)=>{e&&Math.hypot(n-e.x,r-e.y)>6&&(t=!0)},pointerCancel:()=>{e=null,t=!1},pointerUp:r=>{if(!e)return!1;let i=!t;return e=null,t=!1,i?(n=!0,r(),!0):(n=!0,!1)},click:e=>n?(n=!1,!1):(e(),!0)}},X=h(),Z=I.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSessionSelect:r,onClose:a,style:o},c)=>{let{t:u}=ee(),d=me()??``,f=w(e=>e.currentSessionId),p=O(e=>e.activeSessions),m=T(e=>e.activeProjectId),h=T(e=>e.projects),g=I.useMemo(()=>h.find(e=>e.id===m)?.path??null,[m,h]),_=I.useMemo(()=>{let e=g||d;return e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null},[g,d]),y=fe(e=>_?e.byRoot[_]:void 0),b=te(e=>e.getVisibleAgents),x=v(e=>e.searchFiles),S=pe(e,180),ne=l(),re=s(),[ie,ae]=I.useState([]),[oe,se]=I.useState([]),[D,j]=I.useState(!1),[M,N]=I.useState(0),P=I.useRef(0),[F,L]=I.useState(360),[R,z]=I.useState({}),[de,B]=I.useState({}),V=I.useRef([]),H=I.useRef([]),U=I.useRef([]),W=I.useRef(null),G=I.useRef(null);G.current||=ye();let K=i(e=>e.isMobile),he=ve(W,K),ge=(e??``).trim(),_e=I.useMemo(()=>{if(!_||!y)return[];let e=[y.selectedPath,...y.openPaths.slice().reverse()].filter(e=>typeof e==`string`&&e.length>0),t=new Set,n=ge.toLowerCase();return e.filter(e=>{if(t.has(e))return!1;t.add(e);let r=e.startsWith(`${_}/`)?e.slice(_.length+1):e;return!n||r.toLowerCase().includes(n)}).slice(0,6).map(e=>{let t=e.replace(/\\/g,`/`),n=t.split(`/`).filter(Boolean).pop()||t;return{name:n,path:t,relativePath:t.startsWith(`${_}/`)?t.slice(_.length+1):t,extension:n.includes(`.`)?n.split(`.`).pop()?.toLowerCase():void 0}})},[ge,_,y]),q=I.useMemo(()=>ge.length>0?oe:oe.slice(0,2),[oe,ge.length]),J=I.useMemo(()=>r?E({sessions:p,currentSessionId:f,searchQuery:ge}):[],[p,f,ge,r]),Y=_e,Z=ie;I.useEffect(()=>{let e=e=>{let t=e.target;!t||!W.current||W.current.contains(t)||a()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[a]),I.useEffect(()=>{if(!d){ae([]);return}let e=(S??``).trim().replace(/^\.\//,``).replace(/^\/+/,``).toLowerCase();if(!e){ae([]);return}let t=!1;j(!0);let n={includeHidden:ne,respectGitignore:!re};return Promise.all([x(d,e,80,{...n,type:`file`}),x(d,e,40,{...n,type:`directory`})]).then(([n,r])=>{if(t)return;let i=new Set(_e.map(e=>e.path));ae(ce({files:n,directories:r,query:e,excludePaths:i,limit:20}))}).catch(()=>{t||ae([])}).finally(()=>{t||j(!1)}),()=>{t=!0}},[d,S,_e,x,ne,re]),I.useEffect(()=>{let t=b(),n=(e??``).trim().toLowerCase(),r=t.filter(e=>e.mode&&e.mode!==`primary`).filter(e=>!n||`${e.name} ${e.description??``}`.toLowerCase().includes(n)).map(e=>({name:e.name,description:e.description,mode:e.mode})).sort((e,t)=>e.name.localeCompare(t.name));se(r)},[b,e]),I.useEffect(()=>{N(0),z({}),B({})},[Z,Y.length,q.length,J.length]),I.useEffect(()=>{P.current=M},[M]),I.useEffect(()=>{V.current[M]?.scrollIntoView({block:`nearest`})},[M]),I.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};H.current.forEach((n,r)=>{if(!n)return;let i=U.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}}),z(e),B(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[Z,Y]),I.useEffect(()=>{let e=H.current[M];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&L(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[M]);let be=C(e=>{t(e)}),xe=C(e=>{n?.(e)}),Se=C(e=>{r?.(e)}),Ce=(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:()=>N(e)});I.useImperativeHandle(c,()=>({handleKeyDown:e=>{if(e===`Escape`){a();return}let t=q.length+J.length+Y.length+Z.length;if(t!==0){if(e===`ArrowDown`){N(e=>(e+1)%t);return}if(e===`ArrowUp`){N(e=>(e-1+t)%t);return}if(e===`Enter`||e===`Tab`){let e=(P.current%t+t)%t;if(e<q.length){let t=q[e];t&&xe(t.name);return}let n=e-q.length;if(n<J.length){let e=J[n];e&&Se(e);return}let r=n-J.length,i=r<Y.length?Y[r]:Z[r-Y.length];i&&be(i)}}}}),[Z,Y,q,J,a,be,xe,Se]);let we=e=>{if(e.isDirectory)return(0,X.jsx)(A,{name:`folder-3-fill`,className:`h-3.5 w-3.5 text-current`});switch(e.extension?.toLowerCase()){case`ts`:case`tsx`:case`js`:case`jsx`:return(0,X.jsx)(A,{name:`code`,className:`h-3.5 w-3.5 text-current`});case`json`:return(0,X.jsx)(A,{name:`code`,className:`h-3.5 w-3.5 text-current`});case`md`:case`mdx`:return(0,X.jsx)(A,{name:`file`,className:`h-3.5 w-3.5 text-current`});case`png`:case`jpg`:case`jpeg`:case`gif`:case`svg`:return(0,X.jsx)(A,{name:`file-image`,className:`h-3.5 w-3.5 text-current`});default:return(0,X.jsx)(A,{name:`file-pdf`,className:`h-3.5 w-3.5 text-current`})}};return(0,X.jsxs)(`div`,{ref:W,className:`absolute z-[100] min-w-0 w-full max-w-[640px] max-h-64 bg-background border-2 border-border/60 rounded-xl shadow-none bottom-full mb-2 left-0 flex flex-col`,style:he===void 0?o:{...o,maxHeight:he},children:[(0,X.jsx)(ue,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,X.jsxs)(`div`,{className:`pb-2`,children:[q.length>0&&(0,X.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.groups.agents`)}),q.map((e,t)=>(0,X.jsx)(`div`,{ref:e=>{V.current[t]=e},className:k(`flex items-start gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,M===t&&`bg-interactive-selection text-interactive-selection-foreground`),...Ce(t,()=>xe(e.name)),children:(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`font-semibold truncate`,children:[`@`,e.name]}),e.description&&!K?(0,X.jsx)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:e.description}):null]})},`agent-${e.name}`)),q.length===2&&ge.length===0&&oe.length>2&&(0,X.jsx)(`div`,{className:`px-3 py-1 typography-meta text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.searchMoreAgents`)}),J.length>0&&(0,X.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.groups.sessions`)}),J.map((e,t)=>{let n=q.length+t;return(0,X.jsxs)(`div`,{ref:e=>{V.current[n]=e},className:k(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,M===n&&`bg-interactive-selection text-interactive-selection-foreground`),...Ce(n,()=>Se(e)),children:[(0,X.jsx)(A,{name:`chat-thread`,className:`h-4 w-4 flex-shrink-0 text-[var(--primary-base)]`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.title||u(`chat.fileMentionAutocomplete.untitledSession`),children:e.title||u(`chat.fileMentionAutocomplete.untitledSession`)}),K?null:(0,X.jsx)(`span`,{className:`flex-shrink-0 typography-meta text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.sessionType`)})]},`session-${e.id}`)}),Y.length>0&&(0,X.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.groups.recentFiles`)}),Y.map((e,t)=>{let n=q.length+J.length+t,r=e.relativePath||e.name,i=le(r,{maxLength:60}),a=M===n,o=R[n]??!1,s=de[n]??2.6;return(0,X.jsxs)(`div`,{ref:e=>{V.current[n]=e},className:k(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,a&&`bg-interactive-selection text-interactive-selection-foreground`),...Ce(n,()=>be(e)),children:[we(e),(0,X.jsxs)(`span`,{ref:e=>{H.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${F}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,X.jsx)(`span`,{ref:e=>{U.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,X.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:r}):(0,X.jsx)(`span`,{className:`block truncate`,children:i})]})]},`recent-${e.path}`)}),Z.length>0&&(0,X.jsx)(`div`,{className:`px-3 pb-1 pt-2 typography-meta font-medium text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.groups.files`)}),Z.map((e,t)=>{let n=q.length+J.length+Y.length+t,r=e.relativePath||e.name,i=le(r,{maxLength:60}),a=M===n,o=R[n]??!1,s=de[n]??2.6;return(0,X.jsxs)(`div`,{ref:e=>{V.current[n]=e},className:k(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,K&&`min-h-11`,a&&`bg-interactive-selection text-interactive-selection-foreground`),...Ce(n,()=>be(e)),children:[we(e),(0,X.jsxs)(`span`,{ref:e=>{H.current[n]=e},className:`relative flex-1 min-w-0 overflow-hidden file-mention-marquee-container`,style:a?{"--file-mention-marquee-width":`${F}px`,"--file-mention-marquee-duration":`${s}s`}:void 0,"aria-label":r,children:[(0,X.jsx)(`span`,{ref:e=>{U.current[n]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:r}),o&&a?(0,X.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:r}):(0,X.jsx)(`span`,{className:`block truncate`,children:i})]})]},e.path)}),D&&Z.length===0?(0,X.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,X.jsx)(A,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!D&&Z.length===0&&Y.length===0&&q.length===0&&J.length===0&&(0,X.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.fileMentionAutocomplete.empty`)})]})}),!K&&(0,X.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})}),be=new Set([`new`,`fork`,`compact`,`undo`,`redo`,`model`,`goal`]),xe=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&be.has(n))},Se=(e,t)=>!e||t({name:e}),Ce=` `,we=(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]===Ce&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},Te=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,Ee=k(Te,`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)]`),De=k(Te,`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)]`),Oe=k(Te,`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)]`),ke=k(Te,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),Ae=(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=ae(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)},je=(e,t)=>{let n=!!e.sessionID;return{hasSession:n,canStartSessionCommand:n||e.hasNewDraft,canUseReviewHandoffFlow:n&&!t&&!o()}},Me=I.forwardRef(({searchQuery:e,onCommandSelect:t,onClose:n,directory:r,style:a,commandPolicy:o,commandContext:s},c)=>{let{t:l}=ee(),u=i(e=>e.isMobile),d=w(e=>e.currentSessionId),f=w(e=>!!e.newSessionDraft?.open),p=w(I.useCallback(e=>d?e.getDirectoryForSession(d):void 0,[d])),m=oe(d??``,p??void 0),h=I.useMemo(()=>s??{sessionID:d??null,hasMessages:m.length>0,hasNewDraft:f},[s,d,m.length,f]),{hasSession:g,canStartSessionCommand:_,canUseReviewHandoffFlow:v}=I.useMemo(()=>je(h,u),[h,u]),y=h.hasMessages,[b,x]=I.useState([]),[S,C]=I.useState(!1),te=se({directory:r}),re=I.useMemo(()=>te.data??[],[te.data]),ie=te.isFetching,ae=ne({directory:r}),T=I.useMemo(()=>ae.data??[],[ae.data]),[E,ce]=I.useState(0),D=I.useRef(0),O=I.useRef(!1),le=I.useRef([]),j=I.useRef(null),M=ve(j,u),N=I.useRef(!1),P=I.useRef(null),F=I.useRef(!1);I.useEffect(()=>{let e=e=>{let t=e.target;!t||!j.current||j.current.contains(t)||n()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[n]),I.useEffect(()=>{(async()=>{C(ie);try{let t=re.map((e,t)=>({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,isSkill:e.source===`skill`,scope:e.scope,reference:e.reference})),n=T.map((e,t)=>({id:`skill:${e.scope}:${e.source??`opencode`}:${e.name}:${t}`,name:e.name,source:`skill`,description:e.description,isSkill:!0,scope:e.scope})),r=[{id:`openchamber:new`,name:`new`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},...g&&!y?[{id:`openchamber:init`,name:`init`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],...g?[{id:`openchamber:undo`,name:`undo`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`openchamber:redo`,name:`redo`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`openchamber:fork`,name:`fork`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`openchamber:timeline`,name:`timeline`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`openchamber:model`,name:`model`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`openchamber:compact`,name:`compact`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...g?[{id:`openchamber:summary`,name:`summary`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.summaryDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:workspace-review`,name:`workspace-review`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.workspaceReviewDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:handoff-review`,name:`handoff-review`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.handoffReviewDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:plan-feature`,name:`plan-feature`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.featurePlanDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:craft-goal`,name:`craft-goal`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.craftGoalDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:goal`,name:`goal`,source:`openchamber`,description:l(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:catch-up`,name:`catch-up`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.catchUpDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:debug`,name:`debug`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.debugDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:weigh`,name:`weigh`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.weighDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:explore`,name:`explore`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.exploreDescription`),isOpenChamber:!0}]:[],...t,...n],i=!y,a=r.filter(e=>(i||e.name!==`init`)&&(o?.(e)??!0));x(Ae(a,e))}catch{let t=!y,n=[{id:`openchamber:new`,name:`new`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},...g&&!y?[{id:`openchamber:init`,name:`init`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],...g?[{id:`openchamber:undo`,name:`undo`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`openchamber:redo`,name:`redo`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`openchamber:fork`,name:`fork`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`openchamber:timeline`,name:`timeline`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`openchamber:model`,name:`model`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`openchamber:compact`,name:`compact`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...g?[{id:`openchamber:summary`,name:`summary`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.summaryDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:workspace-review`,name:`workspace-review`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.workspaceReviewDescription`),isOpenChamber:!0}]:[],...v?[{id:`openchamber:handoff-review`,name:`handoff-review`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.handoffReviewDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:plan-feature`,name:`plan-feature`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.featurePlanDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:craft-goal`,name:`craft-goal`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.craftGoalDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:goal`,name:`goal`,source:`openchamber`,description:l(`chat.goal.button.armAria`),isBuiltIn:!0}]:[],..._?[{id:`openchamber:catch-up`,name:`catch-up`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.catchUpDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:debug`,name:`debug`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.debugDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:weigh`,name:`weigh`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.weighDescription`),isOpenChamber:!0}]:[],..._?[{id:`openchamber:explore`,name:`explore`,source:`openchamber`,description:l(`chat.commandAutocomplete.command.exploreDescription`),isOpenChamber:!0}]:[]].filter(e=>(t||e.name!==`init`)&&(o?.(e)??!0));x(Ae(n,e))}finally{C(!1)}})()},[e,y,g,_,v,re,ie,T,l,o]),I.useEffect(()=>{ce(0)},[b]),I.useEffect(()=>{D.current=E},[E]),I.useEffect(()=>{le.current[E]?.scrollIntoView({block:`nearest`})},[E]),I.useImperativeHandle(c,()=>({handleKeyDown:e=>{let r=b.length;if(e===`Escape`){n();return}if(r!==0){if(e===`ArrowDown`){O.current=!0,ce(e=>(e+1)%r);return}if(e===`ArrowUp`){O.current=!0,ce(e=>(e-1+r)%r);return}if(e===`Enter`||e===`Tab`){let n=(D.current%r+r)%r,i=b[n];i&&t(i,xe(i,e===`Enter`))}}}}),[b,n,t]);let L=e=>{switch(e.name){case`new`:return(0,X.jsx)(A,{name:`add`,className:`h-3.5 w-3.5`});case`init`:return(0,X.jsx)(A,{name:`file`,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,X.jsx)(A,{name:`arrow-go-back`,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,X.jsx)(A,{name:`arrow-go-forward`,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:return(0,X.jsx)(A,{name:`time`,className:`h-3.5 w-3.5`});case`compact`:return(0,X.jsx)(A,{name:`scissors`,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,X.jsx)(A,{name:`target`,className:`h-3.5 w-3.5`});case`review`:return(0,X.jsx)(A,{name:`search-eye`,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,X.jsx)(A,{name:`terminal-box`,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,X.jsx)(A,{name:`flashlight`,className:`h-3.5 w-3.5 text-yellow-500`}):(0,X.jsx)(A,{name:`command`,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,X.jsxs)(`div`,{ref:j,className:`absolute z-[100] min-w-0 w-full max-w-[450px] max-h-64 bg-background border-2 border-border/60 rounded-xl shadow-none bottom-full mb-2 left-0 flex flex-col`,style:M===void 0?a:{...a,maxHeight:M},children:[(0,X.jsx)(ue,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 pb-2`,children:S?(0,X.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,X.jsx)(A,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,X.jsxs)(`div`,{children:[b.map((e,n)=>{let r=e.isBuiltIn,i=e.isOpenChamber;return(0,X.jsxs)(`div`,{ref:e=>{le.current[n]=e},className:k(`flex gap-2 px-3 py-2 cursor-pointer rounded-lg`,u?`items-center`:`items-start`,n===E&&`bg-interactive-selection`),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(P.current={x:e.clientX,y:e.clientY},F.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!P.current)return;let t=e.clientX-P.current.x,n=e.clientY-P.current.y;Math.hypot(t,n)>6&&(F.current=!0)},onPointerUp:n=>{if(n.pointerType!==`touch`)return;let r=F.current;P.current=null,F.current=!1,!r&&(n.preventDefault(),n.stopPropagation(),N.current=!0,t(e,xe(e,u)))},onPointerCancel:()=>{P.current=null,F.current=!1},onClick:()=>{if(N.current){N.current=!1;return}t(e,xe(e,u))},onMouseMove:()=>{O.current=!1,ce(n)},children:[(0,X.jsx)(`div`,{className:k(!u&&`mt-0.5`),children:L(e)}),(0,X.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,e.name]}),e.isSkill?(0,X.jsx)(`span`,{className:Ee,children:l(`chat.commandAutocomplete.badge.skill`)}):(0,X.jsx)(`span`,{className:Ee,children:l(`chat.commandAutocomplete.badge.command`)}),i?(0,X.jsx)(`span`,{className:ke,children:`OpenChamber`}):r?(0,X.jsx)(`span`,{className:ke,children:l(`chat.commandAutocomplete.badge.system`)}):e.scope?(0,X.jsx)(`span`,{className:e.scope===`project`?Oe:De,children:e.scope}):null,e.agent&&(0,X.jsx)(`span`,{className:ke,children:e.agent})]}),e.description&&!u&&(0,X.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:e.description})]})]},e.id)}),b.length===0&&(0,X.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:l(`chat.commandAutocomplete.empty`)})]})}),!u&&(0,X.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:l(`chat.autocomplete.keyboardHint`)})]})});Me.displayName=`CommandAutocomplete`;function Ne(e){return(e.description||e.content).replace(/\s+/g,` `).trim().slice(0,120)}var Pe=I.forwardRef((e,t)=>{let n=(0,H.c)(63),{searchQuery:r,onSnippetSelect:a,onClose:o,style:s}=e,{t:c}=ee(),l=I.useRef(null),u=i(Fe),d=ve(l,u),[f,p]=I.useState(0),m=I.useRef(0),h;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=[],n[0]=h):h=n[0];let[g,_]=I.useState(h),v;n[1]===Symbol.for(`react.memo_cache_sentinel`)?(v=[],n[1]=v):v=n[1];let y=I.useRef(v),b=N(Ie),x=N(Le),S=N(Re),C=N(ze),te=i(Be),ne=i(Ve),re,ie;n[2]===x?(re=n[3],ie=n[4]):(re=()=>{x()},ie=[x],n[2]=x,n[3]=re,n[4]=ie),I.useEffect(re,ie);let oe,w;n[5]!==r||n[6]!==b?(oe=()=>{let e=r.trim();if(!e.length){let e=[...b].sort(He);_(e),p(+!!e.length);return}let t=ae(b,e,Ue);t.sort(We);let n=t.map(Ge);_(n),p(+!!n.length)},w=[r,b],n[5]=r,n[6]=b,n[7]=oe,n[8]=w):(oe=n[7],w=n[8]),I.useEffect(oe,w);let T,E;n[9]===f?(T=n[10],E=n[11]):(T=()=>{m.current=f,y.current[f]?.scrollIntoView({block:`nearest`})},E=[f],n[9]=f,n[10]=T,n[11]=E),I.useEffect(T,E);let se,ce;n[12]===o?(se=n[13],ce=n[14]):(ce=()=>{let e=e=>{let t=e.target;t&&l.current&&!l.current.contains(t)&&o()};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},se=[o],n[12]=o,n[13]=se,n[14]=ce),I.useEffect(ce,se);let D;n[15]!==a||n[16]!==r?(D=e=>{let t=r.trim(),n=e.aliases.includes(t)?t:e.name;a(e,n)},n[15]=a,n[16]=r,n[17]=D):D=n[17];let O=D,le;n[18]!==o||n[19]!==C||n[20]!==te||n[21]!==ne||n[22]!==S||n[23]!==b?(le=()=>{let e=new Set(b.map(Ke)),t=`new-snippet`,n=1;for(;e.has(t);)t=`new-snippet-${n++}`;S({name:t,scope:`global`}),C(t),ne(`snippets`),te(!0),o()},n[18]=o,n[19]=C,n[20]=te,n[21]=ne,n[22]=S,n[23]=b,n[24]=le):le=n[24];let j=le,M,P;n[25]!==O||n[26]!==g||n[27]!==o||n[28]!==j?(M=()=>({handleKeyDown:e=>{if(e===`Escape`){o();return}let t=g.length+1;if(e===`ArrowDown`){p(e=>(e+1)%t);return}if(e===`ArrowUp`){p(e=>(e-1+t)%t);return}if(e===`Enter`||e===`Tab`){if(m.current===0){j();return}let e=g[m.current-1];e&&O(e)}}}),P=[O,g,o,j],n[25]=O,n[26]=g,n[27]=o,n[28]=j,n[29]=M,n[30]=P):(M=n[29],P=n[30]),I.useImperativeHandle(t,M,P);let F;n[31]!==d||n[32]!==s?(F=d===void 0?s:{...s,maxHeight:d},n[31]=d,n[32]=s,n[33]=F):F=n[33];let L;n[34]===Symbol.for(`react.memo_cache_sentinel`)?(L=e=>{y.current[0]=e},n[34]=L):L=n[34];let R=f===0&&`bg-interactive-selection`,z;n[35]===R?z=n[36]:(z=k(`flex items-center gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label`,R),n[35]=R,n[36]=z);let de,B;n[37]===Symbol.for(`react.memo_cache_sentinel`)?(de=()=>p(0),B=(0,X.jsx)(A,{name:`add`,className:`h-3.5 w-3.5 text-muted-foreground`}),n[37]=de,n[38]=B):(de=n[37],B=n[38]);let V;n[39]===c?V=n[40]:(V=c(`chat.snippetAutocomplete.action.addNew`),n[39]=c,n[40]=V);let fe;n[41]===V?fe=n[42]:(fe=(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:V}),n[41]=V,n[42]=fe);let pe;n[43]!==j||n[44]!==z||n[45]!==fe?(pe=(0,X.jsxs)(`div`,{ref:L,className:z,onClick:j,onMouseMove:de,children:[B,fe]}),n[43]=j,n[44]=z,n[45]=fe,n[46]=pe):pe=n[46];let me;n[47]!==O||n[48]!==g||n[49]!==u||n[50]!==f||n[51]!==c?(me=g.length?g.map((e,t)=>(0,X.jsx)(`div`,{ref:e=>{y.current[t+1]=e},className:k(`flex gap-2 px-3 py-1.5 cursor-pointer rounded-lg typography-ui-label`,u?`items-center`:`items-start`,t+1===f&&`bg-interactive-selection`),onClick:()=>O(e),onMouseMove:()=>p(t+1),children:(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`font-semibold truncate`,children:[`#`,e.name]}),(0,X.jsx)(`span`,{className:`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0 bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`,children:c(`snippets.source.${e.source}`)})]}),!u&&(0,X.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:Ne(e)})]})},`${e.source}:${e.filePath}`)):(0,X.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:c(`chat.snippetAutocomplete.empty`)}),n[47]=O,n[48]=g,n[49]=u,n[50]=f,n[51]=c,n[52]=me):me=n[52];let U;n[53]!==pe||n[54]!==me?(U=(0,X.jsxs)(ue,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 pb-2`,children:[pe,me]}),n[53]=pe,n[54]=me,n[55]=U):U=n[55];let W;n[56]!==u||n[57]!==c?(W=!u&&(0,X.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:c(`chat.snippetAutocomplete.footer`)}),n[56]=u,n[57]=c,n[58]=W):W=n[58];let G;return n[59]!==F||n[60]!==U||n[61]!==W?(G=(0,X.jsxs)(`div`,{ref:l,className:`absolute z-[100] min-w-0 w-full max-w-[450px] max-h-60 bg-background border-2 border-border/60 rounded-xl shadow-none bottom-full mb-2 left-0 flex flex-col`,style:F,children:[U,W]}),n[59]=F,n[60]=U,n[61]=W,n[62]=G):G=n[62],G});Pe.displayName=`SnippetAutocomplete`;function Fe(e){return e.isMobile}function Ie(e){return e.snippets}function Le(e){return e.loadSnippets}function Re(e){return e.setSnippetDraft}function ze(e){return e.setSelectedSnippet}function Be(e){return e.setSettingsDialogOpen}function Ve(e){return e.setSettingsPage}function He(e,t){return e.source===`project`&&t.source!==`project`?-1:e.source!==`project`&&t.source===`project`?1:e.name.localeCompare(t.name)}function Ue(e){return[e.name,...e.aliases]}function We(e,t){return e.score===t.score?e.item.source===`project`&&t.item.source!==`project`?-1:e.item.source!==`project`&&t.item.source===`project`?1:e.item.name.localeCompare(t.item.name):e.score-t.score}function Ge(e){return e.item}function Ke(e){return e.name}var qe=2,Je=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Ye=e=>{let t=e?.trim().replace(/\\/g,`/`);return t?t.length>1?t.replace(/\/+$/,``):t:null},Xe=e=>Je(e)&&Array.isArray(e.all)&&e.all.every(e=>typeof e==`string`)&&typeof e.current==`string`&&Je(e.branches),Ze=(e,t)=>JSON.stringify([e,t]),Qe=e=>`version`in e&&e.version===qe&&Je(e.entries),$e=e=>{if(!e)return null;try{let t=JSON.parse(e);return Je(t)?t.version===qe&&Je(t.entries)?{version:qe,entries:t.entries}:t:null}catch{return null}},et=(e,t)=>{try{e.setItem(`oc.gitBranchCache`,JSON.stringify(t))}catch{}},tt=(e,t,n)=>{let r=Ye(e);if(!r||!t)return null;let i;try{i=n.getItem(`oc.gitBranchCache`)}catch{return null}let a=$e(i);if(!a)return null;if(Qe(a))return Xe(a.entries[Ze(t,r)])?a.entries[Ze(t,r)]:null;let o={};for(let[e,n]of Object.entries(a)){let r=Ye(e);r&&Xe(n)&&(o[Ze(t,r)]=n)}return et(n,{version:qe,entries:o}),o[Ze(t,r)]??null},nt=(e,t,n,r)=>{let i=Ye(e);if(!i||!t||!Xe(n))return;let a=null;try{a=r.getItem(`oc.gitBranchCache`)}catch{return}let o=$e(a);et(r,{version:qe,entries:{...o&&Qe(o)?o.entries:{},[Ze(t,i)]:n}})},rt=3e4,it=Ye,at=(e,n=t())=>c.git.branches(it(e),n),ot=(e,n=t())=>c.git.remotes(it(e),n),st=async(e,t,n)=>{n.throwIfAborted();let r=d()?.git,i=t?.getGitBranches?await t.getGitBranches(e,{signal:n}):r?await r.getGitBranches(e,{signal:n}):await y(e,{signal:n});return n.throwIfAborted(),i},ct=async(e,t,n)=>{n.throwIfAborted();let r=d()?.git,i=t?.getRemotes?await t.getRemotes(e,{signal:n}):r?await r.getRemotes(e,{signal:n}):await _(e,{signal:n});return n.throwIfAborted(),i},lt=(e,r,i=t(),a=n())=>{let o=it(e),s=r;return{queryKey:at(o,i),queryFn:async({signal:e})=>{if(!o)throw Error(`Git branches require a directory`);let t=await st(o,s,e);return nt(o,i,t,a),t},staleTime:rt,gcTime:1/0,initialData:()=>tt(o,i,a)??void 0,initialDataUpdatedAt:0}},ut=(e,n,r=t())=>{let i=it(e),a=n;return{queryKey:ot(i,r),queryFn:({signal:e})=>{if(!i)throw Error(`Git remotes require a directory`);return ct(i,a,e)},staleTime:rt,gcTime:1/0}},dt=(e,n,i)=>{let a=(0,H.c)(9),o=i===void 0||i,s=I.useSyncExternalStore(r,t,t),c,l,u;a[0]!==e||a[1]!==n||a[2]!==s?(c=it(e),u=S,l=lt(c,n,s),a[0]=e,a[1]=n,a[2]=s,a[3]=c,a[4]=l,a[5]=u):(c=a[3],l=a[4],u=a[5]);let d=o&&!!c,f;return a[6]!==l||a[7]!==d?(f={...l,enabled:d},a[6]=l,a[7]=d,a[8]=f):f=a[8],u(f)},ft=(e,n,i)=>{let a=(0,H.c)(9),o=i===void 0||i,s=I.useSyncExternalStore(r,t,t),c,l,u;a[0]!==e||a[1]!==n||a[2]!==s?(c=it(e),u=S,l=ut(c,n,s),a[0]=e,a[1]=n,a[2]=s,a[3]=c,a[4]=l,a[5]=u):(c=a[3],l=a[4],u=a[5]);let d=o&&!!c,f;return a[6]!==l||a[7]!==d?(f={...l,enabled:d},a[6]=l,a[7]=d,a[8]=f):f=a[8],u(f)},pt=(e,n,r=u,i=t())=>r.fetchQuery(lt(e,n,i)),mt=(e,n,r=u,i=t())=>r.fetchQuery({...lt(e,n,i),staleTime:0}),ht=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,gt=1e4,_t=6e4,vt=5e3,yt=3e4,bt=6e4,xt=25,St=40,Ct=2,wt=15e3,Tt=500,Et=30,Dt=20971520,Ot=new Map,kt=new Map,At=new Map,jt=new Map,Mt=new Map,Nt=(e,t)=>`${t}:${e}`,Pt=e=>kt.get(e)??0,Ft=e=>{let t=Pt(e)+1;return kt.set(e,t),t},It=e=>{let t=(At.get(e)??0)+1;return At.set(e,t),t},Lt=e=>{let t=Ot.get(e);if(t)return t;let n=new Set;return Ot.set(e,n),n},Q=()=>({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}),Rt=(e,t=Et,n=Dt)=>{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},zt=(e,t)=>{if(!e&&!t)return!1;if(!e||!t)return!0;let n=new Set([...Object.keys(e),...Object.keys(t)]);for(let r of n){let n=e[r],i=t[r];if(!(!n&&!i)&&(!n||!i||n.insertions!==i.insertions||n.deletions!==i.deletions))return!0}return!1},Bt=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,Vt=(e,t)=>{if(!e&&!t)return!1;if(!e||!t)return!0;let n=e.files??[],r=t.files??[];if(n.length!==r.length||e.ahead!==t.ahead||e.behind!==t.behind||e.current!==t.current||e.tracking!==t.tracking||e.isClean!==t.isClean||t.upstreamComparison!==void 0&&Bt(e.upstreamComparison,t.upstreamComparison))return!0;let i=new Set(n.map(e=>`${e.path}:${e.index}:${e.working_dir}`));for(let e of r)if(!i.has(`${e.path}:${e.index}:${e.working_dir}`))return!0;return!!(t.diffStats!==void 0&&zt(e.diffStats,t.diffStats))},Ht=(e,t)=>{let n=new Set;if(!t)return n;let r=e?.files??[],i=t.files??[],a=new Map(r.map(e=>[e.path,e])),o=new Map(i.map(e=>[e.path,e])),s=new Set([...a.keys(),...o.keys()]);for(let e of s){let t=a.get(e),r=o.get(e);if(!t||!r){n.add(e);continue}if(t.index!==r.index||t.working_dir!==r.working_dir){n.add(e);continue}}if(t.diffStats!==void 0){let r=e?.diffStats??{},i=t.diffStats??{},a=new Set([...Object.keys(r),...Object.keys(i)]);for(let e of a){let t=r[e],a=i[e];if(!t||!a){n.add(e);continue}(t.insertions!==a.insertions||t.deletions!==a.deletions)&&n.add(e)}}return n},Ut=(e,t)=>{if(!e&&!t)return!1;if(!e||!t)return!0;let n=e.files??[],r=t.files??[],i=e=>{let t=e?.trim()??``;return t===`?`?``:t},a=new Map(n.map(e=>[e.path,i(e.index)])),o=new Map(r.map(e=>[e.path,i(e.index)])),s=new Set([...a.keys(),...o.keys()]);for(let e of s)if((a.get(e)??``)!==(o.get(e)??``))return!0;return!1},Wt=e=>!e||e.trim().length===0,Gt=e=>(e||``).trim()===`U`,Kt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(Gt(t)||Gt(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},qt=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(Gt(t)||Gt(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},Jt=e=>Wt(e.index)&&Wt(e.working_dir),$=f()(m((e,n)=>({directories:new Map,activeDirectory:null,setActiveDirectory:t=>{let{activeDirectory:r,directories:i}=n();if(r!==t)if(r&&Ft(r),t&&Ft(t),t&&!i.has(t)){let n=new Map(i);n.set(t,Q()),e({activeDirectory:t,directories:n})}else e({activeDirectory:t})},getDirectoryState:e=>n().directories.get(e)??null,fetchStatus:async(t,r,i={})=>{let a=i.mode??`full`,o=Nt(t,a),s=jt.get(o)??(a===`light`?jt.get(Nt(t,`full`)):void 0);if(s)return s;let c=(async()=>{let{silent:a=!1}=i,{directories:o}=n(),s=o.get(t);if(s||=Q(),!a){let r=new Map(n().directories),i=r.get(t)??Q();r.set(t,{...i,isLoadingStatus:!0}),e({directories:r})}let c=!1;try{let a=Date.now(),o=s.isGitRepo!==!0||a-(s.lastRepoCheckAt||0)>_t,l=s.isGitRepo===!0;if(o&&(l=await r.checkIsGitRepository(t)),!l){let r=new Map(n().directories),i=r.get(t)??s;return r.set(t,{...i,isGitRepo:!1,status:null,isLoadingStatus:!1,lastRepoCheckAt:a,lastStatusFetch:a}),e({directories:r}),!1}let u=await r.getGitStatus(t,i.mode?{mode:i.mode}:void 0);if(Vt(s.status,u)){c=!0;let r=new Map(n().directories),i=r.get(t)??Q(),s=Ht(i.status,u),l=Ut(i.status,u),d=new Set((i.status?.files??[]).map(e=>e.path)),f=new Set((u.files??[]).map(e=>e.path)),p=new Map(i.diffCache);for(let e of d)f.has(e)||p.delete(e);for(let e of s)p.delete(e);let m=s.size>0;m&&Ft(t);let h={...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(t,{...i,isGitRepo:!0,status:h,diffCache:p,indexRevision:l?i.indexRevision+1:i.indexRevision,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:m?Date.now():i.lastStatusChange}),e({directories:r})}else{let r=new Map(n().directories),i=r.get(t)??Q();r.set(t,{...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(n().directories),i=r.get(t)??Q();r.set(t,{...i,isLoadingStatus:!1}),e({directories:r})}}return c})();jt.set(o,c);try{return await c}finally{jt.get(o)===c&&jt.delete(o)}},moveStatusPathsOptimistically:(t,r,i)=>{let a=new Set(r.map(e=>e.trim()).filter(Boolean));if(a.size===0)return null;let{directories:o}=n(),s=o.get(t),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`?Kt(e):qt(e);t!==e&&(l=!0),Jt(t)?l=!0:u.push(t)}if(!l)return c;let d=new Map(o);return d.set(t,{...s,status:{...c,files:u,isClean:u.length===0},indexRevision:s.indexRevision+1,lastStatusChange:Date.now()}),e({directories:d}),c},restoreStatus:(t,r)=>{let{directories:i}=n(),a=i.get(t);if(!a)return;let o=new Map(i);o.set(t,{...a,status:r,indexRevision:a.indexRevision+1,lastStatusChange:Date.now()}),e({directories:o})},bumpIndexRevision:t=>{let{directories:r}=n(),i=r.get(t);if(!i)return;let a=new Map(r);a.set(t,{...i,indexRevision:i.indexRevision+1}),e({directories:a})},fetchBranches:async(r,i,a={})=>{let o=t(),s=It(r);{let t=new Map(n().directories),i=t.get(r)??Q();t.set(r,{...i,isLoadingBranches:!0}),e({directories:t})}try{let c=a.force?await mt(r,i,void 0,o):await pt(r,i,void 0,o);if(s!==At.get(r)||o!==t())return;let l=new Map(n().directories),u=l.get(r)??Q();l.set(r,{...u,branches:c,branchesTransportIdentity:o,isLoadingBranches:!1,lastBranchesFetch:Date.now()}),e({directories:l})}catch(i){if(ht(i)||console.error(`Failed to fetch git branches:`,i),s!==At.get(r)||o!==t())return;let a=new Map(n().directories),c=a.get(r)??Q();a.set(r,{...c,isLoadingBranches:!1}),e({directories:a})}},fetchLog:async(t,r,i)=>{let{directories:a}=n(),o=a.get(t),s=i??o?.logMaxCount??25;{let r=new Map(n().directories),i=r.get(t)??Q();r.set(t,{...i,isLoadingLog:!0}),e({directories:r})}try{let i=await r.getGitLog(t,{maxCount:s}),a=new Map(n().directories),o=a.get(t)??Q();a.set(t,{...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(n().directories),a=i.get(t)??Q();i.set(t,{...a,isLoadingLog:!1}),e({directories:i})}},fetchIdentity:async(t,r)=>{{let r=new Map(n().directories),i=r.get(t)??Q();r.set(t,{...i,isLoadingIdentity:!0}),e({directories:r})}try{let i=await r.getCurrentGitIdentity(t),a=new Map(n().directories),o=a.get(t)??Q();a.set(t,{...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(n().directories),a=i.get(t)??Q();i.set(t,{...a,isLoadingIdentity:!1}),e({directories:i})}},fetchAll:async(t,r,i={})=>{let{directories:a}=n(),o=a.get(t);if(!o){o=Q();let n=new Map(a);n.set(t,o),e({directories:n})}let{force:s=!1,silentIfCached:c=!1}=i,l=Date.now();await n().fetchStatus(t,r,{silent:c&&!!o?.status});let u=n().directories.get(t);if(!u?.isGitRepo)return;await n().fetchBranches(t,r,{force:s});let d=l-(u.lastLogFetch||0);(s||d>gt||!u.log)&&await n().fetchLog(t,r),await n().fetchIdentity(t,r)},getDiff:(e,t)=>n().directories.get(e)?.diffCache.get(t)??null,setDiff:(t,r,i)=>{let a=new Map(n().directories),o=a.get(t)??Q(),s=new Map(o.diffCache);s.set(r,{...i,fetchedAt:Date.now()});let c=Rt(s);a.set(t,{...o,diffCache:c}),e({directories:a})},clearDiffCache:t=>{Ft(t);let r=new Map(n().directories),i=r.get(t);i&&(r.set(t,{...i,diffCache:new Map}),e({directories:r}))},fetchAllDiffs:async(e,t)=>{let r=n().directories.get(e);if(!r?.status?.files||r.status.files.length===0)return;let i=r.status.files.map(e=>e.path).slice(0,xt);await n().prefetchDiffs(e,t,i,{maxFiles:xt})},prefetchDiffs:async(t,r,i,a={})=>{let o=n().directories.get(t);if(!o?.status?.files||o.status.files.length===0||i.length===0)return;let{maxFiles:s=St}=a,c=new Set(o.status.files.map(e=>e.path)),l=o.status.diffStats,u=Lt(t),d=[],f=new Set;for(let e of i){if(!e||f.has(e)||(f.add(e),!c.has(e))||o.diffCache.has(e)||u.has(e))continue;let t=l?.[e];t&&t.insertions+t.deletions>Tt||d.push(e)}let p=d.slice(0,Math.max(1,s));if(p.length===0)return;let m=Pt(t);if(typeof document<`u`&&document.hidden)return;p.forEach(e=>u.add(e));let h=0,g=[],_=()=>{let e=h;return h+=1,e<p.length?p[e]:null},v=async e=>{let n=r.getGitFileDiff(t,{path:e}),i=new Promise((e,t)=>{setTimeout(()=>t(Error(`Timed out after ${wt}ms`)),wt)}),a=await Promise.race([n,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},y=async()=>{for(;;){if(m!==Pt(t))return;let e=_();if(!e)return;try{g.push(await v(e))}catch{}finally{u.delete(e)}}},b=Math.min(Ct,p.length);if(await Promise.allSettled(Array.from({length:b},()=>y())),p.forEach(e=>u.delete(e)),m!==Pt(t))return;let x=new Map(n().directories),S=x.get(t);if(!S)return;let C=new Map(S.diffCache),ee=Date.now();g.forEach(e=>{C.set(e.path,{...e.diff,fetchedAt:ee})});let te=Rt(C);x.set(t,{...S,diffCache:te}),e({directories:x})},setLogMaxCount:(t,r)=>{let i=new Map(n().directories),a=i.get(t)??Q();i.set(t,{...a,logMaxCount:r}),e({directories:i})},ensureStatus:async(e,t)=>{let r=n().directories.get(e),i=Date.now();r?.status&&i-r.lastStatusFetch<vt||await n().fetchStatus(e,t,{silent:!!r?.status})},ensureAll:(e,t)=>{let r=Mt.get(e);if(r)return r;let i=(async()=>{let r=n().directories.get(e),i=Date.now();(!r?.status||r.status.diffStats===void 0||i-(r?.lastStatusFetch??0)>=vt)&&await n().fetchStatus(e,t,{silent:!!r?.status});let a=n().directories.get(e);if(!a?.isGitRepo)return;let o=[];(!a.branches||i-a.lastBranchesFetch>=yt)&&o.push(n().fetchBranches(e,t)),(!a.log||i-a.lastLogFetch>=gt)&&o.push(n().fetchLog(e,t)),(!a.identity||i-a.lastIdentityFetch>=bt)&&o.push(n().fetchIdentity(e,t)),o.length>0&&await Promise.all(o)})();return Mt.set(e,i),i.finally(()=>{Mt.get(e)===i&&Mt.delete(e)}),i},refresh:async(e,t={})=>{let{activeDirectory:r}=n();r&&await n().fetchAll(r,e,t)}}),{name:`git-store`})),Yt=e=>{let t=(0,H.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),$(n)},Xt=e=>{let n=(0,H.c)(3),i=I.useSyncExternalStore(r,t,t),a;return n[0]!==e||n[1]!==i?(a=t=>{if(!e)return null;let n=t.directories.get(e);return n?.branchesTransportIdentity===i?n.branches:null},n[0]=e,n[1]=i,n[2]=a):a=n[2],$(a)},Zt=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.log??null:null,t[0]=e,t[1]=n),$(n)},Qt=e=>{let t=(0,H.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),$(n)},$t=e=>{let t=(0,H.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),$(n)},en={current:new Map},tn=()=>$(sn),nn=e=>{let t=(0,H.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=I.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),$(i)},rn=e=>{let t=(0,H.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),$(n)},an=e=>{let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingLog??!1:!1,t[0]=e,t[1]=n),$(n)},on=e=>{let t=(0,H.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),$(n)};function sn(e){let t=en.current,n=t.size===e.directories.size;if(n){for(let[r,i]of e.directories)if(t.get(r)!==(i.status?.current??null)){n=!1;break}}if(n)return t;let r=new Map;for(let[t,n]of e.directories)r.set(t,n.status?.current??null);return en.current=r,r}var cn=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)}},ln=e=>String(e||``).trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/^remotes\//,``),un=e=>e.branchName?ln(e.branchName):e.mode===`existing`?ln(e.existingBranch||e.preferredName||``):ln(e.preferredName||``),dn=async e=>{let t=await P(e);try{let n=cn((await j(e)).branches?.[t]?.tracking||null);if(n?.remote)return n.remote}catch{}try{let t=cn((await M(e)).tracking);if(t?.remote)return t.remote}catch{}return null},fn=async(e,t)=>{let n=await dn(e),r=ln(t);return!n||!r?null:{setUpstream:!0,upstreamRemote:n,upstreamBranch:r}},pn=async(e,t,n)=>{let r=un(t),i=n?.resolvedRootTrackingRemote,a=i===void 0?await fn(e,r):i&&ln(r)?{setUpstream:!0,upstreamRemote:i,upstreamBranch:ln(r)}:null;return a?{...t,setUpstream:t.setUpstream??a.setUpstream,upstreamRemote:t.upstreamRemote||a.upstreamRemote,upstreamBranch:t.upstreamBranch||a.upstreamBranch}:t},mn=async(e,t,n)=>{let r=await pn(e.path,t,n);return F(e,r)},hn=`oc:lastWorktreeSourceBranch`,gn=({mode:e,sourceBranch:t,linkedPr:n,selectedBranch:r})=>e===`existing-branch`?r||null:n?null:t||null,_n=({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},vn=(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?` `:``}`},yn=(e,t,n)=>{let r=vn(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},bn=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=yn(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}},xn=(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]:[...e,t]},Sn=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{ve as A,dt as C,we as D,Me as E,pe as M,fe as N,Se as O,mt as S,Pe as T,Zt as _,hn as a,$ as b,mn as c,tn as d,$t as f,rn as g,an as h,yn as i,me as j,Z as k,dn as l,on as m,xn as n,_n as o,Xt as p,bn as r,gn as s,Sn as t,pn as u,nn as v,ft as w,Qt as x,Yt as y};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/renderMobileApp-BCV81Ryl.js","assets/rolldown-runtime-C0FnF6B9.js","assets/useUIStore-5agS8bsW.js","assets/vendor-zustand-B4dlGEM2.js","assets/vendor-base-ui-CnHfUmDN.js","assets/persistence-DPNMIbF5.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-react-DLPElpoQ.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/gitApiHttp-D8j1qRH4.js","assets/vendor-opencode-sdk-C07HQypa.js","assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js","assets/vendor-sonner-DVzioF3d.js","assets/vendor-reactuses-core-DDoDDyM9.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/clipboard-BW7nk_Cx.js","assets/store-wa1ersRf.js","assets/useMobileNavigationStore-DnzT4jO2.js","assets/vendor-tanstack-react-query-D7pys_c9.js","assets/useAssistantUIStore-Bq3cPj2x.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/MobileShareBridge-apXM34Lb.js","assets/desktopHosts-CBoBpJ1Z.js","assets/desktopRelayRestore-l2R9muux.js","assets/MobileDetailNavigation-Q2IzHqGA.js","assets/utils-Co19EJEL.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/Icon-AXqa-fYB.js","assets/button-CDvMVaiO.js","assets/AgentAvatar-B2kZjgaf.js","assets/dialog-DjYfj1Sn.js","assets/gitApi-BYxg_qGJ.js","assets/useAppFontEffects-CM0VKsdo.js","assets/vendor-simplewebauthn-browser-Dwhcdg_5.js","assets/projectMeta-v-LP2mzz.js","assets/input-k9DGGyZ6.js","assets/tooltip-DMNR5rN0.js","assets/OverlayScrollbar-D6NySAxi.js","assets/vendor-dnd-kit-core-CvWxUPdb.js","assets/vendor-dnd-kit-accessibility-BY5LhhUB.js","assets/vendor-dnd-kit-sortable-hHdP9lLb.js","assets/useSessionAutoCleanup-DxZeceKO.js","assets/radio-CJuhbQ5a.js","assets/vendor-codemirror-autocomplete-DHomsvW7.js","assets/vendor-codemirror-lang-angular-DShkBD6m.js","assets/vendor-codemirror-lang-json-CYJRHck9.js","assets/vendor-codemirror-lang-markdown-WORgx6ZD.js","assets/vendor-codemirror-lang-python-Du6XQ8Zw.js","assets/vendor-codemirror-legacy-modes-DuRAjNvB.js","assets/useThemeSystem-DMzWVJaW.js","assets/vendor-codemirror-language-data-BfYFhIH1.js","assets/markdownTheme-DNT93i5L.js","assets/vendor-pierre-diffs-BenIz2TM.js","assets/vendor-hast-util-to-html-B0p1k5Xa.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-DpDied8H.js","assets/ChatContainer-D6yfuigV.js","assets/useRuntimeAPIs-DSLXJybW.js","assets/appThemeRegistry-CgfOR_0L.js","assets/markdown-worker-DkeWiER6.js","assets/url-7MqoLs9X.js","assets/useEffectiveDirectory-aUC3zzl_.js","assets/FadeInOnReveal-aeWlaqVB.js","assets/insertionBoundaries-DzXMTleb.js","assets/useWorkerHighlightedLines-CiYQjBe6.js","assets/vendor-tanstack-react-virtual-tlDgH6PG.js","assets/vendor-cmdk-CeAGfrLo.js","assets/vendor-aria-hidden-BbL3cEyI.js","assets/sortable-tabs-strip-D8JHUI0z.js","assets/vendor-framer-motion-DFy_BSVd.js","assets/useFontPreferences-CIurCeNv.js","assets/terminalApi-tB3qLcfa.js","assets/MobileSurface-htGkf7Ua.js","assets/collapsible-C2aamDvD.js","assets/vendor-codemirror-commands-C9DCaJ0C.js","assets/vendor-codemirror-search-D2SOgzph.js","assets/vendor-replit-codemirror-vim-CEibx3EP.js","assets/projectActions-CWvNGKfA.js","assets/runtimeEndpointReset-Dg3DMy9v.js","assets/context-menu-BaxmodD8.js","assets/vendor-cron-parser-CCD11YFT.js","assets/SettingsView-DxMpVLlt.js","assets/vendor-yaml-DIcAK3EC.js","assets/vendor-qrcode-DAuVxiQR.js","assets/vendor-dijkstrajs-DztKuCwY.js","assets/AssistantView-DvoyOGkx.js","assets/fileQueries-CE_DaZWQ.js","assets/src-oHrYIqHF.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{t as e}from"./runtimeConfig-BtWi74Pm.js";import{o as t}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";/* empty css */window.__OPENCHAMBER_RUNTIME_APIS__=e(),t(async()=>{let{renderMobileApp:e}=await import(`./renderMobileApp-BCV81Ryl.js`);return{renderMobileApp: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])).then(({renderMobileApp:t})=>{t(window.__OPENCHAMBER_RUNTIME_APIS__??e())});
|