@openchamber/web 1.11.1 → 1.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{JsonTreeView-bLRkNPS9.js → JsonTreeView-9F0tH9yA.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-FSTq-eVA.js → MarkdownRendererImpl-C3QofAGm.js} +1 -1
- package/dist/assets/{MultiRunWindow-DezP_Pyy.js → MultiRunWindow-wnUGv0Dl.js} +1 -1
- package/dist/assets/{OnboardingScreen-CeZMVgH8.js → OnboardingScreen-17dAs0NH.js} +2 -2
- package/dist/assets/{SettingsWindow-Dlfk0yzA.js → SettingsWindow-BgyVY5gz.js} +1 -1
- package/dist/assets/TerminalView-D11XIZuz.js +1 -0
- package/dist/assets/{ToolOutputDialog-CePopKV7.js → ToolOutputDialog-DFG7ANVw.js} +6 -6
- package/dist/assets/es-Chl2Hu6K.js +15 -0
- package/dist/assets/index-0bVkxg-Z.css +1 -0
- package/dist/assets/{index-CKlDk4Io.js → index-BV2XTsJJ.js} +1 -1
- package/dist/assets/ko-BSrH3F9n.js +15 -0
- package/dist/assets/{main-BvaFBcXN.js → main-BHkNwOz1.js} +2 -2
- package/dist/assets/main-Bqf4fXgq.js +225 -0
- package/dist/assets/miniChat-BmB-E5xo.js +2 -0
- package/dist/assets/{modelPrefsAutoSave-HUPrH1r2.js → modelPrefsAutoSave-2uwW8uD9.js} +98 -96
- package/dist/assets/pl-YlGvPmFg.js +15 -0
- package/dist/assets/pt-BR-BonIMDN_.js +15 -0
- package/dist/assets/{renderElectronMiniChatApp-EXGwfTjq.js → renderElectronMiniChatApp-B_qrXCU2.js} +2 -2
- package/dist/assets/uk-lPqA3MHn.js +15 -0
- package/dist/assets/{vendor-.bun-BFTPeDgG.js → vendor-.bun-Boz6Tqcq.js} +20 -20
- package/dist/assets/zh-CN-C5nQQsUL.js +15 -0
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +4 -4
- package/package.json +1 -1
- package/server/lib/git/DOCUMENTATION.md +1 -0
- package/server/lib/git/routes.js +26 -0
- package/server/lib/git/service.js +96 -10
- package/server/lib/git/service.test.js +39 -0
- package/server/lib/opencode/settings-helpers.js +10 -1
- package/server/lib/opencode/settings-helpers.test.js +35 -0
- package/server/lib/opencode/skill-routes.js +43 -49
- package/server/lib/opencode/skills.js +78 -10
- package/dist/assets/TerminalView-CdCfCaFq.js +0 -1
- package/dist/assets/es-CyjenLd8.js +0 -15
- package/dist/assets/index-NnYXwoao.css +0 -1
- package/dist/assets/ko-Cs7yF9Jn.js +0 -15
- package/dist/assets/main-DcpUnRRo.js +0 -225
- package/dist/assets/miniChat-Dmzb8Mwv.js +0 -2
- package/dist/assets/pl-XjTt7Hsk.js +0 -15
- package/dist/assets/pt-BR-knvpJ94d.js +0 -15
- package/dist/assets/uk-DUPvcQAj.js +0 -15
- package/dist/assets/zh-CN-DWiTG93s.js +0 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as s,j as e}from"./vendor-.bun-
|
|
1
|
+
import{R as s,j as e}from"./vendor-.bun-Boz6Tqcq.js";import{u as j,at as u,I as x,eS as b}from"./modelPrefsAutoSave-2uwW8uD9.js";const N=s.memo(function({jsonString:t,className:l,maxHeight:i="100%",initiallyExpandedDepth:m=2}){const{t:r}=j(),n=s.useRef(null),[c,o]=s.useState(null),d=s.useMemo(()=>{try{const a=t.trim();if(!a)return o(r("jsonTreeView.error.emptyJson")),null;const f=JSON.parse(a);return o(null),f}catch(a){return o(a instanceof Error?a.message:r("jsonTreeView.error.invalidJson")),null}},[t,r]),p=s.useCallback(()=>{n.current?.expandAll()},[]),v=s.useCallback(()=>{n.current?.collapseAll()},[]);return c?e.jsx("div",{className:l,children:e.jsxs("div",{className:"rounded-md border border-[var(--interactive-border)] bg-[var(--syntax-base-background)] p-4",children:[e.jsx("div",{className:"mb-1 font-medium text-[var(--surface-foreground)]",children:r("jsonTreeView.error.invalidJsonTitle")}),e.jsx("div",{className:"font-mono text-xs text-[var(--surface-mutedForeground)]",children:c})]})}):d===null?null:e.jsxs("div",{className:l,children:[e.jsxs("div",{className:"flex items-center gap-1 border-b border-[var(--interactive-border)] px-2 py-1",children:[e.jsxs(u,{variant:"ghost",size:"xs",onClick:p,className:"gap-1 text-xs text-muted-foreground",children:[e.jsx(x,{name:"arrow-down-s",className:"h-3 w-3"}),r("jsonTreeView.actions.expandAll")]}),e.jsxs(u,{variant:"ghost",size:"xs",onClick:v,className:"gap-1 text-xs text-muted-foreground",children:[e.jsx(x,{name:"arrow-up-s",className:"h-3 w-3"}),r("jsonTreeView.actions.collapseAll")]})]}),e.jsx("div",{className:"bg-[var(--syntax-base-background)] py-1",style:{maxHeight:i,overflow:"auto"},children:e.jsx(b,{ref:n,data:d,maxHeight:i,initiallyExpandedDepth:m})})]})});export{N as J};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{R as C,c as V,by as We,bz as Ue,j as a,bA as He,bB as Ve,bC as qe,bD as Ze,bE as Ke,bF as Ge,
|
|
1
|
+
import{R as C,c as V,by as We,bz as Ue,j as a,bA as He,bB as Ve,bC as qe,bD as Ze,bE as Ke,bF as Ge,am as Ye}from"./vendor-.bun-Boz6Tqcq.js";import{M as Ce,bg as Re,a as be,u as le,bM as Ee,c as L,b1 as Qe,b3 as ke,eP as Je,eQ as he,O as Xe,eR as et,I as U,b as ge,v as se,w as Te}from"./modelPrefsAutoSave-2uwW8uD9.js";import"./index-BV2XTsJJ.js";const we=()=>{const t=V.c(4),e=Qe();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=ke(!1),t[0]=n):n=t[0];const s=n;let r;t[1]===Symbol.for("react.memo_cache_sentinel")?(r=ke(!0),t[1]=r):r=t[1];const o=r;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=V.c(4),{containerRef:n,enabled:s}=t;let r,o;e[0]!==n||e[1]!==s?(r=()=>{if(s===!1)return;const i=n.current;if(!i)return;const c=Mt;return i.addEventListener("click",c),()=>{i.removeEventListener("click",c)}},o=[n,s],e[0]=n,e[1]=s,e[2]=r,e[3]=o):(r=e[2],o=e[3]),C.useEffect(r,o)},Ae=t=>{const e=[],n=[],s=t.querySelector("thead");s&&s.querySelectorAll("th").forEach(i=>e.push(i.innerText.trim()));const r=t.querySelector("tbody");return r&&r.querySelectorAll("tr").forEach(i=>{const c=i.querySelectorAll("td"),d=[];c.forEach(l=>d.push(l.innerText.trim())),n.push(d)}),{headers:e,rows:n}},Le=({headers:t,rows:e})=>{const n=r=>r.includes(",")||r.includes('"')||r.includes(`
|
|
2
2
|
`)?`"${r.replace(/"/g,'""')}"`:r,s=[];return t.length>0&&s.push(t.map(n).join(",")),e.forEach(r=>s.push(r.map(n).join(","))),s.join(`
|
|
3
3
|
`)},tt=({headers:t,rows:e})=>{const n=r=>r.replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r"),s=[];return t.length>0&&s.push(t.map(n).join(" ")),e.forEach(r=>s.push(r.map(n).join(" "))),s.join(`
|
|
4
4
|
`)},rt=({headers:t,rows:e})=>{if(t.length===0)return"";const n=r=>r.replace(/\\/g,"\\\\").replace(/\|/g,"\\|"),s=[];return s.push(`| ${t.map(n).join(" | ")} |`),s.push(`| ${t.map(()=>"---").join(" | ")} |`),e.forEach(r=>{const o=t.map((i,c)=>n(r[c]||""));s.push(`| ${o.join(" | ")} |`)}),s.join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as _,R as k,j as n,aW as D,aY as C,b0 as I,a$ as M,aZ as S}from"./vendor-.bun-
|
|
1
|
+
import{c as _,R as k,j as n,aW as D,aY as C,b0 as I,a$ as M,aZ as S}from"./vendor-.bun-Boz6Tqcq.js";import{u as z,c as w,I as O}from"./modelPrefsAutoSave-2uwW8uD9.js";import{M as P}from"./main-Bqf4fXgq.js";import"./index-BV2XTsJJ.js";import"./JsonTreeView-9F0tH9yA.js";const F=R=>{const e=_.c(33),{open:b,onOpenChange:t,initialPrompt:v}=R,a=k.useId(),{t:i}=z(),N=W;let o;e[0]!==t?(o=j=>{!j&&N()||t(j)},e[0]=t,e[1]=o):o=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 s;e[4]!==t?(s=()=>t(!1),e[4]=t,e[5]=s):s=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(O,{name:"close",className:"h-5 w-5"}),e[8]=h):h=e[8];let r;e[9]!==s||e[10]!==l?(r=n.jsx("div",{className:"absolute right-0.5 top-0.5 z-50",children:n.jsx("button",{type:"button",onClick:s,"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]=s,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(P,{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(M,{"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]!==o||e[31]!==p?(y=n.jsx(S,{open:b,onOpenChange:o,children:p}),e[29]=b,e[30]=o,e[31]=p,e[32]=y):y=e[32],y};function W(){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
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-.bun-
|
|
2
|
-
import{r as O,j as t,R as s,c as $,_ as le}from"./vendor-.bun-BFTPeDgG.js";import{u as z,eJ as ie,eK as Q,a1 as X,eL as J,m as L,at as T,al as H,N as oe,ab as ce,d as ne,cS as W,v as se,c as G,I,a3 as Y}from"./modelPrefsAutoSave-HUPrH1r2.js";import"./index-CKlDk4Io.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)}`,q={id:P,label:y,url:b},re=K?r.hosts.map(M=>M.id===P?q:M):[...r.hosts,q];await J({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 J({...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:G("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:G("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-BFTPeDgG.js").then(K=>K.bK);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 Y(l.trim());if(e)return Y(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:Y(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:G("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 J({...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
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-.bun-Boz6Tqcq.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-Boz6Tqcq.js";import{u as z,eK as ie,eL as Q,a1 as X,eM as q,m as L,at as T,al as H,N as oe,ab as ce,d as ne,cT as W,v as se,c as G,I,a3 as Y}from"./modelPrefsAutoSave-2uwW8uD9.js";import"./index-BV2XTsJJ.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:G("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:G("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-Boz6Tqcq.js").then(K=>K.bK);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 Y(l.trim());if(e)return Y(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:Y(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:G("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,aW as w,aY as j,b0 as v,a$ as D,aZ as k}from"./vendor-.bun-
|
|
1
|
+
import{c as h,R as b,j as t,aW as w,aY as j,b0 as v,a$ as D,aZ as k}from"./vendor-.bun-Boz6Tqcq.js";import{u as R,c as g}from"./modelPrefsAutoSave-2uwW8uD9.js";import{a as S}from"./main-Bqf4fXgq.js";import"./index-BV2XTsJJ.js";import"./JsonTreeView-9F0tH9yA.js";const z=x=>{const e=h.c(19),{open:m,onOpenChange:a}=x,{t:u}=R(),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(S,{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(k,{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{z as SettingsWindow};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{R as n,j as a,s as yt,bv as ht,bw as bt,bx as gt}from"./vendor-.bun-Boz6Tqcq.js";import{u as dt,v as xt,a$ as vt,c as Ue,M as Tt,bH as kt,eN as Ct,a as Ie,b as Et,V as ft,bg as Rt,I as ie,eO as et,cv as ct,at as Z}from"./modelPrefsAutoSave-2uwW8uD9.js";import{u as J,P as At,S as St}from"./main-Bqf4fXgq.js";import{a4 as It}from"./index-BV2XTsJJ.js";import"./JsonTreeView-9F0tH9yA.js";function Mt(f){const{colors:p}=f,m=p.syntax.base;return{background:p.surface.background,foreground:m.foreground,cursor:p.interactive.cursor,cursorAccent:p.surface.background,selectionBackground:p.interactive.selection,selectionForeground:p.interactive.selectionForeground,selectionInactiveBackground:p.interactive.selection+"50",black:p.surface.muted,red:p.status.error,green:p.status.success,yellow:p.status.warning,blue:m.function,magenta:m.keyword,cyan:m.type,white:m.foreground,brightBlack:m.comment,brightRed:p.status.error,brightGreen:p.status.success,brightYellow:p.status.warning,brightBlue:m.function,brightMagenta:m.keyword,brightCyan:m.type,brightWhite:p.surface.elevatedForeground}}function Bt(f,p,m,ee,de=!1){const ye=`${f}, "JetBrainsMonoNL Nerd Font", "FiraCode Nerd Font", "Cascadia Code PL", "Fira Code", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace`;return{cursorBlink:!1,cursorStyle:"bar",fontSize:p,lineHeight:1.15,fontFamily:ye,allowTransparency:!1,theme:{background:m.background,foreground:m.foreground,cursor:m.cursor,cursorAccent:m.cursorAccent,selectionBackground:m.selectionBackground,selectionForeground:m.selectionForeground,black:m.black,red:m.red,green:m.green,yellow:m.yellow,blue:m.blue,magenta:m.magenta,cyan:m.cyan,white:m.white,brightBlack:m.brightBlack,brightRed:m.brightRed,brightGreen:m.brightGreen,brightYellow:m.brightYellow,brightBlue:m.brightBlue,brightMagenta:m.brightMagenta,brightCyan:m.brightCyan,brightWhite:m.brightWhite},scrollback:1e4,ghostty:ee,disableStdin:de}}let lt=null;function Dt(){return lt||(lt=gt.load()),lt}function Nt(f){if(typeof window>"u")return null;const p=[f,...Array.from(f.querySelectorAll("*"))];let m=null;for(const ee of p){const Me=window.getComputedStyle(ee).overflowY;if(!(Me!=="auto"&&Me!=="scroll")){if(ee.scrollHeight-ee.clientHeight>2)return ee;m||(m=ee)}}return m}const pt=n.forwardRef(({sessionKey:f,chunks:p,onInput:m,onResize:ee,theme:de,fontFamily:Me,fontSize:ye,className:Be,enableTouchScroll:E,autoFocus:tt=!0,isVisible:je=!0},he)=>{const{t:F}=dt(),N=n.useRef(null),Fe=n.useRef(null),I=n.useRef(null),_e=n.useRef(null),P=n.useRef(m),ze=n.useRef(ee),h=n.useRef(null),be=n.useRef(""),te=n.useRef(null),Le=n.useRef(!1),Ke=n.useRef(null),pe=n.useRef(!0),ne=n.useRef(null),q=n.useRef(null),ge=n.useRef(0),re=n.useRef(null),qe=n.useRef(null),ce=n.useRef(!1),k=n.useRef(!1),R=n.useRef(null),me=n.useRef(null),Ye=n.useRef(null),j=n.useRef(""),Oe=n.useRef(null),xe=n.useRef(!E),$e=n.useRef(je),[,nt]=n.useReducer(e=>e+1,0),[We,O]=n.useReducer(e=>e+1,0);P.current=m,ze.current=ee;const at=typeof navigator<"u"&&(/Android/i.test(navigator.userAgent)||navigator.userAgentData?.platform==="Android"),y=!!E;n.useEffect(()=>{if(!E){xe.current=!0,$e.current=je;return}!$e.current&&je&&(xe.current=!1),$e.current=je},[E,je]);const ve=n.useCallback(()=>{if(!y)return;const e=N.current,o=re.current;if(!e)return;const s=[];e.getAttribute("contenteditable")==="true"&&s.push(e),s.push(...Array.from(e.querySelectorAll('[contenteditable="true"]'))),s.forEach(r=>{r.setAttribute("data-terminal-disabled-contenteditable","true"),r.setAttribute("contenteditable","false"),r.setAttribute("aria-hidden","true"),r.tabIndex=-1,r.style.setProperty("caret-color","transparent"),r.style.color="transparent",r.style.setProperty("-webkit-text-fill-color","transparent"),r.style.background="transparent",r.style.outline="none",r.style.boxShadow="none",r.style.textShadow="none",r.style.setProperty("user-select","none"),r.style.setProperty("-webkit-user-select","none")}),e.tabIndex=-1,e.removeAttribute("role"),e.removeAttribute("aria-multiline"),Array.from(e.querySelectorAll("textarea")).forEach(r=>{r.style.setProperty("caret-color","transparent"),r.style.color="transparent",r.style.setProperty("-webkit-text-fill-color","transparent"),r.style.background="transparent",r.style.border="0",r.style.outline="none",r.style.boxShadow="none",r.style.textShadow="none",r.style.fontSize="0",r.style.lineHeight="0",r!==o&&r.getAttribute("data-terminal-disabled-input")!=="true"&&(r.setAttribute("data-terminal-disabled-input","true"),r.setAttribute("aria-hidden","true"),r.tabIndex=-1,r.disabled=!0,r.style.position="absolute",r.style.opacity="0",r.style.width="0px",r.style.height="0px",r.style.pointerEvents="none",r.style.zIndex="-1")})},[y]),A=n.useCallback(e=>{if(Oe.current===e)return;const o=I.current;if(o)try{if(typeof o.setOption=="function"){o.setOption("cursorBlink",e),Oe.current=e;return}o.options&&(o.options.cursorBlink=e,Oe.current=e)}catch{}},[]),M=y&&at,C=n.useCallback((e,o)=>{const s=M?qe.current:re.current,c=N.current;if(!s||!c)return;const r=c.getBoundingClientRect(),v=typeof window<"u"?window.innerWidth:r.width,S=typeof window<"u"?window.innerHeight:r.height,D=r.left+r.width/2,G=r.top+r.height-12,l=typeof e=="number"?e:D,T=typeof o=="number"?o:G,V=8,H=Math.max(V,Math.min(v-V,l)),K=Math.max(V,Math.min(S-V,T));s.style.left=`${H}px`,s.style.top=`${K}px`,s.style.bottom="",(s instanceof HTMLTextAreaElement||s instanceof HTMLInputElement)&&(s.disabled=!1,s.readOnly=!1,s.removeAttribute("disabled"),s.removeAttribute("readonly"));try{s.focus({preventScroll:!0})}catch{try{s.focus()}catch{}}},[M]),Te=n.useCallback(()=>{if(y){C(),A(!0);return}I.current?.focus(),A(!0)},[C,A,y]),le=n.useCallback(e=>e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement?e.value:e.textContent??"",[]),W=n.useCallback(e=>{if(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement){e.value="";return}e.textContent=""},[]),He=n.useCallback(e=>{if(typeof window>"u"||M)return;Ye.current!==null&&(window.clearTimeout(Ye.current),Ye.current=null);let o=0;const s=3,c=()=>{Ye.current=window.setTimeout(()=>{Ye.current=null;const r=le(e);if(!r){if(o+=1,o<s){c();return}return}const v=j.current;j.current=r;const S=r.startsWith(v)?r.slice(v.length):r;S&&P.current(S.replace(/\r\n|\r|\n/g,"\r")),W(e),j.current=""},o===0?0:24)};c()},[W,le,M]);n.useEffect(()=>{const e=N.current;if(!y||!e||E)return;const o=s=>{const c=s.target;if(c&&c.getAttribute("data-terminal-hidden-input")!=="true"&&e.contains(c)){try{c.blur()}catch{}C()}};return e.addEventListener("focusin",o,!0),()=>{e.removeEventListener("focusin",o,!0)}},[E,y,C]);const De=n.useCallback(()=>{const e=I.current;if(!e||typeof e.getSelection!="function")return"";const o=e.getSelection();return typeof o=="string"?o:""},[]),ue=n.useCallback(()=>{if(typeof window>"u")return"";const e=window.getSelection();if(!e)return"";const o=e.toString();if(!o.trim())return"";const s=N.current;if(!s)return"";const c=e.anchorNode,r=e.focusNode;return c&&!s.contains(c)||r&&!s.contains(r)?"":o},[]),ke=n.useCallback(async()=>{if(typeof document>"u")return;const e=De()||ue();e.trim()&&await xt(e)},[ue,De]),X=n.useCallback(()=>De().trim()?!0:!!ue().trim(),[ue,De]);n.useEffect(()=>{if(typeof window>"u")return;const e=o=>{X()&&(o.preventDefault(),ke())};return window.addEventListener("openchamber:copy",e),()=>{window.removeEventListener("openchamber:copy",e)}},[ke,X]);const U=n.useCallback(()=>{be.current="",te.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(te.current),te.current=null,Le.current=!1,Ke.current=null},[]),L=n.useCallback(()=>{const e=_e.current,o=I.current,s=N.current;if(!e||!o||!s)return;const c=s.getBoundingClientRect();if(!(c.width<24||c.height<24))try{e.fit();const r={cols:o.cols,rows:o.rows},v=h.current;(!v||v.cols!==r.cols||v.rows!==r.rows)&&(h.current=r,ze.current(r.cols,r.rows))}catch{}},[]),Ne=n.useCallback(()=>{if(Le.current)return;const e=I.current;if(!e){U();return}if(!be.current)return;const o=be.current;be.current="",Le.current=!0,e.write(o,()=>{Le.current=!1,be.current&&(typeof window<"u"?te.current=window.requestAnimationFrame(()=>{te.current=null,Ne()}):Ne())})},[U]),Ge=n.useCallback(()=>{te.current===null&&(typeof window<"u"?te.current=window.requestAnimationFrame(()=>{te.current=null,Ne()}):Ne())},[Ne]),Xe=n.useCallback(e=>{e&&(be.current+=e,Ge())},[Ge]),Ce=n.useCallback(()=>{if(ne.current?.(),ne.current=null,q.current!==null&&typeof window<"u"&&(window.clearTimeout(q.current),q.current=null),!E){ge.current=0;return}const e=N.current;if(!e)return;const o=I.current;if(!o)return;ge.current=0;const s=2.2,c=2.8,r=25,v=.25,S=8,D=.05,G=.015,l={lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1},T=()=>typeof performance<"u"?performance.now():Date.now(),V=Math.max(12,Math.round(ye*1.35));let H=0;const K=t=>{if(!t)return!1;const u=o.getViewportY(),i=H+t,b=Math.trunc(i/V);return H=i-b*V,b!==0&&o.scrollLines(b),o.getViewportY()!==u},Y=()=>{l.rafId!==null&&typeof window<"u"&&window.cancelAnimationFrame(l.rafId),l.rafId=null},x={passive:!1,capture:!1};if(typeof window<"u"&&"PointerEvent"in window){const t=Object.assign(l,{pointerId:null,startX:null,startY:null,moved:!1}),u=6,i=d=>{if(d.pointerType==="touch"){Y(),t.pointerId=d.pointerId,t.startX=d.clientX,t.startY=d.clientY,t.moved=!1,t.lastY=d.clientY,t.lastTime=T(),t.velocity=0;try{e.setPointerCapture(d.pointerId)}catch{}}},b=d=>{if(d.pointerType!=="touch"||t.pointerId!==d.pointerId)return;if(t.startX!==null&&t.startY!==null&&!t.moved){const mt=d.clientX-t.startX,wt=d.clientY-t.startY;Math.hypot(mt,wt)>=u&&(t.moved=!0)}if(t.lastY===null){t.lastY=d.clientY,t.lastTime=T();return}const _=t.lastY,oe=t.lastTime??T(),$=T();t.lastY=d.clientY,t.lastTime=$;const ae=_-d.clientY;if(Math.abs(ae)<1)return;const Se=Math.max($-oe,8),se=s+Math.min(c,Math.abs(ae)/r),Pe=ae*se,Je=Pe/Se;t.velocity=t.velocity*(1-v)+Je*v,t.velocity>S?t.velocity=S:t.velocity<-S&&(t.velocity=-S),t.moved&&(d.cancelable&&d.preventDefault(),d.stopPropagation()),K(Pe)},w=d=>{if(d.pointerType!=="touch"||t.pointerId!==d.pointerId)return;const _=!t.moved;t.pointerId=null,t.startX=null,t.startY=null,t.moved=!1,t.lastY=null,t.lastTime=null;try{e.releasePointerCapture(d.pointerId)}catch{}if(_){y?C(d.clientX,d.clientY):E&&!xe.current&&(xe.current=!0,I.current?.focus());return}if(typeof window>"u")return;if(Math.abs(t.velocity)<D){t.velocity=0;return}let oe=T();const $=()=>{const ae=T(),Se=Math.max(ae-oe,8);oe=ae;const se=K(t.velocity*Se)??!1,Pe=Math.sign(t.velocity),Je=Math.max(0,Math.abs(t.velocity)-G*Se);if(t.velocity=Je*Pe,!se||Je<=D){Y(),t.velocity=0;return}t.rafId=window.requestAnimationFrame($)};t.rafId=window.requestAnimationFrame($)};e.addEventListener("pointerdown",i,x),e.addEventListener("pointermove",b,x),e.addEventListener("pointerup",w,x),e.addEventListener("pointercancel",w,x);const g=e.style.touchAction;e.style.touchAction="manipulation",ne.current=()=>{Y(),q.current!==null&&typeof window<"u"&&(window.clearTimeout(q.current),q.current=null),ge.current=0,e.removeEventListener("pointerdown",i,x),e.removeEventListener("pointermove",b,x),e.removeEventListener("pointerup",w,x),e.removeEventListener("pointercancel",w,x),e.style.touchAction=g};return}const Re=6,z=t=>{t.touches.length===1&&(Y(),l.lastY=t.touches[0].clientY,l.lastTime=T(),l.velocity=0,l.startX=t.touches[0].clientX,l.startY=t.touches[0].clientY,l.didMove=!1)},Ve=t=>{if(t.touches.length!==1){l.lastY=null,l.lastTime=null,l.velocity=0,l.startX=null,l.startY=null,l.didMove=!1,Y();return}const u=t.touches[0].clientX,i=t.touches[0].clientY;if(l.startX!==null&&l.startY!==null&&!l.didMove){const Se=u-l.startX,se=i-l.startY;Math.hypot(Se,se)>=Re&&(l.didMove=!0)}if(l.lastY===null){l.lastY=i,l.lastTime=T();return}const b=l.lastY,w=l.lastTime??T(),g=T();l.lastY=i,l.lastTime=g;const d=b-i;if(Math.abs(d)<1)return;const _=Math.max(g-w,8),oe=s+Math.min(c,Math.abs(d)/r),$=d*oe,ae=$/_;l.velocity=l.velocity*(1-v)+ae*v,l.velocity>S?l.velocity=S:l.velocity<-S&&(l.velocity=-S),l.didMove&&(t.preventDefault(),t.stopPropagation()),K($)},Ae=t=>{const u=!l.didMove;l.lastY=null,l.lastTime=null;const i=l.velocity;if(l.startX=null,l.startY=null,l.didMove=!1,u){const g=t.changedTouches?.[0];y?C(g?.clientX,g?.clientY):E&&!xe.current&&(xe.current=!0,I.current?.focus());return}if(typeof window>"u")return;if(Math.abs(i)<D){l.velocity=0;return}let b=T();const w=()=>{const g=T(),d=Math.max(g-b,8);b=g;const _=K(l.velocity*d)??!1,oe=Math.sign(l.velocity),$=Math.max(0,Math.abs(l.velocity)-G*d);if(l.velocity=$*oe,!_||$<=D){Y(),l.velocity=0;return}l.rafId=window.requestAnimationFrame(w)};l.rafId=window.requestAnimationFrame(w)};e.addEventListener("touchstart",z,x),e.addEventListener("touchmove",Ve,x),e.addEventListener("touchend",Ae,x),e.addEventListener("touchcancel",Ae,x);const Q=e.style.touchAction;e.style.touchAction="manipulation",ne.current=()=>{Y(),q.current!==null&&typeof window<"u"&&(window.clearTimeout(q.current),q.current=null),ge.current=0,e.removeEventListener("touchstart",z,x),e.removeEventListener("touchmove",Ve,x),e.removeEventListener("touchend",Ae,x),e.removeEventListener("touchcancel",Ae,x),e.style.touchAction=Q}},[E,y,C,ye]);n.useEffect(()=>{let e=!1,o=null,s=null,c=null,r=[],v=null,S=null;const D=N.current;if(!D)return;if(D.tabIndex=y?-1:0,y){const Y=D.focus.bind(D),x=D;x.focus=((...B)=>{C()}),S=()=>{x.focus=Y}}const G=()=>{A(!0)},l=()=>{A(!1)},T=Y=>{const x=Y.target;if(x&&D.contains(x)){if(y&&x instanceof HTMLElement){window.setTimeout(()=>{x.blur(),C()},0),A(!1);return}if(E&&!xe.current&&x instanceof HTMLElement){window.setTimeout(()=>{x.blur()},0),A(!1);return}A(!0);return}A(!1)},V=()=>{A(!1)};let H=null;return(async()=>{try{const Y=await Dt();if(e)return;const x=Bt(Me,ye,de,Y,!1),B=new ht(x);pe.current=!0,y&&(B.focus=()=>{});const Re=B;if(typeof Re.scrollToBottom=="function"){const Q=Re.scrollToBottom.bind(Re);Re.scrollToBottom=()=>{pe.current&&Q()},v=()=>{Re.scrollToBottom=Q}}const z=new bt;o=B,I.current=B,_e.current=z,B.loadAddon(z),B.open(D),O(),Oe.current=!1,H=B.textarea??D.querySelector("textarea"),H&&(H.addEventListener("focus",G),H.addEventListener("blur",l)),ve(),typeof MutationObserver<"u"&&(c=new MutationObserver(()=>{ve()}),c.observe(D,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["contenteditable","role","tabindex","aria-label"]}));const Ve=Nt(D);Ve?(Ve.classList.add("overlay-scrollbar-target","overlay-scrollbar-container"),Fe.current=Ve,nt()):Fe.current=null,L();const Ae=z;typeof Ae.observeResize=="function"&&Ae.observeResize(),Ce(),r=[B.onData(Q=>{P.current(Q)}),B.onScroll(Q=>{if(typeof Q=="number"&&Number.isFinite(Q)){const t=typeof B.hasSelection=="function"&&B.hasSelection();pe.current=!t&&Q<=.5}}),B.onSelectionChange(()=>{if(typeof B.hasSelection=="function"&&B.hasSelection()){pe.current=!1;return}const t=typeof B.getViewportY=="function"?B.getViewportY():0;pe.current=t<=.5})],s=new ResizeObserver(()=>{L()}),s.observe(D),typeof window<"u"&&window.setTimeout(()=>{L()},0)}catch{}})(),document.addEventListener("focusin",T,!0),window.addEventListener("blur",V),()=>{e=!0,ne.current?.(),ne.current=null,document.removeEventListener("focusin",T,!0),window.removeEventListener("blur",V),r.forEach(Y=>Y.dispose()),v?.(),v=null,H&&(H.removeEventListener("focus",G),H.removeEventListener("blur",l)),s?.disconnect(),c?.disconnect(),S?.(),o?.dispose(),I.current=null,_e.current=null,Fe.current=null,h.current=null,Oe.current=null,U()}},[ve,E,L,C,Me,ye,Ce,de,U,A,y]),n.useEffect(()=>{const e=I.current;e&&(e.reset(),U(),h.current=null,L())},[f,We,L,U]),n.useEffect(()=>{!tt||!I.current||Te()},[tt,Te,f,We]),n.useEffect(()=>(Ce(),()=>{ne.current?.(),ne.current=null}),[Ce,f]),n.useEffect(()=>{const e=I.current;if(!e)return;if(p.length===0){Ke.current!==null&&(e.reset(),U(),L());return}const o=Ke.current;let s;if(o===null)s=p;else{const c=p.findIndex(r=>r.id===o);s=c>=0?p.slice(c+1):p}s.length>0&&Xe(s.map(c=>c.data).join("")),Ke.current=p[p.length-1].id},[p,We,Xe,L,U]),n.useImperativeHandle(he,()=>({focus:()=>{Te()},clear:()=>{const e=I.current;e&&(e.reset(),U(),L())},fit:()=>{L()}}),[Te,L,U]);const Qe=n.useCallback(e=>{if(!y)return;const o=N.current,s=e.relatedTarget,c=s?.tagName,r=c==="INPUT"||c==="TEXTAREA"||s?.isContentEditable,v=s?.getAttribute("data-terminal-hidden-input")==="true",S=!!(s&&o?.contains(s))},[y]),we=n.useCallback(e=>{const o=e.nativeEvent,s=o?.inputType??"",c=typeof o?.data=="string"?o.data:"";if(me.current=typeof performance<"u"?performance.now():Date.now(),s==="insertCompositionText"){ce.current=!0;return}if(!s&&c){if(ce.current)return;e.preventDefault(),P.current(c),R.current={type:"insertText",at:typeof performance<"u"?performance.now():Date.now()},k.current=!0;return}if(s==="insertText"&&c){if(ce.current)return;e.preventDefault(),P.current(c),R.current={type:s,at:typeof performance<"u"?performance.now():Date.now()},k.current=!0;return}if(s==="insertLineBreak"){if(ce.current)return;e.preventDefault(),P.current("\r"),R.current={type:s,at:typeof performance<"u"?performance.now():Date.now()},k.current=!0;return}if(s==="deleteContentBackward"){if(ce.current)return;e.preventDefault(),P.current(""),R.current={type:s,at:typeof performance<"u"?performance.now():Date.now()},k.current=!0}},[]),fe=n.useCallback(e=>{const o=e.currentTarget;if(me.current=typeof performance<"u"?performance.now():Date.now(),ce.current)return;if(k.current){const r=R.current,v=typeof performance<"u"?performance.now():Date.now();if(r&&v-r.at<50){k.current=!1,W(o);return}k.current=!1}const s=le(o);if(!s)return;j.current=s;const c=s.replace(/\r\n|\r|\n/g,"\r");P.current(c),W(o),j.current=""},[W,le]),rt=n.useCallback(e=>{e.stopPropagation();const o=e.key.toLowerCase(),s=e.metaKey&&!e.ctrlKey&&!e.altKey&&o==="c",c=e.ctrlKey&&e.shiftKey&&!e.metaKey&&!e.altKey&&o==="c";if((s||c)&&X()){e.preventDefault(),ke();return}if(e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.length===1){const V=e.key.toUpperCase();if(V>="A"&&V<="Z"){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),P.current(String.fromCharCode(V.charCodeAt(0)-64)),W(e.currentTarget);return}}if(e.altKey&&!e.ctrlKey&&!e.metaKey&&e.key.length===1){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),P.current("\x1B"+e.key),W(e.currentTarget);return}const v={ArrowUp:"\x1B[A",ArrowDown:"\x1B[B",ArrowRight:"\x1B[C",ArrowLeft:"\x1B[D",Escape:"\x1B",Tab:" ",Delete:"\x1B[3~",Home:"\x1B[H",End:"\x1B[F"}[e.key];if(v){e.preventDefault(),P.current(v),W(e.currentTarget);return}const S=e.currentTarget;if(e.nativeEvent?.isComposing)return;const G=R.current,l=typeof performance<"u"?performance.now():Date.now(),T=!!(G&&l-G.at<50);if(e.key==="Enter"){if(T&&G?.type==="insertLineBreak")return;e.preventDefault(),P.current("\r"),W(S);return}if(e.key==="Backspace"){if(e.preventDefault(),T&&G?.type==="deleteContentBackward")return;le(S)||P.current("")}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const V=me.current;V&&l-V<50||(e.preventDefault(),P.current(e.key),k.current=!0,R.current={type:"keydown-text",at:l})}He(S)},[W,ke,X,le,He]),Ee=n.useCallback(e=>{e.stopPropagation();const o=e.currentTarget;e.nativeEvent?.isComposing||He(o)},[He]),ot=n.useCallback(e=>{const o=e.currentTarget;ce.current=!1;const s=e.data||le(o);if(me.current=typeof performance<"u"?performance.now():Date.now(),!s)return;const c=s.replace(/\r\n|\r|\n/g,"\r");P.current(c),W(o),R.current={type:"compositionend",at:typeof performance<"u"?performance.now():Date.now()},k.current=!0},[W,le]),st=n.useCallback(e=>{e.stopPropagation();const o=e.clipboardData?.getData("text")??"";if(!o)return;e.preventDefault();const c=I.current?.hasBracketedPaste?.()?`\x1B[200~${o}\x1B[201~`:o;P.current(c)},[]),Ze={position:"fixed",left:0,top:0,width:1,height:1,opacity:0,zIndex:-1,background:"transparent",color:"transparent",WebkitTextFillColor:"transparent",caretColor:"transparent",textShadow:"none",WebkitAppearance:"none",appearance:"none",resize:"none",overflow:"hidden",whiteSpace:"nowrap",border:"0",padding:0,margin:0,outline:"none",outlineOffset:0,fontSize:16,fontWeight:400,pointerEvents:"none",WebkitUserSelect:"none",userSelect:"none"};return a.jsxs("div",{ref:N,className:Ue("relative h-full w-full terminal-viewport-container",Be),"data-hidden-input-overlay-active":y?"true":void 0,style:{backgroundColor:de.background},onTouchStart:e=>{if(!(!y||E)&&!X()){const o=e.touches?.[0];C(o?.clientX,o?.clientY)}},onClick:e=>{if(!E)if(y){if(X())return;C(e.clientX,e.clientY)}else I.current?.focus()},onMouseUp:()=>{!E&&X()&&ke()},onTouchEnd:()=>{!E&&X()&&ke()},children:[y&&typeof document<"u"?yt.createPortal(a.jsxs(a.Fragment,{children:[a.jsx("input",{ref:qe,type:"text",inputMode:"text",autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,tabIndex:-1,enterKeyHint:"send","data-terminal-hidden-input":"true","aria-label":F("terminalView.viewport.inputAria"),"aria-hidden":"true",style:{...Ze,display:M?"block":"none"},onBlur:Qe,onBeforeInput:we,onCompositionStart:()=>{ce.current=!0},onInput:fe,onKeyDown:rt,onKeyUp:Ee,onCompositionEnd:ot,onPaste:st}),a.jsx("textarea",{ref:re,inputMode:"text",autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",spellCheck:!1,tabIndex:-1,enterKeyHint:"send","data-terminal-hidden-input":"true","aria-label":F("terminalView.viewport.inputAria"),"aria-hidden":"true",style:{...Ze,display:M?"none":"block"},onBlur:Qe,onBeforeInput:we,onCompositionStart:()=>{ce.current=!0},onInput:fe,onKeyDown:rt,onKeyUp:Ee,onCompositionEnd:ot,onPaste:st})]}),document.body):null,Fe.current&&!E?a.jsx(vt,{containerRef:Fe,disableHorizontal:!0,className:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero"}):null]})});pt.displayName="TerminalViewport";const Vt={esc:"\x1B",tab:" ",enter:"\r","arrow-up":"\x1B[A","arrow-down":"\x1B[B","arrow-left":"\x1B[D","arrow-right":"\x1B[C"},it={ctrl:"5",cmd:"3"},ut={retry:{maxRetries:3,initialDelayMs:500,maxDelayMs:8e3},connectionTimeoutMs:1e4},Pt={retry:{...ut.retry,initialDelayMs:200,maxDelayMs:500},connectionTimeoutMs:1500},jt=(f,p)=>{if(p)switch(f){case"arrow-up":return`\x1B[1;${it[p]}A`;case"arrow-down":return`\x1B[1;${it[p]}B`;case"arrow-right":return`\x1B[1;${it[p]}C`;case"arrow-left":return`\x1B[1;${it[p]}D`}return Vt[f]??null},Ht=()=>{const{t:f}=dt(),{terminal:p,runtime:m}=Tt(),{currentTheme:ee}=kt(),{monoFont:de}=Ct(),Me=Ie(t=>t.terminalFontSize),ye=Ie(t=>t.bottomTerminalHeight),Be=Ie(t=>t.isBottomTerminalExpanded),{isMobile:E,isTablet:tt,hasTouchOnlyPointer:je}=Et(),he=E||tt,F=(he||je)&&m.platform==="web",N=m.platform!=="vscode",Fe=Ie(t=>t.showTerminalQuickKeysOnDesktop),I=he||Fe,_e=ft(t=>t.currentSessionId),P=ft(t=>t.newSessionDraft),ze=_e!==null||P?.open===!0,h=Rt()??null,be=J(t=>t.sessions),te=J(t=>t.hasHydrated),Le=J(t=>t.ensureDirectory),Ke=J(t=>t.createTab),pe=J(t=>t.setActiveTab),ne=J(t=>t.closeTab),q=J(t=>t.setTabSessionId),ge=J(t=>t.setTabLifecycle),re=J(t=>t.setConnecting),qe=J(t=>t.appendToBuffer),ce=Ie(t=>t.openContextPreview),k=n.useMemo(()=>{if(h)return be.get(h)},[be,h]),R=n.useMemo(()=>k?N?k.activeTabId??k.tabs[0]?.id??null:k.tabs[0]?.id??null:null,[k,N]),me=n.useMemo(()=>{if(k)return R?k.tabs.find(t=>t.id===R)??k.tabs[0]:k.tabs[0]},[k,R]),Ye=n.useMemo(()=>(k?.tabs??[]).map(t=>({icon:(()=>{const u=t.iconKey?At[t.iconKey]??"terminal":"terminal";return a.jsx(ie,{name:u,className:"h-4 w-4"})})(),id:t.id,label:t.label,title:t.label,closeLabel:f("terminalView.tabs.closeTabTitle")})),[k?.tabs,f]),j=me?.terminalSessionId??null,Oe=me?.lifecycle??"idle",xe=me?.bufferChunks??[],$e=me?.isConnecting??!1,nt=me?.previewUrl??null,[We,O]=n.useState(null),[at,y]=n.useState(!1),[ve,A]=n.useState(!1),[M,C]=n.useState(null),[Te,le]=n.useState(!1),[W,He]=n.useState(0),De=n.useRef(null),ue=n.useRef(null),ke=n.useRef(R),X=n.useRef(j),U=n.useRef(h),L=n.useRef(null),Ne=n.useRef(null),Ge=n.useRef(!1),Xe=n.useRef(null),Ce=n.useRef(new Set),Qe=n.useRef(!1),we=n.useCallback(()=>{F||typeof document<"u"&&!document.hasFocus()||L.current?.focus()},[F]),fe=n.useCallback(()=>{F||L.current?.focus()},[F]);n.useEffect(()=>{if(!te||Qe.current)return;Qe.current=!0;const t=new Set;for(const[,u]of J.getState().sessions.entries())for(const i of u.tabs)i.terminalSessionId&&t.add(i.terminalSessionId);Ce.current=t},[te]);const rt=Ie(t=>t.activeMainTab),Ee=Ie(t=>t.isBottomTerminalOpen),ot=Ie(t=>t.setBottomTerminalOpen),st=Ie(t=>t.setBottomTerminalExpanded),Ze=rt==="terminal",e=Ze||Ee,[o,s]=n.useState(e);n.useEffect(()=>{!e||m.platform==="vscode"||It()},[e,m.platform]),n.useEffect(()=>{e&&s(!0)},[e]),n.useEffect(()=>{Ge.current=e},[e]),n.useEffect(()=>{X.current=j},[j]),n.useEffect(()=>{ke.current=R},[R]),n.useEffect(()=>{U.current=h},[h]),n.useEffect(()=>{!I&&M!==null&&C(null)},[I,M,C]),n.useEffect(()=>{!j&&M!==null&&C(null)},[j,M,C]);const c=n.useCallback(()=>{De.current?.(),De.current=null,ue.current=null,A(!1)},[]);n.useEffect(()=>()=>{c(),X.current=null},[c]);const r=n.useCallback((t,u,i,b=ut)=>{if(ue.current===i)return;c(),ue.current=i;const w=p.connect(i,{onEvent:g=>{if(ue.current===i)switch(g.type){case"connected":{re(t,u,!1),O(null),y(!1),A(!1),we(),Xe.current===i&&(Xe.current=null,p.sendInput(i,"\r").catch(()=>{}));break}case"reconnecting":{O(null),y(!1),A(!0);break}case"data":{g.data&&qe(t,u,g.data);break}case"exit":{const d=typeof g.exitCode=="number"?g.exitCode:null,_=typeof g.signal=="number"?g.signal:null,$=!!J.getState().getDirectoryState(t)?.tabs.find(ae=>ae.id===u)?.label?.startsWith("Action:");qe(t,u,f("terminalView.stream.processExitedMessage",{exitCodeSegment:d!==null?f("terminalView.stream.processExitedWithCode",{exitCode:d}):"",signalSegment:_!==null?f("terminalView.stream.processExitedWithSignal",{signal:_}):""})),ge(t,u,"exited"),q(t,u,null),re(t,u,!1),O($?null:f("terminalView.error.sessionEnded")),y(!1),A(!1),c();break}}},onError:(g,d)=>{if(ue.current===i){if(!d){O(null),y(!1);return}A(!1),O(f("terminalView.error.connectionFailed",{message:g.message})),y(!0),re(t,u,!1),ge(t,u,"exited"),q(t,u,null),c()}}},b);De.current=()=>{w.close(),ue.current=null}},[qe,c,we,re,ge,q,f,p]);n.useEffect(()=>{let t=!1;if(!te||!o)return;if(!h){O(f(ze?"terminalView.empty.noWorkingDirectory":"terminalView.empty.selectSession")),c();return}return(async()=>{const i=h;if(!U.current||U.current!==i)return;Le(i);const b=J.getState().getDirectoryState(i);if(!b||b.tabs.length===0)return;const w=N?b.activeTabId??b.tabs[0]?.id??null:b.tabs[0]?.id??null;if(!w)return;const g=b.tabs.find(se=>se.id===w)??b.tabs[0];let d=g?.terminalSessionId??null;const _=g?.lifecycle??"idle",oe=!!g?.label?.startsWith("Action:"),$=(g?.bufferLength??0)>0||(g?.bufferChunks?.length??0)>0,ae=!!d&&Ce.current.has(d)&&(g?.bufferLength??0)===0&&(g?.bufferChunks?.length??0)===0,Se=!!d&&Ce.current.has(d);if(!d){if(_==="exited"){re(i,w,!1);return}if(oe&&$){re(i,w,!1);return}O(null),y(!1),A(!1),re(i,w,!0);try{const se=Ne.current,Pe=await p.createSession({cwd:i,cols:se?.cols,rows:se?.rows});if(!(!t&&U.current===i&&ke.current===w)){try{await p.close(Pe.sessionId)}catch{}return}q(i,w,Pe.sessionId),d=Pe.sessionId}catch(se){t||(O(se instanceof Error?se.message:f("terminalView.error.startSessionFailed")),y(!0),A(!1),re(i,w,!1));return}}!d||t||(X.current=d,Se&&Ce.current.delete(d),ae&&(Xe.current=d),r(i,w,d,Se?Pt:ut))})(),()=>{t=!0,X.current=null,c()}},[ze,h,j,Oe,R,o,N,te,Le,re,ge,q,r,c,f,p]),n.useEffect(()=>{if(!e||F)return;if(typeof window>"u"){we();return}const t=window.requestAnimationFrame(()=>{we()});return()=>{window.cancelAnimationFrame(t)}},[R,we,e,F]);const v=n.useCallback(async()=>{if(!h||Te)return;const t=J.getState().getDirectoryState(h),u=N?R??t?.activeTabId??t?.tabs[0]?.id??null:t?.tabs[0]?.id??null;if(u){le(!0),O(null),y(!1),A(!1),c();try{await ne(h,u)}catch(i){O(i instanceof Error?i.message:f("terminalView.error.restartFailed")),y(!0),A(!1)}finally{le(!1)}}},[R,ne,c,h,N,Te,f]),S=n.useCallback(async()=>{await v()},[v]),D=n.useCallback(()=>{if(!h)return;const t=Ke(h);pe(h,t),O(null),y(!1),A(!1),c()},[Ke,c,h,pe]),G=n.useCallback(t=>{h&&(pe(h,t),O(null),y(!1),A(!1),c())},[c,h,pe]),l=n.useCallback(t=>{h&&(t===R&&c(),O(null),y(!1),A(!1),ne(h,t))},[R,ne,c,h]),T=n.useCallback(t=>{if(!t||ve)return;let u=t,i=!1;if(M&&t.length>0){const w=t[0];if(w.length===1&&/[a-zA-Z]/.test(w)){const g=w.toUpperCase();(M==="ctrl"||M==="cmd")&&(u=String.fromCharCode(g.charCodeAt(0)&31),i=!0)}i||(i=!0)}const b=X.current;b&&(p.sendInput(b,u).catch(w=>{ve||O(w instanceof Error?w.message:f("terminalView.error.sendInputFailed"))}),i&&(C(null),fe()))},[M,fe,ve,C,f,p]),V=n.useCallback((t,u)=>{if(Ne.current={cols:t,rows:u},!Ge.current)return;const i=X.current;i&&p.resize({sessionId:i,cols:t,rows:u}).catch(()=>{})},[p]),H=n.useCallback(t=>{C(u=>u===t?null:t),fe()},[fe,C]),K=n.useCallback(t=>{const u=jt(t,M);u&&(T(u),C(null),fe())},[M,fe,T,C]);n.useEffect(()=>{if(!I||!M||!j)return;const t=u=>{if(u.repeat)return;const i=u.key;if(!i||i==="Control"||i==="Meta"||i==="Alt"||i==="Shift")return;const b=i.length===1?i.toLowerCase():i,w=u.code??"",g=w.startsWith("Key")&&w.length===4?w.slice(3).toUpperCase():null,d=i.length===1&&/[a-zA-Z]/.test(i)?i.toUpperCase():g,_={Tab:"tab",Enter:"enter",ArrowUp:"arrow-up",ArrowDown:"arrow-down",ArrowLeft:"arrow-left",ArrowRight:"arrow-right",Escape:"esc",tab:"tab",enter:"enter",arrowup:"arrow-up",arrowdown:"arrow-down",arrowleft:"arrow-left",arrowright:"arrow-right",escape:"esc"};if(b in _){u.preventDefault(),u.stopPropagation(),K(_[b]);return}if(M==="ctrl"&&d&&d.length===1&&d>="A"&&d<="Z"){const oe=String.fromCharCode(d.charCodeAt(0)&31);u.preventDefault(),u.stopPropagation(),T(oe),C(null),fe()}};return window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t)}},[M,K,T,fe,I,C,j]);const Y=n.useMemo(()=>{const t=et[ct].stack;if(typeof window>"u")return(et[de]??et[ct]).stack;const i=window.getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono");return i&&i.trim().length>0?i.trim():(et[de]??et[ct]).stack??t},[de]),x=n.useMemo(()=>Mt(ee),[ee]),B=n.useMemo(()=>`${h??"no-dir"}::${R??"no-tab"}::${j??"no-terminal"}`,[h,R,j]),Re=n.useMemo(()=>`${B}::layout-${W}`,[B,W]);if(n.useEffect(()=>{if(F||!Ee||!e)return;if(typeof window>"u"){He(u=>u+1);return}const t=window.setTimeout(()=>{He(u=>u+1)},140);return()=>{window.clearTimeout(t)}},[ye,Be,Ee,e,F]),n.useEffect(()=>{if(!e||F)return;const t=L.current;if(!t)return;const u=()=>{t.fit()};if(typeof window<"u"){const i=window.requestAnimationFrame(()=>{u(),we()}),b=[220,400].map(w=>window.setTimeout(u,w));return()=>{window.cancelAnimationFrame(i),b.forEach(w=>window.clearTimeout(w))}}u()},[we,e,F,B,j]),n.useEffect(()=>{if(F||!e||!Ee)return;const t=L.current;if(!t)return;const u=()=>{t.fit()};if(typeof window<"u"){const i=window.requestAnimationFrame(()=>{u()}),b=[0,80,180,320].map(w=>window.setTimeout(u,w));return()=>{window.cancelAnimationFrame(i),b.forEach(w=>window.clearTimeout(w))}}u()},[ye,Be,Ee,e,F]),!ze)return a.jsx("div",{className:"flex h-full items-center justify-center p-4 text-center text-sm text-muted-foreground",children:f("terminalView.empty.selectSession")});if(!h)return a.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-sm text-muted-foreground",children:[a.jsx("p",{children:f("terminalView.empty.noWorkingDirectoryForSession")}),a.jsx("button",{onClick:v,className:"rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:f("terminalView.actions.retry")})]});const z=!j||$e||Te||ve,Ve=o,Ae=!he&&Ee&&!Ze,Q=a.jsxs(a.Fragment,{children:[a.jsx(Z,{type:"button",size:"sm",variant:"outline",className:"h-6 px-2 text-xs",onClick:()=>K("esc"),disabled:z,children:f("terminalView.quickKeys.escape")}),a.jsxs(Z,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>K("tab"),disabled:z,children:[a.jsx(ie,{name:"arrow-right",className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.tabAria")})]}),a.jsxs(Z,{type:"button",size:"sm",variant:"chip","aria-pressed":M==="ctrl",className:"h-6 w-9 p-0",onClick:()=>H("ctrl"),disabled:z,children:[a.jsx("span",{className:"text-xs font-medium",children:f("terminalView.quickKeys.controlLabel")}),a.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.controlModifierAria")})]}),a.jsxs(Z,{type:"button",size:"sm",variant:"chip","aria-pressed":M==="cmd",className:"h-6 w-9 p-0",onClick:()=>H("cmd"),disabled:z,children:[a.jsx(ie,{name:"command"}),a.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.commandModifierAria")})]}),a.jsxs(Z,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>K("arrow-up"),disabled:z,children:[a.jsx(ie,{name:"arrow-up"}),a.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.arrowUpAria")})]}),a.jsxs(Z,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>K("arrow-left"),disabled:z,children:[a.jsx(ie,{name:"arrow-left"}),a.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.arrowLeftAria")})]}),a.jsxs(Z,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>K("arrow-down"),disabled:z,children:[a.jsx(ie,{name:"arrow-down"}),a.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.arrowDownAria")})]}),a.jsxs(Z,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>K("arrow-right"),disabled:z,children:[a.jsx(ie,{name:"arrow-right"}),a.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.arrowRightAria")})]}),a.jsxs(Z,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>K("enter"),disabled:z,children:[a.jsx(ie,{name:"arrow-go-back"}),a.jsx("span",{className:"sr-only",children:f("terminalView.quickKeys.enterAria")})]})]});return a.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-[var(--surface-background)]",children:[a.jsxs("div",{className:Ue("app-region-no-drag sticky top-0 z-20 shrink-0 bg-[var(--surface-background)] text-xs",he?"px-3 py-1.5":"pl-3 pr-1.5 py-1"),children:[N&&k?a.jsxs("div",{className:"flex items-center gap-2 pl-1 pr-1",children:[a.jsx("div",{className:Ue("min-w-0 flex-1",he?"h-8":"h-7"),children:a.jsx(St,{items:Ye,activeId:R,onSelect:G,onClose:l,layoutMode:"scrollable",variant:"default",className:"h-full bg-transparent"})}),a.jsx(Z,{type:"button",size:"xs",variant:"ghost",className:Ue("shrink-0",he?"h-8 w-8 p-0":"h-7 w-7 p-0"),onClick:D,title:f("terminalView.tabs.newTabTitle"),children:a.jsx(ie,{name:"add",className:`${he?"h-[18px] w-[18px]":"h-4 w-4"}`})}),a.jsxs("div",{className:"flex shrink-0 items-center gap-1 overflow-visible",children:[nt?a.jsxs(Z,{type:"button",size:"xs",variant:"outline",className:"h-6 shrink-0 gap-1 px-2",onClick:()=>{h&&ce(h,nt)},title:f("terminalView.preview.openTitle"),children:[a.jsx(ie,{name:"global",className:"h-3.5 w-3.5 shrink-0"}),a.jsx("span",{className:"whitespace-nowrap",children:f("terminalView.preview.open")})]}):null,Ae?a.jsxs(a.Fragment,{children:[a.jsx(Z,{type:"button",size:"xs",variant:"ghost",onClick:()=>st(!Be),className:Ue("shrink-0 p-0",E?"h-8 w-8":"h-7 w-7"),title:f(Be?"terminalView.bottomDock.restoreTitle":"terminalView.bottomDock.expandTitle"),"aria-label":f(Be?"terminalView.bottomDock.restoreAria":"terminalView.bottomDock.expandAria"),children:Be?a.jsx(ie,{name:"fullscreen-exit",className:"h-4 w-4"}):a.jsx(ie,{name:"fullscreen",className:"h-4 w-4"})}),a.jsx(Z,{type:"button",size:"xs",variant:"ghost",onClick:()=>ot(!1),className:Ue("shrink-0 p-0",E?"h-8 w-8":"h-7 w-7"),title:f("terminalView.bottomDock.closeTitle"),"aria-label":f("terminalView.bottomDock.closeAria"),children:a.jsx(ie,{name:"close",className:"h-4 w-4"})})]}):null]})]}):null,!E&&I&&N&&k?a.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1 pl-1 pr-1",children:Q}):null,I&&(E||!N||!k)?a.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1",children:Q}):null]}),a.jsxs("div",{className:"relative flex-1 overflow-hidden",style:{backgroundColor:x.background},children:[a.jsx("div",{className:"h-full w-full box-border pl-4 pr-1.5 pt-3 pb-4",children:Ve?a.jsx(pt,{ref:t=>{L.current=t},sessionKey:Re,chunks:xe,onInput:T,onResize:V,theme:x,fontFamily:Y,fontSize:Me,enableTouchScroll:F,autoFocus:!F&&e,isVisible:e}):null}),!ve&&We&&a.jsxs("div",{className:"absolute inset-x-0 bottom-0 bg-[var(--status-error-background)] px-3 py-2 text-xs text-[var(--status-error-foreground)] flex items-center justify-between gap-2",children:[a.jsx("span",{children:We}),at&&E&&a.jsx(Z,{size:"sm",variant:"secondary",className:"h-6 px-2 py-0 text-xs",onClick:S,disabled:Te,title:f("terminalView.actions.hardRestartTitle"),type:"button",children:f("terminalView.actions.hardRestart")})]})]})]})};export{Ht as TerminalView};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import{R as v,c as he,j as i,
|
|
1
|
+
import{R as v,c as he,j as i,x as Ke,bG as Le,am as Ie,ak as He,bm as Ye,s as Fe}from"./vendor-.bun-Boz6Tqcq.js";import{u as Me,c as pe,I as D,bF as Xe,eT as Te,b6 as Ve,eU as Qe,eV as et,eW as tt,eX as nt,eY as it,be as We,eZ as st,e_ as ot,b1 as rt,b3 as Ee,e$ as at,b4 as Ce,au as lt,av as ct}from"./modelPrefsAutoSave-2uwW8uD9.js";import{J as dt}from"./JsonTreeView-9F0tH9yA.js";import"./index-BV2XTsJJ.js";const ut=80,mt=20,ft=n=>n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),ht=n=>Object.entries(n).filter(([,e])=>e!=null).map(([e,t])=>`${ft(e)}:${String(t)};`).join(""),pt=n=>n.split(",").map(e=>e.trim()).filter(Boolean).flatMap(e=>e.startsWith(".token")?[`.oc-virtualized-prism ${e}`]:e.startsWith("token.")?[`.oc-virtualized-prism .${e}`]:/^[a-z0-9_-]+$/i.test(e)?[`.oc-virtualized-prism .token.${e}`]:e.includes("token")?[`.oc-virtualized-prism ${e}`]:[]),gt=n=>{const e=[];return Object.entries(n).forEach(([t,a])=>{const l=pt(t);if(l.length===0)return;const o=ht(a);o&&e.push(`${l.join(",")}{${o}}`)}),e.join(`
|
|
2
2
|
`)},xt={text:"plain",plaintext:"plain",shell:"bash",sh:"bash",zsh:"bash",patch:"diff",dockerfile:"docker",js:"javascript",ts:"typescript"},wt=n=>{const e=n.toLowerCase();return xt[e]??e},bt=5e3,ye=new Map,yt=(n,e)=>{const t=wt(e),a=`${t}
|
|
3
|
-
${n}`,l=ye.get(a);if(l!==void 0)return l;const o=Le.languages[t]??Le.languages.text;if(!o){const r=Ae(n);return ye.set(a,r),r}try{const r=Le.highlight(n,o,t);if(ye.size>=bt){const s=ye.keys().next().value;typeof s=="string"&&ye.delete(s)}return ye.set(a,r),r}catch{const r=Ae(n);return ye.set(a,r),r}};function Ae(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}const Ue=v.memo(n=>{const e=he.c(26),{lines:t,language:a,syntaxTheme:l,maxHeight:o,showLineNumbers:r,lineStyles:s}=n,c=o===void 0?"60vh":o,d=r===void 0?!0:r;let
|
|
3
|
+
${n}`,l=ye.get(a);if(l!==void 0)return l;const o=Le.languages[t]??Le.languages.text;if(!o){const r=Ae(n);return ye.set(a,r),r}try{const r=Le.highlight(n,o,t);if(ye.size>=bt){const s=ye.keys().next().value;typeof s=="string"&&ye.delete(s)}return ye.set(a,r),r}catch{const r=Ae(n);return ye.set(a,r),r}};function Ae(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}const Ue=v.memo(n=>{const e=he.c(26),{lines:t,language:a,syntaxTheme:l,maxHeight:o,showLineNumbers:r,lineStyles:s}=n,c=o===void 0?"60vh":o,d=r===void 0?!0:r;let m;e[0]!==l?(m=gt(l),e[0]=l,e[1]=m):m=e[1];const g=m;if(!(t.length>ut)){let b;e[2]!==c?(b={maxHeight:c,overflow:"auto"},e[2]=c,e[3]=b):b=e[3];let w;e[4]!==g?(w=g?i.jsx("style",{children:g}):null,e[4]=g,e[5]=w):w=e[5];let y;if(e[6]!==a||e[7]!==s||e[8]!==t||e[9]!==d){let x;e[11]!==a||e[12]!==s||e[13]!==d?(x=(_,k)=>i.jsx(De,{line:_,language:a,showLineNumbers:d,style:s?.(_)},k),e[11]=a,e[12]=s,e[13]=d,e[14]=x):x=e[14],y=t.map(x),e[6]=a,e[7]=s,e[8]=t,e[9]=d,e[10]=y}else y=e[10];let P;return e[15]!==b||e[16]!==w||e[17]!==y?(P=i.jsxs("div",{className:"typography-code font-mono w-full min-w-0 oc-virtualized-prism",style:b,children:[w,y]}),e[15]=b,e[16]=w,e[17]=y,e[18]=P):P=e[18],P}let R;return e[19]!==a||e[20]!==s||e[21]!==t||e[22]!==c||e[23]!==g||e[24]!==d?(R=i.jsx(Ge,{lines:t,language:a,prismThemeCss:g,maxHeight:c,showLineNumbers:d,lineStyles:s}),e[19]=a,e[20]=s,e[21]=t,e[22]=c,e[23]=g,e[24]=d,e[25]=R):R=e[25],R});Ue.displayName="VirtualizedCodeBlock";const Ge=v.memo(({lines:n,language:e,prismThemeCss:t,maxHeight:a,showLineNumbers:l,lineStyles:o})=>{const r=v.useRef(null),s=Ke({count:n.length,getScrollElement:()=>r.current,estimateSize:()=>mt,overscan:20});return i.jsxs("div",{ref:r,className:"typography-code font-mono w-full min-w-0 oc-virtualized-prism",style:{maxHeight:a,overflow:"auto"},children:[t?i.jsx("style",{children:t}):null,i.jsx("div",{style:{height:`${s.getTotalSize()}px`,width:"100%",position:"relative"},children:s.getVirtualItems().map(c=>{const d=n[c.index];return i.jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:`${c.size}px`,transform:`translateY(${c.start}px)`},children:i.jsx(De,{line:d,language:e,showLineNumbers:l,style:o?.(d)})},c.index)})})]})});Ge.displayName="VirtualizedRows";const De=v.memo(n=>{const e=he.c(15),{line:t,language:a,showLineNumbers:l,style:o}=n;let r;e[0]!==a||e[1]!==t.text?(r=yt(t.text,a),e[0]=a,e[1]=t.text,e[2]=r):r=e[2];const s=r;let c;e[3]!==t.isInfo||e[4]!==t.lineNumber||e[5]!==l?(c=l&&i.jsx("span",{className:"w-10 flex-shrink-0 text-right pr-3 select-none border-r mr-3 -my-0.5 py-0.5",style:{color:"var(--tools-edit-line-number)",borderColor:"var(--tools-border)"},children:!t.isInfo&&t.lineNumber!=null?t.lineNumber:""}),e[3]=t.isInfo,e[4]=t.lineNumber,e[5]=l,e[6]=c):c=e[6];let d;e[7]!==s||e[8]!==t.isInfo||e[9]!==t.text?(d=i.jsx("div",{className:"flex-1 min-w-0",children:t.isInfo?i.jsx("div",{className:"whitespace-pre-wrap break-words text-muted-foreground/70 italic",children:t.text}):i.jsx("div",{className:"whitespace-pre",dangerouslySetInnerHTML:{__html:s}})}),e[7]=s,e[8]=t.isInfo,e[9]=t.text,e[10]=d):d=e[10];let m;return e[11]!==o||e[12]!==c||e[13]!==d?(m=i.jsxs("div",{className:"typography-code font-mono flex w-full min-w-0",style:o,children:[c,d]}),e[11]=o,e[12]=c,e[13]=d,e[14]=m):m=e[14],m});De.displayName="VirtualizedCodeBlock.Row";const jt=n=>{const e="h-3.5 w-3.5 flex-shrink-0",t=n.toLowerCase();return t==="reasoning"?i.jsx(D,{name:"brain-ai-3",className:e}):t==="image-preview"?i.jsx(D,{name:"file-image",className:e}):t==="mermaid-preview"?i.jsx(D,{name:"file-list-2",className:e}):t==="edit"||t==="multiedit"||t==="apply_patch"||t==="str_replace"||t==="str_replace_based_edit_tool"?i.jsx(D,{name:"pencil-ai",className:e}):t==="write"||t==="create"||t==="file_write"?i.jsx(D,{name:"file-pdf",className:e}):t==="read"||t==="view"||t==="file_read"||t==="cat"?i.jsx(D,{name:"file-pdf",className:e}):t==="bash"||t==="shell"||t==="cmd"||t==="terminal"?i.jsx(D,{name:"terminal-box",className:e}):t==="list"||t==="ls"||t==="dir"||t==="list_files"?i.jsx(D,{name:"folder-6",className:e}):t==="search"||t==="grep"||t==="find"||t==="ripgrep"?i.jsx(D,{name:"search",className:e}):t==="glob"?i.jsx(D,{name:"file-search",className:e}):t==="fetch"||t==="curl"||t==="wget"||t==="webfetch"?i.jsx(D,{name:"global",className:e}):t==="web-search"||t==="websearch"||t==="search_web"||t==="google"||t==="bing"||t==="duckduckgo"?i.jsx(D,{name:"search",className:e}):t==="todowrite"||t==="todoread"?i.jsx(D,{name:"list-check-3",className:e}):t==="plan_enter"?i.jsx(D,{name:"file-list-2",className:e}):t==="plan_exit"?i.jsx(D,{name:"task",className:e}):t.startsWith("git")?i.jsx(D,{name:"git-branch",className:e}):i.jsx(D,{name:"tools",className:e})},Oe=150,vt=40,Nt=120,Tt=3,Re={style:{background:"transparent",backgroundColor:"transparent",fontSize:"inherit"}},St={download:!1,copy:!1,fullscreen:!1,panZoom:!0},_t=`
|
|
4
4
|
[data-diff-header],
|
|
5
5
|
[data-diff] {
|
|
6
6
|
[data-separator] {
|
|
7
7
|
height: 24px !important;
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
-
`,kt={hunkLineCount:50,lineHeight:24,diffHeaderHeight:44,hunkSeparatorHeight:24,fileGap:0},It=()=>{const n=he.c(22),e=rt();let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t=Ee(!1),n[0]=t):t=n[0];const a=t;let l;n[1]===Symbol.for("react.memo_cache_sentinel")?(l=Ee(!0),n[1]=l):l=n[1];const o=l;let r;n[2]!==e?.availableThemes?(r=()=>e?.availableThemes??[a,o],n[2]=e?.availableThemes,n[3]=r):r=n[3],e?.availableThemes;let s;n[4]!==r?(s=r(),n[4]=r,n[5]=s):s=n[5];const c=s,d=e?.lightThemeId??a.metadata.id,f=e?.darkThemeId??o.metadata.id;let g;n[6]!==c||n[7]!==d?(g=c.find(N=>N.metadata.id===d)??a,n[6]=c,n[7]=d,n[8]=g):g=n[8];const E=g;let R;n[9]!==c||n[10]!==f?(R=c.find(N=>N.metadata.id===f)??o,n[9]=c,n[10]=f,n[11]=R):R=n[11];const b=R;let w,y;n[12]!==b||n[13]!==E?(w=()=>{Ce(E),Ce(b)},y=[b,E],n[12]=b,n[13]=E,n[14]=w,n[15]=y):(w=n[14],y=n[15]),v.useEffect(w,y);const P=e?.currentTheme.metadata.variant??"light";let x;n[16]!==b.metadata.id||n[17]!==E.metadata.id?(x={light:E.metadata.id,dark:b.metadata.id},n[16]=b.metadata.id,n[17]=E.metadata.id,n[18]=x):x=n[18];const _=P==="dark"?"dark":"light";let k;return n[19]!==x||n[20]!==_?(k={theme:x,themeType:_},n[19]=x,n[20]=_,n[21]=k):k=n[21],k},ze=()=>({width:typeof window<"u"?window.innerWidth:0,height:typeof window<"u"?window.innerHeight:0}),$e={mobile:{widthRatio:.94,heightRatio:.86,padding:10},desktop:{widthRatio:.8,heightRatio:.8,padding:16}},Rt=(n,e)=>{const t=e?$e.mobile:$e.desktop,a=Math.max(160,n.width-t.padding*2),l=Math.max(160,n.height-t.padding*2);return{maxWidth:Math.max(160,Math.min(a,n.width*t.widthRatio)),maxHeight:Math.max(160,Math.min(l,n.height*t.heightRatio))}},Pt=n=>{try{const o=Array.from(n.querySelectorAll("g"));let r=0,s=null;for(const c of o){if(!(c instanceof SVGGraphicsElement))continue;const d=c.getBBox();if(!(d.width>0&&d.height>0))continue;const f=d.width*d.height;f>r&&(r=f,s=d.width/d.height)}if(s&&Number.isFinite(s)&&s>0)return s}catch{}const e=n.getAttribute("viewBox");if(e){const o=e.trim().split(/\s+/).map(Number);if(o.length===4){const r=o[2],s=o[3];if(Number.isFinite(r)&&Number.isFinite(s)&&r>0&&s>0)return r/s}}const t=Number(n.getAttribute("width")),a=Number(n.getAttribute("height"));if(Number.isFinite(t)&&Number.isFinite(a)&&t>0&&a>0)return t/a;const l=n.getBoundingClientRect();return l.width>0&&l.height>0?l.width/l.height:null},Be=n=>{const e=he.c(7),[t,a]=v.useState(n),[l,o]=v.useState(n),[r,s]=v.useState(!1);let c,d;e[0]!==n?(c=()=>{if(n){if(a(!0),s(!0),typeof window>"u"){o(!0);return}const E=window.requestAnimationFrame(()=>{o(!0)}),R=window.setTimeout(()=>{s(!1)},Oe);return()=>{window.cancelAnimationFrame(E),window.clearTimeout(R)}}if(o(!1),s(!0),typeof window>"u"){a(!1);return}const g=window.setTimeout(()=>{a(!1),s(!1)},Oe);return()=>{window.clearTimeout(g)}},d=[n],e[0]=n,e[1]=c,e[2]=d):(c=e[1],d=e[2]),v.useEffect(c,d);let f;return e[3]!==t||e[4]!==r||e[5]!==l?(f={isRendered:t,isVisible:l,isTransitioning:r},e[3]=t,e[4]=r,e[5]=l,e[6]=f):f=e[6],f},qe=n=>{const e=he.c(3),[t,a]=v.useState(ze);let l,o;return e[0]!==n?(l=()=>{if(!n||typeof window>"u")return;const r=()=>{a(ze())};return r(),window.addEventListener("resize",r),()=>{window.removeEventListener("resize",r)}},o=[n],e[0]=n,e[1]=l,e[2]=o):(l=e[1],o=e[2]),v.useEffect(l,o),t},Lt=n=>{const e=he.c(103),{popup:t,onOpenChange:a,isMobile:l}=n,{t:o}=Me();let r;e:{const u=t.image;if(!u){let I;e[0]===Symbol.for("react.memo_cache_sentinel")?(I=[],e[0]=I):I=e[0],r=I;break e}let h;e[1]!==u.gallery?(h=Array.isArray(u.gallery)?u.gallery.filter(Dt):[],e[1]=u.gallery,e[2]=h):h=e[2];const M=h;if(M.length>0){r=M;break e}let C;e[3]!==u.filename||e[4]!==u.mimeType||e[5]!==u.size||e[6]!==u.url?(C=[{url:u.url,mimeType:u.mimeType,filename:u.filename,size:u.size}],e[3]=u.filename,e[4]=u.mimeType,e[5]=u.size,e[6]=u.url,e[7]=C):C=e[7],r=C}const s=r,[c,d]=v.useState(0),[f,g]=v.useState(null),{isRendered:E,isVisible:R,isTransitioning:b}=Be(t.open),w=qe(t.open);let y;e[8]!==s||e[9]!==t.image||e[10]!==t.open?(y=()=>{if(!t.open||s.length===0)return;const u=typeof t.image?.index=="number"?t.image.index:-1;if(u>=0&&u<s.length){d(u);return}const h=t.image?.url?s.findIndex(M=>M.url===t.image?.url):-1;d(h>=0?h:0)},e[8]=s,e[9]=t.image,e[10]=t.open,e[11]=y):y=e[11];const P=t.image?.index,x=t.image?.url;let _;e[12]!==s||e[13]!==t.open||e[14]!==P||e[15]!==x?(_=[s,P,x,t.open],e[12]=s,e[13]=t.open,e[14]=P,e[15]=x,e[16]=_):_=e[16],v.useEffect(y,_);const k=s[c]??s[0]??t.image,N=k?.filename||t.title||"Image preview",p=s.length>1;let T;e[17]!==s.length?(T=()=>{s.length<=1||d(u=>(u-1+s.length)%s.length)},e[17]=s.length,e[18]=T):T=e[18];const S=T;let z;e[19]!==s.length?(z=()=>{s.length<=1||d(u=>(u+1)%s.length)},e[19]=s.length,e[20]=z):z=e[20];const m=z;let $,L;e[21]!==p||e[22]!==a||e[23]!==t.open||e[24]!==m||e[25]!==S?($=()=>{if(!t.open)return;const u=h=>{if(h.key==="Escape"){a(!1);return}if(h.key==="ArrowLeft"&&p){h.preventDefault(),S();return}h.key==="ArrowRight"&&p&&(h.preventDefault(),m())};return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u)}},L=[p,a,t.open,m,S],e[21]=p,e[22]=a,e[23]=t.open,e[24]=m,e[25]=S,e[26]=$,e[27]=L):($=e[26],L=e[27]),v.useEffect($,L);let X;e[28]===Symbol.for("react.memo_cache_sentinel")?(X=()=>{g(null)},e[28]=X):X=e[28];const K=k?.url;let ie;e[29]!==K?(ie=[K],e[29]=K,e[30]=ie):ie=e[30],v.useEffect(X,ie);let je;e:{const u=Math.max(160,w.width*(l?.86:.75)),h=Math.max(160,w.height*(l?.72:.75));if(!f){let ve;e[31]!==u?(ve=Math.round(u),e[31]=u,e[32]=ve):ve=e[32];let Ne;e[33]!==h?(Ne=Math.round(h),e[33]=h,e[34]=Ne):Ne=e[34];let ke;e[35]!==ve||e[36]!==Ne?(ke={width:ve,height:Ne},e[35]=ve,e[36]=Ne,e[37]=ke):ke=e[37],je=ke;break e}const M=u/f.width,C=h/f.height,I=Math.min(M,C);let A;e[38]!==f.width||e[39]!==I?(A=Math.round(f.width*I),e[38]=f.width,e[39]=I,e[40]=A):A=e[40];const Y=Math.max(1,A);let Se;e[41]!==f.height||e[42]!==I?(Se=Math.round(f.height*I),e[41]=f.height,e[42]=I,e[43]=Se):Se=e[43];const Pe=Math.max(1,Se);let _e;e[44]!==Y||e[45]!==Pe?(_e={width:Y,height:Pe},e[44]=Y,e[45]=Pe,e[46]=_e):_e=e[46],je=_e}const ge=je;if(!E||!k||typeof document>"u")return null;const se=t.open?"pointer-events-auto":"pointer-events-none";let oe;e[47]!==se?(oe=pe("fixed inset-0 z-50",se),e[47]=se,e[48]=oe):oe=e[48];const xe=b&&"transition-opacity duration-150 ease-out",re=R?"opacity-100":"opacity-0";let H;e[49]!==xe||e[50]!==re?(H=pe("absolute inset-0 bg-black/40",xe,re),e[49]=xe,e[50]=re,e[51]=H):H=e[51];let F;e[52]!==a?(F=()=>a(!1),e[52]=a,e[53]=F):F=e[53];let ae;e[54]!==H||e[55]!==F?(ae=i.jsx("div",{"aria-hidden":"true",className:H,onMouseDown:F}),e[54]=H,e[55]=F,e[56]=ae):ae=e[56];let V;e[57]!==p||e[58]!==m||e[59]!==S||e[60]!==o?(V=p&&i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",onMouseDown:Et,onClick:S,className:"absolute left-3 top-1/2 -translate-y-1/2 z-10 h-10 w-10 flex items-center justify-center rounded-full bg-black/40 text-foreground/90 hover:bg-black/55 focus:outline-none focus:ring-2 focus:ring-primary/60","aria-label":o("chat.toolOutputDialog.image.previousAria"),children:i.jsx(D,{name:"arrow-left-s",className:"h-6 w-6"})}),i.jsx("button",{type:"button",onMouseDown:Ct,onClick:m,className:"absolute right-3 top-1/2 -translate-y-1/2 z-10 h-10 w-10 flex items-center justify-center rounded-full bg-black/40 text-foreground/90 hover:bg-black/55 focus:outline-none focus:ring-2 focus:ring-primary/60","aria-label":o("chat.toolOutputDialog.image.nextAria"),children:i.jsx(D,{name:"arrow-right-s",className:"h-6 w-6"})})]}),e[57]=p,e[58]=m,e[59]=S,e[60]=o,e[61]=V):V=e[61];const we=l?"p-2.5":"p-4";let le;e[62]!==we?(le=pe("absolute inset-0 flex items-center justify-center pointer-events-none",we),e[62]=we,e[63]=le):le=e[63];const ce=b&&"transition-opacity duration-150 ease-out",be=R?"opacity-100":"opacity-0";let W;e[64]!==ce||e[65]!==be?(W=pe("pointer-events-auto flex flex-col gap-2",ce,be),e[64]=ce,e[65]=be,e[66]=W):W=e[66];const de=`${ge.width}px`;let U;e[67]!==de?(U={width:de},e[67]=de,e[68]=U):U=e[68];let Q;e[69]!==N?(Q=i.jsx("div",{className:"min-w-0 flex-1 text-foreground typography-ui-header font-semibold truncate",title:N,children:N}),e[69]=N,e[70]=Q):Q=e[70];let G;e[71]!==a?(G=()=>a(!1),e[71]=a,e[72]=G):G=e[72];let ue;e[73]!==o?(ue=o("chat.toolOutputDialog.image.closeAria"),e[73]=o,e[74]=ue):ue=e[74];let ee;e[75]===Symbol.for("react.memo_cache_sentinel")?(ee=i.jsx(D,{name:"close",className:"h-4 w-4"}),e[75]=ee):ee=e[75];let B;e[76]!==G||e[77]!==ue?(B=i.jsx("button",{type:"button",className:"h-8 w-8 flex items-center justify-center rounded-lg text-muted-foreground/80 hover:text-foreground focus:outline-none focus:ring-2 focus:ring-primary/60",onClick:G,"aria-label":ue,children:ee}),e[76]=G,e[77]=ue,e[78]=B):B=e[78];let q;e[79]!==Q||e[80]!==B?(q=i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[Q,B]}),e[79]=Q,e[80]=B,e[81]=q):q=e[81];const fe=`${ge.width}px`,me=`${ge.height}px`;let Z;e[82]!==fe||e[83]!==me?(Z={width:fe,height:me},e[82]=fe,e[83]=me,e[84]=Z):Z=e[84];let te;e[85]===Symbol.for("react.memo_cache_sentinel")?(te=u=>{const h=u.currentTarget,M=h.naturalWidth,C=h.naturalHeight;M>0&&C>0&&g(I=>I&&I.width===M&&I.height===C?I:{width:M,height:C})},e[85]=te):te=e[85];let J;e[86]!==k.url||e[87]!==N||e[88]!==Z?(J=i.jsx("img",{src:k.url,alt:N,className:"block object-contain",style:Z,loading:"lazy",onLoad:te}),e[86]=k.url,e[87]=N,e[88]=Z,e[89]=J):J=e[89];let ne;e[90]!==W||e[91]!==U||e[92]!==q||e[93]!==J?(ne=i.jsxs("div",{className:W,style:U,children:[q,J]}),e[90]=W,e[91]=U,e[92]=q,e[93]=J,e[94]=ne):ne=e[94];let j;e[95]!==le||e[96]!==ne?(j=i.jsx("div",{className:le,children:ne}),e[95]=le,e[96]=ne,e[97]=j):j=e[97];let O;if(e[98]!==oe||e[99]!==ae||e[100]!==V||e[101]!==j){const u=i.jsxs("div",{className:oe,children:[ae,V,j]});O=Fe.createPortal(u,document.body),e[98]=oe,e[99]=ae,e[100]=V,e[101]=j,e[102]=O}else O=e[102];return O},Ze=v.memo(n=>{const e=he.c(7),{popup:t,diffViewMode:a,pierreThemeConfig:l}=n,o=t.content||"",r=a==="unified"?"unified":"split";let s;e[0]!==l.theme||e[1]!==l.themeType||e[2]!==r?(s={diffStyle:r,diffIndicators:"none",hunkSeparators:"line-info-basic",lineDiffType:"none",disableFileHeader:!0,maxLineDiffLength:1e3,expansionLineCount:20,overflow:"wrap",theme:l.theme,themeType:l.themeType,unsafeCSS:_t},e[0]=l.theme,e[1]=l.themeType,e[2]=r,e[3]=s):s=e[3];let c;return e[4]!==o||e[5]!==s?(c=i.jsx("div",{className:"typography-code",children:i.jsx(Ye,{patch:o,metrics:kt,options:s,className:"block w-full"})}),e[4]=o,e[5]=s,e[6]=c):c=e[6],c});Ze.displayName="DialogUnifiedDiff";const Je=v.memo(n=>{const e=he.c(30),{popup:t,syntaxTheme:a,pierreThemeConfig:l}=n;let o;e[0]!==t.content?(o=at(t.content),e[0]=t.content,e[1]=o):o=e[1];const r=o,s=t.metadata?.input;let c;e[2]!==s?(c=typeof s=="object"&&s!==null?s:{},e[2]=s,e[3]=c):c=e[3];const d=c,f=typeof d.offset=="number"?d.offset:0,g=typeof d.file_path=="string"?d.file_path:typeof d.filePath=="string"?d.filePath:typeof d.path=="string"?d.path:"read-output";let E;e[4]!==r.lines?(E=r.lines.map(At).join(`
|
|
11
|
-
`),e[4]=r.lines,e[5]=E):E=e[5];const R=E;let b;e[6]!==g||e[7]!==t.language?(b=t.language||Ve(g)||"text",e[6]=g,e[7]=t.language,e[8]=b):b=e[8];const w=b;let y;e[9]!==r.lines?(y=r.lines.some(Ot),e[9]=r.lines,e[10]=y):y=e[10];const P=y;let x;if(e[11]!==P||e[12]!==
|
|
10
|
+
`,kt={hunkLineCount:50,lineHeight:24,diffHeaderHeight:44,hunkSeparatorHeight:24,fileGap:0},It=()=>{const n=he.c(22),e=rt();let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t=Ee(!1),n[0]=t):t=n[0];const a=t;let l;n[1]===Symbol.for("react.memo_cache_sentinel")?(l=Ee(!0),n[1]=l):l=n[1];const o=l;let r;n[2]!==e?.availableThemes?(r=()=>e?.availableThemes??[a,o],n[2]=e?.availableThemes,n[3]=r):r=n[3],e?.availableThemes;let s;n[4]!==r?(s=r(),n[4]=r,n[5]=s):s=n[5];const c=s,d=e?.lightThemeId??a.metadata.id,m=e?.darkThemeId??o.metadata.id;let g;n[6]!==c||n[7]!==d?(g=c.find(N=>N.metadata.id===d)??a,n[6]=c,n[7]=d,n[8]=g):g=n[8];const E=g;let R;n[9]!==c||n[10]!==m?(R=c.find(N=>N.metadata.id===m)??o,n[9]=c,n[10]=m,n[11]=R):R=n[11];const b=R;let w,y;n[12]!==b||n[13]!==E?(w=()=>{Ce(E),Ce(b)},y=[b,E],n[12]=b,n[13]=E,n[14]=w,n[15]=y):(w=n[14],y=n[15]),v.useEffect(w,y);const P=e?.currentTheme.metadata.variant??"light";let x;n[16]!==b.metadata.id||n[17]!==E.metadata.id?(x={light:E.metadata.id,dark:b.metadata.id},n[16]=b.metadata.id,n[17]=E.metadata.id,n[18]=x):x=n[18];const _=P==="dark"?"dark":"light";let k;return n[19]!==x||n[20]!==_?(k={theme:x,themeType:_},n[19]=x,n[20]=_,n[21]=k):k=n[21],k},ze=()=>({width:typeof window<"u"?window.innerWidth:0,height:typeof window<"u"?window.innerHeight:0}),$e={mobile:{widthRatio:.94,heightRatio:.86,padding:10},desktop:{widthRatio:.8,heightRatio:.8,padding:16}},Rt=(n,e)=>{const t=e?$e.mobile:$e.desktop,a=Math.max(160,n.width-t.padding*2),l=Math.max(160,n.height-t.padding*2);return{maxWidth:Math.max(160,Math.min(a,n.width*t.widthRatio)),maxHeight:Math.max(160,Math.min(l,n.height*t.heightRatio))}},Pt=n=>{try{const o=Array.from(n.querySelectorAll("g"));let r=0,s=null;for(const c of o){if(!(c instanceof SVGGraphicsElement))continue;const d=c.getBBox();if(!(d.width>0&&d.height>0))continue;const m=d.width*d.height;m>r&&(r=m,s=d.width/d.height)}if(s&&Number.isFinite(s)&&s>0)return s}catch{}const e=n.getAttribute("viewBox");if(e){const o=e.trim().split(/\s+/).map(Number);if(o.length===4){const r=o[2],s=o[3];if(Number.isFinite(r)&&Number.isFinite(s)&&r>0&&s>0)return r/s}}const t=Number(n.getAttribute("width")),a=Number(n.getAttribute("height"));if(Number.isFinite(t)&&Number.isFinite(a)&&t>0&&a>0)return t/a;const l=n.getBoundingClientRect();return l.width>0&&l.height>0?l.width/l.height:null},Be=n=>{const e=he.c(7),[t,a]=v.useState(n),[l,o]=v.useState(n),[r,s]=v.useState(!1);let c,d;e[0]!==n?(c=()=>{if(n){if(a(!0),s(!0),typeof window>"u"){o(!0);return}const E=window.requestAnimationFrame(()=>{o(!0)}),R=window.setTimeout(()=>{s(!1)},Oe);return()=>{window.cancelAnimationFrame(E),window.clearTimeout(R)}}if(o(!1),s(!0),typeof window>"u"){a(!1);return}const g=window.setTimeout(()=>{a(!1),s(!1)},Oe);return()=>{window.clearTimeout(g)}},d=[n],e[0]=n,e[1]=c,e[2]=d):(c=e[1],d=e[2]),v.useEffect(c,d);let m;return e[3]!==t||e[4]!==r||e[5]!==l?(m={isRendered:t,isVisible:l,isTransitioning:r},e[3]=t,e[4]=r,e[5]=l,e[6]=m):m=e[6],m},qe=n=>{const e=he.c(3),[t,a]=v.useState(ze);let l,o;return e[0]!==n?(l=()=>{if(!n||typeof window>"u")return;const r=()=>{a(ze())};return r(),window.addEventListener("resize",r),()=>{window.removeEventListener("resize",r)}},o=[n],e[0]=n,e[1]=l,e[2]=o):(l=e[1],o=e[2]),v.useEffect(l,o),t},Lt=n=>{const e=he.c(103),{popup:t,onOpenChange:a,isMobile:l}=n,{t:o}=Me();let r;e:{const u=t.image;if(!u){let I;e[0]===Symbol.for("react.memo_cache_sentinel")?(I=[],e[0]=I):I=e[0],r=I;break e}let h;e[1]!==u.gallery?(h=Array.isArray(u.gallery)?u.gallery.filter(Dt):[],e[1]=u.gallery,e[2]=h):h=e[2];const M=h;if(M.length>0){r=M;break e}let C;e[3]!==u.filename||e[4]!==u.mimeType||e[5]!==u.size||e[6]!==u.url?(C=[{url:u.url,mimeType:u.mimeType,filename:u.filename,size:u.size}],e[3]=u.filename,e[4]=u.mimeType,e[5]=u.size,e[6]=u.url,e[7]=C):C=e[7],r=C}const s=r,[c,d]=v.useState(0),[m,g]=v.useState(null),{isRendered:E,isVisible:R,isTransitioning:b}=Be(t.open),w=qe(t.open);let y;e[8]!==s||e[9]!==t.image||e[10]!==t.open?(y=()=>{if(!t.open||s.length===0)return;const u=typeof t.image?.index=="number"?t.image.index:-1;if(u>=0&&u<s.length){d(u);return}const h=t.image?.url?s.findIndex(M=>M.url===t.image?.url):-1;d(h>=0?h:0)},e[8]=s,e[9]=t.image,e[10]=t.open,e[11]=y):y=e[11];const P=t.image?.index,x=t.image?.url;let _;e[12]!==s||e[13]!==t.open||e[14]!==P||e[15]!==x?(_=[s,P,x,t.open],e[12]=s,e[13]=t.open,e[14]=P,e[15]=x,e[16]=_):_=e[16],v.useEffect(y,_);const k=s[c]??s[0]??t.image,N=k?.filename||t.title||"Image preview",p=s.length>1;let T;e[17]!==s.length?(T=()=>{s.length<=1||d(u=>(u-1+s.length)%s.length)},e[17]=s.length,e[18]=T):T=e[18];const S=T;let z;e[19]!==s.length?(z=()=>{s.length<=1||d(u=>(u+1)%s.length)},e[19]=s.length,e[20]=z):z=e[20];const f=z;let $,L;e[21]!==p||e[22]!==a||e[23]!==t.open||e[24]!==f||e[25]!==S?($=()=>{if(!t.open)return;const u=h=>{if(h.key==="Escape"){a(!1);return}if(h.key==="ArrowLeft"&&p){h.preventDefault(),S();return}h.key==="ArrowRight"&&p&&(h.preventDefault(),f())};return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u)}},L=[p,a,t.open,f,S],e[21]=p,e[22]=a,e[23]=t.open,e[24]=f,e[25]=S,e[26]=$,e[27]=L):($=e[26],L=e[27]),v.useEffect($,L);let X;e[28]===Symbol.for("react.memo_cache_sentinel")?(X=()=>{g(null)},e[28]=X):X=e[28];const K=k?.url;let ie;e[29]!==K?(ie=[K],e[29]=K,e[30]=ie):ie=e[30],v.useEffect(X,ie);let je;e:{const u=Math.max(160,w.width*(l?.86:.75)),h=Math.max(160,w.height*(l?.72:.75));if(!m){let ve;e[31]!==u?(ve=Math.round(u),e[31]=u,e[32]=ve):ve=e[32];let Ne;e[33]!==h?(Ne=Math.round(h),e[33]=h,e[34]=Ne):Ne=e[34];let ke;e[35]!==ve||e[36]!==Ne?(ke={width:ve,height:Ne},e[35]=ve,e[36]=Ne,e[37]=ke):ke=e[37],je=ke;break e}const M=u/m.width,C=h/m.height,I=Math.min(M,C);let A;e[38]!==m.width||e[39]!==I?(A=Math.round(m.width*I),e[38]=m.width,e[39]=I,e[40]=A):A=e[40];const Y=Math.max(1,A);let Se;e[41]!==m.height||e[42]!==I?(Se=Math.round(m.height*I),e[41]=m.height,e[42]=I,e[43]=Se):Se=e[43];const Pe=Math.max(1,Se);let _e;e[44]!==Y||e[45]!==Pe?(_e={width:Y,height:Pe},e[44]=Y,e[45]=Pe,e[46]=_e):_e=e[46],je=_e}const ge=je;if(!E||!k||typeof document>"u")return null;const se=t.open?"pointer-events-auto":"pointer-events-none";let oe;e[47]!==se?(oe=pe("fixed inset-0 z-50",se),e[47]=se,e[48]=oe):oe=e[48];const xe=b&&"transition-opacity duration-150 ease-out",re=R?"opacity-100":"opacity-0";let H;e[49]!==xe||e[50]!==re?(H=pe("absolute inset-0 bg-black/40",xe,re),e[49]=xe,e[50]=re,e[51]=H):H=e[51];let F;e[52]!==a?(F=()=>a(!1),e[52]=a,e[53]=F):F=e[53];let ae;e[54]!==H||e[55]!==F?(ae=i.jsx("div",{"aria-hidden":"true",className:H,onMouseDown:F}),e[54]=H,e[55]=F,e[56]=ae):ae=e[56];let V;e[57]!==p||e[58]!==f||e[59]!==S||e[60]!==o?(V=p&&i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",onMouseDown:Et,onClick:S,className:"absolute left-3 top-1/2 -translate-y-1/2 z-10 h-10 w-10 flex items-center justify-center rounded-full bg-black/40 text-foreground/90 hover:bg-black/55 focus:outline-none focus:ring-2 focus:ring-primary/60","aria-label":o("chat.toolOutputDialog.image.previousAria"),children:i.jsx(D,{name:"arrow-left-s",className:"h-6 w-6"})}),i.jsx("button",{type:"button",onMouseDown:Ct,onClick:f,className:"absolute right-3 top-1/2 -translate-y-1/2 z-10 h-10 w-10 flex items-center justify-center rounded-full bg-black/40 text-foreground/90 hover:bg-black/55 focus:outline-none focus:ring-2 focus:ring-primary/60","aria-label":o("chat.toolOutputDialog.image.nextAria"),children:i.jsx(D,{name:"arrow-right-s",className:"h-6 w-6"})})]}),e[57]=p,e[58]=f,e[59]=S,e[60]=o,e[61]=V):V=e[61];const we=l?"p-2.5":"p-4";let le;e[62]!==we?(le=pe("absolute inset-0 flex items-center justify-center pointer-events-none",we),e[62]=we,e[63]=le):le=e[63];const ce=b&&"transition-opacity duration-150 ease-out",be=R?"opacity-100":"opacity-0";let W;e[64]!==ce||e[65]!==be?(W=pe("pointer-events-auto flex flex-col gap-2",ce,be),e[64]=ce,e[65]=be,e[66]=W):W=e[66];const de=`${ge.width}px`;let U;e[67]!==de?(U={width:de},e[67]=de,e[68]=U):U=e[68];let Q;e[69]!==N?(Q=i.jsx("div",{className:"min-w-0 flex-1 text-foreground typography-ui-header font-semibold truncate",title:N,children:N}),e[69]=N,e[70]=Q):Q=e[70];let G;e[71]!==a?(G=()=>a(!1),e[71]=a,e[72]=G):G=e[72];let ue;e[73]!==o?(ue=o("chat.toolOutputDialog.image.closeAria"),e[73]=o,e[74]=ue):ue=e[74];let ee;e[75]===Symbol.for("react.memo_cache_sentinel")?(ee=i.jsx(D,{name:"close",className:"h-4 w-4"}),e[75]=ee):ee=e[75];let B;e[76]!==G||e[77]!==ue?(B=i.jsx("button",{type:"button",className:"h-8 w-8 flex items-center justify-center rounded-lg text-muted-foreground/80 hover:text-foreground focus:outline-none focus:ring-2 focus:ring-primary/60",onClick:G,"aria-label":ue,children:ee}),e[76]=G,e[77]=ue,e[78]=B):B=e[78];let q;e[79]!==Q||e[80]!==B?(q=i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[Q,B]}),e[79]=Q,e[80]=B,e[81]=q):q=e[81];const me=`${ge.width}px`,fe=`${ge.height}px`;let Z;e[82]!==me||e[83]!==fe?(Z={width:me,height:fe},e[82]=me,e[83]=fe,e[84]=Z):Z=e[84];let te;e[85]===Symbol.for("react.memo_cache_sentinel")?(te=u=>{const h=u.currentTarget,M=h.naturalWidth,C=h.naturalHeight;M>0&&C>0&&g(I=>I&&I.width===M&&I.height===C?I:{width:M,height:C})},e[85]=te):te=e[85];let J;e[86]!==k.url||e[87]!==N||e[88]!==Z?(J=i.jsx("img",{src:k.url,alt:N,className:"block object-contain",style:Z,loading:"lazy",onLoad:te}),e[86]=k.url,e[87]=N,e[88]=Z,e[89]=J):J=e[89];let ne;e[90]!==W||e[91]!==U||e[92]!==q||e[93]!==J?(ne=i.jsxs("div",{className:W,style:U,children:[q,J]}),e[90]=W,e[91]=U,e[92]=q,e[93]=J,e[94]=ne):ne=e[94];let j;e[95]!==le||e[96]!==ne?(j=i.jsx("div",{className:le,children:ne}),e[95]=le,e[96]=ne,e[97]=j):j=e[97];let O;if(e[98]!==oe||e[99]!==ae||e[100]!==V||e[101]!==j){const u=i.jsxs("div",{className:oe,children:[ae,V,j]});O=Fe.createPortal(u,document.body),e[98]=oe,e[99]=ae,e[100]=V,e[101]=j,e[102]=O}else O=e[102];return O},Ze=v.memo(n=>{const e=he.c(7),{popup:t,diffViewMode:a,pierreThemeConfig:l}=n,o=t.content||"",r=a==="unified"?"unified":"split";let s;e[0]!==l.theme||e[1]!==l.themeType||e[2]!==r?(s={diffStyle:r,diffIndicators:"none",hunkSeparators:"line-info-basic",lineDiffType:"none",disableFileHeader:!0,maxLineDiffLength:1e3,expansionLineCount:20,overflow:"wrap",theme:l.theme,themeType:l.themeType,unsafeCSS:_t},e[0]=l.theme,e[1]=l.themeType,e[2]=r,e[3]=s):s=e[3];let c;return e[4]!==o||e[5]!==s?(c=i.jsx("div",{className:"typography-code",children:i.jsx(Ye,{patch:o,metrics:kt,options:s,className:"block w-full"})}),e[4]=o,e[5]=s,e[6]=c):c=e[6],c});Ze.displayName="DialogUnifiedDiff";const Je=v.memo(n=>{const e=he.c(30),{popup:t,syntaxTheme:a,pierreThemeConfig:l}=n;let o;e[0]!==t.content?(o=at(t.content),e[0]=t.content,e[1]=o):o=e[1];const r=o,s=t.metadata?.input;let c;e[2]!==s?(c=typeof s=="object"&&s!==null?s:{},e[2]=s,e[3]=c):c=e[3];const d=c,m=typeof d.offset=="number"?d.offset:0,g=typeof d.file_path=="string"?d.file_path:typeof d.filePath=="string"?d.filePath:typeof d.path=="string"?d.path:"read-output";let E;e[4]!==r.lines?(E=r.lines.map(At).join(`
|
|
11
|
+
`),e[4]=r.lines,e[5]=E):E=e[5];const R=E;let b;e[6]!==g||e[7]!==t.language?(b=t.language||Ve(g)||"text",e[6]=g,e[7]=t.language,e[8]=b):b=e[8];const w=b;let y;e[9]!==r.lines?(y=r.lines.some(Ot),e[9]=r.lines,e[10]=y):y=e[10];const P=y;let x;if(e[11]!==P||e[12]!==m||e[13]!==r.lines||e[14]!==r.type){x=[];let N=m;for(const p of r.lines){p.lineNumber!==null&&(N=p.lineNumber);const T=r.type==="file"&&!P&&p.lineNumber===null&&!p.isInfo,S=p.lineNumber??(T?N+1:null);typeof S=="number"&&(N=S),x.push({text:p.text,lineNumber:S,isInfo:p.isInfo})}e[11]=P,e[12]=m,e[13]=r.lines,e[14]=r.type,e[15]=x}else x=e[15];const _=x;if(r.type==="file"){const N=w||void 0;let p;e[16]!==R||e[17]!==g||e[18]!==N?(p={name:g,contents:R,lang:N},e[16]=R,e[17]=g,e[18]=N,e[19]=p):p=e[19];let T;e[20]!==l.theme||e[21]!==l.themeType?(T={disableFileHeader:!0,overflow:"wrap",theme:l.theme,themeType:l.themeType},e[20]=l.theme,e[21]=l.themeType,e[22]=T):T=e[22];let S;return e[23]!==p||e[24]!==T?(S=i.jsx(He,{file:p,options:T,className:"block w-full"}),e[23]=p,e[24]=T,e[25]=S):S=e[25],S}let k;return e[26]!==_||e[27]!==w||e[28]!==a?(k=i.jsx(Ue,{lines:_,language:w,syntaxTheme:a,maxHeight:"70vh"}),e[26]=_,e[27]=w,e[28]=a,e[29]=k):k=e[29],k});Je.displayName="DialogReadContent";const Mt=n=>{const e=he.c(89),{popup:t,onOpenChange:a,isMobile:l}=n,{t:o}=Me(),[r,s]=v.useState(t.mermaid?.source||""),[c,d]=v.useState(t.mermaid?.source?"ready":"idle"),[m,g]=v.useState(""),{isRendered:E,isVisible:R,isTransitioning:b}=Be(t.open),[w,y]=v.useState(null),P=qe(t.open),x=v.useRef(0),_=v.useRef(null),k=Ft,N=Vt;let p;e[0]!==t.mermaid||e[1]!==o?(p=async()=>{const j=t.mermaid;if(!j?.url){d("error"),g(o("chat.toolOutputDialog.mermaid.missingSource"));return}if(j.source){s(j.source),d("ready"),g("");return}const O=x.current+1;x.current=O,d("loading"),g("");let u;if(j.url.startsWith("data:"))u=Promise.resolve(N(j.url));else if(j.url.toLowerCase().startsWith("file://")){const h=k(j.url);h?u=fetch(`/api/fs/raw?path=${encodeURIComponent(h)}`).then(Wt):u=Promise.reject(new Error("Invalid local file path for Mermaid preview."))}else{const M=(typeof URL.canParse=="function"?URL.canParse(j.url,window.location.origin):!1)?new URL(j.url,window.location.origin):null;!M||M.protocol!=="http:"&&M.protocol!=="https:"?u=Promise.reject(new Error("Unsupported Mermaid URL protocol.")):u=fetch(M.toString()).then(Ut)}await u.then(h=>{x.current===O&&(s(h),d("ready"))}).catch(h=>{x.current===O&&(d("error"),g(h instanceof Error?h.message:o("chat.toolOutputDialog.mermaid.loadFailed")))})},e[0]=t.mermaid,e[1]=o,e[2]=p):p=e[2];const T=p;let S,z;e[3]!==T||e[4]!==t.mermaid||e[5]!==t.open?(S=()=>{!t.open||!t.mermaid||T()},z=[T,t.mermaid,t.open],e[3]=T,e[4]=t.mermaid,e[5]=t.open,e[6]=S,e[7]=z):(S=e[6],z=e[7]),v.useEffect(S,z);let f,$;e[8]!==a||e[9]!==t.open?(f=()=>{if(!t.open)return;const j=O=>{O.key==="Escape"&&a(!1)};return window.addEventListener("keydown",j),()=>{window.removeEventListener("keydown",j)}},$=[a,t.open],e[8]=a,e[9]=t.open,e[10]=f,e[11]=$):(f=e[10],$=e[11]),v.useEffect(f,$);let L;e[12]!==t.open||e[13]!==c?(L=()=>{if(!t.open||c!=="ready"){y(null);return}const j=()=>{const I=_.current?.querySelector("svg");if(!I)return!1;const A=Pt(I);return!A||!Number.isFinite(A)||A<=0?!1:(y(Y=>Y&&Math.abs(Y-A)<.001?Y:A),!0)};let O=window.requestAnimationFrame(()=>{j()||(O=window.requestAnimationFrame(()=>{j()}))}),u=0,h;const M=()=>{u>=Tt||(h=window.setTimeout(()=>{u=u+1,j()||M()},Nt))};M();const C=new MutationObserver(()=>{j()});return _.current&&C.observe(_.current,{childList:!0,subtree:!0,attributes:!0}),()=>{window.cancelAnimationFrame(O),typeof h=="number"&&window.clearTimeout(h),C.disconnect()}},e[12]=t.open,e[13]=c,e[14]=L):L=e[14];let X;e[15]!==t.open||e[16]!==r||e[17]!==c?(X=[t.open,r,c],e[15]=t.open,e[16]=r,e[17]=c,e[18]=X):X=e[18],v.useEffect(L,X);const K=`\`\`\`mermaid
|
|
12
12
|
${r}
|
|
13
|
-
\`\`\``;let ie;if(e[19]!==w||e[20]!==l||e[21]!==P){e:{const{maxWidth:j,maxHeight:O}=Rt(P,l),u=Math.max(160,O-vt);if(w&&w<1){const C=Math.min(j,u);let I;e[23]!==C?(I=Math.round(C),e[23]=C,e[24]=I):I=e[24];let A;e[25]!==C?(A=Math.round(C),e[25]=C,e[26]=A):A=e[26];let Y;e[27]!==A||e[28]!==I?(Y={width:I,height:A},e[27]=A,e[28]=I,e[29]=Y):Y=e[29],ie=Y;break e}const h=Math.round(j);let M;e[30]!==u?(M=Math.round(u),e[30]=u,e[31]=M):M=e[31],ie={width:h,height:M}}e[19]=w,e[20]=l,e[21]=P,e[22]=ie}else ie=e[22];const je=ie;if(!E||typeof document>"u")return null;const ge=t.open?"pointer-events-auto":"pointer-events-none";let se;e[32]!==ge?(se=pe("fixed inset-0 z-50",ge),e[32]=ge,e[33]=se):se=e[33];const oe=b&&"transition-opacity duration-150 ease-out",xe=R?"opacity-100":"opacity-0";let re;e[34]!==oe||e[35]!==xe?(re=pe("absolute inset-0 bg-black/40",oe,xe),e[34]=oe,e[35]=xe,e[36]=re):re=e[36];let H;e[37]!==a?(H=()=>a(!1),e[37]=a,e[38]=H):H=e[38];let F;e[39]!==re||e[40]!==H?(F=i.jsx("div",{"aria-hidden":"true",className:re,onMouseDown:H}),e[39]=re,e[40]=H,e[41]=F):F=e[41];const ae=l?"p-2.5":"p-4";let V;e[42]!==ae?(V=pe("absolute inset-0 flex items-center justify-center pointer-events-none",ae),e[42]=ae,e[43]=V):V=e[43];const we=b&&"transition-opacity duration-150 ease-out",le=R?"opacity-100":"opacity-0";let ce;e[44]!==we||e[45]!==le?(ce=pe("pointer-events-auto flex flex-col gap-2",we,le),e[44]=we,e[45]=le,e[46]=ce):ce=e[46];const be=`${je.width}px`;let W;e[47]!==be?(W={width:be},e[47]=be,e[48]=W):W=e[48];let de;e[49]!==a?(de=()=>a(!1),e[49]=a,e[50]=de):de=e[50];let U;e[51]!==o?(U=o("chat.toolOutputDialog.mermaid.closeAria"),e[51]=o,e[52]=U):U=e[52];let Q;e[53]===Symbol.for("react.memo_cache_sentinel")?(Q=i.jsx(D,{name:"close",className:"h-4 w-4"}),e[53]=Q):Q=e[53];let G;e[54]!==de||e[55]!==U?(G=i.jsx("div",{className:"flex items-center justify-end",children:i.jsx("button",{type:"button",className:"h-8 w-8 flex items-center justify-center rounded-lg text-muted-foreground/80 hover:text-foreground focus:outline-none focus:ring-2 focus:ring-primary/60",onClick:de,"aria-label":U,children:Q})}),e[54]=de,e[55]=U,e[56]=G):G=e[56];const ue=`${je.height}px`;let ee;e[57]!==ue?(ee={height:ue},e[57]=ue,e[58]=ee):ee=e[58];let B;e[59]!==c||e[60]!==o?(B=c==="loading"&&i.jsxs("div",{className:"h-full min-h-28 flex items-center justify-center gap-2 text-muted-foreground typography-meta",children:[i.jsx(D,{name:"loader-4",className:"h-4 w-4 animate-spin"}),i.jsx("span",{children:o("chat.toolOutputDialog.mermaid.loading")})]}),e[59]=c,e[60]=o,e[61]=B):B=e[61];let q;e[62]!==
|
|
13
|
+
\`\`\``;let ie;if(e[19]!==w||e[20]!==l||e[21]!==P){e:{const{maxWidth:j,maxHeight:O}=Rt(P,l),u=Math.max(160,O-vt);if(w&&w<1){const C=Math.min(j,u);let I;e[23]!==C?(I=Math.round(C),e[23]=C,e[24]=I):I=e[24];let A;e[25]!==C?(A=Math.round(C),e[25]=C,e[26]=A):A=e[26];let Y;e[27]!==A||e[28]!==I?(Y={width:I,height:A},e[27]=A,e[28]=I,e[29]=Y):Y=e[29],ie=Y;break e}const h=Math.round(j);let M;e[30]!==u?(M=Math.round(u),e[30]=u,e[31]=M):M=e[31],ie={width:h,height:M}}e[19]=w,e[20]=l,e[21]=P,e[22]=ie}else ie=e[22];const je=ie;if(!E||typeof document>"u")return null;const ge=t.open?"pointer-events-auto":"pointer-events-none";let se;e[32]!==ge?(se=pe("fixed inset-0 z-50",ge),e[32]=ge,e[33]=se):se=e[33];const oe=b&&"transition-opacity duration-150 ease-out",xe=R?"opacity-100":"opacity-0";let re;e[34]!==oe||e[35]!==xe?(re=pe("absolute inset-0 bg-black/40",oe,xe),e[34]=oe,e[35]=xe,e[36]=re):re=e[36];let H;e[37]!==a?(H=()=>a(!1),e[37]=a,e[38]=H):H=e[38];let F;e[39]!==re||e[40]!==H?(F=i.jsx("div",{"aria-hidden":"true",className:re,onMouseDown:H}),e[39]=re,e[40]=H,e[41]=F):F=e[41];const ae=l?"p-2.5":"p-4";let V;e[42]!==ae?(V=pe("absolute inset-0 flex items-center justify-center pointer-events-none",ae),e[42]=ae,e[43]=V):V=e[43];const we=b&&"transition-opacity duration-150 ease-out",le=R?"opacity-100":"opacity-0";let ce;e[44]!==we||e[45]!==le?(ce=pe("pointer-events-auto flex flex-col gap-2",we,le),e[44]=we,e[45]=le,e[46]=ce):ce=e[46];const be=`${je.width}px`;let W;e[47]!==be?(W={width:be},e[47]=be,e[48]=W):W=e[48];let de;e[49]!==a?(de=()=>a(!1),e[49]=a,e[50]=de):de=e[50];let U;e[51]!==o?(U=o("chat.toolOutputDialog.mermaid.closeAria"),e[51]=o,e[52]=U):U=e[52];let Q;e[53]===Symbol.for("react.memo_cache_sentinel")?(Q=i.jsx(D,{name:"close",className:"h-4 w-4"}),e[53]=Q):Q=e[53];let G;e[54]!==de||e[55]!==U?(G=i.jsx("div",{className:"flex items-center justify-end",children:i.jsx("button",{type:"button",className:"h-8 w-8 flex items-center justify-center rounded-lg text-muted-foreground/80 hover:text-foreground focus:outline-none focus:ring-2 focus:ring-primary/60",onClick:de,"aria-label":U,children:Q})}),e[54]=de,e[55]=U,e[56]=G):G=e[56];const ue=`${je.height}px`;let ee;e[57]!==ue?(ee={height:ue},e[57]=ue,e[58]=ee):ee=e[58];let B;e[59]!==c||e[60]!==o?(B=c==="loading"&&i.jsxs("div",{className:"h-full min-h-28 flex items-center justify-center gap-2 text-muted-foreground typography-meta",children:[i.jsx(D,{name:"loader-4",className:"h-4 w-4 animate-spin"}),i.jsx("span",{children:o("chat.toolOutputDialog.mermaid.loading")})]}),e[59]=c,e[60]=o,e[61]=B):B=e[61];let q;e[62]!==m||e[63]!==T||e[64]!==c||e[65]!==o?(q=c==="error"&&i.jsxs("div",{className:"rounded-xl border border-border/30 bg-muted/20 p-3 space-y-3",children:[i.jsx("p",{className:"typography-markdown",style:{color:"var(--status-error)"},children:m||o("chat.toolOutputDialog.mermaid.renderFailed")}),i.jsx("button",{type:"button",onClick:()=>{T()},className:"px-3 py-1.5 rounded-lg typography-meta border transition-colors hover:bg-[var(--interactive-hover)]",style:{borderColor:"var(--interactive-border)",color:"var(--surface-foreground)"},children:o("chat.toolOutputDialog.mermaid.retry")})]}),e[62]=m,e[63]=T,e[64]=c,e[65]=o,e[66]=q):q=e[66];let me;e[67]!==K||e[68]!==c?(me=c==="ready"&&i.jsx("div",{ref:_,className:"h-full",children:i.jsx(We,{content:K,variant:"tool",allowMermaidWheelZoom:!0,className:"markdown-mermaid-fullscreen h-full [&_[data-markdown='mermaid-block']_button]:hidden",mermaidControls:St})}),e[67]=K,e[68]=c,e[69]=me):me=e[69];let fe;e[70]!==B||e[71]!==q||e[72]!==me?(fe=i.jsxs("div",{className:"h-full overflow-hidden",children:[B,q,me]}),e[70]=B,e[71]=q,e[72]=me,e[73]=fe):fe=e[73];let Z;e[74]!==ee||e[75]!==fe?(Z=i.jsx("div",{className:"relative overflow-hidden",style:ee,children:fe}),e[74]=ee,e[75]=fe,e[76]=Z):Z=e[76];let te;e[77]!==ce||e[78]!==W||e[79]!==G||e[80]!==Z?(te=i.jsxs("div",{className:ce,style:W,onMouseDown:Gt,children:[G,Z]}),e[77]=ce,e[78]=W,e[79]=G,e[80]=Z,e[81]=te):te=e[81];let J;e[82]!==V||e[83]!==te?(J=i.jsx("div",{className:V,children:te}),e[82]=V,e[83]=te,e[84]=J):J=e[84];let ne;if(e[85]!==se||e[86]!==F||e[87]!==J){const j=i.jsxs("div",{className:se,children:[F,J]});ne=Fe.createPortal(j,document.body),e[85]=se,e[86]=F,e[87]=J,e[88]=ne}else ne=e[88];return ne},Kt=n=>{const e=he.c(50),{popup:t,onOpenChange:a,syntaxTheme:l,isMobile:o}=n,{t:r}=Me(),[s,c]=v.useState("unified"),d=It();let m;e[0]!==t.open?(m=()=>{t.open&&c("unified")},e[0]=t.open,e[1]=m):m=e[1];let g;if(e[2]!==t.open||e[3]!==t.title?(g=[t.open,t.title],e[2]=t.open,e[3]=t.title,e[4]=g):g=e[4],v.useEffect(m,g),t.image){let f;return e[5]!==o||e[6]!==a||e[7]!==t?(f=i.jsx(Lt,{popup:t,onOpenChange:a,isMobile:o}),e[5]=o,e[6]=a,e[7]=t,e[8]=f):f=e[8],f}if(t.mermaid){let f;return e[9]!==o||e[10]!==a||e[11]!==t?(f=i.jsx(Mt,{popup:t,onOpenChange:a,isMobile:o}),e[9]=o,e[10]=a,e[11]=t,e[12]=f):f=e[12],f}const E=t.open,R=o?"w-[95vw] max-w-[95vw]":"max-w-5xl",b=o?"[&>button]:right-1":"[&>button]:top-2.5 [&>button]:right-4";let w;e[13]!==R||e[14]!==b?(w=pe("overflow-hidden flex flex-col min-h-0 pt-3 pb-4 px-4 gap-1","[&>button]:top-1.5",R,b),e[13]=R,e[14]=b,e[15]=w):w=e[15];let y;e[16]===Symbol.for("react.memo_cache_sentinel")?(y={maxHeight:"90vh"},e[16]=y):y=e[16];let P;e[17]!==t.metadata?(P=t.metadata?.tool?jt(t.metadata.tool):i.jsx(D,{name:"tools",className:"h-3.5 w-3.5 text-foreground flex-shrink-0"}),e[17]=t.metadata,e[18]=P):P=e[18];let x;e[19]!==t.title?(x=i.jsx("span",{className:"break-words flex-1 leading-tight",children:t.title}),e[19]=t.title,e[20]=x):x=e[20];let _;e[21]!==s||e[22]!==t.isDiff?(_=t.isDiff&&i.jsx(Xe,{mode:s,onModeChange:c,className:"mr-8 flex-shrink-0"}),e[21]=s,e[22]=t.isDiff,e[23]=_):_=e[23];let k;e[24]!==_||e[25]!==P||e[26]!==x?(k=i.jsx("div",{className:"flex-shrink-0 pb-1",children:i.jsxs("div",{className:"flex items-start gap-2 text-foreground typography-ui-header font-semibold",children:[P,x,_]})}),e[24]=_,e[25]=P,e[26]=x,e[27]=k):k=e[27];let N;e[28]!==d||e[29]!==t.metadata||e[30]!==l?(N=t.metadata?.input&&typeof t.metadata.input=="object"&&Object.keys(t.metadata.input).length>0&&t.metadata?.tool!=="todowrite"&&t.metadata?.tool!=="todoread"&&t.metadata?.tool!=="apply_patch"?(()=>{const f=t.metadata,$=f.input,L=X=>{const K=$[X];return typeof K=="string"?K:typeof K=="number"?String(K):null};return i.jsxs("div",{className:"border-b border-border/20 p-4 -mx-3",children:[i.jsx("div",{className:"typography-markdown font-medium text-muted-foreground mb-2 px-3",children:f.tool==="bash"?"Command:":f.tool==="task"?"Task Details:":"Input:"}),f.tool==="bash"&&L("command")?i.jsx("div",{className:"tool-input-surface bg-transparent rounded-xl border border-border/20 mx-3",children:i.jsx(Ie,{style:l,language:"bash",PreTag:"div",customStyle:Te.getPopupStyles(),codeTagProps:Re,wrapLongLines:!0,children:L("command")})}):f.tool==="task"&&L("prompt")?i.jsxs("div",{className:"tool-input-surface bg-transparent rounded-xl border border-border/20 font-mono whitespace-pre-wrap text-foreground/90 mx-3",style:Te.getPopupStyles(),children:[L("description")?`Task: ${L("description")}
|
|
14
14
|
`:"",L("subagent_type")?`Agent Type: ${L("subagent_type")}
|
|
15
15
|
`:"",`Instructions:
|
|
16
|
-
${L("prompt")}`]}):
|
|
16
|
+
${L("prompt")}`]}):f.tool==="write"&&L("content")?i.jsx("div",{className:"tool-input-surface bg-transparent rounded-xl border border-border/20 mx-3",children:i.jsx(He,{file:{name:L("filePath")||L("file_path")||"new-file",contents:L("content"),lang:Ve(L("filePath")||L("file_path")||"")||void 0},options:{disableFileHeader:!0,overflow:"wrap",theme:d.theme,themeType:d.themeType},className:"block w-full"})}):i.jsx("div",{className:"tool-input-surface bg-transparent rounded-xl border border-border/20 font-mono whitespace-pre-wrap text-foreground/90 mx-3",style:Te.getPopupStyles(),children:Qe($,f.tool)})]})})():null,e[28]=d,e[29]=t.metadata,e[30]=l,e[31]=N):N=e[31];let p;e[32]!==s||e[33]!==o||e[34]!==d||e[35]!==t||e[36]!==l||e[37]!==r?(p=t.isDiff?i.jsx(Ze,{popup:t,diffViewMode:s,pierreThemeConfig:d}):t.content?i.jsx("div",{className:"p-4",children:(()=>{const f=t.metadata?.tool;return f==="todowrite"||f==="todoread"?et(t.content,{total:r("chat.todo.total"),inProgress:r("chat.todo.inProgress"),pending:r("chat.todo.pending"),completed:r("chat.todo.completed"),cancelled:r("chat.todo.cancelled")})||i.jsx(Ie,{style:l,language:"json",PreTag:"div",wrapLongLines:!0,customStyle:Te.getPopupContainerStyles(),codeTagProps:Re,children:t.content}):f==="list"?tt(t.content)||i.jsx("pre",{className:"typography-markdown bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap",children:t.content}):f==="grep"?nt(t.content,o)||i.jsx("pre",{className:"typography-code bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap",children:t.content}):f==="glob"?it(t.content,o)||i.jsx("pre",{className:"typography-code bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap",children:t.content}):f==="task"||f==="reasoning"?i.jsx("div",{className:f==="reasoning"?"text-muted-foreground/70":"",children:i.jsx(We,{content:t.content,variant:"tool"})}):f==="web-search"||f==="websearch"||f==="search_web"?st(t.content)||i.jsx(Ie,{style:l,language:"text",PreTag:"div",wrapLongLines:!0,customStyle:Te.getPopupContainerStyles(),codeTagProps:Re,children:t.content}):f==="read"?i.jsx(Je,{popup:t,syntaxTheme:l,pierreThemeConfig:d}):(t.content?ot(t.content):{isJson:!1}).isJson?i.jsx(dt,{jsonString:t.content,initiallyExpandedDepth:3,maxHeight:"70vh"}):i.jsx(Ie,{style:l,language:t.language||"text",PreTag:"div",wrapLongLines:!0,customStyle:Te.getPopupContainerStyles(),codeTagProps:Re,children:t.content})})()}):i.jsxs("div",{className:"p-8 text-muted-foreground typography-ui-header",children:[i.jsx("div",{className:"mb-2",children:r("chat.toolOutputDialog.commandCompleted")}),i.jsx("div",{className:"typography-meta",children:r("chat.toolOutputDialog.noOutputProduced")})]}),e[32]=s,e[33]=o,e[34]=d,e[35]=t,e[36]=l,e[37]=r,e[38]=p):p=e[38];let T;e[39]!==N||e[40]!==p?(T=i.jsx("div",{className:"flex-1 min-h-0 rounded-xl border border-border/30 bg-muted/10 overflow-hidden",children:i.jsxs("div",{className:"tool-output-surface h-full max-h-[75vh] overflow-y-auto px-3 pr-4",children:[N,p]})}),e[39]=N,e[40]=p,e[41]=T):T=e[41];let S;e[42]!==k||e[43]!==T||e[44]!==w?(S=i.jsxs(lt,{className:w,style:y,children:[k,T]}),e[42]=k,e[43]=T,e[44]=w,e[45]=S):S=e[45];let z;return e[46]!==a||e[47]!==t.open||e[48]!==S?(z=i.jsx(ct,{open:E,onOpenChange:a,children:S}),e[46]=a,e[47]=t.open,e[48]=S,e[49]=z):z=e[49],z};function Dt(n){return!!n?.url}function Et(n){return n.stopPropagation()}function Ct(n){return n.stopPropagation()}function At(n){return n.text}function Ot(n){return n.lineNumber!==null}function zt(n){if(!n||/[\0\r\n]/.test(n))return!1;const e=n.replace(/\\/g,"/");return e.split("/").filter(Boolean).includes("..")?!1:e.startsWith("/")?!0:/^[A-Za-z]:\//.test(e)}function $t(n,e){const t=Number.parseInt(e,16);return Number.isFinite(t)?String.fromCharCode(t):`%${e}`}function Ht(n){return n.replace(/%([0-9A-Fa-f]{2})/g,$t)}function Ft(n){const e=n.trim();if(!e.toLowerCase().startsWith("file://"))return null;const t=zt,a=Ht;if(typeof URL.canParse=="function"?URL.canParse(e):!1){let s=a(new URL(e).pathname||"");return/^\/[A-Za-z]:\//.test(s)&&(s=s.slice(1)),t(s)?s:null}const o=e.replace(/^file:\/\//i,""),r=a(o);return t(r)?r:t(o)?o:null}function Vt(n){const e=n.indexOf(",");if(e<0)throw new Error("Malformed data URL");const t=n.slice(0,e).toLowerCase(),a=n.slice(e+1);return t.includes(";base64")?atob(a):decodeURIComponent(a)}function Wt(n){return n.ok?n.text():Promise.reject(new Error(`Failed to read diagram file (${n.status})`))}function Ut(n){return n.ok?n.text():Promise.reject(new Error(`Failed to load diagram (${n.status})`))}function Gt(n){return n.stopPropagation()}export{Kt as default};
|