@seqyuan/annovibe 0.8.40 → 0.8.41
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/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +4 -4
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +3 -3
- package/.next/required-server-files.js +1 -1
- package/.next/required-server-files.json +1 -1
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/api/agent/runtime/route.js +1 -1
- package/.next/server/app/api/internal/runtime/route.js +1 -1
- package/.next/server/app/api/version/route.js +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +2 -2
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/index.segments/_full.segment.rsc +2 -2
- package/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/.next/server/app/login.html +1 -1
- package/.next/server/app/login.rsc +1 -1
- package/.next/server/app/login.segments/_full.segment.rsc +1 -1
- package/.next/server/app/login.segments/_head.segment.rsc +1 -1
- package/.next/server/app/login.segments/_index.segment.rsc +1 -1
- package/.next/server/app/login.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/login.segments/login/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/login.segments/login.segment.rsc +1 -1
- package/.next/server/app/page.js +3 -3
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/smoke/page_client-reference-manifest.js +1 -1
- package/.next/server/app/smoke.html +2 -2
- package/.next/server/app/smoke.rsc +2 -2
- package/.next/server/app/smoke.segments/_full.segment.rsc +2 -2
- package/.next/server/app/smoke.segments/_head.segment.rsc +1 -1
- package/.next/server/app/smoke.segments/_index.segment.rsc +1 -1
- package/.next/server/app/smoke.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/smoke.segments/smoke/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/smoke.segments/smoke.segment.rsc +1 -1
- package/.next/server/app-paths-manifest.json +4 -4
- package/.next/server/chunks/1210.js +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/9595-2f001a1f6d133466.js +246 -0
- package/.next/static/chunks/app/{page-3291f6a1f268c41d.js → page-d82d53365a2be371.js} +3 -3
- package/package.json +1 -1
- package/.next/static/chunks/9595-64b81f0fd7a50dc4.js +0 -246
- /package/.next/static/{_cg-NeIs7evKmS6N4eYHl → 3gDAeILrwgLWhlwi2MAOg}/_buildManifest.js +0 -0
- /package/.next/static/{_cg-NeIs7evKmS6N4eYHl → 3gDAeILrwgLWhlwi2MAOg}/_ssgManifest.js +0 -0
package/package.json
CHANGED
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9595],{2112:(e,t,n)=>{function r(e){let t,n=[],r=/`{1,3}show-widget`{0,3}\s*(?:\n\s*`{3}(?:json|html)?\s*)?\n?/g,o=0,a=!1;for(;null!==(t=r.exec(e));){a=!0;let s=e.slice(o,t.index).trim();s&&n.push({type:"text",content:s});let d=t.index+t[0].length,c=e.indexOf("```",d),u=e.indexOf("{",d);if(-1!==u&&u<=d+200&&(-1===c||u<c)){let t=function(e,t){let n=0,r=!1,i=!1;for(let l=t;l<e.length;l++){let t=e[l];if(i){i=!1;continue}if("\\"===t&&r){i=!0;continue}if('"'===t){r=!r;continue}if(!r&&("{"===t&&n++,"}"===t)&&0==--n)return l}return -1}(e,u);if(-1===t){let t=function(e){try{let t=i(e);if(t)return t}catch{}let t=e.indexOf('"widget_code"');if(-1===t)return null;let n=e.indexOf(":",t+13);if(-1===n)return null;let r=e.indexOf('"',n+1);if(-1===r)return null;let o=e.slice(r+1);(o=o.replace(/"\s*\}\s*$/,"")).endsWith("\\")&&(o=o.slice(0,-1));let a=e.match(/"title"\s*:\s*"([^"]*?)"/)?.[1],s=l(o.replace(/\\\\/g,"\0BACKSLASH\0").replace(/\\n/g,"\n").replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\"/g,'"').replace(/\\u([0-9a-fA-F]{4})/g,(e,t)=>String.fromCharCode(parseInt(t,16))).replace(/\x00BACKSLASH\x00/g,"\\"));return s.code.trim()?{title:a,code:s.code,showOverlay:s.truncated}:null}(e.slice(u));t&&n.push({type:"widget",...t,partial:!0}),o=e.length;break}let a=i(e.slice(u,t+1).trim());a&&n.push({type:"widget",...a});let s=t+1,d=e.slice(s,s+16).match(/^\s*\n?`{1,3}\s*/);d&&(s+=d[0].length),o=s,r.lastIndex=s;continue}if(-1!==c){let t=e.slice(d,c).trim(),l=i(t);l?n.push({type:"widget",...l}):t&&n.push({type:"text",content:t}),r.lastIndex=o=c+3}else{let t=i(e.slice(d).trim());if(t){let e=l(t.code);n.push({type:"widget",title:t.title,code:e.code,partial:!0,showOverlay:e.truncated})}o=e.length;break}}let s=e.slice(o).trim();return s&&n.push({type:"text",content:s}),!a&&0===n.length&&e.trim()&&n.push({type:"text",content:e}),n}function i(e){if(e.startsWith("{")){if(!e.endsWith("}"))return null;try{let t=JSON.parse(e),n=t.widget_code??t.code;if(n)return{title:t.title,code:n}}catch{return null}}return/<(!DOCTYPE|html|svg|canvas|script|style|div)/i.test(e)?{code:e}:null}function l(e){let t=e.lastIndexOf("<script");if(-1===t)return{code:e,truncated:!1};let n=e.slice(t);return/<script[\s\S]*?<\/script>/i.test(n)?{code:e,truncated:!1}:{code:e.slice(0,t).trim(),truncated:!0}}function o(e){return/`{1,3}show-widget/.test(e)}function a(e){return u(e)}function s(e){return u(e).replace(/\s+on[a-z]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>"']*)/gi,"").replace(/<script[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\/?>/gi,"").replace(/\s+(href|src|action)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>"']*))/gi,(e,t,n,r,i)=>{let l=(n??r??i??"").trim();return/^\s*(javascript|data)\s*:/i.test(l)?"":e})}n.d(t,{L$:()=>a,SR:()=>p,Xw:()=>s,aH:()=>r,f7:()=>g,qk:()=>o,sM:()=>f});let d=/<(iframe|object|embed|meta|link|base|form)[\s>][\s\S]*?<\/\1>/gi,c=/<(iframe|object|embed|meta|link|base)\b[^>]*\/?>/gi;function u(e){return e.replace(d,"").replace(c,"")}let h=["--bg","--bg-panel","--bg-hover","--bg-selected","--border","--text","--text-muted","--text-dim","--accent","--accent-hover"];function p(){if("u"<typeof document)return{};let e=getComputedStyle(document.documentElement),t={};for(let n of h){let r=e.getPropertyValue(n).trim();r&&(t[n]=r)}return t}function g(e){let t=Object.entries({"--bg":"#ffffff","--bg-panel":"#f5f5f5","--bg-hover":"#eeeeee","--bg-selected":"#e8e8e8","--border":"#e0e0e0","--text":"#1a1a1a","--text-muted":"#6b7280","--text-dim":"#9ca3af","--accent":"#2563eb","--accent-hover":"#1d4ed8",...e,"--font-mono":"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace"}).map(([e,t])=>` ${e}: ${t};`).join("\n");return`
|
|
2
|
-
:root {
|
|
3
|
-
${t}
|
|
4
|
-
}
|
|
5
|
-
.dark { color-scheme: dark; }
|
|
6
|
-
body {
|
|
7
|
-
--color-background-primary: var(--bg, #fff);
|
|
8
|
-
--color-background-secondary: var(--bg-panel, #f5f5f5);
|
|
9
|
-
--color-background-tertiary: var(--bg-hover, #eee);
|
|
10
|
-
--color-text-primary: var(--text, #1a1a1a);
|
|
11
|
-
--color-text-secondary: var(--text-muted, #6b7280);
|
|
12
|
-
--color-text-tertiary: var(--text-dim, #9ca3af);
|
|
13
|
-
--color-border-tertiary: var(--border, #e0e0e0);
|
|
14
|
-
--color-border-secondary: var(--border, #e0e0e0);
|
|
15
|
-
--color-border-primary: var(--accent, #2563eb);
|
|
16
|
-
--font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
|
|
17
|
-
--border-radius-md: 8px;
|
|
18
|
-
--border-radius-lg: 12px;
|
|
19
|
-
margin: 0;
|
|
20
|
-
padding: 0;
|
|
21
|
-
font-family: var(--font-sans);
|
|
22
|
-
font-size: 14px;
|
|
23
|
-
line-height: 1.6;
|
|
24
|
-
color: var(--color-text-primary);
|
|
25
|
-
background: transparent;
|
|
26
|
-
}
|
|
27
|
-
* { box-sizing: border-box; }
|
|
28
|
-
svg { max-width: 100%; height: auto; display: block; }
|
|
29
|
-
a { color: var(--accent, #2563eb); }
|
|
30
|
-
button, input, select, textarea { font: inherit; }
|
|
31
|
-
button {
|
|
32
|
-
border: 1px solid var(--color-border-tertiary);
|
|
33
|
-
border-radius: var(--border-radius-md);
|
|
34
|
-
background: var(--color-background-secondary);
|
|
35
|
-
color: var(--color-text-primary);
|
|
36
|
-
padding: 5px 10px;
|
|
37
|
-
cursor: pointer;
|
|
38
|
-
}
|
|
39
|
-
button:hover { background: var(--color-background-tertiary); }
|
|
40
|
-
input[type="range"] { accent-color: var(--accent, #2563eb); }
|
|
41
|
-
`}function f(e="",t=!1){return`<!DOCTYPE html>
|
|
42
|
-
<html class="${t?"dark":""}">
|
|
43
|
-
<head>
|
|
44
|
-
<meta charset="utf-8">
|
|
45
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
46
|
-
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline' https://cdnjs.cloudflare.com https://cdn.jsdelivr.net https://unpkg.com https://esm.sh; style-src 'unsafe-inline'; img-src * data: blob:; font-src * data:; connect-src 'none'">
|
|
47
|
-
<style>
|
|
48
|
-
${e}
|
|
49
|
-
</style>
|
|
50
|
-
</head>
|
|
51
|
-
<body>
|
|
52
|
-
<div id="__root" style="height:fit-content;"></div>
|
|
53
|
-
<script>
|
|
54
|
-
(function() {
|
|
55
|
-
var root = document.getElementById("__root");
|
|
56
|
-
var timer = null;
|
|
57
|
-
var first = true;
|
|
58
|
-
var lastHeight = 0;
|
|
59
|
-
|
|
60
|
-
function notifyReady() {
|
|
61
|
-
parent.postMessage({ type: "widget:ready" }, "*");
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function reportHeight() {
|
|
65
|
-
if (timer) clearTimeout(timer);
|
|
66
|
-
timer = setTimeout(function() {
|
|
67
|
-
var rect = root.getBoundingClientRect();
|
|
68
|
-
var h = Math.ceil(Math.max(rect.height, document.body.scrollHeight, document.documentElement.scrollHeight));
|
|
69
|
-
if (h > 0 && h !== lastHeight) {
|
|
70
|
-
lastHeight = h;
|
|
71
|
-
parent.postMessage({ type: "widget:resize", height: h, first: first }, "*");
|
|
72
|
-
}
|
|
73
|
-
first = false;
|
|
74
|
-
}, 60);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function handleUpdate(html) {
|
|
78
|
-
root.innerHTML = html;
|
|
79
|
-
reportHeight();
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function handleFinalize(html) {
|
|
83
|
-
var tmp = document.createElement("div");
|
|
84
|
-
tmp.innerHTML = html;
|
|
85
|
-
var nodes = tmp.querySelectorAll("script");
|
|
86
|
-
var scripts = [];
|
|
87
|
-
for (var i = 0; i < nodes.length; i++) {
|
|
88
|
-
var item = { src: nodes[i].src || "", text: nodes[i].textContent || "", attrs: [] };
|
|
89
|
-
for (var j = 0; j < nodes[i].attributes.length; j++) {
|
|
90
|
-
var attr = nodes[i].attributes[j];
|
|
91
|
-
if (attr.name !== "src" && attr.name !== "onload") item.attrs.push({ name: attr.name, value: attr.value });
|
|
92
|
-
}
|
|
93
|
-
scripts.push(item);
|
|
94
|
-
nodes[i].remove();
|
|
95
|
-
}
|
|
96
|
-
var visualHtml = tmp.innerHTML;
|
|
97
|
-
if (root.innerHTML !== visualHtml) root.innerHTML = visualHtml;
|
|
98
|
-
|
|
99
|
-
var cdnScripts = scripts.filter(function(s) { return !!s.src; });
|
|
100
|
-
var inlineScripts = scripts.filter(function(s) { return !s.src && s.text; });
|
|
101
|
-
function appendInline() {
|
|
102
|
-
for (var k = 0; k < inlineScripts.length; k++) {
|
|
103
|
-
var s = document.createElement("script");
|
|
104
|
-
s.textContent = inlineScripts[k].text;
|
|
105
|
-
for (var a = 0; a < inlineScripts[k].attrs.length; a++) {
|
|
106
|
-
s.setAttribute(inlineScripts[k].attrs[a].name, inlineScripts[k].attrs[a].value);
|
|
107
|
-
}
|
|
108
|
-
root.appendChild(s);
|
|
109
|
-
}
|
|
110
|
-
reportHeight();
|
|
111
|
-
setTimeout(function() { parent.postMessage({ type: "widget:scriptsReady" }, "*"); }, 50);
|
|
112
|
-
}
|
|
113
|
-
if (cdnScripts.length === 0) {
|
|
114
|
-
appendInline();
|
|
115
|
-
} else {
|
|
116
|
-
var pending = cdnScripts.length;
|
|
117
|
-
function done() { pending--; if (pending <= 0) appendInline(); }
|
|
118
|
-
for (var c = 0; c < cdnScripts.length; c++) {
|
|
119
|
-
var n = document.createElement("script");
|
|
120
|
-
n.src = cdnScripts[c].src;
|
|
121
|
-
n.onload = done;
|
|
122
|
-
n.onerror = done;
|
|
123
|
-
for (var d = 0; d < cdnScripts[c].attrs.length; d++) {
|
|
124
|
-
n.setAttribute(cdnScripts[c].attrs[d].name, cdnScripts[c].attrs[d].value);
|
|
125
|
-
}
|
|
126
|
-
root.appendChild(n);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
reportHeight();
|
|
130
|
-
setTimeout(reportHeight, 150);
|
|
131
|
-
setTimeout(reportHeight, 600);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function handleTheme(vars) {
|
|
135
|
-
Object.entries(vars || {}).forEach(function(_a) {
|
|
136
|
-
var key = _a[0], val = _a[1];
|
|
137
|
-
document.documentElement.style.setProperty(key, val);
|
|
138
|
-
});
|
|
139
|
-
if (typeof arguments[1] === "boolean") {
|
|
140
|
-
document.documentElement.className = arguments[1] ? "dark" : "";
|
|
141
|
-
}
|
|
142
|
-
reportHeight();
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function captureRenderedWidget(requestId) {
|
|
146
|
-
try {
|
|
147
|
-
var html = root.innerHTML;
|
|
148
|
-
var styles = "";
|
|
149
|
-
var styleEls = document.querySelectorAll("style");
|
|
150
|
-
for (var si = 0; si < styleEls.length; si++) {
|
|
151
|
-
styles += styleEls[si].textContent || "";
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
var canvases = document.querySelectorAll("canvas");
|
|
155
|
-
var snapshots = [];
|
|
156
|
-
var placeholders = [];
|
|
157
|
-
var hidden = [];
|
|
158
|
-
for (var ci = 0; ci < canvases.length; ci++) {
|
|
159
|
-
try {
|
|
160
|
-
var canvas = canvases[ci];
|
|
161
|
-
var placeholder = document.createElement("img");
|
|
162
|
-
placeholder.setAttribute("data-canvas-export", String(ci));
|
|
163
|
-
placeholder.style.cssText = "width:" + canvas.offsetWidth + "px;height:" + canvas.offsetHeight + "px;display:block;";
|
|
164
|
-
canvas.parentNode.insertBefore(placeholder, canvas);
|
|
165
|
-
placeholders.push(placeholder);
|
|
166
|
-
hidden.push({ node: canvas, display: canvas.style.display });
|
|
167
|
-
canvas.style.display = "none";
|
|
168
|
-
snapshots.push({
|
|
169
|
-
dataUrl: canvas.toDataURL("image/png"),
|
|
170
|
-
width: canvas.offsetWidth,
|
|
171
|
-
height: canvas.offsetHeight,
|
|
172
|
-
});
|
|
173
|
-
} catch (_err) {
|
|
174
|
-
snapshots.push(null);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
html = root.innerHTML;
|
|
179
|
-
|
|
180
|
-
for (var pi = 0; pi < placeholders.length; pi++) {
|
|
181
|
-
placeholders[pi].remove();
|
|
182
|
-
}
|
|
183
|
-
for (var hi = 0; hi < hidden.length; hi++) {
|
|
184
|
-
hidden[hi].node.style.display = hidden[hi].display;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
parent.postMessage({
|
|
188
|
-
type: "widget:captured",
|
|
189
|
-
requestId: requestId,
|
|
190
|
-
html: html,
|
|
191
|
-
styles: styles,
|
|
192
|
-
canvases: snapshots,
|
|
193
|
-
bodyWidth: document.body.scrollWidth,
|
|
194
|
-
bodyHeight: document.body.scrollHeight,
|
|
195
|
-
}, "*");
|
|
196
|
-
} catch (_err) {
|
|
197
|
-
parent.postMessage({ type: "widget:captured", requestId: requestId, html: null }, "*");
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
var ro = new ResizeObserver(reportHeight);
|
|
202
|
-
ro.observe(root);
|
|
203
|
-
|
|
204
|
-
window.addEventListener("message", function(e) {
|
|
205
|
-
if (!e.data || typeof e.data.type !== "string") return;
|
|
206
|
-
switch (e.data.type) {
|
|
207
|
-
case "widget:update": handleUpdate(e.data.html || ""); break;
|
|
208
|
-
case "widget:finalize": handleFinalize(e.data.html || ""); break;
|
|
209
|
-
case "widget:theme": handleTheme(e.data.vars, e.data.isDark); break;
|
|
210
|
-
case "widget:capture": captureRenderedWidget(e.data.requestId); break;
|
|
211
|
-
case "widget:crossFilter":
|
|
212
|
-
window.dispatchEvent(new CustomEvent("widget-filter", { detail: e.data.payload }));
|
|
213
|
-
break;
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
document.addEventListener("click", function(e) {
|
|
218
|
-
var a = e.target && e.target.closest ? e.target.closest("a[href]") : null;
|
|
219
|
-
if (!a) return;
|
|
220
|
-
var href = a.getAttribute("href");
|
|
221
|
-
if (!href || href.charAt(0) === "#") return;
|
|
222
|
-
e.preventDefault();
|
|
223
|
-
parent.postMessage({ type: "widget:link", href: href }, "*");
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
window.__widgetSendMessage = function(text) {
|
|
227
|
-
if (typeof text === "string" && text.length <= 500) {
|
|
228
|
-
parent.postMessage({ type: "widget:sendMessage", text: text }, "*");
|
|
229
|
-
}
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
window.__widgetPublish = function(topic, data) {
|
|
233
|
-
if (typeof topic === "string") {
|
|
234
|
-
parent.postMessage({ type: "widget:publish", topic: topic, data: data }, "*");
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
notifyReady();
|
|
239
|
-
})();
|
|
240
|
-
</script>
|
|
241
|
-
</body>
|
|
242
|
-
</html>`}},6750:(e,t,n)=>{n.d(t,{OI:()=>a,PH:()=>o,QG:()=>i,ok:()=>l});var r=n(95155);function i({children:e,style:t}){return(0,r.jsx)("div",{"data-document-surface":"canvas-stage",style:{width:"100%",display:"flex",justifyContent:"center",alignItems:"flex-start",...t},children:e})}function l({children:e,style:t}){return(0,r.jsx)("div",{"data-document-surface":"canvas-card",style:{background:"#fff",border:"1px solid var(--border)",borderRadius:8,boxShadow:"0 2px 8px rgba(0,0,0,0.08)",overflow:"hidden",...t},children:e})}function o({children:e,style:t}){return(0,r.jsx)("div",{"data-document-surface":"canvas-header",style:{padding:"8px 16px",background:"var(--bg)",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-dim)",fontFamily:"var(--font-mono)",...t},children:e})}function a({children:e,style:t}){return(0,r.jsx)("div",{"data-document-surface":"canvas-body",style:{padding:"24px 32px 40px",...t},children:e})}},7834:(e,t,n)=>{n.d(t,{D:()=>r});function r(e){if(navigator.clipboard?.writeText)return navigator.clipboard.writeText(e);try{let t=document.createElement("textarea");return t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t),Promise.resolve()}catch{return Promise.reject()}}},17689:(e,t,n)=>{n.d(t,{Dm:()=>f});var r=n(95155),i=n(12115),l=n(55543),o=n(68515),a=n(31775),s=n(56264);function d({model:e,background:t="transparent",maxHeight:n=280}){return 0===e.resultImages.length&&0===e.collapsedPreviewPaths.length?null:(0,r.jsxs)("div",{style:{padding:"0 10px 10px",background:t},children:[e.resultImages.length>0&&(0,r.jsx)(s.O7,{images:e.resultImages,maxHeight:n}),e.collapsedPreviewPaths.length>0&&(0,r.jsx)(s.eR,{imagePaths:e.collapsedPreviewPaths,maxHeight:n})]})}function c({model:e,inputMaxHeight:t=280,inputBackground:n="var(--bg-subtle)",inputTextColor:i="var(--text-muted)",showBorderTop:l=!1}){let o=(0,r.jsx)(a.m,{text:e.inputText,maxHeight:t,collapsible:!0,textColor:i,background:n});return l?(0,r.jsx)("div",{style:{borderTop:"1px solid var(--border)"},children:o}):o}function u({model:e,result:t,showUnavailableWhenMissing:n=!1,unavailableLabel:i="Result not available"}){return t?(0,r.jsx)(s.qb,{text:e.displayResultText??"",isEmpty:e.resultIsEmpty,isError:t.isError??!1,images:e.resultImages,imagePaths:e.mergedImagePaths}):n?(0,r.jsx)("div",{style:{padding:"8px 10px",borderTop:"1px solid var(--border)",color:"var(--text-dim)",fontSize:12,fontStyle:"italic"},children:i}):null}var h=n(87559);function p({expanded:e,onToggle:t,tool:n,status:i,durationLabel:l,title:a,summary:s,titleTooltip:d,summaryTooltip:c,leading:u,titleStyle:g,buttonStyle:f}){return(0,r.jsx)(o.V,{expanded:e,onToggle:t,status:i,title:a??n.toolName,summary:s??(0,h.Wm)(n.input),durationLabel:l,leading:u,titleTooltip:d,summaryTooltip:c,buttonStyle:f,titleStyle:g})}function g({expanded:e,model:t,result:n,collapsedPreviewBackground:i="transparent",showCollapsedPreview:l=!0,showUnavailableWhenMissing:o=!1,unavailableLabel:a="Result not available",showInputBorderTop:s=!1}){return e?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(c,{model:t,showBorderTop:s}),(0,r.jsx)(u,{model:t,result:n,showUnavailableWhenMissing:o,unavailableLabel:a})]}):l?(0,r.jsx)(d,{model:t,background:i}):null}function f({tool:e,result:t,status:n,durationLabel:o,cwd:a,title:d,summary:c,titleTooltip:u,summaryTooltip:h,leading:m,collapsedPreviewBackground:x="transparent",showCollapsedPreview:y=!0,showUnavailableWhenMissing:v=!1,unavailableLabel:b="Result not available",showInputBorderTop:w=!1,titleStyle:j,buttonStyle:k,containerStyle:S}){let[C,L]=(0,i.useState)(!1),M=(0,i.useMemo)(()=>(function({input:e,result:t,cwd:n}){let r=JSON.stringify(e??{},null,2),i=t?t.content.filter(e=>"text"===e.type).map(e=>e.text).join("\n"):null,l=t?t.content.filter(e=>"image"===e.type):[],o=(0,s.Ln)(i,l.length>0),a=null!==o&&("(no output)"===o.trim()||""===o.trim()),d=(0,s.qn)(r,n),c=(0,s.qn)(o,n),u=(0,s.Xz)([...c,...d]),h=c.length>0?c:d;return{inputText:r,displayResultText:o,resultImages:l,resultIsEmpty:a,inputImagePaths:d,resultImagePaths:c,mergedImagePaths:u,collapsedPreviewPaths:h}})({input:e.input,result:t,cwd:a}),[a,t,e.input]);return(0,r.jsxs)(l.t,{kind:"tool-call",style:{fontSize:12,minWidth:0,...S},children:[(0,r.jsx)(p,{expanded:C,onToggle:()=>L(e=>!e),tool:e,status:n,durationLabel:o,title:d,summary:c,titleTooltip:u,summaryTooltip:h,leading:m,titleStyle:j,buttonStyle:k}),(0,r.jsx)(g,{expanded:C,model:M,result:t,collapsedPreviewBackground:x,showCollapsedPreview:y,showUnavailableWhenMissing:v,unavailableLabel:b,showInputBorderTop:w})]})}},18678:(e,t,n)=>{n.d(t,{Gb:()=>l,U1:()=>s,s2:()=>i});var r=n(95155);function i(e,t){return e?.isError?"error":e?"success":t?"running":"unknown"}function l(e){return"success"===e?"#16a34a":"error"===e?"#f87171":"running"===e?"#f59e0b":"var(--text-dim)"}function o(e){return"success"===e?"Done":"error"===e?"Error":"running"===e?"Running":"Unknown"}function a({status:e}){return"running"===e?(0,r.jsx)("span",{style:{width:6,height:6,borderRadius:999,background:l(e),animation:"pulse 1.2s ease-in-out infinite"}}):"success"===e?(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})}):"error"===e?(0,r.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("path",{d:"m18 6-12 12"}),(0,r.jsx)("path",{d:"m6 6 12 12"})]}):(0,r.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,r.jsx)("path",{d:"M12 8v5"}),(0,r.jsx)("path",{d:"M12 16h.01"})]})}function s({status:e}){let t=l(e);return(0,r.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:5,minHeight:18,padding:"0 6px",borderRadius:999,border:`1px solid color-mix(in srgb, ${t} 35%, transparent)`,background:`color-mix(in srgb, ${t} 10%, transparent)`,color:t,fontSize:10,fontWeight:600,whiteSpace:"nowrap",flexShrink:0},title:o(e),children:[(0,r.jsx)(a,{status:e}),(0,r.jsx)("span",{children:o(e)})]})}},27568:(e,t,n)=>{n.d(t,{g:()=>f});var r=n(95155),i=n(12115),l=n(27071),o=n(89561),a=n(82228),s=n(46732),d=n(74059),c=n(4238),u=n(44542);let h={javascript:()=>Promise.all([n.e(2320),n.e(3307)]).then(n.bind(n,13307)).then(e=>e.javascript()),typescript:()=>Promise.all([n.e(2320),n.e(3307)]).then(n.bind(n,13307)).then(e=>e.javascript({typescript:!0})),python:()=>Promise.all([n.e(2320),n.e(3689)]).then(n.bind(n,53689)).then(e=>e.python()),sql:()=>Promise.all([n.e(2320),n.e(4097)]).then(n.bind(n,14097)).then(e=>e.sql()),json:()=>Promise.all([n.e(2320),n.e(5460)]).then(n.bind(n,25460)).then(e=>e.json()),html:()=>Promise.all([n.e(2320),n.e(3307),n.e(2774),n.e(144)]).then(n.bind(n,20144)).then(e=>e.html()),css:()=>Promise.all([n.e(2320),n.e(2774)]).then(n.bind(n,82774)).then(e=>e.css()),scss:()=>Promise.all([n.e(2320),n.e(2774)]).then(n.bind(n,82774)).then(e=>e.css()),less:()=>Promise.all([n.e(2320),n.e(2774)]).then(n.bind(n,82774)).then(e=>e.css()),markdown:()=>Promise.all([n.e(2320),n.e(3307),n.e(2774),n.e(144),n.e(2733)]).then(n.bind(n,62733)).then(e=>e.markdown()),xml:()=>Promise.all([n.e(2320),n.e(7482)]).then(n.bind(n,77482)).then(e=>e.xml()),yaml:()=>Promise.all([n.e(2320),n.e(7482)]).then(n.bind(n,77482)).then(e=>e.xml()),toml:()=>Promise.all([n.e(2320),n.e(7482)]).then(n.bind(n,77482)).then(e=>e.xml()),rust:()=>Promise.all([n.e(2320),n.e(5135)]).then(n.bind(n,55135)).then(e=>e.rust()),go:()=>Promise.all([n.e(2320),n.e(1209)]).then(n.bind(n,11209)).then(e=>e.go()),java:()=>Promise.all([n.e(2320),n.e(8198)]).then(n.bind(n,88198)).then(e=>e.java())},p=new Map;async function g(e){let t=h[e];if(!t)return null;let n=p.get(e);if(n)return n;let r=await t();return p.set(e,r),r}function f({initialContent:e,language:t,isDark:n,onChange:h,onSave:p}){let m=(0,i.useRef)(null),x=(0,i.useRef)(null),y=(0,i.useRef)(h),v=(0,i.useRef)(p);return y.current=h,v.current=p,(0,i.useEffect)(()=>{let r=m.current;if(!r)return;let i=!1,h=x.current;return h&&(h.destroy(),x.current=null),(async()=>{let h=await g(t);if(i||!r)return;let p=v.current?o.w4.of([{key:"Mod-s",run:()=>(v.current?.(),!0),preventDefault:!0}]):[],f=l.$t.create({doc:e,extensions:[(0,o.$K)(),(0,o.dz)(),(0,a.b6)(),(0,s.y9)(s.Zt),o.w4.of([...a.pw,...a.cL,...u.OO,...c.Eo]),p,(0,u.yU)(),...n?[d.bM]:[],...h?[h]:[],o.Lz.updateListener.of(e=>{e.docChanged&&y.current?.(e.state.doc.toString())}),o.Lz.theme({"&":{height:"100%",fontSize:"13px"},".cm-scroller":{overflow:"auto",fontFamily:"var(--font-mono)"},".cm-content":{padding:"8px 0"},".cm-gutters":{borderRight:"1px solid var(--border)",background:"var(--bg)",color:"var(--text-dim)"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground":{background:n?"#3a3d4e":"#b4d5fe"}})]});i||!r||(x.current&&x.current.destroy(),x.current=new o.Lz({state:f,parent:r}))})(),()=>{i=!0,x.current?.destroy(),x.current=null}},[t,n]),(0,i.useEffect)(()=>{let t=x.current;t&&t.state.doc.toString()!==e&&t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})},[e]),(0,r.jsx)("div",{ref:m,style:{height:"100%",overflow:"hidden"}})}},28093:(e,t,n)=>{n.d(t,{pm:()=>c});var r=n(95155),i=n(12115),l=n(55543),o=n(84841),a=n(49006);function s({expanded:e,onToggle:t,durationLabel:n,isStreaming:i=!1,leading:l,label:d="Thinking",buttonStyle:c,labelStyle:u,durationStyle:h}){return(0,r.jsxs)(o.R,{expanded:e,onToggle:t,buttonStyle:{width:"100%",display:"flex",alignItems:"center",gap:7,minWidth:0,textAlign:"left",cursor:"pointer",border:"none",background:"transparent",color:"var(--text-muted)",...c},children:[l,(0,r.jsx)("span",{style:{fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,flex:1,...u},children:i?(0,r.jsx)(a.n,{children:d}):d}),n&&(0,r.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",fontVariantNumeric:"tabular-nums",flexShrink:0,...h},children:n})]})}function d({content:e,contentStyle:t}){return(0,r.jsx)(l.p,{style:{color:"var(--text-muted)",fontSize:12,lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word",...t},children:(0,r.jsx)("div",{style:{padding:"8px 10px"},children:e})})}function c({content:e,durationLabel:t,isStreaming:n=!1,leading:o,label:a="Thinking",containerStyle:u,buttonStyle:h,labelStyle:p,durationStyle:g,contentStyle:f}){let[m,x]=(0,i.useState)(!1);return(0,r.jsxs)(l.t,{kind:"thinking",style:u,children:[(0,r.jsx)(s,{expanded:m,onToggle:()=>x(e=>!e),durationLabel:t,isStreaming:n,leading:o,label:a,buttonStyle:h,labelStyle:p,durationStyle:g}),m&&(0,r.jsx)(d,{content:e,contentStyle:f})]})}},28999:(e,t,n)=>{function r(e){return/^[a-zA-Z]:[\\/]/.test(e)||e.startsWith("\\\\")?e.replace(/\\/g,"/"):e}n.d(t,{HG:()=>a,HR:()=>o,WP:()=>s,e_:()=>c,qP:()=>d});let i=/^[A-Za-z]:[\\/]/;function l(e){let t=r(e),n=t.startsWith("/")||i.test(t);if(i.test(t))return t;let l=[];for(let e of t.split("/"))if(e&&"."!==e){if(".."===e){l.length>0&&".."!==l[l.length-1]?l.pop():n||l.push(e);continue}l.push(e)}return`${n?"/":""}${l.join("/")}`}function o(e,t,n){let o=e.trim().replace(/^file:\/\//i,"").replace(/[),.;:!?]+$/g,"");if(!o||o.startsWith("//"))return null;if((o=r(o)).startsWith("~/")){let e=function(e){if(!e)return null;let t=r(e),n=t.match(/^(\/Users\/[^/]+|\/home\/[^/]+)(?:\/|$)/);if(n)return n[1];let i=t.match(/^([A-Za-z]:\/Users\/[^/]+)(?:\/|$)/);return i?i[1]:null}(t);return e?l(`${e}/${o.slice(2)}`):null}if(o.startsWith("/")||i.test(o))return l(o);if(n){let e=r(n),t=e.lastIndexOf("/"),i=t>=0?e.slice(0,t):"";return l(`${i}/${o}`)}return t?l(`${t.replace(/\/+$/,"")}/${o.replace(/^\.?\//,"")}`):null}function a(e){return r(e).split("/").filter(Boolean).map(encodeURIComponent).join("/")}function s(e){let t=r(e).replace(/\/+$/,"");return t.split("/").pop()??t}function d(e,t){if(!t)return e;let n=r(e),i=r(t).replace(/\/$/,"");return n.startsWith(i+"/")?n.slice(i.length+1):e}function c(e,t){return`${r(e).replace(/\/$/,"")}/${t}`}},31775:(e,t,n)=>{n.d(t,{m:()=>s});var r=n(95155),i=n(177),l=n.n(i);let o=/\x1B\[[0-?]*[ -/]*[@-~]/;var a=n(99947);function s({text:e,maxHeight:t=400,collapsible:n=!0,textColor:i="var(--text-muted)",background:d="var(--bg)",empty:c=!1}){let u=e.replace(/\r\n/g,"\n").replace(/\r/g,"\n"),h=u.split("\n"),p=o.test(e)?(0,r.jsx)("div",{style:{fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.55,whiteSpace:"pre-wrap",wordBreak:"break-word",overflowX:"auto",padding:"8px 10px",maxHeight:n?void 0:t,overflowY:n?void 0:"auto",background:d,color:i,opacity:c?.6:1,fontStyle:c?"italic":"normal"},children:(0,r.jsx)(l(),{children:e})}):(0,r.jsx)("pre",{style:{margin:0,padding:"8px 10px",fontSize:12,lineHeight:1.5,overflowX:"auto",maxHeight:n?void 0:t,overflowY:n?void 0:"auto",background:d,whiteSpace:"pre-wrap",wordBreak:"break-all",fontFamily:"var(--font-mono)",opacity:c?.6:1,fontStyle:c?"italic":"normal",color:i},children:u});return!n||h.length<=20?(0,r.jsx)(r.Fragment,{children:p}):(0,r.jsx)(a.oG,{totalLines:h.length,expandedMaxHeight:t,overlayBackground:d,footerBackground:d,children:p})}},40332:(e,t,n)=>{n.d(t,{u:()=>b});var r=n(95155),i=n(12115),l=n(96793),o=n(2112);let a=["--bg","--bg-panel","--bg-hover","--bg-selected","--border","--text","--text-muted","--text-dim","--accent","--accent-hover"];async function s(e){if(navigator.clipboard?.writeText)return void await navigator.clipboard.writeText(e);let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.inset="0",t.style.opacity="0",document.body.appendChild(t),t.focus(),t.select();let n=document.execCommand("copy");if(document.body.removeChild(t),!n)throw Error("Clipboard copy failed.")}async function d(e){let t=await c(e.code);if(t)return t;if(e.capture)return function(e){if(!e.html)throw Error("The widget did not provide capturable HTML.");let t=p({width:e.bodyWidth||640,height:e.bodyHeight||360}),n=function(e){let t=document.createElement("template");t.innerHTML=(0,o.L$)(e.html||"");let n=document.createElement("div");for(let r of(n.appendChild(t.content.cloneNode(!0)),Array.from(n.querySelectorAll("img[data-canvas-export]")))){let t=Number(r.getAttribute("data-canvas-export")),n=Number.isFinite(t)?e.canvases?.[t]:null;if(!n?.dataUrl){r.remove();continue}r.setAttribute("src",n.dataUrl),r.setAttribute("width",String(n.width)),r.setAttribute("height",String(n.height)),r.setAttribute("style",function(e,t){let n=new Map;for(let t of(e||"").split(";")){let[e,...r]=t.split(":");e?.trim()&&r.length>0&&n.set(e.trim(),r.join(":").trim())}for(let[e,r]of Object.entries(t))n.set(e,r);return Array.from(n.entries()).map(([e,t])=>e+":"+t).join(";")}(r.getAttribute("style"),{width:n.width+"px",height:n.height+"px",display:"block"}))}return u(n),Array.from(n.childNodes).map(e=>new XMLSerializer().serializeToString(e)).join("")}(e);if(!n.trim())throw Error("The widget capture was empty.");let r=[e.styles||"","#__widget_export_root{"+function(){if("u"<typeof document)return"";let e=getComputedStyle(document.documentElement);return a.map(t=>{let n=e.getPropertyValue(t).trim();return n?t+":"+n+";":""}).join("")}()+'font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,sans-serif;font-size:14px;line-height:1.6;color:var(--text,#1a1a1a);background:transparent;}',"#__widget_export_root *{box-sizing:border-box;}\n#__widget_export_root svg{max-width:100%;height:auto;display:block;}"].join("\n");return f(m('<svg xmlns="http://www.w3.org/2000/svg" width="'+t.width+'" height="'+t.height+'" viewBox="0 0 '+t.width+" "+t.height+'"><defs><style><![CDATA['+r.replace(/\]\]>/g,"]]]]><![CDATA[>")+']]></style></defs><foreignObject x="0" y="0" width="100%" height="100%">'+('<div xmlns="http://www.w3.org/1999/xhtml" id="__widget_export_root" style="width:'+t.width+"px;min-height:")+t.height+'px;overflow:visible;">'+n+"</div></foreignObject></svg>"),t.width,t.height)}(e.capture);throw Error("PNG export needs a rendered widget capture.")}async function c(e){var t;let n,r,i,l,a=function(e){let t=(0,o.L$)(e).trim();if(!/^<\s*(style|svg)\b/i.test(t))return null;let n=new DOMParser().parseFromString(t,"text/html"),r=Array.from(n.body.children),i=r.filter(e=>"svg"===e.tagName.toLowerCase()),l=r.filter(e=>"style"!==e.tagName.toLowerCase());if(1!==i.length||1!==l.length)return null;let a=i[0].cloneNode(!0),s=Array.from(n.body.querySelectorAll("style")).map(e=>e.textContent||"").join("\n").trim();if(s){let e=document.createElementNS("http://www.w3.org/2000/svg","style");e.textContent=s,a.insertBefore(e,a.firstChild)}return a}(e);if(!a)return null;u(a),a.setAttribute("xmlns","http://www.w3.org/2000/svg");let s=p((n=function(e){if(!e)return null;let t=e.trim().split(/[\s,]+/).map(Number);return 4!==t.length||t.some(e=>!Number.isFinite(e))||t[2]<=0||t[3]<=0?null:{width:t[2],height:t[3]}}((t=a).getAttribute("viewBox")),r=h(t.getAttribute("width"))??n?.width??640,i=n?n.height/n.width:.5625,l=h(t.getAttribute("height"))??n?.height??r*i,{width:r,height:l}));return a.setAttribute("width",String(s.width)),a.setAttribute("height",String(s.height)),a.getAttribute("viewBox")||a.setAttribute("viewBox","0 0 "+s.width+" "+s.height),f(m(new XMLSerializer().serializeToString(a)),s.width,s.height)}function u(e){for(let t of Array.from(e.querySelectorAll("script, iframe, object, embed, meta, link, base, form")))t.remove();for(let t of[e,...Array.from(e.querySelectorAll("*"))])for(let e of Array.from(t.attributes)){let n=e.name.toLowerCase(),r=e.value.trim();if(n.startsWith("on")){t.removeAttribute(e.name);continue}("href"===n||"src"===n||n.endsWith(":href"))&&/^\s*(javascript|data:text\/html)/i.test(r)&&t.removeAttribute(e.name)}}function h(e){if(!e||e.includes("%"))return null;let t=Number.parseFloat(e);return Number.isFinite(t)&&t>0?t:null}function p(e){let t=g(Math.ceil(e.width||640),240,2e3),n=g(Math.ceil(e.height||360),80,4e3),r=t*n;if(r>8e6){let e=Math.sqrt(8e6/r);t=Math.max(240,Math.floor(t*e)),n=Math.max(80,Math.floor(n*e))}return{width:t,height:n}}function g(e,t,n){return Math.min(Math.max(e,t),n)}function f(e,t,n){return new Promise((r,i)=>{let l=new Image,o=URL.createObjectURL(new Blob([e],{type:"image/svg+xml;charset=utf-8"}));l.onload=()=>{URL.revokeObjectURL(o);try{let e=document.createElement("canvas"),o=Math.min(window.devicePixelRatio||1,2);e.width=Math.ceil(t*o),e.height=Math.ceil(n*o),e.style.width=t+"px",e.style.height=n+"px";let a=e.getContext("2d");if(!a)throw Error("Canvas is not available.");a.scale(o,o),a.drawImage(l,0,0,t,n),e.toBlob(e=>{e?r(e):i(Error("Canvas export returned no image."))},"image/png")}catch(e){i(e instanceof Error?e:Error("PNG export failed."))}},l.onerror=()=>{URL.revokeObjectURL(o),i(Error("The browser could not render this widget as PNG."))},l.src=o})}function m(e){if("u"<typeof document)return e;let t=getComputedStyle(document.documentElement);return e.replace(/var\(\s*(--[a-zA-Z0-9_-]+)(?:\s*,\s*([^)]+))?\)/g,(e,n,r)=>t.getPropertyValue(n).trim()||r?.trim()||"#000")}let x=/cdnjs\.cloudflare\.com|cdn\.jsdelivr\.net|unpkg\.com|esm\.sh/,y=new Map;function v(e){return e.slice(0,200)}function b({code:e,isStreaming:t,title:n,showOverlay:a,onSendMessage:c}){let{isDark:u}=(0,l.D)(),h=(0,i.useRef)(null),p=(0,i.useRef)(null),g=(0,i.useRef)(null),f=(0,i.useRef)(new Map),m=(0,i.useRef)(""),[w,j]=(0,i.useState)(!1),[k,S]=(0,i.useState)(()=>y.get(v(e))??0),[C,L]=(0,i.useState)(!1),[M,$]=(0,i.useState)(!1),[E,W]=(0,i.useState)(null),[z,R]=(0,i.useState)(!1),[T,H]=(0,i.useState)(!1),P=(0,i.useRef)(""),B=(0,i.useRef)((y.get(v(e))??0)>0),N=(0,i.useRef)(!1),I=(0,i.useRef)(u),[F,A]=(0,i.useState)(()=>(0,o.sM)((0,o.f7)({}),I.current)),O=(0,i.useMemo)(()=>x.test(e),[e]);(0,i.useEffect)(()=>{A((0,o.sM)((0,o.f7)((0,o.SR)()),I.current))},[]),(0,i.useEffect)(()=>{function t(t){if(t.data&&"string"==typeof t.data.type&&(!h.current||t.source===h.current.contentWindow))switch(t.data.type){case"widget:ready":j(!0);break;case"widget:captured":{let e=String(t.data.requestId??""),n=f.current.get(e);if(!n)break;clearTimeout(n.timeout),f.current.delete(e),n.resolve({html:"string"==typeof t.data.html?t.data.html:null,styles:"string"==typeof t.data.styles?t.data.styles:"",canvases:Array.isArray(t.data.canvases)?t.data.canvases:[],bodyWidth:"number"==typeof t.data.bodyWidth?t.data.bodyWidth:void 0,bodyHeight:"number"==typeof t.data.bodyHeight?t.data.bodyHeight:void 0});break}case"widget:resize":if("number"==typeof t.data.height&&t.data.height>0){let n=Math.min(t.data.height+2,2e3),r=v(e);if(N.current){S(e=>{let t=Math.max(e,n);return y.set(r,t),t});break}if(y.set(r,n),B.current)S(n);else{B.current=!0;let e=h.current;e&&(e.style.transition="none",e.offsetHeight),S(n),requestAnimationFrame(()=>{e&&(e.style.transition="height 0.2s ease-out")})}}break;case"widget:link":{let e=String(t.data.href??"");e&&!/^\s*(javascript|data)\s*:/i.test(e)&&window.open(e,"_blank","noopener,noreferrer");break}case"widget:sendMessage":{let e=String(t.data.text??"");e&&e.length<=500&&c?.(e);break}case"widget:publish":window.dispatchEvent(new CustomEvent("widget-cross-publish",{detail:{topic:t.data.topic,data:t.data.data,sourceIframe:h.current}}))}}return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[e,c]),(0,i.useEffect)(()=>{let e=f.current;return()=>{for(let t of(g.current&&clearTimeout(g.current),e.values()))clearTimeout(t.timeout),t.reject(Error("Widget renderer unmounted."));e.clear()}},[]),(0,i.useEffect)(()=>{function e(e){let t=e.detail;h.current?.contentWindow&&t?.sourceIframe!==h.current&&h.current.contentWindow.postMessage({type:"widget:crossFilter",payload:{topic:t?.topic,data:t?.data}},"*")}return window.addEventListener("widget-cross-publish",e),()=>window.removeEventListener("widget-cross-publish",e)},[]);let _=(0,i.useCallback)(e=>{let t=h.current;t?.contentWindow&&e!==m.current&&(m.current=e,t.contentWindow.postMessage({type:"widget:update",html:e},"*"))},[]);(0,i.useEffect)(()=>{if(!t||!w)return;let n=(0,o.Xw)(e);return p.current&&clearTimeout(p.current),p.current=setTimeout(()=>_(n),120),()=>{p.current&&clearTimeout(p.current)}},[e,t,w,_]),(0,i.useEffect)(()=>{if(t||!w||P.current===e)return;let n=(0,o.L$)(e),r=h.current;if(!r?.contentWindow)return;P.current=e,m.current=n,N.current=!0,H(!1),r.contentWindow.postMessage({type:"widget:finalize",html:n},"*");let i=setTimeout(()=>{N.current=!1,H(!0)},450);return()=>clearTimeout(i)},[t,w,e]),(0,i.useEffect)(()=>{if(!w)return;let e=()=>{h.current?.contentWindow?.postMessage({type:"widget:theme",vars:(0,o.SR)(),isDark:u},"*")};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[w,u]),(0,i.useEffect)(()=>{if(!M)return;let e=document.body.style.overflow;document.body.style.overflow="hidden";let t=e=>{"Escape"===e.key&&$(!1)};return window.addEventListener("keydown",t),()=>{document.body.style.overflow=e,window.removeEventListener("keydown",t)}},[M]);let D=(0,i.useCallback)(e=>{g.current&&clearTimeout(g.current),W(e),g.current=setTimeout(()=>W(null),1800)},[]),G=(0,i.useCallback)(()=>{let e=h.current?.contentWindow;return e?new Promise((t,n)=>{let r=`${Date.now()}-${Math.random().toString(36).slice(2)}`,i=setTimeout(()=>{f.current.delete(r),n(Error("Timed out waiting for widget capture."))},2500);f.current.set(r,{resolve:t,reject:n,timeout:i}),e.postMessage({type:"widget:capture",requestId:r},"*")}):Promise.reject(Error("Widget iframe is not ready."))},[]),U=(0,i.useCallback)(async()=>{try{let t;await s((t={widget_code:e},n?.trim()&&(t.title=n.trim()),"```show-widget\n"+JSON.stringify(t,null,2)+"\n```")),D("Copied source")}catch{D("Copy failed")}},[e,n,D]),q=(0,i.useCallback)(async()=>{try{await s(e),D("Copied HTML/SVG")}catch{D("Copy failed")}},[e,D]),V=(0,i.useCallback)(async()=>{if(!t&&!z){R(!0),D("Exporting PNG...");try{var r,i;let t,l,o;try{t=await d({code:e})}catch{let n=await G();t=await d({code:e,capture:n})}r=t,i=`${((n||"widget").trim()||"widget").replace(/[^a-zA-Z0-9._-]+/g,"_").replace(/^_+|_+$/g,"")||"widget"}.png`,l=URL.createObjectURL(r),(o=document.createElement("a")).href=l,o.download=i,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(l),D("Downloaded PNG")}catch(e){console.warn("[WidgetRenderer] PNG export failed:",e),D("PNG export unavailable")}finally{R(!1)}}},[e,n,t,z,G,D]),Z=a||O&&!t&&w&&!T,J={width:24,height:22,padding:0,background:"var(--bg-hover)",color:"var(--text-dim)",border:"1px solid var(--border)",borderRadius:3,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},X={...J,width:48,fontSize:10,whiteSpace:"nowrap"};return(0,r.jsxs)("div",{className:"widget-frame",style:{position:M?"fixed":"relative",inset:M?12:void 0,zIndex:M?1e3:void 0,marginTop:4*!M,marginBottom:4*!M,borderRadius:M?8:6,background:M?"var(--bg)":void 0,boxShadow:M?"0 24px 80px rgba(0, 0, 0, 0.35)":void 0,display:M?"flex":void 0,flexDirection:M?"column":void 0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"4px 10px",background:"var(--bg-panel)",border:"1px solid var(--border)",borderBottom:"none",borderRadius:`${M?8:6}px ${M?8:6}px 0 0`,fontSize:11,color:"var(--text-dim)",minHeight:26,flexShrink:0},children:[(0,r.jsx)("span",{style:{fontWeight:600,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n||"Widget"}),t&&(0,r.jsx)("span",{style:{fontSize:10,color:"var(--accent)",animation:"pulse 1.5s infinite",flexShrink:0},children:"streaming…"}),E&&(0,r.jsx)("span",{"aria-live":"polite",style:{marginLeft:"auto",fontSize:10,color:"var(--text-muted)",flexShrink:0},children:E}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,marginLeft:E?0:"auto",flexShrink:0},children:[(0,r.jsx)("button",{type:"button",onClick:U,title:"Copy show-widget source","aria-label":"Copy show-widget source",style:J,children:(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("polyline",{points:"16 18 22 12 16 6"}),(0,r.jsx)("polyline",{points:"8 6 2 12 8 18"})]})}),(0,r.jsx)("button",{type:"button",onClick:q,title:"Copy widget HTML/SVG","aria-label":"Copy widget HTML/SVG",style:J,children:(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),(0,r.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}),(0,r.jsx)("button",{type:"button",onClick:V,disabled:t||z,title:t?"PNG export is available after streaming finishes":"Export widget as PNG","aria-label":"Export widget as PNG",style:{...J,...t||z?{opacity:.45,cursor:"not-allowed"}:null},children:z?(0,r.jsx)("span",{style:{fontSize:9},children:"..."}):(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,r.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,r.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}),(0,r.jsx)("button",{type:"button",onClick:()=>$(e=>!e),title:M?"Exit full screen":"View full screen","aria-label":M?"Exit full screen":"View full screen",style:J,children:M?(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("polyline",{points:"4 14 10 14 10 20"}),(0,r.jsx)("polyline",{points:"20 10 14 10 14 4"}),(0,r.jsx)("line",{x1:"14",y1:"10",x2:"21",y2:"3"}),(0,r.jsx)("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]}):(0,r.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("polyline",{points:"15 3 21 3 21 9"}),(0,r.jsx)("polyline",{points:"9 21 3 21 3 15"}),(0,r.jsx)("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),(0,r.jsx)("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]})}),(0,r.jsx)("button",{type:"button",onClick:()=>L(e=>!e),title:C?"Show widget preview":"Show widget code","aria-pressed":C,style:X,children:C?"Preview":"Code"})]})]}),C&&(0,r.jsx)("pre",{style:{margin:0,padding:"8px 10px",fontSize:11,fontFamily:"var(--font-mono)",color:"var(--text-muted)",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"0 0 6px 6px",overflow:"auto",maxHeight:M?"none":400,flex:M?1:void 0,whiteSpace:"pre-wrap"},children:e}),(0,r.jsx)("iframe",{ref:h,sandbox:"allow-scripts",srcDoc:F,title:n||"Widget",onLoad:()=>j(!0),style:{width:"100%",height:M?"calc(100vh - 50px)":k,minHeight:k>0?void 0:80,border:"1px solid var(--border)",borderRadius:`0 0 ${M?8:6}px ${M?8:6}px`,display:C?"none":"block",overflow:"hidden",background:"transparent",flex:M?1:void 0,transition:B.current?"height 0.2s ease-out":"none"}}),Z&&!C&&(0,r.jsx)("div",{className:"widget-shimmer",style:{position:"absolute",inset:0,top:26,pointerEvents:"none",borderRadius:"0 0 6px 6px"}})]})}},44667:(e,t,n)=>{n.d(t,{T:()=>P});var r=n(95155),i=n(12115),l=n(18931),o=n(79204),a=n(50643),s=n(82086),d=n(77322),c=n(92509),u=n(96793),h=n(99947),p=n(72518);function g({code:e,language:t,showLineNumbers:n=!0,testAsyncDelayMs:l=0}){let{isDark:o}=(0,u.D)(),a=(0,i.useMemo)(()=>(0,p.Rd)(e,t,o),[e,o,t]),[s,d]=(0,i.useState)(()=>a?.tokens??null),[c,h]=(0,i.useState)(()=>a?"cache":"raw"),f=(0,i.useRef)(""),m=(0,i.useMemo)(()=>(0,p.nS)(e).tokens,[e]);(0,i.useEffect)(()=>{let n=`${e}:${t}:${o?"dark":"light"}`;f.current=n;let r=!1;if(a)return d(a.tokens),h(e=>"async"===e?e:"cache"),()=>{r=!0};let i=(0,p.wY)(e,t,o,e=>{if(!r&&f.current===n){let t=()=>{r||f.current!==n||(d(e.tokens),h("async"))};l>0?window.setTimeout(t,l):t()}});return i?(d(i.tokens),h("cache")):(d(null),h("raw")),()=>{r=!0}},[a,e,o,t,l]);let x=s??a?.tokens??m,y="async"===c?"async":a?"cache":c;return(0,r.jsx)("pre",{"data-highlight-source":y,"data-highlight-language":t||"text",style:{margin:0,padding:"10px 12px",fontSize:12.5,lineHeight:1.6,overflow:"auto",background:"var(--bg)",fontFamily:"var(--font-mono)"},children:(0,r.jsx)("code",{children:x.map((e,t)=>(0,r.jsxs)("span",{style:{display:"block"},children:[n&&(0,r.jsx)("span",{style:{display:"inline-block",width:"2rem",textAlign:"right",marginRight:"1rem",color:"var(--text-dim)",userSelect:"none",fontFamily:"var(--font-mono)"},children:t+1}),0===e.length?"\n":e.map((e,t)=>{let n=(0,p.tG)(e.fontStyle);return(0,r.jsx)("span",{style:{color:e.color??"inherit",...n},children:e.content},t)})]},t))})})}var f=n(7834);function m({code:e,language:t,variant:n,isStreaming:l=!1,testAsyncDelayMs:o=0}){let[a,s]=(0,i.useState)(!1),[d,c]=(0,i.useState)(!1),u=e.replace(/\r\n/g,"\n").replace(/\r/g,"\n").split("\n").length,p=t||"text",x=l?(0,r.jsx)("pre",{"data-highlight-source":"raw","data-highlight-language":p,style:{margin:0,padding:"10px 12px",fontSize:12.5,lineHeight:1.6,overflow:"auto",background:"var(--bg)",fontFamily:"var(--font-mono)",whiteSpace:"pre-wrap",wordBreak:"break-all",color:"var(--text)"},children:(0,r.jsx)("code",{children:e})}):(0,r.jsx)(g,{code:e,language:p,showLineNumbers:"chat"===n,testAsyncDelayMs:o});return(0,r.jsxs)(h.NG,{className:`markdown-code-block markdown-code-block-${n}`,style:{marginTop:"file"===n?12:4,marginBottom:"file"===n?12:4},children:[(0,r.jsx)(h.iO,{title:p,actions:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(h.Mi,{onClick:()=>{let n=e.includes("```")?"````":"```",r=`${n}${t||""}
|
|
243
|
-
${e}
|
|
244
|
-
${n}`;(0,f.D)(r).then(()=>{c(!0),setTimeout(()=>c(!1),1500)})},title:"Copy as Markdown fence",ariaLabel:"Copy as Markdown fence",label:"markdown",activeLabel:"md copied",active:d}),(0,r.jsx)(h.Mi,{onClick:()=>{(0,f.D)(e).then(()=>{s(!0),setTimeout(()=>s(!1),1500)})},ariaLabel:"Copy code",label:"copy",activeLabel:"copied",active:a})]})}),(0,r.jsx)(h.oG,{totalLines:u,children:x})]})}function x({chart:e}){let{isDark:t}=(0,u.D)(),[l,o]=(0,i.useState)(null),[a,s]=(0,i.useState)(null),d=(0,i.useRef)(`mermaid-${Math.random().toString(36).slice(2)}`);return((0,i.useEffect)(()=>{let r=!1,i=e.trim();return(o(null),s(null),i)?(Promise.resolve().then(n.bind(n,43328)).then(({default:e})=>(e.initialize({startOnLoad:!1,securityLevel:"strict",theme:t?"dark":"default",suppressErrorRendering:!0}),e.parse(i,{suppressErrors:!0}).then(t=>{if(!t)throw Error("Invalid Mermaid syntax");return e.render(`${d.current}-${Date.now()}`,i)}))).then(e=>{r||o(e.svg)}).catch(e=>{r||s(e instanceof Error?e.message:String(e))}),()=>{r=!0}):void s("Empty Mermaid diagram")},[e,t]),a)?(0,r.jsxs)("div",{className:"mermaid-diagram mermaid-diagram-error",children:[(0,r.jsx)("div",{className:"mermaid-diagram-error-title",children:"Mermaid render failed"}),(0,r.jsx)("div",{className:"mermaid-diagram-error-message",children:a}),(0,r.jsx)("pre",{children:e})]}):(0,r.jsx)("div",{className:"mermaid-diagram",children:l?(0,r.jsx)("div",{className:"mermaid-diagram-canvas",dangerouslySetInnerHTML:{__html:l}}):(0,r.jsx)("div",{className:"mermaid-diagram-loading",children:"Rendering diagram..."})})}var y=n(40332);let v=new Set,b=new Map,w=null;function j(){return w||(w=Promise.all([n.e(2619),n.e(6586)]).then(n.bind(n,66586)).then(e=>{if(0===v.size){for(let t of Object.keys(e.bundledLanguages??{}))v.add(t.toLowerCase());for(let t of e.bundledLanguagesInfo??[]){let e=t.id.toLowerCase();for(let n of t.aliases??[])b.set(n.toLowerCase(),e)}}return e})),w}var k=n(2112),S=n(28999);function C(e){return e?.replace(/^language-/,"").trim()??""}function L(e){return/^[a-z][a-z\d+.-]*:/i.test(e)||e.startsWith("//")}function M(e,t,n){let r;if(!n||n.startsWith("#")||L(n))return null;let i=(r=/^([^?#]*)(.*)$/.exec(n),r?.[1]??n);if(!i)return null;let l=function(e){try{return decodeURI(e)}catch{return e}}(i);return(0,S.HR)(l,t,e)}function $(e){return`/api/files/${(0,S.HG)(e)}?type=read`}function E(e){let t=/^\s*!\[([^\]]*)\]\((.+)\)\s*$/.exec(e);if(!t)return null;let n=t[2]?.trim()??"";if(!n)return null;let r=/^(.+?)\s+(?:"[^"]*"|'[^']*')\s*$/.exec(n);return{alt:t[1]?.trim()||void 0,src:(r?.[1]??n).trim()}}function W({items:e,baseFilePath:t,cwd:n,onOpenLocalFile:i}){let l=1===e.length;return(0,r.jsx)("div",{className:"report-image-gallery",style:{display:"grid",gridTemplateColumns:l?"minmax(0, 1fr)":"repeat(auto-fit, minmax(min(100%, 240px), 1fr))",gap:12,margin:"16px 0"},children:e.map((e,o)=>{let a=M(t,n,e.src),s=a?$(a):e.src,d=e.alt??e.caption??`Figure ${o+1}`,c=(0,r.jsx)("img",{src:s,alt:d,loading:"lazy",title:a??e.src,style:{display:"block",width:"100%",maxHeight:l?520:340,objectFit:"contain",border:"1px solid var(--border)",borderRadius:6,background:"var(--bg-panel)"}});return(0,r.jsxs)("figure",{style:{margin:0,minWidth:0},children:[a&&i?(0,r.jsx)("button",{type:"button",onClick:()=>i(a,(0,S.WP)(a)),title:`Open ${a}`,style:{display:"block",width:"100%",padding:0,border:"none",background:"none",cursor:"zoom-in"},children:c}):c,e.caption&&(0,r.jsx)("figcaption",{style:{marginTop:6,color:"var(--text-muted)",fontSize:12,lineHeight:1.45},children:e.caption})]},`${e.src}-${o}`)})})}function z({href:e,children:t,baseFilePath:n,cwd:i,onOpenLocalFile:l,title:o,...a}){let s=M(n,i,e),d=!!s,c=!!e&&L(e);return(0,r.jsx)("a",{...a,href:d?$(s):e,target:c?"_blank":void 0,rel:c?"noreferrer":void 0,onClick:e=>{s&&l&&(e.preventDefault(),l(s,(0,S.WP)(s)))},title:d?s:o,children:t})}function R({src:e,alt:t,title:n,baseFilePath:i,cwd:l,onOpenLocalFile:o,...a}){let s="string"==typeof e?e:void 0,d=M(i,l,s),c=d?$(d):s,u=(0,r.jsx)("img",{...a,src:c,alt:t??"",loading:"lazy",title:d??n,style:{...a.style??{},cursor:c?"zoom-in":a.style?.cursor}});return c?(0,r.jsx)("a",{href:c,target:"_blank",rel:"noreferrer",title:d??n??"Open image",style:{display:"inline-block",maxWidth:"100%"},onClick:e=>{d&&o&&(e.preventDefault(),o(d,(0,S.WP)(d)))},children:u}):u}function T({code:e,language:t,variant:n,isStreaming:i=!1,baseFilePath:l,cwd:o,onOpenLocalFile:a,onWidgetSendMessage:s,renderVisualCodeBlocks:d=!1,testAsyncCodeDelayMs:c=0}){let u,h,p;if("mermaid"===(u=t.trim().toLowerCase())||"mmd"===u)return(0,r.jsx)(x,{chart:e});if("show-widget"===t.trim().toLowerCase()){let t,n=(t=(0,k.aH)(`\`\`\`show-widget
|
|
245
|
-
${e}
|
|
246
|
-
\`\`\``).find(e=>"widget"===e.type),t?.type==="widget"?{title:t.title,code:t.code}:null);if(n)return(0,r.jsx)(y.u,{code:n.code,isStreaming:!1,title:n.title,onSendMessage:s})}if("report-gallery"===t.trim().toLowerCase()){let t=function(e){try{let t=JSON.parse(e);if(!Array.isArray(t))return null;let n=t.flatMap(e=>e&&"object"==typeof e&&"string"==typeof e.src&&e.src.trim()?[{src:e.src.trim(),alt:"string"==typeof e.alt&&e.alt.trim()?e.alt.trim():void 0,caption:"string"==typeof e.caption&&e.caption.trim()?e.caption.trim():void 0}]:[]);return n.length>0?n.slice(0,12):null}catch{return null}}(e);if(t)return(0,r.jsx)(W,{items:t,baseFilePath:l,cwd:o,onOpenLocalFile:a})}return d&&(h=t.trim().toLowerCase(),(p=e.trim())&&("svg"===h||"xml"===h&&/^<svg[\s>]/i.test(p)?/^<svg[\s>]/i.test(p):!("html"!==h||/<!doctype|<html[\s>]|<head[\s>]|<body[\s>]/i.test(p))&&/^<(style|svg|div|section|article|main|figure|canvas)\b/i.test(p)))?(0,r.jsx)(y.u,{code:e,isStreaming:!1,title:`${t||"visual"} preview`,onSendMessage:s}):(0,r.jsx)(m,{code:e,language:t,variant:n,isStreaming:i,testAsyncDelayMs:c})}function H({children:e,className:t,node:n,baseFilePath:i,cwd:l,onOpenLocalFile:o,onWidgetSendMessage:a,renderVisualCodeBlocks:s=!1,isStreaming:d=!1,testAsyncCodeDelayMs:c=0,...u}){let h=("string"==typeof e?e:Array.isArray(e)?e.map(e=>"string"==typeof e?e:"").join(""):"").replace(/\n$/,""),p=C(t);return"data-block"in u?(0,r.jsx)(T,{code:h,language:p,variant:"chat",isStreaming:d||!!u["data-incomplete"],baseFilePath:i,cwd:l,onOpenLocalFile:o,onWidgetSendMessage:a,renderVisualCodeBlocks:s,testAsyncCodeDelayMs:c}):(0,r.jsx)("code",{style:{background:"var(--bg-selected)",padding:"1px 4px",borderRadius:3,fontFamily:"var(--font-mono)",fontSize:"0.9em"},...u,children:e})}function P({content:e,className:t="markdown-body",style:n,codeBlockVariant:h="chat",baseFilePath:g,cwd:f,onOpenLocalFile:m,onWidgetSendMessage:x,renderVisualCodeBlocks:y=!1,enableImageGallery:w=!1,isStreaming:k=!1,renderer:S="react-markdown",testAsyncCodeDelayMs:L=0}){let{isDark:M}=(0,u.D)(),$=w?function(e){let t=e.split("\n"),n=[],r=0;for(;r<t.length;){if(!E(t[r])){n.push(t[r]),r+=1;continue}let e=[],i=r;for(;i<t.length;){let n=E(t[i]);if(!n)break;let r=i+1,l=r;for(;l<t.length&&!t[l].trim();)l+=1;let o=l<t.length?function(e){let t=/^\s*(?:_([^_]+)_|\*([^*]+)\*)\s*$/.exec(e);return(t?.[1]??t?.[2]??"").trim()||null}(t[l]):null;o&&(n.caption=o,r=l+1),e.push(n);let a=r;for(;a<t.length&&!t[a].trim();)a+=1;if(!E(t[a])){i=r;break}i=a}if(e.length>1||e.some(e=>e.caption)){n.push(["```report-gallery",JSON.stringify(e,null,2),"```"].join("\n")),r=i;continue}n.push(t[r]),r+=1}return n.join("\n")}(e):e,W=(0,i.useMemo)(()=>k?{cjk:s.h,math:d.D,mermaid:c.a}:{cjk:s.h,math:d.D,mermaid:c.a,code:function(e,t=[p.cx,p.aU]){return j(),{name:"shiki",type:"code-highlighter",getSupportedLanguages:()=>[...v],getThemes:()=>t,supportsLanguage(e){let t;return 0===v.size||null!==((t=e.trim().toLowerCase())?v.has(t)?t:b.get(t)??null:null)},highlight(t,n){let r=t.language,i=(0,p.wY)(t.code,r,e,e=>{n?.({tokens:e.tokens,bg:e.bg,fg:e.fg})});return i?{tokens:i.tokens,bg:i.bg,fg:i.fg}:(j(),null)}}}(M)},[M,k]);return"streamdown"!==S||g||w?(0,r.jsx)("div",{className:t,style:n,children:(0,r.jsx)(l.oz,{remarkPlugins:[o.A],components:{code({className:e,children:t,node:n,...i}){let l=C(e),o=String(t),a=o.replace(/\n$/,"");return e?.includes("language-")||o.includes("\n")?(0,r.jsx)(T,{code:a,language:l,variant:h,isStreaming:k,baseFilePath:g,cwd:f,onOpenLocalFile:m,onWidgetSendMessage:x,renderVisualCodeBlocks:y,testAsyncCodeDelayMs:L}):(0,r.jsx)("code",{style:{background:"var(--bg-selected)",padding:"1px 4px",borderRadius:3,fontFamily:"var(--font-mono)",fontSize:"0.9em"},...i,children:t})},pre:({children:e})=>(0,r.jsx)(r.Fragment,{children:e}),a:({href:e,children:t,node:n,...i})=>(0,r.jsx)(z,{...i,href:e,baseFilePath:g,cwd:f,onOpenLocalFile:m,children:t}),img:({src:e,alt:t,node:n,...i})=>(0,r.jsx)(R,{...i,src:e,alt:t,baseFilePath:g,cwd:f,onOpenLocalFile:m})},children:$})}):(0,r.jsx)("div",{className:t,style:n,children:(0,r.jsx)(a.jH,{mode:k?"streaming":"static",isAnimating:!!k,plugins:W,components:{code:({children:e,className:t,node:n,...i})=>(0,r.jsx)(H,{...i,node:n,className:t,baseFilePath:g,cwd:f,onOpenLocalFile:m,onWidgetSendMessage:x,renderVisualCodeBlocks:y,isStreaming:k,testAsyncCodeDelayMs:L,children:e}),a:({href:e,children:t,node:n,...i})=>(0,r.jsx)(z,{...i,href:e,baseFilePath:g,cwd:f,onOpenLocalFile:m,children:t}),img:({src:e,alt:t,node:n,...i})=>(0,r.jsx)(R,{...i,src:e,alt:t,baseFilePath:g,cwd:f,onOpenLocalFile:m})},children:$})})}},49006:(e,t,n)=>{n.d(t,{n:()=>a,r:()=>s});var r=n(95155),i=n(12115);let l="smoke-reduced-motion-change";function o(){if("u"<typeof document)return null;let e=document.documentElement.dataset.smokeReducedMotion;return"true"===e||"false"!==e&&null}function a({children:e,duration:t=2,style:n,...s}){let[d,c]=(0,i.useState)(!1);return((0,i.useEffect)(()=>{let e=window.matchMedia("(prefers-reduced-motion: reduce)"),t=()=>{c(o()??e.matches)};t();let n=e=>{null===o()&&c(e.matches)},r=()=>t();return e.addEventListener("change",n),window.addEventListener(l,r),()=>{e.removeEventListener("change",n),window.removeEventListener(l,r)}},[]),d)?(0,r.jsx)("span",{...s,children:e}):(0,r.jsx)("span",{style:{display:"inline-block",backgroundImage:"linear-gradient(90deg, var(--text-dim) 25%, var(--text-muted) 50%, var(--text-dim) 75%)",backgroundSize:"200% 100%",backgroundClip:"text",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",color:"transparent",animation:`text-shimmer ${t}s linear infinite`,...n},...s,children:e})}function s({className:e,style:t,height:n=80}){let[a,d]=(0,i.useState)(!1);(0,i.useEffect)(()=>{let e=window.matchMedia("(prefers-reduced-motion: reduce)"),t=()=>{d(o()??e.matches)};t();let n=e=>{null===o()&&d(e.matches)},r=()=>t();return e.addEventListener("change",n),window.addEventListener(l,r),()=>{e.removeEventListener("change",n),window.removeEventListener(l,r)}},[]);let c={borderRadius:6,background:"var(--bg-panel)",overflow:"hidden",height:n,...t};return a?(0,r.jsx)("div",{className:e,style:c}):(0,r.jsx)("div",{className:e,style:c,children:(0,r.jsx)("div",{style:{width:"100%",height:"100%",background:"linear-gradient(90deg, transparent 0%, var(--bg-hover) 50%, transparent 100%)",backgroundSize:"200% 100%",animation:"surface-shimmer 1.5s ease-in-out infinite"}})})}},51256:(e,t,n)=>{n.d(t,{It:()=>l,W_:()=>i,tU:()=>o});let r=/```(?:analysis-report-update|report-update)\s*\n([\s\S]*?)```/gi;function i(e){let t=[];for(let n of e.matchAll(r)){let e=n[0],r=function(e){try{var t,n;let r=JSON.parse(e);if("object"!=typeof r||null===r||Array.isArray(r))return null;return{topic:"string"==typeof r.topic?r.topic:void 0,section:"string"==typeof r.section?r.section:void 0,action:(t=r.action,"replace"===t?"replace":"append"===t?"append":void 0),status:(n=r.status,"draft"===n||"verified"===n||"outdated"===n||"needs_review"===n?n:"needs review"===n?"needs_review":void 0),markdown:"string"==typeof r.markdown?r.markdown:void 0,sources:Array.isArray(r.sources)?r.sources:void 0,invalidates:Array.isArray(r.invalidates)?r.invalidates.filter(e=>"string"==typeof e):void 0,note:"string"==typeof r.note?r.note:void 0}}catch{return null}}(n[1]?.trim()??"");r&&t.push({update:r,raw:e})}return t}function l(e){return e.replace(r,"").replace(/\n{3,}/g,"\n\n").trim()}function o(e){return r.lastIndex=0,r.test(e)}},52496:(e,t,n)=>{n.d(t,{h:()=>P});var r=n(95155),i=n(12115),l=n(76577),o=n(27568);function a({dir:e}){return(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:"asc"===e?(0,r.jsx)("polyline",{points:"2 6 5 3 8 6"}):(0,r.jsx)("polyline",{points:"2 4 5 7 8 4"})})}function s(e,t,n){let r=new Blob([e],{type:n}),i=URL.createObjectURL(r),l=document.createElement("a");l.href=i,l.download=t,document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>URL.revokeObjectURL(i),1e3)}function d({content:e,delimiter:t,fileName:n="table"}){let[l,o]=(0,i.useState)(null),[c,u]=(0,i.useState)("asc"),{header:h,rows:p}=(0,i.useMemo)(()=>(function(e,t){let n=e.replace(/\r\n/g,"\n").replace(/\r/g,"\n"),r=[],i=[],l="",o=!1;for(let e=0;e<n.length;e+=1){let a=n[e];if('"'===a){o&&'"'===n[e+1]?(l+='"',e+=1):o=!o;continue}if(a===t&&!o){i.push(l),l="";continue}if("\n"===a&&!o){i.push(l),i.some(e=>e.length>0)&&r.push(i),i=[],l="";continue}l+=a}i.push(l),i.some(e=>e.length>0)&&r.push(i);let a=r[0]??[],s=a.length;return{header:a,rows:r.slice(1).map(e=>{let t=[...e];for(;t.length<s;)t.push("");return t.slice(0,s)})}})(e,t),[e,t]),g=(0,i.useMemo)(()=>{if(null===l)return p;let e=[...p];return e.sort((e,t)=>{let n=e[l]??"",r=t[l]??"",i=Number(n),o=Number(r),a=""===n||""===r||Number.isNaN(i)||Number.isNaN(o)?n.localeCompare(r):i-o;return"asc"===c?a:-a}),e},[p,c,l]);return 0===h.length&&0===p.length?(0,r.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-muted)",fontSize:13},children:"No tabular data to display"}):(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,padding:"8px 12px",borderBottom:"1px solid var(--border)",background:"var(--bg-panel)",flexShrink:0},children:[(0,r.jsxs)("div",{style:{fontSize:11,color:"var(--text-dim)"},children:[p.length," rows, ",h.length," columns"]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,r.jsxs)("button",{onClick:()=>{s(e,n," "===t?"text/tab-separated-values;charset=utf-8":"text/csv;charset=utf-8")},style:{padding:"2px 8px",fontSize:11,cursor:"pointer",background:"var(--bg-hover)",color:"var(--text-muted)",border:"1px solid var(--border)",borderRadius:5},children:["Export "," "===t?"TSV":"CSV"]}),(0,r.jsx)("button",{onClick:()=>{s(JSON.stringify(g.map(e=>Object.fromEntries(h.map((t,n)=>[t||`column_${n+1}`,e[n]??""]))),null,2),n.replace(/\.[^.]+$/,"")+".json","application/json;charset=utf-8")},style:{padding:"2px 8px",fontSize:11,cursor:"pointer",background:"var(--bg-hover)",color:"var(--text-muted)",border:"1px solid var(--border)",borderRadius:5},children:"Export JSON"})]})]}),(0,r.jsx)("div",{style:{minHeight:0,flex:1,overflow:"auto",background:"var(--bg)"},children:(0,r.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse",tableLayout:"fixed",fontSize:12},children:[(0,r.jsx)("thead",{style:{position:"sticky",top:0,zIndex:1,background:"var(--bg-panel)"},children:(0,r.jsx)("tr",{children:h.map((e,t)=>(0,r.jsx)("th",{onClick:()=>{l===t?u(e=>"asc"===e?"desc":"asc"):(o(t),u("asc"))},title:e,style:{padding:"8px 10px",borderBottom:"1px solid var(--border)",textAlign:"left",color:"var(--text-muted)",fontWeight:600,cursor:"pointer",userSelect:"none",fontSize:11,whiteSpace:"nowrap"},children:(0,r.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,minWidth:0},children:[(0,r.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:e||`column_${t+1}`}),l===t&&(0,r.jsx)("span",{style:{color:"var(--accent)",display:"inline-flex",flexShrink:0},children:(0,r.jsx)(a,{dir:c})})]})},`${e}-${t}`))})}),(0,r.jsx)("tbody",{children:g.map((e,t)=>(0,r.jsx)("tr",{style:{borderBottom:"1px solid rgba(127,127,127,0.14)",background:t%2==1?"var(--bg-subtle)":"transparent"},children:h.map((n,i)=>(0,r.jsx)("td",{title:e[i]??"",style:{padding:"6px 10px",color:"var(--text)",fontFamily:"var(--font-mono)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:0},children:e[i]??""},`${n}-${t}-${i}`))},t))})]})})]})}var c=n(99947),u=n(7834),h=n(72518);let p={display:"inline-block",minWidth:"3em",paddingRight:"1em",textAlign:"right",color:"var(--text-dim)",fontStyle:"normal",userSelect:"none"};function g({code:e,language:t,isDark:n,wrapLines:l=!1}){let o="text"===t||"csv"===t||"tsv"===t?"plaintext":t||"plaintext",a=e.split("\n").length,s=(0,i.useMemo)(()=>(0,h.Rd)(e,o,n),[e,n,o]),[d,f]=(0,i.useState)(()=>s?.tokens??null),m=(0,i.useRef)(""),x=(0,i.useMemo)(()=>(0,h.nS)(e).tokens,[e]);(0,i.useEffect)(()=>{let t=`${e}:${o}:${n?"dark":"light"}`;m.current=t;let r=!1;return s?(f(s.tokens),()=>{r=!0}):((0,h.wY)(e,o,n,e=>{r||m.current!==t||f(e.tokens)}),()=>{r=!0})},[s,e,n,o]);let y=d??s?.tokens??x;return(0,r.jsxs)(c.NG,{style:{border:"none",borderRadius:0,minHeight:"100%"},children:[(0,r.jsx)(c.iO,{title:`${o} \xb7 ${a} lines`,actions:(0,r.jsx)(c.Mi,{onClick:()=>{(0,u.D)(e)},ariaLabel:"Copy file contents",title:"Copy file contents",label:"copy"}),style:{padding:"4px 16px",borderBottom:"1px solid var(--border)",background:"var(--bg)"}}),(0,r.jsx)("pre",{style:{margin:0,padding:"12px 0",background:"var(--bg)",fontSize:13,lineHeight:1.6,fontFamily:"var(--font-mono)",minHeight:"100%",overflow:"auto",whiteSpace:l?"pre-wrap":"pre",wordBreak:l?"break-word":void 0},children:(0,r.jsx)("code",{style:{fontFamily:"var(--font-mono)"},children:y.map((e,t)=>(0,r.jsxs)("span",{style:{display:"block"},children:[(0,r.jsx)("span",{style:p,children:t+1}),0===e.length?"\n":e.map((e,t)=>{let n=(0,h.tG)(e.fontStyle);return(0,r.jsx)("span",{style:{color:e.color??"inherit",...n},children:e.content},t)})]},t))})})]})}var f=n(44667),m=n(96793),x=n(28999);function y(e){let t=(0,x.WP)(e).toLowerCase().split(".").pop()??"";return"csv"===t?",":"tsv"===t?" ":null}function v(e){let t=e.includes("/")?e.slice(0,e.lastIndexOf("/")):".",n=(0,x.HG)(t);return`/api/files/${n}/?type=read&raw=1`}function b({oldContent:e,newContent:t,language:n}){let i=function(e,t){let n=e.length,r=t.length,i=n+r,l=Array(2*i+1).fill(0),o=[];for(let a=0;a<=i;a++){o.push([...l]);for(let s=-a;s<=a;s+=2){let d,c=(d=s===-a||s!==a&&l[s-1+i]<l[s+1+i]?l[s+1+i]:l[s-1+i]+1)-s;for(;d<n&&c<r&&e[d]===t[c];)d++,c++;if(l[s+i]=d,d>=n&&c>=r){let l=[],s=n,d=r;for(let n=a;n>0;n--){let r,a=o[n-1],c=s-d;r=c===-n||c!==n&&a[c-1+i]<a[c+1+i]?c+1:c-1;let u=a[r+i],h=u-r;for(;s>u&&d>h;)s--,d--,l.unshift({type:"unchanged",text:e[s],lineNo:s+1});n>0&&(s>u?(s--,l.unshift({type:"removed",text:e[s],lineNo:s+1})):(d--,l.unshift({type:"added",text:t[d],lineNo:d+1})))}for(;s>0&&d>0;)s--,d--,l.unshift({type:"unchanged",text:e[s],lineNo:s+1});return l}}}return[...e.map((e,t)=>({type:"removed",text:e,lineNo:t+1})),...t.map((e,t)=>({type:"added",text:e,lineNo:t+1}))]}(e.split("\n"),t.split("\n"));return(0,r.jsx)(l.pg,{diff:i})}function w({filePath:e,cwd:t,onOpenFile:n}){let{isDark:a}=(0,m.D)(),[s,c]=(0,i.useState)(null),[u,h]=(0,i.useState)(null),[p,j]=(0,i.useState)(!0),[k,S]=(0,i.useState)(null),[C,L]=(0,i.useState)(null),[M,$]=(0,i.useState)(!1),[E,W]=(0,i.useState)("source"),[z,R]=(0,i.useState)(!1),[T,H]=(0,i.useState)(0),[P,B]=(0,i.useState)(!1),[N,I]=(0,i.useState)(0),[F,A]=(0,i.useState)(!1),[O,_]=(0,i.useState)(""),[D,G]=(0,i.useState)(!1),[U,q]=(0,i.useState)(!1),[V,Z]=(0,i.useState)(!1),[J,X]=(0,i.useState)(null),K=(0,i.useRef)(null),Y=(0,i.useRef)(!1);Y.current=F;let Q=(0,i.useCallback)((e,t=!1)=>{let n=(0,x.HG)(e);return fetch(`/api/files/${n}?type=read`).then(e=>e.json()).then(e=>e.error?(S(e.error),null):(t?(c(t=>(t&&h(t.content),e)),I(e=>e+1)):c(e),S(null),e)).catch(e=>(S(String(e)),null))},[]);(0,i.useEffect)(()=>{j(!0),S(null),c(null),h(null),$(!1),W("source"),R(!1),H(0),I(0),B(!1),K.current&&(K.current.close(),K.current=null),Q(e).then(t=>{(t?.language==="markdown"||y(e))&&$(!0)}).finally(()=>j(!1));let t=(0,x.HG)(e),n=new EventSource(`/api/files/${t}?type=watch`);return K.current=n,n.addEventListener("connected",()=>{B(!0)}),n.addEventListener("change",()=>{Y.current?q(!0):Q(e,!0)}),n.addEventListener("error",()=>{B(!1)}),n.onerror=()=>{B(!1)},()=>{n.close(),K.current=null}},[e,Q]);let ee=(0,i.useCallback)(()=>{s&&(A(!0),_(s.content),X(s.mtime??null),Z(!1),L(null),q(!1),$(!1),W("source"))},[s]),et=(0,i.useCallback)(async(t=!1)=>{let n=(0,x.HG)(e);G(!0),Z(!1),L(null);try{let r=await fetch(`/api/files/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:O,...t||!J?{}:{baseMtime:J}})});if(409===r.status){let e=await r.json().catch(()=>({error:"File changed on disk since it was opened"}));throw Z(!0),q(!0),Error(e.error??"File changed on disk since it was opened")}if(!r.ok){let e=await r.json().catch(()=>({error:String(r.status)}));throw Error(e.error??`HTTP ${r.status}`)}let i=await Q(e,!0);X(i?.mtime??null),A(!1),q(!1),Z(!1)}catch(e){L(e instanceof Error?e.message:String(e))}finally{G(!1)}},[J,O,Q,e]),en=(0,i.useCallback)(()=>{A(!1),q(!1),Z(!1),L(null),X(null)},[]),er=(0,i.useCallback)(()=>{H(e=>e+1)},[]),ei=(0,i.useCallback)(async()=>{let t=await Q(e,!0);t&&(_(t.content),X(t.mtime??null),q(!1),Z(!1),L(null),S(null))},[Q,e]);if(p)return(0,r.jsx)(l.nG,{children:"Loading..."});if(k)return(0,r.jsx)(l.nG,{tone:"error",children:k});if(!s)return null;let el="html"===s.language,eo="markdown"===s.language,ea=y(e),es=null!==ea,ed=s.content.split("\n"),ec=null!==u&&u!==s.content,eu=(0,i.useMemo)(()=>{var t;let n,r;return el?(t=s.content,n=v(e),r=`<base href="${n}">`,/<head(\s[^>]*)?>/i.test(t)?t.replace(/<head(\s[^>]*)?>/i,e=>`${e}${r}`):/<html(\s[^>]*)?>/i.test(t)?t.replace(/<html(\s[^>]*)?>/i,e=>`${e}<head>${r}</head>`):`<!doctype html><html><head>${r}</head><body>${t}</body></html>`):""},[s.content,e,el]),eh=(0,i.useMemo)(()=>{if(!el)return"";let t=v(e).includes("?")?"&":"?";return`${v(e)}${encodeURIComponent((0,x.WP)(e))}${t}v=${T}`},[e,T,el]);return(0,r.jsxs)(l.fj,{children:[(0,r.jsx)(l.K$,{pathLabel:(0,x.qP)(e,t),title:e,trailing:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{children:s.language}),"source"===E&&(0,r.jsxs)("span",{children:[ed.length," lines"]}),(0,r.jsx)("span",{children:(0,l.v7)(s.size)}),(0,r.jsx)(l.mK,{watching:P}),F?(0,r.jsxs)(r.Fragment,{children:[(U||V||C)&&(0,r.jsxs)("span",{title:"File changed on disk while editing",style:{padding:"2px 8px",fontSize:11,background:"rgba(234,179,8,0.1)",color:"#b8860b",border:"1px solid rgba(234,179,8,0.3)",borderRadius:5,display:"flex",alignItems:"center",gap:4},children:[(0,r.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,r.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),C??"External change",(U||V)&&(0,r.jsx)(l.ml,{onClick:ei,style:{marginLeft:4,fontSize:10,background:"rgba(234,179,8,0.2)",color:"#b8860b",border:"1px solid rgba(234,179,8,0.3)",borderRadius:3,fontWeight:600},children:"Reload"}),V&&(0,r.jsx)(l.ml,{onClick:()=>void et(!0),disabled:D,emphasis:"danger",style:{marginLeft:4,fontSize:10,borderRadius:3,fontWeight:600},children:"Overwrite"})]}),(0,r.jsx)(l.ml,{onClick:()=>void et(),disabled:D,title:"Save file (Ctrl+S)",emphasis:"primary",style:{fontWeight:600},children:D?"Saving…":"Save"}),(0,r.jsx)(l.ml,{onClick:en,title:"Cancel editing",emphasis:"danger",style:{fontWeight:600},children:"Cancel"})]}):(0,r.jsx)(l.ml,{onClick:ee,title:"Edit file",style:{fontWeight:600},children:"Edit"}),ec&&(0,r.jsx)(l.Tg,{options:[{key:"source",label:"Source",active:"source"===E,onClick:()=>W("source")},{key:"diff",label:(0,r.jsxs)(r.Fragment,{children:["Diff ",N>0&&(0,r.jsxs)("span",{style:{color:"#4ade80",marginLeft:2},children:["+",N]})]}),active:"diff"===E,onClick:()=>W("diff")}]}),"source"===E&&!M&&(0,r.jsx)(l.ml,{onClick:()=>R(e=>!e),title:z?"Disable word wrap":"Enable word wrap",active:z,children:"wrap"}),el&&M&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l.ml,{onClick:er,title:"Reload the HTML preview",children:"Refresh preview"}),eh&&(0,r.jsx)(l.ml,{onClick:()=>window.open(eh,"_blank","noopener,noreferrer"),title:"Open HTML preview in a new tab",children:"Open in new tab"})]}),el&&"source"===E&&(0,r.jsx)(l.Tg,{options:[{key:"code",label:"Code",active:!M,onClick:()=>$(!1)},{key:"preview",label:"Preview",active:M,onClick:()=>$(!0)}]}),eo&&"source"===E&&(0,r.jsx)(l.Tg,{options:[{key:"preview",label:"Preview",active:M,onClick:()=>$(!0)},{key:"raw",label:F?"Edit":"Raw",active:!M,onClick:()=>$(!1)}]}),es&&"source"===E&&(0,r.jsx)(l.Tg,{options:[{key:"table",label:"Table",active:M,onClick:()=>$(!0)},{key:"raw",label:"Raw",active:!M,onClick:()=>$(!1)}]})]})}),(0,r.jsx)(l.Ph,{children:F&&!(eo&&M)?(0,r.jsx)(o.g,{initialContent:O,language:s.language,isDark:a,onChange:_,onSave:()=>void et()}):F&&eo&&M?(0,r.jsx)(f.T,{content:O,className:"markdown-body markdown-file-preview",codeBlockVariant:"file",baseFilePath:e,onOpenLocalFile:n,style:{padding:"28px 36px",maxWidth:920,margin:"0 auto"}}):"diff"===E&&ec?(0,r.jsx)(b,{oldContent:u,newContent:s.content,language:s.language}):el&&M?(0,r.jsx)("iframe",{srcDoc:eu,sandbox:"allow-same-origin allow-scripts",style:{width:"100%",height:"100%",border:"none",background:"var(--bg)"},title:"HTML preview"},T):eo&&M?(0,r.jsx)(f.T,{content:s.content,className:"markdown-body markdown-file-preview",codeBlockVariant:"file",baseFilePath:e,onOpenLocalFile:n,style:{padding:"28px 36px",maxWidth:920,margin:"0 auto"}}):es&&M&&ea?(0,r.jsx)(d,{content:s.content,delimiter:ea,fileName:(0,x.WP)(e)}):(0,r.jsx)(g,{code:s.content,language:s.language,isDark:a,wrapLines:z})})]})}var j=n(6750),k=n(63161);let S=null;function C({arrayBuffer:e,fileName:t}){let o=(0,i.useRef)(null),[a,s]=(0,i.useState)(!0),[d,c]=(0,i.useState)(null),[u,h]=(0,i.useState)(0),[p,g]=(0,i.useState)(1),[f,m]=(0,i.useState)(1),x=(0,i.useRef)(f);x.current=f;let y=(0,i.useRef)(null),v=(0,i.useRef)(null),b=(0,i.useCallback)(async e=>{if(!S||!y.current)return;let t=y.current;if(!(e<1)&&!(e>t.numPages)){v.current&&(v.current.cancel(),v.current=null);try{let n=await t.getPage(e),r=n.getViewport({scale:x.current*(window.devicePixelRatio||1)}),i=o.current;if(!i)return;let l=i.querySelector("canvas");if(l||((l=document.createElement("canvas")).style.display="block",l.style.margin="0 auto",i.innerHTML="",i.appendChild(l)),l.width=r.width,l.height=r.height,l.style.width=`${r.width/(window.devicePixelRatio||1)}px`,l.style.height=`${r.height/(window.devicePixelRatio||1)}px`,!l.getContext("2d"))return;let a=n.render({canvas:l,viewport:r});v.current=a,await a.promise,v.current=null}catch(e){"RenderingCancelledException"!==e.name&&console.error("PDF render error:",e)}}},[]);return(0,i.useEffect)(()=>{let t=!1;return async function(){s(!0),c(null);try{S||((S=await Promise.all([n.e(2213),n.e(2619)]).then(n.bind(n,12810))).GlobalWorkerOptions.workerSrc=new n.U(n(53228)).toString());let r=await S.getDocument({data:e}).promise;if(t)return;y.current=r,h(r.numPages),g(1),s(!1)}catch(e){t||(c(String(e)),s(!1))}}(),()=>{t=!0,v.current&&(v.current.cancel(),v.current=null)}},[e]),(0,i.useEffect)(()=>{!a&&u>0&&b(p)},[a,p,u,b]),(0,i.useEffect)(()=>{!a&&u>0&&b(p)},[f]),(0,r.jsx)(k.B,{fileName:t,pageInfo:u>0?`Page ${p} / ${u}`:void 0,zoom:f,onZoomIn:()=>m(e=>Math.min(e+.25,3)),onZoomOut:()=>m(e=>Math.max(e-.25,.25)),loading:a,loadingLabel:"Loading PDF...",error:d,bodyStyle:{background:"#525659",display:"flex",justifyContent:"center",padding:16},extra:u>1&&(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4},children:[(0,r.jsx)(l.ml,{onClick:()=>g(e=>Math.max(e-1,1)),title:"Previous page",disabled:p<=1,style:{width:24,height:24,padding:0,lineHeight:1},children:(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",children:(0,r.jsx)("polyline",{points:"6 2 3 5 6 8"})})}),(0,r.jsxs)("span",{style:{fontSize:11,color:"var(--text-dim)",minWidth:28,textAlign:"center"},children:[p,"/",u]}),(0,r.jsx)(l.ml,{onClick:()=>g(e=>Math.min(e+1,u)),title:"Next page",disabled:p>=u,style:{width:24,height:24,padding:0,lineHeight:1},children:(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",children:(0,r.jsx)("polyline",{points:"4 2 7 5 4 8"})})})]}),children:!a&&!d&&(0,r.jsx)(j.QG,{style:{minWidth:"100%"},children:(0,r.jsx)("div",{ref:o})})})}function L({arrayBuffer:e,fileName:t}){let l=(0,i.useRef)(null),[o,a]=(0,i.useState)(!0),[s,d]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let t=!1;return async function(){a(!0),d(null);try{let{renderAsync:r}=await Promise.all([n.e(2619),n.e(4453),n.e(2274)]).then(n.bind(n,52274)),i=l.current;if(!i||t)return;i.innerHTML="",await r(e,i,void 0,{className:"docx-preview",inWrapper:!0,ignoreWidth:!1,ignoreHeight:!1,ignoreFonts:!1,breakPages:!0,ignoreLastRenderedPageBreak:!1,experimental:!1,trimXmlDeclaration:!0,useBase64URL:!1,renderChanges:!1,renderHeaders:!0,renderFooters:!0,renderFootnotes:!0,renderEndnotes:!0}),t||a(!1)}catch(e){t||(console.error("DOCX render error:",e),d(String(e)),a(!1))}}(),()=>{t=!0}},[e]),(0,r.jsx)(k.B,{fileName:t,loading:o,loadingLabel:"Loading document...",error:s,bodyStyle:{background:"#e8e8e8",padding:"24px 0"},children:!o&&!s&&(0,r.jsx)(j.QG,{children:(0,r.jsx)(j.ok,{style:{width:"100%",maxWidth:816,minHeight:100,visibility:o?"hidden":"visible",boxShadow:"0 1px 4px rgba(0,0,0,0.12)"},children:(0,r.jsx)("div",{ref:l,className:"docx-preview-container"})})})})}function M({arrayBuffer:e,fileName:t}){let[o,a]=(0,i.useState)(!0),[s,d]=(0,i.useState)(null),[c,u]=(0,i.useState)([]),[h,p]=(0,i.useState)(0),g=(0,i.useRef)(null),[f,m]=(0,i.useState)(!1);return(0,i.useEffect)(()=>{let t=!1;return async function(){a(!0),d(null);try{let r=await Promise.all([n.e(3524),n.e(8436)]).then(n.bind(n,15967)),i=r.read(e,{type:"array"}),l=i.SheetNames.map(e=>{let t=i.Sheets[e],n=r.utils.sheet_to_html(t,{editable:!1});return{name:e,html:n}});t||(u(l),p(0),a(!1))}catch(e){t||(console.error("XLSX parse error:",e),d(String(e)),a(!1))}}(),()=>{t=!0}},[e]),(0,i.useEffect)(()=>{let e=g.current;if(!e)return;let t=e.querySelector("table");if(!t)return;let n=()=>{m(t.querySelectorAll("colgroup col, thead tr:first-child th, tbody tr:first-child td").length>8)};n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[h,c]),(0,r.jsx)(k.B,{fileName:t,loading:o,loadingLabel:"Loading spreadsheet...",error:s,bodyStyle:{background:"var(--bg-panel)"},extra:c.length>1&&(0,r.jsx)("div",{style:{display:"flex",alignItems:"center",maxWidth:"min(520px, 48vw)"},children:(0,r.jsx)(l.Tg,{options:c.map((e,t)=>({key:e.name,label:(0,r.jsx)("span",{title:e.name,style:{display:"block",maxWidth:120,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),active:t===h,onClick:()=>p(t)}))})}),children:!o&&!s&&c.length>0&&(0,r.jsx)("div",{ref:g,style:{padding:"0 16px 16px",overflow:f?"auto":"visible"},dangerouslySetInnerHTML:{__html:c[h]?.html??""},className:"xlsx-preview"})})}var $=n(53308);function E({arrayBuffer:e,fileName:t}){let[o,a]=(0,i.useState)(!0),[s,d]=(0,i.useState)(null),[c,u]=(0,i.useState)([]),[h,p]=(0,i.useState)(0);(0,i.useEffect)(()=>{let t=!1;return async function(){a(!0),d(null);try{let r=(await Promise.all([n.e(2619),n.e(4453)]).then(n.t.bind(n,54453,23))).default,i=await r.loadAsync(e),l=[];i.forEach(e=>{let t=/^ppt\/slides\/slide(\d+)\.xml$/i.exec(e);t&&l.push({name:e,index:parseInt(t[1],10)})}),l.sort((e,t)=>e.index-t.index);let o=[];for(let e of l){let n;if(t)return;let r=await i.file(e.name).async("string"),l=/<a:t[^>]*>([^<]*)<\/a:t>/g,a=[];for(;null!==(n=l.exec(r));){let e=n[1].trim();e&&a.push(e)}o.push({index:e.index,texts:a})}t||(u(o),a(!1))}catch(e){t||(console.error("PPTX parse error:",e),d(String(e)),a(!1))}}(),()=>{t=!0}},[e]);let g=c[h],f=c.length;return(0,r.jsx)(k.B,{fileName:t,pageInfo:f>0?`Slide ${h+1} / ${f}`:void 0,loading:o,loadingLabel:"Loading presentation...",error:s,bodyStyle:{background:"var(--bg-panel)",display:"flex",justifyContent:"center",alignItems:"flex-start",padding:24},extra:f>1&&(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4},children:[(0,r.jsx)(l.ml,{onClick:()=>p(e=>Math.max(e-1,0)),title:"Previous slide",disabled:h<=0,style:{width:24,height:24,padding:0,lineHeight:1},children:(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",children:(0,r.jsx)("polyline",{points:"6 2 3 5 6 8"})})}),(0,r.jsxs)("span",{style:{fontSize:11,color:"var(--text-dim)",minWidth:28,textAlign:"center"},children:[h+1,"/",f]}),(0,r.jsx)(l.ml,{onClick:()=>p(e=>Math.min(e+1,f-1)),title:"Next slide",disabled:h>=f-1,style:{width:24,height:24,padding:0,lineHeight:1},children:(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",children:(0,r.jsx)("polyline",{points:"4 2 7 5 4 8"})})})]}),children:!o&&!s&&g&&(0,r.jsx)(j.QG,{children:(0,r.jsxs)("div",{style:{width:"100%",maxWidth:800},children:[(0,r.jsxs)(j.ok,{children:[(0,r.jsxs)(j.PH,{children:["Slide ",g.index]}),(0,r.jsx)(j.OI,{style:{minHeight:200},children:0===g.texts.length?(0,r.jsx)("div",{style:{color:"var(--text-dim)",fontStyle:"italic",fontSize:13},children:"(No text content)"}):(0,r.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:g.texts.map((e,t)=>(0,r.jsx)("li",{style:{padding:"4px 0",fontSize:14,lineHeight:1.6,color:"var(--text)",borderBottom:t<g.texts.length-1?"1px solid var(--bg-panel)":"none"},children:e},t))})})]}),f>1&&(0,r.jsx)($._t,{title:"All slides",children:(0,r.jsx)($.S7,{children:c.map((e,t)=>(0,r.jsx)($.HF,{title:`Slide ${e.index}`,summary:e.texts[0]||"(empty)",active:t===h,onClick:()=>p(t)},e.index))})})]})})})}let W=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif"]),z=new Set(["mp3","wav","ogg","oga","opus","m4a","aac","flac","weba","webm"]),R=new Set(["pdf","docx","xlsx","pptx","doc","xls","ppt"]);function T({filePath:e,cwd:t}){let[n,o]=(0,i.useState)(!1),[a,s]=(0,i.useState)(0),[d,c]=(0,i.useState)(null),[u,h]=(0,i.useState)(null),[p,g]=(0,i.useState)(null),[f,m]=(0,i.useState)(100),y=(0,i.useRef)(null),v=(0,x.WP)(e).toLowerCase().split(".").pop()??"";(0,i.useEffect)(()=>{s(0),c(null),h(null),g(null),o(!1),m(100),y.current&&(y.current.close(),y.current=null);let t=(0,x.HG)(e),n=new EventSource(`/api/files/${t}?type=watch`);return y.current=n,n.addEventListener("connected",()=>o(!0)),n.addEventListener("change",e=>{try{let t=JSON.parse(e.data);"number"==typeof t.size&&c(t.size)}catch{}s(e=>e+1)}),n.addEventListener("error",()=>o(!1)),n.onerror=()=>o(!1),()=>{n.close(),y.current=null}},[e]);let b=(0,x.HG)(e),w=`/api/files/${b}?type=read${a?`&v=${a}`:""}`,j=null!=d?(0,l.v7)(d):null,k=e=>m(Math.max(10,Math.min(500,e)));return(0,r.jsxs)(l.fj,{children:[(0,r.jsx)(l.K$,{pathLabel:(0,x.qP)(e,t),title:e,trailing:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,flexShrink:0},children:[(0,r.jsx)(l.ml,{onClick:()=>k(f-25),title:"Zoom out",style:{width:24,height:22,fontSize:13,lineHeight:1,padding:0},children:"-"}),(0,r.jsx)("select",{value:f,onChange:e=>k(Number(e.target.value)),title:"Image zoom",style:{height:22,border:"1px solid var(--border)",borderRadius:5,background:"var(--bg-panel)",color:"var(--text)",fontSize:11,fontFamily:"var(--font-mono)",outline:"none",cursor:"pointer"},children:[25,50,75,100,125,150,200,300].map(e=>(0,r.jsxs)("option",{value:e,children:[e,"%"]},e))}),(0,r.jsx)(l.ml,{onClick:()=>k(f+25),title:"Zoom in",style:{width:24,height:22,fontSize:13,lineHeight:1,padding:0},children:"+"})]}),(0,r.jsx)("span",{style:{flexShrink:0},children:v||"image"}),u&&(0,r.jsxs)("span",{children:[u.w," \xd7 ",u.h]}),j&&(0,r.jsx)("span",{children:j}),(0,r.jsx)(l.mK,{watching:n})]})}),(0,r.jsx)(l.Ph,{style:{background:"var(--bg-panel)",WebkitOverflowScrolling:"touch",overscrollBehavior:"contain",backgroundImage:"linear-gradient(45deg, var(--bg) 25%, transparent 25%), linear-gradient(-45deg, var(--bg) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--bg) 75%), linear-gradient(-45deg, transparent 75%, var(--bg) 75%)",backgroundSize:"16px 16px",backgroundPosition:"0 0, 0 8px, 8px -8px, -8px 0px"},children:p?(0,r.jsx)(l.nG,{tone:"error",style:{minWidth:"100%",minHeight:"100%"},children:p}):(0,r.jsx)("div",{style:{minWidth:"100%",minHeight:"100%",width:"max-content",height:"max-content",boxSizing:"border-box",display:"flex",alignItems:"flex-start",justifyContent:"flex-start",padding:16},children:(0,r.jsx)("img",{src:w,alt:e,onLoad:e=>{let t=e.currentTarget;h({w:t.naturalWidth,h:t.naturalHeight})},onError:()=>g("Failed to load image"),style:{width:u?Math.max(1,Math.round(u.w*f/100)):"auto",height:u?Math.max(1,Math.round(u.h*f/100)):"auto",maxWidth:"none",maxHeight:"none",objectFit:"contain",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"}})})})]})}function H({filePath:e,cwd:t}){let[n,o]=(0,i.useState)(!1),[a,s]=(0,i.useState)(0),[d,c]=(0,i.useState)(null),[u,h]=(0,i.useState)(null),[p,g]=(0,i.useState)(null),f=(0,i.useRef)(null),m=(0,x.WP)(e).toLowerCase().split(".").pop()??"";(0,i.useEffect)(()=>{s(0),c(null),h(null),g(null),o(!1),f.current&&(f.current.close(),f.current=null);let t=(0,x.HG)(e),n=new EventSource(`/api/files/${t}?type=watch`);return f.current=n,n.addEventListener("connected",()=>o(!0)),n.addEventListener("change",e=>{try{let t=JSON.parse(e.data);"number"==typeof t.size&&c(t.size)}catch{}h(null),g(null),s(e=>e+1)}),n.addEventListener("error",()=>o(!1)),n.onerror=()=>o(!1),()=>{n.close(),f.current=null}},[e]);let y=(0,x.HG)(e),v=`/api/files/${y}?type=read${a?`&v=${a}`:""}`;return(0,r.jsxs)(l.fj,{children:[(0,r.jsx)(l.K$,{pathLabel:(0,x.qP)(e,t),title:e,trailing:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{children:m||"audio"}),null!=u&&(0,r.jsx)("span",{children:function(e){if(!Number.isFinite(e))return"";let t=Math.round(e),n=Math.floor(t/60);return`${n}:${String(t%60).padStart(2,"0")}`}(u)}),null!=d&&(0,r.jsx)("span",{children:(0,l.v7)(d)}),(0,r.jsx)(l.mK,{watching:n})]})}),(0,r.jsx)(l.Ph,{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:24,background:"var(--bg-panel)"},children:(0,r.jsxs)("div",{style:{width:"min(680px, 100%)"},children:[p&&(0,r.jsx)("div",{style:{color:"#f87171",fontSize:13,marginBottom:12,textAlign:"center"},children:p}),(0,r.jsx)("audio",{controls:!0,preload:"metadata",src:v,onLoadedMetadata:e=>h(e.currentTarget.duration),onError:()=>g("Failed to load audio"),style:{width:"100%"}},v)]})})]})}function P({filePath:e,cwd:t,onOpenFile:n}){let i,l,o;return(0,x.WP)(e).toLowerCase().endsWith(".h5ad")?(0,r.jsx)(B,{filePath:e,cwd:t}):(i=(0,x.WP)(e).toLowerCase().split(".").pop()??"",W.has(i))?(0,r.jsx)(T,{filePath:e,cwd:t}):(l=(0,x.WP)(e).toLowerCase().split(".").pop()??"",z.has(l))?(0,r.jsx)(H,{filePath:e,cwd:t}):(o=(0,x.WP)(e).toLowerCase().split(".").pop()??"",R.has(o))?(0,r.jsx)(N,{filePath:e,cwd:t}):(0,r.jsx)(w,{filePath:e,cwd:t,onOpenFile:n})}function B({filePath:e,cwd:t}){return(0,r.jsxs)(l.fj,{style:{background:"var(--bg)"},children:[(0,r.jsx)(l.K$,{pathLabel:(0,x.qP)(e,t),title:e,style:{padding:"9px 12px",fontSize:12,color:"var(--text-muted)"}}),(0,r.jsx)(l.nG,{children:"H5AD is a binary dataset. Use @explore from the file tree to open the interactive explorer."})]})}function N({filePath:e,cwd:t}){let n,[o,a]=(0,i.useState)(null),[s,d]=(0,i.useState)(!0),[c,u]=(0,i.useState)(null),h=(0,i.useRef)(null),p=(0,i.useRef)(0),g="pdf"===(n=(0,x.WP)(e).toLowerCase().split(".").pop()??"")?"pdf":"docx"===n||"doc"===n?"docx":"xlsx"===n||"xls"===n?"xlsx":"pptx"===n||"ppt"===n?"pptx":"other",f=(0,x.WP)(e).toLowerCase().split(".").pop()??"",m=(0,i.useCallback)(async e=>{try{let t=(0,x.HG)(e),n=p.current?`&v=${p.current}`:"",r=await fetch(`/api/files/${t}?type=read${n}`);if(!r.ok){let e=await r.json().catch(()=>({error:String(r.status)}));u(e.error??`HTTP ${r.status}`);return}let i=await r.arrayBuffer();a(i),u(null)}catch(e){u(String(e))}},[]);if((0,i.useEffect)(()=>{d(!0),u(null),a(null),p.current=0,h.current&&(h.current.close(),h.current=null),m(e).finally(()=>d(!1));let t=(0,x.HG)(e),n=new EventSource(`/api/files/${t}?type=watch`);return h.current=n,n.addEventListener("connected",()=>{}),n.addEventListener("change",()=>{p.current+=1,m(e)}),n.addEventListener("error",()=>{}),n.onerror=()=>{},()=>{n.close(),h.current=null}},[e,m]),s&&!o)return(0,r.jsx)(l.nG,{children:"Loading..."});if(c&&!o)return(0,r.jsx)(l.nG,{tone:"error",children:c});if(!o)return null;let y=(0,x.qP)(e,t);return(0,r.jsxs)(l.fj,{children:["pdf"===g&&(0,r.jsx)(C,{arrayBuffer:o,fileName:y}),"docx"===g&&(0,r.jsx)(L,{arrayBuffer:o,fileName:y}),"xlsx"===g&&(0,r.jsx)(M,{arrayBuffer:o,fileName:y}),"pptx"===g&&(0,r.jsx)(E,{arrayBuffer:o,fileName:y}),"other"===g&&(0,r.jsxs)(l.nG,{children:["Unsupported document format: .",f]})]})}},53308:(e,t,n)=>{n.d(t,{HF:()=>o,S7:()=>l,_t:()=>i});var r=n(95155);function i({title:e,children:t,style:n}){return(0,r.jsxs)("div",{"data-document-surface":"outline",style:{marginTop:24,...n},children:[e&&(0,r.jsx)("div",{"data-document-surface":"outline-title",style:{fontSize:12,color:"var(--text-dim)",marginBottom:8},children:e}),t]})}function l({children:e,minItemWidth:t=140,style:n}){return(0,r.jsx)("div",{"data-document-surface":"outline-grid",style:{display:"grid",gridTemplateColumns:`repeat(auto-fill, minmax(${t}px, 1fr))`,gap:8,...n},children:e})}function o({title:e,summary:t,active:n=!1,onClick:i}){return(0,r.jsxs)("button",{"data-document-surface":"outline-item","data-document-active":n?"true":"false",onClick:i,style:{padding:"10px 12px",background:n?"var(--bg-selected)":"var(--bg)",border:n?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:6,cursor:"pointer",textAlign:"left",fontSize:11,color:"var(--text-muted)",transition:"border-color 0.12s, background 0.12s"},onMouseEnter:e=>{n||(e.currentTarget.style.background="var(--bg-hover)")},onMouseLeave:e=>{n||(e.currentTarget.style.background="var(--bg)")},children:[(0,r.jsx)("div",{style:{fontWeight:600,marginBottom:2*!!t,color:"var(--text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e}),t&&(0,r.jsx)("div",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]})}},55543:(e,t,n)=>{n.d(t,{p:()=>l,t:()=>i});var r=n(95155);function i({children:e,style:t,kind:n}){return(0,r.jsx)("div",{"data-disclosure-surface":"panel","data-disclosure-kind":n,style:{border:"1px solid var(--border)",borderRadius:6,overflow:"hidden",background:"var(--bg-panel)",...t},children:e})}function l({children:e,style:t}){return(0,r.jsx)("div",{"data-disclosure-surface":"body",style:{borderTop:"1px solid var(--border)",...t},children:e})}},56264:(e,t,n)=>{n.d(t,{Ln:()=>p,O7:()=>g,Xz:()=>h,eR:()=>f,h5:()=>c,qb:()=>m,qn:()=>u});var r=n(95155),i=n(12115),l=n(31775),o=n(28999);let a=/(?:file:\/\/)?(?:(?:[A-Za-z]:[\\/])|\/|~\/|\.{1,2}[\\/]|[A-Za-z0-9_.-]+[\\/])[^`"'<>|\s{}\[\]]+?\.(?:png|jpe?g|webp|gif|svg|bmp|avif|pdf)(?=$|[\s`"'<>|{}\[\]),.;:!?])/gi,s=/\.(?:png|jpe?g|webp|gif|svg|bmp|avif)$/i,d=/\.pdf$/i;function c(e){return e.source?.type==="base64"&&e.source.data?`data:${e.source.media_type??"image/png"};base64,${e.source.data}`:e.source?.type==="url"&&e.source.url?e.source.url:e.data?`data:${e.mimeType??"image/png"};base64,${e.data}`:null}function u(e,t){if(!e)return[];let n=[],r=new Set,i=new Set;for(let t of e.matchAll(/!\[[^\]]*]\(([^)]+)\)/g))t[1]&&i.add(t[1].trim());let l=e=>{!e||r.has(e)||n.length>=24||(r.add(e),n.push(e))};for(let n of(a.lastIndex=0,e.matchAll(a))){let r=n[0];if(/^[a-z][a-z\d+.-]*:\/\//i.test(r)&&!/^file:\/\//i.test(r))continue;let a=e.slice(Math.max(0,n.index-12),n.index);if(/[A-Za-z][A-Za-z\d+.-]*:\/?$/.test(a)||r.startsWith("//")||i.has(r))continue;let c=(0,o.HR)(r,t);c&&(s.test(c)?l(c):d.test(c)&&l(c.replace(d,".png")))}return n}function h(e){let t=new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n}function p(e,t){return e&&t?e.replace(/\n?\[Current model does not support images\. The image will be omitted from this request\.\]\s*/g,"").trim():e}function g({images:e,maxHeight:t=360}){return 0===e.length?null:(0,r.jsx)("div",{style:{display:"grid",gridTemplateColumns:1===e.length?"minmax(0, 1fr)":"repeat(auto-fit, minmax(180px, 1fr))",gap:8,minWidth:0},children:e.map((e,n)=>{let i=c(e);return i?(0,r.jsx)("a",{href:i,target:"_blank",rel:"noreferrer",title:"Open image",style:{display:"block",minWidth:0,border:"1px solid var(--border)",borderRadius:6,overflow:"hidden",background:"var(--bg)"},children:(0,r.jsx)("img",{src:i,alt:"",loading:"lazy",style:{display:"block",width:"100%",maxHeight:t,objectFit:"contain"}})},n):null})})}function f({imagePaths:e,maxHeight:t=360}){let[n,l]=(0,i.useState)(()=>new Set),a=(0,i.useRef)(new Map),s=e.join("\0");(0,i.useEffect)(()=>{let t=new Set(e);a.current=new Map([...a.current].filter(([e])=>t.has(e))),l(e=>{let n=new Set([...e].filter(e=>t.has(e)));return n.size===e.size?e:n})},[e,s]),(0,i.useEffect)(()=>{if(![...n].some(e=>(a.current.get(e)??0)<3))return;let e=window.setTimeout(()=>{l(e=>{let t=new Set(e);for(let n of e)(a.current.get(n)??0)<3&&t.delete(n);return t})},2500);return()=>window.clearTimeout(e)},[n]);let d=e.filter(e=>!n.has(e));return 0===d.length?null:(0,r.jsx)("div",{style:{display:"grid",gridTemplateColumns:1===d.length?"minmax(0, 1fr)":"repeat(auto-fit, minmax(180px, 1fr))",gap:8,minWidth:0},children:d.map(e=>{let n=`/api/files/${(0,o.HG)(e)}?type=read`,i=(0,o.WP)(e);return(0,r.jsxs)("a",{href:n,target:"_blank",rel:"noreferrer",title:e,style:{display:"block",minWidth:0,border:"1px solid var(--border)",borderRadius:6,overflow:"hidden",background:"var(--bg)"},children:[(0,r.jsx)("img",{src:n,alt:i,loading:"lazy",onError:()=>{a.current.set(e,(a.current.get(e)??0)+1),l(t=>{let n=new Set(t);return n.add(e),n})},style:{display:"block",width:"100%",maxHeight:t,objectFit:"contain"}}),(0,r.jsx)("div",{style:{padding:"4px 6px",borderTop:"1px solid var(--border)",color:"var(--text-dim)",fontSize:10,fontFamily:"var(--font-mono)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:i})]},e)})})}function m({text:e,isEmpty:t,isError:n,images:i,imagePaths:o}){let a=!t||e.trim().length>0;return(0,r.jsxs)("div",{style:{borderTop:`1px solid ${n?"rgba(248,113,113,0.3)":"rgba(34,197,94,0.15)"}`,background:n?"rgba(248,113,113,0.04)":"var(--bg-subtle)"},children:[i.length>0&&(0,r.jsx)("div",{style:{padding:"10px 10px 0",background:"var(--bg)"},children:(0,r.jsx)(g,{images:i})}),o.length>0&&(0,r.jsx)("div",{style:{padding:"10px 10px 0",background:"var(--bg)"},children:(0,r.jsx)(f,{imagePaths:o})}),a&&(0,r.jsx)(l.m,{text:t?"(no output)":e,maxHeight:400,collapsible:!0,textColor:n?"#f87171":t?"var(--text-dim)":"var(--text-muted)",background:"var(--bg)",empty:t})]})}},63161:(e,t,n)=>{n.d(t,{B:()=>o});var r=n(95155),i=n(76577);function l({fileName:e,pageInfo:t,onZoomIn:n,onZoomOut:o,zoom:a,extra:s}){let d=(0,r.jsxs)(r.Fragment,{children:[t&&(0,r.jsx)("span",{children:t}),void 0!==a&&o&&n&&(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4},children:[(0,r.jsx)(i.ml,{onClick:o,title:"Zoom out",style:{width:24,height:24,padding:0,lineHeight:1},children:(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",children:(0,r.jsx)("line",{x1:"2",y1:"5",x2:"8",y2:"5"})})}),(0,r.jsxs)("span",{style:{minWidth:36,textAlign:"center",fontVariantNumeric:"tabular-nums"},children:[Math.round(100*a),"%"]}),(0,r.jsx)(i.ml,{onClick:n,title:"Zoom in",style:{width:24,height:24,padding:0,lineHeight:1},children:(0,r.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",children:[(0,r.jsx)("line",{x1:"5",y1:"2",x2:"5",y2:"8"}),(0,r.jsx)("line",{x1:"2",y1:"5",x2:"8",y2:"5"})]})})]}),s]});return(0,r.jsx)(i.K$,{pathLabel:e??"document",title:e,trailing:d,style:{minHeight:32}})}function o({fileName:e,pageInfo:t,onZoomIn:n,onZoomOut:a,zoom:s,extra:d,bodyStyle:c,loading:u=!1,loadingLabel:h="Loading document...",error:p=null,children:g}){return(0,r.jsxs)(i.fj,{children:[(0,r.jsx)(l,{fileName:e,pageInfo:t,onZoomIn:n,onZoomOut:a,zoom:s,extra:d}),(0,r.jsx)(i.Ph,{style:c,children:u?(0,r.jsx)(i.nG,{children:h}):p?(0,r.jsx)(i.nG,{tone:"error",children:p}):g})]})}n(12115)},68515:(e,t,n)=>{n.d(t,{V:()=>a});var r=n(95155),i=n(84841),l=n(49006),o=n(18678);function a({expanded:e,onToggle:t,status:n,title:s,summary:d,durationLabel:c,leading:u,titleTooltip:h,summaryTooltip:p,buttonStyle:g,titleStyle:f,summaryStyle:m,durationStyle:x}){return(0,r.jsxs)(i.R,{expanded:e,onToggle:t,buttonStyle:g,children:[u,(0,r.jsx)("span",{title:h??s,style:{color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontWeight:600,fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:+!d,minWidth:0,flex:d?void 0:1,...f},children:"running"===n?(0,r.jsx)(l.n,{children:s}):s}),d?(0,r.jsx)("span",{title:p??d,style:{color:"var(--text-dim)",fontFamily:"var(--font-mono)",fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0,...m},children:"running"===n?(0,r.jsx)(l.n,{children:d}):d}):(0,r.jsx)("span",{style:{flex:1,minWidth:0}}),(0,r.jsx)(o.U1,{status:n}),c?(0,r.jsx)("span",{style:{fontSize:11,color:"var(--text-dim)",fontVariantNumeric:"tabular-nums",flexShrink:0,...x},children:c}):null]})}},72518:(e,t,n)=>{n.d(t,{aU:()=>l,cx:()=>i,nS:()=>x,Rd:()=>m,wY:()=>f,tG:()=>h});class r{#e;#t;constructor(e){this.#t=new Map,this.#e=e}get(e){if(!this.#t.has(e))return;let t=this.#t.get(e);return this.#t.delete(e),this.#t.set(e,t),t}set(e,t){for(this.#t.has(e)&&this.#t.delete(e);this.#t.size>=this.#e;){let e=this.#t.keys().next().value;if(void 0===e)break;this.#t.delete(e)}this.#t.set(e,t)}delete(e){this.#t.delete(e)}get size(){return this.#t.size}}let i="github-light",l="github-dark",o=new r(10),a=new r(200),s=new Set,d=new Map,c=null;function u(e,t,n){let r=e.slice(0,100),i=e.length>100?e.slice(-100):"";return`${t}:${n}:${e.length}:${r}:${i}`}function h(e){return void 0===e||0===e?{}:{fontStyle:1&e?"italic":void 0,fontWeight:2&e?700:void 0,textDecorationLine:4&e?"underline":void 0}}function p(){return c||(c=Promise.all([n.e(2619),n.e(6586)]).then(n.bind(n,66586)).then(e=>{if(0===s.size){for(let t of Object.keys(e.bundledLanguages??{}))s.add(t.toLowerCase());for(let t of e.bundledLanguagesInfo??[]){let e=t.id.toLowerCase();for(let n of t.aliases??[])d.set(n.toLowerCase(),e)}}return e})),c}async function g(e,t=i,n=l){let r=`${e}:${t}:${n}`,a=o.get(r);if(a)return a;let s=p().then(({createHighlighter:r})=>r({langs:[e],themes:[t,n]})).catch(e=>{throw o.delete(r),e});return o.set(r,s),s}function f(e,t,n,r){let o=m(e,t,n);if(o)return o;let c=n?l:i,h=t.trim().toLowerCase();if(!h)return null;let f=u(e,h,c);return p().then(()=>{let n,o=(n=t.trim().toLowerCase())?s.has(n)?n:d.get(n)??null:null;return o?g(o,i,l).then(t=>{let n=t.codeToTokens(e,{lang:o,theme:c}),i={bg:n.bg??"transparent",fg:n.fg??"inherit",tokens:n.tokens};return a.set(f,i),r(i),i}):null}).catch(e=>{console.warn("[Shiki] highlight failed:",e)}),null}function m(e,t,n){let r=t.trim().toLowerCase();if(!r)return null;let o=u(e,r,n?l:i);return a.get(o)??null}function x(e){return{bg:"transparent",fg:"inherit",tokens:e.replace(/\r\n/g,"\n").replace(/\r/g,"\n").split("\n").map(e=>""===e?[]:[{color:"inherit",content:e}])}}},76577:(e,t,n)=>{n.d(t,{K$:()=>a,Ph:()=>o,Tg:()=>h,fj:()=>l,mK:()=>s,ml:()=>d,nG:()=>c,pg:()=>u,v7:()=>i});var r=n(95155);function i(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function l({children:e,style:t}){return(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden",...t},children:e})}function o({children:e,style:t}){return(0,r.jsx)("div",{style:{flex:1,overflow:"auto",background:"var(--bg)",...t},children:e})}function a({pathLabel:e,title:t,trailing:n,style:i}){return(0,r.jsxs)("div",{"data-file-viewer-surface":"status-bar",style:{display:"flex",alignItems:"center",gap:12,padding:"4px 16px",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-dim)",background:"var(--bg)",flexShrink:0,...i},children:[(0,r.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"var(--font-mono)"},title:t??e,children:e}),n]})}function s({watching:e}){return(0,r.jsxs)("span",{title:e?"Live sync active":"Not watching",style:{display:"flex",alignItems:"center",gap:4,color:e?"#4ade80":"var(--text-dim)"},children:[(0,r.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:e?"#4ade80":"var(--border)",display:"inline-block",boxShadow:e?"0 0 4px #4ade80":"none"}}),e?"live":"static"]})}function d({children:e,onClick:t,title:n,disabled:i=!1,active:l=!1,emphasis:o="default",style:a}){let s="primary"==o,c="danger"==o;return(0,r.jsx)("button",{"data-file-viewer-surface":"toolbar-button",onClick:t,disabled:i,title:n,style:{padding:"2px 10px",fontSize:11,cursor:i?"not-allowed":"pointer",background:s?"var(--accent)":c?"rgba(239,68,68,0.1)":l?"var(--bg-selected)":"var(--bg-hover)",color:s?"#fff":c?"#ef4444":l?"var(--text)":"var(--text-muted)",border:`1px solid ${s?"var(--accent)":c?"rgba(239,68,68,0.3)":"var(--border)"}`,borderRadius:5,fontWeight:l||s||c?600:400,opacity:i?.6:1,...a},children:e})}function c({children:e,tone:t="muted",style:n}){return(0,r.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",padding:24,color:"error"===t?"#f87171":"var(--text-muted)",fontSize:13,textAlign:"center",...n},children:e})}function u({diff:e,emptyLabel:t="No changes"}){if(!e.some(e=>"unchanged"!==e.type))return(0,r.jsx)("div",{style:{padding:"12px 16px",fontSize:12,color:"var(--text-dim)",fontFamily:"var(--font-mono)"},children:t});let n=new Set(e.flatMap((e,t)=>"unchanged"!==e.type?[t]:[])),i=new Set;for(let t of n)for(let n=Math.max(0,t-3);n<=Math.min(e.length-1,t+3);n++)i.add(n);let l=[],o=0;for(;o<e.length;)if(i.has(o)){let t=[];for(;o<e.length&&i.has(o);)t.push(e[o]),o++;l.push({hidden:!1,lines:t})}else{let t=0;for(;o<e.length&&!i.has(o);)t++,o++;l.push({hidden:!0,count:t})}let a=[],s=1;for(let t of e)"removed"===t.type?a.push(0):a.push(s++);let d=0;return(0,r.jsx)("div",{style:{fontFamily:"var(--font-mono)",fontSize:13,lineHeight:1.6},children:l.map((e,t)=>{if(e.hidden){let n=(0,r.jsxs)("div",{style:{padding:"2px 16px",color:"var(--text-dim)",background:"var(--bg-panel)",fontSize:11,borderTop:"1px solid var(--border)",borderBottom:"1px solid var(--border)"},children:["... ",e.count," unchanged lines ..."]},t);return d+=e.count,n}let n=e.lines.map((e,t)=>{let n=a[d+t],i="added"===e.type?"rgba(0,200,80,0.12)":"removed"===e.type?"rgba(240,60,60,0.14)":"transparent",l="added"===e.type?"+":"removed"===e.type?"-":" ",o="added"===e.type?"#4ade80":"removed"===e.type?"#f87171":"var(--text-dim)";return(0,r.jsxs)("div",{style:{display:"flex",background:i,borderLeft:"added"===e.type?"3px solid #4ade80":"removed"===e.type?"3px solid #f87171":"3px solid transparent"},children:[(0,r.jsx)("span",{style:{minWidth:44,padding:"0 8px 0 16px",textAlign:"right",color:"var(--text-dim)",userSelect:"none",fontSize:11,lineHeight:1.6,borderRight:"1px solid var(--border)",background:"var(--bg-panel)",flexShrink:0},children:"removed"===e.type?e.lineNo:n||""}),(0,r.jsx)("span",{style:{minWidth:16,padding:"0 6px",color:o,userSelect:"none",flexShrink:0,fontWeight:600},children:l}),(0,r.jsx)("span",{style:{flex:1,padding:"0 8px 0 0",whiteSpace:"pre",color:"var(--text)",overflowX:"auto"},children:e.text||"\xa0"})]},t)});return d+=e.lines.length,(0,r.jsx)("div",{children:n},t)})})}function h({options:e}){return(0,r.jsx)("div",{"data-file-viewer-surface":"segmented-toggle",style:{display:"flex",borderRadius:5,overflow:"hidden",border:"1px solid var(--border)"},children:e.map((e,t)=>(0,r.jsx)("button",{onClick:e.onClick,style:{padding:"2px 8px",fontSize:11,border:"none",borderLeft:0===t?"none":"1px solid var(--border)",cursor:"pointer",background:e.active?"var(--bg-selected)":"var(--bg-hover)",color:e.active?"var(--text)":"var(--text-muted)",fontWeight:e.active?600:400},children:e.label},e.key))})}},84841:(e,t,n)=>{n.d(t,{R:()=>i});var r=n(95155);function i({expanded:e,onToggle:t,children:n,title:l,buttonStyle:o,chevronColor:a="var(--text-dim)",chevronStyle:s}){return(0,r.jsxs)("button",{type:"button",onClick:t,"aria-expanded":e,title:l,style:o,children:[n,(0,r.jsx)("span",{style:{display:"inline-flex",color:a,transform:e?"rotate(180deg)":"none",transition:"transform 0.15s",flexShrink:0,...s},children:(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("polyline",{points:"2 3.5 5 6.5 8 3.5"})})})]})}},87559:(e,t,n)=>{function r(e,t){for(let n of t){let t=e[n];if(null!=t&&""!==t)return String(t)}return null}function i(e,t=60){let n=e.replace(/\s+/g," ").trim();return n.length<=t?n:`${n.slice(0,Math.max(0,t-3))}...`}function l(e){let t=e.toLowerCase().split("__").filter(Boolean);return t[t.length-1]??e.toLowerCase()}function o(e,t=120){let n=Object.keys(e);return 0===n.length?"":"command"in e?String(e.command).slice(0,t):"cmd"in e?String(e.cmd).slice(0,t):"path"in e?String(e.path).slice(0,t):"file_path"in e?String(e.file_path).slice(0,t):"pattern"in e?String(e.pattern).slice(0,t):"query"in e?String(e.query).slice(0,t):String(e[n[0]]).slice(0,t)}function a(e){let t=e.toolName||"tool",n=l(t),o=e.input??{};if(["bash","execute","run","shell","exec_command","execute_command"].includes(n))return{canonicalName:n,kind:"terminal",label:"Shell",summary:i(r(o,["command","cmd"])??t,60)};if(["read","readfile","read_file"].includes(n))return{canonicalName:n,kind:"read",label:"Read",summary:i(r(o,["file_path","path"])??t,60)};if(["write","edit","write_file","create_file","notebook_edit"].includes(n)){let e,l=r(o,["file_path","path","notebook_path","filename"]);return{canonicalName:n,kind:"edit",label:"Edit",summary:i(l?(e=l.split(/[\\/]/).filter(Boolean))[e.length-1]??l:t,60)}}if(["search","grep","glob","find","find_files","websearch"].includes(n))return{canonicalName:n,kind:"search",label:"Search",summary:i(r(o,["pattern","query","glob"])??t,60)};if(["subagent","agent"].includes(n))return{canonicalName:n,kind:"agent",label:"Agent",summary:i([r(o,["agent","name","agentName"]),r(o,["prompt","task","message"])].filter(Boolean).join(": ")||t,60)};let a=r(o,["command","cmd","path","file_path","pattern","query","glob","prompt","description"])??function(e){try{return JSON.stringify(e)}catch{return String(e)}}(o)??t;return{canonicalName:n,kind:"tool",label:i(t,60),summary:i(a,60)}}n.d(t,{WI:()=>l,Wm:()=>o,wS:()=>a})},94456:(e,t,n)=>{n.d(t,{D:()=>D});var r=n(95155),i=n(12115),l=n(44667),o=n(49006),a=n(28093),s=n(17689),d=n(18678),c=n(56264),u=n(40332),h=n(51256),p=n(2112);function g({block:e,toolResults:t,isStreaming:n,streamingDuration:i,toolCallDurations:l,onSendMessage:o,renderVisualCodeBlocks:a,cwd:s}){if("text"===e.type)return(0,r.jsx)(f,{block:e,isStreaming:n,onSendMessage:o,renderVisualCodeBlocks:a,cwd:s});if("image"===e.type)return(0,r.jsx)(c.O7,{images:[e]});if("thinking"===e.type)return(0,r.jsx)(v,{block:e,duration:i,isStreaming:n});let d=t?.get(e.toolCallId),u=l?.get(e.toolCallId);return(0,r.jsx)(b,{block:e,result:d,duration:u,isStreaming:n,cwd:s})}function f({block:e,isStreaming:t,onSendMessage:n,renderVisualCodeBlocks:i,cwd:l}){let o=(0,h.It)(e.text),a=(0,p.aH)(o),s=a.some(e=>"widget"===e.type),d=(0,h.tU)(e.text);if(!s){if(d&&!o.trim())return(0,r.jsx)(m,{isStreaming:t});if(t&&(0,p.qk)(o)){let e=a.filter(e=>"text"===e.type).map(e=>e.content).join("\n\n");return(0,r.jsxs)(r.Fragment,{children:[e&&(0,r.jsx)(x,{text:e,isStreaming:t,onSendMessage:n,renderVisualCodeBlocks:i,cwd:l}),(0,r.jsx)(y,{})]})}return(0,r.jsx)(x,{text:o,isStreaming:t,onSendMessage:n,renderVisualCodeBlocks:i,cwd:l})}return(0,r.jsx)(r.Fragment,{children:a.map((e,o)=>"text"===e.type?(0,r.jsx)(x,{text:e.content,isStreaming:t,onSendMessage:n,renderVisualCodeBlocks:i,cwd:l},o):(0,r.jsx)(u.u,{code:e.code,isStreaming:!!e.partial,title:e.title,showOverlay:e.showOverlay,onSendMessage:n},o))})}function m({isStreaming:e}){return(0,r.jsx)("div",{style:{border:"1px solid var(--border)",borderRadius:6,padding:"8px 10px",background:"var(--bg-panel)",color:"var(--text-muted)",fontSize:12},children:e?"Updating analysis report...":"Analysis report updated"})}function x({text:e,isStreaming:t,onSendMessage:n,renderVisualCodeBlocks:o,cwd:a}){let s=(0,i.useMemo)(()=>(0,c.qn)(e,a),[a,e]);return(0,r.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8*(s.length>0)},children:[(0,r.jsx)(l.T,{content:e,cwd:a,onWidgetSendMessage:n,renderVisualCodeBlocks:o,isStreaming:t,renderer:"streamdown"}),s.length>0&&(0,r.jsx)(c.eR,{imagePaths:s})]})}function y(){return(0,r.jsx)(o.r,{height:88,style:{border:"1px solid var(--border)"}})}function v({block:e,duration:t,isStreaming:n}){return(0,r.jsx)(a.pm,{content:e.thinking,durationLabel:void 0!==t?`${t}s`:null,isStreaming:n,buttonStyle:{width:"100%",padding:"6px 10px",fontSize:12},containerStyle:{fontSize:13},contentStyle:{background:"var(--bg-panel)"}})}function b({block:e,result:t,duration:n,isStreaming:i,cwd:l}){let o=(0,d.s2)(t,i),a=(0,d.Gb)(o);return(0,r.jsx)(s.Dm,{tool:e,result:t,status:o,durationLabel:void 0!==n?`${n}s`:null,cwd:l,titleStyle:{color:a},collapsedPreviewBackground:`color-mix(in srgb, ${a} 5%, transparent)`,buttonStyle:{display:"flex",alignItems:"center",gap:7,width:"100%",padding:"6px 10px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:12,textAlign:"left",minWidth:0},containerStyle:{border:`1px solid color-mix(in srgb, ${a} 38%, transparent)`,background:`color-mix(in srgb, ${a} 8%, transparent)`}})}var w=n(7834);function j(e=768){let[t,n]=(0,i.useState)(!1);return(0,i.useEffect)(()=>{let t=window.matchMedia(`(max-width: ${e}px)`),r=()=>n(t.matches);return r(),t.addEventListener?.("change",r),()=>t.removeEventListener?.("change",r)},[e]),t}function k({children:e,hovered:t,onHoverChange:n,style:i}){return(0,r.jsx)("div",{style:i,onMouseEnter:()=>n?.(!0),onMouseLeave:()=>n?.(!1),"data-message-hovered":t?"true":"false",children:e})}function S({children:e,justify:t="flex-start",style:n}){let i=j();return(0,r.jsx)("div",{"data-message-surface":"footer",style:{display:"flex",alignItems:"center",justifyContent:t,gap:i?4:6,marginTop:4,...n},children:e})}function C({children:e,alignEnd:t=!1,style:n}){return(0,r.jsx)("span",{"data-message-surface":"timestamp",style:{fontSize:10,color:"var(--text-dim)",marginLeft:t?"auto":void 0,...n},children:e})}function L({children:e,visible:t,style:n}){return(0,r.jsx)("div",{style:{display:"flex",gap:3,opacity:+!!t,pointerEvents:t?"auto":"none",transition:"opacity 0.12s",...n},children:e})}function M({children:e,onClick:t,disabled:n=!1,title:i,active:l=!1,style:o,onMouseEnterColor:a="var(--accent)",onMouseLeaveColor:s="var(--text-dim)",iconOnlyOnMobile:d=!1}){let c=j();return(0,r.jsx)("button",{onClick:t,disabled:n,title:i,style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",height:22,background:"none",border:"none",borderRadius:5,color:l?"var(--accent)":"var(--text-dim)",cursor:n?"not-allowed":"pointer",fontSize:11,fontWeight:400,whiteSpace:"nowrap",transition:"color 0.12s",...o},onMouseEnter:e=>{n||(e.currentTarget.style.color=a)},onMouseLeave:e=>{n||(e.currentTarget.style.color=s)},children:d&&c&&Array.isArray(e)?e[0]:e})}function $({children:e,hovered:t,onHoverChange:n}){let i=j();return(0,r.jsx)(k,{hovered:t,onHoverChange:n,style:{marginBottom:i?12:16,display:"flex",flexDirection:"column",alignItems:"flex-end"},children:e})}function E({children:e}){let t=j();return(0,r.jsx)("div",{style:{display:"flex",alignItems:"flex-end",gap:t?4:6,maxWidth:t?"92%":"85%"},children:(0,r.jsx)("div",{style:{flex:1,minWidth:0,background:"var(--user-bg)",border:"1px solid rgba(59,130,246,0.2)",borderRadius:12,padding:t?"7px 10px":"8px 12px",fontSize:14,lineHeight:1.6,color:"var(--text)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:e})})}function W({children:e,hasBody:t=!1}){let n=j();return(0,r.jsx)("div",{style:{display:"flex",gap:n?4:6,flexWrap:"wrap",marginBottom:t?n?6:8:0},children:e})}function z({children:e,hovered:t,onHoverChange:n}){let i=j();return(0,r.jsx)(k,{hovered:t,onHoverChange:n,style:{marginBottom:i?12:16},children:e})}function R({children:e}){let t=j();return(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:t?6:8},children:e})}function T({children:e,accent:t="default"}){let n="subagent"===t;return(0,r.jsx)("div",{"data-message-surface":"custom-card","data-message-accent":t,style:{padding:"8px 14px",borderRadius:8,border:`1px solid ${n?"rgba(99,102,241,0.25)":"var(--border)"}`,background:n?"rgba(99,102,241,0.05)":"var(--bg-panel)",fontSize:13,lineHeight:1.6,color:"var(--text-muted)"},children:e})}function H({icon:e,children:t}){return(0,r.jsxs)("div",{"data-message-surface":"custom-icon-row",style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,r.jsx)("span",{style:{flexShrink:0,fontSize:14},children:e}),(0,r.jsx)("div",{style:{flex:1,minWidth:0},children:t})]})}function P({text:e,title:t="Copy message",style:n}){let[l,o]=(0,i.useState)(!1),a=j();return(0,r.jsxs)("button",{onClick:()=>{(0,w.D)(e).then(()=>{o(!0),setTimeout(()=>o(!1),1500)})},title:t,style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",height:22,background:"none",border:"none",borderRadius:5,color:l?"var(--accent)":"var(--text-dim)",cursor:"pointer",fontSize:11,fontWeight:400,whiteSpace:"nowrap",transition:"color 0.12s",...n},onMouseEnter:e=>{l||(e.currentTarget.style.color="var(--accent)")},onMouseLeave:e=>{l||(e.currentTarget.style.color="var(--text-dim)")},children:[l?(0,r.jsx)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})}):(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,r.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),(0,r.jsx)("span",{style:a?{display:"none"}:void 0,children:l?"Copied":"Copy"})]})}function B({provider:e,model:t,modelNames:n,isStreaming:i=!1,estimatedTokens:l=0,tps:o=null}){let a=e&&t?n?.[`${e}:${t}`]??n?.[t]??t:null;return(0,r.jsxs)("div",{style:{fontSize:11,color:"var(--text-dim)",marginBottom:4,display:"flex",alignItems:"center",gap:6},children:[a&&(0,r.jsx)("span",{children:a}),i&&l>0&&(0,r.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:4,color:"var(--text)"},title:"预估 token 数(流式接收中)",children:[(0,r.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:2,fontSize:11,fontWeight:400},children:[(0,r.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("line",{x1:"5",y1:"1.5",x2:"5",y2:"8.5"}),(0,r.jsx)("polyline",{points:"2 6 5 8.5 8 6"})]}),l]}),null!==o&&(0,r.jsxs)("span",{style:{marginLeft:6,padding:"1px 6px",borderRadius:4,background:o>=50?"#53b3cb":o>=30?"#9bc53d":o>=15?"#f9c22e":"#e01a4f",color:"#fff",fontSize:11,fontWeight:400},children:[o.toFixed(1)," t/s"]})]})]})}var N=n(99670);function I(e){let t=0;for(let n of e){if("text"===n.type){t+=n.text.length;continue}if("thinking"===n.type){t+=n.thinking.length;continue}"toolCall"===n.type&&(t+=JSON.stringify(n.input??{}).length)}return t}let F=[],A=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function O(e){return e.toString().padStart(2,"0")}function _(e){if(!e)return null;let t=new Date(e),n=new Date,r=t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate(),i=`${O(t.getHours())}:${O(t.getMinutes())}`;if(r)return i;let l=[`${A[t.getMonth()]} ${t.getDate()}`];t.getFullYear()!==n.getFullYear()&&l.push(String(t.getFullYear()));let o=l.join(", ");return`${o} ${i}`}function D({message:e,isStreaming:t,toolResults:n,modelNames:i,entryId:l,onFork:o,forking:a,onNavigate:s,prevAssistantEntryId:d,onEditContent:c,onSendMessage:u,showTimestamp:h,prevTimestamp:p,renderVisualCodeBlocks:g,cwd:f}){return"user"===e.role?(0,r.jsx)(G,{message:e,entryId:l,onFork:o,forking:a,onNavigate:s,prevAssistantEntryId:d,onEditContent:c}):"assistant"===e.role?(0,r.jsx)(U,{message:e,isStreaming:t,toolResults:n,modelNames:i,onSendMessage:u,showTimestamp:h,prevTimestamp:p,renderVisualCodeBlocks:g,cwd:f}):"toolResult"===e.role?null:"custom"===e.role?(0,r.jsx)(q,{message:e,showTimestamp:h}):null}function G({message:e,entryId:t,onFork:n,forking:l,onNavigate:o,prevAssistantEntryId:a,onEditContent:s}){let[d,u]=(0,i.useState)(!1),h="string"==typeof e.content?e.content:e.content.filter(e=>"text"===e.type).map(e=>e.text).join("\n"),p="string"==typeof e.content?[]:e.content.filter(e=>"image"===e.type),g=_(e.timestamp),f=!!t&&!!n,m=!!a&&!!o;return(0,r.jsxs)($,{hovered:d,onHoverChange:u,children:[(0,r.jsxs)(E,{children:[p.length>0&&(0,r.jsx)(W,{hasBody:!!h,children:p.map((e,t)=>{let n=(0,c.h5)(e);return n?(0,r.jsx)("a",{href:n,target:"_blank",rel:"noreferrer",title:"Open image",style:{display:"block",cursor:"zoom-in"},children:(0,r.jsx)("img",{src:n,alt:"",style:{maxWidth:240,maxHeight:240,borderRadius:6,objectFit:"contain",display:"block",border:"1px solid rgba(59,130,246,0.15)"}})},t):null})}),h]}),(0,r.jsxs)(S,{justify:"flex-end",style:{marginTop:3},children:[(0,r.jsx)(L,{visible:d,children:(0,r.jsx)(P,{text:h})}),(f||m)&&(0,r.jsxs)(L,{visible:d||!!l,children:[m&&(0,r.jsxs)(M,{iconOnlyOnMobile:!0,onClick:()=>{o(a),s?.(h)},title:"Edit from here — branches within this session",children:[(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("polyline",{points:"15 10 20 15 15 20"}),(0,r.jsx)("path",{d:"M4 4v7a4 4 0 0 0 4 4h12"})]}),"Edit from here"]}),f&&(0,r.jsxs)(M,{iconOnlyOnMobile:!0,onClick:()=>{n(t)},disabled:l,active:!!l,title:l?"Creating new session…":"New session — creates an independent copy from here",children:[(0,r.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,r.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,r.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,r.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),l?"Creating…":"New session"]})]}),g&&(0,r.jsx)(C,{children:g})]})]})}function U({message:e,isStreaming:t,toolResults:n,modelNames:l,onSendMessage:o,showTimestamp:a,prevTimestamp:s,renderVisualCodeBlocks:d,cwd:c}){var u;let h,p=a?_(e.timestamp):null,f=e.content??F,[m,x]=(0,i.useState)(!1),y=(0,i.useRef)(null),v=(0,i.useRef)(new Map),b=(0,i.useRef)(f),[w,j]=(0,i.useState)(null),[k,M]=(0,i.useState)(new Map);b.current=f;let $=(0,i.useMemo)(()=>{if(!e.timestamp||!s)return;let t=Math.round((e.timestamp-s)/1e3);return t>0?t:void 0},[e.timestamp,s]),E=(0,i.useMemo)(()=>(function(e,t){let n=new Map;if(!e||!t)return n;for(let[r,i]of e){if(!i.timestamp)continue;let e=Math.round((i.timestamp-t)/1e3);e>0&&n.set(r,e)}return n})(n,e.timestamp),[n,e.timestamp]),W=(0,i.useMemo)(()=>(function(e,t,n){let r=[],i=[],l=[];for(let[o,a]of e.entries()){if("thinking"===a.type){i.push({content:a.thinking,duration:t.get(o)??n});continue}if("toolCall"===a.type){r.push(a);continue}l.push(a)}return{tools:r,thinkingBlocks:i,visibleBlocks:l}})(f,k,$),[f,k,$]),T=(0,i.useMemo)(()=>f.filter(e=>"text"===e.type).map(e=>e.text).join("\n"),[f]),H=(0,i.useMemo)(()=>Math.round(I(f)/4),[f]);return(0,i.useEffect)(()=>{if(!t){let e=Date.now();M(t=>{let n=new Map(t);for(let[t,r]of v.current)n.has(t)||n.set(t,Math.round((e-r)/1e3));return n}),y.current=null,j(null);return}let e=setInterval(()=>{let e=b.current,t=Date.now();e.forEach((e,n)=>{v.current.has(n)||v.current.set(n,t)}),M(n=>{let r=!1,i=new Map(n);for(let n=0;n<e.length-1;n++)if(!i.has(n)&&v.current.has(n)){let e=v.current.get(n),l=v.current.get(n+1)??t;i.set(n,Math.round((l-e)/1e3)),r=!0}return r?i:n});let n=I(e);if(0===n)return;null===y.current&&(y.current=t);let r=(t-y.current)/1e3;r>.5&&j(n/4/r)},300);return()=>clearInterval(e)},[t]),(0,r.jsxs)(z,{hovered:m,onHoverChange:x,children:[(0,r.jsx)(B,{provider:e.provider,model:e.model,modelNames:l,isStreaming:t,estimatedTokens:H,tps:w}),(0,r.jsxs)(R,{children:[(W.tools.length>0||W.thinkingBlocks.length>0)&&(0,r.jsx)(N.kD,{tools:W.tools,results:n,durations:E,thinkingBlocks:W.thinkingBlocks,isStreaming:t,cwd:c}),W.visibleBlocks.map((e,i)=>(0,r.jsx)(g,{block:e,toolResults:n,isStreaming:t,toolCallDurations:E,onSendMessage:o,renderVisualCodeBlocks:d,cwd:c},i))]}),(0,r.jsxs)(S,{style:{gap:8},children:[e.usage&&!t&&(0,r.jsx)("div",{style:{fontSize:11,color:"var(--text-dim)"},children:(u=e.usage,h=[],u.input&&h.push(`${u.input.toLocaleString()} in`),u.output&&h.push(`${u.output.toLocaleString()} out`),u.cacheRead&&h.push(`${u.cacheRead.toLocaleString()} cache`),u.cost?.total&&h.push(`$${u.cost.total.toFixed(4)}`),h.join(" \xb7 "))}),T&&!t&&(0,r.jsx)(L,{visible:m,children:(0,r.jsx)(P,{text:T})}),p&&(0,r.jsx)(C,{alignEnd:!0,children:p})]})]})}function q({message:e,showTimestamp:t}){if(!e.display)return null;let n=t?_(e.timestamp):null,i="string"==typeof e.content?e.content:e.content.filter(e=>"text"===e.type).map(e=>e.text).join("\n"),o="subagent-notify"===e.customType,a=i.match(/^Background task (completed|failed|paused):\s*\*\*(.+?)\*\*/),s=a?"completed"===a[1]?"✅":"failed"===a[1]?"❌":"⏸":o?"\uD83E\uDD16":"ℹ";return(0,r.jsxs)("div",{style:{marginBottom:12},children:[(0,r.jsx)(T,{accent:o?"subagent":"default",children:(0,r.jsx)(H,{icon:s,children:(0,r.jsx)("div",{"data-message-surface":"custom-body",children:(0,r.jsx)(l.T,{content:i,style:{fontSize:13}})})})}),(n||a)&&(0,r.jsxs)(S,{justify:"flex-end",style:{marginTop:3},children:[a&&(0,r.jsx)(C,{children:a[2]}),n&&(0,r.jsx)(C,{children:n})]})]})}},96793:(e,t,n)=>{n.d(t,{D:()=>s});var r=n(12115);let i=new Set;function l(e){return i.add(e),()=>{i.delete(e)}}function o(){return"u"<typeof document?"light":document.documentElement.classList.contains("dark")?"dark":"light"}function a(){return"light"}function s(){let e=(0,r.useSyncExternalStore)(l,o,a);return{theme:e,toggleTheme:(0,r.useCallback)(e=>{let t="dark"===o()?"light":"dark",n=()=>{"dark"===t?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark");try{localStorage.setItem("pi-theme",t)}catch{}i.forEach(e=>e())},r=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;if("function"!=typeof document.startViewTransition||r)return void n();let l=e?.x??window.innerWidth/2,a=e?.y??window.innerHeight/2,s=Math.hypot(Math.max(l,window.innerWidth-l),Math.max(a,window.innerHeight-a));document.startViewTransition(n).ready.then(()=>{document.documentElement.animate({clipPath:[`circle(0px at ${l}px ${a}px)`,`circle(${s}px at ${l}px ${a}px)`]},{duration:450,easing:"cubic-bezier(0.22, 0.61, 0.36, 1)",pseudoElement:"::view-transition-new(root)"})}).catch(()=>{})},[]),isDark:"dark"===e}}},99670:(e,t,n)=>{n.d(t,{kD:()=>C,Ld:()=>u,pR:()=>b,y0:()=>c,q:()=>y,cP:()=>v,o0:()=>w});var r=n(95155),i=n(12115),l=n(18678),o=n(55543),a=n(28093),s=n(68515),d=n(17689);function c({children:e,style:t,...n}){return(0,r.jsx)("div",{...n,style:{borderLeft:"2px solid var(--border)",paddingLeft:8,minWidth:0,...t},children:e})}function u({children:e,style:t,...n}){return(0,r.jsx)("div",{...n,style:{display:"flex",flexDirection:"column",gap:4,paddingTop:6,...t},children:e})}function h({name:e}){let t={width:13,height:13,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0};return"terminal"===e?(0,r.jsxs)("svg",{...t,children:[(0,r.jsx)("polyline",{points:"4 7 10 12 4 17"}),(0,r.jsx)("line",{x1:"12",y1:"17",x2:"20",y2:"17"})]}):"edit"===e?(0,r.jsxs)("svg",{...t,children:[(0,r.jsx)("path",{d:"M12 20h9"}),(0,r.jsx)("path",{d:"M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z"})]}):"read"===e?(0,r.jsxs)("svg",{...t,children:[(0,r.jsx)("path",{d:"M4 19.5V5a2 2 0 0 1 2-2h11.5a1.5 1.5 0 0 1 0 3H6"}),(0,r.jsx)("path",{d:"M6 6v15h12"})]}):"search"===e?(0,r.jsxs)("svg",{...t,children:[(0,r.jsx)("circle",{cx:"11",cy:"11",r:"7"}),(0,r.jsx)("path",{d:"m20 20-4-4"})]}):"agent"===e?(0,r.jsxs)("svg",{...t,children:[(0,r.jsx)("path",{d:"M12 8V4"}),(0,r.jsx)("rect",{x:"5",y:"8",width:"14",height:"11",rx:"3"}),(0,r.jsx)("path",{d:"M9 13h.01"}),(0,r.jsx)("path",{d:"M15 13h.01"}),(0,r.jsx)("path",{d:"M10 17h4"})]}):"thinking"===e?(0,r.jsxs)("svg",{...t,children:[(0,r.jsx)("path",{d:"M9 18h6"}),(0,r.jsx)("path",{d:"M10 22h4"}),(0,r.jsx)("path",{d:"M8.5 14.5a6 6 0 1 1 7 0c-.8.6-1.5 1.6-1.5 2.5h-4c0-.9-.7-1.9-1.5-2.5Z"})]}):"success"===e?(0,r.jsx)("svg",{...t,children:(0,r.jsx)("polyline",{points:"20 6 9 17 4 12"})}):"error"===e?(0,r.jsxs)("svg",{...t,children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,r.jsx)("path",{d:"m15 9-6 6"}),(0,r.jsx)("path",{d:"m9 9 6 6"})]}):"unknown"===e?(0,r.jsxs)("svg",{...t,children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,r.jsx)("path",{d:"M9.5 9a2.8 2.8 0 0 1 5 1.8c0 1.8-2.5 2.1-2.5 3.7"}),(0,r.jsx)("path",{d:"M12 18h.01"})]}):"chevron"===e?(0,r.jsx)("svg",{...t,children:(0,r.jsx)("polyline",{points:"8 10 12 14 16 10"})}):"running"===e?(0,r.jsxs)("svg",{...t,style:{animation:"spin 0.8s linear infinite"},children:[(0,r.jsx)("path",{d:"M21 12a9 9 0 0 1-9 9"}),(0,r.jsx)("path",{d:"M3 12a9 9 0 0 1 9-9"})]}):(0,r.jsxs)("svg",{...t,children:[(0,r.jsx)("path",{d:"M12 3v18"}),(0,r.jsx)("path",{d:"M3 12h18"}),(0,r.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})}function p(e){if(void 0===e)return null;if(e<60)return`~${e}s`;let t=Math.floor(e/60),n=e%60;return`~${t}m${n?` ${n}s`:""}`}function g({expanded:e,total:t,summary:n,runningDescription:i,onToggle:l}){return(0,r.jsxs)("button",{type:"button",onClick:l,"aria-expanded":e,title:e?"Collapse process":"Expand process",style:{width:"100%",minHeight:30,display:"flex",alignItems:"center",gap:8,border:"1px solid var(--border)",borderRadius:6,background:e?"var(--bg-panel)":"transparent",color:"var(--text-muted)",padding:"5px 8px",cursor:"pointer",textAlign:"left",minWidth:0},children:[(0,r.jsx)("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",minWidth:22,height:18,borderRadius:5,background:"var(--bg-selected)",color:"var(--text-muted)",fontSize:11,fontFamily:"var(--font-mono)",flexShrink:0},children:t}),(0,r.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,fontSize:12,flex:1},children:n}),i&&(0,r.jsx)("span",{title:i,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:220,minWidth:0,fontSize:11,flexShrink:1},children:i}),(0,r.jsx)("span",{style:{display:"inline-flex",color:"var(--text-dim)",flexShrink:0,transform:e?"rotate(180deg)":"none",transition:"transform 0.15s"},children:(0,r.jsx)(h,{name:"chevron"})})]})}function f({item:e,isStreaming:t=!1}){let n=p(e.duration);return(0,r.jsx)(a.pm,{content:e.content,durationLabel:n,isStreaming:t,leading:(0,r.jsx)("span",{style:{display:"inline-flex",color:"var(--text-dim)",flexShrink:0},children:(0,r.jsx)(h,{name:"thinking"})}),buttonStyle:{minHeight:28,padding:"5px 8px"}})}function m({item:e,cwd:t}){let[n,a]=(0,i.useState)(!1),d=e.tools.some(e=>"running"===e.status),c=e.tools.some(e=>"error"===e.status),u=e.tools.every(e=>"unknown"===e.status),p=d?"running":c?"error":u?"unknown":"success";return(0,r.jsxs)(o.t,{kind:"context-group",children:[(0,r.jsx)(s.V,{expanded:n,onToggle:()=>a(e=>!e),status:p,title:`${d?"Gathering context":"Gathered context"} (${e.tools.length})`,leading:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{style:{display:"inline-flex",color:(0,l.Gb)(p),flexShrink:0},children:(0,r.jsx)(h,{name:p})}),(0,r.jsx)("span",{style:{display:"inline-flex",color:"var(--text-dim)",flexShrink:0},children:(0,r.jsx)(h,{name:"read"})})]}),buttonStyle:{width:"100%",minHeight:28,display:"flex",alignItems:"center",gap:7,padding:"5px 8px",border:"none",background:"transparent",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",minWidth:0},titleStyle:{fontFamily:"inherit",fontWeight:400,fontSize:12}}),n&&(0,r.jsx)(o.p,{children:(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4,padding:"4px 6px 6px"},children:e.tools.map(e=>(0,r.jsx)(x,{item:e,cwd:t,nested:!0},e.tool.toolCallId))})})]})}function x({item:e,cwd:t,nested:n}){let i=p(e.duration);return(0,r.jsx)(d.Dm,{tool:e.tool,result:e.result,status:e.status,durationLabel:i,cwd:t,title:e.meta.label,summary:e.meta.summary,titleTooltip:e.tool.toolName,summaryTooltip:e.meta.summary,leading:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{style:{display:"inline-flex",color:(0,l.Gb)(e.status),flexShrink:0},children:(0,r.jsx)(h,{name:e.status})}),(0,r.jsx)("span",{style:{display:"inline-flex",color:"var(--text-dim)",flexShrink:0},children:(0,r.jsx)(h,{name:e.meta.kind})})]}),showCollapsedPreview:!1,showUnavailableWhenMissing:"unknown"===e.status,showInputBorderTop:!0,buttonStyle:{width:"100%",minHeight:28,display:"flex",alignItems:"center",gap:7,padding:"5px 8px",border:"none",background:"transparent",color:"var(--text-muted)",cursor:"pointer",textAlign:"left",minWidth:0},titleStyle:{color:"error"===e.status?"#f87171":"var(--text-muted)",maxWidth:120},containerStyle:{border:n?"1px solid color-mix(in srgb, var(--border) 70%, transparent)":"1px solid var(--border)",background:n?"var(--bg)":"var(--bg-panel)"}})}let y=g,v=f,b=m,w=x;var j=n(87559);let k=new Set(["read","read_file","readfile","search","grep","glob","find","find_files","ls","list","list_files"]),S=[];function C({tools:e,results:t,durations:n,thinkingBlocks:o=S,isStreaming:a,cwd:s}){let d,h,p,y,v=function(e=768){let[t,n]=(0,i.useState)(!1);return(0,i.useEffect)(()=>{let t=window.matchMedia(`(max-width: ${e}px)`),r=()=>n(t.matches);return r(),t.addEventListener?.("change",r),()=>t.removeEventListener?.("change",r)},[e]),t}(),b=(0,i.useMemo)(()=>{let r=[];return o.forEach((e,t)=>{r.push({type:"thinking",key:`thinking-${t}`,content:e.content,duration:e.duration})}),e.forEach(e=>{let i,o=t?.get(e.toolCallId);r.push({type:"tool",tool:e,result:o,status:(0,l.s2)(o,a),duration:n?.get(e.toolCallId),meta:{label:(i=(0,j.wS)(e)).label,summary:i.summary,kind:i.kind}})}),r},[n,a,t,o,e]),w=(0,i.useMemo)(()=>(function(e,t){let n=[],r=[],i=()=>{r.length>=3?n.push({type:"contextGroup",key:r.map(e=>e.tool.toolCallId).join(":"),tools:r}):n.push(...r),r=[]};for(let o of e){var l;if("tool"===o.type&&(l=o.tool,k.has((0,j.WI)(l.toolName)))&&(!t||"running"!==o.status)){r.push(o);continue}i(),n.push(o)}return i(),n})(b,a),[a,b]),L=b.filter(e=>"tool"===e.type),M=L.filter(e=>"running"===e.status),$=M.length>0,[E,W]=(0,i.useState)(null),z=!v&&(!!a||$),R=E??z,T=L.length+o.length,H=M[M.length-1]?.meta.summary;if(0===T)return null;let P=(d=L.filter(e=>"running"===e.status),h=L.filter(e=>"success"===e.status).length,p=L.filter(e=>"error"===e.status).length,y=L.filter(e=>"unknown"===e.status).length,[L.length>0?`${L.length} ${1===L.length?"tool":"tools"}`:null,o.length>0?`${o.length} ${1===o.length?"thought":"thoughts"}`:null,d.length>0?`${d.length} running`:null,h>0?`${h} completed`:null,p>0?`${p} failed`:null,y>0?`${y} unknown`:null].filter(Boolean));return(0,r.jsxs)(c,{children:[(0,r.jsx)(g,{expanded:R,total:T,summary:P.join(" \xb7 "),runningDescription:H,onToggle:()=>W(e=>!(e??z))}),R&&(0,r.jsx)(u,{children:w.map(e=>"thinking"===e.type?(0,r.jsx)(f,{item:e,isStreaming:!!a},e.key):"contextGroup"===e.type?(0,r.jsx)(m,{item:e,cwd:s},e.key):(0,r.jsx)(x,{item:e,cwd:s},e.tool.toolCallId))})]})}},99947:(e,t,n)=>{n.d(t,{NG:()=>o,oG:()=>s,iO:()=>a,Mi:()=>d});var r=n(95155),i=n(12115);function l({children:e,totalLines:t,className:n,collapsedMaxHeight:o="15.5rem",expandedMaxHeight:a,overlayBackground:s="var(--bg)",footerBackground:d="var(--bg-panel)"}){let[c,u]=(0,i.useState)(!1);return t<=20?(0,r.jsx)(r.Fragment,{children:e}):(0,r.jsxs)("div",{className:n,children:[(0,r.jsxs)("div",{style:{position:"relative",...c?{maxHeight:a,overflowY:a?"auto":"visible",overflowX:"hidden"}:{maxHeight:o,overflow:"hidden"}},children:[e,!c&&(0,r.jsx)("div",{style:{position:"absolute",insetInline:0,bottom:0,height:"3.5rem",background:`linear-gradient(to top, ${s} 0%, transparent 100%)`,pointerEvents:"none"}})]}),(0,r.jsx)("button",{type:"button",onClick:()=>u(e=>!e),"aria-expanded":c,style:{display:"flex",alignItems:"center",gap:4,width:"100%",minHeight:28,padding:"4px 8px",justifyContent:"center",background:d,border:"none",borderTop:"1px solid var(--border)",color:"var(--text-dim)",cursor:"pointer",fontSize:11},children:c?"Collapse":`Show all ${t} lines`})]})}function o({children:e,className:t,style:n}){return(0,r.jsx)("div",{className:t,style:{borderRadius:6,overflow:"hidden",border:"1px solid var(--border)",...n},children:e})}function a({title:e,actions:t,style:n}){return(0,r.jsxs)("div",{style:{padding:"3px 10px",background:"var(--bg-panel)",borderBottom:"1px solid var(--border)",fontSize:11,color:"var(--text-dim)",display:"flex",justifyContent:"space-between",alignItems:"center",gap:8,...n},children:[(0,r.jsx)("span",{children:e}),t?(0,r.jsx)("div",{style:{display:"flex",gap:8,alignItems:"center"},children:t}):null]})}function s({children:e,totalLines:t,expandedMaxHeight:n,overlayBackground:i,footerBackground:o}){return(0,r.jsx)(l,{totalLines:t,expandedMaxHeight:n,overlayBackground:i,footerBackground:o,children:e})}function d({onClick:e,label:t,activeLabel:n,active:i=!1,title:l,ariaLabel:o}){return(0,r.jsx)("button",{type:"button",onClick:e,title:l,"aria-label":o,style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:11},children:i&&n?n:t})}}}]);
|
|
File without changes
|
|
File without changes
|