@openchamber/web 1.11.5 → 1.11.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{MarkdownRendererImpl-C3-ZpwEx.js → MarkdownRendererImpl-COdbjw73.js} +3 -3
- package/dist/assets/{MultiRunWindow-BDfPzMDy.js → MultiRunWindow-BKSHxjMq.js} +1 -1
- package/dist/assets/{OnboardingScreen-DGgh4IXB.js → OnboardingScreen-Chjg337p.js} +1 -1
- package/dist/assets/{SettingsWindow-B8QKr5dB.js → SettingsWindow-C0lRRW8M.js} +1 -1
- package/dist/assets/{TerminalView-D7IIkSGJ.js → TerminalView-Bvil3j1u.js} +4 -4
- package/dist/assets/es-BZIAUghG.js +15 -0
- package/dist/assets/index-UcCH2KN9.css +1 -0
- package/dist/assets/ko-DU9l-zox.js +15 -0
- package/dist/assets/{main-VVcyjpiF.js → main-Blhx9Fp5.js} +2 -2
- package/dist/assets/main-d2-dY4er.js +232 -0
- package/dist/assets/miniChat-CJ7-rZFl.js +2 -0
- package/dist/assets/{modelPrefsAutoSave-Ctdc3cCY.js → modelPrefsAutoSave-DRJSYigo.js} +96 -96
- package/dist/assets/{pl-C577DpsX.js → pl-CdqzokG-.js} +1 -1
- package/dist/assets/pt-BR-Bknbr_Y3.js +15 -0
- package/dist/assets/{renderElectronMiniChatApp-CsddCM3q.js → renderElectronMiniChatApp-BxZRI73j.js} +2 -2
- package/dist/assets/uk-Be4E8ZNO.js +15 -0
- package/dist/assets/zh-CN-qpPiaZMg.js +15 -0
- package/dist/index.html +3 -3
- package/dist/mini-chat.html +3 -3
- package/package.json +1 -1
- package/server/index.js +2 -0
- package/server/lib/cloudflare-tunnel.js +3 -5
- package/server/lib/ngrok-tunnel.js +209 -0
- package/server/lib/opencode/core-routes.js +1 -0
- package/server/lib/opencode/feature-routes-runtime.js +35 -0
- package/server/lib/opencode/index.js +19 -0
- package/server/lib/opencode/npm-registry.js +157 -0
- package/server/lib/opencode/npm-registry.test.js +179 -0
- package/server/lib/opencode/plugin-routes.js +373 -0
- package/server/lib/opencode/plugin-routes.test.js +384 -0
- package/server/lib/opencode/plugin-spec.js +107 -0
- package/server/lib/opencode/plugin-spec.test.js +154 -0
- package/server/lib/opencode/plugins.js +393 -0
- package/server/lib/opencode/plugins.test.js +176 -0
- package/server/lib/opencode/settings-helpers.js +3 -0
- package/server/lib/opencode/settings-helpers.test.js +11 -0
- package/server/lib/tunnels/DOCUMENTATION.md +1 -0
- package/server/lib/tunnels/providers/ngrok.js +117 -0
- package/server/lib/tunnels/types.js +2 -0
- package/dist/assets/es-dIVpApmS.js +0 -15
- package/dist/assets/index-Bk9IWJe1.css +0 -1
- package/dist/assets/ko-Cqf3E9-d.js +0 -15
- package/dist/assets/main-D45l3Dxw.js +0 -232
- package/dist/assets/miniChat-a9w7WM0c.js +0 -2
- package/dist/assets/pt-BR-BeeF6VlK.js +0 -15
- package/dist/assets/uk-CZ7XVz_D.js +0 -15
- package/dist/assets/zh-CN-BMSSqdyO.js +0 -15
- /package/dist/assets/{index-DHluop4D.js → index-B9LvUHdG.js} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{R as C,c as
|
|
1
|
+
import{R as C,c as U,bE as Ve,bF as Ue,j as a,bG as qe,bH as Ke,bI as Ze,bJ as Ge,bK as Xe,bL as Ye,ad as Je}from"./vendor-.bun-Bum-iBXX.js";import{M as Se,bh as Re,a as be,u as le,bQ as Te,c as F,b2 as Qe,b4 as ye,eV as et,eW as Le,O as tt,i as ge,eX as rt,I as V,eY as nt,b as we,v as ae,w as _e}from"./modelPrefsAutoSave-DRJSYigo.js";import"./index-B9LvUHdG.js";const ve=()=>{const t=U.c(4),e=Qe();let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=ye(!1),t[0]=r):r=t[0];const s=r;let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=ye(!0),t[1]=n):n=t[1];const o=n;let i;return t[2]!==e?.currentTheme?(i=e?.currentTheme??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?o:s),t[2]=e?.currentTheme,t[3]=i):i=t[3],i},Me=t=>{const e=U.c(4),{containerRef:r,enabled:s}=t;let n,o;e[0]!==r||e[1]!==s?(n=()=>{if(s===!1)return;const i=r.current;if(!i)return;const l=Wt;return i.addEventListener("click",l),()=>{i.removeEventListener("click",l)}},o=[r,s],e[0]=r,e[1]=s,e[2]=n,e[3]=o):(n=e[2],o=e[3]),C.useEffect(n,o)},ot=t=>{const e=U.c(5),{href:r}=t,[s,n]=C.useState(!1);let o;e[0]!==r?(o=nt(r),e[0]=r,e[1]=o):o=e[1];const i=o;if(!i||s)return null;let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>n(!0),e[2]=l):l=e[2];let c;return e[3]!==i?(c=a.jsx("span",{className:"mr-1 inline-flex size-[18px] items-center justify-center rounded border border-[var(--border)] bg-[var(--interactive-hover)] align-middle",children:a.jsx("img",{src:i,alt:"","aria-hidden":"true",loading:"lazy",decoding:"async",className:"size-3.5 rounded-sm",onError:l})}),e[3]=i,e[4]=c):c=e[4],c},Ae=t=>{const e=[],r=[],s=t.querySelector("thead");s&&s.querySelectorAll("th").forEach(i=>e.push(i.innerText.trim()));const n=t.querySelector("tbody");return n&&n.querySelectorAll("tr").forEach(i=>{const l=i.querySelectorAll("td"),c=[];l.forEach(d=>c.push(d.innerText.trim())),r.push(c)}),{headers:e,rows:r}},Fe=({headers:t,rows:e})=>{const r=n=>n.includes(",")||n.includes('"')||n.includes(`
|
|
2
2
|
`)?`"${n.replace(/"/g,'""')}"`:n,s=[];return t.length>0&&s.push(t.map(r).join(",")),e.forEach(n=>s.push(n.map(r).join(","))),s.join(`
|
|
3
3
|
`)},st=({headers:t,rows:e})=>{const r=n=>n.replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r"),s=[];return t.length>0&&s.push(t.map(r).join(" ")),e.forEach(n=>s.push(n.map(r).join(" "))),s.join(`
|
|
4
4
|
`)},at=({headers:t,rows:e})=>{if(t.length===0)return"";const r=n=>n.replace(/\\/g,"\\\\").replace(/\|/g,"\\|"),s=[];return s.push(`| ${t.map(r).join(" | ")} |`),s.push(`| ${t.map(()=>"---").join(" | ")} |`),e.forEach(n=>{const o=t.map((i,l)=>r(n[l]||""));s.push(`| ${o.join(" | ")} |`)}),s.join(`
|
|
5
|
-
`)},it=(t,e,r)=>{const s=new Blob([e],{type:r}),n=URL.createObjectURL(s),o=document.createElement("a");o.href=n,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)},lt=t=>{const e=V.c(20),{tableRef:r}=t,{t:s}=le(),[n,o]=C.useState(!1),[i,l]=C.useState(!1),c=C.useRef(null);let d,m;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{const T=w=>{c.current&&!c.current.contains(w.target)&&l(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},m=[],e[0]=d,e[1]=m):(d=e[0],m=e[1]),C.useEffect(d,m);let g;e[2]!==r?(g=async T=>{const w=r.current?.querySelector("table");if(!w)return;const y=Ae(w),f=T==="csv"?Fe(y):st(y);try{await navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([f],{type:"text/plain"}),"text/html":new Blob([w.outerHTML],{type:"text/html"})})]),o(!0),l(!1),setTimeout(()=>o(!1),2e3)}catch(j){const S=j;if((await ae(f)).ok){o(!0),l(!1),setTimeout(()=>o(!1),2e3);return}console.error("Failed to copy table:",S)}},e[2]=r,e[3]=g):g=e[3];const h=g;let p;e[4]!==i?(p=()=>l(!i),e[4]=i,e[5]=p):p=e[5];let k;e[6]!==s?(k=s("markdownRenderer.table.actions.copyTitle"),e[6]=s,e[7]=k):k=e[7];let v;e[8]!==n?(v=n?a.jsx(U,{name:"check",className:"size-3.5"}):a.jsx(U,{name:"file-copy",className:"size-3.5"}),e[8]=n,e[9]=v):v=e[9];let x;e[10]!==p||e[11]!==k||e[12]!==v?(x=a.jsx("button",{onClick:p,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:k,children:v}),e[10]=p,e[11]=k,e[12]=v,e[13]=x):x=e[13];let u;e[14]!==h||e[15]!==i?(u=i&&a.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[100px] overflow-hidden rounded-md border border-border bg-background shadow-none",children:[a.jsx("button",{className:"w-full px-3 py-1.5 text-left text-sm transition-colors hover:bg-interactive-hover/40",onClick:()=>h("csv"),children:"CSV"}),a.jsx("button",{className:"w-full px-3 py-1.5 text-left text-sm transition-colors hover:bg-interactive-hover/40",onClick:()=>h("tsv"),children:"TSV"})]}),e[14]=h,e[15]=i,e[16]=u):u=e[16];let M;return e[17]!==x||e[18]!==u?(M=a.jsxs("div",{className:"relative",ref:c,children:[x,u]}),e[17]=x,e[18]=u,e[19]=M):M=e[19],M},ct=t=>{const e=V.c(19),{tableRef:r}=t,{t:s}=le(),[n,o]=C.useState(!1),i=C.useRef(null);let l,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{const u=M=>{i.current&&!i.current.contains(M.target)&&o(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},c=[],e[0]=l,e[1]=c):(l=e[0],c=e[1]),C.useEffect(l,c);let d;e[2]!==s||e[3]!==r?(d=u=>{const M=r.current?.querySelector("table");if(!M)return;const T=Ae(M),w=u==="csv"?Fe(T):at(T);it(u==="csv"?"table.csv":"table.md",w,u==="csv"?"text/csv":"text/markdown"),o(!1),_e.success(s("markdownRenderer.table.toast.downloadedAsFormat",{format:u.toUpperCase()}))},e[2]=s,e[3]=r,e[4]=d):d=e[4];const m=d;let g;e[5]!==n?(g=()=>o(!n),e[5]=n,e[6]=g):g=e[6];let h;e[7]!==s?(h=s("markdownRenderer.table.actions.downloadTitle"),e[7]=s,e[8]=h):h=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(U,{name:"download",className:"size-3.5"}),e[9]=p):p=e[9];let k;e[10]!==g||e[11]!==h?(k=a.jsx("button",{onClick:g,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:h,children:p}),e[10]=g,e[11]=h,e[12]=k):k=e[12];let v;e[13]!==m||e[14]!==n?(v=n&&a.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[100px] overflow-hidden rounded-md border border-border bg-background shadow-none",children:[a.jsx("button",{className:"w-full px-3 py-1.5 text-left text-sm transition-colors hover:bg-interactive-hover/40",onClick:()=>m("csv"),children:"CSV"}),a.jsx("button",{className:"w-full px-3 py-1.5 text-left text-sm transition-colors hover:bg-interactive-hover/40",onClick:()=>m("markdown"),children:"Markdown"})]}),e[13]=m,e[14]=n,e[15]=v):v=e[15];let x;return e[16]!==k||e[17]!==v?(x=a.jsxs("div",{className:"relative",ref:i,children:[k,v]}),e[16]=k,e[17]=v,e[18]=x):x=e[18],x},dt=t=>{const e=V.c(14),{children:r,className:s}=t,n=C.useRef(null),{isMobile:o,isTablet:i}=we(),c=o||i?"opacity-100":"opacity-0 group-hover:opacity-100";let d;e[0]!==c?(d=F("flex items-center justify-end gap-1 transition-opacity",c),e[0]=c,e[1]=d):d=e[1];let m,g;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=a.jsx(lt,{tableRef:n}),g=a.jsx(ct,{tableRef:n}),e[2]=m,e[3]=g):(m=e[2],g=e[3]);let h;e[4]!==d?(h=a.jsxs("div",{className:d,children:[m,g]}),e[4]=d,e[5]=h):h=e[5];let p;e[6]!==s?(p=F("w-full border-collapse text-sm",s),e[6]=s,e[7]=p):p=e[7];let k;e[8]!==r||e[9]!==p?(k=a.jsx("div",{className:"overflow-x-auto rounded-lg border border-border/80 bg-[var(--surface-elevated)]",children:a.jsx("table",{className:p,"data-markdown":"table",children:r})}),e[8]=r,e[9]=p,e[10]=k):k=e[10];let v;return e[11]!==h||e[12]!==k?(v=a.jsxs("div",{className:"group my-4 flex flex-col space-y-2","data-markdown":"table-wrapper",ref:n,children:[h,k]}),e[11]=h,e[12]=k,e[13]=v):v=e[13],v},mt=t=>{const e=V.c(83),{source:r,mode:s}=t,{t:n}=le(),o=ve(),{isMobile:i,isTablet:l}=we(),[c,d]=C.useState(!1),[m,g]=C.useState(!1);let h;e:{if(s!=="svg"){h="";break e}try{let b;e[0]!==o.colors.interactive.border||e[1]!==o.colors.primary.base||e[2]!==o.colors.surface.elevated||e[3]!==o.colors.surface.foreground||e[4]!==o.colors.surface.muted||e[5]!==o.colors.surface.mutedForeground||e[6]!==r?(b=Xe(r,{bg:o.colors.surface.elevated,fg:o.colors.surface.foreground,line:o.colors.interactive.border,accent:o.colors.primary.base,muted:o.colors.surface.mutedForeground,surface:o.colors.surface.muted,border:o.colors.interactive.border,transparent:!0,font:"IBM Plex Sans, sans-serif"}),e[0]=o.colors.interactive.border,e[1]=o.colors.primary.base,e[2]=o.colors.surface.elevated,e[3]=o.colors.surface.foreground,e[4]=o.colors.surface.muted,e[5]=o.colors.surface.mutedForeground,e[6]=r,e[7]=b):b=e[7],h=b}catch{h=""}}const p=h;let k;e:{if(s!=="ascii"){k="";break e}try{let b;e[8]!==r?(b=Ye(r),e[8]=r,e[9]=b):b=e[9],k=b}catch{k=""}}const v=k,x=i||l?"opacity-100":"opacity-0 group-hover:opacity-100";let u;e[10]===Symbol.for("react.memo_cache_sentinel")?(u=async b=>{if(!b)return;(await ae(b)).ok&&(d(!0),setTimeout(()=>d(!1),2e3))},e[10]=u):u=e[10];const M=u;let T;e[11]!==r?(T=async()=>{if(!r)return;(await ae(r)).ok&&(d(!0),setTimeout(()=>d(!1),2e3))},e[11]=r,e[12]=T):T=e[12];const w=T;let y;e[13]!==p||e[14]!==n?(y=()=>{if(p)try{const b=new Blob([p],{type:"image/svg+xml;charset=utf-8"}),E=URL.createObjectURL(b),N=document.createElement("a");N.href=E,N.download=`diagram-${Date.now()}.svg`,document.body.appendChild(N),N.click(),document.body.removeChild(N),URL.revokeObjectURL(E),g(!0),setTimeout(()=>g(!1),2e3)}catch{_e.error(n("markdownRenderer.mermaid.toast.downloadFailed"))}},e[13]=p,e[14]=n,e[15]=y):y=e[15];const f=y;if(s==="ascii"){const b=v||r;let E;e[16]!==b?(E=a.jsx("div",{"data-markdown":"mermaid-scroll",children:a.jsx("pre",{"data-markdown":"mermaid-ascii",children:b})}),e[16]=b,e[17]=E):E=e[17];let N;e[18]!==x?(N=F("absolute top-1 right-2 transition-opacity",x),e[18]=x,e[19]=N):N=e[19];let R;e[20]!==b?(R=()=>M(b),e[20]=b,e[21]=R):R=e[21];let L;e[22]!==n?(L=n("markdownRenderer.mermaid.actions.copyTitle"),e[22]=n,e[23]=L):L=e[23];let _;e[24]!==c?(_=c?a.jsx(U,{name:"check",className:"size-3.5"}):a.jsx(U,{name:"file-copy",className:"size-3.5"}),e[24]=c,e[25]=_):_=e[25];let O;e[26]!==_||e[27]!==R||e[28]!==L?(O=a.jsx("button",{onClick:R,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:L,children:_}),e[26]=_,e[27]=R,e[28]=L,e[29]=O):O=e[29];let H;e[30]!==O||e[31]!==N?(H=a.jsx("div",{className:N,children:O}),e[30]=O,e[31]=N,e[32]=H):H=e[32];let K;return e[33]!==H||e[34]!==E?(K=a.jsxs("div",{"data-markdown":"mermaid-block",className:"group",children:[E,H]}),e[33]=H,e[34]=E,e[35]=K):K=e[35],K}if(!p){let b;e[36]!==r?(b=a.jsx("div",{"data-markdown":"mermaid-scroll",children:a.jsx("pre",{"data-markdown":"mermaid-ascii",children:r})}),e[36]=r,e[37]=b):b=e[37];let E;e[38]!==x?(E=F("absolute top-1 right-2 transition-opacity",x),e[38]=x,e[39]=E):E=e[39];let N;e[40]!==r?(N=()=>M(r),e[40]=r,e[41]=N):N=e[41];let R;e[42]!==n?(R=n("markdownRenderer.mermaid.actions.copyTitle"),e[42]=n,e[43]=R):R=e[43];let L;e[44]!==c?(L=c?a.jsx(U,{name:"check",className:"size-3.5"}):a.jsx(U,{name:"file-copy",className:"size-3.5"}),e[44]=c,e[45]=L):L=e[45];let _;e[46]!==L||e[47]!==N||e[48]!==R?(_=a.jsx("button",{onClick:N,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:R,children:L}),e[46]=L,e[47]=N,e[48]=R,e[49]=_):_=e[49];let O;e[50]!==_||e[51]!==E?(O=a.jsx("div",{className:E,children:_}),e[50]=_,e[51]=E,e[52]=O):O=e[52];let H;return e[53]!==O||e[54]!==b?(H=a.jsxs("div",{"data-markdown":"mermaid-block",className:"group",children:[b,O]}),e[53]=O,e[54]=b,e[55]=H):H=e[55],H}let j;e[56]!==p?(j=a.jsx("div",{"data-markdown":"mermaid-scroll",children:a.jsx("div",{"data-markdown":"mermaid",dangerouslySetInnerHTML:{__html:p}})}),e[56]=p,e[57]=j):j=e[57];let S;e[58]!==x?(S=F("absolute top-1 right-2 flex items-center gap-1 transition-opacity",x),e[58]=x,e[59]=S):S=e[59];let B;e[60]!==n?(B=n("markdownRenderer.mermaid.actions.copySourceTitle"),e[60]=n,e[61]=B):B=e[61];let A;e[62]!==c?(A=c?a.jsx(U,{name:"check",className:"size-3.5"}):a.jsx(U,{name:"file-copy",className:"size-3.5"}),e[62]=c,e[63]=A):A=e[63];let $;e[64]!==w||e[65]!==B||e[66]!==A?($=a.jsx("button",{onClick:w,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:B,children:A}),e[64]=w,e[65]=B,e[66]=A,e[67]=$):$=e[67];let z;e[68]!==n?(z=n("markdownRenderer.mermaid.actions.downloadSvgTitle"),e[68]=n,e[69]=z):z=e[69];let P;e[70]!==m?(P=m?a.jsx(U,{name:"check",className:"size-3.5"}):a.jsx(U,{name:"download",className:"size-3.5"}),e[70]=m,e[71]=P):P=e[71];let D;e[72]!==f||e[73]!==z||e[74]!==P?(D=a.jsx("button",{onClick:f,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:z,children:P}),e[72]=f,e[73]=z,e[74]=P,e[75]=D):D=e[75];let I;e[76]!==$||e[77]!==D||e[78]!==S?(I=a.jsxs("div",{className:S,children:[$,D]}),e[76]=$,e[77]=D,e[78]=S,e[79]=I):I=e[79];let W;return e[80]!==I||e[81]!==j?(W=a.jsxs("div",{"data-markdown":"mermaid-block",className:"group",children:[j,I]}),e[80]=I,e[81]=j,e[82]=W):W=e[82],W},Ie=t=>{if(!t.includes("mermaid"))return[];const e=[],r=/(?:^|\r?\n)(`{3,}|~{3,})mermaid[^\n\r]*\r?\n([\s\S]*?)\r?\n\1(?=\r?\n|$)/gi;let s=r.exec(t);for(;s;){const n=(s[2]??"").replace(/\s+$/,"");e.push(n),s=r.exec(t)}return e},ut=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},ft=t=>/^\[[^\]]+\]:\s+\S+/m.test(t)||/^\[\^[^\]]+\]:\s+/m.test(t),ht=t=>{const e=t.match(/^[ \t]{0,3}(`{3,}|~{3,})/);if(!e)return!1;const r=e[1];if(!r)return!1;const s=r[0],n=r.length,o=t.trimEnd().split(`
|
|
6
|
-
`).at(-1)?.trim()??"";return!new RegExp(`^[\\t ]{0,3}${s}{${n},}[\\t ]*$`).test(o)},Ne=t=>Ve(t,{linkMode:"text-only"}),pt=t=>{let e=2166136261;for(let r=0;r<t.length;r+=1)e^=t.charCodeAt(r),e=e+((e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24))>>>0;return e.toString(16)},ne=(t,e,r,s)=>{const n=e.length>400?`${e.slice(0,200)}${e.slice(-200)}`:e;return`${t}:${r}:${s}:${e.length}:${pt(n)}`},bt=(t,e,r)=>{if(!e)return[{key:ne(r,t,0,"full"),raw:t,src:t,mode:"full"}];const s=Ne(t);if(ft(t))return[{key:ne(r,t,0,"live"),raw:t,src:s,mode:"live"}];const n=Ue.lexer(t),o=[];let i=0;for(let l=0;l<n.length;l+=1){const c=n[l];if(c.type==="space")continue;const d=c.raw??"",m=l===n.length-1||n.slice(l+1).every(p=>p.type==="space"),g=m?"live":"full",h=m&&c.type==="code"&&ht(d)?d:Ne(d);o.push({key:ne(r,d,i,g),raw:d,src:h,mode:g}),i+=1}return o.length===0?[{key:ne(r,t,0,"live"),raw:t,src:s,mode:"live"}]:o},$e=(t,e,r)=>{const s=C.useRef([]);return C.useMemo(()=>{const n=bt(t,e,r),o=s.current,i=n.map((c,d)=>{const m=o[d];return m&&m.key===c.key&&m.src===c.src?m:c});return i.length===o.length&&i.every((c,d)=>c===o[d])?o:(s.current=i,i)},[r,e,t])},pe=t=>typeof t=="string"?t:Array.isArray(t)?t.map(e=>pe(e)).join(""):C.isValidElement(t)?pe(t.props.children):"",gt=t=>t?.match(/language-([\w-]+)/)?.[1]?.toLowerCase()??"text",wt=t=>{let e=t;for(let r=0;r<3;r+=1){const s=e.replace(/"/g,'"').replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&");if(s===e)return e;e=s}return e},vt=(t,e)=>!["json","jsonc","json5"].includes(e)||!/&(quot|#34|amp;quot|lt|gt|amp|apos|#39);/.test(t)?t:wt(t),xt=300,kt=1200,yt=200,oe={margin:0,background:"transparent",padding:0,fontSize:"var(--text-code)",lineHeight:"var(--markdown-code-block-line-height)"},Nt=(t,e)=>{let r=1;for(let s=0;s<t.length;s+=1)if(t.charCodeAt(s)===10&&(r+=1,r>e))return!0;return!1},Et=()=>ge()?yt:kt,jt=(t,e,r)=>{if(!(typeof window>"u"))try{const s=new Blob([t],{type:r}),n=URL.createObjectURL(s),o=document.createElement("a");o.href=n,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)}catch{}},Ct=t=>{const e=V.c(52),{code:r,language:s,syntaxTheme:n}=t,[o,i]=C.useState(!1),[l,c]=C.useState(!0),[d,m]=C.useState("code"),g=C.useRef(r),h=C.useRef(null),{isMobile:p,isTablet:k}=we();let v;e[0]!==r?(v=Nt(r,Et()),e[0]=r,e[1]=v):v=e[1];const x=v,u=s==="html"||s==="htm";let M,T;e[2]!==u||e[3]!==d?(M=()=>{!u&&d!=="code"&&m("code")},T=[u,d],e[2]=u,e[3]=d,e[4]=M,e[5]=T):(M=e[4],T=e[5]),C.useEffect(M,T);let w,y;e[6]!==r?(w=()=>{if(g.current!==r)return g.current=r,h.current&&clearTimeout(h.current),c(!1),h.current=setTimeout(()=>{c(!0),h.current=null},xt),()=>{h.current&&(clearTimeout(h.current),h.current=null)}},y=[r],e[6]=r,e[7]=w,e[8]=y):(w=e[7],y=e[8]),C.useEffect(w,y);let f;e[9]!==r?(f=async()=>{(await ae(r)).ok&&(i(!0),window.setTimeout(()=>i(!1),2e3))},e[9]=r,e[10]=f):f=e[10];const j=f;let S;e[11]!==u||e[12]!==r?(S=()=>{if(!u)return;const H=Date.now().toString(36);jt(r,`preview-${H}.html`,"text/html;charset=utf-8")},e[11]=u,e[12]=r,e[13]=S):S=e[13];const B=S;let A;e[14]!==s?(A=a.jsx("span",{className:"font-mono text-[13px] text-muted-foreground",children:s}),e[14]=s,e[15]=A):A=e[15];const $=p||k?"opacity-100":"opacity-100 md:opacity-0 md:group-hover:opacity-100";let z;e[16]!==$?(z=F("flex items-center gap-1 transition-opacity",$),e[16]=$,e[17]=z):z=e[17];let P;e[18]!==u||e[19]!==d?(P=u?a.jsx("button",{type:"button",onClick:()=>m(Ut),className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:d==="preview"?"Show code":"Preview","aria-pressed":d==="preview","aria-label":d==="preview"?"Show code":"Preview HTML",children:d==="preview"?a.jsx(U,{name:"code",className:"size-3.5"}):a.jsx(U,{name:"eye",className:"size-3.5"})}):null,e[18]=u,e[19]=d,e[20]=P):P=e[20];let D;e[21]!==u||e[22]!==B?(D=u?a.jsx("button",{type:"button",onClick:B,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:"Download HTML","aria-label":"Download HTML",children:a.jsx(U,{name:"download",className:"size-3.5"})}):null,e[21]=u,e[22]=B,e[23]=D):D=e[23];let I;e[24]!==j?(I=()=>{j()},e[24]=j,e[25]=I):I=e[25];const W=o?"Copied":"Copy code",b=o?"Copied":"Copy code";let E;e[26]!==o?(E=o?a.jsx(U,{name:"check",className:"size-3.5"}):a.jsx(U,{name:"file-copy",className:"size-3.5"}),e[26]=o,e[27]=E):E=e[27];let N;e[28]!==I||e[29]!==W||e[30]!==b||e[31]!==E?(N=a.jsx("button",{type:"button",onClick:I,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:W,"aria-label":b,children:E}),e[28]=I,e[29]=W,e[30]=b,e[31]=E,e[32]=N):N=e[32];let R;e[33]!==z||e[34]!==P||e[35]!==D||e[36]!==N?(R=a.jsxs("div",{className:z,children:[P,D,N]}),e[33]=z,e[34]=P,e[35]=D,e[36]=N,e[37]=R):R=e[37];let L;e[38]!==R||e[39]!==A?(L=a.jsxs("div",{className:"flex items-center justify-between border-b border-border/70 px-3 py-1.5",children:[A,R]}),e[38]=R,e[39]=A,e[40]=L):L=e[40];let _;e[41]!==u||e[42]!==r||e[43]!==l||e[44]!==s||e[45]!==x||e[46]!==n||e[47]!==d?(_=u&&d==="preview"?a.jsx("div",{className:"h-[320px] md:h-[420px] bg-background",children:a.jsx("iframe",{srcDoc:r,title:"HTML preview",className:"h-full w-full border-0",sandbox:"allow-scripts allow-forms"})}):a.jsx("div",{className:"px-3 py-2.5",children:l&&!x?a.jsx(Je,{language:s,style:n,customStyle:oe,codeTagProps:{style:oe},PreTag:"pre",children:r}):a.jsx("pre",{style:oe,children:a.jsx("code",{style:oe,children:r})})}),e[41]=u,e[42]=r,e[43]=l,e[44]=s,e[45]=x,e[46]=n,e[47]=d,e[48]=_):_=e[48];let O;return e[49]!==L||e[50]!==_?(O=a.jsxs("div",{"data-component":"markdown-code",className:"my-4 group overflow-hidden rounded-2xl border border-border/80 bg-[var(--surface-elevated)]",children:[L,_]}),e[49]=L,e[50]=_,e[51]=O):O=e[51],O},Pe=({syntaxTheme:t,onPreviewLoopback:e,previewLabel:r,previewTitle:s})=>({table({children:n,...o}){return a.jsx(dt,{className:o.className,children:n})},h1({children:n,...o}){return a.jsx("h1",{...o,className:F("typography-markdown-h1 mt-4 mb-2 text-[var(--markdown-heading1,var(--primary))] font-semibold",o.className),children:n})},h2({children:n,...o}){return a.jsx("h2",{...o,className:F("typography-markdown-h2 mt-3.5 mb-1.5 text-[var(--markdown-heading2,var(--primary))] font-semibold",o.className),children:n})},h3({children:n,...o}){return a.jsx("h3",{...o,className:F("typography-markdown-h3 mt-3 mb-1 text-[var(--markdown-heading3,var(--primary))] font-semibold",o.className),children:n})},h4({children:n,...o}){return a.jsx("h4",{...o,className:F("typography-markdown-h4 mt-2.5 mb-1 text-[var(--markdown-heading4,var(--foreground))] font-semibold",o.className),children:n})},h5({children:n,...o}){return a.jsx("h5",{...o,className:F("typography-markdown-h4 mt-2.5 mb-1 text-[var(--markdown-heading4,var(--foreground))] font-semibold",o.className),children:n})},h6({children:n,...o}){return a.jsx("h6",{...o,className:F("typography-markdown-h4 mt-2.5 mb-1 text-[var(--markdown-heading4,var(--foreground))] font-semibold",o.className),children:n})},p({children:n,...o}){return a.jsx("p",{...o,className:F("typography-markdown-body my-2 text-foreground/90",o.className),children:n})},thead({children:n,...o}){return a.jsx("thead",{...o,className:F("[&_tr]:border-b [&_tr]:border-border/80",o.className),children:n})},tbody({children:n,...o}){return a.jsx("tbody",{...o,className:F("[&_tr:last-child]:border-0",o.className),children:n})},tr({children:n,...o}){return a.jsx("tr",{...o,className:F("border-b border-border/60",o.className),children:n})},th({children:n,...o}){return a.jsx("th",{...o,className:F("border-r border-border/60 px-4 py-2.5 text-left align-middle font-semibold text-foreground last:border-r-0",o.className),children:n})},td({children:n,...o}){return a.jsx("td",{...o,className:F("border-r border-border/60 px-4 py-2.5 align-middle text-foreground/90 last:border-r-0",o.className),children:n})},ul({children:n,...o}){return a.jsx("ul",{...o,className:F("typography-markdown-body my-2",o.className),children:n})},ol({children:n,...o}){return a.jsx("ol",{...o,className:F("typography-markdown-body my-2",o.className),children:n})},li({children:n,...o}){return a.jsx("li",{...o,className:F("typography-markdown-body my-0.5 text-foreground/90",o.className),children:n})},blockquote({children:n,...o}){return a.jsx("blockquote",{...o,className:F("my-3 border-l-2 border-[var(--markdown-blockquote-border,var(--border))] pl-4 typography-markdown-body text-[var(--markdown-blockquote,var(--muted-foreground))]",o.className),children:n})},pre({children:n,...o}){const i=C.Children.only(n),l=i.props.className,c=gt(l),d=vt(pe(i.props.children).replace(/\n$/,""),c);return c==="mermaid"?a.jsx(mt,{source:d,mode:be.getState().mermaidRenderingMode}):a.jsx(Ct,{code:d,language:c,syntaxTheme:t,...o})},code({className:n,children:o,...i}){return a.jsx("code",{...i,className:F("rounded bg-[var(--surface-elevated)] px-1 py-0.5 font-mono text-[0.95em]",n),"data-markdown":"inline-code",children:o})},a({href:n,children:o,...i}){const l=n??"",c=Le(l),d=e?rt(l):!1;return a.jsxs(a.Fragment,{children:[a.jsxs("a",{...i,href:n,target:c?"_blank":void 0,rel:c?"noopener noreferrer":void 0,children:[c?a.jsx(ot,{href:l}):null,o]}),d&&e?a.jsxs("button",{type:"button",onClick:m=>{m.preventDefault(),m.stopPropagation(),e(l)},className:"ml-1 inline-flex h-5 items-center gap-0.5 rounded border border-[var(--border)] bg-[var(--surface-background)] px-1.5 align-middle text-[11px] leading-none text-[var(--muted-foreground)] transition-colors hover:bg-[var(--surface-hover)] hover:text-[var(--foreground)]","aria-label":s??r??"Open preview pane",title:s??r??"Open preview pane","data-loopback-preview-trigger":"true",children:[a.jsx(U,{name:"eye",className:"size-3","aria-hidden":"true"}),a.jsx("span",{className:"font-medium",children:r??"Preview"})]}):null]})}}),xe=C.memo(t=>{const e=V.c(5),{block:r,components:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=[Ke,Ze],e[0]=n):n=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=[[Ge,{throwOnError:!1,errorColor:"var(--destructive)"}]],e[1]=o):o=e[1];let i;return e[2]!==r.src||e[3]!==s?(i=a.jsx(qe,{remarkPlugins:n,rehypePlugins:o,components:s,children:r.src}),e[2]=r.src,e[3]=s,e[4]=i):i=e[4],i},(t,e)=>t.block===e.block&&t.components===e.components);xe.displayName="MarkdownBlockView";const me='[data-markdown="mermaid-block"]',Ee='[data-openchamber-file-link="true"]',St=4,Rt=1e3,Tt=200,Lt=200,_t=40,G=new Map;let se=0;const je=[],Mt=()=>ge()?Tt:Rt,At=()=>ge()?_t:Lt,Ft=/^[A-Za-z]:[\\/]/,It=/^\\\\[^\\]+\\[^\\]+/,De=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),Ce=Array.from(De).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),Z=t=>{const e=(t||"").trim();if(!e)return"";const r=e.replace(/\\/g,"/"),s=r.startsWith("//");let n=r.replace(/\/+/g,"/");s&&!n.startsWith("//")&&(n=`/${n}`);const o=n==="/",i=/^[A-Za-z]:\/$/.test(n);return!o&&!i&&(n=n.replace(/\/+$/,"")),n},ze=t=>t.startsWith("/")||Ft.test(t)||It.test(t)||t.startsWith("//"),$t=(t,e)=>{const r=Z(e);if(!r)return Z(t);if(ze(r))return r;const s=Z(t);if(!s)return r;const n=/^[A-Za-z]:/.test(s),o=n?s.slice(0,2):"",l=(n?s.slice(2):s).split("/").filter(Boolean),c=r.split("/").filter(Boolean);for(const d of c)if(d!=="."){if(d===".."){l.length>0&&l.pop();continue}l.push(d)}return n?`${o}/${l.join("/")}`:`/${l.join("/")}`},ie=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):""},ue=t=>{let e=ie(t);if(!e)return"";const r=e.indexOf(";");r>=0&&(e=e.slice(0,r)),e=e.replace(/#.*$/,"");const s=e.match(/^(.*\.[A-Za-z0-9_-]{1,16}):.*$/);s&&(e=s[1]??e);const n=Ce.length>0?e.match(new RegExp(`^(.*(?:/|^)(${Ce})):.*$`,"i")):null;return n&&(e=n[1]??e),ie(e)},Oe=t=>{const e=ie(t);if(!e)return null;const r=e.indexOf(";"),s=r>=0?ie(e.slice(0,r)):e;if(!s)return null;const n=s.match(/^(.*)#L(\d+)(?:C(\d+))?$/i);if(n){const l=ue(n[1]??""),c=Number.parseInt(n[2]??"",10),d=n[3]?Number.parseInt(n[3],10):void 0;return!l||!Number.isFinite(c)?null:{path:l,line:c,column:Number.isFinite(d??Number.NaN)?d:void 0}}const o=s.match(/^(.*):(\d+)(?::(\d+))?$/);if(o){const l=ue(o[1]??""),c=Number.parseInt(o[2]??"",10),d=o[3]?Number.parseInt(o[3],10):void 0;return!l||!Number.isFinite(c)?null:{path:l,line:c,column:Number.isFinite(d??Number.NaN)?d:void 0}}const i=ue(s);return i?{path:i}:null},Pt=t=>{const e=t.split("/").filter(Boolean).pop()??"";return!e||e.endsWith(".")?!1:/\.[A-Za-z0-9_-]{1,16}$/.test(e)},Be=t=>{if(!t||t.startsWith("--")||t.includes("://")||/[<>]/.test(t)||/\s{2,}/.test(t))return!1;const e=Z(t),r=e.split("/").filter(Boolean).pop()??e;if(!r||r==="."||r==="..")return!1;const s=r.toLowerCase();return De.has(s)||s.startsWith(".")&&s.length>1?!0:Pt(e)},Dt=t=>{const e=Oe(t);return e?Be(e.path):!1},fe=t=>{if(t.tagName.toLowerCase()==="a"){const e=t.getAttribute("href")?.trim();if(e&&Dt(e))return e}return(t.textContent||"").trim()},he=(t,e)=>{const r=Oe(t);if(!r||!Be(r.path))return null;const s=ze(r.path)?Z(r.path):$t(e,r.path);return s?{...r,resolvedPath:s}:null},zt=t=>{const e=Z(t);if(!e)return Promise.resolve(!1);const r=G.get(e);if(r)return G.delete(e),G.set(e,r),r;const s=new Promise(o=>{const i=()=>{se+=1,fetch(`/api/fs/stat?path=${encodeURIComponent(e)}`,{method:"GET",cache:"no-store"}).then(l=>o(l.ok)).catch(()=>o(!1)).finally(()=>{se=Math.max(0,se-1),je.shift()?.()})};if(se<St){i();return}je.push(i)}),n=Mt();for(;G.size>=n;){const o=G.keys().next().value;if(typeof o!="string")break;G.delete(o)}return G.set(e,s),s},Ot=(t,e)=>{const r=Z(t);if(r)return r;const s=Z(e);return s.replace(/\/[^/]*$/,"")||s},He=t=>{const e=V.c(7),{containerRef:r,effectiveDirectory:s,editor:n,preferRuntimeEditor:o,enabled:i}=t,l=C.useRef(null);let c,d;e[0]!==r||e[1]!==n||e[2]!==s||e[3]!==i||e[4]!==o?(c=()=>{const m=r.current;if(!m)return;let g=!1;const h=At(),p=Vt,k=()=>{const w=m.querySelectorAll(Ee);for(const y of Array.from(w))p(y)};if(!i){k();return}const v=()=>{const w=m.querySelectorAll('[data-markdown="inline-code"], a');let y=0;for(const f of Array.from(w)){const j=fe(f),S=he(j,s);p(f),S&&(y>=h||(y=y+1,zt(S.resolvedPath).then(B=>{if(g||!B||!m.contains(f))return;const A=fe(f),$=he(A,s);!$||$.resolvedPath!==S.resolvedPath||(f.setAttribute("data-openchamber-file-link","true"),f.setAttribute("data-openchamber-file-ref",A),f.setAttribute("data-openchamber-file-path",$.resolvedPath),f.setAttribute("title","Open file"),f.tagName.toLowerCase()!=="a"&&(f.setAttribute("role","button"),f.setAttribute("tabindex","0")))})))}},x=w=>{const y=w.getAttribute("data-openchamber-file-ref")||fe(w),f=he(y,s);if(!f)return;const j=Ot(s,f.resolvedPath);if(o&&n){n.openFile(f.resolvedPath,Number.isFinite(f.line??Number.NaN)?Math.max(1,Math.trunc(f.line)):void 0,Number.isFinite(f.column??Number.NaN)?Math.max(1,Math.trunc(f.column)):void 0);return}const S=be.getState();Number.isFinite(f.line??Number.NaN)?S.openContextFileAtLine(j,f.resolvedPath,Math.max(1,Math.trunc(f.line)),Number.isFinite(f.column??Number.NaN)?Math.max(1,Math.trunc(f.column)):1):S.openContextFile(j,f.resolvedPath)},u=w=>{const y=w.target;if(!(y instanceof Element))return;const f=y.closest(Ee);f instanceof HTMLElement&&(w.preventDefault(),w.stopPropagation(),x(f))},M=w=>{if(w.key!=="Enter"&&w.key!==" ")return;const y=w.target;!(y instanceof HTMLElement)||y.getAttribute("data-openchamber-file-link")!=="true"||(w.preventDefault(),w.stopPropagation(),x(y))};v();const T=new MutationObserver(()=>{if(l.current!==null&&typeof window<"u"&&window.clearTimeout(l.current),typeof window>"u"){v();return}l.current=window.setTimeout(()=>{l.current=null,v()},120)});return T.observe(m,{childList:!0,subtree:!0}),m.addEventListener("click",u),m.addEventListener("keydown",M),()=>{g=!0,l.current!==null&&typeof window<"u"&&window.clearTimeout(l.current),l.current=null,T.disconnect(),m.removeEventListener("click",u),m.removeEventListener("keydown",M)}},d=[r,n,s,o,i],e[0]=r,e[1]=n,e[2]=s,e[3]=i,e[4]=o,e[5]=c,e[6]=d):(c=e[5],d=e[6]),C.useEffect(c,d)},We=t=>{const e=V.c(6),{containerRef:r,mermaidBlocks:s,onShowPopup:n,allowWheelZoom:o}=t;let i,l;e[0]!==o||e[1]!==r||e[2]!==s||e[3]!==n?(i=()=>{const c=r.current;if(!c)return;const d=g=>{if(!n)return;const h=g.target;if(!(h instanceof Element)||h.closest('button, a, [role="button"]'))return;const p=h.closest(me);if(!p)return;const v=Array.from(c.querySelectorAll(me)).indexOf(p);if(v<0)return;const x=s[v];if(!x||x.trim().length===0)return;const u=`Diagram ${v+1}`;n({open:!0,title:u,content:"",metadata:{tool:"mermaid-preview",filename:u},mermaid:{url:`data:text/plain;charset=utf-8,${encodeURIComponent(x)}`,source:x,filename:u}})},m=g=>{if(o)return;const h=g.target;!(h instanceof Element)||!h.closest(me)||g.stopPropagation()};return c.addEventListener("click",d),c.addEventListener("wheel",m,{capture:!0,passive:!0}),()=>{c.removeEventListener("click",d),c.removeEventListener("wheel",m,!0)}},l=[o,r,s,n],e[0]=o,e[1]=r,e[2]=s,e[3]=n,e[4]=i,e[5]=l):(i=e[4],l=e[5]),C.useEffect(i,l)},Bt=t=>{const e=V.c(42),{content:r,part:s,messageId:n,isAnimated:o,skipFadeIn:i,className:l,isStreaming:c,disableStreamAnimation:d,variant:m,onShowPopup:g,enableFileReferences:h}=t,p=o===void 0?!0:o,k=i===void 0?!1:i,v=c===void 0?!1:c,x=d===void 0?!1:d,u=m===void 0?"assistant":m,M=h===void 0?!0:h,T=ve(),{editor:w,runtime:y}=Se(),f=C.useRef(null),j=Re()??"";let S;e[0]!==r?(S=Ie(r),e[0]=r,e[1]=S):S=e[1];const B=S;let A;e[2]!==B||e[3]!==g?(A={containerRef:f,mermaidBlocks:B,onShowPopup:g},e[2]=B,e[3]=g,e[4]=A):A=e[4],We(A);const $=M&&!v;let z;e[5]!==w||e[6]!==j||e[7]!==y.isVSCode||e[8]!==$?(z={containerRef:f,effectiveDirectory:j,editor:w,preferRuntimeEditor:y.isVSCode,enabled:$},e[5]=w,e[6]=j,e[7]=y.isVSCode,e[8]=$,e[9]=z):z=e[9],He(z);let P;e[10]===Symbol.for("react.memo_cache_sentinel")?(P={containerRef:f},e[10]=P):P=e[10],Me(P);const D=be(qt),{t:I}=le();let W;e[11]!==j||e[12]!==D?(W=q=>{j&&D(j,q)},e[11]=j,e[12]=D,e[13]=W):W=e[13];const b=W;let E;e[14]!==I?(E=I("terminalView.preview.open"),e[14]=I,e[15]=E):E=e[15];const N=E;let R;e[16]!==I?(R=I("terminalView.preview.openTitle"),e[16]=I,e[17]=R):R=e[17];const L=R;let _;e[18]!==T?(_=Te(T),e[18]=T,e[19]=_):_=e[19];const O=_,H=j?b:void 0;let K;e[20]!==N||e[21]!==L||e[22]!==O||e[23]!==H?(K=Pe({syntaxTheme:O,onPreviewLoopback:H,previewLabel:N,previewTitle:L}),e[20]=N,e[21]=L,e[22]=O,e[23]=H,e[24]=K):K=e[24];const Q=K,ee=`markdown-${s?.id?`part-${s.id}`:`message-${n}`}`,ce=$e(r,v&&!x,ee),de=u==="tool"?"markdown-content markdown-tool":u==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed";let X;e[25]!==l?(X=F("break-words w-full min-w-0",l),e[25]=l,e[26]=X):X=e[26];let Y;if(e[27]!==ce||e[28]!==Q){let q;e[30]!==Q?(q=ke=>a.jsx(xe,{block:ke,components:Q},ke.key),e[30]=Q,e[31]=q):q=e[31],Y=ce.map(q),e[27]=ce,e[28]=Q,e[29]=Y}else Y=e[29];let J;e[32]!==de||e[33]!==Y?(J=a.jsx("div",{className:de,children:Y}),e[32]=de,e[33]=Y,e[34]=J):J=e[34];let te;e[35]!==X||e[36]!==J?(te=a.jsx("div",{className:X,ref:f,children:J}),e[35]=X,e[36]=J,e[37]=te):te=e[37];const re=te;if(p){let q;return e[38]!==ee||e[39]!==re||e[40]!==k?(q=a.jsx(et,{skipAnimation:k,children:re},ee),e[38]=ee,e[39]=re,e[40]=k,e[41]=q):q=e[41],q}return re},Xt=C.memo(Bt,(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.part?.id===e.part?.id),Ht=t=>{const e=V.c(33),{content:r,className:s,variant:n,disableLinkSafety:o,stripFrontmatter:i,onShowPopup:l,allowMermaidWheelZoom:c,enableFileReferences:d}=t,m=n===void 0?"assistant":n,g=i===void 0?!1:i,h=c===void 0?!1:c,p=d===void 0?!0:d,{editor:k,runtime:v}=Se();let x;e[0]!==r||e[1]!==g?(x=g?ut(r):r,e[0]=r,e[1]=g,e[2]=x):x=e[2];const u=x,M=ve(),T=C.useRef(null),w=Re()??"";let y;e[3]!==u?(y=Ie(u),e[3]=u,e[4]=y):y=e[4];const f=y;let j;e[5]!==h||e[6]!==f||e[7]!==l?(j={containerRef:T,mermaidBlocks:f,onShowPopup:l,allowWheelZoom:h},e[5]=h,e[6]=f,e[7]=l,e[8]=j):j=e[8],We(j);let S;e[9]!==k||e[10]!==w||e[11]!==p||e[12]!==v.isVSCode?(S={containerRef:T,effectiveDirectory:w,editor:k,preferRuntimeEditor:v.isVSCode,enabled:p},e[9]=k,e[10]=w,e[11]=p,e[12]=v.isVSCode,e[13]=S):S=e[13],He(S);const B=!o;let A;e[14]!==B?(A={containerRef:T,enabled:B},e[14]=B,e[15]=A):A=e[15],Me(A);let $;e[16]!==M?($=Te(M),e[16]=M,e[17]=$):$=e[17];const z=$;let P;e[18]!==z?(P=Pe({syntaxTheme:z}),e[18]=z,e[19]=P):P=e[19];const D=P,I=$e(u,!1,`simple:${m}`),W=m==="tool"?"markdown-content markdown-tool":m==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed";let b;e[20]!==s?(b=F("break-words w-full min-w-0",s),e[20]=s,e[21]=b):b=e[21];let E;if(e[22]!==I||e[23]!==D){let L;e[25]!==D?(L=_=>a.jsx(xe,{block:_,components:D},_.key),e[25]=D,e[26]=L):L=e[26],E=I.map(L),e[22]=I,e[23]=D,e[24]=E}else E=e[24];let N;e[27]!==W||e[28]!==E?(N=a.jsx("div",{className:W,children:E}),e[27]=W,e[28]=E,e[29]=N):N=e[29];let R;return e[30]!==b||e[31]!==N?(R=a.jsx("div",{className:b,ref:T,children:N}),e[30]=b,e[31]=N,e[32]=R):R=e[32],R},Yt=C.memo(Ht,(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 Wt(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 r=e.closest("a[href]");if(!(r instanceof HTMLAnchorElement)||r.getAttribute("data-openchamber-file-link")==="true")return;const s=r.getAttribute("href")??"";Le(s)&&(t.preventDefault(),t.stopPropagation(),tt(s))}function Ut(t){return t==="preview"?"code":"preview"}function Vt(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 qt(t){return t.openContextPreview}export{Xt as MarkdownRenderer,Yt as SimpleMarkdownRenderer};
|
|
5
|
+
`)},it=(t,e,r)=>{const s=new Blob([e],{type:r}),n=URL.createObjectURL(s),o=document.createElement("a");o.href=n,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)},lt=t=>{const e=U.c(20),{tableRef:r}=t,{t:s}=le(),[n,o]=C.useState(!1),[i,l]=C.useState(!1),c=C.useRef(null);let d,m;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{const T=w=>{c.current&&!c.current.contains(w.target)&&l(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},m=[],e[0]=d,e[1]=m):(d=e[0],m=e[1]),C.useEffect(d,m);let g;e[2]!==r?(g=async T=>{const w=r.current?.querySelector("table");if(!w)return;const y=Ae(w),f=T==="csv"?Fe(y):st(y);try{await navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([f],{type:"text/plain"}),"text/html":new Blob([w.outerHTML],{type:"text/html"})})]),o(!0),l(!1),setTimeout(()=>o(!1),2e3)}catch(j){const S=j;if((await ae(f)).ok){o(!0),l(!1),setTimeout(()=>o(!1),2e3);return}console.error("Failed to copy table:",S)}},e[2]=r,e[3]=g):g=e[3];const h=g;let p;e[4]!==i?(p=()=>l(!i),e[4]=i,e[5]=p):p=e[5];let k;e[6]!==s?(k=s("markdownRenderer.table.actions.copyTitle"),e[6]=s,e[7]=k):k=e[7];let v;e[8]!==n?(v=n?a.jsx(V,{name:"check",className:"size-3.5"}):a.jsx(V,{name:"file-copy",className:"size-3.5"}),e[8]=n,e[9]=v):v=e[9];let x;e[10]!==p||e[11]!==k||e[12]!==v?(x=a.jsx("button",{onClick:p,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:k,children:v}),e[10]=p,e[11]=k,e[12]=v,e[13]=x):x=e[13];let u;e[14]!==h||e[15]!==i?(u=i&&a.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[100px] overflow-hidden rounded-md border border-border bg-background shadow-none",children:[a.jsx("button",{className:"w-full px-3 py-1.5 text-left text-sm transition-colors hover:bg-interactive-hover/40",onClick:()=>h("csv"),children:"CSV"}),a.jsx("button",{className:"w-full px-3 py-1.5 text-left text-sm transition-colors hover:bg-interactive-hover/40",onClick:()=>h("tsv"),children:"TSV"})]}),e[14]=h,e[15]=i,e[16]=u):u=e[16];let M;return e[17]!==x||e[18]!==u?(M=a.jsxs("div",{className:"relative",ref:c,children:[x,u]}),e[17]=x,e[18]=u,e[19]=M):M=e[19],M},ct=t=>{const e=U.c(19),{tableRef:r}=t,{t:s}=le(),[n,o]=C.useState(!1),i=C.useRef(null);let l,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{const u=M=>{i.current&&!i.current.contains(M.target)&&o(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},c=[],e[0]=l,e[1]=c):(l=e[0],c=e[1]),C.useEffect(l,c);let d;e[2]!==s||e[3]!==r?(d=u=>{const M=r.current?.querySelector("table");if(!M)return;const T=Ae(M),w=u==="csv"?Fe(T):at(T);it(u==="csv"?"table.csv":"table.md",w,u==="csv"?"text/csv":"text/markdown"),o(!1),_e.success(s("markdownRenderer.table.toast.downloadedAsFormat",{format:u.toUpperCase()}))},e[2]=s,e[3]=r,e[4]=d):d=e[4];const m=d;let g;e[5]!==n?(g=()=>o(!n),e[5]=n,e[6]=g):g=e[6];let h;e[7]!==s?(h=s("markdownRenderer.table.actions.downloadTitle"),e[7]=s,e[8]=h):h=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(V,{name:"download",className:"size-3.5"}),e[9]=p):p=e[9];let k;e[10]!==g||e[11]!==h?(k=a.jsx("button",{onClick:g,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:h,children:p}),e[10]=g,e[11]=h,e[12]=k):k=e[12];let v;e[13]!==m||e[14]!==n?(v=n&&a.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[100px] overflow-hidden rounded-md border border-border bg-background shadow-none",children:[a.jsx("button",{className:"w-full px-3 py-1.5 text-left text-sm transition-colors hover:bg-interactive-hover/40",onClick:()=>m("csv"),children:"CSV"}),a.jsx("button",{className:"w-full px-3 py-1.5 text-left text-sm transition-colors hover:bg-interactive-hover/40",onClick:()=>m("markdown"),children:"Markdown"})]}),e[13]=m,e[14]=n,e[15]=v):v=e[15];let x;return e[16]!==k||e[17]!==v?(x=a.jsxs("div",{className:"relative",ref:i,children:[k,v]}),e[16]=k,e[17]=v,e[18]=x):x=e[18],x},dt=t=>{const e=U.c(14),{children:r,className:s}=t,n=C.useRef(null),{isMobile:o,isTablet:i}=we(),c=o||i?"opacity-100":"opacity-0 group-hover:opacity-100";let d;e[0]!==c?(d=F("flex items-center justify-end gap-1 transition-opacity",c),e[0]=c,e[1]=d):d=e[1];let m,g;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=a.jsx(lt,{tableRef:n}),g=a.jsx(ct,{tableRef:n}),e[2]=m,e[3]=g):(m=e[2],g=e[3]);let h;e[4]!==d?(h=a.jsxs("div",{className:d,children:[m,g]}),e[4]=d,e[5]=h):h=e[5];let p;e[6]!==s?(p=F("w-full border-collapse text-sm",s),e[6]=s,e[7]=p):p=e[7];let k;e[8]!==r||e[9]!==p?(k=a.jsx("div",{className:"overflow-x-auto rounded-lg border border-border/80 bg-[var(--surface-elevated)]",children:a.jsx("table",{className:p,"data-markdown":"table",children:r})}),e[8]=r,e[9]=p,e[10]=k):k=e[10];let v;return e[11]!==h||e[12]!==k?(v=a.jsxs("div",{className:"group my-4 flex flex-col space-y-2","data-markdown":"table-wrapper",ref:n,children:[h,k]}),e[11]=h,e[12]=k,e[13]=v):v=e[13],v},mt=t=>{const e=U.c(83),{source:r,mode:s}=t,{t:n}=le(),o=ve(),{isMobile:i,isTablet:l}=we(),[c,d]=C.useState(!1),[m,g]=C.useState(!1);let h;e:{if(s!=="svg"){h="";break e}try{let b;e[0]!==o.colors.interactive.border||e[1]!==o.colors.primary.base||e[2]!==o.colors.surface.elevated||e[3]!==o.colors.surface.foreground||e[4]!==o.colors.surface.muted||e[5]!==o.colors.surface.mutedForeground||e[6]!==r?(b=Xe(r,{bg:o.colors.surface.elevated,fg:o.colors.surface.foreground,line:o.colors.interactive.border,accent:o.colors.primary.base,muted:o.colors.surface.mutedForeground,surface:o.colors.surface.muted,border:o.colors.interactive.border,transparent:!0,font:"IBM Plex Sans, sans-serif"}),e[0]=o.colors.interactive.border,e[1]=o.colors.primary.base,e[2]=o.colors.surface.elevated,e[3]=o.colors.surface.foreground,e[4]=o.colors.surface.muted,e[5]=o.colors.surface.mutedForeground,e[6]=r,e[7]=b):b=e[7],h=b}catch{h=""}}const p=h;let k;e:{if(s!=="ascii"){k="";break e}try{let b;e[8]!==r?(b=Ye(r),e[8]=r,e[9]=b):b=e[9],k=b}catch{k=""}}const v=k,x=i||l?"opacity-100":"opacity-0 group-hover:opacity-100";let u;e[10]===Symbol.for("react.memo_cache_sentinel")?(u=async b=>{if(!b)return;(await ae(b)).ok&&(d(!0),setTimeout(()=>d(!1),2e3))},e[10]=u):u=e[10];const M=u;let T;e[11]!==r?(T=async()=>{if(!r)return;(await ae(r)).ok&&(d(!0),setTimeout(()=>d(!1),2e3))},e[11]=r,e[12]=T):T=e[12];const w=T;let y;e[13]!==p||e[14]!==n?(y=()=>{if(p)try{const b=new Blob([p],{type:"image/svg+xml;charset=utf-8"}),E=URL.createObjectURL(b),N=document.createElement("a");N.href=E,N.download=`diagram-${Date.now()}.svg`,document.body.appendChild(N),N.click(),document.body.removeChild(N),URL.revokeObjectURL(E),g(!0),setTimeout(()=>g(!1),2e3)}catch{_e.error(n("markdownRenderer.mermaid.toast.downloadFailed"))}},e[13]=p,e[14]=n,e[15]=y):y=e[15];const f=y;if(s==="ascii"){const b=v||r;let E;e[16]!==b?(E=a.jsx("div",{"data-markdown":"mermaid-scroll",children:a.jsx("pre",{"data-markdown":"mermaid-ascii",children:b})}),e[16]=b,e[17]=E):E=e[17];let N;e[18]!==x?(N=F("absolute top-1 right-2 transition-opacity",x),e[18]=x,e[19]=N):N=e[19];let R;e[20]!==b?(R=()=>M(b),e[20]=b,e[21]=R):R=e[21];let L;e[22]!==n?(L=n("markdownRenderer.mermaid.actions.copyTitle"),e[22]=n,e[23]=L):L=e[23];let _;e[24]!==c?(_=c?a.jsx(V,{name:"check",className:"size-3.5"}):a.jsx(V,{name:"file-copy",className:"size-3.5"}),e[24]=c,e[25]=_):_=e[25];let O;e[26]!==_||e[27]!==R||e[28]!==L?(O=a.jsx("button",{onClick:R,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:L,children:_}),e[26]=_,e[27]=R,e[28]=L,e[29]=O):O=e[29];let H;e[30]!==O||e[31]!==N?(H=a.jsx("div",{className:N,children:O}),e[30]=O,e[31]=N,e[32]=H):H=e[32];let K;return e[33]!==H||e[34]!==E?(K=a.jsxs("div",{"data-markdown":"mermaid-block",className:"group",children:[E,H]}),e[33]=H,e[34]=E,e[35]=K):K=e[35],K}if(!p){let b;e[36]!==r?(b=a.jsx("div",{"data-markdown":"mermaid-scroll",children:a.jsx("pre",{"data-markdown":"mermaid-ascii",children:r})}),e[36]=r,e[37]=b):b=e[37];let E;e[38]!==x?(E=F("absolute top-1 right-2 transition-opacity",x),e[38]=x,e[39]=E):E=e[39];let N;e[40]!==r?(N=()=>M(r),e[40]=r,e[41]=N):N=e[41];let R;e[42]!==n?(R=n("markdownRenderer.mermaid.actions.copyTitle"),e[42]=n,e[43]=R):R=e[43];let L;e[44]!==c?(L=c?a.jsx(V,{name:"check",className:"size-3.5"}):a.jsx(V,{name:"file-copy",className:"size-3.5"}),e[44]=c,e[45]=L):L=e[45];let _;e[46]!==L||e[47]!==N||e[48]!==R?(_=a.jsx("button",{onClick:N,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:R,children:L}),e[46]=L,e[47]=N,e[48]=R,e[49]=_):_=e[49];let O;e[50]!==_||e[51]!==E?(O=a.jsx("div",{className:E,children:_}),e[50]=_,e[51]=E,e[52]=O):O=e[52];let H;return e[53]!==O||e[54]!==b?(H=a.jsxs("div",{"data-markdown":"mermaid-block",className:"group",children:[b,O]}),e[53]=O,e[54]=b,e[55]=H):H=e[55],H}let j;e[56]!==p?(j=a.jsx("div",{"data-markdown":"mermaid-scroll",children:a.jsx("div",{"data-markdown":"mermaid",dangerouslySetInnerHTML:{__html:p}})}),e[56]=p,e[57]=j):j=e[57];let S;e[58]!==x?(S=F("absolute top-1 right-2 flex items-center gap-1 transition-opacity",x),e[58]=x,e[59]=S):S=e[59];let B;e[60]!==n?(B=n("markdownRenderer.mermaid.actions.copySourceTitle"),e[60]=n,e[61]=B):B=e[61];let A;e[62]!==c?(A=c?a.jsx(V,{name:"check",className:"size-3.5"}):a.jsx(V,{name:"file-copy",className:"size-3.5"}),e[62]=c,e[63]=A):A=e[63];let $;e[64]!==w||e[65]!==B||e[66]!==A?($=a.jsx("button",{onClick:w,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:B,children:A}),e[64]=w,e[65]=B,e[66]=A,e[67]=$):$=e[67];let z;e[68]!==n?(z=n("markdownRenderer.mermaid.actions.downloadSvgTitle"),e[68]=n,e[69]=z):z=e[69];let P;e[70]!==m?(P=m?a.jsx(V,{name:"check",className:"size-3.5"}):a.jsx(V,{name:"download",className:"size-3.5"}),e[70]=m,e[71]=P):P=e[71];let D;e[72]!==f||e[73]!==z||e[74]!==P?(D=a.jsx("button",{onClick:f,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:z,children:P}),e[72]=f,e[73]=z,e[74]=P,e[75]=D):D=e[75];let I;e[76]!==$||e[77]!==D||e[78]!==S?(I=a.jsxs("div",{className:S,children:[$,D]}),e[76]=$,e[77]=D,e[78]=S,e[79]=I):I=e[79];let W;return e[80]!==I||e[81]!==j?(W=a.jsxs("div",{"data-markdown":"mermaid-block",className:"group",children:[j,I]}),e[80]=I,e[81]=j,e[82]=W):W=e[82],W},Ie=t=>{if(!t.includes("mermaid"))return[];const e=[],r=/(?:^|\r?\n)(`{3,}|~{3,})mermaid[^\n\r]*\r?\n([\s\S]*?)\r?\n\1(?=\r?\n|$)/gi;let s=r.exec(t);for(;s;){const n=(s[2]??"").replace(/\s+$/,"");e.push(n),s=r.exec(t)}return e},ut=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},ft=t=>/^\[[^\]]+\]:\s+\S+/m.test(t)||/^\[\^[^\]]+\]:\s+/m.test(t),ht=t=>{const e=t.match(/^[ \t]{0,3}(`{3,}|~{3,})/);if(!e)return!1;const r=e[1];if(!r)return!1;const s=r[0],n=r.length,o=t.trimEnd().split(`
|
|
6
|
+
`).at(-1)?.trim()??"";return!new RegExp(`^[\\t ]{0,3}${s}{${n},}[\\t ]*$`).test(o)},Ne=t=>Ue(t,{linkMode:"text-only"}),pt=t=>{let e=2166136261;for(let r=0;r<t.length;r+=1)e^=t.charCodeAt(r),e=e+((e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24))>>>0;return e.toString(16)},ne=(t,e,r,s)=>{const n=e.length>400?`${e.slice(0,200)}${e.slice(-200)}`:e;return`${t}:${r}:${s}:${e.length}:${pt(n)}`},bt=(t,e,r)=>{if(!e)return[{key:ne(r,t,0,"full"),raw:t,src:t,mode:"full"}];const s=Ne(t);if(ft(t))return[{key:ne(r,t,0,"live"),raw:t,src:s,mode:"live"}];const n=Ve.lexer(t),o=[];let i=0;for(let l=0;l<n.length;l+=1){const c=n[l];if(c.type==="space")continue;const d=c.raw??"",m=l===n.length-1||n.slice(l+1).every(p=>p.type==="space"),g=m?"live":"full",h=m&&c.type==="code"&&ht(d)?d:Ne(d);o.push({key:ne(r,d,i,g),raw:d,src:h,mode:g}),i+=1}return o.length===0?[{key:ne(r,t,0,"live"),raw:t,src:s,mode:"live"}]:o},$e=(t,e,r)=>{const s=C.useRef([]);return C.useMemo(()=>{const n=bt(t,e,r),o=s.current,i=n.map((c,d)=>{const m=o[d];return m&&m.key===c.key&&m.src===c.src?m:c});return i.length===o.length&&i.every((c,d)=>c===o[d])?o:(s.current=i,i)},[r,e,t])},pe=t=>typeof t=="string"?t:Array.isArray(t)?t.map(e=>pe(e)).join(""):C.isValidElement(t)?pe(t.props.children):"",gt=t=>t?.match(/language-([\w-]+)/)?.[1]?.toLowerCase()??"text",wt=t=>{let e=t;for(let r=0;r<3;r+=1){const s=e.replace(/"/g,'"').replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&");if(s===e)return e;e=s}return e},vt=(t,e)=>!["json","jsonc","json5"].includes(e)||!/&(quot|#34|amp;quot|lt|gt|amp|apos|#39);/.test(t)?t:wt(t),xt=300,kt=1200,yt=200,oe={margin:0,background:"transparent",padding:0,fontSize:"var(--text-code)",lineHeight:"var(--markdown-code-block-line-height)"},Nt=(t,e)=>{let r=1;for(let s=0;s<t.length;s+=1)if(t.charCodeAt(s)===10&&(r+=1,r>e))return!0;return!1},Et=()=>ge()?yt:kt,jt=(t,e,r)=>{if(!(typeof window>"u"))try{const s=new Blob([t],{type:r}),n=URL.createObjectURL(s),o=document.createElement("a");o.href=n,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)}catch{}},Ct=t=>{const e=U.c(52),{code:r,language:s,syntaxTheme:n}=t,[o,i]=C.useState(!1),[l,c]=C.useState(!0),[d,m]=C.useState("code"),g=C.useRef(r),h=C.useRef(null),{isMobile:p,isTablet:k}=we();let v;e[0]!==r?(v=Nt(r,Et()),e[0]=r,e[1]=v):v=e[1];const x=v,u=s==="html"||s==="htm";let M,T;e[2]!==u||e[3]!==d?(M=()=>{!u&&d!=="code"&&m("code")},T=[u,d],e[2]=u,e[3]=d,e[4]=M,e[5]=T):(M=e[4],T=e[5]),C.useEffect(M,T);let w,y;e[6]!==r?(w=()=>{if(g.current!==r)return g.current=r,h.current&&clearTimeout(h.current),c(!1),h.current=setTimeout(()=>{c(!0),h.current=null},xt),()=>{h.current&&(clearTimeout(h.current),h.current=null)}},y=[r],e[6]=r,e[7]=w,e[8]=y):(w=e[7],y=e[8]),C.useEffect(w,y);let f;e[9]!==r?(f=async()=>{(await ae(r)).ok&&(i(!0),window.setTimeout(()=>i(!1),2e3))},e[9]=r,e[10]=f):f=e[10];const j=f;let S;e[11]!==u||e[12]!==r?(S=()=>{if(!u)return;const H=Date.now().toString(36);jt(r,`preview-${H}.html`,"text/html;charset=utf-8")},e[11]=u,e[12]=r,e[13]=S):S=e[13];const B=S;let A;e[14]!==s?(A=a.jsx("span",{className:"font-mono text-[13px] text-muted-foreground",children:s}),e[14]=s,e[15]=A):A=e[15];const $=p||k?"opacity-100":"opacity-100 md:opacity-0 md:group-hover:opacity-100";let z;e[16]!==$?(z=F("flex items-center gap-1 transition-opacity",$),e[16]=$,e[17]=z):z=e[17];let P;e[18]!==u||e[19]!==d?(P=u?a.jsx("button",{type:"button",onClick:()=>m(Vt),className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:d==="preview"?"Show code":"Preview","aria-pressed":d==="preview","aria-label":d==="preview"?"Show code":"Preview HTML",children:d==="preview"?a.jsx(V,{name:"code",className:"size-3.5"}):a.jsx(V,{name:"eye",className:"size-3.5"})}):null,e[18]=u,e[19]=d,e[20]=P):P=e[20];let D;e[21]!==u||e[22]!==B?(D=u?a.jsx("button",{type:"button",onClick:B,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:"Download HTML","aria-label":"Download HTML",children:a.jsx(V,{name:"download",className:"size-3.5"})}):null,e[21]=u,e[22]=B,e[23]=D):D=e[23];let I;e[24]!==j?(I=()=>{j()},e[24]=j,e[25]=I):I=e[25];const W=o?"Copied":"Copy code",b=o?"Copied":"Copy code";let E;e[26]!==o?(E=o?a.jsx(V,{name:"check",className:"size-3.5"}):a.jsx(V,{name:"file-copy",className:"size-3.5"}),e[26]=o,e[27]=E):E=e[27];let N;e[28]!==I||e[29]!==W||e[30]!==b||e[31]!==E?(N=a.jsx("button",{type:"button",onClick:I,className:"p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",title:W,"aria-label":b,children:E}),e[28]=I,e[29]=W,e[30]=b,e[31]=E,e[32]=N):N=e[32];let R;e[33]!==z||e[34]!==P||e[35]!==D||e[36]!==N?(R=a.jsxs("div",{className:z,children:[P,D,N]}),e[33]=z,e[34]=P,e[35]=D,e[36]=N,e[37]=R):R=e[37];let L;e[38]!==R||e[39]!==A?(L=a.jsxs("div",{className:"flex items-center justify-between border-b border-border/70 px-3 py-1.5",children:[A,R]}),e[38]=R,e[39]=A,e[40]=L):L=e[40];let _;e[41]!==u||e[42]!==r||e[43]!==l||e[44]!==s||e[45]!==x||e[46]!==n||e[47]!==d?(_=u&&d==="preview"?a.jsx("div",{className:"h-[320px] md:h-[420px] bg-background",children:a.jsx("iframe",{srcDoc:r,title:"HTML preview",className:"h-full w-full border-0",sandbox:"allow-scripts allow-forms"})}):a.jsx("div",{className:"px-3 py-2.5",children:l&&!x?a.jsx(Je,{language:s,style:n,customStyle:oe,codeTagProps:{style:oe},PreTag:"pre",children:r}):a.jsx("pre",{style:oe,children:a.jsx("code",{style:oe,children:r})})}),e[41]=u,e[42]=r,e[43]=l,e[44]=s,e[45]=x,e[46]=n,e[47]=d,e[48]=_):_=e[48];let O;return e[49]!==L||e[50]!==_?(O=a.jsxs("div",{"data-component":"markdown-code",className:"my-4 group overflow-hidden rounded-2xl border border-border/80 bg-[var(--surface-elevated)]",children:[L,_]}),e[49]=L,e[50]=_,e[51]=O):O=e[51],O},Pe=({syntaxTheme:t,onPreviewLoopback:e,previewLabel:r,previewTitle:s})=>({table({children:n,...o}){return a.jsx(dt,{className:o.className,children:n})},h1({children:n,...o}){return a.jsx("h1",{...o,className:F("typography-markdown-h1 mt-4 mb-2 text-[var(--markdown-heading1,var(--primary))] font-semibold",o.className),children:n})},h2({children:n,...o}){return a.jsx("h2",{...o,className:F("typography-markdown-h2 mt-3.5 mb-1.5 text-[var(--markdown-heading2,var(--primary))] font-semibold",o.className),children:n})},h3({children:n,...o}){return a.jsx("h3",{...o,className:F("typography-markdown-h3 mt-3 mb-1 text-[var(--markdown-heading3,var(--primary))] font-semibold",o.className),children:n})},h4({children:n,...o}){return a.jsx("h4",{...o,className:F("typography-markdown-h4 mt-2.5 mb-1 text-[var(--markdown-heading4,var(--foreground))] font-semibold",o.className),children:n})},h5({children:n,...o}){return a.jsx("h5",{...o,className:F("typography-markdown-h4 mt-2.5 mb-1 text-[var(--markdown-heading4,var(--foreground))] font-semibold",o.className),children:n})},h6({children:n,...o}){return a.jsx("h6",{...o,className:F("typography-markdown-h4 mt-2.5 mb-1 text-[var(--markdown-heading4,var(--foreground))] font-semibold",o.className),children:n})},p({children:n,...o}){return a.jsx("p",{...o,className:F("typography-markdown-body my-2 text-foreground/90",o.className),children:n})},thead({children:n,...o}){return a.jsx("thead",{...o,className:F("[&_tr]:border-b [&_tr]:border-border/80",o.className),children:n})},tbody({children:n,...o}){return a.jsx("tbody",{...o,className:F("[&_tr:last-child]:border-0",o.className),children:n})},tr({children:n,...o}){return a.jsx("tr",{...o,className:F("border-b border-border/60",o.className),children:n})},th({children:n,...o}){return a.jsx("th",{...o,className:F("border-r border-border/60 px-4 py-2.5 text-left align-middle font-semibold text-foreground last:border-r-0",o.className),children:n})},td({children:n,...o}){return a.jsx("td",{...o,className:F("border-r border-border/60 px-4 py-2.5 align-middle text-foreground/90 last:border-r-0",o.className),children:n})},ul({children:n,...o}){return a.jsx("ul",{...o,className:F("typography-markdown-body my-2",o.className),children:n})},ol({children:n,...o}){return a.jsx("ol",{...o,className:F("typography-markdown-body my-2",o.className),children:n})},li({children:n,...o}){return a.jsx("li",{...o,className:F("typography-markdown-body my-0.5 text-foreground/90",o.className),children:n})},blockquote({children:n,...o}){return a.jsx("blockquote",{...o,className:F("my-3 border-l-2 border-[var(--markdown-blockquote-border,var(--border))] pl-4 typography-markdown-body text-[var(--markdown-blockquote,var(--muted-foreground))]",o.className),children:n})},pre({children:n,...o}){const i=C.Children.only(n),l=i.props.className,c=gt(l),d=vt(pe(i.props.children).replace(/\n$/,""),c);return c==="mermaid"?a.jsx(mt,{source:d,mode:be.getState().mermaidRenderingMode}):a.jsx(Ct,{code:d,language:c,syntaxTheme:t,...o})},code({className:n,children:o,...i}){return a.jsx("code",{...i,className:F("rounded bg-[var(--surface-elevated)] px-1 py-0.5 font-mono text-[0.95em]",n),"data-markdown":"inline-code",children:o})},a({href:n,children:o,...i}){const l=n??"",c=Le(l),d=e?rt(l):!1;return a.jsxs(a.Fragment,{children:[a.jsxs("a",{...i,href:n,target:c?"_blank":void 0,rel:c?"noopener noreferrer":void 0,children:[c?a.jsx(ot,{href:l}):null,o]}),d&&e?a.jsxs("button",{type:"button",onClick:m=>{m.preventDefault(),m.stopPropagation(),e(l)},className:"ml-1 inline-flex h-5 items-center gap-0.5 rounded border border-[var(--border)] bg-[var(--surface-background)] px-1.5 align-middle text-[11px] leading-none text-[var(--muted-foreground)] transition-colors hover:bg-[var(--surface-hover)] hover:text-[var(--foreground)]","aria-label":s??r??"Open preview pane",title:s??r??"Open preview pane","data-loopback-preview-trigger":"true",children:[a.jsx(V,{name:"eye",className:"size-3","aria-hidden":"true"}),a.jsx("span",{className:"font-medium",children:r??"Preview"})]}):null]})}}),xe=C.memo(t=>{const e=U.c(5),{block:r,components:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=[Ke,Ze],e[0]=n):n=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=[[Ge,{throwOnError:!1,errorColor:"var(--destructive)"}]],e[1]=o):o=e[1];let i;return e[2]!==r.src||e[3]!==s?(i=a.jsx(qe,{remarkPlugins:n,rehypePlugins:o,components:s,children:r.src}),e[2]=r.src,e[3]=s,e[4]=i):i=e[4],i},(t,e)=>t.block===e.block&&t.components===e.components);xe.displayName="MarkdownBlockView";const me='[data-markdown="mermaid-block"]',Ee='[data-openchamber-file-link="true"]',St=4,Rt=1e3,Tt=200,Lt=200,_t=40,G=new Map;let se=0;const je=[],Mt=()=>ge()?Tt:Rt,At=()=>ge()?_t:Lt,Ft=/^[A-Za-z]:[\\/]/,It=/^\\\\[^\\]+\\[^\\]+/,De=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),Ce=Array.from(De).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),Z=t=>{const e=(t||"").trim();if(!e)return"";const r=e.replace(/\\/g,"/"),s=r.startsWith("//");let n=r.replace(/\/+/g,"/");s&&!n.startsWith("//")&&(n=`/${n}`);const o=n==="/",i=/^[A-Za-z]:\/$/.test(n);return!o&&!i&&(n=n.replace(/\/+$/,"")),n},ze=t=>t.startsWith("/")||Ft.test(t)||It.test(t)||t.startsWith("//"),$t=(t,e)=>{const r=Z(e);if(!r)return Z(t);if(ze(r))return r;const s=Z(t);if(!s)return r;const n=/^[A-Za-z]:/.test(s),o=n?s.slice(0,2):"",l=(n?s.slice(2):s).split("/").filter(Boolean),c=r.split("/").filter(Boolean);for(const d of c)if(d!=="."){if(d===".."){l.length>0&&l.pop();continue}l.push(d)}return n?`${o}/${l.join("/")}`:`/${l.join("/")}`},ie=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):""},ue=t=>{let e=ie(t);if(!e)return"";const r=e.indexOf(";");r>=0&&(e=e.slice(0,r)),e=e.replace(/#.*$/,"");const s=e.match(/^(.*\.[A-Za-z0-9_-]{1,16}):.*$/);s&&(e=s[1]??e);const n=Ce.length>0?e.match(new RegExp(`^(.*(?:/|^)(${Ce})):.*$`,"i")):null;return n&&(e=n[1]??e),ie(e)},Oe=t=>{const e=ie(t);if(!e)return null;const r=e.indexOf(";"),s=r>=0?ie(e.slice(0,r)):e;if(!s)return null;const n=s.match(/^(.*)#L(\d+)(?:C(\d+))?$/i);if(n){const l=ue(n[1]??""),c=Number.parseInt(n[2]??"",10),d=n[3]?Number.parseInt(n[3],10):void 0;return!l||!Number.isFinite(c)?null:{path:l,line:c,column:Number.isFinite(d??Number.NaN)?d:void 0}}const o=s.match(/^(.*):(\d+)(?::(\d+))?$/);if(o){const l=ue(o[1]??""),c=Number.parseInt(o[2]??"",10),d=o[3]?Number.parseInt(o[3],10):void 0;return!l||!Number.isFinite(c)?null:{path:l,line:c,column:Number.isFinite(d??Number.NaN)?d:void 0}}const i=ue(s);return i?{path:i}:null},Pt=t=>{const e=t.split("/").filter(Boolean).pop()??"";return!e||e.endsWith(".")?!1:/\.[A-Za-z0-9_-]{1,16}$/.test(e)},Be=t=>{if(!t||t.startsWith("--")||t.includes("://")||/[<>]/.test(t)||/\s{2,}/.test(t))return!1;const e=Z(t),r=e.split("/").filter(Boolean).pop()??e;if(!r||r==="."||r==="..")return!1;const s=r.toLowerCase();return De.has(s)||s.startsWith(".")&&s.length>1?!0:Pt(e)},Dt=t=>{const e=Oe(t);return e?Be(e.path):!1},fe=t=>{if(t.tagName.toLowerCase()==="a"){const e=t.getAttribute("href")?.trim();if(e&&Dt(e))return e}return(t.textContent||"").trim()},he=(t,e)=>{const r=Oe(t);if(!r||!Be(r.path))return null;const s=ze(r.path)?Z(r.path):$t(e,r.path);return s?{...r,resolvedPath:s}:null},zt=t=>{const e=Z(t);if(!e)return Promise.resolve(!1);const r=G.get(e);if(r)return G.delete(e),G.set(e,r),r;const s=new Promise(o=>{const i=()=>{se+=1,fetch(`/api/fs/stat?path=${encodeURIComponent(e)}`,{method:"GET",cache:"no-store"}).then(l=>o(l.ok)).catch(()=>o(!1)).finally(()=>{se=Math.max(0,se-1),je.shift()?.()})};if(se<St){i();return}je.push(i)}),n=Mt();for(;G.size>=n;){const o=G.keys().next().value;if(typeof o!="string")break;G.delete(o)}return G.set(e,s),s},Ot=(t,e)=>{const r=Z(t);if(r)return r;const s=Z(e);return s.replace(/\/[^/]*$/,"")||s},He=t=>{const e=U.c(7),{containerRef:r,effectiveDirectory:s,editor:n,preferRuntimeEditor:o,enabled:i}=t,l=C.useRef(null);let c,d;e[0]!==r||e[1]!==n||e[2]!==s||e[3]!==i||e[4]!==o?(c=()=>{const m=r.current;if(!m)return;let g=!1;const h=At(),p=Ut,k=()=>{const w=m.querySelectorAll(Ee);for(const y of Array.from(w))p(y)};if(!i){k();return}const v=()=>{const w=m.querySelectorAll('[data-markdown="inline-code"], a');let y=0;for(const f of Array.from(w)){const j=fe(f),S=he(j,s);p(f),S&&(y>=h||(y=y+1,zt(S.resolvedPath).then(B=>{if(g||!B||!m.contains(f))return;const A=fe(f),$=he(A,s);!$||$.resolvedPath!==S.resolvedPath||(f.setAttribute("data-openchamber-file-link","true"),f.setAttribute("data-openchamber-file-ref",A),f.setAttribute("data-openchamber-file-path",$.resolvedPath),f.setAttribute("title","Open file"),f.tagName.toLowerCase()!=="a"&&(f.setAttribute("role","button"),f.setAttribute("tabindex","0")))})))}},x=w=>{const y=w.getAttribute("data-openchamber-file-ref")||fe(w),f=he(y,s);if(!f)return;const j=Ot(s,f.resolvedPath);if(o&&n){n.openFile(f.resolvedPath,Number.isFinite(f.line??Number.NaN)?Math.max(1,Math.trunc(f.line)):void 0,Number.isFinite(f.column??Number.NaN)?Math.max(1,Math.trunc(f.column)):void 0);return}const S=be.getState();Number.isFinite(f.line??Number.NaN)?S.openContextFileAtLine(j,f.resolvedPath,Math.max(1,Math.trunc(f.line)),Number.isFinite(f.column??Number.NaN)?Math.max(1,Math.trunc(f.column)):1):S.openContextFile(j,f.resolvedPath)},u=w=>{const y=w.target;if(!(y instanceof Element))return;const f=y.closest(Ee);f instanceof HTMLElement&&(w.preventDefault(),w.stopPropagation(),x(f))},M=w=>{if(w.key!=="Enter"&&w.key!==" ")return;const y=w.target;!(y instanceof HTMLElement)||y.getAttribute("data-openchamber-file-link")!=="true"||(w.preventDefault(),w.stopPropagation(),x(y))};v();const T=new MutationObserver(()=>{if(l.current!==null&&typeof window<"u"&&window.clearTimeout(l.current),typeof window>"u"){v();return}l.current=window.setTimeout(()=>{l.current=null,v()},120)});return T.observe(m,{childList:!0,subtree:!0}),m.addEventListener("click",u),m.addEventListener("keydown",M),()=>{g=!0,l.current!==null&&typeof window<"u"&&window.clearTimeout(l.current),l.current=null,T.disconnect(),m.removeEventListener("click",u),m.removeEventListener("keydown",M)}},d=[r,n,s,o,i],e[0]=r,e[1]=n,e[2]=s,e[3]=i,e[4]=o,e[5]=c,e[6]=d):(c=e[5],d=e[6]),C.useEffect(c,d)},We=t=>{const e=U.c(6),{containerRef:r,mermaidBlocks:s,onShowPopup:n,allowWheelZoom:o}=t;let i,l;e[0]!==o||e[1]!==r||e[2]!==s||e[3]!==n?(i=()=>{const c=r.current;if(!c)return;const d=g=>{if(!n)return;const h=g.target;if(!(h instanceof Element)||h.closest('button, a, [role="button"]'))return;const p=h.closest(me);if(!p)return;const v=Array.from(c.querySelectorAll(me)).indexOf(p);if(v<0)return;const x=s[v];if(!x||x.trim().length===0)return;const u=`Diagram ${v+1}`;n({open:!0,title:u,content:"",metadata:{tool:"mermaid-preview",filename:u},mermaid:{url:`data:text/plain;charset=utf-8,${encodeURIComponent(x)}`,source:x,filename:u}})},m=g=>{if(o)return;const h=g.target;!(h instanceof Element)||!h.closest(me)||g.stopPropagation()};return c.addEventListener("click",d),c.addEventListener("wheel",m,{capture:!0,passive:!0}),()=>{c.removeEventListener("click",d),c.removeEventListener("wheel",m,!0)}},l=[o,r,s,n],e[0]=o,e[1]=r,e[2]=s,e[3]=n,e[4]=i,e[5]=l):(i=e[4],l=e[5]),C.useEffect(i,l)},Bt=t=>{const e=U.c(42),{content:r,part:s,messageId:n,isAnimated:o,skipFadeIn:i,className:l,isStreaming:c,disableStreamAnimation:d,variant:m,onShowPopup:g,enableFileReferences:h}=t,p=o===void 0?!0:o,k=i===void 0?!1:i,v=c===void 0?!1:c,x=d===void 0?!1:d,u=m===void 0?"assistant":m,M=h===void 0?!0:h,T=ve(),{editor:w,runtime:y}=Se(),f=C.useRef(null),j=Re()??"";let S;e[0]!==r?(S=Ie(r),e[0]=r,e[1]=S):S=e[1];const B=S;let A;e[2]!==B||e[3]!==g?(A={containerRef:f,mermaidBlocks:B,onShowPopup:g},e[2]=B,e[3]=g,e[4]=A):A=e[4],We(A);const $=M&&!v;let z;e[5]!==w||e[6]!==j||e[7]!==y.isVSCode||e[8]!==$?(z={containerRef:f,effectiveDirectory:j,editor:w,preferRuntimeEditor:y.isVSCode,enabled:$},e[5]=w,e[6]=j,e[7]=y.isVSCode,e[8]=$,e[9]=z):z=e[9],He(z);let P;e[10]===Symbol.for("react.memo_cache_sentinel")?(P={containerRef:f},e[10]=P):P=e[10],Me(P);const D=be(qt),{t:I}=le();let W;e[11]!==j||e[12]!==D?(W=q=>{j&&D(j,q)},e[11]=j,e[12]=D,e[13]=W):W=e[13];const b=W;let E;e[14]!==I?(E=I("terminalView.preview.open"),e[14]=I,e[15]=E):E=e[15];const N=E;let R;e[16]!==I?(R=I("terminalView.preview.openTitle"),e[16]=I,e[17]=R):R=e[17];const L=R;let _;e[18]!==T?(_=Te(T),e[18]=T,e[19]=_):_=e[19];const O=_,H=j?b:void 0;let K;e[20]!==N||e[21]!==L||e[22]!==O||e[23]!==H?(K=Pe({syntaxTheme:O,onPreviewLoopback:H,previewLabel:N,previewTitle:L}),e[20]=N,e[21]=L,e[22]=O,e[23]=H,e[24]=K):K=e[24];const Q=K,ee=`markdown-${s?.id?`part-${s.id}`:`message-${n}`}`,ce=$e(r,v&&!x,ee),de=u==="tool"?"markdown-content markdown-tool":u==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed";let X;e[25]!==l?(X=F("break-words w-full min-w-0",l),e[25]=l,e[26]=X):X=e[26];let Y;if(e[27]!==ce||e[28]!==Q){let q;e[30]!==Q?(q=ke=>a.jsx(xe,{block:ke,components:Q},ke.key),e[30]=Q,e[31]=q):q=e[31],Y=ce.map(q),e[27]=ce,e[28]=Q,e[29]=Y}else Y=e[29];let J;e[32]!==de||e[33]!==Y?(J=a.jsx("div",{className:de,children:Y}),e[32]=de,e[33]=Y,e[34]=J):J=e[34];let te;e[35]!==X||e[36]!==J?(te=a.jsx("div",{className:X,ref:f,children:J}),e[35]=X,e[36]=J,e[37]=te):te=e[37];const re=te;if(p){let q;return e[38]!==ee||e[39]!==re||e[40]!==k?(q=a.jsx(et,{skipAnimation:k,children:re},ee),e[38]=ee,e[39]=re,e[40]=k,e[41]=q):q=e[41],q}return re},Xt=C.memo(Bt,(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.part?.id===e.part?.id),Ht=t=>{const e=U.c(33),{content:r,className:s,variant:n,disableLinkSafety:o,stripFrontmatter:i,onShowPopup:l,allowMermaidWheelZoom:c,enableFileReferences:d}=t,m=n===void 0?"assistant":n,g=i===void 0?!1:i,h=c===void 0?!1:c,p=d===void 0?!0:d,{editor:k,runtime:v}=Se();let x;e[0]!==r||e[1]!==g?(x=g?ut(r):r,e[0]=r,e[1]=g,e[2]=x):x=e[2];const u=x,M=ve(),T=C.useRef(null),w=Re()??"";let y;e[3]!==u?(y=Ie(u),e[3]=u,e[4]=y):y=e[4];const f=y;let j;e[5]!==h||e[6]!==f||e[7]!==l?(j={containerRef:T,mermaidBlocks:f,onShowPopup:l,allowWheelZoom:h},e[5]=h,e[6]=f,e[7]=l,e[8]=j):j=e[8],We(j);let S;e[9]!==k||e[10]!==w||e[11]!==p||e[12]!==v.isVSCode?(S={containerRef:T,effectiveDirectory:w,editor:k,preferRuntimeEditor:v.isVSCode,enabled:p},e[9]=k,e[10]=w,e[11]=p,e[12]=v.isVSCode,e[13]=S):S=e[13],He(S);const B=!o;let A;e[14]!==B?(A={containerRef:T,enabled:B},e[14]=B,e[15]=A):A=e[15],Me(A);let $;e[16]!==M?($=Te(M),e[16]=M,e[17]=$):$=e[17];const z=$;let P;e[18]!==z?(P=Pe({syntaxTheme:z}),e[18]=z,e[19]=P):P=e[19];const D=P,I=$e(u,!1,`simple:${m}`),W=m==="tool"?"markdown-content markdown-tool":m==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed";let b;e[20]!==s?(b=F("break-words w-full min-w-0",s),e[20]=s,e[21]=b):b=e[21];let E;if(e[22]!==I||e[23]!==D){let L;e[25]!==D?(L=_=>a.jsx(xe,{block:_,components:D},_.key),e[25]=D,e[26]=L):L=e[26],E=I.map(L),e[22]=I,e[23]=D,e[24]=E}else E=e[24];let N;e[27]!==W||e[28]!==E?(N=a.jsx("div",{className:W,children:E}),e[27]=W,e[28]=E,e[29]=N):N=e[29];let R;return e[30]!==b||e[31]!==N?(R=a.jsx("div",{className:b,ref:T,children:N}),e[30]=b,e[31]=N,e[32]=R):R=e[32],R},Yt=C.memo(Ht,(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 Wt(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 r=e.closest("a[href]");if(!(r instanceof HTMLAnchorElement)||r.getAttribute("data-openchamber-file-link")==="true")return;const s=r.getAttribute("href")??"";Le(s)&&(t.preventDefault(),t.stopPropagation(),tt(s))}function Vt(t){return t==="preview"?"code":"preview"}function Ut(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 qt(t){return t.openContextPreview}export{Xt as MarkdownRenderer,Yt as SimpleMarkdownRenderer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as _,R as k,j as n,aP as D,aR as C,aV as I,aU as S,aS as M}from"./vendor-.bun-Bum-iBXX.js";import{u as P,c as w,I as z}from"./modelPrefsAutoSave-
|
|
1
|
+
import{c as _,R as k,j as n,aP as D,aR as C,aV as I,aU as S,aS as M}from"./vendor-.bun-Bum-iBXX.js";import{u as P,c as w,I as z}from"./modelPrefsAutoSave-DRJSYigo.js";import{M as O}from"./main-d2-dY4er.js";import"./index-B9LvUHdG.js";const F=R=>{const e=_.c(33),{open:b,onOpenChange:t,initialPrompt:v}=R,a=k.useId(),{t:i}=P(),N=B;let s;e[0]!==t?(s=j=>{!j&&N()||t(j)},e[0]=t,e[1]=s):s=e[1];let x;e[2]===Symbol.for("react.memo_cache_sentinel")?(x=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]=x):x=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 o;e[4]!==t?(o=()=>t(!1),e[4]=t,e[5]=o):o=e[5];let l;e[6]!==i?(l=i("multiRun.window.actions.closeAria"),e[6]=i,e[7]=l):l=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(z,{name:"close",className:"h-5 w-5"}),e[8]=h):h=e[8];let r;e[9]!==o||e[10]!==l?(r=n.jsx("div",{className:"absolute right-0.5 top-0.5 z-50",children:n.jsx("button",{type:"button",onClick:o,"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:h})}),e[9]=o,e[10]=l,e[11]=r):r=e[11];let c;e[12]!==i?(c=i("multiRun.window.description"),e[12]=i,e[13]=c):c=e[13];let d;e[14]!==a||e[15]!==c?(d=n.jsx(C,{id:a,className:"sr-only",children:c}),e[14]=a,e[15]=c,e[16]=d):d=e[16];let u,f;e[17]!==t?(u=()=>t(!1),f=()=>t(!1),e[17]=t,e[18]=u,e[19]=f):(u=e[18],f=e[19]);let m;e[20]!==v||e[21]!==u||e[22]!==f?(m=n.jsx(O,{initialPrompt:v,onCreated:u,onCancel:f,isWindowed:!0}),e[20]=v,e[21]=u,e[22]=f,e[23]=m):m=e[23];let p;e[24]!==a||e[25]!==m||e[26]!==r||e[27]!==d?(p=n.jsxs(I,{children:[x,n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center pointer-events-none",children:n.jsxs(S,{"aria-describedby":a,className:g,children:[r,d,m]})})]}),e[24]=a,e[25]=m,e[26]=r,e[27]=d,e[28]=p):p=e[28];let y;return e[29]!==b||e[30]!==s||e[31]!==p?(y=n.jsx(M,{open:b,onOpenChange:s,children:p}),e[29]=b,e[30]=s,e[31]=p,e[32]=y):y=e[32],y};function B(){return typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]')}export{F as MultiRunWindow};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-.bun-Bum-iBXX.js","assets/vendor--V65Sl9C2.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as O,j as t,R as s,c as $,_ as le}from"./vendor-.bun-Bum-iBXX.js";import{u as z,eN as ie,eO as Q,a1 as X,eP as q,m as L,as as T,aI as H,N as oe,ab as ce,d as ne,cY as W,v as se,c as Y,I,a3 as G}from"./modelPrefsAutoSave-Ctdc3cCY.js";import"./index-DHluop4D.js";function de(l){switch(l){case"ok":return null;case"auth":return"onboarding.remoteConnection.probe.authMessage";case"wrong-service":return"onboarding.remoteConnection.probe.wrongServiceMessage";case"unreachable":return"onboarding.remoteConnection.probe.unreachableMessage";default:return null}}function V(l){return l==="wrong-service"||l==="unreachable"}function ae({onBack:l,showBackButton:e=!0,initialUrl:c="",initialLabel:a="",isRecoveryMode:o=!1,onConnect:x,onSwitchToLocal:i}){const{t:n}=z(),[m,k]=O.useState(c),[g,_]=O.useState(a),[N,p]=O.useState("idle"),[h,w]=O.useState(null),[R,S]=O.useState(""),b=ie(m),f=O.useCallback(u=>{k(u.target.value),p("idle"),w(null),S("")},[]),j=O.useCallback(u=>{_(u.target.value)},[]),v=O.useCallback(async()=>{if(b){p("testing"),w(null),S("");try{const u=await Q(b);w(u),p(u.status==="ok"?"success":"error")}catch(u){S(u instanceof Error?u.message:n("onboarding.remoteConnection.errors.connectionTestFailed")),p("error")}}},[b,n]),C=O.useCallback(async()=>{if(b){p("testing"),w(null),S("");try{const u=await Q(b);if(w(u),V(u.status)){p("error");return}const r=await X(),y=g.trim()||b,K=r.hosts.find(M=>M.url===b),P=K?K.id:`host-${Date.now().toString(16)}`,J={id:P,label:y,url:b},re=K?r.hosts.map(M=>M.id===P?J:M):[...r.hosts,J];await q({hosts:re,defaultHostId:P,initialHostChoiceCompleted:!0}),x?.(),L()&&await window.__TAURI__?.core?.invoke?.("desktop_restart")}catch(u){S(u instanceof Error?u.message:n("onboarding.remoteConnection.errors.failedToSaveConnection")),p("error")}}},[b,g,x,n]),U=N==="testing",D=b!==null&&!U,A=b!==null&&!U&&!V(h?.status??null),E=de(h?.status??null),F=h?.status==="ok",B=h?.status==="auth",d=V(h?.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(T,{variant:"ghost",onClick:l,className:"p-0 text-muted-foreground hover:text-foreground",children:n("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:n(o?"onboarding.remoteConnection.titleRecovery":"onboarding.remoteConnection.title")}),t.jsx("p",{className:"text-muted-foreground text-sm",children:n("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:n("onboarding.remoteConnection.field.serverAddress")}),t.jsx(H,{id:"remote-url",type:"url",value:m,onChange:f,placeholder:n("onboarding.remoteConnection.field.serverAddressPlaceholder"),disabled:U})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"remote-label",className:"text-sm text-foreground",children:n("onboarding.remoteConnection.field.nameOptional")}),t.jsx(H,{id:"remote-label",type:"text",value:g,onChange:j,placeholder:n("onboarding.remoteConnection.field.namePlaceholder"),disabled:U})]})]}),h&&F&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-success)",color:"var(--status-success)"},children:n("onboarding.remoteConnection.status.connectedSuccessfully",{latencyMs:h.latencyMs})}),h&&B&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:n("onboarding.remoteConnection.status.authWarning")}),h&&d&&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:n("onboarding.remoteConnection.status.connectionFailed")}),t.jsx("div",{className:"opacity-90",children:E?n(E):null})]}),t.jsx("div",{className:"text-xs opacity-80",children:h.status==="unreachable"?n("onboarding.remoteConnection.status.suggestionsUnreachable"):n("onboarding.remoteConnection.status.suggestionsWrongService")})]}),R&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:R}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx(T,{variant:"outline",onClick:v,disabled:!D,children:n(U?"onboarding.remoteConnection.actions.testing":"onboarding.remoteConnection.actions.testConnection")}),t.jsx(T,{onClick:C,disabled:!A,children:n("onboarding.remoteConnection.actions.connectAndRestart")})]}),d&&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:n("onboarding.remoteConnection.actions.whatToDo")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(T,{variant:"outline",size:"sm",onClick:l,className:"flex-1",children:n("onboarding.remoteConnection.actions.chooseDifferentServer")}),!o&&i&&t.jsx(T,{variant:"outline",size:"sm",onClick:i,className:"flex-1",children:n("onboarding.remoteConnection.actions.useLocalInstead")})]})]})]})})}const ue="curl -fsSL https://opencode.ai/install | bash",me="https://opencode.ai/docs",pe="https://opencode.ai/docs/windows-wsl",Z=2500;function he(l){const e=$.c(5),{onCopy:c,copyTitle:a}=l;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 x;e[1]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx(I,{name:"file-copy",className:"h-4 w-4"}),e[1]=x):x=e[1];let i;return e[2]!==a||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:a,"aria-label":a,children:x})]}),e[2]=a,e[3]=c,e[4]=i):i=e[4],i}function fe({onCliAvailable:l}){const{t:e}=z(),[c,a]=s.useState(!1),[o,x]=s.useState(!1),[i,n]=s.useState(!1),[m,k]=s.useState(!1),[g,_]=s.useState(""),[N,p]=s.useState("unknown"),[h,w]=s.useState("local"),[R,S]=s.useState(!1),[b,f]=s.useState(!1);s.useEffect(()=>{x(oe())},[]),s.useEffect(()=>{if(typeof navigator>"u"){p("unknown");return}const r=navigator.userAgent||"";/Windows/i.test(r)?p("windows"):/Macintosh|Mac OS X/i.test(r)?p("macos"):/Linux/i.test(r)?p("linux"):p("unknown")},[]),s.useEffect(()=>{let r=!1;return(async()=>{try{const y=await fetch("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!y.ok)return;const K=await y.json().catch(()=>null);if(!K||r)return;const P=typeof K.opencodeBinary=="string"?K.opencodeBinary.trim():"";P&&_(P)}catch{}})(),()=>{r=!0}},[]);const j=s.useCallback(async r=>{const y=r.target;y.closest(".app-region-no-drag")||y.closest("button, a, input, select, textarea, code, summary, details")||r.button===0&&o&&await ce()},[o]),v=s.useCallback(async()=>{try{const r=await fetch("/health");if(!r.ok)return!1;const y=await r.json();return y.openCodeRunning===!0||y.isOpenCodeReady===!0}catch{return!1}},[]),C=s.useCallback(async r=>{if(!L())return;const y=await X();await q({...y,...r==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})},[]),U=s.useCallback(async()=>{L()&&await C("local"),l?.()},[l,C]);s.useEffect(()=>{if(h!=="local")return;let r=!1,y=null;const K=async()=>{if(!r){try{const P=await v();if(r)return;if(P){await U();return}}catch{}r||(y=setTimeout(K,Z))}};return y=setTimeout(K,Z),()=>{r=!0,y&&clearTimeout(y)}},[h,v,U]);const D=s.useCallback(async()=>{k(!0);try{await v()&&await U()}finally{k(!1)}},[v,U]),A=s.useCallback(async()=>{if(typeof window>"u"||!o||!L())return;const r=window.__TAURI__;if(r?.dialog?.open)try{const y=await r.dialog.open({title:e("onboarding.localSetup.dialog.selectOpencodeBinary"),multiple:!1,directory:!1});typeof y=="string"&&y.trim().length>0&&_(y.trim())}catch{}},[o,e]),E=s.useCallback(async()=>{n(!0);try{if(await ne({opencodeBinary:g.trim()}),L()){await C("local"),await W();return}await fetch("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>n(!1),1e3)}},[g,C]),F=s.useCallback(async()=>{const r=await se(ue);r.ok?(a(!0),setTimeout(()=>a(!1),2e3)):console.error("Failed to copy:",r.error)},[]),B=N==="windows"?pe:me,d=N==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":N==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode",u=!o||!L()||h==="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:j,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&&L()&&t.jsxs("div",{className:"app-region-no-drag flex gap-1.5",children:[t.jsx("button",{type:"button",className:Y("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",h==="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:()=>w("local"),children:e("onboarding.chooser.tabs.localInstall")}),t.jsx("button",{type:"button",className:Y("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",h==="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:()=>w("remote"),children:e("onboarding.chooser.tabs.connectRemote")})]}),o&&L()&&h==="remote"?t.jsx("div",{className:"app-region-no-drag",children:t.jsx(ae,{onBack:()=>w("local"),showBackButton:!1,onSwitchToLocal:()=>w("local")})}):null,u&&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.jsxs("li",{children:[e("onboarding.localSetup.windows.stepInstallWsl")," ",t.jsx("code",{className:"text-foreground/80",children:"wsl --install"})," ",e("onboarding.localSetup.windows.stepInstallWslSuffix")]}),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(I,{name:"check",className:"h-4 w-4"}),e("onboarding.common.status.copiedToClipboard")]}):t.jsx(he,{onCopy:F,copyTitle:e("onboarding.common.copyToClipboard")})}),t.jsxs("div",{className:"app-region-no-drag flex items-center justify-between",children:[t.jsxs("a",{href:B,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(I,{name:"external-link",className:"h-3 w-3"})]}),t.jsx("button",{type:"button",onClick:D,disabled:m,className:"text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:e(m?"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:R,onToggle:r=>S(r.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(I,{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(H,{value:g,onChange:r=>_(r.target.value),placeholder:d,disabled:i,className:"flex-1 font-mono text-xs"}),t.jsx(T,{type:"button",variant:"secondary",size:"sm",onClick:A,disabled:i||!o||!L(),children:e("onboarding.localSetup.actions.browse")}),t.jsx(T,{type:"button",size:"sm",onClick:E,disabled:i||!g.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:b,onToggle:r=>f(r.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(I,{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.jsxs(t.Fragment,{children:[t.jsx("li",{children:e("onboarding.localSetup.windows.hintInstallInWsl")}),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 xe="curl -fsSL https://opencode.ai/install | bash",ge="https://opencode.ai/docs",be="https://opencode.ai/docs/windows-wsl";function ye(l){const e=$.c(5),{onCopy:c,copyTitle:a}=l;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 x;e[1]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx(I,{name:"file-copy",className:"h-4 w-4"}),e[1]=x):x=e[1];let i;return e[2]!==a||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:a,children:x})]}),e[2]=a,e[3]=c,e[4]=i):i=e[4],i}const ve=3e4;function we({onBack:l,onCliAvailable:e,isFromRecovery:c=!1,onSwitchToRemote:a}){const{t:o}=z(),[x,i]=s.useState(!1),[n,m]=s.useState(!1),[k,g]=s.useState(!1),[_,N]=s.useState(!1),[p,h]=s.useState(!1),[w,R]=s.useState(null),[S,b]=s.useState(""),[f,j]=s.useState("unknown");s.useEffect(()=>{const d=setTimeout(()=>m(!0),ve);return()=>clearTimeout(d)},[]),s.useEffect(()=>{g(oe())},[]),s.useEffect(()=>{if(typeof navigator>"u"){j("unknown");return}const d=navigator.userAgent||"";if(/Windows/i.test(d)){j("windows");return}if(/Macintosh|Mac OS X/i.test(d)){j("macos");return}if(/Linux/i.test(d)){j("linux");return}j("unknown")},[]),s.useEffect(()=>{let d=!1;return(async()=>{try{const u=await fetch("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!u.ok)return;const r=await u.json().catch(()=>null);if(!r||d)return;const y=typeof r.opencodeBinary=="string"?r.opencodeBinary.trim():"";y&&b(y)}catch{}})(),()=>{d=!0}},[]);const v=s.useCallback(async d=>{if(!d.target.closest("button, a, input, select, textarea, code")&&d.button===0&&k&&L())try{const{getCurrentWindow:u}=await le(async()=>{const{getCurrentWindow:y}=await import("./vendor-.bun-Bum-iBXX.js").then(K=>K.bP);return{getCurrentWindow:y}},__vite__mapDeps([0,1]));await u().startDragging()}catch(u){console.error("Failed to start window dragging:",u)}},[k]),C=s.useCallback(async()=>{try{const d=await fetch("/health");if(!d.ok)return!1;const u=await d.json();return u.openCodeRunning===!0||u.isOpenCodeReady===!0}catch{return!1}},[]),U=s.useCallback(async()=>{if(typeof window>"u"||!k||!L())return;const d=window.__TAURI__;if(d?.dialog?.open)try{const u=await d.dialog.open({title:o("onboarding.localSetup.dialog.selectOpencodeBinary"),multiple:!1,directory:!1});typeof u=="string"&&u.trim().length>0&&b(u.trim())}catch{}},[k,o]),D=s.useCallback(async()=>{N(!0);try{if(await ne({opencodeBinary:S.trim()}),L()){await W();return}await fetch("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>N(!1),1e3)}},[S]),A=s.useCallback(async()=>{const d=await se(xe);d.ok?(i(!0),setTimeout(()=>i(!1),2e3)):console.error("Failed to copy:",d.error)},[]),E=s.useCallback(async()=>{h(!0),R(null);try{await C()?e?.():R(o("onboarding.localSetup.errors.cliNotReady"))}catch(d){R(d instanceof Error?d.message:o("onboarding.localSetup.errors.detectionFailed"))}finally{h(!1)}},[C,e,o]),F=f==="windows"?be:ge,B=f==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":f==="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:v,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(T,{variant:"ghost",onClick:l,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")})]}),f==="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.jsxs("li",{children:[o("onboarding.localSetup.windows.stepInstallWsl")," ",t.jsx("code",{className:"text-foreground/80",children:"wsl --install"})," ",o("onboarding.localSetup.windows.stepInstallWslSuffix")]}),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:x?t.jsxs("div",{className:"flex items-center justify-center gap-2",style:{color:"var(--status-success)"},children:[t.jsx(I,{name:"check",className:"h-4 w-4"}),o("onboarding.common.status.copiedToClipboard")]}):t.jsx(ye,{onCopy:A,copyTitle:o("onboarding.common.copyToClipboard")})})}),t.jsxs("a",{href:F,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(f==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),t.jsx(I,{name:"external-link",className:"h-3 w-3"})]}),w&&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:w}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(T,{type:"button",onClick:E,disabled:p,className:"w-full max-w-xs",size:"lg",children:o(p?"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(H,{value:S,onChange:d=>b(d.target.value),placeholder:B,disabled:_,className:"flex-1 font-mono text-xs"}),t.jsx(T,{type:"button",variant:"secondary",onClick:U,disabled:_||!k||!L(),children:o("onboarding.localSetup.actions.browse")}),t.jsx(T,{type:"button",onClick:D,disabled:_,children:o("onboarding.localSetup.actions.apply")})]}),t.jsx("div",{className:"text-xs text-muted-foreground/70",children:o("onboarding.localSetup.helper.saveAndReload")})]})}),c&&a&&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(T,{variant:"link",onClick:a,children:o("onboarding.localSetup.actions.connectRemoteServer")})]})]}),n&&t.jsx("div",{className:"absolute bottom-8 left-0 right-0 text-center space-y-1",children:f==="windows"?t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.windows.hintInstallInWsl")}),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 ee(l,e){if(l?.trim())return G(l.trim());if(e)return G(e)}function je(l,e,c){switch(l){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 a=ee(e,c);return{title:"Remote Server Unreachable",description:`Could not connect to "${a||"the remote server"}". Check your network connection and verify the server address.`,titleKey:"onboarding.desktopRecovery.remoteUnreachable.title",descriptionKey:"onboarding.desktopRecovery.remoteUnreachable.description",descriptionParams:a?{host:a}: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 a=ee(e,c);return{title:"Incompatible Server",description:`The server at "${a||"unknown"}" is not running OpenChamber. Verify the address points to an OpenChamber server.`,titleKey:"onboarding.desktopRecovery.incompatibleServer.title",descriptionKey:"onboarding.desktopRecovery.incompatibleServer.description",descriptionParams:a?{host:a}: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"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 a=l;throw new Error(`Unknown recovery variant: ${a}`)}}}function ke(l){switch(l){case"local":return t.jsx(I,{name:"macbook",className:"h-8 w-8"});case"remote":return t.jsx(I,{name:"server",className:"h-8 w-8"})}}function Ce({variant:l,hostLabel:e,hostUrl:c,onRetry:a,onUseLocal:o,onUseRemote:x,isRetrying:i=!1}){const{t:n}=z(),m=je(l,e,c),k=m.retryLabelKey??"onboarding.desktopRecovery.actions.retryConnection",g=s.useMemo(()=>{if(m.descriptionParams?.host)return m.descriptionParams;if(l==="remote-unreachable")return{host:n("onboarding.desktopRecovery.placeholders.remoteServer")};if(l==="remote-wrong-service")return{host:n("onboarding.desktopRecovery.placeholders.unknownServer")}},[m.descriptionParams,n,l]);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:ke(m.iconKey)})}),t.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:n(m.titleKey)}),t.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:n(m.descriptionKey,g)})]}),c&&(l==="remote-unreachable"||l==="remote-wrong-service")&&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:n("onboarding.remoteConnection.field.serverAddress")}),t.jsx("div",{className:"font-mono text-sm text-foreground truncate",children:G(c)})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[m.showRetry&&a&&t.jsxs(T,{onClick:a,disabled:i,className:"w-full",children:[t.jsx(I,{name:"refresh",className:Y("h-4 w-4",i&&"animate-spin")}),n(i?"onboarding.desktopRecovery.actions.retrying":k)]}),t.jsxs("div",{className:"flex gap-2",children:[m.showUseLocal&&o&&t.jsxs(T,{variant:"outline",onClick:o,disabled:i,className:"flex-1",children:[t.jsx(I,{name:"macbook",className:"h-4 w-4"}),n(m.useLocalLabelKey)]}),m.showUseRemote&&x&&t.jsxs(T,{variant:"outline",onClick:x,disabled:i,className:"flex-1",children:[t.jsx(I,{name:"server",className:"h-4 w-4"}),n(m.useRemoteLabelKey)]})]})]})]})})}function te(l,e){if(e==="use-remote")return{kind:"remote-form"};switch(l){case"local-unavailable":return{kind:"local-setup"};case"remote-unreachable":case"remote-wrong-service":case"remote-missing":case"missing-default-host":return{kind:"switch-default-to-local"};default:{const c=l;throw new Error(`Unhandled RecoveryVariant: ${c}`)}}}function Se(l){const e=$.c(27),{variant:c,hostUrl:a,hostLabel:o,onRetry:x,onChooseRemote:i,showRemoteForm:n,onCloseRemoteForm:m,onSwitchToLocalFromRemote:k,onEnterLocalSetup:g,isRetrying:_}=l,N=n===void 0?!1:n,p=_===void 0?!1:_,h=Ne;let w;e[0]!==x?(w=async()=>{if(L()){await W();return}await fetch("/api/config/reload",{method:"POST"}),x?.()},e[0]=x,e[1]=w):w=e[1];const R=w;let S;e[2]!==g||e[3]!==c?(S=async()=>{if(te(c,"use-local").kind==="local-setup"){g?.();return}if(await h("local"),L()){await W();return}window.location.reload()},e[2]=g,e[3]=c,e[4]=S):S=e[4];const b=S;let f;e[5]!==i||e[6]!==c?(f=()=>{te(c,"use-remote").kind==="remote-form"&&i?.()},e[5]=i,e[6]=c,e[7]=f):f=e[7];const j=f;if(N){const C=c==="remote-wrong-service"?"":a||"",U=c==="remote-wrong-service"?"":o||"";let D;e[8]!==i||e[9]!==m?(D=m||(()=>i?.()),e[8]=i,e[9]=m,e[10]=D):D=e[10];let A;e[11]!==g||e[12]!==k?(A=k||(()=>{h("local").then(()=>{L()?W():g?.()})}),e[11]=g,e[12]=k,e[13]=A):A=e[13];let E;return e[14]!==U||e[15]!==C||e[16]!==D||e[17]!==A?(E=t.jsx(ae,{onBack:D,initialUrl:C,initialLabel:U,isRecoveryMode:!0,onSwitchToLocal:A}),e[14]=U,e[15]=C,e[16]=D,e[17]=A,e[18]=E):E=e[18],E}let v;return e[19]!==R||e[20]!==b||e[21]!==j||e[22]!==o||e[23]!==a||e[24]!==p||e[25]!==c?(v=t.jsx(Ce,{variant:c,hostLabel:o,hostUrl:a,onRetry:R,onUseLocal:b,onUseRemote:j,isRetrying:p}),e[19]=R,e[20]=b,e[21]=j,e[22]=o,e[23]=a,e[24]=p,e[25]=c,e[26]=v):v=e[26],v}async function Ne(l){if(!L())return;const e=await X();await q({...e,...l==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})}function Ue(l){const e=$.c(26),{onBack:c,onCliAvailable:a,mode:o,recoveryVariant:x,recoveryHostUrl:i,recoveryHostLabel:n,onEnterLocalSetup:m}=l,k=o===void 0?"first-launch":o,g=x===void 0?"missing-default-host":x,[_,N]=s.useState(!1),[p,h]=s.useState(!1);let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{h(!1),N(!1)},e[0]=w):w=e[0];let R;e[1]!==k||e[2]!==n||e[3]!==i||e[4]!==g?(R=[k,g,i,n],e[1]=k,e[2]=n,e[3]=i,e[4]=g,e[5]=R):R=e[5],s.useEffect(w,R);const S=p?"local-setup":k;if(S==="recovery"){let f,j;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=()=>N(!1),j=()=>{N(!1),h(!0)},e[6]=f,e[7]=j):(f=e[6],j=e[7]);let v;e[8]!==m?(v=()=>{h(!0),m?.()},e[8]=m,e[9]=v):v=e[9];let C;return e[10]!==n||e[11]!==i||e[12]!==g||e[13]!==_||e[14]!==v?(C=t.jsx(Se,{variant:g,hostUrl:i,hostLabel:n,showRemoteForm:_,onCloseRemoteForm:f,onSwitchToLocalFromRemote:j,onEnterLocalSetup:v}),e[10]=n,e[11]=i,e[12]=g,e[13]=_,e[14]=v,e[15]=C):C=e[15],C}if(S==="local-setup"){let f;e[16]!==c||e[17]!==p?(f=()=>{p?h(!1):c?.()},e[16]=c,e[17]=p,e[18]=f):f=e[18];let j;e[19]===Symbol.for("react.memo_cache_sentinel")?(j=()=>N(!0),e[19]=j):j=e[19];let v;return e[20]!==a||e[21]!==p||e[22]!==f?(v=t.jsx(we,{onBack:f,onCliAvailable:a,isFromRecovery:p,onSwitchToRemote:j}),e[20]=a,e[21]=p,e[22]=f,e[23]=v):v=e[23],v}let b;return e[24]!==a?(b=t.jsx(fe,{onCliAvailable:a}),e[24]=a,e[25]=b):b=e[25],b}export{Ue as OnboardingScreen};
|
|
2
|
+
import{r as O,j as t,R as s,c as $,_ as le}from"./vendor-.bun-Bum-iBXX.js";import{u as z,eQ as ie,eR as J,a1 as X,eS as Q,m as L,as as T,aI as H,N as oe,ab as ce,d as ne,cY as W,v as se,c as Y,I,a3 as G}from"./modelPrefsAutoSave-DRJSYigo.js";import"./index-B9LvUHdG.js";function de(l){switch(l){case"ok":return null;case"auth":return"onboarding.remoteConnection.probe.authMessage";case"wrong-service":return"onboarding.remoteConnection.probe.wrongServiceMessage";case"unreachable":return"onboarding.remoteConnection.probe.unreachableMessage";default:return null}}function V(l){return l==="wrong-service"||l==="unreachable"}function ae({onBack:l,showBackButton:e=!0,initialUrl:c="",initialLabel:a="",isRecoveryMode:o=!1,onConnect:x,onSwitchToLocal:i}){const{t:n}=z(),[m,k]=O.useState(c),[g,_]=O.useState(a),[N,p]=O.useState("idle"),[h,w]=O.useState(null),[R,S]=O.useState(""),b=ie(m),f=O.useCallback(u=>{k(u.target.value),p("idle"),w(null),S("")},[]),j=O.useCallback(u=>{_(u.target.value)},[]),v=O.useCallback(async()=>{if(b){p("testing"),w(null),S("");try{const u=await J(b);w(u),p(u.status==="ok"?"success":"error")}catch(u){S(u instanceof Error?u.message:n("onboarding.remoteConnection.errors.connectionTestFailed")),p("error")}}},[b,n]),C=O.useCallback(async()=>{if(b){p("testing"),w(null),S("");try{const u=await J(b);if(w(u),V(u.status)){p("error");return}const r=await X(),y=g.trim()||b,K=r.hosts.find(M=>M.url===b),P=K?K.id:`host-${Date.now().toString(16)}`,q={id:P,label:y,url:b},re=K?r.hosts.map(M=>M.id===P?q:M):[...r.hosts,q];await Q({hosts:re,defaultHostId:P,initialHostChoiceCompleted:!0}),x?.(),L()&&await window.__TAURI__?.core?.invoke?.("desktop_restart")}catch(u){S(u instanceof Error?u.message:n("onboarding.remoteConnection.errors.failedToSaveConnection")),p("error")}}},[b,g,x,n]),U=N==="testing",D=b!==null&&!U,A=b!==null&&!U&&!V(h?.status??null),E=de(h?.status??null),F=h?.status==="ok",B=h?.status==="auth",d=V(h?.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(T,{variant:"ghost",onClick:l,className:"p-0 text-muted-foreground hover:text-foreground",children:n("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:n(o?"onboarding.remoteConnection.titleRecovery":"onboarding.remoteConnection.title")}),t.jsx("p",{className:"text-muted-foreground text-sm",children:n("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:n("onboarding.remoteConnection.field.serverAddress")}),t.jsx(H,{id:"remote-url",type:"url",value:m,onChange:f,placeholder:n("onboarding.remoteConnection.field.serverAddressPlaceholder"),disabled:U})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"remote-label",className:"text-sm text-foreground",children:n("onboarding.remoteConnection.field.nameOptional")}),t.jsx(H,{id:"remote-label",type:"text",value:g,onChange:j,placeholder:n("onboarding.remoteConnection.field.namePlaceholder"),disabled:U})]})]}),h&&F&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-success)",color:"var(--status-success)"},children:n("onboarding.remoteConnection.status.connectedSuccessfully",{latencyMs:h.latencyMs})}),h&&B&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:n("onboarding.remoteConnection.status.authWarning")}),h&&d&&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:n("onboarding.remoteConnection.status.connectionFailed")}),t.jsx("div",{className:"opacity-90",children:E?n(E):null})]}),t.jsx("div",{className:"text-xs opacity-80",children:h.status==="unreachable"?n("onboarding.remoteConnection.status.suggestionsUnreachable"):n("onboarding.remoteConnection.status.suggestionsWrongService")})]}),R&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:R}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx(T,{variant:"outline",onClick:v,disabled:!D,children:n(U?"onboarding.remoteConnection.actions.testing":"onboarding.remoteConnection.actions.testConnection")}),t.jsx(T,{onClick:C,disabled:!A,children:n("onboarding.remoteConnection.actions.connectAndRestart")})]}),d&&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:n("onboarding.remoteConnection.actions.whatToDo")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(T,{variant:"outline",size:"sm",onClick:l,className:"flex-1",children:n("onboarding.remoteConnection.actions.chooseDifferentServer")}),!o&&i&&t.jsx(T,{variant:"outline",size:"sm",onClick:i,className:"flex-1",children:n("onboarding.remoteConnection.actions.useLocalInstead")})]})]})]})})}const ue="curl -fsSL https://opencode.ai/install | bash",me="https://opencode.ai/docs",pe="https://opencode.ai/docs/windows-wsl",Z=2500;function he(l){const e=$.c(5),{onCopy:c,copyTitle:a}=l;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 x;e[1]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx(I,{name:"file-copy",className:"h-4 w-4"}),e[1]=x):x=e[1];let i;return e[2]!==a||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:a,"aria-label":a,children:x})]}),e[2]=a,e[3]=c,e[4]=i):i=e[4],i}function fe({onCliAvailable:l}){const{t:e}=z(),[c,a]=s.useState(!1),[o,x]=s.useState(!1),[i,n]=s.useState(!1),[m,k]=s.useState(!1),[g,_]=s.useState(""),[N,p]=s.useState("unknown"),[h,w]=s.useState("local"),[R,S]=s.useState(!1),[b,f]=s.useState(!1);s.useEffect(()=>{x(oe())},[]),s.useEffect(()=>{if(typeof navigator>"u"){p("unknown");return}const r=navigator.userAgent||"";/Windows/i.test(r)?p("windows"):/Macintosh|Mac OS X/i.test(r)?p("macos"):/Linux/i.test(r)?p("linux"):p("unknown")},[]),s.useEffect(()=>{let r=!1;return(async()=>{try{const y=await fetch("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!y.ok)return;const K=await y.json().catch(()=>null);if(!K||r)return;const P=typeof K.opencodeBinary=="string"?K.opencodeBinary.trim():"";P&&_(P)}catch{}})(),()=>{r=!0}},[]);const j=s.useCallback(async r=>{const y=r.target;y.closest(".app-region-no-drag")||y.closest("button, a, input, select, textarea, code, summary, details")||r.button===0&&o&&await ce()},[o]),v=s.useCallback(async()=>{try{const r=await fetch("/health");if(!r.ok)return!1;const y=await r.json();return y.openCodeRunning===!0||y.isOpenCodeReady===!0}catch{return!1}},[]),C=s.useCallback(async r=>{if(!L())return;const y=await X();await Q({...y,...r==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})},[]),U=s.useCallback(async()=>{L()&&await C("local"),l?.()},[l,C]);s.useEffect(()=>{if(h!=="local")return;let r=!1,y=null;const K=async()=>{if(!r){try{const P=await v();if(r)return;if(P){await U();return}}catch{}r||(y=setTimeout(K,Z))}};return y=setTimeout(K,Z),()=>{r=!0,y&&clearTimeout(y)}},[h,v,U]);const D=s.useCallback(async()=>{k(!0);try{await v()&&await U()}finally{k(!1)}},[v,U]),A=s.useCallback(async()=>{if(typeof window>"u"||!o||!L())return;const r=window.__TAURI__;if(r?.dialog?.open)try{const y=await r.dialog.open({title:e("onboarding.localSetup.dialog.selectOpencodeBinary"),multiple:!1,directory:!1});typeof y=="string"&&y.trim().length>0&&_(y.trim())}catch{}},[o,e]),E=s.useCallback(async()=>{n(!0);try{if(await ne({opencodeBinary:g.trim()}),L()){await C("local"),await W();return}await fetch("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>n(!1),1e3)}},[g,C]),F=s.useCallback(async()=>{const r=await se(ue);r.ok?(a(!0),setTimeout(()=>a(!1),2e3)):console.error("Failed to copy:",r.error)},[]),B=N==="windows"?pe:me,d=N==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":N==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode",u=!o||!L()||h==="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:j,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&&L()&&t.jsxs("div",{className:"app-region-no-drag flex gap-1.5",children:[t.jsx("button",{type:"button",className:Y("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",h==="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:()=>w("local"),children:e("onboarding.chooser.tabs.localInstall")}),t.jsx("button",{type:"button",className:Y("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",h==="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:()=>w("remote"),children:e("onboarding.chooser.tabs.connectRemote")})]}),o&&L()&&h==="remote"?t.jsx("div",{className:"app-region-no-drag",children:t.jsx(ae,{onBack:()=>w("local"),showBackButton:!1,onSwitchToLocal:()=>w("local")})}):null,u&&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.jsxs("li",{children:[e("onboarding.localSetup.windows.stepInstallWsl")," ",t.jsx("code",{className:"text-foreground/80",children:"wsl --install"})," ",e("onboarding.localSetup.windows.stepInstallWslSuffix")]}),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(I,{name:"check",className:"h-4 w-4"}),e("onboarding.common.status.copiedToClipboard")]}):t.jsx(he,{onCopy:F,copyTitle:e("onboarding.common.copyToClipboard")})}),t.jsxs("div",{className:"app-region-no-drag flex items-center justify-between",children:[t.jsxs("a",{href:B,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(I,{name:"external-link",className:"h-3 w-3"})]}),t.jsx("button",{type:"button",onClick:D,disabled:m,className:"text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:e(m?"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:R,onToggle:r=>S(r.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(I,{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(H,{value:g,onChange:r=>_(r.target.value),placeholder:d,disabled:i,className:"flex-1 font-mono text-xs"}),t.jsx(T,{type:"button",variant:"secondary",size:"sm",onClick:A,disabled:i||!o||!L(),children:e("onboarding.localSetup.actions.browse")}),t.jsx(T,{type:"button",size:"sm",onClick:E,disabled:i||!g.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:b,onToggle:r=>f(r.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(I,{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.jsxs(t.Fragment,{children:[t.jsx("li",{children:e("onboarding.localSetup.windows.hintInstallInWsl")}),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 xe="curl -fsSL https://opencode.ai/install | bash",ge="https://opencode.ai/docs",be="https://opencode.ai/docs/windows-wsl";function ye(l){const e=$.c(5),{onCopy:c,copyTitle:a}=l;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 x;e[1]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx(I,{name:"file-copy",className:"h-4 w-4"}),e[1]=x):x=e[1];let i;return e[2]!==a||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:a,children:x})]}),e[2]=a,e[3]=c,e[4]=i):i=e[4],i}const ve=3e4;function we({onBack:l,onCliAvailable:e,isFromRecovery:c=!1,onSwitchToRemote:a}){const{t:o}=z(),[x,i]=s.useState(!1),[n,m]=s.useState(!1),[k,g]=s.useState(!1),[_,N]=s.useState(!1),[p,h]=s.useState(!1),[w,R]=s.useState(null),[S,b]=s.useState(""),[f,j]=s.useState("unknown");s.useEffect(()=>{const d=setTimeout(()=>m(!0),ve);return()=>clearTimeout(d)},[]),s.useEffect(()=>{g(oe())},[]),s.useEffect(()=>{if(typeof navigator>"u"){j("unknown");return}const d=navigator.userAgent||"";if(/Windows/i.test(d)){j("windows");return}if(/Macintosh|Mac OS X/i.test(d)){j("macos");return}if(/Linux/i.test(d)){j("linux");return}j("unknown")},[]),s.useEffect(()=>{let d=!1;return(async()=>{try{const u=await fetch("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!u.ok)return;const r=await u.json().catch(()=>null);if(!r||d)return;const y=typeof r.opencodeBinary=="string"?r.opencodeBinary.trim():"";y&&b(y)}catch{}})(),()=>{d=!0}},[]);const v=s.useCallback(async d=>{if(!d.target.closest("button, a, input, select, textarea, code")&&d.button===0&&k&&L())try{const{getCurrentWindow:u}=await le(async()=>{const{getCurrentWindow:y}=await import("./vendor-.bun-Bum-iBXX.js").then(K=>K.bP);return{getCurrentWindow:y}},__vite__mapDeps([0,1]));await u().startDragging()}catch(u){console.error("Failed to start window dragging:",u)}},[k]),C=s.useCallback(async()=>{try{const d=await fetch("/health");if(!d.ok)return!1;const u=await d.json();return u.openCodeRunning===!0||u.isOpenCodeReady===!0}catch{return!1}},[]),U=s.useCallback(async()=>{if(typeof window>"u"||!k||!L())return;const d=window.__TAURI__;if(d?.dialog?.open)try{const u=await d.dialog.open({title:o("onboarding.localSetup.dialog.selectOpencodeBinary"),multiple:!1,directory:!1});typeof u=="string"&&u.trim().length>0&&b(u.trim())}catch{}},[k,o]),D=s.useCallback(async()=>{N(!0);try{if(await ne({opencodeBinary:S.trim()}),L()){await W();return}await fetch("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>N(!1),1e3)}},[S]),A=s.useCallback(async()=>{const d=await se(xe);d.ok?(i(!0),setTimeout(()=>i(!1),2e3)):console.error("Failed to copy:",d.error)},[]),E=s.useCallback(async()=>{h(!0),R(null);try{await C()?e?.():R(o("onboarding.localSetup.errors.cliNotReady"))}catch(d){R(d instanceof Error?d.message:o("onboarding.localSetup.errors.detectionFailed"))}finally{h(!1)}},[C,e,o]),F=f==="windows"?be:ge,B=f==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":f==="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:v,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(T,{variant:"ghost",onClick:l,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")})]}),f==="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.jsxs("li",{children:[o("onboarding.localSetup.windows.stepInstallWsl")," ",t.jsx("code",{className:"text-foreground/80",children:"wsl --install"})," ",o("onboarding.localSetup.windows.stepInstallWslSuffix")]}),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:x?t.jsxs("div",{className:"flex items-center justify-center gap-2",style:{color:"var(--status-success)"},children:[t.jsx(I,{name:"check",className:"h-4 w-4"}),o("onboarding.common.status.copiedToClipboard")]}):t.jsx(ye,{onCopy:A,copyTitle:o("onboarding.common.copyToClipboard")})})}),t.jsxs("a",{href:F,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(f==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),t.jsx(I,{name:"external-link",className:"h-3 w-3"})]}),w&&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:w}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(T,{type:"button",onClick:E,disabled:p,className:"w-full max-w-xs",size:"lg",children:o(p?"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(H,{value:S,onChange:d=>b(d.target.value),placeholder:B,disabled:_,className:"flex-1 font-mono text-xs"}),t.jsx(T,{type:"button",variant:"secondary",onClick:U,disabled:_||!k||!L(),children:o("onboarding.localSetup.actions.browse")}),t.jsx(T,{type:"button",onClick:D,disabled:_,children:o("onboarding.localSetup.actions.apply")})]}),t.jsx("div",{className:"text-xs text-muted-foreground/70",children:o("onboarding.localSetup.helper.saveAndReload")})]})}),c&&a&&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(T,{variant:"link",onClick:a,children:o("onboarding.localSetup.actions.connectRemoteServer")})]})]}),n&&t.jsx("div",{className:"absolute bottom-8 left-0 right-0 text-center space-y-1",children:f==="windows"?t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.windows.hintInstallInWsl")}),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 ee(l,e){if(l?.trim())return G(l.trim());if(e)return G(e)}function je(l,e,c){switch(l){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 a=ee(e,c);return{title:"Remote Server Unreachable",description:`Could not connect to "${a||"the remote server"}". Check your network connection and verify the server address.`,titleKey:"onboarding.desktopRecovery.remoteUnreachable.title",descriptionKey:"onboarding.desktopRecovery.remoteUnreachable.description",descriptionParams:a?{host:a}: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 a=ee(e,c);return{title:"Incompatible Server",description:`The server at "${a||"unknown"}" is not running OpenChamber. Verify the address points to an OpenChamber server.`,titleKey:"onboarding.desktopRecovery.incompatibleServer.title",descriptionKey:"onboarding.desktopRecovery.incompatibleServer.description",descriptionParams:a?{host:a}: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"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 a=l;throw new Error(`Unknown recovery variant: ${a}`)}}}function ke(l){switch(l){case"local":return t.jsx(I,{name:"macbook",className:"h-8 w-8"});case"remote":return t.jsx(I,{name:"server",className:"h-8 w-8"})}}function Ce({variant:l,hostLabel:e,hostUrl:c,onRetry:a,onUseLocal:o,onUseRemote:x,isRetrying:i=!1}){const{t:n}=z(),m=je(l,e,c),k=m.retryLabelKey??"onboarding.desktopRecovery.actions.retryConnection",g=s.useMemo(()=>{if(m.descriptionParams?.host)return m.descriptionParams;if(l==="remote-unreachable")return{host:n("onboarding.desktopRecovery.placeholders.remoteServer")};if(l==="remote-wrong-service")return{host:n("onboarding.desktopRecovery.placeholders.unknownServer")}},[m.descriptionParams,n,l]);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:ke(m.iconKey)})}),t.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:n(m.titleKey)}),t.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:n(m.descriptionKey,g)})]}),c&&(l==="remote-unreachable"||l==="remote-wrong-service")&&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:n("onboarding.remoteConnection.field.serverAddress")}),t.jsx("div",{className:"font-mono text-sm text-foreground truncate",children:G(c)})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[m.showRetry&&a&&t.jsxs(T,{onClick:a,disabled:i,className:"w-full",children:[t.jsx(I,{name:"refresh",className:Y("h-4 w-4",i&&"animate-spin")}),n(i?"onboarding.desktopRecovery.actions.retrying":k)]}),t.jsxs("div",{className:"flex gap-2",children:[m.showUseLocal&&o&&t.jsxs(T,{variant:"outline",onClick:o,disabled:i,className:"flex-1",children:[t.jsx(I,{name:"macbook",className:"h-4 w-4"}),n(m.useLocalLabelKey)]}),m.showUseRemote&&x&&t.jsxs(T,{variant:"outline",onClick:x,disabled:i,className:"flex-1",children:[t.jsx(I,{name:"server",className:"h-4 w-4"}),n(m.useRemoteLabelKey)]})]})]})]})})}function te(l,e){if(e==="use-remote")return{kind:"remote-form"};switch(l){case"local-unavailable":return{kind:"local-setup"};case"remote-unreachable":case"remote-wrong-service":case"remote-missing":case"missing-default-host":return{kind:"switch-default-to-local"};default:{const c=l;throw new Error(`Unhandled RecoveryVariant: ${c}`)}}}function Se(l){const e=$.c(27),{variant:c,hostUrl:a,hostLabel:o,onRetry:x,onChooseRemote:i,showRemoteForm:n,onCloseRemoteForm:m,onSwitchToLocalFromRemote:k,onEnterLocalSetup:g,isRetrying:_}=l,N=n===void 0?!1:n,p=_===void 0?!1:_,h=Ne;let w;e[0]!==x?(w=async()=>{if(L()){await W();return}await fetch("/api/config/reload",{method:"POST"}),x?.()},e[0]=x,e[1]=w):w=e[1];const R=w;let S;e[2]!==g||e[3]!==c?(S=async()=>{if(te(c,"use-local").kind==="local-setup"){g?.();return}if(await h("local"),L()){await W();return}window.location.reload()},e[2]=g,e[3]=c,e[4]=S):S=e[4];const b=S;let f;e[5]!==i||e[6]!==c?(f=()=>{te(c,"use-remote").kind==="remote-form"&&i?.()},e[5]=i,e[6]=c,e[7]=f):f=e[7];const j=f;if(N){const C=c==="remote-wrong-service"?"":a||"",U=c==="remote-wrong-service"?"":o||"";let D;e[8]!==i||e[9]!==m?(D=m||(()=>i?.()),e[8]=i,e[9]=m,e[10]=D):D=e[10];let A;e[11]!==g||e[12]!==k?(A=k||(()=>{h("local").then(()=>{L()?W():g?.()})}),e[11]=g,e[12]=k,e[13]=A):A=e[13];let E;return e[14]!==U||e[15]!==C||e[16]!==D||e[17]!==A?(E=t.jsx(ae,{onBack:D,initialUrl:C,initialLabel:U,isRecoveryMode:!0,onSwitchToLocal:A}),e[14]=U,e[15]=C,e[16]=D,e[17]=A,e[18]=E):E=e[18],E}let v;return e[19]!==R||e[20]!==b||e[21]!==j||e[22]!==o||e[23]!==a||e[24]!==p||e[25]!==c?(v=t.jsx(Ce,{variant:c,hostLabel:o,hostUrl:a,onRetry:R,onUseLocal:b,onUseRemote:j,isRetrying:p}),e[19]=R,e[20]=b,e[21]=j,e[22]=o,e[23]=a,e[24]=p,e[25]=c,e[26]=v):v=e[26],v}async function Ne(l){if(!L())return;const e=await X();await Q({...e,...l==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})}function Ue(l){const e=$.c(26),{onBack:c,onCliAvailable:a,mode:o,recoveryVariant:x,recoveryHostUrl:i,recoveryHostLabel:n,onEnterLocalSetup:m}=l,k=o===void 0?"first-launch":o,g=x===void 0?"missing-default-host":x,[_,N]=s.useState(!1),[p,h]=s.useState(!1);let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{h(!1),N(!1)},e[0]=w):w=e[0];let R;e[1]!==k||e[2]!==n||e[3]!==i||e[4]!==g?(R=[k,g,i,n],e[1]=k,e[2]=n,e[3]=i,e[4]=g,e[5]=R):R=e[5],s.useEffect(w,R);const S=p?"local-setup":k;if(S==="recovery"){let f,j;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=()=>N(!1),j=()=>{N(!1),h(!0)},e[6]=f,e[7]=j):(f=e[6],j=e[7]);let v;e[8]!==m?(v=()=>{h(!0),m?.()},e[8]=m,e[9]=v):v=e[9];let C;return e[10]!==n||e[11]!==i||e[12]!==g||e[13]!==_||e[14]!==v?(C=t.jsx(Se,{variant:g,hostUrl:i,hostLabel:n,showRemoteForm:_,onCloseRemoteForm:f,onSwitchToLocalFromRemote:j,onEnterLocalSetup:v}),e[10]=n,e[11]=i,e[12]=g,e[13]=_,e[14]=v,e[15]=C):C=e[15],C}if(S==="local-setup"){let f;e[16]!==c||e[17]!==p?(f=()=>{p?h(!1):c?.()},e[16]=c,e[17]=p,e[18]=f):f=e[18];let j;e[19]===Symbol.for("react.memo_cache_sentinel")?(j=()=>N(!0),e[19]=j):j=e[19];let v;return e[20]!==a||e[21]!==p||e[22]!==f?(v=t.jsx(we,{onBack:f,onCliAvailable:a,isFromRecovery:p,onSwitchToRemote:j}),e[20]=a,e[21]=p,e[22]=f,e[23]=v):v=e[23],v}let b;return e[24]!==a?(b=t.jsx(fe,{onCliAvailable:a}),e[24]=a,e[25]=b):b=e[25],b}export{Ue as OnboardingScreen};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as h,R as b,j as t,aP as w,aR as j,aV as v,aU as D,aS as R}from"./vendor-.bun-Bum-iBXX.js";import{u as S,c as g}from"./modelPrefsAutoSave-
|
|
1
|
+
import{c as h,R as b,j as t,aP as w,aR as j,aV as v,aU as D,aS as R}from"./vendor-.bun-Bum-iBXX.js";import{u as S,c as g}from"./modelPrefsAutoSave-DRJSYigo.js";import{a as k}from"./main-d2-dY4er.js";import"./index-B9LvUHdG.js";const P=x=>{const e=h.c(19),{open:m,onOpenChange:a}=x,{t:u}=S(),n=b.useId(),y=_;let s;e[0]!==a?(s=f=>{!f&&y()||a(f)},e[0]=a,e[1]=s):s=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx(w,{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]!==u?(o=u("settings.window.description"),e[4]=u,e[5]=o):o=e[5];let i;e[6]!==n||e[7]!==o?(i=t.jsx(j,{id:n,className:"sr-only",children:o}),e[6]=n,e[7]=o,e[8]=i):i=e[8];let l;e[9]!==a?(l=t.jsx(k,{onClose:()=>a(!1),isWindowed:!0}),e[9]=a,e[10]=l):l=e[10];let r;e[11]!==n||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(D,{"aria-describedby":n,className:d,children:[i,l]})})]}),e[11]=n,e[12]=i,e[13]=l,e[14]=r):r=e[14];let p;return e[15]!==m||e[16]!==s||e[17]!==r?(p=t.jsx(R,{open:m,onOpenChange:s,children:r}),e[15]=m,e[16]=s,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{P as SettingsWindow};
|