@openchambery/web 2.1.6 → 2.1.7-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentAvatar-Ah1nMt7y.js → AgentAvatar-CAR4F5Sn.js} +1 -1
- package/dist/assets/AssistantView-gJYQLjJ3.js +3 -0
- package/dist/assets/{DiagramView-BMb2wYbe.js → DiagramView-BfOWoVlT.js} +1 -1
- package/dist/assets/{FadeInOnReveal-BssISEuf.js → FadeInOnReveal-CCVddfP5.js} +1 -1
- package/dist/assets/{Icon-DewMAW7N.js → Icon-DDB7S6Vz.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-D7q71Qgl.js → ImageLoadingPlaceholder-C6fDEcU1.js} +1 -1
- package/dist/assets/{LoadingImage-BBGT-9VQ.js → LoadingImage-ByBH-5WW.js} +1 -1
- package/dist/assets/MarkdownRenderer-DiQPj3zp.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-BHJyOEtM.js → MarkdownRendererImpl-Bbiy-nFx.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-tGQ_A1nY.js → MarkstreamRendererImpl-Du_pQflq.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-hYERDT-V.js → MobileDetailNavigation-DHEof6Xp.js} +1 -1
- package/dist/assets/MobileShareBridge-RncdV5OG.js +4 -0
- package/dist/assets/MobileTabPageHeader-htBRNUU5.js +2 -0
- package/dist/assets/{MultiRunWindow-B2XKXiwZ.js → MultiRunWindow-ga6oMWY6.js} +1 -1
- package/dist/assets/OnboardingScreen-DINUboLT.js +1 -0
- package/dist/assets/{OverlayScrollbar-C24-p2ns.js → OverlayScrollbar-BkxmoyYl.js} +1 -1
- package/dist/assets/{SettingsView-DJNhpwyz.js → SettingsView-D5STpT-G.js} +9 -9
- package/dist/assets/{SettingsWindow-ChQIxx1T.js → SettingsWindow-BjtKpUgd.js} +1 -1
- package/dist/assets/{TerminalView-ezDxLLqj.js → TerminalView-B73IPj8t.js} +1 -1
- package/dist/assets/ToolOutputDialog-Ol_NdZdw.js +10 -0
- package/dist/assets/{appThemeRegistry-an4Akg1y.js → appThemeRegistry-BpqASUSd.js} +1 -1
- package/dist/assets/{button-kJNzMb1G.js → button-DymteyMv.js} +1 -1
- package/dist/assets/{collapsible-MInYZ7dA.js → collapsible-Dzp5rO0Q.js} +1 -1
- package/dist/assets/{desktopHosts-BKeEWmL5.js → desktopHosts-DSBZ-9-L.js} +1 -1
- package/dist/assets/{desktopRelayRestore-FWm2fXr6.js → desktopRelayRestore-DK8TzHRx.js} +1 -1
- package/dist/assets/{diagram-BDSPghN-.js → diagram-CQs9px6y.js} +1 -1
- package/dist/assets/dialog-DfUeXqdE.js +1 -0
- package/dist/assets/dropdown-menu.styles-B6YMNOZz.js +1 -0
- package/dist/assets/{es-CLTWsqOO.js → es-2YvsazK2.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-D8shekVD.js → fileMentionTouchSelection-UGCePzqT.js} +1 -1
- package/dist/assets/{fileQueries-Dhgypzyl.js → fileQueries-BGE5l3Jd.js} +1 -1
- package/dist/assets/{fr-BNyfwida.js → fr-Cy0M48Gw.js} +1 -1
- package/dist/assets/{gitApi-DKkx78zO.js → gitApi-jesfo75O.js} +1 -1
- package/dist/assets/{image-loading-DDV3Ixi1.css → image-loading-CObM4tcX.css} +1 -1
- package/dist/assets/{image-loading-OgMEw4Jq.js → image-loading-qNtUCy69.js} +1 -1
- package/dist/assets/{input-02eTmC8w.js → input-BvpZiRHI.js} +1 -1
- package/dist/assets/{insertionBoundaries-DC6LhiXE.js → insertionBoundaries-BKaakPCA.js} +1 -1
- package/dist/assets/{ja-D7MYkMo9.js → ja-1zLWWJ2R.js} +1 -1
- package/dist/assets/{ko-CFNLrmLm.js → ko-BLk_5Dhc.js} +1 -1
- package/dist/assets/{main-CtK997zX.js → main-B70CpYy5.js} +21 -21
- package/dist/assets/main-D7axZ-68.js +2 -0
- package/dist/assets/{markdownHeightCache-CAVQhVdd.js → markdownHeightCache-MW1NYOaG.js} +1 -1
- package/dist/assets/{mcpQueries-CB2NAD7N.js → mcpQueries-D0hGK5or.js} +1 -1
- package/dist/assets/miniChat-CHz-dfV6.js +2 -0
- package/dist/assets/mobile-IDzFxCKP.js +2 -0
- package/dist/assets/{multirun-DV5TMnaP.js → multirun-DJHCRK8q.js} +1 -1
- package/dist/assets/{persistence-DUPZl7Oy.js → persistence-B7ORJ371.js} +1 -1
- package/dist/assets/{pl-aKpW58gt.js → pl-BE8MC0XQ.js} +1 -1
- package/dist/assets/{platform-z2erC6Bs.js → platform-CiBU2bCp.js} +2 -2
- package/dist/assets/{projectMeta-DT6vocn9.js → projectMeta-C2W05Ema.js} +1 -1
- package/dist/assets/{pt-BR-MliQk6-s.js → pt-BR-ubhNymyH.js} +1 -1
- package/dist/assets/rasterizePng-CpK-xCkB.js +1 -0
- package/dist/assets/renderElectronMiniChatApp-BVBUj0PS.js +2 -0
- package/dist/assets/renderMobileApp-DYUCAwQx.js +28 -0
- package/dist/assets/{runtimeConfig-Dthkfz2P.js → runtimeConfig-qrx2Um5J.js} +1 -1
- package/dist/assets/runtimeEndpointReset-DjAuC4DZ.js +149 -0
- package/dist/assets/scheduledTaskNavigation-BnKGGUlX.js +1 -0
- package/dist/assets/sessionChangeSummary-Du4sCUoa.js +2 -0
- package/dist/assets/{sessionLookup-Boow5kCB.js → sessionLookup-qmXzah_M.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-DSGwZHAT.js → sortable-tabs-strip-CWR8KhJB.js} +1 -1
- package/dist/assets/{speechSettingsQueries-BepWtZaB.js → speechSettingsQueries-CDN4NwYP.js} +3 -3
- package/dist/assets/src-C9BNQK0O.css +2 -0
- package/dist/assets/{store-D5OeM4wB.js → store-n-H5RvRn.js} +1 -1
- package/dist/assets/{terminalApi-BnjU_lmF.js → terminalApi-bN5IYQau.js} +1 -1
- package/dist/assets/{textarea-yLPH5NYp.js → textarea-ClPlugKE.js} +1 -1
- package/dist/assets/{tooltip-B3eYZnNS.js → tooltip-D-1Pgmq1.js} +1 -1
- package/dist/assets/{uk-8Ovv1FvC.js → uk-BNyyigDo.js} +1 -1
- package/dist/assets/{url-DAyfGWPH.js → url-nbXEti6c.js} +1 -1
- package/dist/assets/{useAppFontEffects-DFTA_GW0.js → useAppFontEffects-CA6OGq9Z.js} +53 -53
- package/dist/assets/{useAssistantUIStore-Dt0l5AKe.js → useAssistantUIStore-Dlvb7P0q.js} +1 -1
- package/dist/assets/{useDesktopWindowControlsLayout-CWqj2fDY.js → useDesktopWindowControlsLayout-XV0q6OV5.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-CT3VhbVS.js → useEffectiveDirectory-DlNcsuzO.js} +1 -1
- package/dist/assets/{useFontPreferences-B4Cgu3bS.js → useFontPreferences-6LD7d7hP.js} +1 -1
- package/dist/assets/useMobileNavigationStore-BaX-xQnU.js +417 -0
- package/dist/assets/useUIStore-CDMI_Yzu.js +1 -0
- package/dist/assets/{useWorkerHighlightedLines-Vnb6JoM_.js → useWorkerHighlightedLines-BrZrVBSe.js} +1 -1
- package/dist/assets/{zh-CN-DYC-d6-i.js → zh-CN-CNWzMPgL.js} +1 -1
- package/dist/assets/{zh-TW-OPu9_qbz.js → zh-TW-DrZ9S1yn.js} +1 -1
- package/dist/index.html +9 -9
- package/dist/mini-chat.html +9 -9
- package/dist/mobile.html +9 -9
- package/package.json +1 -1
- package/server/lib/assistants/DOCUMENTATION.md +39 -0
- package/server/lib/assistants/harness.js +20 -7
- package/server/lib/assistants/harness.test.js +21 -0
- package/server/lib/assistants/routes.js +2 -1
- package/server/lib/assistants/service.js +76 -13
- package/server/lib/assistants/service.test.js +53 -0
- package/server/lib/content-search/DOCUMENTATION.md +46 -0
- package/server/lib/content-search/routes.test.js +22 -0
- package/server/lib/content-search/runtime.js +17 -4
- package/server/lib/content-search/runtime.test.js +96 -0
- package/server/lib/content-search/service.js +25 -5
- package/server/lib/content-search/service.test.js +37 -0
- package/server/lib/notifications/DOCUMENTATION.md +5 -0
- package/server/lib/opencode/feature-routes-runtime.js +1 -0
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +25 -0
- package/server/lib/scheduled-tasks/run-history-store.js +18 -5
- package/server/lib/scheduled-tasks/run-history-store.test.js +51 -0
- package/server/lib/scheduled-tasks/runtime.js +70 -12
- package/server/lib/scheduled-tasks/runtime.test.js +131 -0
- package/dist/assets/AssistantView-qt_ud4Nc.js +0 -3
- package/dist/assets/MarkdownRenderer-BrnwB_5z.js +0 -2
- package/dist/assets/MobileShareBridge-Btm7sD6Q.js +0 -4
- package/dist/assets/MobileTabPageHeader-ChvRBBO4.js +0 -2
- package/dist/assets/OnboardingScreen-BjikXNcy.js +0 -1
- package/dist/assets/ToolOutputDialog-B5EFlFnb.js +0 -10
- package/dist/assets/context-menu-BYq0LM7H.js +0 -1
- package/dist/assets/dropdown-menu.styles-BXvVFEkh.js +0 -1
- package/dist/assets/main-5uaFaww8.js +0 -2
- package/dist/assets/miniChat-BjFb74VD.js +0 -2
- package/dist/assets/mobile-V6jbZiro.js +0 -2
- package/dist/assets/rasterizePng-DCmIQQsI.js +0 -1
- package/dist/assets/renderElectronMiniChatApp-BQBfuJqo.js +0 -2
- package/dist/assets/renderMobileApp-OOyAHKm3.js +0 -28
- package/dist/assets/runtimeEndpointReset-DlUwUDnO.js +0 -148
- package/dist/assets/sessionChangeSummary-Da1AQvgD.js +0 -2
- package/dist/assets/src-BAWBlgDt.css +0 -2
- package/dist/assets/useMobileNavigationStore-CuLx5fxh.js +0 -417
- package/dist/assets/useUIStore-pl39iO82.js +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-capacitor-app-B5H_XtmE.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,o as r}from"./runtime-switch-3ad3yzM7.js";import{n as i}from"./runtime-fetch-QCWYlAx0.js";import{Gt as a,Kt as o,Mn as s,Sn as c,_ as l,an as u,dn as d,f,fn as p,h as m,i as h,ln as g,m as _,on as v,ot as y,sn as b,st as x,u as S,un as C}from"./persistence-DUPZl7Oy.js";import{a as w,i as T,r as E}from"./vendor-zustand-o69pgTEK.js";import{it as D,nt as O,rt as k}from"./vendor-base-ui-CdzJ6My_.js";import{Ct as A,Nt as j,Vt as M,n as N,t as P}from"./platform-z2erC6Bs.js";import{b as F,n as I}from"./useUIStore-pl39iO82.js";import{n as L}from"./vendor-react-BP2cRVqX.js";import{o as R}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{o as ee}from"./vendor-tanstack-react-query-CdqCAt40.js";import{t as te}from"./types-BuiqMmh_.js";import{A as ne,G as re,H as z,K as ie,L as ae,P as B,Q as oe,T as se,V,W as H,X as ce,Z as le,a as ue,g as de,ht as fe,lt as pe,mt as me,pt as he,q as ge,st as U,tt as _e}from"./vendor-codemirror-autocomplete-DHomsvW7.js";import{n as W}from"./vendor-reactuses-core-BpfIZ1tg.js";import{a as ve,d as ye,f as G,p as be,r as K,t as q}from"./button-kJNzMb1G.js";import{Ar as xe,Dr as Se,Pr as J,Qn as Ce,ar as we,br as Te,co as Y,d as Ee,di as De,er as Oe,gi as ke,ir as Ae,nr as je,ro as Me,tr as Ne,yn as Pe}from"./useMobileNavigationStore-CuLx5fxh.js";import{i as Fe,n as Ie,o as Le,r as Re,s as ze}from"./rasterizePng-DCmIQQsI.js";import{n as Be}from"./useThemeSystem-8jhE4Zyk.js";import{n as X}from"./Icon-DewMAW7N.js";import{L as Ve,_ as He,b as Ue,c as We,n as Ge,s as Ke,u as qe}from"./gitApi-DKkx78zO.js";import{A as Je,_ as Ye,a as Xe,b as Ze,c as Qe,h as $e,m as et,n as tt,r as nt,t as rt,x as it}from"./projectMeta-DT6vocn9.js";import{t as at}from"./input-02eTmC8w.js";import{i as ot,n as st,t as ct}from"./tooltip-B3eYZnNS.js";import{$t as lt,A as ut,F as dt,I as ft,J as pt,N as mt,Q as ht,Qt as gt,Xt as _t,Y as vt,Yt as yt,Z as bt,Zt as xt,cn as St,ct as Ct,en as wt,mt as Tt,o as Et,q as Dt,rn as Ot,st as kt,y as At}from"./speechSettingsQueries-BepWtZaB.js";import{i as jt,n as Mt}from"./OverlayScrollbar-C24-p2ns.js";import{n as Nt,t as Pt}from"./textarea-yLPH5NYp.js";import{n as Ft}from"./MarkdownRenderer-BrnwB_5z.js";import{a as It}from"./url-DAyfGWPH.js";import{r as Lt}from"./markdown-worker-DFNZ3KJ_.js";import{i as Rt,n as zt,o as Bt}from"./mcpQueries-CB2NAD7N.js";import{n as Vt,r as Ht,t as Ut}from"./collapsible-MInYZ7dA.js";import{a as Wt,d as Gt,o as Kt,s as qt}from"./vendor-codemirror-commands-C9DCaJ0C.js";import{a as Jt,c as Yt,i as Xt,o as Zt,r as Qt,s as $t}from"./vendor-codemirror-search-D2SOgzph.js";import{n as en,t as tn}from"./vendor-replit-codemirror-vim-CEibx3EP.js";import{i as nn,n as rn,r as an,t as on}from"./projectActions-CWvNGKfA.js";var sn=[{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`}],cn=e=>[...sn,...e.filter(e=>e.source===`magpie`).map(e=>({id:e.providerId,name:e.providerName}))],Z=L(),Q=k();function ln(e){let t=(0,Z.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.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,Q.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,Q.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 un={},dn=(e,t=n())=>JSON.stringify([t,zt(e)]),fn=(e,t,n)=>{if(!e[t]?.[n])return e;let r={...e[t]};return delete r[n],{...e,[t]:r}},pn=e=>{let t=zt(e);return t?j.getScopedApiClient(t):j.getApiClient()},mn=e=>e?{location:{directory:e}}:void 0,hn=e=>zt(e===void 0?A.getState().currentDirectory:e),gn=w()(E((e,t)=>({diagnosticsByDirectory:{},getDiagnosticForDirectory:e=>{let n=dn(hn(e));return t().diagnosticsByDirectory[n]??un},clearDiagnostic:(t,n,r)=>{let i=dn(hn(n),r);e(e=>({diagnosticsByDirectory:fn(e.diagnosticsByDirectory,i,t)}))},connect:async(t,r)=>{let i=hn(r),a=n(),o=dn(i,a),s=pn(i);try{await s.mcp.connect({server:t,...mn(i)})}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 Bt(_,i,a),e(e=>({diagnosticsByDirectory:fn(e.diagnosticsByDirectory,o,t)}))},disconnect:async(t,r)=>{let i=hn(r),a=n(),o=dn(i,a);await pn(i).mcp.disconnect({server:t,...mn(i)}),await Bt(_,i,a),e(e=>({diagnosticsByDirectory:fn(e.diagnosticsByDirectory,o,t)}))},startAuth:async(e,t)=>{throw M(`mcp.auth`)},completeAuth:async(e,t,n)=>{throw M(`mcp.auth`)},clearAuth:async(e,t)=>{throw M(`mcp.auth`)},testConnection:async(t,r)=>{let i=hn(r),a=n(),o=dn(i,a),s=pn(i),c=Rt(_,i,a)[t]?.status===`connected`,l,u;try{await s.mcp.connect({server:t,...mn(i)})}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 Bt(_,i,a))[t],f=d;if(!c&&d?.status===`connected`){try{await s.mcp.disconnect({server:t,...mn(i)})}catch(e){u=`Connection test succeeded, but cleanup disconnect failed: ${e instanceof Error?e.message:`Disconnect failed`}`}await Bt(_,i,a)}return l||e(e=>({diagnosticsByDirectory:fn(e.diagnosticsByDirectory,o,t)})),{status:f??Rt(_,i,a)[t],error:l,warning:u}}}))),$=e(D(),1),_n=e=>typeof e==`string`&&e.trim().length>0?e.trim():null,vn=()=>_n(`2.1.6`),yn=(e,t)=>_n(t)||_n(e),bn=(e,t)=>{let n=_n(e);return n?typeof t!=`number`||!Number.isFinite(t)?n:`${n} (${t})`:null},xn=async()=>{let e=vn();if(!N())return e;try{let{App:t}=await R(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2]));return yn((await t.getInfo()).version,e)}catch{return e}},Sn=async()=>{if(!N())return null;try{let{App:e}=await R(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.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}},Cn=`https://openchamber.xiaobe.top/v1/update/check`,wn=`https://openchamber-update.vercel.app/v1/update/check`,Tn=`https://github.com/yee94/openchamber/releases/latest`,En=`https://github.com/yee94/openchamber/releases`,Dn=`https://testflight.apple.com/join/ZCENBHtm`,On=1e4;function kn(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 An(e,t){let n=kn(e),r=kn(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 jn(){return[Cn,wn]}function Mn(e,t,n=Date.now){let r=e-n();return r<=0||t<=0?null:Math.max(1,Math.ceil(r/t))}function Nn(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 Pn(e,t,n,r){try{if(N())try{let{CapacitorHttp:r}=await R(async()=>{let{CapacitorHttp:e}=await import(`./vendor-aparajita-capacitor-secure-storage-xol_6BsB.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 Fn(e,t){return e===`ios`?Dn:`${En}/download/v${t}/app-release.apk`}function In(e,t,n){if(typeof e.latestVersion!=`string`||e.latestVersion.trim().length===0)return null;let r=e.latestVersion.trim(),i=An(r,t);if(i<0)return null;let a=typeof e.releaseNotesUrl==`string`&&e.releaseNotesUrl.trim().length>0?e.releaseNotesUrl.trim():`${En}/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():Fn(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 Ln(e,t,n,r){let i=await Pn(e,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify(Nn(t))},n,r);if(!i?.ok)return null;let a;try{a=await i.json()}catch{return null}return In(a,t.currentVersion,t.platform)}async function Rn(e,t,n,r){let i=await Pn(Tn,{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:Tn,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=An(s,e),l=`${En}/tag/v${s}`;return{available:c>0,version:s,currentVersion:e,releaseUrl:l,downloadUrl:Fn(t,s)}}async function zn(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=jn(),a=r()+On;for(let[t,o]of i.entries()){let s=Mn(a,i.length-t+1,r);if(s===null)break;let c=await Ln(o,e,s,n);if(c)return c}let o=Mn(a,1,r);if(o!==null){let r=await Rn(t,e.platform,o,n);if(r)return r}return{available:!1,currentVersion:t,error:`Unable to check for mobile updates`}}function Bn(){if(typeof window>`u`)return`unknown`;try{let{deviceType:e}=Mt();return e}catch{return`unknown`}}function Vn(){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 Hn(){let e=P();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 Un(e){let t=I.getState().reportUsage,n=new URLSearchParams({reportUsage:t?`true`:`false`});return n.set(`deviceClass`,Bn()),n.set(`arch`,Vn()),n.set(`platform`,Hn()),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 Wn(e,t){let n=t??`unknown`;try{let r=Un(e),a=typeof window<`u`?window.__VSCODE_CONFIG__?.extensionVersion:void 0;t?r.set(`currentVersion`,t):e===`vscode`&&a&&r.set(`currentVersion`,a);let o=await i(`/api/openchamber/update-check?${r.toString()}`,{method:`GET`,headers:{Accept:`application/json`}}),s=null;try{s=await o.json()}catch{s=null}if(!o.ok)return{available:!1,currentVersion:n,error:typeof s?.error==`string`&&s.error.trim().length>0?s.error.trim():`Server responded with ${o.status}`};if(!s)return{available:!1,currentVersion:n,error:`Update check returned an invalid response`};let c=typeof s.error==`string`&&s.error.trim().length>0?s.error.trim():void 0;return{available:s.available===!0,version:typeof s.version==`string`?s.version:void 0,currentVersion:typeof s.currentVersion==`string`?s.currentVersion:n,body:typeof s.body==`string`?s.body:void 0,releaseUrl:typeof s.releaseUrl==`string`?s.releaseUrl:void 0,downloadUrl:typeof s.downloadUrl==`string`?s.downloadUrl:void 0,nextSuggestedCheckInSec:typeof s.nextSuggestedCheckInSec==`number`&&Number.isFinite(s.nextSuggestedCheckInSec)?s.nextSuggestedCheckInSec:void 0,packageManager:typeof s.packageManager==`string`?s.packageManager:void 0,updateCommand:typeof s.updateCommand==`string`?s.updateCommand:void 0,error:c}}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 Gn(){return N()?`mobile`:b()?`desktop`:g()?`vscode`:C()?`web`:null}var Kn={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 qn(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 Jn=0,Yn=w()((e,t)=>({...Kn,checkForUpdates:async()=>{let n=Gn();if(!n)return null;let r=++Jn;e({checking:!0,error:null,runtimeType:n});try{let i=null,o=null;if(n===`desktop`){let n=I.getState().otaChannelOverride;t().lastOtaChannelOverride!==n&&e({downloaded:!1,downloading:!1,available:!1,info:null,otaDecision:null,progress:null,otaPhase:`checking`});let i=await a(n);if(r!==Jn||I.getState().otaChannelOverride!==n)return null;let o=i?.downloaded===!0;return e({checking:!1,available:i?.available??!1,downloaded:o,...o?{downloading:!1,progress:null}:{},info:i,error:null,lastChecked:Date.now(),nextCheckInSec:i?.nextSuggestedCheckInSec??null,otaDecision:i?.otaDecision??null,otaPhase:o?`pending_restart`:i?.inAppApply?`available`:`idle`,lastOtaChannelOverride:n}),i?.nextSuggestedCheckInSec??null}if(n===`web`)i=await Wn(`web`),o=i?.nextSuggestedCheckInSec??null;else if(n===`vscode`)o=(await Wn(`vscode`))?.nextSuggestedCheckInSec??null;else if(n===`mobile`){let n=await xn()??`unknown`,r=N()?s()?.mobileUpdates:void 0,a=I.getState().otaChannelOverride;if(r)try{let i=t().lastOtaChannelOverride!==a;e(i?{otaDecision:null,otaPhase:`checking`,downloaded:!1,otaDownloadSkipped:!1,progress:null,available:!1,info:null}:{otaPhase:`checking`});let o=await r.checkForOtaUpdate(a===`beta`||a===`stable`?{channelOverride:a}:void 0),s=qn(o,n),c=(i?void 0:t().otaDecision?.ota.bundle?.bundleId)!==o.ota.bundle?.bundleId,l=!i&&t().downloaded&&!c;return e({checking:!1,available:s.available,info:s.info,error:s.info.error??null,lastChecked:Date.now(),nextCheckInSec:o.nextCheckInSec,otaDecision:o,otaPhase:l?`pending_restart`:s.otaPhase,lastOtaChannelOverride:a,...c||i?{downloaded:!1,otaDownloadSkipped:!1,progress:null}:{}}),o.nextCheckInSec}catch(t){if(!(t instanceof te)){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:a}),null}}return i=await zn({currentVersion:n,platform:Hn()===`ios`?`ios`:`android`,deviceClass:Bn(),arch:Vn(),reportUsage:I.getState().reportUsage}),o=i?.nextSuggestedCheckInSec??null,e({checking:!1,available:i?.available??!1,info:i,error:i?.error??null,lastChecked:Date.now(),nextCheckInSec:o,otaDecision:null,otaPhase:`idle`}),o}return e({checking:!1,available:n===`vscode`?!1:i?.available??!1,info:n===`vscode`?null:i,error:n===`vscode`?null:i?.error??null,lastChecked:Date.now(),nextCheckInSec:o}),o}catch(i){return r===Jn&&e({checking:!1,error:i instanceof Error?i.message:`Failed to check for updates`,...n===`desktop`&&!t().downloaded?{otaPhase:`error`}:{}}),null}},downloadUpdate:async()=>{let{available:n,runtimeType:r,otaDecision:i,downloading:c,downloaded:l}=t();if(r===`mobile`&&i?.primaryAction===`apply_ota`&&i.ota.bundle){if(c||l)return;let t=s()?.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=I.getState().otaChannelOverride,r=await a(n);if(n!==I.getState().otaChannelOverride)throw Error(`OTA channel changed`);if(!r?.available||r.manualUpdate)throw Error(`Update detected, but desktop package is not ready yet. Retry in a moment.`);if(e(e=>({info:e.info?{...e.info,...r,body:r.body||e.info.body,available:e.info.available}:r})),r.downloaded||t().downloaded){e({downloading:!1,downloaded:!0,progress:null});return}if(r.downloading&&e({downloading:!0,progress:r.progress??{downloaded:0}}),!await o(t=>{e({progress:t})}))throw Error(`Failed to download update`);e({downloading:!1,downloaded:!0,progress:null,otaPhase:`pending_restart`})}catch(t){e({downloading:!1,error:t instanceof Error?t.message:`Failed to download update`})}}},subscribeDesktopUpdateEvents:async()=>{if(!b())return()=>{};let n=[],r=await d(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 p(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=s()?.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 c())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:()=>{t().otaPhase!==`pending_restart`&&e({available:!1,downloaded:!1,info:null,otaDecision:null,otaPhase:`idle`,otaDownloadSkipped:!1})},reset:()=>{e(Kn)}})),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(be(),{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 i(`/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 i(`/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 i(`/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}=G(),[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 ye(E)).ok&&(f(!0),setTimeout(()=>f(!1),2e3))},A=(0,$.useCallback)(async e=>{await It(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,Q.jsx)(Ie,{open:e,onOpenChange:N?void 0:D,children:(0,Q.jsxs)(Re,{className:`max-w-4xl gap-0 p-4 sm:p-5 bg-background border-[var(--interactive-border)]`,showCloseButton:!0,children:[(0,Q.jsxs)(`div`,{className:`mb-3 pr-8 sm:mb-4`,children:[(0,Q.jsxs)(ze,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(X,{name:`download-cloud`,className:`h-5 w-5 text-[var(--primary-base)]`}),(0,Q.jsx)(`span`,{className:`font-semibold text-foreground`,children:u(p===`restarting`||p===`reconnecting`?`updateDialog.header.updating`:`updateDialog.header.updateAvailable`)})]}),(n?.currentVersion||n?.version)&&(0,Q.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,Q.jsx)(`span`,{className:`text-muted-foreground/75`,children:n.currentVersion}),n?.currentVersion&&n?.version&&(0,Q.jsx)(`span`,{className:`text-muted-foreground/40`,children:`→`}),n?.version&&(0,Q.jsx)(`span`,{className:`font-medium text-[var(--primary-base)]`,children:n.version})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[x&&N&&(0,Q.jsxs)(`div`,{className:`rounded-lg bg-[var(--surface-elevated)]/30 p-5 border border-[var(--surface-subtle)]`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(X,{name:`loader`,className:`h-5 w-5 animate-spin text-[var(--primary-base)]`}),(0,Q.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,Q.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:u(`updateDialog.status.autoReloadHint`)})]}),P&&!N&&(0,Q.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-[var(--surface-subtle)] bg-[var(--surface-elevated)]/20`,children:[(0,Q.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,Q.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--primary-base)]`,"aria-hidden":`true`}),(0,Q.jsx)(`h3`,{className:`typography-ui-caption font-medium text-muted-foreground`,children:P.title})]}),(0,Q.jsx)(Nt,{className:`max-h-[min(42dvh,22rem)] p-0 sm:max-h-[400px]`,fillContainer:!1,children:P.kind===`raw`?(0,Q.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,Q.jsx)(Ft,{content:P.content,disableLinkSafety:!0,enableFileReferences:!1})}):(0,Q.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:P.sections.map(e=>(0,Q.jsxs)(`div`,{className:`p-3.5 sm:p-4`,children:[(0,Q.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-center gap-x-2 gap-y-1 sm:mb-3`,children:[(0,Q.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,Q.jsx)(`span`,{className:`text-[11px] leading-4 text-muted-foreground/75 sm:text-xs`,children:e.dateLabel})]}),(0,Q.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,Q.jsx)(Ft,{content:e.content,disableLinkSafety:!0,enableFileReferences:!1})})]},e.version))})})]}),x&&p===`error`&&(0,Q.jsxs)(`div`,{className:`space-y-2 mt-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 typography-meta text-muted-foreground`,children:[(0,Q.jsx)(X,{name:`terminal`,className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:u(`updateDialog.fallback.updateViaTerminal`)})]}),(0,Q.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,Q.jsx)(`code`,{className:`flex-1 font-mono text-sm text-foreground overflow-x-auto whitespace-nowrap`,children:E}),(0,Q.jsx)(`button`,{onClick:k,className:K(`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,Q.jsx)(X,{name:`check`,className:`h-4 w-4`}):(0,Q.jsx)(X,{name:`clipboard`,className:`h-4 w-4`})})]})]}),!x&&(!S||w)&&r&&(0,Q.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,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground sm:text-[13px]`,children:u(`updateDialog.status.downloadingPayload`)}),(0,Q.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] leading-4 text-foreground tabular-nums sm:text-xs`,children:[b,`%`]})]}),(0,Q.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-[var(--surface-subtle)] sm:h-1.5`,children:(0,Q.jsx)(`div`,{className:`h-full rounded-full bg-[var(--primary-base)] transition-all duration-300`,style:{width:`${b}%`}})})]}),(o||h)&&(0,Q.jsx)(`div`,{className:`p-3 mt-4 bg-[var(--status-error-background)] border border-[var(--status-error-border)] rounded-lg`,children:(0,Q.jsx)(`p`,{className:`text-sm text-[var(--status-error)]`,children:o||h})})]}),w&&i&&_&&(0,Q.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,Q.jsx)(X,{name:`check`,className:`h-4 w-4 shrink-0`}),(0,Q.jsx)(`span`,{children:u(`updateDialog.status.otaBundleReused`)})]}),(0,Q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-4`,children:[!S||C?(0,Q.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,Q.jsx)(X,{name:`external-link`,className:`h-4 w-4`}),`GitHub`]}):(0,Q.jsx)(`span`,{}),(0,Q.jsxs)(`div`,{className:`flex-1 flex justify-end`,children:[!x&&(!S||w)&&!T&&!i&&!r&&(0,Q.jsxs)(q,{onClick:s,size:`default`,children:[(0,Q.jsx)(X,{name:`download`,className:`h-4 w-4`}),u(w?`updateDialog.actions.applyOtaNow`:`updateDialog.actions.downloadUpdate`)]}),!x&&!S&&T&&!i&&!r&&(0,Q.jsxs)(q,{onClick:()=>void A(v),size:`default`,children:[(0,Q.jsx)(X,{name:`external-link`,className:`h-4 w-4`}),u(`updateDialog.actions.openMobileUpdate`)]}),!x&&(!S||w)&&r&&(0,Q.jsxs)(q,{disabled:!0,size:`default`,children:[(0,Q.jsx)(X,{name:`loader`,className:`h-4 w-4 animate-spin`}),u(`updateDialog.status.downloading`)]}),!x&&(!S||w)&&i&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[w&&(0,Q.jsx)(q,{onClick:O,variant:`ghost`,size:`default`,children:u(`updateDialog.actions.later`)}),(0,Q.jsxs)(q,{onClick:c,size:`default`,children:[(0,Q.jsx)(X,{name:`restart`,className:`h-4 w-4`}),u(`updateDialog.actions.restartToUpdate`)]})]}),S&&!w&&C&&(0,Q.jsxs)(q,{onClick:M,size:`default`,children:[(0,Q.jsx)(X,{name:`external-link`,className:`h-4 w-4`}),u(`updateDialog.actions.openMobileUpdate`)]}),x&&!N&&(0,Q.jsxs)(q,{onClick:j,size:`default`,children:[(0,Q.jsx)(X,{name:`download`,className:`h-4 w-4`}),u(`updateDialog.actions.updateNow`)]}),x&&N&&(0,Q.jsxs)(q,{disabled:!0,size:`default`,children:[(0,Q.jsx)(X,{name:`loader`,className:`h-4 w-4 animate-spin`}),u(`updateDialog.status.updating`)]})]})]})]})})},cr=e(O(),1);function lr(e){let t=(0,Z.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=K(`oc-settings-group`,s),t[0]=s,t[1]=d);let f;t[2]!==n||t[3]!==u?(f=n?(0,Q.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=K(`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,Q.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,Q.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,Q.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,Z.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,Q.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,Q.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,Z.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=K(`oc-settings-group-row oc-settings-split-row`,o),t[0]=o,t[1]=l);let u;t[2]===s?u=t[3]:(u=K(`oc-settings-split-row-copy`,s),t[2]=s,t[3]=u);let d;t[4]===n?d=t[5]:(d=n?(0,Q.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,Q.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,Q.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=K(`oc-settings-split-row-control`,c),t[12]=c,t[13]=m);let h;t[14]!==r||t[15]!==m?(h=(0,Q.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,Q.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,Z.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=K(`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,Q.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,Q.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,Q.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,Q.jsx)(`div`,{"data-settings-value":``,className:`oc-settings-split-row-control`,children:(0,Q.jsx)(Je,{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,Q.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}var mr=[`connection`,`personalization`,`workspace`,`opencode`,`content`,`system`],hr=[`instances`,`appearance`,`chat`,`notifications`,`sessions`,`archived-sessions`,`summary-ai`,`shortcuts`,`projects`,`git`,`remote-instances`,`providers`,`agents`,`assistants`,`behavior`,`commands`,`mcp`,`plugins`,`global-config`,`magic-prompts`,`skills.installed`,`skills.catalog`,`usage`,`voice`,`about`],gr=[`instances`,`appearance`,`chat`,`notifications`,`sessions`,`archived-sessions`,`summary-ai`,`projects`,`git`,`providers`,`agents`,`assistants`,`behavior`,`commands`,`mcp`,`plugins`,`magic-prompts`,`skills.installed`,`usage`,`voice`,`about`],_r=[{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:`archived-sessions`,title:`Archived sessions`,group:`personalization`,kind:`single`,keywords:[`archive`,`archived`,`restore`,`preview`,`history`]},{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:`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||e.isDesktop}];function vr(e){let t=new Map(hr.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 mr.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 yr={sessions:`sessions`,agents:`agents`,commands:`commands`,mcp:`mcp`,skills:`skills.installed`,providers:`providers`,usage:`usage`,"git-identities":`git`,settings:`home`};function br(e){let t=e.trim().toLowerCase();return _r.find(e=>e.slug===t)??null}function xr(e){let t=(e??``).trim().toLowerCase();if(!t)return`home`;let n=yr[t];if(n)return n;let r=br(t);return r?r.slug:`home`}var Sr=`/mcp/oauth/callback`,Cr=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}},wr=e=>{let t=Er(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}},Tr=e=>{let t=e.get(`state`);return typeof t==`string`&&t.trim()||null},Er=e=>{if(typeof e!=`string`||!e.trim())return null;let t=Cr(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}},Dr=e=>typeof e==`object`&&!!e&&`updateStatus`in e&&typeof e.updateStatus==`function`,Or=e=>{let t=document.createElement(`div`);t.className=`cm-vim-panel`;let n=tn(e);if(!n)return{top:!1,dom:t};n.state.statusbar=t;let r=n.state.vimPlugin;return Dr(r)&&r.updateStatus(),{top:!1,dom:t,destroy(){n.state.statusbar===t&&(n.state.statusbar=null)}}};function kr(e){return e?[en(),_e.of(Or),ge()]:[]}var Ar={next:`Next match`,prev:`Previous match`,select:`Select all matches`,replace:`Replace`,replaceAll:`Replace all`,close:`Close`},jr={case:`Match case`,re:`Regular expression`,word:`Match whole word`};function Mr(e){let t=e.querySelector(`.cm-search`);if(t){for(let[e,n]of Object.entries(Ar)){let r=t.querySelector(`button[name="${e}"]`);r&&!r.title&&(r.title=n)}for(let[e,n]of Object.entries(jr)){let r=t.querySelector(`input[name="${e}"]`)?.parentElement;r&&!r.title&&(r.title=n)}}}var Nr=new WeakMap;function Pr(e,t){let n=Xt(e.state);if(!n.valid)return Nr.delete(e),0;let r=Nr.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 Nr.set(e,{query:n,doc:e.state.doc,total:a}),a}function Fr(e){let t=Xt(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 Ir(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=Pr(t,n),o=a===0?0:Fr(t);i.textContent=a===0?``:`${o}/${a}`}var Lr=new U,Rr=new U,zr=new U,Br=new U,Vr=new U,Hr=new U,Ur=new U,Wr=e=>e,Gr=se,Kr=Jt,qr=Qt,Jr=class extends ie{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(){}},Yr=(e,t)=>!e||e.length===0?[]:fe.define({create(n){let r=new he,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 Jr(e.id,t),block:!0,side:1}))}return r.finish()},update(e,t){return e.map(t.changes)},provide:e=>H.decorations.from(e)}),Xr=e=>{if(!e)return[];let t=Math.max(1,e.start),n=Math.max(t,e.end);return re.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 he;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 Zr({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=pe.create({doc:g.current,extensions:[...e?[H.cspNonce.of(e)]:[],ce({fixed:!0}),Lr.of(oe(a)),Kt(),ne.of(` `),Ur.of(kr(p)),le.of([Gt,...Wt,...qt]),H.updateListener.of(e=>{D(e.view),(e.viewportChanged||e.geometryChanged)&&E(x.current);let t=Yt(e.startState),n=Yt(e.state);t!==n&&b.current?.(n);let r=!Xt(e.startState).eq(Xt(e.state));if(n&&(t!==n||r||e.docChanged||e.selectionSet)&&Ir(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)}),Rr.of(H.editable.of(!i)),zr.of(n??[]),Br.of(Xr(o)),Vr.of(Yr(l,C.current)),Hr.of(u?[Zt({top:!0}),le.of(Wr($t))]:[])]});return h.current=new H({state:t,parent:m.current}),Gr(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:[Lr.reconfigure(oe(a)),Rr.reconfigure(H.editable.of(!i)),zr.reconfigure(n??[]),Br.reconfigure(Xr(o)),Vr.reconfigure(Yr(l,C.current)),Hr.reconfigure(u?[Zt({top:!0}),le.of(Wr($t))]:[])]}),Gr(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:Ur.reconfigure(kr(p))}))},[p]),$.useEffect(()=>{let e=h.current;!e||u===!1||(d?(Kr(e),requestAnimationFrame(()=>{Mr(e.dom),Ir(e.dom,e,!0)})):qr(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}}),Gr(t,t.state.doc.length,300),t.requestMeasure(),requestAnimationFrame(()=>D(t)))},[e,D]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{ref:m,className:K(`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 Qr(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=ue.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=ue.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(de,{fallback:!0}),B(ae),B(c),B(l)]}var $r=180,ei=me.define(),ti=1,ni=2,ri=4,ii=new Map,ai=(e,t)=>{let n=`${e}|${t}`,r=ii.get(n);if(r)return r;let i=``;e&&(i+=`color:${e};`),t&ti&&(i+=`font-style:italic;`),t&ni&&(i+=`font-weight:bold;`),t&ri&&(i+=`text-decoration:underline;`);let a=z.mark({attributes:{style:i}});return ii.set(n,a),a},oi=(e,t)=>{let n=new he,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,ai(t,r)))}}return n.finish()},si=fe.define({create(){return z.none},update(e,t){let n=e.map(t.changes);for(let e of t.effects)e.is(ei)&&(n=e.value);return n},provide:e=>H.decorations.from(e)}),ci=e=>re.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)},$r)}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 Lt(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:ei.of(oi(t,a))}))}destroy(){this.timer&&clearTimeout(this.timer),this.abortController?.abort(),this.abortController=void 0}}),li=e=>[si,ci(e)],ui=e=>{let t=(0,Z.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,Q.jsx)(X,{name:`eye`,className:`size-4`,"aria-hidden":`true`}):(0,Q.jsx)(X,{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,Q.jsx)(ot,{asChild:!0,children:(0,Q.jsx)(q,{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,Q.jsx)(st,{sideOffset:8,children:o}),t[6]=o,t[7]=l);let u;return t[8]!==c||t[9]!==l?(u=(0,Q.jsxs)(ct,{children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10],u},di=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 He(),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 Ue();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 qe()}),!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=s()?.settings;if(e)try{n=t(((await e.load())?.settings||{}).defaultGitIdentityId)}catch{}}if(n===null)try{let e=await i(`/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 h({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 Ke(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 Ve(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 We(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:F(),partialize:e=>({selectedProfileId:e.selectedProfileId})}),{name:`git-identities-store`}));typeof window<`u`&&(window.__zustand_git_identities_store__=di);var fi=`w-full max-w-[30rem]`,pi=e=>{let t=(0,Z.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,Q.jsx)(`span`,{className:`truncate`,children:n}),t[0]=n,t[1]=u);let d;t[2]!==u||t[3]!==a?(d=(0,Q.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,Q.jsx)(`div`,{className:`shrink-0`,children:o}):null,t[5]=o,t[6]=f);let p;t[7]!==d||t[8]!==f?(p=(0,Q.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=K(`oc-settings-group-row`,l),t[10]=l,t[11]=m);let h;t[12]!==s||t[13]!==m?(h=(0,Q.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,Q.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,Q.jsx)(`div`,{"data-settings-item":i,className:c,children:g}),t[19]=c,t[20]=i,t[21]=g,t[22]=_):_=t[22],_},mi=450,hi=({projectRef:e=null})=>{let{t}=G(),{isMobile:n,isTablet:r}=jt(),i=n||r,a=Y(e=>e.getActiveProject()),o=e?.path??a?.path??null,s=Ee(e=>e.getWorktreeMetadata),c=Pe(),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 Qe(T);x(e)}catch{}},[T,v]);$.useEffect(()=>{if(!o)return;let e=!1;return y(null),(async()=>{try{let t=await Ge(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 Qe(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([Oe(T),Ne(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 Ae(T,n)?(_(JSON.stringify(e)),!0):(J.error(t(`settings.openchamber.worktrees.setup.toast.saveFailed`)),!1)}catch{return J.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}})())},mi);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&&we(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=[...xe.getState().activeSessions,...xe.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));ke.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,Q.jsxs)(ct,{children:[(0,Q.jsx)(ot,{asChild:!0,children:(0,Q.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,Q.jsxs)(st,{sideOffset:8,className:`max-w-xs`,children:[t(`settings.openchamber.worktrees.setup.tooltipPrefix`),` `,(0,Q.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,Q.jsxs)(ct,{children:[(0,Q.jsx)(ot,{asChild:!0,children:(0,Q.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,Q.jsx)(st,{sideOffset:8,className:`max-w-xs`,children:t(`settings.openchamber.worktrees.list.tooltip`)})]});return o?v===!1?(0,Q.jsx)(pi,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.worktrees.state.gitOnly`)})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(pi,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,titleAccessory:L,children:m?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.worktrees.setup.loading`)}):(0,Q.jsxs)(`div`,{className:K(`flex flex-col gap-2`,fi),children:[u.map((e,n)=>(0,Q.jsxs)(`div`,{className:`oc-settings-group-row flex w-full items-center gap-2`,children:[(0,Q.jsx)(at,{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,Q.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,Q.jsx)(X,{name:`close`,className:`h-4 w-4`})})]},n)),(0,Q.jsxs)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:j,children:[(0,Q.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),t(`settings.openchamber.worktrees.setup.addCommand`)]}),(0,Q.jsxs)(`label`,{"data-settings-item":`projects.worktree.setup.wait`,className:`flex cursor-pointer items-center gap-2 py-1`,children:[(0,Q.jsx)(Je,{checked:f,onChange:P,ariaLabel:t(`settings.openchamber.worktrees.setup.waitForCommandsAria`)}),(0,Q.jsx)(`span`,{className:K(`typography-ui-label font-normal`,f?`text-foreground`:`text-foreground/60`),children:t(`settings.openchamber.worktrees.setup.waitForCommands`)})]})]})}),(0,Q.jsx)(pi,{title:t(`settings.openchamber.worktrees.list.title`),titleAccessory:R,children:S?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.worktrees.list.loading`)}):b.length===0?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground/70`,children:t(`settings.openchamber.worktrees.list.empty`)}):(0,Q.jsx)(`div`,{className:K(`space-y-1`,fi),children:b.map(e=>(0,Q.jsxs)(`div`,{className:`group flex w-full items-center gap-2 py-1.5`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`p`,{className:`typography-meta min-w-0 truncate text-foreground`,children:e.label||e.branch||t(`settings.openchamber.worktrees.list.detachedHead`)}),(0,Q.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,Q.jsx)(`p`,{className:`typography-micro truncate text-muted-foreground/60`,children:ve(e.path,l)})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>F(e),className:K(`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,Q.jsx)(X,{name:`delete-bin`,className:`h-4 w-4`})})]},e.path))})})]}):(0,Q.jsx)(pi,{title:t(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.worktrees.state.selectProject`)})})},gi=(e,t)=>t.updatedAtMs-e.updatedAtMs,_i=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([lt(),Ot()]),i={};for(let e of r.sort(gi))i[e.id]=e;t().listenerReady||await St(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 gt(),isImportsLoading:!1})}catch(t){e({isImportsLoading:!1,error:t instanceof Error?t.message:String(t)})}}},refreshStatuses:async()=>{try{let t=await Ot(),n={};for(let e of t.sort(gi))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 wt({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=yt(e,n);r&&r.trim()&&(i.nickname=r.trim()),await t().upsertInstance(i)},removeInstance:async n=>{await xt(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 _t(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 xt(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})})),vi=450,yi=()=>x(),bi=()=>({id:yi(),name:``,command:``,icon:`play`}),xi=({projectRef:e})=>{let{t}=G(),n=$.useMemo(()=>v(),[]),r=_i(e=>e.instances),i=_i(e=>e.load),[a,o]=$.useState([]),[s,c]=$.useState(!1),[l,u]=$.useState(null),[d,f]=$.useState({}),p=$.useRef(!1),m=$.useRef(null);$.useEffect(()=>{n&&i().catch(()=>void 0)},[n,i]),$.useEffect(()=>{let t=!1;return c(!0),(async()=>{try{let n=await Ce(e);if(t)return;o(n.actions),u(JSON.stringify({actions:n.actions}))}catch{if(t)return;o([]),u(JSON.stringify({actions:[]}))}finally{t||c(!1)}})(),()=>{t=!0}},[e]);let h=$.useMemo(()=>n?nn(r):[],[r,n]),g=$.useMemo(()=>a.some(e=>e.name.trim().length===0||e.command.trim().length===0)?t(`settings.projects.actions.validation.fillNameAndCommand`):null,[a,t]),_=$.useMemo(()=>l!==null&&l!==JSON.stringify({actions:a}),[a,l]),y=$.useCallback(async n=>await je(e,{actions:n,primaryActionId:null})?(u(JSON.stringify({actions:n})),typeof window<`u`&&window.dispatchEvent(new CustomEvent(on,{detail:{projectId:e.id}})),!0):(J.error(t(`settings.projects.actions.toast.saveFailed`)),!1),[e,t]);$.useEffect(()=>{if(!_||s||g||p.current)return;let e=window.setTimeout(()=>{p.current||(p.current=!0,(async()=>{try{await y(a)}finally{p.current=!1}})())},vi);return()=>{window.clearTimeout(e)}},[a,_,s,y,g]),$.useEffect(()=>{if(!_||!g||s){g||(m.current=null);return}let e=window.setTimeout(()=>{m.current!==g&&(m.current=g,J.error(g))},1e3);return()=>{window.clearTimeout(e)}},[_,s,g]);let b=$.useCallback(()=>{let e=bi();o(t=>[...t,e]),f(t=>({...t,[e.id]:!0}))},[]),x=$.useCallback(e=>{o(t=>t.filter(t=>t.id!==e)),f(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,Q.jsxs)(pi,{title:t(`settings.projects.actions.title`),description:t(`settings.projects.actions.description`),settingsItem:`projects.actions`,headerAction:(0,Q.jsxs)(q,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:b,children:[(0,Q.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),t(`settings.projects.actions.actions.add`)]}),contentClassName:`space-y-0`,children:[s?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.loading`)}):a.length===0?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.empty`)}):(0,Q.jsx)(`div`,{className:K(`space-y-0`,fi),children:a.map(e=>{let r=e.icon||`play`,i=an[r]||`play`,a=d[e.id]??!1,o=e.name.trim()||t(`settings.projects.actions.state.untitled`);return(0,Q.jsxs)(Ut,{open:a,onOpenChange:t=>{f(n=>({...n,[e.id]:t}))},className:`py-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsxs)(Ht,{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,Q.jsx)(X,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground`}):(0,Q.jsx)(X,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground`}),(0,Q.jsx)(X,{name:i,className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}),(0,Q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Q.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:o})})]}),(0,Q.jsx)(q,{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,Q.jsx)(X,{name:`delete-bin`,className:`h-3.5 w-3.5`})})]}),(0,Q.jsx)(Vt,{className:`pt-1.5`,children:(0,Q.jsxs)(`div`,{className:`space-y-2 pb-4 pl-3 pr-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,Q.jsxs)(kt,{children:[(0,Q.jsx)(Tt,{asChild:!0,children:(0,Q.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,Q.jsx)(X,{name:i,className:`h-4 w-4`})})}),(0,Q.jsx)(Ct,{align:`start`,className:`w-56 p-2`,children:(0,Q.jsx)(`div`,{className:`grid grid-cols-6 gap-1`,children:rn.map(n=>{let r=n.Icon,i=(e.icon||`play`)===n.key;return(0,Q.jsx)(`button`,{type:`button`,onClick:()=>S(e.id,e=>({...e,icon:n.key})),className:K(`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,Q.jsx)(X,{name:r,className:`h-4 w-4`})},n.key)})})})]}),(0,Q.jsx)(at,{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,Q.jsxs)(`div`,{className:`py-1`,children:[(0,Q.jsx)(`p`,{className:`typography-meta mb-0.5 text-muted-foreground`,children:t(`settings.projects.actions.field.command`)}),(0,Q.jsx)(Pt,{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,Q.jsxs)(`div`,{className:`py-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Q.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:t(`settings.projects.actions.field.autoOpenUrl`)}),(0,Q.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,Q.jsx)(Je,{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,Q.jsx)(`span`,{className:`typography-ui-label font-normal text-foreground/80`,children:t(`settings.projects.actions.field.autoOpenUrlDescription`)})]})]}),e.autoOpenUrl===!0?(0,Q.jsxs)(`div`,{className:`mt-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(at,{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,Q.jsxs)(ct,{children:[(0,Q.jsx)(ot,{asChild:!0,children:(0,Q.jsx)(X,{name:`information`,className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/60 cursor-help`})}),(0,Q.jsx)(st,{sideOffset:8,className:`max-w-xs`,children:t(`settings.projects.actions.field.overrideUrlTooltip`)})]})]}),n?(0,Q.jsxs)(`div`,{className:`mt-2`,children:[(0,Q.jsx)(`p`,{className:`typography-meta mb-0.5 text-muted-foreground`,children:t(`settings.projects.actions.field.desktopSshForward`)}),h.length>0?(0,Q.jsxs)(et,{value:e.desktopOpenSshForward&&h.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,Q.jsx)(Ze,{className:`h-7 w-full`,children:(0,Q.jsx)(it,{placeholder:t(`settings.projects.actions.field.useOutputManualUrl`)})}),(0,Q.jsxs)($e,{children:[(0,Q.jsx)(Ye,{value:`__none__`,children:t(`settings.projects.actions.field.useOutputManualUrl`)}),h.map(e=>(0,Q.jsx)(Ye,{value:e.id,children:e.label},e.id))]})]}):(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.projects.actions.state.noDesktopSshForwards`)})]}):null]}):null]})]})})]},e.id)})}),g&&a.length>0?(0,Q.jsx)(`p`,{className:`typography-meta text-[var(--status-warning)]`,children:g}):null]})},Si=e=>{let t=(0,Z.c)(123),{form:n}=e,{t:r}=G(),{currentTheme:i}=Be(),{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?tt[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,Q.jsx)(at,{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,Q.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 te;t[15]===r?te=t[16]:(te=r(`settings.projects.page.field.defaultModelDescription`),t[15]=r,t[16]=te);let ne;t[17]!==m||t[18]!==p.modelId||t[19]!==p.providerId?(ne=(0,Q.jsx)(ht,{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]=ne):ne=t[20];let re;t[21]!==ee||t[22]!==te||t[23]!==ne?(re=(0,Q.jsx)(ur,{label:ee,description:te,descriptionPlacement:`outside`,itemId:`projects.default-model`,children:ne}),t[21]=ee,t[22]=te,t[23]=ne,t[24]=re):re=t[24];let z;t[25]===r?z=t[26]:(z=r(`settings.projects.page.field.accentColor`),t[25]=r,t[26]=z);let ie;t[27]===u?ie=t[28]:(ie=()=>u(null),t[27]=u,t[28]=ie);let ae=l===null?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-border/40 hover:border-border hover:bg-[var(--surface-muted)]`,B;t[29]===ae?B=t[30]:(B=K(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,ae),t[29]=ae,t[30]=B);let oe;t[31]===r?oe=t[32]:(oe=r(`settings.projects.page.field.none`),t[31]=r,t[32]=oe);let se;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Q.jsx)(X,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[33]=se):se=t[33];let V;t[34]!==ie||t[35]!==B||t[36]!==oe?(V=(0,Q.jsx)(`button`,{type:`button`,onClick:ie,className:B,title:oe,children:se}),t[34]=ie,t[35]=B,t[36]=oe,t[37]=V):V=t[37];let H;t[38]!==l||t[39]!==u?(H=rt.map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>u(e.key),className:K(`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]=H):H=t[40];let ce;t[41]!==V||t[42]!==H?(ce=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[V,H]}),t[41]=V,t[42]=H,t[43]=ce):ce=t[43];let le;t[44]!==z||t[45]!==ce?(le=(0,Q.jsx)(ur,{label:z,itemId:`projects.accent-color`,children:ce}),t[44]=z,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,Q.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 me=s===null?`border-2 border-foreground bg-[var(--primary-base)]/10`:`border-border/40 hover:border-border hover:bg-[var(--surface-muted)]`,he;t[56]===me?he=t[57]:(he=K(`h-7 w-7 rounded-md border transition-colors flex items-center justify-center`,me),t[56]=me,t[57]=he);let ge;t[58]===r?ge=t[59]:(ge=r(`settings.projects.page.field.none`),t[58]=r,t[59]=ge);let U;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Q.jsx)(X,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[60]=U):U=t[60];let _e;t[61]!==pe||t[62]!==he||t[63]!==ge?(_e=(0,Q.jsx)(`button`,{type:`button`,onClick:pe,className:he,title:ge,children:U}),t[61]=pe,t[62]=he,t[63]=ge,t[64]=_e):_e=t[64];let W;t[65]!==N||t[66]!==s||t[67]!==c?(W=nt.map(e=>{let t=e.Icon;return(0,Q.jsx)(`button`,{type:`button`,onClick:()=>c(e.key),className:K(`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,Q.jsx)(X,{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]=W):W=t[68];let ve;t[69]!==_e||t[70]!==W?(ve=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[_e,W]}),t[69]=_e,t[70]=W,t[71]=ve):ve=t[71];let ye;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?(ye=w&&E&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:r(`settings.projects.page.field.preview`)}),(0,Q.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,Q.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,Q.jsx)(`img`,{src:b,alt:``,className:`h-full w-full object-contain`,draggable:!1,onError:()=>x(!0)}):(0,Q.jsx)(Xe,{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]=ye):ye=t[82];let be;t[83]!==w||t[84]!==d||t[85]!==f||t[86]!==r?(be=w&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,Q.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,Q.jsx)(at,{value:d??``,onChange:e=>f(e.target.value),placeholder:`#000000`,className:`h-7 w-[8rem]`}),(0,Q.jsx)(q,{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,Q.jsx)(X,{name:`close`,className:`h-3.5 w-3.5`})})]}),t[83]=w,t[84]=d,t[85]=f,t[86]=r,t[87]=be):be=t[87];let xe;t[88]!==D||t[89]!==A||t[90]!==C||t[91]!==_||t[92]!==h||t[93]!==r?(xe=!C&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{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,Q.jsx)(q,{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]=xe):xe=t[94];let Se;t[95]!==k||t[96]!==T||t[97]!==g||t[98]!==r?(Se=T&&(0,Q.jsx)(q,{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]=Se):Se=t[99];let J;t[100]!==g||t[101]!==v||t[102]!==y||t[103]!==r?(J=v&&(0,Q.jsx)(q,{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]=J):J=t[104];let Ce;t[105]!==xe||t[106]!==Se||t[107]!==J?(Ce=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[xe,Se,J]}),t[105]=xe,t[106]=Se,t[107]=J,t[108]=Ce):Ce=t[108];let we;t[109]!==fe||t[110]!==ve||t[111]!==ye||t[112]!==be||t[113]!==Ce?(we=(0,Q.jsxs)(`div`,{className:`flex w-full flex-col items-end gap-2`,children:[fe,ve,ye,be,Ce]}),t[109]=fe,t[110]=ve,t[111]=ye,t[112]=be,t[113]=Ce,t[114]=we):we=t[114];let Te;t[115]!==ue||t[116]!==we?(Te=(0,Q.jsx)(ur,{label:ue,itemId:`projects.icon`,children:we}),t[115]=ue,t[116]=we,t[117]=Te):Te=t[117];let Y;return t[118]!==le||t[119]!==Te||t[120]!==R||t[121]!==re?(Y=(0,Q.jsxs)(`div`,{className:`oc-settings-section-stack`,children:[R,re,le,Te]}),t[118]=le,t[119]=Te,t[120]=R,t[121]=re,t[122]=Y):Y=t[122],Y},Ci=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,wi=e=>{if(!e)return null;let t=e.trim();return t&&Ci.test(t)?t.toLowerCase():null},Ti=e=>{let{t}=G(),n=Y(e=>e.uploadProjectIcon),r=Y(e=>e.removeProjectIcon),i=Y(e=>e.discoverProjectIcon),a=Y(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(()=>Me(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),te=!O&&(F||ee),ne=!!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),re=$.useCallback((e,t)=>{h(e&&t?`${e}/${t}`:void 0)},[]),z=$.useCallback(t=>{!e||!t||g||(C(!1),k(!1),T(t),D(e=>(e&&URL.revokeObjectURL(e),URL.createObjectURL(t))))},[g,e]),ie=$.useCallback(()=>{!e||!R||v||(F&&j(),C(!!P),k(!1))},[j,F,R,P,v,e]),ae=$.useCallback(async()=>{if(!(!e||b)){j(),C(!1),k(!1),x(!0);try{let n=await i(e.id);if(!n.ok){J.error(n.error||t(`settings.projects.page.toast.discoverIconFailed`));return}if(n.skipped){J.success(t(`settings.projects.page.toast.customIconAlreadySet`));return}J.success(t(`settings.projects.page.toast.iconDiscovered`))}finally{x(!1)}}},[j,i,b,e,t]),B=$.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 J.error(r.error||t(`settings.projects.page.toast.uploadIconFailed`)),null;a||J.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 J.error(n.error||t(`settings.projects.page.toast.removeIconFailed`)),null;a||J.success(t(`settings.projects.page.toast.iconRemoved`)),C(!1),p(null)}return{label:s,icon:c,color:u,iconBackground:wi(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:re,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:te,fileInputRef:A,clearPendingUploadIcon:j,handleUploadIcon:z,handleRemoveImageIcon:ie,handleDiscoverIcon:ae,hasChanges:ne,prepareSaveData:B,currentIconImage:a,project:e}},Ei=450,Di=(e,t)=>{let{t:n}=G(),{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{J.error(n(`settings.projects.page.toast.saveFailed`))}}finally{m.current=!1}})())},Ei);return()=>{window.clearTimeout(e)}},[o,c,r,a,s,f,d,i,t,l,u,p,n])},Oi=e=>{let t=(0,Z.c)(25),{project:n,onIdentitySave:r}=e,{t:i}=G(),a=Ti(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),Di(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,Q.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,Q.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,Q.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,Q.jsx)(Si,{form:a}),t[15]=a,t[16]=m);let h,g;t[17]===s?(h=t[18],g=t[19]):(h=(0,Q.jsx)(xi,{projectRef:s}),g=(0,Q.jsx)(hi,{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,Q.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 ki(e,t,n){return Math.min(n,Math.max(t,e))}function Ai(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 ji(e,t){let n=Ai(t);return n<=0?e:Number(e.toFixed(n))}var Mi=$.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}=G(),[h,g]=$.useState(()=>e===void 0?``:String(e)),{isMobile:_}=jt(),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=ji(ki(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=ji(ki(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,Q.jsxs)(`div`,{"data-slot":`number-input`,className:K(`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,Q.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.decreaseAria`),disabled:D,onTouchStart:A(O),onClick:j(O),className:K(`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,Q.jsx)(X,{name:`subtract`,className:`block h-4 w-4`})}),(0,Q.jsx)(`div`,{"data-slot":`number-input-value`,className:K(`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,Q.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.increaseAria`),disabled:E,onTouchStart:A(k),onClick:j(k),className:K(`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,Q.jsx)(X,{name:`add`,className:`block h-4 w-4`})})]}):(0,Q.jsxs)(`div`,{"data-slot":`number-input`,className:K(`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,Q.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.decreaseAria`),disabled:D,onClick:()=>C(S.current-i),className:K(`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,Q.jsx)(X,{name:`subtract`,className:`block h-3.5 w-3.5`})}),(0,Q.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:K(`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,Q.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.increaseAria`),disabled:E,onClick:()=>C(S.current+i),className:K(`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,Q.jsx)(X,{name:`add`,className:`block h-3.5 w-3.5`})})]})});Mi.displayName=`NumberInput`;function Ni(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 Pi={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 Fi(e,t){let n=Pi[t]??[];for(let t of n)if(t.matcher(e))return t;return null}function Ii(e){return Pi[e]??[]}function Li(e){return[...e].sort((e,t)=>e.order-t.order)}function Ri(e,t){let n=new Map;for(let r of Object.keys(e)){let e=Fi(r,t)?.id??null;n.has(e)||n.set(e,[]),n.get(e).push(r)}return n}function zi(e,t,n){let r=new Map;for(let i of e){let e=Fi(t(i),n)?.id??null;r.has(e)||r.set(e,[]),r.get(e).push(i)}return r}function Bi(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 Vi=(e,t=``,n=!1)=>ee({queryKey:m.scoped(`magpie-quotas`,e,t,n),staleTime:0,retry:!1,queryFn:async({signal:t})=>{let r=await i(`/api/quota/magpie`,{signal:t,query:{...e?{directory:e}:{},...n?{refresh:`1`}:{}}});if(!r.ok)throw Error(`Unable to discover Magpie quota sources`);let a=await r.json();if(!a||!Array.isArray(a.sources)||!a.sources.every(e=>e&&typeof e.id==`string`&&typeof e.name==`string`&&Array.isArray(e.results)&&e.results.every(t=>f(t)&&t.source===`magpie`&&t.sourceId===e.id&&t.providerId.startsWith(`magpie:${e.id}:`))))throw Error(`Invalid Magpie quota response`);return a}}),Hi=6e4,Ui=0,Wi=0,Gi,Ki=0,qi=0,Ji=0,Yi=new Map,Xi=e=>{let t=sn.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))):Hi,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`&&(e.startsWith(`magpie:`)||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{magpieUsageUrl:typeof e?.magpieUsageUrl==`string`?e.magpieUsageUrl:``,magpieHiddenProviders:Array.isArray(e?.magpieHiddenProviders)?e.magpieHiddenProviders.filter(e=>typeof e==`string`&&e.startsWith(`magpie:`)):[],autoRefresh:n,refreshIntervalMs:r,displayMode:i,showPredValues:a,dropdownProviderIds:s,selectedModels:c,expandedFamilies:u}},Zi=async()=>{let e=s()?.settings;if(e)try{let t=(await e.load())?.settings;return Xi(t??null)}catch{}if(!g()){let e=await i(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(e.ok)return Xi(await e.json().catch(()=>null))}return{magpieUsageUrl:``,magpieHiddenProviders:[],autoRefresh:!1,refreshIntervalMs:Hi,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:sn.map(e=>e.id),selectedModels:{},expandedFamilies:{}}},Qi=(e,t,n)=>{let r=e.filter(e=>e?.providerId&&e.providerId!==t);return f(n)&&r.push(n),r},$i=async(e,t)=>{let n=Wi;Yi.set(e,(Yi.get(e)??0)+1),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:!0}}));try{let r=await _.fetchQuery({queryKey:m.quota(e),queryFn:({signal:t})=>S(e,t),staleTime:0,retry:!1});if(n!==Wi)return{providerId:e,stale:!0};if(!f(r))throw Error(`Invalid quota response`);return t(t=>({results:Qi(t.results,e,r)})),{providerId:e,result:r}}catch(r){return n===Wi?(t(e=>e.results.every(e=>e?.providerId)?{}:{results:e.results.filter(e=>e?.providerId)}),{providerId:e,error:r instanceof Error?r.message:`Failed to fetch quota`}):{providerId:e,stale:!0}}finally{if(n===Wi){let n=(Yi.get(e)??1)-1;n>0?Yi.set(e,n):Yi.delete(e),t(t=>({isFetchingProvider:{...t.isFetchingProvider,[e]:n>0}}))}}},ea=()=>{Gi=void 0,Ki+=1,Wi+=1,Ui+=1,Yi.clear(),ta.setState({magpieUsageUrl:``,magpieHiddenProviders:[],magpieSources:[],magpieError:null,results:[],isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null})},ta=w()(E((e,t)=>({magpieSources:[],magpieError:null,magpieHiddenProviders:[],magpieUsageUrl:``,results:[],selectedProviderId:null,isLoading:!1,isFetchingProvider:{},lastUpdated:null,error:null,autoRefresh:!1,refreshIntervalMs:Hi,displayMode:`usage`,showPredValues:!1,dropdownProviderIds:sn.map(e=>e.id),selectedModels:{},expandedFamilies:{},loadSettings:async()=>{let t=Wi;try{let n=await Zi();if(t!==Wi)return;e(e=>({...n,dropdownProviderIds:[...n.dropdownProviderIds.filter(e=>!e.startsWith(`magpie:`)),...e.results.filter(e=>e.source===`magpie`&&!n.magpieHiddenProviders.includes(e.providerId)).map(e=>e.providerId)]}))}catch(e){console.warn(`Failed to load usage settings:`,e)}},fetchAllQuotas:async()=>{let n=++Ui;e({isLoading:!0,error:null});let r=sn.map(e=>e.id),[i]=await Promise.all([Promise.all(r.map(t=>$i(t,e))),t().fetchMagpieQuotas(!0)]);if(n===Ui){let t=i.find(e=>`error`in e);e({isLoading:!1,...i.some(e=>`result`in e)?{lastUpdated:Date.now()}:{},error:t?.error??null})}},fetchProviderQuota:async n=>{if(n.startsWith(`magpie:`))return t().fetchMagpieQuotas(!0);let r=await $i(n,e);`stale`in r||e({error:`error`in r?r.error:null})},fetchMagpieQuotas:async(n=!1)=>{let r=Wi,i=A.getState().currentDirectory,a=t().magpieUsageUrl,o=JSON.stringify([i,a]);Gi!==o&&(Gi=o,Ki+=1,e(e=>({results:e.results.filter(e=>e?.source!==`magpie`),magpieSources:[],magpieError:null})));let s=Ki,c=++qi;try{let{sources:o,incomplete:l}=await _.fetchQuery(Vi(i,a,n));if(r!==Wi||s!==Ki||c<Ji||i!==A.getState().currentDirectory||a!==t().magpieUsageUrl)return;Ji=c,e(e=>{let t=new Map(o.filter(e=>e.error&&!e.clearPrevious&&e.results.length===0).map(e=>[e.id,e.error]));if(l){let n=new Set(o.map(e=>e.id));for(let r of e.results)r.sourceId&&!n.has(r.sourceId)&&t.set(r.sourceId,`Magpie discovery is incomplete`)}let n=e.results.filter(e=>e?.providerId&&(e.source!==`magpie`||t.has(e.sourceId??``))).map(e=>e.source===`magpie`&&t.has(e.sourceId??``)?{...e,ok:!1,error:t.get(e.sourceId??``)}:e);n.push(...o.flatMap(e=>e.results));let r=n.filter(e=>e.source===`magpie`).map(e=>e.providerId);return{results:n,magpieSources:o,magpieError:null,dropdownProviderIds:[...e.dropdownProviderIds.filter(e=>!e.startsWith(`magpie:`)),...r.filter(t=>!e.magpieHiddenProviders.includes(t))]}})}catch(n){if(r!==Wi||s!==Ki||c<Ji||i!==A.getState().currentDirectory||a!==t().magpieUsageUrl)return;Ji=c,e({magpieError:n instanceof Error?n.message:`Unable to read Magpie quotas`})}},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:n=>{let r=t().results.filter(e=>e.source===`magpie`),i=new Set(r.map(e=>e.providerId));e({dropdownProviderIds:n,magpieHiddenProviders:[...t().magpieHiddenProviders.filter(e=>!i.has(e)),...r.filter(e=>!n.includes(e.providerId)).map(e=>e.providerId)]})},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}})),h({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}}}),h({usageExpandedFamilies:t().expandedFamilies})},applyDefaultSelections:(n,r)=>{if((t().selectedModels[n]?.length??0)>0)return;let i=Bi(n,r);i.length!==0&&(e(e=>({selectedModels:{...e.selectedModels,[n]:i}})),h({usageSelectedModels:t().selectedModels}))}}),{name:`quota-store`})),na=()=>{let e=(0,Z.c)(11),t=A(ra),n=ta(ia),r=ta(aa),i;e[0]===r?i=e[1]:(i=()=>{r()},e[0]=r,e[1]=i);let a;e[2]!==t||e[3]!==r||e[4]!==n?(a=[t,n,r],e[2]=t,e[3]=r,e[4]=n,e[5]=a):a=e[5],$.useEffect(i,a);let o=ta(oa),s=ta(sa),c=ta(ca),l,u;e[6]!==o||e[7]!==c||e[8]!==s?(l=()=>{if(!o)return;let e=window.setInterval(()=>{c()},s);return()=>window.clearInterval(e)},u=[o,s,c],e[6]=o,e[7]=c,e[8]=s,e[9]=l,e[10]=u):(l=e[9],u=e[10]),$.useEffect(l,u)};function ra(e){return e.currentDirectory}function ia(e){return e.magpieUsageUrl}function aa(e){return e.fetchMagpieQuotas}function oa(e){return e.autoRefresh}function sa(e){return e.refreshIntervalMs}function ca(e){return e.fetchAllQuotas}var la=e=>{let t=(0,Z.c)(20),{percent:n,tonePercent:r,className:i,expectedMarkerPercent:a}=e,o;t[0]===n?o=t[1]:(o=ut(n)??0,t[0]=n,t[1]=o);let s=o,c=r??n,l;t[2]===c?l=t[3]:(l=ft(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=K(`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,Q.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,Q.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,Q.jsxs)(`div`,{className:m,children:[_,v]}),t[16]=m,t[17]=_,t[18]=v,t[19]=y):y=t[19],y},ua=e=>{let t=(0,Z.c)(67),{paceInfo:n,className:r,compact:i}=e,a=i!==void 0&&i,{t:o}=G(),s;t[0]===n.status?s=t[1]:(s=dt(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=K(`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,Q.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,Q.jsx)(Q.Fragment,{children:o(`settings.usage.pace.wait`,{duration:mt(n.remainingSeconds)})}):(0,Q.jsx)(Q.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,Q.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,Q.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=K(`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,Q.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,Q.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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:u}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.waitSeparator`)}),(0,Q.jsx)(`span`,{className:`font-medium`,children:mt(n.remainingSeconds)})]}):(0,Q.jsxs)(`span`,{title:f,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.predictionLabel`)}),(0,Q.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,Q.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,Q.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,Q.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,Q.jsxs)(`div`,{className:p,children:[h,x]}),t[63]=x,t[64]=p,t[65]=h,t[66]=S):S=t[66],S},da=e=>e instanceof Error&&e.name===`CancelledError`,fa=w(()=>({setStatus:e=>vt(_,e),refreshStatus:async(e,t)=>{let r=n();t?.force&&await _.cancelQueries({queryKey:m.github.auth(r),exact:!0});try{return await pt(_,e,r)}catch(e){if(da(e))return Dt(_,r);throw e}}})),pa={displayMode:`browser`,installed:!1,browserTab:!0},ma=new Set,ha=pa,ga=!1,_a,va=()=>{let e=Et();return{displayMode:e,installed:e!==`browser`,browserTab:e===`browser`}},ya=()=>(!ga&&typeof window<`u`&&(ha=va(),ga=!0),ha),ba=()=>{let e=va();ga=!0,e.displayMode!==ha.displayMode&&(ha=e,ma.forEach(e=>e()))},xa=()=>{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`,ba):typeof t.addListener==`function`&&t.addListener(ba);return window.addEventListener(`appinstalled`,ba),window.addEventListener(`focus`,ba),()=>{for(let t of e)typeof t.removeEventListener==`function`?t.removeEventListener(`change`,ba):typeof t.removeListener==`function`&&t.removeListener(ba);window.removeEventListener(`appinstalled`,ba),window.removeEventListener(`focus`,ba)}},Sa=e=>(ma.add(e),_a??=xa(),ba(),()=>{ma.delete(e),ma.size===0&&(_a?.(),_a=void 0)}),Ca=()=>$.useSyncExternalStore(Sa,ya,wa);function wa(){return pa}var Ta=`OPEN CHAMBER`,Ea=w()(T(e=>({sidebarBrandName:Ta,setSidebarBrandName:t=>{let n=t.slice(0,64);e(e=>e.sidebarBrandName===n?e:{sidebarBrandName:n})}}),{name:`sidebar-brand-store`,storage:l(),version:2,migrate:(e,t)=>{if(!e||typeof e!=`object`)return e;let n=e;return t<1&&n.sidebarBrandName===`YEE CODE`&&(n.sidebarBrandName=Ta),t<2&&n.sidebarBrandName===`Open Chamber`&&(n.sidebarBrandName=Ta),n}}));typeof window<`u`&&t(e=>{r(e)&&Ea.persist.rehydrate()});var Da=(e,t)=>e?t.kind===e.kind?t.projectRoot.length===e.projectRoot.length?t.projectId.localeCompare(e.projectId)<0:t.projectRoot.length>e.projectRoot.length:t.kind===`project`:!0,Oa=(e,t,n)=>{Da(e.get(t),n)&&e.set(t,n)},ka=e=>{let t=e;return y(t.directory)??y(t.project?.worktree)},Aa=e=>{if(e===`/`||/^[A-Z]:$/.test(e))return null;let t=e.lastIndexOf(`/`);return t<0?null:t===0?`/`:t===2&&/^[A-Z]:\//.test(e)?e.slice(0,2):e.slice(0,t)},ja=(e,t,n,r,i=[])=>{let a=new Map,o=new Map;for(let e of t){let t=y(e.normalizedPath);if(!t)continue;let n=o.get(t);(!n||e.id.localeCompare(n.id)<0)&&o.set(t,e),Oa(a,t,{projectId:e.id,projectRoot:t,scopeDirectory:t,kind:`project`})}if(!r)for(let[e,t]of n){let n=y(e),r=n?o.get(n):void 0;if(!(!r||!n))for(let e of t){let t=y(e.path);t&&Oa(a,t,{projectId:r.id,projectRoot:n,scopeDirectory:t,kind:`worktree`})}}let s=new Map,c=new Map,l=new Map,u=new Map,d=new Map,f=e=>{if(!e)return null;if(s.has(e))return s.get(e)??null;if(r){let t=a.get(e)??null;return s.set(e,t),t}let t=[],n=e,i=null;for(;n;){if(s.has(n)){i=s.get(n)??null;break}if(t.push(n),i=a.get(n)??null,i)break;n=Aa(n)}for(let e of t)s.set(e,i);return i},p=(e,t,n)=>{for(let r of e){let e=f(ka(r));if(!e)continue;c.set(r.id,e);let i=t.get(e.projectId);if(i?i.push(r):t.set(e.projectId,[r]),!n)continue;let a=n.get(e.scopeDirectory);a?a.add(r.id):n.set(e.scopeDirectory,new Set([r.id]))}};return p(e,l,d),p(i,u),{bySessionId:c,sessionsByProject:l,archivedSessionsByProject:u,sessionsByScope:d,directoryResolutions:s.size}},Ma=`__other__`;function Na(e){return e.time?.updated??e.time?.archived??e.time?.created??0}function Pa({mode:e=`dialog`}){let{t}=G(),{isMobile:n,isTablet:r,hasTouchInput:i}=jt(),a=n||r||i,o=e===`page`,s=I(e=>e.isArchivedSessionsDialogOpen),c=I(e=>e.setArchivedSessionsDialogOpen),l=o||s,u=Y(e=>e.projects),d=xe(e=>e.archivedSessions),f=Ee(e=>e.setCurrentSession),p=I(e=>e.setSettingsDialogOpen),[m,h]=$.useState(!1),[_,v]=$.useState(null),[y,b]=$.useState(null);$.useEffect(()=>{if(!l){v(null),b(null);return}let e=!1;return h(!0),Te().catch(()=>{e||J.error(t(`settings.openchamber.archivedSessions.toast.loadFailed`))}).finally(()=>{e||h(!1)}),()=>{e=!0}},[l,t]);let x=$.useMemo(()=>{let e=ja([],u.map(e=>({id:e.id,normalizedPath:e.path})),new Map,g(),d),n=new Map;for(let[t,r]of e.archivedSessionsByProject)n.set(t,[...r].sort((e,t)=>Na(t)-Na(e)));let r=new Set;for(let e of n.values())for(let t of e)r.add(t.id);let i=d.filter(e=>!r.has(e.id)).sort((e,t)=>Na(t)-Na(e));i.length>0&&n.set(Ma,i);let a=[];for(let e of u){let t=n.get(e.id)??[];t.length!==0&&a.push({projectId:e.id,label:e.label||e.path,path:e.path,sessions:t})}let o=n.get(Ma);return o&&o.length>0&&a.push({projectId:Ma,label:t(`settings.openchamber.archivedSessions.otherProjects`),path:null,sessions:o}),a.sort((e,t)=>t.sessions.length-e.sessions.length||e.label.localeCompare(t.label)),a},[d,u,t]),S=d.length,C=_?x.find(e=>e.projectId===_)??null:null,w=$.useCallback(async e=>{b(e.id);try{await De(e.id)?J.success(t(`settings.openchamber.archivedSessions.toast.restored`)):J.error(t(`settings.openchamber.archivedSessions.toast.restoreFailed`))}finally{b(null)}},[t]),T=$.useCallback(e=>{let t=Se(e);f(e.id,t),c(!1),p(!1)},[f,c,p]),E=C?C.label:t(`settings.openchamber.archivedSessions.dialog.title`),D=C?C.sessions.length===1?t(`settings.openchamber.archivedSessions.dialog.sessionCountSingle`,{count:C.sessions.length}):t(`settings.openchamber.archivedSessions.dialog.sessionCountPlural`,{count:C.sessions.length}):t(`settings.openchamber.archivedSessions.dialog.description`),O=(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[C?(0,Q.jsxs)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`!h-7 !px-2 !font-normal text-muted-foreground`,onClick:()=>v(null),children:[(0,Q.jsx)(X,{name:`arrow-left-s`,className:`mr-1 h-4 w-4`}),t(`settings.openchamber.archivedSessions.dialog.backToProjects`)]}):null,m?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 typography-meta text-muted-foreground py-6`,children:[(0,Q.jsx)(X,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),t(`settings.openchamber.archivedSessions.dialog.loading`)]}):C?C.sessions.length===0?(0,Q.jsx)(`div`,{className:`rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:t(`settings.openchamber.archivedSessions.dialog.emptyProject`)}):(0,Q.jsx)(`div`,{className:`space-y-1.5`,children:C.sessions.map(e=>{let n=Se(e),r=Na(e),i=y===e.id;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-border/60 px-3 py-2.5 sm:flex-row sm:items-center sm:gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`typography-ui-label font-medium text-foreground truncate`,children:e.title||t(`sessions.sidebar.session.untitled`)}),(0,Q.jsxs)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:[r>0?At(r):null,r>0&&n?` · `:null,n?ve(n):null]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,Q.jsx)(q,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,disabled:i,onClick:()=>T(e),children:t(`settings.openchamber.archivedSessions.actions.preview`)}),(0,Q.jsxs)(q,{type:`button`,variant:`default`,size:`xs`,className:`!font-normal`,disabled:i,onClick:()=>void w(e),children:[i?(0,Q.jsx)(X,{name:`loader-4`,className:`mr-1 h-3.5 w-3.5 animate-spin`}):(0,Q.jsx)(X,{name:`inbox-unarchive`,className:`mr-1 h-3.5 w-3.5`}),t(`settings.openchamber.archivedSessions.actions.restore`)]})]})]},e.id)})}):x.length===0?(0,Q.jsx)(`div`,{className:`rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:t(`settings.openchamber.archivedSessions.dialog.empty`)}):(0,Q.jsx)(`div`,{className:`space-y-1.5`,children:x.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>v(e.projectId),className:K(`flex w-full items-center gap-3 rounded-lg border border-border/60 px-3 py-2.5 text-left`,`hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),children:[(0,Q.jsx)(X,{name:`folder`,className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`typography-ui-label font-medium text-foreground truncate`,children:e.label}),e.path?(0,Q.jsx)(`div`,{className:`typography-meta text-muted-foreground truncate`,children:ve(e.path)}):null]}),(0,Q.jsx)(`span`,{className:`typography-meta tabular-nums text-muted-foreground shrink-0`,children:e.sessions.length===1?t(`settings.openchamber.archivedSessions.dialog.sessionCountSingle`,{count:e.sessions.length}):t(`settings.openchamber.archivedSessions.dialog.sessionCountPlural`,{count:e.sessions.length})}),(0,Q.jsx)(X,{name:`arrow-right-s`,className:`h-4 w-4 shrink-0 text-muted-foreground`})]},e.projectId))}),!C&&!m&&S>0?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(S===1?`settings.openchamber.archivedSessions.summarySingle`:`settings.openchamber.archivedSessions.summaryPlural`,{count:S})}):null]});return o?(0,Q.jsxs)(`div`,{"data-settings-item":`archived-sessions.manage`,className:`oc-settings-section-stack`,children:[(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.archivedSessions.description`)}),O]}):a?(0,Q.jsx)(bt,{open:s,title:E,onClose:()=>c(!1),contentMaxHeightClassName:`max-h-[min(80vh,640px)]`,renderHeader:e=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border/40 px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:E}),e]}),(0,Q.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:D})]}),children:O}):(0,Q.jsx)(Ie,{open:s,onOpenChange:c,children:(0,Q.jsxs)(Re,{className:`max-h-[85vh] max-w-2xl overflow-y-auto`,children:[(0,Q.jsxs)(Le,{children:[(0,Q.jsx)(ze,{children:E}),(0,Q.jsx)(Fe,{children:D})]}),O]})})}function Fa(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(Pa,{mode:`dialog`}),e[0]=t):t=e[0],t}var Ia=48;function La({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/Ia)),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,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`header`,{ref:i,className:K(`oc-mobile-collapsing-header flex shrink-0 items-start gap-4`,r),children:(0,Q.jsxs)(`div`,{className:`oc-mobile-collapsing-header-inner`,children:[(0,Q.jsxs)(`div`,{className:`oc-mobile-collapsing-header-title-block min-w-0 flex-1`,children:[t?(0,Q.jsx)(`p`,{className:`oc-mobile-collapsing-header-eyebrow truncate typography-micro font-medium text-muted-foreground`,children:t}):null,(0,Q.jsx)(`h1`,{className:`oc-mobile-root-page-title truncate font-semibold text-foreground`,children:e})]}),n?(0,Q.jsx)(`div`,{className:`oc-mobile-collapsing-header-trailing flex min-h-10 shrink-0 items-center gap-3.5`,children:n}):null]})}),(0,Q.jsx)(`div`,{className:`oc-mobile-collapsing-header-spacer`,"aria-hidden":`true`})]})}export{_r as A,bn as B,li as C,wr as D,Sr as E,lr as F,sn as G,xn as H,dr as I,cn as K,fr as L,vr as M,xr as N,Tr as O,ur as P,sr as R,ui as S,Zr as T,gn as U,Sn as V,ln as W,Li as _,Ea as a,_i as b,ua as c,na as d,ta as f,zi as g,Ri as h,ja as i,br as j,gr as k,la as l,Ni as m,Fa as n,Ca as o,Ii as p,Pa as r,fa as s,La as t,ea as u,Mi as v,Qr as w,di as x,Oi as y,Yn as z};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t}from"./runtime-fetch-QCWYlAx0.js";import{i as n,kn as r,on as i,xn as a,yn as o}from"./persistence-DUPZl7Oy.js";import{_ as s,h as c,i as l,n as u,r as d}from"./desktopHosts-BKeEWmL5.js";import{it as f,rt as p}from"./vendor-base-ui-CdzJ6My_.js";import{n as m}from"./vendor-react-BP2cRVqX.js";import{d as h,f as g,r as _,t as v}from"./button-kJNzMb1G.js";import{n as y}from"./Icon-DewMAW7N.js";import{t as b}from"./input-02eTmC8w.js";var x=m(),S=e(f(),1),C=p();function w(e){switch(e){case`ok`:return null;case`auth`:return`onboarding.remoteConnection.probe.authMessage`;case`update-recommended`:return`onboarding.remoteConnection.probe.updateRecommendedMessage`;case`incompatible`:return`onboarding.remoteConnection.probe.incompatibleMessage`;case`wrong-service`:return`onboarding.remoteConnection.probe.wrongServiceMessage`;case`unreachable`:return`onboarding.remoteConnection.probe.unreachableMessage`;default:return null}}function T(e){return e===`wrong-service`||e===`unreachable`||e===`incompatible`}function E({onBack:e,showBackButton:t=!0,initialUrl:n=``,initialLabel:r=``,isRecoveryMode:o=!1,onConnect:c,onSwitchToLocal:f}){let{t:p}=g(),[m,h]=(0,S.useState)(n),[_,y]=(0,S.useState)(r),[x,E]=(0,S.useState)(`idle`),[D,O]=(0,S.useState)(null),[k,A]=(0,S.useState)(``),j=s(m),M=j?.persistedUrl??null,N=(0,S.useCallback)(e=>{h(e.target.value),E(`idle`),O(null),A(``)},[]),P=(0,S.useCallback)(e=>{y(e.target.value)},[]),F=(0,S.useCallback)(async()=>{if(M){E(`testing`),O(null),A(``);try{let e=await u(M);O(e),E(e.status===`ok`||e.status===`update-recommended`?`success`:`error`)}catch(e){A(e instanceof Error?e.message:p(`onboarding.remoteConnection.errors.connectionTestFailed`)),E(`error`)}}},[M,p]),I=(0,S.useCallback)(async()=>{if(!j)return;let e=j.persistedUrl;E(`testing`),O(null),A(``);try{let t=await u(e);if(O(t),T(t.status)){E(`error`);return}let n=await d(),r=_.trim()||e,o=n.hosts.find(t=>t.url===e),s=o?o.id:`host-${Date.now().toString(16)}`,f={id:s,label:r,url:e,apiUrl:e},p=o?n.hosts.map(e=>e.id===s?f:e):[...n.hosts,f];if(await l({hosts:p,defaultHostId:s,initialHostChoiceCompleted:!0}),c?.(),j.redeemUrl){window.location.assign(j.redeemUrl);return}i()&&await a()}catch(e){A(e instanceof Error?e.message:p(`onboarding.remoteConnection.errors.failedToSaveConnection`)),E(`error`)}},[j,_,c,p]),L=x===`testing`,R=M!==null&&!L,z=M!==null&&!L&&!T(D?.status??null),B=w(D?.status??null),V=D?.status===`ok`,H=D?.status===`update-recommended`,U=D?.status===`auth`,W=T(D?.status??null);return(0,C.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-8`,children:(0,C.jsxs)(`div`,{className:`w-full max-w-md space-y-6`,children:[t&&(0,C.jsx)(`div`,{className:`flex items-center`,children:(0,C.jsx)(v,{variant:`ghost`,onClick:e,className:`p-0 text-muted-foreground hover:text-foreground`,children:p(`onboarding.common.actions.back`)})}),(0,C.jsxs)(`div`,{className:`space-y-2 text-center`,children:[(0,C.jsx)(`h1`,{className:`typography-ui-header text-xl font-semibold text-foreground`,children:p(o?`onboarding.remoteConnection.titleRecovery`:`onboarding.remoteConnection.title`)}),(0,C.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:p(`onboarding.remoteConnection.description`)})]}),(0,C.jsxs)(`div`,{className:`space-y-4`,children:[(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(0,C.jsx)(`label`,{htmlFor:`remote-url`,className:`text-sm text-foreground`,children:p(`onboarding.remoteConnection.field.serverAddress`)}),(0,C.jsx)(b,{id:`remote-url`,type:`url`,value:m,onChange:N,placeholder:p(`onboarding.remoteConnection.field.serverAddressPlaceholder`),disabled:L})]}),(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(0,C.jsx)(`label`,{htmlFor:`remote-label`,className:`text-sm text-foreground`,children:p(`onboarding.remoteConnection.field.nameOptional`)}),(0,C.jsx)(b,{id:`remote-label`,type:`text`,value:_,onChange:P,placeholder:p(`onboarding.remoteConnection.field.namePlaceholder`),disabled:L})]})]}),D&&V&&(0,C.jsx)(`div`,{className:`rounded-lg border p-3 text-sm`,style:{borderColor:`var(--status-success)`,color:`var(--status-success)`},children:p(`onboarding.remoteConnection.status.connectedSuccessfully`,{latencyMs:D.latencyMs})}),D&&U&&(0,C.jsx)(`div`,{className:`rounded-lg border p-3 text-sm`,style:{borderColor:`var(--status-warning)`,color:`var(--status-warning)`},children:p(`onboarding.remoteConnection.status.authWarning`)}),D&&H&&(0,C.jsx)(`div`,{className:`rounded-lg border p-3 text-sm`,style:{borderColor:`var(--status-warning)`,color:`var(--status-warning)`},children:B?p(B):null}),D&&W&&(0,C.jsxs)(`div`,{className:`rounded-lg border p-3 text-sm space-y-3`,style:{borderColor:`var(--status-error)`,color:`var(--status-error)`},children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`font-semibold mb-1`,children:p(`onboarding.remoteConnection.status.connectionFailed`)}),(0,C.jsx)(`div`,{className:`opacity-90`,children:B?p(B):null})]}),(0,C.jsx)(`div`,{className:`text-xs opacity-80`,children:D.status===`unreachable`?p(`onboarding.remoteConnection.status.suggestionsUnreachable`):p(`onboarding.remoteConnection.status.suggestionsWrongService`)})]}),k&&(0,C.jsx)(`div`,{className:`rounded-lg border p-3 text-sm`,style:{borderColor:`var(--status-error)`,color:`var(--status-error)`},children:k}),(0,C.jsxs)(`div`,{className:`flex gap-3`,children:[(0,C.jsx)(v,{variant:`outline`,onClick:F,disabled:!R,children:p(L?`onboarding.remoteConnection.actions.testing`:`onboarding.remoteConnection.actions.testConnection`)}),(0,C.jsx)(v,{onClick:I,disabled:!z,children:p(`onboarding.remoteConnection.actions.connectAndRestart`)})]}),W&&(0,C.jsxs)(`div`,{className:`flex flex-col gap-2 pt-2 border-t border-border`,children:[(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground text-center`,children:p(`onboarding.remoteConnection.actions.whatToDo`)}),(0,C.jsxs)(`div`,{className:`flex gap-2`,children:[(0,C.jsx)(v,{variant:`outline`,size:`sm`,onClick:e,className:`flex-1`,children:p(`onboarding.remoteConnection.actions.chooseDifferentServer`)}),!o&&f&&(0,C.jsx)(v,{variant:`outline`,size:`sm`,onClick:f,className:`flex-1`,children:p(`onboarding.remoteConnection.actions.useLocalInstead`)})]})]})]})})}async function D(){let e=await t(`/health`);if(!e.ok)return!1;let n=await e.json().catch(()=>null);return n?.openCodeRunning===!0||n?.isOpenCodeReady===!0}async function O(){return(await t(`/api/opencode/retry`,{method:`POST`})).ok?D():!1}var k=`curl -fsSL https://opencode.ai/v2/install | bash`,A=`https://opencode.ai/docs`,j=2500,M=1e4;function N(e){let t=(0,x.c)(5),{onCopy:n,copyTitle:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,C.jsxs)(`code`,{className:`flex-1 text-left overflow-x-auto whitespace-nowrap`,children:[(0,C.jsx)(`span`,{style:{color:`var(--syntax-keyword)`},children:`curl`}),(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:` -fsSL `}),(0,C.jsx)(`span`,{style:{color:`var(--syntax-string)`},children:`https://opencode.ai/v2/install`}),(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:` | `}),(0,C.jsx)(`span`,{style:{color:`var(--syntax-keyword)`},children:`bash`})]}),t[0]=i):i=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,C.jsx)(y,{name:`file-copy`,className:`h-4 w-4`}),t[1]=a):a=t[1];let o;return t[2]!==r||t[3]!==n?(o=(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 w-full`,children:[i,(0,C.jsx)(`button`,{onClick:n,className:`inline-flex items-center text-muted-foreground hover:text-foreground transition-colors shrink-0`,title:r,"aria-label":r,children:a})]}),t[2]=r,t[3]=n,t[4]=o):o=t[4],o}function P({onCliAvailable:e}){let{t:s}=g(),[c,u]=S.useState(!1),[f,p]=S.useState(!1),[m,x]=S.useState(!1),[w,T]=S.useState(!1),[P,F]=S.useState(``),[I,L]=S.useState(`unknown`),[R,z]=S.useState(`local`),[B,V]=S.useState(!1),[H,U]=S.useState(!1),[W,G]=S.useState(null),K=S.useRef(!1);S.useEffect(()=>{p(i())},[]),S.useEffect(()=>{if(typeof navigator>`u`){L(`unknown`);return}let e=navigator.userAgent||``;/Windows/i.test(e)?L(`windows`):/Macintosh|Mac OS X/i.test(e)?L(`macos`):/Linux/i.test(e)?L(`linux`):L(`unknown`)},[]),S.useEffect(()=>{let e=!1;return(async()=>{try{let n=await t(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(!n.ok)return;let r=await n.json().catch(()=>null);if(!r||e)return;let i=typeof r.opencodeBinary==`string`?r.opencodeBinary.trim():``;i&&F(i)}catch{}})(),()=>{e=!0}},[]);let q=S.useCallback(async e=>{let t=e.target;t.closest(`.app-region-no-drag`)||t.closest(`button, a, input, select, textarea, code, summary, details`)||e.button===0&&f&&await r()},[f]),J=S.useCallback(async e=>{if(!f)return;let t=await d();await l({...t,...e===`local`?{defaultHostId:`local`}:{},initialHostChoiceCompleted:!0})},[f]),Y=S.useCallback(async()=>{if(!K.current){K.current=!0;try{f&&await J(`local`),await e?.()}catch(e){throw K.current=!1,e}}},[f,e,J]);S.useEffect(()=>{if(R!==`local`)return;let e=!1,t=null,n=0,r=async()=>{if(!e){try{let t=await D(),r=Date.now();if(!t&&r-n>=M&&(n=r,t=await O()),e)return;if(t){await Y();return}}catch{}e||(t=setTimeout(r,j))}};return t=setTimeout(r,j),()=>{e=!0,t&&clearTimeout(t)}},[R,Y]);let X=S.useCallback(async()=>{T(!0),G(null);try{let e=await D();e||=await O(),e?await Y():G(s(`onboarding.localSetup.errors.cliNotReady`))}catch{G(s(`onboarding.localSetup.errors.detectionFailed`))}finally{T(!1)}},[Y,s]),Z=S.useCallback(async()=>{if(!(typeof window>`u`)&&f)try{let e=await o();e.success&&e.path&&e.path.trim().length>0&&F(e.path.trim())}catch{}},[f]),Q=S.useCallback(async()=>{x(!0);try{if(await n({opencodeBinary:P.trim()}),f){await J(`local`),await a();return}await t(`/api/config/reload`,{method:`POST`})}finally{setTimeout(()=>x(!1),1e3)}},[f,P,J]),$=S.useCallback(async()=>{let e=await h(k);e.ok?(u(!0),setTimeout(()=>u(!1),2e3)):console.error(`Failed to copy:`,e.error)},[]),ee=A,te=I===`windows`?`C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd`:I===`linux`?`/home/you/.bun/bin/opencode`:`/Users/you/.bun/bin/opencode`,ne=!f||R===`local`;return(0,C.jsx)(`div`,{className:`app-region-drag h-full flex items-center justify-center bg-transparent p-8 cursor-default select-none overflow-y-auto`,onMouseDown:q,children:(0,C.jsxs)(`div`,{className:`w-full max-w-md space-y-7`,children:[(0,C.jsxs)(`header`,{className:`text-center space-y-1.5`,children:[(0,C.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-foreground`,children:s(`onboarding.chooser.title`)}),(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(`onboarding.chooser.description`)})]}),f&&(0,C.jsxs)(`div`,{className:`app-region-no-drag flex gap-1.5`,children:[(0,C.jsx)(`button`,{type:`button`,className:_(`flex-1 px-4 py-2 rounded-lg border transition-colors text-sm`,R===`local`?`border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10`:`border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground`),onClick:()=>z(`local`),children:s(`onboarding.chooser.tabs.localInstall`)}),(0,C.jsx)(`button`,{type:`button`,className:_(`flex-1 px-4 py-2 rounded-lg border transition-colors text-sm`,R===`remote`?`border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10`:`border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground`),onClick:()=>z(`remote`),children:s(`onboarding.chooser.tabs.connectRemote`)})]}),f&&R===`remote`?(0,C.jsx)(`div`,{className:`app-region-no-drag`,children:(0,C.jsx)(E,{onBack:()=>z(`local`),showBackButton:!1,onSwitchToLocal:()=>z(`local`)})}):null,ne&&(0,C.jsxs)(`div`,{className:`space-y-4`,children:[I===`windows`&&(0,C.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/50 p-4`,children:[(0,C.jsx)(`div`,{className:`text-sm text-foreground`,children:s(`onboarding.localSetup.windows.title`)}),(0,C.jsxs)(`ol`,{className:`mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground`,children:[(0,C.jsx)(`li`,{children:s(`onboarding.localSetup.windows.stepRunInstallInWsl`)}),(0,C.jsx)(`li`,{children:s(`onboarding.localSetup.windows.stepSetBinaryPath`)})]})]}),(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground text-center leading-relaxed`,children:s(`onboarding.localSetup.intro`)}),(0,C.jsx)(`div`,{className:`app-region-no-drag rounded-lg border border-border bg-background/60 backdrop-blur-sm px-4 py-3 font-mono text-sm`,children:c?(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,style:{color:`var(--status-success)`},children:[(0,C.jsx)(y,{name:`check`,className:`h-4 w-4`}),s(`onboarding.common.status.copiedToClipboard`)]}):(0,C.jsx)(N,{onCopy:$,copyTitle:s(`onboarding.common.copyToClipboard`)})}),(0,C.jsxs)(`div`,{className:`app-region-no-drag flex items-center justify-between`,children:[(0,C.jsxs)(`a`,{href:ee,target:`_blank`,rel:`noopener noreferrer`,className:`text-xs text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1`,children:[s(I===`windows`?`onboarding.localSetup.docs.windows`:`onboarding.localSetup.docs.default`),(0,C.jsx)(y,{name:`external-link`,className:`h-3 w-3`})]}),(0,C.jsx)(`button`,{type:`button`,onClick:X,disabled:w,className:`text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,children:s(w?`onboarding.localSetup.actions.checking`:`onboarding.localSetup.actions.checkNow`)})]}),W&&(0,C.jsx)(`p`,{role:`alert`,className:`text-center text-xs text-[var(--status-error-foreground)]`,children:W}),(0,C.jsxs)(`div`,{className:`rounded-lg border px-4 py-3 flex items-center gap-3`,style:{borderColor:`color-mix(in srgb, var(--primary-base) 20%, transparent)`,backgroundColor:`color-mix(in srgb, var(--primary-base) 6%, transparent)`},role:`status`,"aria-live":`polite`,children:[(0,C.jsxs)(`span`,{className:`relative inline-flex h-2.5 w-2.5 shrink-0`,"aria-hidden":!0,children:[(0,C.jsx)(`span`,{className:`absolute inset-0 rounded-full`,style:{backgroundColor:`var(--primary-base)`,animation:`pulse-opacity 1.6s ease-in-out infinite`}}),(0,C.jsx)(`span`,{className:`absolute inset-[-4px] rounded-full`,style:{backgroundColor:`var(--primary-base)`,animation:`pulse-opacity-dim 1.6s ease-in-out infinite`,opacity:0}})]}),(0,C.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,C.jsx)(`div`,{className:`text-sm text-foreground leading-tight`,children:s(`onboarding.localSetup.status.watching`)}),(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground leading-tight mt-0.5`,children:s(`onboarding.localSetup.status.autoContinue`)})]})]}),(0,C.jsxs)(`details`,{className:`app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors`,open:B,onToggle:e=>V(e.currentTarget.open),children:[(0,C.jsxs)(`summary`,{className:`flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden`,children:[(0,C.jsx)(`span`,{children:s(`onboarding.localSetup.advanced.title`)}),(0,C.jsx)(y,{name:`arrow-down-s`,className:`h-4 w-4 transition-transform group-open:rotate-180`})]}),(0,C.jsxs)(`div`,{className:`pb-4 space-y-2`,children:[(0,C.jsxs)(`div`,{className:`flex gap-2`,children:[(0,C.jsx)(b,{value:P,onChange:e=>F(e.target.value),placeholder:te,disabled:m,className:`flex-1 font-mono text-xs`}),(0,C.jsx)(v,{type:`button`,variant:`secondary`,size:`sm`,onClick:Z,disabled:m||!f,children:s(`onboarding.localSetup.actions.browse`)}),(0,C.jsx)(v,{type:`button`,size:`sm`,onClick:Q,disabled:m||!P.trim(),children:s(`onboarding.localSetup.actions.apply`)})]}),(0,C.jsx)(`p`,{className:`text-xs text-muted-foreground/70`,children:s(`onboarding.localSetup.helper.saveAndReload`)})]})]}),(0,C.jsxs)(`details`,{className:`app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors`,open:H,onToggle:e=>U(e.currentTarget.open),children:[(0,C.jsxs)(`summary`,{className:`flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden`,children:[(0,C.jsx)(`span`,{children:s(`onboarding.localSetup.troubleshoot.title`)}),(0,C.jsx)(y,{name:`arrow-down-s`,className:`h-4 w-4 transition-transform group-open:rotate-180`})]}),(0,C.jsx)(`ul`,{className:`pb-4 space-y-1.5 text-xs text-muted-foreground list-disc pl-4`,children:I===`windows`?(0,C.jsx)(C.Fragment,{children:(0,C.jsx)(`li`,{children:s(`onboarding.localSetup.windows.hintDetectionFailed`)})}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`li`,{children:s(`onboarding.localSetup.hint.ensurePath`)}),(0,C.jsx)(`li`,{children:s(`onboarding.localSetup.hint.setEnv`)}),(0,C.jsx)(`li`,{children:s(`onboarding.localSetup.hint.missingRuntime`)})]})})]})]})]})})}var F=`curl -fsSL https://opencode.ai/v2/install | bash`,I=`https://opencode.ai/docs`;function L(e){let t=(0,x.c)(5),{onCopy:n,copyTitle:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,C.jsxs)(`code`,{children:[(0,C.jsx)(`span`,{style:{color:`var(--syntax-keyword)`},children:`curl`}),(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:` -fsSL `}),(0,C.jsx)(`span`,{style:{color:`var(--syntax-string)`},children:`https://opencode.ai/v2/install`}),(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:` | `}),(0,C.jsx)(`span`,{style:{color:`var(--syntax-keyword)`},children:`bash`})]}),t[0]=i):i=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,C.jsx)(y,{name:`file-copy`,className:`h-4 w-4`}),t[1]=a):a=t[1];let o;return t[2]!==r||t[3]!==n?(o=(0,C.jsxs)(`div`,{className:`flex items-center justify-center gap-3`,children:[i,(0,C.jsx)(`button`,{onClick:n,className:`inline-flex items-center text-muted-foreground hover:text-foreground transition-colors`,title:r,children:a})]}),t[2]=r,t[3]=n,t[4]=o):o=t[4],o}var R=3e4;function z({onBack:e,onCliAvailable:s,isFromRecovery:c=!1,onSwitchToRemote:l}){let{t:u}=g(),[d,f]=S.useState(!1),[p,m]=S.useState(!1),[_,x]=S.useState(!1),[w,T]=S.useState(!1),[E,k]=S.useState(!1),[A,j]=S.useState(null),[M,N]=S.useState(``),[P,z]=S.useState(`unknown`);S.useEffect(()=>{let e=setTimeout(()=>m(!0),R);return()=>clearTimeout(e)},[]),S.useEffect(()=>{x(i())},[]),S.useEffect(()=>{if(typeof navigator>`u`){z(`unknown`);return}let e=navigator.userAgent||``;if(/Windows/i.test(e)){z(`windows`);return}if(/Macintosh|Mac OS X/i.test(e)){z(`macos`);return}if(/Linux/i.test(e)){z(`linux`);return}z(`unknown`)},[]),S.useEffect(()=>{let e=!1;return(async()=>{try{let n=await t(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(!n.ok)return;let r=await n.json().catch(()=>null);if(!r||e)return;let i=typeof r.opencodeBinary==`string`?r.opencodeBinary.trim():``;i&&N(i)}catch{}})(),()=>{e=!0}},[]);let B=S.useCallback(async e=>{e.target.closest(`button, a, input, select, textarea, code`)||e.button===0&&_&&await r()},[_]),V=S.useCallback(async()=>{if(!(typeof window>`u`)&&_)try{let e=await o();e.success&&e.path&&e.path.trim().length>0&&N(e.path.trim())}catch{}},[_]),H=S.useCallback(async()=>{T(!0);try{if(await n({opencodeBinary:M.trim()}),_){await a();return}await t(`/api/config/reload`,{method:`POST`})}finally{setTimeout(()=>T(!1),1e3)}},[_,M]),U=S.useCallback(async()=>{let e=await h(F);e.ok?(f(!0),setTimeout(()=>f(!1),2e3)):console.error(`Failed to copy:`,e.error)},[]),W=S.useCallback(async()=>{k(!0),j(null);try{let e=await D();e||=await O(),e?s?.():j(u(`onboarding.localSetup.errors.cliNotReady`))}catch(e){j(e instanceof Error?e.message:u(`onboarding.localSetup.errors.detectionFailed`))}finally{k(!1)}},[s,u]),G=I,K=P===`windows`?`C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd`:P===`linux`?`/home/you/.bun/bin/opencode`:`/Users/you/.bun/bin/opencode`;return(0,C.jsxs)(`div`,{className:`h-full flex items-center justify-center bg-transparent p-8 relative cursor-default select-none`,onMouseDown:B,children:[(0,C.jsxs)(`div`,{className:`w-full max-w-lg space-y-4 text-center`,children:[(0,C.jsx)(`div`,{className:`flex items-center`,children:(0,C.jsx)(v,{variant:`ghost`,onClick:e,className:`p-0 text-muted-foreground hover:text-foreground`,children:u(`onboarding.common.actions.back`)})}),(0,C.jsxs)(`div`,{className:`space-y-4`,children:[(0,C.jsx)(`h1`,{className:`text-3xl font-semibold tracking-tight text-foreground`,children:u(`onboarding.localSetup.title`)}),(0,C.jsx)(`p`,{className:`text-muted-foreground`,children:u(`onboarding.localSetup.description`)})]}),P===`windows`&&(0,C.jsxs)(`div`,{className:`mx-auto max-w-2xl rounded-lg border border-border bg-background/50 p-4 text-left`,children:[(0,C.jsx)(`div`,{className:`text-sm text-foreground`,children:u(`onboarding.localSetup.windows.title`)}),(0,C.jsxs)(`ol`,{className:`mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground`,children:[(0,C.jsx)(`li`,{children:u(`onboarding.localSetup.windows.stepRunInstallInWsl`)}),(0,C.jsx)(`li`,{children:u(`onboarding.localSetup.windows.stepSetBinaryPath`)})]})]}),(0,C.jsx)(`div`,{className:`flex justify-center`,children:(0,C.jsx)(`div`,{className:`bg-background/60 backdrop-blur-sm border border-border rounded-lg px-5 py-3 font-mono text-sm w-fit`,children:d?(0,C.jsxs)(`div`,{className:`flex items-center justify-center gap-2`,style:{color:`var(--status-success)`},children:[(0,C.jsx)(y,{name:`check`,className:`h-4 w-4`}),u(`onboarding.common.status.copiedToClipboard`)]}):(0,C.jsx)(L,{onCopy:U,copyTitle:u(`onboarding.common.copyToClipboard`)})})}),(0,C.jsxs)(`a`,{href:G,target:`_blank`,rel:`noopener noreferrer`,className:`text-sm text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1 justify-center`,children:[u(P===`windows`?`onboarding.localSetup.docs.windows`:`onboarding.localSetup.docs.default`),(0,C.jsx)(y,{name:`external-link`,className:`h-3 w-3`})]}),A&&(0,C.jsx)(`div`,{className:`mx-auto max-w-md rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive`,children:A}),(0,C.jsxs)(`div`,{className:`space-y-3`,children:[(0,C.jsx)(v,{type:`button`,onClick:W,disabled:E,className:`w-full max-w-xs`,size:`lg`,children:u(E?`onboarding.localSetup.actions.checking`:`onboarding.localSetup.actions.checkAndContinue`)}),(0,C.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`onboarding.localSetup.helper.checkAndContinue`)})]}),(0,C.jsx)(`div`,{className:`mx-auto w-full max-w-xl pt-4`,children:(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(0,C.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:u(`onboarding.localSetup.field.alreadyInstalled`)}),(0,C.jsxs)(`div`,{className:`flex gap-2`,children:[(0,C.jsx)(b,{value:M,onChange:e=>N(e.target.value),placeholder:K,disabled:w,className:`flex-1 font-mono text-xs`}),(0,C.jsx)(v,{type:`button`,variant:`secondary`,onClick:V,disabled:w||!_,children:u(`onboarding.localSetup.actions.browse`)}),(0,C.jsx)(v,{type:`button`,onClick:H,disabled:w,children:u(`onboarding.localSetup.actions.apply`)})]}),(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground/70`,children:u(`onboarding.localSetup.helper.saveAndReload`)})]})}),c&&l&&(0,C.jsxs)(`div`,{className:`text-center pt-4`,children:[(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground mb-2`,children:u(`onboarding.localSetup.remotePreference`)}),(0,C.jsx)(v,{variant:`link`,onClick:l,children:u(`onboarding.localSetup.actions.connectRemoteServer`)})]})]}),p&&(0,C.jsx)(`div`,{className:`absolute bottom-8 left-0 right-0 text-center space-y-1`,children:P===`windows`?(0,C.jsx)(C.Fragment,{children:(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground/70`,children:u(`onboarding.localSetup.windows.hintDetectionFailed`)})}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground/70`,children:u(`onboarding.localSetup.hint.ensurePath`)}),(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground/70`,children:u(`onboarding.localSetup.hint.setEnv`)}),(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground/70`,children:u(`onboarding.localSetup.hint.missingRuntime`)})]})})]})}function B(e,t){if(e?.trim())return c(e.trim());if(t)return c(t)}function V(e,t,n){switch(e){case`local-unavailable`:return{title:`Local OpenCode Unavailable`,description:`OpenCode CLI could not be started or is not installed. Install OpenCode or connect to a remote server instead.`,titleKey:`onboarding.desktopRecovery.localUnavailable.title`,descriptionKey:`onboarding.desktopRecovery.localUnavailable.description`,iconKey:`local`,showRetry:!0,retryLabel:`Retry Local`,retryLabelKey:`onboarding.desktopRecovery.localUnavailable.retry`,showUseLocal:!0,showUseRemote:!0,useLocalLabel:`Set Up Local`,useLocalLabelKey:`onboarding.desktopRecovery.localUnavailable.useLocal`,useRemoteLabel:`Use Remote`,useRemoteLabelKey:`onboarding.desktopRecovery.common.useRemote`};case`remote-missing`:return{title:`No Default Connection`,description:`Your saved default connection could not be found. Choose how you want to connect.`,titleKey:`onboarding.desktopRecovery.noDefaultConnection.title`,descriptionKey:`onboarding.desktopRecovery.noDefaultConnection.description`,iconKey:`local`,showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:`Use Local`,useLocalLabelKey:`onboarding.desktopRecovery.common.useLocal`,useRemoteLabel:`Use Remote`,useRemoteLabelKey:`onboarding.desktopRecovery.common.useRemote`};case`remote-unreachable`:{let e=B(t,n);return{title:`Remote Server Unreachable`,description:`Could not connect to "${e||`the remote server`}". Check your network connection and verify the server address.`,titleKey:`onboarding.desktopRecovery.remoteUnreachable.title`,descriptionKey:`onboarding.desktopRecovery.remoteUnreachable.description`,descriptionParams:e?{host:e}:void 0,iconKey:`remote`,showRetry:!0,retryLabel:`Retry Connection`,retryLabelKey:`onboarding.desktopRecovery.remoteUnreachable.retry`,showUseLocal:!0,showUseRemote:!0,useLocalLabel:`Use Local`,useLocalLabelKey:`onboarding.desktopRecovery.common.useLocal`,useRemoteLabel:`Use Remote`,useRemoteLabelKey:`onboarding.desktopRecovery.common.useRemote`}}case`remote-wrong-service`:{let e=B(t,n);return{title:`Incompatible Server`,description:`The server at "${e||`unknown`}" is not running OpenChamberY. Verify the address points to an OpenChamberY server.`,titleKey:`onboarding.desktopRecovery.incompatibleServer.title`,descriptionKey:`onboarding.desktopRecovery.incompatibleServer.description`,descriptionParams:e?{host:e}:void 0,iconKey:`remote`,showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:`Use Local`,useLocalLabelKey:`onboarding.desktopRecovery.common.useLocal`,useRemoteLabel:`Use Remote`,useRemoteLabelKey:`onboarding.desktopRecovery.common.useRemote`}}case`remote-incompatible`:{let e=B(t,n);return{title:`Server Update Required`,description:`The OpenChamberY server at "${e||`unknown`}" is not compatible with this app version. Update OpenChamberY on the server, then try again.`,titleKey:`onboarding.desktopRecovery.remoteIncompatible.title`,descriptionKey:`onboarding.desktopRecovery.remoteIncompatible.description`,descriptionParams:e?{host:e}:void 0,iconKey:`remote`,showRetry:!0,retryLabel:`Retry Connection`,retryLabelKey:`onboarding.desktopRecovery.remoteUnreachable.retry`,showUseLocal:!0,showUseRemote:!0,useLocalLabel:`Use Local`,useLocalLabelKey:`onboarding.desktopRecovery.common.useLocal`,useRemoteLabel:`Use Remote`,useRemoteLabelKey:`onboarding.desktopRecovery.common.useRemote`}}case`missing-default-host`:return{title:`No Default Connection`,description:`Your saved default connection could not be found. Choose how you want to connect.`,titleKey:`onboarding.desktopRecovery.noDefaultConnection.title`,descriptionKey:`onboarding.desktopRecovery.noDefaultConnection.description`,iconKey:`local`,showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:`Use Local`,useLocalLabelKey:`onboarding.desktopRecovery.common.useLocal`,useRemoteLabel:`Use Remote`,useRemoteLabelKey:`onboarding.desktopRecovery.common.useRemote`};default:throw Error(`Unknown recovery variant: ${e}`)}}function H(e){switch(e){case`local`:return(0,C.jsx)(y,{name:`macbook`,className:`h-8 w-8`});case`remote`:return(0,C.jsx)(y,{name:`server`,className:`h-8 w-8`})}}function U({variant:e,hostLabel:t,hostUrl:n,onRetry:r,onUseLocal:i,onUseRemote:a,isRetrying:o=!1}){let{t:s}=g(),l=V(e,t,n),u=l.retryLabelKey??`onboarding.desktopRecovery.actions.retryConnection`,d=S.useMemo(()=>{if(l.descriptionParams?.host)return l.descriptionParams;if(e===`remote-unreachable`)return{host:s(`onboarding.desktopRecovery.placeholders.remoteServer`)};if(e===`remote-wrong-service`||e===`remote-incompatible`)return{host:s(`onboarding.desktopRecovery.placeholders.unknownServer`)}},[l.descriptionParams,s,e]);return(0,C.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-8`,children:(0,C.jsxs)(`div`,{className:`w-full max-w-md space-y-6`,children:[(0,C.jsxs)(`div`,{className:`flex flex-col items-center space-y-3 text-center`,children:[(0,C.jsx)(`div`,{className:`p-3 rounded-full`,style:{backgroundColor:`var(--status-warning)`,opacity:.15},children:(0,C.jsx)(`div`,{style:{color:`var(--status-warning)`},children:H(l.iconKey)})}),(0,C.jsx)(`h1`,{className:`typography-ui-header text-xl font-semibold text-foreground`,children:s(l.titleKey)}),(0,C.jsx)(`p`,{className:`text-muted-foreground text-sm max-w-sm`,children:s(l.descriptionKey,d)})]}),n&&(e===`remote-unreachable`||e===`remote-wrong-service`||e===`remote-incompatible`)&&(0,C.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/50 p-3`,children:[(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:s(`onboarding.remoteConnection.field.serverAddress`)}),(0,C.jsx)(`div`,{className:`font-mono text-sm text-foreground truncate`,children:c(n)})]}),(0,C.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[l.showRetry&&r&&(0,C.jsxs)(v,{onClick:r,disabled:o,className:`w-full`,children:[(0,C.jsx)(y,{name:`refresh`,className:_(`h-4 w-4`,o&&`animate-spin`)}),s(o?`onboarding.desktopRecovery.actions.retrying`:u)]}),(0,C.jsxs)(`div`,{className:`flex gap-2`,children:[l.showUseLocal&&i&&(0,C.jsxs)(v,{variant:`outline`,onClick:i,disabled:o,className:`flex-1`,children:[(0,C.jsx)(y,{name:`macbook`,className:`h-4 w-4`}),s(l.useLocalLabelKey)]}),l.showUseRemote&&a&&(0,C.jsxs)(v,{variant:`outline`,onClick:a,disabled:o,className:`flex-1`,children:[(0,C.jsx)(y,{name:`server`,className:`h-4 w-4`}),s(l.useRemoteLabelKey)]})]})]})]})})}function W(e,t){if(t===`use-remote`)return{kind:`remote-form`};switch(e){case`local-unavailable`:return{kind:`local-setup`};case`remote-unreachable`:case`remote-incompatible`:case`remote-wrong-service`:case`remote-missing`:case`missing-default-host`:return{kind:`switch-default-to-local`};default:throw Error(`Unhandled RecoveryVariant: ${e}`)}}function G(e){let n=(0,x.c)(27),{variant:r,hostUrl:o,hostLabel:s,onRetry:c,onChooseRemote:l,showRemoteForm:u,onCloseRemoteForm:d,onSwitchToLocalFromRemote:f,onEnterLocalSetup:p,isRetrying:m}=e,h=u!==void 0&&u,g=m!==void 0&&m,_=K,v;n[0]===c?v=n[1]:(v=async()=>{if(i()){await a();return}await t(`/api/config/reload`,{method:`POST`}),c?.()},n[0]=c,n[1]=v);let y=v,b;n[2]!==p||n[3]!==r?(b=async()=>{if(W(r,`use-local`).kind===`local-setup`){p?.();return}if(await _(`local`),i()){await a();return}window.location.reload()},n[2]=p,n[3]=r,n[4]=b):b=n[4];let S=b,w;n[5]!==l||n[6]!==r?(w=()=>{W(r,`use-remote`).kind===`remote-form`&&l?.()},n[5]=l,n[6]=r,n[7]=w):w=n[7];let T=w;if(h){let e=r===`remote-wrong-service`?``:o||``,t=r===`remote-wrong-service`?``:s||``,c;n[8]!==l||n[9]!==d?(c=d||(()=>l?.()),n[8]=l,n[9]=d,n[10]=c):c=n[10];let u;n[11]!==p||n[12]!==f?(u=f||(()=>{_(`local`).then(()=>{i()?a():p?.()})}),n[11]=p,n[12]=f,n[13]=u):u=n[13];let m;return n[14]!==t||n[15]!==e||n[16]!==c||n[17]!==u?(m=(0,C.jsx)(E,{onBack:c,initialUrl:e,initialLabel:t,isRecoveryMode:!0,onSwitchToLocal:u}),n[14]=t,n[15]=e,n[16]=c,n[17]=u,n[18]=m):m=n[18],m}let D;return n[19]!==y||n[20]!==S||n[21]!==T||n[22]!==s||n[23]!==o||n[24]!==g||n[25]!==r?(D=(0,C.jsx)(U,{variant:r,hostLabel:s,hostUrl:o,onRetry:y,onUseLocal:S,onUseRemote:T,isRetrying:g}),n[19]=y,n[20]=S,n[21]=T,n[22]=s,n[23]=o,n[24]=g,n[25]=r,n[26]=D):D=n[26],D}async function K(e){if(!i())return;let t=await d();await l({...t,...e===`local`?{defaultHostId:`local`}:{},initialHostChoiceCompleted:!0})}function q(e){let t=(0,x.c)(26),{onBack:n,onCliAvailable:r,mode:i,recoveryVariant:a,recoveryHostUrl:o,recoveryHostLabel:s,onEnterLocalSetup:c}=e,l=i===void 0?`first-launch`:i,u=a===void 0?`missing-default-host`:a,[d,f]=S.useState(!1),[p,m]=S.useState(!1),h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>{m(!1),f(!1)},t[0]=h):h=t[0];let g;t[1]!==l||t[2]!==s||t[3]!==o||t[4]!==u?(g=[l,u,o,s],t[1]=l,t[2]=s,t[3]=o,t[4]=u,t[5]=g):g=t[5],S.useEffect(h,g);let _=p?`local-setup`:l;if(_===`recovery`){let e,n;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>f(!1),n=()=>{f(!1),m(!0)},t[6]=e,t[7]=n):(e=t[6],n=t[7]);let r;t[8]===c?r=t[9]:(r=()=>{m(!0),c?.()},t[8]=c,t[9]=r);let i;return t[10]!==s||t[11]!==o||t[12]!==u||t[13]!==d||t[14]!==r?(i=(0,C.jsx)(G,{variant:u,hostUrl:o,hostLabel:s,showRemoteForm:d,onCloseRemoteForm:e,onSwitchToLocalFromRemote:n,onEnterLocalSetup:r}),t[10]=s,t[11]=o,t[12]=u,t[13]=d,t[14]=r,t[15]=i):i=t[15],i}if(_===`local-setup`){let e;t[16]!==n||t[17]!==p?(e=()=>{p?m(!1):n?.()},t[16]=n,t[17]=p,t[18]=e):e=t[18];let i;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>f(!0),t[19]=i):i=t[19];let a;return t[20]!==r||t[21]!==p||t[22]!==e?(a=(0,C.jsx)(z,{onBack:e,onCliAvailable:r,isFromRecovery:p,onSwitchToRemote:i}),t[20]=r,t[21]=p,t[22]=e,t[23]=a):a=t[23],a}let v;return t[24]===r?v=t[25]:(v=(0,C.jsx)(P,{onCliAvailable:r}),t[24]=r,t[25]=v),v}export{q as OnboardingScreen};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t}from"./runtime-fetch-QCWYlAx0.js";import{it as n,nt as r,rt as i}from"./vendor-base-ui-CdzJ6My_.js";import{_ as a}from"./useUIStore-pl39iO82.js";import{n as o}from"./vendor-react-BP2cRVqX.js";import{a as s,i as c}from"./vendor-pierre-diffs-DPBtNDJ5.js";import{n as l}from"./vendor-reactuses-core-BpfIZ1tg.js";import{f as u,r as d,t as f}from"./button-kJNzMb1G.js";import{n as p,r as m}from"./rasterizePng-DCmIQQsI.js";import{n as h,t as g}from"./useThemeSystem-8jhE4Zyk.js";import{n as _}from"./Icon-DewMAW7N.js";import{s as v,v as y}from"./image-loading-OgMEw4Jq.js";import{i as b,t as x}from"./appThemeRegistry-an4Akg1y.js";import{n as S}from"./MarkdownRenderer-BrnwB_5z.js";import{l as C}from"./markdown-worker-DFNZ3KJ_.js";import{n as w}from"./useEffectiveDirectory-CT3VhbVS.js";import{i as T,n as E}from"./markdownTheme-CV7_0QAL.js";import{t as D}from"./ImageLoadingPlaceholder-D7q71Qgl.js";import{_ as O,d as ee,f as k,g as A,h as j,l as M,m as N,n as P,p as F,r as I,s as L,t as R,u as te}from"./useWorkerHighlightedLines-Vnb6JoM_.js";import{t as z}from"./vendor-tanstack-react-virtual-B_EO--9t.js";var B=o(),V=e(n(),1),H=i(),U=80,W=20,ne=V.memo(e=>{let t=(0,B.c)(26),{lines:n,language:r,maxHeight:i,showLineNumbers:a,lineStyles:o}=e,s=i===void 0?`60vh`:i,c=a===void 0||a,{currentTheme:l}=h(),u;t[0]===l?u=t[1]:(u=E(l),t[0]=l,t[1]=u);let d=u,f;t[2]===n?f=t[3]:(f=n.map(ae).join(`
|
|
2
|
-
`),t[2]=n,t[3]=f);let p=R(f,r);if(!(n.length>U)){let e=d,r;t[4]!==s||t[5]!==e?(r={...e,maxHeight:s,overflow:`auto`},t[4]=s,t[5]=e,t[6]=r):r=t[6];let i;if(t[7]!==p||t[8]!==o||t[9]!==n||t[10]!==c){let e;t[12]!==p||t[13]!==o||t[14]!==c?(e=(e,t)=>(0,H.jsx)(ie,{line:e,html:p?.[t],showLineNumbers:c,style:o?.(e)},t),t[12]=p,t[13]=o,t[14]=c,t[15]=e):e=t[15],i=n.map(e),t[7]=p,t[8]=o,t[9]=n,t[10]=c,t[11]=i}else i=t[11];let a;return t[16]!==r||t[17]!==i?(a=(0,H.jsx)(`div`,{className:`typography-code font-mono w-full min-w-0`,style:r,children:i}),t[16]=r,t[17]=i,t[18]=a):a=t[18],a}let m;return t[19]!==p||t[20]!==o||t[21]!==n||t[22]!==s||t[23]!==c||t[24]!==d?(m=(0,H.jsx)(re,{lines:n,highlighted:p,syntaxVars:d,maxHeight:s,showLineNumbers:c,lineStyles:o}),t[19]=p,t[20]=o,t[21]=n,t[22]=s,t[23]=c,t[24]=d,t[25]=m):m=t[25],m});ne.displayName=`VirtualizedCodeBlock`;var re=V.memo(({lines:e,highlighted:t,syntaxVars:n,maxHeight:r,showLineNumbers:i,lineStyles:a})=>{let o=V.useRef(null),s=`min(${e.length*W}px, ${r})`,c=z({count:e.length,getScrollElement:()=>o.current,estimateSize:()=>W,overscan:20}),l=c.getVirtualItems();return(0,H.jsx)(`div`,{ref:o,className:`typography-code font-mono w-full min-w-0`,style:{...n,height:s,maxHeight:r,overflow:`auto`},children:(0,H.jsx)(`div`,{style:{height:c.getTotalSize(),position:`relative`},children:l.map(n=>{let r=e[n.index];return r?(0,H.jsx)(`div`,{"data-index":n.index,ref:c.measureElement,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${n.start}px)`},children:(0,H.jsx)(ie,{line:r,html:t?.[n.index],showLineNumbers:i,style:a?.(r)})},n.index):null})})})});re.displayName=`VirtualizedRows`;var ie=V.memo(e=>{let t=(0,B.c)(12),{line:n,html:r,showLineNumbers:i,style:a}=e,o;t[0]!==n.isInfo||t[1]!==n.lineNumber||t[2]!==i?(o=i&&(0,H.jsx)(`span`,{className:`w-10 flex-shrink-0 text-right pr-3 select-none border-r mr-3 -my-0.5 py-0.5`,style:{color:`var(--tools-edit-line-number)`,borderColor:`var(--tools-border)`},children:!n.isInfo&&n.lineNumber!=null?n.lineNumber:``}),t[0]=n.isInfo,t[1]=n.lineNumber,t[2]=i,t[3]=o):o=t[3];let s;t[4]!==r||t[5]!==n.isInfo||t[6]!==n.text?(s=(0,H.jsx)(`div`,{className:`flex-1 min-w-0`,children:n.isInfo?(0,H.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-muted-foreground/70 italic`,children:n.text}):r===void 0?(0,H.jsx)(`div`,{className:`whitespace-pre`,children:n.text}):(0,H.jsx)(`div`,{className:`whitespace-pre`,dangerouslySetInnerHTML:{__html:r}})}),t[4]=r,t[5]=n.isInfo,t[6]=n.text,t[7]=s):s=t[7];let c;return t[8]!==a||t[9]!==o||t[10]!==s?(c=(0,H.jsxs)(`div`,{className:`typography-code font-mono flex w-full min-w-0`,style:a,children:[o,s]}),t[8]=a,t[9]=o,t[10]=s,t[11]=c):c=t[11],c});ie.displayName=`VirtualizedCodeBlock.Row`;function ae(e){return e.text}var oe=V.memo(function({jsonString:e,className:t,maxHeight:n=`100%`,initiallyExpandedDepth:r=2}){let{t:i}=u(),a=V.useRef(null),[o,s]=V.useState(null),c=V.useMemo(()=>{try{let t=e.trim();if(!t)return s(i(`jsonTreeView.error.emptyJson`)),null;let n=JSON.parse(t);return s(null),n}catch(e){return s(e instanceof Error?e.message:i(`jsonTreeView.error.invalidJson`)),null}},[e,i]),l=V.useCallback(()=>{a.current?.expandAll()},[]),d=V.useCallback(()=>{a.current?.collapseAll()},[]);return o?(0,H.jsx)(`div`,{className:t,children:(0,H.jsxs)(`div`,{className:`rounded-md border border-[var(--interactive-border)] bg-[var(--syntax-base-background)] p-4`,children:[(0,H.jsx)(`div`,{className:`mb-1 font-medium text-[var(--surface-foreground)]`,children:i(`jsonTreeView.error.invalidJsonTitle`)}),(0,H.jsx)(`div`,{className:`font-mono text-xs text-[var(--surface-mutedForeground)]`,children:o})]})}):c===null?null:(0,H.jsxs)(`div`,{className:t,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-[var(--interactive-border)] px-2 py-1`,children:[(0,H.jsxs)(f,{variant:`ghost`,size:`xs`,onClick:l,className:`gap-1 text-xs text-muted-foreground`,children:[(0,H.jsx)(_,{name:`arrow-down-s`,className:`h-3 w-3`}),i(`jsonTreeView.actions.expandAll`)]}),(0,H.jsxs)(f,{variant:`ghost`,size:`xs`,onClick:d,className:`gap-1 text-xs text-muted-foreground`,children:[(0,H.jsx)(_,{name:`arrow-up-s`,className:`h-3 w-3`}),i(`jsonTreeView.actions.collapseAll`)]})]}),(0,H.jsx)(`div`,{className:`bg-[var(--syntax-base-background)] py-1`,style:{maxHeight:n,overflow:`auto`},children:(0,H.jsx)(I,{ref:a,data:c,maxHeight:n,initiallyExpandedDepth:r})})]})}),se=class extends Error{key;params;constructor(e,t){super(e),this.name=`MermaidLoadFailure`,this.key=e,this.params=t}},G=(e,t)=>new se(e,t),ce=e=>e instanceof se,le=e=>e+1,K=(e,t)=>e===t,q=e=>{let t=e.indexOf(`,`);if(t<0)throw G(`chat.toolOutputDialog.mermaid.dataUrlMalformed`);let n=e.slice(0,t).toLowerCase(),r=e.slice(t+1);return n.includes(`;base64`)?atob(r):decodeURIComponent(r)},ue=e=>Promise.resolve().then(()=>q(e)),J=1,de=56,Y=(e,t,n)=>Math.min(n,Math.max(t,e)),fe=({isMobile:e,pointerType:t,cancelled:n,moved:r,suppressTap:i,targetWasCanvas:a,start:o,end:s,startScale:c,hasMultipleImages:l})=>{if(n||i)return`none`;let u={x:s.x-o.x,y:s.y-o.y},d=Math.hypot(u.x,u.y),f=t!==`mouse`;if(e&&f&&c<=1.01&&Math.abs(u.x)>=de&&Math.abs(u.x)>Math.abs(u.y)*1.2)return l?u.x<0?`next`:`previous`:`none`;let p=!r&&d<=10;return e&&f&&p||!e&&t===`mouse`&&p&&a?`close`:`none`},pe=(e,t)=>{if(e.width<=0||e.height<=0||t.width<=0||t.height<=0)return{width:1,height:1};let n=Math.min(t.width/e.width,t.height/e.height);return{width:Math.max(1,e.width*n),height:Math.max(1,e.height*n)}},X=(e,t)=>{let n=t.minScale??J,r=t.maxScale??5,i=Y(e.scale,n,r),a=Math.max(0,(t.image.width*i-t.viewport.width)/2),o=Math.max(0,(t.image.height*i-t.viewport.height)/2);return{scale:i,x:Y(e.x,-a,a),y:Y(e.y,-o,o)}},me=(e,t,n,r,i)=>{let a=Y(t,i.minScale??J,i.maxScale??5),o=a/e.scale;return X({scale:a,x:n.x-r.x-(n.x-r.x-e.x)*o,y:n.y-r.y-(n.y-r.y-e.y)*o},i)},he=(e,t,n)=>X({...e,x:e.x+t.x,y:e.y+t.y},n),ge=(e,t,n,r,i,a)=>{let o=Y(r,a.minScale??J,a.maxScale??5),s=o/e.scale;return X({scale:o,x:n.x-i.x-(t.x-i.x-e.x)*s,y:n.y-i.y-(t.y-i.y-e.y)*s},a)},Z=500,_e=24,ve=(e,t={})=>{let n=t.target??(typeof document>`u`?null:document);if(!n)return()=>{};let r=t.durationMs??Z,i=t.maxDistance??_e,a=!0,o,s=()=>{a&&(a=!1,n.removeEventListener(`click`,c,!0),o!==void 0&&globalThis.clearTimeout(o))},c=t=>{let n=t;typeof n.clientX==`number`&&typeof n.clientY==`number`&&(Math.hypot(n.clientX-e.x,n.clientY-e.y)>i||(s(),t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()))};return n.addEventListener(`click`,c,!0),o=globalThis.setTimeout(s,r),s},ye=(e,t,n={})=>{ve(e,n),t()},be=e(r(),1);function xe(e,t,n,r,i=()=>{}){let a=e?.getBoundingClientRect(),o=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;if(!document.startViewTransition||o||!e?.isConnected||!t||!n||!a?.width||!a.height||a.bottom<=0||a.top>=window.innerHeight||a.right<=0||a.left>=window.innerWidth){if(!n?.animate||o)return i(),()=>{};let e=n.animate({opacity:r?[1,0]:[0,1]},{duration:150,fill:`forwards`}),t=!1;return e.finished.then(()=>{t||i()},()=>{}),()=>{t=!0,e.cancel()}}let s=e.style.viewTransitionName,c=t.style.viewTransitionName,l=n.style.visibility,u=!1,d=`oc-media-preview`;e.style.viewTransitionName=r?`none`:d,t.style.viewTransitionName=r?d:`none`,r||(n.style.visibility=`hidden`);let f=document.startViewTransition(()=>{u||(e.style.viewTransitionName=r?d:`none`,t.style.viewTransitionName=r?`none`:d,n.style.visibility=r?`hidden`:l)}),p=()=>{e.style.viewTransitionName=s,t.style.viewTransitionName=c,n.style.visibility=l};f.ready.catch(()=>{});let m=()=>{u||(p(),i())};return f.finished.then(m,m),()=>{u=!0,f.skipTransition(),p()}}function Se(e){let t=(0,B.c)(12),{onClose:n,isMobile:r,size:i}=e,{t:a}=u(),o;t[0]!==r||t[1]!==i?(o=r?{top:`calc(var(--oc-safe-area-top, 0px) + 0.5rem)`,right:`calc(var(--oc-safe-area-right, 0px) + 0.75rem)`}:{top:i?`calc(50% - ${i.height/2}px + 0.5rem)`:`0.5rem`,right:i?`calc(50% - ${i.width/2}px + 0.5rem)`:`0.5rem`},t[0]=r,t[1]=i,t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=a(`dialog.common.actions.close`),t[3]=a,t[4]=s);let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,H.jsx)(_,{name:`close`,className:`size-5`}),t[5]=c):c=t[5];let l;t[6]!==n||t[7]!==s?(l=(0,H.jsx)(f,{variant:`mobileGlass`,size:`mobileIcon`,"aria-label":s,onClick:n,children:c}),t[6]=n,t[7]=s,t[8]=l):l=t[8];let d;return t[9]!==o||t[10]!==l?(d=(0,H.jsx)(`div`,{className:`absolute right-3 z-20`,style:o,children:l}),t[9]=o,t[10]=l,t[11]=d):d=t[11],d}function Ce(e){let t=(0,B.c)(25),{open:n,title:r,kind:i,source:a,isMobile:o,onOpenChange:s,children:c}=e,u=V.useRef(null),d=V.useRef(null),f=V.useRef(!1),[p,m]=V.useState(!1),h;t[0]!==s||t[1]!==a?(h=()=>{if(f.current)return;f.current=!0,d.current?.();let e=u.current?.querySelector(`[data-preview-transition-target]`)??null;d.current=xe(e?.dataset.previewReturn===`false`?void 0:a,e,u.current,!0,()=>{m(!0),s(!1)})},t[0]=s,t[1]=a,t[2]=h):h=t[2];let g=l(h),_=`${i}-preview`,v=n&&!p&&o,y;t[3]!==g||t[4]!==_||t[5]!==v?(y={id:_,active:v,layer:`overlay`,onBack:g,surfaceRef:u},t[3]=g,t[4]=_,t[5]=v,t[6]=y):y=t[6],b(y);let x,S;if(t[7]!==p||t[8]!==n||t[9]!==a?(x=()=>{if(!n){m(!1),f.current=!1;return}if(p)return;let e=u.current,t=document.activeElement instanceof HTMLElement?document.activeElement:null;return e?.querySelector(`button`)?.focus({preventScroll:!0}),d.current=xe(a,e?.querySelector(`[data-preview-transition-target]`)??null,e,!1),()=>{d.current?.(),d.current=null,f.current=!1,t?.isConnected&&t.focus({preventScroll:!0})}},S=[p,n,a],t[7]=p,t[8]=n,t[9]=a,t[10]=x,t[11]=S):(x=t[10],S=t[11]),V.useLayoutEffect(x,S),!n||p||typeof document>`u`)return null;let C=o?`var(--oc-media-preview-background)`:`color-mix(in srgb, var(--oc-media-preview-background) ${i===`mermaid`?90:70}%, transparent)`,w;t[12]===C?w=t[13]:(w={backgroundColor:C,color:`var(--oc-media-preview-foreground)`},t[12]=C,t[13]=w);let T;t[14]===g?T=t[15]:(T=e=>{if(e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),g()),e.key!==`Tab`)return;let t=Array.from(e.currentTarget.querySelectorAll(`button:not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex="0"]`)),n=t[0],r=t.at(-1);e.shiftKey&&document.activeElement===n?(e.preventDefault(),r?.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n?.focus())},t[14]=g,t[15]=T);let E;t[16]!==c||t[17]!==g?(E=c(g),t[16]=c,t[17]=g,t[18]=E):E=t[18];let D;return t[19]!==i||t[20]!==E||t[21]!==w||t[22]!==T||t[23]!==r?(D=(0,be.createPortal)((0,H.jsx)(`div`,{ref:u,role:`dialog`,"aria-modal":`true`,"aria-label":r,"data-media-preview":i,"data-page-scroll-lock":`true`,tabIndex:-1,className:`fixed inset-0 z-50 overflow-hidden select-none`,style:w,onClick:we,onKeyDown:T,children:E}),document.body),t[19]=i,t[20]=E,t[21]=w,t[22]=T,t[23]=r,t[24]=D):D=t[24],D}function we(e){e.preventDefault(),e.stopPropagation()}var Te=500,Ee=400,Q=(e,t)=>new se(e,t),De=e=>{let t=`h-3.5 w-3.5 flex-shrink-0`,n=e.toLowerCase();return n===`reasoning`?(0,H.jsx)(_,{name:`brain-ai-3`,className:t}):n===`image-preview`?(0,H.jsx)(_,{name:`file-image`,className:t}):n===`mermaid-preview`?(0,H.jsx)(_,{name:`file-list-2`,className:t}):n===`edit`||n===`multiedit`||n===`apply_patch`||n===`str_replace`||n===`str_replace_based_edit_tool`?(0,H.jsx)(_,{name:`pencil-ai`,className:t}):n===`write`||n===`create`||n===`file_write`||n===`read`||n===`view`||n===`file_read`||n===`cat`?(0,H.jsx)(_,{name:`file-pdf`,className:t}):n===`bash`||n===`shell`||n===`cmd`||n===`terminal`?(0,H.jsx)(_,{name:`terminal-box`,className:t}):n===`list`||n===`ls`||n===`dir`||n===`list_files`?(0,H.jsx)(_,{name:`folder-6`,className:t}):n===`search`||n===`grep`||n===`find`||n===`ripgrep`?(0,H.jsx)(_,{name:`search`,className:t}):n===`glob`?(0,H.jsx)(_,{name:`file-search`,className:t}):n===`fetch`||n===`curl`||n===`wget`||n===`webfetch`?(0,H.jsx)(_,{name:`global`,className:t}):n===`web-search`||n===`websearch`||n===`search_web`||n===`google`||n===`bing`||n===`duckduckgo`?(0,H.jsx)(_,{name:`search`,className:t}):n===`todowrite`||n===`todoread`?(0,H.jsx)(_,{name:`list-check-3`,className:t}):n.startsWith(`git`)?(0,H.jsx)(_,{name:`git-branch`,className:t}):(0,H.jsx)(_,{name:`tools`,className:t})},Oe={style:{background:`transparent`,backgroundColor:`transparent`,fontSize:`inherit`}},ke={download:!1,copy:!1,showPanZoomControls:!0},Ae=`
|
|
3
|
-
[data-diff-header],
|
|
4
|
-
[data-diff] {
|
|
5
|
-
[data-separator] {
|
|
6
|
-
height: 24px !important;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
`,je={hunkLineCount:50,lineHeight:24,diffHeaderHeight:44,hunkSeparatorHeight:24,spacing:0},$=()=>{let e=(0,B.c)(22),t=g(),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=y(!1),e[0]=n):n=e[0];let r=n,i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=y(!0),e[1]=i):i=e[1];let a=i,o;e[2]===t?.availableThemes?o=e[3]:(o=()=>t?.availableThemes??[r,a],e[2]=t?.availableThemes,e[3]=o),t?.availableThemes;let s;e[4]===o?s=e[5]:(s=o(),e[4]=o,e[5]=s);let c=s,l=t?.lightThemeId??r.metadata.id,u=t?.darkThemeId??a.metadata.id,d;e[6]!==c||e[7]!==l?(d=c.find(e=>e.metadata.id===l)??r,e[6]=c,e[7]=l,e[8]=d):d=e[8];let f=d,p;e[9]!==c||e[10]!==u?(p=c.find(e=>e.metadata.id===u)??a,e[9]=c,e[10]=u,e[11]=p):p=e[11];let m=p,h,_;e[12]!==m||e[13]!==f?(h=()=>{x(f),x(m)},_=[m,f],e[12]=m,e[13]=f,e[14]=h,e[15]=_):(h=e[14],_=e[15]),V.useEffect(h,_);let v=t?.currentTheme.metadata.variant??`light`,b;e[16]!==m.metadata.id||e[17]!==f.metadata.id?(b={light:f.metadata.id,dark:m.metadata.id},e[16]=m.metadata.id,e[17]=f.metadata.id,e[18]=b):b=e[18];let S=v===`dark`?`dark`:`light`,C;return e[19]!==b||e[20]!==S?(C={theme:b,themeType:S},e[19]=b,e[20]=S,e[21]=C):C=e[21],C},Me=()=>({width:typeof window<`u`?window.innerWidth:0,height:typeof window<`u`?window.innerHeight:0}),Ne=e=>{let t=(0,B.c)(3),[n,r]=V.useState(Me),i,a;return t[0]===e?(i=t[1],a=t[2]):(i=()=>{if(!e||typeof window>`u`)return;let t=()=>{r(Me())};return t(),window.addEventListener(`resize`,t),()=>{window.removeEventListener(`resize`,t)}},a=[e],t[0]=e,t[1]=i,t[2]=a),V.useEffect(i,a),n},Pe=({popup:e,onOpenChange:t,isMobile:n})=>{let{t:r}=u(),i=g(),a=w()??``,o=V.useMemo(()=>{let t=e.image;if(!t)return[];let n=Array.isArray(t.gallery)?t.gallery.filter(e=>!!e?.url):[];return n.length>0?n:[{url:t.url,mimeType:t.mimeType,filename:t.filename,size:t.size}]},[e.image]),[s,c]=V.useState(()=>{let t=e.image?.index??o.findIndex(t=>t.url===e.image?.url);return t>=0&&t<o.length?t:0}),p=e.previewSource instanceof HTMLImageElement?e.previewSource:void 0,m=p?.naturalWidth&&p.naturalHeight?{width:p.naturalWidth,height:p.naturalHeight}:null,[h,y]=V.useState(m),[b,x]=V.useState(!!m),S=e.open,C=Ne(e.open),E=V.useRef(null),ee=V.useRef(null),k=V.useRef(null),A=V.useRef(null),j=V.useRef({scale:1,x:0,y:0}),M=V.useRef({image:{width:1,height:1},viewport:{width:1,height:1},maxScale:5}),N=V.useRef(new Map),P=V.useRef(null),F=V.useRef(null),I=V.useRef(null),L=V.useRef(null),R=V.useRef(0);V.useEffect(()=>{e.open&&(R.current=typeof performance<`u`?performance.now():Date.now())},[e.open]);let te=l(()=>(typeof performance<`u`?performance.now():Date.now())-R.current<Ee),z=l(()=>{let e=P.current;e?.longPressTimer&&(clearTimeout(e.longPressTimer),e.longPressTimer=null)});V.useEffect(()=>{if(!e.open||o.length===0)return;let t=typeof e.image?.index==`number`?e.image.index:-1;if(t>=0&&t<o.length){c(t);return}let n=e.image?.url?o.findIndex(t=>t.url===e.image?.url):-1;c(n>=0?n:0)},[o,e.image?.index,e.image?.url,e.open]);let B=o[s]??o[0]??e.image,U=v(B?.url??``,a,`preview`),W=U.source||(B?.url===e.image?.url?p?.currentSrc:``)||``,ne=`${U.key}\n${W}`,[re,ie]=V.useState(``),ae=!!(U.error||re===ne),oe=l(()=>ie(ne)),se=B?.filename||e.title,G=o.length>1,ce=l(()=>{let t=B?.url??e.image?.url??``;if(!t&&!W)return;let n=B?.mimeType||e.image?.mimeType,r=B?.filename||e.image?.filename||e.title,i=k.current;if(i&&i.naturalWidth>0){O(i,n||`image/png`).then(e=>{T({sourceUrl:t||W,displayUrl:W||i.currentSrc||i.src||void 0,filename:r,mimeType:n,effectiveDirectory:a,prefetchedBlob:e??void 0})});return}T({sourceUrl:t||W,displayUrl:W||void 0,filename:r,mimeType:n,effectiveDirectory:a})}),le=l(()=>{o.length<=1||c(e=>(e-1+o.length)%o.length)}),K=l(()=>{o.length<=1||c(e=>(e+1)%o.length)}),q=V.useMemo(()=>{let e={width:Math.max(1,C.width*(n?1:.8)),height:Math.max(1,C.height*(n?1:.95))};return h?pe(h,e):e},[h,n,C.height,C.width]),ue=V.useMemo(()=>({image:q,viewport:{width:Math.max(1,C.width),height:Math.max(1,C.height)},maxScale:5}),[q,C.height,C.width]),J=l((e,t=!1)=>{let n=X(e,M.current);j.current=n,L.current={transform:n,animate:t},!(I.current!==null||typeof window>`u`)&&(I.current=window.requestAnimationFrame(()=>{I.current=null;let e=L.current;L.current=null,e&&(k.current&&(k.current.style.transition=e.animate?`transform 180ms cubic-bezier(0.22, 1, 0.36, 1)`:`none`,k.current.style.transform=`translate3d(${e.transform.x}px, ${e.transform.y}px, 0) scale(${e.transform.scale})`),A.current&&(A.current.textContent=`${Math.round(e.transform.scale*100)}%`),E.current&&(E.current.style.cursor=e.transform.scale>1?`grab`:`zoom-in`))}))}),de=l((e=!0)=>{J({scale:1,x:0,y:0},e)}),Y=l(()=>({x:M.current.viewport.width/2,y:M.current.viewport.height/2})),Z=l((e,t,n=!1)=>{J(me(j.current,e,t,Y(),M.current),n)}),_e=l(e=>{if(j.current.scale>1.01){de(!0);return}Z(2,e,!0)}),ve=l(e=>{if(!(n||e.defaultPrevented)){if(e.key===`+`||e.key===`=`){e.preventDefault(),Z(j.current.scale*1.4,Y(),!0);return}if(e.key===`-`||e.key===`_`){e.preventDefault(),Z(j.current.scale/1.4,Y(),!0);return}if(e.key===`0`){e.preventDefault(),de(!0);return}if(e.key===`ArrowLeft`&&G){e.preventDefault(),le();return}e.key===`ArrowRight`&&G&&(e.preventDefault(),K())}});V.useEffect(()=>{if(e.open)return window.addEventListener(`keydown`,ve),()=>{window.removeEventListener(`keydown`,ve)}},[e.open]),V.useEffect(()=>{I.current!==null&&window.cancelAnimationFrame(I.current),I.current=null,L.current=null;let t=B?.url===e.image?.url?p:void 0;y(t?.naturalWidth&&t.naturalHeight?{width:t.naturalWidth,height:t.naturalHeight}:null),x(!!t?.naturalWidth),j.current={scale:1,x:0,y:0},N.current.clear(),P.current=null,F.current=null,k.current&&(k.current.style.transform=`translate3d(0, 0, 0) scale(1)`),A.current&&(A.current.textContent=`100%`)},[B?.url,W,e.image?.url,p]),V.useLayoutEffect(()=>{M.current=ue;let e=X(j.current,M.current);j.current=e,k.current&&(k.current.style.transition=`none`,k.current.style.transform=`translate3d(${e.x}px, ${e.y}px, 0) scale(${e.scale})`)},[ue]),V.useEffect(()=>()=>{I.current!==null&&window.cancelAnimationFrame(I.current),I.current=null,L.current=null;let e=P.current;e?.longPressTimer&&(clearTimeout(e.longPressTimer),e.longPressTimer=null)},[]);let be=l(e=>{if(n)return;e.preventDefault();let t={x:e.clientX,y:e.clientY},r=Math.exp(-e.deltaY*.002);Z(j.current.scale*r,t)});V.useEffect(()=>{let e=E.current;if(!(!S||n||!e))return e.addEventListener(`wheel`,be,{passive:!1}),()=>e.removeEventListener(`wheel`,be)},[n,S]);let xe=l(e=>{n||(e.preventDefault(),_e({x:e.clientX,y:e.clientY}))}),Ce=l(e=>{e.preventDefault(),e.stopPropagation()}),we=l(e=>{e.pointerType!==`mouse`&&e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId);let t={x:e.clientX,y:e.clientY};if(N.current.set(e.pointerId,{point:t,pointerType:e.pointerType}),N.current.size===1){if(P.current={pointerId:e.pointerId,pointerType:e.pointerType,start:t,transform:j.current,moved:!1,targetWasCanvas:e.target===e.currentTarget,suppressTap:!1,longPressTimer:null,longPressTriggered:!1},e.pointerType!==`mouse`||j.current.scale<=1.01){let t=P.current;t.longPressTimer=setTimeout(()=>{!P.current||P.current.pointerId!==e.pointerId||P.current.moved||(P.current.longPressTriggered=!0,P.current.suppressTap=!0,ce())},Te)}E.current&&j.current.scale>1&&(E.current.style.cursor=`grabbing`);return}z(),P.current&&(P.current.suppressTap=!0,P.current.longPressTriggered=!1);let n=Array.from(N.current.values()).slice(0,2).map(e=>e.point),r=n[1].x-n[0].x,i=n[1].y-n[0].y;F.current={distance:Math.max(1,Math.hypot(r,i)),midpoint:{x:(n[0].x+n[1].x)/2,y:(n[0].y+n[1].y)/2},transform:j.current},P.current&&(P.current.suppressTap=!0)}),Q=l(e=>{if(!N.current.has(e.pointerId))return;e.preventDefault();let t={x:e.clientX,y:e.clientY};if(N.current.set(e.pointerId,{point:t,pointerType:e.pointerType}),N.current.size>=2&&F.current){z();let e=Array.from(N.current.values()).slice(0,2).map(e=>e.point),t=e[1].x-e[0].x,n=e[1].y-e[0].y,r={x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},i=F.current.transform.scale*Math.hypot(t,n)/F.current.distance;J(ge(F.current.transform,F.current.midpoint,r,i,Y(),M.current));return}let n=P.current;if(!n||n.pointerId!==e.pointerId)return;let r={x:t.x-n.start.x,y:t.y-n.start.y};Math.hypot(r.x,r.y)>10&&(n.moved=!0,z()),n.transform.scale>1.01&&J(he(n.transform,r,M.current))}),De=l((e,r)=>{let i=P.current,a=N.current.get(e.pointerId)?{x:e.clientX,y:e.clientY}:void 0;if(N.current.delete(e.pointerId),i?.pointerId===e.pointerId&&(z(),a&&!i.longPressTriggered)){let e=fe({isMobile:n,pointerType:i.pointerType,cancelled:r,moved:i.moved||Math.hypot(a.x-i.start.x,a.y-i.start.y)>10,suppressTap:i.suppressTap,targetWasCanvas:i.targetWasCanvas,start:i.start,end:a,startScale:i.transform.scale,hasMultipleImages:G});if(e===`next`&&K(),e===`previous`&&le(),e===`close`){if(te())return;if(n&&i.pointerType!==`mouse`){ye(a,()=>t(!1));return}t(!1)}}if(N.current.size===1){let[e,t]=Array.from(N.current.entries())[0];P.current={pointerId:e,pointerType:t.pointerType,start:t.point,transform:j.current,moved:!1,targetWasCanvas:!1,suppressTap:!0,longPressTimer:null,longPressTriggered:!1},F.current=null}else N.current.size===0&&(P.current=null,F.current=null,E.current&&(E.current.style.cursor=j.current.scale>1?`grab`:`zoom-in`));e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)}),Oe=l(e=>{e.preventDefault(),e.stopPropagation(),ce()}),ke=l(e=>{let t=e.currentTarget;t.naturalWidth>0&&t.naturalHeight>0&&y(e=>e?.width===t.naturalWidth&&e.height===t.naturalHeight?e:{width:t.naturalWidth,height:t.naturalHeight}),x(!0)});if(!S||!B||typeof document>`u`)return null;let Ae=i?.currentTheme.metadata.variant===`dark`,je=Ae?`border-foreground/15 bg-foreground/10 text-foreground`:`border-background/15 bg-background/10 text-background`,$=Ae?`text-foreground hover:bg-foreground/15 hover:text-foreground`:`text-background hover:bg-background/15 hover:text-background`;return(0,H.jsxs)(`div`,{ref:ee,className:`absolute inset-0 overflow-hidden select-none`,tabIndex:-1,onClick:Ce,children:[(0,H.jsx)(Se,{onClose:()=>t(!1),isMobile:n,size:q}),(0,H.jsxs)(`div`,{ref:E,className:`absolute inset-0 flex items-center justify-center overflow-hidden touch-none [overscroll-behavior:none]`,onDoubleClick:n?void 0:xe,onContextMenu:Oe,onPointerDown:we,onPointerMove:Q,onPointerUp:e=>De(e,!1),onPointerCancel:e=>De(e,!0),onLostPointerCapture:e=>De(e,!0),children:[!b&&!ae&&(0,H.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center`,role:`status`,children:(0,H.jsx)(D,{className:`aspect-square w-64 max-w-[80vw] rounded-xl`})}),ae?(0,H.jsx)(`p`,{role:`status`,className:`px-6 text-center typography-ui-label`,children:r(`filesView.error.readFileFailed`)}):(0,H.jsx)(`img`,{ref:k,"data-preview-transition-target":``,"data-preview-return":B?.url===e.image?.url,src:W||void 0,alt:se??``,className:d(`block max-w-none object-contain will-change-transform`,b?`opacity-100`:`opacity-0`),style:{width:`${q.width}px`,height:`${q.height}px`},loading:`lazy`,draggable:!1,onLoad:ke,onError:oe})]}),(0,H.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 z-10 flex justify-center px-2 pb-2`,children:(0,H.jsxs)(`div`,{className:d(`pointer-events-auto flex h-10 items-center gap-0.5 rounded-full border px-1 shadow-lg backdrop-blur-xl`,je),onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:[G&&(0,H.jsx)(f,{variant:`ghost`,size:`icon`,className:d(`size-8 rounded-full`,$),onClick:le,"aria-label":r(`chat.toolOutputDialog.image.previousAria`),title:r(`chat.toolOutputDialog.image.previousAria`),children:(0,H.jsx)(_,{name:`arrow-left-s`,className:`size-5`})}),G&&(0,H.jsxs)(`span`,{className:`min-w-10 px-1 text-center typography-micro tabular-nums opacity-80`,children:[s+1,` / `,o.length]}),G&&(0,H.jsx)(f,{variant:`ghost`,size:`icon`,className:d(`size-8 rounded-full`,$),onClick:K,"aria-label":r(`chat.toolOutputDialog.image.nextAria`),title:r(`chat.toolOutputDialog.image.nextAria`),children:(0,H.jsx)(_,{name:`arrow-right-s`,className:`size-5`})}),G&&(0,H.jsx)(`span`,{className:`mx-0.5 h-4 w-px bg-current opacity-15`,"aria-hidden":`true`}),(0,H.jsx)(f,{variant:`ghost`,size:`icon`,className:d(`size-8 rounded-full`,$),onClick:()=>Z(j.current.scale/1.4,Y(),!0),"aria-label":r(`chat.toolOutputDialog.image.zoomOutAria`),title:r(`chat.toolOutputDialog.image.zoomOutAria`),children:(0,H.jsx)(_,{name:`subtract`,className:`size-4`})}),(0,H.jsxs)(f,{variant:`ghost`,size:`sm`,className:d(`h-8 min-w-14 rounded-full px-2 tabular-nums`,$),onClick:()=>de(!0),"aria-label":r(`chat.toolOutputDialog.image.resetZoomAria`),title:r(`chat.toolOutputDialog.image.resetZoomAria`),children:[(0,H.jsx)(_,{name:`restart`,className:`size-3.5`}),(0,H.jsx)(`span`,{ref:A,children:`100%`})]}),(0,H.jsx)(f,{variant:`ghost`,size:`icon`,className:d(`size-8 rounded-full`,$),onClick:()=>Z(j.current.scale*1.4,Y(),!0),"aria-label":r(`chat.toolOutputDialog.image.zoomInAria`),title:r(`chat.toolOutputDialog.image.zoomInAria`),children:(0,H.jsx)(_,{name:`add`,className:`size-4`})})]})})]})},Fe=V.memo(e=>{let t=(0,B.c)(7),{popup:n,diffViewMode:r,pierreThemeConfig:i}=e,a=n.content||``,o=r===`unified`?`unified`:`split`,s;t[0]!==i.theme||t[1]!==i.themeType||t[2]!==o?(s={diffStyle:o,diffIndicators:`none`,hunkSeparators:`line-info-basic`,lineDiffType:`none`,disableFileHeader:!0,maxLineDiffLength:1e3,expansionLineCount:20,overflow:`wrap`,theme:i.theme,themeType:i.themeType,unsafeCSS:Ae},t[0]=i.theme,t[1]=i.themeType,t[2]=o,t[3]=s):s=t[3];let l;return t[4]!==a||t[5]!==s?(l=(0,H.jsx)(`div`,{className:`typography-code`,children:(0,H.jsx)(c,{patch:a,metrics:je,options:s,className:`block w-full`})}),t[4]=a,t[5]=s,t[6]=l):l=t[6],l});Fe.displayName=`DialogUnifiedDiff`;var Ie=V.memo(e=>{let t=(0,B.c)(29),{popup:n,pierreThemeConfig:r}=e,i;t[0]===n.content?i=t[1]:(i=M(n.content),t[0]=n.content,t[1]=i);let a=i,o=n.metadata?.input,c;t[2]===o?c=t[3]:(c=typeof o==`object`&&o?o:{},t[2]=o,t[3]=c);let l=c,u=typeof l.offset==`number`?l.offset:0,d=typeof l.file_path==`string`?l.file_path:typeof l.filePath==`string`?l.filePath:typeof l.path==`string`?l.path:`read-output`,f;t[4]===a.lines?f=t[5]:(f=a.lines.map(ze).join(`
|
|
10
|
-
`),t[4]=a.lines,t[5]=f);let p=f,m;t[6]!==d||t[7]!==n.language?(m=n.language||C(d)||`text`,t[6]=d,t[7]=n.language,t[8]=m):m=t[8];let h=m,g;t[9]===a.lines?g=t[10]:(g=a.lines.some(Be),t[9]=a.lines,t[10]=g);let _=g,v;if(t[11]!==_||t[12]!==u||t[13]!==a.lines||t[14]!==a.type){v=[];let e=u;for(let t of a.lines){t.lineNumber!==null&&(e=t.lineNumber);let n=a.type===`file`&&!_&&t.lineNumber===null&&!t.isInfo,r=t.lineNumber??(n?e+1:null);typeof r==`number`&&(e=r),v.push({text:t.text,lineNumber:r,isInfo:t.isInfo})}t[11]=_,t[12]=u,t[13]=a.lines,t[14]=a.type,t[15]=v}else v=t[15];let y=v;if(a.type===`file`){let e=h||void 0,n;t[16]!==p||t[17]!==d||t[18]!==e?(n={name:d,contents:p,lang:e},t[16]=p,t[17]=d,t[18]=e,t[19]=n):n=t[19];let i;t[20]!==r.theme||t[21]!==r.themeType?(i={disableFileHeader:!0,overflow:`wrap`,theme:r.theme,themeType:r.themeType},t[20]=r.theme,t[21]=r.themeType,t[22]=i):i=t[22];let a;return t[23]!==n||t[24]!==i?(a=(0,H.jsx)(s,{file:n,options:i,className:`block w-full`}),t[23]=n,t[24]=i,t[25]=a):a=t[25],a}let b;return t[26]!==y||t[27]!==h?(b=(0,H.jsx)(ne,{lines:y,language:h,maxHeight:`70vh`}),t[26]=y,t[27]=h,t[28]=b):b=t[28],b});Ie.displayName=`DialogReadContent`;var Le=({popup:e,onOpenChange:n,isMobile:r})=>{let{t:i}=u(),a=g(),o=V.useMemo(()=>a?.currentTheme.metadata.variant===`dark`?a.currentTheme:a?.availableThemes.find(e=>e.metadata.id===a.darkThemeId&&e.metadata.variant===`dark`)??y(!0),[a?.currentTheme,a?.availableThemes,a?.darkThemeId]),[s,c]=V.useState(e.mermaid?.source||``),[l,d]=V.useState(e.mermaid?.source?`ready`:`idle`),[f,p]=V.useState(``),m=V.useRef(0),h=V.useCallback(e=>{let t=e.trim();if(!t.toLowerCase().startsWith(`file://`))return null;let n=e=>{if(!e||/[\0\r\n]/.test(e))return!1;let t=e.replace(/\\/g,`/`);return t.split(`/`).filter(Boolean).includes(`..`)?!1:t.startsWith(`/`)?!0:/^[A-Za-z]:\//.test(t)},r=e=>e.replace(/%([0-9A-Fa-f]{2})/g,(e,t)=>{let n=Number.parseInt(t,16);return Number.isFinite(n)?String.fromCharCode(n):`%${t}`});if(typeof URL.canParse==`function`&&URL.canParse(t)){let e=r(new URL(t).pathname||``);return/^\/[A-Za-z]:\//.test(e)&&(e=e.slice(1)),n(e)?e:null}let i=t.replace(/^file:\/\//i,``),a=r(i);return n(a)?a:n(i)?i:null},[]),v=V.useCallback(async()=>{let n=e.mermaid,r=le(m.current);if(m.current=r,!n?.url){d(`error`),p(i(`chat.toolOutputDialog.mermaid.missingSource`));return}if(n.source){c(n.source),d(`ready`),p(``);return}d(`loading`),p(``);let a;if(n.url.startsWith(`data:`))a=ue(n.url);else if(n.url.toLowerCase().startsWith(`file://`)){let e=h(n.url);a=e?t(`/api/fs/raw`,{query:{path:e}}).then(e=>e.ok?e.text():Promise.reject(Q(`chat.toolOutputDialog.mermaid.readFileFailedWithStatus`,{status:e.status}))):Promise.reject(Q(`chat.toolOutputDialog.mermaid.invalidLocalPath`))}else{let e=typeof URL.canParse==`function`&&URL.canParse(n.url,window.location.origin)?new URL(n.url,window.location.origin):null;a=!e||e.protocol!==`http:`&&e.protocol!==`https:`?Promise.reject(Q(`chat.toolOutputDialog.mermaid.unsupportedUrlProtocol`)):fetch(e.toString()).then(e=>e.ok?e.text():Promise.reject(Q(`chat.toolOutputDialog.mermaid.loadFailedWithStatus`,{status:e.status})))}await a.then(e=>{K(m.current,r)&&(c(e),d(`ready`))}).catch(e=>{K(m.current,r)&&(d(`error`),p(ce(e)?i(e.key,e.params):i(`chat.toolOutputDialog.mermaid.loadFailed`)))})},[h,e.mermaid,i]);V.useEffect(()=>{!e.open||!e.mermaid||v()},[v,e.mermaid,e.open]);let b=`\`\`\`mermaid\n${s}\n\`\`\``;return!e.open||typeof document>`u`?null:(0,H.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,onClick:e=>{e.target===e.currentTarget&&n(!1)},children:(0,H.jsxs)(`div`,{"data-mermaid-preview":`true`,"data-preview-transition-target":``,className:`relative flex min-h-0 flex-col overflow-hidden`,style:{width:r?`100%`:`80%`,height:r?`100%`:`95%`},onMouseDown:e=>e.stopPropagation(),children:[(0,H.jsx)(Se,{onClose:()=>n(!1),isMobile:r}),(0,H.jsx)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:(0,H.jsxs)(`div`,{className:`h-full overflow-hidden`,children:[l===`loading`&&(0,H.jsxs)(`div`,{className:`h-full min-h-28 flex items-center justify-center gap-2 text-muted-foreground typography-meta`,children:[(0,H.jsx)(_,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),(0,H.jsx)(`span`,{children:i(`chat.toolOutputDialog.mermaid.loading`)})]}),l===`error`&&(0,H.jsxs)(`div`,{className:`rounded-xl border p-3 space-y-3`,style:{backgroundColor:`var(--status-error-background)`,borderColor:`var(--status-error-border)`},children:[(0,H.jsx)(`p`,{className:`typography-markdown`,style:{color:`var(--status-error)`},children:f||i(`chat.toolOutputDialog.mermaid.renderFailed`)}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>{v()},className:`px-3 py-1.5 rounded-lg typography-meta border transition-colors hover:bg-[var(--interactive-hover)]`,style:{borderColor:`var(--interactive-border)`,color:`var(--surface-foreground)`},children:i(`chat.toolOutputDialog.mermaid.retry`)})]}),l===`ready`&&(0,H.jsx)(`div`,{className:`h-full`,children:(0,H.jsx)(S,{content:b,variant:`tool`,allowMermaidWheelEvents:!0,className:`markdown-mermaid-fullscreen h-full`,mermaidControls:ke,mermaidTheme:o,enableFileReferences:!1})})]})})]})})},Re=e=>{let t=(0,B.c)(51),{popup:n,onOpenChange:r,isMobile:i}=e,{t:o}=u(),[c,l]=V.useState(`unified`),f=$(),h;t[0]===n.open?h=t[1]:(h=()=>{n.open&&l(`unified`)},t[0]=n.open,t[1]=h);let g;if(t[2]!==n.open||t[3]!==n.title?(g=[n.open,n.title],t[2]=n.open,t[3]=n.title,t[4]=g):g=t[4],V.useEffect(h,g),n.image||n.mermaid){let e=n.image?`image`:`mermaid`,a;t[5]!==i||t[6]!==n?(a=e=>n.image?(0,H.jsx)(Pe,{popup:n,onOpenChange:e,isMobile:i}):(0,H.jsx)(Le,{popup:n,onOpenChange:e,isMobile:i}),t[5]=i,t[6]=n,t[7]=a):a=t[7];let o;return t[8]!==i||t[9]!==r||t[10]!==n.open||t[11]!==n.previewSource||t[12]!==n.title||t[13]!==e||t[14]!==a?(o=(0,H.jsx)(Ce,{open:n.open,title:n.title,kind:e,source:n.previewSource,isMobile:i,onOpenChange:r,children:a}),t[8]=i,t[9]=r,t[10]=n.open,t[11]=n.previewSource,t[12]=n.title,t[13]=e,t[14]=a,t[15]=o):o=t[15],o}let v=n.open,y=i?`w-[95vw] max-w-[95vw]`:`max-w-5xl`,b=i?`[&>button]:right-1`:`[&>button]:top-2.5 [&>button]:right-4`,x;t[16]!==y||t[17]!==b?(x=d(`overflow-hidden flex flex-col min-h-0 pt-3 pb-4 px-4 gap-1`,`[&>button]:top-1.5`,y,b),t[16]=y,t[17]=b,t[18]=x):x=t[18];let w;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(w={maxHeight:`90vh`},t[19]=w):w=t[19];let T;t[20]===n.metadata?T=t[21]:(T=n.metadata?.tool?De(n.metadata.tool):(0,H.jsx)(_,{name:`tools`,className:`h-3.5 w-3.5 text-foreground flex-shrink-0`}),t[20]=n.metadata,t[21]=T);let E;t[22]===n.title?E=t[23]:(E=(0,H.jsx)(`span`,{className:`break-words flex-1 leading-tight`,children:n.title}),t[22]=n.title,t[23]=E);let D;t[24]!==c||t[25]!==n.isDiff?(D=n.isDiff&&(0,H.jsx)(P,{mode:c,onModeChange:l,className:`mr-8 flex-shrink-0`}),t[24]=c,t[25]=n.isDiff,t[26]=D):D=t[26];let O;t[27]!==D||t[28]!==T||t[29]!==E?(O=(0,H.jsx)(`div`,{className:`flex-shrink-0 pb-1`,children:(0,H.jsxs)(`div`,{className:`flex items-start gap-2 text-foreground typography-ui-header font-semibold`,children:[T,E,D]})}),t[27]=D,t[28]=T,t[29]=E,t[30]=O):O=t[30];let M;t[31]!==f||t[32]!==n.metadata?(M=n.metadata?.input&&typeof n.metadata.input==`object`&&Object.keys(n.metadata.input).length>0&&n.metadata?.tool!==`todowrite`&&n.metadata?.tool!==`todoread`&&n.metadata?.tool!==`apply_patch`?(()=>{let e=n.metadata,t=e.input,r=e=>{let n=t[e];return typeof n==`string`?n:typeof n==`number`?String(n):null};return(0,H.jsxs)(`div`,{className:`border-b border-border/20 p-4 -mx-3`,children:[(0,H.jsx)(`div`,{className:`typography-markdown font-medium text-muted-foreground mb-2 px-3`,children:e.tool===`bash`||e.tool===`shell`?`Command:`:e.tool===`task`||e.tool===`subagent`?`Task Details:`:`Input:`}),(e.tool===`bash`||e.tool===`shell`)&&r(`command`)?(0,H.jsx)(`div`,{className:`tool-input-surface bg-transparent rounded-xl border border-border/20 mx-3`,children:(0,H.jsx)(A,{language:`bash`,code:r(`command`),style:a.getPopupStyles(),codeStyle:Oe.style,wrap:!0})}):(e.tool===`task`||e.tool===`subagent`)&&r(`prompt`)?(0,H.jsxs)(`div`,{className:`tool-input-surface bg-transparent rounded-xl border border-border/20 font-mono whitespace-pre-wrap text-foreground/90 mx-3`,style:a.getPopupStyles(),children:[r(`description`)?`Task: ${r(`description`)}\n`:``,r(`subagent_type`)||r(`agent`)?`Agent Type: ${r(`subagent_type`)||r(`agent`)}\n`:``,`Instructions:\n${r(`prompt`)}`]}):e.tool===`write`&&r(`content`)?(0,H.jsx)(`div`,{className:`tool-input-surface bg-transparent rounded-xl border border-border/20 mx-3`,children:(0,H.jsx)(s,{file:{name:r(`filePath`)||r(`file_path`)||`new-file`,contents:r(`content`),lang:C(r(`filePath`)||r(`file_path`)||``)||void 0},options:{disableFileHeader:!0,overflow:`wrap`,theme:f.theme,themeType:f.themeType},className:`block w-full`})}):(0,H.jsx)(`div`,{className:`tool-input-surface bg-transparent rounded-xl border border-border/20 font-mono whitespace-pre-wrap text-foreground/90 mx-3`,style:a.getPopupStyles(),children:L(t,e.tool)})]})})():null,t[31]=f,t[32]=n.metadata,t[33]=M):M=t[33];let I;t[34]!==c||t[35]!==i||t[36]!==f||t[37]!==n||t[38]!==o?(I=n.isDiff?(0,H.jsx)(Fe,{popup:n,diffViewMode:c,pierreThemeConfig:f}):n.content?(0,H.jsx)(`div`,{className:`p-4`,children:(()=>{let e=n.metadata?.tool;return e===`todowrite`||e===`todoread`?F(n.content)||(0,H.jsx)(A,{language:`json`,code:n.content,style:a.getPopupContainerStyles(),codeStyle:Oe.style,wrap:!0}):e===`list`?k(n.content)||(0,H.jsx)(`pre`,{className:`typography-markdown bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap`,children:n.content}):e===`grep`?ee(n.content,i)||(0,H.jsx)(`pre`,{className:`typography-code bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap`,children:n.content}):e===`glob`?te(n.content,i)||(0,H.jsx)(`pre`,{className:`typography-code bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap`,children:n.content}):e===`task`||e===`subagent`||e===`reasoning`?(0,H.jsx)(`div`,{className:e===`reasoning`?`text-muted-foreground/70`:``,children:(0,H.jsx)(S,{content:n.content,variant:`tool`})}):e===`web-search`||e===`websearch`||e===`search_web`?N(n.content)||(0,H.jsx)(A,{language:`text`,code:n.content,style:a.getPopupContainerStyles(),codeStyle:Oe.style,wrap:!0}):e===`read`?(0,H.jsx)(Ie,{popup:n,pierreThemeConfig:f}):(n.content?j(n.content):{data:null,isJson:!1}).isJson?(0,H.jsx)(oe,{jsonString:n.content,initiallyExpandedDepth:3,maxHeight:`70vh`}):(0,H.jsx)(A,{language:n.language||`text`,code:n.content,style:a.getPopupContainerStyles(),codeStyle:Oe.style,wrap:!0})})()}):(0,H.jsxs)(`div`,{className:`p-8 text-muted-foreground typography-ui-header`,children:[(0,H.jsx)(`div`,{className:`mb-2`,children:o(`chat.toolOutputDialog.commandCompleted`)}),(0,H.jsx)(`div`,{className:`typography-meta`,children:o(`chat.toolOutputDialog.noOutputProduced`)})]}),t[34]=c,t[35]=i,t[36]=f,t[37]=n,t[38]=o,t[39]=I):I=t[39];let R;t[40]!==M||t[41]!==I?(R=(0,H.jsx)(`div`,{className:`flex-1 min-h-0 rounded-xl border border-border/30 bg-muted/10 overflow-hidden`,children:(0,H.jsxs)(`div`,{className:`tool-output-surface h-full max-h-[75vh] overflow-y-auto px-3 pr-4`,children:[M,I]})}),t[40]=M,t[41]=I,t[42]=R):R=t[42];let z;t[43]!==O||t[44]!==R||t[45]!==x?(z=(0,H.jsxs)(m,{className:x,style:w,children:[O,R]}),t[43]=O,t[44]=R,t[45]=x,t[46]=z):z=t[46];let U;return t[47]!==r||t[48]!==n.open||t[49]!==z?(U=(0,H.jsx)(p,{open:v,onOpenChange:r,children:z}),t[47]=r,t[48]=n.open,t[49]=z,t[50]=U):U=t[50],U};function ze(e){return e.text}function Be(e){return e.lineNumber!==null}export{Re as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./rolldown-runtime-hePW80VL.js";import{D as e,F as t,I as n,L as r,P as i,a,i as o,it as s,rt as c}from"./vendor-base-ui-CdzJ6My_.js";import{n as l}from"./vendor-react-BP2cRVqX.js";import{r as u}from"./button-kJNzMb1G.js";import{n as d,r as f,t as p}from"./dropdown-menu.styles-BXvVFEkh.js";var m=l();s();var h=c();function g(e){let t=(0,m.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,h.jsx)(a,{...n}),t[2]=n,t[3]=r),r}function _(e){let t=(0,m.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,h.jsx)(o,{...n}),t[2]=n,t[3]=r),r}function v(e){let r=(0,m.c)(20),a,o,s,c,l;r[0]===e?(a=r[1],o=r[2],s=r[3],c=r[4],l=r[5]):({className:o,positionerClassName:s,children:a,style:l,...c}=e,r[0]=e,r[1]=a,r[2]=o,r[3]=s,r[4]=c,r[5]=l);let f;r[6]===s?f=r[7]:(f=u(`app-region-no-drag z-50`,s),r[6]=s,r[7]=f);let p;r[8]===l?p=r[9]:(p={backgroundColor:`var(--surface-elevated)`,color:`var(--surface-elevated-foreground)`,...l},r[8]=l,r[9]=p);let g;r[10]===o?g=r[11]:(g=u(d,o),r[10]=o,r[11]=g);let _;r[12]!==a||r[13]!==c||r[14]!==p||r[15]!==g?(_=(0,h.jsx)(n,{"data-slot":`dropdown-menu-content`,style:p,className:g,...c,children:a}),r[12]=a,r[13]=c,r[14]=p,r[15]=g,r[16]=_):_=r[16];let v;return r[17]!==f||r[18]!==_?(v=(0,h.jsx)(t,{children:(0,h.jsx)(i,{className:f,children:_})}),r[17]=f,r[18]=_,r[19]=v):v=r[19],v}function y(e){let t=(0,m.c)(8),n,i;t[0]===e?(n=t[1],i=t[2]):({className:n,...i}=e,t[0]=e,t[1]=n,t[2]=i);let a;t[3]===n?a=t[4]:(a=u(p,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,h.jsx)(r,{className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function b(t){let n=(0,m.c)(8),r,i;n[0]===t?(r=n[1],i=n[2]):({className:r,...i}=t,n[0]=t,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=u(f,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,h.jsx)(e,{className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}export{_ as a,b as i,v as n,y as r,g as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{p as t}from"./runtime-auth-C8w0nlKy.js";import{c as n,f as r,i}from"./runtime-switch-3ad3yzM7.js";import{n as a}from"./runtime-fetch-QCWYlAx0.js";import{it as o}from"./vendor-base-ui-CdzJ6My_.js";import{St as s}from"./platform-z2erC6Bs.js";import{n as c}from"./vendor-react-BP2cRVqX.js";import{n as l}from"./vendor-reactuses-core-BpfIZ1tg.js";import{f as u}from"./button-kJNzMb1G.js";var d=e(o(),1);async function f(e,t){let n=i(),r=await a(`/api/voice/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({kind:e}),signal:AbortSignal.any([t,AbortSignal.timeout(2e4)])});if(t.throwIfAborted(),n!==i())throw Error(`Speech runtime changed`);if(r.status===404||r.ok&&r.headers.get(`content-type`)?.includes(`text/html`))return await r.body?.cancel(),null;if(!r.ok)throw await r.body?.cancel(),Error(`Unable to create speech session`);let o=await r.json();if(t.throwIfAborted(),n!==i())throw Error(`Speech runtime changed`);if(o?.transport===`host`)return null;if(o?.transport!==`volcengine-direct`||typeof o.token!=`string`||o.token.length>16384||!/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(o.token)||typeof o.appId!=`string`||!/^[A-Za-z0-9_-]{1,128}$/.test(o.appId)||typeof o.resourceId!=`string`||!/^[A-Za-z0-9._-]{1,128}$/.test(o.resourceId)||!Number.isFinite(o.expiresAt)||o.expiresAt<=Date.now()+5e3||o.expiresAt>Date.now()+36e4||e===`tts`&&(typeof o.voice!=`string`||!/^[A-Za-z0-9_-]{1,200}$/.test(o.voice)||!Number.isFinite(o.speed)||o.speed<.5||o.speed>2||!Number.isFinite(o.pitch)||o.pitch<.5||o.pitch>2||!Number.isFinite(o.volume)||o.volume<0||o.volume>1)||e===`asr`&&o.asrContext!==void 0&&(typeof o.asrContext!=`string`||o.asrContext.length>2e3||/\0/.test(o.asrContext)))throw Error(`Invalid speech session`);return o}function p(e,t){let n=new URL(t===`asr`?`wss://openspeech.bytedance.com/api/v3/sauc/bigmodel_async`:`wss://openspeech.bytedance.com/api/v3/tts/bidirection`);return n.search=new URLSearchParams({api_app_key:e.appId,api_access_key:`Jwt; ${e.token}`,api_resource_id:e.resourceId}).toString(),n.toString()}var m=new TextEncoder,h=new TextDecoder,g=1048576;function _(e,t=!1,n=!1){let r=new Uint8Array(8+e.length);return r.set([17,(t?2:1)<<4|(n?2:0),t?0:16,0]),new DataView(r.buffer).setUint32(4,e.length),r.set(e,8),r}function v(e,t=``,n={}){let r=m.encode(t),i=m.encode(JSON.stringify(n)),a=new Uint8Array(12+i.length+(t?4+r.length:0));a.set([17,20,16,0]);let o=new DataView(a.buffer);o.setInt32(4,e);let s=8;return t&&(o.setUint32(s,r.length),a.set(r,s+4),s+=4+r.length),o.setUint32(s,i.length),a.set(i,s+4),a}async function y(e,t){if(e.byteLength<8||e.byteLength>g)throw Error(`Invalid speech frame size`);let n=new Uint8Array(e),r=new DataView(e),i=n[1]>>4,a=n[1]&15,o=n[2]&15,s=(n[0]&15)*4;if(n[0]>>4!=1||s<4||s>n.length-4)throw Error(`Invalid speech frame`);let c=()=>{if(s+4>n.length)throw Error(`Truncated speech frame`);let e=r.getUint32(s);return s+=4,e};if(i===15)throw Error(`Speech provider failed (code ${c()})`);if(i!==9&&(t!==`tts`||i!==11))throw Error(`Unexpected speech frame`);a&1&&c();let l=0,u=``;if(a&4&&(l=c(),t===`tts`)){let e=c();if(e>256||s+e>n.length)throw Error(`Invalid speech session ID`);u=h.decode(n.subarray(s,s+e)),s+=e}let d=c();if(s+d!==n.length)throw Error(`Truncated speech payload`);let f=n.slice(s);if(o===1){let e=new Blob([f]).stream().pipeThrough(new DecompressionStream(`gzip`)).getReader(),t=[],n=0;try{for(;;){let r=await e.read();if(r.done)break;if(n+=r.value.length,n>g)throw Error(`Speech payload exceeds size limit`);t.push(r.value)}}finally{await e.cancel().catch(()=>void 0),e.releaseLock()}f=new Uint8Array(n);let r=0;for(let e of t)f.set(e,r),r+=e.length}else if(o!==0)throw Error(`Unsupported speech compression`);return{type:i,event:l,sessionId:u,final:!!(a&2),payload:f}}function b(e){let t=JSON.parse(h.decode(e));if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Invalid speech response`);return t}async function x(e,t){t.throwIfAborted();let n=new WebSocket(e);n.binaryType=`arraybuffer`;let r=[],i=0,a=null,o=null,s=null,c=(e=!0)=>{t.removeEventListener(`abort`,u),n.onmessage=null,n.onclose=null,n.onerror=null,n.onopen=null,e&&(r.length=0,i=0),n.close(),o?.()},l=(e,t=!0)=>{a??=e,s?.(a),c(t)},u=()=>l(new DOMException(`Speech cancelled`,`AbortError`));t.addEventListener(`abort`,u,{once:!0}),n.onmessage=e=>{if(!(e.data instanceof ArrayBuffer)||e.data.byteLength>g){l(Error(`Invalid speech message`));return}if(i+=e.data.byteLength,i>33554432||r.length>=4096){l(Error(`Speech receive buffer exceeded`));return}r.push(e.data),o?.()},n.onerror=()=>l(Error(`Speech connection failed`)),n.onclose=()=>l(Error(`Speech connection ended before completion`),!1);let d=setTimeout(()=>l(Error(`Speech connection timed out`)),1e4);try{await new Promise((e,t)=>{s=t,n.onopen=()=>e()})}finally{clearTimeout(d),s=null}return{send(e){if(t.throwIfAborted(),a)throw a;if(n.readyState!==WebSocket.OPEN||n.bufferedAmount+e.length>g)throw Error(`Speech send buffer exceeded`);n.send(e)},async read(){let e=setTimeout(()=>l(Error(`Speech response timed out`)),6e4);try{for(;!r.length&&!a;)await new Promise(e=>{o=e});if(t.throwIfAborted(),!r.length&&a)throw a;let e=r.shift();return i-=e.byteLength,e}finally{clearTimeout(e),o=null}},close(){a??=new DOMException(`Speech closed`,`AbortError`),c()}}}var S=class{abort;partial;disconnected;socket=null;failure=null;completion=null;text=``;final=!1;finishing=!1;sequence=0;constructor(e,t,n){this.abort=e,this.partial=t,this.disconnected=n}get connected(){return this.socket!==null&&!this.failure&&!this.abort.signal.aborted}async start(e,t){if(t!==`audio/pcm;rate=16000;bits=16`)throw Error(`Direct speech requires 16 kHz PCM16 audio`);let n=await x(p(e,`asr`),this.abort.signal);this.socket=n;try{n.send(_(new TextEncoder().encode(JSON.stringify({user:{uid:`openchamber`},audio:{format:`pcm`,codec:`raw`,rate:16e3,bits:16,channel:1},request:{model_name:`bigmodel`,result_type:`full`,enable_itn:!0,enable_punc:!0,enable_nonstream:!0,show_utterances:!0,...e.asrContext?.trim()?{corpus:{context:JSON.stringify({context_type:`dialog_ctx`,context_data:[{text:e.asrContext.trim()}]})}}:{}}}))))}catch(e){throw n.close(),e}this.completion=this.receive().catch(e=>{this.failure=e instanceof Error?e:Error(`Speech recognition failed`),n.close(),!this.abort.signal.aborted&&!this.finishing&&this.disconnected()})}send(e,t){if(!this.connected||this.finishing||this.final||e!==this.sequence)return!1;try{if(t.length>128e3)throw Error(`Speech audio chunk exceeds size limit`);let e=atob(t);if(e.length%2)throw Error(`Invalid PCM audio`);let n=Uint8Array.from(e,e=>e.charCodeAt(0));return this.socket.send(_(n,!0)),this.sequence++,!0}catch{return this.failure=Error(`Unable to send speech audio`),this.socket?.close(),!1}}async finish(e){if(this.failure)throw this.failure;if(!this.socket||e!==this.sequence-1)throw Error(`Incomplete speech audio`);this.finishing=!0,this.socket.send(_(new Uint8Array,!0,!0));let t=setTimeout(()=>{this.failure=Error(`Speech finalization timed out`),this.socket?.close()},3e4);try{if(await this.completion,this.abort.signal.throwIfAborted(),this.failure)throw this.failure;if(!this.final)throw Error(`Incomplete speech recognition`);return{text:this.text}}finally{clearTimeout(t),this.socket.close()}}cancel(){this.abort.abort(),this.socket?.close()}async receive(){for(;;){let e=await y(await this.socket.read(),`asr`);this.abort.signal.throwIfAborted();let t=b(e.payload);if(t.code!==void 0&&![0,1e3,2e7].includes(Number(t.code)))throw Error(`Speech recognition failed`);let n=t.result;if(n!==void 0&&(!n||typeof n!=`object`||Array.isArray(n)))throw Error(`Invalid speech transcript`);if(n&&typeof n==`object`&&`text`in n){if(typeof n.text!=`string`)throw Error(`Invalid speech transcript`);this.text=n.text,e.final||this.partial(this.text)}if(e.final){if(!this.finishing)throw Error(`Speech recognition ended unexpectedly`);this.final=!0;return}}}},C=(e,t,n)=>{let r=Error(e);return r.name=`DictationStreamError`,r.retryable=t,n&&(r.reasonCode=n),r},w=1e4,T=15e3,E=3e4,D=3e4,O=new class{socket=null;connectPromise=null;idleCloseTimer=null;pendingStarts=new Map;pendingFinishes=new Map;connectionListeners=new Set;partialListeners=new Set;activeDictations=0;directStarts=new Map;directSessions=new Map;get isConnected(){if(this.socket?.readyState===WebSocket.OPEN)return!0;for(let e of this.directSessions.values())if(e.connected)return!0;return!1}subscribeConnectionStatus(e){return this.connectionListeners.add(e),()=>{this.connectionListeners.delete(e)}}onPartial(e){return this.partialListeners.add(e),()=>{this.partialListeners.delete(e)}}async ensureConnected(){if(this.socket?.readyState!==WebSocket.OPEN){if(this.connectPromise){await this.connectPromise;return}try{await t()}catch{}this.connectPromise=new Promise((e,t)=>{let n=!1,i;try{let e=r().websocket(`/api/dictation/ws`);i=s(e)}catch(e){this.connectPromise=null,t(e instanceof Error?e:Error(String(e)));return}let a=setTimeout(()=>{if(!n){n=!0,this.connectPromise=null;try{i.close()}catch{}t(Error(`Dictation connection timed out`))}},w);i.onopen=()=>{},i.onmessage=t=>{let r;try{r=JSON.parse(String(t.data))}catch{return}if(!n&&r.type===`ready`){n=!0,clearTimeout(a),this.socket=i,this.connectPromise=null,this.notifyConnection(!0),e();return}this.handleMessage(r)},i.onerror=()=>{window.setTimeout(()=>{n||(n=!0,clearTimeout(a),this.connectPromise=null,t(Error(`Dictation connection failed`)))},250)},i.onclose=e=>{if(!n){n=!0,clearTimeout(a),this.connectPromise=null;let r=e?.reason?`: ${e.reason}`:``;t(Error(`Dictation connection failed${r}`));return}this.socket===i&&(this.socket=null,this.rejectAllPending(Error(`Dictation connection lost`)),this.notifyConnection(!1))}}),await this.connectPromise}}async startDictationStream(e,t){let n=new AbortController;this.directStarts.set(e,n);try{let r=await f(`asr`,n.signal);if(n.signal.throwIfAborted(),r){let i=new S(n,t=>{for(let n of this.partialListeners)n(e,t)},()=>{this.directSessions.delete(e),i.cancel(),this.notifyConnection(!1)});this.directSessions.set(e,i),await i.start(r,t),n.signal.throwIfAborted(),this.notifyConnection(!0);return}await this.ensureConnected(),n.signal.throwIfAborted()}catch(t){throw this.directSessions.get(e)?.cancel(),this.directSessions.delete(e),t}finally{this.directStarts.delete(e)}return this.activeDictations+=1,this.clearIdleCloseTimer(),new Promise((n,r)=>{let i=setTimeout(()=>{this.pendingStarts.delete(e),this.releaseDictation(),r(Error(`Dictation start timed out`))},T);this.pendingStarts.set(e,{resolve:()=>{clearTimeout(i),n()},reject:e=>{clearTimeout(i),this.releaseDictation(),r(e)},timeout:i}),this.send({type:`start`,dictationId:e,format:t})||(clearTimeout(i),this.pendingStarts.delete(e),this.releaseDictation(),r(Error(`Dictation connection lost`)))})}sendDictationStreamChunk(e,t,n){let r=this.directSessions.get(e);return r?r.send(t,n):this.send({type:`chunk`,dictationId:e,seq:t,audio:n})}finishDictationStream(e,t){let n=this.directSessions.get(e);return n?n.finish(t).finally(()=>{n.cancel(),this.directSessions.delete(e)}):new Promise((n,r)=>{let i={resolve:e=>{i.timeout&&clearTimeout(i.timeout),this.releaseDictation(),n(e)},reject:e=>{i.timeout&&clearTimeout(i.timeout),this.releaseDictation(),r(e)},timeout:null};i.timeout=setTimeout(()=>{this.pendingFinishes.delete(e),this.releaseDictation(),r(Error(`Timed out waiting for transcription`))},D),this.pendingFinishes.set(e,i),this.send({type:`finish`,dictationId:e,finalSeq:t})||(this.pendingFinishes.delete(e),i.reject(Error(`Dictation connection lost`)))})}cancelDictationStream(e){this.directStarts.get(e)?.abort(),this.directStarts.delete(e);let t=this.directSessions.get(e);if(t){t.cancel(),this.directSessions.delete(e);return}this.send({type:`cancel`,dictationId:e});let n=this.pendingStarts.get(e);n&&(this.pendingStarts.delete(e),n.reject(Error(`Dictation cancelled`)));let r=this.pendingFinishes.get(e);r&&(this.pendingFinishes.delete(e),r.reject(Error(`Dictation cancelled`))),this.releaseDictation(),this.scheduleIdleCloseIfReady()}handleMessage(e){let t=e.dictationId;if(t)switch(e.type){case`ack`:{let e=this.pendingStarts.get(t);e&&(this.pendingStarts.delete(t),e.resolve());return}case`partial`:for(let n of this.partialListeners)n(t,e.text??``);return;case`finish_accepted`:{let n=this.pendingFinishes.get(t);n&&typeof e.timeoutMs==`number`&&(n.timeout&&clearTimeout(n.timeout),n.timeout=setTimeout(()=>{this.pendingFinishes.delete(t),n.reject(Error(`Timed out waiting for transcription`))},e.timeoutMs+5e3));return}case`final`:{let n=this.pendingFinishes.get(t);n&&(this.pendingFinishes.delete(t),n.resolve({text:e.text??``})),this.scheduleIdleCloseIfReady();return}case`error`:{let n=C(e.error||`Dictation failed`,e.retryable!==!1,e.reasonCode),r=this.pendingStarts.get(t);r&&(this.pendingStarts.delete(t),r.reject(n));let i=this.pendingFinishes.get(t);i&&(this.pendingFinishes.delete(t),i.reject(n)),this.scheduleIdleCloseIfReady();return}}}send(e){if(!this.isConnected||!this.socket)return!1;try{return this.socket.send(JSON.stringify(e)),!0}catch{return!1}}notifyConnection(e){for(let t of this.connectionListeners)t(e)}rejectAllPending(e){for(let[t,n]of this.pendingStarts)this.pendingStarts.delete(t),n.reject(e);for(let[t,n]of this.pendingFinishes)this.pendingFinishes.delete(t),n.reject(e);this.activeDictations=0}releaseDictation(){this.activeDictations=Math.max(0,this.activeDictations-1),this.scheduleIdleCloseIfReady()}scheduleIdleCloseIfReady(){this.activeDictations>0||this.pendingFinishes.size>0||this.pendingStarts.size>0||(this.clearIdleCloseTimer(),this.idleCloseTimer=setTimeout(()=>{if(this.activeDictations===0&&this.pendingFinishes.size===0&&this.pendingStarts.size===0){let e=this.socket;if(this.socket=null,e){try{e.close(1e3,`idle`)}catch{}this.notifyConnection(!1)}}},E))}cancelAllForRuntimeSwitch(){for(let e of this.directStarts.values())e.abort();this.directStarts.clear();for(let e of this.directSessions.values())e.cancel();this.directSessions.clear(),this.clearIdleCloseTimer();let e=this.socket;if(this.socket=null,this.connectPromise=null,this.rejectAllPending(Error(`Runtime changed`)),e){try{e.close(1e3,`runtime switch`)}catch{}this.notifyConnection(!1)}}clearIdleCloseTimer(){this.idleCloseTimer&&=(clearTimeout(this.idleCloseTimer),null)}};typeof window<`u`&&window.addEventListener(`openchamber:runtime-endpoint-changed`,()=>{O.cancelAllForRuntimeSwitch()});var k=128,A=`audio/pcm;rate=16000;bits=16`,j=()=>new Promise(e=>setTimeout(e,0)),M=()=>{let e=Math.random().toString(36).slice(2,10);return`dic_${Date.now().toString(16)}${e}`},N=class{client;format;createDictationId;dictationId=null;sendSeq=0;segments=[];streamReady=!1;flushTimer=null;drainWaiters=[];startGeneration=0;startPromise=null;constructor(e){this.client=e.client,this.format=e.format??A,this.createDictationId=e.createDictationId??M}getDictationId(){return this.dictationId}getFinalSeq(){return this.segments.length-1}hasSegments(){return this.segments.length>0}clearAll(){this.dictationId&&this.client.cancelDictationStream(this.dictationId),this.clearScheduledFlush(),this.dictationId=null,this.sendSeq=0,this.segments=[],this.streamReady=!1,this.startPromise=null,this.startGeneration+=1}resetStreamForReplay(){this.dictationId&&this.client.cancelDictationStream(this.dictationId),this.clearScheduledFlush(),this.dictationId=null,this.sendSeq=0,this.streamReady=!1,this.startPromise=null,this.startGeneration+=1}enqueueSegment(e){if(this.segments.push(e),this.client.isConnected){if(!this.dictationId){this.startPromise||this.restartStream().catch(()=>{});return}this.flush()}}flush(){let e=this.dictationId;if(!this.client.isConnected||!e||!this.streamReady)return 0;let t=0;for(;this.sendSeq<this.segments.length&&t<k;){let n=this.sendSeq,r=this.segments[n];if(!this.client.sendDictationStreamChunk(e,n,r))break;this.sendSeq=n+1,t+=1}return this.hasPendingSegments()?this.scheduleFlush():this.resolveDrainWaiters(),t}async restartStream(){this.startGeneration+=1;let e=this.startGeneration,t=this.createDictationId();this.dictationId=t,this.sendSeq=0,this.streamReady=!1;let n=(async()=>{await this.client.startDictationStream(t,this.format),this.startGeneration===e&&this.dictationId===t&&(this.streamReady=!0,this.flush())})().catch(n=>{throw this.startGeneration===e&&this.dictationId===t&&(this.dictationId=null,this.streamReady=!1),n}).finally(()=>{this.startPromise===n&&(this.startPromise=null)});this.startPromise=n,await n}async finish(e){this.dictationId||await this.restartStream(),this.startPromise&&await this.startPromise;let t=this.dictationId;if(!t||!this.streamReady)throw Error(`Failed to start dictation stream`);return this.flush(),await this.waitForFlushDrain(),{dictationId:t,text:(await this.client.finishDictationStream(t,e)).text}}cancel(){this.resetStreamForReplay()}hasPendingSegments(){return this.sendSeq<this.segments.length}scheduleFlush(){this.flushTimer||=setTimeout(()=>{this.flushTimer=null,this.flush()},0)}clearScheduledFlush(){this.resolveDrainWaiters(),this.flushTimer&&=(clearTimeout(this.flushTimer),null)}async waitForFlushDrain(){for(;this.hasPendingSegments();){if(!this.client.isConnected||!this.dictationId||!this.streamReady)throw Error(`Failed to flush dictation stream`);await new Promise(e=>{this.drainWaiters.push(e)}),await j()}}resolveDrainWaiters(){let e=this.drainWaiters;this.drainWaiters=[];for(let t of e)t()}},P=c(),F=new Set;function I(e){return F.add(e),()=>{F.delete(e)}}function L(){for(let e of F)e();if(typeof window<`u`&&window.speechSynthesis?.cancel(),typeof navigator>`u`)return;let e=navigator.audioSession;if(e)try{e.type=`play-and-record`}catch{}}function R(){if(typeof navigator>`u`)return;let e=navigator.audioSession;if(e)try{e.type!==`playback`&&(e.type=`playback`)}catch{}}var z=16e3,B=z/5,V=()=>{if(typeof window>`u`)return null;let e=window;return e.AudioContext||e.webkitAudioContext||null},H=e=>{let t=Math.max(-1,Math.min(1,e));return Math.round(t<0?t*32768:t*32767)},U=(e,t,n)=>{if(e.length===0)return new Int16Array;if(t===n){let t=new Int16Array(e.length);for(let n=0;n<e.length;n++)t[n]=H(e[n]);return t}let r=t/n,i=Math.max(1,Math.round(e.length/r)),a=new Int16Array(i);for(let t=0;t<i;t++){let n=t*r,i=Math.floor(n),o=Math.min(e.length-1,i+1),s=n-i;a[t]=H(e[i]*(1-s)+e[o]*s)}return a},W=(e,t)=>{if(e.length===0)return t;if(t.length===0)return e;let n=new Int16Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n},G=e=>{let t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n=``;for(let e=0;e<t.length;e++)n+=String.fromCharCode(t[e]);return btoa(n)},K=()=>({stream:null,context:null,source:null,processor:null,gain:null,pending:new Int16Array,started:!1}),q=e=>{if(e)try{e.disconnect()}catch{}},J=()=>typeof navigator>`u`||typeof window>`u`||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!=`function`?!1:V()!==null;function Y(e){let t=(0,P.c)(16),[n,r]=(0,d.useState)(0),i=(0,d.useRef)(e.onPcmSegment),a=(0,d.useRef)(e.onError),o,s;t[0]!==e.onError||t[1]!==e.onPcmSegment?(o=()=>{i.current=e.onPcmSegment,a.current=e.onError},s=[e.onPcmSegment,e.onError],t[0]=e.onError,t[1]=e.onPcmSegment,t[2]=o,t[3]=s):(o=t[2],s=t[3]),(0,d.useEffect)(o,s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=K(),t[4]=c):c=t[4];let u=(0,d.useRef)(c),f=(0,d.useRef)(0),p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=async()=>{if(u.current.started)return;if(typeof navigator>`u`||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!=`function`)throw Error(`Microphone capture is not supported in this environment`);let e=V();if(!e)throw Error(`AudioContext unavailable`);let t=f.current+=1;L();let n=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,noiseSuppression:!0,echoCancellation:!0,autoGainControl:!0}});if(t!==f.current){n.getTracks().forEach(ee);return}let a=new e;try{if(a.state===`suspended`&&await a.resume().catch($),t!==f.current){n.getTracks().forEach(Q),await a.close();return}let e=a.createMediaStreamSource(n),o=a.createScriptProcessor(4096,1,1),s=a.createGain();s.gain.value=0,u.current={stream:n,context:a,source:e,processor:o,gain:s,pending:new Int16Array,started:!0},o.onaudioprocess=e=>{let t=u.current;if(!t.started)return;let n=e.inputBuffer.getChannelData(0),o=0;for(let e=0;e<n.length;e++)o+=n[e]*n[e];let s=Math.sqrt(o/Math.max(1,n.length));r(Math.min(1,Math.max(0,s*2)));let c=U(n,a.sampleRate,z);for(t.pending=W(t.pending,c);t.pending.length>=B;){let e=t.pending.slice(0,B);t.pending=t.pending.slice(B),i.current(G(e))}},e.connect(o),o.connect(s),s.connect(a.destination)}catch(e){let t=e;n.getTracks().forEach(Z);try{await a.close()}catch{}throw u.current=K(),t instanceof Error?t:Error(String(t))}},t[5]=p):p=t[5];let m=l(p),h;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(h=async()=>{f.current+=1;let e=u.current;if(e.started=!1,r(0),e.processor)try{e.processor.onaudioprocess=null}catch{}q(e.processor),q(e.source),q(e.gain),e.stream&&e.stream.getTracks().forEach(X);let t=e.pending;if(e.pending=new Int16Array,t.length>0&&i.current(G(t)),e.context)try{await e.context.close()}catch{}u.current===e&&(u.current=K())},t[6]=h):h=t[6];let g=l(h),_,v;t[7]===g?(_=t[8],v=t[9]):(_=()=>()=>{g().catch(e=>{a.current?.(e instanceof Error?e:Error(String(e)))})},v=[g],t[7]=g,t[8]=_,t[9]=v),(0,d.useEffect)(_,v);let y;t[10]===m?y=t[11]:(y=async()=>{try{await m()}catch(e){let t=e,n=t instanceof Error?t:Error(String(t));throw a.current?.(n),n}},t[10]=m,t[11]=y);let b;return t[12]!==g||t[13]!==y||t[14]!==n?(b={start:y,stop:g,volume:n},t[12]=g,t[13]=y,t[14]=n,t[15]=b):b=t[15],b}function X(e){try{e.stop()}catch{}}function Z(e){try{e.stop()}catch{}}function Q(e){return e.stop()}function $(){}function ee(e){return e.stop()}var te=1e3,ne=e=>e instanceof Error?e:Error(String(e));function re(e={}){let{t}=u(),{onTranscript:r,onError:i,canStart:a}=e,[o,s]=(0,d.useState)(`idle`),[c,f]=(0,d.useState)(!1),[p,m]=(0,d.useState)(``),[h,g]=(0,d.useState)(0),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)(null),x=(0,d.useRef)(o);(0,d.useEffect)(()=>{x.current=o},[o]);let S=(0,d.useRef)(``),C=(0,d.useRef)(null),w=(0,d.useRef)({starting:!1,confirming:!1,cancelling:!1}),T=(0,d.useRef)(0),E=(0,d.useRef)(r),D=(0,d.useRef)(i);(0,d.useEffect)(()=>{E.current=r,D.current=i},[r,i]);let k=(0,d.useRef)(null);k.current||=new N({client:O});let A=l(()=>{C.current&&=(clearInterval(C.current),null)}),j=l(()=>{C.current||=setInterval(()=>{g(e=>e+1)},te)}),M=l(e=>{let n=ne(e),r=n.name===`NotFoundError`||n.name===`DevicesNotFoundError`?Error(t(`chat.dictation.error.microphoneNotFound`),{cause:n}):n;v(r.message);let i=n.reasonCode;b(typeof i==`string`?i:null),D.current?.(r)}),P=l(()=>{v(null),b(null)}),F=l(()=>{k.current?.clearAll(),S.current=``,m(``)}),I=l(t=>e.onPartialTranscript?.(t));(0,d.useEffect)(()=>O.onPartial((e,t)=>{let n=k.current?.getDictationId();!n||e!==n||(S.current=t,m(t),I(t))}),[I]),(0,d.useEffect)(()=>O.subscribeConnectionStatus(e=>{if(!e){x.current===`recording`&&k.current?.resetStreamForReplay();return}if(x.current!==`recording`||k.current?.getDictationId())return;let t=T.current;k.current?.restartStream().catch(e=>{T.current===t&&M(e)})}),[M]);let L=Y({onPcmSegment:e=>{x.current===`recording`&&k.current?.enqueueSegment(e)},onError:e=>{D.current?.(e)}}),R=(0,d.useRef)(L.stop);(0,d.useEffect)(()=>{R.current=L.stop},[L.stop]);let z=l(e=>{g(0),s(`idle`),x.current=`idle`;let t=e.trim();return F(),t?(E.current?.(t),t):null}),B=l(e=>{k.current?.hasSegments()?(s(`failed`),x.current=`failed`):(s(`idle`),x.current=`idle`),M(e)}),V=l(async()=>{let e=w.current;if(e.starting||e.confirming||e.cancelling||x.current!==`idle`||a&&!a())return;e.starting=!0,f(!0);let t=++T.current;P(),m(``),g(0),s(`recording`),x.current=`recording`,F();try{if(await L.start(),T.current!==t||x.current!==`recording`)return;f(!1),j(),await k.current?.restartStream().catch(e=>{T.current===t&&M(e)})}catch(e){if(T.current!==t)return;await L.stop().catch(()=>void 0),A(),s(`idle`),x.current=`idle`,M(e)}finally{T.current===t&&f(!1),e.starting=!1}}),H=l(async()=>{let e=w.current;if(!e.cancelling&&(x.current===`recording`||x.current===`uploading`)){e.cancelling=!0,f(!1),T.current+=1,A(),g(0),P(),s(`idle`),x.current=`idle`;try{k.current?.cancel()}catch{}F();try{await L.stop()}catch{}finally{e.cancelling=!1}}}),U=l(async()=>{let e=w.current;if(e.confirming||x.current!==`recording`)return null;e.confirming=!0,f(!1);let t=++T.current;P(),A();try{if(await L.stop(),T.current!==t)return null;s(`uploading`),x.current=`uploading`;let e=k.current?.getFinalSeq()??-1;if(e<0)return k.current?.cancel(),z(``);let n=await k.current.finish(e);return T.current===t?z(n.text):null}catch(e){return T.current===t&&B(e),null}finally{e.confirming=!1}}),W=l(async()=>{if(x.current!==`failed`||!k.current?.hasSegments())return null;P();let e=++T.current;s(`uploading`),x.current=`uploading`;try{k.current.resetStreamForReplay();let t=k.current.getFinalSeq(),n=await k.current.finish(t);return T.current===e?z(n.text):null}catch(t){return T.current===e&&B(t),null}}),G=l(()=>{if(x.current!==`failed`)return null;let e=S.current.trim();g(0),s(`idle`),x.current=`idle`,P();try{k.current?.cancel()}catch{}return F(),e?(E.current?.(e),e):null}),K=l(()=>{g(0),s(`idle`),x.current=`idle`,P(),F()});return(0,d.useEffect)(()=>n(()=>{x.current===`failed`?(T.current+=1,K()):H()}),[H,K]),(0,d.useEffect)(()=>{if(o!==`recording`||y!==`model_download_in_progress`)return;let e=setInterval(()=>{x.current!==`recording`||k.current?.getDictationId()||k.current?.restartStream().then(()=>{P()}).catch(e=>{M(e)})},3e3);return()=>clearInterval(e)},[o,y,P,M]),(0,d.useEffect)(()=>()=>{T.current+=1,A(),R.current().catch(()=>void 0),k.current?.cancel()},[A]),{status:o,isRecording:o===`recording`,isStarting:c,isProcessing:o===`uploading`,partialTranscript:p,volume:L.volume,duration:h,error:_,errorReason:y,startDictation:V,confirmDictation:U,cancelDictation:H,retryFailedDictation:W,acceptPartialTranscript:G,discardFailedDictation:K}}var ie=`app-region-no-drag transition-[opacity,transform] duration-150 ease-out data-[starting-style]:opacity-0 data-[starting-style]:scale-95 data-[ending-style]:opacity-0 data-[ending-style]:scale-95 z-50 max-h-[var(--available-height)] min-w-[8rem] origin-[var(--transform-origin)] overflow-visible rounded-xl p-1 shadow-[inset_0_1px_0_0_rgba(255,255,255,0.8),inset_0_0_0_1px_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.10),0_1px_2px_-0.5px_rgba(0,0,0,0.08),0_4px_8px_-2px_rgba(0,0,0,0.08),0_12px_20px_-4px_rgba(0,0,0,0.08)] dark:shadow-[inset_0_1px_0_0_rgba(255,255,255,0.12),inset_0_0_0_1px_rgba(255,255,255,0.08),0_0_0_1px_rgba(0,0,0,0.36),0_1px_1px_-0.5px_rgba(0,0,0,0.22),0_3px_3px_-1.5px_rgba(0,0,0,0.20),0_6px_6px_-3px_rgba(0,0,0,0.16)]`,ae=`data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover active:bg-interactive-active data-[variant=destructive]:text-destructive data-[variant=destructive]:hover:bg-destructive/10 dark:data-[variant=destructive]:hover:bg-destructive/20 data-[variant=destructive]:hover:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1 typography-ui-label outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5`,oe=`data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover active:bg-interactive-active [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1 typography-ui-label outline-hidden select-none data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5`,se=`bg-border -mx-1 my-0.5 h-px`;export{re as a,R as c,x as d,b as f,p as h,oe as i,I as l,f as m,ie as n,J as o,v as p,se as r,L as s,ae as t,y as u};
|