@openchamber/web 1.14.0 → 1.14.1

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 (55) hide show
  1. package/dist/assets/{DiagramView-CIaZCGUT.js → DiagramView-Cb58svCq.js} +1 -1
  2. package/dist/assets/MarkdownRendererImpl-D2yCDL5A.js +7 -0
  3. package/dist/assets/{MultiRunWindow-Bsbr3i8y.js → MultiRunWindow-BPSxV_B7.js} +1 -1
  4. package/dist/assets/{OnboardingScreen-3IAKkM5k.js → OnboardingScreen-Sl-6JgaP.js} +1 -1
  5. package/dist/assets/{SessionSwitcherDropdown-CLm6tF5n.js → SessionSwitcherDropdown-4FWg9xMC.js} +1 -1
  6. package/dist/assets/{SettingsWindow-K-ErjehP.js → SettingsWindow-CY8q4msv.js} +1 -1
  7. package/dist/assets/{TerminalView-DF7-jlam.js → TerminalView-fTYjnQkh.js} +1 -1
  8. package/dist/assets/{es-DQIFCjC2.js → es-bWcuDy_2.js} +1 -1
  9. package/dist/assets/{fr-CJRav0LS.js → fr-DzRs3OzV.js} +2 -2
  10. package/dist/assets/index-KnWk9fmM.css +1 -0
  11. package/dist/assets/index-ZJTzZ0_U.js +2 -0
  12. package/dist/assets/{ja-CjAaqvHO.js → ja-BqUX_UD3.js} +2 -2
  13. package/dist/assets/{ko-BEbFxvrd.js → ko-BQo10SNx.js} +2 -2
  14. package/dist/assets/main-BDoqLlQB.js +236 -0
  15. package/dist/assets/{main-C2put7uQ.js → main-DUGyTrDt.js} +2 -2
  16. package/dist/assets/miniChat-DNDiX8GA.js +2 -0
  17. package/dist/assets/mobile-DnghtOCb.js +2 -0
  18. package/dist/assets/pl-Bgx_ATJT.js +15 -0
  19. package/dist/assets/{pt-BR-9Sk3esQZ.js → pt-BR-B1yXRvoX.js} +1 -1
  20. package/dist/assets/{renderElectronMiniChatApp-CdDj0ms1.js → renderElectronMiniChatApp-BB4C1K7t.js} +2 -2
  21. package/dist/assets/renderMobileApp-CZgaXKi5.js +16 -0
  22. package/dist/assets/runtimeEndpointReset-By39StyB.js +167 -0
  23. package/dist/assets/{uk-DW_dTfoO.js → uk-C9k8SP8q.js} +1 -1
  24. package/dist/assets/{useAppFontEffects-DTO332li.js → useAppFontEffects-BUUJYbAZ.js} +129 -117
  25. package/dist/assets/{zh-CN-r2_euV7U.js → zh-CN-Bri-Vo5y.js} +1 -1
  26. package/dist/assets/{zh-TW-BdPx3NWh.js → zh-TW-DAUGzmYG.js} +1 -1
  27. package/dist/index.html +3 -3
  28. package/dist/mini-chat.html +3 -3
  29. package/dist/mobile.html +3 -3
  30. package/package.json +1 -1
  31. package/server/index.js +27 -5
  32. package/server/lib/opencode/core-routes.js +1 -0
  33. package/server/lib/opencode/feature-routes-runtime.js +10 -0
  34. package/server/lib/opencode/models-metadata.js +61 -0
  35. package/server/lib/opencode/openchamber-routes.js +7 -40
  36. package/server/lib/opencode/settings-helpers.js +13 -0
  37. package/server/lib/opencode/shutdown-runtime.js +2 -0
  38. package/server/lib/session-assist/DOCUMENTATION.md +66 -0
  39. package/server/lib/session-assist/runtime.js +394 -0
  40. package/server/lib/small-model/DOCUMENTATION.md +78 -0
  41. package/server/lib/small-model/call.js +380 -0
  42. package/server/lib/small-model/catalog.js +13 -0
  43. package/server/lib/small-model/index.js +167 -0
  44. package/server/lib/small-model/resolve.js +131 -0
  45. package/server/lib/small-model/resolve.test.js +197 -0
  46. package/server/lib/small-model/routes.js +44 -0
  47. package/dist/assets/MarkdownRendererImpl-DWgOeIpO.js +0 -7
  48. package/dist/assets/index-5eUDDB6w.js +0 -2
  49. package/dist/assets/index-CgpE7F8T.css +0 -1
  50. package/dist/assets/main-DuQEoz31.js +0 -214
  51. package/dist/assets/miniChat-o3AAQ-8r.js +0 -2
  52. package/dist/assets/mobile-X0421aWz.js +0 -2
  53. package/dist/assets/pl-D4kzai5T.js +0 -15
  54. package/dist/assets/renderMobileApp-cZ_HZKSe.js +0 -16
  55. package/dist/assets/runtimeEndpointReset-BYLVW9e7.js +0 -167
@@ -1 +1 @@
1
- import{R as s,j as e}from"./vendor-.bun-C6iL44L9.js";import{u as c}from"./index-5eUDDB6w.js";import{c as j,d as b,I as a}from"./useAppFontEffects-DTO332li.js";import{D as y}from"./main-DuQEoz31.js";import"./runtimeEndpointReset-BYLVW9e7.js";import"./mobileLayoutPreference-Dio-WWkI.js";import"./SessionSwitcherDropdown-CLm6tF5n.js";function S(){const{t:n}=j(),{files:r}=b(),[t,x]=s.useState(null),[l,o]=s.useState(""),[p,m]=s.useState(!0),u=s.useRef(null),f=c(i=>i.pendingDiagramFile),d=s.useCallback(async i=>{m(!0),x(i);try{const g=await r?.readFile?.(i);g&&o(g.content)}catch{o("")}finally{m(!1)}},[r]);s.useEffect(()=>{if(!f)return;const i=c.getState().consumePendingDiagramFile();i&&d(i)},[d,f]);const h=s.useCallback(async()=>{const i=u.current?.getXml();t&&r?.writeFile&&i&&i!==l&&(await r.writeFile(t,i),o(i))},[t,r,l]),v=t?t.split("/").pop()||t:"";return t?p?e.jsx("div",{className:"flex h-full items-center justify-center p-3",children:e.jsx(a,{name:"loader-4",className:"size-4 animate-spin"})}):e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border/30 px-3 py-1.5",children:[e.jsx(a,{name:"file",className:"size-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"typography-ui text-muted-foreground truncate flex-1",children:v}),e.jsx("button",{type:"button",onClick:()=>{h()},className:"size-6 flex items-center justify-center rounded-md text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:n("filesView.diagram.saveDiagram"),children:e.jsx(a,{name:"save-3",className:"size-4"})}),e.jsx("button",{type:"button",onClick:()=>c.getState().setActiveMainTab("chat"),className:"size-6 flex items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:n("filesView.diagram.closeDiagramView"),children:e.jsx(a,{name:"close",className:"size-4"})})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(y,{ref:u,xml:l,className:"h-full"})})]}):e.jsx("div",{className:"flex h-full items-center justify-center p-3",children:e.jsx("div",{className:"typography-ui text-muted-foreground",children:n("filesView.editor.pickFileFromTree")})})}export{S as DiagramView};
1
+ import{R as s,j as e}from"./vendor-.bun-C6iL44L9.js";import{u as c}from"./index-ZJTzZ0_U.js";import{c as j,d as b,I as a}from"./useAppFontEffects-BUUJYbAZ.js";import{D as y}from"./main-BDoqLlQB.js";import"./runtimeEndpointReset-By39StyB.js";import"./mobileLayoutPreference-Dio-WWkI.js";import"./SessionSwitcherDropdown-4FWg9xMC.js";function S(){const{t:n}=j(),{files:r}=b(),[t,x]=s.useState(null),[l,o]=s.useState(""),[p,m]=s.useState(!0),u=s.useRef(null),f=c(i=>i.pendingDiagramFile),d=s.useCallback(async i=>{m(!0),x(i);try{const g=await r?.readFile?.(i);g&&o(g.content)}catch{o("")}finally{m(!1)}},[r]);s.useEffect(()=>{if(!f)return;const i=c.getState().consumePendingDiagramFile();i&&d(i)},[d,f]);const h=s.useCallback(async()=>{const i=u.current?.getXml();t&&r?.writeFile&&i&&i!==l&&(await r.writeFile(t,i),o(i))},[t,r,l]),v=t?t.split("/").pop()||t:"";return t?p?e.jsx("div",{className:"flex h-full items-center justify-center p-3",children:e.jsx(a,{name:"loader-4",className:"size-4 animate-spin"})}):e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border/30 px-3 py-1.5",children:[e.jsx(a,{name:"file",className:"size-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"typography-ui text-muted-foreground truncate flex-1",children:v}),e.jsx("button",{type:"button",onClick:()=>{h()},className:"size-6 flex items-center justify-center rounded-md text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:n("filesView.diagram.saveDiagram"),children:e.jsx(a,{name:"save-3",className:"size-4"})}),e.jsx("button",{type:"button",onClick:()=>c.getState().setActiveMainTab("chat"),className:"size-6 flex items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:n("filesView.diagram.closeDiagramView"),children:e.jsx(a,{name:"close",className:"size-4"})})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(y,{ref:u,xml:l,className:"h-full"})})]}):e.jsx("div",{className:"flex h-full items-center justify-center p-3",children:e.jsx("div",{className:"typography-ui text-muted-foreground",children:n("filesView.editor.pickFileFromTree")})})}export{S as DiagramView};
@@ -0,0 +1,7 @@
1
+ import{ce as $e,cf as Pe,cg as oe,ch as st,R as C,b as B,ci as it,cj as ct,ck as lt,j as X}from"./vendor-.bun-C6iL44L9.js";import{eU as dt,eV as ut,eW as mt,eX as ft,eY as Oe,eZ as pt,e_ as ht,w as le,cY as bt,cZ as gt,e$ as wt,f0 as yt,d as De,e as Be,f1 as He,p as qe,dC as kt,y as ye,c as Et,f2 as At,f3 as vt,f4 as Ct,aD as St,f5 as ke,f6 as Nt,f7 as xt,ca as Mt}from"./useAppFontEffects-BUUJYbAZ.js";import{y as be,u as ge,l as Lt,m as Rt,h as Tt}from"./index-ZJTzZ0_U.js";const G=t=>t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),_t=t=>/^\[[^\]]+\]:\s+\S+/m.test(t)||/^\[\^[^\]]+\]:\s+/m.test(t),Ft=t=>{const e=t.match(/^[ \t]{0,3}(`{3,}|~{3,})/);if(!e)return!1;const n=e[1];if(!n)return!1;const r=n[0],s=n.length,o=t.trimEnd().split(`
2
+ `).at(-1)?.trim()??"";return!new RegExp(`^[\\t ]{0,3}${r}{${s},}[\\t ]*$`).test(o)},Z=t=>{try{return st(t,{linkMode:"text-only"})}catch{return t}},It=(t,e)=>{if(!e)return[{raw:t,src:t,mode:"full",highlight:!0}];if(_t(t))return[{raw:t,src:Z(t),mode:"live",highlight:!0}];let n;try{n=$e.lexer(t)}catch{return[{raw:t,src:Z(t),mode:"live",highlight:!0}]}let r=-1;for(let o=n.length-1;o>=0;o-=1)if(n[o]?.type!=="space"){r=o;break}if(r<0)return[{raw:t,src:Z(t),mode:"live",highlight:!0}];const s=[];for(let o=0;o<n.length;o+=1){const i=n[o];if(!i||i.type==="space")continue;const a=i.raw??"",c=o===r,l=i.type==="code"&&Ft(a);s.push({raw:a,src:l?a:Z(a),mode:c?"live":"full",highlight:!l})}return s.length===0?[{raw:t,src:Z(t),mode:"live",highlight:!0}]:s},We=(t,e,n)=>{try{return Pe.renderToString(t,{displayMode:n,throwOnError:!1})}catch{return e}},$t={name:"inlineMath",level:"inline",start(t){const e=t.indexOf("\\(");return e<0?void 0:e},tokenizer(t){const e=/^\\\(([\s\S]+?)\\\)/.exec(t);if(e)return{type:"inlineMath",raw:e[0],text:e[1]??""}},renderer(t){const e=t;return We(e.text,e.raw,!1)}},Pt={name:"blockMath",level:"block",start(t){const e=t.indexOf("\\[");return e<0?void 0:e},tokenizer(t){const e=/^\\\[([\s\S]+?)\\\]/.exec(t);if(e)return{type:"blockMath",raw:e[0],text:e[1]??""}},renderer(t){const e=t;return We(e.text,e.raw,!0)}},je=$e.use({gfm:!0,breaks:!1,extensions:[$t,Pt],renderer:{link({href:t,title:e,text:n}){const r=t??"",s=dt(r);if(s)return`<a href="${G(mt(s))}" data-openchamber-agent-mention="true" class="text-primary hover:underline" target="_blank" rel="noopener noreferrer">${n}</a>`;const o=ut(r);if(o)return`<a href="${G(r)}" data-skill-name="${G(o)}" class="text-primary hover:underline">${n}</a>`;const i=e?` title="${G(e)}"`:"";return`<a href="${G(r)}"${i} class="external-link" target="_blank" rel="noopener noreferrer">${n}</a>`}}}),Ot=t=>t.replace(/\$\$([\s\S]*?)\$\$/g,(e,n)=>{try{return Pe.renderToString(n,{displayMode:!0,throwOnError:!1})}catch{return`$$${n}$$`}}),ze=t=>{if(t.indexOf("$")===-1)return t;const e=/(<(?:pre|code|kbd)[^>]*>[\s\S]*?<\/(?:pre|code|kbd)>)/gi;return t.split(e).map((n,r)=>r%2===1?n:Ot(n)).join("")},Dt=/<pre><code(?:\s+class="language-([^"]*)")?>([\s\S]*?)<\/code><\/pre>/g,Bt=1200,Ht=200,qt=(t,e)=>{let n=1;for(let r=0;r<t.length;r+=1)if(t.charCodeAt(r)===10&&++n>e)return!0;return!1},Wt=t=>t.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&amp;/g,"&"),jt=async t=>{const e=[...t.matchAll(Dt)];if(e.length===0)return t;const n=be()?Ht:Bt;let r=t;for(const s of e){const[o,i,a]=s,c=(i||"text").toLowerCase();if(c==="mermaid")continue;const l=Wt(a??"");if(qt(l,n)){r=r.replace(o,()=>o.replace("<pre",`<pre data-md-lang="${c}"`));continue}const d=await ft(l,c);if(d){const m=d.replace(/^<pre/,`<pre data-md-lang="${c}"`);r=r.replace(o,()=>m)}}return r},zt={USE_PROFILES:{html:!0,mathMl:!0,svg:!0},ADD_TAGS:["svg","path","g","rect","line","polygon","polyline","circle","ellipse","text","tspan","defs","marker"],ADD_ATTR:["d","viewBox","preserveAspectRatio","xmlns","target","fill","stroke","stroke-width","transform","points","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","style"],FORBID_TAGS:["script"],FORBID_CONTENTS:["script"]};let Ee=!1;const Kt=()=>{Ee||typeof window>"u"||!oe.isSupported||(Ee=!0,oe.addHook("afterSanitizeAttributes",t=>{t instanceof HTMLAnchorElement&&t.target==="_blank"&&t.setAttribute("rel","noopener noreferrer")}))},Ke=t=>oe.isSupported?(Kt(),oe.sanitize(t,zt)):"",Vt=240,K=new Map,Ut=t=>{let e=2166136261;for(let n=0;n<t.length;n+=1)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return(e>>>0).toString(36)},Ae=(t,e)=>{if(K.delete(t),K.set(t,e),K.size<=Vt)return;const n=K.keys().next().value;n&&K.delete(n)},Gt=async t=>{const e=await Promise.resolve(je.parse(t.src)),n=ze(e),r=t.highlight?await jt(n):n;return Ke(r)},Zt=t=>{if(!t)return"";const e=je.parse(t),n=ze(e);return Ke(n)},Xt=async(t,e,n)=>{if(!t)return[];const r=It(t,e);return Promise.all(r.map(async(s,o)=>{const i=Ut(s.raw),a=`${i}:${s.mode}:${s.highlight?1:0}`,c=`${n}:${o}:${s.mode}`,l=K.get(c);if(l&&l.hash===i)return Ae(c,l),{id:a,html:l.html};const d=await Gt(s);return Ae(c,{hash:i,html:d}),{id:a,html:d}}))},de=t=>`<svg class="remixicon size-3.5" viewBox="0 0 24 24" aria-hidden="true"><use href="#oc-${t}"></use></svg>`,ae={copy:de("file-copy"),check:de("check"),download:de("download")},Ve="p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",Y=(t,e)=>{t.innerHTML=e},U=(t,e,n)=>{const r=document.createElement("button");return r.type="button",r.className=Ve,r.setAttribute("data-md-action",n),r.setAttribute("title",e),r.setAttribute("aria-label",e),Y(r,ae[t]),r},ve=(t,e,n,r)=>{Y(t,ae.check),t.setAttribute("title",e),window.setTimeout(()=>{Y(t,ae[n]),t.setAttribute("title",r)},2e3)},Yt=t=>{const e=t.querySelectorAll(":not(pre) > code");for(const n of Array.from(e))n.getAttribute("data-markdown")!=="inline-code"&&n.setAttribute("data-markdown","inline-code")},Jt=(t,e)=>{const n=t.querySelectorAll("pre");for(const r of Array.from(n)){if(r.querySelector("code.language-mermaid"))continue;const s=r.parentElement;if(!s||s.closest('[data-component="markdown-code"]'))continue;const o=r.querySelector("code")?.className.match(/language-([\w+#.-]+)/)?.[1],i=r.getAttribute("data-md-lang")??o??"text",a=document.createElement("div");a.setAttribute("data-component","markdown-code"),a.className="my-4 group overflow-hidden rounded-2xl border border-border/80 bg-[var(--surface-elevated)]";const c=document.createElement("div");c.className="flex items-center justify-between border-b border-border/70 px-3 py-1.5";const l=document.createElement("span");l.className="font-mono text-[13px] text-muted-foreground",l.textContent=i;const d=U("copy",e.copy,"copy-code");c.appendChild(l),c.appendChild(d);const m=document.createElement("div");m.className="px-3 py-2.5 overflow-x-auto",s.replaceChild(a,r),r.style.margin="0",r.style.background="transparent",m.appendChild(r),a.appendChild(c),a.appendChild(m)}},Ce=t=>{const e=[],n=[],r=t.querySelectorAll("thead th");for(const o of Array.from(r))e.push((o.textContent??"").trim());const s=t.querySelectorAll("tbody tr");for(const o of Array.from(s)){const i=Array.from(o.querySelectorAll("td")).map(a=>(a.textContent??"").trim());i.length>0&&n.push(i)}return{headers:e,rows:n}},Qt=t=>/[",\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t,Se=({headers:t,rows:e})=>[t,...e].map(n=>n.map(Qt).join(",")).join(`
3
+ `),en=({headers:t,rows:e})=>[t,...e].map(n=>n.join(" ")).join(`
4
+ `),Ne=({headers:t,rows:e})=>{const n=`| ${t.join(" | ")} |`,r=`| ${t.map(()=>"---").join(" | ")} |`,s=e.map(o=>`| ${o.join(" | ")} |`).join(`
5
+ `);return`${n}
6
+ ${r}
7
+ ${s}`},xe=(t,e)=>{const n=document.createElement("div");n.className=`absolute top-full right-0 mt-1 hidden ${bt}`,n.style.backgroundColor="var(--surface-elevated)",n.style.color="var(--surface-elevated-foreground)",n.setAttribute("data-md-menu",t);for(const r of e){const s=document.createElement("button");s.type="button",s.className=`w-full text-left ${gt}`,s.setAttribute("data-md-action",`${t}-${r.key}`),s.textContent=r.label,n.appendChild(s)}return n},tn=(t,e)=>{const n=t.querySelectorAll("table");for(const r of Array.from(n)){if(r.closest('[data-markdown="table-wrapper"]'))continue;const o=document.createElement("div");o.className="group my-4 flex flex-col space-y-2",o.setAttribute("data-markdown","table-wrapper");const i=document.createElement("div");i.className="flex items-center justify-end gap-1";const a=document.createElement("div");a.className="relative",a.appendChild(U("copy",e.copyTable,"table-copy-toggle")),a.appendChild(xe("table-copy",[{key:"csv",label:"CSV"},{key:"tsv",label:"TSV"},{key:"markdown",label:"Markdown"}]));const c=document.createElement("div");c.className="relative",c.appendChild(U("download",e.downloadTable,"table-download-toggle")),c.appendChild(xe("table-download",[{key:"csv",label:"CSV"},{key:"markdown",label:"Markdown"}])),i.appendChild(a),i.appendChild(c);const l=document.createElement("div");l.className="overflow-x-auto rounded-lg border border-border/80 bg-[var(--surface-elevated)]";const d=r.parentElement;if(!d)continue;d.replaceChild(o,r),r.setAttribute("data-markdown","table"),r.classList.add("w-full","border-collapse","text-sm");for(const p of Array.from(r.querySelectorAll("tr")))p.classList.add("border-b","border-border/60");const m=r.querySelector("tbody tr:last-child");m?.classList.remove("border-b"),m?.classList.add("border-0");for(const p of Array.from(r.querySelectorAll("th")))p.classList.add("border-r","border-border/60","px-4","py-2.5","text-left","align-middle","font-semibold","text-foreground","last:border-r-0");for(const p of Array.from(r.querySelectorAll("td")))p.classList.add("border-r","border-border/60","px-4","py-2.5","align-middle","text-foreground/90","last:border-r-0");l.appendChild(r),o.appendChild(i),o.appendChild(l)}},nn=(t,e)=>{const n=t.querySelectorAll("pre > code.language-mermaid");for(const r of Array.from(n)){const s=r.parentElement;if(!s)continue;const o=(r.textContent??"").replace(/\s+$/,""),i=e.renderMermaid(o),a=document.createElement("div");a.setAttribute("data-markdown","mermaid-block"),a.className="group relative";const c=document.createElement("div");c.setAttribute("data-markdown","mermaid-scroll");const l=document.createElement("div");if(l.className="absolute top-1 right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",i.svg){const m=document.createElement("div");m.setAttribute("data-markdown","mermaid"),Y(m,i.svg),c.appendChild(m);const p=U("copy",e.labels.copyDiagram,"mermaid-copy");p.setAttribute("data-md-source",o);const g=U("download",e.labels.downloadDiagram,"mermaid-download");g.setAttribute("data-md-svg","1"),l.appendChild(p),l.appendChild(g)}else{const m=document.createElement("pre");m.setAttribute("data-markdown","mermaid-ascii"),m.textContent=i.ascii||o,c.appendChild(m);const p=U("copy",e.labels.copyDiagram,"mermaid-copy");p.setAttribute("data-md-source",i.ascii||o),l.appendChild(p)}a.appendChild(c),a.appendChild(l);const d=s.parentElement;d&&d.replaceChild(a,s)}},rn=(t,e)=>{const n=t.querySelectorAll("a[href]");for(const r of Array.from(n)){if(r.getAttribute("data-md-link-decorated")==="true"||r.getAttribute("data-openchamber-file-link")==="true")continue;const s=r.getAttribute("href")??"";if(!Oe(s))continue;r.setAttribute("data-md-link-decorated","true");const o=pt(s);if(o){const i=document.createElement("span");i.className="mr-1 inline-flex size-[18px] items-center justify-center rounded border border-[var(--border)] bg-[var(--interactive-hover)] align-middle";const a=document.createElement("img");a.src=o,a.alt="",a.setAttribute("aria-hidden","true"),a.loading="lazy",a.decoding="async",a.className="size-3.5 rounded-sm",a.addEventListener("error",()=>i.remove(),{once:!0}),i.appendChild(a),r.parentNode?.insertBefore(i,r)}if(e.onPreviewLoopback&&ht(s)){const i=document.createElement("button");i.type="button",i.className=`ml-1 align-middle ${Ve}`,i.setAttribute("data-md-action","preview-loopback"),i.setAttribute("data-md-url",s),i.setAttribute("title",e.labels.previewTitle),i.setAttribute("aria-label",e.labels.previewLabel),Y(i,ae.download),r.parentNode?.insertBefore(i,r.nextSibling)}}},Me=(t,e)=>{Yt(t),nn(t,e),Jt(t,e.labels),tn(t,e.labels),rn(t,e)},Le=(t,e,n)=>{const r=new Blob([e],{type:n}),s=URL.createObjectURL(r),o=document.createElement("a");o.href=s,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(s)},te=t=>{for(const e of Array.from(t.querySelectorAll("[data-md-menu]")))e.classList.add("hidden")},on=(t,e)=>{const n=r=>{const s=r.target;if(!(s instanceof Element))return;const o=s.closest("[data-md-action]");if(!o){te(t);return}const i=o.getAttribute("data-md-action")??"";if(i==="copy-code"){const c=o.closest('[data-component="markdown-code"]')?.querySelector("code")?.textContent??"";c&&le(c).then(()=>ve(o,e.labels.copied,"copy",e.labels.copy));return}if(i==="table-copy-toggle"||i==="table-download-toggle"){r.preventDefault();const a=o.parentElement?.querySelector("[data-md-menu]")??null,c=a?.classList.contains("hidden")??!1;te(t),a&&c&&a.classList.remove("hidden");return}if(i.startsWith("table-copy-")){const a=i.replace("table-copy-",""),c=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(c instanceof HTMLTableElement){const l=Ce(c),d=a==="csv"?Se(l):a==="tsv"?en(l):Ne(l);le(d)}te(t);return}if(i.startsWith("table-download-")){const a=i.replace("table-download-",""),c=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(c instanceof HTMLTableElement){const l=Ce(c),d=a==="csv"?Se(l):Ne(l);Le(a==="csv"?"table.csv":"table.md",d,a==="csv"?"text/csv":"text/markdown")}te(t);return}if(i==="mermaid-copy"){const a=o.getAttribute("data-md-source")??"";a&&le(a).then(()=>ve(o,e.labels.copied,"copy",e.labels.copyDiagram));return}if(i==="mermaid-download"){const c=o.closest('[data-markdown="mermaid-block"]')?.querySelector('[data-markdown="mermaid"]')?.innerHTML??"";c&&Le("diagram.svg",c,"image/svg+xml;charset=utf-8");return}if(i==="preview-loopback"){r.preventDefault();const a=o.getAttribute("data-md-url")??"";a&&e.onPreviewLoopback?.(a);return}};return t.addEventListener("click",n),()=>t.removeEventListener("click",n)},an=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),Re=Array.from(an).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),sn=t=>yt(t),cn=t=>wt(t),se=t=>{let e=(t||"").trim();return e?((e.startsWith("`")&&e.endsWith("`")||e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1).trim()),e=e.replace(/[.,;!?]+$/g,""),e.endsWith(")")&&!e.includes("(")&&(e=e.slice(0,-1)),e.endsWith("]")&&!e.includes("[")&&(e=e.slice(0,-1)),e):""},ne=t=>{let e=se(t);if(!e)return"";const n=e.indexOf(";");n>=0&&(e=e.slice(0,n)),e=e.replace(/#.*$/,"");const r=e.match(/^(.*\.[A-Za-z0-9_-]{1,16}):.*$/);r&&(e=r[1]??e);const s=Re.length>0?e.match(new RegExp(`^(.*(?:/|^)(${Re})):.*$`,"i")):null;return s&&(e=s[1]??e),se(e)},Ue=t=>{const e=se(t);if(!e)return null;const n=e.indexOf(";"),r=n>=0?se(e.slice(0,n)):e;if(!r)return null;const s=r.match(/^(.*?):(\d+)-(\d+)$/);if(s){const c=ne(s[1]??""),l=Number.parseInt(s[2]??"",10),d=Number.parseInt(s[3]??"",10);return!c||!Number.isFinite(l)||!Number.isFinite(d)||d<l?null:{path:c,line:l,endLine:d}}const o=r.match(/^(.*)#L(\d+)(?:C(\d+))?$/i);if(o){const c=ne(o[1]??""),l=Number.parseInt(o[2]??"",10),d=o[3]?Number.parseInt(o[3],10):void 0;return!c||!Number.isFinite(l)?null:{path:c,line:l,column:Number.isFinite(d??Number.NaN)?d:void 0}}const i=r.match(/^(.*?):(\d+)(?::(\d+))?$/);if(i){const c=ne(i[1]??""),l=Number.parseInt(i[2]??"",10),d=i[3]?Number.parseInt(i[3],10):void 0;return!c||!Number.isFinite(l)?null:{path:c,line:l,column:Number.isFinite(d??Number.NaN)?d:void 0}}const a=ne(r);return a?{path:a}:null},ue=/(?:[A-Za-z]:[\\/])?[\w.\-/@+]*[\w\-/@+]\.[A-Za-z0-9]{1,8}(?::\d+(?:-\d+)?(?::\d+)?)?/g,Ge=()=>{const t=B.c(4),e=kt();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=ye(!1),t[0]=n):n=t[0];const r=n;let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=ye(!0),t[1]=s):s=t[1];const o=s;let i;return t[2]!==e?.currentTheme?(i=e?.currentTheme??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?o:r),t[2]=e?.currentTheme,t[3]=i):i=t[3],i},Ze=t=>{const e=B.c(4),{containerRef:n,enabled:r}=t;let s,o;e[0]!==n||e[1]!==r?(s=()=>{if(r===!1)return;const i=n.current;if(!i)return;const a=On;return i.addEventListener("click",a),()=>{i.removeEventListener("click",a)}},o=[n,r],e[0]=n,e[1]=r,e[2]=s,e[3]=o):(s=e[2],o=e[3]),C.useEffect(s,o)},Xe=t=>{if(!t.includes("mermaid"))return[];const e=[],n=/(?:^|\r?\n)(`{3,}|~{3,})mermaid[^\n\r]*\r?\n([\s\S]*?)\r?\n\1(?=\r?\n|$)/gi;let r=n.exec(t);for(;r;){const s=(r[2]??"").replace(/\s+$/,"");e.push(s),r=n.exec(t)}return e},ln=t=>{const e=t.match(/^(?:\uFEFF)?(---|\+\+\+)[^\S\r\n]*\r?\n[\s\S]*?\r?\n\1[^\S\r\n]*(?:\r?\n|$)/);return e?t.slice(e[0].length):t},me='[data-markdown="mermaid-block"]',Te='[data-openchamber-file-link="true"]',Ye="data-openchamber-block-path-token",Je=`[${Ye}]`,V="data-openchamber-block-paths-scanned",dn=2e5,un=4,mn=1e3,fn=200,pn=80,hn=40,_e=160,O=new Map;let re=0;const Fe=[],bn=()=>be()?fn:mn,gn=()=>be()?hn:pn,wn=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),we=t=>sn(t),yn=t=>cn(t),kn=(t,e)=>Mt(t,e),En=t=>{const e=t.split("/").filter(Boolean).pop()??"";return!e||e.endsWith(".")?!1:/\.[A-Za-z0-9_-]{1,16}$/.test(e)},Qe=t=>{if(!t||t.startsWith("--")||t.includes("://")||/[<>]/.test(t)||/\s{2,}/.test(t))return!1;const e=we(t),n=e.split("/").filter(Boolean).pop()??e;if(!n||n==="."||n==="..")return!1;const r=n.toLowerCase();return wn.has(r)||r.startsWith(".")&&r.length>1?!0:En(e)},et=t=>{const e=Ue(t);return e?Qe(e.path):!1},Ie=(t,e)=>{let n=0;for(const s of t){const o=n+s.data.length;if(e<=o)return{node:s,offset:Math.max(0,e-n)};n=o}const r=t.at(-1);return r?{node:r,offset:r.data.length}:null},An=t=>{const e=t.querySelectorAll(Je);for(const r of Array.from(e))r.replaceWith(t.ownerDocument.createTextNode(r.textContent??""));const n=t.querySelectorAll(`code[${V}]`);for(const r of Array.from(n))r.removeAttribute(V),r.normalize()},fe=t=>{if(t.tagName.toLowerCase()==="a"){const e=t.getAttribute("href")?.trim();if(e&&et(e))return e}return(t.textContent||"").trim()},vn=t=>{const e=t.querySelectorAll("pre code");if(e.length===0)return;const n=t.ownerDocument;if(n)for(const r of Array.from(e)){if(r.getAttribute(V)==="true")continue;if((r.textContent??"").length>dn){r.setAttribute(V,"true");continue}const s=n.createTreeWalker(r,NodeFilter.SHOW_TEXT),o=[];let i=s.nextNode();for(;i;)o.push(i),i=s.nextNode();const a=r.textContent??"";if(!a.includes(".")){r.setAttribute(V,"true");continue}ue.lastIndex=0;const c=[];let l=ue.exec(a);for(;l;){const d=l[0];d&&et(d)&&c.push({start:l.index,end:l.index+d.length,raw:d}),l=ue.exec(a)}for(const{start:d,end:m,raw:p}of c.reverse()){const g=Ie(o,d),E=Ie(o,m);if(!g||!E)continue;const k=n.createRange();k.setStart(g.node,g.offset),k.setEnd(E.node,E.offset);const w=n.createElement("span");w.setAttribute(Ye,"true"),w.textContent=p,k.deleteContents(),k.insertNode(w)}r.setAttribute(V,"true")}},pe=(t,e)=>{const n=Ue(t);if(!n||!Qe(n.path))return null;const r=yn(n.path)?we(n.path):kn(e,n.path);return r?{...n,resolvedPath:r}:null},Cn=t=>{const e=we(t);if(!e)return Promise.resolve(!1);const n=O.get(e);if(n)return O.delete(e),O.set(e,n),n;const r=new Promise(o=>{const i=()=>{re+=1,Tt(`/api/fs/stat?path=${encodeURIComponent(e)}&optional=true`,{method:"GET",cache:"no-store"}).then(async a=>{if(!a.ok){o(!1);return}const c=await a.json().catch(()=>null);o(c?.exists!==!1)}).catch(()=>o(!1)).finally(()=>{re=Math.max(0,re-1),Fe.shift()?.()})};if(re<un){i();return}Fe.push(i)}),s=bn();for(;O.size>=s;){const o=O.keys().next().value;if(typeof o!="string")break;O.delete(o)}return O.set(e,r),r},Sn=(t,e)=>t||xt(t,e),tt=t=>{const e=B.c(7),{containerRef:n,effectiveDirectory:r,editor:s,preferRuntimeEditor:o,enabled:i}=t,a=C.useRef(null);let c,l;e[0]!==n||e[1]!==s||e[2]!==r||e[3]!==i||e[4]!==o?(c=()=>{const d=n.current;if(!d)return;let m=!1;const p=gn(),g=i&&!vt(),E=Dn,k=()=>{const f=d.querySelectorAll(Te);for(const h of Array.from(f))E(h);An(d)};if(!g){k();return}const w=f=>{const h=f;if(a.current!==null&&typeof window<"u"&&window.clearTimeout(a.current),typeof window>"u"){b();return}a.current=window.setTimeout(()=>{a.current=null,window.requestAnimationFrame(()=>{m||b()})},h)},b=()=>{g&&vn(d);const f=d.querySelectorAll(`[data-markdown="inline-code"], a, ${Je}`);let h=0;for(const u of Array.from(f)){const S=fe(u),x=pe(S,r);if(E(u),!x||h>=p)continue;h=h+1,(Lt()&&Rt()&&!ke(x.resolvedPath,r)?Promise.resolve(!0):Cn(x.resolvedPath)).then(_=>{if(m||!_||!d.contains(u))return;const F=fe(u),M=pe(F,r);!M||M.resolvedPath!==x.resolvedPath||(u.setAttribute("data-openchamber-file-link","true"),u.setAttribute("data-openchamber-file-ref",F),u.setAttribute("data-openchamber-file-path",M.resolvedPath),u.setAttribute("title","Open file"),u.tagName.toLowerCase()!=="a"&&(u.setAttribute("role","button"),u.setAttribute("tabindex","0")))})}},A=async f=>{const h=f.getAttribute("data-openchamber-file-ref")||fe(f),u=pe(h,r);if(!u)return;const S=Sn(r,u.resolvedPath);if(o&&s){s.openFile(u.resolvedPath,Number.isFinite(u.line??Number.NaN)?Math.max(1,Math.trunc(u.line)):void 0,Number.isFinite(u.column??Number.NaN)?Math.max(1,Math.trunc(u.column)):void 0);return}ke(u.resolvedPath,r)||await Nt(u.resolvedPath,r);const x=ge.getState();Number.isFinite(u.line??Number.NaN)?x.openContextFileAtLine(S,u.resolvedPath,Math.max(1,Math.trunc(u.line)),Number.isFinite(u.column??Number.NaN)?Math.max(1,Math.trunc(u.column)):1):x.openContextFile(S,u.resolvedPath)},y=f=>{const h=f.target;if(!(h instanceof Element))return;const u=h.closest(Te);u instanceof HTMLElement&&(f.preventDefault(),f.stopPropagation(),A(u))},v=f=>{if(f.key!=="Enter"&&f.key!==" ")return;const h=f.target;!(h instanceof HTMLElement)||h.getAttribute("data-openchamber-file-link")!=="true"||(f.preventDefault(),f.stopPropagation(),A(h))};w(_e);const N=new MutationObserver(()=>{w(_e)});return N.observe(d,{childList:!0,subtree:!0}),d.addEventListener("click",y),d.addEventListener("keydown",v),()=>{m=!0,a.current!==null&&typeof window<"u"&&window.clearTimeout(a.current),a.current=null,N.disconnect(),d.removeEventListener("click",y),d.removeEventListener("keydown",v)}},l=[n,s,r,o,i],e[0]=n,e[1]=s,e[2]=r,e[3]=i,e[4]=o,e[5]=c,e[6]=l):(c=e[5],l=e[6]),C.useEffect(c,l)},nt=t=>{const e=B.c(6),{containerRef:n,mermaidBlocks:r,onShowPopup:s,allowWheelZoom:o}=t;let i,a;e[0]!==o||e[1]!==n||e[2]!==r||e[3]!==s?(i=()=>{const c=n.current;if(!c)return;const l=m=>{if(!s)return;const p=m.target;if(!(p instanceof Element)||p.closest('button, a, [role="button"]'))return;const g=p.closest(me);if(!g)return;const k=Array.from(c.querySelectorAll(me)).indexOf(g);if(k<0)return;const w=r[k];if(!w||w.trim().length===0)return;const b=`Diagram ${k+1}`;s({open:!0,title:b,content:"",metadata:{tool:"mermaid-preview",filename:b},mermaid:{url:`data:text/plain;charset=utf-8,${encodeURIComponent(w)}`,source:w,filename:b}})},d=m=>{if(o)return;const p=m.target;!(p instanceof Element)||!p.closest(me)||m.stopPropagation()};return c.addEventListener("click",l),c.addEventListener("wheel",d,{capture:!0,passive:!0}),()=>{c.removeEventListener("click",l),c.removeEventListener("wheel",d,!0)}},a=[o,n,r,s],e[0]=o,e[1]=n,e[2]=r,e[3]=s,e[4]=i,e[5]=a):(i=e[4],a=e[5]),C.useEffect(i,a)},he=64,Nn=24,xn=he/Nn,Mn=/[\s.,!?;:)\]]/,Ln=t=>{const e=t<=12?2:t<=48?4:t<=96?8:Math.min(24,Math.ceil(t/8));return Math.max(1,Math.round(e*xn))},Rn=(t,e)=>{const n=Math.min(t.length,e+Ln(t.length-e));for(let r=n;r<Math.min(t.length,n+8);r+=1)if(Mn.test(t[r]??""))return r+1;return n},Tn=(t,e)=>{const[n,r]=C.useState(()=>e?0:t.length),s=C.useRef(n);return s.current=n,C.useEffect(()=>{if(!e||typeof window>"u"){r(t.length);return}s.current>t.length&&r(t.length);let o=null;const i=()=>{const a=Math.min(s.current,t.length);if(a>=t.length){o=null;return}r(Rn(t,a)),o=window.setTimeout(i,he)};return s.current<t.length&&(o=window.setTimeout(i,he)),()=>{o!==null&&window.clearTimeout(o)}},[t,e]),e?t.slice(0,Math.min(n,t.length)):t},D=new Map,_n=100,Fn=(t,e)=>{const n=D.get(t);if(n)return D.delete(t),D.set(t,n),n;const r=e();if(D.set(t,r),D.size>_n){const s=D.keys().next().value;s&&D.delete(s)}return r},In=t=>({bg:t.colors.surface.elevated,fg:t.colors.surface.foreground,line:t.colors.interactive.border,accent:t.colors.primary.base,muted:t.colors.surface.mutedForeground,surface:t.colors.surface.muted,border:t.colors.interactive.border,transparent:!0,font:"system-ui, sans-serif"}),rt=(t,e)=>{const{t:n}=Et(),r=C.useMemo(()=>({copy:"Copy code",copied:"Copied",copyTable:n("markdownRenderer.table.actions.copyTitle"),downloadTable:n("markdownRenderer.table.actions.downloadTitle"),copyDiagram:n("markdownRenderer.mermaid.actions.copySourceTitle"),downloadDiagram:n("markdownRenderer.mermaid.actions.downloadSvgTitle"),previewLabel:n("terminalView.preview.open"),previewTitle:n("terminalView.preview.openTitle")}),[n]);return C.useMemo(()=>{const s=In(t),o=ge.getState().mermaidRenderingMode,i=t.metadata?.id??"theme";return{labels:r,renderMermaid:c=>Fn(`${i}:${o}:${c}`,()=>{try{return o==="ascii"?{ascii:it(c)}:{svg:ct(c,s)}}catch{return{}}}),onPreviewLoopback:e}},[t,r,e])},ot=t=>{const e=B.c(21),{containerRef:n,text:r,streaming:s,cacheKey:o,syntaxVars:i,ctx:a}=t;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0],C.useEffect(Bn,c);let l,d;e[1]!==n||e[2]!==a||e[3]!==r?(l=()=>{const b=n.current,A=b?.querySelector("[data-markdown-content]")??b;if(A&&r&&A.childNodes.length===0){const y=document.createElement("div");y.setAttribute("data-md-block",""),y.style.display="contents",y.innerHTML=Zt(r),Me(y,a),A.appendChild(y)}},d=[n,r,a],e[1]=n,e[2]=a,e[3]=r,e[4]=l,e[5]=d):(l=e[4],d=e[5]),C.useLayoutEffect(l,d);let m,p;e[6]!==o||e[7]!==n||e[8]!==a||e[9]!==s||e[10]!==r?(m=()=>{const b=n.current;if(!b)return;const A=b.querySelector("[data-markdown-content]")??b;let y=!0;return Xt(r,s,o).then(v=>{if(!y)return;const N=Array.from(A.children);v.forEach((f,h)=>{let u=N[h];if(u||(u=document.createElement("div"),u.setAttribute("data-md-block",""),u.style.display="contents",A.appendChild(u)),u.getAttribute("data-md-id")===f.id)return;const S=document.createElement("div");S.innerHTML=f.html,Me(S,a),lt(u,S,{childrenOnly:!0,onBeforeElUpdated:Hn}),u.setAttribute("data-md-id",f.id)});for(let f=N.length-1;f>=v.length;f=f-1,f)N[f]?.remove()}),()=>{y=!1}},p=[n,r,s,o,a],e[6]=o,e[7]=n,e[8]=a,e[9]=s,e[10]=r,e[11]=m,e[12]=p):(m=e[11],p=e[12]),C.useEffect(m,p);let g,E;e[13]!==n||e[14]!==a?(g=()=>{const b=n.current;if(b)return on(b,a)},E=[n,a],e[13]=n,e[14]=a,e[15]=g,e[16]=E):(g=e[15],E=e[16]),C.useEffect(g,E);let k,w;e[17]!==n||e[18]!==i?(k=()=>{const b=n.current,A=b?.querySelector("[data-markdown-content]")??b;if(A)for(const[y,v]of Object.entries(i))A.style.setProperty(y,v)},w=[n,i],e[17]=n,e[18]=i,e[19]=k,e[20]=w):(k=e[19],w=e[20]),C.useEffect(k,w)},at=t=>t==="tool"?"markdown-content markdown-tool":t==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed",$n=t=>{const e=B.c(35),{content:n,part:r,messageId:s,isAnimated:o,skipFadeIn:i,className:a,isStreaming:c,disableStreamAnimation:l,variant:d,onShowPopup:m,enableFileReferences:p}=t,g=o===void 0?!0:o,E=i===void 0?!1:i,k=c===void 0?!1:c,w=l===void 0?!1:l,b=d===void 0?"assistant":d,A=p===void 0?!0:p,y=Ge(),{editor:v,runtime:N}=De(),f=C.useRef(null),h=Be()??"",u=ge(qn);let S;e[0]!==h||e[1]!==u?(S=z=>{h&&u(h,z)},e[0]=h,e[1]=u,e[2]=S):S=e[2];const x=S,T=k&&!w,P=Tn(n,T);let _;e[3]!==n?(_=Xe(n),e[3]=n,e[4]=_):_=e[4];const F=_;let M;e[5]!==F||e[6]!==m?(M={containerRef:f,mermaidBlocks:F,onShowPopup:m},e[5]=F,e[6]=m,e[7]=M):M=e[7],nt(M);const I=A&&!k;let L;e[8]!==v||e[9]!==h||e[10]!==N.isVSCode||e[11]!==I?(L={containerRef:f,effectiveDirectory:h,editor:v,preferRuntimeEditor:N.isVSCode,enabled:I},e[8]=v,e[9]=h,e[10]=N.isVSCode,e[11]=I,e[12]=L):L=e[12],tt(L);let R;e[13]===Symbol.for("react.memo_cache_sentinel")?(R={containerRef:f},e[13]=R):R=e[13],Ze(R);let $;e[14]!==y?($=He(y),e[14]=y,e[15]=$):$=e[15];const ie=$,ce=rt(y,h?x:void 0),H=`markdown-${r?.id?`part-${r.id}`:`message-${s}`}`;let J;e[16]!==H||e[17]!==ce||e[18]!==T||e[19]!==P||e[20]!==ie?(J={containerRef:f,text:P,streaming:T,cacheKey:H,syntaxVars:ie,ctx:ce},e[16]=H,e[17]=ce,e[18]=T,e[19]=P,e[20]=ie,e[21]=J):J=e[21],ot(J);let q;e[22]!==a?(q=qe("break-words w-full min-w-0",a),e[22]=a,e[23]=q):q=e[23];let W;e[24]!==b?(W=at(b),e[24]=b,e[25]=W):W=e[25];let j;e[26]!==W?(j=X.jsx("div",{className:W,"data-markdown-content":!0}),e[26]=W,e[27]=j):j=e[27];let Q;e[28]!==q||e[29]!==j?(Q=X.jsx("div",{className:q,ref:f,children:j}),e[28]=q,e[29]=j,e[30]=Q):Q=e[30];const ee=Q;if(g){let z;return e[31]!==H||e[32]!==ee||e[33]!==E?(z=X.jsx(Ct,{skipAnimation:E,children:ee},H),e[31]=H,e[32]=ee,e[33]=E,e[34]=z):z=e[34],z}return ee},Kn=C.memo($n,(t,e)=>t.content===e.content&&t.isStreaming===e.isStreaming&&t.disableStreamAnimation===e.disableStreamAnimation&&t.variant===e.variant&&t.isAnimated===e.isAnimated&&t.skipFadeIn===e.skipFadeIn&&t.className===e.className&&t.messageId===e.messageId&&t.onShowPopup===e.onShowPopup&&t.enableFileReferences===e.enableFileReferences&&t.part?.id===e.part?.id),Pn=t=>{const e=B.c(32),{content:n,className:r,variant:s,disableLinkSafety:o,stripFrontmatter:i,onShowPopup:a,allowMermaidWheelZoom:c,enableFileReferences:l}=t,d=s===void 0?"assistant":s,m=i===void 0?!1:i,p=c===void 0?!1:c,g=l===void 0?!0:l,{editor:E,runtime:k}=De(),w=Ge(),b=C.useRef(null),A=Be()??"";let y;e[0]!==n||e[1]!==m?(y=m?ln(n):n,e[0]=n,e[1]=m,e[2]=y):y=e[2];const v=y;let N;e[3]!==v?(N=Xe(v),e[3]=v,e[4]=N):N=e[4];const f=N;let h;e[5]!==p||e[6]!==f||e[7]!==a?(h={containerRef:b,mermaidBlocks:f,onShowPopup:a,allowWheelZoom:p},e[5]=p,e[6]=f,e[7]=a,e[8]=h):h=e[8],nt(h);let u;e[9]!==E||e[10]!==A||e[11]!==g||e[12]!==k.isVSCode?(u={containerRef:b,effectiveDirectory:A,editor:E,preferRuntimeEditor:k.isVSCode,enabled:g},e[9]=E,e[10]=A,e[11]=g,e[12]=k.isVSCode,e[13]=u):u=e[13],tt(u);const S=!o;let x;e[14]!==S?(x={containerRef:b,enabled:S},e[14]=S,e[15]=x):x=e[15],Ze(x);let T;e[16]!==w?(T=He(w),e[16]=w,e[17]=T):T=e[17];const P=T,_=rt(w),F=`simple:${d}`;let M;e[18]!==_||e[19]!==v||e[20]!==P||e[21]!==F?(M={containerRef:b,text:v,streaming:!1,cacheKey:F,syntaxVars:P,ctx:_},e[18]=_,e[19]=v,e[20]=P,e[21]=F,e[22]=M):M=e[22],ot(M);let I;e[23]!==r?(I=qe("break-words w-full min-w-0",r),e[23]=r,e[24]=I):I=e[24];let L;e[25]!==d?(L=at(d),e[25]=d,e[26]=L):L=e[26];let R;e[27]!==L?(R=X.jsx("div",{className:L,"data-markdown-content":!0}),e[27]=L,e[28]=R):R=e[28];let $;return e[29]!==I||e[30]!==R?($=X.jsx("div",{className:I,ref:b,children:R}),e[29]=I,e[30]=R,e[31]=$):$=e[31],$},Vn=C.memo(Pn,(t,e)=>t.content===e.content&&t.variant===e.variant&&t.className===e.className&&t.disableLinkSafety===e.disableLinkSafety&&t.stripFrontmatter===e.stripFrontmatter&&t.onShowPopup===e.onShowPopup&&t.allowMermaidWheelZoom===e.allowMermaidWheelZoom&&t.enableFileReferences===e.enableFileReferences);function On(t){if(t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.altKey||t.shiftKey)return;const e=t.target;if(!(e instanceof Element))return;const n=e.closest("a[href]");if(!(n instanceof HTMLAnchorElement)||n.getAttribute("data-openchamber-file-link")==="true")return;const r=n.getAttribute("href")??"";Oe(r)&&(t.preventDefault(),t.stopPropagation(),St(r))}function Dn(t){t.removeAttribute("data-openchamber-file-link"),t.removeAttribute("data-openchamber-file-ref"),t.removeAttribute("data-openchamber-file-path"),t.getAttribute("title")==="Open file"&&t.removeAttribute("title"),t.tagName.toLowerCase()!=="a"&&(t.removeAttribute("role"),t.removeAttribute("tabindex"))}function Bn(){At()}function Hn(t,e){return!t.isEqualNode(e)}function qn(t){return t.openContextPreview}export{Kn as MarkdownRenderer,Vn as SimpleMarkdownRenderer};
@@ -1 +1 @@
1
- import{b as N,R as _,j as n,bk as D,bi as C,bj as I,bg as M,be as S}from"./vendor-.bun-C6iL44L9.js";import{c as z,p as w,I as O}from"./useAppFontEffects-DTO332li.js";import{M as P}from"./main-DuQEoz31.js";import"./index-5eUDDB6w.js";import"./runtimeEndpointReset-BYLVW9e7.js";import"./mobileLayoutPreference-Dio-WWkI.js";import"./SessionSwitcherDropdown-CLm6tF5n.js";const G=R=>{const e=N.c(33),{open:y,onOpenChange:t,initialPrompt:j}=R,i=_.useId(),{t:o}=z(),k=B;let s;e[0]!==t?(s=v=>{!v&&k()||t(v)},e[0]=t,e[1]=s):s=e[1];let b;e[2]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(D,{className:w("fixed inset-0 z-50 bg-black/50 dark:bg-black/75","transition-opacity duration-150 ease-out","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0")}),e[2]=b):b=e[2];let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=w("relative pointer-events-auto","w-[90vw] max-w-[720px] h-[680px] max-h-[85vh]","flex flex-col rounded-xl border shadow-none overflow-hidden origin-center","bg-background","transition-all duration-150 ease-out","data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]","data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]"),e[3]=g):g=e[3];let a;e[4]!==t?(a=()=>t(!1),e[4]=t,e[5]=a):a=e[5];let l;e[6]!==o?(l=o("multiRun.window.actions.closeAria"),e[6]=o,e[7]=l):l=e[7];let x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(O,{name:"close",className:"h-5 w-5"}),e[8]=x):x=e[8];let r;e[9]!==a||e[10]!==l?(r=n.jsx("div",{className:"absolute right-0.5 top-0.5 z-50",children:n.jsx("button",{type:"button",onClick:a,"aria-label":l,className:"inline-flex h-7 w-7 items-center justify-center rounded-md p-0.5 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:x})}),e[9]=a,e[10]=l,e[11]=r):r=e[11];let c;e[12]!==o?(c=o("multiRun.window.description"),e[12]=o,e[13]=c):c=e[13];let d;e[14]!==i||e[15]!==c?(d=n.jsx(C,{id:i,className:"sr-only",children:c}),e[14]=i,e[15]=c,e[16]=d):d=e[16];let u,m;e[17]!==t?(u=()=>t(!1),m=()=>t(!1),e[17]=t,e[18]=u,e[19]=m):(u=e[18],m=e[19]);let f;e[20]!==j||e[21]!==u||e[22]!==m?(f=n.jsx(P,{initialPrompt:j,onCreated:u,onCancel:m,isWindowed:!0}),e[20]=j,e[21]=u,e[22]=m,e[23]=f):f=e[23];let p;e[24]!==i||e[25]!==f||e[26]!==r||e[27]!==d?(p=n.jsxs(I,{children:[b,n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center pointer-events-none",children:n.jsxs(M,{"aria-describedby":i,className:g,children:[r,d,f]})})]}),e[24]=i,e[25]=f,e[26]=r,e[27]=d,e[28]=p):p=e[28];let h;return e[29]!==y||e[30]!==s||e[31]!==p?(h=n.jsx(S,{open:y,onOpenChange:s,children:p}),e[29]=y,e[30]=s,e[31]=p,e[32]=h):h=e[32],h};function B(){return typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]')}export{G as MultiRunWindow};
1
+ import{b as N,R as _,j as n,bk as D,bi as C,bj as I,bg as M,be as S}from"./vendor-.bun-C6iL44L9.js";import{c as z,p as w,I as O}from"./useAppFontEffects-BUUJYbAZ.js";import{M as P}from"./main-BDoqLlQB.js";import"./index-ZJTzZ0_U.js";import"./runtimeEndpointReset-By39StyB.js";import"./mobileLayoutPreference-Dio-WWkI.js";import"./SessionSwitcherDropdown-4FWg9xMC.js";const G=R=>{const e=N.c(33),{open:y,onOpenChange:t,initialPrompt:j}=R,i=_.useId(),{t:o}=z(),k=B;let s;e[0]!==t?(s=v=>{!v&&k()||t(v)},e[0]=t,e[1]=s):s=e[1];let b;e[2]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(D,{className:w("fixed inset-0 z-50 bg-black/50 dark:bg-black/75","transition-opacity duration-150 ease-out","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0")}),e[2]=b):b=e[2];let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=w("relative pointer-events-auto","w-[90vw] max-w-[720px] h-[680px] max-h-[85vh]","flex flex-col rounded-xl border shadow-none overflow-hidden origin-center","bg-background","transition-all duration-150 ease-out","data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]","data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]"),e[3]=g):g=e[3];let a;e[4]!==t?(a=()=>t(!1),e[4]=t,e[5]=a):a=e[5];let l;e[6]!==o?(l=o("multiRun.window.actions.closeAria"),e[6]=o,e[7]=l):l=e[7];let x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(O,{name:"close",className:"h-5 w-5"}),e[8]=x):x=e[8];let r;e[9]!==a||e[10]!==l?(r=n.jsx("div",{className:"absolute right-0.5 top-0.5 z-50",children:n.jsx("button",{type:"button",onClick:a,"aria-label":l,className:"inline-flex h-7 w-7 items-center justify-center rounded-md p-0.5 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:x})}),e[9]=a,e[10]=l,e[11]=r):r=e[11];let c;e[12]!==o?(c=o("multiRun.window.description"),e[12]=o,e[13]=c):c=e[13];let d;e[14]!==i||e[15]!==c?(d=n.jsx(C,{id:i,className:"sr-only",children:c}),e[14]=i,e[15]=c,e[16]=d):d=e[16];let u,m;e[17]!==t?(u=()=>t(!1),m=()=>t(!1),e[17]=t,e[18]=u,e[19]=m):(u=e[18],m=e[19]);let f;e[20]!==j||e[21]!==u||e[22]!==m?(f=n.jsx(P,{initialPrompt:j,onCreated:u,onCancel:m,isWindowed:!0}),e[20]=j,e[21]=u,e[22]=m,e[23]=f):f=e[23];let p;e[24]!==i||e[25]!==f||e[26]!==r||e[27]!==d?(p=n.jsxs(I,{children:[b,n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center pointer-events-none",children:n.jsxs(M,{"aria-describedby":i,className:g,children:[r,d,f]})})]}),e[24]=i,e[25]=f,e[26]=r,e[27]=d,e[28]=p):p=e[28];let h;return e[29]!==y||e[30]!==s||e[31]!==p?(h=n.jsx(S,{open:y,onOpenChange:s,children:p}),e[29]=y,e[30]=s,e[31]=p,e[32]=h):h=e[32],h};function B(){return typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]')}export{G as MultiRunWindow};
@@ -1 +1 @@
1
- import{H as I,j as t,R as a,b as z}from"./vendor-.bun-C6iL44L9.js";import{l as O,a2 as M,h as B,B as re,E as ae,k as le}from"./index-5eUDDB6w.js";import{c as V,ef as me,f8 as oe,aP as Z,ee,B as U,q as W,w as ce,p as J,I as T,aS as Q}from"./useAppFontEffects-DTO332li.js";function pe(r){switch(r){case"ok":return null;case"auth":return"onboarding.remoteConnection.probe.authMessage";case"update-recommended":return"onboarding.remoteConnection.probe.updateRecommendedMessage";case"incompatible":return"onboarding.remoteConnection.probe.incompatibleMessage";case"wrong-service":return"onboarding.remoteConnection.probe.wrongServiceMessage";case"unreachable":return"onboarding.remoteConnection.probe.unreachableMessage";default:return null}}function Y(r){return r==="wrong-service"||r==="unreachable"||r==="incompatible"}function ie({onBack:r,showBackButton:e=!0,initialUrl:c="",initialLabel:n="",isRecoveryMode:o=!1,onConnect:b,onSwitchToLocal:i}){const{t:s}=V(),[h,y]=I.useState(c),[x,R]=I.useState(n),[N,f]=I.useState("idle"),[m,v]=I.useState(null),[S,C]=I.useState(""),j=me(h),p=j?.persistedUrl??null,w=I.useCallback(d=>{y(d.target.value),f("idle"),v(null),C("")},[]),g=I.useCallback(d=>{R(d.target.value)},[]),k=I.useCallback(async()=>{if(p){f("testing"),v(null),C("");try{const d=await oe(p);v(d),f(d.status==="ok"||d.status==="update-recommended"?"success":"error")}catch(d){C(d instanceof Error?d.message:s("onboarding.remoteConnection.errors.connectionTestFailed")),f("error")}}},[p,s]),K=I.useCallback(async()=>{if(!j)return;const d=j.persistedUrl;f("testing"),v(null),C("");try{const D=await oe(d);if(v(D),Y(D.status)){f("error");return}const F=await Z(),de=x.trim()||d,q=F.hosts.find($=>$.url===d),G=q?q.id:`host-${Date.now().toString(16)}`,te={id:G,label:de,url:d,apiUrl:d},ue=q?F.hosts.map($=>$.id===G?te:$):[...F.hosts,te];if(await ee({hosts:ue,defaultHostId:G,initialHostChoiceCompleted:!0}),b?.(),j.redeemUrl){window.location.assign(j.redeemUrl);return}O()&&await M()}catch(D){C(D instanceof Error?D.message:s("onboarding.remoteConnection.errors.failedToSaveConnection")),f("error")}},[j,x,b,s]),L=N==="testing",A=p!==null&&!L,E=p!==null&&!L&&!Y(m?.status??null),P=pe(m?.status??null),H=m?.status==="ok",u=m?.status==="update-recommended",_=m?.status==="auth",l=Y(m?.status??null);return t.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:t.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e&&t.jsx("div",{className:"flex items-center",children:t.jsx(U,{variant:"ghost",onClick:r,className:"p-0 text-muted-foreground hover:text-foreground",children:s("onboarding.common.actions.back")})}),t.jsxs("div",{className:"space-y-2 text-center",children:[t.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:s(o?"onboarding.remoteConnection.titleRecovery":"onboarding.remoteConnection.title")}),t.jsx("p",{className:"text-muted-foreground text-sm",children:s("onboarding.remoteConnection.description")})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"remote-url",className:"text-sm text-foreground",children:s("onboarding.remoteConnection.field.serverAddress")}),t.jsx(W,{id:"remote-url",type:"url",value:h,onChange:w,placeholder:s("onboarding.remoteConnection.field.serverAddressPlaceholder"),disabled:L})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"remote-label",className:"text-sm text-foreground",children:s("onboarding.remoteConnection.field.nameOptional")}),t.jsx(W,{id:"remote-label",type:"text",value:x,onChange:g,placeholder:s("onboarding.remoteConnection.field.namePlaceholder"),disabled:L})]})]}),m&&H&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-success)",color:"var(--status-success)"},children:s("onboarding.remoteConnection.status.connectedSuccessfully",{latencyMs:m.latencyMs})}),m&&_&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:s("onboarding.remoteConnection.status.authWarning")}),m&&u&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:P?s(P):null}),m&&l&&t.jsxs("div",{className:"rounded-lg border p-3 text-sm space-y-3",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-semibold mb-1",children:s("onboarding.remoteConnection.status.connectionFailed")}),t.jsx("div",{className:"opacity-90",children:P?s(P):null})]}),t.jsx("div",{className:"text-xs opacity-80",children:m.status==="unreachable"?s("onboarding.remoteConnection.status.suggestionsUnreachable"):s("onboarding.remoteConnection.status.suggestionsWrongService")})]}),S&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:S}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx(U,{variant:"outline",onClick:k,disabled:!A,children:s(L?"onboarding.remoteConnection.actions.testing":"onboarding.remoteConnection.actions.testConnection")}),t.jsx(U,{onClick:K,disabled:!E,children:s("onboarding.remoteConnection.actions.connectAndRestart")})]}),l&&t.jsxs("div",{className:"flex flex-col gap-2 pt-2 border-t border-border",children:[t.jsx("div",{className:"text-xs text-muted-foreground text-center",children:s("onboarding.remoteConnection.actions.whatToDo")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(U,{variant:"outline",size:"sm",onClick:r,className:"flex-1",children:s("onboarding.remoteConnection.actions.chooseDifferentServer")}),!o&&i&&t.jsx(U,{variant:"outline",size:"sm",onClick:i,className:"flex-1",children:s("onboarding.remoteConnection.actions.useLocalInstead")})]})]})]})})}const he="curl -fsSL https://opencode.ai/install | bash",fe="https://opencode.ai/docs",se=2500;function be(r){const e=z.c(5),{onCopy:c,copyTitle:n}=r;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsxs("code",{className:"flex-1 text-left overflow-x-auto whitespace-nowrap",children:[t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),t.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),t.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/install"}),t.jsx("span",{className:"text-muted-foreground",children:" | "}),t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]}),e[0]=o):o=e[0];let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx(T,{name:"file-copy",className:"h-4 w-4"}),e[1]=b):b=e[1];let i;return e[2]!==n||e[3]!==c?(i=t.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[o,t.jsx("button",{onClick:c,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors shrink-0",title:n,"aria-label":n,children:b})]}),e[2]=n,e[3]=c,e[4]=i):i=e[4],i}function xe({onCliAvailable:r}){const{t:e}=V(),[c,n]=a.useState(!1),[o,b]=a.useState(!1),[i,s]=a.useState(!1),[h,y]=a.useState(!1),[x,R]=a.useState(""),[N,f]=a.useState("unknown"),[m,v]=a.useState("local"),[S,C]=a.useState(!1),[j,p]=a.useState(!1);a.useEffect(()=>{b(O())},[]),a.useEffect(()=>{if(typeof navigator>"u"){f("unknown");return}const l=navigator.userAgent||"";/Windows/i.test(l)?f("windows"):/Macintosh|Mac OS X/i.test(l)?f("macos"):/Linux/i.test(l)?f("linux"):f("unknown")},[]),a.useEffect(()=>{let l=!1;return(async()=>{try{const d=await B("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!d.ok)return;const D=await d.json().catch(()=>null);if(!D||l)return;const F=typeof D.opencodeBinary=="string"?D.opencodeBinary.trim():"";F&&R(F)}catch{}})(),()=>{l=!0}},[]);const w=a.useCallback(async l=>{const d=l.target;d.closest(".app-region-no-drag")||d.closest("button, a, input, select, textarea, code, summary, details")||l.button===0&&o&&await re()},[o]),g=a.useCallback(async()=>{try{const l=await B("/health");if(!l.ok)return!1;const d=await l.json();return d.openCodeRunning===!0||d.isOpenCodeReady===!0}catch{return!1}},[]),k=a.useCallback(async l=>{if(!o)return;const d=await Z();await ee({...d,...l==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})},[o]),K=a.useCallback(async()=>{o&&await k("local"),r?.()},[o,r,k]);a.useEffect(()=>{if(m!=="local")return;let l=!1,d=null;const D=async()=>{if(!l){try{const F=await g();if(l)return;if(F){await K();return}}catch{}l||(d=setTimeout(D,se))}};return d=setTimeout(D,se),()=>{l=!0,d&&clearTimeout(d)}},[m,g,K]);const L=a.useCallback(async()=>{y(!0);try{await g()&&await K()}finally{y(!1)}},[g,K]),A=a.useCallback(async()=>{if(!(typeof window>"u")&&o)try{const l=await ae();l.success&&l.path&&l.path.trim().length>0&&R(l.path.trim())}catch{}},[o]),E=a.useCallback(async()=>{s(!0);try{if(await le({opencodeBinary:x.trim()}),o){await k("local"),await M();return}await B("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>s(!1),1e3)}},[o,x,k]),P=a.useCallback(async()=>{const l=await ce(he);l.ok?(n(!0),setTimeout(()=>n(!1),2e3)):console.error("Failed to copy:",l.error)},[]),H=fe,u=N==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":N==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode",_=!o||m==="local";return t.jsx("div",{className:"app-region-drag h-full flex items-center justify-center bg-transparent p-8 cursor-default select-none overflow-y-auto",onMouseDown:w,children:t.jsxs("div",{className:"w-full max-w-md space-y-7",children:[t.jsxs("header",{className:"text-center space-y-1.5",children:[t.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:e("onboarding.chooser.title")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:e("onboarding.chooser.description")})]}),o&&t.jsxs("div",{className:"app-region-no-drag flex gap-1.5",children:[t.jsx("button",{type:"button",className:J("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",m==="local"?"border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>v("local"),children:e("onboarding.chooser.tabs.localInstall")}),t.jsx("button",{type:"button",className:J("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",m==="remote"?"border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>v("remote"),children:e("onboarding.chooser.tabs.connectRemote")})]}),o&&m==="remote"?t.jsx("div",{className:"app-region-no-drag",children:t.jsx(ie,{onBack:()=>v("local"),showBackButton:!1,onSwitchToLocal:()=>v("local")})}):null,_&&t.jsxs("div",{className:"space-y-4",children:[N==="windows"&&t.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-4",children:[t.jsx("div",{className:"text-sm text-foreground",children:e("onboarding.localSetup.windows.title")}),t.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[t.jsx("li",{children:e("onboarding.localSetup.windows.stepRunInstallInWsl")}),t.jsx("li",{children:e("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),t.jsx("p",{className:"text-sm text-muted-foreground text-center leading-relaxed",children:e("onboarding.localSetup.intro")}),t.jsx("div",{className:"app-region-no-drag rounded-lg border border-border bg-background/60 backdrop-blur-sm px-4 py-3 font-mono text-sm",children:c?t.jsxs("div",{className:"flex items-center gap-2",style:{color:"var(--status-success)"},children:[t.jsx(T,{name:"check",className:"h-4 w-4"}),e("onboarding.common.status.copiedToClipboard")]}):t.jsx(be,{onCopy:P,copyTitle:e("onboarding.common.copyToClipboard")})}),t.jsxs("div",{className:"app-region-no-drag flex items-center justify-between",children:[t.jsxs("a",{href:H,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1",children:[e(N==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),t.jsx(T,{name:"external-link",className:"h-3 w-3"})]}),t.jsx("button",{type:"button",onClick:L,disabled:h,className:"text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:e(h?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkNow")})]}),t.jsxs("div",{className:"rounded-lg border px-4 py-3 flex items-center gap-3",style:{borderColor:"color-mix(in srgb, var(--primary-base) 20%, transparent)",backgroundColor:"color-mix(in srgb, var(--primary-base) 6%, transparent)"},role:"status","aria-live":"polite",children:[t.jsxs("span",{className:"relative inline-flex h-2.5 w-2.5 shrink-0","aria-hidden":!0,children:[t.jsx("span",{className:"absolute inset-0 rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity 1.6s ease-in-out infinite"}}),t.jsx("span",{className:"absolute inset-[-4px] rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity-dim 1.6s ease-in-out infinite",opacity:0}})]}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-foreground leading-tight",children:e("onboarding.localSetup.status.watching")}),t.jsx("div",{className:"text-xs text-muted-foreground leading-tight mt-0.5",children:e("onboarding.localSetup.status.autoContinue")})]})]}),t.jsxs("details",{className:"app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors",open:S,onToggle:l=>C(l.currentTarget.open),children:[t.jsxs("summary",{className:"flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden",children:[t.jsx("span",{children:e("onboarding.localSetup.advanced.title")}),t.jsx(T,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),t.jsxs("div",{className:"pb-4 space-y-2",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(W,{value:x,onChange:l=>R(l.target.value),placeholder:u,disabled:i,className:"flex-1 font-mono text-xs"}),t.jsx(U,{type:"button",variant:"secondary",size:"sm",onClick:A,disabled:i||!o,children:e("onboarding.localSetup.actions.browse")}),t.jsx(U,{type:"button",size:"sm",onClick:E,disabled:i||!x.trim(),children:e("onboarding.localSetup.actions.apply")})]}),t.jsx("p",{className:"text-xs text-muted-foreground/70",children:e("onboarding.localSetup.helper.saveAndReload")})]})]}),t.jsxs("details",{className:"app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors",open:j,onToggle:l=>p(l.currentTarget.open),children:[t.jsxs("summary",{className:"flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden",children:[t.jsx("span",{children:e("onboarding.localSetup.troubleshoot.title")}),t.jsx(T,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),t.jsx("ul",{className:"pb-4 space-y-1.5 text-xs text-muted-foreground list-disc pl-4",children:N==="windows"?t.jsx(t.Fragment,{children:t.jsx("li",{children:e("onboarding.localSetup.windows.hintDetectionFailed")})}):t.jsxs(t.Fragment,{children:[t.jsx("li",{children:e("onboarding.localSetup.hint.ensurePath")}),t.jsx("li",{children:e("onboarding.localSetup.hint.setEnv")}),t.jsx("li",{children:e("onboarding.localSetup.hint.missingRuntime")})]})})]})]})]})})}const ge="curl -fsSL https://opencode.ai/install | bash",ye="https://opencode.ai/docs";function ve(r){const e=z.c(5),{onCopy:c,copyTitle:n}=r;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsxs("code",{children:[t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),t.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),t.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/install"}),t.jsx("span",{className:"text-muted-foreground",children:" | "}),t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]}),e[0]=o):o=e[0];let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx(T,{name:"file-copy",className:"h-4 w-4"}),e[1]=b):b=e[1];let i;return e[2]!==n||e[3]!==c?(i=t.jsxs("div",{className:"flex items-center justify-center gap-3",children:[o,t.jsx("button",{onClick:c,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors",title:n,children:b})]}),e[2]=n,e[3]=c,e[4]=i):i=e[4],i}const we=3e4;function je({onBack:r,onCliAvailable:e,isFromRecovery:c=!1,onSwitchToRemote:n}){const{t:o}=V(),[b,i]=a.useState(!1),[s,h]=a.useState(!1),[y,x]=a.useState(!1),[R,N]=a.useState(!1),[f,m]=a.useState(!1),[v,S]=a.useState(null),[C,j]=a.useState(""),[p,w]=a.useState("unknown");a.useEffect(()=>{const u=setTimeout(()=>h(!0),we);return()=>clearTimeout(u)},[]),a.useEffect(()=>{x(O())},[]),a.useEffect(()=>{if(typeof navigator>"u"){w("unknown");return}const u=navigator.userAgent||"";if(/Windows/i.test(u)){w("windows");return}if(/Macintosh|Mac OS X/i.test(u)){w("macos");return}if(/Linux/i.test(u)){w("linux");return}w("unknown")},[]),a.useEffect(()=>{let u=!1;return(async()=>{try{const _=await B("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!_.ok)return;const l=await _.json().catch(()=>null);if(!l||u)return;const d=typeof l.opencodeBinary=="string"?l.opencodeBinary.trim():"";d&&j(d)}catch{}})(),()=>{u=!0}},[]);const g=a.useCallback(async u=>{u.target.closest("button, a, input, select, textarea, code")||u.button===0&&y&&await re()},[y]),k=a.useCallback(async()=>{try{const u=await B("/health");if(!u.ok)return!1;const _=await u.json();return _.openCodeRunning===!0||_.isOpenCodeReady===!0}catch{return!1}},[]),K=a.useCallback(async()=>{if(!(typeof window>"u")&&y)try{const u=await ae();u.success&&u.path&&u.path.trim().length>0&&j(u.path.trim())}catch{}},[y]),L=a.useCallback(async()=>{N(!0);try{if(await le({opencodeBinary:C.trim()}),y){await M();return}await B("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>N(!1),1e3)}},[y,C]),A=a.useCallback(async()=>{const u=await ce(ge);u.ok?(i(!0),setTimeout(()=>i(!1),2e3)):console.error("Failed to copy:",u.error)},[]),E=a.useCallback(async()=>{m(!0),S(null);try{await k()?e?.():S(o("onboarding.localSetup.errors.cliNotReady"))}catch(u){S(u instanceof Error?u.message:o("onboarding.localSetup.errors.detectionFailed"))}finally{m(!1)}},[k,e,o]),P=ye,H=p==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":p==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode";return t.jsxs("div",{className:"h-full flex items-center justify-center bg-transparent p-8 relative cursor-default select-none",onMouseDown:g,children:[t.jsxs("div",{className:"w-full max-w-lg space-y-4 text-center",children:[t.jsx("div",{className:"flex items-center",children:t.jsx(U,{variant:"ghost",onClick:r,className:"p-0 text-muted-foreground hover:text-foreground",children:o("onboarding.common.actions.back")})}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-foreground",children:o("onboarding.localSetup.title")}),t.jsx("p",{className:"text-muted-foreground",children:o("onboarding.localSetup.description")})]}),p==="windows"&&t.jsxs("div",{className:"mx-auto max-w-2xl rounded-lg border border-border bg-background/50 p-4 text-left",children:[t.jsx("div",{className:"text-sm text-foreground",children:o("onboarding.localSetup.windows.title")}),t.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[t.jsx("li",{children:o("onboarding.localSetup.windows.stepRunInstallInWsl")}),t.jsx("li",{children:o("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"bg-background/60 backdrop-blur-sm border border-border rounded-lg px-5 py-3 font-mono text-sm w-fit",children:b?t.jsxs("div",{className:"flex items-center justify-center gap-2",style:{color:"var(--status-success)"},children:[t.jsx(T,{name:"check",className:"h-4 w-4"}),o("onboarding.common.status.copiedToClipboard")]}):t.jsx(ve,{onCopy:A,copyTitle:o("onboarding.common.copyToClipboard")})})}),t.jsxs("a",{href:P,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1 justify-center",children:[o(p==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),t.jsx(T,{name:"external-link",className:"h-3 w-3"})]}),v&&t.jsx("div",{className:"mx-auto max-w-md rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive",children:v}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(U,{type:"button",onClick:E,disabled:f,className:"w-full max-w-xs",size:"lg",children:o(f?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkAndContinue")}),t.jsx("p",{className:"text-xs text-muted-foreground",children:o("onboarding.localSetup.helper.checkAndContinue")})]}),t.jsx("div",{className:"mx-auto w-full max-w-xl pt-4",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"text-sm text-muted-foreground",children:o("onboarding.localSetup.field.alreadyInstalled")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(W,{value:C,onChange:u=>j(u.target.value),placeholder:H,disabled:R,className:"flex-1 font-mono text-xs"}),t.jsx(U,{type:"button",variant:"secondary",onClick:K,disabled:R||!y,children:o("onboarding.localSetup.actions.browse")}),t.jsx(U,{type:"button",onClick:L,disabled:R,children:o("onboarding.localSetup.actions.apply")})]}),t.jsx("div",{className:"text-xs text-muted-foreground/70",children:o("onboarding.localSetup.helper.saveAndReload")})]})}),c&&n&&t.jsxs("div",{className:"text-center pt-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:o("onboarding.localSetup.remotePreference")}),t.jsx(U,{variant:"link",onClick:n,children:o("onboarding.localSetup.actions.connectRemoteServer")})]})]}),s&&t.jsx("div",{className:"absolute bottom-8 left-0 right-0 text-center space-y-1",children:p==="windows"?t.jsx(t.Fragment,{children:t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.windows.hintDetectionFailed")})}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.hint.ensurePath")}),t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.hint.setEnv")}),t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.hint.missingRuntime")})]})})]})}function X(r,e){if(r?.trim())return Q(r.trim());if(e)return Q(e)}function ke(r,e,c){switch(r){case"local-unavailable":return{title:"Local OpenCode Unavailable",description:"OpenCode CLI could not be started or is not installed. Install OpenCode or connect to a remote server instead.",titleKey:"onboarding.desktopRecovery.localUnavailable.title",descriptionKey:"onboarding.desktopRecovery.localUnavailable.description",iconKey:"local",showRetry:!0,retryLabel:"Retry Local",retryLabelKey:"onboarding.desktopRecovery.localUnavailable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Set Up Local",useLocalLabelKey:"onboarding.desktopRecovery.localUnavailable.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-missing":return{title:"No Default Connection",description:"Your saved default connection could not be found. Choose how you want to connect.",titleKey:"onboarding.desktopRecovery.noDefaultConnection.title",descriptionKey:"onboarding.desktopRecovery.noDefaultConnection.description",iconKey:"local",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-unreachable":{const n=X(e,c);return{title:"Remote Server Unreachable",description:`Could not connect to "${n||"the remote server"}". Check your network connection and verify the server address.`,titleKey:"onboarding.desktopRecovery.remoteUnreachable.title",descriptionKey:"onboarding.desktopRecovery.remoteUnreachable.description",descriptionParams:n?{host:n}:void 0,iconKey:"remote",showRetry:!0,retryLabel:"Retry Connection",retryLabelKey:"onboarding.desktopRecovery.remoteUnreachable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"remote-wrong-service":{const n=X(e,c);return{title:"Incompatible Server",description:`The server at "${n||"unknown"}" is not running OpenChamber. Verify the address points to an OpenChamber server.`,titleKey:"onboarding.desktopRecovery.incompatibleServer.title",descriptionKey:"onboarding.desktopRecovery.incompatibleServer.description",descriptionParams:n?{host:n}:void 0,iconKey:"remote",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"remote-incompatible":{const n=X(e,c);return{title:"Server Update Required",description:`The OpenChamber server at "${n||"unknown"}" is not compatible with this app version. Update OpenChamber on the server, then try again.`,titleKey:"onboarding.desktopRecovery.remoteIncompatible.title",descriptionKey:"onboarding.desktopRecovery.remoteIncompatible.description",descriptionParams:n?{host:n}:void 0,iconKey:"remote",showRetry:!0,retryLabel:"Retry Connection",retryLabelKey:"onboarding.desktopRecovery.remoteUnreachable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"missing-default-host":return{title:"No Default Connection",description:"Your saved default connection could not be found. Choose how you want to connect.",titleKey:"onboarding.desktopRecovery.noDefaultConnection.title",descriptionKey:"onboarding.desktopRecovery.noDefaultConnection.description",iconKey:"local",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};default:{const n=r;throw new Error(`Unknown recovery variant: ${n}`)}}}function Ce(r){switch(r){case"local":return t.jsx(T,{name:"macbook",className:"h-8 w-8"});case"remote":return t.jsx(T,{name:"server",className:"h-8 w-8"})}}function Ne({variant:r,hostLabel:e,hostUrl:c,onRetry:n,onUseLocal:o,onUseRemote:b,isRetrying:i=!1}){const{t:s}=V(),h=ke(r,e,c),y=h.retryLabelKey??"onboarding.desktopRecovery.actions.retryConnection",x=a.useMemo(()=>{if(h.descriptionParams?.host)return h.descriptionParams;if(r==="remote-unreachable")return{host:s("onboarding.desktopRecovery.placeholders.remoteServer")};if(r==="remote-wrong-service"||r==="remote-incompatible")return{host:s("onboarding.desktopRecovery.placeholders.unknownServer")}},[h.descriptionParams,s,r]);return t.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:t.jsxs("div",{className:"w-full max-w-md space-y-6",children:[t.jsxs("div",{className:"flex flex-col items-center space-y-3 text-center",children:[t.jsx("div",{className:"p-3 rounded-full",style:{backgroundColor:"var(--status-warning)",opacity:.15},children:t.jsx("div",{style:{color:"var(--status-warning)"},children:Ce(h.iconKey)})}),t.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:s(h.titleKey)}),t.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:s(h.descriptionKey,x)})]}),c&&(r==="remote-unreachable"||r==="remote-wrong-service"||r==="remote-incompatible")&&t.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-3",children:[t.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:s("onboarding.remoteConnection.field.serverAddress")}),t.jsx("div",{className:"font-mono text-sm text-foreground truncate",children:Q(c)})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[h.showRetry&&n&&t.jsxs(U,{onClick:n,disabled:i,className:"w-full",children:[t.jsx(T,{name:"refresh",className:J("h-4 w-4",i&&"animate-spin")}),s(i?"onboarding.desktopRecovery.actions.retrying":y)]}),t.jsxs("div",{className:"flex gap-2",children:[h.showUseLocal&&o&&t.jsxs(U,{variant:"outline",onClick:o,disabled:i,className:"flex-1",children:[t.jsx(T,{name:"macbook",className:"h-4 w-4"}),s(h.useLocalLabelKey)]}),h.showUseRemote&&b&&t.jsxs(U,{variant:"outline",onClick:b,disabled:i,className:"flex-1",children:[t.jsx(T,{name:"server",className:"h-4 w-4"}),s(h.useRemoteLabelKey)]})]})]})]})})}function ne(r,e){if(e==="use-remote")return{kind:"remote-form"};switch(r){case"local-unavailable":return{kind:"local-setup"};case"remote-unreachable":case"remote-incompatible":case"remote-wrong-service":case"remote-missing":case"missing-default-host":return{kind:"switch-default-to-local"};default:{const c=r;throw new Error(`Unhandled RecoveryVariant: ${c}`)}}}function Se(r){const e=z.c(27),{variant:c,hostUrl:n,hostLabel:o,onRetry:b,onChooseRemote:i,showRemoteForm:s,onCloseRemoteForm:h,onSwitchToLocalFromRemote:y,onEnterLocalSetup:x,isRetrying:R}=r,N=s===void 0?!1:s,f=R===void 0?!1:R,m=Re;let v;e[0]!==b?(v=async()=>{if(O()){await M();return}await B("/api/config/reload",{method:"POST"}),b?.()},e[0]=b,e[1]=v):v=e[1];const S=v;let C;e[2]!==x||e[3]!==c?(C=async()=>{if(ne(c,"use-local").kind==="local-setup"){x?.();return}if(await m("local"),O()){await M();return}window.location.reload()},e[2]=x,e[3]=c,e[4]=C):C=e[4];const j=C;let p;e[5]!==i||e[6]!==c?(p=()=>{ne(c,"use-remote").kind==="remote-form"&&i?.()},e[5]=i,e[6]=c,e[7]=p):p=e[7];const w=p;if(N){const k=c==="remote-wrong-service"?"":n||"",K=c==="remote-wrong-service"?"":o||"";let L;e[8]!==i||e[9]!==h?(L=h||(()=>i?.()),e[8]=i,e[9]=h,e[10]=L):L=e[10];let A;e[11]!==x||e[12]!==y?(A=y||(()=>{m("local").then(()=>{O()?M():x?.()})}),e[11]=x,e[12]=y,e[13]=A):A=e[13];let E;return e[14]!==K||e[15]!==k||e[16]!==L||e[17]!==A?(E=t.jsx(ie,{onBack:L,initialUrl:k,initialLabel:K,isRecoveryMode:!0,onSwitchToLocal:A}),e[14]=K,e[15]=k,e[16]=L,e[17]=A,e[18]=E):E=e[18],E}let g;return e[19]!==S||e[20]!==j||e[21]!==w||e[22]!==o||e[23]!==n||e[24]!==f||e[25]!==c?(g=t.jsx(Ne,{variant:c,hostLabel:o,hostUrl:n,onRetry:S,onUseLocal:j,onUseRemote:w,isRetrying:f}),e[19]=S,e[20]=j,e[21]=w,e[22]=o,e[23]=n,e[24]=f,e[25]=c,e[26]=g):g=e[26],g}async function Re(r){if(!O())return;const e=await Z();await ee({...e,...r==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})}function Ke(r){const e=z.c(26),{onBack:c,onCliAvailable:n,mode:o,recoveryVariant:b,recoveryHostUrl:i,recoveryHostLabel:s,onEnterLocalSetup:h}=r,y=o===void 0?"first-launch":o,x=b===void 0?"missing-default-host":b,[R,N]=a.useState(!1),[f,m]=a.useState(!1);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{m(!1),N(!1)},e[0]=v):v=e[0];let S;e[1]!==y||e[2]!==s||e[3]!==i||e[4]!==x?(S=[y,x,i,s],e[1]=y,e[2]=s,e[3]=i,e[4]=x,e[5]=S):S=e[5],a.useEffect(v,S);const C=f?"local-setup":y;if(C==="recovery"){let p,w;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=()=>N(!1),w=()=>{N(!1),m(!0)},e[6]=p,e[7]=w):(p=e[6],w=e[7]);let g;e[8]!==h?(g=()=>{m(!0),h?.()},e[8]=h,e[9]=g):g=e[9];let k;return e[10]!==s||e[11]!==i||e[12]!==x||e[13]!==R||e[14]!==g?(k=t.jsx(Se,{variant:x,hostUrl:i,hostLabel:s,showRemoteForm:R,onCloseRemoteForm:p,onSwitchToLocalFromRemote:w,onEnterLocalSetup:g}),e[10]=s,e[11]=i,e[12]=x,e[13]=R,e[14]=g,e[15]=k):k=e[15],k}if(C==="local-setup"){let p;e[16]!==c||e[17]!==f?(p=()=>{f?m(!1):c?.()},e[16]=c,e[17]=f,e[18]=p):p=e[18];let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w=()=>N(!0),e[19]=w):w=e[19];let g;return e[20]!==n||e[21]!==f||e[22]!==p?(g=t.jsx(je,{onBack:p,onCliAvailable:n,isFromRecovery:f,onSwitchToRemote:w}),e[20]=n,e[21]=f,e[22]=p,e[23]=g):g=e[23],g}let j;return e[24]!==n?(j=t.jsx(xe,{onCliAvailable:n}),e[24]=n,e[25]=j):j=e[25],j}export{Ke as OnboardingScreen};
1
+ import{H as I,j as t,R as a,b as z}from"./vendor-.bun-C6iL44L9.js";import{l as O,a2 as M,h as B,B as re,E as ae,k as le}from"./index-ZJTzZ0_U.js";import{c as V,ef as me,f8 as oe,aP as Z,ee,B as U,q as W,w as ce,p as J,I as T,aS as Q}from"./useAppFontEffects-BUUJYbAZ.js";function pe(r){switch(r){case"ok":return null;case"auth":return"onboarding.remoteConnection.probe.authMessage";case"update-recommended":return"onboarding.remoteConnection.probe.updateRecommendedMessage";case"incompatible":return"onboarding.remoteConnection.probe.incompatibleMessage";case"wrong-service":return"onboarding.remoteConnection.probe.wrongServiceMessage";case"unreachable":return"onboarding.remoteConnection.probe.unreachableMessage";default:return null}}function Y(r){return r==="wrong-service"||r==="unreachable"||r==="incompatible"}function ie({onBack:r,showBackButton:e=!0,initialUrl:c="",initialLabel:n="",isRecoveryMode:o=!1,onConnect:b,onSwitchToLocal:i}){const{t:s}=V(),[h,y]=I.useState(c),[x,R]=I.useState(n),[N,f]=I.useState("idle"),[m,v]=I.useState(null),[S,C]=I.useState(""),j=me(h),p=j?.persistedUrl??null,w=I.useCallback(d=>{y(d.target.value),f("idle"),v(null),C("")},[]),g=I.useCallback(d=>{R(d.target.value)},[]),k=I.useCallback(async()=>{if(p){f("testing"),v(null),C("");try{const d=await oe(p);v(d),f(d.status==="ok"||d.status==="update-recommended"?"success":"error")}catch(d){C(d instanceof Error?d.message:s("onboarding.remoteConnection.errors.connectionTestFailed")),f("error")}}},[p,s]),K=I.useCallback(async()=>{if(!j)return;const d=j.persistedUrl;f("testing"),v(null),C("");try{const D=await oe(d);if(v(D),Y(D.status)){f("error");return}const F=await Z(),de=x.trim()||d,q=F.hosts.find($=>$.url===d),G=q?q.id:`host-${Date.now().toString(16)}`,te={id:G,label:de,url:d,apiUrl:d},ue=q?F.hosts.map($=>$.id===G?te:$):[...F.hosts,te];if(await ee({hosts:ue,defaultHostId:G,initialHostChoiceCompleted:!0}),b?.(),j.redeemUrl){window.location.assign(j.redeemUrl);return}O()&&await M()}catch(D){C(D instanceof Error?D.message:s("onboarding.remoteConnection.errors.failedToSaveConnection")),f("error")}},[j,x,b,s]),L=N==="testing",A=p!==null&&!L,E=p!==null&&!L&&!Y(m?.status??null),P=pe(m?.status??null),H=m?.status==="ok",u=m?.status==="update-recommended",_=m?.status==="auth",l=Y(m?.status??null);return t.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:t.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e&&t.jsx("div",{className:"flex items-center",children:t.jsx(U,{variant:"ghost",onClick:r,className:"p-0 text-muted-foreground hover:text-foreground",children:s("onboarding.common.actions.back")})}),t.jsxs("div",{className:"space-y-2 text-center",children:[t.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:s(o?"onboarding.remoteConnection.titleRecovery":"onboarding.remoteConnection.title")}),t.jsx("p",{className:"text-muted-foreground text-sm",children:s("onboarding.remoteConnection.description")})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"remote-url",className:"text-sm text-foreground",children:s("onboarding.remoteConnection.field.serverAddress")}),t.jsx(W,{id:"remote-url",type:"url",value:h,onChange:w,placeholder:s("onboarding.remoteConnection.field.serverAddressPlaceholder"),disabled:L})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"remote-label",className:"text-sm text-foreground",children:s("onboarding.remoteConnection.field.nameOptional")}),t.jsx(W,{id:"remote-label",type:"text",value:x,onChange:g,placeholder:s("onboarding.remoteConnection.field.namePlaceholder"),disabled:L})]})]}),m&&H&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-success)",color:"var(--status-success)"},children:s("onboarding.remoteConnection.status.connectedSuccessfully",{latencyMs:m.latencyMs})}),m&&_&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:s("onboarding.remoteConnection.status.authWarning")}),m&&u&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:P?s(P):null}),m&&l&&t.jsxs("div",{className:"rounded-lg border p-3 text-sm space-y-3",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-semibold mb-1",children:s("onboarding.remoteConnection.status.connectionFailed")}),t.jsx("div",{className:"opacity-90",children:P?s(P):null})]}),t.jsx("div",{className:"text-xs opacity-80",children:m.status==="unreachable"?s("onboarding.remoteConnection.status.suggestionsUnreachable"):s("onboarding.remoteConnection.status.suggestionsWrongService")})]}),S&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:S}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx(U,{variant:"outline",onClick:k,disabled:!A,children:s(L?"onboarding.remoteConnection.actions.testing":"onboarding.remoteConnection.actions.testConnection")}),t.jsx(U,{onClick:K,disabled:!E,children:s("onboarding.remoteConnection.actions.connectAndRestart")})]}),l&&t.jsxs("div",{className:"flex flex-col gap-2 pt-2 border-t border-border",children:[t.jsx("div",{className:"text-xs text-muted-foreground text-center",children:s("onboarding.remoteConnection.actions.whatToDo")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(U,{variant:"outline",size:"sm",onClick:r,className:"flex-1",children:s("onboarding.remoteConnection.actions.chooseDifferentServer")}),!o&&i&&t.jsx(U,{variant:"outline",size:"sm",onClick:i,className:"flex-1",children:s("onboarding.remoteConnection.actions.useLocalInstead")})]})]})]})})}const he="curl -fsSL https://opencode.ai/install | bash",fe="https://opencode.ai/docs",se=2500;function be(r){const e=z.c(5),{onCopy:c,copyTitle:n}=r;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsxs("code",{className:"flex-1 text-left overflow-x-auto whitespace-nowrap",children:[t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),t.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),t.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/install"}),t.jsx("span",{className:"text-muted-foreground",children:" | "}),t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]}),e[0]=o):o=e[0];let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx(T,{name:"file-copy",className:"h-4 w-4"}),e[1]=b):b=e[1];let i;return e[2]!==n||e[3]!==c?(i=t.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[o,t.jsx("button",{onClick:c,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors shrink-0",title:n,"aria-label":n,children:b})]}),e[2]=n,e[3]=c,e[4]=i):i=e[4],i}function xe({onCliAvailable:r}){const{t:e}=V(),[c,n]=a.useState(!1),[o,b]=a.useState(!1),[i,s]=a.useState(!1),[h,y]=a.useState(!1),[x,R]=a.useState(""),[N,f]=a.useState("unknown"),[m,v]=a.useState("local"),[S,C]=a.useState(!1),[j,p]=a.useState(!1);a.useEffect(()=>{b(O())},[]),a.useEffect(()=>{if(typeof navigator>"u"){f("unknown");return}const l=navigator.userAgent||"";/Windows/i.test(l)?f("windows"):/Macintosh|Mac OS X/i.test(l)?f("macos"):/Linux/i.test(l)?f("linux"):f("unknown")},[]),a.useEffect(()=>{let l=!1;return(async()=>{try{const d=await B("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!d.ok)return;const D=await d.json().catch(()=>null);if(!D||l)return;const F=typeof D.opencodeBinary=="string"?D.opencodeBinary.trim():"";F&&R(F)}catch{}})(),()=>{l=!0}},[]);const w=a.useCallback(async l=>{const d=l.target;d.closest(".app-region-no-drag")||d.closest("button, a, input, select, textarea, code, summary, details")||l.button===0&&o&&await re()},[o]),g=a.useCallback(async()=>{try{const l=await B("/health");if(!l.ok)return!1;const d=await l.json();return d.openCodeRunning===!0||d.isOpenCodeReady===!0}catch{return!1}},[]),k=a.useCallback(async l=>{if(!o)return;const d=await Z();await ee({...d,...l==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})},[o]),K=a.useCallback(async()=>{o&&await k("local"),r?.()},[o,r,k]);a.useEffect(()=>{if(m!=="local")return;let l=!1,d=null;const D=async()=>{if(!l){try{const F=await g();if(l)return;if(F){await K();return}}catch{}l||(d=setTimeout(D,se))}};return d=setTimeout(D,se),()=>{l=!0,d&&clearTimeout(d)}},[m,g,K]);const L=a.useCallback(async()=>{y(!0);try{await g()&&await K()}finally{y(!1)}},[g,K]),A=a.useCallback(async()=>{if(!(typeof window>"u")&&o)try{const l=await ae();l.success&&l.path&&l.path.trim().length>0&&R(l.path.trim())}catch{}},[o]),E=a.useCallback(async()=>{s(!0);try{if(await le({opencodeBinary:x.trim()}),o){await k("local"),await M();return}await B("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>s(!1),1e3)}},[o,x,k]),P=a.useCallback(async()=>{const l=await ce(he);l.ok?(n(!0),setTimeout(()=>n(!1),2e3)):console.error("Failed to copy:",l.error)},[]),H=fe,u=N==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":N==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode",_=!o||m==="local";return t.jsx("div",{className:"app-region-drag h-full flex items-center justify-center bg-transparent p-8 cursor-default select-none overflow-y-auto",onMouseDown:w,children:t.jsxs("div",{className:"w-full max-w-md space-y-7",children:[t.jsxs("header",{className:"text-center space-y-1.5",children:[t.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:e("onboarding.chooser.title")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:e("onboarding.chooser.description")})]}),o&&t.jsxs("div",{className:"app-region-no-drag flex gap-1.5",children:[t.jsx("button",{type:"button",className:J("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",m==="local"?"border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>v("local"),children:e("onboarding.chooser.tabs.localInstall")}),t.jsx("button",{type:"button",className:J("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",m==="remote"?"border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>v("remote"),children:e("onboarding.chooser.tabs.connectRemote")})]}),o&&m==="remote"?t.jsx("div",{className:"app-region-no-drag",children:t.jsx(ie,{onBack:()=>v("local"),showBackButton:!1,onSwitchToLocal:()=>v("local")})}):null,_&&t.jsxs("div",{className:"space-y-4",children:[N==="windows"&&t.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-4",children:[t.jsx("div",{className:"text-sm text-foreground",children:e("onboarding.localSetup.windows.title")}),t.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[t.jsx("li",{children:e("onboarding.localSetup.windows.stepRunInstallInWsl")}),t.jsx("li",{children:e("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),t.jsx("p",{className:"text-sm text-muted-foreground text-center leading-relaxed",children:e("onboarding.localSetup.intro")}),t.jsx("div",{className:"app-region-no-drag rounded-lg border border-border bg-background/60 backdrop-blur-sm px-4 py-3 font-mono text-sm",children:c?t.jsxs("div",{className:"flex items-center gap-2",style:{color:"var(--status-success)"},children:[t.jsx(T,{name:"check",className:"h-4 w-4"}),e("onboarding.common.status.copiedToClipboard")]}):t.jsx(be,{onCopy:P,copyTitle:e("onboarding.common.copyToClipboard")})}),t.jsxs("div",{className:"app-region-no-drag flex items-center justify-between",children:[t.jsxs("a",{href:H,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1",children:[e(N==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),t.jsx(T,{name:"external-link",className:"h-3 w-3"})]}),t.jsx("button",{type:"button",onClick:L,disabled:h,className:"text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:e(h?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkNow")})]}),t.jsxs("div",{className:"rounded-lg border px-4 py-3 flex items-center gap-3",style:{borderColor:"color-mix(in srgb, var(--primary-base) 20%, transparent)",backgroundColor:"color-mix(in srgb, var(--primary-base) 6%, transparent)"},role:"status","aria-live":"polite",children:[t.jsxs("span",{className:"relative inline-flex h-2.5 w-2.5 shrink-0","aria-hidden":!0,children:[t.jsx("span",{className:"absolute inset-0 rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity 1.6s ease-in-out infinite"}}),t.jsx("span",{className:"absolute inset-[-4px] rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity-dim 1.6s ease-in-out infinite",opacity:0}})]}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-foreground leading-tight",children:e("onboarding.localSetup.status.watching")}),t.jsx("div",{className:"text-xs text-muted-foreground leading-tight mt-0.5",children:e("onboarding.localSetup.status.autoContinue")})]})]}),t.jsxs("details",{className:"app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors",open:S,onToggle:l=>C(l.currentTarget.open),children:[t.jsxs("summary",{className:"flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden",children:[t.jsx("span",{children:e("onboarding.localSetup.advanced.title")}),t.jsx(T,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),t.jsxs("div",{className:"pb-4 space-y-2",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(W,{value:x,onChange:l=>R(l.target.value),placeholder:u,disabled:i,className:"flex-1 font-mono text-xs"}),t.jsx(U,{type:"button",variant:"secondary",size:"sm",onClick:A,disabled:i||!o,children:e("onboarding.localSetup.actions.browse")}),t.jsx(U,{type:"button",size:"sm",onClick:E,disabled:i||!x.trim(),children:e("onboarding.localSetup.actions.apply")})]}),t.jsx("p",{className:"text-xs text-muted-foreground/70",children:e("onboarding.localSetup.helper.saveAndReload")})]})]}),t.jsxs("details",{className:"app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors",open:j,onToggle:l=>p(l.currentTarget.open),children:[t.jsxs("summary",{className:"flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden",children:[t.jsx("span",{children:e("onboarding.localSetup.troubleshoot.title")}),t.jsx(T,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),t.jsx("ul",{className:"pb-4 space-y-1.5 text-xs text-muted-foreground list-disc pl-4",children:N==="windows"?t.jsx(t.Fragment,{children:t.jsx("li",{children:e("onboarding.localSetup.windows.hintDetectionFailed")})}):t.jsxs(t.Fragment,{children:[t.jsx("li",{children:e("onboarding.localSetup.hint.ensurePath")}),t.jsx("li",{children:e("onboarding.localSetup.hint.setEnv")}),t.jsx("li",{children:e("onboarding.localSetup.hint.missingRuntime")})]})})]})]})]})})}const ge="curl -fsSL https://opencode.ai/install | bash",ye="https://opencode.ai/docs";function ve(r){const e=z.c(5),{onCopy:c,copyTitle:n}=r;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsxs("code",{children:[t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),t.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),t.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/install"}),t.jsx("span",{className:"text-muted-foreground",children:" | "}),t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]}),e[0]=o):o=e[0];let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx(T,{name:"file-copy",className:"h-4 w-4"}),e[1]=b):b=e[1];let i;return e[2]!==n||e[3]!==c?(i=t.jsxs("div",{className:"flex items-center justify-center gap-3",children:[o,t.jsx("button",{onClick:c,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors",title:n,children:b})]}),e[2]=n,e[3]=c,e[4]=i):i=e[4],i}const we=3e4;function je({onBack:r,onCliAvailable:e,isFromRecovery:c=!1,onSwitchToRemote:n}){const{t:o}=V(),[b,i]=a.useState(!1),[s,h]=a.useState(!1),[y,x]=a.useState(!1),[R,N]=a.useState(!1),[f,m]=a.useState(!1),[v,S]=a.useState(null),[C,j]=a.useState(""),[p,w]=a.useState("unknown");a.useEffect(()=>{const u=setTimeout(()=>h(!0),we);return()=>clearTimeout(u)},[]),a.useEffect(()=>{x(O())},[]),a.useEffect(()=>{if(typeof navigator>"u"){w("unknown");return}const u=navigator.userAgent||"";if(/Windows/i.test(u)){w("windows");return}if(/Macintosh|Mac OS X/i.test(u)){w("macos");return}if(/Linux/i.test(u)){w("linux");return}w("unknown")},[]),a.useEffect(()=>{let u=!1;return(async()=>{try{const _=await B("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!_.ok)return;const l=await _.json().catch(()=>null);if(!l||u)return;const d=typeof l.opencodeBinary=="string"?l.opencodeBinary.trim():"";d&&j(d)}catch{}})(),()=>{u=!0}},[]);const g=a.useCallback(async u=>{u.target.closest("button, a, input, select, textarea, code")||u.button===0&&y&&await re()},[y]),k=a.useCallback(async()=>{try{const u=await B("/health");if(!u.ok)return!1;const _=await u.json();return _.openCodeRunning===!0||_.isOpenCodeReady===!0}catch{return!1}},[]),K=a.useCallback(async()=>{if(!(typeof window>"u")&&y)try{const u=await ae();u.success&&u.path&&u.path.trim().length>0&&j(u.path.trim())}catch{}},[y]),L=a.useCallback(async()=>{N(!0);try{if(await le({opencodeBinary:C.trim()}),y){await M();return}await B("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>N(!1),1e3)}},[y,C]),A=a.useCallback(async()=>{const u=await ce(ge);u.ok?(i(!0),setTimeout(()=>i(!1),2e3)):console.error("Failed to copy:",u.error)},[]),E=a.useCallback(async()=>{m(!0),S(null);try{await k()?e?.():S(o("onboarding.localSetup.errors.cliNotReady"))}catch(u){S(u instanceof Error?u.message:o("onboarding.localSetup.errors.detectionFailed"))}finally{m(!1)}},[k,e,o]),P=ye,H=p==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":p==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode";return t.jsxs("div",{className:"h-full flex items-center justify-center bg-transparent p-8 relative cursor-default select-none",onMouseDown:g,children:[t.jsxs("div",{className:"w-full max-w-lg space-y-4 text-center",children:[t.jsx("div",{className:"flex items-center",children:t.jsx(U,{variant:"ghost",onClick:r,className:"p-0 text-muted-foreground hover:text-foreground",children:o("onboarding.common.actions.back")})}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-foreground",children:o("onboarding.localSetup.title")}),t.jsx("p",{className:"text-muted-foreground",children:o("onboarding.localSetup.description")})]}),p==="windows"&&t.jsxs("div",{className:"mx-auto max-w-2xl rounded-lg border border-border bg-background/50 p-4 text-left",children:[t.jsx("div",{className:"text-sm text-foreground",children:o("onboarding.localSetup.windows.title")}),t.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[t.jsx("li",{children:o("onboarding.localSetup.windows.stepRunInstallInWsl")}),t.jsx("li",{children:o("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"bg-background/60 backdrop-blur-sm border border-border rounded-lg px-5 py-3 font-mono text-sm w-fit",children:b?t.jsxs("div",{className:"flex items-center justify-center gap-2",style:{color:"var(--status-success)"},children:[t.jsx(T,{name:"check",className:"h-4 w-4"}),o("onboarding.common.status.copiedToClipboard")]}):t.jsx(ve,{onCopy:A,copyTitle:o("onboarding.common.copyToClipboard")})})}),t.jsxs("a",{href:P,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1 justify-center",children:[o(p==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),t.jsx(T,{name:"external-link",className:"h-3 w-3"})]}),v&&t.jsx("div",{className:"mx-auto max-w-md rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive",children:v}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(U,{type:"button",onClick:E,disabled:f,className:"w-full max-w-xs",size:"lg",children:o(f?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkAndContinue")}),t.jsx("p",{className:"text-xs text-muted-foreground",children:o("onboarding.localSetup.helper.checkAndContinue")})]}),t.jsx("div",{className:"mx-auto w-full max-w-xl pt-4",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"text-sm text-muted-foreground",children:o("onboarding.localSetup.field.alreadyInstalled")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(W,{value:C,onChange:u=>j(u.target.value),placeholder:H,disabled:R,className:"flex-1 font-mono text-xs"}),t.jsx(U,{type:"button",variant:"secondary",onClick:K,disabled:R||!y,children:o("onboarding.localSetup.actions.browse")}),t.jsx(U,{type:"button",onClick:L,disabled:R,children:o("onboarding.localSetup.actions.apply")})]}),t.jsx("div",{className:"text-xs text-muted-foreground/70",children:o("onboarding.localSetup.helper.saveAndReload")})]})}),c&&n&&t.jsxs("div",{className:"text-center pt-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:o("onboarding.localSetup.remotePreference")}),t.jsx(U,{variant:"link",onClick:n,children:o("onboarding.localSetup.actions.connectRemoteServer")})]})]}),s&&t.jsx("div",{className:"absolute bottom-8 left-0 right-0 text-center space-y-1",children:p==="windows"?t.jsx(t.Fragment,{children:t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.windows.hintDetectionFailed")})}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.hint.ensurePath")}),t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.hint.setEnv")}),t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.hint.missingRuntime")})]})})]})}function X(r,e){if(r?.trim())return Q(r.trim());if(e)return Q(e)}function ke(r,e,c){switch(r){case"local-unavailable":return{title:"Local OpenCode Unavailable",description:"OpenCode CLI could not be started or is not installed. Install OpenCode or connect to a remote server instead.",titleKey:"onboarding.desktopRecovery.localUnavailable.title",descriptionKey:"onboarding.desktopRecovery.localUnavailable.description",iconKey:"local",showRetry:!0,retryLabel:"Retry Local",retryLabelKey:"onboarding.desktopRecovery.localUnavailable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Set Up Local",useLocalLabelKey:"onboarding.desktopRecovery.localUnavailable.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-missing":return{title:"No Default Connection",description:"Your saved default connection could not be found. Choose how you want to connect.",titleKey:"onboarding.desktopRecovery.noDefaultConnection.title",descriptionKey:"onboarding.desktopRecovery.noDefaultConnection.description",iconKey:"local",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-unreachable":{const n=X(e,c);return{title:"Remote Server Unreachable",description:`Could not connect to "${n||"the remote server"}". Check your network connection and verify the server address.`,titleKey:"onboarding.desktopRecovery.remoteUnreachable.title",descriptionKey:"onboarding.desktopRecovery.remoteUnreachable.description",descriptionParams:n?{host:n}:void 0,iconKey:"remote",showRetry:!0,retryLabel:"Retry Connection",retryLabelKey:"onboarding.desktopRecovery.remoteUnreachable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"remote-wrong-service":{const n=X(e,c);return{title:"Incompatible Server",description:`The server at "${n||"unknown"}" is not running OpenChamber. Verify the address points to an OpenChamber server.`,titleKey:"onboarding.desktopRecovery.incompatibleServer.title",descriptionKey:"onboarding.desktopRecovery.incompatibleServer.description",descriptionParams:n?{host:n}:void 0,iconKey:"remote",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"remote-incompatible":{const n=X(e,c);return{title:"Server Update Required",description:`The OpenChamber server at "${n||"unknown"}" is not compatible with this app version. Update OpenChamber on the server, then try again.`,titleKey:"onboarding.desktopRecovery.remoteIncompatible.title",descriptionKey:"onboarding.desktopRecovery.remoteIncompatible.description",descriptionParams:n?{host:n}:void 0,iconKey:"remote",showRetry:!0,retryLabel:"Retry Connection",retryLabelKey:"onboarding.desktopRecovery.remoteUnreachable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"missing-default-host":return{title:"No Default Connection",description:"Your saved default connection could not be found. Choose how you want to connect.",titleKey:"onboarding.desktopRecovery.noDefaultConnection.title",descriptionKey:"onboarding.desktopRecovery.noDefaultConnection.description",iconKey:"local",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};default:{const n=r;throw new Error(`Unknown recovery variant: ${n}`)}}}function Ce(r){switch(r){case"local":return t.jsx(T,{name:"macbook",className:"h-8 w-8"});case"remote":return t.jsx(T,{name:"server",className:"h-8 w-8"})}}function Ne({variant:r,hostLabel:e,hostUrl:c,onRetry:n,onUseLocal:o,onUseRemote:b,isRetrying:i=!1}){const{t:s}=V(),h=ke(r,e,c),y=h.retryLabelKey??"onboarding.desktopRecovery.actions.retryConnection",x=a.useMemo(()=>{if(h.descriptionParams?.host)return h.descriptionParams;if(r==="remote-unreachable")return{host:s("onboarding.desktopRecovery.placeholders.remoteServer")};if(r==="remote-wrong-service"||r==="remote-incompatible")return{host:s("onboarding.desktopRecovery.placeholders.unknownServer")}},[h.descriptionParams,s,r]);return t.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:t.jsxs("div",{className:"w-full max-w-md space-y-6",children:[t.jsxs("div",{className:"flex flex-col items-center space-y-3 text-center",children:[t.jsx("div",{className:"p-3 rounded-full",style:{backgroundColor:"var(--status-warning)",opacity:.15},children:t.jsx("div",{style:{color:"var(--status-warning)"},children:Ce(h.iconKey)})}),t.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:s(h.titleKey)}),t.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:s(h.descriptionKey,x)})]}),c&&(r==="remote-unreachable"||r==="remote-wrong-service"||r==="remote-incompatible")&&t.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-3",children:[t.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:s("onboarding.remoteConnection.field.serverAddress")}),t.jsx("div",{className:"font-mono text-sm text-foreground truncate",children:Q(c)})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[h.showRetry&&n&&t.jsxs(U,{onClick:n,disabled:i,className:"w-full",children:[t.jsx(T,{name:"refresh",className:J("h-4 w-4",i&&"animate-spin")}),s(i?"onboarding.desktopRecovery.actions.retrying":y)]}),t.jsxs("div",{className:"flex gap-2",children:[h.showUseLocal&&o&&t.jsxs(U,{variant:"outline",onClick:o,disabled:i,className:"flex-1",children:[t.jsx(T,{name:"macbook",className:"h-4 w-4"}),s(h.useLocalLabelKey)]}),h.showUseRemote&&b&&t.jsxs(U,{variant:"outline",onClick:b,disabled:i,className:"flex-1",children:[t.jsx(T,{name:"server",className:"h-4 w-4"}),s(h.useRemoteLabelKey)]})]})]})]})})}function ne(r,e){if(e==="use-remote")return{kind:"remote-form"};switch(r){case"local-unavailable":return{kind:"local-setup"};case"remote-unreachable":case"remote-incompatible":case"remote-wrong-service":case"remote-missing":case"missing-default-host":return{kind:"switch-default-to-local"};default:{const c=r;throw new Error(`Unhandled RecoveryVariant: ${c}`)}}}function Se(r){const e=z.c(27),{variant:c,hostUrl:n,hostLabel:o,onRetry:b,onChooseRemote:i,showRemoteForm:s,onCloseRemoteForm:h,onSwitchToLocalFromRemote:y,onEnterLocalSetup:x,isRetrying:R}=r,N=s===void 0?!1:s,f=R===void 0?!1:R,m=Re;let v;e[0]!==b?(v=async()=>{if(O()){await M();return}await B("/api/config/reload",{method:"POST"}),b?.()},e[0]=b,e[1]=v):v=e[1];const S=v;let C;e[2]!==x||e[3]!==c?(C=async()=>{if(ne(c,"use-local").kind==="local-setup"){x?.();return}if(await m("local"),O()){await M();return}window.location.reload()},e[2]=x,e[3]=c,e[4]=C):C=e[4];const j=C;let p;e[5]!==i||e[6]!==c?(p=()=>{ne(c,"use-remote").kind==="remote-form"&&i?.()},e[5]=i,e[6]=c,e[7]=p):p=e[7];const w=p;if(N){const k=c==="remote-wrong-service"?"":n||"",K=c==="remote-wrong-service"?"":o||"";let L;e[8]!==i||e[9]!==h?(L=h||(()=>i?.()),e[8]=i,e[9]=h,e[10]=L):L=e[10];let A;e[11]!==x||e[12]!==y?(A=y||(()=>{m("local").then(()=>{O()?M():x?.()})}),e[11]=x,e[12]=y,e[13]=A):A=e[13];let E;return e[14]!==K||e[15]!==k||e[16]!==L||e[17]!==A?(E=t.jsx(ie,{onBack:L,initialUrl:k,initialLabel:K,isRecoveryMode:!0,onSwitchToLocal:A}),e[14]=K,e[15]=k,e[16]=L,e[17]=A,e[18]=E):E=e[18],E}let g;return e[19]!==S||e[20]!==j||e[21]!==w||e[22]!==o||e[23]!==n||e[24]!==f||e[25]!==c?(g=t.jsx(Ne,{variant:c,hostLabel:o,hostUrl:n,onRetry:S,onUseLocal:j,onUseRemote:w,isRetrying:f}),e[19]=S,e[20]=j,e[21]=w,e[22]=o,e[23]=n,e[24]=f,e[25]=c,e[26]=g):g=e[26],g}async function Re(r){if(!O())return;const e=await Z();await ee({...e,...r==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})}function Ke(r){const e=z.c(26),{onBack:c,onCliAvailable:n,mode:o,recoveryVariant:b,recoveryHostUrl:i,recoveryHostLabel:s,onEnterLocalSetup:h}=r,y=o===void 0?"first-launch":o,x=b===void 0?"missing-default-host":b,[R,N]=a.useState(!1),[f,m]=a.useState(!1);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{m(!1),N(!1)},e[0]=v):v=e[0];let S;e[1]!==y||e[2]!==s||e[3]!==i||e[4]!==x?(S=[y,x,i,s],e[1]=y,e[2]=s,e[3]=i,e[4]=x,e[5]=S):S=e[5],a.useEffect(v,S);const C=f?"local-setup":y;if(C==="recovery"){let p,w;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=()=>N(!1),w=()=>{N(!1),m(!0)},e[6]=p,e[7]=w):(p=e[6],w=e[7]);let g;e[8]!==h?(g=()=>{m(!0),h?.()},e[8]=h,e[9]=g):g=e[9];let k;return e[10]!==s||e[11]!==i||e[12]!==x||e[13]!==R||e[14]!==g?(k=t.jsx(Se,{variant:x,hostUrl:i,hostLabel:s,showRemoteForm:R,onCloseRemoteForm:p,onSwitchToLocalFromRemote:w,onEnterLocalSetup:g}),e[10]=s,e[11]=i,e[12]=x,e[13]=R,e[14]=g,e[15]=k):k=e[15],k}if(C==="local-setup"){let p;e[16]!==c||e[17]!==f?(p=()=>{f?m(!1):c?.()},e[16]=c,e[17]=f,e[18]=p):p=e[18];let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w=()=>N(!0),e[19]=w):w=e[19];let g;return e[20]!==n||e[21]!==f||e[22]!==p?(g=t.jsx(je,{onBack:p,onCliAvailable:n,isFromRecovery:f,onSwitchToRemote:w}),e[20]=n,e[21]=f,e[22]=p,e[23]=g):g=e[23],g}let j;return e[24]!==n?(j=t.jsx(xe,{onCliAvailable:n}),e[24]=n,e[25]=j):j=e[25],j}export{Ke as OnboardingScreen};
@@ -1 +1 @@
1
- import{b as ne,R as je,j as r,H as Oe,a as Ue,ae as Ae}from"./vendor-.bun-C6iL44L9.js";import{c as _e,p as q,aH as Be,ah as We,ai as Ge,I as V,M as Ye,aG as He,aF as Ke,c1 as Je,c2 as Qe,bk as Re,u as Xe,b as qe,cw as Ve,r as ke,ay as Ze,aA as et,aB as tt,D as Pe,cU as st,cW as nt}from"./useAppFontEffects-DTO332li.js";import{z as Se,P as rt,u as Ne}from"./index-5eUDDB6w.js";const Bt=s=>{const e=ne.c(129),{totalTokens:t,percentage:o,colorPercentage:n,contextLimit:i,outputLimit:a,size:c,isMobile:x,hideIcon:f,showPercentIcon:l,className:m,valueClassName:v,percentIconClassName:b,onClick:p,pressed:w}=s,S=c===void 0?"default":c,h=x===void 0?!1:x,j=f===void 0?!1:f,N=l===void 0?!1:l,C=w===void 0?!1:w,{t:d}=_e(),[_,y]=je.useState(!1),u=typeof n=="number"?n:o;let g,D,k,I,L,W,B,G;if(e[0]!==u||e[1]!==i||e[2]!==j||e[3]!==h||e[4]!==p||e[5]!==a||e[6]!==b||e[7]!==o||e[8]!==N||e[9]!==d||e[10]!==t||e[11]!==v){const z=We(o)??0,M=Ge(u),$=M==="critical"?"var(--status-error)":M==="warn"?"var(--status-warning)":"var(--status-success)";g=ot,D=it;const T=2*Math.PI*8.5,P=T*(1-z/100);I=typeof a=="number"?Math.max(a,0):0;let E;e[20]!==d||e[21]!==t?(E=d("contextUsage.tooltip.usedTokens",{tokens:g(t)}),e[20]=d,e[21]=t,e[22]=E):E=e[22];let O;e[23]!==i||e[24]!==d?(O=d("contextUsage.tooltip.contextLimit",{tokens:g(i)}),e[23]=i,e[24]=d,e[25]=O):O=e[25];let U;e[26]!==I||e[27]!==d?(U=d("contextUsage.tooltip.outputLimit",{tokens:g(I)}),e[26]=I,e[27]=d,e[28]=U):U=e[28];let R;e[29]!==O||e[30]!==U||e[31]!==E?(R=[E,O,U],e[29]=O,e[30]=U,e[31]=E,e[32]=R):R=e[32],G=R,k=!h&&typeof p=="function",e[33]!==j||e[34]!==h?(B=!h&&!j&&r.jsx(V,{name:"donut-chart",className:"h-4 w-4 flex-shrink-0"}),e[33]=j,e[34]=h,e[35]=B):B=e[35],e[36]!==v?(L=q("font-medium inline-flex items-center gap-1.5",v),e[36]=v,e[37]=L):L=e[37],W=N?r.jsxs(r.Fragment,{children:[r.jsxs("svg",{viewBox:"0 0 20 20",className:q("h-3.5 w-3.5 -rotate-90",b),role:"progressbar","aria-valuenow":Math.round(z),"aria-valuemin":0,"aria-valuemax":100,children:[r.jsx("circle",{cx:10,cy:10,r:8.5,fill:"none",stroke:"var(--interactive-border)",strokeWidth:3}),r.jsx("circle",{cx:10,cy:10,r:8.5,fill:"none",stroke:$,strokeWidth:3,strokeLinecap:"round",strokeDasharray:T,strokeDashoffset:P,className:"transition-[stroke-dashoffset,stroke] duration-300"})]}),r.jsxs("span",{className:"text-foreground",children:[Math.min(o,999).toFixed(1),"%"]})]}):r.jsxs(r.Fragment,{children:[r.jsx("span",{className:D(u),children:Math.min(o,999).toFixed(1)}),"%"]}),e[0]=u,e[1]=i,e[2]=j,e[3]=h,e[4]=p,e[5]=a,e[6]=b,e[7]=o,e[8]=N,e[9]=d,e[10]=t,e[11]=v,e[12]=g,e[13]=D,e[14]=k,e[15]=I,e[16]=L,e[17]=W,e[18]=B,e[19]=G}else g=e[12],D=e[13],k=e[14],I=e[15],L=e[16],W=e[17],B=e[18],G=e[19];let Y;e[38]!==L||e[39]!==W?(Y=r.jsx("span",{className:L,children:W}),e[38]=L,e[39]=W,e[40]=Y):Y=e[40];let Z;e[41]!==B||e[42]!==Y?(Z=r.jsxs(r.Fragment,{children:[B,Y]}),e[41]=B,e[42]=Y,e[43]=Z):Z=e[43];const H=Z,ee=S==="compact"?"typography-micro":"typography-meta";let te;e[44]!==m||e[45]!==k||e[46]!==ee?(te=q("app-region-no-drag flex items-center gap-1.5 select-none",ee,k?q("rounded-md px-2 py-1.5 text-foreground transition-colors","hover:bg-interactive-hover","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"):"text-muted-foreground/60",m),e[44]=m,e[45]=k,e[46]=ee,e[47]=te):te=e[47];const K=te;let J;e[48]!==H||e[49]!==k||e[50]!==h||e[51]!==p||e[52]!==C||e[53]!==K||e[54]!==d?(J=k?r.jsx("button",{type:"button",className:K,"aria-label":d("contextUsage.aria.label"),"aria-pressed":C,onClick:p,children:H}):r.jsx("div",{className:K,"aria-label":d("contextUsage.aria.label"),onClick:h?()=>y(!0):void 0,children:H}),e[48]=H,e[49]=k,e[50]=h,e[51]=p,e[52]=C,e[53]=K,e[54]=d,e[55]=J):J=e[55];const X=J;if(h){let z;e[56]===Symbol.for("react.memo_cache_sentinel")?(z=()=>y(!1),e[56]=z):z=e[56];let M;e[57]!==d?(M=d("contextUsage.mobile.title"),e[57]=d,e[58]=M):M=e[58];let $;e[59]!==d?($=d("contextUsage.mobile.usedTokens"),e[59]=d,e[60]=$):$=e[60];let T;e[61]!==$?(T=r.jsx("span",{className:"typography-meta text-muted-foreground",children:$}),e[61]=$,e[62]=T):T=e[62];let P;e[63]!==g||e[64]!==t?(P=g(t),e[63]=g,e[64]=t,e[65]=P):P=e[65];let E;e[66]!==P?(E=r.jsx("span",{className:"typography-meta text-foreground font-medium",children:P}),e[66]=P,e[67]=E):E=e[67];let O;e[68]!==T||e[69]!==E?(O=r.jsxs("div",{className:"flex justify-between items-center",children:[T,E]}),e[68]=T,e[69]=E,e[70]=O):O=e[70];let U;e[71]!==d?(U=d("contextUsage.mobile.contextLimit"),e[71]=d,e[72]=U):U=e[72];let R;e[73]!==U?(R=r.jsx("span",{className:"typography-meta text-muted-foreground",children:U}),e[73]=U,e[74]=R):R=e[74];let re;e[75]!==i||e[76]!==g?(re=g(i),e[75]=i,e[76]=g,e[77]=re):re=e[77];let oe;e[78]!==re?(oe=r.jsx("span",{className:"typography-meta text-foreground font-medium",children:re}),e[78]=re,e[79]=oe):oe=e[79];let ie;e[80]!==R||e[81]!==oe?(ie=r.jsxs("div",{className:"flex justify-between items-center",children:[R,oe]}),e[80]=R,e[81]=oe,e[82]=ie):ie=e[82];let ae;e[83]!==d?(ae=d("contextUsage.mobile.outputLimit"),e[83]=d,e[84]=ae):ae=e[84];let le;e[85]!==ae?(le=r.jsx("span",{className:"typography-meta text-muted-foreground",children:ae}),e[85]=ae,e[86]=le):le=e[86];let ce;e[87]!==g||e[88]!==I?(ce=g(I),e[87]=g,e[88]=I,e[89]=ce):ce=e[89];let de;e[90]!==ce?(de=r.jsx("span",{className:"typography-meta text-foreground font-medium",children:ce}),e[90]=ce,e[91]=de):de=e[91];let ue;e[92]!==le||e[93]!==de?(ue=r.jsxs("div",{className:"flex justify-between items-center",children:[le,de]}),e[92]=le,e[93]=de,e[94]=ue):ue=e[94];let fe;e[95]!==d?(fe=d("contextUsage.mobile.usage"),e[95]=d,e[96]=fe):fe=e[96];let me;e[97]!==fe?(me=r.jsx("span",{className:"typography-meta text-muted-foreground",children:fe}),e[97]=fe,e[98]=me):me=e[98];let he;e[99]!==u||e[100]!==D?(he=q("typography-meta font-semibold",D(u)),e[99]=u,e[100]=D,e[101]=he):he=e[101];const De=Math.min(o,999);let pe;e[102]!==De?(pe=De.toFixed(1),e[102]=De,e[103]=pe):pe=e[103];let ge;e[104]!==he||e[105]!==pe?(ge=r.jsxs("span",{className:he,children:[pe,"%"]}),e[104]=he,e[105]=pe,e[106]=ge):ge=e[106];let xe;e[107]!==me||e[108]!==ge?(xe=r.jsxs("div",{className:"flex justify-between items-center pt-1 border-t border-border/40",children:[me,ge]}),e[107]=me,e[108]=ge,e[109]=xe):xe=e[109];let be;e[110]!==O||e[111]!==ie||e[112]!==ue||e[113]!==xe?(be=r.jsx("div",{className:"flex flex-col gap-1.5",children:r.jsxs("div",{className:"rounded-xl border border-border/40 bg-sidebar/30 px-3 py-2 space-y-1",children:[O,ie,ue,xe]})}),e[110]=O,e[111]=ie,e[112]=ue,e[113]=xe,e[114]=be):be=e[114];let we;e[115]!==_||e[116]!==M||e[117]!==be?(we=r.jsx(Ye,{open:_,onClose:z,title:M,children:be}),e[115]=_,e[116]=M,e[117]=be,e[118]=we):we=e[118];let ve;return e[119]!==X||e[120]!==we?(ve=r.jsxs(r.Fragment,{children:[X,we]}),e[119]=X,e[120]=we,e[121]=ve):ve=e[121],ve}let A;e[122]!==X?(A=r.jsx(He,{asChild:!0,children:X}),e[122]=X,e[123]=A):A=e[123];let F;e[124]!==G?(F=r.jsx(Be,{children:r.jsx("div",{className:"space-y-0.5",children:G.map(at)})}),e[124]=G,e[125]=F):F=e[125];let Q;return e[126]!==A||e[127]!==F?(Q=r.jsxs(Ke,{children:[A,F]}),e[126]=A,e[127]=F,e[128]=Q):Q=e[128],Q};function ot(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toFixed(1).replace(/\.0$/,"")}function it(s){return s>=90?"text-status-error":s>=75?"text-status-warning":"text-status-success"}function at(s){return r.jsx("p",{className:"typography-micro leading-tight",children:s},s)}const Wt=je.memo(function(e){const t=ne.c(40),{visible:o}=e,{t:n}=_e(),[i,a]=je.useState(!1);let c,x;if(t[0]!==o?(c=()=>{if(!o)return;let D=!1;Se("desktop_get_current_window_state").then(I=>{D||a(!!I?.maximized)}).catch(lt);const k=I=>{const L=I.detail;a(!!L?.maximized)};return window.addEventListener("openchamber:window-maximized-changed",k),()=>{D=!0,window.removeEventListener("openchamber:window-maximized-changed",k)}},x=[o],t[0]=o,t[1]=c,t[2]=x):(c=t[1],x=t[2]),Oe.useEffect(c,x),!o)return null;let f;t[3]!==n?(f=n("header.windowControls.groupAria"),t[3]=n,t[4]=f):f=t[4];let l;t[5]!==n?(l=n("header.windowControls.minimize"),t[5]=n,t[6]=l):l=t[6];let m;t[7]!==n?(m=n("header.windowControls.minimize"),t[7]=n,t[8]=m):m=t[8];let v;t[9]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(V,{name:"subtract",className:"h-4 w-4"}),t[9]=v):v=t[9];let b;t[10]!==l||t[11]!==m?(b=r.jsx("button",{type:"button",className:"app-region-no-drag inline-flex h-12 w-11 items-center justify-center text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:ct,title:l,"aria-label":m,children:v}),t[10]=l,t[11]=m,t[12]=b):b=t[12];let p;t[13]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{Se("desktop_toggle_current_window_maximized").then(D=>a(!!D?.maximized)).catch(dt)},t[13]=p):p=t[13];let w;t[14]!==i||t[15]!==n?(w=n(i?"header.windowControls.restore":"header.windowControls.maximize"),t[14]=i,t[15]=n,t[16]=w):w=t[16];let S;t[17]!==i||t[18]!==n?(S=n(i?"header.windowControls.restore":"header.windowControls.maximize"),t[17]=i,t[18]=n,t[19]=S):S=t[19];const h=i?"fullscreen-exit":"checkbox-blank";let j;t[20]!==h?(j=r.jsx(V,{name:h,className:"h-3.5 w-3.5"}),t[20]=h,t[21]=j):j=t[21];let N;t[22]!==S||t[23]!==j||t[24]!==w?(N=r.jsx("button",{type:"button",className:"app-region-no-drag inline-flex h-12 w-11 items-center justify-center text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:p,title:w,"aria-label":S,children:j}),t[22]=S,t[23]=j,t[24]=w,t[25]=N):N=t[25];let C;t[26]===Symbol.for("react.memo_cache_sentinel")?(C=q("app-region-no-drag inline-flex h-12 w-11 items-center justify-center text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","hover:bg-status-error hover:text-status-error-foreground"),t[26]=C):C=t[26];let d;t[27]!==n?(d=n("header.windowControls.close"),t[27]=n,t[28]=d):d=t[28];let _;t[29]!==n?(_=n("header.windowControls.close"),t[29]=n,t[30]=_):_=t[30];let y;t[31]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(V,{name:"close",className:"h-4 w-4"}),t[31]=y):y=t[31];let u;t[32]!==d||t[33]!==_?(u=r.jsx("button",{type:"button",className:C,onClick:ut,title:d,"aria-label":_,children:y}),t[32]=d,t[33]=_,t[34]=u):u=t[34];let g;return t[35]!==N||t[36]!==u||t[37]!==f||t[38]!==b?(g=r.jsxs("div",{className:"app-region-no-drag -mr-3 ml-2 flex h-12 shrink-0 items-center","aria-label":f,children:[b,N,u]}),t[35]=N,t[36]=u,t[37]=f,t[38]=b,t[39]=g):g=t[39],g});function lt(){}function ct(){Se("desktop_minimize_current_window")}function dt(){}function ut(){Se("desktop_close_current_window")}const Fe="oc.sessions.pinned",ft=s=>{try{const e=s.getItem(Fe);if(!e)return new Set;const t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(o=>typeof o=="string")):new Set}catch{return new Set}},Me=(s,e)=>{try{s.setItem(Fe,JSON.stringify([...e]))}catch{}},Ce=rt(),mt=Ue((s,e)=>({ids:ft(Ce),setIds:t=>{const o=e().ids,n=typeof t=="function"?t(o):t;n!==o&&(s({ids:n}),Me(Ce,n))},toggle:t=>{const o=e().ids,n=new Set(o);n.has(t)?n.delete(t):n.add(t),s({ids:n}),Me(Ce,n)}})),se=(s,e)=>Je(Qe.getState().dictionary,s,e),ht=s=>{const e=new Date(s),t=new Date,o=(a,c)=>a.getFullYear()===c.getFullYear()&&a.getMonth()===c.getMonth()&&a.getDate()===c.getDate(),n=new Date(t);return n.setDate(t.getDate()-1),o(e,t)?se("common.date.today"):o(e,n)?se("common.date.yesterday"):e.toLocaleDateString(Re(),{month:"short",day:"numeric",year:"numeric"}).replace(",","")},Gt=s=>{const e=new Date,t=new Date(s);if(((n,i)=>n.getFullYear()===i.getFullYear()&&n.getMonth()===i.getMonth()&&n.getDate()===i.getDate())(t,e)){const n=Date.now()-s;return n<6e4?se("common.relative.justNow"):n<36e5?se("common.relative.minutesAgoShort",{count:Math.floor(n/6e4)}):se("common.relative.hoursAgoShort",{count:Math.floor(n/36e5)})}return ht(s)},pt=s=>{const e=Math.max(0,Date.now()-s),t=6e4,o=60*t,n=24*o,i=7*n,a=30*n,c=365*n;return e<o?`${Math.max(1,Math.floor(e/t))}m`:e<n?`${Math.floor(e/o)}h`:e<i?se("common.relative.daysAgoCompact",{count:Math.floor(e/n)}):e<5*i?se("common.relative.weeksAgoCompact",{count:Math.floor(e/i)}):e<c?`${Math.floor(e/a)}mo`:se("common.relative.yearsAgoCompact",{count:Math.floor(e/c)})},ye=s=>{if(!s)return null;const e=s.replace(/\\/g,"/").replace(/\/+$/,"");return e.length===0?"/":e},gt=(s,e)=>{const t=ye(s),o=ye(e);return!t||!o?!1:t===o?!0:o==="/"?t.startsWith("/"):t.startsWith(`${o}/`)},Le=s=>s.toLowerCase().replace(/^opencode[/-]?/i,"").replace(/[-_]/g,"").trim(),Yt=(s,e)=>s?Le(s)!==Le(e):!1,Ie=s=>{if(typeof s=="number"&&Number.isFinite(s))return s;if(typeof s=="string"&&s.trim().length>0){const e=Number(s);if(Number.isFinite(e))return e}},$e=s=>Ie(s.time?.created)??0,ze=s=>Ie(s.time?.updated)??Ie(s.time?.created)??0,Te=(s,e,t)=>{const o=t.has(s.id),n=t.has(e.id);return o!==n?o?-1:1:o&&n?$e(e)-$e(s):ze(e)-ze(s)},Ht=s=>{const e=new Map;return s.forEach(t=>{e.set(t.id,t)}),Array.from(e.values())},Kt=s=>`__archived__:${s}`,Jt=(s,e)=>{const t=ye(s.directory??null),o=ye(s.project?.worktree??null),n=t??o;if(!n)return"unassigned";if(e&&n===e)return"project root";const a=(e&&n.startsWith(`${e}/`)?n.slice(e.length+1):n).split("/").filter(Boolean);return a[a.length-1]??"unassigned"},Qt=(s,e,t)=>{const o=ye(s.directory??null),n=ye(s.project?.worktree??null);return n&&(n===e||n.startsWith(`${e}/`))?!0:o?t&&t.has(o)?!0:o===e||o.startsWith(`${e}/`):!1},Rt=s=>s.replace(/[-_]/g," ").replace(/\b\w/g,e=>e.toUpperCase()),Xt=(s,e)=>{if(!e)return s;const t=s.toLowerCase(),o=e.toLowerCase(),n=o.length;if(n===0)return s;const i=[];let a=0,c=t.indexOf(o,a);for(;c!==-1;){c>a&&i.push(s.slice(a,c));const x=s.slice(c,c+n);i.push(r.jsx("mark",{className:"bg-primary text-primary-foreground ring-1 ring-primary/90",children:x},`${c}-${x}`)),a=c+n,c=t.indexOf(o,a)}return a<s.length&&i.push(s.slice(a)),i.length>0?i:s},xt=7,bt=s=>{if(!s)return null;const e=s.replace(/\\/g,"/");return e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e},wt=s=>{if(!s)return null;const e=s.label?.trim();if(e)return e;const t=s.path.split(/[\\/]/).filter(Boolean);return t[t.length-1]??null},yt=(s,e)=>{const t=ne.c(18);let o;t[0]!==e?(o=e===void 0?{}:e,t[0]=e,t[1]=o):o=t[1];const n=o,{scopeProjectId:i}=n,a=i===void 0?null:i,c=Xe(vt),x=qe(jt),f=mt(St),l=Ve();let m;t[2]!==x?(m=x.map(Nt).filter(_t),t[2]=x,t[3]=m):m=t[3];const v=m;let b;t[4]!==v?(b=h=>h?v.filter(N=>gt(h,N.normalizedPath)).sort(Dt)[0]??null:null,t[4]=v,t[5]=b):b=t[5];const p=b;let w;{let h;if(t[7]!==c||t[8]!==l||t[9]!==p||t[10]!==f||t[11]!==a){const j=new Map;for(const y of c){const u=y.parentID;if(!u||y.time?.archived)continue;const g=j.get(u);g?g.push(y):j.set(u,[y])}j.forEach(y=>{y.sort((u,g)=>Te(u,g,f))});let N;t[13]!==p||t[14]!==a?(N=y=>{if(!a)return!0;const u=ke(y);return p(u)?.id===a},t[13]=p,t[14]=a,t[15]=N):N=t[15];let C;t[16]!==f?(C=(y,u)=>Te(y,u,f),t[16]=f,t[17]=C):C=t[17];const d=c.filter(Ct).filter(kt).filter(N).sort(C).slice(0,xt),_=y=>{const u=j.get(y.id)??[];return{session:y,children:u.map(g=>_(g)),worktree:null}};h=d.map(y=>{const u=ke(y),g=p(u),D=wt(g),k=u?l.get(u)??null:null;return{node:_(y),projectId:g?.id??null,groupDirectory:u,secondaryMeta:{projectLabel:D,branchLabel:k&&k!==D?k:null}}}),t[7]=c,t[8]=l,t[9]=p,t[10]=f,t[11]=a,t[12]=h}else h=t[12];w=h}return w};function vt(s){return s.activeSessions}function jt(s){return s.projects}function St(s){return s.ids}function Nt(s){return{...s,normalizedPath:bt(s.path)}}function _t(s){return s.normalizedPath}function Dt(s,e){return(e.normalizedPath?.length??0)-(s.normalizedPath?.length??0)}function Ct(s){return!s.time?.archived}function kt(s){return!s.parentID}function qt(s){const e=ne.c(18),{children:t,variant:o,scopeProjectId:n,align:i}=s,a=o===void 0?"default":o,c=n===void 0?null:n,x=i===void 0?"start":i,f=Ne(It),l=Ne(Pt);let m;e[0]!==t?(m=r.jsx(Ze,{asChild:!0,children:t}),e[0]=t,e[1]=m):m=e[1];const v=a==="compact"?"w-[280px]":"w-[360px]";let b;e[2]!==v?(b=q("overflow-hidden p-1 max-w-[calc(100vw-32px)]",v),e[2]=v,e[3]=b):b=e[3];let p;e[4]!==f||e[5]!==c||e[6]!==l||e[7]!==a?(p=f?r.jsx(Mt,{onSelect:()=>l(!1),variant:a,scopeProjectId:c}):null,e[4]=f,e[5]=c,e[6]=l,e[7]=a,e[8]=p):p=e[8];let w;e[9]!==x||e[10]!==b||e[11]!==p?(w=r.jsx(et,{align:x,sideOffset:6,className:b,children:p}),e[9]=x,e[10]=b,e[11]=p,e[12]=w):w=e[12];let S;return e[13]!==f||e[14]!==l||e[15]!==m||e[16]!==w?(S=r.jsxs(tt,{open:f,onOpenChange:l,modal:!1,children:[m,w]}),e[13]=f,e[14]=l,e[15]=m,e[16]=w,e[17]=S):S=e[17],S}function Pt(s){return s.setSessionDropdownOpen}function It(s){return s.isSessionDropdownOpen}function Mt(s){const e=ne.c(26),{onSelect:t,variant:o,scopeProjectId:n}=s;let i;e[0]!==n?(i={scopeProjectId:n},e[0]=n,e[1]=i):i=e[1];const a=yt(!0,i),c=Pe($t),x=Ne(Lt),{t:f}=_e();let l;e[2]!==t||e[3]!==c||e[4]!==x?(l=()=>{x("chat"),t(),c()},e[2]=t,e[3]=c,e[4]=x,e[5]=l):l=e[5];const m=l;let v;e[6]===Symbol.for("react.memo_cache_sentinel")?(v=new Set,e[6]=v):v=e[6];const[b,p]=je.useState(v);let w;e[7]===Symbol.for("react.memo_cache_sentinel")?(w=u=>{p(g=>{const D=new Set(g);return D.has(u)?D.delete(u):D.add(u),D})},e[7]=w):w=e[7];const S=w;let h,j;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=q("group relative flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),j=r.jsx(V,{name:"chat-new",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),e[8]=h,e[9]=j):(h=e[8],j=e[9]);let N;e[10]!==f?(N=f("sessions.sidebar.header.actions.newSession"),e[10]=f,e[11]=N):N=e[11];let C;e[12]!==N?(C=r.jsx("span",{className:"truncate text-[14px] font-normal leading-tight text-foreground",children:N}),e[12]=N,e[13]=C):C=e[13];let d;e[14]!==m||e[15]!==C?(d=r.jsxs(Ae,{onClick:m,className:h,children:[j,C]}),e[14]=m,e[15]=C,e[16]=d):d=e[16];let _;e[17]!==b||e[18]!==a||e[19]!==t||e[20]!==f||e[21]!==o?(_=a.length===0?r.jsx("div",{className:"px-3 py-4 text-center typography-meta text-muted-foreground",children:f("sessions.switcher.empty")}):a.map(u=>r.jsx(Ee,{item:u,depth:0,variant:o,expandedParents:b,toggleParent:S,closeDropdown:t},u.node.session.id)),e[17]=b,e[18]=a,e[19]=t,e[20]=f,e[21]=o,e[22]=_):_=e[22];let y;return e[23]!==_||e[24]!==d?(y=r.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:r.jsxs("div",{className:"space-y-0.5",children:[d,_]})}),e[23]=_,e[24]=d,e[25]=y):y=e[25],y}function Lt(s){return s.setActiveMainTab}function $t(s){return s.openNewSessionDraft}function Ee(s){const e=ne.c(31),{item:t,depth:o,variant:n,expandedParents:i,toggleParent:a,closeDropdown:c}=s,{node:x,secondaryMeta:f}=t,l=x.session,m=x.children.length>0;let v;e[0]!==i||e[1]!==l.id?(v=i.has(l.id),e[0]=i,e[1]=l.id,e[2]=v):v=e[2];const b=v;let p;e[3]!==m||e[4]!==l.id||e[5]!==a?(p=m?()=>a(l.id):void 0,e[3]=m,e[4]=l.id,e[5]=a,e[6]=p):p=e[6];let w;e[7]!==c||e[8]!==o||e[9]!==m||e[10]!==b||e[11]!==f||e[12]!==l||e[13]!==p||e[14]!==n?(w=r.jsx(zt,{session:l,depth:o,variant:n,secondaryMeta:f,hasChildren:m,isExpanded:b,onToggleExpand:p,closeDropdown:c}),e[7]=c,e[8]=o,e[9]=m,e[10]=b,e[11]=f,e[12]=l,e[13]=p,e[14]=n,e[15]=w):w=e[15];let S;e[16]!==c||e[17]!==o||e[18]!==i||e[19]!==m||e[20]!==b||e[21]!==t.groupDirectory||e[22]!==t.projectId||e[23]!==x.children||e[24]!==f||e[25]!==a||e[26]!==n?(S=m&&b?x.children.map(j=>r.jsx(Ee,{item:{node:j,projectId:t.projectId,groupDirectory:t.groupDirectory,secondaryMeta:f},depth:o+1,variant:n,expandedParents:i,toggleParent:a,closeDropdown:c},j.session.id)):null,e[16]=c,e[17]=o,e[18]=i,e[19]=m,e[20]=b,e[21]=t.groupDirectory,e[22]=t.projectId,e[23]=x.children,e[24]=f,e[25]=a,e[26]=n,e[27]=S):S=e[27];let h;return e[28]!==w||e[29]!==S?(h=r.jsxs(r.Fragment,{children:[w,S]}),e[28]=w,e[29]=S,e[30]=h):h=e[30],h}function zt(s){const e=ne.c(57),{session:t,depth:o,variant:n,secondaryMeta:i,hasChildren:a,isExpanded:c,onToggleExpand:x,closeDropdown:f}=s,{t:l}=_e(),m=Pe(Ft),v=Pe(At),b=Ne(Tt),p=st(t.id),w=nt(t.id),S=m===t.id;let h;e[0]!==t.title||e[1]!==l?(h=t.title?.trim()||l("sessions.sidebar.session.untitled"),e[0]=t.title,e[1]=l,e[2]=h):h=e[2];const j=h,N=!!t.parentID,C=w>0&&(!N||b),d=p?.type??"idle",_=d==="busy"||d==="retry",y=!_&&C&&!S;let u;e[3]!==t.time?.created||e[4]!==t.time?.updated?(u=t.time?.updated||t.time?.created||Date.now(),e[3]=t.time?.created,e[4]=t.time?.updated,e[5]=u):u=e[5];const g=u;let D;e[6]!==g?(D=pt(g),e[6]=g,e[7]=D):D=e[7];const k=D;let I;e[8]!==i?.projectLabel?(I=i?.projectLabel?.trim()||null,e[8]=i?.projectLabel,e[9]=I):I=e[9];const L=I;let W;e[10]!==i?.branchLabel?(W=i?.branchLabel?.trim()||null,e[10]=i?.branchLabel,e[11]=W):W=e[11];const B=W,G=B&&B!=="HEAD"?B:null;let Y;e[12]!==f||e[13]!==S||e[14]!==t||e[15]!==v?(Y=()=>{if(S){f();return}const P=ke(t);v(t.id,P??null),f()},e[12]=f,e[13]=S,e[14]=t,e[15]=v,e[16]=Y):Y=e[16];const Z=Y;let H;e[17]!==Z?(H=P=>{if(P.target?.closest("[data-switcher-expand]")){P.preventDefault();return}Z()},e[17]=Z,e[18]=H):H=e[18];let ee;e[19]===Symbol.for("react.memo_cache_sentinel")?(ee=q("group relative flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),e[19]=ee):ee=e[19];const te=8+o*12;let K;e[20]!==te?(K={paddingLeft:te},e[20]=te,e[21]=K):K=e[21];let J;e[22]!==a||e[23]!==c||e[24]!==x||e[25]!==l||e[26]!==n?(J=n==="compact"&&a?r.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:P=>{P.preventDefault(),P.stopPropagation(),x?.()},className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground","aria-label":l(c?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:c?r.jsx(V,{name:"arrow-down-s",className:"h-3.5 w-3.5"}):r.jsx(V,{name:"arrow-right-s",className:"h-3.5 w-3.5"})}):null,e[22]=a,e[23]=c,e[24]=x,e[25]=l,e[26]=n,e[27]=J):J=e[27];const X=S?"text-primary":"text-foreground";let A;e[28]!==X?(A=q("truncate text-[14px] font-normal leading-tight",X),e[28]=X,e[29]=A):A=e[29];let F;e[30]!==j||e[31]!==A?(F=r.jsx("span",{className:A,children:j}),e[30]=j,e[31]=A,e[32]=F):F=e[32];let Q;e[33]!==J||e[34]!==F?(Q=r.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[J,F]}),e[33]=J,e[34]=F,e[35]=Q):Q=e[35];let z;e[36]!==G||e[37]!==a||e[38]!==c||e[39]!==x||e[40]!==L||e[41]!==l||e[42]!==k||e[43]!==n?(z=n==="default"?r.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 truncate text-muted-foreground/70 leading-tight",style:{fontSize:"calc(var(--text-ui-label) * 0.85)"},children:[a?r.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:P=>{P.preventDefault(),P.stopPropagation(),x?.()},className:"inline-flex h-3 w-3 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground","aria-label":l(c?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:c?r.jsx(V,{name:"arrow-down-s",className:"h-3 w-3"}):r.jsx(V,{name:"arrow-right-s",className:"h-3 w-3"})}):null,r.jsx("span",{className:"flex-shrink-0",children:k}),L?r.jsx("span",{className:"truncate",children:L}):null,G?r.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[r.jsx(V,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),r.jsx("span",{className:"truncate",children:G})]}):null]}):null,e[36]=G,e[37]=a,e[38]=c,e[39]=x,e[40]=L,e[41]=l,e[42]=k,e[43]=n,e[44]=z):z=e[44];let M;e[45]!==Q||e[46]!==z?(M=r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[Q,z]}),e[45]=Q,e[46]=z,e[47]=M):M=e[47];let $;e[48]!==_||e[49]!==y||e[50]!==l?($=_||y?r.jsx("span",{className:"flex h-3 w-3 flex-shrink-0 items-center justify-center self-center",children:_?r.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary animate-busy-pulse","aria-label":l("sessions.sidebar.session.status.active"),title:l("sessions.sidebar.session.status.active")}):r.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--status-info)]","aria-label":l("sessions.sidebar.session.status.unread"),title:l("sessions.sidebar.session.status.unread")})}):null,e[48]=_,e[49]=y,e[50]=l,e[51]=$):$=e[51];let T;return e[52]!==K||e[53]!==M||e[54]!==$||e[55]!==H?(T=r.jsxs(Ae,{onClick:H,"data-slot":"session-switcher-item",className:ee,style:K,children:[M,$]}),e[52]=K,e[53]=M,e[54]=$,e[55]=H,e[56]=T):T=e[56],T}function Tt(s){return s.notifyOnSubtasks}function At(s){return s.setCurrentSession}function Ft(s){return s.currentSessionId}export{Bt as C,qt as S,Wt as W,Le as a,Yt as b,Te as c,Ht as d,Xt as e,Rt as f,Kt as g,Gt as h,Qt as i,pt as j,ye as n,Jt as r,mt as u};
1
+ import{b as ne,R as je,j as r,H as Oe,a as Ue,ae as Ae}from"./vendor-.bun-C6iL44L9.js";import{c as _e,p as q,aH as Be,ah as We,ai as Ge,I as V,M as Ye,aG as He,aF as Ke,c1 as Je,c2 as Qe,bk as Re,u as Xe,b as qe,cw as Ve,r as ke,ay as Ze,aA as et,aB as tt,D as Pe,cU as st,cW as nt}from"./useAppFontEffects-BUUJYbAZ.js";import{z as Se,P as rt,u as Ne}from"./index-ZJTzZ0_U.js";const Bt=s=>{const e=ne.c(129),{totalTokens:t,percentage:o,colorPercentage:n,contextLimit:i,outputLimit:a,size:c,isMobile:x,hideIcon:f,showPercentIcon:l,className:m,valueClassName:v,percentIconClassName:b,onClick:p,pressed:w}=s,S=c===void 0?"default":c,h=x===void 0?!1:x,j=f===void 0?!1:f,N=l===void 0?!1:l,C=w===void 0?!1:w,{t:d}=_e(),[_,y]=je.useState(!1),u=typeof n=="number"?n:o;let g,D,k,I,L,W,B,G;if(e[0]!==u||e[1]!==i||e[2]!==j||e[3]!==h||e[4]!==p||e[5]!==a||e[6]!==b||e[7]!==o||e[8]!==N||e[9]!==d||e[10]!==t||e[11]!==v){const z=We(o)??0,M=Ge(u),$=M==="critical"?"var(--status-error)":M==="warn"?"var(--status-warning)":"var(--status-success)";g=ot,D=it;const T=2*Math.PI*8.5,P=T*(1-z/100);I=typeof a=="number"?Math.max(a,0):0;let E;e[20]!==d||e[21]!==t?(E=d("contextUsage.tooltip.usedTokens",{tokens:g(t)}),e[20]=d,e[21]=t,e[22]=E):E=e[22];let O;e[23]!==i||e[24]!==d?(O=d("contextUsage.tooltip.contextLimit",{tokens:g(i)}),e[23]=i,e[24]=d,e[25]=O):O=e[25];let U;e[26]!==I||e[27]!==d?(U=d("contextUsage.tooltip.outputLimit",{tokens:g(I)}),e[26]=I,e[27]=d,e[28]=U):U=e[28];let R;e[29]!==O||e[30]!==U||e[31]!==E?(R=[E,O,U],e[29]=O,e[30]=U,e[31]=E,e[32]=R):R=e[32],G=R,k=!h&&typeof p=="function",e[33]!==j||e[34]!==h?(B=!h&&!j&&r.jsx(V,{name:"donut-chart",className:"h-4 w-4 flex-shrink-0"}),e[33]=j,e[34]=h,e[35]=B):B=e[35],e[36]!==v?(L=q("font-medium inline-flex items-center gap-1.5",v),e[36]=v,e[37]=L):L=e[37],W=N?r.jsxs(r.Fragment,{children:[r.jsxs("svg",{viewBox:"0 0 20 20",className:q("h-3.5 w-3.5 -rotate-90",b),role:"progressbar","aria-valuenow":Math.round(z),"aria-valuemin":0,"aria-valuemax":100,children:[r.jsx("circle",{cx:10,cy:10,r:8.5,fill:"none",stroke:"var(--interactive-border)",strokeWidth:3}),r.jsx("circle",{cx:10,cy:10,r:8.5,fill:"none",stroke:$,strokeWidth:3,strokeLinecap:"round",strokeDasharray:T,strokeDashoffset:P,className:"transition-[stroke-dashoffset,stroke] duration-300"})]}),r.jsxs("span",{className:"text-foreground",children:[Math.min(o,999).toFixed(1),"%"]})]}):r.jsxs(r.Fragment,{children:[r.jsx("span",{className:D(u),children:Math.min(o,999).toFixed(1)}),"%"]}),e[0]=u,e[1]=i,e[2]=j,e[3]=h,e[4]=p,e[5]=a,e[6]=b,e[7]=o,e[8]=N,e[9]=d,e[10]=t,e[11]=v,e[12]=g,e[13]=D,e[14]=k,e[15]=I,e[16]=L,e[17]=W,e[18]=B,e[19]=G}else g=e[12],D=e[13],k=e[14],I=e[15],L=e[16],W=e[17],B=e[18],G=e[19];let Y;e[38]!==L||e[39]!==W?(Y=r.jsx("span",{className:L,children:W}),e[38]=L,e[39]=W,e[40]=Y):Y=e[40];let Z;e[41]!==B||e[42]!==Y?(Z=r.jsxs(r.Fragment,{children:[B,Y]}),e[41]=B,e[42]=Y,e[43]=Z):Z=e[43];const H=Z,ee=S==="compact"?"typography-micro":"typography-meta";let te;e[44]!==m||e[45]!==k||e[46]!==ee?(te=q("app-region-no-drag flex items-center gap-1.5 select-none",ee,k?q("rounded-md px-2 py-1.5 text-foreground transition-colors","hover:bg-interactive-hover","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"):"text-muted-foreground/60",m),e[44]=m,e[45]=k,e[46]=ee,e[47]=te):te=e[47];const K=te;let J;e[48]!==H||e[49]!==k||e[50]!==h||e[51]!==p||e[52]!==C||e[53]!==K||e[54]!==d?(J=k?r.jsx("button",{type:"button",className:K,"aria-label":d("contextUsage.aria.label"),"aria-pressed":C,onClick:p,children:H}):r.jsx("div",{className:K,"aria-label":d("contextUsage.aria.label"),onClick:h?()=>y(!0):void 0,children:H}),e[48]=H,e[49]=k,e[50]=h,e[51]=p,e[52]=C,e[53]=K,e[54]=d,e[55]=J):J=e[55];const X=J;if(h){let z;e[56]===Symbol.for("react.memo_cache_sentinel")?(z=()=>y(!1),e[56]=z):z=e[56];let M;e[57]!==d?(M=d("contextUsage.mobile.title"),e[57]=d,e[58]=M):M=e[58];let $;e[59]!==d?($=d("contextUsage.mobile.usedTokens"),e[59]=d,e[60]=$):$=e[60];let T;e[61]!==$?(T=r.jsx("span",{className:"typography-meta text-muted-foreground",children:$}),e[61]=$,e[62]=T):T=e[62];let P;e[63]!==g||e[64]!==t?(P=g(t),e[63]=g,e[64]=t,e[65]=P):P=e[65];let E;e[66]!==P?(E=r.jsx("span",{className:"typography-meta text-foreground font-medium",children:P}),e[66]=P,e[67]=E):E=e[67];let O;e[68]!==T||e[69]!==E?(O=r.jsxs("div",{className:"flex justify-between items-center",children:[T,E]}),e[68]=T,e[69]=E,e[70]=O):O=e[70];let U;e[71]!==d?(U=d("contextUsage.mobile.contextLimit"),e[71]=d,e[72]=U):U=e[72];let R;e[73]!==U?(R=r.jsx("span",{className:"typography-meta text-muted-foreground",children:U}),e[73]=U,e[74]=R):R=e[74];let re;e[75]!==i||e[76]!==g?(re=g(i),e[75]=i,e[76]=g,e[77]=re):re=e[77];let oe;e[78]!==re?(oe=r.jsx("span",{className:"typography-meta text-foreground font-medium",children:re}),e[78]=re,e[79]=oe):oe=e[79];let ie;e[80]!==R||e[81]!==oe?(ie=r.jsxs("div",{className:"flex justify-between items-center",children:[R,oe]}),e[80]=R,e[81]=oe,e[82]=ie):ie=e[82];let ae;e[83]!==d?(ae=d("contextUsage.mobile.outputLimit"),e[83]=d,e[84]=ae):ae=e[84];let le;e[85]!==ae?(le=r.jsx("span",{className:"typography-meta text-muted-foreground",children:ae}),e[85]=ae,e[86]=le):le=e[86];let ce;e[87]!==g||e[88]!==I?(ce=g(I),e[87]=g,e[88]=I,e[89]=ce):ce=e[89];let de;e[90]!==ce?(de=r.jsx("span",{className:"typography-meta text-foreground font-medium",children:ce}),e[90]=ce,e[91]=de):de=e[91];let ue;e[92]!==le||e[93]!==de?(ue=r.jsxs("div",{className:"flex justify-between items-center",children:[le,de]}),e[92]=le,e[93]=de,e[94]=ue):ue=e[94];let fe;e[95]!==d?(fe=d("contextUsage.mobile.usage"),e[95]=d,e[96]=fe):fe=e[96];let me;e[97]!==fe?(me=r.jsx("span",{className:"typography-meta text-muted-foreground",children:fe}),e[97]=fe,e[98]=me):me=e[98];let he;e[99]!==u||e[100]!==D?(he=q("typography-meta font-semibold",D(u)),e[99]=u,e[100]=D,e[101]=he):he=e[101];const De=Math.min(o,999);let pe;e[102]!==De?(pe=De.toFixed(1),e[102]=De,e[103]=pe):pe=e[103];let ge;e[104]!==he||e[105]!==pe?(ge=r.jsxs("span",{className:he,children:[pe,"%"]}),e[104]=he,e[105]=pe,e[106]=ge):ge=e[106];let xe;e[107]!==me||e[108]!==ge?(xe=r.jsxs("div",{className:"flex justify-between items-center pt-1 border-t border-border/40",children:[me,ge]}),e[107]=me,e[108]=ge,e[109]=xe):xe=e[109];let be;e[110]!==O||e[111]!==ie||e[112]!==ue||e[113]!==xe?(be=r.jsx("div",{className:"flex flex-col gap-1.5",children:r.jsxs("div",{className:"rounded-xl border border-border/40 bg-sidebar/30 px-3 py-2 space-y-1",children:[O,ie,ue,xe]})}),e[110]=O,e[111]=ie,e[112]=ue,e[113]=xe,e[114]=be):be=e[114];let we;e[115]!==_||e[116]!==M||e[117]!==be?(we=r.jsx(Ye,{open:_,onClose:z,title:M,children:be}),e[115]=_,e[116]=M,e[117]=be,e[118]=we):we=e[118];let ve;return e[119]!==X||e[120]!==we?(ve=r.jsxs(r.Fragment,{children:[X,we]}),e[119]=X,e[120]=we,e[121]=ve):ve=e[121],ve}let A;e[122]!==X?(A=r.jsx(He,{asChild:!0,children:X}),e[122]=X,e[123]=A):A=e[123];let F;e[124]!==G?(F=r.jsx(Be,{children:r.jsx("div",{className:"space-y-0.5",children:G.map(at)})}),e[124]=G,e[125]=F):F=e[125];let Q;return e[126]!==A||e[127]!==F?(Q=r.jsxs(Ke,{children:[A,F]}),e[126]=A,e[127]=F,e[128]=Q):Q=e[128],Q};function ot(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toFixed(1).replace(/\.0$/,"")}function it(s){return s>=90?"text-status-error":s>=75?"text-status-warning":"text-status-success"}function at(s){return r.jsx("p",{className:"typography-micro leading-tight",children:s},s)}const Wt=je.memo(function(e){const t=ne.c(40),{visible:o}=e,{t:n}=_e(),[i,a]=je.useState(!1);let c,x;if(t[0]!==o?(c=()=>{if(!o)return;let D=!1;Se("desktop_get_current_window_state").then(I=>{D||a(!!I?.maximized)}).catch(lt);const k=I=>{const L=I.detail;a(!!L?.maximized)};return window.addEventListener("openchamber:window-maximized-changed",k),()=>{D=!0,window.removeEventListener("openchamber:window-maximized-changed",k)}},x=[o],t[0]=o,t[1]=c,t[2]=x):(c=t[1],x=t[2]),Oe.useEffect(c,x),!o)return null;let f;t[3]!==n?(f=n("header.windowControls.groupAria"),t[3]=n,t[4]=f):f=t[4];let l;t[5]!==n?(l=n("header.windowControls.minimize"),t[5]=n,t[6]=l):l=t[6];let m;t[7]!==n?(m=n("header.windowControls.minimize"),t[7]=n,t[8]=m):m=t[8];let v;t[9]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(V,{name:"subtract",className:"h-4 w-4"}),t[9]=v):v=t[9];let b;t[10]!==l||t[11]!==m?(b=r.jsx("button",{type:"button",className:"app-region-no-drag inline-flex h-12 w-11 items-center justify-center text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:ct,title:l,"aria-label":m,children:v}),t[10]=l,t[11]=m,t[12]=b):b=t[12];let p;t[13]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{Se("desktop_toggle_current_window_maximized").then(D=>a(!!D?.maximized)).catch(dt)},t[13]=p):p=t[13];let w;t[14]!==i||t[15]!==n?(w=n(i?"header.windowControls.restore":"header.windowControls.maximize"),t[14]=i,t[15]=n,t[16]=w):w=t[16];let S;t[17]!==i||t[18]!==n?(S=n(i?"header.windowControls.restore":"header.windowControls.maximize"),t[17]=i,t[18]=n,t[19]=S):S=t[19];const h=i?"fullscreen-exit":"checkbox-blank";let j;t[20]!==h?(j=r.jsx(V,{name:h,className:"h-3.5 w-3.5"}),t[20]=h,t[21]=j):j=t[21];let N;t[22]!==S||t[23]!==j||t[24]!==w?(N=r.jsx("button",{type:"button",className:"app-region-no-drag inline-flex h-12 w-11 items-center justify-center text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:p,title:w,"aria-label":S,children:j}),t[22]=S,t[23]=j,t[24]=w,t[25]=N):N=t[25];let C;t[26]===Symbol.for("react.memo_cache_sentinel")?(C=q("app-region-no-drag inline-flex h-12 w-11 items-center justify-center text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","hover:bg-status-error hover:text-status-error-foreground"),t[26]=C):C=t[26];let d;t[27]!==n?(d=n("header.windowControls.close"),t[27]=n,t[28]=d):d=t[28];let _;t[29]!==n?(_=n("header.windowControls.close"),t[29]=n,t[30]=_):_=t[30];let y;t[31]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(V,{name:"close",className:"h-4 w-4"}),t[31]=y):y=t[31];let u;t[32]!==d||t[33]!==_?(u=r.jsx("button",{type:"button",className:C,onClick:ut,title:d,"aria-label":_,children:y}),t[32]=d,t[33]=_,t[34]=u):u=t[34];let g;return t[35]!==N||t[36]!==u||t[37]!==f||t[38]!==b?(g=r.jsxs("div",{className:"app-region-no-drag -mr-3 ml-2 flex h-12 shrink-0 items-center","aria-label":f,children:[b,N,u]}),t[35]=N,t[36]=u,t[37]=f,t[38]=b,t[39]=g):g=t[39],g});function lt(){}function ct(){Se("desktop_minimize_current_window")}function dt(){}function ut(){Se("desktop_close_current_window")}const Fe="oc.sessions.pinned",ft=s=>{try{const e=s.getItem(Fe);if(!e)return new Set;const t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(o=>typeof o=="string")):new Set}catch{return new Set}},Me=(s,e)=>{try{s.setItem(Fe,JSON.stringify([...e]))}catch{}},Ce=rt(),mt=Ue((s,e)=>({ids:ft(Ce),setIds:t=>{const o=e().ids,n=typeof t=="function"?t(o):t;n!==o&&(s({ids:n}),Me(Ce,n))},toggle:t=>{const o=e().ids,n=new Set(o);n.has(t)?n.delete(t):n.add(t),s({ids:n}),Me(Ce,n)}})),se=(s,e)=>Je(Qe.getState().dictionary,s,e),ht=s=>{const e=new Date(s),t=new Date,o=(a,c)=>a.getFullYear()===c.getFullYear()&&a.getMonth()===c.getMonth()&&a.getDate()===c.getDate(),n=new Date(t);return n.setDate(t.getDate()-1),o(e,t)?se("common.date.today"):o(e,n)?se("common.date.yesterday"):e.toLocaleDateString(Re(),{month:"short",day:"numeric",year:"numeric"}).replace(",","")},Gt=s=>{const e=new Date,t=new Date(s);if(((n,i)=>n.getFullYear()===i.getFullYear()&&n.getMonth()===i.getMonth()&&n.getDate()===i.getDate())(t,e)){const n=Date.now()-s;return n<6e4?se("common.relative.justNow"):n<36e5?se("common.relative.minutesAgoShort",{count:Math.floor(n/6e4)}):se("common.relative.hoursAgoShort",{count:Math.floor(n/36e5)})}return ht(s)},pt=s=>{const e=Math.max(0,Date.now()-s),t=6e4,o=60*t,n=24*o,i=7*n,a=30*n,c=365*n;return e<o?`${Math.max(1,Math.floor(e/t))}m`:e<n?`${Math.floor(e/o)}h`:e<i?se("common.relative.daysAgoCompact",{count:Math.floor(e/n)}):e<5*i?se("common.relative.weeksAgoCompact",{count:Math.floor(e/i)}):e<c?`${Math.floor(e/a)}mo`:se("common.relative.yearsAgoCompact",{count:Math.floor(e/c)})},ye=s=>{if(!s)return null;const e=s.replace(/\\/g,"/").replace(/\/+$/,"");return e.length===0?"/":e},gt=(s,e)=>{const t=ye(s),o=ye(e);return!t||!o?!1:t===o?!0:o==="/"?t.startsWith("/"):t.startsWith(`${o}/`)},Le=s=>s.toLowerCase().replace(/^opencode[/-]?/i,"").replace(/[-_]/g,"").trim(),Yt=(s,e)=>s?Le(s)!==Le(e):!1,Ie=s=>{if(typeof s=="number"&&Number.isFinite(s))return s;if(typeof s=="string"&&s.trim().length>0){const e=Number(s);if(Number.isFinite(e))return e}},$e=s=>Ie(s.time?.created)??0,ze=s=>Ie(s.time?.updated)??Ie(s.time?.created)??0,Te=(s,e,t)=>{const o=t.has(s.id),n=t.has(e.id);return o!==n?o?-1:1:o&&n?$e(e)-$e(s):ze(e)-ze(s)},Ht=s=>{const e=new Map;return s.forEach(t=>{e.set(t.id,t)}),Array.from(e.values())},Kt=s=>`__archived__:${s}`,Jt=(s,e)=>{const t=ye(s.directory??null),o=ye(s.project?.worktree??null),n=t??o;if(!n)return"unassigned";if(e&&n===e)return"project root";const a=(e&&n.startsWith(`${e}/`)?n.slice(e.length+1):n).split("/").filter(Boolean);return a[a.length-1]??"unassigned"},Qt=(s,e,t)=>{const o=ye(s.directory??null),n=ye(s.project?.worktree??null);return n&&(n===e||n.startsWith(`${e}/`))?!0:o?t&&t.has(o)?!0:o===e||o.startsWith(`${e}/`):!1},Rt=s=>s.replace(/[-_]/g," ").replace(/\b\w/g,e=>e.toUpperCase()),Xt=(s,e)=>{if(!e)return s;const t=s.toLowerCase(),o=e.toLowerCase(),n=o.length;if(n===0)return s;const i=[];let a=0,c=t.indexOf(o,a);for(;c!==-1;){c>a&&i.push(s.slice(a,c));const x=s.slice(c,c+n);i.push(r.jsx("mark",{className:"bg-primary text-primary-foreground ring-1 ring-primary/90",children:x},`${c}-${x}`)),a=c+n,c=t.indexOf(o,a)}return a<s.length&&i.push(s.slice(a)),i.length>0?i:s},xt=7,bt=s=>{if(!s)return null;const e=s.replace(/\\/g,"/");return e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e},wt=s=>{if(!s)return null;const e=s.label?.trim();if(e)return e;const t=s.path.split(/[\\/]/).filter(Boolean);return t[t.length-1]??null},yt=(s,e)=>{const t=ne.c(18);let o;t[0]!==e?(o=e===void 0?{}:e,t[0]=e,t[1]=o):o=t[1];const n=o,{scopeProjectId:i}=n,a=i===void 0?null:i,c=Xe(vt),x=qe(jt),f=mt(St),l=Ve();let m;t[2]!==x?(m=x.map(Nt).filter(_t),t[2]=x,t[3]=m):m=t[3];const v=m;let b;t[4]!==v?(b=h=>h?v.filter(N=>gt(h,N.normalizedPath)).sort(Dt)[0]??null:null,t[4]=v,t[5]=b):b=t[5];const p=b;let w;{let h;if(t[7]!==c||t[8]!==l||t[9]!==p||t[10]!==f||t[11]!==a){const j=new Map;for(const y of c){const u=y.parentID;if(!u||y.time?.archived)continue;const g=j.get(u);g?g.push(y):j.set(u,[y])}j.forEach(y=>{y.sort((u,g)=>Te(u,g,f))});let N;t[13]!==p||t[14]!==a?(N=y=>{if(!a)return!0;const u=ke(y);return p(u)?.id===a},t[13]=p,t[14]=a,t[15]=N):N=t[15];let C;t[16]!==f?(C=(y,u)=>Te(y,u,f),t[16]=f,t[17]=C):C=t[17];const d=c.filter(Ct).filter(kt).filter(N).sort(C).slice(0,xt),_=y=>{const u=j.get(y.id)??[];return{session:y,children:u.map(g=>_(g)),worktree:null}};h=d.map(y=>{const u=ke(y),g=p(u),D=wt(g),k=u?l.get(u)??null:null;return{node:_(y),projectId:g?.id??null,groupDirectory:u,secondaryMeta:{projectLabel:D,branchLabel:k&&k!==D?k:null}}}),t[7]=c,t[8]=l,t[9]=p,t[10]=f,t[11]=a,t[12]=h}else h=t[12];w=h}return w};function vt(s){return s.activeSessions}function jt(s){return s.projects}function St(s){return s.ids}function Nt(s){return{...s,normalizedPath:bt(s.path)}}function _t(s){return s.normalizedPath}function Dt(s,e){return(e.normalizedPath?.length??0)-(s.normalizedPath?.length??0)}function Ct(s){return!s.time?.archived}function kt(s){return!s.parentID}function qt(s){const e=ne.c(18),{children:t,variant:o,scopeProjectId:n,align:i}=s,a=o===void 0?"default":o,c=n===void 0?null:n,x=i===void 0?"start":i,f=Ne(It),l=Ne(Pt);let m;e[0]!==t?(m=r.jsx(Ze,{asChild:!0,children:t}),e[0]=t,e[1]=m):m=e[1];const v=a==="compact"?"w-[280px]":"w-[360px]";let b;e[2]!==v?(b=q("overflow-hidden p-1 max-w-[calc(100vw-32px)]",v),e[2]=v,e[3]=b):b=e[3];let p;e[4]!==f||e[5]!==c||e[6]!==l||e[7]!==a?(p=f?r.jsx(Mt,{onSelect:()=>l(!1),variant:a,scopeProjectId:c}):null,e[4]=f,e[5]=c,e[6]=l,e[7]=a,e[8]=p):p=e[8];let w;e[9]!==x||e[10]!==b||e[11]!==p?(w=r.jsx(et,{align:x,sideOffset:6,className:b,children:p}),e[9]=x,e[10]=b,e[11]=p,e[12]=w):w=e[12];let S;return e[13]!==f||e[14]!==l||e[15]!==m||e[16]!==w?(S=r.jsxs(tt,{open:f,onOpenChange:l,modal:!1,children:[m,w]}),e[13]=f,e[14]=l,e[15]=m,e[16]=w,e[17]=S):S=e[17],S}function Pt(s){return s.setSessionDropdownOpen}function It(s){return s.isSessionDropdownOpen}function Mt(s){const e=ne.c(26),{onSelect:t,variant:o,scopeProjectId:n}=s;let i;e[0]!==n?(i={scopeProjectId:n},e[0]=n,e[1]=i):i=e[1];const a=yt(!0,i),c=Pe($t),x=Ne(Lt),{t:f}=_e();let l;e[2]!==t||e[3]!==c||e[4]!==x?(l=()=>{x("chat"),t(),c()},e[2]=t,e[3]=c,e[4]=x,e[5]=l):l=e[5];const m=l;let v;e[6]===Symbol.for("react.memo_cache_sentinel")?(v=new Set,e[6]=v):v=e[6];const[b,p]=je.useState(v);let w;e[7]===Symbol.for("react.memo_cache_sentinel")?(w=u=>{p(g=>{const D=new Set(g);return D.has(u)?D.delete(u):D.add(u),D})},e[7]=w):w=e[7];const S=w;let h,j;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=q("group relative flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),j=r.jsx(V,{name:"chat-new",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),e[8]=h,e[9]=j):(h=e[8],j=e[9]);let N;e[10]!==f?(N=f("sessions.sidebar.header.actions.newSession"),e[10]=f,e[11]=N):N=e[11];let C;e[12]!==N?(C=r.jsx("span",{className:"truncate text-[14px] font-normal leading-tight text-foreground",children:N}),e[12]=N,e[13]=C):C=e[13];let d;e[14]!==m||e[15]!==C?(d=r.jsxs(Ae,{onClick:m,className:h,children:[j,C]}),e[14]=m,e[15]=C,e[16]=d):d=e[16];let _;e[17]!==b||e[18]!==a||e[19]!==t||e[20]!==f||e[21]!==o?(_=a.length===0?r.jsx("div",{className:"px-3 py-4 text-center typography-meta text-muted-foreground",children:f("sessions.switcher.empty")}):a.map(u=>r.jsx(Ee,{item:u,depth:0,variant:o,expandedParents:b,toggleParent:S,closeDropdown:t},u.node.session.id)),e[17]=b,e[18]=a,e[19]=t,e[20]=f,e[21]=o,e[22]=_):_=e[22];let y;return e[23]!==_||e[24]!==d?(y=r.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:r.jsxs("div",{className:"space-y-0.5",children:[d,_]})}),e[23]=_,e[24]=d,e[25]=y):y=e[25],y}function Lt(s){return s.setActiveMainTab}function $t(s){return s.openNewSessionDraft}function Ee(s){const e=ne.c(31),{item:t,depth:o,variant:n,expandedParents:i,toggleParent:a,closeDropdown:c}=s,{node:x,secondaryMeta:f}=t,l=x.session,m=x.children.length>0;let v;e[0]!==i||e[1]!==l.id?(v=i.has(l.id),e[0]=i,e[1]=l.id,e[2]=v):v=e[2];const b=v;let p;e[3]!==m||e[4]!==l.id||e[5]!==a?(p=m?()=>a(l.id):void 0,e[3]=m,e[4]=l.id,e[5]=a,e[6]=p):p=e[6];let w;e[7]!==c||e[8]!==o||e[9]!==m||e[10]!==b||e[11]!==f||e[12]!==l||e[13]!==p||e[14]!==n?(w=r.jsx(zt,{session:l,depth:o,variant:n,secondaryMeta:f,hasChildren:m,isExpanded:b,onToggleExpand:p,closeDropdown:c}),e[7]=c,e[8]=o,e[9]=m,e[10]=b,e[11]=f,e[12]=l,e[13]=p,e[14]=n,e[15]=w):w=e[15];let S;e[16]!==c||e[17]!==o||e[18]!==i||e[19]!==m||e[20]!==b||e[21]!==t.groupDirectory||e[22]!==t.projectId||e[23]!==x.children||e[24]!==f||e[25]!==a||e[26]!==n?(S=m&&b?x.children.map(j=>r.jsx(Ee,{item:{node:j,projectId:t.projectId,groupDirectory:t.groupDirectory,secondaryMeta:f},depth:o+1,variant:n,expandedParents:i,toggleParent:a,closeDropdown:c},j.session.id)):null,e[16]=c,e[17]=o,e[18]=i,e[19]=m,e[20]=b,e[21]=t.groupDirectory,e[22]=t.projectId,e[23]=x.children,e[24]=f,e[25]=a,e[26]=n,e[27]=S):S=e[27];let h;return e[28]!==w||e[29]!==S?(h=r.jsxs(r.Fragment,{children:[w,S]}),e[28]=w,e[29]=S,e[30]=h):h=e[30],h}function zt(s){const e=ne.c(57),{session:t,depth:o,variant:n,secondaryMeta:i,hasChildren:a,isExpanded:c,onToggleExpand:x,closeDropdown:f}=s,{t:l}=_e(),m=Pe(Ft),v=Pe(At),b=Ne(Tt),p=st(t.id),w=nt(t.id),S=m===t.id;let h;e[0]!==t.title||e[1]!==l?(h=t.title?.trim()||l("sessions.sidebar.session.untitled"),e[0]=t.title,e[1]=l,e[2]=h):h=e[2];const j=h,N=!!t.parentID,C=w>0&&(!N||b),d=p?.type??"idle",_=d==="busy"||d==="retry",y=!_&&C&&!S;let u;e[3]!==t.time?.created||e[4]!==t.time?.updated?(u=t.time?.updated||t.time?.created||Date.now(),e[3]=t.time?.created,e[4]=t.time?.updated,e[5]=u):u=e[5];const g=u;let D;e[6]!==g?(D=pt(g),e[6]=g,e[7]=D):D=e[7];const k=D;let I;e[8]!==i?.projectLabel?(I=i?.projectLabel?.trim()||null,e[8]=i?.projectLabel,e[9]=I):I=e[9];const L=I;let W;e[10]!==i?.branchLabel?(W=i?.branchLabel?.trim()||null,e[10]=i?.branchLabel,e[11]=W):W=e[11];const B=W,G=B&&B!=="HEAD"?B:null;let Y;e[12]!==f||e[13]!==S||e[14]!==t||e[15]!==v?(Y=()=>{if(S){f();return}const P=ke(t);v(t.id,P??null),f()},e[12]=f,e[13]=S,e[14]=t,e[15]=v,e[16]=Y):Y=e[16];const Z=Y;let H;e[17]!==Z?(H=P=>{if(P.target?.closest("[data-switcher-expand]")){P.preventDefault();return}Z()},e[17]=Z,e[18]=H):H=e[18];let ee;e[19]===Symbol.for("react.memo_cache_sentinel")?(ee=q("group relative flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none","data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover"),e[19]=ee):ee=e[19];const te=8+o*12;let K;e[20]!==te?(K={paddingLeft:te},e[20]=te,e[21]=K):K=e[21];let J;e[22]!==a||e[23]!==c||e[24]!==x||e[25]!==l||e[26]!==n?(J=n==="compact"&&a?r.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:P=>{P.preventDefault(),P.stopPropagation(),x?.()},className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground","aria-label":l(c?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:c?r.jsx(V,{name:"arrow-down-s",className:"h-3.5 w-3.5"}):r.jsx(V,{name:"arrow-right-s",className:"h-3.5 w-3.5"})}):null,e[22]=a,e[23]=c,e[24]=x,e[25]=l,e[26]=n,e[27]=J):J=e[27];const X=S?"text-primary":"text-foreground";let A;e[28]!==X?(A=q("truncate text-[14px] font-normal leading-tight",X),e[28]=X,e[29]=A):A=e[29];let F;e[30]!==j||e[31]!==A?(F=r.jsx("span",{className:A,children:j}),e[30]=j,e[31]=A,e[32]=F):F=e[32];let Q;e[33]!==J||e[34]!==F?(Q=r.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[J,F]}),e[33]=J,e[34]=F,e[35]=Q):Q=e[35];let z;e[36]!==G||e[37]!==a||e[38]!==c||e[39]!==x||e[40]!==L||e[41]!==l||e[42]!==k||e[43]!==n?(z=n==="default"?r.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 truncate text-muted-foreground/70 leading-tight",style:{fontSize:"calc(var(--text-ui-label) * 0.85)"},children:[a?r.jsx("span",{role:"button",tabIndex:-1,"data-switcher-expand":!0,onClick:P=>{P.preventDefault(),P.stopPropagation(),x?.()},className:"inline-flex h-3 w-3 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground","aria-label":l(c?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:c?r.jsx(V,{name:"arrow-down-s",className:"h-3 w-3"}):r.jsx(V,{name:"arrow-right-s",className:"h-3 w-3"})}):null,r.jsx("span",{className:"flex-shrink-0",children:k}),L?r.jsx("span",{className:"truncate",children:L}):null,G?r.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[r.jsx(V,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),r.jsx("span",{className:"truncate",children:G})]}):null]}):null,e[36]=G,e[37]=a,e[38]=c,e[39]=x,e[40]=L,e[41]=l,e[42]=k,e[43]=n,e[44]=z):z=e[44];let M;e[45]!==Q||e[46]!==z?(M=r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[Q,z]}),e[45]=Q,e[46]=z,e[47]=M):M=e[47];let $;e[48]!==_||e[49]!==y||e[50]!==l?($=_||y?r.jsx("span",{className:"flex h-3 w-3 flex-shrink-0 items-center justify-center self-center",children:_?r.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary animate-busy-pulse","aria-label":l("sessions.sidebar.session.status.active"),title:l("sessions.sidebar.session.status.active")}):r.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--status-info)]","aria-label":l("sessions.sidebar.session.status.unread"),title:l("sessions.sidebar.session.status.unread")})}):null,e[48]=_,e[49]=y,e[50]=l,e[51]=$):$=e[51];let T;return e[52]!==K||e[53]!==M||e[54]!==$||e[55]!==H?(T=r.jsxs(Ae,{onClick:H,"data-slot":"session-switcher-item",className:ee,style:K,children:[M,$]}),e[52]=K,e[53]=M,e[54]=$,e[55]=H,e[56]=T):T=e[56],T}function Tt(s){return s.notifyOnSubtasks}function At(s){return s.setCurrentSession}function Ft(s){return s.currentSessionId}export{Bt as C,qt as S,Wt as W,Le as a,Yt as b,Te as c,Ht as d,Xt as e,Rt as f,Kt as g,Gt as h,Qt as i,pt as j,ye as n,Jt as r,mt as u};
@@ -1 +1 @@
1
- import{b,R as h,j as t,bk as j,bi as w,bj as v,bg as k,be as D}from"./vendor-.bun-C6iL44L9.js";import{c as R,p as g}from"./useAppFontEffects-DTO332li.js";import{h as S}from"./runtimeEndpointReset-BYLVW9e7.js";import"./index-5eUDDB6w.js";import"./mobileLayoutPreference-Dio-WWkI.js";const B=x=>{const e=b.c(19),{open:m,onOpenChange:n}=x,{t:f}=R(),s=h.useId(),y=_;let a;e[0]!==n?(a=u=>{!u&&y()||n(u)},e[0]=n,e[1]=a):a=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx(j,{className:g("fixed inset-0 z-50 bg-black/50 dark:bg-black/75","transition-opacity duration-150 ease-out","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0")}),e[2]=c):c=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=g("relative pointer-events-auto","w-[90vw] max-w-[1200px] h-[85vh] max-h-[900px]","rounded-xl border shadow-none overflow-hidden origin-center","bg-background","transition-all duration-150 ease-out","data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]","data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]"),e[3]=d):d=e[3];let o;e[4]!==f?(o=f("settings.window.description"),e[4]=f,e[5]=o):o=e[5];let i;e[6]!==s||e[7]!==o?(i=t.jsx(w,{id:s,className:"sr-only",children:o}),e[6]=s,e[7]=o,e[8]=i):i=e[8];let l;e[9]!==n?(l=t.jsx(S,{onClose:()=>n(!1),isWindowed:!0}),e[9]=n,e[10]=l):l=e[10];let r;e[11]!==s||e[12]!==i||e[13]!==l?(r=t.jsxs(v,{children:[c,t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center pointer-events-none",children:t.jsxs(k,{"aria-describedby":s,className:d,children:[i,l]})})]}),e[11]=s,e[12]=i,e[13]=l,e[14]=r):r=e[14];let p;return e[15]!==m||e[16]!==a||e[17]!==r?(p=t.jsx(D,{open:m,onOpenChange:a,children:r}),e[15]=m,e[16]=a,e[17]=r,e[18]=p):p=e[18],p};function _(){return typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]')}export{B as SettingsWindow};
1
+ import{b,R as h,j as t,bk as j,bi as w,bj as v,bg as k,be as D}from"./vendor-.bun-C6iL44L9.js";import{c as R,p as g}from"./useAppFontEffects-BUUJYbAZ.js";import{h as S}from"./runtimeEndpointReset-By39StyB.js";import"./index-ZJTzZ0_U.js";import"./mobileLayoutPreference-Dio-WWkI.js";const B=x=>{const e=b.c(19),{open:m,onOpenChange:n}=x,{t:f}=R(),s=h.useId(),y=_;let a;e[0]!==n?(a=u=>{!u&&y()||n(u)},e[0]=n,e[1]=a):a=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx(j,{className:g("fixed inset-0 z-50 bg-black/50 dark:bg-black/75","transition-opacity duration-150 ease-out","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0")}),e[2]=c):c=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=g("relative pointer-events-auto","w-[90vw] max-w-[1200px] h-[85vh] max-h-[900px]","rounded-xl border shadow-none overflow-hidden origin-center","bg-background","transition-all duration-150 ease-out","data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]","data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]"),e[3]=d):d=e[3];let o;e[4]!==f?(o=f("settings.window.description"),e[4]=f,e[5]=o):o=e[5];let i;e[6]!==s||e[7]!==o?(i=t.jsx(w,{id:s,className:"sr-only",children:o}),e[6]=s,e[7]=o,e[8]=i):i=e[8];let l;e[9]!==n?(l=t.jsx(S,{onClose:()=>n(!1),isWindowed:!0}),e[9]=n,e[10]=l):l=e[10];let r;e[11]!==s||e[12]!==i||e[13]!==l?(r=t.jsxs(v,{children:[c,t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center pointer-events-none",children:t.jsxs(k,{"aria-describedby":s,className:d,children:[i,l]})})]}),e[11]=s,e[12]=i,e[13]=l,e[14]=r):r=e[14];let p;return e[15]!==m||e[16]!==a||e[17]!==r?(p=t.jsx(D,{open:m,onOpenChange:a,children:r}),e[15]=m,e[16]=a,e[17]=r,e[18]=p):p=e[18],p};function _(){return typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]')}export{B as SettingsWindow};