@openchambery/web 2.0.0-beta.9 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/dist/assets/{AgentAvatar-CzTtVMnI.js → AgentAvatar-C1MGZ7qC.js} +1 -1
- package/dist/assets/AssistantView-vqCFvVo0.js +3 -0
- package/dist/assets/{DiagramView-oeXj4YHn.js → DiagramView-CYO5iVVm.js} +1 -1
- package/dist/assets/{FadeInOnReveal-DCqrQkkz.js → FadeInOnReveal-BMSk_tY-.js} +1 -1
- package/dist/assets/Icon-BdzPRCSy.js +1 -0
- package/dist/assets/MarkdownRenderer-FMynjkGR.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-CahUctxC.js → MarkdownRendererImpl-DoWvw5jj.js} +3 -3
- package/dist/assets/{MarkstreamRendererImpl-5JUaTSdl.js → MarkstreamRendererImpl-DoeYajmw.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-agQ-Yhpd.js → MobileDetailNavigation-BzBz-co_.js} +1 -1
- package/dist/assets/{MobileShareBridge-yCN95dYg.js → MobileShareBridge-D1Uoj6l_.js} +3 -3
- package/dist/assets/MobileSurface-8YpZ51Qo.js +2 -0
- package/dist/assets/{MultiRunWindow-C0HqMFpp.js → MultiRunWindow-BxcYUPta.js} +1 -1
- package/dist/assets/{OnboardingScreen-O4cGdz5p.js → OnboardingScreen-yRdQTR1M.js} +1 -1
- package/dist/assets/{OverlayScrollbar-CRfGtcmG.js → OverlayScrollbar-BUjtqnxn.js} +1 -1
- package/dist/assets/SettingsView-D7KrvqvH.js +25 -0
- package/dist/assets/{SettingsWindow-B_d5Aqq3.js → SettingsWindow-DX2w-cDc.js} +1 -1
- package/dist/assets/{TerminalView-DdNQQb8W.js → TerminalView-CiUcCQPm.js} +1 -1
- package/dist/assets/{ToolOutputDialog-4DC5OE1J.js → ToolOutputDialog-DQvXtK71.js} +1 -1
- package/dist/assets/appThemeRegistry-BXC6cIDE.js +1 -0
- package/dist/assets/{assistant-attachment-cache-DphJleHr.js → assistant-attachment-cache-sG8YQsVs.js} +1 -1
- package/dist/assets/{button-DIIrsMjW.js → button-CUwjpv-i.js} +1 -1
- package/dist/assets/{collapsible-CnvUeYst.js → collapsible-paItOH3A.js} +1 -1
- package/dist/assets/{context-menu-BGBUpZEQ.js → context-menu-K6zNumqN.js} +1 -1
- package/dist/assets/{desktopHosts-JGFqhlaM.js → desktopHosts-DuftEj8B.js} +1 -1
- package/dist/assets/desktopRelayRestore-g378BdZf.js +1 -0
- package/dist/assets/{diagram-rvn7_qBM.js → diagram-D6nY5hbD.js} +1 -1
- package/dist/assets/dialog-PjKWayIU.js +1 -0
- package/dist/assets/dropdown-menu.styles-ayLWk2gf.js +1 -0
- package/dist/assets/{es-Dsmc0A_3.js → es-BBbon7SL.js} +4 -4
- package/dist/assets/fileMentionTouchSelection-78v5mNTE.js +2 -0
- package/dist/assets/{fileQueries-DN6gbLhM.js → fileQueries-DuF89nFO.js} +1 -1
- package/dist/assets/{fr-C_ZlZDI2.js → fr-BsKj2CTi.js} +4 -4
- package/dist/assets/{gitApi-da8etTTe.js → gitApi-eoKSJcvW.js} +4 -4
- package/dist/assets/{imageSource-BMztRu0c.js → imageSource-BpUsiwFd.js} +1 -1
- package/dist/assets/{input-BVu-iykl.js → input-BeVw4D0W.js} +1 -1
- package/dist/assets/insertionBoundaries-BI3RHOpf.js +1 -0
- package/dist/assets/{ja-BqqTaWTi.js → ja-1mgxunoM.js} +4 -4
- package/dist/assets/{ko-DP2XPM37.js → ko-Ra9znPcL.js} +4 -4
- package/dist/assets/main-CQpUPjPK.js +169 -0
- package/dist/assets/{main-KwlAomA8.js → main-MN0YKJ0_.js} +2 -2
- package/dist/assets/main-qSeeJRW1.css +1 -0
- package/dist/assets/{markdownHeightCache-D9-B1wdY.js → markdownHeightCache-CGCWmHgq.js} +1 -1
- package/dist/assets/{mcpQueries-3GTWeMU-.js → mcpQueries-X424Iq2z.js} +1 -1
- package/dist/assets/miniChat-DFIl76ku.js +2 -0
- package/dist/assets/mobile-C3fWXGQJ.js +2 -0
- package/dist/assets/multirun-DuSX3YRs.js +3 -0
- package/dist/assets/persistence-Dnj1QOdX.js +3 -0
- package/dist/assets/pl-B714sdql.js +15 -0
- package/dist/assets/platform-jCZ3KfMQ.js +6 -0
- package/dist/assets/projectMeta-Cn08pTNi.js +1 -0
- package/dist/assets/{pt-BR-W09Q2pvn.js → pt-BR-DVoT_I7_.js} +4 -4
- package/dist/assets/{relay-image-stream-DrdVj99c.js → relay-image-stream-D2XooXKZ.js} +1 -1
- package/dist/assets/renderElectronMiniChatApp-CRPdctIn.js +2 -0
- package/dist/assets/renderMobileApp-CVURQbeh.js +28 -0
- package/dist/assets/{runtime-fetch-Fs9ZV2V8.js → runtime-fetch-CiqQd__Y.js} +1 -1
- package/dist/assets/runtime-switch-BJM2k_uH.js +1 -0
- package/dist/assets/runtimeConfig-xivE1wxC.js +2 -0
- package/dist/assets/runtimeEndpointReset-B8DzKzwg.js +148 -0
- package/dist/assets/runtimeEndpointReset-D_vfNOQz.css +1 -0
- package/dist/assets/sessionChangeSummary-yBsR2pyd.js +2 -0
- package/dist/assets/{sessionLookup-0Z4e-J1g.js → sessionLookup-1Z1FWZRB.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-CE7W7lJ9.js → sortable-tabs-strip-D611LPyd.js} +1 -1
- package/dist/assets/src-TBM7scxy.css +2 -0
- package/dist/assets/{store-jaP79mqI.js → store-l_X_jQNz.js} +4 -4
- package/dist/assets/{terminalApi-mDR2jXTo.js → terminalApi-BZW_rAc3.js} +1 -1
- package/dist/assets/{textarea-XD2oX_Ee.js → textarea-QtZjf4L8.js} +1 -1
- package/dist/assets/{tooltip-DYeQ_Hvy.js → tooltip-DDNnmcXI.js} +1 -1
- package/dist/assets/{uk-BgFzz8m2.js → uk-ChNnTgKP.js} +4 -4
- package/dist/assets/{url-CGbJbiJq.js → url-DNRMq_0R.js} +1 -1
- package/dist/assets/{useAppFontEffects-y_GTVXhJ.js → useAppFontEffects-DJy8P5By.js} +55 -55
- package/dist/assets/{useAssistantUIStore-Bz4tRflF.js → useAssistantUIStore-DBwfg9nX.js} +1 -1
- package/dist/assets/useDesktopWindowControlsLayout-DlwSomVK.js +1 -0
- package/dist/assets/{useEffectiveDirectory-BW9jNyuK.js → useEffectiveDirectory-eJorVTT9.js} +1 -1
- package/dist/assets/{useFontPreferences-Bjx8zkGM.js → useFontPreferences-Bjgt_lzl.js} +1 -1
- package/dist/assets/useMobileNavigationStore-A_ZNTfpl.js +415 -0
- package/dist/assets/useSessionAutoCleanup-CqC3dEou.js +2 -0
- package/dist/assets/{useUIStore-syVmbuDA.js → useUIStore-Dfx6TKvi.js} +1 -1
- package/dist/assets/{useWorkerHighlightedLines-BUcSLKlL.js → useWorkerHighlightedLines-B0vSL6jr.js} +1 -1
- package/dist/assets/vendor-opencode-client-MF2GBrFx.js +12 -0
- package/dist/assets/{vendor-zustand-B4dlGEM2.js → vendor-zustand-DzRqcymP.js} +1 -1
- package/dist/assets/{zh-CN-BhqSLgUY.js → zh-CN-DHEFf4u1.js} +4 -4
- package/dist/assets/{zh-TW-BsaBgY-p.js → zh-TW-rdSa8atW.js} +4 -4
- package/dist/index.html +13 -13
- package/dist/mini-chat.html +13 -13
- package/dist/mobile.html +13 -13
- package/package.json +3 -3
- package/server/index.js +8 -20
- package/server/lib/client-auth/remote-clients.js +15 -0
- package/server/lib/client-auth/remote-clients.test.js +42 -1
- package/server/lib/git/DOCUMENTATION.md +1 -0
- package/server/lib/git/routes.js +7 -4
- package/server/lib/git/routes.test.js +34 -0
- package/server/lib/git/service.js +3 -1
- package/server/lib/llm/DOCUMENTATION.md +6 -4
- package/server/lib/llm/generate.js +8 -9
- package/server/lib/llm/generate.test.js +33 -6
- package/server/lib/message-queue/service.js +1 -1
- package/server/lib/opencode/DOCUMENTATION.md +33 -22
- package/server/lib/opencode/agents.js +13 -22
- package/server/lib/opencode/auth-state-runtime.js +3 -3
- package/server/lib/opencode/auth-state-runtime.test.js +59 -0
- package/server/lib/opencode/auth.d.ts +13 -0
- package/server/lib/opencode/auth.js +74 -64
- package/server/lib/opencode/auth.test.js +57 -0
- package/server/lib/opencode/commands.js +1 -1
- package/server/lib/opencode/config-entities-layering.test.js +72 -0
- package/server/lib/opencode/config-entity-routes.js +10 -123
- package/server/lib/opencode/config-entity-routes.test.js +23 -11
- package/server/lib/opencode/config-files.d.ts +17 -0
- package/server/lib/opencode/config-files.js +187 -0
- package/server/lib/opencode/config-files.test.js +201 -0
- package/server/lib/opencode/core-routes.js +17 -1
- package/server/lib/opencode/core-routes.test.js +43 -15
- package/server/lib/opencode/credential-boundary.d.ts +1 -0
- package/server/lib/opencode/credential-boundary.js +11 -0
- package/server/lib/opencode/ensure-cli.js +4 -1
- package/server/lib/opencode/env-config.js +4 -1
- package/server/lib/opencode/env-config.test.js +28 -0
- package/server/lib/opencode/env-runtime.test.js +18 -1
- package/server/lib/opencode/feature-routes-runtime.js +9 -7
- package/server/lib/opencode/hmr-state-runtime.js +4 -4
- package/server/lib/opencode/lifecycle.js +1 -49
- package/server/lib/opencode/lifecycle.test.js +30 -4
- package/server/lib/opencode/location-release.d.ts +8 -0
- package/server/lib/opencode/location-release.js +32 -0
- package/server/lib/opencode/location-release.test.js +43 -0
- package/server/lib/opencode/mcp.js +1 -1
- package/server/lib/opencode/opencode2-pin.js +2 -1
- package/server/lib/opencode/owned-runtime-upgrade.test.js +5 -5
- package/server/lib/opencode/plugin-routes.test.js +4 -2
- package/server/lib/opencode/plugins.js +12 -60
- package/server/lib/opencode/plugins.test.js +5 -3
- package/server/lib/opencode/providers.js +6 -3
- package/server/lib/opencode/proxy.js +7 -0
- package/server/lib/opencode/proxy.test.js +13 -0
- package/server/lib/opencode/remote-upgrade.integration.test.js +66 -0
- package/server/lib/opencode/routes.js +10 -8
- package/server/lib/opencode/routes.test.js +51 -10
- package/server/lib/opencode/runtime-contract.js +3 -2
- package/server/lib/opencode/runtime-contract.test.js +12 -12
- package/server/lib/opencode/settings-normalization-runtime.js +3 -1
- package/server/lib/opencode/settings-normalization-runtime.test.js +36 -0
- package/server/lib/opencode/settings-runtime.test.js +58 -1
- package/server/lib/opencode/shared.js +6 -175
- package/server/lib/opencode/update-discovery.js +39 -0
- package/server/lib/opencode/update-discovery.test.js +39 -0
- package/server/lib/opencode/upgrade-screen.js +4 -11
- package/server/lib/opencode/upgrade-screen.test.js +25 -25
- package/server/lib/opencode/version-alignment.test.js +40 -0
- package/server/lib/question-auto-delegate/DOCUMENTATION.md +21 -6
- package/server/lib/question-auto-delegate/core.d.ts +5 -1
- package/server/lib/question-auto-delegate/core.js +21 -13
- package/server/lib/question-auto-delegate/form-io.d.ts +6 -0
- package/server/lib/question-auto-delegate/form-io.js +39 -0
- package/server/lib/question-auto-delegate/runtime.js +4 -24
- package/server/lib/question-auto-delegate/runtime.test.js +138 -0
- package/server/lib/quota/DOCUMENTATION.md +9 -0
- package/server/lib/quota/provider-credentials.test.js +29 -0
- package/server/lib/quota/providers/claude.js +4 -4
- package/server/lib/quota/providers/codex.js +4 -4
- package/server/lib/quota/providers/codex.test.js +1 -1
- package/server/lib/quota/providers/copilot.js +5 -5
- package/server/lib/quota/providers/google/auth.js +3 -3
- package/server/lib/quota/providers/google/index.js +2 -2
- package/server/lib/quota/providers/index.js +3 -7
- package/server/lib/quota/providers/index.test.js +2 -2
- package/server/lib/quota/providers/kimi.js +4 -4
- package/server/lib/quota/providers/minimax-shared.js +4 -4
- package/server/lib/quota/providers/nanogpt.js +4 -4
- package/server/lib/quota/providers/openai.js +4 -4
- package/server/lib/quota/providers/openrouter.js +4 -4
- package/server/lib/quota/providers/wafer.js +4 -4
- package/server/lib/quota/providers/zai.js +4 -4
- package/server/lib/quota/providers/zhipuai-coding-plan.js +6 -20
- package/server/lib/quota/routes.js +1 -1
- package/server/lib/relay/DOCUMENTATION.md +3 -1
- package/server/lib/relay/service.js +1 -0
- package/server/lib/relay/service.test.js +13 -0
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +8 -1
- package/server/lib/scheduled-tasks/runtime.js +12 -4
- package/server/lib/scheduled-tasks/runtime.test.js +81 -6
- package/server/lib/session-goal/DOCUMENTATION.md +11 -0
- package/server/lib/session-goal/runtime.js +4 -4
- package/server/lib/session-goal/runtime.test.js +32 -3
- package/server/lib/session-index/DOCUMENTATION.md +7 -0
- package/server/lib/session-index/event-ingest.js +13 -0
- package/server/lib/session-index/event-ingest.test.js +7 -0
- package/server/lib/session-index/service.js +45 -0
- package/server/lib/session-index/service.test.js +47 -0
- package/server/lib/session-metadata/DOCUMENTATION.md +6 -0
- package/server/lib/session-metadata/session-metadata-store.test.js +23 -0
- package/server/lib/session-metadata/session-projection.d.ts +1 -0
- package/server/lib/session-metadata/session-projection.js +23 -0
- package/server/lib/session-metadata/session-projection.test.js +35 -0
- package/server/lib/session-title/DOCUMENTATION.md +52 -14
- package/server/lib/session-title/native-runtime.test.js +59 -5
- package/server/lib/session-title/runtime.js +63 -17
- package/server/lib/session-title/session-access.js +108 -3
- package/server/lib/session-title/session-access.test.js +125 -7
- package/server/lib/tts/DOCUMENTATION.md +7 -5
- package/server/lib/tts/credential-source.test.js +23 -0
- package/server/lib/tts/routes.js +2 -2
- package/server/lib/tts/service.js +16 -37
- package/dist/assets/AssistantView-CLFPj5Ki.js +0 -3
- package/dist/assets/Icon-B8fSTLdP.js +0 -1
- package/dist/assets/MarkdownRenderer-BK69MEHQ.js +0 -2
- package/dist/assets/MobileSurface-D0HP_lTS.js +0 -2
- package/dist/assets/SettingsView-xLYb22wV.js +0 -25
- package/dist/assets/appThemeRegistry-LkVH62uF.js +0 -1
- package/dist/assets/desktopRelayRestore-CHEwrI93.js +0 -1
- package/dist/assets/dialog-CQ63sc9E.js +0 -1
- package/dist/assets/dropdown-menu.styles-Bzo6L3FH.js +0 -1
- package/dist/assets/fileMentionTouchSelection-CBzDuQxP.js +0 -3
- package/dist/assets/insertionBoundaries-DQrE5qG2.js +0 -1
- package/dist/assets/main-D2BzpnUt.css +0 -1
- package/dist/assets/main-DYISNvWY.js +0 -169
- package/dist/assets/miniChat-DYIqdWi7.js +0 -2
- package/dist/assets/mobile-CwiCcmWt.js +0 -2
- package/dist/assets/multirun-C3snjTFs.js +0 -4
- package/dist/assets/persistence-D0y7226-.js +0 -3
- package/dist/assets/pl-BCf5uLlK.js +0 -15
- package/dist/assets/platform-CurqO28D.js +0 -6
- package/dist/assets/projectMeta-BkhYFMaM.js +0 -3
- package/dist/assets/renderElectronMiniChatApp-7iyh_419.js +0 -2
- package/dist/assets/renderMobileApp-y0_NeckR.js +0 -28
- package/dist/assets/runtime-switch-LvWDU-SL.js +0 -1
- package/dist/assets/runtimeConfig-12C5j02f.js +0 -2
- package/dist/assets/runtimeEndpointReset-DTY2ZXXb.js +0 -149
- package/dist/assets/sessionChangeSummary-CwPBIb3Z.js +0 -2
- package/dist/assets/src-lS1keDVV.css +0 -2
- package/dist/assets/useDesktopWindowControlsLayout-CR_DcY77.js +0 -1
- package/dist/assets/useMobileNavigationStore-DwupvLSA.js +0 -414
- package/dist/assets/useSessionAutoCleanup-DkGO_usj.js +0 -2
- package/dist/assets/vendor-opencode-client-C12gfjag.js +0 -12
- package/server/lib/opencode/snippets.js +0 -242
- package/server/lib/opencode/snippets.test.js +0 -97
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/assistant-attachment-cache-DphJleHr.js","assets/rolldown-runtime-C0FnF6B9.js","assets/runtime-auth-D66yq6ie.js","assets/runtime-switch-LvWDU-SL.js","assets/runtime-fetch-Fs9ZV2V8.js","assets/relay-image-stream-DrdVj99c.js","assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js","assets/dualLimitLru-D8Sphgua.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{i as t,l as n}from"./runtime-switch-LvWDU-SL.js";import{n as r}from"./runtime-fetch-Fs9ZV2V8.js";import{Cn as i,Jt as a,Qt as o,Yt as s,d as c,tt as l,u}from"./persistence-D0y7226-.js";import{h as d}from"./desktopHosts-JGFqhlaM.js";import{i as f,n as p,r as m}from"./desktopRelayRestore-CHEwrI93.js";import{A as h,D as g,E as _,F as v,I as y,M as b,N as x,P as S,j as C,k as w,nt as ee,rt as T,tt as E}from"./vendor-base-ui-CnHfUmDN.js";import{Nt as D,Rn as O}from"./platform-CurqO28D.js";import{n as k}from"./useUIStore-syVmbuDA.js";import{n as A}from"./vendor-react-DLPElpoQ.js";import{o as j}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as te}from"./vendor-tanstack-query-core-BWz0ose6.js";import{i as ne,l as M,n as re,r as ie,s as ae}from"./vendor-tanstack-react-query-D7pys_c9.js";import{P as N,V as P,a as F,f as I,l as L}from"./vendor-codemirror-autocomplete-DHomsvW7.js";import{c as oe,o as R,r as se}from"./vendor-codemirror-lang-angular-DShkBD6m.js";import{n as z,r as ce}from"./vendor-codemirror-lang-json-CYJRHck9.js";import{n as B}from"./vendor-codemirror-lang-markdown-WORgx6ZD.js";import{n as le}from"./vendor-codemirror-lang-python-Du6XQ8Zw.js";import{O as ue}from"./vendor-codemirror-legacy-modes-DuRAjNvB.js";import{n as de}from"./vendor-reactuses-core-Dq5ocTF8.js";import{d as fe,f as pe,l as me,p as V,r as H,t as he}from"./button-DIIrsMjW.js";import{i as ge,t as _e}from"./store-jaP79mqI.js";import{$a as ve,Na as ye,Tr as be,d as xe,dr as Se,fa as Ce,ja as we,ma as U,vr as Te,xr as W,za as Ee}from"./useMobileNavigationStore-DwupvLSA.js";import{t as De}from"./AgentAvatar-CzTtVMnI.js";import{n as G}from"./Icon-B8fSTLdP.js";import{i as Oe,n as ke,r as Ae,t as je}from"./vendor-simplewebauthn-browser-Dwhcdg_5.js";import{C as Me,D as Ne,O as Pe,S as Fe,T as Ie,w as Le}from"./projectMeta-BkhYFMaM.js";import{t as Re}from"./input-BVu-iykl.js";import{t as ze}from"./useThemeSystem-DMzWVJaW.js";import{i as Be}from"./OverlayScrollbar-CRfGtcmG.js";import{_ as Ve,g as He,h as Ue,i as We,n as Ge,v as Ke}from"./textarea-XD2oX_Ee.js";import{n as qe,r as Je,t as Ye}from"./dropdown-menu.styles-Bzo6L3FH.js";import{t as Xe}from"./vendor-codemirror-language-data-BfYFhIH1.js";var K=A(),Ze=[`desktopHostSwitch`],Qe=class extends Error{result;host;constructor(e,t){super(e.reason),this.name=`DesktopHostSwitchError`,this.result=e,this.host=t}},$e=(e,t)=>_e(ge.getState().dictionary,e,t),et=async e=>{let{host:t}=e;if(t.id===`local`){let r=(e.localApiOrigin||``).trim();if(!r)throw new Qe({ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unreachable`},t);return n({apiBaseUrl:r,clientToken:e.localClientToken||null,runtimeKey:m(t)}),{ok:!0,via:`direct`,status:{status:`ok`,latencyMs:0}}}let r=await f(t,{cachedProbe:e.cachedProbe});if(!r.ok)throw new Qe(r,t);return r},tt=null,nt=()=>tt||(tt=new te(u,{mutationKey:Ze,mutationFn:et,onError:(e,t)=>{if(e instanceof Qe&&e.result.reason!==`unsupported`){if(e.result.status.status===`auth`){be.error($e(`desktopHostSwitcher.status.authRequired`));return}be.error($e(`desktopHostSwitcher.toast.instanceUnreachable`,{host:d(t.host.label)}))}}}),tt.subscribe(()=>void 0),tt),rt=async e=>{if(p(e.host))return{ok:!0,via:`direct`,status:e.cachedProbe?.status===`ok`?e.cachedProbe:{status:`ok`,latencyMs:0}};if(u.isMutating({mutationKey:Ze})>0)return{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unsupported`};try{return await nt().mutate(e)}catch(e){if(e instanceof Qe)return e.result;throw e}},it=()=>{let e=(0,K.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={mutationKey:Ze},e[0]=t):t=e[0],ie(t)>0},at=()=>{let e=(0,K.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={filters:{mutationKey:Ze,status:`pending`},select:ot},e[0]=t):t=e[0],ne(t)[0]?.host.id??null};function ot(e){return e.state.variables}var q=e=>typeof e==`object`&&!!e,J=(e,t)=>{let n=e[t];return typeof n==`string`?n:null},Y=(e,t)=>{let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:null},X=(e,t)=>{let n=e[t];return typeof n==`boolean`?n:null},st=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],ct=()=>a()?(e,t)=>s(e,t):null,lt=e=>{if(!q(e))return;let t=X(e,`enabled`)??!1,n=J(e,`store`)?.toLowerCase()===`settings`?`settings`:`never`,r=J(e,`value`);return{enabled:t,store:n,...r?{value:r}:{}}},ut=e=>e===`remote`||e===`dynamic`?e:`local`,dt=e=>{if(!q(e))return null;let t=J(e,`id`);if(!t)return null;let n=X(e,`enabled`)??!0,r=ut(J(e,`type`)),i=J(e,`localHost`)||J(e,`local_host`)||void 0,a=Y(e,`localPort`)??Y(e,`local_port`)??void 0,o=J(e,`remoteHost`)||J(e,`remote_host`)||void 0,s=Y(e,`remotePort`)??Y(e,`remote_port`)??void 0;return{id:t,enabled:n,type:r,...i?{localHost:i}:{},...typeof a==`number`?{localPort:a}:{},...o?{remoteHost:o}:{},...typeof s==`number`?{remotePort:s}:{}}},ft=e=>{if(!q(e))return null;let t=J(e,`id`),n=J(e,`sshCommand`)||J(e,`ssh_command`);if(!t||!n)return null;let r=J(e,`nickname`),i=e.sshParsed,a=q(i)?{destination:J(i,`destination`)||``,args:st(i.args)}:void 0,o=q(e.remoteOpenchamber)?e.remoteOpenchamber:q(e.remote_openchamber)?e.remote_openchamber:{},s=q(e.localForward)?e.localForward:q(e.local_forward)?e.local_forward:{},c=q(e.auth)?e.auth:{},l=J(o,`mode`)?.toLowerCase()===`external`?`external`:`managed`,u=J(o,`installMethod`)||J(o,`install_method`),d=u===`npm`||u===`download_release`||u===`upload_bundle`?u:`bun`,f=J(s,`bindHost`)||J(s,`bind_host`)||`127.0.0.1`,p=f===`localhost`||f===`0.0.0.0`?f:`127.0.0.1`,m=(Array.isArray(e.portForwards)?e.portForwards:Array.isArray(e.port_forwards)?e.port_forwards:[]).map(e=>dt(e)).filter(e=>!!e),h=Y(o,`preferredPort`)??Y(o,`preferred_port`),g=Y(s,`preferredLocalPort`)??Y(s,`preferred_local_port`),_=lt(c.sshPassword||c.ssh_password),v=lt(c.openchamberPassword||c.openchamber_password);return{id:t,...r?{nickname:r}:{},sshCommand:n,...a&&a.destination?{sshParsed:a}:{},connectionTimeoutSec:Y(e,`connectionTimeoutSec`)??Y(e,`connection_timeout_sec`)??60,remoteOpenchamber:{mode:l,keepRunning:X(o,`keepRunning`)??X(o,`keep_running`)??!0,relayHost:X(o,`relayHost`)??X(o,`relay_host`)??!0,...h?{preferredPort:h}:{},installMethod:d,uploadBundleOverSsh:X(o,`uploadBundleOverSsh`)??X(o,`upload_bundle_over_ssh`)??!1},localForward:{...g?{preferredLocalPort:g}:{},bindHost:p},auth:{..._?{sshPassword:_}:{},...v?{openchamberPassword:v}:{}},portForwards:m}},pt=e=>{switch(e){case`config_resolved`:case`auth_check`:case`master_connecting`:case`remote_probe`:case`installing`:case`updating`:case`server_detecting`:case`server_starting`:case`forwarding`:case`ready`:case`degraded`:case`error`:return e;default:return`idle`}},mt=e=>{if(!q(e))return null;let t=J(e,`id`);return t?{id:t,phase:pt(J(e,`phase`)),...J(e,`detail`)?{detail:J(e,`detail`)||void 0}:{},...J(e,`localUrl`)||J(e,`local_url`)?{localUrl:J(e,`localUrl`)||J(e,`local_url`)||void 0}:{},...typeof(Y(e,`localPort`)??Y(e,`local_port`))==`number`?{localPort:Y(e,`localPort`)??Y(e,`local_port`)??void 0}:{},...typeof(Y(e,`remotePort`)??Y(e,`remote_port`))==`number`?{remotePort:Y(e,`remotePort`)??Y(e,`remote_port`)??void 0}:{},startedByUs:X(e,`startedByUs`)??X(e,`started_by_us`)??!1,retryAttempt:Y(e,`retryAttempt`)??Y(e,`retry_attempt`)??0,requiresUserAction:X(e,`requiresUserAction`)??X(e,`requires_user_action`)??!1,...J(e,`errorCode`)||J(e,`error_code`)?{errorCode:J(e,`errorCode`)||J(e,`error_code`)||void 0}:{},updatedAtMs:Y(e,`updatedAtMs`)??Y(e,`updated_at_ms`)??Date.now()}:null},ht=e=>{if(!q(e))return null;let t=J(e,`host`),n=J(e,`source`),r=J(e,`sshCommand`)||J(e,`ssh_command`);return!t||!n||!r?null:{host:t,source:n,sshCommand:r,pattern:X(e,`pattern`)??!1}},gt=(e,t)=>({id:e,sshCommand:t,connectionTimeoutSec:60,remoteOpenchamber:{mode:`managed`,keepRunning:!0,relayHost:!0,installMethod:`bun`,uploadBundleOverSsh:!1},localForward:{bindHost:`127.0.0.1`},auth:{},portForwards:[]}),_t=async()=>{let e=ct();if(!e)return{instances:[]};let t=await e(`desktop_ssh_instances_get`);return q(t)?{instances:(Array.isArray(t.instances)?t.instances:Array.isArray(t.desktopSshInstances)?t.desktopSshInstances:[]).map(e=>ft(e)).filter(e=>!!e)}:{instances:[]}},vt=async e=>{let t=ct();t&&await t(`desktop_ssh_instances_set`,{config:{instances:e.instances}})},yt=async()=>{let e=ct();if(!e)return[];let t=await e(`desktop_ssh_import_hosts`);return Array.isArray(t)?t.map(e=>ht(e)).filter(e=>!!e):[]},bt=async e=>{let t=ct();t&&await t(`desktop_ssh_connect`,{id:e})},xt=async e=>{let t=ct();t&&await t(`desktop_ssh_disconnect`,{id:e})},St=async e=>{let t=ct();if(!t)return[];let n=await t(`desktop_ssh_status`,{...e?{id:e}:{}});return Array.isArray(n)?n.map(e=>mt(e)).filter(e=>!!e):[]},Ct=async(e,t)=>{let n=ct();if(!n)return[];let r=await n(`desktop_ssh_logs`,{id:e,...typeof t==`number`?{limit:t}:{}});return Array.isArray(r)?r.filter(e=>typeof e==`string`):[]},wt=async e=>{let t=ct();t&&await t(`desktop_ssh_logs_clear`,{id:e})},Tt=(e,t)=>{let n=Math.max(0,Math.trunc(Number(e.fileGroups)||0)),r=Math.max(0,Math.trunc(Number(e.singleFiles)||0)),i=Math.max(0,Math.trunc(Number(e.directories)||0));return{fileGroups:Array.from({length:n},()=>!0),singleFiles:Array.from({length:r},()=>!0),directories:Array.from({length:i},()=>!0),agentsRoot:!0,authFile:t?.includeAuthFile===!0}},Et=e=>{if(!q(e))return null;let t=J(e,`path`),n=Y(e,`bytes`);return!t||n===null?null:{path:t,bytes:n}},Dt=e=>{if(!q(e))return null;let t=J(e,`path`),n=Y(e,`fileCount`)??Y(e,`file_count`),r=Y(e,`bytes`);return!t||n===null||r===null?null:{path:t,fileCount:n,bytes:r}},Ot=e=>{if(e==null||!q(e))return null;let t=Y(e,`fileCount`)??Y(e,`file_count`),n=Y(e,`bytes`);return t===null||n===null?null:{fileCount:t,bytes:n}},kt=e=>{if(e==null||!q(e))return null;let t=Y(e,`bytes`);return t===null?null:{bytes:t}},At=e=>{if(!q(e))return null;let t=Array.isArray(e.files)?e.files:null,n=Array.isArray(e.directories)?e.directories:null,r=st(e.deletes),i=Y(e,`totalBytes`)??Y(e,`total_bytes`);if(!t||!n||i===null||!(`agentsRoot`in e)&&!(`agents_root`in e))return null;let a=t.map(e=>Et(e)).filter(e=>!!e),o=n.map(e=>Dt(e)).filter(e=>!!e);if(a.length!==t.length||o.length!==n.length)return null;let s=e.agentsRoot??e.agents_root,c=s==null?null:Ot(s);if(s!=null&&c===null)return null;let l=e.authFile??e.auth_file,u=l==null?null:kt(l),d=e.direction===`pull`||e.direction===`push`?e.direction:void 0,f=e.selections,p=q(f)?{fileGroups:Array.isArray(f.fileGroups)?f.fileGroups.map(e=>e!==!1):[],singleFiles:Array.isArray(f.singleFiles)?f.singleFiles.map(e=>e!==!1):[],directories:Array.isArray(f.directories)?f.directories.map(e=>e!==!1):[],agentsRoot:f.agentsRoot!==!1,authFile:f.authFile===!0}:void 0,m=jt(e.selectionShape??e.selection_shape);return{files:a,directories:o,agentsRoot:c,authFile:u,deletes:r,totalBytes:i,...d?{direction:d}:{},...p?{selections:p}:{},...m?{selectionShape:m}:{}}},jt=e=>{if(!q(e))return null;let t=Y(e,`fileGroups`)??Y(e,`file_groups`),n=Y(e,`singleFiles`)??Y(e,`single_files`),r=Y(e,`directories`);return t===null||n===null||r===null||t<0||n<0||r<0?null:{fileGroups:t,singleFiles:n,directories:r}},Mt=e=>{if(!q(e))return null;let t=At(e.plan);if(!t)return null;let n=jt(e.selectionShape??e.selection_shape)??t.selectionShape??null;return{plan:t,remoteExisting:st(e.remoteExisting??e.remote_existing),remoteAgentsRootExists:X(e,`remoteAgentsRootExists`)??X(e,`remote_agents_root_exists`)??!1,remoteAuthFileExists:X(e,`remoteAuthFileExists`)??X(e,`remote_auth_file_exists`)??!1,...n?{selectionShape:n}:{}}},Nt=e=>{if(!q(e)||X(e,`ok`)!==!0)return null;let t=Y(e,`files`),n=Y(e,`directories`),r=Y(e,`deletes`),i=Y(e,`totalBytes`)??Y(e,`total_bytes`);if(t===null||n===null||r===null||i===null||!(`agentsRoot`in e)&&!(`agents_root`in e))return null;let a=e.agentsRoot??e.agents_root,o=null;if(a!=null){if(!q(a))return null;let e=Y(a,`fileCount`)??Y(a,`file_count`);if(e===null)return null;o={fileCount:e}}let s=e.authFile??e.auth_file,c=s==null?null:kt(s);return{ok:!0,files:t,directories:n,deletes:r,totalBytes:i,agentsRoot:o,authFile:c}},Pt=async(e={})=>{let t=ct();if(!t)return console.error(`[desktopSsh] config sync local scan skipped: desktop IPC bridge is unavailable in this window`),null;let n=await t(`desktop_ssh_sync_opencode_config`,{stage:`local`,...e.direction?{direction:e.direction}:{},...e.selections?{selections:e.selections}:{}});if(!q(n))return console.error(`[desktopSsh] config sync local scan returned a non-object payload`,n),null;let r=At(n.plan);if(!r)return console.error(`[desktopSsh] config sync local scan plan payload was not recognized`,n),null;let i=jt(n.selectionShape??n.selection_shape)??r.selectionShape??null;return i?{...r,selectionShape:i}:r},Ft=async(e,t={})=>{let n=ct();if(!n)return console.error(`[desktopSsh] config sync preview skipped: desktop IPC bridge is unavailable in this window`),null;let r=await n(`desktop_ssh_sync_opencode_config`,{id:e,...t.targetKind?{targetKind:t.targetKind}:{},...t.direction?{direction:t.direction}:{},...t.selections?{selections:t.selections}:{}}),i=Mt(r);return i||console.error(`[desktopSsh] config sync preview payload was not recognized`,r),i},It=async(e,t={})=>{let n=ct();if(!n)return console.error(`[desktopSsh] config sync apply skipped: desktop IPC bridge is unavailable in this window`),null;let r=await n(`desktop_ssh_sync_opencode_config`,{id:e,apply:!0,...t.targetKind?{targetKind:t.targetKind}:{},...t.direction?{direction:t.direction}:{},...t.selections?{selections:t.selections}:{}}),i=Nt(r);return i||console.error(`[desktopSsh] config sync apply payload was not recognized`,r),i},Lt=async(e,t={})=>{let n=ct();if(!n)return[];let r=await n(`desktop_ssh_sync_runs_list`,{id:e,...t.targetKind?{targetKind:t.targetKind}:{}});return Array.isArray(r)?r.filter(e=>q(e)&&typeof e.syncRunId==`string`&&typeof e.targetId==`string`):[]},Rt=async e=>{if(!a())return async()=>{};let t=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof t!=`function`)return async()=>{};let n=await t(`openchamber:ssh-instance-status`,t=>{let n=mt(t?.payload);n&&e(n)});return async()=>{await n()}},zt=new Set([`nodeRuntimeMissing`,`packageManagerMissing`,`nativeBinding`,`openchamberCliMissing`,`openchamberRegistry`,`openchamberInstall`,`openchamberCliIncompatible`,`opencodeInstall`,`serverStart`,`sshAuth`,`sshUnreachable`,`timeout`,`unknown`]),Bt=e=>typeof e==`string`&&zt.has(e),Vt=e=>{let t=String(e||``);return/requires Node\.js \d+|no supported Node runtime/i.test(t)?`nodeRuntimeMissing`:/neither bun nor npm/i.test(t)?`packageManagerMissing`:/better-sqlite3|node_gyp_bins|gyp ERR|failed to prepare better-sqlite3/i.test(t)?`nativeBinding`:/OpenChamber installation completed but the executable is unavailable/i.test(t)?`openchamberCliMissing`:/could not reach the npm registry|ENOTFOUND|ECONNREFUSED|ETIMEDOUT|EAI_AGAIN|CERT_HAS_EXPIRED|UNABLE_TO_GET_ISSUER_CERT|self-signed certificate|registry\.npmjs|npm error code E404|npm ERR! code E404|getaddrinfo/i.test(t)?`openchamberRegistry`:/Failed to install OpenChamber/i.test(t)?`openchamberInstall`:/Unknown option:\s*--relay-host|does not advertise --relay-host|does not support --relay-host/i.test(t)||/Unknown option:/i.test(t)?`openchamberCliIncompatible`:/Failed to install OpenCode|OpenCode CLI/i.test(t)?`opencodeInstall`:/failed to become reachable|Managed OpenChamber server failed/i.test(t)?`serverStart`:/Permission denied|Authentication failed|publickey|keyboard-interactive/i.test(t)?`sshAuth`:/Could not resolve hostname|Connection refused|Connection timed out|ControlMaster connection timed out|SSH master process exited|Network is unreachable/i.test(t)?`sshUnreachable`:/Timed out waiting for SSH|Timed out waiting for forwarded/i.test(t)?`timeout`:`unknown`},Ht=(e,t)=>Bt(e)?e:Vt(t),Ut=e=>{switch(e){case`nodeRuntimeMissing`:return`desktopHostSwitcher.sshError.nodeRuntimeMissing.title`;case`packageManagerMissing`:return`desktopHostSwitcher.sshError.packageManagerMissing.title`;case`nativeBinding`:return`desktopHostSwitcher.sshError.nativeBinding.title`;case`openchamberCliMissing`:return`desktopHostSwitcher.sshError.openchamberCliMissing.title`;case`openchamberRegistry`:return`desktopHostSwitcher.sshError.openchamberRegistry.title`;case`openchamberInstall`:return`desktopHostSwitcher.sshError.openchamberInstall.title`;case`openchamberCliIncompatible`:return`desktopHostSwitcher.sshError.openchamberCliIncompatible.title`;case`opencodeInstall`:return`desktopHostSwitcher.sshError.opencodeInstall.title`;case`serverStart`:return`desktopHostSwitcher.sshError.serverStart.title`;case`sshAuth`:return`desktopHostSwitcher.sshError.sshAuth.title`;case`sshUnreachable`:return`desktopHostSwitcher.sshError.sshUnreachable.title`;case`timeout`:return`desktopHostSwitcher.sshError.timeout.title`;default:return`desktopHostSwitcher.sshError.unknown.title`}},Wt=e=>{switch(e){case`nodeRuntimeMissing`:return`desktopHostSwitcher.sshError.nodeRuntimeMissing.guidance`;case`packageManagerMissing`:return`desktopHostSwitcher.sshError.packageManagerMissing.guidance`;case`nativeBinding`:return`desktopHostSwitcher.sshError.nativeBinding.guidance`;case`openchamberCliMissing`:return`desktopHostSwitcher.sshError.openchamberCliMissing.guidance`;case`openchamberRegistry`:return`desktopHostSwitcher.sshError.openchamberRegistry.guidance`;case`openchamberInstall`:return`desktopHostSwitcher.sshError.openchamberInstall.guidance`;case`openchamberCliIncompatible`:return`desktopHostSwitcher.sshError.openchamberCliIncompatible.guidance`;case`opencodeInstall`:return`desktopHostSwitcher.sshError.opencodeInstall.guidance`;case`serverStart`:return`desktopHostSwitcher.sshError.serverStart.guidance`;case`sshAuth`:return`desktopHostSwitcher.sshError.sshAuth.guidance`;case`sshUnreachable`:return`desktopHostSwitcher.sshError.sshUnreachable.guidance`;case`timeout`:return`desktopHostSwitcher.sshError.timeout.guidance`;default:return`desktopHostSwitcher.sshError.unknown.guidance`}},Gt=e=>e===`unknown`||e===`openchamberCliIncompatible`,Kt=(e,t,n)=>{let r=typeof n==`string`?n.trim():``;return!Gt(t)||!r||r===e?e:`${e}\n${r}`},Z=ee();function qt(e){let t=(0,K.c)(27),{errorCode:n,detail:r,className:i}=e,{t:a}=pe(),o,s,c,l,u,d;if(t[0]!==i||t[1]!==r||t[2]!==n||t[3]!==a){let e=Ht(n,r);o=a(Wt(e));let f;t[10]===r?f=t[11]:(f=typeof r==`string`?r.trim():``,t[10]=r,t[11]=f),s=f,c=Gt(e)&&!!s&&s!==o,t[12]===i?d=t[13]:(d=H(`space-y-1`,i),t[12]=i,t[13]=d),l=`typography-ui-label text-[var(--status-error)]`,u=a(Ut(e)),t[0]=i,t[1]=r,t[2]=n,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d}else o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9];let f;t[14]!==l||t[15]!==u?(f=(0,Z.jsx)(`p`,{className:l,children:u}),t[14]=l,t[15]=u,t[16]=f):f=t[16];let p;t[17]===o?p=t[18]:(p=(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:o}),t[17]=o,t[18]=p);let m;t[19]!==s||t[20]!==c?(m=c?(0,Z.jsx)(`p`,{className:`typography-meta break-words text-muted-foreground`,children:s}):null,t[19]=s,t[20]=c,t[21]=m):m=t[21];let h;return t[22]!==d||t[23]!==f||t[24]!==p||t[25]!==m?(h=(0,Z.jsxs)(`div`,{className:d,children:[f,p,m]}),t[22]=d,t[23]=f,t[24]=p,t[25]=m,t[26]=h):h=t[26],h}var Q=e(T(),1),Jt=[.2,.45,.15,.55,.35,.1,.5,.25,.4,.3,.45,.15,.55,.2,.35,.1],Yt=[.3,.15,.45,.25,.5,.35,.1,.4,.2,.55,.3,.15,.45,.25,.4,.2],Xt=(e,t,n,r,i=4)=>{let a=[];for(let o=0;o<i;o++)for(let s=0;s<i;s++){let c=s/i,l=(s+1)/i,u=o/i,d=(o+1)/i,f=(e,t,n)=>e+(t-e)*n,p=(e,t,n,r,i,a)=>{let o=f(e,t,i),s=f(r,n,i);return f(o,s,a)},m={x:p(e.x,t.x,n.x,r.x,c,u),y:p(e.y,t.y,n.y,r.y,c,u)},h={x:p(e.x,t.x,n.x,r.x,l,u),y:p(e.y,t.y,n.y,r.y,l,u)},g={x:p(e.x,t.x,n.x,r.x,l,d),y:p(e.y,t.y,n.y,r.y,l,d)},_={x:p(e.x,t.x,n.x,r.x,c,d),y:p(e.y,t.y,n.y,r.y,c,d)};a.push({path:`M${m.x} ${m.y} L${h.x} ${h.y} L${g.x} ${g.y} L${_.x} ${_.y} Z`,row:o,col:s})}return a},Zt=({className:e=``,width:t=70,height:n=70,isAnimated:r=!1})=>{let{t:i}=pe(),a=ze(),o=!0;a?o=a.currentTheme.metadata.variant!==`light`:typeof window<`u`&&(o=window.matchMedia(`(prefers-color-scheme: dark)`).matches);let s=(0,Q.useMemo)(()=>{if(a)return a.currentTheme.colors.surface.foreground;if(typeof window<`u`){let e=getComputedStyle(document.documentElement).getPropertyValue(`--splash-stroke`).trim();if(e)return e}return o?`white`:`black`},[a,o]),c=(0,Q.useMemo)(()=>typeof window>`u`||typeof CSS>`u`||typeof CSS.supports!=`function`?!1:CSS.supports(`color`,`color-mix(in srgb, white 50%, transparent)`),[]),l=(0,Q.useMemo)(()=>{if(a)return c?`color-mix(in srgb, ${s} 15%, transparent)`:o?`rgba(255,255,255,0.15)`:`rgba(0,0,0,0.15)`;if(typeof window<`u`){let e=getComputedStyle(document.documentElement).getPropertyValue(`--splash-face-fill`).trim();if(e)return e}return o?`rgba(255,255,255,0.15)`:`rgba(0,0,0,0.15)`},[a,c,s,o]),u=(0,Q.useMemo)(()=>{if(a)return c?`color-mix(in srgb, ${s} 35%, transparent)`:o?`rgba(255,255,255,0.35)`:`rgba(0,0,0,0.4)`;if(typeof window<`u`){let e=getComputedStyle(document.documentElement).getPropertyValue(`--splash-cell-fill`).trim();if(e)return e}return o?`rgba(255,255,255,0.35)`:`rgba(0,0,0,0.4)`},[a,c,s,o]),d=s,f=.866,p=.5,m={x:50,y:2},h={x:50-48*f,y:50-48*p},g={x:91.568,y:50-48*p},_={x:50,y:50},v={x:50-48*f,y:74},y={x:91.568,y:74},b={x:50,y:98},x=`matrix(0.866, 0.5, -0.866, 0.5, 50, ${(m.y+h.y+_.y+g.y)/4})`,S=Xt(h,_,b,v),C=Xt(_,g,y,b);return(0,Z.jsxs)(`svg`,{width:t,height:n,viewBox:`0 0 100 100`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,className:e,role:`img`,"aria-label":i(`openChamberLogo.aria.logo`),children:[r?(0,Z.jsx)(`style`,{children:`@keyframes oc-logo-glow{0%,100%{filter:drop-shadow(0 0 0 transparent)}50%{filter:drop-shadow(0 0 4px var(--oc-glow-color))}}.oc-logo-glow{animation:oc-logo-glow 1.8s ease-in-out infinite}@media (prefers-reduced-motion:reduce){.oc-logo-glow{animation:none}}`}):null,(0,Z.jsx)(`path`,{d:`M${_.x} ${_.y} L${h.x} ${h.y} L${v.x} ${v.y} L${b.x} ${b.y} Z`,fill:l,stroke:s,strokeWidth:`2`,strokeLinejoin:`round`}),S.map((e,t)=>(0,Z.jsx)(`path`,{d:e.path,fill:u,opacity:Jt[e.row*4+(3-e.col)]??.35},`left-${t}`)),(0,Z.jsx)(`path`,{d:`M${_.x} ${_.y} L${g.x} ${g.y} L${y.x} ${y.y} L${b.x} ${b.y} Z`,fill:l,stroke:s,strokeWidth:`2`,strokeLinejoin:`round`}),C.map((e,t)=>(0,Z.jsx)(`path`,{d:e.path,fill:u,opacity:Yt[e.row*4+e.col]??.35},`right-${t}`)),(0,Z.jsx)(`path`,{d:`M${m.x} ${m.y} L${h.x} ${h.y} L${_.x} ${_.y} L${g.x} ${g.y} Z`,fill:`none`,stroke:s,strokeWidth:`2`,strokeLinejoin:`round`}),(0,Z.jsx)(`g`,{opacity:1,className:r?`oc-logo-glow`:void 0,style:r?{"--oc-glow-color":s}:void 0,children:(0,Z.jsxs)(`g`,{transform:`${x} scale(0.75)`,children:[(0,Z.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M-16 -20 L16 -20 L16 20 L-16 20 Z M-8 -12 L-8 12 L8 12 L8 -12 Z`,fill:d}),(0,Z.jsx)(`path`,{d:`M-8 -4 L8 -4 L8 12 L-8 12 Z`,fill:d,fillOpacity:`0.4`})]})})]})},Qt=`/auth/passkey/authenticate/options`,$t=`/auth/passkey/authenticate/verify`,en=`/auth/passkey/register/options`,tn=`/auth/passkey/register/verify`,nn=`/api/passkeys`,rn=`/auth/passkey/status`,an=`/api/auth/reset`,on={enabled:!1,hasPasskeys:!1,passkeyCount:0,rpID:null},sn=async(e,t)=>r(e,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:t===void 0?void 0:JSON.stringify(t)}),cn=async(e,t)=>{try{let t=await e.json();if(t&&typeof t.error==`string`&&t.error.trim())return t.error}catch{}return t},ln=e=>e instanceof Oe&&e.code===`ERROR_CEREMONY_ABORTED`,un=()=>{Ae.cancelCeremony()},dn=()=>typeof window>`u`?{supported:!1,reason:`Passkeys are unavailable outside the browser.`}:window.isSecureContext?{supported:!0,reason:``}:{supported:!1,reason:`Passkeys require HTTPS or localhost.`},fn=async()=>{let e=dn();if(!e.supported)throw Error(e.reason);let t=await sn(en,{label:typeof navigator.userAgent==`string`&&navigator.userAgent.trim()?navigator.userAgent:`This device`});if(!t.ok)throw Error(await cn(t,`Could not start passkey setup.`));let{requestId:n,optionsJSON:r}=await t.json(),i=await sn(tn,{requestId:n,response:await ke({optionsJSON:r})});if(!i.ok)throw Error(await cn(i,`Could not finish passkey setup.`));return i.json().catch(()=>null)},pn=async(e,t={})=>{let n=dn();if(!n.supported)throw Error(n.reason);let r=await sn(Qt);if(!r.ok)throw Error(await cn(r,`Passkey sign-in is not available right now.`));let{requestId:i,optionsJSON:a}=await r.json(),o=await sn($t,{requestId:i,response:await je({optionsJSON:a}),trustDevice:e,issueClientToken:t.issueClientToken===!0,clientLabel:t.clientLabel,clientKind:t.clientKind,dedupeKey:t.dedupeKey});if(!o.ok)throw Error(await cn(o,`Passkey sign-in failed.`));return o.json().catch(()=>null)},mn=async()=>{let e=await r(rn,{method:`GET`,credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return on;let t=await e.json().catch(()=>null);return{enabled:t?.enabled===!0,hasPasskeys:t?.hasPasskeys===!0,passkeyCount:typeof t?.passkeyCount==`number`?t.passkeyCount:0,rpID:typeof t?.rpID==`string`&&t.rpID?t.rpID:null}},hn=async()=>{let e=await r(nn,{method:`GET`,credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(await cn(e,`Could not load passkeys.`));let t=await e.json().catch(()=>null);return Array.isArray(t?.passkeys)?t.passkeys:[]},gn=async e=>{let t=await r(`${nn}/${encodeURIComponent(e)}`,{method:`DELETE`,credentials:`include`,headers:{Accept:`application/json`}});if(!t.ok)throw Error(await cn(t,`Could not remove passkey.`));return t.json().catch(()=>null)},_n=async()=>{let e=await sn(an);if(!e.ok)throw Error(await cn(e,`Could not clear saved authentication.`));try{let{clearAssistantAttachmentCacheAll:e}=await j(async()=>{let{clearAssistantAttachmentCacheAll:e}=await import(`./assistant-attachment-cache-DphJleHr.js`).then(e=>e.t);return{clearAssistantAttachmentCacheAll:e}},__vite__mapDeps([0,1,2,3,4,5,6,7])),{invalidateRuntimeAuthSession:t}=await j(async()=>{let{invalidateRuntimeAuthSession:e}=await import(`./runtime-auth-D66yq6ie.js`).then(e=>e.m);return{invalidateRuntimeAuthSession:e}},__vite__mapDeps([2,1]));await e(`auth-reset`),t()}catch{}return e.json().catch(()=>null)};function vn(e){let t=(0,K.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=H(`bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`card`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function yn(e){let t=(0,K.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=H(`@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`card-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function bn(e){let t=(0,K.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=H(`leading-none font-semibold`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`card-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function xn(e){let t=(0,K.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=H(`px-6`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(`div`,{"data-slot":`card-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var Sn=class extends Q.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){this.setState({error:e,errorInfo:t,copied:!1}),console.error(`Error caught by boundary:`,e,t)}handleReset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})};handleCopy=async()=>{let{strings:e}=this.props,t=`${this.state.error?String(this.state.error):e.unknownError}${this.state.error?.stack?`\n\nStack:\n${this.state.error.stack}`:``}${this.state.errorInfo?.componentStack?`\n\n${e.componentStackLabel}${this.state.errorInfo.componentStack}`:``}`;(await fe(t)).ok&&(this.setState({copied:!0}),window.setTimeout(()=>{this.setState(e=>e.copied?{copied:!1}:null)},1500))};render(){let{strings:e}=this.props;return this.state.hasError?this.props.fallback?this.props.fallback:(0,Z.jsx)(`div`,{className:`p-4 flex items-center justify-center min-h-screen`,children:(0,Z.jsxs)(vn,{className:`w-full max-w-md`,children:[(0,Z.jsx)(yn,{className:`text-center`,children:(0,Z.jsxs)(bn,{className:`flex items-center justify-center gap-2 text-destructive`,children:[(0,Z.jsx)(G,{name:`error-warning`,className:`h-5 w-5`}),e.title]})}),(0,Z.jsxs)(xn,{className:`space-y-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground text-center`,children:e.description}),this.state.error&&(0,Z.jsxs)(`details`,{className:`text-xs font-mono bg-muted p-3 rounded`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer hover:bg-interactive-hover/80`,children:e.detailsSummary}),(0,Z.jsxs)(`pre`,{className:`mt-2 max-h-48 overflow-auto`,children:[this.state.error.toString(),this.state.errorInfo?.componentStack?`\n\n${e.componentStackLabel}${this.state.errorInfo.componentStack}`:``]})]}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsxs)(he,{onClick:this.handleReset,variant:`outline`,className:`flex-1`,children:[(0,Z.jsx)(G,{name:`restart`,className:`h-4 w-4 mr-2`}),e.tryAgain]}),(0,Z.jsx)(he,{onClick:this.handleCopy,variant:`outline`,className:`flex-1`,children:this.state.copied?e.copied:e.copy})]})]})]})}):this.props.children}},Cn=e=>{let t=(0,K.c)(29),{children:n,fallback:r}=e,{t:i}=pe(),a;t[0]===i?a=t[1]:(a=i(`errorBoundary.state.unknownError`),t[0]=i,t[1]=a);let o;t[2]===i?o=t[3]:(o=i(`errorBoundary.title`),t[2]=i,t[3]=o);let s;t[4]===i?s=t[5]:(s=i(`errorBoundary.description`),t[4]=i,t[5]=s);let c;t[6]===i?c=t[7]:(c=i(`errorBoundary.actions.errorDetails`),t[6]=i,t[7]=c);let l;t[8]===i?l=t[9]:(l=i(`errorBoundary.state.componentStackLabel`),t[8]=i,t[9]=l);let u;t[10]===i?u=t[11]:(u=i(`errorBoundary.actions.tryAgain`),t[10]=i,t[11]=u);let d;t[12]===i?d=t[13]:(d=i(`errorBoundary.actions.copied`),t[12]=i,t[13]=d);let f;t[14]===i?f=t[15]:(f=i(`errorBoundary.actions.copy`),t[14]=i,t[15]=f);let p;t[16]!==a||t[17]!==o||t[18]!==s||t[19]!==c||t[20]!==l||t[21]!==u||t[22]!==d||t[23]!==f?(p={unknownError:a,title:o,description:s,detailsSummary:c,componentStackLabel:l,tryAgain:u,copied:d,copy:f},t[16]=a,t[17]=o,t[18]=s,t[19]=c,t[20]=l,t[21]=u,t[22]=d,t[23]=f,t[24]=p):p=t[24];let m=p,h;return t[25]!==n||t[26]!==r||t[27]!==m?(h=(0,Z.jsx)(Sn,{fallback:r,strings:m,children:n}),t[25]=n,t[26]=r,t[27]=m,t[28]=h):h=t[28],h},wn=`__unassigned__`,Tn={mod:`mod`,shift:`shift`,alt:`alt`,option:`alt`,ctrl:`ctrl`,meta:`mod`,cmd:`mod`,command:`mod`},En={mod:me()?`⌘`:`Ctrl`,shift:`⇧`,alt:`⌥`,option:`⌥`,ctrl:`⌃`},Dn={comma:`,`,period:`.`,enter:`Enter`,escape:`Esc`,tab:`Tab`,space:`Space`,backspace:`⌫`,delete:`⌦`,arrowup:`↑`,arrowdown:`↓`,arrowleft:`←`,arrowright:`→`,home:`Home`,end:`End`,pageup:`Page Up`,pagedown:`Page Down`,backtick:"`",grave:"`","=":`=`,equal:`=`,plus:`+`,minus:`-`,"-":`-`},On=[`mod`,`ctrl`,`shift`,`alt`],kn={"{":`[`,"}":`]`,":":`;`,'"':`'`,"<":`,`,">":`.`,"?":`/`,"|":`\\`,"~":"`","!":`1`,"@":`2`,"#":`3`,$:`4`,"%":`5`,"^":`6`,"&":`7`,"*":`8`,"(":`9`,")":`0`};function An(e){return e.trim().toLowerCase()===wn}function jn(e){let t=e.toLowerCase();return t===`,`?`comma`:t===`.`?`period`:t===` `?`space`:t===`esc`?`escape`:t===`+`?`plus`:t===`-`||t===`_`?`minus`:t===`arrowup`?`arrowup`:t===`arrowdown`?`arrowdown`:t===`arrowleft`?`arrowleft`:t===`arrowright`?`arrowright`:t==="`"?`backtick`:kn[t]??t}var Mn=[{id:`open_go_to_line`,defaultCombo:`alt+g`,label:`Go to line (files editor)`,description:`Open go to line in the files editor`,customizable:!0},{id:`open_command_palette`,defaultCombo:`mod+p`,label:`Open command palette`,description:`Open the command palette`,customizable:!0},{id:`focus_input`,defaultCombo:`mod+i`,label:`Focus input`,description:`Focus the chat input field`,customizable:!0},{id:`open_status`,defaultCombo:`mod+shift+o`,label:`Open OpenCode status`,description:`Open the OpenCode status dialog`},{id:`open_settings`,defaultCombo:`mod+comma`,label:`Open settings`,description:`Open the settings panel`,customizable:!0},{id:`toggle_terminal`,defaultCombo:`ctrl+backtick`,label:`Toggle terminal`,description:`Toggle the integrated terminal`,customizable:!0},{id:`toggle_bottom_panel`,defaultCombo:`mod+j`,label:`Toggle bottom panel`,description:`Toggle the bottom panel dock`,customizable:!0},{id:`toggle_terminal_expanded`,defaultCombo:`mod+shift+j`,label:`Toggle terminal expanded`,description:`Toggle terminal expanded or collapsed`,customizable:!0},{id:`new_terminal_tab`,defaultCombo:`mod+t`,label:`New terminal tab`,description:`Create a new terminal tab when the terminal is focused`,customizable:!0},{id:`open_new_terminal`,defaultCombo:`mod+shift+backtick`,label:`Open new terminal`,description:`Open the terminal panel and create a new terminal tab`,customizable:!0},{id:`previous_terminal_tab`,defaultCombo:`mod+shift+[`,label:`Previous terminal tab`,description:`Switch to the previous terminal tab when the terminal is focused`,customizable:!0},{id:`next_terminal_tab`,defaultCombo:`mod+shift+]`,label:`Next terminal tab`,description:`Switch to the next terminal tab when the terminal is focused`,customizable:!0},{id:`toggle_files`,defaultCombo:`mod+shift+f`,label:`Toggle files`,description:`Toggle the files panel`},{id:`toggle_sidebar`,defaultCombo:`mod+b`,label:`Toggle sidebar`,description:`Toggle the session sidebar`,customizable:!0},{id:`open_timeline_dialog`,defaultCombo:`mod+t`,label:`Open conversation timeline`,description:`Search and navigate within current conversation`,customizable:!0},{id:`toggle_prompt_navigator`,defaultCombo:`mod+alt+p`,label:`Toggle prompt navigator`,description:`Show or hide the prompt navigator panel in chat`,customizable:!0},{id:`toggle_right_sidebar`,defaultCombo:`mod+alt+b`,defaultAliases:[`mod+\\`],label:`Toggle review panel`,description:`Toggle the review panel (right sidebar)`,customizable:!0},{id:`open_right_sidebar_git`,defaultCombo:`mod+shift+g`,label:`Open right sidebar Git tab`,description:`Open right sidebar and select Git`,customizable:!0},{id:`open_right_sidebar_files`,defaultCombo:`mod+shift+f`,label:`Open right sidebar Files tab`,description:`Open right sidebar and select Files`,customizable:!0},{id:`cycle_right_sidebar_tab`,defaultCombo:`mod+alt+shift+r`,label:`Cycle right sidebar tab`,description:`Cycle through right sidebar tabs`,customizable:!0},{id:`close_context_panel_tab`,defaultCombo:`mod+w`,label:`Close context panel tab`,description:`Close the active context panel tab (closes the panel when empty)`,customizable:!0},{id:`previous_session`,defaultCombo:`mod+shift+[`,defaultAliases:[`mod+arrowup`],label:`Previous session`,description:`Switch to the previous session`,customizable:!0},{id:`next_session`,defaultCombo:`mod+shift+]`,defaultAliases:[`mod+arrowdown`],label:`Next session`,description:`Switch to the next session`,customizable:!0},{id:`new_chat`,defaultCombo:`mod+n`,label:`New session`,description:`Start a new session`,customizable:!0},{id:`new_chat_worktree`,defaultCombo:`mod+shift+alt+n`,label:`New worktree draft`,description:`Create a new worktree and open a draft in it`,customizable:!0},{id:`new_mini_chat`,defaultCombo:`mod+alt+n`,label:`New Mini Chat window`,description:`Open a new Mini Chat draft window`,customizable:!0},{id:`submit_message`,defaultCombo:`mod+enter`,label:`Submit message`,description:`Submit the current message`},{id:`clear_input`,defaultCombo:`escape`,label:`Clear input`,description:`Clear the input field`},{id:`clear_all_messages`,defaultCombo:`ctrl+c`,label:`Clear all messages`,description:`Clear the composer input and queued messages`,customizable:!0},{id:`open_diff_panel`,defaultCombo:`mod+2`,label:`Open diff panel`,description:`Switch to the diff panel`},{id:`open_terminal_panel`,defaultCombo:`mod+3`,label:`Open terminal panel`,description:`Switch to the terminal panel`},{id:`open_git_panel`,defaultCombo:`mod+4`,label:`Open git panel`,description:`Switch to the git panel`},{id:`open_help`,defaultCombo:`mod+.`,label:`Open keyboard shortcuts`,description:`Show the keyboard shortcuts help`,customizable:!0},{id:`toggle_services_menu`,defaultCombo:`mod+shift+s`,label:`Toggle services menu`,description:`Open or close the services menu`,customizable:!0},{id:`open_usage`,defaultCombo:`mod+shift+c`,label:`Open usage`,description:`Open the usage panel`,customizable:!0},{id:`cycle_services_tab`,defaultCombo:`mod+alt+shift+s`,label:`Cycle services tab`,description:`Cycle through tabs in the services menu`,customizable:!0},{id:`cycle_theme`,defaultCombo:`mod+/`,label:`Cycle theme`,description:`Cycle between light, dark, and system theme`,customizable:!0},{id:`zoom_in`,defaultCombo:`mod+=`,label:`Zoom in`,description:`Increase the webview zoom level`,customizable:!0},{id:`zoom_out`,defaultCombo:`mod+-`,label:`Zoom out`,description:`Decrease the webview zoom level`,customizable:!0},{id:`zoom_reset`,defaultCombo:`mod+0`,label:`Reset zoom`,description:`Reset the webview zoom level to 100%`,customizable:!0},{id:`leader_key`,defaultCombo:`ctrl+x`,label:`Leader key`,description:`Start an OpenCode-style chord, then press M / A / N / C`,customizable:!0},{id:`open_model_selector`,defaultCombo:`mod+shift+m`,label:`Open model selector`,description:`Open model selector while in chat`,customizable:!0},{id:`cycle_thinking_variant`,defaultCombo:`mod+shift+t`,label:`Cycle thinking variant`,description:`Cycle thinking variant while in chat`},{id:`cycle_agent`,defaultCombo:`tab`,label:`Cycle agent`,description:`Cycle agent while the model selector is open`,customizable:!0},{id:`cycle_favorite_model_forward`,defaultCombo:`ctrl+]`,label:`Cycle favorite model forward`,description:`Cycle forward through starred models without opening the picker`,customizable:!0},{id:`cycle_favorite_model_backward`,defaultCombo:`ctrl+[`,label:`Cycle favorite model backward`,description:`Cycle backward through starred models without opening the picker`,customizable:!0},{id:`expand_input`,defaultCombo:`mod+shift+e`,label:`Expand input`,description:`Toggle focus mode for the chat input`,customizable:!0},{id:`toggle_dictation`,defaultCombo:`mod+alt+v`,label:`Voice input`,description:`Start dictation; press again to confirm and insert the transcript`,customizable:!0},{id:`abort_run`,defaultCombo:`escape`,label:`Abort active run`,description:`Abort the currently running task (double press)`},{id:`switch_tab_1`,defaultCombo:`mod+1`,label:`Switch to visible session 1`,description:`Switch to the first visible sidebar session`},{id:`switch_tab_2`,defaultCombo:`mod+2`,label:`Switch to visible session 2`,description:`Switch to the second visible sidebar session`},{id:`switch_tab_3`,defaultCombo:`mod+3`,label:`Switch to visible session 3`,description:`Switch to the third visible sidebar session`},{id:`switch_tab_4`,defaultCombo:`mod+4`,label:`Switch to visible session 4`,description:`Switch to the fourth visible sidebar session`},{id:`switch_tab_5`,defaultCombo:`mod+5`,label:`Switch to visible session 5`,description:`Switch to the fifth visible sidebar session`},{id:`switch_tab_6`,defaultCombo:`mod+6`,label:`Switch to visible session 6`,description:`Switch to the sixth visible sidebar session`},{id:`switch_tab_7`,defaultCombo:`mod+7`,label:`Switch to visible session 7`,description:`Switch to the seventh visible sidebar session`},{id:`switch_tab_8`,defaultCombo:`mod+8`,label:`Switch to visible session 8`,description:`Switch to the eighth visible sidebar session`},{id:`switch_tab_9`,defaultCombo:`mod+9`,label:`Switch to visible session 9`,description:`Switch to the ninth visible sidebar session`}];function Nn(e){if(An(e))return wn;let t=e.toLowerCase().trim().split(`+`).map(e=>e.trim()).filter(Boolean),n=new Set,r=``;for(let e of t){let t=e===`,`?`comma`:e===`.`?`period`:e,i=Tn[t];if(i){n.add(i);continue}r=t}return[...On.filter(e=>n.has(e)),r].filter(Boolean).join(`+`)}function Pn(e){return An(e)?!0:Fn(e).key.trim().length>0}function Fn(e){if(An(e))return{modifiers:new Set,key:wn};let t=Nn(e).split(`+`),n=new Set,r=``;for(let e of t){let t=Tn[e];t?n.add(t):r=e}return{modifiers:n,key:r}}function In(e){if(An(e))return`Unassigned`;let t=Fn(e);if(!t.key&&t.modifiers.size===0)return`Unassigned`;let n=[];for(let e of On)t.modifiers.has(e)&&n.push(En[e]);if(t.key){let e=Dn[t.key.toLowerCase()]||t.key.toUpperCase();n.push(e)}return n.join(` + `)}function Ln(e){return Mn.find(t=>t.id===e)}function Rn(){return Mn.filter(e=>e.customizable===!0)}function zn(e,t){let n=Ln(e);if(!n)return``;let r=t?.[e];if(typeof r==`string`){if(r.trim().toLowerCase()===`__unassigned__`)return``;let e=Nn(r);if(e===`__unassigned__`)return wn;if(Pn(e))return e}return n.defaultCombo}function Bn(e,t){let n=Ln(e);if(!n)return[];let r=zn(e,t);return r===n.defaultCombo?[n.defaultCombo,...n.defaultAliases??[]]:r?[r]:[]}function Vn(e){if(An(e))return!1;let t=Fn(e);if(!t.modifiers.has(`mod`))return!1;let n=t.key.toLowerCase();return new Set([`w`,`t`,`r`,`p`,`s`,`f`,`l`,`n`]).has(n)&&!t.modifiers.has(`shift`)&&!t.modifiers.has(`alt`)}function Hn(e,t){let n=typeof t==`string`?t:t.defaultCombo;if(An(n))return!1;let r=Fn(n),i=r.modifiers.has(`mod`),a=r.modifiers.has(`shift`),s=r.modifiers.has(`alt`),c=r.modifiers.has(`ctrl`),l=me()&&o(),u=me(),d=l?e.metaKey:u&&e.metaKey||e.ctrlKey;if(i&&!d||!i&&e.metaKey||a!==e.shiftKey||s!==e.altKey)return!1;if(c){if(!e.ctrlKey)return!1}else{let t=i&&!l&&e.ctrlKey;if(e.ctrlKey&&!t)return!1}let f=e.key;return(!f||f===`Dead`)&&e.code===`Backquote`&&(f="`"),e.altKey&&(e.code.startsWith(`Key`)&&e.code.length===4?f=e.code.slice(3).toLowerCase():e.code.startsWith(`Digit`)&&e.code.length===6&&(f=e.code.slice(5))),jn(f)===jn(r.key)}function Un(){return me()?`⌘`:`Ctrl`}function Wn(e,t,n){if(Hn(e,n))return!0;let r=Nn(n),i=me()&&o(),a=me();return!(i?e.metaKey:a&&e.metaKey||e.ctrlKey)||e.altKey||i&&e.ctrlKey&&!e.metaKey?!1:t===`in`&&r===`mod+=`?e.key===`+`||e.code===`NumpadAdd`:t===`out`&&(r===`mod+-`||r===`mod+minus`)?e.key===`_`||e.code===`NumpadSubtract`:!1}var Gn=Q.createContext(null),Kn=e=>e?e.closest(`[data-slot="dialog-content"], [role="dialog"]`):null;function qn(e,t){return e&&Q.isValidElement(t)?{render:t}:{children:t}}function Jn(e){let t=(0,K.c)(9),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let[r,i]=Q.useState(null),a;t[2]===r?a=t[3]:(a={portalContainer:r,setPortalContainer:i},t[2]=r,t[3]=a);let o=a,s;t[4]===n?s=t[5]:(s=(0,Z.jsx)(w,{...n}),t[4]=n,t[5]=s);let c;return t[6]!==o||t[7]!==s?(c=(0,Z.jsx)(Gn.Provider,{value:o,children:s}),t[6]=o,t[7]=s,t[8]=c):c=t[8],c}function Yn(e){let t=(0,K.c)(22),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({asChild:n,children:r,onPointerDownCapture:a,onFocusCapture:i,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=Q.useContext(Gn),c;t[6]===s?c=t[7]:(c=e=>{if(!s)return;let t=e instanceof HTMLElement?e:null;s.setPortalContainer(Kn(t))},t[6]=s,t[7]=c);let l=c,u;t[8]!==n||t[9]!==r?(u=qn(n,r),t[8]=n,t[9]=r,t[10]=u):u=t[10];let d=u,f;t[11]!==a||t[12]!==l?(f=e=>{l(e.currentTarget),a?.(e)},t[11]=a,t[12]=l,t[13]=f):f=t[13];let p;t[14]!==i||t[15]!==l?(p=e=>{l(e.currentTarget),i?.(e)},t[14]=i,t[15]=l,t[16]=p):p=t[16];let m;return t[17]!==o||t[18]!==d||t[19]!==f||t[20]!==p?(m=(0,Z.jsx)(g,{"data-slot":`dropdown-menu-trigger`,onPointerDownCapture:f,onFocusCapture:p,...o,...d}),t[17]=o,t[18]=d,t[19]=f,t[20]=p,t[21]=m):m=t[21],m}function Xn(e){let t=(0,K.c)(40),n,r,i,a,o,s,c,l,u,d,f,p,m;if(t[0]!==e){let{className:h,sideOffset:g,align:_,side:v,alignOffset:y,anchor:b,portalToBody:x,positionerClassName:S,style:C,children:w,onCloseAutoFocus:ee,collisionPadding:T,collisionAvoidance:E,...D}=e;o=h,d=g,n=_,l=v,r=y,i=b,f=x,s=S,u=C,a=w,p=T,m=E,c=D,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=u,t[10]=d,t[11]=f,t[12]=p,t[13]=m}else n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],u=t[9],d=t[10],f=t[11],p=t[12],m=t[13];let h=d===void 0?4:d,g=f!==void 0&&f,_=p===void 0?8:p,y;t[14]===m?y=t[15]:(y=m===void 0?{side:`shift`,align:`shift`}:m,t[14]=m,t[15]=y);let b=y,C=Q.useContext(Gn),w=g?void 0:C?.portalContainer||void 0,ee;t[16]===s?ee=t[17]:(ee=H(`app-region-no-drag z-50`,s),t[16]=s,t[17]=ee);let T;t[18]===u?T=t[19]:(T={backgroundColor:`var(--surface-elevated)`,color:`var(--surface-elevated-foreground)`,...u},t[18]=u,t[19]=T);let E;t[20]===o?E=t[21]:(E=H(qe,o),t[20]=o,t[21]=E);let D;t[22]!==a||t[23]!==c||t[24]!==T||t[25]!==E?(D=(0,Z.jsx)(v,{"data-slot":`dropdown-menu-content`,style:T,className:E,...c,children:a}),t[22]=a,t[23]=c,t[24]=T,t[25]=E,t[26]=D):D=t[26];let O;t[27]!==n||t[28]!==r||t[29]!==i||t[30]!==b||t[31]!==_||t[32]!==l||t[33]!==h||t[34]!==D||t[35]!==ee?(O=(0,Z.jsx)(x,{anchor:i,sideOffset:h,align:n,side:l,alignOffset:r,collisionPadding:_,collisionAvoidance:b,className:ee,children:D}),t[27]=n,t[28]=r,t[29]=i,t[30]=b,t[31]=_,t[32]=l,t[33]=h,t[34]=D,t[35]=ee,t[36]=O):O=t[36];let k;return t[37]!==O||t[38]!==w?(k=(0,Z.jsx)(S,{container:w,children:O}),t[37]=O,t[38]=w,t[39]=k):k=t[39],k}function Zn(e){let t=(0,K.c)(24),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({className:i,inset:a,variant:l,asChild:n,children:r,onSelect:s,onClick:o,...c}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u=l===void 0?`default`:l,d;t[9]!==n||t[10]!==r?(d=qn(n,r),t[9]=n,t[10]=r,t[11]=d):d=t[11];let f=d,p;t[12]!==o||t[13]!==s?(p=e=>{o?.(e),e.defaultPrevented||s?.(e)},t[12]=o,t[13]=s,t[14]=p):p=t[14];let m=p,h;t[15]===i?h=t[16]:(h=H(Ye,i),t[15]=i,t[16]=h);let g;return t[17]!==m||t[18]!==a||t[19]!==c||t[20]!==f||t[21]!==h||t[22]!==u?(g=(0,Z.jsx)(y,{"data-slot":`dropdown-menu-item`,"data-inset":a,"data-variant":u,className:h,...c,onClick:m,...f}),t[17]=m,t[18]=a,t[19]=c,t[20]=f,t[21]=h,t[22]=u,t[23]=g):g=t[23],g}function Qn(e){let t=(0,K.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Z.jsx)(b,{"data-slot":`dropdown-menu-radio-group`,...n}),t[2]=n,t[3]=r),r}function $n(e){let t=(0,K.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=H(`data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover data-[checked]:bg-interactive-selection data-[checked]:text-interactive-selection-foreground relative flex cursor-pointer items-start gap-2 rounded-lg py-1 pl-2 pr-8 typography-ui-label outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5`,r),t[4]=r,t[5]=a);let o;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-3.5 items-center justify-center text-primary`,children:(0,Z.jsx)(h,{children:(0,Z.jsx)(G,{name:`check`,className:`size-3`})})}),t[6]=o):o=t[6];let s;return t[7]!==n||t[8]!==i||t[9]!==a?(s=(0,Z.jsxs)(C,{"data-slot":`dropdown-menu-radio-item`,className:a,...i,children:[o,n]}),t[7]=n,t[8]=i,t[9]=a,t[10]=s):s=t[10],s}function er(e){let t=(0,K.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,inset:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=H(`px-2 py-1 typography-ui-label font-medium data-[inset]:pl-8`,n),t[4]=n,t[5]=a);let o;return t[6]!==r||t[7]!==i||t[8]!==a?(o=(0,Z.jsx)(`div`,{"data-slot":`dropdown-menu-label`,"data-inset":r,className:a,...i}),t[6]=r,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function tr(e){let t=(0,K.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=H(Je,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Z.jsx)(_,{"data-slot":`dropdown-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function nr(){let e=(0,K.c)(5),t=U(or),n=U(ar),r=U(ir),i=U(rr),a=t||i,o=!a&&r===`init_error`,s=!a&&!o,c;return e[0]!==n||e[1]!==a||e[2]!==o||e[3]!==s?(c={isReady:a,isLoading:s,isUnavailable:o,connectionPhase:n},e[0]=n,e[1]=a,e[2]=o,e[3]=s,e[4]=c):c=e[4],c}function rr(e){return e.providers.length>0}function ir(e){return e.lastDisconnectReason}function ar(e){return e.connectionPhase}function or(e){return e.isInitialized}var sr=e=>{let t=(0,K.c)(41),{agentName:n,onChange:r,className:i,filter:a,dropdownPortalToBody:o,showIcon:s,agents:c}=e,l=o!==void 0&&o,u=s===void 0||s,{t:d}=pe(),{isReady:f,isUnavailable:p}=nr(),m=U(cr),h=Ee(lr),g=U(ur),{data:_}=ve(),v;t[0]===_?v=t[1]:(v=_===void 0?[]:_,t[0]=_,t[1]=v);let y=v,b;bb0:{if(c){b=c;break bb0}if(Array.isArray(m)&&m.length>0){b=m;break bb0}b=y}let x=b,S;if(t[2]!==a||t[3]!==x){let e=ye(x);S=a?e.filter(a):e,t[2]=a,t[3]=x,t[4]=S}else S=t[4];let C=S,w=k(dr),{isMobile:ee}=Be(),T=w||ee,[E,D]=Q.useState(!1),O;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(O=()=>{D(!0),U.getState().refreshCatalogsOnPickerOpen({source:`agentSelector:mobilePanel`})},t[5]=O):O=t[5];let A=de(O),j=de(fr),te=Q.useId(),ne,M;t[6]!==c||t[7]!==h||t[8]!==g||t[9]!==x.length?(ne=()=>{c||x.length>0||(g(),h())},M=[c,x.length,g,h],t[6]=c,t[7]=h,t[8]=g,t[9]=x.length,t[10]=ne,t[11]=M):(ne=t[10],M=t[11]),Q.useEffect(ne,M);let re;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>D(!1),t[12]=re):re=t[12];let ie=re,ae;t[13]===r?ae=t[14]:(ae=e=>{r(e)},t[13]=r,t[14]=ae);let N=ae,P;t[15]!==n||t[16]!==C||t[17]!==N||t[18]!==T||t[19]!==E||t[20]!==te||t[21]!==d?(P=()=>T?(0,Z.jsx)(We,{id:`mobile-agent-selector-sheet-${te}`,open:E,onOpenChange:e=>{e||ie()},ariaLabel:d(`settings.commands.agentSelector.title`),closeAriaLabel:d(`mobile.surface.closeAria`),resizeAriaLabel:d(`mobile.sessions.sheet.resizeAria`),bodyClassName:`px-2`,children:(0,Z.jsxs)(Ge,{useScrollShadow:!0,disableHorizontal:!0,preventOverscroll:!0,outerClassName:`min-h-0 flex-1`,className:`flex flex-col gap-1 overscroll-contain`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:H(`grid w-full grid-cols-[1rem_minmax(0,1fr)_auto] items-center gap-x-2 rounded-lg border border-border/40 bg-background/95 px-2 py-1.5 text-left`,n?`text-foreground`:`bg-primary/10 text-primary`),onClick:()=>{N(``),ie()},children:[(0,Z.jsx)(De,{name:`default`,size:16}),(0,Z.jsx)(`span`,{className:H(`min-w-0 typography-meta`,n?`text-muted-foreground`:`font-medium`),children:d(`settings.commands.agentSelector.notSelected`)}),!n&&(0,Z.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-primary`})]}),C.map(e=>{let t=e.name===n;return(0,Z.jsxs)(`button`,{type:`button`,className:H(`grid w-full grid-cols-[1rem_minmax(0,1fr)_auto] items-start gap-x-2 rounded-lg border border-border/40 bg-background/95 px-2 py-1.5 text-left`,t?`bg-primary/10 text-primary`:`text-foreground`),onClick:()=>{N(e.name),ie()},children:[(0,Z.jsx)(De,{name:e.name,size:16,className:`mt-1.5`}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`typography-meta font-medium`,children:e.name}),e.description&&(0,Z.jsx)(`span`,{className:`mt-0.5 block whitespace-normal break-words typography-micro text-muted-foreground`,children:e.description})]}),t&&(0,Z.jsx)(`div`,{className:`mt-2 h-2 w-2 rounded-full bg-primary`})]},e.name)})]})}):null,t[15]=n,t[16]=C,t[17]=N,t[18]=T,t[19]=E,t[20]=te,t[21]=d,t[22]=P):P=t[22];let F=P,I;t[23]!==n||t[24]!==C||t[25]!==i||t[26]!==l||t[27]!==N||t[28]!==j||t[29]!==T||t[30]!==f||t[31]!==p||t[32]!==A||t[33]!==u||t[34]!==d?(I=T?(0,Z.jsxs)(`button`,{type:`button`,onClick:f?A:void 0,disabled:!f,className:H(`flex w-full items-center justify-between gap-2 rounded-lg border border-border/40 bg-background/95 px-2 py-1.5 text-left`,!f&&`opacity-60 cursor-not-allowed`,i),children:[(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:f?(0,Z.jsxs)(Z.Fragment,{children:[u?(0,Z.jsx)(De,{name:n||`default`,size:14}):null,(0,Z.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:n||d(`settings.commands.agentSelector.selectAgentPlaceholder`)})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(G,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:d(p?`common.unavailable`:`common.loading`)})]})}),(0,Z.jsx)(G,{name:`arrow-down-s`,className:`h-3 w-3 text-muted-foreground`})]}):f?(0,Z.jsxs)(Jn,{onOpenChange:j,children:[(0,Z.jsx)(Yn,{asChild:!0,children:(0,Z.jsxs)(`div`,{className:H(`flex items-center gap-2 px-2 rounded-lg bg-interactive-selection/20 border border-border/20 cursor-pointer hover:bg-interactive-hover/30 h-6 w-fit`,i),children:[u?(0,Z.jsx)(De,{name:n||`default`,size:14}):null,(0,Z.jsx)(`span`,{className:`typography-micro font-medium whitespace-nowrap`,children:n||d(`settings.commands.agentSelector.notSelected`)}),(0,Z.jsx)(G,{name:`arrow-down-s`,className:`h-3 w-3 flex-shrink-0 text-muted-foreground`})]})}),(0,Z.jsxs)(Xn,{className:`max-w-[300px]`,portalToBody:l,children:[(0,Z.jsxs)(Zn,{className:`typography-meta`,onSelect:()=>N(``),children:[(0,Z.jsx)(De,{name:`default`,size:14}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:d(`settings.commands.agentSelector.notSelected`)})]}),C.map(e=>(0,Z.jsxs)(Zn,{className:`typography-meta`,onSelect:()=>N(e.name),children:[(0,Z.jsx)(De,{name:e.name,size:14}),(0,Z.jsx)(`span`,{className:`font-medium`,children:e.name})]},e.name))]})]}):(0,Z.jsxs)(`div`,{className:H(`flex items-center gap-2 px-2 rounded-lg bg-interactive-selection/20 border border-border/20 h-6 w-fit opacity-60`,i),children:[(0,Z.jsx)(G,{name:`loader-4`,className:`h-3 w-3 animate-spin text-muted-foreground flex-shrink-0`}),(0,Z.jsx)(`span`,{className:`typography-micro font-medium whitespace-nowrap text-muted-foreground`,children:d(p?`common.unavailable`:`common.loading`)})]}),t[23]=n,t[24]=C,t[25]=i,t[26]=l,t[27]=N,t[28]=j,t[29]=T,t[30]=f,t[31]=p,t[32]=A,t[33]=u,t[34]=d,t[35]=I):I=t[35];let L;t[36]===F?L=t[37]:(L=F(),t[36]=F,t[37]=L);let oe;return t[38]!==I||t[39]!==L?(oe=(0,Z.jsxs)(Z.Fragment,{children:[I,L]}),t[38]=I,t[39]=L,t[40]=oe):oe=t[40],oe};function cr(e){return e.agents}function lr(e){return e.loadAgents}function ur(e){return e.loadAgents}function dr(e){return e.isMobile}function fr(e){e&&U.getState().refreshCatalogsOnPickerOpen({source:`agentSelector:desktopMenu`})}var pr={compact:{notation:`compact`,compactDisplay:`short`,maximumFractionDigits:1,minimumFractionDigits:0},compactTokensShort:{notation:`compact`,compactDisplay:`short`,maximumFractionDigits:1},usd:{style:`currency`,currency:`USD`,maximumFractionDigits:4,minimumFractionDigits:2}},mr=null,hr={},gr=(e,t)=>{mr!==t&&(mr=t,hr.compact=void 0,hr.compactTokensShort=void 0,hr.usd=void 0);let n=hr[e];if(n)return n;let r=new Intl.NumberFormat(t,pr[e]);return hr[e]=r,r},_r=(e,t=V())=>gr(`compact`,t).format(e),vr=(e,t=V())=>gr(`compactTokensShort`,t).format(e),yr=(e,t=V())=>gr(`usd`,t).format(e),br=(e,t=V())=>e.toLocaleDateString(t,{month:`short`,day:`numeric`,year:`numeric`}),xr=(e,t=V())=>new Date(e).toLocaleDateString(t,{year:`numeric`,month:`short`,day:`numeric`}),Sr=(e,t=V())=>new Date(e).toLocaleTimeString(t,{hour:`numeric`,minute:`2-digit`}),Cr=8,wr=e=>typeof e!=`number`||Number.isNaN(e)?``:vr(e),Tr=(e,t,n)=>{let r=e.find(e=>e.id===t)?.models?.find(e=>e.id===n);return r?.variants?Object.keys(r.variants):[]},Er=e=>{let t=(0,K.c)(54),{open:n,onClose:r,selectedProviderID:i,selectedModelID:a,resolveSelectedVariant:o,onSelect:s,providers:c,favoriteModels:l,recentModels:u,hiddenModels:d,allowedProviderIds:f,allowedModelIdsByProvider:p,providerOrder:m,variantSelectionEnabled:h,isFavorite:g,onToggleFavorite:_,getMetadata:v,view:y,onViewChange:b}=e,x;t[0]===d?x=t[1]:(x=d===void 0?[]:d,t[0]=d,t[1]=x);let S=x,C=h===void 0||h,{t:w}=pe(),ee=Q.useId(),[T,E]=Q.useState(``),D;t[2]===i?D=t[3]:(D=()=>new Set(i?[i]:[]),t[2]=i,t[3]=D);let[O,k]=Q.useState(D),[A,j]=Q.useState(null),[te,ne]=Q.useState(`model`),[M,re]=Q.useState(null),ie=Q.useRef(!1),ae=y??te,N,P;t[4]!==n||t[5]!==i?(N=()=>{n&&!ie.current&&k(new Set(i?[i]:[])),n||(E(``),j(null),ne(`model`),re(null)),ie.current=n},P=[n,i],t[4]=n,t[5]=i,t[6]=N,t[7]=P):(N=t[6],P=t[7]),Q.useEffect(N,P);let F;t[8]===b?F=t[9]:(F=e=>{ne(e),b?.(e)},t[8]=b,t[9]=F);let I=F,L=ae===`variant`&&!!(M??(i&&a)),oe=`mobile-model-picker-sheet-${ee}`,R;t[10]===r?R=t[11]:(R=e=>{e||r()},t[10]=r,t[11]=R);let se;t[12]!==L||t[13]!==I||t[14]!==w?(se=L?(0,Z.jsx)(he,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>I(`model`),"aria-label":w(`onboarding.common.actions.back`),children:(0,Z.jsx)(G,{name:`arrow-left`,className:`size-5`})}):void 0,t[12]=L,t[13]=I,t[14]=w,t[15]=se):se=t[15];let z;t[16]!==L||t[17]!==w?(z=w(L?`chat.modelControls.thinking`:`chat.modelControls.selectModel`),t[16]=L,t[17]=w,t[18]=z):z=t[18];let ce;t[19]===w?ce=t[20]:(ce=w(`mobile.surface.closeAria`),t[19]=w,t[20]=ce);let B;t[21]===w?B=t[22]:(B=w(`mobile.sessions.sheet.resizeAria`),t[21]=w,t[22]=B);let le;t[23]!==ae||t[24]!==p||t[25]!==f||t[26]!==A||t[27]!==O||t[28]!==l||t[29]!==v||t[30]!==S||t[31]!==g||t[32]!==s||t[33]!==_||t[34]!==m||t[35]!==c||t[36]!==T||t[37]!==u||t[38]!==o||t[39]!==a||t[40]!==i||t[41]!==I||t[42]!==C||t[43]!==M?(le=(0,Z.jsx)(Dr,{query:T,onQueryChange:E,expandedProviders:O,onExpandedProvidersChange:k,expandedModelKey:A,onExpandedModelKeyChange:j,activeView:ae,setView:I,variantTarget:M,onVariantTargetChange:re,selectedProviderID:i,selectedModelID:a,resolveSelectedVariant:o,onSelect:s,providers:c,favoriteModels:l,recentModels:u,hiddenModels:S,allowedProviderIds:f,allowedModelIdsByProvider:p,providerOrder:m,variantSelectionEnabled:C,isFavorite:g,onToggleFavorite:_,getMetadata:v}),t[23]=ae,t[24]=p,t[25]=f,t[26]=A,t[27]=O,t[28]=l,t[29]=v,t[30]=S,t[31]=g,t[32]=s,t[33]=_,t[34]=m,t[35]=c,t[36]=T,t[37]=u,t[38]=o,t[39]=a,t[40]=i,t[41]=I,t[42]=C,t[43]=M,t[44]=le):le=t[44];let ue;return t[45]!==n||t[46]!==se||t[47]!==z||t[48]!==ce||t[49]!==B||t[50]!==le||t[51]!==oe||t[52]!==R?(ue=(0,Z.jsx)(We,{id:oe,open:n,onOpenChange:R,leading:se,ariaLabel:z,closeAriaLabel:ce,resizeAriaLabel:B,bodyClassName:`px-2`,children:le}),t[45]=n,t[46]=se,t[47]=z,t[48]=ce,t[49]=B,t[50]=le,t[51]=oe,t[52]=R,t[53]=ue):ue=t[53],ue},Dr=e=>{let t=(0,K.c)(117),{query:n,onQueryChange:r,expandedProviders:i,onExpandedProvidersChange:a,expandedModelKey:o,onExpandedModelKeyChange:s,activeView:c,setView:l,variantTarget:u,onVariantTargetChange:d,selectedProviderID:f,selectedModelID:p,resolveSelectedVariant:m,onSelect:h,providers:g,favoriteModels:_,recentModels:v,hiddenModels:y,allowedProviderIds:b,allowedModelIdsByProvider:x,providerOrder:S,variantSelectionEnabled:C,isFavorite:w,onToggleFavorite:ee,getMetadata:T}=e,{t:E}=pe(),D;t[0]===b?D=t[1]:(D=b&&b.length>0?new Set(b):null,t[0]=b,t[1]=D);let O=D,k;t[2]===x?k=t[3]:(k=x?new Map(Object.entries(x).map(Or)):null,t[2]=x,t[3]=k);let A=k,j;t[4]===y?j=t[5]:(j=new Set(y.map(kr)),t[4]=y,t[5]=j);let te=j,ne;t[6]===g?ne=t[7]:(ne=new Map(g.map(Ar)),t[6]=g,t[7]=ne);let M=ne,re;bb0:{if(!S?.length){re=g;break bb0}let e;t[8]===S?e=t[9]:(e=new Map(S.map(jr)),t[8]=S,t[9]=e);let n=e,r;if(t[10]!==g||t[11]!==n){let e;t[13]===n?e=t[14]:(e=(e,t)=>{let r=n.get(e.id),i=n.get(t.id);return r===void 0&&i===void 0?0:r===void 0?1:i===void 0?-1:r-i},t[13]=n,t[14]=e),r=[...g].sort(e),t[10]=g,t[11]=n,t[12]=r}else r=t[12];re=r}let ie=re,ae;t[15]!==A||t[16]!==O||t[17]!==te?(ae=(e,t)=>O&&!O.has(e)||A&&A.get(e)?.has(t)!==!0?!1:!te.has(`${e}:${t}`),t[15]=A,t[16]=O,t[17]=te,t[18]=ae):ae=t[18];let N=ae,P;t[19]!==M||t[20]!==n?(P=e=>{let t=n.trim();if(!t)return!0;let r=M.get(e.providerID)?.name||e.providerID,i=we(e.model,e.modelID,{maxLength:40});return Me(i,t)||Me(e.modelID,t)||Me(r,t)},t[19]=M,t[20]=n,t[21]=P):P=t[21];let F=P,I;if(t[22]!==_||t[23]!==N||t[24]!==F){let e;t[26]!==N||t[27]!==F?(e=e=>N(e.providerID,e.modelID)&&F(e),t[26]=N,t[27]=F,t[28]=e):e=t[28],I=_.filter(e),t[22]=_,t[23]=N,t[24]=F,t[25]=I}else I=t[25];let L=I,oe;if(t[29]!==N||t[30]!==F||t[31]!==v){let e;t[33]!==N||t[34]!==F?(e=e=>N(e.providerID,e.modelID)&&F(e),t[33]=N,t[34]=F,t[35]=e):e=t[35],oe=v.filter(e),t[29]=N,t[30]=F,t[31]=v,t[32]=oe}else oe=t[32];let R=oe,se;if(t[36]!==O||t[37]!==N||t[38]!==ie||t[39]!==n){let e=n.trim(),r;t[41]===O?r=t[42]:(r=e=>!O||O.has(e.id),t[41]=O,t[42]=r),se=ie.filter(r).map(t=>{let n=e.length>0&&(Me(t.name||t.id,e)||Me(t.id,e));return{provider:t,models:(t.models??[]).filter(r=>{let i=typeof r.id==`string`?r.id:``;return!i||!N(t.id,i)?!1:n||!e?!0:Me(we(r,i,{maxLength:40}),e)||Me(i,e)})}}).filter(Mr),t[36]=O,t[37]=N,t[38]=ie,t[39]=n,t[40]=se}else se=t[40];let z=se,ce;t[43]===E?ce=t[44]:(ce=e=>{if(!e?.trim())return E(`chat.modelControls.default`);let t=e.trim();return/^\d+(\.\d+)?$/.test(t)?t:t.charAt(0).toUpperCase()+t.slice(1)},t[43]=E,t[44]=ce);let B=ce,le;t[45]===E?le=t[46]:(le=e=>{let t=[];e?.tool_call&&t.push({key:`tool_call`,icon:`tools`,label:E(`chat.modelControls.capability.toolCalling`)}),e?.reasoning&&t.push({key:`reasoning`,icon:`brain-ai-3`,label:E(`chat.modelControls.capability.reasoning`)});let n={text:{icon:`text`,label:E(`chat.modelControls.modality.text`)},image:{icon:`file-image`,label:E(`chat.modelControls.modality.image`)},video:{icon:`file-video`,label:E(`chat.modelControls.modality.video`)},audio:{icon:`file-music`,label:E(`chat.modelControls.modality.audio`)},pdf:{icon:`file-pdf`,label:E(`chat.modelControls.modality.pdf`)}};for(let r of[...e?.modalities?.input??[],...e?.modalities?.output??[]]){let e=r.trim().toLowerCase(),i=n[e];i&&!t.some(t=>t.key===e)&&t.push({key:e,...i})}return t},t[45]=E,t[46]=le);let ue=le,de;t[47]!==d||t[48]!==l?(de=(e,t,n)=>{d(n===void 0?{providerID:e,modelID:t}:{providerID:e,modelID:t,variant:n}),l(`variant`)},t[47]=d,t[48]=l,t[49]=de):de=t[49];let fe=de,me;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(me={onPointerDown:He,onClickCapture:Nr},t[50]=me):me=t[50];let V=me,he;t[51]!==o||t[52]!==B||t[53]!==T||t[54]!==ue||t[55]!==w||t[56]!==s||t[57]!==h||t[58]!==ee||t[59]!==fe||t[60]!==M||t[61]!==g||t[62]!==m||t[63]!==p||t[64]!==f||t[65]!==E||t[66]!==C?(he=(e,t)=>{let n=t===void 0?{}:t,{model:r,providerID:i,modelID:a}=e,c=`${i}:${a}`,l=i===f&&a===p,u=Le(i,r,T?.(i,a)),d=C?Tr(g,i,a):[],_=m(i,a),v=n.preferRememberedVariant&&e.variant!==void 0&&d.includes(e.variant)?e.variant:void 0,y=v===void 0?_:v,b=l||v===void 0?_:v,x=[void 0,...d].slice(0,Cr),S=o===c,D=ue(u),O=u?.limit?.context?`${wr(u.limit.context)} ctx`:null;return(0,Z.jsxs)(`div`,{className:H(`border-b border-border/30 last:border-b-0`,l&&`bg-interactive-selection/15 text-interactive-selection-foreground`),children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[(0,Z.jsx)(`button`,{type:`button`,...V,onClick:()=>h(i,a,y),className:`flex min-w-0 flex-1 items-start gap-2 rounded-lg text-left focus:outline-none focus-visible:ring-1 focus-visible:ring-primary`,children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[n.showProvider?(0,Z.jsx)(`span`,{className:`truncate text-[10px] leading-none text-muted-foreground/60`,children:M.get(i)?.name||i}):null,(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Z.jsx)(Pe,{modelId:a,providerId:i,className:`size-3.5 flex-shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate typography-meta font-medium text-foreground`,children:we(r,a,{maxLength:40})}),l?(0,Z.jsx)(G,{name:`check`,className:`size-4 flex-shrink-0 text-primary`}):null]}),O||D.length>0?(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 overflow-hidden typography-micro text-muted-foreground`,children:[O?(0,Z.jsx)(`span`,{className:`flex-shrink-0 whitespace-nowrap`,children:O}):null,O&&D.length>0?(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-px flex-shrink-0 bg-border/50`}):null,(0,Z.jsx)(`div`,{className:`flex min-w-0 items-center gap-1 overflow-hidden whitespace-nowrap pl-0.5`,children:D.map(e=>{let{key:t,icon:n,label:r}=e;return(0,Z.jsx)(`span`,{className:`flex size-4 flex-shrink-0 items-center justify-center text-muted-foreground`,title:r,"aria-label":r,children:(0,Z.jsx)(G,{name:n,className:`size-3`})},`${c}-${t}`)})})]}):null]})}),d.length>0?(0,Z.jsxs)(`button`,{type:`button`,...V,onClick:()=>s(e=>e===c?null:c),className:`flex flex-shrink-0 items-center gap-0.5 typography-micro font-medium text-muted-foreground hover:text-foreground`,"aria-expanded":S,"aria-label":E(S?`chat.modelControls.hideThinkingModes`:`chat.modelControls.showThinkingModes`),children:[(0,Z.jsx)(`span`,{className:`whitespace-nowrap`,children:B(b)}),(0,Z.jsx)(G,{name:S?`arrow-down-s`:`arrow-right-s`,className:`size-3.5`})]}):null,(0,Z.jsx)(`button`,{type:`button`,...V,onClick:e=>{e.preventDefault(),e.stopPropagation(),ee(i,a)},className:H(`model-favorite-button flex size-5 flex-shrink-0 items-center justify-center hover:text-primary/80`,w(i,a)?`text-primary`:`text-muted-foreground`),"aria-label":w(i,a)?E(`chat.modelControls.unfavoriteAria`):E(`chat.modelControls.favoriteAria`),title:w(i,a)?E(`chat.modelControls.removeFromFavorites`):E(`chat.modelControls.addToFavorites`),children:(0,Z.jsx)(G,{name:w(i,a)?`star-fill`:`star`,className:`size-4`})})]}),S&&d.length>0?(0,Z.jsx)(`div`,{className:`border-t border-border/30 p-2`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[x.map(e=>{let t=e===b||!e&&!b;return(0,Z.jsx)(`button`,{type:`button`,...V,onClick:()=>h(i,a,e),className:H(`inline-flex items-center rounded-full border px-2.5 py-1 typography-meta font-medium`,t?`border-primary/30 bg-primary/10 text-foreground`:`border-border/40 text-muted-foreground hover:bg-interactive-hover/50`),"aria-pressed":t,children:B(e)},`${c}-${e??`default`}`)}),x.length<d.length+1?(0,Z.jsx)(`button`,{type:`button`,...V,onClick:()=>fe(i,a,b),className:`inline-flex items-center rounded-full border border-border/40 px-2.5 py-1 typography-meta font-medium text-muted-foreground hover:bg-interactive-hover/50`,"aria-label":E(`chat.modelControls.moreThinkingModes`),children:E(`inlineComment.actions.showMore`)}):null]})}):null]},`mobile-model-${c}`)},t[51]=o,t[52]=B,t[53]=T,t[54]=ue,t[55]=w,t[56]=s,t[57]=h,t[58]=ee,t[59]=fe,t[60]=M,t[61]=g,t[62]=m,t[63]=p,t[64]=f,t[65]=E,t[66]=C,t[67]=he):he=t[67];let ge=he,_e,ve,ye,be,xe,Se,Ce,U,Te,W;if(t[68]!==c||t[69]!==i||t[70]!==L||t[71]!==z||t[72]!==R||t[73]!==B||t[74]!==s||t[75]!==a||t[76]!==r||t[77]!==h||t[78]!==g||t[79]!==n||t[80]!==ge||t[81]!==m||t[82]!==p||t[83]!==f||t[84]!==E||t[85]!==u){let e=u??(c===`variant`&&f&&p?{providerID:f,modelID:p}:null),o=e?Tr(g,e.providerID,e.modelID):[],l;bb1:{if(!e){l=void 0;break bb1}if(e.providerID===f&&e.modelID===p){l=m(e.providerID,e.modelID);break bb1}l=(e.variant!==void 0&&o.includes(e.variant)?e.variant:void 0)??m(e.providerID,e.modelID)}let d=l,_=L.length>0||R.length>0||z.length>0,v=c===`variant`&&!!e;Te=`flex min-h-0 flex-1 flex-col gap-2`,t[96]!==v||t[97]!==s||t[98]!==r||t[99]!==n||t[100]!==E?(W=v?null:(0,Z.jsxs)(`div`,{className:`relative z-10 shrink-0`,"data-mobile-sheet-no-dismiss":``,"data-mobile-sheet-search":``,children:[(0,Z.jsx)(G,{name:`search`,className:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,Z.jsx)(Re,{type:`text`,value:n,onChange:e=>{r(e.target.value),s(null)},onPointerUp:Pr,placeholder:E(`chat.modelControls.searchProvidersOrModels`),className:`h-9 rounded-xl border-border/40 bg-[var(--surface-elevated)] pl-7 typography-meta`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,enterKeyHint:`search`,inputMode:`search`}),n?(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{r(``),s(null)},className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,"aria-label":E(`chat.modelControls.clearSearch`),children:(0,Z.jsx)(G,{name:`close-circle`,className:`size-4`})}):null]}),t[96]=v,t[97]=s,t[98]=r,t[99]=n,t[100]=E,t[101]=W):W=t[101],_e=Ge,be=!0,xe=!0,Se=!0,Ce=`min-h-0 flex-1`,U=`overscroll-contain`,ve=`flex flex-col gap-2`,ye=v&&e?(0,Z.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:[void 0,...o].map(t=>{let n=t===d||!t&&!d;return(0,Z.jsxs)(`button`,{type:`button`,className:H(`flex w-full items-center justify-between gap-2 rounded-xl border px-2 py-1.5 text-left focus:outline-none focus-visible:ring-1 focus-visible:ring-primary`,n?`border-primary/30 bg-primary/10`:`border-border/40`),...V,onClick:()=>h(e.providerID,e.modelID,t),children:[(0,Z.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:B(t)}),n?(0,Z.jsx)(G,{name:`check`,className:`size-4 flex-shrink-0 text-primary`}):null]},t??`default`)})}):(0,Z.jsxs)(Z.Fragment,{children:[_?null:(0,Z.jsx)(`div`,{className:`px-3 py-8 text-center typography-meta text-muted-foreground`,children:E(`chat.modelControls.noProvidersOrModelsFound`)}),L.length>0?(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border/40 bg-[var(--surface-elevated)]`,children:[(0,Z.jsxs)(`div`,{className:`px-2 py-1.5 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,Z.jsx)(G,{name:`star-fill`,className:`mr-1.5 inline-block size-3 text-primary`}),E(`chat.modelControls.favorites`)]}),(0,Z.jsx)(`div`,{className:`flex flex-col border-t border-border/30`,children:L.map(e=>ge(e,{showProvider:!0,preferRememberedVariant:!0}))})]}):null,R.length>0?(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border/40 bg-[var(--surface-elevated)]`,children:[(0,Z.jsxs)(`div`,{className:`px-2 py-1.5 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,Z.jsx)(G,{name:`time`,className:`mr-1.5 inline-block size-3`}),E(`chat.modelControls.recent`)]}),(0,Z.jsx)(`div`,{className:`flex flex-col border-t border-border/30`,children:R.map(e=>ge(e,{showProvider:!0,preferRememberedVariant:!0}))})]}):null,z.map(e=>{let{provider:t,models:r}=e,o=i.has(t.id)||n.trim().length>0;return(0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-border/40 bg-[var(--surface-elevated)]`,children:[(0,Z.jsxs)(`button`,{type:`button`,...V,onClick:()=>{n.trim()||a(e=>{let n=new Set(e);return n.has(t.id)?n.delete(t.id):n.add(t.id),n})},className:`flex w-full items-center justify-between gap-1.5 px-2 py-1.5 text-left`,"aria-expanded":o,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Ie,{providerId:t.id,className:`size-3.5`}),(0,Z.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:t.name||t.id}),t.id===f?(0,Z.jsx)(`span`,{className:`typography-micro text-primary/80`,children:E(`chat.modelControls.current`)}):null]}),(0,Z.jsx)(G,{name:o?`arrow-down-s`:`arrow-right-s`,className:`size-3 text-muted-foreground`})]}),o?(0,Z.jsx)(`div`,{className:`flex flex-col border-t border-border/30`,children:r.map(e=>ge({model:e,providerID:t.id,modelID:e.id}))}):null]},t.id)})]}),t[68]=c,t[69]=i,t[70]=L,t[71]=z,t[72]=R,t[73]=B,t[74]=s,t[75]=a,t[76]=r,t[77]=h,t[78]=g,t[79]=n,t[80]=ge,t[81]=m,t[82]=p,t[83]=f,t[84]=E,t[85]=u,t[86]=_e,t[87]=ve,t[88]=ye,t[89]=be,t[90]=xe,t[91]=Se,t[92]=Ce,t[93]=U,t[94]=Te,t[95]=W}else _e=t[86],ve=t[87],ye=t[88],be=t[89],xe=t[90],Se=t[91],Ce=t[92],U=t[93],Te=t[94],W=t[95];let Ee;t[102]!==ve||t[103]!==ye?(Ee=(0,Z.jsx)(`div`,{className:ve,children:ye}),t[102]=ve,t[103]=ye,t[104]=Ee):Ee=t[104];let De;t[105]!==_e||t[106]!==be||t[107]!==xe||t[108]!==Se||t[109]!==Ce||t[110]!==U||t[111]!==Ee?(De=(0,Z.jsx)(_e,{useScrollShadow:be,disableHorizontal:xe,preventOverscroll:Se,outerClassName:Ce,className:U,children:Ee}),t[105]=_e,t[106]=be,t[107]=xe,t[108]=Se,t[109]=Ce,t[110]=U,t[111]=Ee,t[112]=De):De=t[112];let Oe;return t[113]!==Te||t[114]!==W||t[115]!==De?(Oe=(0,Z.jsxs)(`div`,{className:Te,children:[W,De]}),t[113]=Te,t[114]=W,t[115]=De,t[116]=Oe):Oe=t[116],Oe};function Or(e){let[t,n]=e;return[t,new Set(n)]}function kr(e){return`${e.providerID}:${e.modelID}`}function Ar(e){return[e.id,e]}function jr(e,t){return[e,t]}function Mr(e){return e.models.length>0}function Nr(e){Ue(e)||(e.preventDefault(),e.stopPropagation())}function Pr(e){document.activeElement!==e.currentTarget&&e.currentTarget.focus({preventScroll:!0})}var Fr=e=>{let t=(0,K.c)(217),{providerId:n,modelId:r,variant:i,onChange:a,className:o,allowedProviderIds:s,allowedModelIdsByProvider:c,placeholder:l,tooltipsEnabled:u,dropdownPortalToBody:d,showIcon:f,providers:p}=e,m=u===void 0||u,h=d!==void 0&&d,g=f===void 0||f,{t:_}=pe(),{isReady:v,isUnavailable:y}=nr(),b=U(Ir),x=p??b,S=U(Lr),C=k(Rr),w=k(zr),ee=k(Br),T=k(Vr),E=k(Hr),D=k(Ur),O;t[0]!==r||t[1]!==n?(O={currentProviderID:n,currentModelID:r},t[0]=r,t[1]=n,t[2]=O):O=t[2];let{favoriteModelsList:A,recentModelsList:j}=Ne(O),{isMobile:te}=Be(),ne=C||te,[M,re]=Q.useState(!1),[ie,ae]=Q.useState(!1),N;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(N=()=>{re(!0),U.getState().refreshCatalogsOnPickerOpen({source:`modelSelector:mobilePanel`})},t[3]=N):N=t[3];let P=de(N),F;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(F=e=>{ae(e),e&&U.getState().refreshCatalogsOnPickerOpen({source:`modelSelector:desktopMenu`})},t[4]=F):F=t[4];let I=de(F),[L,oe]=Q.useState(``),[R,se]=Q.useState(null),z=i!==void 0,ce;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(ce=()=>{re(!1),ae(!1),oe(``),se(null)},t[5]=ce):ce=t[5];let B=ce,le;t[6]===x?le=t[7]:(le=e=>{let t=x.find(t=>t.id===e.providerID)?.models?.find(t=>t.id===e.modelID);return t?.variants?Object.keys(t.variants):[]},t[6]=x,t[7]=le);let ue=le,fe;t[8]!==E||t[9]!==ue||t[10]!==r||t[11]!==a||t[12]!==n||t[13]!==i||t[14]!==z?(fe=e=>{let t=ue(e),o=e.providerID===n&&e.modelID===r,s=e.variant!==void 0&&t.includes(e.variant)?e.variant:void 0,c=o&&i&&t.includes(i)?i:s??``;a(e.providerID,e.modelID,z?c:void 0),E(e.providerID,e.modelID,z&&c||void 0),B()},t[8]=E,t[9]=ue,t[10]=r,t[11]=a,t[12]=n,t[13]=i,t[14]=z,t[15]=fe):fe=t[15];let me=fe,V;t[16]!==a||t[17]!==z?(V=()=>{a(``,``,z?``:void 0),B()},t[16]=a,t[17]=z,t[18]=V):V=t[18];let he=V,ge;t[19]!==E||t[20]!==a||t[21]!==R?(ge=e=>{R&&(a(R.providerID,R.modelID,e),E(R.providerID,R.modelID,e||void 0),B())},t[19]=E,t[20]=a,t[21]=R,t[22]=ge):ge=t[22];let _e=ge,ve;t[23]===_?ve=t[24]:(ve=_(`settings.agents.modelSelector.searchPlaceholder`),t[23]=_,t[24]=ve);let ye;t[25]===_?ye=t[26]:(ye=_(`settings.agents.modelSelector.state.noModelsFound`),t[25]=_,t[26]=ye);let be;t[27]===_?be=t[28]:(be=_(`settings.agents.modelSelector.section.favorites`),t[27]=_,t[28]=be);let xe;t[29]===_?xe=t[30]:(xe=_(`settings.agents.modelSelector.section.recent`),t[29]=_,t[30]=xe);let Se;t[31]===_?Se=t[32]:(Se=_(`settings.agents.modelSelector.keyboardHints`),t[31]=_,t[32]=Se);let Ce;t[33]!==l||t[34]!==_?(Ce=l||_(`settings.agents.modelSelector.notSelected`),t[33]=l,t[34]=_,t[35]=Ce):Ce=t[35];let we;t[36]===_?we=t[37]:(we=_(`settings.agents.modelSelector.actions.favorite`),t[36]=_,t[37]=we);let Te;t[38]===_?Te=t[39]:(Te=_(`settings.agents.modelSelector.actions.unfavorite`),t[38]=_,t[39]=Te);let W;t[40]===_?W=t[41]:(W=_(`chat.modelControls.provider`),t[40]=_,t[41]=W);let Ee;t[42]===_?Ee=t[43]:(Ee=_(`chat.modelControls.capabilities`),t[42]=_,t[43]=Ee);let De;t[44]===_?De=t[45]:(De=_(`chat.modelControls.capability.toolCalling`),t[44]=_,t[45]=De);let Oe;t[46]===_?Oe=t[47]:(Oe=_(`chat.modelControls.capability.reasoning`),t[46]=_,t[47]=Oe);let ke;t[48]===_?ke=t[49]:(ke=_(`chat.modelControls.modality.image`),t[48]=_,t[49]=ke);let Ae;t[50]===_?Ae=t[51]:(Ae=_(`chat.modelControls.modality.video`),t[50]=_,t[51]=Ae);let je;t[52]===_?je=t[53]:(je=_(`chat.modelControls.modality.audio`),t[52]=_,t[53]=je);let Me;t[54]===_?Me=t[55]:(Me=_(`chat.modelControls.costPerMillion`),t[54]=_,t[55]=Me);let Ie;t[56]===_?Ie=t[57]:(Ie=_(`chat.modelControls.costInput`),t[56]=_,t[57]=Ie);let Le;t[58]===_?Le=t[59]:(Le=_(`chat.modelControls.costOutput`),t[58]=_,t[59]=Le);let Re;t[60]!==ve||t[61]!==ye||t[62]!==be||t[63]!==xe||t[64]!==Se||t[65]!==Ce||t[66]!==we||t[67]!==Te||t[68]!==W||t[69]!==Ee||t[70]!==De||t[71]!==Oe||t[72]!==ke||t[73]!==Ae||t[74]!==je||t[75]!==Me||t[76]!==Ie||t[77]!==Le?(Re={searchPlaceholder:ve,noResults:ye,favorites:be,recent:xe,keyboardHint:Se,notSelected:Ce,favorite:we,unfavorite:Te,provider:W,capabilities:Ee,capabilityToolCalling:De,capabilityReasoning:Oe,modalityImage:ke,modalityVideo:Ae,modalityAudio:je,costPerMillion:Me,costInput:Ie,costOutput:Le},t[60]=ve,t[61]=ye,t[62]=be,t[63]=xe,t[64]=Se,t[65]=Ce,t[66]=we,t[67]=Te,t[68]=W,t[69]=Ee,t[70]=De,t[71]=Oe,t[72]=ke,t[73]=Ae,t[74]=je,t[75]=Me,t[76]=Ie,t[77]=Le,t[78]=Re):Re=t[78];let ze=Re,Ve;t[79]!==r||t[80]!==n?(Ve=n&&r?{providerID:n,modelID:r}:null,t[79]=r,t[80]=n,t[81]=Ve):Ve=t[81];let He=Ve,Ue;t[82]!==r||t[83]!==l||t[84]!==n||t[85]!==_?(Ue=n&&r?`${n}/${r}`:l||_(`settings.agents.modelSelector.notSelected`),t[82]=r,t[83]=l,t[84]=n,t[85]=_,t[86]=Ue):Ue=t[86];let We=Ue,Ge;t[87]!==_||t[88]!==i||t[89]!==z?(Ge=z?i||_(`chat.modelControls.default`):null,t[87]=_,t[88]=i,t[89]=z,t[90]=Ge):Ge=t[90];let Ke=Ge,qe;t[91]!==r||t[92]!==n||t[93]!==i||t[94]!==z?(qe=(e,t)=>{if(!(!z||e!==n||t!==r))return i||void 0},t[91]=r,t[92]=n,t[93]=i,t[94]=z,t[95]=qe):qe=t[95];let Je=qe,Ye;t[96]!==E||t[97]!==a||t[98]!==z?(Ye=(e,t,n)=>{a(e,t,z?n??``:void 0),E(e,t,z&&n||void 0),B()},t[96]=E,t[97]=a,t[98]=z,t[99]=Ye):Ye=t[99];let Xe=Ye,Ze;t[100]!==ue||t[101]!==_||t[102]!==i||t[103]!==z?(Ze=(e,t)=>{let n=ue(e);if(!z||n.length===0)return null;let r=e.variant!==void 0&&n.includes(e.variant)?e.variant:void 0,a=t.isSelected?i:r??``;return(0,Z.jsxs)(`button`,{type:`button`,className:`flex min-h-9 shrink-0 items-center gap-0.5 rounded-md px-1.5 typography-micro font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground`,onClick:t=>{t.preventDefault(),t.stopPropagation(),se(e)},"aria-label":_(`chat.modelControls.showThinkingModes`),children:[(0,Z.jsx)(`span`,{className:`max-w-24 truncate`,children:a||_(`chat.modelControls.default`)}),(0,Z.jsx)(G,{name:`arrow-right-s`,className:`size-3.5`})]})},t[100]=ue,t[101]=_,t[102]=i,t[103]=z,t[104]=Ze):Ze=t[104];let Qe=Ze,$e=ne?`max-h-none flex-1`:void 0,et=m&&(ne?M:ie),tt;t[105]===T?tt=t[106]:(tt=e=>T(e.providerID,e.modelID),t[105]=T,t[106]=tt);let nt;t[107]!==r||t[108]!==n||t[109]!==ee||t[110]!==i?(nt=e=>ee(e.providerID,e.modelID,e.providerID===n&&e.modelID===r?i||void 0:e.variant),t[107]=r,t[108]=n,t[109]=ee,t[110]=i,t[111]=nt):nt=t[111];let rt;t[112]!==c||t[113]!==s||t[114]!==A||t[115]!==S||t[116]!==me||t[117]!==he||t[118]!==w||t[119]!==ze||t[120]!==D||t[121]!==x||t[122]!==j||t[123]!==Qe||t[124]!==L||t[125]!==He||t[126]!==$e||t[127]!==et||t[128]!==tt||t[129]!==nt?(rt=(0,Z.jsx)(Fe,{providers:x,providerOrder:D,favoriteModels:A,recentModels:j,getMetadata:S,searchQuery:L,onSearchQueryChange:oe,onSelect:me,labels:ze,selectedModel:He,hiddenModels:w,allowedProviderIds:s,allowedModelIdsByProvider:c,includeNotSelected:!0,onSelectNone:he,onEscape:B,maxHeightClassName:$e,tooltipsEnabled:et,isFavorite:tt,onToggleFavorite:nt,renderRowEnd:Qe}),t[112]=c,t[113]=s,t[114]=A,t[115]=S,t[116]=me,t[117]=he,t[118]=w,t[119]=ze,t[120]=D,t[121]=x,t[122]=j,t[123]=Qe,t[124]=L,t[125]=He,t[126]=$e,t[127]=et,t[128]=tt,t[129]=nt,t[130]=rt):rt=t[130];let it=rt,at;t[131]!==ue||t[132]!==R?(at=R?ue(R):[],t[131]=ue,t[132]=R,t[133]=at):at=t[133];let ot=at,q;bb0:{if(!R){q=``;break bb0}if(R.providerID===n&&R.modelID===r){q=i||``;break bb0}q=R.variant!==void 0&&ot.includes(R.variant)?R.variant:``}let J=q,Y;t[134]!==_e||t[135]!==_||t[136]!==R||t[137]!==J||t[138]!==ot?(Y=R?(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`flex min-h-11 items-center gap-2 border-b border-border/40 px-3 text-left typography-ui-label font-medium text-foreground hover:bg-interactive-hover`,onClick:()=>se(null),"aria-label":_(`header.actions.backAria`),children:[(0,Z.jsx)(G,{name:`arrow-left`,className:`size-4`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:R.modelID})]}),(0,Z.jsx)(`div`,{className:`space-y-1 p-2`,role:`listbox`,"aria-label":_(`chat.modelControls.thinking`),children:[``,...ot].map(e=>{let t=J===e;return(0,Z.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,className:H(`flex min-h-11 w-full items-center justify-between rounded-lg px-3 text-left typography-ui-label transition-colors`,t?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),onClick:()=>_e(e),children:[(0,Z.jsx)(`span`,{className:`truncate`,children:e||_(`chat.modelControls.default`)}),t?(0,Z.jsx)(G,{name:`check`,className:`size-4 shrink-0`}):null]},e||`__default`)})})]}):null,t[134]=_e,t[135]=_,t[136]=R,t[137]=J,t[138]=ot,t[139]=Y):Y=t[139];let X=Y||it;if(ne){let e=v?P:void 0,a=!v,l=!v&&`opacity-60 cursor-not-allowed`,u;t[140]!==o||t[141]!==l?(u=H(`flex w-full items-center justify-between gap-2 rounded-lg border border-border/40 bg-[var(--surface-elevated)] px-2 py-1.5 text-left`,l,o),t[140]=o,t[141]=l,t[142]=u):u=t[142];let d;t[143]!==v||t[144]!==y||t[145]!==r||t[146]!==n||t[147]!==g||t[148]!==_?(d=v?g&&(n||r)?(0,Z.jsx)(Pe,{modelId:r,providerId:n,className:`h-3.5 w-3.5 flex-shrink-0`}):g?(0,Z.jsx)(G,{name:`pencil-ai`,className:`h-3 w-3 text-muted-foreground`}):null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(G,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:_(y?`common.unavailable`:`common.loading`)})]}),t[143]=v,t[144]=y,t[145]=r,t[146]=n,t[147]=g,t[148]=_,t[149]=d):d=t[149];let f;t[150]!==v||t[151]!==We?(f=v?(0,Z.jsx)(`span`,{className:`typography-meta font-medium text-foreground truncate`,children:We}):null,t[150]=v,t[151]=We,t[152]=f):f=t[152];let p;t[153]!==v||t[154]!==Ke?(p=v&&Ke?(0,Z.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground`,children:Ke}):null,t[153]=v,t[154]=Ke,t[155]=p):p=t[155];let m;t[156]!==d||t[157]!==f||t[158]!==p?(m=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[d,f,p]}),t[156]=d,t[157]=f,t[158]=p,t[159]=m):m=t[159];let h;t[160]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(G,{name:`arrow-down-s`,className:`h-3 w-3 flex-shrink-0 text-muted-foreground`}),t[160]=h):h=t[160];let b;t[161]!==e||t[162]!==a||t[163]!==u||t[164]!==m?(b=(0,Z.jsxs)(`button`,{type:`button`,onClick:e,disabled:a,className:u,children:[m,h]}),t[161]=e,t[162]=a,t[163]=u,t[164]=m,t[165]=b):b=t[165];let C;t[166]!==A||t[167]!==r||t[168]!==n||t[169]!==j||t[170]!==ee||t[171]!==i?(C=(e,t)=>ee(e,t,e===n&&t===r?i||void 0:A.find(n=>n.providerID===e&&n.modelID===t)?.variant??j.find(n=>n.providerID===e&&n.modelID===t)?.variant),t[166]=A,t[167]=r,t[168]=n,t[169]=j,t[170]=ee,t[171]=i,t[172]=C):C=t[172];let E;t[173]!==c||t[174]!==s||t[175]!==A||t[176]!==S||t[177]!==Xe||t[178]!==w||t[179]!==T||t[180]!==M||t[181]!==r||t[182]!==n||t[183]!==D||t[184]!==x||t[185]!==j||t[186]!==Je||t[187]!==C||t[188]!==z?(E=(0,Z.jsx)(Er,{open:M,onClose:B,selectedProviderID:n,selectedModelID:r,resolveSelectedVariant:Je,onSelect:Xe,providers:x,favoriteModels:A,recentModels:j,getMetadata:S,hiddenModels:w,allowedProviderIds:s,allowedModelIdsByProvider:c,providerOrder:D,variantSelectionEnabled:z,isFavorite:T,onToggleFavorite:C}),t[173]=c,t[174]=s,t[175]=A,t[176]=S,t[177]=Xe,t[178]=w,t[179]=T,t[180]=M,t[181]=r,t[182]=n,t[183]=D,t[184]=x,t[185]=j,t[186]=Je,t[187]=C,t[188]=z,t[189]=E):E=t[189];let O;return t[190]!==b||t[191]!==E?(O=(0,Z.jsxs)(Z.Fragment,{children:[b,E]}),t[190]=b,t[191]=E,t[192]=O):O=t[192],O}let st=v&&ie,ct=v?I:void 0,lt=!v&&`opacity-60 cursor-not-allowed`,ut;t[193]!==o||t[194]!==lt?(ut=H(`border-input data-[placeholder]:text-muted-foreground flex min-w-0 items-center justify-between gap-2 rounded-lg border bg-transparent px-2 py-2 typography-ui-label whitespace-nowrap shadow-none outline-none hover:bg-interactive-hover data-[popup-open]:bg-interactive-active h-6 w-fit`,lt,o),t[193]=o,t[194]=lt,t[195]=ut):ut=t[195];let dt;t[196]!==v||t[197]!==y||t[198]!==r||t[199]!==n||t[200]!==g||t[201]!==_||t[202]!==We||t[203]!==Ke?(dt=v?(0,Z.jsxs)(Z.Fragment,{children:[g?n||r?(0,Z.jsx)(Pe,{modelId:r,providerId:n,className:`h-3.5 w-3.5 flex-shrink-0`}):(0,Z.jsx)(G,{name:`pencil-ai`,className:`h-3.5 w-3.5 flex-shrink-0 text-muted-foreground`}):null,(0,Z.jsx)(`span`,{className:`typography-ui-label min-w-0 flex-1 truncate text-left font-normal text-foreground`,children:We}),Ke?(0,Z.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground`,children:Ke}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(G,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin text-muted-foreground flex-shrink-0`}),(0,Z.jsx)(`span`,{className:`typography-ui-label font-normal whitespace-nowrap text-muted-foreground`,children:_(y?`common.unavailable`:`common.loading`)})]}),t[196]=v,t[197]=y,t[198]=r,t[199]=n,t[200]=g,t[201]=_,t[202]=We,t[203]=Ke,t[204]=dt):dt=t[204];let ft;t[205]===Symbol.for(`react.memo_cache_sentinel`)?(ft=(0,Z.jsx)(G,{name:`arrow-down-s`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground/50`}),t[205]=ft):ft=t[205];let pt;t[206]!==ut||t[207]!==dt?(pt=(0,Z.jsx)(Yn,{asChild:!0,children:(0,Z.jsxs)(`div`,{className:ut,children:[dt,ft]})}),t[206]=ut,t[207]=dt,t[208]=pt):pt=t[208];let mt;t[209]!==h||t[210]!==X?(mt=(0,Z.jsx)(Xn,{className:`w-[min(380px,calc(100vw-2rem))] p-0 flex flex-col`,align:`start`,portalToBody:h,children:X}),t[209]=h,t[210]=X,t[211]=mt):mt=t[211];let ht;return t[212]!==st||t[213]!==ct||t[214]!==pt||t[215]!==mt?(ht=(0,Z.jsxs)(Jn,{open:st,onOpenChange:ct,children:[pt,mt]}),t[212]=st,t[213]=ct,t[214]=pt,t[215]=mt,t[216]=ht):ht=t[216],ht};function Ir(e){return e.providers}function Lr(e){return e.getModelMetadata}function Rr(e){return e.isMobile}function zr(e){return e.hiddenModels}function Br(e){return e.toggleFavoriteModel}function Vr(e){return e.isFavoriteModel}function Hr(e){return e.addRecentModel}function Ur(e){return e.providerOrder}var Wr=e(E(),1),Gr=`mobile-overlay-root`,Kr=16,qr=200,Jr=[],Yr=0,Xr=``,Zr=0,Qr=()=>{if(typeof document>`u`)return null;let e=document.getElementById(Gr);return e||(e=document.createElement(`div`),e.id=Gr,document.body.appendChild(e)),e},$r=({open:e,title:t,onClose:n,children:r,footer:i,className:a,contentMaxHeightClassName:o,renderHeader:s,containedBody:c=!1,closeAriaLabel:l})=>{let u=Q.useRef(null),d=Q.useRef(Symbol(`mobile-overlay`)),f=Q.useRef(n);f.current=n;let[p,m]=Q.useState(!1),[h,g]=Q.useState(!1);if(typeof document<`u`&&!u.current&&(u.current=Qr()),Q.useEffect(()=>{if(!e){m(!1),g(!1);return}let t=window.setTimeout(()=>m(!0),Kr),n=window.setTimeout(()=>g(!0),266);return()=>{window.clearTimeout(t),window.clearTimeout(n)}},[e]),Q.useLayoutEffect(()=>{if(e)return Zr===0&&window.dispatchEvent(new Event(`oc:mobile-overlay-opened`)),Zr+=1,()=>{Zr=Math.max(0,Zr-1),Zr===0&&window.dispatchEvent(new Event(`oc:mobile-overlay-closed`))}},[e]),Q.useEffect(()=>{if(!e)return;let t=d.current;Jr.push(t),Yr===0&&(Xr=document.body.style.overflow),Yr+=1,document.body.style.overflow=`hidden`;let n=e=>{e.key===`Escape`&&Jr[Jr.length-1]===t&&f.current()};return document.addEventListener(`keydown`,n),()=>{let e=Jr.lastIndexOf(t);e>=0&&Jr.splice(e,1),Yr=Math.max(0,Yr-1),Yr===0&&(document.body.style.overflow=Xr),document.removeEventListener(`keydown`,n)}},[e]),!e||!u.current)return null;let _=o??`max-h-[min(70vh,520px)]`,v=(0,Z.jsx)(`div`,{className:H(`oc-keyboard-inset-surface fixed inset-0 z-[60] flex flex-col bg-[rgb(0_0_0_/_0.45)] transition-opacity duration-200 ease-out`,!h&&`oc-keyboard-inset-snap`,p?`opacity-100`:`opacity-0`),role:`dialog`,"aria-modal":`true`,"aria-label":t,onPointerDown:Ve,onClick:e=>{Ke(e)&&n()},children:(0,Z.jsxs)(`div`,{className:H(`mt-auto flex max-h-[calc(100dvh-0.75rem)] min-h-0 w-full flex-col rounded-t-xl border-x border-t border-border/50 bg-background pb-[max(0.5rem,var(--oc-app-bottom-safe,0px),var(--oc-safe-area-bottom,env(safe-area-inset-bottom,0px)))] shadow-none pwa-overlay-panel`,`mx-auto max-w-lg`,a),style:{transform:p?`none`:`translateY(100%)`,transition:`transform ${qr}ms cubic-bezier(0.32, 0.72, 0, 1)`},onClick:e=>e.stopPropagation(),children:[(()=>{let e=(0,Z.jsx)(`button`,{type:`button`,onClick:n,className:H(`flex items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover`,c?`size-11`:`h-8 w-8`),"aria-label":l??t,children:(0,Z.jsx)(G,{name:`close`,className:`h-4 w-4`})});return s?s(e):(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border/40`,children:[(0,Z.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:t}),e]})})(),c?(0,Z.jsx)(`div`,{className:H(`flex min-h-0 flex-1 flex-col overflow-hidden`,_),children:r}):(0,Z.jsx)(Ge,{useScrollShadow:!0,disableHorizontal:!0,preventOverscroll:!0,outerClassName:H(`min-h-0 flex-1`,_),className:`px-2 py-2 pwa-overlay-scroll`,children:r}),i?(0,Z.jsx)(`div`,{className:`shrink-0 border-t border-border/40 px-3 py-2`,children:i}):null]})});return(0,Wr.createPortal)(v,u.current)},ei=e=>e??i()?.github,ti=(e=t())=>c.github.auth(e),ni=async(e,t)=>{if(e)return e.authStatus();let n=await r(`/api/github/auth/status`,{method:`GET`,headers:{Accept:`application/json`},signal:t}),i=await n.json().catch(()=>null);if(!n.ok||!i)throw Error(i?.error||n.statusText||`Failed to load GitHub status`);return i},ri=(e,n=t())=>{let r=ei(e);return{queryKey:ti(n),queryFn:async({signal:e})=>ni(r,e),retry:2}},ii=e=>!!e&&typeof e==`object`&&`authStatus`in e,ai=e=>{let t=(0,K.c)(5),n=ii(e)?e:void 0,r=ii(e)?void 0:e?.enabled,i;t[0]===n?i=t[1]:(i=ri(n),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a={...i,enabled:r},t[2]=r,t[3]=i,t[4]=a):a=t[4],ae(a)},oi=(e=u,n=t())=>e.getQueryData(ti(n))??null,si=async(e,n,r)=>t()===r?e.fetchQuery({...ri(n,r),staleTime:0}):e.getQueryData(ti(r))??null,ci=(e=u,n,r=t())=>{e.setQueryData(ti(r),n)},li=I.define(ue),ui=ce.data.of({commentTokens:{line:`//`,block:{open:`/*`,close:`*/`}}});function di(e){let t=e.trim().toLowerCase();switch(t){case`bash`:case`sh`:case`zsh`:case`shell`:case`shellsession`:case`console`:return li;case`json`:case`jsonc`:case`json5`:return z().language;case`js`:case`javascript`:return R().language;case`jsx`:return R({jsx:!0}).language;case`ts`:case`typescript`:return R({typescript:!0}).language;case`tsx`:return R({typescript:!0,jsx:!0}).language;case`html`:return se().language;case`css`:return oe().language;case`py`:case`python`:return le().language;case`md`:case`markdown`:case`mdown`:case`mkd`:return B().language;case`heex`:case`eex`:case`leex`:return se().language;default:return L.matchLanguageName(Xe,t,!0)}}var fi=e=>e.split(`/`).pop()?.toLowerCase()??``,pi=e=>{let t=fi(e);return t?L.matchFilename(Xe,t):null},mi=()=>N(F.define([{tag:[P.heading1,P.heading2,P.heading3,P.heading4,P.heading5,P.heading6],fontWeight:`600`},{tag:P.strong,fontWeight:`600`},{tag:P.emphasis,fontStyle:`italic`},{tag:P.strikethrough,textDecoration:`line-through`},{tag:[P.link,P.url],color:`var(--markdown-link, currentColor)`,textDecoration:`underline`},{tag:P.monospace,color:`var(--markdown-inline-code, currentColor)`,backgroundColor:`var(--markdown-inline-code-bg, transparent)`},{tag:P.quote,color:`var(--markdown-blockquote, currentColor)`,fontStyle:`italic`},{tag:P.list,color:`color-mix(in srgb, var(--muted-foreground) 40%, var(--foreground) 60%)`},{tag:P.heading,color:`var(--markdown-heading1, currentColor)`}]));function hi(e){let t=e.toLowerCase();switch(fi(t)){case`makefile`:case`gnumakefile`:return li}let n=t.lastIndexOf(`.`),r=n>=0?t.slice(n+1):``;switch(r){case`ts`:case`tsx`:case`mts`:case`cts`:return R({typescript:!0,jsx:r===`tsx`});case`js`:case`jsx`:case`mjs`:case`cjs`:return R({typescript:!1,jsx:r===`jsx`});case`jsonc`:case`json5`:return[z(),ui];case`json`:case`jsonl`:case`ndjson`:case`geojson`:return z();case`css`:case`scss`:case`sass`:case`less`:return oe();case`html`:case`htm`:case`xml`:case`drawio`:case`dio`:return se();case`md`:case`mdx`:case`markdown`:case`mdown`:case`mkd`:return[B({codeLanguages:di}),mi()];case`sh`:case`bash`:case`zsh`:case`fish`:case`env`:return li;case`py`:case`pyw`:case`pyi`:return le();default:return null}}async function gi(e){let t=pi(e);if(!t)return null;if(t.support)return t.support;try{return await t.load()}catch{return null}}var _i=e=>e===`allow`||e===`deny`||e===`ask`;function vi(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function yi(e){return vi(e)?typeof e.action==`string`&&typeof e.resource==`string`&&_i(e.effect)?{action:e.action,resource:e.resource,effect:e.effect}:typeof e.permission==`string`&&typeof e.pattern==`string`&&_i(e.action)?{action:e.permission,resource:e.pattern,effect:e.action}:null:null}function bi(e){if(Array.isArray(e))return e.flatMap(e=>{let t=yi(e);return t?[t]:[]});if(_i(e))return[{action:`*`,resource:`*`,effect:e}];if(!vi(e))return[];let t=[];for(let[n,r]of Object.entries(e))if(n!==`__originalKeys`){if(_i(r)){t.push({action:n,resource:`*`,effect:r});continue}if(vi(r))for(let[e,i]of Object.entries(r))_i(i)&&t.push({action:n,resource:e,effect:i})}return t}function xi(e){return bi(e)}var Si=60,Ci=400;function wi(e){let t=e.replace(/\s+/g,` `).trim();if(!t)return[];let n=t.match(/[^.!?…]+[.!?…]+["')\]]*\s*|[^.!?…]+$/g)??[t],r=[],i=``;for(let e of n)for(let t=0;t<e.length;t+=Ci){let n=e.slice(t,t+Ci);i&&i.length+n.length>Ci&&(r.push(i.trim()),i=``),i+=n,i.length>=Si&&/[.!?…]["')\]]*\s*$/.test(i)&&(r.push(i.trim()),i=``)}if(i.trim()&&r.push(i.trim()),r.length>0&&r[0].length>120){let e=r[0],t=/[,;:]\s/g,n=-1,i;for(;(i=t.exec(e))!==null;){let e=i.index+1;if(!(e<40)){if(e>160)break;n=e;break}}if(n>0){let t=e.slice(0,n).trim(),i=e.slice(n).trim();r.splice(0,1,t,i)}}return r}var Ti=null;function Ei(){return Ti||=new(window.AudioContext||window.webkitAudioContext),Ti}function Di(){let[e,t]=(0,Q.useState)(!1),[n,i]=(0,Q.useState)(null),a=(0,Q.useRef)(null),o=(0,Q.useRef)(null),s=(0,Q.useCallback)(async()=>{try{let e=Ei();e.state===`suspended`&&await e.resume();let t=e.createBuffer(1,1,22050),n=e.createBufferSource();n.buffer=t,n.connect(e.destination),n.start(0)}catch{}},[]),c=(0,Q.useCallback)(()=>{let e=o.current;if(e&&(e.cancelled=!0,e.abort.abort(),o.current=null),a.current){try{a.current.onended=null,a.current.stop()}catch{}a.current=null}t(!1)},[]),l=(0,Q.useCallback)(async(e,n)=>{c();let s=wi(e);if(s.length===0){i(`No text to speak`),n?.onError?.(`No text to speak`);return}i(null);let l={cancelled:!1,abort:new AbortController};o.current=l;let u=async e=>{let t=await r(`/api/dictation/tts/speak`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e,...typeof n?.speakerId==`number`?{speakerId:n.speakerId}:{},...typeof n?.speed==`number`?{speed:n.speed}:{}}),signal:l.abort.signal});if(!t.ok){let e=await t.json().catch(()=>({error:`Unknown error`}));throw Error(e.error||`HTTP ${t.status}`)}return(await t.blob()).arrayBuffer()},d=async e=>{let t=Ei();t.state===`suspended`&&await t.resume();let n=await t.decodeAudioData(e);l.cancelled||await new Promise(e=>{let r=t.createBufferSource();r.buffer=n,r.connect(t.destination),a.current=r,r.onended=()=>{a.current===r&&(a.current=null),e()},r.start(0)})};try{t(!0),n?.onStart?.();let e=u(s[0]);for(let t=0;t<s.length;t+=1){let n=await e;if(l.cancelled||(t+1<s.length&&(e=u(s[t+1])),await d(n),l.cancelled))return}t(!1),n?.onEnd?.()}catch(e){if(e.name===`AbortError`||l.cancelled)return;let r=e instanceof Error?e.message:`Failed to speak`;i(r),n?.onError?.(r),t(!1)}finally{o.current===l&&(o.current=null)}},[c]);return(0,Q.useEffect)(()=>()=>{c()},[c]),{isPlaying:e,error:n,speak:l,stop:c,unlockAudio:s}}var Oi=new class{recognition=null;isListening=!1;currentLang=`en-US`;onResultCallback=null;onErrorCallback=null;restartOnEnd=!1;conversationMode=!1;isSpeaking=!1;audioContext=null;audioUnlockRequired=!1;isSupported(){let e=`SpeechRecognition`in window||`webkitSpeechRecognition`in window,t=`speechSynthesis`in window;return e&&t}getSupportDetails(){return{recognition:`SpeechRecognition`in window||`webkitSpeechRecognition`in window,synthesis:`speechSynthesis`in window,prefixed:!(`SpeechRecognition`in window)&&`webkitSpeechRecognition`in window,secureContext:window.isSecureContext}}setConversationMode(e){this.conversationMode=e,e||(this.restartOnEnd=!1)}isConversationMode(){return this.conversationMode}pauseListening(){if(this.restartOnEnd=!1,this.recognition)try{this.recognition.stop()}catch{}this.isListening=!1}resumeListening(){if(this.conversationMode,this.onResultCallback,this.isSpeaking,this.currentLang,this.conversationMode&&this.onResultCallback&&!this.isSpeaking)try{this.startListeningSync(this.currentLang,this.onResultCallback,this.onErrorCallback||void 0)}catch(e){console.error(`[BrowserVoiceService] Failed to resume listening:`,e)}}async checkMicrophonePermission(){try{return`permissions`in navigator&&(await navigator.permissions.query({name:`microphone`})).state===`granted`}catch{return!1}}async prepareListening(){if(!this.isSupported())throw Error(`Web Speech API not supported in this browser`);if(typeof navigator>`u`||typeof navigator.mediaDevices?.getUserMedia!=`function`)return!0;try{return(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(e=>e.stop()),!0}catch(e){let t=typeof e==`object`&&e&&`name`in e?String(e.name):``;if(t===`NotAllowedError`)throw Error(`Microphone permission denied`);if(t===`NotFoundError`)throw Error(`No microphone found`);let n=e instanceof Error?e.message:`Unable to access microphone`;throw Error(n)}}startListeningSync(e,t,n){if(!this.isSupported()){let e=`Web Speech API not supported in this browser`;throw n?.(e),Error(e)}this.stopListening();let r=window.SpeechRecognition||window.webkitSpeechRecognition;if(!r){let e=`Web Speech API not supported in this browser`;throw n?.(e),Error(e)}let i=new r;this.recognition=i,this.currentLang=e,this.onResultCallback=t,this.onErrorCallback=n||null,i.continuous=!0,i.interimResults=!0,i.lang=e,i.onstart=()=>{this.isListening=!0,this.restartOnEnd=!0},i.onaudiostart=()=>{},i.onsoundstart=()=>{},i.onresult=e=>{e.results.length;let t=``,n=``;for(let r=e.resultIndex;r<e.results.length;r++){let i=e.results[r];i.isFinal?t+=i[0].transcript:n+=i[0].transcript}n&&this.onResultCallback?.(n,!1),t&&this.onResultCallback?.(t,!0)},i.onerror=e=>{if(e.error===`aborted`)return;let t=this.getErrorMessage(e.error);this.onErrorCallback?.(t),(e.error===`not-allowed`||e.error===`service-not-allowed`||e.error===`network`)&&(this.restartOnEnd=!1,this.isListening=!1)},i.onend=()=>{if(this.isListening=!1,this.restartOnEnd&&this.recognition&&!this.isSpeaking)try{this.recognition.start()}catch{}};try{i.start()}catch(e){let t=e instanceof Error?e.message:`Failed to start speech recognition`;throw n?.(t),Error(t)}}async startListening(e,t,n){this.startListeningSync(e,t,n)}stopListening(){if(this.restartOnEnd=!1,this.recognition){try{this.recognition.stop()}catch{}this.recognition=null}this.isListening=!1}getIsListening(){return this.isListening}getCurrentLang(){return this.currentLang}async resumeAudioContext(){this.audioContext||=new(window.AudioContext||window.webkitAudioContext),this.audioContext.state===`suspended`&&await this.audioContext.resume()}isAudioUnlockRequired(){return this.audioUnlockRequired}async unlockAudio(){try{let e=new Audio;if(e.src=`data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA`,e.volume=.01,await e.play(),await this.resumeAudioContext(),this.isMobileDevice()&&`speechSynthesis`in window){let e=new SpeechSynthesisUtterance(``);e.volume=0,window.speechSynthesis.speak(e),window.speechSynthesis.cancel()}return this.audioUnlockRequired=!1,!0}catch(e){return console.error(`[BrowserVoiceService] Failed to unlock audio:`,e),!1}}async speakText(e,t,n,r){if(!(`speechSynthesis`in window))throw Error(`Speech synthesis not supported`);await this.resumeAudioContext();let i=await this.waitForVoices();await new Promise(e=>setTimeout(e,50)),this.isSpeaking=!0,this.pauseListening(),window.speechSynthesis.cancel();let a=new SpeechSynthesisUtterance(e);a.lang=t,a.rate=r?.rate??1,a.pitch=r?.pitch??1,a.volume=r?.volume??1;let o=null;return r?.voiceName&&(o=i.find(e=>e.name===r.voiceName)||null,o?`${o.name}${o.lang}`:console.warn(`[BrowserVoiceService] Selected voice "${r.voiceName}" not found, falling back to language match`)),o||(o=this.findBestVoice(i,t),o?`${o.name}${o.lang}`:console.warn(`[BrowserVoiceService] No voice found for language: ${t}, using default`)),o&&(a.voice=o),`${e.length}${t}`,new Promise((e,t)=>{let r=!1;a.onstart=()=>{r=!0,e()},a.onend=()=>{this.isSpeaking=!1,n?.()},a.onerror=e=>{this.isSpeaking=!1,console.error(`[BrowserVoiceService] Speech synthesis error:`,e.error),(e.error===`not-allowed`||e.error===`interrupted`)&&(this.audioUnlockRequired=!0);let n=`Speech synthesis error: ${e.error||`unknown`}`;e.error===`not-allowed`?n=`Audio blocked by browser autoplay policy. Please interact with the page first.`:e.error===`interrupted`&&(n=`Speech was interrupted. Please try again.`),t(Error(n))},setTimeout(()=>{r||(console.warn(`[BrowserVoiceService] Speech start timeout - audio may be blocked`),this.audioUnlockRequired=!0)},2e3),window.speechSynthesis.speak(a)})}cancelSpeech(){`speechSynthesis`in window&&window.speechSynthesis.cancel()}getVoices(){return`speechSynthesis`in window?window.speechSynthesis.getVoices():[]}async waitForVoices(){if(!(`speechSynthesis`in window))return[];let e=window.speechSynthesis.getVoices();return e.length>0?e:new Promise(e=>{let t=()=>{e(window.speechSynthesis.getVoices()),window.speechSynthesis.onvoiceschanged=null};window.speechSynthesis.onvoiceschanged=t,setTimeout(()=>{e(window.speechSynthesis.getVoices()),window.speechSynthesis.onvoiceschanged=null},1e3)})}findBestVoice(e,t){let n=e.find(e=>e.lang===t);if(!n){let r=t.split(`-`)[0];n=e.find(e=>e.lang.startsWith(r))}return n||=e.find(e=>e.lang.startsWith(t.split(`-`)[0])&&e.localService),n||null}isMobileDevice(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent.toLowerCase();return/iphone|ipad|ipod|android|mobile|webos|blackberry|iemobile|opera mini/i.test(e)}isIOSSafari(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent.toLowerCase(),t=/iphone|ipad|ipod/i.test(e),n=/safari/i.test(e)&&!/chrome|crios|crmo/i.test(e);return t&&n}getErrorMessage(e){let t=this.isMobileDevice(),n=this.isIOSSafari();return{"no-speech":`No speech detected`,aborted:`Speech recognition aborted`,"audio-capture":`No microphone found`,network:`Network error - check connection`,"not-allowed":t?`Microphone permission denied. Check Settings > Safari > Microphone`:`Microphone permission denied`,"service-not-allowed":n?`Speech recognition requires a user gesture. Please tap the microphone button again.`:`Speech recognition service not allowed`,"bad-grammar":`Grammar error`,"language-not-supported":`Language not supported`}[e]||`Speech recognition error: ${e}`}},ki=e=>{if(e===`12h`)return!0;if(e===`24h`)return!1},Ai=(e,t,n={})=>{let r=e instanceof Date?e:new Date(e);return Number.isFinite(r.getTime())?r.toLocaleTimeString(V(),{hour:n.hour??`numeric`,minute:`2-digit`,second:n.precision===`second`?`2-digit`:void 0,hour12:ki(t)}):n.fallback??``},ji=(e,t,n)=>{let r=e instanceof Date?e:new Date(e);return Number.isFinite(r.getTime())?r.toLocaleString(V(),{...n,hour12:n.hour?ki(t):n.hour12}):``},$=e=>_e(ge.getState().dictionary,e),Mi=e=>typeof e!=`number`||!Number.isFinite(e)?null:Math.max(0,Math.min(100,Math.round(e))),Ni=e=>typeof e!=`number`||!Number.isFinite(e)?`-`:`${Math.round(e)}%`,Pi=(e,t)=>e??Ni(t),Fi=(e,t,n=`auto`)=>{if(!e)return t??``;try{let r=new Date(e);if(!Number.isFinite(r.getTime()))return t??``;let i=new Date;return r.toDateString()===i.toDateString()?Ai(r,n,{fallback:t??``}):ji(r,n,{month:`short`,day:`numeric`,weekday:`short`,hour:`numeric`,minute:`2-digit`})}catch{return t??``}},Ii=e=>e===null?`safe`:e>=80?`critical`:e>=50?`warn`:`safe`,Li=e=>e===`5h`?$(`quota.window.5h`):e===`7d`?$(`quota.window.7d`):e===`7d-sonnet`?$(`quota.window.7dSonnet`):e===`7d-opus`?$(`quota.window.7dOpus`):e===`weekly`?$(`quota.window.weekly`):e===`daily`?$(`quota.window.daily`):e===`monthly`?$(`quota.window.monthly`):e===`credits`?$(`quota.window.credits`):e===`credits_balance`?$(`quota.window.creditsBalance`):e===`billing_cycle`?$(`quota.window.billingCycle`):e===`auto`?$(`quota.window.auto`):e===`api`?$(`quota.window.api`):e===`plan_limit`?$(`quota.window.planLimit`):e===`on_demand`?$(`quota.window.onDemand`):e===`session`?$(`quota.window.session`):e===`premium`?$(`quota.window.premium`):e===`chat`?$(`quota.window.chat`):e===`completions`?$(`quota.window.completions`):e===`premium_interactions`?$(`quota.window.premiumInteractions`):e,Ri=e=>{let t=e.toLowerCase().trim();if(t===`5h`)return 18e3;if(t===`7d`||t===`weekly`||t===`7d-sonnet`||t===`7d-opus`)return 604800;if(t===`monthly`)return 2592e3;if(t===`24h`||t===`daily`)return 86400;if(t===`1h`)return 3600;let n=t.match(/^(\d+)h$/);if(n)return parseInt(n[1],10)*3600;let r=t.match(/^(\d+)d$/);return r?parseInt(r[1],10)*86400:null},zi=(e,t,n,r)=>{let i=n;if(i===null&&r&&(i=Ri(r)),e===null||t===null||i===null||i<=0)return null;let a=Math.max(0,(t-Date.now())/1e3),o=Math.max(0,Math.min(i,i-a)),s=Math.max(0,Math.min(1,o/i)),c=e/100,l=e>=100&&a>0,u;u=s>.01?Math.min(999,c/s*100):e;let d;d=l?`exhausted`:c<=s?`on-track`:u<=130?`slightly-fast`:`too-fast`;let f=i>=432e3,p=f?86400:3600,m=f?`d`:`h`,h=i/p,g=e/Math.max(o/p,h*.01),_=Number.isFinite(g)?`${Math.min(999.9,Math.max(0,g)).toFixed(1)}%/${m}`:`-`,v=u>100?`+${Math.round(u)}%`:`${Math.round(u)}%`,y=null,b=i/86400;return b>=7&&(y=100/b),{elapsedRatio:s,usageRatio:c,predictedFinalPercent:u,remainingSeconds:a,isExhausted:l,elapsedSeconds:o,totalSeconds:i,status:d,paceRateText:_,predictText:v,dailyAllocationPercent:y}},Bi=e=>{switch(e){case`exhausted`:case`too-fast`:return`var(--status-error)`;case`slightly-fast`:return`var(--status-warning)`;case`on-track`:return`var(--status-success)`}},Vi=e=>{let t=Math.floor(Math.max(0,Math.floor(e))/60),n=Math.floor(t/60),r=Math.floor(n/24),i=n%24,a=t%60;return r>0?`${r}d ${i}h`:n>0?`${n}h`:t===0?`<1m`:`${a}m`},Hi=e=>Math.min(100,Math.max(0,e*100)),Ui=(e,t)=>_e(ge.getState().dictionary,e,t),Wi=e=>{let t=new Date(e),n=new Date,r=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),i=new Date(n);return i.setDate(n.getDate()-1),r(t,n)?Ui(`common.date.today`):r(t,i)?Ui(`common.date.yesterday`):t.toLocaleDateString(V(),{month:`short`,day:`numeric`,year:`numeric`}).replace(`,`,``)},Gi=e=>{let t=new Date;if(((e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate())(new Date(e),t)){let t=Date.now()-e;return t<6e4?Ui(`common.relative.justNow`):t<36e5?Ui(`common.relative.minutesAgoShort`,{count:Math.floor(t/6e4)}):Ui(`common.relative.hoursAgoShort`,{count:Math.floor(t/36e5)})}return Wi(e)},Ki=e=>{let t=Math.max(0,Date.now()-e),n=6e4,r=60*n,i=24*r,a=7*i,o=365*i;return t<r?Ui(`common.relative.minutesAgoCompact`,{count:Math.max(1,Math.floor(t/n))}):t<i?Ui(`common.relative.hoursAgoCompact`,{count:Math.floor(t/r)}):t<a?Ui(`common.relative.daysAgoCompact`,{count:Math.floor(t/i)}):t<5*a?Ui(`common.relative.weeksAgoCompact`,{count:Math.floor(t/a)}):t<o?Ui(`common.relative.monthsAgoCompact`,{count:Math.floor(t/2592e6)}):Ui(`common.relative.yearsAgoCompact`,{count:Math.floor(t/o)})},qi=(e,t)=>Ji(l(e),l(t)),Ji=(e,t)=>!e||!t?!1:e===t?!0:t===`/`?e.startsWith(`/`):e.startsWith(`${t}/`),Yi=e=>e.toLowerCase().replace(/^opencode[/-]?/i,``).replace(/[-_]/g,``).trim(),Xi=(e,t)=>e?Yi(e)!==Yi(t):!1,Zi=e=>{if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`string`&&e.trim().length>0){let t=Number(e);if(Number.isFinite(t))return t}},Qi=e=>Zi(e.time?.created)??0,$i=(e,t,n)=>{let r=n.has(e.id),i=n.has(t.id);return r===i?r&&i?Qi(t)-Qi(e):Ce(t)-Ce(e):r?-1:1},ea=e=>{let t=new Map;return e.forEach(e=>{t.set(e.id,e)}),Array.from(t.values())},ta=e=>`__archived__:${e}`,na=(e,t)=>{let n=l(e.directory??null),r=l(e.project?.worktree??null),i=n??r;if(!i)return`unassigned`;if(t&&i===t)return`project root`;let a=(t&&i.startsWith(`${t}/`)?i.slice(t.length+1):i).split(`/`).filter(Boolean);return a[a.length-1]??`unassigned`},ra=`box-border w-full px-2 py-1.5 text-left typography-micro text-muted-foreground/70 select-none`,ia=`bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] dark:bg-[color-mix(in_srgb,var(--surface-foreground)_11%,transparent)]`,aa=`hover:bg-[color-mix(in_srgb,var(--surface-foreground)_3.5%,transparent)] dark:hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)]`,oa=e=>{let t=Math.max(0,e);return t===0?8:30+(t-1)*14},sa=(e,t)=>{if(!t)return e;let n=e.toLowerCase(),r=t.toLowerCase(),i=r.length;if(i===0)return e;let a=[],o=0,s=n.indexOf(r,o);for(;s!==-1;){s>o&&a.push(e.slice(o,s));let t=e.slice(s,s+i);a.push((0,Z.jsx)(`mark`,{className:`bg-primary text-primary-foreground ring-1 ring-primary/90`,children:t},`${s}-${t}`)),o=s+i,s=n.indexOf(r,o)}return o<e.length&&a.push(e.slice(o)),a.length>0?a:e},ca=`/api/browser-providers`,la=`/api/browser-providers/selection`,ua=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/,da=200,fa=e=>`/api/browser-providers/${encodeURIComponent(e)}/surface/ws`,pa=e=>!!e&&typeof e==`object`&&!Array.isArray(e),ma=e=>typeof e==`string`&&ua.test(e)?e:null,ha=e=>{if(!pa(e))return null;let t=ma(e.id),n=typeof e.name==`string`?e.name.trim():``;return!t||!n||n.length>da?null:{id:t,name:n,surface:e.surface===!0}},ga=e=>{if(!pa(e)||!Array.isArray(e.providers))return null;let t=[],n=new Set;for(let r of e.providers){let e=ha(r);!e||n.has(e.id)||(n.add(e.id),t.push(e))}let r=ma(e.selectedId);return{providers:t,selectedId:r&&n.has(r)?r:null}},_a=e=>{if(!pa(e))return null;let t=ma(e.selectedId);return t?{selectedId:t}:null},va=e=>e?.selectedId?e.providers.find(t=>t.id===e.selectedId)??null:null,ya=e=>!!(e&&e.providers.length>0),ba=e=>va(e)!==null,xa=e=>typeof e==`number`&&Number.isFinite(e),Sa=e=>{if(!pa(e)||typeof e.type!=`string`)return null;if(e.type===`hello`&&typeof e.viewerId==`string`&&e.viewerId.length>0)return{type:`hello`,viewerId:e.viewerId};if(e.type===`frame`){let t=e.mime===`image/jpeg`||e.mime===`image/png`?e.mime:null;if(!t||!xa(e.seq)||!xa(e.width)||!xa(e.height)||!xa(e.bytes)||e.bytes<1||typeof e.agentActive!=`boolean`)return null;let n=typeof e.title==`string`?e.title:void 0;return{type:`frame`,seq:e.seq,width:e.width,height:e.height,mime:t,bytes:e.bytes,title:n,agentActive:e.agentActive}}if(e.type===`control`){let t=e.controller===`none`||e.controller===`agent`||e.controller===`user`?e.controller:null;return!t||typeof e.mine!=`boolean`?null:{type:`control`,controller:t,mine:e.mine}}return e.type===`resized`&&xa(e.width)&&xa(e.height)?{type:`resized`,width:e.width,height:e.height}:e.type===`error`&&typeof e.code==`string`&&typeof e.message==`string`?{type:`error`,code:e.code,message:e.message}:e.type===`ended`&&(e.reason===`service-stopped`||e.reason===`extension-unavailable`||e.reason===`host-shutdown`)?{type:`ended`,reason:e.reason}:null},Ca=class extends Error{status;constructor(e){super(`browser_provider_request_failed:${e}`),this.name=`BrowserProviderRequestError`,this.status=e}},wa=(e=t())=>c.browserProviders.catalog(e),Ta=async e=>{let t=await e.text();if(!t)return null;try{return JSON.parse(t)}catch{return null}},Ea=async e=>{let t=await r(ca,{method:`GET`,headers:{Accept:`application/json`},signal:e}),n=await Ta(t);if(!t.ok)throw new Ca(t.status);let i=ga(n);if(!i)throw new Ca(t.status||502);return i},Da=(e=t())=>({queryKey:wa(e),queryFn:({signal:e})=>Ea(e),staleTime:5e3,refetchOnWindowFocus:!0,refetchInterval:e=>{let t=e.state.error;return t instanceof Ca&&(t.status===404||t.status===501)?!1:15e3}}),Oa=()=>{let e=(0,K.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=Da(),e[0]=t):t=e[0],ae(t)},ka=(e=u,n=t())=>e.getQueryData(wa(n))??null,Aa=(e,t)=>e?.providers.some(e=>e.id===t)?{providers:e.providers,selectedId:t}:null,ja=async(e,n=u,i)=>{let a=t(),o=await r(la,{method:`PUT`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({id:e}),signal:i}),s=await Ta(o);if(!o.ok)throw new Ca(o.status);let c=_a(s);if(!c||c.selectedId!==e||t()!==a)throw new Ca(o.status||502);let l=Aa(n.getQueryData(wa(a)),c.selectedId);if(!l)throw new Ca(409);return l},Ma=()=>{let e=(0,K.c)(2),n=M(),r;return e[0]===n?r=e[1]:(r={mutationFn:e=>ja(e,n),onMutate:async e=>{let r=t(),i=wa(r);await n.cancelQueries({queryKey:i});let a=n.getQueryData(i),o=Aa(a,e);return o&&n.setQueryData(i,o),{previous:a,key:i,transport:r}},onError:(e,r,i)=>{!i||t()!==i.transport||n.setQueryData(i.key,i.previous)},onSuccess:(e,r,i)=>{!i||t()!==i.transport||n.setQueryData(i.key,e)}},e[0]=n,e[1]=r),re(r)},Na=[`standalone`,`minimal-ui`,`fullscreen`,`window-controls-overlay`],Pa=`openchamber.pwaRecentSessions`,Fa=e=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(display-mode: ${e})`).matches,Ia=()=>typeof window>`u`?`browser`:typeof document<`u`&&document.referrer.startsWith(`android-app://`)?`twa`:window.navigator.standalone?`standalone`:Na.find(e=>Fa(e))??`browser`,La=864e5,Ra=5,za=864e5,Ba=e=>e.time?.updated??e.time?.created??0,Va=({sessions:e,currentSessionId:t,cutoffDays:n,keepRecent:r=Ra,now:i=Date.now()})=>{if(!Array.isArray(e)||n<=0)return[];let a=i-n*La,o=[...e].sort((e,t)=>Ba(t)-Ba(e)),s=new Set(o.slice(0,r).map(e=>e.id));return o.filter(e=>{if(!e?.id||s.has(e.id)||e.id===t||e.share)return!1;let n=Ba(e);return n?n<a:!1}).map(e=>e.id)},Ha=e=>{let t=typeof e==`object`?e:void 0,n=t?.autoRun!==!1,r=typeof e==`boolean`?e:t?.enabled??!0,i=xe(e=>e.currentSessionId),a=xe(e=>e.isLoading),o=W(e=>e.activeSessions),s=W(e=>e.hasLoadedFullCatalog),c=k(e=>e.autoDeleteEnabled),l=k(e=>e.autoDeleteAfterDays),u=k(e=>e.sessionRetentionAction),d=k(e=>e.autoDeleteLastRunAt),f=k(e=>e.setAutoDeleteLastRunAt),[p,m]=Q.useState(!1),h=Q.useRef(!1);Q.useEffect(()=>{if(!r||!n||!c||l<=0)return;let e=window.setTimeout(()=>{Se(O())},8e3);return()=>window.clearTimeout(e)},[l,c,n,r]);let g=Q.useMemo(()=>l<=0?[]:Va({sessions:o,currentSessionId:i,cutoffDays:l}),[l,i,o]),_=Q.useCallback(async({force:e=!1}={})=>{if(h.current)return{completedIds:[],failedIds:[],action:u,skippedReason:`running`};if((!c||l<=0)&&!e)return{completedIds:[],failedIds:[],action:u,skippedReason:`disabled`};if(a)return{completedIds:[],failedIds:[],action:u,skippedReason:`loading`};let t=Date.now();if(!e&&d&&t-d<za)return{completedIds:[],failedIds:[],action:u,skippedReason:`cooldown`};let{activeSessions:n}=await Se(O());if(n.length===0)return{completedIds:[],failedIds:[],action:u,skippedReason:`no-candidates`};let r=Va({sessions:n,currentSessionId:i,cutoffDays:l,now:t});if(r.length===0)return f(t),{completedIds:[],failedIds:[],action:u,skippedReason:`no-candidates`};h.current=!0,m(!0);try{let e=new Map(n.map(e=>[e.id,e])),t=[],i=[];for(let n of r){let r=e.get(n),a=r?Te(r):null;if(!a){i.push(n);continue}try{u===`archive`?await D.updateSession(n,{time:{archived:Date.now()}},a):await D.deleteSession(n,a),t.push(n)}catch{i.push(n)}}return u===`archive`?W.getState().archiveSessions(t):W.getState().removeSessions(t),{completedIds:t,failedIds:i,action:u}}finally{h.current=!1,m(!1),f(Date.now())}},[l,c,d,i,a,u,f]);return Q.useEffect(()=>{r&&n&&(!c||l<=0||a||!s||o.length===0||d&&Date.now()-d<za||_())},[l,c,d,n,r,s,o.length,a,_]),{candidates:g,isRunning:p,runCleanup:_,keepRecentCount:Ra,action:u}};export{Sr as $,St as $t,Vi as A,on as At,di as B,Kt as Bt,sa as C,Cn as Ct,Mi as D,bn as Dt,zi as E,yn as Et,Ai as F,fn as Ft,ci as G,gt as Gt,gi as H,Wt as Ht,Oi as I,_n as It,Fr as J,yt as Jt,ai as K,bt as Kt,Di as L,gn as Lt,Bi as M,hn as Mt,Ii as N,dn as Nt,Fi as O,pn as Ot,ji as P,ln as Pt,xr as Q,wt as Qt,xi as R,Zt as Rt,Yi as S,Nn as St,Hi as T,xn as Tt,oi as U,Ut,hi as V,Ht as Vt,si as W,Tt as Wt,_r as X,vt as Xt,Er as Y,_t as Yt,br as Z,Ct as Zt,Gi as _,Bn as _t,Oa as a,rt as an,Zn as at,Xi as b,Vn as bt,Sa as c,$n as ct,ra as d,wn as dt,It as en,yr as et,ia as f,Hn as ft,Ki as g,zn as gt,ea as h,Rn as ht,ka as i,Rt as in,Xn as it,Li as j,mn as jt,Pi as k,un as kt,ba as l,tr as lt,$i as m,In as mt,Pa as n,Ft as nn,nr as nt,Ma as o,it as on,er as ot,aa as p,Wn as pt,$r as q,xt as qt,Ia as r,Lt as rn,Jn as rt,fa as s,at as sn,Qn as st,Ha as t,Pt as tn,sr as tt,ya as u,Yn as ut,ta as v,Un as vt,na as w,vn as wt,qi as x,jn as xt,oa as y,Ln as yt,bi as z,qt as zt};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
var e=Object.defineProperty,t=e=>e;function n(e,n){this[e]=t.bind(null,n)}var r=(t,r)=>{for(var i in r)e(t,i,{get:r[i],enumerable:!0,configurable:!0,set:n.bind(r,i)})},i={};r(i,{SharedEvents:()=>i,make:()=>a});function a(e){let t,n=4096;function r(e){e.connected=void 0,e.controller.abort(),t===e&&(t=void 0)}async function i(t){let n,i={};try{if(t.controller.signal.aborted)return;for(n=e(t.controller.signal,()=>{t.subscribers.forEach(e=>e.activity?.())})[Symbol.asyncIterator]();!t.controller.signal.aborted;){let e=await n.next();if(e.done||t.controller.signal.aborted)break;e.value.type===`server.connected`&&(t.connected=e.value),t.subscribers.forEach(t=>t.push(e.value))}}catch(e){i={error:e}}finally{r(t);try{await n?.return?.()}catch(e){`error`in i||(i={error:e})}t.subscribers.forEach(e=>e.finish(i))}}return{subscribe(e){return{[Symbol.asyncIterator](){let a=[],o=[],s=!1,c,l;function u(t,n=!0){c=t,n&&(o.length=0),e?.signal?.removeEventListener(`abort`,d),l?.subscribers.delete(f)&&!l.subscribers.size&&r(l),a.splice(0).forEach(e=>{`error`in t?e.reject(t.error):e.resolve({done:!0,value:void 0})})}function d(){u({})}let f={activity:e?.onActivity,finish(e){u(e,!1)},push(e){if(c)return;let t=a.shift();if(t){t.resolve({done:!1,value:e});return}if(o.length===n){u({error:Error(`Event subscriber exceeded its ${n}-event capacity`)});return}o.push(e)}};function p(){if(c)return;let e=!t;l=t??{controller:new AbortController,subscribers:new Set},t=l,l.subscribers.add(f),l.connected&&f.push(l.connected),e&&i(l)}return{next(){let t=o.shift();if(t)return Promise.resolve({done:!1,value:t});if(c)return`error`in c?Promise.reject(c.error):Promise.resolve({done:!0,value:void 0});if(e?.signal?.aborted)return d(),Promise.resolve({done:!0,value:void 0});let n=Promise.withResolvers();return a.push(n),s||(s=!0,e?.signal?.addEventListener(`abort`,d,{once:!0}),p()),n.promise},return(){return u({}),Promise.resolve({done:!0,value:void 0})}}}}}}}var o=class extends Error{reason;name=`ClientError`;constructor(e,t){super(e,t),this.reason=e}};r({},{make:()=>c});var s=16777216;function c(e){let t=e.fetch??globalThis.fetch,n=(t,n)=>{let r=new URL(e.baseUrl);r.pathname.endsWith(`/`)||(r.pathname+=`/`);let i=new URL(t.path.slice(1),r);for(let[e,n]of Object.entries(t.query??{}))u(i.searchParams,e,n);let a=new Headers(e.headers);for(let[e,n]of Object.entries(t.headers??{}))n!=null&&a.set(e,String(n));for(let[e,t]of new Headers(n?.headers))a.set(e,t);return t.body!==void 0&&!a.has(`content-type`)&&a.set(`content-type`,t.binaryBody?`application/octet-stream`:`application/json`),{url:i,init:{method:t.method,signal:n?.signal,headers:a,body:t.body===void 0?void 0:t.binaryBody?t.body:JSON.stringify(t.body)}}},r=async(e,r)=>{try{let i=n(e,r);return await t(i.url,i.init)}catch(e){throw new o(`Transport`,{cause:e})}},i=async(e,t)=>{if(t.declaredStatuses.includes(e.status))throw f(await d(e));try{await e.body?.cancel()}catch{}throw new o(`UnexpectedStatus`,{cause:{status:e.status}})},a=async(e,t)=>{let n=await r(e,t);if(n.status!==e.successStatus)return i(n,e);if(e.binary)return new Uint8Array(await n.arrayBuffer());if(e.empty){try{await n.body?.cancel()}catch{}return}return await d(n)},c=(e,t)=>({async*[Symbol.asyncIterator](){let n=await r(e,t);if(n.status!==e.successStatus&&await i(n,e),!p(n,`text/event-stream`)){try{await n.body?.cancel()}catch{}throw new o(`UnsupportedContentType`)}if(n.body===null)throw new o(`MalformedResponse`);let a=n.body.getReader(),c=new TextDecoder,l=``;try{for(;;){let e;try{e=await a.read()}catch(e){throw new o(`Transport`,{cause:e})}if(e.done||t?.onActivity?.(),l+=c.decode(e.value,{stream:!e.done}),l.length>s)throw new o(`SseEventTooLarge`);let n=!e.done&&l.endsWith(`\r`);n&&(l=l.slice(0,-1)),l=l.replaceAll(`\r
|
|
2
|
-
`,`
|
|
3
|
-
`).replaceAll(`\r`,`
|
|
4
|
-
`),n&&(l+=`\r`),e.done&&l!==``&&(l+=`
|
|
5
|
-
|
|
6
|
-
`);let r=l.indexOf(`
|
|
7
|
-
|
|
8
|
-
`);for(;r>=0;){let e=l.slice(0,r);l=l.slice(r+2);let t=e.split(`
|
|
9
|
-
`).flatMap(e=>e.startsWith(`data:`)?[e.slice(5).trimStart()]:[]).join(`
|
|
10
|
-
`);if(t!==``)try{yield JSON.parse(t)}catch(e){throw new o(`MalformedResponse`,{cause:e})}r=l.indexOf(`
|
|
11
|
-
|
|
12
|
-
`)}if(e.done)return}}finally{try{await a.cancel()}catch{}a.releaseLock()}}});return{server:{info:e=>a({method:`GET`,path:`/api/info`,successStatus:200,declaredStatuses:[400,401],empty:!1},e)},location:{get:(e,t)=>a({method:`GET`,path:`/api/location`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401],empty:!1},t),reload:e=>a({method:`POST`,path:`/api/location/reload`,successStatus:204,declaredStatuses:[400,401,503],empty:!0},e)},agent:{list:(e,t)=>a({method:`GET`,path:`/api/agent`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/agent/${encodeURIComponent(e.agentID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},plugin:{list:(e,t)=>a({method:`GET`,path:`/api/plugin`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401],empty:!1},t),check:(e,t)=>a({method:`POST`,path:`/api/plugin/check`,query:{location:e?.location},body:{target:e?.target},successStatus:200,declaredStatuses:[400,401],empty:!1},t),update:(e,t)=>a({method:`POST`,path:`/api/plugin/update`,query:{location:e.location},body:{targets:e.targets},successStatus:204,declaredStatuses:[400,401,503],empty:!0},t)},session:{list:(e,t)=>a({method:`GET`,path:`/api/session`,query:{limit:e?.limit,order:e?.order,search:e?.search,parentID:e?.parentID,directory:e?.directory,project:e?.project,subpath:e?.subpath,cursor:e?.cursor},successStatus:200,declaredStatuses:[400,401],empty:!1},t),stats:(e,t)=>a({method:`GET`,path:`/api/experimental/session/stats`,query:{from:e?.from,to:e?.to,project:e?.project,timezone:e?.timezone,tools:e?.tools},successStatus:200,declaredStatuses:[400,401],empty:!1},t).then(e=>e.data),create:(e,t)=>a({method:`POST`,path:`/api/session`,body:{id:e?.id,title:e?.title,agent:e?.agent,model:e?.model,location:e?.location,metadata:e?.metadata,permissions:e?.permissions},successStatus:200,declaredStatuses:[400,401],empty:!1},t).then(e=>e.data),import:(e,t)=>a({method:`POST`,path:`/api/experimental/session/import`,body:{info:e.info,messages:e.messages,location:e.location},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),export:(e,t)=>a({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/export`,query:{sanitize:e.sanitize},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t).then(e=>e.data),active:e=>a({method:`GET`,path:`/api/session/active`,successStatus:200,declaredStatuses:[400,401],empty:!1},e).then(e=>e.data),get:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),remove:(e,t)=>a({method:`DELETE`,path:`/api/session/${encodeURIComponent(e.sessionID)}`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),fork:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/fork`,body:{before:e.before},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),switchAgent:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/agent`,body:{agent:e.agent},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),switchModel:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/model`,body:{model:e.model},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),update:(e,t)=>a({method:`PATCH`,path:`/api/session/${encodeURIComponent(e.sessionID)}`,body:{title:e.title,metadata:e.metadata,permissions:e.permissions},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),move:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/move`,body:{directory:e.directory,delivery:e.delivery},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),prompt:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/prompt`,body:{id:e.id,text:e.text,files:e.files,agents:e.agents,skills:e.skills,metadata:e.metadata,delivery:e.delivery,resume:e.resume},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),command:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/command`,body:{name:e.name,text:e.text,files:e.files,agents:e.agents,skills:e.skills,delivery:e.delivery},successStatus:204,declaredStatuses:[400,401,404,500],empty:!0},t),skill:(e,t)=>a({method:`POST`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/skill`,body:{id:e.id,resume:e.resume},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),synthetic:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/synthetic`,body:{id:e.id,text:e.text,description:e.description,metadata:e.metadata,delivery:e.delivery,resume:e.resume},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),shell:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/shell`,body:{id:e.id,command:e.command},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),compact:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/compact`,body:{id:e.id,delivery:e.delivery},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),wait:(e,t)=>a({method:`POST`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/wait`,successStatus:204,declaredStatuses:[400,401,404,503],empty:!0},t),revert:{stage:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/revert/stage`,body:{messageID:e.messageID,files:e.files},successStatus:200,declaredStatuses:[400,401,404,409,500],empty:!1},t).then(e=>e.data),clear:(e,t)=>a({method:`DELETE`,path:`/api/session/${encodeURIComponent(e.sessionID)}/revert`,successStatus:204,declaredStatuses:[400,401,404,409,500],empty:!0},t),commit:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/revert/commit`,successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},t)},context:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/context`,successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t).then(e=>e.data),diff:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/diff`,query:{from:e.from,to:e.to,context:e.context},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t).then(e=>e.data),inbox:{list:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/inbox`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),cancel:(e,t)=>a({method:`DELETE`,path:`/api/session/${encodeURIComponent(e.sessionID)}/inbox/${encodeURIComponent(e.inboxID)}`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),update:(e,t)=>a({method:`PATCH`,path:`/api/session/${encodeURIComponent(e.sessionID)}/inbox/${encodeURIComponent(e.inboxID)}`,body:{delivery:e.delivery},successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},t)},instructions:{entry:{list:(e,t)=>a({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/instructions/entries`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),put:(e,t)=>a({method:`PUT`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/instructions/entries/${encodeURIComponent(e.key)}`,body:{value:e.value},successStatus:204,declaredStatuses:[400,401,404,413],empty:!0},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/instructions/entries/${encodeURIComponent(e.key)}`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)}},generate:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/generate`,body:{prompt:e.prompt},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data),log:(e,t)=>c({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/log`,query:{after:e.after,follow:e.follow},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),interrupt:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/interrupt`,query:{resume:e.resume},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),background:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/background`,successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),message:{get:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/message/${encodeURIComponent(e.messageID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data)},form:{list:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),create:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form`,body:{id:e.id,title:e.title,metadata:e.metadata,fields:e.fields},successStatus:200,declaredStatuses:[400,401,404,409],empty:!1},t).then(e=>e.data),get:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form/${encodeURIComponent(e.formID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),reply:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form/${encodeURIComponent(e.formID)}/reply`,body:{answer:e.answer},successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},t),cancel:(e,t)=>a({method:`DELETE`,path:`/api/session/${encodeURIComponent(e.sessionID)}/form/${encodeURIComponent(e.formID)}`,successStatus:204,declaredStatuses:[400,401,404,409],empty:!0},t)},environment:(e,t)=>a({method:`PUT`,path:`/api/session/${encodeURIComponent(e.sessionID)}/environment`,body:{variables:e.variables},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),view:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/view`,body:{idle:e.idle},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},message:{list:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/message`,query:{limit:e.limit,order:e.order,cursor:e.cursor,type:e.type},successStatus:200,declaredStatuses:[400,401,404,500],empty:!1},t)},model:{list:(e,t)=>a({method:`GET`,path:`/api/model`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,503],empty:!1},t),default:(e,t)=>a({method:`GET`,path:`/api/model/default`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,503],empty:!1},t)},generate:{text:(e,t)=>a({method:`POST`,path:`/api/experimental/generate`,body:{prompt:e.prompt,model:e.model},successStatus:200,declaredStatuses:[400,401,503],empty:!1},t).then(e=>e.data)},provider:{list:(e,t)=>a({method:`GET`,path:`/api/provider`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,503],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/provider/${encodeURIComponent(e.providerID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t)},integration:{list:(e,t)=>a({method:`GET`,path:`/api/integration`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/integration/${encodeURIComponent(e.integrationID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),wellknown:{add:(e,t)=>a({method:`POST`,path:`/api/experimental/integration/wellknown`,query:{location:e.location},body:{url:e.url},successStatus:204,declaredStatuses:[400,401],empty:!0},t)},connect:{key:(e,t)=>a({method:`POST`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/key`,query:{location:e.location},body:{key:e.key,answer:e.answer,label:e.label},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},oauth:{connect:(e,t)=>a({method:`POST`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth`,query:{location:e.location},body:{methodID:e.methodID,answer:e.answer,label:e.label},successStatus:200,declaredStatuses:[400,401],empty:!1},t),status:(e,t)=>a({method:`GET`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),complete:(e,t)=>a({method:`POST`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth/${encodeURIComponent(e.attemptID)}/complete`,query:{location:e.location},body:{code:e.code},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),cancel:(e,t)=>a({method:`DELETE`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401],empty:!0},t)},command:{connect:(e,t)=>a({method:`POST`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/command`,query:{location:e.location},body:{methodID:e.methodID,label:e.label},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),status:(e,t)=>a({method:`GET`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/command/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),cancel:(e,t)=>a({method:`DELETE`,path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/command/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401],empty:!0},t)}},mcp:{list:(e,t)=>a({method:`GET`,path:`/api/mcp`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401],empty:!1},t),add:(e,t)=>a({method:`PUT`,path:`/api/experimental/mcp/${encodeURIComponent(e.server)}`,query:{location:e.location},body:{config:e.config},successStatus:204,declaredStatuses:[400,401],empty:!0},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/experimental/mcp/${encodeURIComponent(e.server)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),connect:(e,t)=>a({method:`POST`,path:`/api/experimental/mcp/${encodeURIComponent(e.server)}/connect`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),disconnect:(e,t)=>a({method:`POST`,path:`/api/experimental/mcp/${encodeURIComponent(e.server)}/disconnect`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),resource:{catalog:(e,t)=>a({method:`GET`,path:`/api/mcp/resource`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401],empty:!1},t)}},credential:{update:(e,t)=>a({method:`PATCH`,path:`/api/credential/${encodeURIComponent(e.credentialID)}`,body:{label:e.label},successStatus:204,declaredStatuses:[400,401],empty:!0},t),activate:(e,t)=>a({method:`POST`,path:`/api/credential/${encodeURIComponent(e.credentialID)}/activate`,successStatus:204,declaredStatuses:[400,401],empty:!0},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/credential/${encodeURIComponent(e.credentialID)}`,successStatus:204,declaredStatuses:[400,401],empty:!0},t)},project:{list:e=>a({method:`GET`,path:`/api/project`,successStatus:200,declaredStatuses:[400,401],empty:!1},e),update:(e,t)=>a({method:`PATCH`,path:`/api/project/${encodeURIComponent(e.projectID)}`,body:{canonical:e.canonical,name:e.name,icon:e.icon,commands:e.commands},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t)},form:{list:(e,t)=>a({method:`GET`,path:`/api/form`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401],empty:!1},t)},permission:{request:{list:(e,t)=>a({method:`GET`,path:`/api/permission/request`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401],empty:!1},t)},saved:{list:(e,t)=>a({method:`GET`,path:`/api/permission/saved`,query:{projectID:e?.projectID},successStatus:200,declaredStatuses:[400,401],empty:!1},t).then(e=>e.data),remove:(e,t)=>a({method:`DELETE`,path:`/api/permission/saved/${encodeURIComponent(e.id)}`,successStatus:204,declaredStatuses:[400,401],empty:!0},t)},create:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/permission`,body:{id:e.id,action:e.action,resources:e.resources,save:e.save,metadata:e.metadata,source:e.source,agent:e.agent},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),list:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/permission`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),get:(e,t)=>a({method:`GET`,path:`/api/session/${encodeURIComponent(e.sessionID)}/permission/${encodeURIComponent(e.requestID)}`,successStatus:200,declaredStatuses:[400,401,404],empty:!1},t).then(e=>e.data),reply:(e,t)=>a({method:`POST`,path:`/api/session/${encodeURIComponent(e.sessionID)}/permission/${encodeURIComponent(e.requestID)}/reply`,body:{decision:e.decision,message:e.message},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},file:{read:(e,t)=>a({method:`GET`,path:`/api/fs/read/${l(e.path)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1,binary:!0},t),list:(e,t)=>a({method:`GET`,path:`/api/fs/list`,query:{location:e?.location,path:e?.path},successStatus:200,declaredStatuses:[400,401],empty:!1},t),find:(e,t)=>a({method:`GET`,path:`/api/fs/find`,query:{location:e.location,query:e.query,type:e.type,limit:e.limit},successStatus:200,declaredStatuses:[400,401],empty:!1},t),write:(e,t)=>a({method:`POST`,path:`/api/experimental/fs/write`,query:{location:e.location,path:e.path},body:e.payload,successStatus:200,declaredStatuses:[400,401],empty:!1,binaryBody:!0},t)},command:{list:(e,t)=>a({method:`GET`,path:`/api/command`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401],empty:!1},t)},skill:{list:(e,t)=>a({method:`GET`,path:`/api/skill`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401],empty:!1},t)},rpc:{call:(e,t)=>a({method:`POST`,path:`/api/rpc/${encodeURIComponent(e.rpcID)}/${encodeURIComponent(e.method)}`,query:{location:e.location},body:{input:e.input},successStatus:200,declaredStatuses:[400,401,500],empty:!1},t)},event:{subscribe:e=>c({method:`GET`,path:`/api/event`,successStatus:200,declaredStatuses:[400,401],empty:!1},e)},pty:{list:(e,t)=>a({method:`GET`,path:`/api/pty`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401],empty:!1},t),create:(e,t)=>a({method:`POST`,path:`/api/pty`,query:{location:e?.location},body:{command:e?.command,args:e?.args,cwd:e?.cwd,title:e?.title,env:e?.env},successStatus:200,declaredStatuses:[400,401],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/pty/${encodeURIComponent(e.ptyID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),update:(e,t)=>a({method:`PUT`,path:`/api/pty/${encodeURIComponent(e.ptyID)}`,query:{location:e.location},body:{title:e.title,size:e.size},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/pty/${encodeURIComponent(e.ptyID)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),connect:{token:(e,t)=>a({method:`POST`,path:`/api/pty/${encodeURIComponent(e.ptyID)}/connect-token`,query:{location:e.location},headers:{"x-opencode-ticket":e[`x-opencode-ticket`]},successStatus:200,declaredStatuses:[400,401,403,404],empty:!1},t)}},experimental:{persistentPty:{read:(e,t)=>a({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/terminal/read`,query:{lines:e.lines},successStatus:200,declaredStatuses:[400,401,503],empty:!1},t).then(e=>e.data),list:(e,t)=>a({method:`GET`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/terminal`,successStatus:200,declaredStatuses:[400,401,503],empty:!1},t).then(e=>e.data),create:(e,t)=>a({method:`POST`,path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/terminal`,body:{command:e.command,args:e.args,cwd:e.cwd,title:e.title,env:e.env,size:e.size},successStatus:200,declaredStatuses:[400,401,503],empty:!1},t).then(e=>e.data),shutdown:e=>a({method:`POST`,path:`/api/experimental/persistent-pty/shutdown`,successStatus:204,declaredStatuses:[400,401,503],empty:!0},e),handoff:e=>a({method:`POST`,path:`/api/experimental/persistent-pty/handoff`,successStatus:200,declaredStatuses:[400,401,503],empty:!1},e),get:(e,t)=>a({method:`GET`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}`,successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data),update:(e,t)=>a({method:`PUT`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}`,body:{attachmentID:e.attachmentID,size:e.size},successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data),snapshot:(e,t)=>a({method:`GET`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}/snapshot`,successStatus:200,declaredStatuses:[400,401,404,503],empty:!1},t).then(e=>e.data),remove:(e,t)=>a({method:`DELETE`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}`,successStatus:204,declaredStatuses:[400,401,404,503],empty:!0},t),connectToken:(e,t)=>a({method:`POST`,path:`/api/experimental/persistent-pty/${encodeURIComponent(e.ptyID)}/connect-token`,headers:{"x-opencode-ticket":e[`x-opencode-ticket`]},successStatus:200,declaredStatuses:[400,401,403,404,503],empty:!1},t).then(e=>e.data)}},shell:{list:(e,t)=>a({method:`GET`,path:`/api/shell`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401],empty:!1},t),create:(e,t)=>a({method:`POST`,path:`/api/shell`,query:{location:e.location},body:{command:e.command,cwd:e.cwd,timeout:e.timeout,metadata:e.metadata},successStatus:200,declaredStatuses:[400,401],empty:!1},t),get:(e,t)=>a({method:`GET`,path:`/api/shell/${encodeURIComponent(e.id)}`,query:{location:e.location},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),output:(e,t)=>a({method:`GET`,path:`/api/shell/${encodeURIComponent(e.id)}/output`,query:{location:e.location,cursor:e.cursor,limit:e.limit},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/shell/${encodeURIComponent(e.id)}`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401],empty:!0},t)},reference:{list:(e,t)=>a({method:`GET`,path:`/api/reference`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401],empty:!1},t)},worktree:{list:(e,t)=>a({method:`GET`,path:`/api/worktree`,query:{projectID:e.projectID},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),create:(e,t)=>a({method:`POST`,path:`/api/worktree`,body:{projectID:e.projectID,from:e.from,branch:e.branch,directory:e.directory,name:e.name},successStatus:200,declaredStatuses:[400,401,404],empty:!1},t),remove:(e,t)=>a({method:`DELETE`,path:`/api/worktree`,body:{projectID:e.projectID,directory:e.directory,force:e.force},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t),refresh:(e,t)=>a({method:`POST`,path:`/api/worktree/refresh`,body:{projectID:e.projectID},successStatus:204,declaredStatuses:[400,401,404],empty:!0},t)},vcs:{get:(e,t)=>a({method:`GET`,path:`/api/vcs`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401],empty:!1},t),base:(e,t)=>a({method:`GET`,path:`/api/vcs/base`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,503],empty:!1},t),status:(e,t)=>a({method:`GET`,path:`/api/vcs/status`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401],empty:!1},t),branch:{list:(e,t)=>a({method:`GET`,path:`/api/vcs/branch`,query:{location:e?.location,search:e?.search,limit:e?.limit},successStatus:200,declaredStatuses:[400,401],empty:!1},t)},diff:(e,t)=>a({method:`GET`,path:`/api/vcs/diff`,query:{location:e.location,mode:e.mode,base:e.base,context:e.context},successStatus:200,declaredStatuses:[400,401,503],empty:!1},t)},debug:{location:{list:e=>a({method:`GET`,path:`/api/debug/location`,successStatus:200,declaredStatuses:[400,401],empty:!1},e),evict:(e,t)=>a({method:`DELETE`,path:`/api/debug/location`,query:{location:e?.location},successStatus:204,declaredStatuses:[400,401],empty:!0},t)}},migration:{v1:{status:e=>a({method:`GET`,path:`/api/experimental/migration/v1`,successStatus:200,declaredStatuses:[400,401],empty:!1},e)}},websearch:{providers:(e,t)=>a({method:`GET`,path:`/api/websearch/provider`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401,503],empty:!1},t),query:(e,t)=>a({method:`POST`,path:`/api/websearch`,query:{location:e.location},body:{query:e.query,providerID:e.providerID},successStatus:200,declaredStatuses:[400,401,503],empty:!1},t)},config:{get:(e,t)=>a({method:`GET`,path:`/api/config`,query:{location:e?.location},successStatus:200,declaredStatuses:[400,401],empty:!1},t),shells:e=>a({method:`GET`,path:`/api/config/shell`,successStatus:200,declaredStatuses:[400,401],empty:!1},e),update:(e,t)=>a({method:`PATCH`,path:`/api/experimental/config`,body:{shell:e.shell},successStatus:204,declaredStatuses:[400,401],empty:!0},t)}}}function l(e){return e.split(`/`).map(encodeURIComponent).join(`/`)}function u(e,t,n){if(n!==void 0){if(n===null){e.append(t,`null`);return}if(Array.isArray(n)){for(let r of n)u(e,t,r);return}if(typeof n==`object`){for(let[r,i]of Object.entries(n))u(e,`${t}[${r}]`,i);return}e.append(t,String(n))}}async function d(e){if(!p(e,`application/json`)&&!e.headers.get(`content-type`)?.includes(`+json`)){try{await e.body?.cancel()}catch{}throw new o(`UnsupportedContentType`)}let t;try{t=await e.text()}catch(e){throw new o(`Transport`,{cause:e})}if(t===``)throw new o(`MalformedResponse`);try{return JSON.parse(t)}catch(e){throw new o(`MalformedResponse`,{cause:e})}}function f(e){let t=Object.assign(Error(e.message??e.data?.message),e);return e._tag&&(t.name=e._tag),t}function p(e,t){return e.headers.get(`content-type`)?.split(`;`,1)[0]?.trim().toLowerCase()===t}var m=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`PermissionNotFoundError`,h=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`RpcError`,g=e=>typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`RpcInternalError`;function _(e,t){return n=>{let r=(e,r)=>{if(!Object.hasOwn(n.events,e))throw Error(`Unknown RPC event: ${n.id}.${e}`);let i=v(n,e);return{[Symbol.asyncIterator](){let e=new AbortController,n=r?.signal?AbortSignal.any([e.signal,r.signal]):e.signal,a=async function*(){try{for await(let e of t.subscribe({signal:n})){if(n.aborted)return;e.type===i&&(yield e)}}catch(e){if(!n.aborted)throw e}finally{e.abort()}}();return{next:()=>a.next(),return:()=>(e.abort(),a.return())}}}};return Object.assign(Object.fromEntries(Object.keys(n.methods).map(t=>[t,async(r,i)=>{try{return(await e.rpc.call({rpcID:n.id,method:t,input:r,location:i?.location},{signal:i?.signal,headers:i?.headers})).output}catch(e){throw!h(e)&&!g(e)?e:e.data===void 0?{type:e.type,message:e.message}:{type:e.type,message:e.message,data:e.data}}}])),{events:{subscribe:r,on:(e,t,n)=>{let i=new AbortController,a=n?.signal?AbortSignal.any([i.signal,n.signal]):i.signal,o=r(e,{signal:a});return(async()=>{for await(let e of o)await t(e)})().catch(e=>console.error(e)),()=>i.abort()}}})}}function v(e,t){return`rpc.${e.id}.${t}`}var y={};r(y,{OpenCode:()=>y,make:()=>b});function b(e){let t=c(e),n=a((e,n)=>t.event.subscribe({signal:e,onActivity:n}));return{...t,rpc:Object.assign(_(t,n),t.rpc),event:n}}export{m as n,o as r,y as t};
|
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import os from 'os';
|
|
4
|
-
import yaml from 'yaml';
|
|
5
|
-
|
|
6
|
-
const OPENCODE_CONFIG_DIR = path.join(os.homedir(), '.config', 'opencode');
|
|
7
|
-
const GLOBAL_SNIPPET_DIR = path.join(OPENCODE_CONFIG_DIR, 'snippet');
|
|
8
|
-
const GLOBAL_SNIPPET_DIR_ALT = path.join(OPENCODE_CONFIG_DIR, 'snippets');
|
|
9
|
-
const SNIPPET_EXTENSION = '.md';
|
|
10
|
-
const SNIPPET_NAME_PATTERN = /^[a-z0-9][a-z0-9_-]{0,79}$/i;
|
|
11
|
-
const HASHTAG_PATTERN = /#([a-z0-9_-]+)/gi;
|
|
12
|
-
const MAX_EXPANSION_COUNT = 15;
|
|
13
|
-
|
|
14
|
-
function getProjectSnippetDirs(workingDirectory) {
|
|
15
|
-
if (!workingDirectory) return [];
|
|
16
|
-
return [
|
|
17
|
-
path.join(workingDirectory, '.opencode', 'snippets'),
|
|
18
|
-
path.join(workingDirectory, '.opencode', 'snippet'),
|
|
19
|
-
];
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function getGlobalSnippetDirs() {
|
|
23
|
-
return [GLOBAL_SNIPPET_DIR_ALT, GLOBAL_SNIPPET_DIR];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function getLoadDirs(workingDirectory) {
|
|
27
|
-
return [
|
|
28
|
-
...getGlobalSnippetDirs().map((dir) => ({ dir, source: 'global' })),
|
|
29
|
-
...getProjectSnippetDirs(workingDirectory).map((dir) => ({ dir, source: 'project' })),
|
|
30
|
-
];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function assertValidSnippetName(name) {
|
|
34
|
-
if (typeof name !== 'string' || !SNIPPET_NAME_PATTERN.test(name)) {
|
|
35
|
-
throw new Error('Snippet name must use letters, numbers, dashes, or underscores');
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function parseMarkdownFile(filePath) {
|
|
40
|
-
const content = fs.readFileSync(filePath, 'utf8');
|
|
41
|
-
const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);
|
|
42
|
-
if (!match) {
|
|
43
|
-
return { frontmatter: {}, body: content.trim() };
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
frontmatter: yaml.parse(match[1]) || {},
|
|
47
|
-
body: match[2].trim(),
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function normalizeAliases(frontmatter) {
|
|
52
|
-
const raw = frontmatter.aliases ?? frontmatter.alias;
|
|
53
|
-
if (!raw) return [];
|
|
54
|
-
const aliases = Array.isArray(raw) ? raw : [raw];
|
|
55
|
-
return aliases.map((alias) => String(alias).trim()).filter(Boolean);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function writeMarkdownFile(filePath, { content, aliases = [], description }) {
|
|
59
|
-
const frontmatter = {};
|
|
60
|
-
const normalizedAliases = aliases.map((alias) => String(alias).trim()).filter(Boolean);
|
|
61
|
-
if (normalizedAliases.length > 0) frontmatter.aliases = normalizedAliases;
|
|
62
|
-
if (description?.trim()) frontmatter.description = description.trim();
|
|
63
|
-
|
|
64
|
-
const body = content ?? '';
|
|
65
|
-
const output = Object.keys(frontmatter).length > 0
|
|
66
|
-
? `---\n${yaml.stringify(frontmatter)}---\n${body ? `\n${body}` : ''}`
|
|
67
|
-
: body;
|
|
68
|
-
|
|
69
|
-
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
70
|
-
fs.writeFileSync(filePath, output, 'utf8');
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function loadSnippetFile(dir, filename, source) {
|
|
74
|
-
const name = path.basename(filename, SNIPPET_EXTENSION);
|
|
75
|
-
if (!SNIPPET_NAME_PATTERN.test(name)) return null;
|
|
76
|
-
const filePath = path.join(dir, filename);
|
|
77
|
-
const { frontmatter, body } = parseMarkdownFile(filePath);
|
|
78
|
-
return {
|
|
79
|
-
name,
|
|
80
|
-
content: body,
|
|
81
|
-
aliases: normalizeAliases(frontmatter),
|
|
82
|
-
description: typeof frontmatter.description === 'string' ? frontmatter.description : undefined,
|
|
83
|
-
filePath,
|
|
84
|
-
source,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function removeSnippetAliases(registry, snippet, canonicalNames) {
|
|
89
|
-
for (const alias of snippet.aliases) {
|
|
90
|
-
const aliasKey = alias.toLowerCase();
|
|
91
|
-
if (canonicalNames.has(aliasKey)) continue;
|
|
92
|
-
if (registry.get(aliasKey) === snippet) registry.delete(aliasKey);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function registerSnippet(registry, snippet, canonicalNames) {
|
|
97
|
-
const key = snippet.name.toLowerCase();
|
|
98
|
-
const existing = registry.get(key);
|
|
99
|
-
if (existing?.name.toLowerCase() === key) {
|
|
100
|
-
removeSnippetAliases(registry, existing, canonicalNames);
|
|
101
|
-
}
|
|
102
|
-
registry.set(key, snippet);
|
|
103
|
-
canonicalNames.add(key);
|
|
104
|
-
for (const alias of snippet.aliases) {
|
|
105
|
-
const aliasKey = alias.toLowerCase();
|
|
106
|
-
if (SNIPPET_NAME_PATTERN.test(alias) && !canonicalNames.has(aliasKey)) registry.set(aliasKey, snippet);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function loadSnippetRegistry(workingDirectory) {
|
|
111
|
-
const registry = new Map();
|
|
112
|
-
const canonicalNames = new Set();
|
|
113
|
-
for (const { dir, source } of getLoadDirs(workingDirectory)) {
|
|
114
|
-
if (!fs.existsSync(dir)) continue;
|
|
115
|
-
for (const filename of fs.readdirSync(dir)) {
|
|
116
|
-
if (!filename.endsWith(SNIPPET_EXTENSION)) continue;
|
|
117
|
-
try {
|
|
118
|
-
const snippet = loadSnippetFile(dir, filename, source);
|
|
119
|
-
if (snippet) registerSnippet(registry, snippet, canonicalNames);
|
|
120
|
-
} catch (error) {
|
|
121
|
-
console.warn(`[Snippets] Failed to load ${path.join(dir, filename)}:`, error);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return registry;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function listUniqueSnippets(registry) {
|
|
129
|
-
const seen = new Set();
|
|
130
|
-
const snippets = [];
|
|
131
|
-
for (const snippet of registry.values()) {
|
|
132
|
-
const key = `${snippet.source}:${snippet.filePath}`;
|
|
133
|
-
if (seen.has(key)) continue;
|
|
134
|
-
seen.add(key);
|
|
135
|
-
snippets.push(snippet);
|
|
136
|
-
}
|
|
137
|
-
return snippets.sort((a, b) => a.name.localeCompare(b.name));
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function getWritableSnippetDir(scope, workingDirectory) {
|
|
141
|
-
if (scope === 'project') {
|
|
142
|
-
if (!workingDirectory) throw new Error('Project directory is required for project snippets');
|
|
143
|
-
const preferred = path.join(workingDirectory, '.opencode', 'snippet');
|
|
144
|
-
const alternate = path.join(workingDirectory, '.opencode', 'snippets');
|
|
145
|
-
return fs.existsSync(alternate) && !fs.existsSync(preferred) ? alternate : preferred;
|
|
146
|
-
}
|
|
147
|
-
return fs.existsSync(GLOBAL_SNIPPET_DIR_ALT) && !fs.existsSync(GLOBAL_SNIPPET_DIR)
|
|
148
|
-
? GLOBAL_SNIPPET_DIR_ALT
|
|
149
|
-
: GLOBAL_SNIPPET_DIR;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function findSnippetByName(name, workingDirectory) {
|
|
153
|
-
assertValidSnippetName(name);
|
|
154
|
-
const registry = loadSnippetRegistry(workingDirectory);
|
|
155
|
-
return registry.get(name.toLowerCase()) ?? null;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function parseSnippetBlocks(content) {
|
|
159
|
-
const blocks = { prepend: [], append: [] };
|
|
160
|
-
let inline = content;
|
|
161
|
-
for (const type of ['prepend', 'append']) {
|
|
162
|
-
const regex = new RegExp(`<${type}>([\\s\\S]*?)(?:<\\/${type}>|$)`, 'gi');
|
|
163
|
-
inline = inline.replace(regex, (_match, value) => {
|
|
164
|
-
const normalized = String(value).trim();
|
|
165
|
-
if (normalized) blocks[type].push(normalized);
|
|
166
|
-
return '';
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
inline = inline.replace(/<inject>[\s\S]*?(?:<\/inject>|$)/gi, '').trim();
|
|
170
|
-
return { inline, prepend: blocks.prepend, append: blocks.append };
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
function expandText(text, registry, expansionCounts, collector) {
|
|
174
|
-
let expanded = text;
|
|
175
|
-
let changed = true;
|
|
176
|
-
|
|
177
|
-
while (changed) {
|
|
178
|
-
const previous = expanded;
|
|
179
|
-
let loopDetected = false;
|
|
180
|
-
HASHTAG_PATTERN.lastIndex = 0;
|
|
181
|
-
|
|
182
|
-
expanded = expanded.replace(HASHTAG_PATTERN, (match, name, offset, input) => {
|
|
183
|
-
if (name.toLowerCase() === 'skill' && input[offset + match.length] === '(') return match;
|
|
184
|
-
const snippet = registry.get(name.toLowerCase());
|
|
185
|
-
if (!snippet) return match;
|
|
186
|
-
|
|
187
|
-
const key = snippet.name.toLowerCase();
|
|
188
|
-
const count = (expansionCounts.get(key) || 0) + 1;
|
|
189
|
-
if (count > MAX_EXPANSION_COUNT) {
|
|
190
|
-
loopDetected = true;
|
|
191
|
-
return match;
|
|
192
|
-
}
|
|
193
|
-
expansionCounts.set(key, count);
|
|
194
|
-
|
|
195
|
-
const parsed = parseSnippetBlocks(snippet.content);
|
|
196
|
-
for (const block of parsed.prepend) collector.prepend.push(expandText(block, registry, expansionCounts, collector));
|
|
197
|
-
for (const block of parsed.append) collector.append.push(expandText(block, registry, expansionCounts, collector));
|
|
198
|
-
return expandText(parsed.inline, registry, expansionCounts, collector);
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
changed = expanded !== previous && !loopDetected;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
return expanded;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
export function listSnippets(workingDirectory) {
|
|
208
|
-
return listUniqueSnippets(loadSnippetRegistry(workingDirectory));
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
export function getSnippet(name, workingDirectory) {
|
|
212
|
-
return findSnippetByName(name, workingDirectory);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
export function createSnippet(name, config, workingDirectory, scope = 'global') {
|
|
216
|
-
assertValidSnippetName(name);
|
|
217
|
-
const dir = getWritableSnippetDir(scope, workingDirectory);
|
|
218
|
-
const filePath = path.join(dir, `${name}${SNIPPET_EXTENSION}`);
|
|
219
|
-
if (fs.existsSync(filePath)) throw new Error(`Snippet "${name}" already exists`);
|
|
220
|
-
writeMarkdownFile(filePath, config || {});
|
|
221
|
-
return getSnippet(name, workingDirectory);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
export function updateSnippet(name, updates, workingDirectory) {
|
|
225
|
-
const existing = findSnippetByName(name, workingDirectory);
|
|
226
|
-
if (!existing) throw new Error(`Snippet "${name}" not found`);
|
|
227
|
-
writeMarkdownFile(existing.filePath, { ...existing, ...(updates || {}) });
|
|
228
|
-
return getSnippet(name, workingDirectory);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
export function deleteSnippet(name, workingDirectory) {
|
|
232
|
-
const existing = findSnippetByName(name, workingDirectory);
|
|
233
|
-
if (!existing) throw new Error(`Snippet "${name}" not found`);
|
|
234
|
-
fs.unlinkSync(existing.filePath);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
export function expandSnippets(text, workingDirectory) {
|
|
238
|
-
const registry = loadSnippetRegistry(workingDirectory);
|
|
239
|
-
const collector = { prepend: [], append: [] };
|
|
240
|
-
const expanded = expandText(text || '', registry, new Map(), collector).trim();
|
|
241
|
-
return [...collector.prepend, expanded, ...collector.append].filter(Boolean).join('\n\n');
|
|
242
|
-
}
|