@openchamber/web 1.13.5 → 1.13.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/lib/commands-update.test.js +50 -0
- package/dist/assets/{DiagramView-Bbj-QI7h.js → DiagramView-BJkP8Fjp.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-BNr_9Jsb.js → MarkdownRendererImpl-Nq7bOf31.js} +3 -3
- package/dist/assets/{MultiRunWindow-DMMu53kw.js → MultiRunWindow-CRKVePMG.js} +1 -1
- package/dist/assets/NewWorktreeDialog-Dj6KETex.js +167 -0
- package/dist/assets/{OnboardingScreen-BucKVBD7.js → OnboardingScreen-DRe8UNiS.js} +1 -1
- package/dist/assets/{SessionSwitcherDropdown-B6kvduse.js → SessionSwitcherDropdown-Cn_yoQrm.js} +1 -1
- package/dist/assets/{SettingsWindow-BEfDro9b.js → SettingsWindow-BIKNrxSK.js} +1 -1
- package/dist/assets/{TerminalView-CMdqMpTy.js → TerminalView-BDjzrhGS.js} +1 -1
- package/dist/assets/{es-Bk-yR0w-.js → es-D0PPWgfL.js} +1 -1
- package/dist/assets/{fr-f1ibV7QU.js → fr-4AxG2GNC.js} +1 -1
- package/dist/assets/index-AsCHiJ5P.js +3 -0
- package/dist/assets/{index-B82A6jBD.css → index-Bv4711NQ.css} +1 -1
- package/dist/assets/{ja-D9mS3zWP.js → ja-BPVJtPU2.js} +1 -1
- package/dist/assets/{ko-Cpl1IA3D.js → ko-BJHERh2a.js} +1 -1
- package/dist/assets/main-BByFAmjA.js +214 -0
- package/dist/assets/{main-KEVf2Yak.js → main-BJDsJGkp.js} +2 -2
- package/dist/assets/miniChat-Ckr71tB9.js +2 -0
- package/dist/assets/mobile-DVDtnIcD.js +2 -0
- package/dist/assets/{pl-CYke_fxL.js → pl-CH00wT_K.js} +1 -1
- package/dist/assets/{pt-BR-Clb6Z8up.js → pt-BR-1tfKEfvN.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-Cb1iUq8M.js → renderElectronMiniChatApp-CXvtB6Rd.js} +2 -2
- package/dist/assets/{renderMobileApp-7chEBHPK.js → renderMobileApp-BVAt5rTM.js} +3 -3
- package/dist/assets/{uk-CXn8cxXa.js → uk-BkeRI8D4.js} +1 -1
- package/dist/assets/{useAppFontEffects-Bd0ks39c.js → useAppFontEffects-B66TruVB.js} +114 -114
- package/dist/assets/{zh-CN-BRwwlEdG.js → zh-CN-DtROWolc.js} +1 -1
- package/dist/assets/{zh-TW-D5pg5Z8l.js → zh-TW-CDqNEP6z.js} +1 -1
- package/dist/index.html +3 -3
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +1 -1
- package/server/lib/package-manager.js +2 -2
- package/server/lib/package-manager.test.js +13 -1
- package/dist/assets/NewWorktreeDialog-5TYBoMMA.js +0 -167
- package/dist/assets/index-BsXkdBYx.js +0 -3
- package/dist/assets/main-DOdUrt3s.js +0 -214
- package/dist/assets/miniChat-Nlzqr3Df.js +0 -2
- package/dist/assets/mobile-BIhOFhia.js +0 -2
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import os from 'os';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
5
|
+
|
|
6
|
+
import { createUpdateCommand } from './commands-update.js';
|
|
7
|
+
|
|
8
|
+
async function withTempOpenChamberDataDir(fn) {
|
|
9
|
+
const previous = process.env.OPENCHAMBER_DATA_DIR;
|
|
10
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'openchamber-update-test-'));
|
|
11
|
+
process.env.OPENCHAMBER_DATA_DIR = dir;
|
|
12
|
+
try {
|
|
13
|
+
return await fn(dir);
|
|
14
|
+
} finally {
|
|
15
|
+
if (typeof previous === 'string') {
|
|
16
|
+
process.env.OPENCHAMBER_DATA_DIR = previous;
|
|
17
|
+
} else {
|
|
18
|
+
delete process.env.OPENCHAMBER_DATA_DIR;
|
|
19
|
+
}
|
|
20
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
describe('update command', () => {
|
|
25
|
+
it('uses the package-manager helpers on the update-available path', async () => {
|
|
26
|
+
await withTempOpenChamberDataDir(async () => {
|
|
27
|
+
const originalWrite = process.stdout.write;
|
|
28
|
+
process.stdout.write = vi.fn(() => true);
|
|
29
|
+
const executeUpdate = vi.fn(() => ({ success: true, exitCode: 0 }));
|
|
30
|
+
const updateCommand = createUpdateCommand({
|
|
31
|
+
packageManagerPath: '/fake/package-manager.js',
|
|
32
|
+
serveCommand: vi.fn(),
|
|
33
|
+
importFromFilePath: vi.fn(async () => ({
|
|
34
|
+
checkForUpdates: vi.fn(async () => ({ available: true, version: '9.9.9' })),
|
|
35
|
+
detectPackageManager: vi.fn(() => 'npm'),
|
|
36
|
+
executeUpdate,
|
|
37
|
+
getCurrentVersion: vi.fn(() => '1.0.0'),
|
|
38
|
+
})),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
await updateCommand({ json: true });
|
|
43
|
+
|
|
44
|
+
expect(executeUpdate).toHaveBeenCalledWith('npm', { silent: true });
|
|
45
|
+
} finally {
|
|
46
|
+
process.stdout.write = originalWrite;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as s,j as e}from"./vendor-.bun-By2L9XvG.js";import{b as c}from"./index-
|
|
1
|
+
import{R as s,j as e}from"./vendor-.bun-By2L9XvG.js";import{b as c}from"./index-AsCHiJ5P.js";import{u as b,a as j,I as a}from"./useAppFontEffects-B66TruVB.js";import{D as y}from"./main-BByFAmjA.js";import"./NewWorktreeDialog-Dj6KETex.js";import"./mobileLayoutPreference-Dio-WWkI.js";import"./SessionSwitcherDropdown-Cn_yoQrm.js";function S(){const{t:n}=b(),{files:r}=j(),[t,x]=s.useState(null),[l,o]=s.useState(""),[p,m]=s.useState(!0),u=s.useRef(null),f=c(i=>i.pendingDiagramFile),d=s.useCallback(async i=>{m(!0),x(i);try{const g=await r?.readFile?.(i);g&&o(g.content)}catch{o("")}finally{m(!1)}},[r]);s.useEffect(()=>{if(!f)return;const i=c.getState().consumePendingDiagramFile();i&&d(i)},[d,f]);const h=s.useCallback(async()=>{const i=u.current?.getXml();t&&r?.writeFile&&i&&i!==l&&(await r.writeFile(t,i),o(i))},[t,r,l]),v=t?t.split("/").pop()||t:"";return t?p?e.jsx("div",{className:"flex h-full items-center justify-center p-3",children:e.jsx(a,{name:"loader-4",className:"size-4 animate-spin"})}):e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border/30 px-3 py-1.5",children:[e.jsx(a,{name:"file",className:"size-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"typography-ui text-muted-foreground truncate flex-1",children:v}),e.jsx("button",{type:"button",onClick:()=>{h()},className:"size-6 flex items-center justify-center rounded-md text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:n("filesView.diagram.saveDiagram"),children:e.jsx(a,{name:"save-3",className:"size-4"})}),e.jsx("button",{type:"button",onClick:()=>c.getState().setActiveMainTab("chat"),className:"size-6 flex items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:n("filesView.diagram.closeDiagramView"),children:e.jsx(a,{name:"close",className:"size-4"})})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(y,{ref:u,xml:l,className:"h-full"})})]}):e.jsx("div",{className:"flex h-full items-center justify-center p-3",children:e.jsx("div",{className:"typography-ui text-muted-foreground",children:n("filesView.editor.pickFileFromTree")})})}export{S as DiagramView};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{cc as $e,cd as Pe,ce as re,cf as it,R as x,e as B,cg as ct,ch as lt,ci as dt,j as X}from"./vendor-.bun-By2L9XvG.js";import{
|
|
2
|
-
`).at(-1)?.trim()??"";return!new RegExp(`^[\\t ]{0,3}${r}{${s},}[\\t ]*$`).test(o)},Z=t=>{try{return it(t,{linkMode:"text-only"})}catch{return t}},It=(t,e)=>{if(!e)return[{raw:t,src:t,mode:"full",highlight:!0}];if(
|
|
1
|
+
import{cc as $e,cd as Pe,ce as re,cf as it,R as x,e as B,cg as ct,ch as lt,ci as dt,j as X}from"./vendor-.bun-By2L9XvG.js";import{eT as ut,eU as mt,eV as ft,eW as pt,eX as Oe,eY as ht,eZ as bt,p as ce,cR as gt,cS as wt,a as De,b as Be,e_ as He,m as qe,dy as yt,r as ye,u as kt,e$ as Et,f0 as At,au as vt,f1 as ke,f2 as Ct,f3 as St,f4 as xt,f5 as Nt,c1 as Mt}from"./useAppFontEffects-B66TruVB.js";import{w as be,b as ge,h as Tt,j as Lt,e as Rt}from"./index-AsCHiJ5P.js";const G=t=>t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"),_t=t=>/^\[[^\]]+\]:\s+\S+/m.test(t)||/^\[\^[^\]]+\]:\s+/m.test(t),Ft=t=>{const e=t.match(/^[ \t]{0,3}(`{3,}|~{3,})/);if(!e)return!1;const n=e[1];if(!n)return!1;const r=n[0],s=n.length,o=t.trimEnd().split(`
|
|
2
|
+
`).at(-1)?.trim()??"";return!new RegExp(`^[\\t ]{0,3}${r}{${s},}[\\t ]*$`).test(o)},Z=t=>{try{return it(t,{linkMode:"text-only"})}catch{return t}},It=(t,e)=>{if(!e)return[{raw:t,src:t,mode:"full",highlight:!0}];if(_t(t))return[{raw:t,src:Z(t),mode:"live",highlight:!0}];let n;try{n=$e.lexer(t)}catch{return[{raw:t,src:Z(t),mode:"live",highlight:!0}]}let r=-1;for(let o=n.length-1;o>=0;o-=1)if(n[o]?.type!=="space"){r=o;break}if(r<0)return[{raw:t,src:Z(t),mode:"live",highlight:!0}];const s=[];for(let o=0;o<n.length;o+=1){const i=n[o];if(!i||i.type==="space")continue;const a=i.raw??"",c=o===r,l=i.type==="code"&&Ft(a);s.push({raw:a,src:l?a:Z(a),mode:c?"live":"full",highlight:!l})}return s.length===0?[{raw:t,src:Z(t),mode:"live",highlight:!0}]:s},We=(t,e,n)=>{try{return Pe.renderToString(t,{displayMode:n,throwOnError:!1})}catch{return e}},$t={name:"inlineMath",level:"inline",start(t){const e=t.indexOf("\\(");return e<0?void 0:e},tokenizer(t){const e=/^\\\(([\s\S]+?)\\\)/.exec(t);if(e)return{type:"inlineMath",raw:e[0],text:e[1]??""}},renderer(t){const e=t;return We(e.text,e.raw,!1)}},Pt={name:"blockMath",level:"block",start(t){const e=t.indexOf("\\[");return e<0?void 0:e},tokenizer(t){const e=/^\\\[([\s\S]+?)\\\]/.exec(t);if(e)return{type:"blockMath",raw:e[0],text:e[1]??""}},renderer(t){const e=t;return We(e.text,e.raw,!0)}},je=$e.use({gfm:!0,breaks:!1,extensions:[$t,Pt],renderer:{link({href:t,title:e,text:n}){const r=t??"",s=ut(r);if(s)return`<a href="${G(ft(s))}" data-openchamber-agent-mention="true" class="text-primary hover:underline" target="_blank" rel="noopener noreferrer">${n}</a>`;const o=mt(r);if(o)return`<a href="${G(r)}" data-skill-name="${G(o)}" class="text-primary hover:underline">${n}</a>`;const i=e?` title="${G(e)}"`:"";return`<a href="${G(r)}"${i} class="external-link" target="_blank" rel="noopener noreferrer">${n}</a>`}}}),Ot=t=>t.replace(/\$\$([\s\S]*?)\$\$/g,(e,n)=>{try{return Pe.renderToString(n,{displayMode:!0,throwOnError:!1})}catch{return`$$${n}$$`}}),ze=t=>{if(t.indexOf("$")===-1)return t;const e=/(<(?:pre|code|kbd)[^>]*>[\s\S]*?<\/(?:pre|code|kbd)>)/gi;return t.split(e).map((n,r)=>r%2===1?n:Ot(n)).join("")},Dt=/<pre><code(?:\s+class="language-([^"]*)")?>([\s\S]*?)<\/code><\/pre>/g,Bt=1200,Ht=200,qt=(t,e)=>{let n=1;for(let r=0;r<t.length;r+=1)if(t.charCodeAt(r)===10&&++n>e)return!0;return!1},Wt=t=>t.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&"),jt=async t=>{const e=[...t.matchAll(Dt)];if(e.length===0)return t;const n=be()?Ht:Bt;let r=t;for(const s of e){const[o,i,a]=s,c=(i||"text").toLowerCase();if(c==="mermaid")continue;const l=Wt(a??"");if(qt(l,n)){r=r.replace(o,()=>o.replace("<pre",`<pre data-md-lang="${c}"`));continue}const d=await pt(l,c);if(d){const m=d.replace(/^<pre/,`<pre data-md-lang="${c}"`);r=r.replace(o,()=>m)}}return r},zt={USE_PROFILES:{html:!0,mathMl:!0,svg:!0},ADD_TAGS:["svg","path","g","rect","line","polygon","polyline","circle","ellipse","text","tspan","defs","marker"],ADD_ATTR:["d","viewBox","preserveAspectRatio","xmlns","target","fill","stroke","stroke-width","transform","points","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","style"],FORBID_TAGS:["script"],FORBID_CONTENTS:["script"]};let Ee=!1;const Kt=()=>{Ee||typeof window>"u"||!re.isSupported||(Ee=!0,re.addHook("afterSanitizeAttributes",t=>{t instanceof HTMLAnchorElement&&t.target==="_blank"&&t.setAttribute("rel","noopener noreferrer")}))},Ke=t=>re.isSupported?(Kt(),re.sanitize(t,zt)):"",Vt=240,K=new Map,Ut=t=>{let e=2166136261;for(let n=0;n<t.length;n+=1)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return(e>>>0).toString(36)},Ae=(t,e)=>{if(K.delete(t),K.set(t,e),K.size<=Vt)return;const n=K.keys().next().value;n&&K.delete(n)},Gt=async t=>{const e=await Promise.resolve(je.parse(t.src)),n=ze(e),r=t.highlight?await jt(n):n;return Ke(r)},Zt=t=>{if(!t)return"";const e=je.parse(t),n=ze(e);return Ke(n)},Xt=async(t,e,n)=>{if(!t)return[];const r=It(t,e);return Promise.all(r.map(async(s,o)=>{const i=Ut(s.raw),a=`${i}:${s.mode}:${s.highlight?1:0}`,c=`${n}:${o}:${s.mode}`,l=K.get(c);if(l&&l.hash===i)return Ae(c,l),{id:a,html:l.html};const d=await Gt(s);return Ae(c,{hash:i,html:d}),{id:a,html:d}}))},le=t=>`<svg class="remixicon size-3.5" viewBox="0 0 24 24" aria-hidden="true"><use href="#oc-${t}"></use></svg>`,oe={copy:le("file-copy"),check:le("check"),download:le("download")},Ve="p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",Y=(t,e)=>{t.innerHTML=e},U=(t,e,n)=>{const r=document.createElement("button");return r.type="button",r.className=Ve,r.setAttribute("data-md-action",n),r.setAttribute("title",e),r.setAttribute("aria-label",e),Y(r,oe[t]),r},ve=(t,e,n,r)=>{Y(t,oe.check),t.setAttribute("title",e),window.setTimeout(()=>{Y(t,oe[n]),t.setAttribute("title",r)},2e3)},Yt=t=>{const e=t.querySelectorAll(":not(pre) > code");for(const n of Array.from(e))n.getAttribute("data-markdown")!=="inline-code"&&n.setAttribute("data-markdown","inline-code")},Jt=(t,e)=>{const n=t.querySelectorAll("pre");for(const r of Array.from(n)){if(r.querySelector("code.language-mermaid"))continue;const s=r.parentElement;if(!s||s.closest('[data-component="markdown-code"]'))continue;const o=r.querySelector("code")?.className.match(/language-([\w+#.-]+)/)?.[1],i=r.getAttribute("data-md-lang")??o??"text",a=document.createElement("div");a.setAttribute("data-component","markdown-code"),a.className="my-4 group overflow-hidden rounded-2xl border border-border/80 bg-[var(--surface-elevated)]";const c=document.createElement("div");c.className="flex items-center justify-between border-b border-border/70 px-3 py-1.5";const l=document.createElement("span");l.className="font-mono text-[13px] text-muted-foreground",l.textContent=i;const d=U("copy",e.copy,"copy-code");c.appendChild(l),c.appendChild(d);const m=document.createElement("div");m.className="px-3 py-2.5 overflow-x-auto",s.replaceChild(a,r),r.style.margin="0",r.style.background="transparent",m.appendChild(r),a.appendChild(c),a.appendChild(m)}},Ce=t=>{const e=[],n=[],r=t.querySelectorAll("thead th");for(const o of Array.from(r))e.push((o.textContent??"").trim());const s=t.querySelectorAll("tbody tr");for(const o of Array.from(s)){const i=Array.from(o.querySelectorAll("td")).map(a=>(a.textContent??"").trim());i.length>0&&n.push(i)}return{headers:e,rows:n}},Qt=t=>/[",\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t,Se=({headers:t,rows:e})=>[t,...e].map(n=>n.map(Qt).join(",")).join(`
|
|
3
3
|
`),en=({headers:t,rows:e})=>[t,...e].map(n=>n.join(" ")).join(`
|
|
4
4
|
`),xe=({headers:t,rows:e})=>{const n=`| ${t.join(" | ")} |`,r=`| ${t.map(()=>"---").join(" | ")} |`,s=e.map(o=>`| ${o.join(" | ")} |`).join(`
|
|
5
5
|
`);return`${n}
|
|
6
6
|
${r}
|
|
7
|
-
${s}`},Ne=(t,e)=>{const n=document.createElement("div");n.className=`absolute top-full right-0 mt-1 hidden ${gt}`,n.style.backgroundColor="var(--surface-elevated)",n.style.color="var(--surface-elevated-foreground)",n.setAttribute("data-md-menu",t);for(const r of e){const s=document.createElement("button");s.type="button",s.className=`w-full text-left ${wt}`,s.setAttribute("data-md-action",`${t}-${r.key}`),s.textContent=r.label,n.appendChild(s)}return n},tn=(t,e)=>{const n=t.querySelectorAll("table");for(const r of Array.from(n)){if(r.closest('[data-markdown="table-wrapper"]'))continue;const o=document.createElement("div");o.className="group my-4 flex flex-col space-y-2",o.setAttribute("data-markdown","table-wrapper");const i=document.createElement("div");i.className="flex items-center justify-end gap-1";const a=document.createElement("div");a.className="relative",a.appendChild(U("copy",e.copyTable,"table-copy-toggle")),a.appendChild(Ne("table-copy",[{key:"csv",label:"CSV"},{key:"tsv",label:"TSV"},{key:"markdown",label:"Markdown"}]));const c=document.createElement("div");c.className="relative",c.appendChild(U("download",e.downloadTable,"table-download-toggle")),c.appendChild(Ne("table-download",[{key:"csv",label:"CSV"},{key:"markdown",label:"Markdown"}])),i.appendChild(a),i.appendChild(c);const l=document.createElement("div");l.className="overflow-x-auto rounded-lg border border-border/80 bg-[var(--surface-elevated)]";const d=r.parentElement;if(!d)continue;d.replaceChild(o,r),r.setAttribute("data-markdown","table"),r.classList.add("w-full","border-collapse","text-sm");for(const p of Array.from(r.querySelectorAll("tr")))p.classList.add("border-b","border-border/60");const m=r.querySelector("tbody tr:last-child");m?.classList.remove("border-b"),m?.classList.add("border-0");for(const p of Array.from(r.querySelectorAll("th")))p.classList.add("border-r","border-border/60","px-4","py-2.5","text-left","align-middle","font-semibold","text-foreground","last:border-r-0");for(const p of Array.from(r.querySelectorAll("td")))p.classList.add("border-r","border-border/60","px-4","py-2.5","align-middle","text-foreground/90","last:border-r-0");l.appendChild(r),o.appendChild(i),o.appendChild(l)}},nn=(t,e)=>{const n=t.querySelectorAll("pre > code.language-mermaid");for(const r of Array.from(n)){const s=r.parentElement;if(!s)continue;const o=(r.textContent??"").replace(/\s+$/,""),i=e.renderMermaid(o),a=document.createElement("div");a.setAttribute("data-markdown","mermaid-block"),a.className="group relative";const c=document.createElement("div");c.setAttribute("data-markdown","mermaid-scroll");const l=document.createElement("div");if(l.className="absolute top-1 right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",i.svg){const m=document.createElement("div");m.setAttribute("data-markdown","mermaid"),Y(m,i.svg),c.appendChild(m);const p=U("copy",e.labels.copyDiagram,"mermaid-copy");p.setAttribute("data-md-source",o);const g=U("download",e.labels.downloadDiagram,"mermaid-download");g.setAttribute("data-md-svg","1"),l.appendChild(p),l.appendChild(g)}else{const m=document.createElement("pre");m.setAttribute("data-markdown","mermaid-ascii"),m.textContent=i.ascii||o,c.appendChild(m);const p=U("copy",e.labels.copyDiagram,"mermaid-copy");p.setAttribute("data-md-source",i.ascii||o),l.appendChild(p)}a.appendChild(c),a.appendChild(l);const d=s.parentElement;d&&d.replaceChild(a,s)}},rn=(t,e)=>{const n=t.querySelectorAll("a[href]");for(const r of Array.from(n)){if(r.getAttribute("data-md-link-decorated")==="true"||r.getAttribute("data-openchamber-file-link")==="true")continue;const s=r.getAttribute("href")??"";if(!Oe(s))continue;r.setAttribute("data-md-link-decorated","true");const o=ht(s);if(o){const i=document.createElement("span");i.className="mr-1 inline-flex size-[18px] items-center justify-center rounded border border-[var(--border)] bg-[var(--interactive-hover)] align-middle";const a=document.createElement("img");a.src=o,a.alt="",a.setAttribute("aria-hidden","true"),a.loading="lazy",a.decoding="async",a.className="size-3.5 rounded-sm",a.addEventListener("error",()=>i.remove(),{once:!0}),i.appendChild(a),r.parentNode?.insertBefore(i,r)}if(e.onPreviewLoopback&&bt(s)){const i=document.createElement("button");i.type="button",i.className=`ml-1 align-middle ${Ve}`,i.setAttribute("data-md-action","preview-loopback"),i.setAttribute("data-md-url",s),i.setAttribute("title",e.labels.previewTitle),i.setAttribute("aria-label",e.labels.previewLabel),Y(i,oe.download),r.parentNode?.insertBefore(i,r.nextSibling)}}},Me=(t,e)=>{Yt(t),nn(t,e),Qt(t,e.labels),tn(t,e.labels),rn(t,e)},Te=(t,e,n)=>{const r=new Blob([e],{type:n}),s=URL.createObjectURL(r),o=document.createElement("a");o.href=s,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(s)},te=t=>{for(const e of Array.from(t.querySelectorAll("[data-md-menu]")))e.classList.add("hidden")},on=(t,e)=>{const n=r=>{const s=r.target;if(!(s instanceof Element))return;const o=s.closest("[data-md-action]");if(!o){te(t);return}const i=o.getAttribute("data-md-action")??"";if(i==="copy-code"){const c=o.closest('[data-component="markdown-code"]')?.querySelector("code")?.textContent??"";c&&ce(c).then(()=>ve(o,e.labels.copied,"copy",e.labels.copy));return}if(i==="table-copy-toggle"||i==="table-download-toggle"){r.preventDefault();const a=o.parentElement?.querySelector("[data-md-menu]")??null,c=a?.classList.contains("hidden")??!1;te(t),a&&c&&a.classList.remove("hidden");return}if(i.startsWith("table-copy-")){const a=i.replace("table-copy-",""),c=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(c instanceof HTMLTableElement){const l=Ce(c),d=a==="csv"?Se(l):a==="tsv"?en(l):xe(l);ce(d)}te(t);return}if(i.startsWith("table-download-")){const a=i.replace("table-download-",""),c=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(c instanceof HTMLTableElement){const l=Ce(c),d=a==="csv"?Se(l):xe(l);Te(a==="csv"?"table.csv":"table.md",d,a==="csv"?"text/csv":"text/markdown")}te(t);return}if(i==="mermaid-copy"){const a=o.getAttribute("data-md-source")??"";a&&ce(a).then(()=>ve(o,e.labels.copied,"copy",e.labels.copyDiagram));return}if(i==="mermaid-download"){const c=o.closest('[data-markdown="mermaid-block"]')?.querySelector('[data-markdown="mermaid"]')?.innerHTML??"";c&&Te("diagram.svg",c,"image/svg+xml;charset=utf-8");return}if(i==="preview-loopback"){r.preventDefault();const a=o.getAttribute("data-md-url")??"";a&&e.onPreviewLoopback?.(a);return}};return t.addEventListener("click",n),()=>t.removeEventListener("click",n)},Ue=()=>{const t=B.c(4),e=yt();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=ye(!1),t[0]=n):n=t[0];const r=n;let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=ye(!0),t[1]=s):s=t[1];const o=s;let i;return t[2]!==e?.currentTheme?(i=e?.currentTheme??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?o:r),t[2]=e?.currentTheme,t[3]=i):i=t[3],i},Ge=t=>{const e=B.c(4),{containerRef:n,enabled:r}=t;let s,o;e[0]!==n||e[1]!==r?(s=()=>{if(r===!1)return;const i=n.current;if(!i)return;const a=Fn;return i.addEventListener("click",a),()=>{i.removeEventListener("click",a)}},o=[n,r],e[0]=n,e[1]=r,e[2]=s,e[3]=o):(s=e[2],o=e[3]),x.useEffect(s,o)},Ze=t=>{if(!t.includes("mermaid"))return[];const e=[],n=/(?:^|\r?\n)(`{3,}|~{3,})mermaid[^\n\r]*\r?\n([\s\S]*?)\r?\n\1(?=\r?\n|$)/gi;let r=n.exec(t);for(;r;){const s=(r[2]??"").replace(/\s+$/,"");e.push(s),r=n.exec(t)}return e},an=t=>{const e=t.match(/^(?:\uFEFF)?(---|\+\+\+)[^\S\r\n]*\r?\n[\s\S]*?\r?\n\1[^\S\r\n]*(?:\r?\n|$)/);return e?t.slice(e[0].length):t},de='[data-markdown="mermaid-block"]',Le='[data-openchamber-file-link="true"]',Xe="data-openchamber-block-path-token",Ye=`[${Xe}]`,V="data-openchamber-block-paths-scanned",ue=/(?:[A-Za-z]:[\\/])?[\w.\-/@+]*[\w\-/@+]\.[A-Za-z0-9]{1,8}(?::\d+){0,2}/g,sn=2e5,cn=4,ln=1e3,dn=200,un=80,mn=40,_e=160,O=new Map;let ne=0;const Re=[],fn=()=>be()?dn:ln,pn=()=>be()?mn:un,Qe=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),Fe=Array.from(Qe).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),we=t=>Nt(t),hn=t=>xt(t),bn=(t,e)=>Mt(t,e),ae=t=>{let e=(t||"").trim();return e?((e.startsWith("`")&&e.endsWith("`")||e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1).trim()),e=e.replace(/[.,;!?]+$/g,""),e.endsWith(")")&&!e.includes("(")&&(e=e.slice(0,-1)),e.endsWith("]")&&!e.includes("[")&&(e=e.slice(0,-1)),e):""},me=t=>{let e=ae(t);if(!e)return"";const n=e.indexOf(";");n>=0&&(e=e.slice(0,n)),e=e.replace(/#.*$/,"");const r=e.match(/^(.*\.[A-Za-z0-9_-]{1,16}):.*$/);r&&(e=r[1]??e);const s=Fe.length>0?e.match(new RegExp(`^(.*(?:/|^)(${Fe})):.*$`,"i")):null;return s&&(e=s[1]??e),ae(e)},Je=t=>{const e=ae(t);if(!e)return null;const n=e.indexOf(";"),r=n>=0?ae(e.slice(0,n)):e;if(!r)return null;const s=r.match(/^(.*)#L(\d+)(?:C(\d+))?$/i);if(s){const a=me(s[1]??""),c=Number.parseInt(s[2]??"",10),l=s[3]?Number.parseInt(s[3],10):void 0;return!a||!Number.isFinite(c)?null:{path:a,line:c,column:Number.isFinite(l??Number.NaN)?l:void 0}}const o=r.match(/^(.*):(\d+)(?::(\d+))?$/);if(o){const a=me(o[1]??""),c=Number.parseInt(o[2]??"",10),l=o[3]?Number.parseInt(o[3],10):void 0;return!a||!Number.isFinite(c)?null:{path:a,line:c,column:Number.isFinite(l??Number.NaN)?l:void 0}}const i=me(r);return i?{path:i}:null},gn=t=>{const e=t.split("/").filter(Boolean).pop()??"";return!e||e.endsWith(".")?!1:/\.[A-Za-z0-9_-]{1,16}$/.test(e)},et=t=>{if(!t||t.startsWith("--")||t.includes("://")||/[<>]/.test(t)||/\s{2,}/.test(t))return!1;const e=we(t),n=e.split("/").filter(Boolean).pop()??e;if(!n||n==="."||n==="..")return!1;const r=n.toLowerCase();return Qe.has(r)||r.startsWith(".")&&r.length>1?!0:gn(e)},tt=t=>{const e=Je(t);return e?et(e.path):!1},Ie=(t,e)=>{let n=0;for(const s of t){const o=n+s.data.length;if(e<=o)return{node:s,offset:Math.max(0,e-n)};n=o}const r=t.at(-1);return r?{node:r,offset:r.data.length}:null},wn=t=>{const e=t.querySelectorAll(Ye);for(const r of Array.from(e))r.replaceWith(t.ownerDocument.createTextNode(r.textContent??""));const n=t.querySelectorAll(`code[${V}]`);for(const r of Array.from(n))r.removeAttribute(V),r.normalize()},fe=t=>{if(t.tagName.toLowerCase()==="a"){const e=t.getAttribute("href")?.trim();if(e&&tt(e))return e}return(t.textContent||"").trim()},yn=t=>{const e=t.querySelectorAll("pre code");if(e.length===0)return;const n=t.ownerDocument;if(n)for(const r of Array.from(e)){if(r.getAttribute(V)==="true")continue;if((r.textContent??"").length>sn){r.setAttribute(V,"true");continue}const s=n.createTreeWalker(r,NodeFilter.SHOW_TEXT),o=[];let i=s.nextNode();for(;i;)o.push(i),i=s.nextNode();const a=r.textContent??"";if(!a.includes(".")){r.setAttribute(V,"true");continue}ue.lastIndex=0;const c=[];let l=ue.exec(a);for(;l;){const d=l[0];d&&tt(d)&&c.push({start:l.index,end:l.index+d.length,raw:d}),l=ue.exec(a)}for(const{start:d,end:m,raw:p}of c.reverse()){const g=Ie(o,d),v=Ie(o,m);if(!g||!v)continue;const w=n.createRange();w.setStart(g.node,g.offset),w.setEnd(v.node,v.offset);const y=n.createElement("span");y.setAttribute(Xe,"true"),y.textContent=p,w.deleteContents(),w.insertNode(y)}r.setAttribute(V,"true")}},pe=(t,e)=>{const n=Je(t);if(!n||!et(n.path))return null;const r=hn(n.path)?we(n.path):bn(e,n.path);return r?{...n,resolvedPath:r}:null},kn=t=>{const e=we(t);if(!e)return Promise.resolve(!1);const n=O.get(e);if(n)return O.delete(e),O.set(e,n),n;const r=new Promise(o=>{const i=()=>{ne+=1,_t(`/api/fs/stat?path=${encodeURIComponent(e)}&optional=true`,{method:"GET",cache:"no-store"}).then(async a=>{if(!a.ok){o(!1);return}const c=await a.json().catch(()=>null);o(c?.exists!==!1)}).catch(()=>o(!1)).finally(()=>{ne=Math.max(0,ne-1),Re.shift()?.()})};if(ne<cn){i();return}Re.push(i)}),s=fn();for(;O.size>=s;){const o=O.keys().next().value;if(typeof o!="string")break;O.delete(o)}return O.set(e,r),r},En=(t,e)=>t||St(t,e),nt=t=>{const e=B.c(7),{containerRef:n,effectiveDirectory:r,editor:s,preferRuntimeEditor:o,enabled:i}=t,a=x.useRef(null);let c,l;e[0]!==n||e[1]!==s||e[2]!==r||e[3]!==i||e[4]!==o?(c=()=>{const d=n.current;if(!d)return;let m=!1;const p=pn(),g=In,v=()=>{const h=d.querySelectorAll(Le);for(const f of Array.from(h))g(f);wn(d)};if(!i){v();return}const w=h=>{const f=h;if(a.current!==null&&typeof window<"u"&&window.clearTimeout(a.current),typeof window>"u"){y();return}a.current=window.setTimeout(()=>{a.current=null,window.requestAnimationFrame(()=>{m||y()})},f)},y=()=>{i&&yn(d);const h=d.querySelectorAll(`[data-markdown="inline-code"], a, ${Ye}`);let f=0;for(const u of Array.from(h)){const E=fe(u),A=pe(E,r);if(g(u),!A||f>=p)continue;f=f+1,(Tt()&&Lt()&&!ke(A.resolvedPath,r)?Promise.resolve(!0):kn(A.resolvedPath)).then(F=>{if(m||!F||!d.contains(u))return;const N=fe(u),M=pe(N,r);!M||M.resolvedPath!==A.resolvedPath||(u.setAttribute("data-openchamber-file-link","true"),u.setAttribute("data-openchamber-file-ref",N),u.setAttribute("data-openchamber-file-path",M.resolvedPath),u.setAttribute("title","Open file"),u.tagName.toLowerCase()!=="a"&&(u.setAttribute("role","button"),u.setAttribute("tabindex","0")))})}},b=async h=>{const f=h.getAttribute("data-openchamber-file-ref")||fe(h),u=pe(f,r);if(!u)return;const E=En(r,u.resolvedPath);if(o&&s){s.openFile(u.resolvedPath,Number.isFinite(u.line??Number.NaN)?Math.max(1,Math.trunc(u.line)):void 0,Number.isFinite(u.column??Number.NaN)?Math.max(1,Math.trunc(u.column)):void 0);return}ke(u.resolvedPath,r)||await Ct(u.resolvedPath,r);const A=ge.getState();Number.isFinite(u.line??Number.NaN)?A.openContextFileAtLine(E,u.resolvedPath,Math.max(1,Math.trunc(u.line)),Number.isFinite(u.column??Number.NaN)?Math.max(1,Math.trunc(u.column)):1):A.openContextFile(E,u.resolvedPath)},C=h=>{const f=h.target;if(!(f instanceof Element))return;const u=f.closest(Le);u instanceof HTMLElement&&(h.preventDefault(),h.stopPropagation(),b(u))},k=h=>{if(h.key!=="Enter"&&h.key!==" ")return;const f=h.target;!(f instanceof HTMLElement)||f.getAttribute("data-openchamber-file-link")!=="true"||(h.preventDefault(),h.stopPropagation(),b(f))};w(_e);const S=new MutationObserver(()=>{w(_e)});return S.observe(d,{childList:!0,subtree:!0}),d.addEventListener("click",C),d.addEventListener("keydown",k),()=>{m=!0,a.current!==null&&typeof window<"u"&&window.clearTimeout(a.current),a.current=null,S.disconnect(),d.removeEventListener("click",C),d.removeEventListener("keydown",k)}},l=[n,s,r,o,i],e[0]=n,e[1]=s,e[2]=r,e[3]=i,e[4]=o,e[5]=c,e[6]=l):(c=e[5],l=e[6]),x.useEffect(c,l)},rt=t=>{const e=B.c(6),{containerRef:n,mermaidBlocks:r,onShowPopup:s,allowWheelZoom:o}=t;let i,a;e[0]!==o||e[1]!==n||e[2]!==r||e[3]!==s?(i=()=>{const c=n.current;if(!c)return;const l=m=>{if(!s)return;const p=m.target;if(!(p instanceof Element)||p.closest('button, a, [role="button"]'))return;const g=p.closest(de);if(!g)return;const w=Array.from(c.querySelectorAll(de)).indexOf(g);if(w<0)return;const y=r[w];if(!y||y.trim().length===0)return;const b=`Diagram ${w+1}`;s({open:!0,title:b,content:"",metadata:{tool:"mermaid-preview",filename:b},mermaid:{url:`data:text/plain;charset=utf-8,${encodeURIComponent(y)}`,source:y,filename:b}})},d=m=>{if(o)return;const p=m.target;!(p instanceof Element)||!p.closest(de)||m.stopPropagation()};return c.addEventListener("click",l),c.addEventListener("wheel",d,{capture:!0,passive:!0}),()=>{c.removeEventListener("click",l),c.removeEventListener("wheel",d,!0)}},a=[o,n,r,s],e[0]=o,e[1]=n,e[2]=r,e[3]=s,e[4]=i,e[5]=a):(i=e[4],a=e[5]),x.useEffect(i,a)},he=64,An=24,vn=he/An,Cn=/[\s.,!?;:)\]]/,Sn=t=>{const e=t<=12?2:t<=48?4:t<=96?8:Math.min(24,Math.ceil(t/8));return Math.max(1,Math.round(e*vn))},xn=(t,e)=>{const n=Math.min(t.length,e+Sn(t.length-e));for(let r=n;r<Math.min(t.length,n+8);r+=1)if(Cn.test(t[r]??""))return r+1;return n},Nn=(t,e)=>{const[n,r]=x.useState(()=>e?0:t.length),s=x.useRef(n);return s.current=n,x.useEffect(()=>{if(!e||typeof window>"u"){r(t.length);return}s.current>t.length&&r(t.length);let o=null;const i=()=>{const a=Math.min(s.current,t.length);if(a>=t.length){o=null;return}r(xn(t,a)),o=window.setTimeout(i,he)};return s.current<t.length&&(o=window.setTimeout(i,he)),()=>{o!==null&&window.clearTimeout(o)}},[t,e]),e?t.slice(0,Math.min(n,t.length)):t},D=new Map,Mn=100,Tn=(t,e)=>{const n=D.get(t);if(n)return D.delete(t),D.set(t,n),n;const r=e();if(D.set(t,r),D.size>Mn){const s=D.keys().next().value;s&&D.delete(s)}return r},Ln=t=>({bg:t.colors.surface.elevated,fg:t.colors.surface.foreground,line:t.colors.interactive.border,accent:t.colors.primary.base,muted:t.colors.surface.mutedForeground,surface:t.colors.surface.muted,border:t.colors.interactive.border,transparent:!0,font:"IBM Plex Sans, sans-serif"}),ot=(t,e)=>{const{t:n}=kt(),r=x.useMemo(()=>({copy:"Copy code",copied:"Copied",copyTable:n("markdownRenderer.table.actions.copyTitle"),downloadTable:n("markdownRenderer.table.actions.downloadTitle"),copyDiagram:n("markdownRenderer.mermaid.actions.copySourceTitle"),downloadDiagram:n("markdownRenderer.mermaid.actions.downloadSvgTitle"),previewLabel:n("terminalView.preview.open"),previewTitle:n("terminalView.preview.openTitle")}),[n]);return x.useMemo(()=>{const s=Ln(t),o=ge.getState().mermaidRenderingMode,i=t.metadata?.id??"theme";return{labels:r,renderMermaid:c=>Tn(`${i}:${o}:${c}`,()=>{try{return o==="ascii"?{ascii:ct(c)}:{svg:lt(c,s)}}catch{return{}}}),onPreviewLoopback:e}},[t,r,e])},at=t=>{const e=B.c(21),{containerRef:n,text:r,streaming:s,cacheKey:o,syntaxVars:i,ctx:a}=t;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0],x.useEffect($n,c);let l,d;e[1]!==n||e[2]!==a||e[3]!==r?(l=()=>{const b=n.current,C=b?.querySelector("[data-markdown-content]")??b;if(C&&r&&C.childNodes.length===0){const k=document.createElement("div");k.setAttribute("data-md-block",""),k.style.display="contents",k.innerHTML=Zt(r),Me(k,a),C.appendChild(k)}},d=[n,r,a],e[1]=n,e[2]=a,e[3]=r,e[4]=l,e[5]=d):(l=e[4],d=e[5]),x.useLayoutEffect(l,d);let m,p;e[6]!==o||e[7]!==n||e[8]!==a||e[9]!==s||e[10]!==r?(m=()=>{const b=n.current;if(!b)return;const C=b.querySelector("[data-markdown-content]")??b;let k=!0;return Xt(r,s,o).then(S=>{if(!k)return;const h=Array.from(C.children);S.forEach((f,u)=>{let E=h[u];if(E||(E=document.createElement("div"),E.setAttribute("data-md-block",""),E.style.display="contents",C.appendChild(E)),E.getAttribute("data-md-id")===f.id)return;const A=document.createElement("div");A.innerHTML=f.html,Me(A,a),dt(E,A,{childrenOnly:!0,onBeforeElUpdated:Pn}),E.setAttribute("data-md-id",f.id)});for(let f=h.length-1;f>=S.length;f=f-1,f)h[f]?.remove()}),()=>{k=!1}},p=[n,r,s,o,a],e[6]=o,e[7]=n,e[8]=a,e[9]=s,e[10]=r,e[11]=m,e[12]=p):(m=e[11],p=e[12]),x.useEffect(m,p);let g,v;e[13]!==n||e[14]!==a?(g=()=>{const b=n.current;if(b)return on(b,a)},v=[n,a],e[13]=n,e[14]=a,e[15]=g,e[16]=v):(g=e[15],v=e[16]),x.useEffect(g,v);let w,y;e[17]!==n||e[18]!==i?(w=()=>{const b=n.current,C=b?.querySelector("[data-markdown-content]")??b;if(C)for(const[k,S]of Object.entries(i))C.style.setProperty(k,S)},y=[n,i],e[17]=n,e[18]=i,e[19]=w,e[20]=y):(w=e[19],y=e[20]),x.useEffect(w,y)},st=t=>t==="tool"?"markdown-content markdown-tool":t==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed",_n=t=>{const e=B.c(35),{content:n,part:r,messageId:s,isAnimated:o,skipFadeIn:i,className:a,isStreaming:c,disableStreamAnimation:l,variant:d,onShowPopup:m,enableFileReferences:p}=t,g=o===void 0?!0:o,v=i===void 0?!1:i,w=c===void 0?!1:c,y=l===void 0?!1:l,b=d===void 0?"assistant":d,C=p===void 0?!0:p,k=Ue(),{editor:S,runtime:h}=De(),f=x.useRef(null),u=Be()??"",E=ge(On);let A;e[0]!==u||e[1]!==E?(A=z=>{u&&E(u,z)},e[0]=u,e[1]=E,e[2]=A):A=e[2];const P=A,_=w&&!y,F=Nn(n,_);let N;e[3]!==n?(N=Ze(n),e[3]=n,e[4]=N):N=e[4];const M=N;let I;e[5]!==M||e[6]!==m?(I={containerRef:f,mermaidBlocks:M,onShowPopup:m},e[5]=M,e[6]=m,e[7]=I):I=e[7],rt(I);const R=C&&!w;let T;e[8]!==S||e[9]!==u||e[10]!==h.isVSCode||e[11]!==R?(T={containerRef:f,effectiveDirectory:u,editor:S,preferRuntimeEditor:h.isVSCode,enabled:R},e[8]=S,e[9]=u,e[10]=h.isVSCode,e[11]=R,e[12]=T):T=e[12],nt(T);let L;e[13]===Symbol.for("react.memo_cache_sentinel")?(L={containerRef:f},e[13]=L):L=e[13],Ge(L);let $;e[14]!==k?($=He(k),e[14]=k,e[15]=$):$=e[15];const se=$,ie=ot(k,u?P:void 0),H=`markdown-${r?.id?`part-${r.id}`:`message-${s}`}`;let Q;e[16]!==H||e[17]!==ie||e[18]!==_||e[19]!==F||e[20]!==se?(Q={containerRef:f,text:F,streaming:_,cacheKey:H,syntaxVars:se,ctx:ie},e[16]=H,e[17]=ie,e[18]=_,e[19]=F,e[20]=se,e[21]=Q):Q=e[21],at(Q);let q;e[22]!==a?(q=qe("break-words w-full min-w-0",a),e[22]=a,e[23]=q):q=e[23];let W;e[24]!==b?(W=st(b),e[24]=b,e[25]=W):W=e[25];let j;e[26]!==W?(j=X.jsx("div",{className:W,"data-markdown-content":!0}),e[26]=W,e[27]=j):j=e[27];let J;e[28]!==q||e[29]!==j?(J=X.jsx("div",{className:q,ref:f,children:j}),e[28]=q,e[29]=j,e[30]=J):J=e[30];const ee=J;if(g){let z;return e[31]!==H||e[32]!==ee||e[33]!==v?(z=X.jsx(At,{skipAnimation:v,children:ee},H),e[31]=H,e[32]=ee,e[33]=v,e[34]=z):z=e[34],z}return ee},qn=x.memo(_n,(t,e)=>t.content===e.content&&t.isStreaming===e.isStreaming&&t.disableStreamAnimation===e.disableStreamAnimation&&t.variant===e.variant&&t.isAnimated===e.isAnimated&&t.skipFadeIn===e.skipFadeIn&&t.className===e.className&&t.messageId===e.messageId&&t.onShowPopup===e.onShowPopup&&t.enableFileReferences===e.enableFileReferences&&t.part?.id===e.part?.id),Rn=t=>{const e=B.c(32),{content:n,className:r,variant:s,disableLinkSafety:o,stripFrontmatter:i,onShowPopup:a,allowMermaidWheelZoom:c,enableFileReferences:l}=t,d=s===void 0?"assistant":s,m=i===void 0?!1:i,p=c===void 0?!1:c,g=l===void 0?!0:l,{editor:v,runtime:w}=De(),y=Ue(),b=x.useRef(null),C=Be()??"";let k;e[0]!==n||e[1]!==m?(k=m?an(n):n,e[0]=n,e[1]=m,e[2]=k):k=e[2];const S=k;let h;e[3]!==S?(h=Ze(S),e[3]=S,e[4]=h):h=e[4];const f=h;let u;e[5]!==p||e[6]!==f||e[7]!==a?(u={containerRef:b,mermaidBlocks:f,onShowPopup:a,allowWheelZoom:p},e[5]=p,e[6]=f,e[7]=a,e[8]=u):u=e[8],rt(u);let E;e[9]!==v||e[10]!==C||e[11]!==g||e[12]!==w.isVSCode?(E={containerRef:b,effectiveDirectory:C,editor:v,preferRuntimeEditor:w.isVSCode,enabled:g},e[9]=v,e[10]=C,e[11]=g,e[12]=w.isVSCode,e[13]=E):E=e[13],nt(E);const A=!o;let P;e[14]!==A?(P={containerRef:b,enabled:A},e[14]=A,e[15]=P):P=e[15],Ge(P);let _;e[16]!==y?(_=He(y),e[16]=y,e[17]=_):_=e[17];const F=_,N=ot(y),M=`simple:${d}`;let I;e[18]!==N||e[19]!==S||e[20]!==F||e[21]!==M?(I={containerRef:b,text:S,streaming:!1,cacheKey:M,syntaxVars:F,ctx:N},e[18]=N,e[19]=S,e[20]=F,e[21]=M,e[22]=I):I=e[22],at(I);let R;e[23]!==r?(R=qe("break-words w-full min-w-0",r),e[23]=r,e[24]=R):R=e[24];let T;e[25]!==d?(T=st(d),e[25]=d,e[26]=T):T=e[26];let L;e[27]!==T?(L=X.jsx("div",{className:T,"data-markdown-content":!0}),e[27]=T,e[28]=L):L=e[28];let $;return e[29]!==R||e[30]!==L?($=X.jsx("div",{className:R,ref:b,children:L}),e[29]=R,e[30]=L,e[31]=$):$=e[31],$},Wn=x.memo(Rn,(t,e)=>t.content===e.content&&t.variant===e.variant&&t.className===e.className&&t.disableLinkSafety===e.disableLinkSafety&&t.stripFrontmatter===e.stripFrontmatter&&t.onShowPopup===e.onShowPopup&&t.allowMermaidWheelZoom===e.allowMermaidWheelZoom&&t.enableFileReferences===e.enableFileReferences);function Fn(t){if(t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.altKey||t.shiftKey)return;const e=t.target;if(!(e instanceof Element))return;const n=e.closest("a[href]");if(!(n instanceof HTMLAnchorElement)||n.getAttribute("data-openchamber-file-link")==="true")return;const r=n.getAttribute("href")??"";Oe(r)&&(t.preventDefault(),t.stopPropagation(),vt(r))}function In(t){t.removeAttribute("data-openchamber-file-link"),t.removeAttribute("data-openchamber-file-ref"),t.removeAttribute("data-openchamber-file-path"),t.getAttribute("title")==="Open file"&&t.removeAttribute("title"),t.tagName.toLowerCase()!=="a"&&(t.removeAttribute("role"),t.removeAttribute("tabindex"))}function $n(){Et()}function Pn(t,e){return!t.isEqualNode(e)}function On(t){return t.openContextPreview}export{qn as MarkdownRenderer,Wn as SimpleMarkdownRenderer};
|
|
7
|
+
${s}`},Ne=(t,e)=>{const n=document.createElement("div");n.className=`absolute top-full right-0 mt-1 hidden ${gt}`,n.style.backgroundColor="var(--surface-elevated)",n.style.color="var(--surface-elevated-foreground)",n.setAttribute("data-md-menu",t);for(const r of e){const s=document.createElement("button");s.type="button",s.className=`w-full text-left ${wt}`,s.setAttribute("data-md-action",`${t}-${r.key}`),s.textContent=r.label,n.appendChild(s)}return n},tn=(t,e)=>{const n=t.querySelectorAll("table");for(const r of Array.from(n)){if(r.closest('[data-markdown="table-wrapper"]'))continue;const o=document.createElement("div");o.className="group my-4 flex flex-col space-y-2",o.setAttribute("data-markdown","table-wrapper");const i=document.createElement("div");i.className="flex items-center justify-end gap-1";const a=document.createElement("div");a.className="relative",a.appendChild(U("copy",e.copyTable,"table-copy-toggle")),a.appendChild(Ne("table-copy",[{key:"csv",label:"CSV"},{key:"tsv",label:"TSV"},{key:"markdown",label:"Markdown"}]));const c=document.createElement("div");c.className="relative",c.appendChild(U("download",e.downloadTable,"table-download-toggle")),c.appendChild(Ne("table-download",[{key:"csv",label:"CSV"},{key:"markdown",label:"Markdown"}])),i.appendChild(a),i.appendChild(c);const l=document.createElement("div");l.className="overflow-x-auto rounded-lg border border-border/80 bg-[var(--surface-elevated)]";const d=r.parentElement;if(!d)continue;d.replaceChild(o,r),r.setAttribute("data-markdown","table"),r.classList.add("w-full","border-collapse","text-sm");for(const p of Array.from(r.querySelectorAll("tr")))p.classList.add("border-b","border-border/60");const m=r.querySelector("tbody tr:last-child");m?.classList.remove("border-b"),m?.classList.add("border-0");for(const p of Array.from(r.querySelectorAll("th")))p.classList.add("border-r","border-border/60","px-4","py-2.5","text-left","align-middle","font-semibold","text-foreground","last:border-r-0");for(const p of Array.from(r.querySelectorAll("td")))p.classList.add("border-r","border-border/60","px-4","py-2.5","align-middle","text-foreground/90","last:border-r-0");l.appendChild(r),o.appendChild(i),o.appendChild(l)}},nn=(t,e)=>{const n=t.querySelectorAll("pre > code.language-mermaid");for(const r of Array.from(n)){const s=r.parentElement;if(!s)continue;const o=(r.textContent??"").replace(/\s+$/,""),i=e.renderMermaid(o),a=document.createElement("div");a.setAttribute("data-markdown","mermaid-block"),a.className="group relative";const c=document.createElement("div");c.setAttribute("data-markdown","mermaid-scroll");const l=document.createElement("div");if(l.className="absolute top-1 right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",i.svg){const m=document.createElement("div");m.setAttribute("data-markdown","mermaid"),Y(m,i.svg),c.appendChild(m);const p=U("copy",e.labels.copyDiagram,"mermaid-copy");p.setAttribute("data-md-source",o);const g=U("download",e.labels.downloadDiagram,"mermaid-download");g.setAttribute("data-md-svg","1"),l.appendChild(p),l.appendChild(g)}else{const m=document.createElement("pre");m.setAttribute("data-markdown","mermaid-ascii"),m.textContent=i.ascii||o,c.appendChild(m);const p=U("copy",e.labels.copyDiagram,"mermaid-copy");p.setAttribute("data-md-source",i.ascii||o),l.appendChild(p)}a.appendChild(c),a.appendChild(l);const d=s.parentElement;d&&d.replaceChild(a,s)}},rn=(t,e)=>{const n=t.querySelectorAll("a[href]");for(const r of Array.from(n)){if(r.getAttribute("data-md-link-decorated")==="true"||r.getAttribute("data-openchamber-file-link")==="true")continue;const s=r.getAttribute("href")??"";if(!Oe(s))continue;r.setAttribute("data-md-link-decorated","true");const o=ht(s);if(o){const i=document.createElement("span");i.className="mr-1 inline-flex size-[18px] items-center justify-center rounded border border-[var(--border)] bg-[var(--interactive-hover)] align-middle";const a=document.createElement("img");a.src=o,a.alt="",a.setAttribute("aria-hidden","true"),a.loading="lazy",a.decoding="async",a.className="size-3.5 rounded-sm",a.addEventListener("error",()=>i.remove(),{once:!0}),i.appendChild(a),r.parentNode?.insertBefore(i,r)}if(e.onPreviewLoopback&&bt(s)){const i=document.createElement("button");i.type="button",i.className=`ml-1 align-middle ${Ve}`,i.setAttribute("data-md-action","preview-loopback"),i.setAttribute("data-md-url",s),i.setAttribute("title",e.labels.previewTitle),i.setAttribute("aria-label",e.labels.previewLabel),Y(i,oe.download),r.parentNode?.insertBefore(i,r.nextSibling)}}},Me=(t,e)=>{Yt(t),nn(t,e),Jt(t,e.labels),tn(t,e.labels),rn(t,e)},Te=(t,e,n)=>{const r=new Blob([e],{type:n}),s=URL.createObjectURL(r),o=document.createElement("a");o.href=s,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(s)},te=t=>{for(const e of Array.from(t.querySelectorAll("[data-md-menu]")))e.classList.add("hidden")},on=(t,e)=>{const n=r=>{const s=r.target;if(!(s instanceof Element))return;const o=s.closest("[data-md-action]");if(!o){te(t);return}const i=o.getAttribute("data-md-action")??"";if(i==="copy-code"){const c=o.closest('[data-component="markdown-code"]')?.querySelector("code")?.textContent??"";c&&ce(c).then(()=>ve(o,e.labels.copied,"copy",e.labels.copy));return}if(i==="table-copy-toggle"||i==="table-download-toggle"){r.preventDefault();const a=o.parentElement?.querySelector("[data-md-menu]")??null,c=a?.classList.contains("hidden")??!1;te(t),a&&c&&a.classList.remove("hidden");return}if(i.startsWith("table-copy-")){const a=i.replace("table-copy-",""),c=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(c instanceof HTMLTableElement){const l=Ce(c),d=a==="csv"?Se(l):a==="tsv"?en(l):xe(l);ce(d)}te(t);return}if(i.startsWith("table-download-")){const a=i.replace("table-download-",""),c=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(c instanceof HTMLTableElement){const l=Ce(c),d=a==="csv"?Se(l):xe(l);Te(a==="csv"?"table.csv":"table.md",d,a==="csv"?"text/csv":"text/markdown")}te(t);return}if(i==="mermaid-copy"){const a=o.getAttribute("data-md-source")??"";a&&ce(a).then(()=>ve(o,e.labels.copied,"copy",e.labels.copyDiagram));return}if(i==="mermaid-download"){const c=o.closest('[data-markdown="mermaid-block"]')?.querySelector('[data-markdown="mermaid"]')?.innerHTML??"";c&&Te("diagram.svg",c,"image/svg+xml;charset=utf-8");return}if(i==="preview-loopback"){r.preventDefault();const a=o.getAttribute("data-md-url")??"";a&&e.onPreviewLoopback?.(a);return}};return t.addEventListener("click",n),()=>t.removeEventListener("click",n)},Ue=()=>{const t=B.c(4),e=yt();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=ye(!1),t[0]=n):n=t[0];const r=n;let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=ye(!0),t[1]=s):s=t[1];const o=s;let i;return t[2]!==e?.currentTheme?(i=e?.currentTheme??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?o:r),t[2]=e?.currentTheme,t[3]=i):i=t[3],i},Ge=t=>{const e=B.c(4),{containerRef:n,enabled:r}=t;let s,o;e[0]!==n||e[1]!==r?(s=()=>{if(r===!1)return;const i=n.current;if(!i)return;const a=Fn;return i.addEventListener("click",a),()=>{i.removeEventListener("click",a)}},o=[n,r],e[0]=n,e[1]=r,e[2]=s,e[3]=o):(s=e[2],o=e[3]),x.useEffect(s,o)},Ze=t=>{if(!t.includes("mermaid"))return[];const e=[],n=/(?:^|\r?\n)(`{3,}|~{3,})mermaid[^\n\r]*\r?\n([\s\S]*?)\r?\n\1(?=\r?\n|$)/gi;let r=n.exec(t);for(;r;){const s=(r[2]??"").replace(/\s+$/,"");e.push(s),r=n.exec(t)}return e},an=t=>{const e=t.match(/^(?:\uFEFF)?(---|\+\+\+)[^\S\r\n]*\r?\n[\s\S]*?\r?\n\1[^\S\r\n]*(?:\r?\n|$)/);return e?t.slice(e[0].length):t},de='[data-markdown="mermaid-block"]',Le='[data-openchamber-file-link="true"]',Xe="data-openchamber-block-path-token",Ye=`[${Xe}]`,V="data-openchamber-block-paths-scanned",ue=/(?:[A-Za-z]:[\\/])?[\w.\-/@+]*[\w\-/@+]\.[A-Za-z0-9]{1,8}(?::\d+){0,2}/g,sn=2e5,cn=4,ln=1e3,dn=200,un=80,mn=40,Re=160,O=new Map;let ne=0;const _e=[],fn=()=>be()?dn:ln,pn=()=>be()?mn:un,Je=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),Fe=Array.from(Je).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),we=t=>Nt(t),hn=t=>xt(t),bn=(t,e)=>Mt(t,e),ae=t=>{let e=(t||"").trim();return e?((e.startsWith("`")&&e.endsWith("`")||e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1).trim()),e=e.replace(/[.,;!?]+$/g,""),e.endsWith(")")&&!e.includes("(")&&(e=e.slice(0,-1)),e.endsWith("]")&&!e.includes("[")&&(e=e.slice(0,-1)),e):""},me=t=>{let e=ae(t);if(!e)return"";const n=e.indexOf(";");n>=0&&(e=e.slice(0,n)),e=e.replace(/#.*$/,"");const r=e.match(/^(.*\.[A-Za-z0-9_-]{1,16}):.*$/);r&&(e=r[1]??e);const s=Fe.length>0?e.match(new RegExp(`^(.*(?:/|^)(${Fe})):.*$`,"i")):null;return s&&(e=s[1]??e),ae(e)},Qe=t=>{const e=ae(t);if(!e)return null;const n=e.indexOf(";"),r=n>=0?ae(e.slice(0,n)):e;if(!r)return null;const s=r.match(/^(.*)#L(\d+)(?:C(\d+))?$/i);if(s){const a=me(s[1]??""),c=Number.parseInt(s[2]??"",10),l=s[3]?Number.parseInt(s[3],10):void 0;return!a||!Number.isFinite(c)?null:{path:a,line:c,column:Number.isFinite(l??Number.NaN)?l:void 0}}const o=r.match(/^(.*):(\d+)(?::(\d+))?$/);if(o){const a=me(o[1]??""),c=Number.parseInt(o[2]??"",10),l=o[3]?Number.parseInt(o[3],10):void 0;return!a||!Number.isFinite(c)?null:{path:a,line:c,column:Number.isFinite(l??Number.NaN)?l:void 0}}const i=me(r);return i?{path:i}:null},gn=t=>{const e=t.split("/").filter(Boolean).pop()??"";return!e||e.endsWith(".")?!1:/\.[A-Za-z0-9_-]{1,16}$/.test(e)},et=t=>{if(!t||t.startsWith("--")||t.includes("://")||/[<>]/.test(t)||/\s{2,}/.test(t))return!1;const e=we(t),n=e.split("/").filter(Boolean).pop()??e;if(!n||n==="."||n==="..")return!1;const r=n.toLowerCase();return Je.has(r)||r.startsWith(".")&&r.length>1?!0:gn(e)},tt=t=>{const e=Qe(t);return e?et(e.path):!1},Ie=(t,e)=>{let n=0;for(const s of t){const o=n+s.data.length;if(e<=o)return{node:s,offset:Math.max(0,e-n)};n=o}const r=t.at(-1);return r?{node:r,offset:r.data.length}:null},wn=t=>{const e=t.querySelectorAll(Ye);for(const r of Array.from(e))r.replaceWith(t.ownerDocument.createTextNode(r.textContent??""));const n=t.querySelectorAll(`code[${V}]`);for(const r of Array.from(n))r.removeAttribute(V),r.normalize()},fe=t=>{if(t.tagName.toLowerCase()==="a"){const e=t.getAttribute("href")?.trim();if(e&&tt(e))return e}return(t.textContent||"").trim()},yn=t=>{const e=t.querySelectorAll("pre code");if(e.length===0)return;const n=t.ownerDocument;if(n)for(const r of Array.from(e)){if(r.getAttribute(V)==="true")continue;if((r.textContent??"").length>sn){r.setAttribute(V,"true");continue}const s=n.createTreeWalker(r,NodeFilter.SHOW_TEXT),o=[];let i=s.nextNode();for(;i;)o.push(i),i=s.nextNode();const a=r.textContent??"";if(!a.includes(".")){r.setAttribute(V,"true");continue}ue.lastIndex=0;const c=[];let l=ue.exec(a);for(;l;){const d=l[0];d&&tt(d)&&c.push({start:l.index,end:l.index+d.length,raw:d}),l=ue.exec(a)}for(const{start:d,end:m,raw:p}of c.reverse()){const g=Ie(o,d),v=Ie(o,m);if(!g||!v)continue;const w=n.createRange();w.setStart(g.node,g.offset),w.setEnd(v.node,v.offset);const y=n.createElement("span");y.setAttribute(Xe,"true"),y.textContent=p,w.deleteContents(),w.insertNode(y)}r.setAttribute(V,"true")}},pe=(t,e)=>{const n=Qe(t);if(!n||!et(n.path))return null;const r=hn(n.path)?we(n.path):bn(e,n.path);return r?{...n,resolvedPath:r}:null},kn=t=>{const e=we(t);if(!e)return Promise.resolve(!1);const n=O.get(e);if(n)return O.delete(e),O.set(e,n),n;const r=new Promise(o=>{const i=()=>{ne+=1,Rt(`/api/fs/stat?path=${encodeURIComponent(e)}&optional=true`,{method:"GET",cache:"no-store"}).then(async a=>{if(!a.ok){o(!1);return}const c=await a.json().catch(()=>null);o(c?.exists!==!1)}).catch(()=>o(!1)).finally(()=>{ne=Math.max(0,ne-1),_e.shift()?.()})};if(ne<cn){i();return}_e.push(i)}),s=fn();for(;O.size>=s;){const o=O.keys().next().value;if(typeof o!="string")break;O.delete(o)}return O.set(e,r),r},En=(t,e)=>t||St(t,e),nt=t=>{const e=B.c(7),{containerRef:n,effectiveDirectory:r,editor:s,preferRuntimeEditor:o,enabled:i}=t,a=x.useRef(null);let c,l;e[0]!==n||e[1]!==s||e[2]!==r||e[3]!==i||e[4]!==o?(c=()=>{const d=n.current;if(!d)return;let m=!1;const p=pn(),g=In,v=()=>{const h=d.querySelectorAll(Le);for(const f of Array.from(h))g(f);wn(d)};if(!i){v();return}const w=h=>{const f=h;if(a.current!==null&&typeof window<"u"&&window.clearTimeout(a.current),typeof window>"u"){y();return}a.current=window.setTimeout(()=>{a.current=null,window.requestAnimationFrame(()=>{m||y()})},f)},y=()=>{i&&yn(d);const h=d.querySelectorAll(`[data-markdown="inline-code"], a, ${Ye}`);let f=0;for(const u of Array.from(h)){const E=fe(u),A=pe(E,r);if(g(u),!A||f>=p)continue;f=f+1,(Tt()&&Lt()&&!ke(A.resolvedPath,r)?Promise.resolve(!0):kn(A.resolvedPath)).then(F=>{if(m||!F||!d.contains(u))return;const N=fe(u),M=pe(N,r);!M||M.resolvedPath!==A.resolvedPath||(u.setAttribute("data-openchamber-file-link","true"),u.setAttribute("data-openchamber-file-ref",N),u.setAttribute("data-openchamber-file-path",M.resolvedPath),u.setAttribute("title","Open file"),u.tagName.toLowerCase()!=="a"&&(u.setAttribute("role","button"),u.setAttribute("tabindex","0")))})}},b=async h=>{const f=h.getAttribute("data-openchamber-file-ref")||fe(h),u=pe(f,r);if(!u)return;const E=En(r,u.resolvedPath);if(o&&s){s.openFile(u.resolvedPath,Number.isFinite(u.line??Number.NaN)?Math.max(1,Math.trunc(u.line)):void 0,Number.isFinite(u.column??Number.NaN)?Math.max(1,Math.trunc(u.column)):void 0);return}ke(u.resolvedPath,r)||await Ct(u.resolvedPath,r);const A=ge.getState();Number.isFinite(u.line??Number.NaN)?A.openContextFileAtLine(E,u.resolvedPath,Math.max(1,Math.trunc(u.line)),Number.isFinite(u.column??Number.NaN)?Math.max(1,Math.trunc(u.column)):1):A.openContextFile(E,u.resolvedPath)},C=h=>{const f=h.target;if(!(f instanceof Element))return;const u=f.closest(Le);u instanceof HTMLElement&&(h.preventDefault(),h.stopPropagation(),b(u))},k=h=>{if(h.key!=="Enter"&&h.key!==" ")return;const f=h.target;!(f instanceof HTMLElement)||f.getAttribute("data-openchamber-file-link")!=="true"||(h.preventDefault(),h.stopPropagation(),b(f))};w(Re);const S=new MutationObserver(()=>{w(Re)});return S.observe(d,{childList:!0,subtree:!0}),d.addEventListener("click",C),d.addEventListener("keydown",k),()=>{m=!0,a.current!==null&&typeof window<"u"&&window.clearTimeout(a.current),a.current=null,S.disconnect(),d.removeEventListener("click",C),d.removeEventListener("keydown",k)}},l=[n,s,r,o,i],e[0]=n,e[1]=s,e[2]=r,e[3]=i,e[4]=o,e[5]=c,e[6]=l):(c=e[5],l=e[6]),x.useEffect(c,l)},rt=t=>{const e=B.c(6),{containerRef:n,mermaidBlocks:r,onShowPopup:s,allowWheelZoom:o}=t;let i,a;e[0]!==o||e[1]!==n||e[2]!==r||e[3]!==s?(i=()=>{const c=n.current;if(!c)return;const l=m=>{if(!s)return;const p=m.target;if(!(p instanceof Element)||p.closest('button, a, [role="button"]'))return;const g=p.closest(de);if(!g)return;const w=Array.from(c.querySelectorAll(de)).indexOf(g);if(w<0)return;const y=r[w];if(!y||y.trim().length===0)return;const b=`Diagram ${w+1}`;s({open:!0,title:b,content:"",metadata:{tool:"mermaid-preview",filename:b},mermaid:{url:`data:text/plain;charset=utf-8,${encodeURIComponent(y)}`,source:y,filename:b}})},d=m=>{if(o)return;const p=m.target;!(p instanceof Element)||!p.closest(de)||m.stopPropagation()};return c.addEventListener("click",l),c.addEventListener("wheel",d,{capture:!0,passive:!0}),()=>{c.removeEventListener("click",l),c.removeEventListener("wheel",d,!0)}},a=[o,n,r,s],e[0]=o,e[1]=n,e[2]=r,e[3]=s,e[4]=i,e[5]=a):(i=e[4],a=e[5]),x.useEffect(i,a)},he=64,An=24,vn=he/An,Cn=/[\s.,!?;:)\]]/,Sn=t=>{const e=t<=12?2:t<=48?4:t<=96?8:Math.min(24,Math.ceil(t/8));return Math.max(1,Math.round(e*vn))},xn=(t,e)=>{const n=Math.min(t.length,e+Sn(t.length-e));for(let r=n;r<Math.min(t.length,n+8);r+=1)if(Cn.test(t[r]??""))return r+1;return n},Nn=(t,e)=>{const[n,r]=x.useState(()=>e?0:t.length),s=x.useRef(n);return s.current=n,x.useEffect(()=>{if(!e||typeof window>"u"){r(t.length);return}s.current>t.length&&r(t.length);let o=null;const i=()=>{const a=Math.min(s.current,t.length);if(a>=t.length){o=null;return}r(xn(t,a)),o=window.setTimeout(i,he)};return s.current<t.length&&(o=window.setTimeout(i,he)),()=>{o!==null&&window.clearTimeout(o)}},[t,e]),e?t.slice(0,Math.min(n,t.length)):t},D=new Map,Mn=100,Tn=(t,e)=>{const n=D.get(t);if(n)return D.delete(t),D.set(t,n),n;const r=e();if(D.set(t,r),D.size>Mn){const s=D.keys().next().value;s&&D.delete(s)}return r},Ln=t=>({bg:t.colors.surface.elevated,fg:t.colors.surface.foreground,line:t.colors.interactive.border,accent:t.colors.primary.base,muted:t.colors.surface.mutedForeground,surface:t.colors.surface.muted,border:t.colors.interactive.border,transparent:!0,font:"IBM Plex Sans, sans-serif"}),ot=(t,e)=>{const{t:n}=kt(),r=x.useMemo(()=>({copy:"Copy code",copied:"Copied",copyTable:n("markdownRenderer.table.actions.copyTitle"),downloadTable:n("markdownRenderer.table.actions.downloadTitle"),copyDiagram:n("markdownRenderer.mermaid.actions.copySourceTitle"),downloadDiagram:n("markdownRenderer.mermaid.actions.downloadSvgTitle"),previewLabel:n("terminalView.preview.open"),previewTitle:n("terminalView.preview.openTitle")}),[n]);return x.useMemo(()=>{const s=Ln(t),o=ge.getState().mermaidRenderingMode,i=t.metadata?.id??"theme";return{labels:r,renderMermaid:c=>Tn(`${i}:${o}:${c}`,()=>{try{return o==="ascii"?{ascii:ct(c)}:{svg:lt(c,s)}}catch{return{}}}),onPreviewLoopback:e}},[t,r,e])},at=t=>{const e=B.c(21),{containerRef:n,text:r,streaming:s,cacheKey:o,syntaxVars:i,ctx:a}=t;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0],x.useEffect($n,c);let l,d;e[1]!==n||e[2]!==a||e[3]!==r?(l=()=>{const b=n.current,C=b?.querySelector("[data-markdown-content]")??b;if(C&&r&&C.childNodes.length===0){const k=document.createElement("div");k.setAttribute("data-md-block",""),k.style.display="contents",k.innerHTML=Zt(r),Me(k,a),C.appendChild(k)}},d=[n,r,a],e[1]=n,e[2]=a,e[3]=r,e[4]=l,e[5]=d):(l=e[4],d=e[5]),x.useLayoutEffect(l,d);let m,p;e[6]!==o||e[7]!==n||e[8]!==a||e[9]!==s||e[10]!==r?(m=()=>{const b=n.current;if(!b)return;const C=b.querySelector("[data-markdown-content]")??b;let k=!0;return Xt(r,s,o).then(S=>{if(!k)return;const h=Array.from(C.children);S.forEach((f,u)=>{let E=h[u];if(E||(E=document.createElement("div"),E.setAttribute("data-md-block",""),E.style.display="contents",C.appendChild(E)),E.getAttribute("data-md-id")===f.id)return;const A=document.createElement("div");A.innerHTML=f.html,Me(A,a),dt(E,A,{childrenOnly:!0,onBeforeElUpdated:Pn}),E.setAttribute("data-md-id",f.id)});for(let f=h.length-1;f>=S.length;f=f-1,f)h[f]?.remove()}),()=>{k=!1}},p=[n,r,s,o,a],e[6]=o,e[7]=n,e[8]=a,e[9]=s,e[10]=r,e[11]=m,e[12]=p):(m=e[11],p=e[12]),x.useEffect(m,p);let g,v;e[13]!==n||e[14]!==a?(g=()=>{const b=n.current;if(b)return on(b,a)},v=[n,a],e[13]=n,e[14]=a,e[15]=g,e[16]=v):(g=e[15],v=e[16]),x.useEffect(g,v);let w,y;e[17]!==n||e[18]!==i?(w=()=>{const b=n.current,C=b?.querySelector("[data-markdown-content]")??b;if(C)for(const[k,S]of Object.entries(i))C.style.setProperty(k,S)},y=[n,i],e[17]=n,e[18]=i,e[19]=w,e[20]=y):(w=e[19],y=e[20]),x.useEffect(w,y)},st=t=>t==="tool"?"markdown-content markdown-tool":t==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed",Rn=t=>{const e=B.c(35),{content:n,part:r,messageId:s,isAnimated:o,skipFadeIn:i,className:a,isStreaming:c,disableStreamAnimation:l,variant:d,onShowPopup:m,enableFileReferences:p}=t,g=o===void 0?!0:o,v=i===void 0?!1:i,w=c===void 0?!1:c,y=l===void 0?!1:l,b=d===void 0?"assistant":d,C=p===void 0?!0:p,k=Ue(),{editor:S,runtime:h}=De(),f=x.useRef(null),u=Be()??"",E=ge(On);let A;e[0]!==u||e[1]!==E?(A=z=>{u&&E(u,z)},e[0]=u,e[1]=E,e[2]=A):A=e[2];const P=A,R=w&&!y,F=Nn(n,R);let N;e[3]!==n?(N=Ze(n),e[3]=n,e[4]=N):N=e[4];const M=N;let I;e[5]!==M||e[6]!==m?(I={containerRef:f,mermaidBlocks:M,onShowPopup:m},e[5]=M,e[6]=m,e[7]=I):I=e[7],rt(I);const _=C&&!w;let T;e[8]!==S||e[9]!==u||e[10]!==h.isVSCode||e[11]!==_?(T={containerRef:f,effectiveDirectory:u,editor:S,preferRuntimeEditor:h.isVSCode,enabled:_},e[8]=S,e[9]=u,e[10]=h.isVSCode,e[11]=_,e[12]=T):T=e[12],nt(T);let L;e[13]===Symbol.for("react.memo_cache_sentinel")?(L={containerRef:f},e[13]=L):L=e[13],Ge(L);let $;e[14]!==k?($=He(k),e[14]=k,e[15]=$):$=e[15];const se=$,ie=ot(k,u?P:void 0),H=`markdown-${r?.id?`part-${r.id}`:`message-${s}`}`;let J;e[16]!==H||e[17]!==ie||e[18]!==R||e[19]!==F||e[20]!==se?(J={containerRef:f,text:F,streaming:R,cacheKey:H,syntaxVars:se,ctx:ie},e[16]=H,e[17]=ie,e[18]=R,e[19]=F,e[20]=se,e[21]=J):J=e[21],at(J);let q;e[22]!==a?(q=qe("break-words w-full min-w-0",a),e[22]=a,e[23]=q):q=e[23];let W;e[24]!==b?(W=st(b),e[24]=b,e[25]=W):W=e[25];let j;e[26]!==W?(j=X.jsx("div",{className:W,"data-markdown-content":!0}),e[26]=W,e[27]=j):j=e[27];let Q;e[28]!==q||e[29]!==j?(Q=X.jsx("div",{className:q,ref:f,children:j}),e[28]=q,e[29]=j,e[30]=Q):Q=e[30];const ee=Q;if(g){let z;return e[31]!==H||e[32]!==ee||e[33]!==v?(z=X.jsx(At,{skipAnimation:v,children:ee},H),e[31]=H,e[32]=ee,e[33]=v,e[34]=z):z=e[34],z}return ee},qn=x.memo(Rn,(t,e)=>t.content===e.content&&t.isStreaming===e.isStreaming&&t.disableStreamAnimation===e.disableStreamAnimation&&t.variant===e.variant&&t.isAnimated===e.isAnimated&&t.skipFadeIn===e.skipFadeIn&&t.className===e.className&&t.messageId===e.messageId&&t.onShowPopup===e.onShowPopup&&t.enableFileReferences===e.enableFileReferences&&t.part?.id===e.part?.id),_n=t=>{const e=B.c(32),{content:n,className:r,variant:s,disableLinkSafety:o,stripFrontmatter:i,onShowPopup:a,allowMermaidWheelZoom:c,enableFileReferences:l}=t,d=s===void 0?"assistant":s,m=i===void 0?!1:i,p=c===void 0?!1:c,g=l===void 0?!0:l,{editor:v,runtime:w}=De(),y=Ue(),b=x.useRef(null),C=Be()??"";let k;e[0]!==n||e[1]!==m?(k=m?an(n):n,e[0]=n,e[1]=m,e[2]=k):k=e[2];const S=k;let h;e[3]!==S?(h=Ze(S),e[3]=S,e[4]=h):h=e[4];const f=h;let u;e[5]!==p||e[6]!==f||e[7]!==a?(u={containerRef:b,mermaidBlocks:f,onShowPopup:a,allowWheelZoom:p},e[5]=p,e[6]=f,e[7]=a,e[8]=u):u=e[8],rt(u);let E;e[9]!==v||e[10]!==C||e[11]!==g||e[12]!==w.isVSCode?(E={containerRef:b,effectiveDirectory:C,editor:v,preferRuntimeEditor:w.isVSCode,enabled:g},e[9]=v,e[10]=C,e[11]=g,e[12]=w.isVSCode,e[13]=E):E=e[13],nt(E);const A=!o;let P;e[14]!==A?(P={containerRef:b,enabled:A},e[14]=A,e[15]=P):P=e[15],Ge(P);let R;e[16]!==y?(R=He(y),e[16]=y,e[17]=R):R=e[17];const F=R,N=ot(y),M=`simple:${d}`;let I;e[18]!==N||e[19]!==S||e[20]!==F||e[21]!==M?(I={containerRef:b,text:S,streaming:!1,cacheKey:M,syntaxVars:F,ctx:N},e[18]=N,e[19]=S,e[20]=F,e[21]=M,e[22]=I):I=e[22],at(I);let _;e[23]!==r?(_=qe("break-words w-full min-w-0",r),e[23]=r,e[24]=_):_=e[24];let T;e[25]!==d?(T=st(d),e[25]=d,e[26]=T):T=e[26];let L;e[27]!==T?(L=X.jsx("div",{className:T,"data-markdown-content":!0}),e[27]=T,e[28]=L):L=e[28];let $;return e[29]!==_||e[30]!==L?($=X.jsx("div",{className:_,ref:b,children:L}),e[29]=_,e[30]=L,e[31]=$):$=e[31],$},Wn=x.memo(_n,(t,e)=>t.content===e.content&&t.variant===e.variant&&t.className===e.className&&t.disableLinkSafety===e.disableLinkSafety&&t.stripFrontmatter===e.stripFrontmatter&&t.onShowPopup===e.onShowPopup&&t.allowMermaidWheelZoom===e.allowMermaidWheelZoom&&t.enableFileReferences===e.enableFileReferences);function Fn(t){if(t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.altKey||t.shiftKey)return;const e=t.target;if(!(e instanceof Element))return;const n=e.closest("a[href]");if(!(n instanceof HTMLAnchorElement)||n.getAttribute("data-openchamber-file-link")==="true")return;const r=n.getAttribute("href")??"";Oe(r)&&(t.preventDefault(),t.stopPropagation(),vt(r))}function In(t){t.removeAttribute("data-openchamber-file-link"),t.removeAttribute("data-openchamber-file-ref"),t.removeAttribute("data-openchamber-file-path"),t.getAttribute("title")==="Open file"&&t.removeAttribute("title"),t.tagName.toLowerCase()!=="a"&&(t.removeAttribute("role"),t.removeAttribute("tabindex"))}function $n(){Et()}function Pn(t,e){return!t.isEqualNode(e)}function On(t){return t.openContextPreview}export{qn as MarkdownRenderer,Wn as SimpleMarkdownRenderer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as _,R as k,j as n,bi as D,bh as C,bg as I,be as M,bc as S}from"./vendor-.bun-By2L9XvG.js";import{u as z,m as w,I as O}from"./useAppFontEffects-
|
|
1
|
+
import{e as _,R as k,j as n,bi as D,bh as C,bg as I,be as M,bc as S}from"./vendor-.bun-By2L9XvG.js";import{u as z,m as w,I as O}from"./useAppFontEffects-B66TruVB.js";import{M as P}from"./main-BByFAmjA.js";import"./index-AsCHiJ5P.js";import"./NewWorktreeDialog-Dj6KETex.js";import"./mobileLayoutPreference-Dio-WWkI.js";import"./SessionSwitcherDropdown-Cn_yoQrm.js";const G=R=>{const e=_.c(33),{open:y,onOpenChange:t,initialPrompt:v}=R,i=k.useId(),{t:o}=z(),N=B;let s;e[0]!==t?(s=j=>{!j&&N()||t(j)},e[0]=t,e[1]=s):s=e[1];let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=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]=g):g=e[2];let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=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]=h):h=e[3];let a;e[4]!==t?(a=()=>t(!1),e[4]=t,e[5]=a):a=e[5];let l;e[6]!==o?(l=o("multiRun.window.actions.closeAria"),e[6]=o,e[7]=l):l=e[7];let x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(O,{name:"close",className:"h-5 w-5"}),e[8]=x):x=e[8];let r;e[9]!==a||e[10]!==l?(r=n.jsx("div",{className:"absolute right-0.5 top-0.5 z-50",children:n.jsx("button",{type:"button",onClick:a,"aria-label":l,className:"inline-flex h-7 w-7 items-center justify-center rounded-md p-0.5 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:x})}),e[9]=a,e[10]=l,e[11]=r):r=e[11];let c;e[12]!==o?(c=o("multiRun.window.description"),e[12]=o,e[13]=c):c=e[13];let d;e[14]!==i||e[15]!==c?(d=n.jsx(C,{id:i,className:"sr-only",children:c}),e[14]=i,e[15]=c,e[16]=d):d=e[16];let u,m;e[17]!==t?(u=()=>t(!1),m=()=>t(!1),e[17]=t,e[18]=u,e[19]=m):(u=e[18],m=e[19]);let f;e[20]!==v||e[21]!==u||e[22]!==m?(f=n.jsx(P,{initialPrompt:v,onCreated:u,onCancel:m,isWindowed:!0}),e[20]=v,e[21]=u,e[22]=m,e[23]=f):f=e[23];let p;e[24]!==i||e[25]!==f||e[26]!==r||e[27]!==d?(p=n.jsxs(I,{children:[g,n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center pointer-events-none",children:n.jsxs(M,{"aria-describedby":i,className:h,children:[r,d,f]})})]}),e[24]=i,e[25]=f,e[26]=r,e[27]=d,e[28]=p):p=e[28];let b;return e[29]!==y||e[30]!==s||e[31]!==p?(b=n.jsx(S,{open:y,onOpenChange:s,children:p}),e[29]=y,e[30]=s,e[31]=p,e[32]=b):b=e[32],b};function B(){return typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]')}export{G as MultiRunWindow};
|