@openchambery/web 1.19.9 → 1.19.10-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AssistantView-DnN3m4Dp.js → AssistantView-BBCGdrHP.js} +1 -1
- package/dist/assets/{DiagramView-E3efnEX7.js → DiagramView-Bl4hBD9Q.js} +1 -1
- package/dist/assets/MarkdownRenderer-B3u13nMz.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-CdpiFWqs.js → MarkdownRendererImpl-D5gapBoS.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-BPyoNg8p.js → MarkstreamRendererImpl-B0-BRwTb.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-Cx7eDb4W.js → MobileDetailNavigation-K_D8tdQt.js} +1 -1
- package/dist/assets/{MobileShareBridge-B_go2MeO.js → MobileShareBridge-kMTuwMC5.js} +1 -1
- package/dist/assets/MobileSurface-iF2V5nla.js +2 -0
- package/dist/assets/{MultiRunWindow-DLCZOjCj.js → MultiRunWindow-DwexB9Qy.js} +1 -1
- package/dist/assets/{OnboardingScreen-C3-wzeSX.js → OnboardingScreen-DS2nugLX.js} +1 -1
- package/dist/assets/{SettingsView-C4mB0uFW.js → SettingsView-CQ1QLvr6.js} +2 -2
- package/dist/assets/{SettingsWindow-OGO76Rgi.js → SettingsWindow-FECd8wxM.js} +1 -1
- package/dist/assets/{TerminalView-Ck5P5GWU.js → TerminalView-DcMHfHtg.js} +1 -1
- package/dist/assets/{ToolOutputDialog-BenN_1If.js → ToolOutputDialog-CSb529wq.js} +1 -1
- package/dist/assets/{appThemeRegistry-DAH35eaE.js → appThemeRegistry-BFv2g9rp.js} +1 -1
- package/dist/assets/desktopHosts-Dc2PS66M.js +1 -0
- package/dist/assets/desktopRelayRestore-T9y0orqa.js +1 -0
- package/dist/assets/{gitApi-DdJQDVmv.js → gitApi-Dio9sS64.js} +1 -1
- package/dist/assets/{insertionBoundaries-DRvsnrxu.js → insertionBoundaries-nICJrO_N.js} +1 -1
- package/dist/assets/{main-CEdvbeao.js → main-CNBO8MzI.js} +2 -2
- package/dist/assets/{main-DPnPRJo9.js → main-CXS9iqzq.js} +22 -22
- package/dist/assets/{miniChat-9KRGMcES.js → miniChat-DtAiI_WP.js} +2 -2
- package/dist/assets/{mobile-CaTrLmyq.js → mobile-Z_dkmwkj.js} +2 -2
- package/dist/assets/{multirun-DZxLNwZx.js → multirun-BR5grr_M.js} +1 -1
- package/dist/assets/{projectMeta-B4mvLrV7.js → projectMeta-FU83d7PY.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-IARSnJ6n.js → renderElectronMiniChatApp-BUopzjBX.js} +2 -2
- package/dist/assets/{renderMobileApp-CvA1QBLw.js → renderMobileApp-kGq58GpN.js} +4 -4
- package/dist/assets/{runtimeConfig-CmL9jcr-.js → runtimeConfig-C8Ch7QlE.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-DUO6iUn_.js → runtimeEndpointReset-ByKPnj63.js} +1 -1
- package/dist/assets/{sessionLookup-CfllxmO1.js → sessionLookup-zfIdBJ9w.js} +1 -1
- package/dist/assets/{useAppFontEffects-COqtb3tR.js → useAppFontEffects-BH9JvmYW.js} +6 -6
- package/dist/assets/{useDesktopWindowControlsLayout-nDXj3p6q.js → useDesktopWindowControlsLayout-CLmxf8gm.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-DOU5Xg5n.js → useEffectiveDirectory-fEbYkT-1.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-BawYHSru.js → useMobileNavigationStore-CeGGCHFp.js} +1 -1
- package/dist/assets/useSessionAutoCleanup-JgEa86T5.js +1 -0
- package/dist/assets/{useWorkerHighlightedLines-Dfd5Ra8Y.js → useWorkerHighlightedLines-CTP9abTJ.js} +1 -1
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +4 -4
- package/dist/mobile.html +4 -4
- package/package.json +1 -1
- package/server/lib/assistants/DOCUMENTATION.md +21 -10
- package/server/lib/assistants/contact-store.js +90 -5
- package/server/lib/assistants/contact-store.test.js +127 -2
- package/server/lib/assistants/contact-tools.js +107 -24
- package/server/lib/assistants/contact-tools.test.js +45 -3
- package/server/lib/assistants/harness.js +15 -5
- package/server/lib/assistants/harness.test.js +65 -3
- package/server/lib/assistants/service.js +76 -10
- package/server/lib/assistants/service.test.js +270 -11
- package/server/lib/llm/DOCUMENTATION.md +6 -0
- package/server/lib/llm/generate.js +4 -1
- package/server/lib/llm/generate.test.js +6 -1
- package/server/lib/opencode/DOCUMENTATION.md +1 -0
- package/server/lib/opencode/openchamber-routes.js +3 -0
- package/server/lib/opencode/openchamber-routes.test.js +43 -0
- package/server/lib/relay/DOCUMENTATION.md +1 -0
- package/dist/assets/MarkdownRenderer-BYryAKz2.js +0 -2
- package/dist/assets/MobileSurface-ByPOhQrz.js +0 -2
- package/dist/assets/desktopHosts-CWxex1c3.js +0 -1
- package/dist/assets/desktopRelayRestore-9EbBYQ9s.js +0 -1
- package/dist/assets/useSessionAutoCleanup-R4Ke7did.js +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-capacitor-app-PzT84wSx.js","assets/rolldown-runtime-C0FnF6B9.js","assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{A as t,E as n,O as r,t as i,y as a}from"./useUIStore-CuaA8-Hp.js";import{$t as o,It as s,Lt as c,Xt as l,Yt as u,Zt as d,d as f,dn as p,en as m,et as h,kn as g,nn as _,p as v,r as y,s as b,tn as x,u as S,xn as C}from"./persistence-DdUac14I.js";import{a as w,i as T,r as E}from"./vendor-zustand-B4dlGEM2.js";import{nt as D,rt as O,tt as k}from"./vendor-base-ui-CnHfUmDN.js";import{Ct as A,Nt as j,n as M,t as N}from"./platform-B4KKLnZ5.js";import{o as P}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as F}from"./vendor-react-DLPElpoQ.js";import{s as I}from"./vendor-tanstack-react-query-D7pys_c9.js";import{t as L}from"./types-BuiqMmh_.js";import{A as R,G as ee,H as z,K as te,L as ne,P as B,Q as re,T as ie,V,W as H,X as ae,Z as oe,a as se,g as ce,ht as le,lt as ue,mt as de,pt as fe,q as pe,st as U,tt as me}from"./vendor-codemirror-autocomplete-DHomsvW7.js";import{n as W}from"./vendor-reactuses-core-DDoDDyM9.js";import{n as he,r as ge,t as _e}from"./clipboard-DJ4nQEuY.js";import{Bn as ve,In as ye,Ln as be,Pn as xe,Rn as Se,Vn as Ce,Xr as we,c as Te,dr as Ee,ho as G,ja as De,mn as Oe,mr as K}from"./useMobileNavigationStore-BawYHSru.js";import{n as ke,o as Ae,t as je}from"./dialog-CgbV5ljg.js";import{r as Me,t as q}from"./utils-BiK3tBGM.js";import{n as J}from"./Icon-BYM02QyU.js";import{n as Ne,t as Y}from"./button-C0cth9tl.js";import{L as Pe,_ as Fe,b as Ie,c as Le,n as Re,s as ze,u as Be}from"./gitApi-DdJQDVmv.js";import{Z as Ve,_ as He,a as Ue,b as We,c as Ge,h as Ke,m as qe,n as Je,r as Ye,t as Xe,x as Ze}from"./projectMeta-B4mvLrV7.js";import{t as Qe}from"./input-DFLpqjGR.js";import{i as $e,n as et,t as tt}from"./tooltip-BifLJ8o0.js";import{At as nt,C as rt,Ct as it,Dt as at,Et as ot,F as st,Ft as ct,P as lt,S as ut,St as dt,T as ft,Tt as pt,V as mt,d as ht,f as gt,l as _t,o as vt,r as yt,wt as bt,x as xt}from"./useSessionAutoCleanup-R4Ke7did.js";import{n as St}from"./useThemeSystem-DMzWVJaW.js";import{i as Ct,n as wt}from"./OverlayScrollbar-KUpvYHdv.js";import{n as Tt}from"./MarkdownRenderer-BYryAKz2.js";import{n as Et,t as Dt}from"./textarea-Cgo_nWUU.js";import{a as Ot}from"./url-Pk6tQ1EZ.js";import{r as kt}from"./markdown-worker-CTsrtpPh.js";import{n as At,r as jt,t as Mt}from"./collapsible-DFT9cE80.js";import{a as Nt,d as Pt,o as Ft,s as It}from"./vendor-codemirror-commands-C9DCaJ0C.js";import{a as Lt,c as Rt,i as zt,o as Bt,r as Vt,s as Ht}from"./vendor-codemirror-search-D2SOgzph.js";import{n as Ut,t as Wt}from"./vendor-replit-codemirror-vim-CEibx3EP.js";import{i as Gt,n as Kt,r as qt,t as Jt}from"./projectActions-CWvNGKfA.js";var Yt=[{id:`claude`,name:`Claude`},{id:`codex`,name:`Codex`},{id:`cursor`,name:`Cursor`},{id:`github-copilot`,name:`GitHub Copilot`},{id:`google`,name:`Google`},{id:`kimi-for-coding`,name:`Kimi for Coding`},{id:`nano-gpt`,name:`NanoGPT`},{id:`openrouter`,name:`OpenRouter`},{id:`zai-coding-plan`,name:`z.ai`},{id:`zhipuai-coding-plan`,name:`Zhipu AI Coding Plan`},{id:`minimax-cn-coding-plan`,name:`MiniMax Coding Plan (minimaxi.com)`},{id:`minimax-coding-plan`,name:`MiniMax Coding Plan (minimax.io)`},{id:`ollama-cloud`,name:`Ollama Cloud`},{id:`wafer`,name:`Wafer.ai`},{id:`opencode-go`,name:`OpenCode Go`},{id:`xai`,name:`Grok`}],X=F(),Z=D();function Xt(e){let t=(0,X.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(`path`,{d:`M15.688 2.343a2.588 2.588 0 00-3.61 0l-9.626 9.44a.863.863 0 01-1.203 0 .823.823 0 010-1.18l9.626-9.44a4.313 4.313 0 016.016 0 4.116 4.116 0 011.204 3.54 4.3 4.3 0 013.609 1.18l.05.05a4.115 4.115 0 010 5.9l-8.706 8.537a.274.274 0 000 .393l1.788 1.754a.823.823 0 010 1.18.863.863 0 01-1.203 0l-1.788-1.753a1.92 1.92 0 010-2.754l8.706-8.538a2.47 2.47 0 000-3.54l-.05-.049a2.588 2.588 0 00-3.607-.003l-7.172 7.034-.002.002-.098.097a.863.863 0 01-1.204 0 .823.823 0 010-1.18l7.273-7.133a2.47 2.47 0 00-.003-3.537z`}),r=(0,Z.jsx)(`path`,{d:`M14.485 4.703a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a4.115 4.115 0 000 5.9 4.314 4.314 0 006.016 0l7.12-6.982a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a2.588 2.588 0 01-3.61 0 2.47 2.47 0 010-3.54l7.12-6.982z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,Z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,fill:`currentColor`,stroke:`currentColor`,strokeWidth:`0.5`,fillRule:`evenodd`,viewBox:`-0.5 -0.5 25 25`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}var Q=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;let n=t.replace(/\\/g,`/`);return n.length>1?n.replace(/\/+$/,``):n},Zt=()=>{let e=G.getState().getActiveProject?.();return Q(e?.path)??Q(j.getDirectory())},Qt=(e,t=n())=>f.mcp.configs(e,t),$t=(e,t=n())=>f.mcp.status(e,t),en=e=>e?j.getScopedApiClient(e):j.getApiClient(),tn=(e=Zt(),t=n())=>{let r=Q(e);return{queryKey:Qt(r,t),queryFn:async({signal:e})=>{let t=r?`?directory=${encodeURIComponent(r)}`:``,n=await g(`/api/config/mcp${t}`,{headers:r?{"x-opencode-directory":r}:void 0,signal:e});if(!n.ok)throw Error(`Failed to load MCP configs`);let i=await n.json();if(!Array.isArray(i))throw Error(`Invalid MCP configs response`);return i},staleTime:5e3,retry:2}},nn=(e,t=n())=>{let r=Q(e);return{queryKey:$t(r,t),queryFn:async()=>(await en(r).mcp.status({},{throwOnError:!0})).data,staleTime:2e3,retry:1}},rn=(e,t)=>{let n=(0,X.c)(9),r;n[0]===t?r=n[1]:(r=t===void 0?{}:t,n[0]=t,n[1]=r);let i=r,a=G(un),o,s;if(n[2]!==a||n[3]!==e){let t=e===void 0?Q(a)??Q(j.getDirectory()):Q(e);s=I,o=tn(t),n[2]=a,n[3]=e,n[4]=o,n[5]=s}else o=n[4],s=n[5];let c;return n[6]!==i.enabled||n[7]!==o?(c={...o,enabled:i.enabled},n[6]=i.enabled,n[7]=o,n[8]=c):c=n[8],s(c)},an=(e,t)=>{let n=(0,X.c)(7),r;n[0]===t?r=n[1]:(r=t===void 0?{}:t,n[0]=t,n[1]=r);let i=r,a=A(dn),o=e===void 0?a:e,s;n[2]===o?s=n[3]:(s=nn(Q(o)),n[2]=o,n[3]=s);let c;return n[4]!==i.enabled||n[5]!==s?(c={...s,enabled:i.enabled},n[4]=i.enabled,n[5]=s,n[6]=c):c=n[6],I(c)},on=(e=S,t=Zt(),r=n())=>e.getQueryData(Qt(Q(t),r))??[],sn=(e=S,t,r=n())=>e.getQueryData($t(Q(t),r))??{},cn=async(e,t,r)=>{let i=Q(t);return n()===r?e.fetchQuery({...tn(i,r),staleTime:0}):on(e,i,r)},ln=async(e,t,r)=>{let i=Q(t);return n()===r?e.fetchQuery({...nn(i,r),staleTime:0}):sn(e,i,r)};function un(e){return e.getActiveProject?.()?.path??null}function dn(e){return e.currentDirectory}var fn={},pn=(e,t=n())=>JSON.stringify([t,Q(e)]),mn=(e,t,n)=>{if(!e[t]?.[n])return e;let r={...e[t]};return delete r[n],{...e,[t]:r}},hn=e=>{let t=Q(e);return t?j.getScopedApiClient(t):j.getApiClient()},gn=e=>Q(e===void 0?A.getState().currentDirectory:e),_n=w()(E((e,t)=>({diagnosticsByDirectory:{},getDiagnosticForDirectory:e=>{let n=pn(gn(e));return t().diagnosticsByDirectory[n]??fn},clearDiagnostic:(t,n,r)=>{let i=pn(gn(n),r);e(e=>({diagnosticsByDirectory:mn(e.diagnosticsByDirectory,i,t)}))},connect:async(t,r)=>{let i=gn(r),a=n(),o=pn(i,a),s=hn(i);try{await s.mcp.connect({name:t},{throwOnError:!0})}catch(n){let r=n instanceof Error?n.message:`Connection failed`;throw e(e=>({diagnosticsByDirectory:{...e.diagnosticsByDirectory,[o]:{...e.diagnosticsByDirectory[o]??{},[t]:{status:`failed`,error:r}}}})),n}await ln(S,i,a),e(e=>({diagnosticsByDirectory:mn(e.diagnosticsByDirectory,o,t)}))},disconnect:async(t,r)=>{let i=gn(r),a=n(),o=pn(i,a);await hn(i).mcp.disconnect({name:t},{throwOnError:!0}),await ln(S,i,a),e(e=>({diagnosticsByDirectory:mn(e.diagnosticsByDirectory,o,t)}))},startAuth:async(e,t)=>{let n=(await hn(gn(t)).mcp.auth.start({name:e},{throwOnError:!0})).data?.authorizationUrl;if(!n)throw Error(`Authorization URL was not returned`);return n},completeAuth:async(t,r,i)=>{let a=gn(i),o=n(),s=pn(a,o);await hn(a).mcp.auth.callback({name:t,code:r},{throwOnError:!0}),await ln(S,a,o),e(e=>({diagnosticsByDirectory:mn(e.diagnosticsByDirectory,s,t)}))},clearAuth:async(t,r)=>{let i=gn(r),a=n(),o=pn(i,a);await hn(i).mcp.auth.remove({name:t},{throwOnError:!0}),await ln(S,i,a),e(e=>({diagnosticsByDirectory:mn(e.diagnosticsByDirectory,o,t)}))},testConnection:async(t,r)=>{let i=gn(r),a=n(),o=pn(i,a),s=hn(i),c=sn(S,i,a)[t]?.status===`connected`,l,u;try{await s.mcp.connect({name:t},{throwOnError:!0})}catch(n){l=n instanceof Error?n.message:`Connection failed`,e(e=>({diagnosticsByDirectory:{...e.diagnosticsByDirectory,[o]:{...e.diagnosticsByDirectory[o]??{},[t]:{status:`failed`,error:l??`Connection failed`}}}}))}let d=(await ln(S,i,a))[t],f=d;if(!c&&d?.status===`connected`){try{await s.mcp.disconnect({name:t},{throwOnError:!0})}catch(e){u=`Connection test succeeded, but cleanup disconnect failed: ${e instanceof Error?e.message:`Disconnect failed`}`}await ln(S,i,a)}return l||e(e=>({diagnosticsByDirectory:mn(e.diagnosticsByDirectory,o,t)})),{status:f??sn(S,i,a)[t],error:l,warning:u}}}))),$=e(O(),1),vn=e=>typeof e==`string`&&e.trim().length>0?e.trim():null,yn=()=>vn(`1.19.9`),bn=(e,t)=>vn(t)||vn(e),xn=(e,t)=>{let n=vn(e);return n?typeof t!=`number`||!Number.isFinite(t)?n:`${n} (${t})`:null},Sn=async()=>{let e=yn();if(!M())return e;try{let{App:t}=await P(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2]));return bn((await t.getInfo()).version,e)}catch{return e}},Cn=async()=>{if(!M())return null;try{let{App:e}=await P(async()=>{let{App:e}=await import(`./vendor-capacitor-app-PzT84wSx.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])),t=await e.getInfo(),n=typeof t.build==`string`?t.build.trim():``;if(n.length===0)return null;let r=Number.parseInt(n,10);return Number.isFinite(r)?r:null}catch{return null}},wn=`https://openchamber.xiaobe.top/v1/update/check`,Tn=`https://openchamber-update.vercel.app/v1/update/check`,En=`https://github.com/yee94/openchamber/releases/latest`,Dn=`https://github.com/yee94/openchamber/releases`,On=`https://testflight.apple.com/join/ZCENBHtm`,kn=1e4;function An(e){let t=String(e||``).replace(/^v/,``).split(`+`)[0]??``,n=t.indexOf(`-`);return{parts:(n>=0?t.slice(0,n):t).split(`.`).map(e=>{let t=Number.parseInt(e||`0`,10);return Number.isFinite(t)?t:0}),prerelease:n>=0}}function jn(e,t){let n=An(e),r=An(t),i=Math.max(n.parts.length,r.parts.length);for(let e=0;e<i;e+=1){let t=(n.parts[e]||0)-(r.parts[e]||0);if(t!==0)return t}return n.prerelease===r.prerelease?0:n.prerelease?-1:1}function Mn(){return[wn,Tn]}function Nn(e,t,n=Date.now){let r=e-n();return r<=0||t<=0?null:Math.max(1,Math.ceil(r/t))}function Pn(e){return{appType:`mobile-capacitor`,deviceClass:e.deviceClass||`mobile`,platform:e.platform===`ios`||e.platform===`android`?e.platform:`android`,arch:e.arch||`unknown`,channel:`stable`,currentVersion:e.currentVersion,instanceMode:`remote`,reportUsage:e.reportUsage===!0}}async function Fn(e,t,n,r){try{if(M())try{let{CapacitorHttp:r}=await P(async()=>{let{CapacitorHttp:e}=await import(`./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js`).then(e=>e.i);return{CapacitorHttp:e}},__vite__mapDeps([2,1])),i=Object.fromEntries(new Headers(t.headers).entries()),a;if(typeof t.body==`string`)try{a=JSON.parse(t.body)}catch{a=t.body}let o=await Promise.race([r.request({url:e,method:t.method||`GET`,headers:i,data:a,connectTimeout:n,readTimeout:n}),new Promise(e=>{window.setTimeout(()=>e(null),n)})]);return o?{ok:o.status>=200&&o.status<300,status:o.status,url:typeof o.url==`string`?o.url:e,json:async()=>{if(typeof o.data==`string`)try{return JSON.parse(o.data)}catch{return o.data}return o.data}}:null}catch{}let i=await r(e,{...t,signal:AbortSignal.timeout(n)});return{ok:i.ok,status:i.status,url:i.url,json:()=>i.json()}}catch{return null}}function In(e,t){return e===`ios`?On:`${Dn}/download/v${t}/app-release.apk`}function Ln(e,t,n){if(typeof e.latestVersion!=`string`||e.latestVersion.trim().length===0)return null;let r=e.latestVersion.trim(),i=jn(r,t);if(i<0)return null;let a=typeof e.releaseNotesUrl==`string`&&e.releaseNotesUrl.trim().length>0?e.releaseNotesUrl.trim():`${Dn}/tag/v${r}`,o=typeof e.downloadUrl==`string`&&e.downloadUrl.trim().length>0?e.downloadUrl.trim():typeof e.download?.url==`string`&&e.download.url.trim().length>0?e.download.url.trim():In(n,r);return{available:!!e.updateAvailable&&i>0,version:r,currentVersion:t,body:typeof e.releaseNotes==`string`?e.releaseNotes:void 0,releaseUrl:a,downloadUrl:o,nextSuggestedCheckInSec:typeof e.nextSuggestedCheckInSec==`number`&&Number.isFinite(e.nextSuggestedCheckInSec)?e.nextSuggestedCheckInSec:void 0}}async function Rn(e,t,n,r){let i=await Fn(e,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify(Pn(t))},n,r);if(!i?.ok)return null;let a;try{a=await i.json()}catch{return null}return Ln(a,t.currentVersion,t.platform)}async function zn(e,t,n,r){let i=await Fn(En,{method:`GET`,headers:{Accept:`text/html`},redirect:`follow`},n,r);if(!i?.ok)return null;let a=typeof i.url==`string`&&i.url.length>0?i.url:En,o=null;try{o=new URL(a).pathname.match(/\/releases\/tag\/v(\d+\.\d+\.\d+(?:-[\w.]+)?)/)}catch{return null}if(!o?.[1])return null;let s=o[1],c=jn(s,e),l=`${Dn}/tag/v${s}`;return{available:c>0,version:s,currentVersion:e,releaseUrl:l,downloadUrl:In(t,s)}}async function Bn(e){let t=e.currentVersion?.trim()||`unknown`;if(t===`unknown`)return{available:!1,currentVersion:t,error:`Unable to check for mobile updates`};let n=e.fetchImpl??fetch,r=e.now??Date.now,i=Mn(),a=r()+kn;for(let[t,o]of i.entries()){let s=Nn(a,i.length-t+1,r);if(s===null)break;let c=await Rn(o,e,s,n);if(c)return c}let o=Nn(a,1,r);if(o!==null){let r=await zn(t,e.platform,o,n);if(r)return r}return{available:!1,currentVersion:t,error:`Unable to check for mobile updates`}}function Vn(){if(typeof window>`u`)return`unknown`;try{let{deviceType:e}=wt();return e}catch{return`unknown`}}function Hn(){let e=typeof window<`u`?window.__VSCODE_CONFIG__?.arch?.toLowerCase?.():void 0;if(e===`arm64`||e===`aarch64`)return`arm64`;if(e===`x64`||e===`amd64`||e===`x86_64`)return`x64`;let t=(typeof navigator<`u`?navigator.userAgentData:void 0)?.architecture?.toLowerCase?.();if(t===`arm`||t===`arm64`||t===`aarch64`)return`arm64`;if(t===`x86`||t===`x64`||t===`amd64`)return`x64`;let n=typeof navigator<`u`?navigator.userAgent.toLowerCase():``;return n.includes(`aarch64`)||n.includes(`arm64`)||n.includes(`armv`)?`arm64`:n.includes(`x86_64`)||n.includes(`x64`)||n.includes(`amd64`)||n.includes(`win64`)?`x64`:`unknown`}function Un(){let e=N();if(e===`android`||e===`ios`)return e;if(typeof navigator>`u`)return`web`;let t=(navigator.platform||``).toLowerCase();return t.includes(`mac`)?`macos`:t.includes(`win`)?`windows`:t.includes(`linux`)?`linux`:`web`}function Wn(e){let t=i.getState().reportUsage,n=new URLSearchParams({reportUsage:t?`true`:`false`});return n.set(`deviceClass`,Vn()),n.set(`arch`,Hn()),n.set(`platform`,Un()),e===`desktop`?(n.set(`appType`,`desktop-electron`),n.set(`instanceMode`,u()?`local`:`remote`),n):e===`vscode`?(n.set(`appType`,`vscode`),n.set(`instanceMode`,`local`),n):e===`mobile`?(n.set(`appType`,`mobile-capacitor`),n.set(`instanceMode`,`remote`),n):(n.set(`appType`,`web`),n.set(`instanceMode`,`unknown`),n)}async function Gn(e,t){let n=t??`unknown`;try{let r=Wn(e),i=typeof window<`u`?window.__VSCODE_CONFIG__?.extensionVersion:void 0;t?r.set(`currentVersion`,t):e===`vscode`&&i&&r.set(`currentVersion`,i);let a=await g(`/api/openchamber/update-check?${r.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),o=null;try{o=await a.json()}catch{o=null}if(!a.ok)return{available:!1,currentVersion:n,error:typeof o?.error==`string`&&o.error.trim().length>0?o.error.trim():`Server responded with ${a.status}`};if(!o)return{available:!1,currentVersion:n,error:`Update check returned an invalid response`};let s=typeof o.error==`string`&&o.error.trim().length>0?o.error.trim():void 0;return{available:o.available===!0,version:typeof o.version==`string`?o.version:void 0,currentVersion:typeof o.currentVersion==`string`?o.currentVersion:n,body:typeof o.body==`string`?o.body:void 0,releaseUrl:typeof o.releaseUrl==`string`?o.releaseUrl:void 0,downloadUrl:typeof o.downloadUrl==`string`?o.downloadUrl:void 0,nextSuggestedCheckInSec:typeof o.nextSuggestedCheckInSec==`number`&&Number.isFinite(o.nextSuggestedCheckInSec)?o.nextSuggestedCheckInSec:void 0,packageManager:typeof o.packageManager==`string`?o.packageManager:void 0,updateCommand:typeof o.updateCommand==`string`?o.updateCommand:void 0,error:s}}catch(e){return console.warn(`Failed to check for updates:`,e),{available:!1,currentVersion:n,error:e instanceof Error?e.message:`Failed to check for updates`}}}function Kn(){return M()?`mobile`:d()?`desktop`:o()?`vscode`:m()?`web`:null}var qn={checking:!1,available:!1,downloading:!1,downloaded:!1,info:null,progress:null,error:null,runtimeType:null,lastChecked:null,nextCheckInSec:null,otaDecision:null,otaPhase:`idle`,otaDownloadSkipped:!1,lastOtaChannelOverride:null};function Jn(e,t){let n=e.isChannelRollback===!0?{isChannelRollback:!0}:{};return e.primaryAction===`apply_ota`&&e.ota.bundle?e.ota.bundle.releaseVersion===t?{available:!1,otaPhase:`idle`,info:{available:!1,currentVersion:t,nextSuggestedCheckInSec:e.nextCheckInSec,...n}}:{available:!0,otaPhase:`available`,info:{available:!0,version:e.ota.bundle.releaseVersion,currentVersion:t,downloadUrl:e.ota.bundle.url,nextSuggestedCheckInSec:e.nextCheckInSec,inAppApply:!0,...e.releaseNotes?{body:e.releaseNotes}:{},...n}}:e.primaryAction===`install_native_required`?{available:e.native.state===`required`||e.native.state===`available`,otaPhase:`idle`,info:{available:e.native.state===`required`||e.native.state===`available`,version:e.native.version,currentVersion:t,downloadUrl:e.native.installUrl,nextSuggestedCheckInSec:e.nextCheckInSec,manualUpdate:!0,...e.releaseNotes?{body:e.releaseNotes}:{},...n}}:{available:!1,otaPhase:`idle`,info:{available:!1,currentVersion:t,nextSuggestedCheckInSec:e.nextCheckInSec,...n}}}var Yn=w()((e,t)=>({...qn,checkForUpdates:async()=>{let n=Kn();if(!n)return null;e({checking:!0,error:null,runtimeType:n});try{let r=null,a=null;if(n===`desktop`){let t=await s(),n=t?.downloaded===!0;return e({checking:!1,available:t?.available??!1,downloaded:n,...n?{downloading:!1,progress:null}:{},info:t,error:null,lastChecked:Date.now(),nextCheckInSec:null}),a}if(n===`web`)r=await Gn(`web`),a=r?.nextSuggestedCheckInSec??null;else if(n===`vscode`)a=(await Gn(`vscode`))?.nextSuggestedCheckInSec??null;else if(n===`mobile`){let n=await Sn()??`unknown`,o=M()?C()?.mobileUpdates:void 0,s=i.getState().otaChannelOverride;if(o)try{let r=t().lastOtaChannelOverride!==s;e(r?{otaDecision:null,otaPhase:`checking`,downloaded:!1,otaDownloadSkipped:!1,progress:null,available:!1,info:null}:{otaPhase:`checking`});let i=await o.checkForOtaUpdate(s===`beta`||s===`stable`?{channelOverride:s}:void 0),a=Jn(i,n),c=(r?void 0:t().otaDecision?.ota.bundle?.bundleId)!==i.ota.bundle?.bundleId,l=!r&&t().downloaded&&!c;return e({checking:!1,available:a.available,info:a.info,error:a.info.error??null,lastChecked:Date.now(),nextCheckInSec:i.nextCheckInSec,otaDecision:i,otaPhase:l?`pending_restart`:a.otaPhase,lastOtaChannelOverride:s,...c||r?{downloaded:!1,otaDownloadSkipped:!1,progress:null}:{}}),i.nextCheckInSec}catch(t){if(!(t instanceof L)){let r=t instanceof Error?t.message:`Mobile OTA check failed`;return e({checking:!1,available:!1,info:{available:!1,currentVersion:n},error:r,lastChecked:Date.now(),otaDecision:null,otaPhase:`error`,lastOtaChannelOverride:s}),null}}return r=await Bn({currentVersion:n,platform:Un()===`ios`?`ios`:`android`,deviceClass:Vn(),arch:Hn(),reportUsage:i.getState().reportUsage}),a=r?.nextSuggestedCheckInSec??null,e({checking:!1,available:r?.available??!1,info:r,error:r?.error??null,lastChecked:Date.now(),nextCheckInSec:a,otaDecision:null,otaPhase:`idle`}),a}return e({checking:!1,available:n===`vscode`?!1:r?.available??!1,info:n===`vscode`?null:r,error:n===`vscode`?null:r?.error??null,lastChecked:Date.now(),nextCheckInSec:a}),a}catch(t){return e({checking:!1,error:t instanceof Error?t.message:`Failed to check for updates`}),null}},downloadUpdate:async()=>{let{available:n,runtimeType:r,otaDecision:i,downloading:a,downloaded:o}=t();if(r===`mobile`&&i?.primaryAction===`apply_ota`&&i.ota.bundle){if(a||o)return;let t=C()?.mobileUpdates;if(!t){e({error:`Mobile OTA updates are unavailable in this runtime`,otaPhase:`error`});return}e({downloading:!0,error:null,progress:null,otaPhase:`downloading`,otaDownloadSkipped:!1});try{let{skipped:n}=await t.downloadOtaUpdate(i.ota.bundle);await t.queueOtaUpdateForNextLaunch(),e({downloading:!1,downloaded:!0,progress:null,otaPhase:`pending_restart`,otaDownloadSkipped:n})}catch(t){e({downloading:!1,error:t instanceof Error?t.message:`Failed to download update`,otaPhase:`error`})}return}if(!(r!==`desktop`||!n)){e({downloading:!0,error:null,progress:null});try{let n=await s();if(!n?.available)throw Error(`Update detected, but desktop package is not ready yet. Retry in a moment.`);if(e(e=>({info:e.info?{...e.info,...n,body:e.info.body||n.body,available:e.info.available}:n})),n.downloaded||t().downloaded){e({downloading:!1,downloaded:!0,progress:null});return}if(n.downloading&&e({downloading:!0,progress:n.progress??{downloaded:0}}),!await c(t=>{e({progress:t})}))throw Error(`Failed to download update`);e({downloading:!1,downloaded:!0,progress:null})}catch(t){e({downloading:!1,error:t instanceof Error?t.message:`Failed to download update`})}}},subscribeDesktopUpdateEvents:async()=>{if(!d())return()=>{};let n=[],r=await x(n=>{let r=n.event,i=n.data??null;if(r===`Started`){if(!t().downloading)return;e({error:null,progress:{downloaded:0,total:typeof i?.contentLength==`number`?i.contentLength:void 0}});return}if(r===`Progress`){if(!t().downloading)return;e({progress:{downloaded:typeof i?.downloaded==`number`?i.downloaded:0,total:typeof i?.total==`number`?i.total:void 0}});return}r===`Finished`&&e({downloading:!1,downloaded:!0,progress:null})});r&&n.push(r);let i=await _(t=>{t.downloaded&&e({downloading:!1,downloaded:!0,available:!0,progress:null})});return i&&n.push(i),async()=>{for(let e of n)try{let t=e();t instanceof Promise&&await t}catch{}}},restartToUpdate:async()=>{let{downloaded:n,runtimeType:r,otaDecision:i}=t();if(r===`mobile`&&i?.primaryAction===`apply_ota`){if(!n)return;let t=C()?.mobileUpdates;if(!t){e({error:`Mobile OTA updates are unavailable in this runtime`,otaPhase:`error`});return}try{await t.applyOtaUpdateNow()}catch(t){e({error:t instanceof Error?t.message:`Failed to restart`,otaPhase:`error`})}return}if(!(r!==`desktop`||!n))try{if(!await p())throw Error(`Failed to restart`)}catch(t){e({error:t instanceof Error?t.message:`Failed to restart`})}},setOtaPhase:(t,n=null)=>{e({otaPhase:t,...n===void 0?{}:{error:n}})},setOtaDownloadPercent:n=>{if(!Number.isFinite(n)||n<0||n>100)return;let r=t();if(!r.downloading)return;let i=Math.round(n);if((r.progress?.total?Math.round(r.progress.downloaded/r.progress.total*100):null)===i)return;let a=r.otaDecision?.ota.bundle?.size;if(typeof a==`number`&&Number.isFinite(a)&&a>0){e({progress:{downloaded:Math.round(a*n/100),total:a}});return}e({progress:{downloaded:n,total:100}})},setOtaDownloadFailed:t=>{e({downloading:!1,downloaded:!1,error:t??`Failed to download update`,otaPhase:`error`})},dismiss:()=>{let n=t();(n.runtimeType!==`mobile`||n.otaPhase!==`pending_restart`)&&e({available:!1,downloaded:!1,info:null,otaDecision:null,otaPhase:`idle`,otaDownloadSkipped:!1})},reset:()=>{e(qn)}})),Xn=`https://github.com/yee94/openchamber/releases`;function Zn(e){let t=new Date(`${e}T00:00:00`);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(ge(),{year:`numeric`,month:`short`,day:`numeric`}).format(t)}function Qn(e){return e.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,``).trim()}function $n(e){return e.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,`$1[@$2](https://github.com/$2)`)}function er(e,t){let n=e.split(`.`).map(e=>Number.parseInt(e,10)),r=t.split(`.`).map(e=>Number.parseInt(e,10));for(let e=0;e<3;e+=1){let t=Number.isFinite(n[e])?n[e]:0,i=Number.isFinite(r[e])?r[e]:0;if(t!==i)return i-t}return 0}function tr(e){let t=/^## \[(\d+\.\d+\.\d+)\] - (\d{4}-\d{2}-\d{2})\s*$/gm,n=[],r;for(;(r=t.exec(e))!==null;)n.push({version:r[1]??``,date:r[2]??``,start:r.index});return n.length===0?[]:n.map((t,r)=>{let i=n[r+1]?.start??e.length,a=e.slice(t.start,i).trim();return{version:t.version,date:t.date,start:t.start,end:i,raw:a}})}var nr=2e3,rr=6e5;async function ir(){try{let e=await g(`/api/openchamber/update-install`,{method:`POST`,headers:{"Content-Type":`application/json`}});return e.ok?{success:!0,autoRestart:(await e.json().catch(()=>({}))).autoRestart!==!1}:{success:!1,error:(await e.json().catch(()=>({}))).error||`Server error: ${e.status}`}}catch(e){return{success:!1,error:e instanceof Error?e.message:void 0}}}async function ar(){try{return(await g(`/health`,{method:`GET`,headers:{Accept:`application/json`}})).ok}catch{return!1}}async function or(e,t=Math.ceil(rr/nr),n=nr){for(let r=0;r<t;r++){try{let t=await g(`/api/openchamber/update-check`,{method:`GET`,headers:{Accept:`application/json`}});if(t.ok){let n=await t.json().catch(()=>null);if(n&&n.available===!1||n&&typeof n.currentVersion==`string`&&typeof e==`string`&&n.currentVersion!==e)return!0}else if((t.status===401||t.status===403)&&await ar())return!0}catch{}await new Promise(e=>setTimeout(e,n))}return!1}var sr=({open:e,onOpenChange:t,info:n,downloading:r,downloaded:i,progress:a,error:o,onDownload:s,onRestart:c,runtimeType:l=`desktop`})=>{let{t:u}=he(),[d,f]=(0,$.useState)(!1),[p,m]=(0,$.useState)(`idle`),[h,g]=(0,$.useState)(null),_=Yn(e=>e.otaDownloadSkipped),v=n?.releaseUrl||(n?.version?`${Xn}/tag/v${n.version}`:Xn),y=n?.downloadUrl,b=a?.total?Math.round(a.downloaded/a.total*100):0,x=l===`web`,S=l===`mobile`,C=S&&n?.manualUpdate===!0&&!!y,w=S&&n?.inAppApply===!0,T=l===`desktop`&&n?.manualUpdate===!0,E=n?.updateCommand||`openchamber update`,D=W(e=>{!e&&w&&i&&Yn.getState().dismiss(),t(e)}),O=W(()=>{Yn.getState().dismiss(),t(!1)});(0,$.useEffect)(()=>{e||(m(`idle`),g(null))},[e]);let k=async()=>{(await _e(E)).ok&&(f(!0),setTimeout(()=>f(!1),2e3))},A=(0,$.useCallback)(async e=>{await Ot(e)},[]),j=(0,$.useCallback)(async()=>{m(`updating`),g(null);let e=await ir();if(!e.success){m(`error`),g(e.error||u(`updateDialog.error.updateFailed`));return}e.autoRestart&&(m(`restarting`),await new Promise(e=>setTimeout(e,2e3))),m(`reconnecting`),await or(n?.currentVersion)?window.location.reload():(m(`error`),g(u(`updateDialog.error.takingLonger`)))},[n?.currentVersion,u]),M=(0,$.useCallback)(()=>{y&&A(y)},[A,y]),N=p!==`idle`&&p!==`error`,P=(0,$.useMemo)(()=>{if(!n?.body)return null;let e=n.body.trim();if(!e)return null;let t=tr(e);if(t.length===0)return{kind:`raw`,title:u(`updateDialog.changelog.title`),content:$n(e)};let r=[...t].sort((e,t)=>er(e.version,t.version));return{kind:`sections`,title:u(`updateDialog.changelog.title`),sections:r.map(t=>({version:t.version,dateLabel:Zn(t.date),content:$n(Qn(t.raw)||e)}))}},[n?.body,u]);return(0,Z.jsx)(je,{open:e,onOpenChange:N?void 0:D,children:(0,Z.jsxs)(ke,{className:`max-w-4xl gap-0 p-4 sm:p-5 bg-background border-[var(--interactive-border)]`,showCloseButton:!0,children:[(0,Z.jsxs)(`div`,{className:`mb-3 pr-8 sm:mb-4`,children:[(0,Z.jsxs)(Ae,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(J,{name:`download-cloud`,className:`h-5 w-5 text-[var(--primary-base)]`}),(0,Z.jsx)(`span`,{className:`font-semibold text-foreground`,children:u(p===`restarting`||p===`reconnecting`?`updateDialog.header.updating`:`updateDialog.header.updateAvailable`)})]}),(n?.currentVersion||n?.version)&&(0,Z.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5 pl-7 font-mono text-[11px] leading-4 tracking-[-0.01em] tabular-nums sm:text-xs`,children:[n?.currentVersion&&(0,Z.jsx)(`span`,{className:`text-muted-foreground/75`,children:n.currentVersion}),n?.currentVersion&&n?.version&&(0,Z.jsx)(`span`,{className:`text-muted-foreground/40`,children:`→`}),n?.version&&(0,Z.jsx)(`span`,{className:`font-medium text-[var(--primary-base)]`,children:n.version})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[x&&N&&(0,Z.jsxs)(`div`,{className:`rounded-lg bg-[var(--surface-elevated)]/30 p-5 border border-[var(--surface-subtle)]`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(J,{name:`loader`,className:`h-5 w-5 animate-spin text-[var(--primary-base)]`}),(0,Z.jsxs)(`div`,{className:`typography-ui-label text-foreground`,children:[p===`updating`&&u(`updateDialog.status.installingUpdate`),p===`restarting`&&u(`updateDialog.status.serverRestarting`),p===`reconnecting`&&u(`updateDialog.status.waitingForServer`)]})]}),(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:u(`updateDialog.status.autoReloadHint`)})]}),P&&!N&&(0,Z.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--surface-subtle)] px-3.5 py-2.5 sm:px-4 sm:py-3`,children:[(0,Z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--primary-base)]`,"aria-hidden":`true`}),(0,Z.jsx)(`h3`,{className:`typography-ui-caption font-medium text-muted-foreground`,children:P.title})]}),(0,Z.jsx)(Et,{className:`max-h-[min(42dvh,22rem)] p-0 sm:max-h-[400px]`,fillContainer:!1,children:P.kind===`raw`?(0,Z.jsx)(`div`,{className:`break-words p-3.5 text-[13px] leading-[1.65] text-foreground sm:p-4 sm:text-sm [&_.markdown-content]:leading-[1.65] [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline`,onClickCapture:e=>{let t=e.target.closest(`a`);t&&t.href&&(e.preventDefault(),e.stopPropagation(),A(t.href))},children:(0,Z.jsx)(Tt,{content:P.content,disableLinkSafety:!0,enableFileReferences:!1})}):(0,Z.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:P.sections.map(e=>(0,Z.jsxs)(`div`,{className:`p-3.5 sm:p-4`,children:[(0,Z.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-center gap-x-2 gap-y-1 sm:mb-3`,children:[(0,Z.jsxs)(`span`,{className:`rounded-md bg-[var(--primary-base)]/10 px-1.5 py-0.5 font-mono text-[11px] font-medium leading-4 text-[var(--primary-base)] tabular-nums sm:text-xs`,children:[`v`,e.version]}),(0,Z.jsx)(`span`,{className:`text-[11px] leading-4 text-muted-foreground/75 sm:text-xs`,children:e.dateLabel})]}),(0,Z.jsx)(`div`,{className:`break-words text-[13px] leading-[1.65] text-foreground sm:text-sm [&_.markdown-content]:leading-[1.65] [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline`,onClickCapture:e=>{let t=e.target.closest(`a`);t&&t.href&&(e.preventDefault(),e.stopPropagation(),A(t.href))},children:(0,Z.jsx)(Tt,{content:e.content,disableLinkSafety:!0,enableFileReferences:!1})})]},e.version))})})]}),x&&p===`error`&&(0,Z.jsxs)(`div`,{className:`space-y-2 mt-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 typography-meta text-muted-foreground`,children:[(0,Z.jsx)(J,{name:`terminal`,className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:u(`updateDialog.fallback.updateViaTerminal`)})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 p-1 pl-3 bg-[var(--surface-elevated)]/50 rounded-md border border-[var(--surface-subtle)]`,children:[(0,Z.jsx)(`code`,{className:`flex-1 font-mono text-sm text-foreground overflow-x-auto whitespace-nowrap`,children:E}),(0,Z.jsx)(`button`,{onClick:k,className:q(`flex items-center justify-center p-2 rounded`,`text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]`,`transition-colors`,d&&`text-[var(--status-success)]`),title:u(d?`updateDialog.actions.copied`:`updateDialog.actions.copyCommand`),children:d?(0,Z.jsx)(J,{name:`check`,className:`h-4 w-4`}):(0,Z.jsx)(J,{name:`clipboard`,className:`h-4 w-4`})})]})]}),!x&&(!S||w)&&r&&(0,Z.jsxs)(`div`,{className:`mt-3 space-y-2 rounded-lg border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20 px-3.5 py-3 sm:mt-4 sm:px-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground sm:text-[13px]`,children:u(`updateDialog.status.downloadingPayload`)}),(0,Z.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] leading-4 text-foreground tabular-nums sm:text-xs`,children:[b,`%`]})]}),(0,Z.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-[var(--surface-subtle)] sm:h-1.5`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-[var(--primary-base)] transition-all duration-300`,style:{width:`${b}%`}})})]}),(o||h)&&(0,Z.jsx)(`div`,{className:`p-3 mt-4 bg-[var(--status-error-background)] border border-[var(--status-error-border)] rounded-lg`,children:(0,Z.jsx)(`p`,{className:`text-sm text-[var(--status-error)]`,children:o||h})})]}),w&&i&&_&&(0,Z.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg border border-[var(--status-success-border)] bg-[var(--status-success-background)] px-3 py-2.5 text-sm text-[var(--status-success)]`,children:[(0,Z.jsx)(J,{name:`check`,className:`h-4 w-4 shrink-0`}),(0,Z.jsx)(`span`,{children:u(`updateDialog.status.otaBundleReused`)})]}),(0,Z.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-4`,children:[!S||C?(0,Z.jsxs)(`a`,{href:S?y:v,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground hover:text-foreground transition-colors shrink-0`,children:[(0,Z.jsx)(J,{name:`external-link`,className:`h-4 w-4`}),`GitHub`]}):(0,Z.jsx)(`span`,{}),(0,Z.jsxs)(`div`,{className:`flex-1 flex justify-end`,children:[!x&&(!S||w)&&!T&&!i&&!r&&(0,Z.jsxs)(Y,{onClick:s,size:`default`,children:[(0,Z.jsx)(J,{name:`download`,className:`h-4 w-4`}),u(w?`updateDialog.actions.applyOtaNow`:`updateDialog.actions.downloadUpdate`)]}),!x&&!S&&T&&!i&&!r&&(0,Z.jsxs)(Y,{onClick:()=>void A(v),size:`default`,children:[(0,Z.jsx)(J,{name:`external-link`,className:`h-4 w-4`}),u(`updateDialog.actions.openMobileUpdate`)]}),!x&&(!S||w)&&r&&(0,Z.jsxs)(Y,{disabled:!0,size:`default`,children:[(0,Z.jsx)(J,{name:`loader`,className:`h-4 w-4 animate-spin`}),u(`updateDialog.status.downloading`)]}),!x&&(!S||w)&&i&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[w&&(0,Z.jsx)(Y,{onClick:O,variant:`ghost`,size:`default`,children:u(`updateDialog.actions.later`)}),(0,Z.jsxs)(Y,{onClick:c,size:`default`,children:[(0,Z.jsx)(J,{name:`restart`,className:`h-4 w-4`}),u(`updateDialog.actions.restartToUpdate`)]})]}),S&&!w&&C&&(0,Z.jsxs)(Y,{onClick:M,size:`default`,children:[(0,Z.jsx)(J,{name:`external-link`,className:`h-4 w-4`}),u(`updateDialog.actions.openMobileUpdate`)]}),x&&!N&&(0,Z.jsxs)(Y,{onClick:j,size:`default`,children:[(0,Z.jsx)(J,{name:`download`,className:`h-4 w-4`}),u(`updateDialog.actions.updateNow`)]}),x&&N&&(0,Z.jsxs)(Y,{disabled:!0,size:`default`,children:[(0,Z.jsx)(J,{name:`loader`,className:`h-4 w-4 animate-spin`}),u(`updateDialog.status.updating`)]})]})]})]})})},cr=e(k(),1);function lr(e){let t=(0,X.c)(20),{label:n,children:r,description:i,itemId:a,ariaLabel:o,className:s,cardClassName:c,cardId:l}=e,u=typeof n==`string`&&/^[\p{Script=Latin}\p{Number}\p{Punctuation}\p{Separator}]+$/u.test(n)?`latin`:void 0,d;t[0]===s?d=t[1]:(d=q(`oc-settings-group`,s),t[0]=s,t[1]=d);let f;t[2]!==n||t[3]!==u?(f=n?(0,Z.jsx)(`div`,{className:`oc-settings-group-label`,"data-settings-label-script":u,children:n}):null,t[2]=n,t[3]=u,t[4]=f):f=t[4];let p;t[5]===c?p=t[6]:(p=q(`oc-settings-group-card`,c),t[5]=c,t[6]=p);let m;t[7]!==l||t[8]!==r||t[9]!==a||t[10]!==p?(m=(0,Z.jsx)(`div`,{id:l,"data-settings-item":a,className:p,children:r}),t[7]=l,t[8]=r,t[9]=a,t[10]=p,t[11]=m):m=t[11];let h;t[12]===i?h=t[13]:(h=i?(0,Z.jsx)(`p`,{className:`oc-settings-group-description text-muted-foreground`,children:i}):null,t[12]=i,t[13]=h);let g;return t[14]!==o||t[15]!==d||t[16]!==f||t[17]!==m||t[18]!==h?(g=(0,Z.jsxs)(`section`,{className:d,"aria-label":o,children:[f,m,h]}),t[14]=o,t[15]=d,t[16]=f,t[17]=m,t[18]=h,t[19]=g):g=t[19],g}function ur(e){let t=(0,X.c)(20),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]):({label:s,description:a,descriptionPlacement:l,ariaLabel:n,groupClassName:o,cardClassName:r,children:i,...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?`inside`:l,d=u===`outside`?a:void 0,f=u===`inside`?a:void 0,p;t[9]!==i||t[10]!==s||t[11]!==c||t[12]!==f?(p=(0,Z.jsx)(dr,{label:s,description:f,...c,children:i}),t[9]=i,t[10]=s,t[11]=c,t[12]=f,t[13]=p):p=t[13];let m;return t[14]!==n||t[15]!==r||t[16]!==o||t[17]!==d||t[18]!==p?(m=(0,Z.jsx)(lr,{ariaLabel:n,className:o,cardClassName:r,description:d,children:p}),t[14]=n,t[15]=r,t[16]=o,t[17]=d,t[18]=p,t[19]=m):m=t[19],m}function dr(e){let t=(0,X.c)(22),{label:n,children:r,description:i,itemId:a,className:o,copyClassName:s,controlClassName:c}=e,l;t[0]===o?l=t[1]:(l=q(`oc-settings-group-row oc-settings-split-row`,o),t[0]=o,t[1]=l);let u;t[2]===s?u=t[3]:(u=q(`oc-settings-split-row-copy`,s),t[2]=s,t[3]=u);let d;t[4]===n?d=t[5]:(d=n?(0,Z.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:n}):null,t[4]=n,t[5]=d);let f;t[6]===i?f=t[7]:(f=i?(0,Z.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:i}):null,t[6]=i,t[7]=f);let p;t[8]!==u||t[9]!==d||t[10]!==f?(p=(0,Z.jsxs)(`div`,{className:u,children:[d,f]}),t[8]=u,t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===c?m=t[13]:(m=q(`oc-settings-split-row-control`,c),t[12]=c,t[13]=m);let h;t[14]!==r||t[15]!==m?(h=(0,Z.jsx)(`div`,{"data-settings-value":``,className:m,children:r}),t[14]=r,t[15]=m,t[16]=h):h=t[16];let g;return t[17]!==a||t[18]!==l||t[19]!==p||t[20]!==h?(g=(0,Z.jsxs)(`div`,{"data-settings-item":a,className:l,children:[p,h]}),t[17]=a,t[18]=l,t[19]=p,t[20]=h,t[21]=g):g=t[21],g}function fr(e){let t=(0,X.c)(32),{checked:n,onChange:r,label:i,ariaLabel:a,description:o,itemId:s,disabled:c,className:l}=e,u=c!==void 0&&c,d;t[0]!==n||t[1]!==u||t[2]!==r?(d=()=>{u||r(!n)},t[0]=n,t[1]=u,t[2]=r,t[3]=d):d=t[3];let f=d,p=pr,m=u?`cursor-not-allowed`:`cursor-pointer`,h;t[4]!==l||t[5]!==m?(h=q(`oc-settings-group-row oc-settings-split-row group`,m,l),t[4]=l,t[5]=m,t[6]=h):h=t[6];let g=u?-1:0,_=u||void 0,v,y;t[7]===f?(v=t[8],y=t[9]):(v=e=>{p(e.target)||f()},y=e=>{p(e.target)||(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),f())},t[7]=f,t[8]=v,t[9]=y);let b;t[10]===i?b=t[11]:(b=(0,Z.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i}),t[10]=i,t[11]=b);let x;t[12]===o?x=t[13]:(x=o?(0,Z.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o}):null,t[12]=o,t[13]=x);let S;t[14]!==x||t[15]!==b?(S=(0,Z.jsxs)(`div`,{className:`oc-settings-split-row-copy`,children:[b,x]}),t[14]=x,t[15]=b,t[16]=S):S=t[16];let C;t[17]!==a||t[18]!==n||t[19]!==u||t[20]!==r?(C=(0,Z.jsx)(`div`,{"data-settings-value":``,className:`oc-settings-split-row-control`,children:(0,Z.jsx)(Ve,{checked:n,onChange:r,disabled:u,ariaLabel:a})}),t[17]=a,t[18]=n,t[19]=u,t[20]=r,t[21]=C):C=t[21];let w;return t[22]!==n||t[23]!==s||t[24]!==S||t[25]!==C||t[26]!==h||t[27]!==g||t[28]!==_||t[29]!==v||t[30]!==y?(w=(0,Z.jsxs)(`div`,{"data-settings-item":s,className:h,role:`button`,tabIndex:g,"aria-pressed":n,"aria-disabled":_,onClick:v,onKeyDown:y,children:[S,C]}),t[22]=n,t[23]=s,t[24]=S,t[25]=C,t[26]=h,t[27]=g,t[28]=_,t[29]=v,t[30]=y,t[31]=w):w=t[31],w}function pr(e){return e instanceof HTMLElement&&e.closest(`button, a, input, select, textarea`)!==null}function mr(e,t,n){return Math.min(n,Math.max(t,e))}function hr(e){if(!Number.isFinite(e))return 0;let t=String(e);if(t.includes(`e-`)){let[,e]=t.split(`e-`);return Number(e)||0}let n=t.split(`.`);return n.length===2?n[1].length:0}function gr(e,t){let n=hr(t);return n<=0?e:Number(e.toFixed(n))}var _r=$.forwardRef(({value:e,onValueChange:t,min:n=-1/0,max:r=1/0,step:i=1,className:a,containerClassName:o,onBlur:s,disabled:c,fallbackValue:l,onClear:u,emptyLabel:d=`—`,...f},p)=>{let{t:m}=he(),[h,g]=$.useState(()=>e===void 0?``:String(e)),{isMobile:_}=Ct(),v=$.useRef(!1),y=$.useRef(null),b=$.useCallback(()=>{if(typeof document>`u`||typeof window>`u`)return;y.current?.();let e=e=>{e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation?.(),y.current?.()},t=window.setTimeout(()=>{y.current?.()},700);y.current=()=>{window.clearTimeout(t),document.removeEventListener(`click`,e,!0),y.current=null},document.addEventListener(`click`,e,!0)},[]);$.useEffect(()=>()=>{y.current?.()},[]),$.useEffect(()=>{g(e===void 0?``:String(e))},[e]);let x=$.useMemo(()=>e===void 0?l===void 0?Number.isFinite(n)?n:0:l:e,[l,n,e]),S=$.useRef(x);$.useEffect(()=>{S.current=x},[x]);let C=$.useCallback(e=>{let a=gr(mr(e,n,r),i);S.current=a,t(a)},[r,n,t,i]),w=$.useCallback(e=>{let t=e.target.value;if(g(t),t.trim()===``){u?.();return}let n=Number(t);Number.isFinite(n)&&C(n)},[C,u]),T=$.useCallback(t=>{if(h.trim()===``){u||g(e===void 0?``:String(e)),s?.(t);return}let a=Number(h);if(!Number.isFinite(a))g(e===void 0?``:String(e));else{let t=gr(mr(a,n,r),i);t===e?S.current=t:C(a),g(String(t))}s?.(t)},[C,h,r,n,s,u,i,e]),E=!!(c||x>=r),D=!!(c||x<=n),O=()=>{D||C(S.current-i)},k=()=>{E||C(S.current+i)},A=e=>t=>{t.preventDefault(),t.stopPropagation(),v.current=!0,b(),e()},j=e=>t=>{if(v.current){v.current=!1,t.preventDefault(),t.stopPropagation();return}e()};return _?(0,Z.jsxs)(`div`,{"data-slot":`number-input`,className:q(`flex h-9 shrink-0 items-stretch overflow-x-hidden overflow-y-hidden rounded-lg border border-border bg-transparent select-none overscroll-contain`,`[-webkit-user-select:none] [-webkit-touch-callout:none]`,`disabled:pointer-events-none disabled:opacity-50`,o),children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.decreaseAria`),disabled:D,onTouchStart:A(O),onClick:j(O),className:q(`grid h-full min-h-0 w-9 place-items-center overflow-x-hidden overflow-y-hidden border-r border-border p-0 leading-none touch-none`,`text-muted-foreground`,`disabled:pointer-events-none disabled:opacity-50`,!D&&`active:bg-interactive-hover`),children:(0,Z.jsx)(J,{name:`subtract`,className:`block h-4 w-4`})}),(0,Z.jsx)(`div`,{"data-slot":`number-input-value`,className:q(`flex h-full min-w-0 w-14 items-center justify-center bg-transparent px-1.5`,`text-center text-[16px] leading-none text-foreground [font-variant-numeric:tabular-nums]`,a),"aria-live":`polite`,children:e===void 0?d:h}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.increaseAria`),disabled:E,onTouchStart:A(k),onClick:j(k),className:q(`grid h-full min-h-0 w-9 place-items-center overflow-x-hidden overflow-y-hidden border-l border-border p-0 leading-none touch-none`,`text-muted-foreground`,`disabled:pointer-events-none disabled:opacity-50`,!E&&`active:bg-interactive-hover`),children:(0,Z.jsx)(J,{name:`add`,className:`block h-4 w-4`})})]}):(0,Z.jsxs)(`div`,{"data-slot":`number-input`,className:q(`flex h-7 shrink-0 items-stretch overflow-x-hidden overflow-y-hidden rounded-lg border border-border bg-transparent`,`disabled:pointer-events-none disabled:opacity-50`,o),children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.decreaseAria`),disabled:D,onClick:()=>C(S.current-i),className:q(`flex h-full w-7 items-center justify-center overflow-x-hidden overflow-y-hidden border-r border-border p-0 leading-none touch-manipulation`,`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`,`disabled:pointer-events-none disabled:opacity-50`),children:(0,Z.jsx)(J,{name:`subtract`,className:`block h-3.5 w-3.5`})}),(0,Z.jsx)(`input`,{...f,"data-slot":`number-input-value`,ref:p,type:`text`,inputMode:f.inputMode??`numeric`,value:h,onChange:w,onBlur:T,disabled:c,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,className:q(`h-full min-w-0 w-14 bg-transparent px-1.5 text-center typography-ui-label leading-none text-foreground [font-variant-numeric:tabular-nums]`,`placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground`,`appearance-none outline-none [appearance:textfield] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,`disabled:pointer-events-none disabled:cursor-not-allowed`,a)}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.increaseAria`),disabled:E,onClick:()=>C(S.current+i),className:q(`flex h-full w-7 items-center justify-center overflow-x-hidden overflow-y-hidden border-l border-border p-0 leading-none touch-manipulation`,`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`,`disabled:pointer-events-none disabled:opacity-50`),children:(0,Z.jsx)(J,{name:`add`,className:`block h-3.5 w-3.5`})})]})});_r.displayName=`NumberInput`;var vr=`/mcp/oauth/callback`,yr=e=>{if(typeof window>`u`)return null;try{let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t.length%4==0?``:`=`.repeat(4-t.length%4),r=window.atob(t+n),i=Uint8Array.from(r,e=>e.charCodeAt(0));return new TextDecoder().decode(i)}catch{return null}},br=e=>{let t=Sr(e.get(`state`));if(t)return t;let n=e.get(`server`);if(typeof n!=`string`||!n.trim())return null;let r=e.get(`directory`);return{name:n.trim(),directory:typeof r==`string`&&r.trim()?r.trim():null}},xr=e=>{let t=e.get(`state`);return typeof t==`string`&&t.trim()||null},Sr=e=>{if(typeof e!=`string`||!e.trim())return null;let t=yr(e.trim());if(!t)return null;try{let e=JSON.parse(t);return e?.v!==1||typeof e.n!=`string`||!e.n.trim()?null:{name:e.n.trim(),directory:typeof e.d==`string`&&e.d.trim()?e.d.trim():null}}catch{return null}},Cr=e=>typeof e==`object`&&!!e&&`updateStatus`in e&&typeof e.updateStatus==`function`,wr=e=>{let t=document.createElement(`div`);t.className=`cm-vim-panel`;let n=Wt(e);if(!n)return{top:!1,dom:t};n.state.statusbar=t;let r=n.state.vimPlugin;return Cr(r)&&r.updateStatus(),{top:!1,dom:t,destroy(){n.state.statusbar===t&&(n.state.statusbar=null)}}};function Tr(e){return e?[Ut(),me.of(wr),pe()]:[]}var Er={next:`Next match`,prev:`Previous match`,select:`Select all matches`,replace:`Replace`,replaceAll:`Replace all`,close:`Close`},Dr={case:`Match case`,re:`Regular expression`,word:`Match whole word`};function Or(e){let t=e.querySelector(`.cm-search`);if(t){for(let[e,n]of Object.entries(Er)){let r=t.querySelector(`button[name="${e}"]`);r&&!r.title&&(r.title=n)}for(let[e,n]of Object.entries(Dr)){let r=t.querySelector(`input[name="${e}"]`)?.parentElement;r&&!r.title&&(r.title=n)}}}var kr=new WeakMap;function Ar(e,t){let n=zt(e.state);if(!n.valid)return kr.delete(e),0;let r=kr.get(e);if(!t&&r?.doc===e.state.doc&&r.query.eq(n))return r.total;let i=n.getCursor(e.state),a=0;for(let e=i.next();!e.done;e=i.next())a+=1;return kr.set(e,{query:n,doc:e.state.doc,total:a}),a}function jr(e){let t=zt(e.state);if(!t.valid)return 0;let n=e.state.selection.main,r=t.getCursor(e.state),i=0,a=0;for(let e=r.next();!e.done;e=r.next()){let t=e.value;if(i+=1,a===0&&(a=i),n.from===t.from&&n.to===t.to||n.from<t.to&&n.to>t.from||t.from>=n.head)return i}return a}function Mr(e,t,n=!1){let r=e.querySelector(`.cm-search`);if(!r)return;let i=r.querySelector(`.cm-search-message`);if(!i){i=document.createElement(`span`),i.className=`cm-search-message`,i.setAttribute(`aria-live`,`polite`);let e=r.querySelector(`button[name="next"]`),t=e?.parentNode===r?e:r.firstChild;r.insertBefore(i,t)}let a=Ar(t,n),o=a===0?0:jr(t);i.textContent=a===0?``:`${o}/${a}`}var Nr=new U,Pr=new U,Fr=new U,Ir=new U,Lr=new U,Rr=new U,zr=new U,Br=e=>e,Vr=ie,Hr=Lt,Ur=Vt,Wr=class extends te{id;containerMap;constructor(e,t){super(),this.id=e,this.containerMap=t}toDOM(){let e=this.containerMap.get(this.id);return e||(e=document.createElement(`div`),e.className=`oc-block-widget`,e.dataset.widgetId=this.id,this.containerMap.set(this.id,e)),e}eq(e){return e.id===this.id}destroy(){}},Gr=(e,t)=>!e||e.length===0?[]:le.define({create(n){let r=new fe,i=[...e].sort((e,t)=>e.afterLine-t.afterLine);for(let e of i){let i=n.doc.lines;if(e.afterLine>i)continue;let a=n.doc.line(e.afterLine);r.add(a.to,a.to,z.widget({widget:new Wr(e.id,t),block:!0,side:1}))}return r.finish()},update(e,t){return e.map(t.changes)},provide:e=>H.decorations.from(e)}),Kr=e=>{if(!e)return[];let t=Math.max(1,e.start),n=Math.max(t,e.end);return ee.fromClass(class{decorations;constructor(e){this.decorations=this.build(e)}update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=this.build(e.view))}build(e){let r=new fe;for(let i=t;i<=n&&i<=e.state.doc.lines;i+=1){let t=e.state.doc.line(i);r.add(t.from,t.from,z.line({class:`oc-cm-selected-line`}))}return r.finish()}},{decorations:e=>e.decorations})};function qr({value:e,onChange:t,extensions:n,className:r,readOnly:i,lineNumbersConfig:a,highlightLines:o,onViewReady:s,onViewDestroy:c,blockWidgets:l,enableSearch:u,searchOpen:d,onSearchOpenChange:f,vimMode:p}){let m=$.useRef(null),h=$.useRef(null),g=$.useRef(e),_=$.useRef(t),v=$.useRef(s),y=$.useRef(c),b=$.useRef(f),x=$.useRef(l),S=$.useRef(p),C=$.useRef(new Map),[w,T]=$.useState([]),E=$.useCallback(e=>{let t=(e??[]).map(e=>{let t=C.current.get(e.id);return t?{id:e.id,content:e.content,container:t}:null}).filter(e=>e!==null);T(e=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.id===r.id&&e.content===r.content&&e.container===r.container})?e:t)},[]),D=$.useCallback(e=>{let t=m.current,n=e??h.current;if(!t||!n)return;let r=n.dom.querySelector(`.cm-gutters`),i=r instanceof HTMLElement?r.getBoundingClientRect().width:0;t.style.setProperty(`--oc-editor-gutter-width`,`${i}px`)},[]);return $.useEffect(()=>{g.current=e},[e]),$.useEffect(()=>{_.current=t},[t]),$.useEffect(()=>{v.current=s,y.current=c},[s,c]),$.useEffect(()=>{b.current=f},[f]),$.useEffect(()=>{x.current=l,E(l)},[l,E]),$.useEffect(()=>{if(!m.current)return;let e=(()=>{if(typeof document>`u`)return null;let e=document.querySelector(`meta[name="csp-nonce"]`)?.getAttribute(`content`);if(e)return e;let t=window.__OPENCHAMBER_CSP_NONCE__;return typeof t==`string`&&t.length>0?t:null})(),t=ue.create({doc:g.current,extensions:[...e?[H.cspNonce.of(e)]:[],ae({fixed:!0}),Nr.of(re(a)),Ft(),R.of(` `),zr.of(Tr(p)),oe.of([Pt,...Nt,...It]),H.updateListener.of(e=>{D(e.view),(e.viewportChanged||e.geometryChanged)&&E(x.current);let t=Rt(e.startState),n=Rt(e.state);t!==n&&b.current?.(n);let r=!zt(e.startState).eq(zt(e.state));if(n&&(t!==n||r||e.docChanged||e.selectionSet)&&Mr(e.view.dom,e.view,t!==n||r||e.docChanged),!e.docChanged)return;let i=e.state.doc.toString();g.current=i,_.current(i),E(x.current)}),Pr.of(H.editable.of(!i)),Fr.of(n??[]),Ir.of(Kr(o)),Lr.of(Gr(l,C.current)),Rr.of(u?[Bt({top:!0}),oe.of(Br(Ht))]:[])]});return h.current=new H({state:t,parent:m.current}),Vr(h.current,h.current.state.doc.length,200),h.current.requestMeasure(),requestAnimationFrame(()=>{D(h.current),E(x.current)}),h.current&&v.current?.(h.current),()=>{y.current?.(),h.current?.destroy(),h.current=null,T([])}},[x,D,E]),$.useEffect(()=>{let e=h.current;e&&(e.dispatch({effects:[Nr.reconfigure(re(a)),Pr.reconfigure(H.editable.of(!i)),Fr.reconfigure(n??[]),Ir.reconfigure(Kr(o)),Lr.reconfigure(Gr(l,C.current)),Rr.reconfigure(u?[Bt({top:!0}),oe.of(Br(Ht))]:[])]}),Vr(e,e.state.doc.length,200),e.requestMeasure(),requestAnimationFrame(()=>{D(e),E(x.current)}))},[n,o,a,i,l,u,D,E]),$.useEffect(()=>{let e=h.current;if(!e){S.current=p;return}S.current!==p&&(S.current=p,e.dispatch({effects:zr.reconfigure(Tr(p))}))},[p]),$.useEffect(()=>{let e=h.current;!e||u===!1||(d?(Hr(e),requestAnimationFrame(()=>{Or(e.dom),Mr(e.dom,e,!0)})):Ur(e))},[d,u]),$.useEffect(()=>{let t=h.current;if(!t)return;let n=t.state.doc.toString();n!==e&&(t.dispatch({changes:{from:0,to:n.length,insert:e}}),Vr(t,t.state.doc.length,300),t.requestMeasure(),requestAnimationFrame(()=>D(t)))},[e,D]),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{ref:m,className:q(`h-full w-full`,`[&_.cm-editor]:h-full [&_.cm-editor]:w-full`,`[&_.cm-scroller]:font-mono [&_.cm-scroller]:text-[var(--text-code)] [&_.cm-scroller]:leading-6`,`[&_.cm-lineNumbers]:text-[var(--tools-edit-line-number)]`,r)}),w.map(e=>(0,cr.createPortal)(e.content,e.container,e.id))]})}function Jr(e,t){let n=e.metadata.variant===`dark`,r=e.config?.fonts?.mono||`monospace`,i=e.colors.syntax.highlights||{},a=e.colors.syntax.tokens||{},o=t?.fontSize?`${t.fontSize}px`:`var(--text-code)`,s=H.theme({"&":{backgroundColor:`var(--background)`,color:e.colors.syntax.base.foreground,fontSize:o,lineHeight:`1.5`,position:`relative`},".cm-scroller":{fontFamily:r,backgroundColor:`var(--background)`},".cm-comment":{color:e.colors.syntax.base.comment},".cm-keyword":{color:e.colors.syntax.base.keyword},".cm-string":{color:e.colors.syntax.base.string},".cm-string-2":{color:a.stringEscape||e.colors.syntax.base.string},".cm-number":{color:e.colors.syntax.base.number},".cm-operator":{color:e.colors.syntax.base.operator},".cm-punctuation":{color:a.punctuation||e.colors.syntax.base.comment},".cm-atom":{color:a.boolean||e.colors.syntax.base.number},".cm-builtin":{color:a.functionCall||e.colors.syntax.base.function},".cm-def":{color:a.variableGlobal||e.colors.syntax.base.variable},".cm-attribute":{color:a.variableOther||a.variableProperty||e.colors.syntax.base.operator},".cm-meta":{color:e.colors.syntax.base.comment},".cm-property":{color:a.variableProperty||e.colors.syntax.base.keyword},".cm-variable":{color:e.colors.syntax.base.variable},".cm-variable-2":{color:a.variableOther||e.colors.syntax.base.function},".cm-variable-3":{color:a.variableGlobal||e.colors.syntax.base.type},".cm-tag":{color:a.tag||e.colors.syntax.base.keyword},".cm-link":{color:a.url||e.colors.syntax.base.keyword,textDecoration:`underline`},".cm-content":{caretColor:e.colors.interactive.cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:e.colors.interactive.cursor},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e.colors.interactive.selection},".cm-gutters":{backgroundColor:`var(--background)`,color:i.lineNumber||e.colors.syntax.base.comment,borderRight:`1px solid ${e.colors.interactive.border}`,position:`sticky`,paddingRight:`8px`,left:0,zIndex:2,boxShadow:`0 0 0 var(--background)`},".cm-gutter":{backgroundColor:`var(--background)`},".cm-gutterElement":{backgroundColor:`var(--background)`},".cm-lineNumbers":{backgroundColor:`var(--background)`},".cm-lineNumbers .cm-gutterElement":{paddingLeft:`8px`,paddingRight:`8px`,minWidth:`42px`},".cm-activeLineGutter":{color:i.lineNumberActive||e.colors.syntax.base.foreground},".cm-activeLine":{backgroundColor:e.colors.surface.overlay},".cm-panels":{backgroundColor:`transparent`,color:e.colors.surface.foreground,position:`absolute`,top:`0`,right:`0`,left:`auto`,width:`auto`,zIndex:10,pointerEvents:`none`},".cm-panels-top":{borderBottom:`none`,position:`absolute`,top:`6px`,right:`14px`,left:`auto`,width:`auto`},".cm-panels-bottom":{position:`static`,width:`100%`,pointerEvents:`auto`},".cm-panels-bottom .cm-vim-panel":{borderTop:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.elevated,color:e.colors.surface.mutedForeground,fontFamily:`var(--font-mono)`,fontSize:`12px`,minHeight:`22px`,padding:`2px 8px`},".cm-panel.cm-search":{pointerEvents:`auto`,padding:`4px`,backgroundColor:`color-mix(in srgb, ${e.colors.surface.elevated} 85%, transparent)`,border:`1px solid ${e.colors.interactive.border}`,borderRadius:`10px`,boxShadow:`0 2px 8px color-mix(in srgb, ${e.colors.surface.background} 60%, transparent)`,width:`auto`,minWidth:`360px`,maxWidth:`480px`},".cm-search":{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:`0`,width:`100%`,color:e.colors.surface.foreground,fontFamily:`inherit`,fontSize:`13px`,lineHeight:`1`},".cm-search br":{display:`none`},".cm-search .cm-textfield":{appearance:`none`,height:`26px`,margin:0,padding:`0 8px`,borderRadius:`6px !important`,border:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.background,color:e.colors.surface.foreground,fontFamily:`inherit`,fontSize:`12px`,lineHeight:`1`,outline:`none`,transition:`border-color 150ms ease`},".cm-search .cm-textfield::placeholder":{color:e.colors.surface.mutedForeground,opacity:1},".cm-search .cm-textfield:focus":{borderColor:e.colors.primary.base},'.cm-search .cm-textfield[name="search"]':{order:1,flex:`1 1 120px`,maxWidth:`calc(100% - 142px)`,minWidth:`100px`},".cm-search label":{order:2,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:0,marginLeft:`1px`,padding:0,borderRadius:`4px`,border:`1px solid transparent`,backgroundColor:`transparent`,color:`transparent`,cursor:`pointer`,userSelect:`none`,fontSize:`1px`,lineHeight:`0`,overflow:`hidden`,position:`relative`,transition:`background-color 120ms ease, border-color 120ms ease`},".cm-search label:hover":{backgroundColor:e.colors.interactive.hover},'.cm-search label:has(input[type="checkbox"]:checked)':{backgroundColor:e.colors.interactive.hover,borderColor:e.colors.interactive.border},'.cm-search [type="checkbox"]':{appearance:`none`,WebkitAppearance:`none`,width:`0`,height:`0`,margin:`0`,padding:`0`,border:`none`,position:`absolute`,opacity:`0`,pointerEvents:`none`},".cm-search label::after":{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,fontSize:`13px`,fontWeight:`600`,lineHeight:`1`,fontFamily:`inherit`,color:e.colors.surface.mutedForeground,pointerEvents:`none`},".cm-search label:hover::after":{color:e.colors.surface.foreground},'.cm-search label:has(input[type="checkbox"]:checked)::after':{color:e.colors.surface.foreground},'.cm-search label:has(input[name="case"])::after':{content:`"Aa"`,fontSize:`12px`,letterSpacing:`-0.5px`},'.cm-search label:has(input[name="re"])::after':{content:`".*"`,fontSize:`13px`,fontFamily:`monospace`},'.cm-search label:has(input[name="word"])::after':{content:`"ab"`,fontSize:`12px`,textDecoration:`underline`,textUnderlineOffset:`2px`},".cm-search .cm-search-message":{order:3,color:e.colors.surface.mutedForeground,backgroundColor:`transparent`,border:`none`,borderRadius:`0`,padding:`0 6px`,fontSize:`11px`,whiteSpace:`nowrap`,lineHeight:`26px`},".cm-search .cm-button":{appearance:`none`,WebkitAppearance:`none`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:0,marginLeft:`1px`,padding:0,borderRadius:`4px`,border:`none`,backgroundColor:`transparent`,backgroundImage:`none`,color:`transparent`,cursor:`pointer`,fontSize:`1px`,fontWeight:`400`,lineHeight:`0`,overflow:`hidden`,position:`relative`,boxShadow:`none`,transition:`background-color 120ms ease`},".cm-search .cm-button::after":{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,fontSize:`15px`,lineHeight:`1`,color:e.colors.surface.mutedForeground,pointerEvents:`none`},".cm-search .cm-button:hover":{backgroundColor:e.colors.interactive.hover},".cm-search .cm-button:hover::after":{color:e.colors.surface.foreground},".cm-search .cm-button:active":{backgroundColor:e.colors.interactive.active},".cm-search .cm-button:focus-visible":{outline:`none`,boxShadow:`0 0 0 1px ${e.colors.interactive.focusRing}`},".cm-search .cm-button:disabled":{opacity:.4,cursor:`default`,pointerEvents:`none`},'.cm-search .cm-button[name="prev"]':{order:21,marginTop:`2px`},'.cm-search .cm-button[name="prev"]::after':{content:`"↑"`},'.cm-search .cm-button[name="next"]':{order:22,marginTop:`2px`},'.cm-search .cm-button[name="next"]::after':{content:`"↓"`},'.cm-search .cm-button[name="select"]':{order:23,marginTop:`2px`},'.cm-search .cm-button[name="select"]::after':{content:`"≡"`,fontSize:`17px`},'.cm-panel.cm-search button[name="close"]':{order:5,appearance:`none`,WebkitAppearance:`none`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:`0 0 0 auto`,padding:`0`,borderRadius:`4px`,border:`none`,backgroundColor:`transparent`,backgroundImage:`none`,color:e.colors.surface.mutedForeground,cursor:`pointer`,fontSize:`16px`,lineHeight:`1`,boxShadow:`none`,position:`relative`,overflow:`visible`,transition:`background-color 120ms ease, color 120ms ease`},'.cm-panel.cm-search button[name="close"]:hover':{backgroundColor:e.colors.interactive.hover,color:e.colors.surface.foreground},'.cm-search .cm-button[name="replace"]':{order:24,marginTop:`2px`},'.cm-search .cm-button[name="replace"]::after':{content:`"⇄"`},'.cm-search .cm-button[name="replaceAll"], .cm-search .cm-button[name="replace-all"]':{order:25,marginTop:`2px`},'.cm-search .cm-button[name="replaceAll"]::after, .cm-search .cm-button[name="replace-all"]::after':{content:`"⇉"`},'.cm-search .cm-textfield[name="replace"]':{order:20,flex:`1 1 100%`,maxWidth:`calc(100% - 142px)`,minWidth:`80px`,marginTop:`2px`},".cm-searchMatch":{backgroundColor:e.colors.status.infoBackground,boxShadow:`inset 0 0 0 1px ${e.colors.status.infoBorder}`,borderRadius:`2px`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:e.colors.interactive.selection,color:e.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${e.colors.interactive.borderFocus}`},"&.cm-focused":{outline:`none`}},{dark:n}),c=se.define([{tag:[V.comment,V.docComment,V.meta,V.documentMeta],class:`cm-comment`},{tag:[V.keyword,V.controlKeyword,V.moduleKeyword,V.definitionKeyword,V.modifier],class:`cm-keyword`},{tag:[V.operatorKeyword,V.operator,V.derefOperator,V.updateOperator,V.definitionOperator,V.typeOperator,V.controlOperator,V.logicOperator,V.bitwiseOperator,V.arithmeticOperator,V.compareOperator],class:`cm-operator`},{tag:[V.punctuation,V.separator,V.bracket,V.paren,V.brace,V.squareBracket,V.angleBracket],class:`cm-punctuation`},{tag:[V.string,V.regexp,V.attributeValue,V.special(V.string),V.monospace],class:`cm-string`},{tag:V.escape,class:`cm-string-2`},{tag:[V.number,V.bool,V.atom,V.null,V.self],class:`cm-number`},{tag:[V.function(V.variableName),V.function(V.definition(V.variableName)),V.function(V.propertyName),V.standard(V.variableName),V.special(V.variableName)],class:`cm-builtin`},{tag:V.definition(V.variableName),class:`cm-def`},{tag:[V.variableName,V.local(V.variableName),V.constant(V.variableName),V.literal],class:`cm-variable`},{tag:V.propertyName,class:`cm-property`},{tag:V.attributeName,class:`cm-attribute`},{tag:[V.className,V.typeName,V.namespace],class:`cm-variable-3`},{tag:[V.tagName,V.labelName,V.annotation,V.macroName],class:`cm-tag`},{tag:V.link,class:`cm-link`},{tag:[V.heading,V.heading1,V.heading2,V.heading3,V.heading4,V.heading5,V.heading6],class:`cm-keyword`}]),l=se.define([{tag:[V.comment,V.docComment,V.meta,V.documentMeta],color:e.colors.syntax.base.comment},{tag:[V.keyword,V.controlKeyword,V.moduleKeyword,V.definitionKeyword,V.modifier],color:e.colors.syntax.base.keyword},{tag:[V.operatorKeyword,V.operator,V.derefOperator,V.updateOperator,V.definitionOperator,V.typeOperator,V.controlOperator,V.logicOperator,V.bitwiseOperator,V.arithmeticOperator,V.compareOperator],color:e.colors.syntax.base.operator},{tag:[V.string,V.regexp,V.attributeValue,V.special(V.string),V.monospace],color:e.colors.syntax.base.string},{tag:V.escape,color:a.stringEscape||e.colors.syntax.base.string},{tag:[V.number,V.bool,V.atom,V.null,V.self],color:e.colors.syntax.base.number},{tag:[V.function(V.variableName),V.function(V.definition(V.variableName)),V.function(V.propertyName),V.standard(V.variableName),V.special(V.variableName)],color:e.colors.syntax.base.function},{tag:V.definition(V.variableName),color:a.variableGlobal||e.colors.syntax.base.variable},{tag:[V.variableName,V.local(V.variableName),V.constant(V.variableName),V.literal],color:e.colors.syntax.base.variable},{tag:V.propertyName,color:a.variableProperty||e.colors.syntax.base.variable},{tag:V.attributeName,color:a.variableOther||e.colors.syntax.base.variable},{tag:[V.className,V.typeName,V.namespace],color:e.colors.syntax.base.type},{tag:[V.tagName,V.labelName,V.annotation,V.macroName],color:a.tag||e.colors.syntax.base.keyword},{tag:V.link,color:a.url||e.colors.syntax.base.function,textDecoration:`underline`},{tag:[V.punctuation,V.separator,V.bracket,V.paren,V.brace,V.squareBracket,V.angleBracket],color:a.punctuation||e.colors.syntax.base.comment}]);return t?.syntaxColors===!1?[s]:[s,B(ce,{fallback:!0}),B(ne),B(c),B(l)]}var Yr=180,Xr=de.define(),Zr=1,Qr=2,$r=4,ei=new Map,ti=(e,t)=>{let n=`${e}|${t}`,r=ei.get(n);if(r)return r;let i=``;e&&(i+=`color:${e};`),t&Zr&&(i+=`font-style:italic;`),t&Qr&&(i+=`font-weight:bold;`),t&$r&&(i+=`text-decoration:underline;`);let a=z.mark({attributes:{style:i}});return ei.set(n,a),a},ni=(e,t)=>{let n=new fe,r=e.state.doc,i=Math.min(t.length,r.lines);for(let e=0;e<i;e+=1){let i=t[e];if(!i||i.length===0)continue;let a=r.line(e+1),o=a.from;for(let[e,t,r]of i){if(e<=0)continue;let i=o,s=Math.min(o+e,a.to);o+=e,!(s<=i)&&(!t&&!r||n.add(i,s,ti(t,r)))}}return n.finish()},ri=le.define({create(){return z.none},update(e,t){let n=e.map(t.changes);for(let e of t.effects)e.is(Xr)&&(n=e.value);return n},provide:e=>H.decorations.from(e)}),ii=e=>ee.fromClass(class{timer;generation=0;abortController;constructor(e){this.tokenize(e)}update(e){e.docChanged&&this.schedule(e.view)}schedule(e){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.tokenize(e)},Yr)}async tokenize(t){let n=++this.generation;this.abortController?.abort();let r=new AbortController;this.abortController=r;let i=t.state.doc.toString(),a=await kt(i,e.language,e.themeName,e.theme,{signal:r.signal,priority:`visible`});a&&(r.signal.aborted||n===this.generation&&t.state.doc.length===i.length&&t.dispatch({effects:Xr.of(ni(t,a))}))}destroy(){this.timer&&clearTimeout(this.timer),this.abortController?.abort(),this.abortController=void 0}}),ai=e=>[ri,ii(e)],oi=e=>{let t=(0,X.c)(11),{currentMode:n,onToggle:r}=e,i=n===`preview`,a=i?`Switch to edit mode`:`Switch to preview mode`,o=i?`Edit`:`Preview`,s;t[0]===i?s=t[1]:(s=i?(0,Z.jsx)(J,{name:`eye`,className:`size-4`,"aria-hidden":`true`}):(0,Z.jsx)(J,{name:`eye-off`,className:`size-4`,"aria-hidden":`true`}),t[0]=i,t[1]=s);let c;t[2]!==a||t[3]!==r||t[4]!==s?(c=(0,Z.jsx)($e,{asChild:!0,children:(0,Z.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:r,"aria-label":a,className:`h-5 w-5 p-0`,children:s})}),t[2]=a,t[3]=r,t[4]=s,t[5]=c):c=t[5];let l;t[6]===o?l=t[7]:(l=(0,Z.jsx)(et,{sideOffset:8,children:o}),t[6]=o,t[7]=l);let u;return t[8]!==c||t[9]!==l?(u=(0,Z.jsxs)(tt,{children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10],u},si=w()(E(T((e,t)=>({selectedProfileId:null,defaultGitIdentityId:null,profiles:[],globalIdentity:null,discoveredCredentials:[],isLoading:!1,setSelectedProfile:t=>{e({selectedProfileId:t})},loadProfiles:async()=>{e({isLoading:!0});let n=t().profiles;try{return e({profiles:await Fe(),isLoading:!1}),!0}catch(t){return console.error(`Failed to load git identity profiles:`,t),e({profiles:n,isLoading:!1}),!1}},loadGlobalIdentity:async()=>{try{let t=await Ie();return t&&t.userName&&t.userEmail?e({globalIdentity:{id:`global`,name:`Global Identity`,userName:t.userName,userEmail:t.userEmail,authType:t.sshCommand?`ssh`:void 0,sshKey:t.sshCommand?t.sshCommand.replace(`ssh -i `,``):null,color:`info`,icon:`house`}}):e({globalIdentity:null}),!0}catch(t){return console.error(`Failed to load global git identity:`,t),e({globalIdentity:null}),!1}},loadDiscoveredCredentials:async()=>{try{return e({discoveredCredentials:await Be()}),!0}catch(t){return console.error(`Failed to discover git credentials:`,t),e({discoveredCredentials:[]}),!1}},loadDefaultGitIdentityId:async()=>{let t=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null};try{let n=null;if(n===null){let e=C()?.settings;if(e)try{n=t(((await e.load())?.settings||{}).defaultGitIdentityId)}catch{}}if(n===null)try{let e=await g(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});e.ok&&(n=t((await e.json().catch(()=>null))?.defaultGitIdentityId))}catch{}return e({defaultGitIdentityId:n}),!0}catch(e){return console.error(`Failed to load default git identity setting:`,e),!1}},setDefaultGitIdentityId:async t=>{try{let n=typeof t==`string`?t.trim():``,r=n.length>0?n:``;return await y({defaultGitIdentityId:r}),e({defaultGitIdentityId:r.length>0?r:null}),!0}catch(e){return console.error(`Failed to save default git identity setting:`,e),!1}},createProfile:async e=>{try{let n={...e,id:e.id||`profile-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,color:e.color||`keyword`,icon:e.icon||`branch`};return await ze(n),await t().loadProfiles(),!0}catch(e){return console.error(`Failed to create git identity profile:`,e),!1}},updateProfile:async(e,n)=>{try{let r=t().profiles.find(t=>t.id===e);if(!r)throw Error(`Profile not found`);let i={...r,...n};return await Pe(e,i),await t().loadProfiles(),!0}catch(e){return console.error(`Failed to update git identity profile:`,e),!1}},deleteProfile:async n=>{try{return await Le(n),t().selectedProfileId===n&&e({selectedProfileId:null}),await t().loadProfiles(),!0}catch(e){return console.error(`Failed to delete git identity profile:`,e),!1}},getProfileById:e=>{let{profiles:n,globalIdentity:r}=t();return e===`global`?r||void 0:n.find(t=>t.id===e)},getUnimportedCredentials:()=>{let{profiles:e,discoveredCredentials:n}=t();return n.filter(t=>!e.some(e=>e.authType===`token`&&e.host===t.host))}}),{name:`git-identities-store`,storage:a(),partialize:e=>({selectedProfileId:e.selectedProfileId})}),{name:`git-identities-store`}));typeof window<`u`&&(window.__zustand_git_identities_store__=si);var ci=`w-full max-w-[30rem]`,li=e=>{let t=(0,X.c)(23),{title:n,description:r,settingsItem:i,titleAccessory:a,headerAction:o,children:s,className:c,contentClassName:l}=e,u;t[0]===n?u=t[1]:(u=(0,Z.jsx)(`span`,{className:`truncate`,children:n}),t[0]=n,t[1]=u);let d;t[2]!==u||t[3]!==a?(d=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[u,a]}),t[2]=u,t[3]=a,t[4]=d):d=t[4];let f;t[5]===o?f=t[6]:(f=o?(0,Z.jsx)(`div`,{className:`shrink-0`,children:o}):null,t[5]=o,t[6]=f);let p;t[7]!==d||t[8]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[d,f]}),t[7]=d,t[8]=f,t[9]=p):p=t[9];let m;t[10]===l?m=t[11]:(m=q(`oc-settings-group-row`,l),t[10]=l,t[11]=m);let h;t[12]!==s||t[13]!==m?(h=(0,Z.jsx)(`div`,{className:m,children:s}),t[12]=s,t[13]=m,t[14]=h):h=t[14];let g;t[15]!==r||t[16]!==p||t[17]!==h?(g=(0,Z.jsx)(lr,{className:`oc-settings-detail-group`,label:p,description:r,children:h}),t[15]=r,t[16]=p,t[17]=h,t[18]=g):g=t[18];let _;return t[19]!==c||t[20]!==i||t[21]!==g?(_=(0,Z.jsx)(`div`,{"data-settings-item":i,className:c,children:g}),t[19]=c,t[20]=i,t[21]=g,t[22]=_):_=t[22],_},ui=450,di=({projectRef:e=null})=>{let{t}=he(),{isMobile:n,isTablet:r}=Ct(),i=n||r,a=G(e=>e.getActiveProject()),o=e?.path??a?.path??null,s=Te(e=>e.getWorktreeMetadata),c=Oe(),l=A(e=>e.homeDirectory),[u,d]=$.useState([]),[f,p]=$.useState(!1),[m,h]=$.useState(!1),[g,_]=$.useState(null),[v,y]=$.useState(null),[b,x]=$.useState([]),[S,C]=$.useState(!1),w=$.useRef(!1),T=$.useMemo(()=>e?.id&&e?.path?{id:e.id,path:e.path}:!a?.id||!o?null:{id:a.id,path:o},[a?.id,o,e?.id,e?.path]),E=$.useCallback(async()=>{if(!(!T||v===!1))try{let e=await Ge(T);x(e)}catch{}},[T,v]);$.useEffect(()=>{if(!o)return;let e=!1;return y(null),(async()=>{try{let t=await Re(o);if(e)return;y(t)}catch{}})(),()=>{e=!0}},[o]),$.useEffect(()=>{if(!T){x([]),C(!1);return}if(v===!1){x([]),C(!1);return}let e=!1;return C(!0),x([]),(async()=>{try{let t=await Ge(T);if(e)return;x(t)}catch{}finally{e||C(!1)}})(),()=>{e=!0}},[T,v]),$.useEffect(()=>{if(!T)return;let e=!1;return h(!0),(async()=>{try{let[t,n]=await Promise.all([ye(T),be(T)]);if(!e){let e=t.length>0?t:[``];d(e),_(JSON.stringify(e)),p(n)}}catch{e||(d([``]),_(JSON.stringify([``])),p(!1))}finally{e||h(!1)}})(),()=>{e=!0}},[T]);let D=$.useCallback(async e=>{if(!T)return!1;let n=e.filter(e=>e.trim().length>0);try{return await ve(T,n)?(_(JSON.stringify(e)),!0):(K.error(t(`settings.openchamber.worktrees.setup.toast.saveFailed`)),!1)}catch{return K.error(t(`settings.openchamber.worktrees.setup.toast.saveFailed`)),!1}},[T,t]),O=$.useMemo(()=>g!==null&&g!==JSON.stringify(u),[g,u]);$.useEffect(()=>{if(!O||m||w.current)return;let e=window.setTimeout(()=>{w.current||(w.current=!0,(async()=>{try{await D(u)}finally{w.current=!1}})())},ui);return()=>{window.clearTimeout(e)}},[O,m,D,u]);let k=$.useCallback((e,t)=>{d(n=>{let r=[...n];return r[e]=t,r})},[]),j=$.useCallback(()=>{d(e=>[...e,``])},[]),M=$.useCallback(e=>{d(t=>{let n=t.filter((t,n)=>n!==e);return n.length>0?n:[``]})},[]),N=$.useCallback(()=>{!O||w.current||(w.current=!0,(async()=>{try{await D(u)}finally{w.current=!1}})())},[O,D,u]),P=$.useCallback(e=>{p(e),T&&Ce(T,e)},[T]),F=$.useCallback(e=>{let t=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),n=t(e.path),r=c.filter(e=>{let r=s(e.id);if(r?.path&&t(r.path)===n)return!0;let i=e.directory;return!!(i&&t(i)===n)}),i=new Set(r.map(e=>e.id)),a=[...Ee.getState().activeSessions,...Ee.getState().archivedSessions],o=e=>{let t=a.filter(t=>{let n=t.parentID;return n&&e.has(n)});if(t.length===0)return[];let n=new Set(t.map(e=>e.id));return[...t,...o(n)]},l=o(i),u=new Set,d=[...r,...l].filter(e=>!u.has(e.id)&&(u.add(e.id),!0));we.requestDelete({sessions:d,mode:`worktree`,worktree:e})},[c,s]),I=$.useMemo(()=>c.map(e=>e.id).join(`,`),[c]);$.useEffect(()=>{v&&o&&E()},[I,v,o,E]);let L=(0,Z.jsxs)(tt,{children:[(0,Z.jsx)($e,{asChild:!0,children:(0,Z.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,Z.jsxs)(et,{sideOffset:8,className:`max-w-xs`,children:[t(`settings.openchamber.worktrees.setup.tooltipPrefix`),` `,(0,Z.jsx)(`code`,{className:`font-mono text-xs bg-sidebar-accent/50 px-1 rounded`,children:`$ROOT_PROJECT_PATH`}),` `,t(`settings.openchamber.worktrees.setup.tooltipSuffix`)]})]}),R=(0,Z.jsxs)(tt,{children:[(0,Z.jsx)($e,{asChild:!0,children:(0,Z.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,Z.jsx)(et,{sideOffset:8,className:`max-w-xs`,children:t(`settings.openchamber.worktrees.list.tooltip`)})]});return o?v===!1?(0,Z.jsx)(li,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.worktrees.state.gitOnly`)})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(li,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,titleAccessory:L,children:m?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.worktrees.setup.loading`)}):(0,Z.jsxs)(`div`,{className:q(`flex flex-col gap-2`,ci),children:[u.map((e,n)=>(0,Z.jsxs)(`div`,{className:`oc-settings-group-row flex w-full items-center gap-2`,children:[(0,Z.jsx)(Qe,{value:e,onChange:e=>k(n,e.target.value),onBlur:N,placeholder:t(`settings.openchamber.worktrees.setup.commandPlaceholder`),className:`min-w-0 flex-1 font-mono text-xs`}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>M(n),className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":t(`settings.openchamber.worktrees.setup.removeCommandAria`),children:(0,Z.jsx)(J,{name:`close`,className:`h-4 w-4`})})]},n)),(0,Z.jsxs)(Y,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:j,children:[(0,Z.jsx)(J,{name:`add`,className:`h-3.5 w-3.5`}),t(`settings.openchamber.worktrees.setup.addCommand`)]}),(0,Z.jsxs)(`label`,{"data-settings-item":`projects.worktree.setup.wait`,className:`flex cursor-pointer items-center gap-2 py-1`,children:[(0,Z.jsx)(Ve,{checked:f,onChange:P,ariaLabel:t(`settings.openchamber.worktrees.setup.waitForCommandsAria`)}),(0,Z.jsx)(`span`,{className:q(`typography-ui-label font-normal`,f?`text-foreground`:`text-foreground/60`),children:t(`settings.openchamber.worktrees.setup.waitForCommands`)})]})]})}),(0,Z.jsx)(li,{title:t(`settings.openchamber.worktrees.list.title`),titleAccessory:R,children:S?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.worktrees.list.loading`)}):b.length===0?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground/70`,children:t(`settings.openchamber.worktrees.list.empty`)}):(0,Z.jsx)(`div`,{className:q(`space-y-1`,ci),children:b.map(e=>(0,Z.jsxs)(`div`,{className:`group flex w-full items-center gap-2 py-1.5`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`p`,{className:`typography-meta min-w-0 truncate text-foreground`,children:e.label||e.branch||t(`settings.openchamber.worktrees.list.detachedHead`)}),(0,Z.jsx)(`span`,{className:`typography-micro flex-shrink-0 self-center rounded bg-sidebar-accent/40 px-1.5 py-[1px] leading-none text-muted-foreground/60`,children:`OpenCode`})]}),(0,Z.jsx)(`p`,{className:`typography-micro truncate text-muted-foreground/60`,children:Me(e.path,l)})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>F(e),className:q(`flex h-7 w-7 shrink-0 items-center justify-center rounded text-muted-foreground/50 transition-opacity hover:bg-destructive/10 hover:text-destructive focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,i?`opacity-100`:`opacity-0 group-hover:opacity-100`),"aria-label":t(`settings.openchamber.worktrees.list.deleteWorktreeAria`,{name:e.branch||e.label||e.path}),children:(0,Z.jsx)(J,{name:`delete-bin`,className:`h-4 w-4`})})]},e.path))})})]}):(0,Z.jsx)(li,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.worktrees.state.selectProject`)})})},fi=(e,t)=>t.updatedAtMs-e.updatedAtMs,pi=w((e,t)=>({instances:[],statusesById:{},importCandidates:[],isLoading:!1,isSaving:!1,isImportsLoading:!1,initialized:!1,listenerReady:!1,error:null,load:async()=>{if(!t().isLoading){e({isLoading:!0,error:null});try{let[n,r]=await Promise.all([ot(),nt()]),i={};for(let e of r.sort(fi))i[e.id]=e;t().listenerReady||await ct(t=>{e(e=>({statusesById:{...e.statusesById,[t.id]:t}}))}),e({instances:n.instances,statusesById:i,isLoading:!1,initialized:!0,listenerReady:!0})}catch(t){e({isLoading:!1,error:t instanceof Error?t.message:String(t)})}}},loadImports:async()=>{if(!t().isImportsLoading){e({isImportsLoading:!0,error:null});try{e({importCandidates:await pt(),isImportsLoading:!1})}catch(t){e({isImportsLoading:!1,error:t instanceof Error?t.message:String(t)})}}},refreshStatuses:async()=>{try{let t=await nt(),n={};for(let e of t.sort(fi))n[e.id]=e;e({statusesById:n})}catch(t){e({error:t instanceof Error?t.message:String(t)})}},setInstances:async n=>{e({isSaving:!0,error:null});try{await at({instances:n}),e({instances:n,isSaving:!1}),await t().refreshStatuses()}catch(t){throw e({isSaving:!1,error:t instanceof Error?t.message:String(t)}),t}},upsertInstance:async e=>{let n=t().instances,r=n.some(t=>t.id===e.id)?n.map(t=>t.id===e.id?e:t):[e,...n];await t().setInstances(r)},createFromCommand:async(e,n,r)=>{let i=dt(e,n);r&&r.trim()&&(i.nickname=r.trim()),await t().upsertInstance(i)},removeInstance:async n=>{await bt(n).catch(()=>void 0);let r=t().instances.filter(e=>e.id!==n);await t().setInstances(r),e(e=>{let t={...e.statusesById};return delete t[n],{statusesById:t}})},connect:async n=>{e({error:null});try{await it(n),await t().refreshStatuses()}catch(t){throw e({error:t instanceof Error?t.message:String(t)}),t}},disconnect:async n=>{e({error:null});try{await bt(n),await t().refreshStatuses()}catch(t){throw e({error:t instanceof Error?t.message:String(t)}),t}},retry:async e=>{await t().connect(e)},getStatus:e=>t().statusesById[e]||null,clearError:()=>e({error:null})})),mi=450,hi=()=>h(),gi=()=>({id:hi(),name:``,command:``,icon:`play`}),_i=({projectRef:e})=>{let{t}=he(),n=$.useMemo(()=>l(),[]),r=pi(e=>e.instances),i=pi(e=>e.load),[a,o]=$.useState([]),[s,c]=$.useState(!1),[u,d]=$.useState(null),[f,p]=$.useState({}),m=$.useRef(!1),h=$.useRef(null);$.useEffect(()=>{n&&i().catch(()=>void 0)},[n,i]),$.useEffect(()=>{let t=!1;return c(!0),(async()=>{try{let n=await xe(e);if(t)return;o(n.actions),d(JSON.stringify({actions:n.actions}))}catch{if(t)return;o([]),d(JSON.stringify({actions:[]}))}finally{t||c(!1)}})(),()=>{t=!0}},[e]);let g=$.useMemo(()=>n?Gt(r):[],[r,n]),_=$.useMemo(()=>a.some(e=>e.name.trim().length===0||e.command.trim().length===0)?t(`settings.projects.actions.validation.fillNameAndCommand`):null,[a,t]),v=$.useMemo(()=>u!==null&&u!==JSON.stringify({actions:a}),[a,u]),y=$.useCallback(async n=>await Se(e,{actions:n,primaryActionId:null})?(d(JSON.stringify({actions:n})),typeof window<`u`&&window.dispatchEvent(new CustomEvent(Jt,{detail:{projectId:e.id}})),!0):(K.error(t(`settings.projects.actions.toast.saveFailed`)),!1),[e,t]);$.useEffect(()=>{if(!v||s||_||m.current)return;let e=window.setTimeout(()=>{m.current||(m.current=!0,(async()=>{try{await y(a)}finally{m.current=!1}})())},mi);return()=>{window.clearTimeout(e)}},[a,v,s,y,_]),$.useEffect(()=>{if(!v||!_||s){_||(h.current=null);return}let e=window.setTimeout(()=>{h.current!==_&&(h.current=_,K.error(_))},1e3);return()=>{window.clearTimeout(e)}},[v,s,_]);let b=$.useCallback(()=>{let e=gi();o(t=>[...t,e]),p(t=>({...t,[e.id]:!0}))},[]),x=$.useCallback(e=>{o(t=>t.filter(t=>t.id!==e)),p(t=>{let n={...t};return delete n[e],n})},[]),S=$.useCallback((e,t)=>{o(n=>n.map(n=>n.id===e?t(n):n))},[]);return(0,Z.jsxs)(li,{title:t(`settings.projects.actions.title`),description:t(`settings.projects.actions.description`),settingsItem:`projects.actions`,headerAction:(0,Z.jsxs)(Y,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:b,children:[(0,Z.jsx)(J,{name:`add`,className:`h-3.5 w-3.5`}),t(`settings.projects.actions.actions.add`)]}),contentClassName:`space-y-0`,children:[s?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.loading`)}):a.length===0?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.empty`)}):(0,Z.jsx)(`div`,{className:q(`space-y-0`,ci),children:a.map(e=>{let r=e.icon||`play`,i=qt[r]||`play`,a=f[e.id]??!1,o=e.name.trim()||t(`settings.projects.actions.state.untitled`);return(0,Z.jsxs)(Mt,{open:a,onOpenChange:t=>{p(n=>({...n,[e.id]:t}))},className:`py-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsxs)(jt,{className:`group flex-1 justify-start gap-2 rounded-md px-0 pr-1 py-1 hover:bg-[var(--interactive-hover)] focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,children:[a?(0,Z.jsx)(J,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground`}):(0,Z.jsx)(J,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground`}),(0,Z.jsx)(J,{name:i,className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:o})})]}),(0,Z.jsx)(Y,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal h-7 w-7 px-0 text-muted-foreground hover:text-[var(--status-error)]`,onClick:()=>x(e.id),children:(0,Z.jsx)(J,{name:`delete-bin`,className:`h-3.5 w-3.5`})})]}),(0,Z.jsx)(At,{className:`pt-1.5`,children:(0,Z.jsxs)(`div`,{className:`space-y-2 pb-4 pl-3 pr-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,Z.jsxs)(lt,{children:[(0,Z.jsx)(mt,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-[var(--interactive-border)] text-foreground hover:bg-[var(--interactive-hover)]`,"aria-label":t(`settings.projects.actions.field.selectIconAria`),children:(0,Z.jsx)(J,{name:i,className:`h-4 w-4`})})}),(0,Z.jsx)(st,{align:`start`,className:`w-56 p-2`,children:(0,Z.jsx)(`div`,{className:`grid grid-cols-6 gap-1`,children:Kt.map(n=>{let r=n.Icon,i=(e.icon||`play`)===n.key;return(0,Z.jsx)(`button`,{type:`button`,onClick:()=>S(e.id,e=>({...e,icon:n.key})),className:q(`inline-flex h-8 w-8 items-center justify-center rounded-md border border-transparent text-foreground hover:bg-[var(--interactive-hover)]`,i&&`border-[var(--primary-base)] bg-[var(--primary-base)]/10 text-[var(--primary-base)]`),"aria-label":t(`settings.projects.actions.field.iconAria`,{icon:n.label}),children:(0,Z.jsx)(J,{name:r,className:`h-4 w-4`})},n.key)})})})]}),(0,Z.jsx)(Qe,{value:e.name,onChange:t=>S(e.id,e=>({...e,name:t.target.value})),placeholder:t(`settings.projects.actions.field.actionNamePlaceholder`),className:`h-7 flex-1 min-w-0`})]}),(0,Z.jsxs)(`div`,{className:`py-1`,children:[(0,Z.jsx)(`p`,{className:`typography-meta mb-0.5 text-muted-foreground`,children:t(`settings.projects.actions.field.command`)}),(0,Z.jsx)(Dt,{embedded:!0,value:e.command,onChange:t=>S(e.id,e=>({...e,command:t.target.value})),placeholder:t(`settings.projects.actions.field.commandPlaceholder`),className:`min-h-[88px] w-full font-mono text-xs`})]}),(0,Z.jsxs)(`div`,{className:`py-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Z.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:t(`settings.projects.actions.field.autoOpenUrl`)}),(0,Z.jsxs)(`div`,{className:`group flex cursor-pointer items-center gap-2`,role:`button`,tabIndex:0,"aria-pressed":e.autoOpenUrl===!0,onClick:()=>S(e.id,e=>({...e,...e.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})),onKeyDown:t=>{(t.key===` `||t.key===`Enter`)&&(t.preventDefault(),S(e.id,e=>({...e,...e.autoOpenUrl===!0?{autoOpenUrl:void 0}:{autoOpenUrl:!0}})))},children:[(0,Z.jsx)(Ve,{checked:e.autoOpenUrl===!0,onChange:t=>S(e.id,e=>({...e,...t?{autoOpenUrl:!0}:{autoOpenUrl:void 0}})),ariaLabel:t(`settings.projects.actions.field.autoOpenUrlForAria`,{title:o})}),(0,Z.jsx)(`span`,{className:`typography-ui-label font-normal text-foreground/80`,children:t(`settings.projects.actions.field.autoOpenUrlDescription`)})]})]}),e.autoOpenUrl===!0?(0,Z.jsxs)(`div`,{className:`mt-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Qe,{value:e.openUrl||``,onChange:t=>S(e.id,e=>({...e,openUrl:t.target.value})),placeholder:t(`settings.projects.actions.field.overrideUrlPlaceholder`),className:`h-7 w-full max-w-[24rem]`}),(0,Z.jsxs)(tt,{children:[(0,Z.jsx)($e,{asChild:!0,children:(0,Z.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/60 cursor-help`})}),(0,Z.jsx)(et,{sideOffset:8,className:`max-w-xs`,children:t(`settings.projects.actions.field.overrideUrlTooltip`)})]})]}),n?(0,Z.jsxs)(`div`,{className:`mt-2`,children:[(0,Z.jsx)(`p`,{className:`typography-meta mb-0.5 text-muted-foreground`,children:t(`settings.projects.actions.field.desktopSshForward`)}),g.length>0?(0,Z.jsxs)(qe,{value:e.desktopOpenSshForward&&g.some(t=>t.id===e.desktopOpenSshForward)?e.desktopOpenSshForward:`__none__`,onValueChange:t=>{S(e.id,e=>({...e,...t===`__none__`?{desktopOpenSshForward:void 0}:{desktopOpenSshForward:t}}))},children:[(0,Z.jsx)(We,{className:`h-7 w-full`,children:(0,Z.jsx)(Ze,{placeholder:t(`settings.projects.actions.field.useOutputManualUrl`)})}),(0,Z.jsxs)(Ke,{children:[(0,Z.jsx)(He,{value:`__none__`,children:t(`settings.projects.actions.field.useOutputManualUrl`)}),g.map(e=>(0,Z.jsx)(He,{value:e.id,children:e.label},e.id))]})]}):(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.noDesktopSshForwards`)})]}):null]}):null]})]})})]},e.id)})}),_&&a.length>0?(0,Z.jsx)(`p`,{className:`typography-meta text-[var(--status-warning)]`,children:_}):null]})},vi=e=>{let t=(0,X.c)(123),{form:n}=e,{t:r}=he(),{currentTheme:i}=St(),{name:a,setName:o,icon:s,setIcon:c,color:l,setColor:u,iconBackground:d,setIconBackground:f,parsedDefaultModel:p,handleDefaultModelChange:m,isUploadingIcon:h,isRemovingCustomIcon:g,isDiscoveringIcon:_,pendingRemoveImageIcon:v,setPendingRemoveImageIcon:y,pendingUploadIconPreviewUrl:b,setPreviewImageFailed:x,hasPendingUploadImageIcon:S,hasCustomIcon:C,effectiveHasImageIcon:w,hasRemovableImageIcon:T,showImagePreview:E,fileInputRef:D,handleUploadIcon:O,handleRemoveImageIcon:k,handleDiscoverIcon:A,currentIconImage:j,project:M}=n;if(!M)return null;let N=l?Je[l]??null:null,P;t[0]===r?P=t[1]:(P=r(`settings.projects.page.field.projectName`),t[0]=r,t[1]=P);let F;t[2]===o?F=t[3]:(F=e=>o(e.target.value),t[2]=o,t[3]=F);let I;t[4]===r?I=t[5]:(I=r(`settings.projects.page.field.projectNamePlaceholder`),t[4]=r,t[5]=I);let L;t[6]!==a||t[7]!==F||t[8]!==I?(L=(0,Z.jsx)(Qe,{value:a,onChange:F,placeholder:I}),t[6]=a,t[7]=F,t[8]=I,t[9]=L):L=t[9];let R;t[10]!==P||t[11]!==L?(R=(0,Z.jsx)(ur,{label:P,itemId:`projects.name`,children:L}),t[10]=P,t[11]=L,t[12]=R):R=t[12];let ee;t[13]===r?ee=t[14]:(ee=r(`settings.projects.page.field.defaultModel`),t[13]=r,t[14]=ee);let z;t[15]===r?z=t[16]:(z=r(`settings.projects.page.field.defaultModelDescription`),t[15]=r,t[16]=z);let te;t[17]!==m||t[18]!==p.modelId||t[19]!==p.providerId?(te=(0,Z.jsx)(ft,{providerId:p.providerId,modelId:p.modelId,onChange:m,className:`oc-settings-inline-value`}),t[17]=m,t[18]=p.modelId,t[19]=p.providerId,t[20]=te):te=t[20];let ne;t[21]!==ee||t[22]!==z||t[23]!==te?(ne=(0,Z.jsx)(ur,{label:ee,description:z,descriptionPlacement:`outside`,itemId:`projects.default-model`,children:te}),t[21]=ee,t[22]=z,t[23]=te,t[24]=ne):ne=t[24];let B;t[25]===r?B=t[26]:(B=r(`settings.projects.page.field.accentColor`),t[25]=r,t[26]=B);let re;t[27]===u?re=t[28]:(re=()=>u(null),t[27]=u,t[28]=re);let ie=l===null?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-border/40 hover:border-border hover:bg-[var(--surface-muted)]`,V;t[29]===ie?V=t[30]:(V=q(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,ie),t[29]=ie,t[30]=V);let H;t[31]===r?H=t[32]:(H=r(`settings.projects.page.field.none`),t[31]=r,t[32]=H);let ae;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,Z.jsx)(J,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[33]=ae):ae=t[33];let oe;t[34]!==re||t[35]!==V||t[36]!==H?(oe=(0,Z.jsx)(`button`,{type:`button`,onClick:re,className:V,title:H,children:ae}),t[34]=re,t[35]=V,t[36]=H,t[37]=oe):oe=t[37];let se;t[38]!==l||t[39]!==u?(se=Xe.map(e=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>u(e.key),className:q(`h-7 w-7 rounded-md border transition-colors`,l===e.key?`border-2 border-foreground ring-1 ring-[var(--primary-base)]/40`:`border-transparent hover:border-border/70`),style:{backgroundColor:e.cssVar},title:e.label},e.key)),t[38]=l,t[39]=u,t[40]=se):se=t[40];let ce;t[41]!==oe||t[42]!==se?(ce=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[oe,se]}),t[41]=oe,t[42]=se,t[43]=ce):ce=t[43];let le;t[44]!==B||t[45]!==ce?(le=(0,Z.jsx)(ur,{label:B,itemId:`projects.accent-color`,children:ce}),t[44]=B,t[45]=ce,t[46]=le):le=t[46];let ue;t[47]===r?ue=t[48]:(ue=r(`settings.projects.page.field.projectIcon`),t[47]=r,t[48]=ue);let de;t[49]===O?de=t[50]:(de=e=>{let t=e.target.files?.[0]??null;O(t),e.currentTarget.value=``},t[49]=O,t[50]=de);let fe;t[51]!==D||t[52]!==de?(fe=(0,Z.jsx)(`input`,{ref:D,type:`file`,accept:`image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg`,className:`hidden`,onChange:de}),t[51]=D,t[52]=de,t[53]=fe):fe=t[53];let pe;t[54]===c?pe=t[55]:(pe=()=>c(null),t[54]=c,t[55]=pe);let U=s===null?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-border/40 hover:border-border hover:bg-[var(--surface-muted)]`,me;t[56]===U?me=t[57]:(me=q(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,U),t[56]=U,t[57]=me);let W;t[58]===r?W=t[59]:(W=r(`settings.projects.page.field.none`),t[58]=r,t[59]=W);let ge;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,Z.jsx)(J,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[60]=ge):ge=t[60];let _e;t[61]!==pe||t[62]!==me||t[63]!==W?(_e=(0,Z.jsx)(`button`,{type:`button`,onClick:pe,className:me,title:W,children:ge}),t[61]=pe,t[62]=me,t[63]=W,t[64]=_e):_e=t[64];let ve;t[65]!==N||t[66]!==s||t[67]!==c?(ve=Ye.map(e=>{let t=e.Icon;return(0,Z.jsx)(`button`,{type:`button`,onClick:()=>c(e.key),className:q(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,s===e.key?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-transparent hover:border-border hover:bg-[var(--surface-muted)]`),title:e.label,children:(0,Z.jsx)(J,{name:t,className:`w-4 h-4`,style:N&&s===e.key?{color:N}:void 0})},e.key)}),t[65]=N,t[66]=s,t[67]=c,t[68]=ve):ve=t[68];let ye;t[69]!==_e||t[70]!==ve?(ye=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[_e,ve]}),t[69]=_e,t[70]=ve,t[71]=ye):ye=t[71];let be;t[72]!==j||t[73]!==i||t[74]!==w||t[75]!==S||t[76]!==d||t[77]!==b||t[78]!==M||t[79]!==x||t[80]!==E||t[81]!==r?(be=w&&E&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Z.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:r(`settings.projects.page.field.preview`)}),(0,Z.jsx)(`span`,{className:`inline-flex h-7 w-7 items-center justify-center rounded-md border border-border/60 bg-[var(--surface-elevated)] p-1`,children:(0,Z.jsx)(`span`,{className:`inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]`,style:d?{backgroundColor:d}:void 0,children:S&&b?(0,Z.jsx)(`img`,{src:b,alt:``,className:`h-full w-full object-contain`,draggable:!1,onError:()=>x(!0)}):(0,Z.jsx)(Ue,{project:{...M,iconImage:j??M.iconImage},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:`h-full w-full object-contain`,onError:()=>x(!0)})})})]}),t[72]=j,t[73]=i,t[74]=w,t[75]=S,t[76]=d,t[77]=b,t[78]=M,t[79]=x,t[80]=E,t[81]=r,t[82]=be):be=t[82];let xe;t[83]!==w||t[84]!==d||t[85]!==f||t[86]!==r?(xe=w&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,Z.jsx)(`input`,{type:`color`,value:d??`#000000`,onChange:e=>f(e.target.value),className:`h-7 w-9 cursor-pointer rounded border border-border bg-transparent p-1`,"aria-label":r(`settings.projects.page.field.projectIconBackgroundAria`)}),(0,Z.jsx)(Qe,{value:d??``,onChange:e=>f(e.target.value),placeholder:`#000000`,className:`h-7 w-[8rem]`}),(0,Z.jsx)(Y,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>f(null),className:`h-7 w-7 p-0`,"aria-label":r(`settings.projects.page.field.clearIconBackgroundAria`),title:r(`settings.projects.page.field.clearBackground`),disabled:!d,children:(0,Z.jsx)(J,{name:`close`,className:`h-3.5 w-3.5`})})]}),t[83]=w,t[84]=d,t[85]=f,t[86]=r,t[87]=xe):xe=t[87];let Se;t[88]!==D||t[89]!==A||t[90]!==C||t[91]!==_||t[92]!==h||t[93]!==r?(Se=!C&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Y,{size:`xs`,className:`h-6 !font-normal`,onClick:()=>D.current?.click(),disabled:h,children:r(h?`settings.projects.page.actions.uploading`:`settings.projects.page.actions.uploadIcon`)}),(0,Z.jsx)(Y,{size:`xs`,className:`h-6 !font-normal`,variant:`outline`,onClick:()=>void A(),disabled:_,children:r(_?`settings.projects.page.actions.discovering`:`settings.projects.page.actions.discoverFavicon`)})]}),t[88]=D,t[89]=A,t[90]=C,t[91]=_,t[92]=h,t[93]=r,t[94]=Se):Se=t[94];let Ce;t[95]!==k||t[96]!==T||t[97]!==g||t[98]!==r?(Ce=T&&(0,Z.jsx)(Y,{size:`xs`,className:`!font-normal`,variant:`outline`,onClick:()=>void k(),disabled:g,children:r(g?`settings.projects.page.actions.removing`:`settings.projects.page.actions.removeProjectIcon`)}),t[95]=k,t[96]=T,t[97]=g,t[98]=r,t[99]=Ce):Ce=t[99];let we;t[100]!==g||t[101]!==v||t[102]!==y||t[103]!==r?(we=v&&(0,Z.jsx)(Y,{size:`xs`,className:`!font-normal`,variant:`outline`,onClick:()=>y(!1),disabled:g,children:r(`settings.projects.page.actions.undoRemove`)}),t[100]=g,t[101]=v,t[102]=y,t[103]=r,t[104]=we):we=t[104];let Te;t[105]!==Se||t[106]!==Ce||t[107]!==we?(Te=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[Se,Ce,we]}),t[105]=Se,t[106]=Ce,t[107]=we,t[108]=Te):Te=t[108];let Ee;t[109]!==fe||t[110]!==ye||t[111]!==be||t[112]!==xe||t[113]!==Te?(Ee=(0,Z.jsxs)(`div`,{className:`flex w-full flex-col items-end gap-2`,children:[fe,ye,be,xe,Te]}),t[109]=fe,t[110]=ye,t[111]=be,t[112]=xe,t[113]=Te,t[114]=Ee):Ee=t[114];let G;t[115]!==ue||t[116]!==Ee?(G=(0,Z.jsx)(ur,{label:ue,itemId:`projects.icon`,children:Ee}),t[115]=ue,t[116]=Ee,t[117]=G):G=t[117];let De;return t[118]!==le||t[119]!==G||t[120]!==R||t[121]!==ne?(De=(0,Z.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[R,ne,le,G]}),t[118]=le,t[119]=G,t[120]=R,t[121]=ne,t[122]=De):De=t[122],De},yi=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,bi=e=>{if(!e)return null;let t=e.trim();return t&&yi.test(t)?t.toLowerCase():null},xi=e=>{let{t}=he(),n=G(e=>e.uploadProjectIcon),r=G(e=>e.removeProjectIcon),i=G(e=>e.discoverProjectIcon),a=G(t=>e?t.projects.find(t=>t.id===e.id)?.iconImage??null:null),[o,s]=$.useState(``),[c,l]=$.useState(null),[u,d]=$.useState(null),[f,p]=$.useState(null),[m,h]=$.useState(void 0),[g,_]=$.useState(!1),[v,y]=$.useState(!1),[b,x]=$.useState(!1),[S,C]=$.useState(!1),[w,T]=$.useState(null),[E,D]=$.useState(null),[O,k]=$.useState(!1),A=$.useRef(null),j=$.useCallback(()=>{T(null),D(e=>(e&&URL.revokeObjectURL(e),null))},[]),M=e?.id??null;$.useEffect(()=>{if(!e){s(``),l(null),d(null),p(null),h(void 0);return}s(e.label??``),l(e.icon??null),d(e.color??null),p(e.iconBackground??null),h(e.defaultModel),C(!1),j(),k(!1)},[e,j]),$.useEffect(()=>()=>{j()},[j]);let N=$.useMemo(()=>De(m)??{providerId:``,modelId:``},[m]),P=!!e?.iconImage,F=!!(w&&E),I=e?.iconImage?.source===`custom`,L=P&&!S||F,R=L,ee=!!(e&&P&&!S),z=!O&&(F||ee),te=!!e&&(o.trim()!==(e?.label??``).trim()||c!==(e?.icon??null)||u!==(e?.color??null)||f!==(e?.iconBackground??null)||(m??void 0)!==(e?.defaultModel??void 0)||S||!!w),ne=$.useCallback((e,t)=>{h(e&&t?`${e}/${t}`:void 0)},[]),B=$.useCallback(t=>{!e||!t||g||(C(!1),k(!1),T(t),D(e=>(e&&URL.revokeObjectURL(e),URL.createObjectURL(t))))},[g,e]),re=$.useCallback(()=>{!e||!R||v||(F&&j(),C(!!P),k(!1))},[j,F,R,P,v,e]),ie=$.useCallback(async()=>{if(!(!e||b)){j(),C(!1),k(!1),x(!0);try{let n=await i(e.id);if(!n.ok){K.error(n.error||t(`settings.projects.page.toast.discoverIconFailed`));return}if(n.skipped){K.success(t(`settings.projects.page.toast.customIconAlreadySet`));return}K.success(t(`settings.projects.page.toast.iconDiscovered`))}finally{x(!1)}}},[j,i,b,e,t]),V=$.useCallback(async i=>{let a=i?.silent===!0;if(!e)return null;let s=o.trim();if(!s)return null;if(w){_(!0);let r=await n(e.id,w);if(_(!1),!r.ok)return K.error(r.error||t(`settings.projects.page.toast.uploadIconFailed`)),null;a||K.success(t(`settings.projects.page.toast.iconUpdated`)),j(),C(!1)}let l=S&&!!e.iconImage;if(l){y(!0);let n=await r(e.id);if(y(!1),!n.ok)return K.error(n.error||t(`settings.projects.page.toast.removeIconFailed`)),null;a||K.success(t(`settings.projects.page.toast.iconRemoved`)),C(!1),p(null)}return{label:s,icon:c,color:u,iconBackground:bi(l?null:f),defaultModel:m??null}},[j,u,m,c,f,o,S,w,e,r,t,n]);return $.useEffect(()=>{k(!1)},[M,a?.updatedAt]),{name:o,setName:s,icon:c,setIcon:l,color:u,setColor:d,iconBackground:f,setIconBackground:p,defaultModel:m,parsedDefaultModel:N,handleDefaultModelChange:ne,isUploadingIcon:g,isRemovingCustomIcon:v,isDiscoveringIcon:b,pendingRemoveImageIcon:S,setPendingRemoveImageIcon:C,pendingUploadIconFile:w,pendingUploadIconPreviewUrl:E,previewImageFailed:O,setPreviewImageFailed:k,hasStoredImageIcon:P,hasPendingUploadImageIcon:F,hasCustomIcon:I,effectiveHasImageIcon:L,hasRemovableImageIcon:R,showStoredImagePreview:ee,showImagePreview:z,fileInputRef:A,clearPendingUploadIcon:j,handleUploadIcon:B,handleRemoveImageIcon:re,handleDiscoverIcon:ie,hasChanges:te,prepareSaveData:V,currentIconImage:a,project:e}},Si=450,Ci=(e,t)=>{let{t:n}=he(),{hasChanges:r,name:i,icon:a,color:o,iconBackground:s,defaultModel:c,pendingRemoveImageIcon:l,pendingUploadIconFile:u,isUploadingIcon:d,isRemovingCustomIcon:f,prepareSaveData:p}=e,m=$.useRef(!1);$.useEffect(()=>{if(!r||!i.trim()||d||f||m.current)return;let e=window.setTimeout(()=>{m.current||(m.current=!0,(async()=>{try{let e=await p({silent:!0});if(e)try{await t(e)}catch{K.error(n(`settings.projects.page.toast.saveFailed`))}}finally{m.current=!1}})())},Si);return()=>{window.clearTimeout(e)}},[o,c,r,a,s,f,d,i,t,l,u,p,n])},wi=e=>{let t=(0,X.c)(25),{project:n,onIdentitySave:r}=e,{t:i}=he(),a=xi(n),o;bb0:{if(!n){o=null;break bb0}let e;t[0]!==n.id||t[1]!==n.path?(e={id:n.id,path:n.path},t[0]=n.id,t[1]=n.path,t[2]=e):e=t[2],o=e}let s=o,c;if(t[3]===r?c=t[4]:(c=async e=>{await r(e)},t[3]=r,t[4]=c),Ci(a,c),!n||!s)return null;let l;t[5]!==n.path||t[6]!==i?(l=n.path.split(/[\\/]/).filter(Boolean).at(-1)??i(`settings.projects.page.title.default`),t[5]=n.path,t[6]=i,t[7]=l):l=t[7];let u=l,d;t[8]===u?d=t[9]:(d=(0,Z.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:u}),t[8]=u,t[9]=d);let f;t[10]===n.path?f=t[11]:(f=(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,title:n.path,children:n.path}),t[10]=n.path,t[11]=f);let p;t[12]!==d||t[13]!==f?(p=(0,Z.jsxs)(`div`,{className:`px-1`,children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;t[15]===a?m=t[16]:(m=(0,Z.jsx)(vi,{form:a}),t[15]=a,t[16]=m);let h,g;t[17]===s?(h=t[18],g=t[19]):(h=(0,Z.jsx)(_i,{projectRef:s}),g=(0,Z.jsx)(di,{projectRef:s}),t[17]=s,t[18]=h,t[19]=g);let _;return t[20]!==p||t[21]!==m||t[22]!==h||t[23]!==g?(_=(0,Z.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[p,m,h,g]}),t[20]=p,t[21]=m,t[22]=h,t[23]=g,t[24]=_):_=t[24],_};function Ti(e){let t=e.indexOf(`/`);if(t!==-1){let n=e.substring(0,t);if(n===`gemini`||n===`antigravity`)return e.substring(t+1)}return e}var Ei={google:[{id:`gemini-auth`,label:`Gemini`,matcher:e=>e.startsWith(`gemini/`),order:1},{id:`antigravity-auth`,label:`Antigravity`,matcher:e=>e.startsWith(`antigravity/`),order:2}]};function Di(e,t){let n=Ei[t]??[];for(let t of n)if(t.matcher(e))return t;return null}function Oi(e){return Ei[e]??[]}function ki(e){return[...e].sort((e,t)=>e.order-t.order)}function Ai(e,t){let n=new Map;for(let r of Object.keys(e)){let e=Di(r,t)?.id??null;n.has(e)||n.set(e,[]),n.get(e).push(r)}return n}function ji(e,t,n){let r=new Map;for(let i of e){let e=Di(t(i),n)?.id??null;r.has(e)||r.set(e,[]),r.get(e).push(i)}return r}function Mi(e,t){return t.filter(e=>{let t=e.toLowerCase(),n=t.includes(`/`)?t.split(`/`)[1]:t;return!!(n.startsWith(`gemini-3-`)||n.startsWith(`claude-`))})}var Ni=6e4,Pi=0,Fi=0,Ii=new Map,Li=e=>{let t=Yt.map(e=>e.id),n=typeof e?.usageAutoRefresh==`boolean`&&e.usageAutoRefresh,r=typeof e?.usageRefreshIntervalMs==`number`&&Number.isFinite(e.usageRefreshIntervalMs)?Math.max(3e4,Math.min(3e5,Math.round(e.usageRefreshIntervalMs))):Ni,i=e?.usageDisplayMode===`remaining`?`remaining`:`usage`,a=typeof e?.usageShowPredValues==`boolean`&&e.usageShowPredValues,o=Array.isArray(e?.usageDropdownProviders)?e?.usageDropdownProviders:null,s=o?o.filter(e=>typeof e==`string`&&t.includes(e)):t,c={},l=e?.usageSelectedModels;if(l&&typeof l==`object`)for(let[e,t]of Object.entries(l))Array.isArray(t)&&(c[e]=t.filter(e=>typeof e==`string`));let u={},d=e?.usageExpandedFamilies;if(d&&typeof d==`object`)for(let[e,t]of Object.entries(d))Array.isArray(t)&&(u[e]=t.filter(e=>typeof e==`string`));return{autoRefresh:n,refreshIntervalMs:r,displayMode:i,showPredValues:a,dropdownProviderIds:s,selectedModels:c,expandedFamilies:u}},Ri=async()=>{let e=C()?.settings;if(e)try{let t=(await e.load())?.settings;return Li(t??null)}catch{}if(!o()){let e=await g(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(e.ok)return Li(await e.json().catch(()=>null))}return{autoRefresh:!1,refreshIntervalMs:Ni,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:Yt.map(e=>e.id),selectedModels:{},expandedFamilies:{}}},zi=async(e,t)=>{let n=Fi;Ii.set(e,(Ii.get(e)??0)+1),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:!0}}));try{let r=await S.fetchQuery({queryKey:f.quota(e),queryFn:({signal:t})=>b(e,t),staleTime:0,retry:!1});return n===Fi?(t(t=>{let n=t.results.filter(t=>t.providerId!==e);return n.push(r),{results:n}}),{providerId:e,result:r}):{providerId:e,stale:!0}}catch(t){return n===Fi?{providerId:e,error:t instanceof Error?t.message:`Failed to fetch quota`}:{providerId:e,stale:!0}}finally{if(n===Fi){let n=(Ii.get(e)??1)-1;n>0?Ii.set(e,n):Ii.delete(e),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:n>0}}))}}},Bi=()=>{Fi+=1,Pi+=1,Ii.clear(),Vi.setState({results:[],isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null})},Vi=w()(E((e,t)=>({results:[],selectedProviderId:null,isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null,autoRefresh:!1,refreshIntervalMs:Ni,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:Yt.map(e=>e.id),selectedModels:{},expandedFamilies:{},loadSettings:async()=>{try{e(await Ri())}catch(e){console.warn(`Failed to load usage settings:`,e)}},fetchAllQuotas:async()=>{let t=++Pi;e({isLoading:!0,error:null});let n=Yt.map(e=>e.id),r=await Promise.all(n.map(t=>zi(t,e)));if(t===Pi){let t=r.find(e=>`error`in e);e({isLoading:!1,...r.some(e=>`result`in e)?{lastUpdated:Date.now()}:{},error:t?.error??null})}},fetchProviderQuota:async t=>{let n=await zi(t,e);`stale`in n||e({error:`error`in n?n.error:null})},setSelectedProvider:t=>e({selectedProviderId:t}),setAutoRefresh:t=>e({autoRefresh:t}),setRefreshInterval:t=>{e({refreshIntervalMs:Math.max(3e4,Math.min(3e5,Math.round(t)))})},setDisplayMode:t=>e({displayMode:t}),setShowPredValues:t=>e({showPredValues:t}),setDropdownProviderIds:t=>e({dropdownProviderIds:t}),setSelectedModels:(t,n)=>{e(e=>({selectedModels:{...e.selectedModels,[t]:n}}))},toggleModelSelected:(t,n)=>{e(e=>{let r=e.selectedModels[t]??[],i=r.includes(n)?r.filter(e=>e!==n):[...r,n];return{selectedModels:{...e.selectedModels,[t]:i}}})},setExpandedFamilies:(n,r)=>{e(e=>({expandedFamilies:{...e.expandedFamilies,[n]:r}})),y({usageExpandedFamilies:t().expandedFamilies})},toggleFamilyExpanded:(n,r)=>{e(e=>{let t=e.expandedFamilies[n]??[],i=t.includes(r)?t.filter(e=>e!==r):[...t,r];return{expandedFamilies:{...e.expandedFamilies,[n]:i}}}),y({usageExpandedFamilies:t().expandedFamilies})},applyDefaultSelections:(n,r)=>{if((t().selectedModels[n]?.length??0)>0)return;let i=Mi(n,r);i.length!==0&&(e(e=>({selectedModels:{...e.selectedModels,[n]:i}})),y({usageSelectedModels:t().selectedModels}))}}),{name:`quota-store`})),Hi=()=>{let e=(0,X.c)(5),t=Vi(Ui),n=Vi(Wi),r=Vi(Gi),i,a;e[0]!==t||e[1]!==r||e[2]!==n?(i=()=>{if(!t)return;let e=window.setInterval(()=>{r()},n);return()=>window.clearInterval(e)},a=[t,n,r],e[0]=t,e[1]=r,e[2]=n,e[3]=i,e[4]=a):(i=e[3],a=e[4]),$.useEffect(i,a)};function Ui(e){return e.autoRefresh}function Wi(e){return e.refreshIntervalMs}function Gi(e){return e.fetchAllQuotas}var Ki=e=>{let t=(0,X.c)(20),{percent:n,tonePercent:r,className:i,expectedMarkerPercent:a}=e,o;t[0]===n?o=t[1]:(o=vt(n)??0,t[0]=n,t[1]=o);let s=o,c=r??n,l;t[2]===c?l=t[3]:(l=gt(c),t[2]=c,t[3]=l);let u=l,d=a==null?null:Math.max(0,Math.min(100,a)),f;t[4]===u?f=t[5]:(f=u===`critical`?{backgroundColor:`var(--status-error)`}:u===`warn`?{backgroundColor:`var(--status-warning)`}:{backgroundColor:`var(--status-success)`},t[4]=u,t[5]=f);let p=f,m;t[6]===i?m=t[7]:(m=q(`relative h-2.5 rounded-full bg-[var(--interactive-border)] overflow-hidden`,i),t[6]=i,t[7]=m);let h=`${s}%`,g;t[8]!==p||t[9]!==h?(g={...p,width:h},t[8]=p,t[9]=h,t[10]=g):g=t[10];let _;t[11]!==s||t[12]!==g?(_=(0,Z.jsx)(`div`,{className:`h-full transition-all duration-300`,style:g,role:`progressbar`,"aria-valuenow":s,"aria-valuemin":0,"aria-valuemax":100}),t[11]=s,t[12]=g,t[13]=_):_=t[13];let v;t[14]===d?v=t[15]:(v=d!=null&&d>0&&d<100&&(0,Z.jsx)(`div`,{className:`absolute top-0 h-full w-0.5 bg-foreground`,style:{left:`${d}%`},title:`Expected usage if spread evenly: ${Math.round(d)}% of quota`,"aria-hidden":`true`}),t[14]=d,t[15]=v);let y;return t[16]!==m||t[17]!==_||t[18]!==v?(y=(0,Z.jsxs)(`div`,{className:m,children:[_,v]}),t[16]=m,t[17]=_,t[18]=v,t[19]=y):y=t[19],y},qi=e=>{let t=(0,X.c)(67),{paceInfo:n,className:r,compact:i}=e,a=i!==void 0&&i,{t:o}=he(),s;t[0]===n.status?s=t[1]:(s=ht(n.status),t[0]=n.status,t[1]=s);let c=s,l;bb0:{switch(n.status){case`on-track`:{let e;t[2]===o?e=t[3]:(e=o(`settings.usage.pace.status.onTrack`),t[2]=o,t[3]=e),l=e;break bb0}case`slightly-fast`:{let e;t[4]===o?e=t[5]:(e=o(`settings.usage.pace.status.slightlyFast`),t[4]=o,t[5]=e),l=e;break bb0}case`too-fast`:{let e;t[6]===o?e=t[7]:(e=o(`settings.usage.pace.status.tooFast`),t[6]=o,t[7]=e),l=e;break bb0}case`exhausted`:{let e;t[8]===o?e=t[9]:(e=o(`settings.usage.pace.status.usedUp`),t[8]=o,t[9]=e),l=e;break bb0}}l=void 0}let u=l,d;t[10]!==n.predictText||t[11]!==o?(d=o(`settings.usage.pace.predictionTooltip`,{prediction:n.predictText}),t[10]=n.predictText,t[11]=o,t[12]=d):d=t[12];let f=d;if(a){let e;t[13]===r?e=t[14]:(e=q(`flex items-center gap-1.5`,r),t[13]=r,t[14]=e);let i;t[15]===c?i=t[16]:(i={backgroundColor:c},t[15]=c,t[16]=i);let a;t[17]!==u||t[18]!==i?(a=(0,Z.jsx)(`div`,{className:`h-2 w-2 rounded-full flex-shrink-0`,style:i,title:u}),t[17]=u,t[18]=i,t[19]=a):a=t[19];let s;t[20]===c?s=t[21]:(s={color:c},t[20]=c,t[21]=s);let l=n.isExhausted?void 0:f,d;t[22]!==n.isExhausted||t[23]!==n.predictText||t[24]!==n.remainingSeconds||t[25]!==o?(d=n.isExhausted?(0,Z.jsx)(Z.Fragment,{children:o(`settings.usage.pace.wait`,{duration:_t(n.remainingSeconds)})}):(0,Z.jsx)(Z.Fragment,{children:o(`settings.usage.pace.prediction`,{prediction:n.predictText})}),t[22]=n.isExhausted,t[23]=n.predictText,t[24]=n.remainingSeconds,t[25]=o,t[26]=d):d=t[26];let p;t[27]!==d||t[28]!==s||t[29]!==l?(p=(0,Z.jsx)(`span`,{className:`typography-micro tabular-nums`,style:s,title:l,children:d}),t[27]=d,t[28]=s,t[29]=l,t[30]=p):p=t[30];let m;return t[31]!==p||t[32]!==e||t[33]!==a?(m=(0,Z.jsxs)(`div`,{className:e,children:[a,p]}),t[31]=p,t[32]=e,t[33]=a,t[34]=m):m=t[34],m}let p;t[35]===r?p=t[36]:(p=q(`flex items-center justify-between gap-2`,r),t[35]=r,t[36]=p);let m;t[37]!==n.isExhausted||t[38]!==n.paceRateText||t[39]!==o?(m=!n.isExhausted&&(0,Z.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:o(`settings.usage.pace.rate`,{rate:n.paceRateText})}),t[37]=n.isExhausted,t[38]=n.paceRateText,t[39]=o,t[40]=m):m=t[40];let h;t[41]===m?h=t[42]:(h=(0,Z.jsx)(`div`,{className:`flex items-center gap-1.5`,children:m}),t[41]=m,t[42]=h);let g;t[43]===c?g=t[44]:(g={color:c},t[43]=c,t[44]=g);let _;t[45]!==n.isExhausted||t[46]!==n.predictText||t[47]!==n.remainingSeconds||t[48]!==f||t[49]!==u||t[50]!==o?(_=n.isExhausted?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:u}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.waitSeparator`)}),(0,Z.jsx)(`span`,{className:`font-medium`,children:_t(n.remainingSeconds)})]}):(0,Z.jsxs)(`span`,{title:f,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.predictionLabel`)}),(0,Z.jsx)(`span`,{className:`font-medium`,children:n.predictText})]}),t[45]=n.isExhausted,t[46]=n.predictText,t[47]=n.remainingSeconds,t[48]=f,t[49]=u,t[50]=o,t[51]=_):_=t[51];let v;t[52]!==g||t[53]!==_?(v=(0,Z.jsx)(`span`,{className:`typography-micro tabular-nums`,style:g,children:_}),t[52]=g,t[53]=_,t[54]=v):v=t[54];let y;t[55]===c?y=t[56]:(y={backgroundColor:c},t[55]=c,t[56]=y);let b;t[57]!==u||t[58]!==y?(b=(0,Z.jsx)(`div`,{className:`h-2 w-2 rounded-full flex-shrink-0`,style:y,title:u}),t[57]=u,t[58]=y,t[59]=b):b=t[59];let x;t[60]!==v||t[61]!==b?(x=(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[v,b]}),t[60]=v,t[61]=b,t[62]=x):x=t[62];let S;return t[63]!==x||t[64]!==p||t[65]!==h?(S=(0,Z.jsxs)(`div`,{className:p,children:[h,x]}),t[63]=x,t[64]=p,t[65]=h,t[66]=S):S=t[66],S},Ji=e=>e instanceof Error&&e.name===`CancelledError`,Yi=w(()=>({setStatus:e=>rt(S,e),refreshStatus:async(e,t)=>{let r=n();t?.force&&await S.cancelQueries({queryKey:f.github.auth(r),exact:!0});try{return await ut(S,e,r)}catch(e){if(Ji(e))return xt(S,r);throw e}}})),Xi={displayMode:`browser`,installed:!1,browserTab:!0},Zi=new Set,Qi=Xi,$i=!1,ea,ta=()=>{let e=yt();return{displayMode:e,installed:e!==`browser`,browserTab:e===`browser`}},na=()=>(!$i&&typeof window<`u`&&(Qi=ta(),$i=!0),Qi),ra=()=>{let e=ta();$i=!0,e.displayMode!==Qi.displayMode&&(Qi=e,Zi.forEach(e=>e()))},ia=()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=[window.matchMedia(`(display-mode: standalone)`),window.matchMedia(`(display-mode: minimal-ui)`),window.matchMedia(`(display-mode: fullscreen)`),window.matchMedia(`(display-mode: window-controls-overlay)`)];for(let t of e)typeof t.addEventListener==`function`?t.addEventListener(`change`,ra):typeof t.addListener==`function`&&t.addListener(ra);return window.addEventListener(`appinstalled`,ra),window.addEventListener(`focus`,ra),()=>{for(let t of e)typeof t.removeEventListener==`function`?t.removeEventListener(`change`,ra):typeof t.removeListener==`function`&&t.removeListener(ra);window.removeEventListener(`appinstalled`,ra),window.removeEventListener(`focus`,ra)}},aa=e=>(Zi.add(e),ea??=ia(),ra(),()=>{Zi.delete(e),Zi.size===0&&(ea?.(),ea=void 0)}),oa=()=>$.useSyncExternalStore(aa,na,sa);function sa(){return Xi}var ca=`OPEN CHAMBER`,la=w()(T(e=>({sidebarBrandName:ca,setSidebarBrandName:t=>{let n=t.slice(0,64);e(e=>e.sidebarBrandName===n?e:{sidebarBrandName:n})}}),{name:`sidebar-brand-store`,storage:v(),version:2,migrate:(e,t)=>{if(!e||typeof e!=`object`)return e;let n=e;return t<1&&n.sidebarBrandName===`YEE CODE`&&(n.sidebarBrandName=ca),t<2&&n.sidebarBrandName===`Open Chamber`&&(n.sidebarBrandName=ca),n}}));typeof window<`u`&&t(e=>{r(e)&&la.persist.rehydrate()});var ua=[`connection`,`personalization`,`workspace`,`opencode`,`content`,`system`],da=[`instances`,`appearance`,`chat`,`notifications`,`sessions`,`summary-ai`,`shortcuts`,`projects`,`git`,`remote-instances`,`providers`,`agents`,`assistants`,`behavior`,`commands`,`mcp`,`plugins`,`global-config`,`magic-prompts`,`snippets`,`skills.installed`,`skills.catalog`,`usage`,`voice`,`about`],fa=[`instances`,`appearance`,`chat`,`notifications`,`sessions`,`summary-ai`,`projects`,`git`,`providers`,`agents`,`assistants`,`behavior`,`commands`,`mcp`,`plugins`,`magic-prompts`,`snippets`,`skills.installed`,`usage`,`voice`,`about`],pa=[{slug:`home`,title:`Settings`,group:`personalization`,kind:`single`,description:`Search and jump to common pages.`,keywords:[`search`,`settings`]},{slug:`projects`,title:`Projects`,group:`workspace`,kind:`split`,keywords:[`project`,`projects`,`worktree`,`worktrees`,`repo`,`repository`,`directory`]},{slug:`instances`,title:`Switch instance`,group:`connection`,kind:`single`,keywords:[`instance`,`instances`,`server`,`connection`,`switch`],isAvailable:e=>e.isMobile},{slug:`remote-instances`,title:`Remote Instances`,group:`workspace`,kind:`single`,keywords:[`ssh`,`remote`,`instances`,`forwarding`,`connection`],isAvailable:e=>!e.isVSCode},{slug:`providers`,title:`Providers`,group:`opencode`,kind:`split`,keywords:[`provider`,`providers`,`models`,`model`,`api key`,`api keys`,`openai`,`anthropic`,`ollama`,`credentials`]},{slug:`usage`,title:`Usage`,group:`system`,kind:`split`,keywords:[`quota`,`billing`,`tokens`,`usage`,`limits`]},{slug:`agents`,title:`Agents`,group:`opencode`,kind:`split`,keywords:[`agent`,`agents`,`prompts`,`tools`,`permissions`]},{slug:`assistants`,title:`Assistants`,group:`opencode`,kind:`split`,keywords:[`assistant`,`assistants`,`sharing`]},{slug:`behavior`,title:`Behavior`,group:`opencode`,kind:`single`,keywords:[`behavior`,`agents.md`,`system prompt`,`global rules`,`instructions`,`override`]},{slug:`commands`,title:`Commands`,group:`opencode`,kind:`split`,keywords:[`command`,`commands`,`slash`,`macros`,`automation`]},{slug:`mcp`,title:`MCP`,group:`opencode`,kind:`split`,keywords:[`mcp`,`model context protocol`,`servers`,`tools`,`remote`,`stdio`]},{slug:`plugins`,title:`Plugins`,group:`opencode`,kind:`split`,keywords:[`plugin`,`plugins`,`extensions`,`addons`,`npm`,`opencode-wakatime`]},{slug:`global-config`,title:`Global Configuration`,group:`opencode`,kind:`single`,keywords:[`global`,`configuration`,`opencode.json`,`opencode.jsonc`,`oh-my-opencode`,`oh-my-openagent`]},{slug:`skills.installed`,title:`Skills`,group:`content`,kind:`split`,keywords:[`skill`,`skills`,`instructions`,`install`,`catalog`]},{slug:`skills.catalog`,title:`Skills Catalog`,group:`content`,kind:`single`,keywords:[`install`,`catalog`,`external`,`repository`,`skills catalog`]},{slug:`git`,title:`Git`,group:`workspace`,kind:`single`,keywords:[`git`,`github`,`identity`,`identities`,`ssh`,`profiles`,`credentials`,`keys`,`commit`,`gitmoji`,`oauth`,`prs`,`issues`],isAvailable:e=>!e.isVSCode},{slug:`appearance`,title:`Appearance`,group:`personalization`,kind:`single`,keywords:[`theme`,`font`,`spacing`,`padding`,`corner radius`,`radius`,`input bar`,`keyboard`,`viewport`,`mobile`,`terminal`,`pwa`,`install name`,`app shortcuts`]},{slug:`chat`,title:`Chat`,group:`personalization`,kind:`single`,keywords:[`tools`,`diff`,`reasoning`,`dotfiles`,`draft`,`queue`,`output`,`copy`,`image`,`split messages`,`message actions`]},{slug:`shortcuts`,title:`Shortcuts`,group:`personalization`,kind:`single`,keywords:[`keyboard`,`hotkeys`,`shortcuts`,`bindings`],isAvailable:e=>!e.isVSCode},{slug:`sessions`,title:`Sessions`,group:`personalization`,kind:`single`,keywords:[`defaults`,`default agent`,`default model`,`retention`,`memory`,`limits`,`zen`]},{slug:`summary-ai`,title:`Summary AI`,group:`personalization`,kind:`single`,keywords:[`summary`,`commit`,`session title`,`prompt`,`provider`,`custom api`,`base url`,`api token`]},{slug:`magic-prompts`,title:`Magic Prompts`,group:`content`,kind:`split`,keywords:[`prompts`,`templates`,`git`,`github`,`review`,`commit`,`pull request`],isAvailable:e=>!e.isVSCode},{slug:`snippets`,title:`Snippets`,group:`content`,kind:`split`,keywords:[`prompt`,`templates`,`multi-run`,`strategy`,`approach`]},{slug:`notifications`,title:`Notifications`,group:`personalization`,kind:`single`,keywords:[`alerts`,`native`,`summary`,`summarization`]},{slug:`voice`,title:`Voice`,group:`system`,kind:`single`,keywords:[`tts`,`speech`,`voice`],isAvailable:e=>!e.isVSCode},{slug:`about`,title:`About`,group:`system`,kind:`single`,keywords:[`about`,`version`,`updates`,`release`,`changelog`],isAvailable:e=>e.isMobile}];function ma(e){let t=new Map(da.map((e,t)=>[e,t])),n=new Map;for(let t of e){let e=n.get(t.group)??[];e.push(t),n.set(t.group,e)}return ua.flatMap(e=>{let r=n.get(e);return r?.length?[{group:e,pages:r.sort((e,n)=>(t.get(e.slug)??999)-(t.get(n.slug)??999))}]:[]})}var ha={sessions:`sessions`,agents:`agents`,commands:`commands`,mcp:`mcp`,skills:`skills.installed`,providers:`providers`,usage:`usage`,"git-identities":`git`,settings:`home`};function ga(e){let t=e.trim().toLowerCase();return pa.find(e=>e.slug===t)??null}function _a(e){let t=(e??``).trim().toLowerCase();if(!t)return`home`;let n=ha[t];if(n)return n;let r=ga(t);return r?r.slug:`home`}var va=48;function ya({title:e,eyebrow:t,trailing:n,className:r}){let i=(0,$.useRef)(null),a=(0,$.useRef)(null),o=(0,$.useRef)(null),s=(0,$.useRef)(null),c=(0,$.useRef)(null),l=W(()=>{s.current=null;let e=i.current,t=a.current;if(!e||!t)return;let n=Math.min(1,Math.max(0,t.scrollTop/va)),r=o.current?.matches?Number(n>=.5):n;c.current!==null&&Math.abs(c.current-r)<.001||(c.current=r,e.style.setProperty(`--oc-mobile-title-collapse`,r.toFixed(4)))}),u=W(()=>{s.current===null&&(s.current=window.requestAnimationFrame(l))});return(0,$.useEffect)(()=>{let e=i.current;if(!e)return;let t=e.closest(`.oc-mobile-settings-root-surface, [role="tabpanel"]`);if(!t)return;let n=window.matchMedia(`(prefers-reduced-motion: reduce)`);return a.current=t,o.current=n,c.current=null,t.addEventListener(`scroll`,u,{passive:!0}),n.addEventListener(`change`,u),l(),()=>{t.removeEventListener(`scroll`,u),n.removeEventListener(`change`,u),s.current!==null&&window.cancelAnimationFrame(s.current),s.current=null,a.current=null,o.current=null,c.current=null}},[]),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`header`,{ref:i,className:q(`oc-mobile-collapsing-header flex shrink-0 items-start gap-4`,r),children:(0,Z.jsxs)(`div`,{className:`oc-mobile-collapsing-header-inner`,children:[(0,Z.jsxs)(`div`,{className:`oc-mobile-collapsing-header-title-block min-w-0 flex-1`,children:[t?(0,Z.jsx)(`p`,{className:`oc-mobile-collapsing-header-eyebrow truncate typography-micro font-medium text-muted-foreground`,children:t}):null,(0,Z.jsx)(`h1`,{className:`oc-mobile-root-page-title truncate font-semibold text-foreground`,children:e})]}),n?(0,Z.jsx)(`div`,{className:`oc-mobile-collapsing-header-trailing flex min-h-10 shrink-0 items-center gap-3.5`,children:n}):null]})}),(0,Z.jsx)(`div`,{className:`oc-mobile-collapsing-header-spacer`,"aria-hidden":`true`})]})}function ba(e){let t=(0,X.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({asChild:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i!==void 0&&i?Ne:`div`,o;t[4]===n?o=t[5]:(o=q(`oc-mobile-floating-surface`,n),t[4]=n,t[5]=o);let s;return t[6]!==a||t[7]!==r||t[8]!==o?(s=(0,Z.jsx)(a,{className:o,...r}),t[6]=a,t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function xa(e){let t=(0,X.c)(20),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({as:o,children:n,className:r,variant:s,surfaceProps:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=o===void 0?`div`:o,l=s===void 0?`actions`:s,u;t[7]===r?u=t[8]:(u=q(`oc-mobile-floating-bottom-bar-frame`,r),t[7]=r,t[8]=u);let d=l===`navigation`?`oc-mobile-floating-bottom-bar-navigation`:`oc-mobile-floating-bottom-bar-actions`,f;t[9]===d?f=t[10]:(f=q(`oc-mobile-floating-bottom-bar`,d),t[9]=d,t[10]=f);let p;t[11]!==n||t[12]!==a||t[13]!==f?(p=(0,Z.jsx)(ba,{...a,className:f,children:n}),t[11]=n,t[12]=a,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==c||t[16]!==i||t[17]!==u||t[18]!==p?(m=(0,Z.jsx)(c,{className:u,...i,children:p}),t[15]=c,t[16]=i,t[17]=u,t[18]=p,t[19]=m):m=t[19],m}function Sa(e){let t=(0,X.c)(17),{title:n,children:r,surface:i,scrollsWithPage:a,showHeader:o,trailing:s,className:c,surfaceClassName:l,surfaceAriaLabel:u}=e,d=i===void 0||i,f=a!==void 0&&a,p=o===void 0||o,m=f&&`oc-mobile-tab-page-flow`,h=!p&&`gap-0`,g;t[0]!==c||t[1]!==m||t[2]!==h?(g=q(`oc-mobile-tab-page`,m,h,c),t[0]=c,t[1]=m,t[2]=h,t[3]=g):g=t[3];let _;t[4]!==p||t[5]!==n||t[6]!==s?(_=p?(0,Z.jsx)(ya,{title:n,trailing:s}):null,t[4]=p,t[5]=n,t[6]=s,t[7]=_):_=t[7];let v;t[8]!==r||t[9]!==d||t[10]!==u||t[11]!==l?(v=d?(0,Z.jsx)(ba,{className:q(`oc-mobile-tab-page-surface`,l),"aria-label":u,children:r}):(0,Z.jsx)(`div`,{className:q(`oc-mobile-tab-page-content`,l),"aria-label":u,children:r}),t[8]=r,t[9]=d,t[10]=u,t[11]=l,t[12]=v):v=t[12];let y;return t[13]!==g||t[14]!==_||t[15]!==v?(y=(0,Z.jsxs)(`div`,{className:g,children:[_,v]}),t[13]=g,t[14]=_,t[15]=v,t[16]=y):y=t[16],y}function Ca(e){let t=(0,X.c)(12),{label:n,children:r,className:i,cardClassName:a,ariaLabel:o}=e,s;t[0]!==a||t[1]!==i?(s=q(`oc-mobile-labeled-surface-group`,a,i),t[0]=a,t[1]=i,t[2]=s):s=t[2];let c;t[3]===n?c=t[4]:(c=(0,Z.jsx)(`div`,{className:`oc-mobile-labeled-surface-group-label`,children:n}),t[3]=n,t[4]=c);let l;t[5]===r?l=t[6]:(l=r?(0,Z.jsx)(`div`,{className:`oc-mobile-labeled-surface-group-content`,children:r}):null,t[5]=r,t[6]=l);let u;return t[7]!==o||t[8]!==s||t[9]!==c||t[10]!==l?(u=(0,Z.jsxs)(`section`,{className:s,"aria-label":o,children:[c,l]}),t[7]=o,t[8]=s,t[9]=c,t[10]=l,t[11]=u):u=t[11],u}export{Yt as $,qr as A,Yn as B,ki as C,oi as D,si as E,ur as F,on as G,Cn as H,lr as I,ln as J,sn as K,dr as L,br as M,xr as N,ai as O,_r as P,Xt as Q,fr as R,ji as S,pi as T,Sn as U,xn as V,_n as W,rn as X,Zt as Y,an as Z,Hi as _,ya as a,Ti as b,ga as c,la as d,oa as f,Bi as g,Ki as h,Sa as i,vr as j,Jr as k,ma as l,qi as m,ba as n,fa as o,Yi as p,cn as q,Ca as r,pa as s,xa as t,_a as u,Vi as v,wi as w,Ai as x,Oi as y,sr as z};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{tt as e}from"./useUIStore-CuaA8-Hp.js";import{Kt as t,qt as n}from"./persistence-DdUac14I.js";var r=e=>typeof e==`object`&&!!e,i=e=>e.trim().toLowerCase()===`authorization`,a=e=>{if(!r(e))return;let t={};for(let[n,r]of Object.entries(e)){let e=n.trim(),a=typeof r==`string`?r.trim():``;!e||!a||/[\r\n:]/.test(e)||/[\r\n]/.test(a)||i(e)||(t[e]=a)}return Object.keys(t).length>0?t:void 0},o=`connect-link`,s=(e,t)=>e.source===`connect-link`||e.relay?!0:t.has(e.id),c=(e,t)=>!t.has(e.id)&&s(e,t),l=e=>`relay://${e}`,u=e=>{if(!r(e))return null;let t=g(e,`relayUrl`)||g(e,`relay_url`),n=g(e,`serverId`)||g(e,`server_id`),i=e.hostEncPubJwk??e.host_enc_pub_jwk;return!t||!n||!r(i)?null:{relayUrl:t,serverId:n,hostEncPubJwk:i}},d=/^(t|.*(?:token|auth|secret|api).*)$/i,f=e=>{let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`http:`&&e.protocol!==`https:`?null:t.split(`#`)[0]||null}catch{return null}},p=e=>{let t=f(e);if(!t)return null;try{let e=new URL(t);if((e.pathname.replace(/\/+$/,``)||`/`)===`/connect`&&e.searchParams.has(`t`))return{persistedUrl:e.origin,redeemUrl:e.toString(),kind:`tunnel-connect-link`}}catch{return null}return{persistedUrl:t,redeemUrl:null,kind:`normal-host`}},m=e=>{let t=f(e);if(!t)return e;try{let e=new URL(t);(e.username||e.password)&&(e.username=``,e.password=``);let n=Array.from(new Set(Array.from(e.searchParams.keys())));for(let t of n)d.test(t)&&e.searchParams.set(t,`[REDACTED]`);return e.toString()}catch{return t}},h=(e,t)=>{let n=f(e),r=f(t);if(!n||!r)return!1;try{let e=new URL(n),t=new URL(r);if(e.origin!==t.origin||t.search&&e.search!==t.search)return!1;let i=t.pathname.length>1?t.pathname.replace(/\/+$/,``):t.pathname,a=e.pathname.length>1?e.pathname.replace(/\/+$/,``):e.pathname;return i===`/`||a===i||a.startsWith(`${i}/`)}catch{return!1}},g=(e,t)=>{let n=e[t];return typeof n==`string`?n:null},_=(e,t)=>{let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:null},v=e=>{if(!r(e))return null;let t=g(e,`id`),n=g(e,`label`),i=g(e,`url`),s=g(e,`apiUrl`)||g(e,`api_url`),c=g(e,`clientToken`)||g(e,`client_token`),l=a(e.requestHeaders),d=u(e.relay),f=g(e,`source`)===`connect-link`?o:void 0;return!t||!n||!i&&!d?null:{id:t,label:n,url:i||``,...s?{apiUrl:s}:{},...c?{clientToken:c}:{},...l?{requestHeaders:l}:{},...d?{relay:d}:{},...f?{source:f}:{}}},y=e=>f(e.apiUrl||e.url)||e.apiUrl||e.url,b=()=>t()?(e,t)=>n(e,t):null,x=async()=>{let e=b();if(!e)return{hosts:[],defaultHostId:null,initialHostChoiceCompleted:!1};let t=await e(`desktop_hosts_get`);if(!r(t))return{hosts:[],defaultHostId:null,initialHostChoiceCompleted:!1};let n=t.hosts;return{hosts:Array.isArray(n)?n.map(v).filter(e=>!!e):[],defaultHostId:g(t,`defaultHostId`)||g(t,`default_host_id`)||g(t,`defaultHostID`),initialHostChoiceCompleted:t.initialHostChoiceCompleted===!0||t.initial_host_choice_completed===!0,localOrigin:g(t,`localOrigin`)||g(t,`local_origin`)}},S=async e=>{let t=b();if(!t)return;let n={hosts:e.hosts,defaultHostId:e.defaultHostId,initialHostChoiceCompleted:e.initialHostChoiceCompleted};e.localClientToken!==void 0&&(n.localClientToken=e.localClientToken),await t(`desktop_hosts_set`,{input:n})},C=async()=>{let e=b();if(!e)return``;let t=await e(`desktop_local_client_token_get`).catch(()=>null);return typeof t==`string`?t.trim():``},w=async()=>{let e=b();if(!e)return``;let t=await e(`desktop_install_id_get`).catch(()=>null);return typeof t==`string`?t.trim():``},T=8e3,E=async(t,n)=>{let r=e({relayUrl:t.relayUrl,serverId:t.serverId,hostEncPubJwk:t.hostEncPubJwk}),i=Date.now(),a=!1;try{return(await Promise.race([r.fetch(`/health`),new Promise(e=>{let t=window.setTimeout(()=>e(null),T);typeof t!=`number`&&typeof t.unref==`function`&&t.unref()})]))?.ok?(a=n?.keepTunnel===!0,{status:`ok`,latencyMs:Math.max(0,Date.now()-i),...a?{tunnel:r}:{}}):{status:`unreachable`,latencyMs:0}}catch{return{status:`unreachable`,latencyMs:0}}finally{a||r.close()}},D=async(e,t)=>{let n=b();if(!n)return{status:`unreachable`,latencyMs:0};let i=await n(`desktop_host_probe`,{url:e,clientToken:t?.clientToken||void 0,requestHeaders:t?.requestHeaders||void 0,expectedServerId:t?.expectedServerId||void 0});if(!r(i))return{status:`unreachable`,latencyMs:0};let a=i.status;return{status:a===`ok`||a===`auth`||a===`update-recommended`||a===`incompatible`||a===`wrong-service`||a===`unreachable`?a:`unreachable`,latencyMs:_(i,`latencyMs`)??_(i,`latency_ms`)??0}},O=async(e,t)=>{let n=b();n&&await n(`desktop_new_window_at_url`,{url:e,clientToken:t?.clientToken||void 0,requestHeaders:t?.requestHeaders||void 0})},k=async e=>{let t=b();t&&await t(`desktop_new_window_for_host`,{hostId:e})};export{p as _,w as a,k as c,s as d,h as f,l as g,m as h,S as i,y as l,E as m,D as n,C as o,f as p,x as r,O as s,o as t,c as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{T as e,X as t,j as n}from"./useUIStore-CuaA8-Hp.js";import{Zt as r,kn as i}from"./persistence-DdUac14I.js";import{i as a,l as o,m as s,n as c,p as l,r as u}from"./desktopHosts-CWxex1c3.js";var d=e=>e===`unreachable`||e===`wrong-service`||e===`incompatible`,f=e=>e.id===`local`?`local`:`host:${e.id}`,p=t=>e()===f(t),m=async(e,i)=>{if(!r())return{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unsupported`};let a=l(o(e))||``;if(!a&&!e.relay)return{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unreachable`};let u=(r,i)=>{i&&t({relayUrl:r.relayUrl,serverId:r.serverId,hostEncPubJwk:r.hostEncPubJwk},i),n({apiBaseUrl:typeof window<`u`?window.location.origin:``,clientToken:e.clientToken||null,runtimeKey:f(e),relay:r}),b(e.id)},p=t=>{n({apiBaseUrl:t,clientToken:e.clientToken||null,requestHeaders:e.requestHeaders||null,runtimeKey:f(e)})},m=i?.cachedProbe;if(m?.status===`ok`){if(m.via===`relay`&&e.relay)return u(e.relay),{ok:!0,via:`relay`,status:m};if(a&&m.via!==`relay`)return p(a),{ok:!0,via:`direct`,status:m};if(e.relay)return u(e.relay),{ok:!0,via:`relay`,status:{...m,via:`relay`}}}let h={status:`unreachable`,latencyMs:0},g=null,_;if(a){let t=await c(a,{clientToken:e.clientToken||null,requestHeaders:e.requestHeaders||null}).catch(()=>({status:`unreachable`,latencyMs:0}));h={status:t.status,latencyMs:t.latencyMs},d(t.status)||(g=`direct`)}if(!g&&e.relay){let t=await s(e.relay,{keepTunnel:!0}).catch(()=>({status:`unreachable`,latencyMs:0}));t.status===`ok`?(h={status:t.status,latencyMs:t.latencyMs,via:`relay`},g=`relay`,_=`tunnel`in t?t.tunnel:void 0):a||(h={status:t.status,latencyMs:t.latencyMs})}return g?g===`relay`&&e.relay?(u(e.relay,_),{ok:!0,via:`relay`,status:h}):(p(a),{ok:!0,via:`direct`,status:h}):{ok:!1,status:h,reason:`unreachable`}},h=5e3,g=1500,_=e=>e===`ok`||e===`update-recommended`,v=!1,y=async t=>{if(!r()||v)return;let o=`host:${t}`;if(e()===o){v=!0;try{let r=await u().catch(()=>null),s=r?.hosts.find(e=>e.id===t);if(!r||!s?.relay)return;let d=s.apiUrl?l(s.apiUrl):null;if(d&&d.startsWith(`https://`))return;let f=await i(`/api/client-auth/connection/candidates`).catch(()=>null);if(!f?.ok)return;let p=await f.json().catch(()=>null);if(!p||p.serverId!==s.relay.serverId)return;let m=Array.isArray(p.candidates)?p.candidates:[],h=[];for(let e of m){if(!e||typeof e!=`object`)continue;let t=e;if(t.type!==`lan`||typeof t.url!=`string`)continue;let n=l(t.url);n&&!h.includes(n)&&h.push(n)}if(h.length===0)return;let g=d&&h.includes(d)?d:h[0];if(g!==d&&await a({hosts:r.hosts.map(e=>e.id===t?{...e,apiUrl:g}:e),defaultHostId:r.defaultHostId,initialHostChoiceCompleted:r.initialHostChoiceCompleted}).catch(()=>void 0),!_((await c(g,{clientToken:s.clientToken||null,requestHeaders:s.requestHeaders||null,expectedServerId:s.relay.serverId}).catch(()=>({status:`unreachable`,latencyMs:0}))).status)||e()!==o)return;n({apiBaseUrl:g,clientToken:s.clientToken||null,requestHeaders:s.requestHeaders||null,runtimeKey:o})}finally{v=!1}}},b=e=>{typeof window>`u`||window.setTimeout(()=>{y(e).catch(()=>void 0)},h)},x=async t=>{if(!r())return;let i=await u().catch(()=>null);if(!i)return;let a=t||(i.defaultHostId===`local`?null:i.defaultHostId);if(!a)return;let s=i.hosts.find(e=>e.id===a);if(!s?.relay)return;let d=f(s);if(e()===d)return;let p=e=>{n({apiBaseUrl:e,clientToken:s.clientToken||null,requestHeaders:s.requestHeaders||null,runtimeKey:d})},m=()=>{n({apiBaseUrl:typeof window<`u`?window.location.origin:``,clientToken:s.clientToken||null,runtimeKey:d,relay:s.relay??void 0}),b(s.id)},h=s.apiUrl?l(o(s)):null;if(!h){m();return}let v=e=>_(e.status),y=c(h,{clientToken:s.clientToken||null,requestHeaders:s.requestHeaders||null,expectedServerId:s.relay.serverId}).catch(()=>({status:`unreachable`,latencyMs:0})),x=await Promise.race([y,new Promise(e=>setTimeout(()=>e(null),g))]);if(x){if(v(x)){p(h);return}m();return}m(),y.then(t=>{v(t)&&e()===d&&p(h)})};export{m as i,p as n,f as r,x as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{E as t,j as n,t as r}from"./useUIStore-CuaA8-Hp.js";import{Kt as i,Xt as a,d as o,kn as s,qt as c,u as l,xn as u}from"./persistence-DdUac14I.js";import{h as d}from"./desktopHosts-CWxex1c3.js";import{i as f,n as p,r as m}from"./desktopRelayRestore-9EbBYQ9s.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}from"./vendor-base-ui-CnHfUmDN.js";import{Nt as E}from"./platform-B4KKLnZ5.js";import{n as D}from"./vendor-react-DLPElpoQ.js";import{n as O}from"./vendor-tanstack-query-core-BWz0ose6.js";import{i as k,r as A,s as j}from"./vendor-tanstack-react-query-D7pys_c9.js";import{P as te,V as M,a as N,f as ne,l as re}from"./vendor-codemirror-autocomplete-DHomsvW7.js";import{c as ie,o as P,r as ae}from"./vendor-codemirror-lang-angular-DShkBD6m.js";import{n as F,r as I}from"./vendor-codemirror-lang-json-CYJRHck9.js";import{n as L}from"./vendor-codemirror-lang-markdown-WORgx6ZD.js";import{n as oe}from"./vendor-codemirror-lang-python-Du6XQ8Zw.js";import{O as R}from"./vendor-codemirror-legacy-modes-DuRAjNvB.js";import{n as se}from"./vendor-reactuses-core-DDoDDyM9.js";import{n as ce,r as z,t as B}from"./clipboard-DJ4nQEuY.js";import{i as V,t as H}from"./store-BDFdnk6l.js";import{$i as le,Ha as ue,Wa as de,Ya as fe,Zi as pe,c as me,cr as he,dr as ge,lo as _e,mr as ve,nr as ye}from"./useMobileNavigationStore-BawYHSru.js";import{s as U,t as W}from"./utils-BiK3tBGM.js";import{t as be}from"./AgentAvatar-CX0a1rKE.js";import{n as G}from"./Icon-BYM02QyU.js";import{t as xe}from"./button-C0cth9tl.js";import{i as Se,n as Ce,r as we,t as Te}from"./vendor-simplewebauthn-browser-Dwhcdg_5.js";import{B as Ee,C as De,D as Oe,O as ke,S as Ae,T as je,V as Me,k as Ne,w as Pe}from"./projectMeta-B4mvLrV7.js";import{t as Fe}from"./input-DFLpqjGR.js";import{t as Ie}from"./useThemeSystem-DMzWVJaW.js";import{i as Le}from"./OverlayScrollbar-KUpvYHdv.js";import{n as Re,r as ze,t as Be}from"./dropdown-menu.styles-Bzo6L3FH.js";import{n as Ve}from"./textarea-Cgo_nWUU.js";import{t as He}from"./vendor-codemirror-language-data-BfYFhIH1.js";var K=D(),Ue=[`desktopHostSwitch`],We=class extends Error{result;host;constructor(e,t){super(e.reason),this.name=`DesktopHostSwitchError`,this.result=e,this.host=t}},Ge=(e,t)=>H(V.getState().dictionary,e,t),Ke=async e=>{let{host:t}=e;if(t.id===`local`){let r=(e.localApiOrigin||``).trim();if(!r)throw new We({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 We(r,t);return r},qe=null,Je=()=>qe||(qe=new O(l,{mutationKey:Ue,mutationFn:Ke,onError:(e,t)=>{e instanceof We&&e.result.reason!==`unsupported`&&ve.error(Ge(`desktopHostSwitcher.toast.instanceUnreachable`,{host:d(t.host.label)}))}}),qe.subscribe(()=>void 0),qe),Ye=async e=>{if(p(e.host))return{ok:!0,via:`direct`,status:e.cachedProbe?.status===`ok`?e.cachedProbe:{status:`ok`,latencyMs:0}};if(l.isMutating({mutationKey:Ue})>0)return{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unsupported`};try{return await Je().mutate(e)}catch(e){if(e instanceof We)return e.result;throw e}},Xe=()=>{let e=(0,K.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={mutationKey:Ue},e[0]=t):t=e[0],A(t)>0},Ze=()=>{let e=(0,K.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={filters:{mutationKey:Ue,status:`pending`},select:Qe},e[0]=t):t=e[0],k(t)[0]?.host.id??null};function Qe(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},$e=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],et=()=>i()?(e,t)=>c(e,t):null,tt=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}:{}}},nt=e=>e===`remote`||e===`dynamic`?e:`local`,rt=e=>{if(!q(e))return null;let t=J(e,`id`);if(!t)return null;let n=X(e,`enabled`)??!0,r=nt(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}:{}}},it=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:$e(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=>rt(e)).filter(e=>!!e),h=Y(o,`preferredPort`)??Y(o,`preferred_port`),g=Y(s,`preferredLocalPort`)??Y(s,`preferred_local_port`),_=tt(c.sshPassword||c.ssh_password),v=tt(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}},at=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`}},ot=e=>{if(!q(e))return null;let t=J(e,`id`);return t?{id:t,phase:at(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},st=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}},ct=(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:[]}),lt=async()=>{let e=et();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=>it(e)).filter(e=>!!e)}:{instances:[]}},ut=async e=>{let t=et();t&&await t(`desktop_ssh_instances_set`,{config:{instances:e.instances}})},dt=async()=>{let e=et();if(!e)return[];let t=await e(`desktop_ssh_import_hosts`);return Array.isArray(t)?t.map(e=>st(e)).filter(e=>!!e):[]},ft=async e=>{let t=et();t&&await t(`desktop_ssh_connect`,{id:e})},pt=async e=>{let t=et();t&&await t(`desktop_ssh_disconnect`,{id:e})},mt=async e=>{let t=et();if(!t)return[];let n=await t(`desktop_ssh_status`,{...e?{id:e}:{}});return Array.isArray(n)?n.map(e=>ot(e)).filter(e=>!!e):[]},ht=async(e,t)=>{let n=et();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`):[]},gt=async e=>{let t=et();t&&await t(`desktop_ssh_logs_clear`,{id:e})},_t=(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}},vt=e=>{if(!q(e))return null;let t=J(e,`path`),n=Y(e,`bytes`);return!t||n===null?null:{path:t,bytes:n}},yt=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}},bt=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}},xt=e=>{if(e==null||!q(e))return null;let t=Y(e,`bytes`);return t===null?null:{bytes:t}},St=e=>{if(!q(e))return null;let t=Array.isArray(e.files)?e.files:null,n=Array.isArray(e.directories)?e.directories:null,r=$e(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=>vt(e)).filter(e=>!!e),o=n.map(e=>yt(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:bt(s);if(s!=null&&c===null)return null;let l=e.authFile??e.auth_file,u=l==null?null:xt(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=Ct(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}:{}}},Ct=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}},wt=e=>{if(!q(e))return null;let t=St(e.plan);if(!t)return null;let n=Ct(e.selectionShape??e.selection_shape)??t.selectionShape??null;return{plan:t,remoteExisting:$e(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}:{}}},Tt=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:xt(s);return{ok:!0,files:t,directories:n,deletes:r,totalBytes:i,agentsRoot:o,authFile:c}},Et=async(e={})=>{let t=et();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=St(n.plan);if(!r)return console.error(`[desktopSsh] config sync local scan plan payload was not recognized`,n),null;let i=Ct(n.selectionShape??n.selection_shape)??r.selectionShape??null;return i?{...r,selectionShape:i}:r},Dt=async(e,t={})=>{let n=et();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=wt(r);return i||console.error(`[desktopSsh] config sync preview payload was not recognized`,r),i},Ot=async(e,t={})=>{let n=et();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=Tt(r);return i||console.error(`[desktopSsh] config sync apply payload was not recognized`,r),i},kt=async(e,t={})=>{let n=et();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`):[]},At=async e=>{if(!i())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=ot(t?.payload);n&&e(n)});return async()=>{await n()}},jt=new Set([`nodeRuntimeMissing`,`packageManagerMissing`,`nativeBinding`,`openchamberCliMissing`,`openchamberRegistry`,`openchamberInstall`,`openchamberCliIncompatible`,`opencodeInstall`,`serverStart`,`sshAuth`,`sshUnreachable`,`timeout`,`unknown`]),Mt=e=>typeof e==`string`&&jt.has(e),Nt=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`},Pt=(e,t)=>Mt(e)?e:Nt(t),Ft=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`}},It=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`}},Lt=e=>e===`unknown`||e===`openchamberCliIncompatible`,Rt=(e,t,n)=>{let r=typeof n==`string`?n.trim():``;return!Lt(t)||!r||r===e?e:`${e}\n${r}`},Z=ee();function zt(e){let t=(0,K.c)(27),{errorCode:n,detail:r,className:i}=e,{t:a}=ce(),o,s,c,l,u,d;if(t[0]!==i||t[1]!==r||t[2]!==n||t[3]!==a){let e=Pt(n,r);o=a(It(e));let f;t[10]===r?f=t[11]:(f=typeof r==`string`?r.trim():``,t[10]=r,t[11]=f),s=f,c=Lt(e)&&!!s&&s!==o,t[12]===i?d=t[13]:(d=W(`space-y-1`,i),t[12]=i,t[13]=d),l=`typography-ui-label text-[var(--status-error)]`,u=a(Ft(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),Bt=[.2,.45,.15,.55,.35,.1,.5,.25,.4,.3,.45,.15,.55,.2,.35,.1],Vt=[.3,.15,.45,.25,.5,.35,.1,.4,.2,.55,.3,.15,.45,.25,.4,.2],Ht=(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},Ut=({className:e=``,width:t=70,height:n=70,isAnimated:r=!1})=>{let{t:i}=ce(),a=Ie(),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=Ht(h,_,b,v),C=Ht(_,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:Bt[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:Vt[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`})]})})]})},Wt=`/auth/passkey/authenticate/options`,Gt=`/auth/passkey/authenticate/verify`,Kt=`/auth/passkey/register/options`,qt=`/auth/passkey/register/verify`,Jt=`/api/passkeys`,Yt=`/auth/passkey/status`,Xt=`/api/auth/reset`,Zt={enabled:!1,hasPasskeys:!1,passkeyCount:0,rpID:null},Qt=async(e,t)=>s(e,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:t===void 0?void 0:JSON.stringify(t)}),$t=async(e,t)=>{try{let t=await e.json();if(t&&typeof t.error==`string`&&t.error.trim())return t.error}catch{}return t},en=e=>e instanceof Se&&e.code===`ERROR_CEREMONY_ABORTED`,tn=()=>{we.cancelCeremony()},nn=()=>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.`},rn=async()=>{let e=nn();if(!e.supported)throw Error(e.reason);let t=await Qt(Kt,{label:typeof navigator.userAgent==`string`&&navigator.userAgent.trim()?navigator.userAgent:`This device`});if(!t.ok)throw Error(await $t(t,`Could not start passkey setup.`));let{requestId:n,optionsJSON:r}=await t.json(),i=await Qt(qt,{requestId:n,response:await Ce({optionsJSON:r})});if(!i.ok)throw Error(await $t(i,`Could not finish passkey setup.`));return i.json().catch(()=>null)},an=async(e,t={})=>{let n=nn();if(!n.supported)throw Error(n.reason);let r=await Qt(Wt);if(!r.ok)throw Error(await $t(r,`Passkey sign-in is not available right now.`));let{requestId:i,optionsJSON:a}=await r.json(),o=await Qt(Gt,{requestId:i,response:await Te({optionsJSON:a}),trustDevice:e,issueClientToken:t.issueClientToken===!0,clientLabel:t.clientLabel,clientKind:t.clientKind,dedupeKey:t.dedupeKey});if(!o.ok)throw Error(await $t(o,`Passkey sign-in failed.`));return o.json().catch(()=>null)},on=async()=>{let e=await s(Yt,{method:`GET`,credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)return Zt;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}},sn=async()=>{let e=await s(Jt,{method:`GET`,credentials:`include`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(await $t(e,`Could not load passkeys.`));let t=await e.json().catch(()=>null);return Array.isArray(t?.passkeys)?t.passkeys:[]},cn=async e=>{let t=await s(`${Jt}/${encodeURIComponent(e)}`,{method:`DELETE`,credentials:`include`,headers:{Accept:`application/json`}});if(!t.ok)throw Error(await $t(t,`Could not remove passkey.`));return t.json().catch(()=>null)},ln=async()=>{let e=await Qt(Xt);if(!e.ok)throw Error(await $t(e,`Could not clear saved authentication.`));return e.json().catch(()=>null)};function un(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=W(`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 dn(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=W(`@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 fn(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=W(`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 pn(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=W(`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 mn=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 B(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)(un,{className:`w-full max-w-md`,children:[(0,Z.jsx)(dn,{className:`text-center`,children:(0,Z.jsxs)(fn,{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)(pn,{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)(xe,{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)(xe,{onClick:this.handleCopy,variant:`outline`,className:`flex-1`,children:this.state.copied?e.copied:e.copy})]})]})]})}):this.props.children}},hn=e=>{let t=(0,K.c)(29),{children:n,fallback:r}=e,{t:i}=ce(),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)(mn,{fallback:r,strings:m,children:n}),t[25]=n,t[26]=r,t[27]=m,t[28]=h):h=t[28],h},gn=`__unassigned__`,_n={mod:`mod`,shift:`shift`,alt:`alt`,option:`alt`,ctrl:`ctrl`,meta:`mod`,cmd:`mod`,command:`mod`},vn={mod:U()&&a()?`⌘`:`Ctrl`,shift:`⇧`,alt:`⌥`,option:`⌥`,ctrl:`⌃`},yn={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:`-`,"-":`-`},bn=[`mod`,`ctrl`,`shift`,`alt`],xn={"{":`[`,"}":`]`,":":`;`,'"':`'`,"<":`,`,">":`.`,"?":`/`,"|":`\\`,"~":"`","!":`1`,"@":`2`,"#":`3`,$:`4`,"%":`5`,"^":`6`,"&":`7`,"*":`8`,"(":`9`,")":`0`};function Sn(e){return e.trim().toLowerCase()===gn}function Cn(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`:xn[t]??t}var wn=[{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 Tn(e){if(Sn(e))return gn;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=_n[t];if(i){n.add(i);continue}r=t}return[...bn.filter(e=>n.has(e)),r].filter(Boolean).join(`+`)}function En(e){return Sn(e)?!0:Dn(e).key.trim().length>0}function Dn(e){if(Sn(e))return{modifiers:new Set,key:gn};let t=Tn(e).split(`+`),n=new Set,r=``;for(let e of t){let t=_n[e];t?n.add(t):r=e}return{modifiers:n,key:r}}function On(e){if(Sn(e))return`Unassigned`;let t=Dn(e);if(!t.key&&t.modifiers.size===0)return`Unassigned`;let n=[];for(let e of bn)t.modifiers.has(e)&&n.push(vn[e]);if(t.key){let e=yn[t.key.toLowerCase()]||t.key.toUpperCase();n.push(e)}return n.join(` + `)}function kn(e){return wn.find(t=>t.id===e)}function An(){return wn.filter(e=>e.customizable===!0)}function jn(e,t){let n=kn(e);if(!n)return``;let r=t?.[e];if(typeof r==`string`){if(r.trim().toLowerCase()===`__unassigned__`)return``;let e=Tn(r);if(e===`__unassigned__`)return gn;if(En(e))return e}return n.defaultCombo}function Mn(e,t){let n=kn(e);if(!n)return[];let r=jn(e,t);return r===n.defaultCombo?[n.defaultCombo,...n.defaultAliases??[]]:r?[r]:[]}function Nn(e){if(Sn(e))return!1;let t=Dn(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 Pn(e,t){let n=typeof t==`string`?t:t.defaultCombo;if(Sn(n))return!1;let r=Dn(n),i=r.modifiers.has(`mod`),o=r.modifiers.has(`shift`),s=r.modifiers.has(`alt`),c=r.modifiers.has(`ctrl`),l=U()&&a(),u=U(),d=l?e.metaKey:u&&e.metaKey||e.ctrlKey;if(i&&!d||!i&&e.metaKey||o!==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))),Cn(f)===Cn(r.key)}function Fn(){return U()&&a()?`⌘`:`Ctrl`}function In(e,t,n){if(Pn(e,n))return!0;let r=Tn(n),i=U()&&a(),o=U();return!(i?e.metaKey:o&&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 Ln=Q.createContext(null),Rn=e=>e?e.closest(`[data-slot="dialog-content"], [role="dialog"]`):null;function zn(e,t){return e&&Q.isValidElement(t)?{render:t}:{children:t}}function Bn(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)(Ln.Provider,{value:o,children:s}),t[6]=o,t[7]=s,t[8]=c):c=t[8],c}function Vn(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(Ln),c;t[6]===s?c=t[7]:(c=e=>{if(!s)return;let t=e instanceof HTMLElement?e:null;s.setPortalContainer(Rn(t))},t[6]=s,t[7]=c);let l=c,u;t[8]!==n||t[9]!==r?(u=zn(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 Hn(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(Ln),w=g?void 0:C?.portalContainer||void 0,ee;t[16]===s?ee=t[17]:(ee=W(`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=W(Re,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 Un(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=zn(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=W(Be,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 Wn(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 Gn(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=W(`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 Kn(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=W(`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 qn(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=W(ze,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 Jn(){let e=(0,K.c)(5),t=pe(Qn),n=pe(Zn),r=pe(Xn),i=pe(Yn),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 Yn(e){return e.providers.length>0}function Xn(e){return e.lastDisconnectReason}function Zn(e){return e.connectionPhase}function Qn(e){return e.isInitialized}var $n=e=>{let t=(0,K.c)(41),{agentName:n,onChange:i,className:a,filter:o,dropdownPortalToBody:s,showIcon:c,agents:l}=e,u=s!==void 0&&s,d=c===void 0||c,{t:f}=ce(),{isReady:p,isUnavailable:m}=Jn(),h=pe(er),g=fe(tr),_=pe(nr),{data:v}=_e(),y;t[0]===v?y=t[1]:(y=v===void 0?[]:v,t[0]=v,t[1]=y);let b=y,x;bb0:{if(l){x=l;break bb0}if(Array.isArray(h)&&h.length>0){x=h;break bb0}x=b}let S=x,C;if(t[2]!==o||t[3]!==S){let e=de(S);C=o?e.filter(o):e,t[2]=o,t[3]=S,t[4]=C}else C=t[4];let w=C,ee=r(rr),{isMobile:T}=Le(),E=ee||T,[D,O]=Q.useState(!1),k;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(k=()=>{O(!0),pe.getState().refreshCatalogsOnPickerOpen({source:`agentSelector:mobilePanel`})},t[5]=k):k=t[5];let A=se(k),j=se(ir),te=Q.useId(),M,N;t[6]!==l||t[7]!==g||t[8]!==_||t[9]!==S.length?(M=()=>{l||S.length>0||(_(),g())},N=[l,S.length,_,g],t[6]=l,t[7]=g,t[8]=_,t[9]=S.length,t[10]=M,t[11]=N):(M=t[10],N=t[11]),Q.useEffect(M,N);let ne;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(ne=()=>O(!1),t[12]=ne):ne=t[12];let re=ne,ie;t[13]===i?ie=t[14]:(ie=e=>{i(e)},t[13]=i,t[14]=ie);let P=ie,ae;t[15]!==n||t[16]!==w||t[17]!==P||t[18]!==E||t[19]!==D||t[20]!==te||t[21]!==f?(ae=()=>E?(0,Z.jsx)(Ne,{id:`mobile-agent-selector-sheet-${te}`,open:D,onOpenChange:e=>{e||re()},ariaLabel:f(`settings.commands.agentSelector.title`),closeAriaLabel:f(`mobile.surface.closeAria`),resizeAriaLabel:f(`mobile.sessions.sheet.resizeAria`),bodyClassName:`px-2`,children:(0,Z.jsxs)(Ve,{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:W(`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:()=>{P(``),re()},children:[(0,Z.jsx)(be,{name:`default`,size:16}),(0,Z.jsx)(`span`,{className:W(`min-w-0 typography-meta`,n?`text-muted-foreground`:`font-medium`),children:f(`settings.commands.agentSelector.notSelected`)}),!n&&(0,Z.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-primary`})]}),w.map(e=>{let t=e.name===n;return(0,Z.jsxs)(`button`,{type:`button`,className:W(`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:()=>{P(e.name),re()},children:[(0,Z.jsx)(be,{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]=w,t[17]=P,t[18]=E,t[19]=D,t[20]=te,t[21]=f,t[22]=ae):ae=t[22];let F=ae,I;t[23]!==n||t[24]!==w||t[25]!==a||t[26]!==u||t[27]!==P||t[28]!==j||t[29]!==E||t[30]!==p||t[31]!==m||t[32]!==A||t[33]!==d||t[34]!==f?(I=E?(0,Z.jsxs)(`button`,{type:`button`,onClick:p?A:void 0,disabled:!p,className:W(`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`,!p&&`opacity-60 cursor-not-allowed`,a),children:[(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:p?(0,Z.jsxs)(Z.Fragment,{children:[d?(0,Z.jsx)(be,{name:n||`default`,size:14}):null,(0,Z.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:n||f(`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:f(m?`common.unavailable`:`common.loading`)})]})}),(0,Z.jsx)(G,{name:`arrow-down-s`,className:`h-3 w-3 text-muted-foreground`})]}):p?(0,Z.jsxs)(Bn,{onOpenChange:j,children:[(0,Z.jsx)(Vn,{asChild:!0,children:(0,Z.jsxs)(`div`,{className:W(`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`,a),children:[d?(0,Z.jsx)(be,{name:n||`default`,size:14}):null,(0,Z.jsx)(`span`,{className:`typography-micro font-medium whitespace-nowrap`,children:n||f(`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)(Hn,{className:`max-w-[300px]`,portalToBody:u,children:[(0,Z.jsxs)(Un,{className:`typography-meta`,onSelect:()=>P(``),children:[(0,Z.jsx)(be,{name:`default`,size:14}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:f(`settings.commands.agentSelector.notSelected`)})]}),w.map(e=>(0,Z.jsxs)(Un,{className:`typography-meta`,onSelect:()=>P(e.name),children:[(0,Z.jsx)(be,{name:e.name,size:14}),(0,Z.jsx)(`span`,{className:`font-medium`,children:e.name})]},e.name))]})]}):(0,Z.jsxs)(`div`,{className:W(`flex items-center gap-2 px-2 rounded-lg bg-interactive-selection/20 border border-border/20 h-6 w-fit opacity-60`,a),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:f(m?`common.unavailable`:`common.loading`)})]}),t[23]=n,t[24]=w,t[25]=a,t[26]=u,t[27]=P,t[28]=j,t[29]=E,t[30]=p,t[31]=m,t[32]=A,t[33]=d,t[34]=f,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 er(e){return e.agents}function tr(e){return e.loadAgents}function nr(e){return e.loadAgents}function rr(e){return e.isMobile}function ir(e){e&&pe.getState().refreshCatalogsOnPickerOpen({source:`agentSelector:desktopMenu`})}var ar={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}},or=null,sr={},cr=(e,t)=>{or!==t&&(or=t,sr.compact=void 0,sr.compactTokensShort=void 0,sr.usd=void 0);let n=sr[e];if(n)return n;let r=new Intl.NumberFormat(t,ar[e]);return sr[e]=r,r},lr=(e,t=z())=>cr(`compact`,t).format(e),ur=(e,t=z())=>cr(`compactTokensShort`,t).format(e),dr=(e,t=z())=>cr(`usd`,t).format(e),fr=(e,t=z())=>e.toLocaleDateString(t,{month:`short`,day:`numeric`,year:`numeric`}),pr=(e,t=z())=>new Date(e).toLocaleDateString(t,{year:`numeric`,month:`short`,day:`numeric`}),mr=(e,t=z())=>new Date(e).toLocaleTimeString(t,{hour:`numeric`,minute:`2-digit`}),hr=8,gr=e=>typeof e!=`number`||Number.isNaN(e)?``:ur(e),_r=(e,t,n)=>{let r=e.find(e=>e.id===t)?.models?.find(e=>e.id===n);return r?.variants?Object.keys(r.variants):[]},vr=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}=ce(),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,M]=Q.useState(`model`),[N,ne]=Q.useState(null),re=Q.useRef(!1),ie=y??te,P,ae;t[4]!==n||t[5]!==i?(P=()=>{n&&!re.current&&k(new Set(i?[i]:[])),n||(E(``),j(null),M(`model`),ne(null)),re.current=n},ae=[n,i],t[4]=n,t[5]=i,t[6]=P,t[7]=ae):(P=t[6],ae=t[7]),Q.useEffect(P,ae);let F;t[8]===b?F=t[9]:(F=e=>{M(e),b?.(e)},t[8]=b,t[9]=F);let I=F,L=ie===`variant`&&!!(N??(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)(xe,{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 B;t[19]===w?B=t[20]:(B=w(`mobile.surface.closeAria`),t[19]=w,t[20]=B);let V;t[21]===w?V=t[22]:(V=w(`mobile.sessions.sheet.resizeAria`),t[21]=w,t[22]=V);let H;t[23]!==ie||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]!==N?(H=(0,Z.jsx)(yr,{query:T,onQueryChange:E,expandedProviders:O,onExpandedProvidersChange:k,expandedModelKey:A,onExpandedModelKeyChange:j,activeView:ie,setView:I,variantTarget:N,onVariantTargetChange:ne,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]=ie,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]=N,t[44]=H):H=t[44];let le;return t[45]!==n||t[46]!==se||t[47]!==z||t[48]!==B||t[49]!==V||t[50]!==H||t[51]!==oe||t[52]!==R?(le=(0,Z.jsx)(Ne,{id:oe,open:n,onOpenChange:R,leading:se,ariaLabel:z,closeAriaLabel:B,resizeAriaLabel:V,bodyClassName:`px-2`,children:H}),t[45]=n,t[46]=se,t[47]=z,t[48]=B,t[49]=V,t[50]=H,t[51]=oe,t[52]=R,t[53]=le):le=t[53],le},yr=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}=ce(),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(br)):null,t[2]=x,t[3]=k);let A=k,j;t[4]===y?j=t[5]:(j=new Set(y.map(xr)),t[4]=y,t[5]=j);let te=j,M;t[6]===g?M=t[7]:(M=new Map(g.map(Sr)),t[6]=g,t[7]=M);let N=M,ne;bb0:{if(!S?.length){ne=g;break bb0}let e;t[8]===S?e=t[9]:(e=new Map(S.map(Cr)),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];ne=r}let re=ne,ie;t[15]!==A||t[16]!==O||t[17]!==te?(ie=(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]=ie):ie=t[18];let P=ie,ae;t[19]!==N||t[20]!==n?(ae=e=>{let t=n.trim();if(!t)return!0;let r=N.get(e.providerID)?.name||e.providerID,i=ue(e.model,e.modelID,{maxLength:40});return De(i,t)||De(e.modelID,t)||De(r,t)},t[19]=N,t[20]=n,t[21]=ae):ae=t[21];let F=ae,I;if(t[22]!==_||t[23]!==P||t[24]!==F){let e;t[26]!==P||t[27]!==F?(e=e=>P(e.providerID,e.modelID)&&F(e),t[26]=P,t[27]=F,t[28]=e):e=t[28],I=_.filter(e),t[22]=_,t[23]=P,t[24]=F,t[25]=I}else I=t[25];let L=I,oe;if(t[29]!==P||t[30]!==F||t[31]!==v){let e;t[33]!==P||t[34]!==F?(e=e=>P(e.providerID,e.modelID)&&F(e),t[33]=P,t[34]=F,t[35]=e):e=t[35],oe=v.filter(e),t[29]=P,t[30]=F,t[31]=v,t[32]=oe}else oe=t[32];let R=oe,se;if(t[36]!==O||t[37]!==P||t[38]!==re||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=re.filter(r).map(t=>{let n=e.length>0&&(De(t.name||t.id,e)||De(t.id,e));return{provider:t,models:(t.models??[]).filter(r=>{let i=typeof r.id==`string`?r.id:``;return!i||!P(t.id,i)?!1:n||!e?!0:De(ue(r,i,{maxLength:40}),e)||De(i,e)})}}).filter(wr),t[36]=O,t[37]=P,t[38]=re,t[39]=n,t[40]=se}else se=t[40];let z=se,B;t[43]===E?B=t[44]:(B=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]=B);let V=B,H;t[45]===E?H=t[46]:(H=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]=H);let le=H,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,pe;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(pe={onPointerDown:Me,onClickCapture:Tr},t[50]=pe):pe=t[50];let me=pe,he;t[51]!==o||t[52]!==V||t[53]!==T||t[54]!==le||t[55]!==w||t[56]!==s||t[57]!==h||t[58]!==ee||t[59]!==fe||t[60]!==N||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=Pe(i,r,T?.(i,a)),d=C?_r(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,hr),S=o===c,D=le(u),O=u?.limit?.context?`${gr(u.limit.context)} ctx`:null;return(0,Z.jsxs)(`div`,{className:W(`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`,...me,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:N.get(i)?.name||i}):null,(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Z.jsx)(ke,{modelId:a,providerId:i,className:`size-3.5 flex-shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate typography-meta font-medium text-foreground`,children:ue(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`,...me,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:V(b)}),(0,Z.jsx)(G,{name:S?`arrow-down-s`:`arrow-right-s`,className:`size-3.5`})]}):null,(0,Z.jsx)(`button`,{type:`button`,...me,onClick:e=>{e.preventDefault(),e.stopPropagation(),ee(i,a)},className:W(`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`,...me,onClick:()=>h(i,a,e),className:W(`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:V(e)},`${c}-${e??`default`}`)}),x.length<d.length+1?(0,Z.jsx)(`button`,{type:`button`,...me,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]=V,t[53]=T,t[54]=le,t[55]=w,t[56]=s,t[57]=h,t[58]=ee,t[59]=fe,t[60]=N,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,U,be,xe,Se,Ce,we,Te;if(t[68]!==c||t[69]!==i||t[70]!==L||t[71]!==z||t[72]!==R||t[73]!==V||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?_r(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;we=`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?(Te=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)(Fe,{type:`text`,value:n,onChange:e=>{r(e.target.value),s(null)},onPointerUp:Er,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]=Te):Te=t[101],_e=Ve,U=!0,be=!0,xe=!0,Se=`min-h-0 flex-1`,Ce=`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:W(`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`),...me,onClick:()=>h(e.providerID,e.modelID,t),children:[(0,Z.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:V(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`,...me,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)(je,{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]=V,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]=U,t[90]=be,t[91]=xe,t[92]=Se,t[93]=Ce,t[94]=we,t[95]=Te}else _e=t[86],ve=t[87],ye=t[88],U=t[89],be=t[90],xe=t[91],Se=t[92],Ce=t[93],we=t[94],Te=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 Oe;t[105]!==_e||t[106]!==U||t[107]!==be||t[108]!==xe||t[109]!==Se||t[110]!==Ce||t[111]!==Ee?(Oe=(0,Z.jsx)(_e,{useScrollShadow:U,disableHorizontal:be,preventOverscroll:xe,outerClassName:Se,className:Ce,children:Ee}),t[105]=_e,t[106]=U,t[107]=be,t[108]=xe,t[109]=Se,t[110]=Ce,t[111]=Ee,t[112]=Oe):Oe=t[112];let Ae;return t[113]!==we||t[114]!==Te||t[115]!==Oe?(Ae=(0,Z.jsxs)(`div`,{className:we,children:[Te,Oe]}),t[113]=we,t[114]=Te,t[115]=Oe,t[116]=Ae):Ae=t[116],Ae};function br(e){let[t,n]=e;return[t,new Set(n)]}function xr(e){return`${e.providerID}:${e.modelID}`}function Sr(e){return[e.id,e]}function Cr(e,t){return[e,t]}function wr(e){return e.models.length>0}function Tr(e){Ee(e)||(e.preventDefault(),e.stopPropagation())}function Er(e){e.currentTarget.focus({preventScroll:!0})}var Dr=e=>{let t=(0,K.c)(217),{providerId:n,modelId:i,variant:a,onChange:o,className:s,allowedProviderIds:c,allowedModelIdsByProvider:l,placeholder:u,tooltipsEnabled:d,dropdownPortalToBody:f,showIcon:p,providers:m}=e,h=d===void 0||d,g=f!==void 0&&f,_=p===void 0||p,{t:v}=ce(),{isReady:y,isUnavailable:b}=Jn(),x=pe(Or),S=m??x,C=pe(kr),w=r(Ar),ee=r(jr),T=r(Mr),E=r(Nr),D=r(Pr),O=r(Fr),k;t[0]!==i||t[1]!==n?(k={currentProviderID:n,currentModelID:i},t[0]=i,t[1]=n,t[2]=k):k=t[2];let{favoriteModelsList:A,recentModelsList:j}=Oe(k),{isMobile:te}=Le(),M=w||te,[N,ne]=Q.useState(!1),[re,ie]=Q.useState(!1),P;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(P=()=>{ne(!0),pe.getState().refreshCatalogsOnPickerOpen({source:`modelSelector:mobilePanel`})},t[3]=P):P=t[3];let ae=se(P),F;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(F=e=>{ie(e),e&&pe.getState().refreshCatalogsOnPickerOpen({source:`modelSelector:desktopMenu`})},t[4]=F):F=t[4];let I=se(F),[L,oe]=Q.useState(``),[R,z]=Q.useState(null),B=a!==void 0,V;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(V=()=>{ne(!1),ie(!1),oe(``),z(null)},t[5]=V):V=t[5];let H=V,le;t[6]===S?le=t[7]:(le=e=>{let t=S.find(t=>t.id===e.providerID)?.models?.find(t=>t.id===e.modelID);return t?.variants?Object.keys(t.variants):[]},t[6]=S,t[7]=le);let ue=le,de;t[8]!==D||t[9]!==ue||t[10]!==i||t[11]!==o||t[12]!==n||t[13]!==a||t[14]!==B?(de=e=>{let t=ue(e),r=e.providerID===n&&e.modelID===i,s=e.variant!==void 0&&t.includes(e.variant)?e.variant:void 0,c=r&&a&&t.includes(a)?a:s??``;o(e.providerID,e.modelID,B?c:void 0),D(e.providerID,e.modelID,B&&c||void 0),H()},t[8]=D,t[9]=ue,t[10]=i,t[11]=o,t[12]=n,t[13]=a,t[14]=B,t[15]=de):de=t[15];let fe=de,me;t[16]!==o||t[17]!==B?(me=()=>{o(``,``,B?``:void 0),H()},t[16]=o,t[17]=B,t[18]=me):me=t[18];let he=me,ge;t[19]!==D||t[20]!==o||t[21]!==R?(ge=e=>{R&&(o(R.providerID,R.modelID,e),D(R.providerID,R.modelID,e||void 0),H())},t[19]=D,t[20]=o,t[21]=R,t[22]=ge):ge=t[22];let _e=ge,ve;t[23]===v?ve=t[24]:(ve=v(`settings.agents.modelSelector.searchPlaceholder`),t[23]=v,t[24]=ve);let ye;t[25]===v?ye=t[26]:(ye=v(`settings.agents.modelSelector.state.noModelsFound`),t[25]=v,t[26]=ye);let U;t[27]===v?U=t[28]:(U=v(`settings.agents.modelSelector.section.favorites`),t[27]=v,t[28]=U);let be;t[29]===v?be=t[30]:(be=v(`settings.agents.modelSelector.section.recent`),t[29]=v,t[30]=be);let xe;t[31]===v?xe=t[32]:(xe=v(`settings.agents.modelSelector.keyboardHints`),t[31]=v,t[32]=xe);let Se;t[33]!==u||t[34]!==v?(Se=u||v(`settings.agents.modelSelector.notSelected`),t[33]=u,t[34]=v,t[35]=Se):Se=t[35];let Ce;t[36]===v?Ce=t[37]:(Ce=v(`settings.agents.modelSelector.actions.favorite`),t[36]=v,t[37]=Ce);let we;t[38]===v?we=t[39]:(we=v(`settings.agents.modelSelector.actions.unfavorite`),t[38]=v,t[39]=we);let Te;t[40]===v?Te=t[41]:(Te=v(`chat.modelControls.provider`),t[40]=v,t[41]=Te);let Ee;t[42]===v?Ee=t[43]:(Ee=v(`chat.modelControls.capabilities`),t[42]=v,t[43]=Ee);let De;t[44]===v?De=t[45]:(De=v(`chat.modelControls.capability.toolCalling`),t[44]=v,t[45]=De);let je;t[46]===v?je=t[47]:(je=v(`chat.modelControls.capability.reasoning`),t[46]=v,t[47]=je);let Me;t[48]===v?Me=t[49]:(Me=v(`chat.modelControls.modality.image`),t[48]=v,t[49]=Me);let Ne;t[50]===v?Ne=t[51]:(Ne=v(`chat.modelControls.modality.video`),t[50]=v,t[51]=Ne);let Pe;t[52]===v?Pe=t[53]:(Pe=v(`chat.modelControls.modality.audio`),t[52]=v,t[53]=Pe);let Fe;t[54]===v?Fe=t[55]:(Fe=v(`chat.modelControls.costPerMillion`),t[54]=v,t[55]=Fe);let Ie;t[56]===v?Ie=t[57]:(Ie=v(`chat.modelControls.costInput`),t[56]=v,t[57]=Ie);let Re;t[58]===v?Re=t[59]:(Re=v(`chat.modelControls.costOutput`),t[58]=v,t[59]=Re);let ze;t[60]!==ve||t[61]!==ye||t[62]!==U||t[63]!==be||t[64]!==xe||t[65]!==Se||t[66]!==Ce||t[67]!==we||t[68]!==Te||t[69]!==Ee||t[70]!==De||t[71]!==je||t[72]!==Me||t[73]!==Ne||t[74]!==Pe||t[75]!==Fe||t[76]!==Ie||t[77]!==Re?(ze={searchPlaceholder:ve,noResults:ye,favorites:U,recent:be,keyboardHint:xe,notSelected:Se,favorite:Ce,unfavorite:we,provider:Te,capabilities:Ee,capabilityToolCalling:De,capabilityReasoning:je,modalityImage:Me,modalityVideo:Ne,modalityAudio:Pe,costPerMillion:Fe,costInput:Ie,costOutput:Re},t[60]=ve,t[61]=ye,t[62]=U,t[63]=be,t[64]=xe,t[65]=Se,t[66]=Ce,t[67]=we,t[68]=Te,t[69]=Ee,t[70]=De,t[71]=je,t[72]=Me,t[73]=Ne,t[74]=Pe,t[75]=Fe,t[76]=Ie,t[77]=Re,t[78]=ze):ze=t[78];let Be=ze,Ve;t[79]!==i||t[80]!==n?(Ve=n&&i?{providerID:n,modelID:i}:null,t[79]=i,t[80]=n,t[81]=Ve):Ve=t[81];let He=Ve,Ue;t[82]!==i||t[83]!==u||t[84]!==n||t[85]!==v?(Ue=n&&i?`${n}/${i}`:u||v(`settings.agents.modelSelector.notSelected`),t[82]=i,t[83]=u,t[84]=n,t[85]=v,t[86]=Ue):Ue=t[86];let We=Ue,Ge;t[87]!==v||t[88]!==a||t[89]!==B?(Ge=B?a||v(`chat.modelControls.default`):null,t[87]=v,t[88]=a,t[89]=B,t[90]=Ge):Ge=t[90];let Ke=Ge,qe;t[91]!==i||t[92]!==n||t[93]!==a||t[94]!==B?(qe=(e,t)=>{if(!(!B||e!==n||t!==i))return a||void 0},t[91]=i,t[92]=n,t[93]=a,t[94]=B,t[95]=qe):qe=t[95];let Je=qe,Ye;t[96]!==D||t[97]!==o||t[98]!==B?(Ye=(e,t,n)=>{o(e,t,B?n??``:void 0),D(e,t,B&&n||void 0),H()},t[96]=D,t[97]=o,t[98]=B,t[99]=Ye):Ye=t[99];let Xe=Ye,Ze;t[100]!==ue||t[101]!==v||t[102]!==a||t[103]!==B?(Ze=(e,t)=>{let n=ue(e);if(!B||n.length===0)return null;let r=e.variant!==void 0&&n.includes(e.variant)?e.variant:void 0,i=t.isSelected?a: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(),z(e)},"aria-label":v(`chat.modelControls.showThinkingModes`),children:[(0,Z.jsx)(`span`,{className:`max-w-24 truncate`,children:i||v(`chat.modelControls.default`)}),(0,Z.jsx)(G,{name:`arrow-right-s`,className:`size-3.5`})]})},t[100]=ue,t[101]=v,t[102]=a,t[103]=B,t[104]=Ze):Ze=t[104];let Qe=Ze,q=M?`max-h-none flex-1`:void 0,J=h&&(M?N:re),Y;t[105]===E?Y=t[106]:(Y=e=>E(e.providerID,e.modelID),t[105]=E,t[106]=Y);let X;t[107]!==i||t[108]!==n||t[109]!==T||t[110]!==a?(X=e=>T(e.providerID,e.modelID,e.providerID===n&&e.modelID===i?a||void 0:e.variant),t[107]=i,t[108]=n,t[109]=T,t[110]=a,t[111]=X):X=t[111];let $e;t[112]!==l||t[113]!==c||t[114]!==A||t[115]!==C||t[116]!==fe||t[117]!==he||t[118]!==ee||t[119]!==Be||t[120]!==O||t[121]!==S||t[122]!==j||t[123]!==Qe||t[124]!==L||t[125]!==He||t[126]!==q||t[127]!==J||t[128]!==Y||t[129]!==X?($e=(0,Z.jsx)(Ae,{providers:S,providerOrder:O,favoriteModels:A,recentModels:j,getMetadata:C,searchQuery:L,onSearchQueryChange:oe,onSelect:fe,labels:Be,selectedModel:He,hiddenModels:ee,allowedProviderIds:c,allowedModelIdsByProvider:l,includeNotSelected:!0,onSelectNone:he,onEscape:H,maxHeightClassName:q,tooltipsEnabled:J,isFavorite:Y,onToggleFavorite:X,renderRowEnd:Qe}),t[112]=l,t[113]=c,t[114]=A,t[115]=C,t[116]=fe,t[117]=he,t[118]=ee,t[119]=Be,t[120]=O,t[121]=S,t[122]=j,t[123]=Qe,t[124]=L,t[125]=He,t[126]=q,t[127]=J,t[128]=Y,t[129]=X,t[130]=$e):$e=t[130];let et=$e,tt;t[131]!==ue||t[132]!==R?(tt=R?ue(R):[],t[131]=ue,t[132]=R,t[133]=tt):tt=t[133];let nt=tt,rt;bb0:{if(!R){rt=``;break bb0}if(R.providerID===n&&R.modelID===i){rt=a||``;break bb0}rt=R.variant!==void 0&&nt.includes(R.variant)?R.variant:``}let it=rt,at;t[134]!==_e||t[135]!==v||t[136]!==R||t[137]!==it||t[138]!==nt?(at=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:()=>z(null),"aria-label":v(`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":v(`chat.modelControls.thinking`),children:[``,...nt].map(e=>{let t=it===e;return(0,Z.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,className:W(`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||v(`chat.modelControls.default`)}),t?(0,Z.jsx)(G,{name:`check`,className:`size-4 shrink-0`}):null]},e||`__default`)})})]}):null,t[134]=_e,t[135]=v,t[136]=R,t[137]=it,t[138]=nt,t[139]=at):at=t[139];let ot=at||et;if(M){let e=y?ae:void 0,r=!y,o=!y&&`opacity-60 cursor-not-allowed`,u;t[140]!==s||t[141]!==o?(u=W(`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`,o,s),t[140]=s,t[141]=o,t[142]=u):u=t[142];let d;t[143]!==y||t[144]!==b||t[145]!==i||t[146]!==n||t[147]!==_||t[148]!==v?(d=y?_&&(n||i)?(0,Z.jsx)(ke,{modelId:i,providerId:n,className:`h-3.5 w-3.5 flex-shrink-0`}):_?(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:v(b?`common.unavailable`:`common.loading`)})]}),t[143]=y,t[144]=b,t[145]=i,t[146]=n,t[147]=_,t[148]=v,t[149]=d):d=t[149];let f;t[150]!==y||t[151]!==We?(f=y?(0,Z.jsx)(`span`,{className:`typography-meta font-medium text-foreground truncate`,children:We}):null,t[150]=y,t[151]=We,t[152]=f):f=t[152];let p;t[153]!==y||t[154]!==Ke?(p=y&&Ke?(0,Z.jsx)(`span`,{className:`shrink-0 typography-micro text-muted-foreground`,children:Ke}):null,t[153]=y,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 g;t[161]!==e||t[162]!==r||t[163]!==u||t[164]!==m?(g=(0,Z.jsxs)(`button`,{type:`button`,onClick:e,disabled:r,className:u,children:[m,h]}),t[161]=e,t[162]=r,t[163]=u,t[164]=m,t[165]=g):g=t[165];let x;t[166]!==A||t[167]!==i||t[168]!==n||t[169]!==j||t[170]!==T||t[171]!==a?(x=(e,t)=>T(e,t,e===n&&t===i?a||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]=i,t[168]=n,t[169]=j,t[170]=T,t[171]=a,t[172]=x):x=t[172];let w;t[173]!==l||t[174]!==c||t[175]!==A||t[176]!==C||t[177]!==Xe||t[178]!==ee||t[179]!==E||t[180]!==N||t[181]!==i||t[182]!==n||t[183]!==O||t[184]!==S||t[185]!==j||t[186]!==Je||t[187]!==x||t[188]!==B?(w=(0,Z.jsx)(vr,{open:N,onClose:H,selectedProviderID:n,selectedModelID:i,resolveSelectedVariant:Je,onSelect:Xe,providers:S,favoriteModels:A,recentModels:j,getMetadata:C,hiddenModels:ee,allowedProviderIds:c,allowedModelIdsByProvider:l,providerOrder:O,variantSelectionEnabled:B,isFavorite:E,onToggleFavorite:x}),t[173]=l,t[174]=c,t[175]=A,t[176]=C,t[177]=Xe,t[178]=ee,t[179]=E,t[180]=N,t[181]=i,t[182]=n,t[183]=O,t[184]=S,t[185]=j,t[186]=Je,t[187]=x,t[188]=B,t[189]=w):w=t[189];let D;return t[190]!==g||t[191]!==w?(D=(0,Z.jsxs)(Z.Fragment,{children:[g,w]}),t[190]=g,t[191]=w,t[192]=D):D=t[192],D}let st=y&&re,ct=y?I:void 0,lt=!y&&`opacity-60 cursor-not-allowed`,ut;t[193]!==s||t[194]!==lt?(ut=W(`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,s),t[193]=s,t[194]=lt,t[195]=ut):ut=t[195];let dt;t[196]!==y||t[197]!==b||t[198]!==i||t[199]!==n||t[200]!==_||t[201]!==v||t[202]!==We||t[203]!==Ke?(dt=y?(0,Z.jsxs)(Z.Fragment,{children:[_?n||i?(0,Z.jsx)(ke,{modelId:i,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:v(b?`common.unavailable`:`common.loading`)})]}),t[196]=y,t[197]=b,t[198]=i,t[199]=n,t[200]=_,t[201]=v,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)(Vn,{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]!==g||t[210]!==ot?(mt=(0,Z.jsx)(Hn,{className:`w-[min(380px,calc(100vw-2rem))] p-0 flex flex-col`,align:`start`,portalToBody:g,children:ot}),t[209]=g,t[210]=ot,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)(Bn,{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 Or(e){return e.providers}function kr(e){return e.getModelMetadata}function Ar(e){return e.isMobile}function jr(e){return e.hiddenModels}function Mr(e){return e.toggleFavoriteModel}function Nr(e){return e.isFavoriteModel}function Pr(e){return e.addRecentModel}function Fr(e){return e.providerOrder}var Ir=e=>e??u()?.github,Lr=(e=t())=>o.github.auth(e),Rr=async(e,t)=>{if(e)return e.authStatus();let n=await s(`/api/github/auth/status`,{method:`GET`,headers:{Accept:`application/json`},signal:t}),r=await n.json().catch(()=>null);if(!n.ok||!r)throw Error(r?.error||n.statusText||`Failed to load GitHub status`);return r},zr=(e,n=t())=>{let r=Ir(e);return{queryKey:Lr(n),queryFn:async({signal:e})=>Rr(r,e),retry:2}},Br=e=>!!e&&typeof e==`object`&&`authStatus`in e,Vr=e=>{let t=(0,K.c)(5),n=Br(e)?e:void 0,r=Br(e)?void 0:e?.enabled,i;t[0]===n?i=t[1]:(i=zr(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],j(a)},Hr=(e=l,n=t())=>e.getQueryData(Lr(n))??null,Ur=async(e,n,r)=>t()===r?e.fetchQuery({...zr(n,r),staleTime:0}):e.getQueryData(Lr(r))??null,Wr=(e=l,n,r=t())=>{e.setQueryData(Lr(r),n)},Gr=ne.define(R),Kr=I.data.of({commentTokens:{line:`//`,block:{open:`/*`,close:`*/`}}});function qr(e){let t=e.trim().toLowerCase();switch(t){case`bash`:case`sh`:case`zsh`:case`shell`:case`shellsession`:case`console`:return Gr;case`json`:case`jsonc`:case`json5`:return F().language;case`js`:case`javascript`:return P().language;case`jsx`:return P({jsx:!0}).language;case`ts`:case`typescript`:return P({typescript:!0}).language;case`tsx`:return P({typescript:!0,jsx:!0}).language;case`html`:return ae().language;case`css`:return ie().language;case`py`:case`python`:return oe().language;case`md`:case`markdown`:case`mdown`:case`mkd`:return L().language;case`heex`:case`eex`:case`leex`:return ae().language;default:return re.matchLanguageName(He,t,!0)}}var Jr=e=>e.split(`/`).pop()?.toLowerCase()??``,Yr=e=>{let t=Jr(e);return t?re.matchFilename(He,t):null},Xr=()=>te(N.define([{tag:[M.heading1,M.heading2,M.heading3,M.heading4,M.heading5,M.heading6],fontWeight:`600`},{tag:M.strong,fontWeight:`600`},{tag:M.emphasis,fontStyle:`italic`},{tag:M.strikethrough,textDecoration:`line-through`},{tag:[M.link,M.url],color:`var(--markdown-link, currentColor)`,textDecoration:`underline`},{tag:M.monospace,color:`var(--markdown-inline-code, currentColor)`,backgroundColor:`var(--markdown-inline-code-bg, transparent)`},{tag:M.quote,color:`var(--markdown-blockquote, currentColor)`,fontStyle:`italic`},{tag:M.list,color:`color-mix(in srgb, var(--muted-foreground) 40%, var(--foreground) 60%)`},{tag:M.heading,color:`var(--markdown-heading1, currentColor)`}]));function Zr(e){let t=e.toLowerCase();switch(Jr(t)){case`makefile`:case`gnumakefile`:return Gr}let n=t.lastIndexOf(`.`),r=n>=0?t.slice(n+1):``;switch(r){case`ts`:case`tsx`:case`mts`:case`cts`:return P({typescript:!0,jsx:r===`tsx`});case`js`:case`jsx`:case`mjs`:case`cjs`:return P({typescript:!1,jsx:r===`jsx`});case`jsonc`:case`json5`:return[F(),Kr];case`json`:case`jsonl`:case`ndjson`:case`geojson`:return F();case`css`:case`scss`:case`sass`:case`less`:return ie();case`html`:case`htm`:case`xml`:case`drawio`:case`dio`:return ae();case`md`:case`mdx`:case`markdown`:case`mdown`:case`mkd`:return[L({codeLanguages:qr}),Xr()];case`sh`:case`bash`:case`zsh`:case`fish`:case`env`:return Gr;case`py`:case`pyw`:case`pyi`:return oe();default:return null}}async function Qr(e){let t=Yr(e);if(!t)return null;if(t.support)return t.support;try{return await t.load()}catch{return null}}var $r=60,ei=400;function ti(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+=ei){let n=e.slice(t,t+ei);i&&i.length+n.length>ei&&(r.push(i.trim()),i=``),i+=n,i.length>=$r&&/[.!?…]["')\]]*\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 ni=null;function ri(){return ni||=new(window.AudioContext||window.webkitAudioContext),ni}function ii(){let[e,t]=(0,Q.useState)(!1),[n,r]=(0,Q.useState)(null),i=(0,Q.useRef)(null),a=(0,Q.useRef)(null),o=(0,Q.useCallback)(async()=>{try{let e=ri();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=a.current;if(e&&(e.cancelled=!0,e.abort.abort(),a.current=null),i.current){try{i.current.onended=null,i.current.stop()}catch{}i.current=null}t(!1)},[]),l=(0,Q.useCallback)(async(e,n)=>{c();let o=ti(e);if(o.length===0){r(`No text to speak`),n?.onError?.(`No text to speak`);return}r(null);let l={cancelled:!1,abort:new AbortController};a.current=l;let u=async e=>{let t=await s(`/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=ri();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),i.current=r,r.onended=()=>{i.current===r&&(i.current=null),e()},r.start(0)})};try{t(!0),n?.onStart?.();let e=u(o[0]);for(let t=0;t<o.length;t+=1){let n=await e;if(l.cancelled||(t+1<o.length&&(e=u(o[t+1])),await d(n),l.cancelled))return}t(!1),n?.onEnd?.()}catch(e){if(e.name===`AbortError`||l.cancelled)return;let i=e instanceof Error?e.message:`Failed to speak`;r(i),n?.onError?.(i),t(!1)}finally{a.current===l&&(a.current=null)}},[c]);return(0,Q.useEffect)(()=>()=>{c()},[c]),{isPlaying:e,error:n,speak:l,stop:c,unlockAudio:o}}var ai=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}`}},oi=e=>{if(e===`12h`)return!0;if(e===`24h`)return!1},si=(e,t,n={})=>{let r=e instanceof Date?e:new Date(e);return Number.isFinite(r.getTime())?r.toLocaleTimeString(z(),{hour:n.hour??`numeric`,minute:`2-digit`,second:n.precision===`second`?`2-digit`:void 0,hour12:oi(t)}):n.fallback??``},ci=(e,t,n)=>{let r=e instanceof Date?e:new Date(e);return Number.isFinite(r.getTime())?r.toLocaleString(z(),{...n,hour12:n.hour?oi(t):n.hour12}):``},li=Q.memo(function(e){let t=(0,K.c)(24),{checked:n,onChange:r,disabled:i,ariaLabel:a,className:o,iconClassName:s}=e,c=i!==void 0&&i,l;t[0]!==n||t[1]!==c||t[2]!==r?(l=e=>{e.preventDefault(),e.stopPropagation(),!c&&!n&&r()},t[0]=n,t[1]=c,t[2]=r,t[3]=l):l=t[3];let u=l,d;t[4]!==n||t[5]!==c||t[6]!==r?(d=e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),!c&&!n&&r())},t[4]=n,t[5]=c,t[6]=r,t[7]=d):d=t[7];let f=d,p=n?`bg-[color-mix(in_srgb,var(--primary-base)_80%,transparent)] shadow-none hover:bg-[var(--primary-base)]`:`bg-[var(--surface-muted)] shadow-[inset_0_0_0_1px_var(--interactive-border)] hover:bg-[var(--interactive-hover)]`,m;t[8]!==o||t[9]!==p?(m=W(`group/radio relative flex h-[14px] w-[14px] min-h-[14px] min-w-[14px] shrink-0 self-center items-center justify-center rounded-full outline-none`,`transition-[background-color,box-shadow] duration-200 ease-out`,p,`focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-background`,`disabled:cursor-not-allowed disabled:opacity-50`,o),t[8]=o,t[9]=p,t[10]=m):m=t[10];let h=!n&&`opacity-0`,g;t[11]!==s||t[12]!==h?(g=W(`block h-[5px] w-[5px] rounded-full bg-white`,h,s),t[11]=s,t[12]=h,t[13]=g):g=t[13];let _;t[14]===g?_=t[15]:(_=(0,Z.jsx)(`span`,{"aria-hidden":!0,className:g}),t[14]=g,t[15]=_);let v;return t[16]!==a||t[17]!==n||t[18]!==c||t[19]!==u||t[20]!==f||t[21]!==m||t[22]!==_?(v=(0,Z.jsx)(`button`,{type:`button`,role:`radio`,onClick:u,onKeyDown:f,disabled:c,"aria-checked":n,"aria-label":a,className:m,children:_}),t[16]=a,t[17]=n,t[18]=c,t[19]=u,t[20]=f,t[21]=m,t[22]=_,t[23]=v):v=t[23],v}),$=e=>H(V.getState().dictionary,e),ui=e=>typeof e!=`number`||!Number.isFinite(e)?null:Math.max(0,Math.min(100,Math.round(e))),di=e=>typeof e!=`number`||!Number.isFinite(e)?`-`:`${Math.round(e)}%`,fi=(e,t)=>e??di(t),pi=(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()?si(r,n,{fallback:t??``}):ci(r,n,{month:`short`,day:`numeric`,weekday:`short`,hour:`numeric`,minute:`2-digit`})}catch{return t??``}},mi=e=>e===null?`safe`:e>=80?`critical`:e>=50?`warn`:`safe`,hi=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,gi=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},_i=(e,t,n,r)=>{let i=n;if(i===null&&r&&(i=gi(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}},vi=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)`}},yi=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`},bi=e=>Math.min(100,Math.max(0,e*100)),xi=[`standalone`,`minimal-ui`,`fullscreen`,`window-controls-overlay`],Si=`openchamber.pwaRecentSessions`,Ci=e=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(display-mode: ${e})`).matches,wi=()=>typeof window>`u`?`browser`:typeof document<`u`&&document.referrer.startsWith(`android-app://`)?`twa`:window.navigator.standalone?`standalone`:xi.find(e=>Ci(e))??`browser`,Ti=864e5,Ei=5,Di=864e5,Oi=e=>e.time?.updated??e.time?.created??0,ki=({sessions:e,currentSessionId:t,cutoffDays:n,keepRecent:r=Ei,now:i=Date.now()})=>{if(!Array.isArray(e)||n<=0)return[];let a=i-n*Ti,o=[...e].sort((e,t)=>Oi(t)-Oi(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=Oi(e);return n?n<a:!1}).map(e=>e.id)},Ai=e=>{let t=typeof e==`object`?e:void 0,n=t?.autoRun!==!1,i=typeof e==`boolean`?e:t?.enabled??!0,a=me(e=>e.currentSessionId),o=me(e=>e.isLoading),s=ge(e=>e.activeSessions),c=ge(e=>e.hasLoadedFullCatalog),l=r(e=>e.autoDeleteEnabled),u=r(e=>e.autoDeleteAfterDays),d=r(e=>e.sessionRetentionAction),f=r(e=>e.autoDeleteLastRunAt),p=r(e=>e.setAutoDeleteLastRunAt),[m,h]=Q.useState(!1),g=Q.useRef(!1);Q.useEffect(()=>{if(!i||!n||!l||u<=0)return;let e=window.setTimeout(()=>{ye(le())},8e3);return()=>window.clearTimeout(e)},[u,l,n,i]);let _=Q.useMemo(()=>u<=0?[]:ki({sessions:s,currentSessionId:a,cutoffDays:u}),[u,a,s]),v=Q.useCallback(async({force:e=!1}={})=>{if(g.current)return{completedIds:[],failedIds:[],action:d,skippedReason:`running`};if((!l||u<=0)&&!e)return{completedIds:[],failedIds:[],action:d,skippedReason:`disabled`};if(o)return{completedIds:[],failedIds:[],action:d,skippedReason:`loading`};let t=Date.now();if(!e&&f&&t-f<Di)return{completedIds:[],failedIds:[],action:d,skippedReason:`cooldown`};let{activeSessions:n}=await ye(le());if(n.length===0)return{completedIds:[],failedIds:[],action:d,skippedReason:`no-candidates`};let r=ki({sessions:n,currentSessionId:a,cutoffDays:u,now:t});if(r.length===0)return p(t),{completedIds:[],failedIds:[],action:d,skippedReason:`no-candidates`};g.current=!0,h(!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?he(r):null;if(!a){i.push(n);continue}try{d===`archive`?await E.updateSession(n,{time:{archived:Date.now()}},a):await E.deleteSession(n,a),t.push(n)}catch{i.push(n)}}return d===`archive`?ge.getState().archiveSessions(t):ge.getState().removeSessions(t),{completedIds:t,failedIds:i,action:d}}finally{g.current=!1,h(!1),p(Date.now())}},[u,l,f,a,o,d,p]);return Q.useEffect(()=>{i&&n&&(!l||u<=0||o||!c||s.length===0||f&&Date.now()-f<Di||v())},[u,l,f,n,i,c,s.length,o,v]),{candidates:_,isRunning:m,runCleanup:v,keepRecentCount:Ei,action:d}};export{Tn as $,mr as A,mt as At,qn as B,Wr as C,ft as Ct,lr as D,ut as Dt,vr as E,lt as Et,Hn as F,At as Ft,On as G,gn as H,Un as I,Ye as It,Mn as J,An as K,Kn as L,Xe as Lt,$n as M,Et as Mt,Jn as N,Dt as Nt,fr as O,ht as Ot,Bn as P,kt as Pt,Cn as Q,Wn as R,Ze as Rt,Ur as S,ct as St,Dr as T,dt as Tt,Pn as U,Vn as V,In as W,kn as X,Fn as Y,Nn as Z,ii as _,Rt as _t,_i as a,an as at,Qr as b,Ft as bt,fi as c,on as ct,vi as d,en as dt,hn as et,mi as f,rn as ft,ai as g,zt as gt,si as h,Ut as ht,bi as i,fn as it,dr as j,Ot as jt,pr as k,gt as kt,yi as l,sn as lt,ci as m,cn as mt,Si as n,pn as nt,ui as o,tn as ot,li as p,ln as pt,jn as q,wi as r,dn as rt,pi as s,Zt as st,Ai as t,un as tt,hi as u,nn as ut,qr as v,Pt as vt,Vr as w,pt as wt,Hr as x,_t as xt,Zr as y,It as yt,Gn as z};
|