@openchamber/web 1.13.6 → 1.13.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/bin/lib/commands-update.test.js +50 -0
  2. package/dist/assets/{DiagramView-C_f1Il8p.js → DiagramView-BJkP8Fjp.js} +1 -1
  3. package/dist/assets/{MarkdownRendererImpl-BR0DXO9F.js → MarkdownRendererImpl-Nq7bOf31.js} +1 -1
  4. package/dist/assets/{MultiRunWindow-WBqBXcts.js → MultiRunWindow-CRKVePMG.js} +1 -1
  5. package/dist/assets/{NewWorktreeDialog-D7l2VA7o.js → NewWorktreeDialog-Dj6KETex.js} +1 -1
  6. package/dist/assets/{OnboardingScreen-ChaxLu9k.js → OnboardingScreen-DRe8UNiS.js} +1 -1
  7. package/dist/assets/{SessionSwitcherDropdown-xaYa-FIx.js → SessionSwitcherDropdown-Cn_yoQrm.js} +1 -1
  8. package/dist/assets/{SettingsWindow-D5aAKCEM.js → SettingsWindow-BIKNrxSK.js} +1 -1
  9. package/dist/assets/{TerminalView-D8GzsMZF.js → TerminalView-BDjzrhGS.js} +1 -1
  10. package/dist/assets/{index-DxqTiFfR.css → index-Bv4711NQ.css} +1 -1
  11. package/dist/assets/{main-DUn82Iwq.js → main-BByFAmjA.js} +3 -3
  12. package/dist/assets/{main-CLkcy9_q.js → main-BJDsJGkp.js} +2 -2
  13. package/dist/assets/miniChat-Ckr71tB9.js +2 -0
  14. package/dist/assets/mobile-DVDtnIcD.js +2 -0
  15. package/dist/assets/{renderElectronMiniChatApp-BTsP-lHc.js → renderElectronMiniChatApp-CXvtB6Rd.js} +2 -2
  16. package/dist/assets/{renderMobileApp-CSEgabkw.js → renderMobileApp-BVAt5rTM.js} +3 -3
  17. package/dist/assets/{useAppFontEffects-BPhei6aO.js → useAppFontEffects-B66TruVB.js} +111 -111
  18. package/dist/index.html +3 -3
  19. package/dist/mini-chat.html +3 -3
  20. package/dist/mobile.html +3 -3
  21. package/package.json +1 -1
  22. package/server/lib/package-manager.js +2 -2
  23. package/server/lib/package-manager.test.js +13 -1
  24. package/dist/assets/miniChat-Ag1CYNF5.js +0 -2
  25. package/dist/assets/mobile-DtojUfiY.js +0 -2
  26. /package/dist/assets/{index-DJHN0H4h.js → index-AsCHiJ5P.js} +0 -0
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-.bun-By2L9XvG.js","assets/vendor--Dwc_TRgJ.css","assets/renderMobileApp-CSEgabkw.js","assets/index-DJHN0H4h.js","assets/index-DxqTiFfR.css","assets/useAppFontEffects-BPhei6aO.js","assets/NewWorktreeDialog-D7l2VA7o.js","assets/mobileLayoutPreference-Dio-WWkI.js","assets/main-DUn82Iwq.js","assets/SessionSwitcherDropdown-xaYa-FIx.js","assets/main-BV3KOtdA.css"])))=>i.map(i=>d[i]);
2
- import{c as w}from"./index-DJHN0H4h.js";import{_ as a}from"./vendor-.bun-By2L9XvG.js";import{g as p}from"./mobileLayoutPreference-Dio-WWkI.js";function h(t={}){const{immediate:r=!1,onNeedRefresh:n,onOfflineReady:o,onRegistered:s,onRegisteredSW:c,onRegisterError:d}=t;let i,u;const f=async(e=!0)=>{await u};async function m(){if("serviceWorker"in navigator){if(i=await a(async()=>{const{Workbox:e}=await import("./vendor-.bun-By2L9XvG.js").then(_=>_.cm);return{Workbox:e}},__vite__mapDeps([0,1])).then(({Workbox:e})=>new e("/sw.js",{scope:"/",type:"classic"})).catch(e=>{d?.(e)}),!i)return;i.addEventListener("activated",e=>{(e.isUpdate||e.isExternal)&&window.location.reload()}),i.addEventListener("installed",e=>{e.isUpdate||o?.()}),i.register({immediate:r}).then(e=>{c?c("/sw.js",e):s?.(e)}).catch(e=>{d?.(e)})}}return u=m(),f}window.__OPENCHAMBER_RUNTIME_APIS__=w();const v=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(pointer: coarse)").matches,g=()=>{const r=new URLSearchParams(window.location.search).get("surface");if(r==="mobile")return"mobile";if(r==="desktop")return"desktop";const n=Math.min(window.innerWidth||0,window.screen?.width||window.innerWidth||0),o=navigator.maxTouchPoints||0;return n>0&&n<=760&&(o>0||v())&&p()==="new"?"mobile":"desktop"},l=g();window.__OPENCHAMBER_SURFACE__=l;const S=()=>!(!("serviceWorker"in navigator)||!window.isSecureContext||window.location.protocol!=="http:"&&window.location.protocol!=="https:"||document.prerendering||String(document.visibilityState)==="prerender"),E=t=>{let r=!1;const n=()=>{r||S()&&(r=!0,t())},o=()=>{setTimeout(n,0)};document.readyState==="complete"?o():window.addEventListener("load",o,{once:!0}),(document.prerendering||String(document.visibilityState)==="prerender")&&document.addEventListener("visibilitychange",n,{once:!0})},P=()=>{E(()=>{try{h({onRegisterError(t){console.warn("[PWA] service worker registration skipped:",t)}})}catch(t){console.warn("[PWA] service worker registration skipped:",t)}})};l==="mobile"?a(async()=>{const{renderMobileApp:t}=await import("./renderMobileApp-CSEgabkw.js");return{renderMobileApp:t}},__vite__mapDeps([2,0,1,3,4,5,6,7])).then(({renderMobileApp:t})=>{t(window.__OPENCHAMBER_RUNTIME_APIS__??w())}):a(()=>import("./main-DUn82Iwq.js").then(t=>t.m),__vite__mapDeps([8,0,1,3,4,5,6,7,9,10]));P();
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-.bun-By2L9XvG.js","assets/vendor--Dwc_TRgJ.css","assets/renderMobileApp-BVAt5rTM.js","assets/index-AsCHiJ5P.js","assets/index-Bv4711NQ.css","assets/useAppFontEffects-B66TruVB.js","assets/NewWorktreeDialog-Dj6KETex.js","assets/mobileLayoutPreference-Dio-WWkI.js","assets/main-BByFAmjA.js","assets/SessionSwitcherDropdown-Cn_yoQrm.js","assets/main-BV3KOtdA.css"])))=>i.map(i=>d[i]);
2
+ import{c as w}from"./index-AsCHiJ5P.js";import{_ as a}from"./vendor-.bun-By2L9XvG.js";import{g as p}from"./mobileLayoutPreference-Dio-WWkI.js";function h(t={}){const{immediate:r=!1,onNeedRefresh:n,onOfflineReady:o,onRegistered:s,onRegisteredSW:c,onRegisterError:d}=t;let i,u;const f=async(e=!0)=>{await u};async function m(){if("serviceWorker"in navigator){if(i=await a(async()=>{const{Workbox:e}=await import("./vendor-.bun-By2L9XvG.js").then(_=>_.cm);return{Workbox:e}},__vite__mapDeps([0,1])).then(({Workbox:e})=>new e("/sw.js",{scope:"/",type:"classic"})).catch(e=>{d?.(e)}),!i)return;i.addEventListener("activated",e=>{(e.isUpdate||e.isExternal)&&window.location.reload()}),i.addEventListener("installed",e=>{e.isUpdate||o?.()}),i.register({immediate:r}).then(e=>{c?c("/sw.js",e):s?.(e)}).catch(e=>{d?.(e)})}}return u=m(),f}window.__OPENCHAMBER_RUNTIME_APIS__=w();const v=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(pointer: coarse)").matches,g=()=>{const r=new URLSearchParams(window.location.search).get("surface");if(r==="mobile")return"mobile";if(r==="desktop")return"desktop";const n=Math.min(window.innerWidth||0,window.screen?.width||window.innerWidth||0),o=navigator.maxTouchPoints||0;return n>0&&n<=760&&(o>0||v())&&p()==="new"?"mobile":"desktop"},l=g();window.__OPENCHAMBER_SURFACE__=l;const S=()=>!(!("serviceWorker"in navigator)||!window.isSecureContext||window.location.protocol!=="http:"&&window.location.protocol!=="https:"||document.prerendering||String(document.visibilityState)==="prerender"),E=t=>{let r=!1;const n=()=>{r||S()&&(r=!0,t())},o=()=>{setTimeout(n,0)};document.readyState==="complete"?o():window.addEventListener("load",o,{once:!0}),(document.prerendering||String(document.visibilityState)==="prerender")&&document.addEventListener("visibilitychange",n,{once:!0})},P=()=>{E(()=>{try{h({onRegisterError(t){console.warn("[PWA] service worker registration skipped:",t)}})}catch(t){console.warn("[PWA] service worker registration skipped:",t)}})};l==="mobile"?a(async()=>{const{renderMobileApp:t}=await import("./renderMobileApp-BVAt5rTM.js");return{renderMobileApp:t}},__vite__mapDeps([2,0,1,3,4,5,6,7])).then(({renderMobileApp:t})=>{t(window.__OPENCHAMBER_RUNTIME_APIS__??w())}):a(()=>import("./main-BByFAmjA.js").then(t=>t.m),__vite__mapDeps([8,0,1,3,4,5,6,7,9,10]));P();
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/renderElectronMiniChatApp-CXvtB6Rd.js","assets/vendor-.bun-By2L9XvG.js","assets/vendor--Dwc_TRgJ.css","assets/index-AsCHiJ5P.js","assets/index-Bv4711NQ.css","assets/useAppFontEffects-B66TruVB.js","assets/SessionSwitcherDropdown-Cn_yoQrm.js"])))=>i.map(i=>d[i]);
2
+ import{c as r}from"./index-AsCHiJ5P.js";import{_ as o}from"./vendor-.bun-By2L9XvG.js";window.__OPENCHAMBER_RUNTIME_APIS__=r();o(async()=>{const{renderElectronMiniChatApp:_}=await import("./renderElectronMiniChatApp-CXvtB6Rd.js");return{renderElectronMiniChatApp:_}},__vite__mapDeps([0,1,2,3,4,5,6])).then(({renderElectronMiniChatApp:_})=>{_(window.__OPENCHAMBER_RUNTIME_APIS__??r())});
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/renderMobileApp-BVAt5rTM.js","assets/vendor-.bun-By2L9XvG.js","assets/vendor--Dwc_TRgJ.css","assets/index-AsCHiJ5P.js","assets/index-Bv4711NQ.css","assets/useAppFontEffects-B66TruVB.js","assets/NewWorktreeDialog-Dj6KETex.js","assets/mobileLayoutPreference-Dio-WWkI.js"])))=>i.map(i=>d[i]);
2
+ import{c as o}from"./index-AsCHiJ5P.js";import{_ as r}from"./vendor-.bun-By2L9XvG.js";window.__OPENCHAMBER_RUNTIME_APIS__=o();r(async()=>{const{renderMobileApp:_}=await import("./renderMobileApp-BVAt5rTM.js");return{renderMobileApp:_}},__vite__mapDeps([0,1,2,3,4,5,6,7])).then(({renderMobileApp:_})=>{_(window.__OPENCHAMBER_RUNTIME_APIS__??o())});
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/useAppFontEffects-BPhei6aO.js","assets/vendor-.bun-By2L9XvG.js","assets/vendor--Dwc_TRgJ.css","assets/index-DJHN0H4h.js","assets/index-DxqTiFfR.css"])))=>i.map(i=>d[i]);
2
- import{e as V,j as c,R as p,_ as jt,G as Dt,H as kt}from"./vendor-.bun-By2L9XvG.js";import{u as le,a5 as Pt,x as fe,b as ut,v as Ct,o as ht,d as gt,i as Et,s as Mt}from"./index-DJHN0H4h.js";import{eR as Rt,u as St,dJ as At,z as v,D as Fe,Q as _,cc as ft,a1 as Nt,a as Lt,f as vt,aL as Ot,aN as Bt,m as Tt,I as He,B as yt,aR as F,a2 as zt,aP as Wt,U as $t,V as Ut,W as Gt,_ as Ht,a0 as Ft,Z as Vt,X as Kt,Y as Jt,eS as qt,cK as Qt,O as Xt,af as Yt,ag as Zt,ah as en,ai as tn,aj as nn,ak as rn,al as sn,am as on,an}from"./useAppFontEffects-BPhei6aO.js";import{C as cn,S as ln,W as dn}from"./SessionSwitcherDropdown-xaYa-FIx.js";const un=t=>{const e=V.c(3),{mode:r,children:s}=t;let n;return e[0]!==s||e[1]!==r?(n=c.jsx(Rt.Provider,{value:r,children:s}),e[0]=s,e[1]=r,e[2]=n):n=e[2],n},fn=t=>{const e=typeof t=="string"?t.trim():"";if(!e)return"";const r=typeof window<"u"?window.__OPENCHAMBER_HOME__:"";if(r&&e===r)return"~";if(r&&e.startsWith(`${r}/`))return`~/${e.slice(r.length+1)}`;const s=e.split("/").filter(Boolean);return s.length<=3?e:`.../${s.slice(-3).join("/")}`},U=t=>{const e=typeof t=="string"?t.trim():"";if(!e)return"";const r=e.replace(/\\/g,"/");return r==="/"?"/":r.replace(/\/+$/,"")},mn=t=>{const e=V.c(125),{mode:r}=t,{t:s}=St(),n=v(hn),l=v(yn),a=v(wn),u=le(gn),f=Fe(Sn),d=Fe(vn),y=_(xn),j=_(bn),D=ft(),g=Nt(n??""),w=Lt(),x=vt(_n);let z;e[0]!==n?(z=o=>n?o.worktreeMetadata.get(n)?.path??"":"",e[0]=n,e[1]=z):z=e[1];const R=v(z);let A;e[2]!==n?(A=o=>n?o.worktreeMetadata.get(n)?.branch?.trim()??null:null,e[2]=n,e[3]=A):A=e[3];const O=v(A);let W;e[4]!==n?(W=o=>n?o.getAttachment(n):void 0,e[4]=n,e[5]=W):W=e[5];const i=Ot(W),N=v(In),[m,I]=p.useState(!1),B=typeof window<"u"?window.__OPENCHAMBER_MACOS_MAJOR__??0:0,L=Number.isFinite(B)&&B>0,Ve=typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__&&window.__OPENCHAMBER_PLATFORM__==="win32",mt=L?B>=26?"h-12":B<=15?"h-14":"":"";let $;e[6]!==n||e[7]!==D?($=n?D.find(o=>o.id===n)??null:null,e[6]=n,e[7]=D,e[8]=$):$=e[8];const E=$,K=E?.worktreeMetadata??null;let me,pe;e[9]===Symbol.for("react.memo_cache_sentinel")?(me=()=>{Pt()&&fe("desktop_get_window_pinned").then(o=>{typeof o?.pinned=="boolean"&&I(o.pinned)})},pe=[],e[9]=me,e[10]=pe):(me=e[9],pe=e[10]),p.useEffect(me,pe);let he;e[11]!==l||e[12]!==r||e[13]!==E?.title||e[14]!==s?(he=E?.title?.trim()||s(l||r==="draft"?"miniChat.header.newSession":"miniChat.header.session"),e[11]=l,e[12]=r,e[13]=E?.title,e[14]=s,e[15]=he):he=e[15];const Ke=he,Je=E?.directory??null;let ye;e[16]!==Je?(ye=U(Je),e[16]=Je,e[17]=ye):ye=e[17];const we=ye,qe=R||K?.path||i?.cwd||i?.worktreeRoot||"";let ge;e[18]!==qe?(ge=U(qe),e[18]=qe,e[19]=ge):ge=e[19];const Se=ge;let ve;e[20]!==u?(ve=U(u),e[20]=u,e[21]=ve):ve=e[21];const k=Se||we||N||ve;let xe;e[22]!==k?(xe=fn(k),e[22]=k,e[23]=xe):xe=e[23];const xt=xe;let be;e[24]!==we||e[25]!==Se?(be=o=>{const h=U(Se||we||"");if(!h)return null;for(const C of o.availableWorktreesByProject.values()){const b=C.find(T=>U(T.path)===h)?.branch?.trim();if(b)return b}return null},e[24]=we,e[25]=Se,e[26]=be):be=e[26];const Qe=v(be);let _e,Ie;e[27]!==x||e[28]!==k||e[29]!==w.git?(_e=()=>{k&&x(k,w.git).catch(jn)},Ie=[x,k,w.git],e[27]=x,e[28]=k,e[29]=w.git,e[30]=_e,e[31]=Ie):(_e=e[30],Ie=e[31]),p.useEffect(_e,Ie),K?.projectDirectory,i?.worktreeRoot;let Xe;e:{const o=K?.projectDirectory??i?.worktreeRoot??null;let h;e[32]!==o?(h=U(o),e[32]=o,e[33]=h):h=e[33];const S=h||k;if(!S){Xe=null;break e}let b;e[34]!==S||e[35]!==f?(b=f.map(Dn).filter(T=>T.normalizedPath&&(T.normalizedPath===S||S.startsWith(`${T.normalizedPath}/`))).sort(kn)[0]??null,e[34]=S,e[35]=f,e[36]=b):b=e[36],Xe=b}const bt=Xe;let je;e:{const o=bt??d;if(!o){je=xt||"OpenChamber";break e}let h;e[37]!==o.label?(h=o.label?.trim(),e[37]=o.label,e[38]=h):h=e[38];const C=h;if(C){je=C;break e}let S;e[39]!==o.path?(S=o.path.split(/[\\/]/).filter(Boolean).at(-1)??o.path,e[39]=o.path,e[40]=S):S=e[40],je=S}const Ye=je,Ze=Bt(k||null);let De;e[41]!==Qe||e[42]!==Ze||e[43]!==K?.branch||e[44]!==i?.branch||e[45]!==O?(De=Ze||O||K?.branch?.trim()||i?.branch?.trim()||Qe,e[41]=Qe,e[42]=Ze,e[43]=K?.branch,e[44]=i?.branch,e[45]=O,e[46]=De):De=e[46];const et=De,ke=et&&et!=="HEAD"?et:null;let Pe;e[47]!==y?(Pe=y(),e[47]=y,e[48]=Pe):Pe=e[48];const pt=Pe;let tt;e:{for(let o=g.length-1;o>=0;o=o-1,o){const h=g[o];if(h.role!=="assistant"||typeof h.providerID!="string"||typeof h.modelID!="string")continue;const S=j.find(b=>b.id===h.providerID)?.models.find(b=>b.id===h.modelID);if(S){tt=S;break e}}tt=void 0}const _t=tt,Ce=pt?.limit?pt:_t,J=Ce&&typeof Ce.limit=="object"&&Ce.limit!==null?Ce.limit:null,G=J&&typeof J.context=="number"?J.context:0,de=J&&typeof J.output=="number"?J.output:0;let Ee;e:{if(!n||g.length===0){Ee=null;break e}let o,h;for(let ue=g.length-1;ue>=0;ue=ue-1,ue){const dt=g[ue];if(dt.role!=="assistant")continue;const H=dt.tokens;if(!H)continue;if(H.input+H.output+H.reasoning+(H.cache?.read??0)+(H.cache?.write??0)>0){o=H,h=dt.id;break}}if(!o){Ee=null;break e}const C=o.input+o.output+o.reasoning+(o.cache?.read??0)+(o.cache?.write??0),S=G>0?G:2e5;let b;e[49]!==G||e[50]!==C?(b=G>0?Math.round(C/G*100):0,e[49]=G,e[50]=C,e[51]=b):b=e[51];const T=b;let Ue;e[52]!==o.output||e[53]!==de?(Ue=de>0?Math.round(o.output/de*100):void 0,e[52]=o.output,e[53]=de,e[54]=Ue):Ue=e[54];const at=Ue,ct=G||0,lt=de||void 0;let Ge;e[55]!==h||e[56]!==at||e[57]!==T||e[58]!==ct||e[59]!==lt||e[60]!==S||e[61]!==C?(Ge={totalTokens:C,percentage:T,contextLimit:ct,outputLimit:lt,normalizedOutput:at,thresholdLimit:S,lastMessageId:h},e[55]=h,e[56]=at,e[57]=T,e[58]=ct,e[59]=lt,e[60]=S,e[61]=C,e[62]=Ge):Ge=e[62],Ee=Ge}const P=Ee,[M,nt]=p.useState(null);let Me;e[63]===Symbol.for("react.memo_cache_sentinel")?(Me={WebkitAppRegion:"drag"},e[63]=Me):Me=e[63];const It=Me;let Re;e[64]===Symbol.for("react.memo_cache_sentinel")?(Re={WebkitAppRegion:"no-drag"},e[64]=Re):Re=e[64];const rt=Re;let Ae,Ne;e[65]!==P||e[66]!==n?(Ae=()=>{if(!n){nt(Pn);return}if(P&&P.totalTokens>0){nt(o=>o&&o.totalTokens===P.totalTokens&&o.percentage===P.percentage&&o.contextLimit===P.contextLimit&&(o.outputLimit??0)===(P.outputLimit??0)&&(o.normalizedOutput??0)===(P.normalizedOutput??0)&&o.thresholdLimit===P.thresholdLimit&&o.lastMessageId===P.lastMessageId?o:P);return}nt(Cn)},Ne=[P,n],e[65]=P,e[66]=n,e[67]=Ae,e[68]=Ne):(Ae=e[67],Ne=e[68]),p.useEffect(Ae,Ne);const st=M&&M.contextLimit>0?Math.min(999,M.totalTokens/M.contextLimit*100):0;let Le;e[69]!==m?(Le=()=>{const o=!m;I(o),fe("desktop_set_window_pinned",{pinned:o}).catch(()=>{I(!o)})},e[69]=m,e[70]=Le):Le=e[70];const ot=Le;let Oe;e[71]!==u||e[72]!==n||e[73]!==a||e[74]!==k||e[75]!==E?(Oe=()=>{const o=n?{sessionId:n,directory:E?.directory??u??""}:{mode:"draft",directory:k||u||"",projectId:a};fe("desktop_focus_main_window",o).then(En)},e[71]=u,e[72]=n,e[73]=a,e[74]=k,e[75]=E,e[76]=Oe):Oe=e[76];const it=Oe;let Be;e[77]===Symbol.for("react.memo_cache_sentinel")?(Be=Tt("flex items-center gap-3 bg-background pr-3",L?"pl-[5.5rem]":"pl-3",Ve?"h-12":mt||"min-h-14"),e[77]=Be):Be=e[77];let q;e[78]!==s?(q=s("sessions.switcher.openAria"),e[78]=s,e[79]=q):q=e[79];let Q;e[80]!==Ke?(Q=c.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:Ke}),e[80]=Ke,e[81]=Q):Q=e[81];let X;e[82]!==Ye?(X=c.jsx("span",{className:"truncate",children:Ye}),e[82]=Ye,e[83]=X):X=e[83];let Y;e[84]!==ke?(Y=ke?c.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[c.jsx(He,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),c.jsx("span",{className:"truncate",children:ke})]}):null,e[84]=ke,e[85]=Y):Y=e[85];let Z;e[86]!==X||e[87]!==Y?(Z=c.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75",children:[X,Y]}),e[86]=X,e[87]=Y,e[88]=Z):Z=e[88];let ee;e[89]!==q||e[90]!==Q||e[91]!==Z?(ee=c.jsx(ln,{children:c.jsxs("button",{type:"button","aria-label":q,style:rt,className:"flex min-w-0 max-w-full flex-col items-start rounded-md px-1 py-0.5 text-left transition-colors hover:bg-interactive-hover/60 focus-visible:outline-none focus-visible:bg-interactive-hover/60",children:[Q,Z]})}),e[89]=q,e[90]=Q,e[91]=Z,e[92]=ee):ee=e[92];let Te;e[93]===Symbol.for("react.memo_cache_sentinel")?(Te=c.jsx("div",{className:"min-w-0 flex-1"}),e[93]=Te):Te=e[93];let te;e[94]!==st||e[95]!==M?(te=M&&M.totalTokens>0?c.jsx(cn,{totalTokens:M.totalTokens,percentage:st,colorPercentage:M.percentage,contextLimit:M.contextLimit,outputLimit:M.outputLimit??0,className:"h-9 shrink-0 pl-1 pr-1 typography-ui-label",valueClassName:"font-semibold leading-none",hideIcon:!0,showPercentIcon:!0,percentIconClassName:"h-4.5 w-4.5"}):null,e[94]=st,e[95]=M,e[96]=te):te=e[96];let ne;e[97]!==m||e[98]!==s?(ne=s(m?"miniChat.actions.unpinAria":"miniChat.actions.pinAria"),e[97]=m,e[98]=s,e[99]=ne):ne=e[99];let re;e[100]!==m||e[101]!==s?(re=s(m?"miniChat.actions.unpin":"miniChat.actions.pin"),e[100]=m,e[101]=s,e[102]=re):re=e[102];let se;e[103]!==m?(se=m?c.jsx(He,{name:"pushpin-2-fill",className:"h-4 w-4"}):c.jsx(He,{name:"pushpin-2",className:"h-4 w-4"}),e[103]=m,e[104]=se):se=e[104];let oe;e[105]!==ot||e[106]!==ne||e[107]!==re||e[108]!==se?(oe=c.jsx(yt,{type:"button",variant:"ghost",size:"icon",onClick:ot,"aria-label":ne,title:re,style:rt,children:se}),e[105]=ot,e[106]=ne,e[107]=re,e[108]=se,e[109]=oe):oe=e[109];let ie;e[110]!==s?(ie=s("miniChat.actions.openMainAria"),e[110]=s,e[111]=ie):ie=e[111];let ae;e[112]!==s?(ae=s("miniChat.actions.openMain"),e[112]=s,e[113]=ae):ae=e[113];let ze;e[114]===Symbol.for("react.memo_cache_sentinel")?(ze=c.jsx(He,{name:"external-link",className:"h-4 w-4"}),e[114]=ze):ze=e[114];let ce;e[115]!==it||e[116]!==ie||e[117]!==ae?(ce=c.jsx(yt,{type:"button",variant:"ghost",size:"icon",onClick:it,"aria-label":ie,title:ae,style:rt,children:ze}),e[115]=it,e[116]=ie,e[117]=ae,e[118]=ce):ce=e[118];let We;e[119]===Symbol.for("react.memo_cache_sentinel")?(We=c.jsx(dn,{visible:Ve}),e[119]=We):We=e[119];let $e;return e[120]!==ee||e[121]!==te||e[122]!==oe||e[123]!==ce?($e=c.jsxs("header",{className:Be,style:It,children:[ee,Te,te,oe,ce,We]}),e[120]=ee,e[121]=te,e[122]=oe,e[123]=ce,e[124]=$e):$e=e[124],$e},pn=t=>{const e=V.c(9),{mode:r,autoOpenDraft:s,unavailable:n}=t,l=s===void 0?!1:s,a=n===void 0?!1:n,{t:u}=St();let f;e[0]!==r?(f=c.jsx(mn,{mode:r}),e[0]=r,e[1]=f):f=e[1];let d;e[2]!==l||e[3]!==u||e[4]!==a?(d=c.jsx("main",{className:"min-h-0 flex-1",children:a?c.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center typography-ui-label text-muted-foreground",children:c.jsxs("div",{className:"max-w-sm rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-4 py-3",children:[c.jsx("div",{className:"font-medium text-foreground",children:u("miniChat.unavailable.title")}),c.jsx("div",{className:"mt-1 typography-small text-muted-foreground",children:u("miniChat.unavailable.description")})]})}):c.jsx(un,{mode:"mini-chat",children:c.jsx(At,{autoOpenDraft:l})})}),e[2]=l,e[3]=u,e[4]=a,e[5]=d):d=e[5];let y;return e[6]!==f||e[7]!==d?(y=c.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:[f,d]}),e[6]=f,e[7]=d,e[8]=y):y=e[8],y};function hn(t){return t.currentSessionId}function yn(t){return!!t.newSessionDraft?.open}function wn(t){return t.newSessionDraft?.selectedProjectId??null}function gn(t){return t.currentDirectory}function Sn(t){return t.projects}function vn(t){return t.getActiveProject()}function xn(t){return t.getCurrentModel}function bn(t){return t.providers}function _n(t){return t.ensureStatus}function In(t){return t.newSessionDraft?.open?U(t.newSessionDraft.bootstrapPendingDirectory??t.newSessionDraft.directoryOverride??""):""}function jn(){}function Dn(t){return{...t,normalizedPath:U(t.path)}}function kn(t,e){return e.path.length-t.path.length}function Pn(t){return t===null?t:null}function Cn(t){return t===null?t:null}function En(t){return t?.focused===!0?fe("desktop_close_current_window"):null}const wt=()=>{document.querySelector('textarea[data-chat-input="true"]')?.focus()},Mn=()=>{const t=ut(n=>n.shortcutOverrides),e=le(n=>n.currentDirectory),r=Fe(n=>n.getActiveProject()),s=v(n=>n.openNewSessionDraft);p.useEffect(()=>{const n=a=>Wt(a,t),l=a=>{if(F(a,n("focus_input"))){a.preventDefault(),wt();return}if(Ct()&&F(a,n("new_mini_chat"))){a.preventDefault(),fe("desktop_open_draft_mini_chat_window",{directory:e||r?.path||"",projectId:r?.id??null})?.catch(d=>{console.warn("[mini-chat-shortcuts] failed to open draft mini chat window",d)});return}if(F(a,n("new_chat"))){a.preventDefault(),s({selectedProjectId:r?.id??null,directoryOverride:e||r?.path||null,preserveDirectoryOverride:!!(e||r?.path)}),wt();return}if(F(a,n("open_model_selector"))){a.preventDefault();const{isModelSelectorOpen:d,setModelSelectorOpen:y}=ut.getState();y(!d);return}if(F(a,n("cycle_thinking_variant"))){const d=_.getState();if(d.getCurrentModelVariants().length===0)return;a.preventDefault(),d.cycleCurrentVariant();const j=_.getState().currentVariant,D=v.getState().currentSessionId,g=_.getState().currentAgentName,w=_.getState().currentProviderId,x=_.getState().currentModelId;D&&g&&w&&x&&zt.getState().saveAgentModelVariantForSession(D,g,w,x,j);return}const u=F(a,n("cycle_favorite_model_forward")),f=F(a,n("cycle_favorite_model_backward"));if(u||f){const{favoriteModels:d,addRecentModel:y}=ut.getState();if(d.length===0)return;a.preventDefault();const{currentProviderId:j,currentModelId:D,setProvider:g,setModel:w}=_.getState(),x=d.findIndex(A=>A.providerID===j&&A.modelID===D),R=d[(x+(u?1:-1)+d.length)%d.length];g(R.providerID),w(R.modelID),y(R.providerID,R.modelID)}};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[r?.id,r?.path,e,s,t])},Rn="openchamber:mini-chat-presence",An=()=>{const t=typeof window<"u"?new URLSearchParams(window.location.search):new URLSearchParams,e=t.get("mode")==="session"?"session":"draft",r=t.get("sessionId")?.trim()||null,s=t.get("directory")?.trim()||null,n=t.get("projectId")?.trim()||null;return{mode:e,sessionId:r,directory:s,projectId:n}},Nn=({config:t})=>{const e=ft(),r=le(i=>i.currentDirectory),s=le(i=>i.setDirectory),n=Fe(i=>i.projects),l=v(i=>i.currentSessionId),a=v(i=>!!i.newSessionDraft?.open),u=v(i=>i.newSessionDraft?.open?i.newSessionDraft.bootstrapPendingDirectory??i.newSessionDraft.directoryOverride??"":""),f=v(i=>i.setCurrentSession),d=v(i=>i.openNewSessionDraft),y=_(i=>i.initializeApp),j=_(i=>i.isInitialized),D=_(i=>i.isConnected),g=_(i=>i.loadProviders),w=_(i=>i.loadAgents),x=_(i=>i.providers.length),z=_(i=>i.agents.length),R=Qt();p.useEffect(()=>{y()},[y]),p.useEffect(()=>{if(j)return;let i=!0,N=0;const m=window.setInterval(()=>{if(i){if(N+=1,N>10){window.clearInterval(m);return}_.getState().isInitialized||_.getState().initializeApp()}},1e3);return()=>{i=!1,window.clearInterval(m)}},[j]);const A=p.useRef(!1);p.useEffect(()=>{if(!A.current&&t.mode==="session"&&t.directory){if(r===t.directory){A.current=!0;return}s(t.directory,{showOverlay:!1}),A.current=!0}},[t.directory,t.mode,r,s]),p.useEffect(()=>{t.mode!=="draft"||!a||l||!u||r===u||s(u,{showOverlay:!1})},[t.mode,r,l,u,a,s]),p.useEffect(()=>{D&&(x===0&&g({source:"electronMiniChat:recovery"}),z===0&&w({source:"electronMiniChat:recovery"}))},[z,D,w,g,x]);const O=p.useRef(!1);p.useEffect(()=>{if(O.current||t.mode!=="session"||!t.sessionId)return;if(l===t.sessionId){O.current=!0;return}if(l){O.current=!0;return}const i=e.find(m=>m.id===t.sessionId);if(!i){R.ensureSessionRenderable(t.sessionId);return}const N=i.directory??t.directory;f(t.sessionId,N),O.current=!0},[t,l,e,f,R]),p.useEffect(()=>{const i=N=>{const m=N.detail,I=typeof m?.sessionId=="string"?m.sessionId.trim():"";if(!I||v.getState().currentSessionId===I)return;const B=typeof m?.directory=="string"&&m.directory.trim().length>0?m.directory.trim():e.find(L=>L.id===I)?.directory??null;R.ensureSessionRenderable(I),f(I,B),O.current=!0};return window.addEventListener("openchamber:open-session",i),()=>window.removeEventListener("openchamber:open-session",i)},[e,f,R]),p.useEffect(()=>{t.mode!=="draft"||a||l||d({selectedProjectId:t.projectId,directoryOverride:t.directory,preserveDirectoryOverride:!!t.directory})},[t,l,a,d]),p.useEffect(()=>{if(n.length===0)return;let i=!1;return(async()=>{const m=new Map,I=[];await Promise.all(n.map(async B=>{const L=B.path.replace(/\\/g,"/").replace(/\/+$/,"");if(L)try{if(!(vt.getState().directories.get(L)?.isGitRepo??await jt(()=>import("./useAppFontEffects-BPhei6aO.js").then(E=>E.f8),__vite__mapDeps([0,1,2,3,4])).then(E=>E.checkIsGitRepository(L))))return;const $=await Xt({id:B.id,path:L});if(i||$.length===0)return;m.set(L,$),I.push(...$)}catch{}})),!i&&v.setState({availableWorktrees:I,availableWorktreesByProject:m})})(),()=>{i=!0}},[n]);const W=p.useRef(!1);return p.useEffect(()=>{if(W.current||!j)return;const i=()=>{if(W.current)return;W.current=!0;const I=typeof document<"u"?document.getElementById("initial-loading"):null;I&&(I.classList.add("fade-out"),window.setTimeout(()=>I.remove(),300))},N=t.mode==="session"?l===t.sessionId:a,m=window.setTimeout(i,N?100:1500);return()=>window.clearTimeout(m)},[j,t.mode,t.sessionId,l,a]),null},Ln=()=>{const t=V.c(4),e=v($n),r=le(Un);let s,n;return t[0]!==r||t[1]!==e?(s=()=>{if(!e||!r||typeof BroadcastChannel>"u")return;const l=new BroadcastChannel(Rn),a=d=>{l.postMessage({type:"mini-chat-session-presence",sessionId:e,directory:r,viewed:d})};a(!0);const u=window.setInterval(()=>a(!0),5e3),f=()=>a(!1);return window.addEventListener("beforeunload",f),()=>{window.clearInterval(u),window.removeEventListener("beforeunload",f),a(!1),l.close()}},n=[r,e],t[0]=r,t[1]=e,t[2]=s,t[3]=n):(s=t[2],n=t[3]),p.useEffect(s,n),null},On=t=>{const e=V.c(6),r=ft(),s=v(Gn),[n,l]=p.useState(!1);let a,u;return e[0]!==t.mode||e[1]!==t.sessionId||e[2]!==s||e[3]!==r?(a=()=>{if(t.mode!=="session"||!t.sessionId||s===t.sessionId){l(!1);return}if(r.some(d=>d.id===t.sessionId)){l(!1);return}const f=window.setTimeout(()=>l(!0),5e3);return()=>window.clearTimeout(f)},u=[t.mode,t.sessionId,s,r],e[0]=t.mode,e[1]=t.sessionId,e[2]=s,e[3]=r,e[4]=a,e[5]=u):(a=e[4],u=e[5]),p.useEffect(a,u),n};function Bn(t){const e=V.c(15),{apis:r}=t;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=An(),e[0]=s):s=e[0];const n=s,l=le(zn);let a,u;e[1]!==l?(a=()=>{ht.setDirectory(l||n.directory||void 0)},u=[n.directory,l],e[1]=l,e[2]=a,e[3]=u):(a=e[2],u=e[3]),p.useEffect(a,u);let f,d;e[4]!==r?(f=()=>(gt(r),Tn),d=[r],e[4]=r,e[5]=f,e[6]=d):(f=e[5],d=e[6]),p.useEffect(f,d),$t(),Mn();let y;e[7]===Symbol.for("react.memo_cache_sentinel")?(y={enabled:!0},e[7]=y):y=e[7],Ut(y),Gt();let j;e[8]===Symbol.for("react.memo_cache_sentinel")?(j=ht.getSdkClient(),e[8]=j):j=e[8];const D=l||n.directory||"";let g;e[9]===Symbol.for("react.memo_cache_sentinel")?(g=c.jsx(Ht,{delayDuration:300,skipDelayDuration:150,children:c.jsxs("div",{className:"h-full text-foreground bg-background",children:[c.jsx(Wn,{config:n}),c.jsx(Ft,{})]})}),e[9]=g):g=e[9];let w;e[10]!==r?(w=c.jsx(Vt,{apis:r,children:g}),e[10]=r,e[11]=w):w=e[11];let x;return e[12]!==w||e[13]!==D?(x=c.jsx(Kt,{children:c.jsx(Jt,{sdk:j,directory:D,children:w})}),e[12]=w,e[13]=D,e[14]=x):x=e[14],x}function Tn(){return gt(null)}function zn(t){return t.currentDirectory}const Wn=t=>{const e=V.c(11),{config:r}=t,s=On(r);let n;e[0]!==r?(n=c.jsx(Nn,{config:r}),e[0]=r,e[1]=n):n=e[1];let l,a;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsx(Ln,{}),a=c.jsx(qt,{embeddedBackgroundWorkEnabled:!0}),e[2]=l,e[3]=a):(l=e[2],a=e[3]);const u=r.mode==="draft";let f;e[4]!==r.mode||e[5]!==s||e[6]!==u?(f=c.jsx(pn,{mode:r.mode,autoOpenDraft:u,unavailable:s}),e[4]=r.mode,e[5]=s,e[6]=u,e[7]=f):f=e[7];let d;return e[8]!==n||e[9]!==f?(d=c.jsxs(c.Fragment,{children:[n,l,a,f]}),e[8]=n,e[9]=f,e[10]=d):d=e[10],d};function $n(t){return t.currentSessionId}function Un(t){return t.currentDirectory}function Gn(t){return t.currentSessionId}const Hn=()=>{nn(),Et().then(()=>{Promise.all([Mt(),rn()]).catch(t=>{console.error("[mini-chat-main] settings init failed:",t)}),sn(),on(),an()}).catch(t=>{console.error("[mini-chat-main] appearance init failed:",t)})};function Xn(t){Hn();const e=document.getElementById("root");if(!e)throw new Error("Root element not found");Dt.createRoot(e).render(c.jsx(kt.StrictMode,{children:c.jsx(Yt,{children:c.jsx(Zt,{children:c.jsx(en,{children:c.jsx(tn,{children:c.jsx(Bn,{apis:t})})})})})}))}export{Xn as renderElectronMiniChatApp};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/useAppFontEffects-B66TruVB.js","assets/vendor-.bun-By2L9XvG.js","assets/vendor--Dwc_TRgJ.css","assets/index-AsCHiJ5P.js","assets/index-Bv4711NQ.css"])))=>i.map(i=>d[i]);
2
+ import{e as V,j as c,R as p,_ as jt,G as Dt,H as kt}from"./vendor-.bun-By2L9XvG.js";import{u as le,a5 as Pt,x as fe,b as ut,v as Ct,o as ht,d as gt,i as Et,s as Mt}from"./index-AsCHiJ5P.js";import{eR as Rt,u as St,dJ as At,z as v,D as Fe,Q as _,cc as ft,a1 as Nt,a as Lt,f as vt,aL as Ot,aN as Bt,m as Tt,I as He,B as yt,aR as F,a2 as zt,aP as Wt,U as $t,V as Ut,W as Gt,_ as Ht,a0 as Ft,Z as Vt,X as Kt,Y as Jt,eS as qt,cK as Qt,O as Xt,af as Yt,ag as Zt,ah as en,ai as tn,aj as nn,ak as rn,al as sn,am as on,an}from"./useAppFontEffects-B66TruVB.js";import{C as cn,S as ln,W as dn}from"./SessionSwitcherDropdown-Cn_yoQrm.js";const un=t=>{const e=V.c(3),{mode:r,children:s}=t;let n;return e[0]!==s||e[1]!==r?(n=c.jsx(Rt.Provider,{value:r,children:s}),e[0]=s,e[1]=r,e[2]=n):n=e[2],n},fn=t=>{const e=typeof t=="string"?t.trim():"";if(!e)return"";const r=typeof window<"u"?window.__OPENCHAMBER_HOME__:"";if(r&&e===r)return"~";if(r&&e.startsWith(`${r}/`))return`~/${e.slice(r.length+1)}`;const s=e.split("/").filter(Boolean);return s.length<=3?e:`.../${s.slice(-3).join("/")}`},U=t=>{const e=typeof t=="string"?t.trim():"";if(!e)return"";const r=e.replace(/\\/g,"/");return r==="/"?"/":r.replace(/\/+$/,"")},mn=t=>{const e=V.c(125),{mode:r}=t,{t:s}=St(),n=v(hn),l=v(yn),a=v(wn),u=le(gn),f=Fe(Sn),d=Fe(vn),y=_(xn),j=_(bn),D=ft(),g=Nt(n??""),w=Lt(),x=vt(_n);let z;e[0]!==n?(z=o=>n?o.worktreeMetadata.get(n)?.path??"":"",e[0]=n,e[1]=z):z=e[1];const R=v(z);let A;e[2]!==n?(A=o=>n?o.worktreeMetadata.get(n)?.branch?.trim()??null:null,e[2]=n,e[3]=A):A=e[3];const O=v(A);let W;e[4]!==n?(W=o=>n?o.getAttachment(n):void 0,e[4]=n,e[5]=W):W=e[5];const i=Ot(W),N=v(In),[m,I]=p.useState(!1),B=typeof window<"u"?window.__OPENCHAMBER_MACOS_MAJOR__??0:0,L=Number.isFinite(B)&&B>0,Ve=typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__&&window.__OPENCHAMBER_PLATFORM__==="win32",mt=L?B>=26?"h-12":B<=15?"h-14":"":"";let $;e[6]!==n||e[7]!==D?($=n?D.find(o=>o.id===n)??null:null,e[6]=n,e[7]=D,e[8]=$):$=e[8];const E=$,K=E?.worktreeMetadata??null;let me,pe;e[9]===Symbol.for("react.memo_cache_sentinel")?(me=()=>{Pt()&&fe("desktop_get_window_pinned").then(o=>{typeof o?.pinned=="boolean"&&I(o.pinned)})},pe=[],e[9]=me,e[10]=pe):(me=e[9],pe=e[10]),p.useEffect(me,pe);let he;e[11]!==l||e[12]!==r||e[13]!==E?.title||e[14]!==s?(he=E?.title?.trim()||s(l||r==="draft"?"miniChat.header.newSession":"miniChat.header.session"),e[11]=l,e[12]=r,e[13]=E?.title,e[14]=s,e[15]=he):he=e[15];const Ke=he,Je=E?.directory??null;let ye;e[16]!==Je?(ye=U(Je),e[16]=Je,e[17]=ye):ye=e[17];const we=ye,qe=R||K?.path||i?.cwd||i?.worktreeRoot||"";let ge;e[18]!==qe?(ge=U(qe),e[18]=qe,e[19]=ge):ge=e[19];const Se=ge;let ve;e[20]!==u?(ve=U(u),e[20]=u,e[21]=ve):ve=e[21];const k=Se||we||N||ve;let xe;e[22]!==k?(xe=fn(k),e[22]=k,e[23]=xe):xe=e[23];const xt=xe;let be;e[24]!==we||e[25]!==Se?(be=o=>{const h=U(Se||we||"");if(!h)return null;for(const C of o.availableWorktreesByProject.values()){const b=C.find(T=>U(T.path)===h)?.branch?.trim();if(b)return b}return null},e[24]=we,e[25]=Se,e[26]=be):be=e[26];const Qe=v(be);let _e,Ie;e[27]!==x||e[28]!==k||e[29]!==w.git?(_e=()=>{k&&x(k,w.git).catch(jn)},Ie=[x,k,w.git],e[27]=x,e[28]=k,e[29]=w.git,e[30]=_e,e[31]=Ie):(_e=e[30],Ie=e[31]),p.useEffect(_e,Ie),K?.projectDirectory,i?.worktreeRoot;let Xe;e:{const o=K?.projectDirectory??i?.worktreeRoot??null;let h;e[32]!==o?(h=U(o),e[32]=o,e[33]=h):h=e[33];const S=h||k;if(!S){Xe=null;break e}let b;e[34]!==S||e[35]!==f?(b=f.map(Dn).filter(T=>T.normalizedPath&&(T.normalizedPath===S||S.startsWith(`${T.normalizedPath}/`))).sort(kn)[0]??null,e[34]=S,e[35]=f,e[36]=b):b=e[36],Xe=b}const bt=Xe;let je;e:{const o=bt??d;if(!o){je=xt||"OpenChamber";break e}let h;e[37]!==o.label?(h=o.label?.trim(),e[37]=o.label,e[38]=h):h=e[38];const C=h;if(C){je=C;break e}let S;e[39]!==o.path?(S=o.path.split(/[\\/]/).filter(Boolean).at(-1)??o.path,e[39]=o.path,e[40]=S):S=e[40],je=S}const Ye=je,Ze=Bt(k||null);let De;e[41]!==Qe||e[42]!==Ze||e[43]!==K?.branch||e[44]!==i?.branch||e[45]!==O?(De=Ze||O||K?.branch?.trim()||i?.branch?.trim()||Qe,e[41]=Qe,e[42]=Ze,e[43]=K?.branch,e[44]=i?.branch,e[45]=O,e[46]=De):De=e[46];const et=De,ke=et&&et!=="HEAD"?et:null;let Pe;e[47]!==y?(Pe=y(),e[47]=y,e[48]=Pe):Pe=e[48];const pt=Pe;let tt;e:{for(let o=g.length-1;o>=0;o=o-1,o){const h=g[o];if(h.role!=="assistant"||typeof h.providerID!="string"||typeof h.modelID!="string")continue;const S=j.find(b=>b.id===h.providerID)?.models.find(b=>b.id===h.modelID);if(S){tt=S;break e}}tt=void 0}const _t=tt,Ce=pt?.limit?pt:_t,J=Ce&&typeof Ce.limit=="object"&&Ce.limit!==null?Ce.limit:null,G=J&&typeof J.context=="number"?J.context:0,de=J&&typeof J.output=="number"?J.output:0;let Ee;e:{if(!n||g.length===0){Ee=null;break e}let o,h;for(let ue=g.length-1;ue>=0;ue=ue-1,ue){const dt=g[ue];if(dt.role!=="assistant")continue;const H=dt.tokens;if(!H)continue;if(H.input+H.output+H.reasoning+(H.cache?.read??0)+(H.cache?.write??0)>0){o=H,h=dt.id;break}}if(!o){Ee=null;break e}const C=o.input+o.output+o.reasoning+(o.cache?.read??0)+(o.cache?.write??0),S=G>0?G:2e5;let b;e[49]!==G||e[50]!==C?(b=G>0?Math.round(C/G*100):0,e[49]=G,e[50]=C,e[51]=b):b=e[51];const T=b;let Ue;e[52]!==o.output||e[53]!==de?(Ue=de>0?Math.round(o.output/de*100):void 0,e[52]=o.output,e[53]=de,e[54]=Ue):Ue=e[54];const at=Ue,ct=G||0,lt=de||void 0;let Ge;e[55]!==h||e[56]!==at||e[57]!==T||e[58]!==ct||e[59]!==lt||e[60]!==S||e[61]!==C?(Ge={totalTokens:C,percentage:T,contextLimit:ct,outputLimit:lt,normalizedOutput:at,thresholdLimit:S,lastMessageId:h},e[55]=h,e[56]=at,e[57]=T,e[58]=ct,e[59]=lt,e[60]=S,e[61]=C,e[62]=Ge):Ge=e[62],Ee=Ge}const P=Ee,[M,nt]=p.useState(null);let Me;e[63]===Symbol.for("react.memo_cache_sentinel")?(Me={WebkitAppRegion:"drag"},e[63]=Me):Me=e[63];const It=Me;let Re;e[64]===Symbol.for("react.memo_cache_sentinel")?(Re={WebkitAppRegion:"no-drag"},e[64]=Re):Re=e[64];const rt=Re;let Ae,Ne;e[65]!==P||e[66]!==n?(Ae=()=>{if(!n){nt(Pn);return}if(P&&P.totalTokens>0){nt(o=>o&&o.totalTokens===P.totalTokens&&o.percentage===P.percentage&&o.contextLimit===P.contextLimit&&(o.outputLimit??0)===(P.outputLimit??0)&&(o.normalizedOutput??0)===(P.normalizedOutput??0)&&o.thresholdLimit===P.thresholdLimit&&o.lastMessageId===P.lastMessageId?o:P);return}nt(Cn)},Ne=[P,n],e[65]=P,e[66]=n,e[67]=Ae,e[68]=Ne):(Ae=e[67],Ne=e[68]),p.useEffect(Ae,Ne);const st=M&&M.contextLimit>0?Math.min(999,M.totalTokens/M.contextLimit*100):0;let Le;e[69]!==m?(Le=()=>{const o=!m;I(o),fe("desktop_set_window_pinned",{pinned:o}).catch(()=>{I(!o)})},e[69]=m,e[70]=Le):Le=e[70];const ot=Le;let Oe;e[71]!==u||e[72]!==n||e[73]!==a||e[74]!==k||e[75]!==E?(Oe=()=>{const o=n?{sessionId:n,directory:E?.directory??u??""}:{mode:"draft",directory:k||u||"",projectId:a};fe("desktop_focus_main_window",o).then(En)},e[71]=u,e[72]=n,e[73]=a,e[74]=k,e[75]=E,e[76]=Oe):Oe=e[76];const it=Oe;let Be;e[77]===Symbol.for("react.memo_cache_sentinel")?(Be=Tt("flex items-center gap-3 bg-background pr-3",L?"pl-[5.5rem]":"pl-3",Ve?"h-12":mt||"min-h-14"),e[77]=Be):Be=e[77];let q;e[78]!==s?(q=s("sessions.switcher.openAria"),e[78]=s,e[79]=q):q=e[79];let Q;e[80]!==Ke?(Q=c.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:Ke}),e[80]=Ke,e[81]=Q):Q=e[81];let X;e[82]!==Ye?(X=c.jsx("span",{className:"truncate",children:Ye}),e[82]=Ye,e[83]=X):X=e[83];let Y;e[84]!==ke?(Y=ke?c.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[c.jsx(He,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),c.jsx("span",{className:"truncate",children:ke})]}):null,e[84]=ke,e[85]=Y):Y=e[85];let Z;e[86]!==X||e[87]!==Y?(Z=c.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75",children:[X,Y]}),e[86]=X,e[87]=Y,e[88]=Z):Z=e[88];let ee;e[89]!==q||e[90]!==Q||e[91]!==Z?(ee=c.jsx(ln,{children:c.jsxs("button",{type:"button","aria-label":q,style:rt,className:"flex min-w-0 max-w-full flex-col items-start rounded-md px-1 py-0.5 text-left transition-colors hover:bg-interactive-hover/60 focus-visible:outline-none focus-visible:bg-interactive-hover/60",children:[Q,Z]})}),e[89]=q,e[90]=Q,e[91]=Z,e[92]=ee):ee=e[92];let Te;e[93]===Symbol.for("react.memo_cache_sentinel")?(Te=c.jsx("div",{className:"min-w-0 flex-1"}),e[93]=Te):Te=e[93];let te;e[94]!==st||e[95]!==M?(te=M&&M.totalTokens>0?c.jsx(cn,{totalTokens:M.totalTokens,percentage:st,colorPercentage:M.percentage,contextLimit:M.contextLimit,outputLimit:M.outputLimit??0,className:"h-9 shrink-0 pl-1 pr-1 typography-ui-label",valueClassName:"font-semibold leading-none",hideIcon:!0,showPercentIcon:!0,percentIconClassName:"h-4.5 w-4.5"}):null,e[94]=st,e[95]=M,e[96]=te):te=e[96];let ne;e[97]!==m||e[98]!==s?(ne=s(m?"miniChat.actions.unpinAria":"miniChat.actions.pinAria"),e[97]=m,e[98]=s,e[99]=ne):ne=e[99];let re;e[100]!==m||e[101]!==s?(re=s(m?"miniChat.actions.unpin":"miniChat.actions.pin"),e[100]=m,e[101]=s,e[102]=re):re=e[102];let se;e[103]!==m?(se=m?c.jsx(He,{name:"pushpin-2-fill",className:"h-4 w-4"}):c.jsx(He,{name:"pushpin-2",className:"h-4 w-4"}),e[103]=m,e[104]=se):se=e[104];let oe;e[105]!==ot||e[106]!==ne||e[107]!==re||e[108]!==se?(oe=c.jsx(yt,{type:"button",variant:"ghost",size:"icon",onClick:ot,"aria-label":ne,title:re,style:rt,children:se}),e[105]=ot,e[106]=ne,e[107]=re,e[108]=se,e[109]=oe):oe=e[109];let ie;e[110]!==s?(ie=s("miniChat.actions.openMainAria"),e[110]=s,e[111]=ie):ie=e[111];let ae;e[112]!==s?(ae=s("miniChat.actions.openMain"),e[112]=s,e[113]=ae):ae=e[113];let ze;e[114]===Symbol.for("react.memo_cache_sentinel")?(ze=c.jsx(He,{name:"external-link",className:"h-4 w-4"}),e[114]=ze):ze=e[114];let ce;e[115]!==it||e[116]!==ie||e[117]!==ae?(ce=c.jsx(yt,{type:"button",variant:"ghost",size:"icon",onClick:it,"aria-label":ie,title:ae,style:rt,children:ze}),e[115]=it,e[116]=ie,e[117]=ae,e[118]=ce):ce=e[118];let We;e[119]===Symbol.for("react.memo_cache_sentinel")?(We=c.jsx(dn,{visible:Ve}),e[119]=We):We=e[119];let $e;return e[120]!==ee||e[121]!==te||e[122]!==oe||e[123]!==ce?($e=c.jsxs("header",{className:Be,style:It,children:[ee,Te,te,oe,ce,We]}),e[120]=ee,e[121]=te,e[122]=oe,e[123]=ce,e[124]=$e):$e=e[124],$e},pn=t=>{const e=V.c(9),{mode:r,autoOpenDraft:s,unavailable:n}=t,l=s===void 0?!1:s,a=n===void 0?!1:n,{t:u}=St();let f;e[0]!==r?(f=c.jsx(mn,{mode:r}),e[0]=r,e[1]=f):f=e[1];let d;e[2]!==l||e[3]!==u||e[4]!==a?(d=c.jsx("main",{className:"min-h-0 flex-1",children:a?c.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center typography-ui-label text-muted-foreground",children:c.jsxs("div",{className:"max-w-sm rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-4 py-3",children:[c.jsx("div",{className:"font-medium text-foreground",children:u("miniChat.unavailable.title")}),c.jsx("div",{className:"mt-1 typography-small text-muted-foreground",children:u("miniChat.unavailable.description")})]})}):c.jsx(un,{mode:"mini-chat",children:c.jsx(At,{autoOpenDraft:l})})}),e[2]=l,e[3]=u,e[4]=a,e[5]=d):d=e[5];let y;return e[6]!==f||e[7]!==d?(y=c.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:[f,d]}),e[6]=f,e[7]=d,e[8]=y):y=e[8],y};function hn(t){return t.currentSessionId}function yn(t){return!!t.newSessionDraft?.open}function wn(t){return t.newSessionDraft?.selectedProjectId??null}function gn(t){return t.currentDirectory}function Sn(t){return t.projects}function vn(t){return t.getActiveProject()}function xn(t){return t.getCurrentModel}function bn(t){return t.providers}function _n(t){return t.ensureStatus}function In(t){return t.newSessionDraft?.open?U(t.newSessionDraft.bootstrapPendingDirectory??t.newSessionDraft.directoryOverride??""):""}function jn(){}function Dn(t){return{...t,normalizedPath:U(t.path)}}function kn(t,e){return e.path.length-t.path.length}function Pn(t){return t===null?t:null}function Cn(t){return t===null?t:null}function En(t){return t?.focused===!0?fe("desktop_close_current_window"):null}const wt=()=>{document.querySelector('textarea[data-chat-input="true"]')?.focus()},Mn=()=>{const t=ut(n=>n.shortcutOverrides),e=le(n=>n.currentDirectory),r=Fe(n=>n.getActiveProject()),s=v(n=>n.openNewSessionDraft);p.useEffect(()=>{const n=a=>Wt(a,t),l=a=>{if(F(a,n("focus_input"))){a.preventDefault(),wt();return}if(Ct()&&F(a,n("new_mini_chat"))){a.preventDefault(),fe("desktop_open_draft_mini_chat_window",{directory:e||r?.path||"",projectId:r?.id??null})?.catch(d=>{console.warn("[mini-chat-shortcuts] failed to open draft mini chat window",d)});return}if(F(a,n("new_chat"))){a.preventDefault(),s({selectedProjectId:r?.id??null,directoryOverride:e||r?.path||null,preserveDirectoryOverride:!!(e||r?.path)}),wt();return}if(F(a,n("open_model_selector"))){a.preventDefault();const{isModelSelectorOpen:d,setModelSelectorOpen:y}=ut.getState();y(!d);return}if(F(a,n("cycle_thinking_variant"))){const d=_.getState();if(d.getCurrentModelVariants().length===0)return;a.preventDefault(),d.cycleCurrentVariant();const j=_.getState().currentVariant,D=v.getState().currentSessionId,g=_.getState().currentAgentName,w=_.getState().currentProviderId,x=_.getState().currentModelId;D&&g&&w&&x&&zt.getState().saveAgentModelVariantForSession(D,g,w,x,j);return}const u=F(a,n("cycle_favorite_model_forward")),f=F(a,n("cycle_favorite_model_backward"));if(u||f){const{favoriteModels:d,addRecentModel:y}=ut.getState();if(d.length===0)return;a.preventDefault();const{currentProviderId:j,currentModelId:D,setProvider:g,setModel:w}=_.getState(),x=d.findIndex(A=>A.providerID===j&&A.modelID===D),R=d[(x+(u?1:-1)+d.length)%d.length];g(R.providerID),w(R.modelID),y(R.providerID,R.modelID)}};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[r?.id,r?.path,e,s,t])},Rn="openchamber:mini-chat-presence",An=()=>{const t=typeof window<"u"?new URLSearchParams(window.location.search):new URLSearchParams,e=t.get("mode")==="session"?"session":"draft",r=t.get("sessionId")?.trim()||null,s=t.get("directory")?.trim()||null,n=t.get("projectId")?.trim()||null;return{mode:e,sessionId:r,directory:s,projectId:n}},Nn=({config:t})=>{const e=ft(),r=le(i=>i.currentDirectory),s=le(i=>i.setDirectory),n=Fe(i=>i.projects),l=v(i=>i.currentSessionId),a=v(i=>!!i.newSessionDraft?.open),u=v(i=>i.newSessionDraft?.open?i.newSessionDraft.bootstrapPendingDirectory??i.newSessionDraft.directoryOverride??"":""),f=v(i=>i.setCurrentSession),d=v(i=>i.openNewSessionDraft),y=_(i=>i.initializeApp),j=_(i=>i.isInitialized),D=_(i=>i.isConnected),g=_(i=>i.loadProviders),w=_(i=>i.loadAgents),x=_(i=>i.providers.length),z=_(i=>i.agents.length),R=Qt();p.useEffect(()=>{y()},[y]),p.useEffect(()=>{if(j)return;let i=!0,N=0;const m=window.setInterval(()=>{if(i){if(N+=1,N>10){window.clearInterval(m);return}_.getState().isInitialized||_.getState().initializeApp()}},1e3);return()=>{i=!1,window.clearInterval(m)}},[j]);const A=p.useRef(!1);p.useEffect(()=>{if(!A.current&&t.mode==="session"&&t.directory){if(r===t.directory){A.current=!0;return}s(t.directory,{showOverlay:!1}),A.current=!0}},[t.directory,t.mode,r,s]),p.useEffect(()=>{t.mode!=="draft"||!a||l||!u||r===u||s(u,{showOverlay:!1})},[t.mode,r,l,u,a,s]),p.useEffect(()=>{D&&(x===0&&g({source:"electronMiniChat:recovery"}),z===0&&w({source:"electronMiniChat:recovery"}))},[z,D,w,g,x]);const O=p.useRef(!1);p.useEffect(()=>{if(O.current||t.mode!=="session"||!t.sessionId)return;if(l===t.sessionId){O.current=!0;return}if(l){O.current=!0;return}const i=e.find(m=>m.id===t.sessionId);if(!i){R.ensureSessionRenderable(t.sessionId);return}const N=i.directory??t.directory;f(t.sessionId,N),O.current=!0},[t,l,e,f,R]),p.useEffect(()=>{const i=N=>{const m=N.detail,I=typeof m?.sessionId=="string"?m.sessionId.trim():"";if(!I||v.getState().currentSessionId===I)return;const B=typeof m?.directory=="string"&&m.directory.trim().length>0?m.directory.trim():e.find(L=>L.id===I)?.directory??null;R.ensureSessionRenderable(I),f(I,B),O.current=!0};return window.addEventListener("openchamber:open-session",i),()=>window.removeEventListener("openchamber:open-session",i)},[e,f,R]),p.useEffect(()=>{t.mode!=="draft"||a||l||d({selectedProjectId:t.projectId,directoryOverride:t.directory,preserveDirectoryOverride:!!t.directory})},[t,l,a,d]),p.useEffect(()=>{if(n.length===0)return;let i=!1;return(async()=>{const m=new Map,I=[];await Promise.all(n.map(async B=>{const L=B.path.replace(/\\/g,"/").replace(/\/+$/,"");if(L)try{if(!(vt.getState().directories.get(L)?.isGitRepo??await jt(()=>import("./useAppFontEffects-B66TruVB.js").then(E=>E.f8),__vite__mapDeps([0,1,2,3,4])).then(E=>E.checkIsGitRepository(L))))return;const $=await Xt({id:B.id,path:L});if(i||$.length===0)return;m.set(L,$),I.push(...$)}catch{}})),!i&&v.setState({availableWorktrees:I,availableWorktreesByProject:m})})(),()=>{i=!0}},[n]);const W=p.useRef(!1);return p.useEffect(()=>{if(W.current||!j)return;const i=()=>{if(W.current)return;W.current=!0;const I=typeof document<"u"?document.getElementById("initial-loading"):null;I&&(I.classList.add("fade-out"),window.setTimeout(()=>I.remove(),300))},N=t.mode==="session"?l===t.sessionId:a,m=window.setTimeout(i,N?100:1500);return()=>window.clearTimeout(m)},[j,t.mode,t.sessionId,l,a]),null},Ln=()=>{const t=V.c(4),e=v($n),r=le(Un);let s,n;return t[0]!==r||t[1]!==e?(s=()=>{if(!e||!r||typeof BroadcastChannel>"u")return;const l=new BroadcastChannel(Rn),a=d=>{l.postMessage({type:"mini-chat-session-presence",sessionId:e,directory:r,viewed:d})};a(!0);const u=window.setInterval(()=>a(!0),5e3),f=()=>a(!1);return window.addEventListener("beforeunload",f),()=>{window.clearInterval(u),window.removeEventListener("beforeunload",f),a(!1),l.close()}},n=[r,e],t[0]=r,t[1]=e,t[2]=s,t[3]=n):(s=t[2],n=t[3]),p.useEffect(s,n),null},On=t=>{const e=V.c(6),r=ft(),s=v(Gn),[n,l]=p.useState(!1);let a,u;return e[0]!==t.mode||e[1]!==t.sessionId||e[2]!==s||e[3]!==r?(a=()=>{if(t.mode!=="session"||!t.sessionId||s===t.sessionId){l(!1);return}if(r.some(d=>d.id===t.sessionId)){l(!1);return}const f=window.setTimeout(()=>l(!0),5e3);return()=>window.clearTimeout(f)},u=[t.mode,t.sessionId,s,r],e[0]=t.mode,e[1]=t.sessionId,e[2]=s,e[3]=r,e[4]=a,e[5]=u):(a=e[4],u=e[5]),p.useEffect(a,u),n};function Bn(t){const e=V.c(15),{apis:r}=t;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=An(),e[0]=s):s=e[0];const n=s,l=le(zn);let a,u;e[1]!==l?(a=()=>{ht.setDirectory(l||n.directory||void 0)},u=[n.directory,l],e[1]=l,e[2]=a,e[3]=u):(a=e[2],u=e[3]),p.useEffect(a,u);let f,d;e[4]!==r?(f=()=>(gt(r),Tn),d=[r],e[4]=r,e[5]=f,e[6]=d):(f=e[5],d=e[6]),p.useEffect(f,d),$t(),Mn();let y;e[7]===Symbol.for("react.memo_cache_sentinel")?(y={enabled:!0},e[7]=y):y=e[7],Ut(y),Gt();let j;e[8]===Symbol.for("react.memo_cache_sentinel")?(j=ht.getSdkClient(),e[8]=j):j=e[8];const D=l||n.directory||"";let g;e[9]===Symbol.for("react.memo_cache_sentinel")?(g=c.jsx(Ht,{delayDuration:300,skipDelayDuration:150,children:c.jsxs("div",{className:"h-full text-foreground bg-background",children:[c.jsx(Wn,{config:n}),c.jsx(Ft,{})]})}),e[9]=g):g=e[9];let w;e[10]!==r?(w=c.jsx(Vt,{apis:r,children:g}),e[10]=r,e[11]=w):w=e[11];let x;return e[12]!==w||e[13]!==D?(x=c.jsx(Kt,{children:c.jsx(Jt,{sdk:j,directory:D,children:w})}),e[12]=w,e[13]=D,e[14]=x):x=e[14],x}function Tn(){return gt(null)}function zn(t){return t.currentDirectory}const Wn=t=>{const e=V.c(11),{config:r}=t,s=On(r);let n;e[0]!==r?(n=c.jsx(Nn,{config:r}),e[0]=r,e[1]=n):n=e[1];let l,a;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsx(Ln,{}),a=c.jsx(qt,{embeddedBackgroundWorkEnabled:!0}),e[2]=l,e[3]=a):(l=e[2],a=e[3]);const u=r.mode==="draft";let f;e[4]!==r.mode||e[5]!==s||e[6]!==u?(f=c.jsx(pn,{mode:r.mode,autoOpenDraft:u,unavailable:s}),e[4]=r.mode,e[5]=s,e[6]=u,e[7]=f):f=e[7];let d;return e[8]!==n||e[9]!==f?(d=c.jsxs(c.Fragment,{children:[n,l,a,f]}),e[8]=n,e[9]=f,e[10]=d):d=e[10],d};function $n(t){return t.currentSessionId}function Un(t){return t.currentDirectory}function Gn(t){return t.currentSessionId}const Hn=()=>{nn(),Et().then(()=>{Promise.all([Mt(),rn()]).catch(t=>{console.error("[mini-chat-main] settings init failed:",t)}),sn(),on(),an()}).catch(t=>{console.error("[mini-chat-main] appearance init failed:",t)})};function Xn(t){Hn();const e=document.getElementById("root");if(!e)throw new Error("Root element not found");Dt.createRoot(e).render(c.jsx(kt.StrictMode,{children:c.jsx(Yt,{children:c.jsx(Zt,{children:c.jsx(en,{children:c.jsx(tn,{children:c.jsx(Bn,{apis:t})})})})})}))}export{Xn as renderElectronMiniChatApp};
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/useAppFontEffects-BPhei6aO.js","assets/vendor-.bun-By2L9XvG.js","assets/vendor--Dwc_TRgJ.css","assets/index-DJHN0H4h.js","assets/index-DxqTiFfR.css"])))=>i.map(i=>d[i]);
2
- import{R as d,j as t,e as ae,P as ot,K as St,f as Ls,g as ls,B as $s,Q as Os,r as Ws,i as Gs,F as Vs,U as Us,Z as Hs,a as Ct,p as cs,k as Ks,u as ds,l as ft,s as us,m as fs,n as ms,o as yt,D as hs,q as ps,S as gs,v as xs,t as bs,w as vs,C as ys,M as js,x as jt,J as ws,y as Qs,z as Lt,A as Et,E as $t,V as qs,_ as Ys,G as Js,H as Xs}from"./vendor-.bun-By2L9XvG.js";import{g as Zs,r as er,a as tr,u as Je,b as Pt,d as Ot,o as Wt,e as sr,i as rr,s as nr}from"./index-DJHN0H4h.js";import{u as de,a as mt,b as At,c as Dt,d as ks,e as or,f as Re,t as Z,s as ir,g as ar,h as lr,i as cr,j as dr,I as me,k as Ns,B as Me,l as qe,S as Ue,m as ee,n as Rt,o as ur,p as Gt,q as Mt,r as Vt,F as fr,v as Ut,w as mr,J as hr,x as Ss,y as Cs,z as Se,A as pr,C as gr,M as Es,D as Pe,P as Ps,E as As,G as Ds,H as xr,K as br,L as vr,N as yr,O as Rs,Q as Ee,R as jr,T as wr,U as kr,V as Nr,W as Sr,X as Ve,Y as Cr,Z as Er,_ as Pr,$ as Ar,a0 as Dr,a1 as Rr,a2 as Mr,a3 as Ir,a4 as Ht,a5 as Kt,a6 as _r,a7 as zr,a8 as Fr,a9 as Tr,aa as Br,ab as Lr,ac as $r,ad as Or,ae as Wr,af as Gr,ag as Vr,ah as Ur,ai as Hr,aj as Kr,ak as Qr,al as qr,am as Yr,an as Jr}from"./useAppFontEffects-BPhei6aO.js";import{S as Xr,C as Zr,a as en,P as tn,b as sn,D as rn,N as nn,u as on,c as an,O as ln,d as cn,e as Qt,f as ct,g as dn,M as un,h as fn,A as mn,i as Ge,j as hn,Q as pn,k as gn,l as xn,m as bn,n as vn}from"./NewWorktreeDialog-D7l2VA7o.js";import"./mobileLayoutPreference-Dio-WWkI.js";const yn=s=>(s||"").replace(/\\/g,"/").replace(/\/+$/g,""),jn=s=>{const e=s.index?.trim();return!!(e&&e!=="?")},wn=s=>{const e=s.working_dir?.trim(),r=s.index?.trim();return!!(e||r==="?")},qt=(s,e)=>e?`${s}\0staged`:s,kn=({onClose:s,initialDiffPath:e,initialDiffStaged:r=!1})=>{const{t:o}=de(),{git:i}=mt(),n=yn(At()??null),l=Dt(n||null),m=ks(n||null),c=or(n||null),u=Re(w=>w.setActiveDirectory),f=Re(w=>w.ensureAll),h=Re(w=>w.fetchStatus),g=Re(w=>w.fetchBranches),b=Re(w=>w.prefetchDiffs),k=Re(w=>w.getDiff),p=Re(w=>w.setDiff),[x,y]=d.useState(()=>e?{type:"diff",path:e,staged:r}:{type:"list"});d.useEffect(()=>{e&&y(w=>w.type==="diff"&&w.path===e&&w.staged===r?w:{type:"diff",path:e,staged:r})},[e,r]);const[C,E]=d.useState(null),[j,v]=d.useState(null),[_,N]=d.useState(""),[T,P]=d.useState(new Set),[M,z]=d.useState(!1),[O,B]=d.useState(!1),[K,W]=d.useState([]),[S,L]=d.useState([]),[V,Q]=d.useState([]),[G,R]=d.useState(null),[U,X]=d.useState(null),[le,xe]=d.useState(0),te=d.useMemo(()=>{const w=l?.files??[],A=new Map;for(const $ of w)A.set($.path,$);return Array.from(A.values()).sort(($,ce)=>$.path.localeCompare(ce.path))},[l?.files]),D=d.useMemo(()=>te.filter(jn),[te]),q=d.useMemo(()=>te.filter(wn),[te]),se=d.useMemo(()=>{if(V.length>0)return V;const w=l?.tracking?.includes("/")?l.tracking.split("/")[0]:null;return w||G?[{name:w||"origin",fetchUrl:G??"",pushUrl:G??""}]:[]},[G,V,l?.tracking]),he=Re(d.useCallback(w=>!n||x.type!=="diff"?null:w.directories.get(n)?.diffCache.get(qt(x.path,x.staged))??null,[n,x])),we=d.useMemo(()=>x.type!=="diff"?null:te.find(w=>w.path===x.path)??null,[te,x]),Y=d.useCallback(async(w=!0)=>{if(n)try{await Promise.all([h(n,i),g(n,i)])}catch(A){w&&Z.error(A instanceof Error?A.message:o("gitView.toast.refreshRepositoryFailed"))}},[n,g,h,i,o]),pe=d.useCallback(async()=>{if(!n){Q([]),R(null);return}try{const[w,A]=await Promise.all([i.getRemotes(n).catch(()=>[]),i.getRemoteUrl?i.getRemoteUrl(n).catch(()=>null):Promise.resolve(null)]);Q(w),R(A)}catch{Q([]),R(null)}},[n,i]);d.useEffect(()=>{n&&(u(n),f(n,i))},[n,f,i,u]),d.useEffect(()=>{pe()},[pe]),d.useEffect(()=>{if(!n||te.length===0)return;const w=Array.from(new Set([...D.map($=>$.path),...S,...te.slice(0,20).map($=>$.path)])).filter(Boolean);if(w.length===0)return;const A=window.setTimeout(()=>{b(n,i,w,{maxFiles:40})},120);return()=>window.clearTimeout(A)},[te,n,i,b,D,S]),d.useEffect(()=>{if(x.type!=="diff"){X(null);return}const w=qt(x.path,x.staged);if(!n||k(n,w)){X(null);return}let A=!1;return X(null),i.getGitFileDiff(n,{path:x.path,staged:x.staged||void 0}).then($=>{A||p(n,w,{original:$.original??"",modified:$.modified??"",isBinary:$.isBinary})}).catch($=>{A||X($ instanceof Error?$.message:String($))}),()=>{A=!0}},[n,le,k,i,x,p]);const re=async(w,A)=>{if(n){E(w);try{const $=ce=>{const ve=`${ce.name}/`,Ce=l?.tracking?.startsWith(ve)?l.tracking.slice(ve.length):void 0;return{remote:ce.name,branch:Ce,rebase:!0}};if(w==="fetch"){if(!A)throw new Error(o("mobile.changes.noRemote"));await i.gitFetch(n,{remote:A.name}),Z.success(o("gitView.toast.fetchedFromRemote",{name:A.name}))}else if(w==="sync"){if(!A)throw new Error(o("mobile.changes.noRemote"));await i.gitFetch(n,{remote:A.name});const ce=await i.getGitStatus(n);if((ce.behind??0)>0){if((ce.files?.length??0)>0){Z.error(o("gitView.toast.commitOrStashBeforeSync"));return}await i.gitPull(n,$(A))}((await i.getGitStatus(n)).ahead??0)>0&&await i.gitPush(n),Z.success(o("gitView.toast.alreadyUpToDate"))}await Y(!1),await pe()}catch($){Z.error($ instanceof Error?$.message:o("gitView.toast.syncActionFailed",{action:o("gitView.sync.syncChanges")}))}finally{E(null)}}},ie=d.useCallback(async(w,A)=>{if(!(!n||w.length===0))try{A==="stage"?w.length>1?await ir(n,w):await ar(n,w[0]):w.length>1?await lr(n,w):await cr(n,w[0]),await Y(!1)}catch($){Z.error($ instanceof Error?$.message:o(A==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed"))}},[n,Y,o]),ge=d.useCallback((w,A=!1)=>{y({type:"diff",path:w,staged:A})},[]),be=d.useCallback(async w=>{if(n){P(A=>new Set(A).add(w));try{await i.revertGitFile(n,w),Z.success(o("gitView.toast.revertedFile",{path:w})),await Y(!1)}catch(A){Z.error(A instanceof Error?A.message:o("gitView.toast.revertFailed"))}finally{P(A=>{const $=new Set(A);return $.delete(w),$})}}},[n,i,Y,o]),ke=d.useCallback(async w=>{if(!n||w.length===0||M)return;const A=Array.from(new Set(w));z(!0),P(new Set(A));try{await Promise.all(A.map($=>i.revertGitFile(n,$))),await Y(!1),Z.success(A.length===1?o("gitView.toast.revertedFilesSingle",{count:A.length}):o("gitView.toast.revertedFilesPlural",{count:A.length}))}catch($){Z.error($ instanceof Error?$.message:o("gitView.toast.revertFailed"))}finally{P(new Set),z(!1)}},[n,i,M,Y,o]),Ie=d.useCallback(w=>{const A=w.map($=>$.trim()).filter(Boolean);if(A.length===0){W([]);return}N($=>`${$.trim()}${$.trim()?`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/useAppFontEffects-B66TruVB.js","assets/vendor-.bun-By2L9XvG.js","assets/vendor--Dwc_TRgJ.css","assets/index-AsCHiJ5P.js","assets/index-Bv4711NQ.css"])))=>i.map(i=>d[i]);
2
+ import{R as d,j as t,e as ae,P as ot,K as St,f as Ls,g as ls,B as $s,Q as Os,r as Ws,i as Gs,F as Vs,U as Us,Z as Hs,a as Ct,p as cs,k as Ks,u as ds,l as ft,s as us,m as fs,n as ms,o as yt,D as hs,q as ps,S as gs,v as xs,t as bs,w as vs,C as ys,M as js,x as jt,J as ws,y as Qs,z as Lt,A as Et,E as $t,V as qs,_ as Ys,G as Js,H as Xs}from"./vendor-.bun-By2L9XvG.js";import{g as Zs,r as er,a as tr,u as Je,b as Pt,d as Ot,o as Wt,e as sr,i as rr,s as nr}from"./index-AsCHiJ5P.js";import{u as de,a as mt,b as At,c as Dt,d as ks,e as or,f as Re,t as Z,s as ir,g as ar,h as lr,i as cr,j as dr,I as me,k as Ns,B as Me,l as qe,S as Ue,m as ee,n as Rt,o as ur,p as Gt,q as Mt,r as Vt,F as fr,v as Ut,w as mr,J as hr,x as Ss,y as Cs,z as Se,A as pr,C as gr,M as Es,D as Pe,P as Ps,E as As,G as Ds,H as xr,K as br,L as vr,N as yr,O as Rs,Q as Ee,R as jr,T as wr,U as kr,V as Nr,W as Sr,X as Ve,Y as Cr,Z as Er,_ as Pr,$ as Ar,a0 as Dr,a1 as Rr,a2 as Mr,a3 as Ir,a4 as Ht,a5 as Kt,a6 as _r,a7 as zr,a8 as Fr,a9 as Tr,aa as Br,ab as Lr,ac as $r,ad as Or,ae as Wr,af as Gr,ag as Vr,ah as Ur,ai as Hr,aj as Kr,ak as Qr,al as qr,am as Yr,an as Jr}from"./useAppFontEffects-B66TruVB.js";import{S as Xr,C as Zr,a as en,P as tn,b as sn,D as rn,N as nn,u as on,c as an,O as ln,d as cn,e as Qt,f as ct,g as dn,M as un,h as fn,A as mn,i as Ge,j as hn,Q as pn,k as gn,l as xn,m as bn,n as vn}from"./NewWorktreeDialog-Dj6KETex.js";import"./mobileLayoutPreference-Dio-WWkI.js";const yn=s=>(s||"").replace(/\\/g,"/").replace(/\/+$/g,""),jn=s=>{const e=s.index?.trim();return!!(e&&e!=="?")},wn=s=>{const e=s.working_dir?.trim(),r=s.index?.trim();return!!(e||r==="?")},qt=(s,e)=>e?`${s}\0staged`:s,kn=({onClose:s,initialDiffPath:e,initialDiffStaged:r=!1})=>{const{t:o}=de(),{git:i}=mt(),n=yn(At()??null),l=Dt(n||null),m=ks(n||null),c=or(n||null),u=Re(w=>w.setActiveDirectory),f=Re(w=>w.ensureAll),h=Re(w=>w.fetchStatus),g=Re(w=>w.fetchBranches),b=Re(w=>w.prefetchDiffs),k=Re(w=>w.getDiff),p=Re(w=>w.setDiff),[x,y]=d.useState(()=>e?{type:"diff",path:e,staged:r}:{type:"list"});d.useEffect(()=>{e&&y(w=>w.type==="diff"&&w.path===e&&w.staged===r?w:{type:"diff",path:e,staged:r})},[e,r]);const[C,E]=d.useState(null),[j,v]=d.useState(null),[_,N]=d.useState(""),[T,P]=d.useState(new Set),[M,z]=d.useState(!1),[O,B]=d.useState(!1),[K,W]=d.useState([]),[S,L]=d.useState([]),[V,Q]=d.useState([]),[G,R]=d.useState(null),[U,X]=d.useState(null),[le,xe]=d.useState(0),te=d.useMemo(()=>{const w=l?.files??[],A=new Map;for(const $ of w)A.set($.path,$);return Array.from(A.values()).sort(($,ce)=>$.path.localeCompare(ce.path))},[l?.files]),D=d.useMemo(()=>te.filter(jn),[te]),q=d.useMemo(()=>te.filter(wn),[te]),se=d.useMemo(()=>{if(V.length>0)return V;const w=l?.tracking?.includes("/")?l.tracking.split("/")[0]:null;return w||G?[{name:w||"origin",fetchUrl:G??"",pushUrl:G??""}]:[]},[G,V,l?.tracking]),he=Re(d.useCallback(w=>!n||x.type!=="diff"?null:w.directories.get(n)?.diffCache.get(qt(x.path,x.staged))??null,[n,x])),we=d.useMemo(()=>x.type!=="diff"?null:te.find(w=>w.path===x.path)??null,[te,x]),Y=d.useCallback(async(w=!0)=>{if(n)try{await Promise.all([h(n,i),g(n,i)])}catch(A){w&&Z.error(A instanceof Error?A.message:o("gitView.toast.refreshRepositoryFailed"))}},[n,g,h,i,o]),pe=d.useCallback(async()=>{if(!n){Q([]),R(null);return}try{const[w,A]=await Promise.all([i.getRemotes(n).catch(()=>[]),i.getRemoteUrl?i.getRemoteUrl(n).catch(()=>null):Promise.resolve(null)]);Q(w),R(A)}catch{Q([]),R(null)}},[n,i]);d.useEffect(()=>{n&&(u(n),f(n,i))},[n,f,i,u]),d.useEffect(()=>{pe()},[pe]),d.useEffect(()=>{if(!n||te.length===0)return;const w=Array.from(new Set([...D.map($=>$.path),...S,...te.slice(0,20).map($=>$.path)])).filter(Boolean);if(w.length===0)return;const A=window.setTimeout(()=>{b(n,i,w,{maxFiles:40})},120);return()=>window.clearTimeout(A)},[te,n,i,b,D,S]),d.useEffect(()=>{if(x.type!=="diff"){X(null);return}const w=qt(x.path,x.staged);if(!n||k(n,w)){X(null);return}let A=!1;return X(null),i.getGitFileDiff(n,{path:x.path,staged:x.staged||void 0}).then($=>{A||p(n,w,{original:$.original??"",modified:$.modified??"",isBinary:$.isBinary})}).catch($=>{A||X($ instanceof Error?$.message:String($))}),()=>{A=!0}},[n,le,k,i,x,p]);const re=async(w,A)=>{if(n){E(w);try{const $=ce=>{const ve=`${ce.name}/`,Ce=l?.tracking?.startsWith(ve)?l.tracking.slice(ve.length):void 0;return{remote:ce.name,branch:Ce,rebase:!0}};if(w==="fetch"){if(!A)throw new Error(o("mobile.changes.noRemote"));await i.gitFetch(n,{remote:A.name}),Z.success(o("gitView.toast.fetchedFromRemote",{name:A.name}))}else if(w==="sync"){if(!A)throw new Error(o("mobile.changes.noRemote"));await i.gitFetch(n,{remote:A.name});const ce=await i.getGitStatus(n);if((ce.behind??0)>0){if((ce.files?.length??0)>0){Z.error(o("gitView.toast.commitOrStashBeforeSync"));return}await i.gitPull(n,$(A))}((await i.getGitStatus(n)).ahead??0)>0&&await i.gitPush(n),Z.success(o("gitView.toast.alreadyUpToDate"))}await Y(!1),await pe()}catch($){Z.error($ instanceof Error?$.message:o("gitView.toast.syncActionFailed",{action:o("gitView.sync.syncChanges")}))}finally{E(null)}}},ie=d.useCallback(async(w,A)=>{if(!(!n||w.length===0))try{A==="stage"?w.length>1?await ir(n,w):await ar(n,w[0]):w.length>1?await lr(n,w):await cr(n,w[0]),await Y(!1)}catch($){Z.error($ instanceof Error?$.message:o(A==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed"))}},[n,Y,o]),ge=d.useCallback((w,A=!1)=>{y({type:"diff",path:w,staged:A})},[]),be=d.useCallback(async w=>{if(n){P(A=>new Set(A).add(w));try{await i.revertGitFile(n,w),Z.success(o("gitView.toast.revertedFile",{path:w})),await Y(!1)}catch(A){Z.error(A instanceof Error?A.message:o("gitView.toast.revertFailed"))}finally{P(A=>{const $=new Set(A);return $.delete(w),$})}}},[n,i,Y,o]),ke=d.useCallback(async w=>{if(!n||w.length===0||M)return;const A=Array.from(new Set(w));z(!0),P(new Set(A));try{await Promise.all(A.map($=>i.revertGitFile(n,$))),await Y(!1),Z.success(A.length===1?o("gitView.toast.revertedFilesSingle",{count:A.length}):o("gitView.toast.revertedFilesPlural",{count:A.length}))}catch($){Z.error($ instanceof Error?$.message:o("gitView.toast.revertFailed"))}finally{P(new Set),z(!1)}},[n,i,M,Y,o]),Ie=d.useCallback(w=>{const A=w.map($=>$.trim()).filter(Boolean);if(A.length===0){W([]);return}N($=>`${$.trim()}${$.trim()?`
3
3
 
4
4
  `:""}${A.join(`
5
5
  `)}`.trim()),W([])},[]),Ae=d.useCallback(async()=>{if(!n)return;const w=D.map(A=>A.path).sort();if(w.length===0){Z.error(o("gitView.toast.selectFileToDescribe"));return}B(!0);try{const{message:A}=await dr(n,w);N(A.subject?.trim()??""),W(Array.isArray(A.highlights)?A.highlights:[])}catch(A){Z.error(A instanceof Error?A.message:o("gitView.toast.generateCommitMessageFailed"))}finally{B(!1)}},[n,D,o]),Be=async(w={})=>{if(!n)return;if(!_.trim()){Z.error(o("gitView.toast.enterCommitMessage"));return}const A=D.map($=>$.path).sort();if(A.length===0){Z.error(o("gitView.toast.selectFileToCommit"));return}v(w.pushAfter?"commitAndPush":"commit");try{if(await i.createGitCommit(n,_.trim(),{files:A}),Z.success(o("gitView.toast.commitCreated")),N(""),W([]),w.pushAfter){const $=l?.tracking?.split("/")[0],ce=se.find(ze=>ze.name===$)??se[0];if(!ce)throw new Error(o("mobile.changes.noRemote"));E("sync");const ve=`${ce.name}/`,Ce=l?.tracking?.startsWith(ve)?l.tracking.slice(ve.length):void 0;await i.gitFetch(n,{remote:ce.name}),((await i.getGitStatus(n)).behind??0)>0&&await i.gitPull(n,{remote:ce.name,branch:Ce,rebase:!0}),((await i.getGitStatus(n)).ahead??0)>0&&await i.gitPush(n),await Y(!1),await pe()}else await Y(!1)}catch($){Z.error($ instanceof Error?$.message:o("gitView.toast.createCommitFailed"))}finally{v(null),w.pushAfter&&E(null)}},We=d.useMemo(()=>{const w=[];return D.length>0&&w.push({id:"staged",title:o("gitView.changes.stagedTitle"),entries:D,actionSymbol:"-",actionAllLabel:o("gitView.changes.unstageAllAria"),getActionLabel:A=>o("gitView.changes.unstageFileAria",{path:A}),onActionFile:A=>{ie([A],"unstage")},onActionAll:A=>{ie(A,"unstage")},onViewDiff:A=>ge(A,!0),onRevertFile:be,showRevertActions:!1,accent:!0}),q.length>0&&w.push({id:"unstaged",title:o("gitView.changes.title"),entries:q,actionSymbol:"+",actionAllLabel:o("gitView.changes.stageAllAria"),getActionLabel:A=>o("gitView.changes.stageFileAria",{path:A}),onActionFile:A=>{ie([A],"stage")},onActionAll:A=>{ie(A,"stage")},onViewDiff:A=>ge(A,!1),onRevertFile:be}),w},[be,ge,ie,D,o,q]),De=w=>t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[s?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":o("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(me,{name:"close",className:"size-5"})}):null,t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[t.jsx("h2",{className:"typography-ui-label text-foreground",children:o("mobile.nav.changes")}),t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:l?.current||n||""})]})]}),t.jsx("div",{className:"min-h-0 flex-1",children:w})]});return n?c&&m===null?De(t.jsx($e,{loading:!0,message:o("gitView.loading.checkingRepository")})):m===!1?De(t.jsx($e,{icon:!0,message:o("gitView.empty.notGitRepository"),description:o("gitView.empty.notGitRepositoryDescription")})):x.type==="diff"?t.jsx(Nn,{path:x.path,diff:he,fileExists:!!we,error:U,onBack:()=>y({type:"list"}),onRetry:()=>xe(w=>w+1)}):t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[s?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":o("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(me,{name:"close",className:"size-5"})}):null,t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[t.jsx("h2",{className:"typography-ui-label text-foreground",children:o("mobile.nav.changes")}),t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:l?.current||n})]}),t.jsx(Xr,{syncAction:C,remotes:se,onFetch:w=>{re("fetch",w)},onSync:w=>{re("sync",w)},disabled:j!==null||c,aheadCount:l?.ahead??0,behindCount:l?.behind??0,trackingRemoteName:l?.tracking?.split("/")[0],hasUncommittedChanges:te.length>0})]}),te.length>0?t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden px-4 pt-4",children:t.jsx(Zr,{groups:We,diffStats:l?.diffStats,revertingPaths:T,onRevertAll:ke,isRevertingAll:M,headerBackgroundClassName:"bg-transparent",onVisiblePathsChange:L})}),t.jsx("div",{className:"shrink-0 border-t border-border/50 px-4 pb-4 pt-3",children:t.jsx(en,{stagedCount:D.length,commitMessage:_,onCommitMessageChange:N,generatedHighlights:K,onInsertHighlights:Ie,onGenerateMessage:Ae,isGeneratingMessage:O,onCommit:()=>{Be({pushAfter:!1})},onCommitAndPush:()=>{Be({pushAfter:!0})},commitAction:j,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx($e,{icon:!0,message:o("gitView.empty.cleanTitle"),description:o("mobile.changes.cleanDescription")})})]}):De(t.jsx($e,{message:o("gitView.empty.selectSessionOrDirectory")}))},$e=s=>{const e=ae.c(13),{message:r,description:o,loading:i,icon:n}=s,l=i===void 0?!1:i,m=n===void 0?!1:n;let c;e[0]!==l?(c=l?t.jsx(me,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):null,e[0]=l,e[1]=c):c=e[1];let u;e[2]!==m?(u=m?t.jsx(me,{name:"git-branch",className:"size-6 text-muted-foreground"}):null,e[2]=m,e[3]=u):u=e[3];let f;e[4]!==r?(f=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:r}),e[4]=r,e[5]=f):f=e[5];let h;e[6]!==o?(h=o?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o}):null,e[6]=o,e[7]=h):h=e[7];let g;return e[8]!==c||e[9]!==u||e[10]!==f||e[11]!==h?(g=t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[c,u,f,h]})}),e[8]=c,e[9]=u,e[10]=f,e[11]=h,e[12]=g):g=e[12],g},Nn=s=>{const e=ae.c(24),{path:r,diff:o,fileExists:i,error:n,onBack:l,onRetry:m}=s,{t:c}=de();let u;e[0]!==r?(u=Ns(r)||"text",e[0]=r,e[1]=u):u=e[1];const f=u;let h;e[2]!==c?(h=c("header.actions.backAria"),e[2]=c,e[3]=h):h=e[3];let g;e[4]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(me,{name:"arrow-left",className:"size-5"}),e[4]=g):g=e[4];let b;e[5]!==l||e[6]!==h?(b=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":h,onClick:l,children:g}),e[5]=l,e[6]=h,e[7]=b):b=e[7];let k;e[8]!==r?(k=t.jsx("div",{className:"min-w-0 flex-1 px-2",children:t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:r})}),e[8]=r,e[9]=k):k=e[9];let p;e[10]!==b||e[11]!==k?(p=t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-3 border-b border-border/50 px-3 text-foreground",children:[b,k]}),e[10]=b,e[11]=k,e[12]=p):p=e[12];let x;e[13]!==o||e[14]!==n||e[15]!==i||e[16]!==f||e[17]!==m||e[18]!==r||e[19]!==c?(x=t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:i?n?t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:c("mobile.changes.diffDetail.loadFailed")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:n}),t.jsx(Me,{type:"button",size:"sm",variant:"outline",onClick:m,children:c("diffView.actions.retry")})]})}):o?o.isBinary?t.jsx($e,{icon:!0,message:c("diffView.binary.unavailable")}):qe(r)?t.jsx($e,{icon:!0,message:c("mobile.changes.diffDetail.imageUnavailable")}):t.jsx(Ue,{className:"h-full overflow-y-auto overflow-x-hidden p-3","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:t.jsx(tn,{original:o.original,modified:o.modified,language:f,fileName:r,renderSideBySide:!1,wrapLines:!0,layout:"inline"})}):t.jsx($e,{loading:!0,message:c("diffView.state.loadingDiff")}):t.jsx($e,{icon:!0,message:c("mobile.changes.diffDetail.missingTitle"),description:c("mobile.changes.diffDetail.missingDescription")})}),e[13]=o,e[14]=n,e[15]=i,e[16]=f,e[17]=m,e[18]=r,e[19]=c,e[20]=x):x=e[20];let y;return e[21]!==p||e[22]!==x?(y=t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[p,x]}),e[21]=p,e[22]=x,e[23]=y):y=e[23],y},Yt=25e4,Xe=s=>(s||"").replace(/\\/g,"/").replace(/\/+$/g,""),Oe=s=>{const e=Xe(s);return!e||e==="/"?e||"/":e.split("/").filter(Boolean).at(-1)??e},Sn=s=>{const e=Xe(s);if(!e||e==="/")return null;const r=e.lastIndexOf("/");return r<=0?e.startsWith("/")?"/":null:e.slice(0,r)},Cn=(s,e)=>{const r=Xe(s),o=Xe(e);return!o||r===o?Oe(r):r.startsWith(`${o}/`)?r.slice(o.length+1):r},En=s=>{if(typeof s!="number"||!Number.isFinite(s)||s<0)return"";if(s<1024)return`${s} B`;const e=["KB","MB","GB"];let r=s/1024;for(const o of e){if(r<1024||o===e[e.length-1])return`${r.toFixed(r>=10?0:1)} ${o}`;r/=1024}return""},Pn=s=>s.toLowerCase().endsWith(".svg")?"":Zs().authenticatedAsset("/api/fs/raw",{path:s}),An=s=>/\.(md|mdx|markdown)$/i.test(s),Dn=s=>/\.(json|jsonc)$/i.test(s),Rn=({onClose:s})=>{const{t:e}=de(),{files:r}=mt(),o=Xe(At()??null),[i,n]=d.useState(()=>({type:"browser",directory:o})),[l,m]=d.useState([]),[c,u]=d.useState(!1),[f,h]=d.useState(null),[g,b]=d.useState(""),[k,p]=d.useState([]),[x,y]=d.useState(!1),[C,E]=d.useState(""),[j,v]=d.useState(null),[_,N]=d.useState(!1),T=d.useRef(0);d.useEffect(()=>{o&&n(R=>R.type==="browser"&&R.directory?R:{type:"browser",directory:o})},[o]);const P=i.type==="browser"?i.directory:i.returnDirectory,M=d.useCallback(async R=>{if(!R)return;const U=T.current+1;T.current=U,u(!0),h(null);try{const X=await r.listDirectory(R);if(T.current!==U)return;m(X.entries.slice().sort((le,xe)=>le.isDirectory!==xe.isDirectory?le.isDirectory?-1:1:le.name.localeCompare(xe.name)))}catch(X){if(T.current!==U)return;m([]),h(X instanceof Error?X.message:e("mobile.files.error.listFailed"))}finally{T.current===U&&u(!1)}},[r,e]);d.useEffect(()=>{i.type==="browser"&&M(i.directory)},[M,i]),d.useEffect(()=>{if(i.type!=="browser")return;const R=g.trim();if(!R){p([]),y(!1);return}let U=!1;const X=window.setTimeout(()=>{y(!0),r.search({directory:i.directory,query:R,maxResults:40}).then(le=>{U||p(le)}).catch(()=>{U||p([])}).finally(()=>{U||y(!1)})},250);return()=>{U=!0,window.clearTimeout(X)}},[r,g,i]),d.useEffect(()=>{if(i.type!=="file")return;if(E(""),v(null),qe(i.path)&&!i.path.toLowerCase().endsWith(".svg")){N(!1);return}if(!r.readFile){v(e("mobile.files.error.readUnavailable")),N(!1);return}let R=!1;return N(!0),r.readFile(i.path).then(U=>{R||E(U.content.length>Yt?`${U.content.slice(0,Yt)}
@@ -13,4 +13,4 @@ ${e("mobile.files.file.truncated")}`:U.content)}).catch(U=>{R||v(U instanceof Er
13
13
  from { opacity: 1; transform: translateY(0) scale(1); }
14
14
  to { opacity: 0; transform: translateY(-6px) scale(0.985); }
15
15
  }
16
- `}),e[41]=V):V=e[41];let Q;return e[42]!==L?(Q=t.jsxs("div",{className:"fixed inset-x-0 bottom-0 top-[calc(var(--oc-safe-area-top,0px)+var(--oc-header-height,56px))] z-20 pointer-events-none",children:[L,V]}),e[42]=L,e[43]=Q):Q=e[43],Q},lo=s=>{const e=ae.c(30),{groups:r,displayMode:o,isLoading:i,timeFormatPreference:n}=s,{t:l}=de();let m;e[0]!==o||e[1]!==l?(m=l(o==="remaining"?"header.services.remaining":"header.services.used"),e[0]=o,e[1]=l,e[2]=m):m=e[2];const c=m;if(r.length===0)return null;let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:t.jsx(me,{name:"timer",className:"size-[18px]"})}),e[3]=u):u=e[3];let f;e[4]!==l?(f=l("mobile.header.metadata.usage"),e[4]=l,e[5]=f):f=e[5];let h;e[6]!==f?(h=t.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:f}),e[6]=f,e[7]=h):h=e[7];let g;e[8]!==i?(g=i?t.jsx(me,{name:"refresh",className:"size-3.5 animate-spin"}):null,e[8]=i,e[9]=g):g=e[9];let b;e[10]!==c?(b=t.jsx("span",{className:"truncate",children:c}),e[10]=c,e[11]=b):b=e[11];let k;e[12]!==g||e[13]!==b?(k=t.jsxs("span",{className:"inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground",children:[g,b]}),e[12]=g,e[13]=b,e[14]=k):k=e[14];let p;e[15]!==h||e[16]!==k?(p=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 px-2.5 pb-1.5",children:[u,h,k]}),e[15]=h,e[16]=k,e[17]=p):p=e[17];let x;if(e[18]!==o||e[19]!==r||e[20]!==n){let E;e[22]!==o||e[23]!==n?(E=j=>t.jsxs("div",{className:"min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx($r,{providerId:j.providerId,className:"size-4 shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground",children:j.providerName}),j.status&&j.rows.length===0?t.jsx("span",{className:"shrink-0 truncate typography-micro text-muted-foreground",children:j.status}):null]}),j.rows.length>0?t.jsx("div",{className:"mt-1.5 space-y-1",children:j.rows.map(v=>{const _=o==="remaining"?v.window.remainingPercent:v.window.usedPercent,N=Or(v.window.valueLabel,_),T=Wr(v.window.resetAt,v.window.resetAfterFormatted??v.window.resetAtFormatted,n);return t.jsxs("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[t.jsxs("span",{className:"inline-flex min-w-0 flex-1 items-baseline gap-1.5",children:[t.jsx("span",{className:"truncate typography-ui-label text-muted-foreground",children:v.subtitle?`${v.subtitle} · ${v.label}`:v.label}),T?t.jsx("span",{className:"shrink-0 truncate typography-micro text-muted-foreground/70",children:T}):null]}),t.jsx("span",{className:ee("shrink-0 typography-ui-label font-semibold tabular-nums",oo(v.window)),children:N==="-"?"":N})]},v.key)})}):null,j.status&&j.rows.length>0?t.jsx("div",{className:"mt-1.5 typography-micro text-muted-foreground",children:j.status}):null]},j.providerId),e[22]=o,e[23]=n,e[24]=E):E=e[24],x=r.map(E),e[18]=o,e[19]=r,e[20]=n,e[21]=x}else x=e[21];let y;e[25]!==x?(y=t.jsx("div",{className:"space-y-1.5",children:x}),e[25]=x,e[26]=y):y=e[26];let C;return e[27]!==y||e[28]!==p?(C=t.jsxs("div",{className:"pt-2.5",children:[p,y]}),e[27]=y,e[28]=p,e[29]=C):C=e[29],C},co=s=>{const e=ae.c(24),{open:r,onClose:o,items:i}=s,{t:n}=de();let l,m;if(e[0]!==o||e[1]!==r?(l=()=>{if(!r)return;const x=y=>{y.key==="Escape"&&o()};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},m=[o,r],e[0]=o,e[1]=r,e[2]=l,e[3]=m):(l=e[2],m=e[3]),d.useEffect(l,m),!r)return null;let c;e[4]!==n?(c=n("mobile.menu.titleAria"),e[4]=n,e[5]=c):c=e[5];let u;e[6]!==n?(u=n("mobile.surface.closeAria"),e[6]=n,e[7]=u):u=e[7];let f;e[8]!==o||e[9]!==u?(f=t.jsx("button",{type:"button",className:"absolute inset-0 cursor-default","aria-label":u,onClick:o}),e[8]=o,e[9]=u,e[10]=f):f=e[10];let h;e[11]===Symbol.for("react.memo_cache_sentinel")?(h={animation:"mobile-menu-in 160ms cubic-bezier(0.32, 0.72, 0, 1)"},e[11]=h):h=e[11];let g;if(e[12]!==i||e[13]!==o){let x;e[15]!==o?(x=(y,C)=>t.jsxs("button",{type:"button",role:"menuitem",className:ee("flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",C>0&&"border-t border-border/30"),style:{touchAction:"manipulation"},onClick:()=>{y.onSelect(),o()},children:[y.iconNode??(y.icon?t.jsx(me,{name:y.icon,className:"size-5 shrink-0 text-muted-foreground"}):null),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:y.label}),y.badge&&y.badge>0?t.jsx("span",{className:"inline-flex size-2 shrink-0 rounded-full bg-primary","aria-hidden":!0}):null]},y.key),e[15]=o,e[16]=x):x=e[16],g=i.map(x),e[12]=i,e[13]=o,e[14]=g}else g=e[14];let b;e[17]!==g?(b=t.jsx("div",{className:"absolute right-2 top-[calc(var(--oc-safe-area-top,0px)+56px+4px)] w-[min(220px,calc(100vw-1rem))] origin-top-right overflow-hidden rounded-2xl border border-border/40 bg-background shadow-[0_18px_60px_rgb(0_0_0_/_0.35)]",role:"menu",style:h,children:g}),e[17]=g,e[18]=b):b=e[18];let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=t.jsx("style",{children:"@keyframes mobile-menu-in { from { opacity: 0; transform: translateY(-6px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }"}),e[19]=k):k=e[19];let p;return e[20]!==c||e[21]!==f||e[22]!==b?(p=t.jsxs("div",{className:"fixed inset-0 z-50",role:"dialog","aria-modal":"true","aria-label":c,children:[f,b,k]}),e[20]=c,e[21]=f,e[22]=b,e[23]=p):p=e[23],p},uo=d.memo(function({open:e,onOpenChange:r,currentSessionId:o,effectiveDirectory:i,gitDirectory:n,isNewSessionDraftOpen:l,primaryLabel:m,secondaryLabel:c}){const{t:u}=de(),{git:f}=mt(),h=d.useRef(null),g=Rr(o??"",i||void 0),b=ks(n),k=Dt(n),p=Re(D=>D.ensureStatus),x=Re(D=>D.fetchStatus),y=Ee(D=>D.providers),C=Ee(D=>D.currentProviderId),E=Ee(D=>D.currentModelId),j=Ee(D=>D.getModelMetadata);Ee(D=>D.modelsMetadata.size);const v=Mr(d.useCallback(D=>o?D.sessionModelSelections.get(o)??null:null,[o])),_=Ge(D=>D.results),N=Ge(D=>D.loadSettings),T=Ge(D=>D.fetchAllQuotas),P=Ge(D=>D.isLoading),M=Ge(D=>D.displayMode),z=Ge(D=>D.dropdownProviderIds),O=Ge(D=>D.selectedModels),B=Pt(D=>D.timeFormatPreference);hn(),d.useEffect(()=>{n&&p(n,f)},[p,f,n]),d.useEffect(()=>{if(n)return Ir.onGitRefreshHint(D=>{nt(D.directory)===n&&x(n,f)})},[x,f,n]),d.useEffect(()=>{N()},[N]),d.useEffect(()=>{Ht(z)},[z]),d.useEffect(()=>{!e||P||!z.some(q=>!_.some(se=>se.providerId===q))||T()},[z,T,P,e,_]);const W=d.useMemo(()=>{for(let D=g.length-1;D>=0;D-=1){const q=g[D];if(q.role!=="user")continue;const se=typeof q.model?.providerID=="string"&&q.model.providerID.trim().length>0?q.model.providerID:void 0,he=typeof q.model?.modelID=="string"&&q.model.modelID.trim().length>0?q.model.modelID:void 0;if(se&&he)return{providerID:se,modelID:he}}return null},[g])??(v?{providerID:v.providerId,modelID:v.modelId}:null)??(C&&E?{providerID:C,modelID:E}:null),L=(W?y.find(D=>D.id===W.providerID):void 0)?.models.find(D=>D.id===W?.modelID),V=W?j(W.providerID,W.modelID):void 0,Q=ro(L?.limit,"context")??V?.limit?.context??0,G=d.useMemo(()=>{for(let D=g.length-1;D>=0;D-=1){const q=g[D];if(q.role!=="assistant"||!q.tokens)continue;const se=tt(q.tokens.input)+tt(q.tokens.output)+tt(q.tokens.reasoning)+tt(q.tokens.cache?.read)+tt(q.tokens.cache?.write);if(se>0)return se}return 0},[g]),R=!l&&G>0&&Q>0?Math.min(G/Q*100,999):null,U=R!==null?`${os(G)}/${os(Q)}`:null,X=R===null?"":R>=90?"text-[var(--status-error)]":R>=75?"text-[var(--status-warning)]":"text-[var(--status-success)]",le=R!==null&&U?{percentage:R,tokens:U,colorClass:X}:null,xe=b===!0?k?.current?.trim()||u("gitView.branch.detachedHead"):u("common.unavailable"),te=d.useMemo(()=>{const D=new Map(_.map(q=>[q.providerId,q]));return pn.filter(q=>z.includes(q.id)).filter(q=>D.get(q.id)?.configured===!0).map(q=>{const se=D.get(q.id),he=[];for(const[ie,ge]of Object.entries(se?.usage?.windows??{}))he.push({key:`window-${ie}`,label:Kt(ie),window:ge});const we=Object.entries(se?.usage?.models??{}),Y=O[q.id]??[],pe=Y.length>0?we.filter(([ie])=>Y.includes(ie)):we;for(const[ie,ge]of pe){const be=Object.entries(ge.windows??{});if(be.length===0)continue;const[ke,Ie]=be[0];he.push({key:`model-${ie}-${ke}`,label:Kt(ke),subtitle:gn(ie),window:Ie})}const re=!se.ok&&se.error?se.error:he.length===0?u("header.services.noRateLimitsReported"):null;return{providerId:q.id,providerName:q.name,rows:he,status:re}})},[z,_,O,u]);return d.useEffect(()=>{!e||te.length===0||Ht(te.map(D=>D.providerId))},[e,te]),t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:h,type:"button",className:"flex min-w-0 flex-1 items-center rounded-full px-2 py-1.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":u("mobile.header.openMetadataAria"),"aria-expanded":e,onClick:()=>r(D=>!D),style:{touchAction:"manipulation"},children:t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col leading-tight",children:[t.jsx("span",{className:"block truncate typography-ui-label text-foreground",children:m}),c?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:c}):null]})}),t.jsx(ao,{open:e,onClose:()=>r(!1),anchorRef:h,contextDisplay:le,branchLabel:xe,usageGroups:te,usageDisplayMode:M,isUsageLoading:P,timeFormatPreference:B})]})}),fo=({onOpenSessions:s,onOpenMenu:e})=>{const{t:r}=de(),[o,i]=d.useState(!1),n=Je(v=>v.currentDirectory),l=Se(v=>v.currentSessionId),c=Se(d.useCallback(v=>l?v.getDirectoryForSession(l):null,[l]))||n,u=nt(c)||null,f=Pe(v=>v.projects),h=Se(v=>v.availableWorktreesByProject),g=Se(d.useCallback(v=>l?v.worktreeMetadata.get(l)??null:null,[l])),b=zr(l,c||void 0),k=Se(v=>!!v.newSessionDraft?.open),p=d.useMemo(()=>{const v=nt(c);if(!v)return r("mobile.header.noProject");const N=(g?.projectDirectory?Fr(f,g.projectDirectory):null)??Tr(f,h,v);return no(N,v)||r("mobile.header.noProject")},[h,g?.projectDirectory,c,f,r]),y=b?.title?.trim()||(l?r("mobile.sessions.untitled"):p),C=l?p:"";d.useEffect(()=>{i(!1)},[l,c]);const E=d.useCallback(()=>{i(!1),s()},[s]),j=d.useCallback(()=>{i(!1),e()},[e]);return t.jsx(t.Fragment,{children:t.jsx("header",{className:"relative z-30 flex shrink-0 items-center gap-1 border-b border-border/30 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",style:{paddingTop:"var(--oc-safe-area-top, 0px)"},children:t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] w-full items-center gap-1 px-2",children:[t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":r("mobile.sessions.openSheetAria"),onClick:E,style:{touchAction:"manipulation"},children:t.jsx(me,{name:"menu",className:"size-5"})}),t.jsx(uo,{open:o,onOpenChange:i,currentSessionId:l,effectiveDirectory:c,gitDirectory:u,isNewSessionDraftOpen:k,primaryLabel:y,secondaryLabel:C}),t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":r("mobile.header.openMenuAria"),onClick:j,style:{touchAction:"manipulation"},children:t.jsx(me,{name:"more-2",className:"size-5"})})]})})})},mo=()=>{const s=ae.c(82),{t:e}=de(),[r,o]=d.useState(!1),[i,n]=d.useState(!1),[l,m]=d.useState(!1),[c,u]=d.useState(!1),[f,h]=d.useState(!1),[g,b]=d.useState(!1),[k,p]=d.useState(!1),[x,y]=d.useState("nav"),[C,E]=d.useState(!1),[j,v]=d.useState(null),_=Je(po),N=Pt(go),T=Qt(xo),P=Qt(bo),M=ct(vo),z=ct(yo),O=ct(jo),B=dn(wo),K=ct(ko);let W;s[0]!==_?(W=nt(_)||null,s[0]=_,s[1]=W):W=s[1];const L=Dt(W)?.files?.length??0;let V;s[2]===Symbol.for("react.memo_cache_sentinel")?(V={openChanges:Ne=>{const{diffPath:Fe,staged:it}=Ne===void 0?{}:Ne;v(Fe?{path:Fe,staged:it===!0}:null),m(!0)},openFiles:()=>n(!0),openSettings:()=>{y("nav"),b(!0)}},s[2]=V):V=s[2];const Q=V;let G;s[3]===Symbol.for("react.memo_cache_sentinel")?(G=()=>{m(!1),v(null)},s[3]=G):G=s[3];const R=G,U=T&&(P==="desktop"||P==="web");let X;s[4]!==M||s[5]!==z||s[6]!==O||s[7]!==N?(X=()=>{let Ne="new-mcp-server",Fe=1;for(;M.some(It=>It.name===Ne);)Ne=`new-mcp-server-${Fe}`,Fe=Fe+1;z({name:Ne,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",timeout:"",enabled:!0}),O(Ne),N("mcp"),u(!1),y("page-content"),b(!0)},s[4]=M,s[5]=z,s[6]=O,s[7]=N,s[8]=X):X=s[8];const le=X;let xe;s[9]!==_||s[10]!==f||s[11]!==K||s[12]!==B?(xe=()=>{if(f)return;h(!0);const Ne=_||null,Fe=new Promise(No);Promise.all([B({directory:Ne,silent:!0}),K({force:!0}),Fe]).finally(()=>h(!1))},s[9]=_,s[10]=f,s[11]=K,s[12]=B,s[13]=xe):xe=s[13];const te=xe;let D;s[14]!==e?(D=e("mobile.menu.files"),s[14]=e,s[15]=D):D=s[15];let q;s[16]===Symbol.for("react.memo_cache_sentinel")?(q=()=>n(!0),s[16]=q):q=s[16];let se;s[17]!==D?(se={key:"files",icon:"file-text",label:D,onSelect:q},s[17]=D,s[18]=se):se=s[18];let he;s[19]!==e?(he=e("mobile.menu.changes"),s[19]=e,s[20]=he):he=s[20];let we;s[21]===Symbol.for("react.memo_cache_sentinel")?(we=()=>m(!0),s[21]=we):we=s[21];let Y;s[22]!==L||s[23]!==he?(Y={key:"changes",icon:"git-branch",label:he,badge:L,onSelect:we},s[22]=L,s[23]=he,s[24]=Y):Y=s[24];let pe;s[25]===Symbol.for("react.memo_cache_sentinel")?(pe=t.jsx(xn,{className:"size-5 shrink-0 text-muted-foreground"}),s[25]=pe):pe=s[25];let re;s[26]!==e?(re=e("mobile.menu.mcp"),s[26]=e,s[27]=re):re=s[27];let ie;s[28]===Symbol.for("react.memo_cache_sentinel")?(ie=()=>u(!0),s[28]=ie):ie=s[28];let ge;s[29]!==re?(ge={key:"mcp",iconNode:pe,label:re,onSelect:ie},s[29]=re,s[30]=ge):ge=s[30];let be;s[31]!==U||s[32]!==e?(be=U?[{key:"update",icon:"download",label:e("mobile.menu.update"),onSelect:()=>p(!0)}]:[],s[31]=U,s[32]=e,s[33]=be):be=s[33];let ke;s[34]!==e?(ke=e("mobile.menu.settings"),s[34]=e,s[35]=ke):ke=s[35];let Ie;s[36]===Symbol.for("react.memo_cache_sentinel")?(Ie=()=>{y("nav"),b(!0)},s[36]=Ie):Ie=s[36];let Ae;s[37]!==ke?(Ae={key:"settings",icon:"settings-3",label:ke,onSelect:Ie},s[37]=ke,s[38]=Ae):Ae=s[38];let Be;s[39]!==Y||s[40]!==ge||s[41]!==be||s[42]!==Ae||s[43]!==se?(Be=[se,Y,ge,...be,Ae],s[39]=Y,s[40]=ge,s[41]=be,s[42]=Ae,s[43]=se,s[44]=Be):Be=s[44];const We=Be;let De;s[45]===Symbol.for("react.memo_cache_sentinel")?(De=t.jsx(fo,{onOpenSessions:()=>o(!0),onOpenMenu:()=>E(!0)}),s[45]=De):De=s[45];let w;s[46]===Symbol.for("react.memo_cache_sentinel")?(w=t.jsx("main",{className:"relative min-h-0 flex-1 overflow-hidden","data-page-scroll-lock":"true",children:t.jsx(Ve,{children:t.jsx(bn,{})})}),s[46]=w):w=s[46];let A;s[47]===Symbol.for("react.memo_cache_sentinel")?(A=()=>E(!1),s[47]=A):A=s[47];let $;s[48]!==We||s[49]!==C?($=t.jsx(co,{open:C,onClose:A,items:We}),s[48]=We,s[49]=C,s[50]=$):$=s[50];let ce;s[51]!==r?(ce=r?t.jsx(to,{open:r,onOpenChange:o}):null,s[51]=r,s[52]=ce):ce=s[52];let ve;s[53]!==i||s[54]!==e?(ve=i?t.jsx(Ye,{open:!0,onClose:()=>n(!1),ariaLabel:e("mobile.menu.files"),headerless:!0,children:t.jsx(Ve,{children:t.jsx(Rn,{onClose:()=>n(!1)})})}):null,s[53]=i,s[54]=e,s[55]=ve):ve=s[55];let Ce;s[56]!==l||s[57]!==j?.path||s[58]!==j?.staged||s[59]!==e?(Ce=l?t.jsx(Ye,{open:!0,onClose:R,ariaLabel:e("mobile.menu.changes"),headerless:!0,children:t.jsx(Ve,{children:t.jsx(kn,{onClose:R,initialDiffPath:j?.path??null,initialDiffStaged:j?.staged===!0})})}):null,s[56]=l,s[57]=j?.path,s[58]=j?.staged,s[59]=e,s[60]=Ce):Ce=s[60];let _e;s[61]!==f||s[62]!==c||s[63]!==le||s[64]!==te||s[65]!==e?(_e=c?t.jsx(Es,{open:!0,onClose:()=>u(!1),title:e("mcpDropdown.title"),className:"h-[72vh]",contentMaxHeightClassName:"max-h-full",renderHeader:Ne=>t.jsxs("div",{className:"shrink-0",children:[t.jsx("div",{className:"flex justify-center pt-2.5 pb-1",children:t.jsx("div",{className:"h-1 w-9 rounded-full bg-[color-mix(in_srgb,var(--surface-mutedForeground)_40%,transparent)]"})}),t.jsxs("div",{className:"flex items-center justify-between gap-2 px-4 pb-2",children:[t.jsx("h2",{className:"text-[16px] font-semibold text-[var(--surface-foreground)]",children:e("mcpDropdown.title")}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{type:"button",className:"flex size-8 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]",onClick:le,"aria-label":e("settings.mcp.sidebar.actions.addServerTitle"),title:e("settings.mcp.sidebar.actions.addServerTitle"),style:{touchAction:"manipulation"},children:t.jsx(me,{name:"add",className:"h-5 w-5"})}),t.jsx("button",{type:"button",className:"flex size-8 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] disabled:opacity-60",onClick:te,disabled:f,"aria-label":e("mcpDropdown.actions.refreshAria"),title:e("mcpDropdown.actions.refreshAria"),style:{touchAction:"manipulation"},children:t.jsx(me,{name:"refresh",className:ee("h-5 w-5",f&&"animate-spin")})}),Ne]})]})]}),children:t.jsx(Ve,{children:t.jsx(un,{active:!0,className:"h-full",listClassName:"max-h-none",hideHeader:!0,mobileListDensity:!0})})}):null,s[61]=f,s[62]=c,s[63]=le,s[64]=te,s[65]=e,s[66]=_e):_e=s[66];let Le;s[67]!==x||s[68]!==g||s[69]!==e?(Le=g?t.jsx(Ye,{open:!0,onClose:()=>b(!1),ariaLabel:e("mobile.menu.settings"),headerless:!0,children:t.jsx(Ve,{children:t.jsx(fn,{forceMobile:!0,isWindowed:!0,initialMobileStage:x,visiblePageSlugs:[...so],onClose:()=>b(!1)})})}):null,s[67]=x,s[68]=g,s[69]=e,s[70]=Le):Le=s[70];let ze;s[71]!==e||s[72]!==k?(ze=k?t.jsx(Ye,{open:!0,onClose:()=>p(!1),ariaLabel:e("mobile.menu.update"),title:e("mobile.menu.update"),children:t.jsx(Ve,{children:t.jsx("div",{className:"h-full overflow-auto px-5 py-4",children:t.jsx(mn,{initialUpdateDialogOpen:!0})})})}):null,s[71]=e,s[72]=k,s[73]=ze):ze=s[73];let He;return s[74]!==$||s[75]!==ce||s[76]!==ve||s[77]!==Ce||s[78]!==_e||s[79]!==Le||s[80]!==ze?(He=t.jsx(_r,{actions:Q,children:t.jsxs("div",{className:"main-content-safe-area flex h-[100dvh] flex-col bg-background text-foreground","data-page-scroll-lock":"true",children:[De,w,$,ce,ve,Ce,_e,Le,ze]})}),s[74]=$,s[75]=ce,s[76]=ve,s[77]=Ce,s[78]=_e,s[79]=Le,s[80]=ze,s[81]=He):He=s[81],He};function ho({apis:s}){const e=Ee(p=>p.initializeApp),r=Ee(p=>p.isInitialized),o=Ee(p=>p.isConnected),i=Ee(p=>p.providers.length),n=Ee(p=>p.agents.length),l=Ee(p=>p.loadProviders),m=Ee(p=>p.loadAgents),c=Je(p=>p.currentDirectory),u=Se(p=>p.error),f=Se(p=>p.clearError),h=Pt(p=>p.setIsMobile),g=jr(p=>p.refreshStatus),b=wr(p=>p.setPlanModeEnabled),k=Pe(p=>p.projects);return d.useEffect(()=>(Ot(s),()=>Ot(null)),[s]),d.useEffect(()=>{h(!0)},[h]),d.useEffect(()=>{e()},[e]),d.useEffect(()=>{o&&(i===0&&l({source:"mobileApp:recovery"}),n===0&&m({source:"mobileApp:recovery"}))},[n,o,m,l,i]),d.useEffect(()=>{o&&Wt.setDirectory(c)},[c,o]),d.useEffect(()=>{g(s.github,{force:!0})},[s.github,g]),d.useEffect(()=>{if(k.length===0)return;let p=!1;return(async()=>{const y=new Map,C=[];await Promise.all(k.map(async E=>{const j=E.path.replace(/\\/g,"/").replace(/\/+$/,"");if(j)try{if(!(Re.getState().directories.get(j)?.isGitRepo??await Ys(()=>import("./useAppFontEffects-BPhei6aO.js").then(T=>T.f8),__vite__mapDeps([0,1,2,3,4])).then(T=>T.checkIsGitRepository(j))))return;const N=await Rs({id:E.id,path:j});if(p||N.length===0)return;y.set(j,N),C.push(...N)}catch{}})),!p&&Se.setState({availableWorktrees:C,availableWorktreesByProject:y})})(),()=>{p=!0}},[k]),d.useEffect(()=>{let p=!1;return(async()=>{const y=await sr("/health",{method:"GET"}).catch(()=>null);if(!y||!y.ok||p)return;const C=await y.json().catch(()=>null);if(!C||p)return;const E=C.planModeExperimentalEnabled;b(E===!0||E===1||E==="1"||E==="true")})(),()=>{p=!0}},[b]),d.useEffect(()=>{if(!u)return;const p=window.setTimeout(()=>f(),5e3);return()=>window.clearTimeout(p)},[f,u]),kr(),Nr({enabled:!0}),on(),Sr(),an(),t.jsx(Ve,{children:t.jsx(Cr,{sdk:Wt.getSdkClient(),directory:c||"",children:t.jsx(Er,{apis:s,children:t.jsx(Pr,{delayDuration:300,skipDelayDuration:150,children:t.jsxs("div",{className:"h-full bg-background text-foreground",children:[t.jsx(Ar,{embeddedBackgroundWorkEnabled:r}),t.jsx(ln,{}),t.jsx(mo,{}),t.jsx(Dr,{}),r?t.jsx(cn,{}):null]})})})})})}function po(s){return s.currentDirectory}function go(s){return s.setSettingsPage}function xo(s){return s.available}function bo(s){return s.runtimeType}function vo(s){return s.mcpServers}function yo(s){return s.setMcpDraft}function jo(s){return s.setSelectedMcp}function wo(s){return s.refresh}function ko(s){return s.loadMcpConfigs}function No(s){return window.setTimeout(s,500)}const So=()=>{Kr(),rr().then(()=>{Promise.all([nr(),Qr()]).catch(s=>{console.error("[mobile-main] settings init failed:",s)}),qr(),Yr(),Jr()}).catch(s=>{console.error("[mobile-main] appearance init failed:",s)})};function Mo(s){So();const e=document.getElementById("root");if(!e)throw new Error("Root element not found");Js.createRoot(e).render(t.jsx(Xs.StrictMode,{children:t.jsx(Gr,{children:t.jsx(Vr,{children:t.jsx(Ur,{children:t.jsx(vn,{children:t.jsx(Hr,{children:t.jsx(ho,{apis:s})})})})})})}))}export{Mo as renderMobileApp};
16
+ `}),e[41]=V):V=e[41];let Q;return e[42]!==L?(Q=t.jsxs("div",{className:"fixed inset-x-0 bottom-0 top-[calc(var(--oc-safe-area-top,0px)+var(--oc-header-height,56px))] z-20 pointer-events-none",children:[L,V]}),e[42]=L,e[43]=Q):Q=e[43],Q},lo=s=>{const e=ae.c(30),{groups:r,displayMode:o,isLoading:i,timeFormatPreference:n}=s,{t:l}=de();let m;e[0]!==o||e[1]!==l?(m=l(o==="remaining"?"header.services.remaining":"header.services.used"),e[0]=o,e[1]=l,e[2]=m):m=e[2];const c=m;if(r.length===0)return null;let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:t.jsx(me,{name:"timer",className:"size-[18px]"})}),e[3]=u):u=e[3];let f;e[4]!==l?(f=l("mobile.header.metadata.usage"),e[4]=l,e[5]=f):f=e[5];let h;e[6]!==f?(h=t.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:f}),e[6]=f,e[7]=h):h=e[7];let g;e[8]!==i?(g=i?t.jsx(me,{name:"refresh",className:"size-3.5 animate-spin"}):null,e[8]=i,e[9]=g):g=e[9];let b;e[10]!==c?(b=t.jsx("span",{className:"truncate",children:c}),e[10]=c,e[11]=b):b=e[11];let k;e[12]!==g||e[13]!==b?(k=t.jsxs("span",{className:"inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground",children:[g,b]}),e[12]=g,e[13]=b,e[14]=k):k=e[14];let p;e[15]!==h||e[16]!==k?(p=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 px-2.5 pb-1.5",children:[u,h,k]}),e[15]=h,e[16]=k,e[17]=p):p=e[17];let x;if(e[18]!==o||e[19]!==r||e[20]!==n){let E;e[22]!==o||e[23]!==n?(E=j=>t.jsxs("div",{className:"min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx($r,{providerId:j.providerId,className:"size-4 shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground",children:j.providerName}),j.status&&j.rows.length===0?t.jsx("span",{className:"shrink-0 truncate typography-micro text-muted-foreground",children:j.status}):null]}),j.rows.length>0?t.jsx("div",{className:"mt-1.5 space-y-1",children:j.rows.map(v=>{const _=o==="remaining"?v.window.remainingPercent:v.window.usedPercent,N=Or(v.window.valueLabel,_),T=Wr(v.window.resetAt,v.window.resetAfterFormatted??v.window.resetAtFormatted,n);return t.jsxs("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[t.jsxs("span",{className:"inline-flex min-w-0 flex-1 items-baseline gap-1.5",children:[t.jsx("span",{className:"truncate typography-ui-label text-muted-foreground",children:v.subtitle?`${v.subtitle} · ${v.label}`:v.label}),T?t.jsx("span",{className:"shrink-0 truncate typography-micro text-muted-foreground/70",children:T}):null]}),t.jsx("span",{className:ee("shrink-0 typography-ui-label font-semibold tabular-nums",oo(v.window)),children:N==="-"?"":N})]},v.key)})}):null,j.status&&j.rows.length>0?t.jsx("div",{className:"mt-1.5 typography-micro text-muted-foreground",children:j.status}):null]},j.providerId),e[22]=o,e[23]=n,e[24]=E):E=e[24],x=r.map(E),e[18]=o,e[19]=r,e[20]=n,e[21]=x}else x=e[21];let y;e[25]!==x?(y=t.jsx("div",{className:"space-y-1.5",children:x}),e[25]=x,e[26]=y):y=e[26];let C;return e[27]!==y||e[28]!==p?(C=t.jsxs("div",{className:"pt-2.5",children:[p,y]}),e[27]=y,e[28]=p,e[29]=C):C=e[29],C},co=s=>{const e=ae.c(24),{open:r,onClose:o,items:i}=s,{t:n}=de();let l,m;if(e[0]!==o||e[1]!==r?(l=()=>{if(!r)return;const x=y=>{y.key==="Escape"&&o()};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},m=[o,r],e[0]=o,e[1]=r,e[2]=l,e[3]=m):(l=e[2],m=e[3]),d.useEffect(l,m),!r)return null;let c;e[4]!==n?(c=n("mobile.menu.titleAria"),e[4]=n,e[5]=c):c=e[5];let u;e[6]!==n?(u=n("mobile.surface.closeAria"),e[6]=n,e[7]=u):u=e[7];let f;e[8]!==o||e[9]!==u?(f=t.jsx("button",{type:"button",className:"absolute inset-0 cursor-default","aria-label":u,onClick:o}),e[8]=o,e[9]=u,e[10]=f):f=e[10];let h;e[11]===Symbol.for("react.memo_cache_sentinel")?(h={animation:"mobile-menu-in 160ms cubic-bezier(0.32, 0.72, 0, 1)"},e[11]=h):h=e[11];let g;if(e[12]!==i||e[13]!==o){let x;e[15]!==o?(x=(y,C)=>t.jsxs("button",{type:"button",role:"menuitem",className:ee("flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",C>0&&"border-t border-border/30"),style:{touchAction:"manipulation"},onClick:()=>{y.onSelect(),o()},children:[y.iconNode??(y.icon?t.jsx(me,{name:y.icon,className:"size-5 shrink-0 text-muted-foreground"}):null),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:y.label}),y.badge&&y.badge>0?t.jsx("span",{className:"inline-flex size-2 shrink-0 rounded-full bg-primary","aria-hidden":!0}):null]},y.key),e[15]=o,e[16]=x):x=e[16],g=i.map(x),e[12]=i,e[13]=o,e[14]=g}else g=e[14];let b;e[17]!==g?(b=t.jsx("div",{className:"absolute right-2 top-[calc(var(--oc-safe-area-top,0px)+56px+4px)] w-[min(220px,calc(100vw-1rem))] origin-top-right overflow-hidden rounded-2xl border border-border/40 bg-background shadow-[0_18px_60px_rgb(0_0_0_/_0.35)]",role:"menu",style:h,children:g}),e[17]=g,e[18]=b):b=e[18];let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=t.jsx("style",{children:"@keyframes mobile-menu-in { from { opacity: 0; transform: translateY(-6px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }"}),e[19]=k):k=e[19];let p;return e[20]!==c||e[21]!==f||e[22]!==b?(p=t.jsxs("div",{className:"fixed inset-0 z-50",role:"dialog","aria-modal":"true","aria-label":c,children:[f,b,k]}),e[20]=c,e[21]=f,e[22]=b,e[23]=p):p=e[23],p},uo=d.memo(function({open:e,onOpenChange:r,currentSessionId:o,effectiveDirectory:i,gitDirectory:n,isNewSessionDraftOpen:l,primaryLabel:m,secondaryLabel:c}){const{t:u}=de(),{git:f}=mt(),h=d.useRef(null),g=Rr(o??"",i||void 0),b=ks(n),k=Dt(n),p=Re(D=>D.ensureStatus),x=Re(D=>D.fetchStatus),y=Ee(D=>D.providers),C=Ee(D=>D.currentProviderId),E=Ee(D=>D.currentModelId),j=Ee(D=>D.getModelMetadata);Ee(D=>D.modelsMetadata.size);const v=Mr(d.useCallback(D=>o?D.sessionModelSelections.get(o)??null:null,[o])),_=Ge(D=>D.results),N=Ge(D=>D.loadSettings),T=Ge(D=>D.fetchAllQuotas),P=Ge(D=>D.isLoading),M=Ge(D=>D.displayMode),z=Ge(D=>D.dropdownProviderIds),O=Ge(D=>D.selectedModels),B=Pt(D=>D.timeFormatPreference);hn(),d.useEffect(()=>{n&&p(n,f)},[p,f,n]),d.useEffect(()=>{if(n)return Ir.onGitRefreshHint(D=>{nt(D.directory)===n&&x(n,f)})},[x,f,n]),d.useEffect(()=>{N()},[N]),d.useEffect(()=>{Ht(z)},[z]),d.useEffect(()=>{!e||P||!z.some(q=>!_.some(se=>se.providerId===q))||T()},[z,T,P,e,_]);const W=d.useMemo(()=>{for(let D=g.length-1;D>=0;D-=1){const q=g[D];if(q.role!=="user")continue;const se=typeof q.model?.providerID=="string"&&q.model.providerID.trim().length>0?q.model.providerID:void 0,he=typeof q.model?.modelID=="string"&&q.model.modelID.trim().length>0?q.model.modelID:void 0;if(se&&he)return{providerID:se,modelID:he}}return null},[g])??(v?{providerID:v.providerId,modelID:v.modelId}:null)??(C&&E?{providerID:C,modelID:E}:null),L=(W?y.find(D=>D.id===W.providerID):void 0)?.models.find(D=>D.id===W?.modelID),V=W?j(W.providerID,W.modelID):void 0,Q=ro(L?.limit,"context")??V?.limit?.context??0,G=d.useMemo(()=>{for(let D=g.length-1;D>=0;D-=1){const q=g[D];if(q.role!=="assistant"||!q.tokens)continue;const se=tt(q.tokens.input)+tt(q.tokens.output)+tt(q.tokens.reasoning)+tt(q.tokens.cache?.read)+tt(q.tokens.cache?.write);if(se>0)return se}return 0},[g]),R=!l&&G>0&&Q>0?Math.min(G/Q*100,999):null,U=R!==null?`${os(G)}/${os(Q)}`:null,X=R===null?"":R>=90?"text-[var(--status-error)]":R>=75?"text-[var(--status-warning)]":"text-[var(--status-success)]",le=R!==null&&U?{percentage:R,tokens:U,colorClass:X}:null,xe=b===!0?k?.current?.trim()||u("gitView.branch.detachedHead"):u("common.unavailable"),te=d.useMemo(()=>{const D=new Map(_.map(q=>[q.providerId,q]));return pn.filter(q=>z.includes(q.id)).filter(q=>D.get(q.id)?.configured===!0).map(q=>{const se=D.get(q.id),he=[];for(const[ie,ge]of Object.entries(se?.usage?.windows??{}))he.push({key:`window-${ie}`,label:Kt(ie),window:ge});const we=Object.entries(se?.usage?.models??{}),Y=O[q.id]??[],pe=Y.length>0?we.filter(([ie])=>Y.includes(ie)):we;for(const[ie,ge]of pe){const be=Object.entries(ge.windows??{});if(be.length===0)continue;const[ke,Ie]=be[0];he.push({key:`model-${ie}-${ke}`,label:Kt(ke),subtitle:gn(ie),window:Ie})}const re=!se.ok&&se.error?se.error:he.length===0?u("header.services.noRateLimitsReported"):null;return{providerId:q.id,providerName:q.name,rows:he,status:re}})},[z,_,O,u]);return d.useEffect(()=>{!e||te.length===0||Ht(te.map(D=>D.providerId))},[e,te]),t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:h,type:"button",className:"flex min-w-0 flex-1 items-center rounded-full px-2 py-1.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":u("mobile.header.openMetadataAria"),"aria-expanded":e,onClick:()=>r(D=>!D),style:{touchAction:"manipulation"},children:t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col leading-tight",children:[t.jsx("span",{className:"block truncate typography-ui-label text-foreground",children:m}),c?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:c}):null]})}),t.jsx(ao,{open:e,onClose:()=>r(!1),anchorRef:h,contextDisplay:le,branchLabel:xe,usageGroups:te,usageDisplayMode:M,isUsageLoading:P,timeFormatPreference:B})]})}),fo=({onOpenSessions:s,onOpenMenu:e})=>{const{t:r}=de(),[o,i]=d.useState(!1),n=Je(v=>v.currentDirectory),l=Se(v=>v.currentSessionId),c=Se(d.useCallback(v=>l?v.getDirectoryForSession(l):null,[l]))||n,u=nt(c)||null,f=Pe(v=>v.projects),h=Se(v=>v.availableWorktreesByProject),g=Se(d.useCallback(v=>l?v.worktreeMetadata.get(l)??null:null,[l])),b=zr(l,c||void 0),k=Se(v=>!!v.newSessionDraft?.open),p=d.useMemo(()=>{const v=nt(c);if(!v)return r("mobile.header.noProject");const N=(g?.projectDirectory?Fr(f,g.projectDirectory):null)??Tr(f,h,v);return no(N,v)||r("mobile.header.noProject")},[h,g?.projectDirectory,c,f,r]),y=b?.title?.trim()||(l?r("mobile.sessions.untitled"):p),C=l?p:"";d.useEffect(()=>{i(!1)},[l,c]);const E=d.useCallback(()=>{i(!1),s()},[s]),j=d.useCallback(()=>{i(!1),e()},[e]);return t.jsx(t.Fragment,{children:t.jsx("header",{className:"relative z-30 flex shrink-0 items-center gap-1 border-b border-border/30 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",style:{paddingTop:"var(--oc-safe-area-top, 0px)"},children:t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] w-full items-center gap-1 px-2",children:[t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":r("mobile.sessions.openSheetAria"),onClick:E,style:{touchAction:"manipulation"},children:t.jsx(me,{name:"menu",className:"size-5"})}),t.jsx(uo,{open:o,onOpenChange:i,currentSessionId:l,effectiveDirectory:c,gitDirectory:u,isNewSessionDraftOpen:k,primaryLabel:y,secondaryLabel:C}),t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":r("mobile.header.openMenuAria"),onClick:j,style:{touchAction:"manipulation"},children:t.jsx(me,{name:"more-2",className:"size-5"})})]})})})},mo=()=>{const s=ae.c(82),{t:e}=de(),[r,o]=d.useState(!1),[i,n]=d.useState(!1),[l,m]=d.useState(!1),[c,u]=d.useState(!1),[f,h]=d.useState(!1),[g,b]=d.useState(!1),[k,p]=d.useState(!1),[x,y]=d.useState("nav"),[C,E]=d.useState(!1),[j,v]=d.useState(null),_=Je(po),N=Pt(go),T=Qt(xo),P=Qt(bo),M=ct(vo),z=ct(yo),O=ct(jo),B=dn(wo),K=ct(ko);let W;s[0]!==_?(W=nt(_)||null,s[0]=_,s[1]=W):W=s[1];const L=Dt(W)?.files?.length??0;let V;s[2]===Symbol.for("react.memo_cache_sentinel")?(V={openChanges:Ne=>{const{diffPath:Fe,staged:it}=Ne===void 0?{}:Ne;v(Fe?{path:Fe,staged:it===!0}:null),m(!0)},openFiles:()=>n(!0),openSettings:()=>{y("nav"),b(!0)}},s[2]=V):V=s[2];const Q=V;let G;s[3]===Symbol.for("react.memo_cache_sentinel")?(G=()=>{m(!1),v(null)},s[3]=G):G=s[3];const R=G,U=T&&(P==="desktop"||P==="web");let X;s[4]!==M||s[5]!==z||s[6]!==O||s[7]!==N?(X=()=>{let Ne="new-mcp-server",Fe=1;for(;M.some(It=>It.name===Ne);)Ne=`new-mcp-server-${Fe}`,Fe=Fe+1;z({name:Ne,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",timeout:"",enabled:!0}),O(Ne),N("mcp"),u(!1),y("page-content"),b(!0)},s[4]=M,s[5]=z,s[6]=O,s[7]=N,s[8]=X):X=s[8];const le=X;let xe;s[9]!==_||s[10]!==f||s[11]!==K||s[12]!==B?(xe=()=>{if(f)return;h(!0);const Ne=_||null,Fe=new Promise(No);Promise.all([B({directory:Ne,silent:!0}),K({force:!0}),Fe]).finally(()=>h(!1))},s[9]=_,s[10]=f,s[11]=K,s[12]=B,s[13]=xe):xe=s[13];const te=xe;let D;s[14]!==e?(D=e("mobile.menu.files"),s[14]=e,s[15]=D):D=s[15];let q;s[16]===Symbol.for("react.memo_cache_sentinel")?(q=()=>n(!0),s[16]=q):q=s[16];let se;s[17]!==D?(se={key:"files",icon:"file-text",label:D,onSelect:q},s[17]=D,s[18]=se):se=s[18];let he;s[19]!==e?(he=e("mobile.menu.changes"),s[19]=e,s[20]=he):he=s[20];let we;s[21]===Symbol.for("react.memo_cache_sentinel")?(we=()=>m(!0),s[21]=we):we=s[21];let Y;s[22]!==L||s[23]!==he?(Y={key:"changes",icon:"git-branch",label:he,badge:L,onSelect:we},s[22]=L,s[23]=he,s[24]=Y):Y=s[24];let pe;s[25]===Symbol.for("react.memo_cache_sentinel")?(pe=t.jsx(xn,{className:"size-5 shrink-0 text-muted-foreground"}),s[25]=pe):pe=s[25];let re;s[26]!==e?(re=e("mobile.menu.mcp"),s[26]=e,s[27]=re):re=s[27];let ie;s[28]===Symbol.for("react.memo_cache_sentinel")?(ie=()=>u(!0),s[28]=ie):ie=s[28];let ge;s[29]!==re?(ge={key:"mcp",iconNode:pe,label:re,onSelect:ie},s[29]=re,s[30]=ge):ge=s[30];let be;s[31]!==U||s[32]!==e?(be=U?[{key:"update",icon:"download",label:e("mobile.menu.update"),onSelect:()=>p(!0)}]:[],s[31]=U,s[32]=e,s[33]=be):be=s[33];let ke;s[34]!==e?(ke=e("mobile.menu.settings"),s[34]=e,s[35]=ke):ke=s[35];let Ie;s[36]===Symbol.for("react.memo_cache_sentinel")?(Ie=()=>{y("nav"),b(!0)},s[36]=Ie):Ie=s[36];let Ae;s[37]!==ke?(Ae={key:"settings",icon:"settings-3",label:ke,onSelect:Ie},s[37]=ke,s[38]=Ae):Ae=s[38];let Be;s[39]!==Y||s[40]!==ge||s[41]!==be||s[42]!==Ae||s[43]!==se?(Be=[se,Y,ge,...be,Ae],s[39]=Y,s[40]=ge,s[41]=be,s[42]=Ae,s[43]=se,s[44]=Be):Be=s[44];const We=Be;let De;s[45]===Symbol.for("react.memo_cache_sentinel")?(De=t.jsx(fo,{onOpenSessions:()=>o(!0),onOpenMenu:()=>E(!0)}),s[45]=De):De=s[45];let w;s[46]===Symbol.for("react.memo_cache_sentinel")?(w=t.jsx("main",{className:"relative min-h-0 flex-1 overflow-hidden","data-page-scroll-lock":"true",children:t.jsx(Ve,{children:t.jsx(bn,{})})}),s[46]=w):w=s[46];let A;s[47]===Symbol.for("react.memo_cache_sentinel")?(A=()=>E(!1),s[47]=A):A=s[47];let $;s[48]!==We||s[49]!==C?($=t.jsx(co,{open:C,onClose:A,items:We}),s[48]=We,s[49]=C,s[50]=$):$=s[50];let ce;s[51]!==r?(ce=r?t.jsx(to,{open:r,onOpenChange:o}):null,s[51]=r,s[52]=ce):ce=s[52];let ve;s[53]!==i||s[54]!==e?(ve=i?t.jsx(Ye,{open:!0,onClose:()=>n(!1),ariaLabel:e("mobile.menu.files"),headerless:!0,children:t.jsx(Ve,{children:t.jsx(Rn,{onClose:()=>n(!1)})})}):null,s[53]=i,s[54]=e,s[55]=ve):ve=s[55];let Ce;s[56]!==l||s[57]!==j?.path||s[58]!==j?.staged||s[59]!==e?(Ce=l?t.jsx(Ye,{open:!0,onClose:R,ariaLabel:e("mobile.menu.changes"),headerless:!0,children:t.jsx(Ve,{children:t.jsx(kn,{onClose:R,initialDiffPath:j?.path??null,initialDiffStaged:j?.staged===!0})})}):null,s[56]=l,s[57]=j?.path,s[58]=j?.staged,s[59]=e,s[60]=Ce):Ce=s[60];let _e;s[61]!==f||s[62]!==c||s[63]!==le||s[64]!==te||s[65]!==e?(_e=c?t.jsx(Es,{open:!0,onClose:()=>u(!1),title:e("mcpDropdown.title"),className:"h-[72vh]",contentMaxHeightClassName:"max-h-full",renderHeader:Ne=>t.jsxs("div",{className:"shrink-0",children:[t.jsx("div",{className:"flex justify-center pt-2.5 pb-1",children:t.jsx("div",{className:"h-1 w-9 rounded-full bg-[color-mix(in_srgb,var(--surface-mutedForeground)_40%,transparent)]"})}),t.jsxs("div",{className:"flex items-center justify-between gap-2 px-4 pb-2",children:[t.jsx("h2",{className:"text-[16px] font-semibold text-[var(--surface-foreground)]",children:e("mcpDropdown.title")}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{type:"button",className:"flex size-8 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]",onClick:le,"aria-label":e("settings.mcp.sidebar.actions.addServerTitle"),title:e("settings.mcp.sidebar.actions.addServerTitle"),style:{touchAction:"manipulation"},children:t.jsx(me,{name:"add",className:"h-5 w-5"})}),t.jsx("button",{type:"button",className:"flex size-8 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] disabled:opacity-60",onClick:te,disabled:f,"aria-label":e("mcpDropdown.actions.refreshAria"),title:e("mcpDropdown.actions.refreshAria"),style:{touchAction:"manipulation"},children:t.jsx(me,{name:"refresh",className:ee("h-5 w-5",f&&"animate-spin")})}),Ne]})]})]}),children:t.jsx(Ve,{children:t.jsx(un,{active:!0,className:"h-full",listClassName:"max-h-none",hideHeader:!0,mobileListDensity:!0})})}):null,s[61]=f,s[62]=c,s[63]=le,s[64]=te,s[65]=e,s[66]=_e):_e=s[66];let Le;s[67]!==x||s[68]!==g||s[69]!==e?(Le=g?t.jsx(Ye,{open:!0,onClose:()=>b(!1),ariaLabel:e("mobile.menu.settings"),headerless:!0,children:t.jsx(Ve,{children:t.jsx(fn,{forceMobile:!0,isWindowed:!0,initialMobileStage:x,visiblePageSlugs:[...so],onClose:()=>b(!1)})})}):null,s[67]=x,s[68]=g,s[69]=e,s[70]=Le):Le=s[70];let ze;s[71]!==e||s[72]!==k?(ze=k?t.jsx(Ye,{open:!0,onClose:()=>p(!1),ariaLabel:e("mobile.menu.update"),title:e("mobile.menu.update"),children:t.jsx(Ve,{children:t.jsx("div",{className:"h-full overflow-auto px-5 py-4",children:t.jsx(mn,{initialUpdateDialogOpen:!0})})})}):null,s[71]=e,s[72]=k,s[73]=ze):ze=s[73];let He;return s[74]!==$||s[75]!==ce||s[76]!==ve||s[77]!==Ce||s[78]!==_e||s[79]!==Le||s[80]!==ze?(He=t.jsx(_r,{actions:Q,children:t.jsxs("div",{className:"main-content-safe-area flex h-[100dvh] flex-col bg-background text-foreground","data-page-scroll-lock":"true",children:[De,w,$,ce,ve,Ce,_e,Le,ze]})}),s[74]=$,s[75]=ce,s[76]=ve,s[77]=Ce,s[78]=_e,s[79]=Le,s[80]=ze,s[81]=He):He=s[81],He};function ho({apis:s}){const e=Ee(p=>p.initializeApp),r=Ee(p=>p.isInitialized),o=Ee(p=>p.isConnected),i=Ee(p=>p.providers.length),n=Ee(p=>p.agents.length),l=Ee(p=>p.loadProviders),m=Ee(p=>p.loadAgents),c=Je(p=>p.currentDirectory),u=Se(p=>p.error),f=Se(p=>p.clearError),h=Pt(p=>p.setIsMobile),g=jr(p=>p.refreshStatus),b=wr(p=>p.setPlanModeEnabled),k=Pe(p=>p.projects);return d.useEffect(()=>(Ot(s),()=>Ot(null)),[s]),d.useEffect(()=>{h(!0)},[h]),d.useEffect(()=>{e()},[e]),d.useEffect(()=>{o&&(i===0&&l({source:"mobileApp:recovery"}),n===0&&m({source:"mobileApp:recovery"}))},[n,o,m,l,i]),d.useEffect(()=>{o&&Wt.setDirectory(c)},[c,o]),d.useEffect(()=>{g(s.github,{force:!0})},[s.github,g]),d.useEffect(()=>{if(k.length===0)return;let p=!1;return(async()=>{const y=new Map,C=[];await Promise.all(k.map(async E=>{const j=E.path.replace(/\\/g,"/").replace(/\/+$/,"");if(j)try{if(!(Re.getState().directories.get(j)?.isGitRepo??await Ys(()=>import("./useAppFontEffects-B66TruVB.js").then(T=>T.f8),__vite__mapDeps([0,1,2,3,4])).then(T=>T.checkIsGitRepository(j))))return;const N=await Rs({id:E.id,path:j});if(p||N.length===0)return;y.set(j,N),C.push(...N)}catch{}})),!p&&Se.setState({availableWorktrees:C,availableWorktreesByProject:y})})(),()=>{p=!0}},[k]),d.useEffect(()=>{let p=!1;return(async()=>{const y=await sr("/health",{method:"GET"}).catch(()=>null);if(!y||!y.ok||p)return;const C=await y.json().catch(()=>null);if(!C||p)return;const E=C.planModeExperimentalEnabled;b(E===!0||E===1||E==="1"||E==="true")})(),()=>{p=!0}},[b]),d.useEffect(()=>{if(!u)return;const p=window.setTimeout(()=>f(),5e3);return()=>window.clearTimeout(p)},[f,u]),kr(),Nr({enabled:!0}),on(),Sr(),an(),t.jsx(Ve,{children:t.jsx(Cr,{sdk:Wt.getSdkClient(),directory:c||"",children:t.jsx(Er,{apis:s,children:t.jsx(Pr,{delayDuration:300,skipDelayDuration:150,children:t.jsxs("div",{className:"h-full bg-background text-foreground",children:[t.jsx(Ar,{embeddedBackgroundWorkEnabled:r}),t.jsx(ln,{}),t.jsx(mo,{}),t.jsx(Dr,{}),r?t.jsx(cn,{}):null]})})})})})}function po(s){return s.currentDirectory}function go(s){return s.setSettingsPage}function xo(s){return s.available}function bo(s){return s.runtimeType}function vo(s){return s.mcpServers}function yo(s){return s.setMcpDraft}function jo(s){return s.setSelectedMcp}function wo(s){return s.refresh}function ko(s){return s.loadMcpConfigs}function No(s){return window.setTimeout(s,500)}const So=()=>{Kr(),rr().then(()=>{Promise.all([nr(),Qr()]).catch(s=>{console.error("[mobile-main] settings init failed:",s)}),qr(),Yr(),Jr()}).catch(s=>{console.error("[mobile-main] appearance init failed:",s)})};function Mo(s){So();const e=document.getElementById("root");if(!e)throw new Error("Root element not found");Js.createRoot(e).render(t.jsx(Xs.StrictMode,{children:t.jsx(Gr,{children:t.jsx(Vr,{children:t.jsx(Ur,{children:t.jsx(vn,{children:t.jsx(Hr,{children:t.jsx(ho,{apis:s})})})})})})}))}export{Mo as renderMobileApp};