tarsk 0.4.28 → 0.4.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +29 -25
- package/dist/public/assets/{account-view-DcpSNB3N.js → account-view-YvC0mymF.js} +1 -1
- package/dist/public/assets/alert-dialog-BFhUZsPe.js +1 -0
- package/dist/public/assets/api-DSvSyBH5.js +1 -0
- package/dist/public/assets/{browser-tab-CiAz6nc1.js → browser-tab-CCXMlmPO.js} +1 -1
- package/dist/public/assets/chat-input-container-VwmGKJFJ.js +21 -0
- package/dist/public/assets/codicon-ngg6Pgfi.ttf +0 -0
- package/dist/public/assets/context-menu-B6K8j1ha.js +1 -0
- package/dist/public/assets/conversation-history-view-DrrLyMbg.js +1 -0
- package/dist/public/assets/css.worker-DyDu5ynT.js +89 -0
- package/dist/public/assets/{dialogs-config-vkfELnGl.js → dialogs-config-B91VQpxo.js} +3 -3
- package/dist/public/assets/diff-view-C09yOc5d.js +3 -0
- package/dist/public/assets/explorer-tab-view-B1DukGdo.js +2 -0
- package/dist/public/assets/explorer-tree-DCeud6YI.js +1 -0
- package/dist/public/assets/{explorer-view-C0KcZ8NQ.js → explorer-view-BCJqE1-z.js} +1 -1
- package/dist/public/assets/history-view-Dj4NiScy.js +1 -0
- package/dist/public/assets/html.worker-IWNXhnIC.js +502 -0
- package/dist/public/assets/{index-Bdde81Uo.css → index-7TFkb0ll.css} +1 -1
- package/dist/public/assets/index-BLCecayZ.js +29 -0
- package/dist/public/assets/json.worker-c4h5s80L.js +58 -0
- package/dist/public/assets/markdown-renderer-9nzN0Pk3.js +10 -0
- package/dist/public/assets/mcp-server-card-BSw_FlEC.js +1 -0
- package/dist/public/assets/monaco-BGyhgQtx.js +1209 -0
- package/dist/public/assets/monaco-Br_kD0ds.css +1 -0
- package/dist/public/assets/onboarding-ClUE_I5q.js +1 -0
- package/dist/public/assets/onboarding-dialog-C2jig8mT.js +1 -0
- package/dist/public/assets/page-toolbar-DnVFnCgq.js +1 -0
- package/dist/public/assets/{project-settings-view-CxD9JZoB.js → project-settings-view-DWn0ty7b.js} +1 -1
- package/dist/public/assets/providers-list-view-B0DqNJYK.js +1 -0
- package/dist/public/assets/radio-group-CM_Wwam0.js +1 -0
- package/dist/public/assets/react-vendor-nPkCWaAR.js +22 -0
- package/dist/public/assets/{resizable-dToeUeVD.js → resizable-CEv7JjTI.js} +1 -1
- package/dist/public/assets/{run-stop-button-DZ4JFwdL.js → run-stop-button-CrjPMC0m.js} +2 -2
- package/dist/public/assets/settings-general-view-CwQYmnI2.js +1 -0
- package/dist/public/assets/{settings-instructions-view-DWzAH2yN.js → settings-instructions-view-C23spY9Y.js} +1 -1
- package/dist/public/assets/{settings-mcp-servers-view-q6gGMMVX.js → settings-mcp-servers-view-ZHar6YbE.js} +4 -4
- package/dist/public/assets/{settings-models-view-BDDFQWWC.js → settings-models-view-Cg6WQ4cy.js} +1 -1
- package/dist/public/assets/settings-rules-view-zAx5JL4w.js +8 -0
- package/dist/public/assets/{settings-skills-view-DV40_L1o.js → settings-skills-view-D60tD-OE.js} +2 -2
- package/dist/public/assets/{settings-slash-commands-view-BEk3BgOY.js → settings-slash-commands-view-DR-pzulT.js} +1 -1
- package/dist/public/assets/settings-subagents-view-InXmwmw9.js +2 -0
- package/dist/public/assets/settings-view-DLRDBuwH.js +2 -0
- package/dist/public/assets/side-panel-container-CO3qgRvc.js +2 -0
- package/dist/public/assets/skeleton-CXoVAzC1.js +1 -0
- package/dist/public/assets/standard-list-item-DyALhVYe.js +1 -0
- package/dist/public/assets/store-D28g9VUj.js +4 -0
- package/dist/public/assets/{tab-context-DWD20a4z.js → tab-context-C3z7YU59.js} +1 -1
- package/dist/public/assets/tabs-sXgL2DZz.js +1 -0
- package/dist/public/assets/{terminal-panel-CkIe2d2K.js → terminal-panel-EifoA6G0.js} +2 -2
- package/dist/public/assets/textarea-Bp3p1-25.js +1 -0
- package/dist/public/assets/todos-view-DRL4px6A.js +1 -0
- package/dist/public/assets/ts.worker-BwM5Ha3L.js +67719 -0
- package/dist/public/assets/use-font-size-BCtvz0bm.js +1 -0
- package/dist/public/assets/{use-toast-yY7qQuQP.js → use-toast-BZ79E_dX.js} +1 -1
- package/dist/public/assets/{utils-BKss67Vg.js → utils-Bhu11Tpg.js} +1 -1
- package/dist/public/assets/{whisper-wasm-B7iuRPFr.js → whisper-wasm-C_Ot631g.js} +1 -1
- package/dist/public/index.html +24 -22
- package/package.json +1 -1
- package/dist/public/assets/alert-dialog-CQRWdGnn.js +0 -1
- package/dist/public/assets/api-CH5gAPs5.js +0 -1
- package/dist/public/assets/chat-input-container-C6U_WFFu.js +0 -21
- package/dist/public/assets/context-menu-A9p22S7d.js +0 -1
- package/dist/public/assets/conversation-history-view-CD_uVRNY.js +0 -1
- package/dist/public/assets/diff-view-CjbcDB6m.js +0 -3
- package/dist/public/assets/explorer-tab-view-BfycKUUW.js +0 -2
- package/dist/public/assets/explorer-tree-DTFYhczJ.js +0 -1
- package/dist/public/assets/history-view-Dn0hQIKU.js +0 -1
- package/dist/public/assets/index-DKQVo4Vz.js +0 -29
- package/dist/public/assets/markdown-renderer-CNuyXHcy.js +0 -10
- package/dist/public/assets/mcp-server-card-DBEBe3Qh.js +0 -1
- package/dist/public/assets/monaco-SWcefg0q.js +0 -11
- package/dist/public/assets/onboarding-DslO5AS6.js +0 -1
- package/dist/public/assets/onboarding-dialog-CE-GhoDt.js +0 -1
- package/dist/public/assets/page-toolbar-CloU_Kvo.js +0 -1
- package/dist/public/assets/providers-list-view-CNxVBJlM.js +0 -1
- package/dist/public/assets/radio-group-Co0Lg6se.js +0 -1
- package/dist/public/assets/react-vendor-DyE9sO8V.js +0 -22
- package/dist/public/assets/settings-rules-view-DsEwgDFr.js +0 -8
- package/dist/public/assets/settings-subagents-view-d3P4ylDX.js +0 -2
- package/dist/public/assets/settings-view-ClTMPafQ.js +0 -2
- package/dist/public/assets/side-panel-container-BAYoMt7B.js +0 -2
- package/dist/public/assets/skeleton-DveUQR4w.js +0 -1
- package/dist/public/assets/standard-list-item-BLlgm1qW.js +0 -1
- package/dist/public/assets/store-BcwWHqYr.js +0 -4
- package/dist/public/assets/tabs-CgvpwOBj.js +0 -1
- package/dist/public/assets/textarea-C2UIAa7y.js +0 -1
- package/dist/public/assets/todos-view-C-awG1dZ.js +0 -1
- /package/dist/public/assets/{dist-Bjt_i1zi.js → dist-D5DgwfYL.js} +0 -0
package/dist/index.js
CHANGED
|
@@ -2183,7 +2183,7 @@ async function invalidateThreadIndex(threadId) {
|
|
|
2183
2183
|
}
|
|
2184
2184
|
|
|
2185
2185
|
// src/tools/code-search.ts
|
|
2186
|
-
var DEFAULT_LIMIT3 =
|
|
2186
|
+
var DEFAULT_LIMIT3 = 30;
|
|
2187
2187
|
var codeSearchSchema = Type5.Object({
|
|
2188
2188
|
query: Type5.Optional(
|
|
2189
2189
|
Type5.String({
|
|
@@ -2197,7 +2197,7 @@ var codeSearchSchema = Type5.Object({
|
|
|
2197
2197
|
),
|
|
2198
2198
|
filePath: Type5.Optional(
|
|
2199
2199
|
Type5.String({
|
|
2200
|
-
description: "Search by file path pattern, e.g. 'camp.page.ts', 'src/app/camp', or 'src/**/camp/*.ts'. Supports glob wildcards (* and **). Returns
|
|
2200
|
+
description: "Search by file path pattern, e.g. 'camp.page.ts', 'src/app/camp', or 'src/**/camp/*.ts'. Supports glob wildcards (* and **). Returns file paths only, no content."
|
|
2201
2201
|
})
|
|
2202
2202
|
),
|
|
2203
2203
|
fileGlob: Type5.Optional(
|
|
@@ -2332,10 +2332,12 @@ function formatOutput(rows, tokens, regex, limit, multiline = false) {
|
|
|
2332
2332
|
const matchLimitReached = rows.length >= limit ? rows.length : void 0;
|
|
2333
2333
|
for (const { file_path, content } of rows) {
|
|
2334
2334
|
const matchingLines = regex ? findLinesByRegex(content, regex, multiline) : findLinesByTokens(content, tokens);
|
|
2335
|
+
if (matchingLines.length === 0) continue;
|
|
2336
|
+
outputLines.push(`${file_path}:`);
|
|
2335
2337
|
for (const { line, text } of matchingLines) {
|
|
2336
2338
|
const { text: truncated, wasTruncated } = truncateLine(text.replace(/\r/g, ""));
|
|
2337
2339
|
if (wasTruncated) linesTruncated = true;
|
|
2338
|
-
outputLines.push(
|
|
2340
|
+
outputLines.push(` ${line}: ${truncated}`);
|
|
2339
2341
|
}
|
|
2340
2342
|
}
|
|
2341
2343
|
return { outputLines, linesTruncated, matchLimitReached };
|
|
@@ -2443,24 +2445,15 @@ function createCodeSearchTool(cwd, threadId) {
|
|
|
2443
2445
|
if (filePath && !query && !pattern) {
|
|
2444
2446
|
const likePattern = filePathToLike(filePath);
|
|
2445
2447
|
const result = await db.execute(
|
|
2446
|
-
`SELECT file_path
|
|
2448
|
+
`SELECT file_path FROM code_files
|
|
2447
2449
|
WHERE thread_id = ?
|
|
2448
2450
|
AND file_path LIKE ? ESCAPE '\\'
|
|
2449
2451
|
LIMIT ? OFFSET ?`,
|
|
2450
2452
|
[threadId, likePattern, limit, offset]
|
|
2451
2453
|
);
|
|
2452
2454
|
const rows2 = result.rows;
|
|
2453
|
-
const
|
|
2454
|
-
|
|
2455
|
-
[],
|
|
2456
|
-
null,
|
|
2457
|
-
limit
|
|
2458
|
-
);
|
|
2459
|
-
if (outputLines2.length === 0) {
|
|
2460
|
-
const names = rows2.map((r) => r.file_path).join("\n");
|
|
2461
|
-
return buildResult(names ? names.split("\n") : [], false, void 0, limit, offset);
|
|
2462
|
-
}
|
|
2463
|
-
return buildResult(outputLines2, linesTruncated2, matchLimitReached2, limit, offset);
|
|
2455
|
+
const names = rows2.map((r) => r.file_path);
|
|
2456
|
+
return buildResult(names, false, void 0, limit, offset);
|
|
2464
2457
|
}
|
|
2465
2458
|
if (filePath && (query || pattern)) {
|
|
2466
2459
|
const likePattern = filePathToLike(filePath);
|
|
@@ -2490,7 +2483,7 @@ function createCodeSearchTool(cwd, threadId) {
|
|
|
2490
2483
|
const args2 = likeFilter ? [threadId, likeFilter] : [threadId];
|
|
2491
2484
|
const result = await db.execute(sql, args2);
|
|
2492
2485
|
const allRows = result.rows;
|
|
2493
|
-
const
|
|
2486
|
+
const fileGroups = [];
|
|
2494
2487
|
let linesTruncated2 = false;
|
|
2495
2488
|
let matchedFiles = 0;
|
|
2496
2489
|
for (const { file_path, content } of allRows) {
|
|
@@ -2499,10 +2492,18 @@ function createCodeSearchTool(cwd, threadId) {
|
|
|
2499
2492
|
matchedFiles++;
|
|
2500
2493
|
if (matchedFiles <= offset) continue;
|
|
2501
2494
|
if (matchedFiles > offset + limit) break;
|
|
2502
|
-
|
|
2503
|
-
|
|
2495
|
+
fileGroups.push({ filePath: file_path, lines: matchingLines });
|
|
2496
|
+
for (const { text } of matchingLines) {
|
|
2497
|
+
const { wasTruncated } = truncateLine(text.replace(/\r/g, ""));
|
|
2504
2498
|
if (wasTruncated) linesTruncated2 = true;
|
|
2505
|
-
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2501
|
+
const outputLines2 = [];
|
|
2502
|
+
for (const group of fileGroups) {
|
|
2503
|
+
outputLines2.push(`${group.filePath}:`);
|
|
2504
|
+
for (const { line, text } of group.lines) {
|
|
2505
|
+
const { text: truncated } = truncateLine(text.replace(/\r/g, ""));
|
|
2506
|
+
outputLines2.push(` ${line}: ${truncated}`);
|
|
2506
2507
|
}
|
|
2507
2508
|
}
|
|
2508
2509
|
const matchLimitReached2 = matchedFiles > offset + limit ? matchedFiles : void 0;
|
|
@@ -10825,6 +10826,9 @@ async function handleDeleteProject(c, projectManager) {
|
|
|
10825
10826
|
// src/features/projects/projects.open-with.ts
|
|
10826
10827
|
init_utils();
|
|
10827
10828
|
import open from "open";
|
|
10829
|
+
function formatOpenError(program, _rawError) {
|
|
10830
|
+
return `${program} could not be started. Maybe it is not installed.`;
|
|
10831
|
+
}
|
|
10828
10832
|
function validateProgram(program) {
|
|
10829
10833
|
if (!program) {
|
|
10830
10834
|
return "Program is required";
|
|
@@ -10876,7 +10880,7 @@ var OpenWithHandler = class {
|
|
|
10876
10880
|
} catch (error) {
|
|
10877
10881
|
const message = error instanceof Error ? error.message : String(error);
|
|
10878
10882
|
console.error("[openWith] open() error:", message);
|
|
10879
|
-
throw new Error(
|
|
10883
|
+
throw new Error(formatOpenError(program, error));
|
|
10880
10884
|
}
|
|
10881
10885
|
}
|
|
10882
10886
|
/**
|
|
@@ -11003,7 +11007,7 @@ async function handleOpenProject(c, projectManager) {
|
|
|
11003
11007
|
});
|
|
11004
11008
|
} catch (error) {
|
|
11005
11009
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
11006
|
-
return errorResponse(c, ErrorCodes.OPEN_PROGRAM_ERROR, errorMessage,
|
|
11010
|
+
return errorResponse(c, ErrorCodes.OPEN_PROGRAM_ERROR, errorMessage, 422);
|
|
11007
11011
|
}
|
|
11008
11012
|
}
|
|
11009
11013
|
|
|
@@ -17127,7 +17131,7 @@ async function handleOpenThread(c, threadManager) {
|
|
|
17127
17131
|
c,
|
|
17128
17132
|
ErrorCodes.OPEN_PROGRAM_ERROR,
|
|
17129
17133
|
`Unsupported program: ${program}`,
|
|
17130
|
-
|
|
17134
|
+
422
|
|
17131
17135
|
);
|
|
17132
17136
|
}
|
|
17133
17137
|
console.log(
|
|
@@ -17147,8 +17151,8 @@ async function handleOpenThread(c, threadManager) {
|
|
|
17147
17151
|
return errorResponse(
|
|
17148
17152
|
c,
|
|
17149
17153
|
ErrorCodes.OPEN_PROGRAM_ERROR,
|
|
17150
|
-
|
|
17151
|
-
|
|
17154
|
+
formatOpenError(program, openError),
|
|
17155
|
+
422
|
|
17152
17156
|
);
|
|
17153
17157
|
}
|
|
17154
17158
|
return successResponse(c, { success: true, message: `Thread opened in ${program}` });
|
|
@@ -17158,7 +17162,7 @@ async function handleOpenThread(c, threadManager) {
|
|
|
17158
17162
|
c,
|
|
17159
17163
|
ErrorCodes.OPEN_PROGRAM_ERROR,
|
|
17160
17164
|
"Failed to open thread",
|
|
17161
|
-
|
|
17165
|
+
422,
|
|
17162
17166
|
errorMessage
|
|
17163
17167
|
);
|
|
17164
17168
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{
|
|
1
|
+
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$i as t,Mr as n,Qt as r,Un as i,nt as a,pa as o,wa as s,wi as c}from"./dialogs-config-B91VQpxo.js";import{t as l}from"./use-toast-BZ79E_dX.js";import{t as u}from"./skeleton-CXoVAzC1.js";var d=e(s(),1),f=n();function p(){let[e,n]=(0,d.useState)(null),[s,p]=(0,d.useState)(!0);(0,d.useEffect)(()=>{m();let e=()=>{document.visibilityState===`visible`&&m()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]);async function m(){p(!0);try{n(await a())}catch(e){l({title:`Error`,description:e instanceof Error?e.message:`Failed to load account info`,variant:`destructive`})}finally{p(!1)}}function h(){r(`https://buy.stripe.com/14AcN6feK0Jjbheb2H3Nm03?client_reference_id=${e?.clientReferenceId??``}`)}function g(){r(`https://buy.stripe.com/9B67sMd6CgIh70Y0o33Nm04?client_reference_id=${e?.clientReferenceId??``}`)}if(s)return(0,f.jsxs)(`div`,{className:`max-w-2xl mx-auto p-6`,children:[(0,f.jsxs)(`div`,{className:`mb-6`,children:[(0,f.jsx)(u,{className:`h-8 w-32 mb-2`}),(0,f.jsx)(u,{className:`h-4 w-64`})]}),(0,f.jsxs)(`div`,{className:`space-y-6`,children:[(0,f.jsxs)(`div`,{className:`flex gap-4`,children:[(0,f.jsxs)(`div`,{className:`flex-1 rounded-xl border bg-card p-5 space-y-2`,children:[(0,f.jsx)(u,{className:`h-4 w-20`}),(0,f.jsx)(u,{className:`h-9 w-28`})]}),(0,f.jsxs)(`div`,{className:`flex-1 rounded-xl border bg-card p-5 space-y-3`,children:[(0,f.jsx)(u,{className:`h-4 w-24`}),(0,f.jsx)(u,{className:`h-6 w-32`}),(0,f.jsx)(u,{className:`h-4 w-full`})]})]}),(0,f.jsxs)(`div`,{className:`space-y-3`,children:[(0,f.jsx)(u,{className:`h-4 w-24`}),(0,f.jsxs)(`div`,{className:`rounded-xl border bg-card p-5 flex items-center justify-between gap-4`,children:[(0,f.jsxs)(`div`,{className:`space-y-1 flex-1`,children:[(0,f.jsx)(u,{className:`h-5 w-28`}),(0,f.jsx)(u,{className:`h-4 w-64`})]}),(0,f.jsx)(u,{className:`h-9 w-28 shrink-0`})]}),(0,f.jsxs)(`div`,{className:`rounded-xl border bg-card p-5 flex items-center justify-between gap-4`,children:[(0,f.jsxs)(`div`,{className:`space-y-1 flex-1`,children:[(0,f.jsx)(u,{className:`h-5 w-36`}),(0,f.jsx)(u,{className:`h-4 w-56`}),(0,f.jsx)(u,{className:`h-4 w-32`})]}),(0,f.jsx)(u,{className:`h-9 w-24 shrink-0`})]})]})]})]});let _=e?.plan===`unlimited-pro`;return(0,f.jsxs)(`div`,{className:`max-w-2xl mx-auto p-6`,children:[(0,f.jsxs)(`div`,{className:`mb-6`,children:[(0,f.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Account`}),(0,f.jsx)(`p`,{className:`text-muted-foreground`,children:`Manage your Tarsk plan and prompt balance.`})]}),(0,f.jsxs)(`div`,{className:`space-y-6`,children:[(0,f.jsxs)(`div`,{className:`flex gap-4`,children:[(0,f.jsxs)(`div`,{className:`flex-1 rounded-xl border bg-card p-5 space-y-2`,children:[(0,f.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-muted-foreground`,children:[(0,f.jsx)(c,{className:`h-4 w-4`}),`Balance`]}),(0,f.jsx)(`div`,{className:`flex items-end gap-2`,children:_?(0,f.jsx)(`span`,{className:`text-3xl font-bold`,children:`Unlimited`}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`span`,{className:`text-3xl font-bold`,children:e?.promptsRemaining.toLocaleString()??0}),(0,f.jsx)(`span`,{className:`text-muted-foreground mb-1 text-sm`,children:`prompts remaining`})]})})]}),(0,f.jsxs)(`div`,{className:`flex-1 rounded-xl border bg-card p-5 space-y-3`,children:[(0,f.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-muted-foreground`,children:[(0,f.jsx)(t,{className:`h-4 w-4`}),`Current Plan`]}),(0,f.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,f.jsx)(`span`,{className:`text-lg font-semibold`,children:_?`Unlimited Pro`:`Pay as you go`}),_&&(0,f.jsx)(`span`,{className:`rounded-full bg-primary/10 px-2 py-0.5 text-xs font-medium text-primary`,children:`Active`})]}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:_?`You have unlimited prompts with no restrictions.`:`Purchase prompts as needed. Upgrade to Pro for unlimited access.`})]})]}),!_&&(0,f.jsxs)(`div`,{className:`space-y-3`,children:[(0,f.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wide`,children:`Add Prompts`}),(0,f.jsxs)(`div`,{className:`rounded-xl border bg-card p-5 flex items-center justify-between gap-4`,children:[(0,f.jsxs)(`div`,{className:`space-y-1`,children:[(0,f.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,f.jsx)(`span`,{className:`font-semibold`,children:`1,000 Prompts`})}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Top up your balance with 1,000 additional prompts for $5.`})]}),(0,f.jsx)(i,{onClick:h,className:`shrink-0`,children:`Top Up Balance`})]}),(0,f.jsxs)(`div`,{className:`rounded-xl border bg-card p-5 flex items-center justify-between gap-4`,children:[(0,f.jsxs)(`div`,{className:`space-y-1`,children:[(0,f.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,f.jsx)(t,{className:`h-4 w-4 text-primary`}),(0,f.jsx)(`span`,{className:`font-semibold`,children:`Unlimited Pro Plan`})]}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Unlimited prompts for $100 and lifetime access to Tarsk.`}),(0,f.jsxs)(`ul`,{className:`text-sm text-muted-foreground space-y-0.5`,children:[(0,f.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,f.jsx)(o,{className:`h-3 w-3 text-primary`}),`Unlimited prompts`]}),(0,f.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,f.jsx)(o,{className:`h-3 w-3 text-primary`}),`Priority access`]})]})]}),(0,f.jsx)(i,{onClick:g,className:`shrink-0`,children:`Purchase`})]})]})]})]})}export{p as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$n as t,Mr as n,Sa as r,Wn as i,wa as a}from"./dialogs-config-B91VQpxo.js";import{_t as o,dt as s,ft as c,gt as l,ht as u,mt as d,pt as f,ut as p}from"./react-vendor-nPkCWaAR.js";var m=r(),h=e(a(),1),g=n(),_=l,v=u,y=h.forwardRef((e,n)=>{let r=(0,m.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=t(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==n||r[7]!==o?(s=(0,g.jsx)(d,{className:o,...a,ref:n}),r[5]=a,r[6]=n,r[7]=o,r[8]=s):s=r[8],s});y.displayName=d.displayName;var b=h.forwardRef((e,n)=>{let r=(0,m.c)(10),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,g.jsx)(y,{}),r[3]=o):o=r[3];let s;r[4]===i?s=r[5]:(s=t(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,i),r[4]=i,r[5]=s);let l;return r[6]!==a||r[7]!==n||r[8]!==s?(l=(0,g.jsxs)(v,{children:[o,(0,g.jsx)(c,{ref:n,className:s,...a})]}),r[6]=a,r[7]=n,r[8]=s,r[9]=l):l=r[9],l});b.displayName=c.displayName;var x=e=>{let n=(0,m.c)(8),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=t(`flex flex-col space-y-2 text-center sm:text-left`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,g.jsx)(`div`,{className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o};x.displayName=`AlertDialogHeader`;var S=e=>{let n=(0,m.c)(8),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=t(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,g.jsx)(`div`,{className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o};S.displayName=`AlertDialogFooter`;var C=h.forwardRef((e,n)=>{let r=(0,m.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let s;r[3]===i?s=r[4]:(s=t(`text-lg font-semibold`,i),r[3]=i,r[4]=s);let c;return r[5]!==a||r[6]!==n||r[7]!==s?(c=(0,g.jsx)(o,{ref:n,className:s,...a}),r[5]=a,r[6]=n,r[7]=s,r[8]=c):c=r[8],c});C.displayName=o.displayName;var w=h.forwardRef((e,n)=>{let r=(0,m.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=t(`text-sm text-muted-foreground`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==n||r[7]!==o?(s=(0,g.jsx)(f,{ref:n,className:o,...a}),r[5]=a,r[6]=n,r[7]=o,r[8]=s):s=r[8],s});w.displayName=f.displayName;var T=h.forwardRef((e,n)=>{let r=(0,m.c)(9),a,o;r[0]===e?(a=r[1],o=r[2]):({className:a,...o}=e,r[0]=e,r[1]=a,r[2]=o);let s;r[3]===a?s=r[4]:(s=t(i(),a),r[3]=a,r[4]=s);let c;return r[5]!==o||r[6]!==n||r[7]!==s?(c=(0,g.jsx)(p,{ref:n,className:s,...o}),r[5]=o,r[6]=n,r[7]=s,r[8]=c):c=r[8],c});T.displayName=p.displayName;var E=h.forwardRef((e,n)=>{let r=(0,m.c)(9),a,o;r[0]===e?(a=r[1],o=r[2]):({className:a,...o}=e,r[0]=e,r[1]=a,r[2]=o);let c;r[3]===a?c=r[4]:(c=t(i({variant:`outline`}),`mt-2 sm:mt-0`,a),r[3]=a,r[4]=c);let l;return r[5]!==o||r[6]!==n||r[7]!==c?(l=(0,g.jsx)(s,{ref:n,className:c,...o}),r[5]=o,r[6]=n,r[7]=c,r[8]=l):l=r[8],l});E.displayName=s.displayName;export{w as a,C as c,b as i,T as n,S as o,E as r,x as s,_ as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{An as e,Fn as t,In as n,Mn as r,Nn as i,Pn as a,jn as o}from"./dialogs-config-B91VQpxo.js";async function s(e,t){return r(`api/threads/${o(e)}/explorer?path=${encodeURIComponent(t)}`)}async function c(e,t){return r(`api/threads/${o(e)}/ai-file?path=${encodeURIComponent(t)}`)}async function l(e,t,r){return n(`api/threads/${o(e)}/ai-file`,{path:t,content:r})}async function u(t,n){return e(`api/threads/${o(t)}/explorer?path=${encodeURIComponent(n)}`)}async function d(e,t,n){return a(`api/threads/${o(e)}/explorer`,{path:t,newName:n})}async function f(e,n,r){return t(`api/threads/${o(e)}/explorer/file`,{dirPath:n,name:r})}function p(e,t){return`${i()}/api/threads/${o(e)}/explorer/media?path=${encodeURIComponent(t)}`}async function m(e,n,r){return t(`api/threads/${o(e)}/explorer/folder`,{dirPath:n,name:r})}export{p as a,l as c,c as i,m as n,s as o,u as r,d as s,f as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{
|
|
1
|
+
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Mr as t,Qt as n,Sa as r,Xi as i,Yr as a,bi as o,si as s,ti as c,wa as l}from"./dialogs-config-B91VQpxo.js";import{a as u}from"./store-D28g9VUj.js";import{n as d}from"./tab-context-C3z7YU59.js";import{t as f}from"./run-stop-button-CrjPMC0m.js";var p=r(),m=e(l(),1),h=t();function g(){let e=(0,p.c)(41),{devServerUrl:t,browserResetTrigger:r}=d(),{state:l}=u(),{selectedProjectId:g,projects:_}=l,v;if(e[0]!==_||e[1]!==g){let t;e[3]===g?t=e[4]:(t=e=>e.projectId===g,e[3]=g,e[4]=t),v=_.find(t),e[0]=_,e[1]=g,e[2]=v}else v=e[2];let y=v,[b,x]=(0,m.useState)(``),[S,C]=(0,m.useState)(``),[w,T]=(0,m.useState)(`desktop`),E=(0,m.useRef)(null),D;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(D=()=>{C(``),x(``),E.current&&(E.current.src=``)},e[5]=D):D=e[5];let O;e[6]===r?O=e[7]:(O=[r],e[6]=r,e[7]=O),(0,m.useEffect)(D,O);let k,A;e[8]===t?(k=e[9],A=e[10]):(k=()=>{t&&(x(t),C(t))},A=[t],e[8]=t,e[9]=k,e[10]=A),(0,m.useEffect)(k,A);let j;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>{let t=e.trim();t&&(!t.startsWith(`http://`)&&!t.startsWith(`https://`)&&(t=`http://`+t),x(t),C(t))},e[11]=j):j=e[11];let M=j,N;e[12]===b?N=e[13]:(N=e=>{e.key===`Enter`&&M(b)},e[12]=b,e[13]=N);let P=N,F;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>{if(E.current){let e=E.current.src;E.current.src=``,setTimeout(()=>{E.current&&(E.current.src=e)},0)}},e[14]=F):F=e[14];let I=F,L;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(L={desktop:{width:`100%`,height:`100%`},tablet:{width:`768px`,height:`1024px`},mobile:{width:`375px`,height:`667px`}},e[15]=L):L=e[15];let R=L[w],z;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>x(e.target.value),e[16]=z):z=e[16];let B;e[17]!==P||e[18]!==b?(B=(0,h.jsx)(`input`,{type:`text`,value:b,onChange:z,onKeyDown:P,placeholder:`Enter URL...`,className:`flex-1 px-4 py-1.5 text-sm bg-muted rounded-full border border-border outline-none focus:ring-1 focus:ring-ring font-mono`,spellCheck:!1}),e[17]=P,e[18]=b,e[19]=B):B=e[19];let V;e[20]===S?V=e[21]:(V=S&&(0,h.jsx)(`button`,{onClick:I,title:`Refresh page`,className:`p-1.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,children:(0,h.jsx)(s,{size:15})}),e[20]=S,e[21]=V);let H;e[22]!==w||e[23]!==S?(H=S&&(0,h.jsxs)(`div`,{className:`flex items-center bg-muted rounded-md p-0.5`,children:[(0,h.jsx)(`button`,{onClick:()=>T(`desktop`),title:`Desktop view`,className:`p-1.5 rounded transition-colors ${w===`desktop`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground hover:bg-background/50`}`,children:(0,h.jsx)(o,{size:15})}),(0,h.jsx)(`button`,{onClick:()=>T(`tablet`),title:`Tablet view`,className:`p-1.5 rounded transition-colors ${w===`tablet`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground hover:bg-background/50`}`,children:(0,h.jsx)(a,{size:15})}),(0,h.jsx)(`button`,{onClick:()=>T(`mobile`),title:`Mobile view`,className:`p-1.5 rounded transition-colors ${w===`mobile`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground hover:bg-background/50`}`,children:(0,h.jsx)(c,{size:15})})]}),e[22]=w,e[23]=S,e[24]=H):H=e[24];let U;e[25]===S?U=e[26]:(U=S&&(0,h.jsx)(`button`,{onClick:()=>void n(S),title:`Open in external browser`,className:`p-1.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,children:(0,h.jsx)(i,{size:15})}),e[25]=S,e[26]=U);let W;e[27]!==B||e[28]!==V||e[29]!==H||e[30]!==U?(W=(0,h.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border shrink-0`,children:[B,V,H,U]}),e[27]=B,e[28]=V,e[29]=H,e[30]=U,e[31]=W):W=e[31];let G;e[32]!==R||e[33]!==w||e[34]!==S||e[35]!==y||e[36]!==g?(G=S?(0,h.jsx)(`div`,{className:`flex-1 flex items-center justify-center bg-background`,children:w===`desktop`?(0,h.jsx)(`iframe`,{ref:E,src:S,className:`flex-1 w-full h-full border-none`,title:`Browser`}):(0,h.jsx)(`div`,{className:`bg-white border border-border rounded-lg shadow-lg overflow-hidden transition-all duration-200`,style:{width:R.width,height:R.height,maxWidth:`100%`,maxHeight:`100%`},children:(0,h.jsx)(`iframe`,{ref:E,src:S,className:`w-full h-full border-none`,title:`Browser`})})}):(0,h.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center gap-6 text-muted-foreground`,children:g&&y?.runCommand?(0,h.jsx)(f,{projectId:g,runCommand:y.runCommand,large:!0}):(0,h.jsx)(`p`,{className:`text-sm`,children:`Enter a URL to browse`})}),e[32]=R,e[33]=w,e[34]=S,e[35]=y,e[36]=g,e[37]=G):G=e[37];let K;return e[38]!==W||e[39]!==G?(K=(0,h.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[W,G]}),e[38]=W,e[39]=G,e[40]=K):K=e[40],K}export{g as BrowserTab};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$n as t,C as n,Ci as r,Di as i,Gr as a,It as o,Jn as s,Jr as c,Ki as l,Lr as u,Lt as d,Mi as f,Mr as p,Mt as m,Nn as h,Nt as g,O as _,Oi as v,On as y,Pi as b,Qn as x,Qr as S,Rr as C,Rt as w,Sa as T,Ui as E,Un as D,Vi as O,Wr as k,Wt as A,Xn as j,Xr as M,Yn as N,Zn as P,aa as F,ai as I,bn as ee,ca as L,d as te,et as R,gn as ne,h as re,ht as ie,ia as z,it as B,j as V,ki as H,kn as U,la as W,li as G,lt as K,ma as q,mi as J,mn as ae,nn as oe,ot as se,pa as ce,qi as le,qn as ue,rt as de,sa as fe,st as pe,ua as me,ui as he,va as ge,wa as _e,xn as ve,yi as ye,zi as be,zt as xe}from"./dialogs-config-B91VQpxo.js";import{$ as Se,Ct as Ce,G as we,H as Te,J as Ee,K as De,Q as Oe,U as ke,X as Ae,Z as je,et as Me,it as Ne,nt as Pe,q as Fe,rt as Ie,tt as Le}from"./react-vendor-nPkCWaAR.js";import{a as Re,l as ze,s as Be,t as Y,u as Ve}from"./store-D28g9VUj.js";import{c as He,s as Ue,u as We}from"./history-view-Dj4NiScy.js";import{n as Ge,t as Ke}from"./use-toast-BZ79E_dX.js";import{a as qe,c as Je,i as Ye,o as Xe,s as Ze,t as Qe}from"./alert-dialog-BFhUZsPe.js";import{n as $e}from"./tab-context-C3z7YU59.js";import{s as et}from"./onboarding-ClUE_I5q.js";import{i as tt,n as nt,r as rt,t as it}from"./whisper-wasm-C_Ot631g.js";import{n as at}from"./utils-Bhu11Tpg.js";var X=T(),Z=e(_e(),1),Q=p();function ot(e){let t=(0,X.c)(30),{node:n,level:r,renderNode:i,defaultOpen:a,indent:o,childContainerClassName:s,openState:c,onToggle:l,forceOpenIds:u}=e,d=!!(n.children&&n.children.length>0),f,p,m;if(t[0]!==a||t[1]!==u||t[2]!==d||t[3]!==r||t[4]!==n||t[5]!==l||t[6]!==c||t[7]!==i){f=u?.has(n.id)||(c[n.id]??a);let e;t[11]!==n.id||t[12]!==l?(e=()=>l(n.id),t[11]=n.id,t[12]=l,t[13]=e):e=t[13];let o=e;p=`min-w-0`,m=i(n,{isOpen:f,level:r,toggle:o,hasChildren:d}),t[0]=a,t[1]=u,t[2]=d,t[3]=r,t[4]=n,t[5]=l,t[6]=c,t[7]=i,t[8]=f,t[9]=p,t[10]=m}else f=t[8],p=t[9],m=t[10];let h;t[14]!==s||t[15]!==a||t[16]!==u||t[17]!==d||t[18]!==o||t[19]!==f||t[20]!==r||t[21]!==n.children||t[22]!==l||t[23]!==c||t[24]!==i?(h=d&&f&&(0,Q.jsx)(`div`,{style:{paddingLeft:o},className:s,children:n.children.map(e=>(0,Q.jsx)(ot,{node:e,level:r+1,renderNode:i,defaultOpen:a,indent:o,childContainerClassName:s,openState:c,onToggle:l,forceOpenIds:u},e.id))}),t[14]=s,t[15]=a,t[16]=u,t[17]=d,t[18]=o,t[19]=f,t[20]=r,t[21]=n.children,t[22]=l,t[23]=c,t[24]=i,t[25]=h):h=t[25];let g;return t[26]!==p||t[27]!==m||t[28]!==h?(g=(0,Q.jsxs)(`div`,{className:p,children:[m,h]}),t[26]=p,t[27]=m,t[28]=h,t[29]=g):g=t[29],g}function st(e){let n=(0,X.c)(27),{nodes:r,renderNode:i,resetKey:a,defaultOpen:o,forceOpenIds:s,indent:c,childContainerClassName:l,className:u}=e,d=o===void 0?!1:o,f=c===void 0?16:c,p;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(p={},n[0]=p):p=n[0];let[m,h]=(0,Z.useState)(p),[g,_]=(0,Z.useState)(a);a!==g&&(_(a),h({}));let v;n[1]===s?v=n[2]:(v=s?new Set(s):void 0,n[1]=s,n[2]=v);let y=v,b;n[3]===d?b=n[4]:(b=e=>{h(t=>({...t,[e]:!(t[e]??d)}))},n[3]=d,n[4]=b);let x=b,S;n[5]===u?S=n[6]:(S=t(`min-w-0`,u),n[5]=u,n[6]=S);let C;if(n[7]!==l||n[8]!==d||n[9]!==y||n[10]!==x||n[11]!==f||n[12]!==r||n[13]!==m||n[14]!==i){let e;n[16]!==l||n[17]!==d||n[18]!==y||n[19]!==x||n[20]!==f||n[21]!==m||n[22]!==i?(e=e=>(0,Q.jsx)(ot,{node:e,level:0,renderNode:i,defaultOpen:d,indent:f,childContainerClassName:l,openState:m,onToggle:x,forceOpenIds:y},e.id),n[16]=l,n[17]=d,n[18]=y,n[19]=x,n[20]=f,n[21]=m,n[22]=i,n[23]=e):e=n[23],C=r.map(e),n[7]=l,n[8]=d,n[9]=y,n[10]=x,n[11]=f,n[12]=r,n[13]=m,n[14]=i,n[15]=C}else C=n[15];let w;return n[24]!==S||n[25]!==C?(w=(0,Q.jsx)(`div`,{className:S,children:C}),n[24]=S,n[25]=C,n[26]=w):w=n[26],w}var ct=(0,Z.createContext)({todos:[],setTodos:()=>{}});function lt(e){let t=(0,X.c)(10),{children:n,threadId:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=[],t[0]=i):i=t[0];let[a,o]=(0,Z.useState)(i),s=(0,Z.useRef)(-1),c;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=(e,t)=>{t>=s.current&&(s.current=t,o(e))},t[1]=c):c=t[1];let l=c,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{s.current=-1,o([])},t[2]=u):u=t[2];let d;t[3]===r?d=t[4]:(d=[r],t[3]=r,t[4]=d),(0,Z.useEffect)(u,d);let f;t[5]===a?f=t[6]:(f={todos:a,setTodos:l},t[5]=a,t[6]=f);let p;return t[7]!==n||t[8]!==f?(p=(0,Q.jsx)(ct.Provider,{value:f,children:n}),t[7]=n,t[8]=f,t[9]=p):p=t[9],p}function ut(e){let t=[e.result,e.content],n=[];for(let e of t)if(typeof e==`string`)n.push(e);else if(Array.isArray(e))for(let t of e)typeof t==`object`&&t&&`text`in t&&typeof t.text==`string`&&n.push(t.text);for(let e of n){let t=e.trim();if(t.startsWith(`{`))try{let e=JSON.parse(t);if(e&&Array.isArray(e.todos))return e.todos}catch(e){console.error(`Failed to parse todo JSON:`,e)}}return null}function dt(e){let t=(0,X.c)(5),{todos:n,sequence:r}=e,{setTodos:i}=(0,Z.useContext)(ct),a,o;return t[0]!==r||t[1]!==i||t[2]!==n?(a=()=>{i(n,r)},o=[n,i,r],t[0]=r,t[1]=i,t[2]=n,t[3]=a,t[4]=o):(a=t[3],o=t[4]),(0,Z.useEffect)(a,o),null}var ft=new Map,pt=new Map;function mt(e){return ft.get(e)}function ht(e,t){let n=pt.get(e);return n||(n=new Set,pt.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&pt.delete(e)}}function gt(e){let t=pt.get(e);if(t)for(let e of t)e()}function _t(e,t){return async function(n,r){let i=await fetch(e+`/api/browser-js/execute-tool`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({threadId:t,toolName:n,params:r})});if(!i.ok){let e=await i.text();try{let t=JSON.parse(e).error||{};e=t.details||t.message||e}catch{}return{text:null,error:`Tool `+n+` failed: `+e}}let a=await i.json();return{text:a.content&&a.content[0]?a.content[0].text:null,error:null}}}function vt(e,t,n){if(ft.has(e))return;ft.set(e,{status:`running`}),gt(e);let r=h();(async()=>{try{let i=_t(r,n),a=Object.getPrototypeOf(async function(){}).constructor,o=await new a(`callTool`,t)(i),s=o===void 0?null:o;ft.set(e,{status:`success`,result:s}),gt(e),await ee(e,s)}catch(t){let n=t instanceof Error?t.stack||t.message:String(t);ft.set(e,{status:`error`,error:n}),gt(e);try{await ee(e,{error:n})}catch(e){console.error(`[browser-js-executor] failed to submit error result`,e)}}})()}function yt({initialValue:e}={}){let{state:t,dispatch:n}=Re(),[r,i]=(0,Z.useState)(()=>{let n=t.selectedThreadId;return n&&t.chatInputDrafts[n]?t.chatInputDrafts[n]:e??``}),[a,o]=(0,Z.useState)(-1),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(0),d=(0,Z.useRef)(r);(0,Z.useEffect)(()=>{d.current=r},[r]);let f=(0,Z.useRef)(t.chatInputDrafts);(0,Z.useEffect)(()=>{f.current=t.chatInputDrafts},[t.chatInputDrafts]);let p=(0,Z.useRef)(!0);(0,Z.useEffect)(()=>(p.current=!0,()=>{p.current=!1}),[]);let[h,g]=(0,Z.useState)([]),[v,b]=(0,Z.useState)(()=>(t.selectedThreadId?t.projectModelSelections[t.selectedThreadId]:void 0)??null),x=(0,Z.useRef)(v?.id??``),S=(0,Z.useRef)(v?.provider??``),C=(0,Z.useRef)(null),[w,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)([]),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(!1),[P,F]=(0,Z.useState)(!1),[I,ee]=(0,Z.useState)([]),[L,te]=(0,Z.useState)(null),[R,ne]=(0,Z.useState)([]),[re,ie]=(0,Z.useState)(!1),[z,V]=(0,Z.useState)(``),[H,U]=(0,Z.useState)(0),[W,G]=(0,Z.useState)([]),[K,q]=(0,Z.useState)([]),[J,ae]=(0,Z.useState)(!1),[oe,ce]=(0,Z.useState)(``),le=(0,Z.useRef)(null),ue=(0,Z.useRef)(null),fe=(0,Z.useRef)(null),pe=(0,Z.useRef)(null),me=(0,Z.useRef)(null),he=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{x.current=v?.id??``,S.current=v?.provider??``},[v?.id,v?.provider]);let ge=(0,Z.useCallback)((e,r)=>{b(e);let i=t.selectedThreadId;if(!i||(n({type:Y.SetProjectModel,threadId:i,model:e}),r?.persist===!1))return;let a=`${i}:${e.provider??``}:${e.id}`;C.current!==a&&(C.current=a,console.log(`[useChatInputState] Persisting model to thread:`,{threadId:i,model:{id:e.id,provider:e.provider}}),y(i,{model:e.id,modelProvider:e.provider}).then(()=>{C.current===a&&(C.current=null),console.log(`[useChatInputState] Model persisted successfully`)}).catch(e=>{C.current===a&&(C.current=null),console.error(`Failed to save model to thread:`,e)}))},[t.selectedThreadId,n]);(0,Z.useEffect)(()=>{(async()=>{let e=t.selectedProjectId?t.projects.find(e=>e.projectId===t.selectedProjectId)?.threads.find(e=>e.threadId===t.selectedThreadId):void 0,n=t.selectedThreadId?t.projectModelSelections[t.selectedThreadId]:void 0,r=e?.model??n?.id??null,i=e?.modelProvider??n?.provider??null;console.log(`[useChatInputState] Loading models for thread:`,{threadId:t.selectedThreadId,projectId:t.selectedProjectId,currentThread:e?{model:e.model,modelProvider:e.modelProvider}:void 0,storedModel:n?{id:n.id,provider:n.provider}:void 0,savedModelId:r,savedModelProvider:i});try{let e=await B(),t=Object.values(e).flat();if(t.length===0){g([]),b(null);return}g(t);let n=r&&i?t.find(e=>e.id===r&&e.provider===i)??null:null,a=t[0],o=n??a,s=!n&&!!(r||i),c=x.current===o.id&&S.current===o.provider;console.log(`[useChatInputState] Model selection decision:`,{matchedSavedModel:n?{id:n.id}:null,fallbackModel:{id:a.id},modelToSelect:{id:o.id},shouldPersistFallback:s,hasSameSelection:c,currentSelected:{id:x.current,provider:S.current}}),c||ge(o,{persist:s})}catch(e){console.error(`Failed to load enabled models:`,e)}})()},[t.selectedThreadId,t.selectedProjectId,t.projects,ge]);let _e=(0,Z.useRef)(ge);(0,Z.useEffect)(()=>{_e.current=ge},[ge]),(0,Z.useEffect)(()=>{t.configUpdatedAt!==0&&(async()=>{try{let e=await B(),t=Object.values(e).flat();if(t.length>0){g(t);let e=x.current,n=S.current;t.some(t=>t.id===e&&t.provider===n)||_e.current(t[0],{persist:!0})}}catch(e){console.error(`Failed to reload enabled models:`,e)}})()},[t.configUpdatedAt]),(0,Z.useEffect)(()=>{!P||I.length>0||(async()=>{try{let e=await de(),t=Object.values(e).flat();t.length>0&&(ee(t),te(e=>e??t[0]))}catch(e){console.error(`Failed to load image models:`,e)}})()},[P,I.length]);let[ve,ye]=(0,Z.useState)(t.selectedThreadId);return(0,Z.useEffect)(()=>{if(t.selectedThreadId!==ve){ve&&d.current.trim()&&f.current[ve]!==d.current&&n({type:Y.SetChatInputDraft,threadId:ve,draft:d.current});let e=!1;return queueMicrotask(()=>{e||!p.current||(ye(t.selectedThreadId),i(t.selectedThreadId?f.current[t.selectedThreadId]??``:``),ne([]),ie(!1),G([]),q([]),ae(!1),j(!1),F(!1),N(!1))}),()=>{e=!0}}},[t.selectedThreadId,ve]),(0,Z.useEffect)(()=>{t.selectedThreadId&&m(t.selectedThreadId).then(({commands:e,skills:t})=>{console.log(`Loaded slash commands:`,e,`skills:`,t),G(e),q(t)}).catch(e=>console.error(`Failed to load slash commands and skills:`,e))},[t.selectedThreadId]),(0,Z.useEffect)(()=>{t.focusChatInput&&t.selectedThreadId&&!t.isStreaming&&(ue.current?.focus(),n({type:Y.ClearFocusChatInput}))},[t.focusChatInput,t.selectedThreadId,t.isStreaming,n]),(0,Z.useEffect)(()=>{let e=t.selectedThreadId;return()=>{e&&d.current.trim()&&f.current[e]!==d.current&&n({type:Y.SetChatInputDraft,threadId:e,draft:d.current})}},[t.selectedThreadId,n]),(0,Z.useEffect)(()=>{let e=e=>{fe.current&&!fe.current.contains(e.target)&&T(!1),pe.current&&!pe.current.contains(e.target)&&D(!1)};if(w||E)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[w,E]),{message:r,setMessage:i,historyIndex:a,setHistoryIndex:o,draftMessage:s,setDraftMessage:c,cursorPosition:l,setCursorPosition:u,availableModels:h,setAvailableModels:g,selectedModel:v,setSelectedModel:ge,selectedModelIdRef:x,showModelMenu:w,setShowModelMenu:T,showPlusMenu:E,setShowPlusMenu:D,attachments:O,setAttachments:k,planMode:A,setPlanMode:j,ralphMode:M,setRalphMode:N,imageMode:P,setImageMode:F,availableImageModels:I,setAvailableImageModels:ee,selectedImageModel:L,setSelectedImageModel:te,allFiles:R,setAllFiles:ne,showSuggestions:re,setShowSuggestions:ie,suggestionQuery:z,setSuggestionQuery:V,selectedIndex:H,setSelectedIndex:U,slashCommands:W,setSlashCommands:G,skills:K,setSkills:q,showCommandSuggestions:J,setShowCommandSuggestions:ae,commandQuery:oe,setCommandQuery:ce,fileInputRef:le,textareaRef:ue,modelMenuRef:fe,plusMenuRef:pe,suggestionsRef:me,commandSuggestionsRef:he,handleNewChat:async()=>{if(t.selectedThreadId)try{let e=await _(t.selectedThreadId);n({type:Y.ClearMessages}),console.log(`New conversation started:`,e);let r=await se(t.selectedThreadId);n({type:Y.SetMessages,messages:r.messages})}catch(e){console.error(`Failed to start new chat:`,e)}},state:t,dispatch:n}}var bt=e=>{te(e)};function xt(e){let t=(0,X.c)(102),{message:n,setMessage:r,attachments:i,selectedModel:a,onSend:s,isStreaming:c,selectedThreadId:l,isListening:u,stopListening:d,resetTranscript:f,dispatch:p,historyIndex:m,setHistoryIndex:h,draftMessage:g,setDraftMessage:_,cursorPosition:v,setCursorPosition:y,showSuggestions:b,setShowSuggestions:x,suggestionQuery:S,setSuggestionQuery:C,allFiles:w,setAllFiles:T,selectedIndex:E,setSelectedIndex:D,showCommandSuggestions:O,setShowCommandSuggestions:k,commandQuery:A,setCommandQuery:j,slashCommands:M,skills:N,textareaRef:P,setAttachments:F,planMode:I,setPlanMode:ee,ralphMode:L,setRalphMode:te,imageMode:R,setImageMode:ne,selectedImageModel:ie}=e,z;t[0]!==i||t[1]!==p||t[2]!==R||t[3]!==u||t[4]!==c||t[5]!==n||t[6]!==s||t[7]!==I||t[8]!==L||t[9]!==f||t[10]!==ie||t[11]!==a||t[12]!==l||t[13]!==F||t[14]!==_||t[15]!==h||t[16]!==r||t[17]!==d||t[18]!==P?(z=()=>{if(!n.trim()&&i.length===0||!l)return;let e=R?ie:a;e&&(u&&(d(),f()),c?p({type:Y.EnqueueChatMessage,message:{id:`queued-${Date.now()}`,threadId:l,message:n,model:e.id,attachments:i,provider:e.provider,planMode:I,imageMode:R,ralphMode:L}}):s(n,e.id,i,e.provider,I,R,L),bt(n),r(``),F([]),h(-1),_(``),l&&p({type:Y.ClearChatInputDraft,threadId:l}),P.current&&(P.current.style.height=`auto`))},t[0]=i,t[1]=p,t[2]=R,t[3]=u,t[4]=c,t[5]=n,t[6]=s,t[7]=I,t[8]=L,t[9]=f,t[10]=ie,t[11]=a,t[12]=l,t[13]=F,t[14]=_,t[15]=h,t[16]=r,t[17]=d,t[18]=P,t[19]=z):z=t[19];let B=z,V;t[20]!==v||t[21]!==n||t[22]!==r||t[23]!==x||t[24]!==S||t[25]!==P?(V=e=>{let t=n.substring(0,v-S.length-1);r(`${t}${e} ${n.substring(v)}`),x(!1),setTimeout(()=>{if(P.current){P.current.focus();let n=t.length+e.length+1;P.current.setSelectionRange(n,n)}},0)},t[20]=v,t[21]=n,t[22]=r,t[23]=x,t[24]=S,t[25]=P,t[26]=V):V=t[26];let H=V,U;t[27]!==A||t[28]!==v||t[29]!==n||t[30]!==ne||t[31]!==r||t[32]!==ee||t[33]!==te||t[34]!==k||t[35]!==P?(U=e=>{let t=n.substring(0,v-A.length-1),i=n.substring(v);r(`${t}${e.content}${i}`),k(!1),setTimeout(()=>{if(P.current){P.current.focus();let n=t.length+e.content.length;P.current.setSelectionRange(n,n)}},0),e.metadata.mode===`plan`?(ee(!0),te(!1),ne(!1)):e.metadata.mode===`ralph`&&(te(!0),ee(!1),ne(!1))},t[27]=A,t[28]=v,t[29]=n,t[30]=ne,t[31]=r,t[32]=ee,t[33]=te,t[34]=k,t[35]=P,t[36]=U):U=t[36];let W=U,G;t[37]!==A||t[38]!==v||t[39]!==n||t[40]!==r||t[41]!==k||t[42]!==P?(G=e=>{let t=n.substring(0,v-A.length-1),i=n.substring(v),a=e.name.includes(` `)?`/"${e.name}"`:`/${e.name}`;r(`${t}${a}${i}`),k(!1),setTimeout(()=>{if(P.current){P.current.focus();let e=t.length+a.length;P.current.setSelectionRange(e,e)}},0)},t[37]=A,t[38]=v,t[39]=n,t[40]=r,t[41]=k,t[42]=P,t[43]=G):G=t[43];let K=G,q,J,ae,oe;if(t[44]!==w||t[45]!==A||t[46]!==g||t[47]!==B||t[48]!==m||t[49]!==W||t[50]!==H||t[51]!==K||t[52]!==n||t[53]!==E||t[54]!==l||t[55]!==T||t[56]!==j||t[57]!==y||t[58]!==_||t[59]!==h||t[60]!==r||t[61]!==D||t[62]!==k||t[63]!==x||t[64]!==C||t[65]!==O||t[66]!==b||t[67]!==N||t[68]!==M||t[69]!==S){ae=e=>{if(O){if(e.key===`ArrowDown`){e.preventDefault(),D((E+1)%q.length);return}if(e.key===`ArrowUp`){e.preventDefault(),D((E-1+q.length)%q.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=q[E];t&&(t.type===`command`?W(t.data):K(t.data));return}if(e.key===`Escape`){k(!1);return}}if(b){let t=J.length>0;if(e.key===`ArrowDown`&&t){e.preventDefault(),D((E+1)%J.length);return}if(e.key===`ArrowUp`&&t){e.preventDefault(),D((E-1+J.length)%J.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),J[E]&&H(J[E]);return}if(e.key===`Escape`){x(!1);return}}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),B();return}let t=re();t.length!==0&&(e.key===`ArrowUp`?(e.preventDefault(),m===-1?(_(n),h(t.length-1),r(t[t.length-1])):m>0&&(h(m-1),r(t[m-1]))):e.key===`ArrowDown`&&(e.preventDefault(),m>0?(h(m-1),r(t[m-1])):m===0&&(h(-1),r(g))))};let e;t[74]!==w||t[75]!==l||t[76]!==T||t[77]!==j||t[78]!==y||t[79]!==r||t[80]!==D||t[81]!==k||t[82]!==x||t[83]!==C?(e=e=>{let t=e.target.value,n=e.target.selectionStart;r(t),y(n);let i=t.substring(0,n),a=i.lastIndexOf(`/`);if(a!==-1){let e=a>0?i[a-1]:``;if(a===0||/\s/.test(e)){let e=i.substring(a+1);e.includes(` `)?k(!1):(j(e),k(!0),x(!1),D(0))}else k(!1)}else{k(!1);let e=i.lastIndexOf(`#`);if(e!==-1){let t=e>0?i[e-1]:``;if(e===0||/\s/.test(t)){let t=i.substring(e+1);t.includes(` `)?x(!1):(C(t),x(!0),D(0),w.length===0&&l&&o(l).then(e=>{T(e)}).catch(wt))}else x(!1)}else x(!1)}let s=e.target;s.style.height=`auto`,s.style.height=`${Math.min(s.scrollHeight,160)}px`},t[74]=w,t[75]=l,t[76]=T,t[77]=j,t[78]=y,t[79]=r,t[80]=D,t[81]=k,t[82]=x,t[83]=C,t[84]=e):e=t[84],oe=e;let i;if(t[85]!==A||t[86]!==N||t[87]!==M){let e;t[89]===A?e=t[90]:(e=e=>e.name.toLowerCase().includes(A.toLowerCase()),t[89]=A,t[90]=e);let n=M.filter(e),r;t[91]===A?r=t[92]:(r=e=>e.name.toLowerCase().includes(A.toLowerCase()),t[91]=A,t[92]=r);let a=N.filter(r);i=[...n.map(Ct),...a.map(St)],t[85]=A,t[86]=N,t[87]=M,t[88]=i}else i=t[88];q=i.slice(0,10),J=b?w.filter(e=>e.toLowerCase().includes(S.toLowerCase())).slice(0,10):[],t[44]=w,t[45]=A,t[46]=g,t[47]=B,t[48]=m,t[49]=W,t[50]=H,t[51]=K,t[52]=n,t[53]=E,t[54]=l,t[55]=T,t[56]=j,t[57]=y,t[58]=_,t[59]=h,t[60]=r,t[61]=D,t[62]=k,t[63]=x,t[64]=C,t[65]=O,t[66]=b,t[67]=N,t[68]=M,t[69]=S,t[70]=q,t[71]=J,t[72]=ae,t[73]=oe}else q=t[70],J=t[71],ae=t[72],oe=t[73];let se;return t[93]!==q||t[94]!==J||t[95]!==ae||t[96]!==B||t[97]!==oe||t[98]!==W||t[99]!==H||t[100]!==K?(se={handleSend:B,handleKeyDown:ae,handleTextareaInput:oe,insertFileReference:H,insertCommand:W,insertSkill:K,allSuggestions:q,fileSuggestions:J},t[93]=q,t[94]=J,t[95]=ae,t[96]=B,t[97]=oe,t[98]=W,t[99]=H,t[100]=K,t[101]=se):se=t[101],se}function St(e){return{type:`skill`,data:e}}function Ct(e){return{type:`command`,data:e}}function wt(e){return console.error(`Failed to fetch files:`,e)}function Tt(e){let n=(0,X.c)(21),{visible:r,commands:i,skills:a,query:o,selectedIndex:s,onSelectCommand:l,onSelectSkill:d,onMouseEnterSuggestion:f,containerRef:p}=e;if(!r)return null;let m;if(n[0]!==i||n[1]!==o||n[2]!==a){let e;n[4]===o?e=n[5]:(e=e=>e.name.toLowerCase().includes(o.toLowerCase()),n[4]=o,n[5]=e);let t=i.filter(e),r;n[6]===o?r=n[7]:(r=e=>e.name.toLowerCase().includes(o.toLowerCase()),n[6]=o,n[7]=r);let s=a.filter(r);m=[...t.map(Dt),...s.map(Et)].slice(0,10),n[0]=i,n[1]=o,n[2]=a,n[3]=m}else m=n[3];let h=m,g;n[8]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Q.jsx)(c,{className:`h-3 w-3`}),n[8]=g):g=n[8];let _=o&&` matching "${o}"`,v;n[9]===_?v=n[10]:(v=(0,Q.jsxs)(`div`,{className:`px-2 py-1.5 text-xs font-semibold text-muted-foreground border-b border-border/50 mb-1 flex items-center gap-2`,children:[g,`Commands & Skills`,_]}),n[9]=_,n[10]=v);let y;n[11]!==h||n[12]!==f||n[13]!==l||n[14]!==d||n[15]!==s?(y=h.length>0?h.map((e,n)=>{let r=n===s;if(e.type===`command`){let i=e.data;return(0,Q.jsxs)(`button`,{type:`button`,className:t(`flex w-full flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors`,r?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>l(i),onMouseEnter:()=>f(n),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(c,{className:`h-3 w-3 text-muted-foreground`}),(0,Q.jsxs)(`span`,{className:`font-medium`,children:[`/`,i.name]}),i.metadata.argumentHint&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i.metadata.argumentHint}),i.scope===`project`&&(0,Q.jsx)(`span`,{className:`ml-auto text-[10px] rounded-full bg-primary/10 px-1.5 py-0.5 text-primary`,children:`project`})]}),i.metadata.description&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i.metadata.description})]},`cmd-${i.name}`)}else{let i=e.data;return(0,Q.jsxs)(`button`,{type:`button`,className:t(`flex w-full flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors`,r?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>d(i),onMouseEnter:()=>f(n),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(u,{className:`h-3 w-3 text-amber-500`}),(0,Q.jsxs)(`span`,{className:`font-medium`,children:[`/`,i.name]}),(0,Q.jsx)(`span`,{className:`ml-auto text-[10px] rounded-full bg-amber-500/10 px-1.5 py-0.5 text-amber-700 dark:text-amber-400`,children:`skill`}),i.scope===`project`&&(0,Q.jsx)(`span`,{className:`text-[10px] rounded-full bg-primary/10 px-1.5 py-0.5 text-primary`,children:`project`})]}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i.description})]},`skill-${i.name}`)}}):(0,Q.jsxs)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:[`No commands or skills found.`,(0,Q.jsx)(`br`,{}),(0,Q.jsxs)(`span`,{className:`text-[10px]`,children:[`Create commands in `,(0,Q.jsx)(`code`,{className:`bg-muted px-1 rounded`,children:`.agents/commands/`}),` or skills in `,(0,Q.jsx)(`code`,{className:`bg-muted px-1 rounded`,children:`.agents/skills/`})]})]}),n[11]=h,n[12]=f,n[13]=l,n[14]=d,n[15]=s,n[16]=y):y=n[16];let b;return n[17]!==p||n[18]!==v||n[19]!==y?(b=(0,Q.jsxs)(`div`,{ref:p,className:`absolute bottom-full left-0 mb-2 w-full max-h-64 overflow-y-auto rounded-xl border border-border bg-popover p-1 shadow-lg z-50 animate-in fade-in slide-in-from-bottom-2`,children:[v,y]}),n[17]=p,n[18]=v,n[19]=y,n[20]=b):b=n[20],b}function Et(e){return{type:`skill`,data:e}}function Dt(e){return{type:`command`,data:e}}function Ot(e){return e.startsWith(`image/`)}function kt(e){let t=(0,X.c)(7),{attachments:n,onRemove:r}=e;if(n.length===0)return null;let i;if(t[0]!==n||t[1]!==r){let e;t[3]===r?e=t[4]:(e=(e,t)=>(0,Q.jsx)(`div`,{className:`group relative flex items-center gap-1 rounded-md bg-muted text-xs text-muted-foreground`,children:Ot(e.mimeType)?(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.content}`,alt:e.fileName,className:`h-16 w-16 rounded-md object-cover`}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>r(t),className:`absolute -right-1.5 -top-1.5 flex h-4 w-4 items-center justify-center rounded-full bg-foreground text-background opacity-0 transition-opacity group-hover:opacity-100`,children:[(0,Q.jsx)(C,{className:`h-2.5 w-2.5`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Remove attachment`})]})]}):(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-1`,children:[(0,Q.jsx)(J,{className:`h-3 w-3`}),e.fileName,(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>r(t),className:`ml-1 hover:text-foreground`,children:[(0,Q.jsx)(C,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Remove attachment`})]})]})},t),t[3]=r,t[4]=e),i=n.map(e),t[0]=n,t[1]=r,t[2]=i}else i=t[2];let a;return t[5]===i?a=t[6]:(a=(0,Q.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,children:i}),t[5]=i,t[6]=a),a}function At(e,t){let n=e.target.files;if(!n||n.length===0)return;let r=Array.from(n),i=r.length,a=Array.from({length:i}),o=0;e.target.value=``,r.forEach((e,n)=>{let r=new FileReader;r.onload=()=>{let s=r.result.split(`,`)[1];a[n]={fileName:e.name,content:s,mimeType:e.type||`application/octet-stream`},o+=1,o===i&&t(a)},r.readAsDataURL(e)})}function jt(e){let n=(0,X.c)(16),{showSuggestions:r,fileSuggestions:i,suggestionQuery:a,selectedIndex:o,onSelectFile:s,onMouseEnterSuggestion:c,containerRef:u}=e;if(!r||i.length===0)return null;let d;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(I,{className:`h-3 w-3`}),n[0]=d):d=n[0];let f;n[1]===a?f=n[2]:(f=(0,Q.jsxs)(`div`,{className:`px-2 py-1.5 text-xs font-semibold text-muted-foreground border-b border-border/50 mb-1 flex items-center gap-2`,children:[d,`Files matching "`,a,`"`]}),n[1]=a,n[2]=f);let p;if(n[3]!==i||n[4]!==c||n[5]!==s||n[6]!==o){let e;n[8]!==c||n[9]!==s||n[10]!==o?(e=(e,n)=>{let r=e.split(`/`).pop()??e;return(0,Q.jsxs)(`button`,{type:`button`,className:t(`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm text-left transition-colors`,n===o?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>s(e),onMouseEnter:()=>c(n),children:[e.endsWith(`.ts`)||e.endsWith(`.tsx`)||e.endsWith(`.js`)||e.endsWith(`.jsx`)?(0,Q.jsx)(le,{className:`h-4 w-4 text-blue-500`}):(0,Q.jsx)(l,{className:`h-4 w-4 text-muted-foreground`}),(0,Q.jsxs)(`div`,{className:`flex flex-col overflow-hidden`,children:[(0,Q.jsx)(`span`,{className:`truncate font-medium`,children:r}),(0,Q.jsx)(`span`,{className:`truncate text-[10px] text-muted-foreground opacity-70`,children:e})]})]},e)},n[8]=c,n[9]=s,n[10]=o,n[11]=e):e=n[11],p=i.map(e),n[3]=i,n[4]=c,n[5]=s,n[6]=o,n[7]=p}else p=n[7];let m;return n[12]!==u||n[13]!==f||n[14]!==p?(m=(0,Q.jsxs)(`div`,{ref:u,className:`absolute bottom-full left-0 mb-2 w-full max-h-64 overflow-y-auto rounded-xl border border-border bg-popover p-1 shadow-lg z-50 animate-in fade-in slide-in-from-bottom-2`,children:[f,p]}),n[12]=u,n[13]=f,n[14]=p,n[15]=m):m=n[15],m}function Mt(e){let t=(0,X.c)(3),{provider:n}=e;if(!n)return null;let r=`https://models.tarsk.io/svg/${n}.svg`,i=`${n} logo`,a;return t[0]!==r||t[1]!==i?(a=(0,Q.jsx)(`img`,{src:r,alt:i,className:`h-3.5 w-3.5 flex-shrink-0 dark:invert`,onError:Nt}),t[0]=r,t[1]=i,t[2]=a):a=t[2],a}function Nt(e){e.currentTarget.style.visibility=`hidden`}function Pt(e){let t=(0,X.c)(26),{availableModels:n,selectedModel:r,onModelSelect:i}=e,[a,o]=Z.useState(!1),s=Z.useRef(null),c,l;t[0]===a?(c=t[1],l=t[2]):(c=()=>{let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)};if(a)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},l=[a],t[0]=a,t[1]=c,t[2]=l),Z.useEffect(c,l);let u;t[3]===i?u=t[4]:(u=e=>{i(e),o(!1)},t[3]=i,t[4]=u);let d=u,f;t[5]===a?f=t[6]:(f=()=>o(!a),t[5]=a,t[6]=f);let p=r?.provider,m;t[7]===p?m=t[8]:(m=(0,Q.jsx)(Mt,{provider:p}),t[7]=p,t[8]=m);let h;t[9]===r?h=t[10]:(h=r?et(r.id):`No model`,t[9]=r,t[10]=h);let g;t[11]===h?g=t[12]:(g=(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:h}),t[11]=h,t[12]=g);let _;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(W,{className:`h-3 w-3`}),t[13]=_):_=t[13];let v;t[14]!==f||t[15]!==m||t[16]!==g?(v=(0,Q.jsxs)(D,{variant:`action`,size:`icon-sm`,className:`gap-1 w-auto px-2`,onClick:f,children:[m,g,_]}),t[14]=f,t[15]=m,t[16]=g,t[17]=v):v=t[17];let y;t[18]!==n||t[19]!==d||t[20]!==r?.id||t[21]!==a?(y=a&&(0,Q.jsx)(`div`,{className:`absolute bottom-full left-0 mb-1 w-80 max-h-80 overflow-y-auto rounded-lg border border-border bg-popover p-1 shadow-md z-50`,children:Object.entries(n.reduce(Ft,{})).map(e=>{let[t,n]=e;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:[(0,Q.jsx)(Mt,{provider:t}),t]}),n.map(e=>(0,Q.jsx)(`button`,{type:`button`,className:`flex w-full items-center whitespace-nowrap rounded-md px-3 py-1.5 pl-8 text-sm text-popover-foreground hover:bg-accent ${e.id===r?.id?`bg-accent font-medium`:``}`,onClick:()=>d(e),children:et(e.id)},e.id))]},t)})}),t[18]=n,t[19]=d,t[20]=r?.id,t[21]=a,t[22]=y):y=t[22];let b;return t[23]!==v||t[24]!==y?(b=(0,Q.jsxs)(`div`,{className:`relative`,ref:s,children:[v,y]}),t[23]=v,t[24]=y,t[25]=b):b=t[25],b}function Ft(e,t){let n=t.provider??`Other`;return e[n]||(e[n]=[]),e[n].push(t),e}var It=[{value:`build`,label:`Build`,icon:b},{value:`plan`,label:`Plan`,icon:H},{value:`image`,label:`Image`,icon:f},{value:`ralph`,label:`Ralph`,icon:G}];function Lt(e,t,n){return n?`ralph`:e?`plan`:t?`image`:`build`}function Rt(e){let t=(0,X.c)(31),{planMode:n,imageMode:r,ralphMode:i,setPlanMode:a,setImageMode:o,setRalphMode:s}=e,[c,l]=Z.useState(!1),u=Z.useRef(null),d;t[0]!==r||t[1]!==n||t[2]!==i?(d=Lt(n,r,i),t[0]=r,t[1]=n,t[2]=i,t[3]=d):d=t[3];let f=d,p;t[4]===f?p=t[5]:(p=It.find(e=>e.value===f),t[4]=f,t[5]=p);let m=p,h=m.icon,g,_;t[6]===c?(g=t[7],_=t[8]):(g=()=>{let e=function(e){u.current&&!u.current.contains(e.target)&&l(!1)};if(c)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},_=[c],t[6]=c,t[7]=g,t[8]=_),Z.useEffect(g,_);let v;t[9]!==o||t[10]!==a||t[11]!==s?(v=function(e){a(e===`plan`),o(e===`image`),s(e===`ralph`),l(!1)},t[9]=o,t[10]=a,t[11]=s,t[12]=v):v=t[12];let y=v,b;t[13]===c?b=t[14]:(b=()=>l(!c),t[13]=c,t[14]=b);let x;t[15]===h?x=t[16]:(x=(0,Q.jsx)(h,{className:`h-3.5 w-3.5`}),t[15]=h,t[16]=x);let S;t[17]===m.label?S=t[18]:(S=(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:m.label}),t[17]=m.label,t[18]=S);let C;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Q.jsx)(W,{className:`h-3 w-3`}),t[19]=C):C=t[19];let w;t[20]!==b||t[21]!==x||t[22]!==S?(w=(0,Q.jsxs)(D,{variant:`action`,size:`icon-sm`,className:`gap-1 w-auto px-2`,onClick:b,children:[x,S,C]}),t[20]=b,t[21]=x,t[22]=S,t[23]=w):w=t[23];let T;t[24]!==f||t[25]!==c||t[26]!==y?(T=c&&(0,Q.jsx)(`div`,{className:`absolute bottom-full right-0 mb-1 w-40 rounded-lg border border-border bg-popover p-1 shadow-md z-50`,children:It.map(e=>{let t=e.icon,n=e.value===f;return(0,Q.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-sm text-popover-foreground hover:bg-accent`,onClick:()=>y(e.value),children:[(0,Q.jsx)(t,{className:`h-3.5 w-3.5`}),e.label,n&&(0,Q.jsx)(ce,{className:`ml-auto h-3.5 w-3.5`})]},e.value)})}),t[24]=f,t[25]=c,t[26]=y,t[27]=T):T=t[27];let E;return t[28]!==w||t[29]!==T?(E=(0,Q.jsxs)(`div`,{className:`relative`,ref:u,children:[w,T]}),t[28]=w,t[29]=T,t[30]=E):E=t[30],E}function zt(e){let t=(0,X.c)(17),{onFileAttach:n}=e,[r,i]=Z.useState(!1),a=Z.useRef(null),o,s;t[0]===r?(o=t[1],s=t[2]):(o=()=>{let e=e=>{a.current&&!a.current.contains(e.target)&&i(!1)};if(r)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},s=[r],t[0]=r,t[1]=o,t[2]=s),Z.useEffect(o,s);let c;t[3]===n?c=t[4]:(c=function(){n(),i(!1)},t[3]=n,t[4]=c);let l=c,u;t[5]===r?u=t[6]:(u=()=>i(!r),t[5]=r,t[6]=u);let d,f;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(he,{}),f=(0,Q.jsx)(`span`,{className:`sr-only`,children:`More options`}),t[7]=d,t[8]=f):(d=t[7],f=t[8]);let p;t[9]===u?p=t[10]:(p=(0,Q.jsxs)(D,{variant:`action`,size:`icon-sm`,onClick:u,children:[d,f]}),t[9]=u,t[10]=p);let m;t[11]!==l||t[12]!==r?(m=r&&(0,Q.jsx)(`div`,{className:`absolute bottom-full left-0 mb-1 w-48 rounded-lg border border-border bg-popover p-1 shadow-md z-50`,children:(0,Q.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-sm text-popover-foreground hover:bg-accent`,onClick:l,children:[(0,Q.jsx)(J,{className:`h-3.5 w-3.5`}),`Attach File`]})}),t[11]=l,t[12]=r,t[13]=m):m=t[13];let h;return t[14]!==p||t[15]!==m?(h=(0,Q.jsxs)(`div`,{className:`relative`,ref:a,children:[p,m]}),t[14]=p,t[15]=m,t[16]=h):h=t[16],h}var $=tt(`useWhisperSpeech`),Bt=`/api/voice-model/download`;function Vt(){let[e,t]=(0,Z.useState)(`idle`),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(0),m=(0,Z.useRef)(null),h=(0,Z.useRef)(null),g=(0,Z.useRef)(null),_=(0,Z.useRef)(null),v=(0,Z.useRef)(null),y=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{let e=!1;async function n(){t(`checking-support`),$.separator(`VOICE SESSION START`),$.info(`Checking WASM support`,{userAgent:navigator.userAgent,platform:navigator.platform});try{let n=new rt;m.current=n;let i=await n.checkWasmSupport();if(e)return;if($.info(`WASM SIMD support check result`,{supported:i}),r(i),!i){$.error(`WASM SIMD not supported — voice input disabled`),t(`error`),d(`WebAssembly SIMD is not supported in this environment.`);return}let o=new nt;h.current=o,$.info(`Checking IndexedDB model cache`,{url:Bt});try{let r=await o.loadModelByUrl(Bt);if(e||($.info(`Cached model found — initializing WASM`,{sizeBytes:r.byteLength,sizeMB:(r.byteLength/1024/1024).toFixed(2)}),a(!0),t(`initializing`),await n.initModel(r),e))return;$.info(`WASM model initialized from cache — ready`),t(`ready`)}catch(n){if(e)return;$.info(`Model not in cache — download required`,{reason:n instanceof Error?n.message:String(n)}),t(`needs-model`)}}catch(n){if(e)return;let r=n instanceof Error?n.message:`Unknown error`;$.error(`Failed to check speech recognition support`,{error:r}),t(`error`),d(`Failed to check speech recognition support: ${r}`)}}return n().catch(e=>{console.error(`Failed to check speech recognition support:`,e)}),()=>{e=!0,g.current&&g.current.getTracks().forEach(e=>e.stop())}},[]);let b=(0,Z.useCallback)(async()=>{if(!(!m.current||!h.current)){t(`downloading-model`),p(0),d(null),$.info(`Model download requested`,{url:Bt});try{let e=await h.current.loadModelByUrl(Bt,e=>{p(e),e%10==0&&$.debug(`Model download progress`,{progress:e})});$.info(`Model download complete — initializing WASM`,{sizeBytes:e.byteLength,sizeMB:(e.byteLength/1024/1024).toFixed(2)}),t(`initializing`),await m.current.initModel(e),$.info(`WASM model initialized after download — ready`),a(!0),t(`ready`)}catch(e){let n=e instanceof Error?e.message:`An unknown error occurred.`;$.error(`Model download or initialization failed`,{error:n}),t(`needs-model`),d(n)}}},[]),x=(0,Z.useCallback)(async()=>{if(!(!m.current||!i)){if(y.current=!1,t(`requesting-mic`),d(null),l(``),$.separator(`RECORDING START`),$.info(`Requesting microphone access`),!navigator.mediaDevices?.getUserMedia){$.error(`navigator.mediaDevices.getUserMedia not available in this environment`),t(`ready`),s(!1),d(`Microphone is not available in this environment.`);return}try{let e=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}),n=e.getAudioTracks();$.info(`Microphone access granted`,{trackCount:n.length,tracks:n.map(e=>({label:e.label,readyState:e.readyState,settings:e.getSettings()}))}),g.current=e,s(!0);let r=new AbortController;_.current=r,t(`recording`),$.info(`Recording started`),v.current=it(e,{signal:r.signal,recordingDurationMs:12e4,logLevel:0},{onError:e=>{$.error(`Audio conversion error during recording`,{error:e instanceof Error?e.message:String(e)})}})}catch(e){if(t(`ready`),e instanceof DOMException&&e.name===`NotAllowedError`)$.error(`Microphone access denied (NotAllowedError)`),s(!1),d(`Microphone access was denied. Please allow microphone access to use voice input.`);else if(e instanceof DOMException&&e.name===`NotFoundError`)$.error(`No microphone found (NotFoundError)`),s(!1),d(`No microphone was found. Please connect a microphone to use voice input.`);else{let t=e instanceof Error?e.message:`Unknown error`;$.error(`Microphone error`,{error:t,type:e instanceof DOMException?e.name:typeof e}),d(`Microphone error: ${t}`)}}}},[i]),S=(0,Z.useCallback)(async()=>{if(!v.current){$.info(`stopListening called but no active recording`),g.current&&=(g.current.getTracks().forEach(e=>e.stop()),null),i&&t(`ready`);return}$.info(`Stopping recording — waiting for audio data`),_.current?.abort(),t(`transcribing`);try{let e=await v.current;if(y.current){$.info(`Transcription cancelled by user`),t(`ready`);return}let n=(e.audioData.length/16e3).toFixed(2);$.info(`Audio capture complete — starting transcription`,{sampleCount:e.audioData.length,durationSec:n,sampleRate:16e3}),g.current&&=(g.current.getTracks().forEach(e=>e.stop()),null);let r=Date.now(),i=typeof SharedArrayBuffer<`u`?4:1,a=m.current.createSession().streaming(e.audioData,{language:`en`,threads:i,translate:!1}),o=``,s=0;for await(let e of a){if(y.current)break;s++,o+=e.text.trim()+` `,$.debug(`Transcription segment received`,{index:s,text:e.text,timeStart:e.timeStart,timeEnd:e.timeEnd}),l(o.trim())}$.info(`Transcription complete`,{segmentCount:s,durationMs:Date.now()-r,textLength:o.trim().length,text:o.trim().slice(0,100)}),t(`ready`)}catch(e){if(y.current){t(`ready`);return}let n=e instanceof Error?e.message:`Unknown transcription error`;if($.error(`Transcription failed`,{error:n,errorType:e instanceof Error?e.constructor.name:typeof e,stack:e instanceof Error?e.stack?.split(`
|
|
2
|
+
`).slice(0,5).join(` | `):void 0}),m.current&&n.includes(`Aborted`)){$.info(`WASM aborted — reinitializing model for next attempt`),t(`initializing`);try{await m.current.restartModel(),$.info(`WASM reinitialized successfully`)}catch(e){$.error(`WASM reinitialization failed`,{error:e instanceof Error?e.message:String(e)})}}t(`ready`),d(`Transcription failed: ${n}`)}finally{v.current=null,_.current=null}},[i]),C=(0,Z.useCallback)(()=>{l(``),d(null)},[]);return{state:e,isSupported:n===!0,isWasmSupported:n,isModelLoaded:i,isMicrophoneAvailable:o,transcript:c,error:u,downloadProgress:f,startListening:x,stopListening:S,requestModelDownload:b,resetTranscript:C}}var Ht=Z.forwardRef((e,n)=>{let r=(0,X.c)(13),i,a,o;r[0]===e?(i=r[1],a=r[2],o=r[3]):({className:i,value:o,...a}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o);let s;r[4]===i?s=r[5]:(s=t(`relative h-4 w-full overflow-hidden rounded-full bg-secondary`,i),r[4]=i,r[5]=s);let c=`translateX(-${100-(o||0)}%)`,l;r[6]===c?l=r[7]:(l=(0,Q.jsx)(Ie,{className:`h-full w-full flex-1 bg-primary transition-all`,style:{transform:c}}),r[6]=c,r[7]=l);let u;return r[8]!==a||r[9]!==n||r[10]!==s||r[11]!==l?(u=(0,Q.jsx)(Ne,{ref:n,className:s,...a,children:l}),r[8]=a,r[9]=n,r[10]=s,r[11]=l,r[12]=u):u=r[12],u});Ht.displayName=Ne.displayName;var Ut=75;function Wt(e){let t=(0,X.c)(11),{open:n,onOpenChange:r,onConfirm:i,downloading:a,progress:o,error:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsxs)(P,{children:[(0,Q.jsx)(x,{children:`Download Voice Model`}),(0,Q.jsxs)(N,{children:[`To enable voice-to-text, a voice model needs to be downloaded. This is a one-time download of approximately `,Ut,`MB. The model will be cached locally for future use.`]})]}),t[0]=l):l=t[0];let u;t[1]!==a||t[2]!==c||t[3]!==i||t[4]!==r||t[5]!==o?(u=(0,Q.jsxs)(s,{children:[l,a?(0,Q.jsxs)(`div`,{className:`space-y-3 py-4`,children:[(0,Q.jsx)(Ht,{value:o,className:`w-full`}),(0,Q.jsx)(`p`,{className:`text-center text-sm text-muted-foreground`,children:o<100?`Downloading model... ${o}%`:`Initializing model...`})]}):c?(0,Q.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md bg-destructive/10 p-3 text-sm text-destructive`,children:[(0,Q.jsx)(L,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,Q.jsx)(`p`,{children:c})]}),(0,Q.jsxs)(j,{children:[(0,Q.jsx)(D,{variant:`outline`,onClick:()=>r(!1),children:`Cancel`}),(0,Q.jsx)(D,{onClick:i,children:`Try Again`})]})]}):(0,Q.jsxs)(j,{children:[(0,Q.jsx)(D,{variant:`outline`,onClick:()=>r(!1),children:`Cancel`}),(0,Q.jsx)(D,{onClick:i,children:`Download Model`})]})]}),t[1]=a,t[2]=c,t[3]=i,t[4]=r,t[5]=o,t[6]=u):u=t[6];let d;return t[7]!==r||t[8]!==n||t[9]!==u?(d=(0,Q.jsx)(ue,{open:n,onOpenChange:r,children:u}),t[7]=r,t[8]=n,t[9]=u,t[10]=d):d=t[10],d}function Gt(e){let t=(0,X.c)(65),{onTranscript:n}=e,{state:a,isWasmSupported:o,transcript:s,error:c,downloadProgress:l,startListening:u,stopListening:d,requestModelDownload:f,resetTranscript:p}=Vt(),{toast:m}=Ge(),[h,g]=(0,Z.useState)(!1),_=(0,Z.useRef)(``),v=(0,Z.useRef)(null),y=a===`recording`,b=a===`transcribing`,x=y||b,S=a===`needs-model`,C=a===`downloading-model`||a===`initializing`,w=a===`checking-support`||a===`idle`,T,E;t[0]!==h||t[1]!==c||t[2]!==m?(T=()=>{c&&c!==v.current&&!h&&m({title:`Voice Input Error`,description:c,variant:`destructive`}),v.current=c},E=[c,h,m],t[0]=h,t[1]=c,t[2]=m,t[3]=T,t[4]=E):(T=t[3],E=t[4]),(0,Z.useEffect)(T,E);let O,k;t[5]!==n||t[6]!==s?(O=()=>{if(s&&s!==_.current){let e=s.substring(_.current.length);_.current=s,n(e)}},k=[s,n],t[5]=n,t[6]=s,t[7]=O,t[8]=k):(O=t[7],k=t[8]),(0,Z.useEffect)(O,k);let A,j;t[9]===s?(A=t[10],j=t[11]):(A=()=>{s||(_.current=``)},j=[s],t[9]=s,t[10]=A,t[11]=j),(0,Z.useEffect)(A,j);let M;t[12]!==x||t[13]!==S||t[14]!==p||t[15]!==u||t[16]!==a||t[17]!==d?(M=()=>{if(S){g(!0);return}x?d():a===`ready`&&(p(),u())},t[12]=x,t[13]=S,t[14]=p,t[15]=u,t[16]=a,t[17]=d,t[18]=M):M=t[18];let N=M,P;t[19]===f?P=t[20]:(P=()=>{f()},t[19]=f,t[20]=P);let F=P,I,ee;if(t[21]!==h||t[22]!==a?(ee=()=>{a===`ready`&&h&&g(!1)},I=[a,h],t[21]=h,t[22]=a,t[23]=I,t[24]=ee):(I=t[23],ee=t[24]),(0,Z.useEffect)(ee,I),w)return null;if(o===!1){let e;return t[25]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsxs)(Ue,{children:[(0,Q.jsx)(We,{asChild:!0,children:(0,Q.jsxs)(D,{variant:`ghost`,size:`icon-sm`,disabled:!0,className:`text-muted-foreground`,children:[(0,Q.jsx)(r,{className:`opacity-50`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Voice input not supported`})]})}),(0,Q.jsx)(He,{side:`top`,className:`bg-popover text-popover-foreground`,children:`Voice input not supported in this browser`})]}),t[25]=e):e=t[25],e}let L;t[26]!==c||t[27]!==C||t[28]!==y||t[29]!==b||t[30]!==S?(L=()=>c||(C?`Downloading speech model...`:b?`Transcribing...`:y?`Stop listening`:S?`Click to download speech model`:`Start listening`),t[26]=c,t[27]=C,t[28]=y,t[29]=b,t[30]=S,t[31]=L):L=t[31];let te=L,R;t[32]!==C||t[33]!==y||t[34]!==b?(R=()=>C||b?(0,Q.jsx)(i,{className:`animate-spin`}):y?(0,Q.jsxs)(`span`,{className:`recording-waveform`,"aria-hidden":!0,children:[(0,Q.jsx)(`span`,{className:`recording-waveform-bar`,style:{animationDelay:`0ms`}}),(0,Q.jsx)(`span`,{className:`recording-waveform-bar`,style:{animationDelay:`150ms`}}),(0,Q.jsx)(`span`,{className:`recording-waveform-bar`,style:{animationDelay:`75ms`}}),(0,Q.jsx)(`span`,{className:`recording-waveform-bar`,style:{animationDelay:`225ms`}})]}):(0,Q.jsx)(r,{}),t[32]=C,t[33]=y,t[34]=b,t[35]=R):R=t[35];let ne=R,re;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,Q.jsx)(`style`,{children:`
|
|
3
|
+
.recording-waveform {
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
gap: 2px;
|
|
7
|
+
height: 16px;
|
|
8
|
+
}
|
|
9
|
+
.recording-waveform-bar {
|
|
10
|
+
display: block;
|
|
11
|
+
width: 3px;
|
|
12
|
+
height: 4px;
|
|
13
|
+
border-radius: 2px;
|
|
14
|
+
background: currentColor;
|
|
15
|
+
animation: waveform-bounce 0.7s ease-in-out infinite alternate;
|
|
16
|
+
}
|
|
17
|
+
@keyframes waveform-bounce {
|
|
18
|
+
from { height: 3px; }
|
|
19
|
+
to { height: 14px; }
|
|
20
|
+
}
|
|
21
|
+
`}),t[36]=re):re=t[36];let ie=y?`bg-primary text-primary-foreground hover:bg-primary/90`:b?`text-muted-foreground`:`text-muted-foreground hover:text-background`,z=w||C||b,B;t[37]===ne?B=t[38]:(B=ne(),t[37]=ne,t[38]=B);let V;t[39]===te?V=t[40]:(V=te(),t[39]=te,t[40]=V);let H;t[41]===V?H=t[42]:(H=(0,Q.jsx)(`span`,{className:`sr-only`,children:V}),t[41]=V,t[42]=H);let U;t[43]!==N||t[44]!==ie||t[45]!==z||t[46]!==B||t[47]!==H?(U=(0,Q.jsx)(We,{asChild:!0,children:(0,Q.jsxs)(D,{variant:`ghost`,size:`icon-sm`,className:ie,onClick:N,disabled:z,children:[B,H]})}),t[43]=N,t[44]=ie,t[45]=z,t[46]=B,t[47]=H,t[48]=U):U=t[48];let W;t[49]===te?W=t[50]:(W=te(),t[49]=te,t[50]=W);let G;t[51]===W?G=t[52]:(G=(0,Q.jsx)(He,{side:`top`,className:`bg-popover text-popover-foreground max-w-64`,children:W}),t[51]=W,t[52]=G);let K;t[53]!==U||t[54]!==G?(K=(0,Q.jsxs)(Ue,{children:[U,G]}),t[53]=U,t[54]=G,t[55]=K):K=t[55];let q;t[56]!==h||t[57]!==l||t[58]!==c||t[59]!==F||t[60]!==C?(q=(0,Q.jsx)(Wt,{open:h,onOpenChange:g,onConfirm:F,downloading:C,progress:l,error:c}),t[56]=h,t[57]=l,t[58]=c,t[59]=F,t[60]=C,t[61]=q):q=t[61];let J;return t[62]!==K||t[63]!==q?(J=(0,Q.jsxs)(Q.Fragment,{children:[re,K,q]}),t[62]=K,t[63]=q,t[64]=J):J=t[64],J}function Kt(e){let t=(0,X.c)(8),{queuedMessages:n,onRemoveQueuedMessage:r}=e;if(n.length===0)return null;let i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:`Queued messages`}),t[0]=i):i=t[0];let a;if(t[1]!==r||t[2]!==n){let e;t[4]===r?e=t[5]:(e=e=>(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border border-border/60 bg-background px-3 py-2 text-sm`,children:[(0,Q.jsx)(`p`,{className:`flex-1 whitespace-pre-wrap text-foreground`,children:e.message}),(0,Q.jsx)(`button`,{type:`button`,className:`rounded-full p-1 text-muted-foreground transition-colors hover:bg-foreground hover:text-background`,onClick:()=>r(e.id),"aria-label":`Remove queued message`,children:(0,Q.jsx)(C,{className:`h-3.5 w-3.5`})})]},e.id),t[4]=r,t[5]=e),a=n.map(e),t[1]=r,t[2]=n,t[3]=a}else a=t[3];let o;return t[6]===a?o=t[7]:(o=(0,Q.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border/60 bg-muted/30 px-4 py-3`,children:[i,(0,Q.jsx)(`div`,{className:`mt-2 flex flex-col gap-2`,children:a})]}),t[6]=a,t[7]=o),o}function qt(e){let t=(0,X.c)(136),{onSend:n,onStop:r,isStreaming:i,disabled:a,initialValue:o,queuedMessages:s,onRemoveQueuedMessage:c,isOverlay:l}=e,u=i===void 0?!1:i,d=l===void 0?!1:l,f;t[0]===o?f=t[1]:(f={initialValue:o},t[0]=o,t[1]=f);let{message:p,setMessage:m,historyIndex:h,setHistoryIndex:g,draftMessage:_,setDraftMessage:v,cursorPosition:y,setCursorPosition:b,availableModels:x,selectedModel:C,setSelectedModel:w,attachments:T,setAttachments:E,planMode:O,setPlanMode:A,ralphMode:j,setRalphMode:M,imageMode:N,setImageMode:P,availableImageModels:F,selectedImageModel:I,setSelectedImageModel:ee,allFiles:L,setAllFiles:te,showSuggestions:R,setShowSuggestions:ne,suggestionQuery:re,setSuggestionQuery:ie,selectedIndex:z,setSelectedIndex:B,slashCommands:V,skills:H,showCommandSuggestions:U,setShowCommandSuggestions:W,commandQuery:G,setCommandQuery:K,fileInputRef:q,textareaRef:J,suggestionsRef:ae,commandSuggestionsRef:oe,state:se,dispatch:ce}=yt(f),le=N?I:C,ue=N?F:x,de=se.selectedThreadId??void 0,fe;t[2]!==L||t[3]!==T||t[4]!==G||t[5]!==y||t[6]!==ce||t[7]!==_||t[8]!==h||t[9]!==N||t[10]!==u||t[11]!==p||t[12]!==n||t[13]!==O||t[14]!==j||t[15]!==I||t[16]!==z||t[17]!==C||t[18]!==te||t[19]!==E||t[20]!==K||t[21]!==b||t[22]!==v||t[23]!==g||t[24]!==P||t[25]!==m||t[26]!==A||t[27]!==M||t[28]!==B||t[29]!==W||t[30]!==ne||t[31]!==ie||t[32]!==U||t[33]!==R||t[34]!==H||t[35]!==V||t[36]!==re||t[37]!==de||t[38]!==J?(fe={message:p,setMessage:m,attachments:T,selectedModel:C,onSend:n,isStreaming:u,selectedThreadId:de,isListening:!1,stopListening:Zt,resetTranscript:Xt,dispatch:ce,historyIndex:h,setHistoryIndex:g,draftMessage:_,setDraftMessage:v,cursorPosition:y,setCursorPosition:b,showSuggestions:R,setShowSuggestions:ne,suggestionQuery:re,setSuggestionQuery:ie,allFiles:L,setAllFiles:te,selectedIndex:z,setSelectedIndex:B,showCommandSuggestions:U,setShowCommandSuggestions:W,commandQuery:G,setCommandQuery:K,slashCommands:V,skills:H,textareaRef:J,setAttachments:E,planMode:O,setPlanMode:A,ralphMode:j,setRalphMode:M,imageMode:N,setImageMode:P,selectedImageModel:I},t[2]=L,t[3]=T,t[4]=G,t[5]=y,t[6]=ce,t[7]=_,t[8]=h,t[9]=N,t[10]=u,t[11]=p,t[12]=n,t[13]=O,t[14]=j,t[15]=I,t[16]=z,t[17]=C,t[18]=te,t[19]=E,t[20]=K,t[21]=b,t[22]=v,t[23]=g,t[24]=P,t[25]=m,t[26]=A,t[27]=M,t[28]=B,t[29]=W,t[30]=ne,t[31]=ie,t[32]=U,t[33]=R,t[34]=H,t[35]=V,t[36]=re,t[37]=de,t[38]=J,t[39]=fe):fe=t[39];let{handleSend:pe,handleKeyDown:me,handleTextareaInput:he,insertFileReference:_e,insertCommand:ve,insertSkill:ye,fileSuggestions:be}=xt(fe),xe;t[40]===m?xe=t[41]:(xe=e=>{m(t=>(t.endsWith(` `),t+e))},t[40]=m,t[41]=xe);let Se=xe,Ce;t[42]===E?Ce=t[43]:(Ce=e=>{let t=e.clipboardData?.items;if(!t)return;let n=Array.from(t).filter(Yt);if(n.length!==0){e.preventDefault();for(let e of n){let t=e.getAsFile();if(!t)continue;let n=new FileReader;n.onload=()=>{let e=n.result.split(`,`)[1];E(n=>[...n,{fileName:t.name||`pasted-image.${t.type.split(`/`)[1]||`png`}`,content:e,mimeType:t.type}])},n.readAsDataURL(t)}}},t[42]=E,t[43]=Ce);let we=Ce,Te=d?`absolute inset-x-0 bottom-0 mx-auto w-full max-w-3xl px-4 pb-4 pointer-events-none`:`relative mx-auto w-full max-w-3xl px-4 pb-4`,Ee=`flex flex-col rounded-2xl border focus-within:ring-2 focus-within:ring-brand pointer-events-auto ${d?`border-border/50 bg-background/80 shadow-lg backdrop-blur-sm`:`border-border bg-background shadow-2xl`}`,De;t[44]!==c||t[45]!==s?(De=(0,Q.jsx)(Kt,{queuedMessages:s,onRemoveQueuedMessage:c}),t[44]=c,t[45]=s,t[46]=De):De=t[46];let Oe=j?`Describe stories for Ralph to implement autonomously...`:O?`Describe what you want Tarsk to plan...`:N?`Describe the image you want to generate...`:`Ask Tarsk anything, # for files, / for commands & skills`,ke;t[47]!==a||t[48]!==me||t[49]!==we||t[50]!==he||t[51]!==p||t[52]!==Oe||t[53]!==J?(ke=(0,Q.jsx)(`textarea`,{ref:J,value:p,onChange:he,onKeyDown:me,onPaste:we,placeholder:Oe,rows:1,className:`w-full resize-none bg-transparent px-6 pt-4 pb-4 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none`,disabled:a}),t[47]=a,t[48]=me,t[49]=we,t[50]=he,t[51]=p,t[52]=Oe,t[53]=J,t[54]=ke):ke=t[54];let Ae;t[55]!==G||t[56]!==oe||t[57]!==ve||t[58]!==ye||t[59]!==z||t[60]!==B||t[61]!==U||t[62]!==H||t[63]!==V?(Ae=(0,Q.jsx)(Tt,{visible:U,commands:V,skills:H,query:G,selectedIndex:z,onSelectCommand:ve,onSelectSkill:ye,onMouseEnterSuggestion:B,containerRef:oe}),t[55]=G,t[56]=oe,t[57]=ve,t[58]=ye,t[59]=z,t[60]=B,t[61]=U,t[62]=H,t[63]=V,t[64]=Ae):Ae=t[64];let je;t[65]!==be||t[66]!==_e||t[67]!==z||t[68]!==B||t[69]!==R||t[70]!==re||t[71]!==ae?(je=(0,Q.jsx)(jt,{showSuggestions:R,fileSuggestions:be,suggestionQuery:re,selectedIndex:z,onSelectFile:_e,onMouseEnterSuggestion:B,containerRef:ae}),t[65]=be,t[66]=_e,t[67]=z,t[68]=B,t[69]=R,t[70]=re,t[71]=ae,t[72]=je):je=t[72];let Me;t[73]!==T||t[74]!==C?.id||t[75]!==C?.name||t[76]!==C?.supportsImages||t[77]!==E?(Me=T.length>0&&(0,Q.jsxs)(`div`,{className:`px-4`,children:[(0,Q.jsx)(kt,{attachments:T,onRemove:e=>E(t=>t.filter((t,n)=>n!==e))}),T.some(Jt)&&C?.supportsImages===!1&&(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 text-xs text-amber-500`,children:[(0,Q.jsx)(k,{className:`h-3 w-3 shrink-0`}),(0,Q.jsxs)(`span`,{children:[`Images are not supported by `,C?.name||C?.id]})]})]}),t[73]=T,t[74]=C?.id,t[75]=C?.name,t[76]=C?.supportsImages,t[77]=E,t[78]=Me):Me=t[78];let Ne;t[79]===q?Ne=t[80]:(Ne=(0,Q.jsx)(zt,{onFileAttach:()=>q.current?.click()}),t[79]=q,t[80]=Ne);let Pe;t[81]===Se?Pe=t[82]:(Pe=(0,Q.jsx)(Gt,{onTranscript:Se}),t[81]=Se,t[82]=Pe);let Fe=N?ee:w,Ie;t[83]!==ue||t[84]!==le||t[85]!==Fe?(Ie=(0,Q.jsx)(Pt,{availableModels:ue,selectedModel:le,onModelSelect:Fe}),t[83]=ue,t[84]=le,t[85]=Fe,t[86]=Ie):Ie=t[86];let Le;t[87]!==Ne||t[88]!==Pe||t[89]!==Ie?(Le=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[Ne,Pe,Ie]}),t[87]=Ne,t[88]=Pe,t[89]=Ie,t[90]=Le):Le=t[90];let Re;t[91]!==N||t[92]!==O||t[93]!==j||t[94]!==P||t[95]!==A||t[96]!==M?(Re=(0,Q.jsx)(Rt,{planMode:O,imageMode:N,ralphMode:j,setPlanMode:A,setImageMode:P,setRalphMode:M}),t[91]=N,t[92]=O,t[93]=j,t[94]=P,t[95]=A,t[96]=M,t[97]=Re):Re=t[97];let ze=u?r:pe,Be;t[98]!==T.length||t[99]!==a||t[100]!==le||t[101]!==u||t[102]!==p?(Be=!u&&((a??!1)||!p.trim()&&T.length===0||!le),t[98]=T.length,t[99]=a,t[100]=le,t[101]=u,t[102]=p,t[103]=Be):Be=t[103];let Y;t[104]===u?Y=t[105]:(Y=u?(0,Q.jsx)(S,{className:`h-3 w-3 fill-current`}):(0,Q.jsx)(ge,{className:`h-3 w-3`}),t[104]=u,t[105]=Y);let Ve=u?`Stop generation`:`Send message`,He;t[106]===Ve?He=t[107]:(He=(0,Q.jsx)(`span`,{className:`sr-only`,children:Ve}),t[106]=Ve,t[107]=He);let Ue;t[108]!==ze||t[109]!==Be||t[110]!==Y||t[111]!==He?(Ue=(0,Q.jsxs)(D,{size:`icon`,className:`h-7 w-7 rounded-full`,onClick:ze,disabled:Be,children:[Y,He]}),t[108]=ze,t[109]=Be,t[110]=Y,t[111]=He,t[112]=Ue):Ue=t[112];let We;t[113]!==Re||t[114]!==Ue?(We=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[Re,Ue]}),t[113]=Re,t[114]=Ue,t[115]=We):We=t[115];let Ge;t[116]!==Le||t[117]!==We?(Ge=(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-3 pb-2`,children:[Le,We]}),t[116]=Le,t[117]=We,t[118]=Ge):Ge=t[118];let Ke;t[119]!==De||t[120]!==ke||t[121]!==Ae||t[122]!==je||t[123]!==Me||t[124]!==Ge||t[125]!==Ee?(Ke=(0,Q.jsxs)(`div`,{className:Ee,children:[De,ke,Ae,je,Me,Ge]}),t[119]=De,t[120]=ke,t[121]=Ae,t[122]=je,t[123]=Me,t[124]=Ge,t[125]=Ee,t[126]=Ke):Ke=t[126];let qe;t[127]===E?qe=t[128]:(qe=e=>At(e,e=>E(t=>[...t,...e])),t[127]=E,t[128]=qe);let Je;t[129]!==q||t[130]!==qe?(Je=(0,Q.jsx)(`input`,{ref:q,type:`file`,multiple:!0,className:`hidden`,onChange:qe}),t[129]=q,t[130]=qe,t[131]=Je):Je=t[131];let Ye;return t[132]!==Ke||t[133]!==Je||t[134]!==Te?(Ye=(0,Q.jsxs)(`div`,{className:Te,children:[Ke,Je]}),t[132]=Ke,t[133]=Je,t[134]=Te,t[135]=Ye):Ye=t[135],Ye}function Jt(e){return e.mimeType.startsWith(`image/`)}function Yt(e){return e.type.startsWith(`image/`)}function Xt(){}function Zt(){}var Qt=je,$t=Pe,en=Se,tn=Z.forwardRef((e,n)=>{let r=(0,X.c)(14),i,a,o,s;r[0]===e?(i=r[1],a=r[2],o=r[3],s=r[4]):({className:a,inset:o,children:i,...s}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o,r[4]=s);let c=o&&`pl-8`,l;r[5]!==a||r[6]!==c?(l=t(`flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,c,a),r[5]=a,r[6]=c,r[7]=l):l=r[7];let u;r[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(me,{className:`ml-auto`}),r[8]=u):u=r[8];let d;return r[9]!==i||r[10]!==s||r[11]!==n||r[12]!==l?(d=(0,Q.jsxs)(Le,{ref:n,className:l,...s,children:[i,u]}),r[9]=i,r[10]=s,r[11]=n,r[12]=l,r[13]=d):d=r[13],d});tn.displayName=Le.displayName;var nn=Z.forwardRef((e,n)=>{let r=(0,X.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=t(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==n||r[7]!==o?(s=(0,Q.jsx)(Me,{ref:n,className:o,...a}),r[5]=a,r[6]=n,r[7]=o,r[8]=s):s=r[8],s});nn.displayName=Me.displayName;var rn=Z.forwardRef((e,n)=>{let r=(0,X.c)(11),i,a,o;r[0]===e?(i=r[1],a=r[2],o=r[3]):({className:i,sideOffset:o,...a}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o);let s=o===void 0?4:o,c;r[4]===i?c=r[5]:(c=t(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,i),r[4]=i,r[5]=c);let l;return r[6]!==a||r[7]!==n||r[8]!==s||r[9]!==c?(l=(0,Q.jsx)(Ee,{children:(0,Q.jsx)(ke,{ref:n,sideOffset:s,className:c,...a})}),r[6]=a,r[7]=n,r[8]=s,r[9]=c,r[10]=l):l=r[10],l});rn.displayName=ke.displayName;var an=Z.forwardRef((e,n)=>{let r=(0,X.c)(11),i,a,o;r[0]===e?(i=r[1],a=r[2],o=r[3]):({className:i,inset:a,...o}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o);let s=a&&`pl-8`,c;r[4]!==i||r[5]!==s?(c=t(`relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,s,i),r[4]=i,r[5]=s,r[6]=c):c=r[6];let l;return r[7]!==o||r[8]!==n||r[9]!==c?(l=(0,Q.jsx)(we,{ref:n,className:c,...o}),r[7]=o,r[8]=n,r[9]=c,r[10]=l):l=r[10],l});an.displayName=we.displayName;var on=Z.forwardRef((e,n)=>{let r=(0,X.c)(14),i,a,o,s;r[0]===e?(i=r[1],a=r[2],o=r[3],s=r[4]):({className:o,children:a,checked:i,...s}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o,r[4]=s);let c;r[5]===o?c=r[6]:(c=t(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,o),r[5]=o,r[6]=c);let l;r[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Q.jsx)(De,{children:(0,Q.jsx)(ce,{className:`h-4 w-4`})})}),r[7]=l):l=r[7];let u;return r[8]!==i||r[9]!==a||r[10]!==s||r[11]!==n||r[12]!==c?(u=(0,Q.jsxs)(Te,{ref:n,className:c,checked:i,...s,children:[l,a]}),r[8]=i,r[9]=a,r[10]=s,r[11]=n,r[12]=c,r[13]=u):u=r[13],u});on.displayName=Te.displayName;var sn=Z.forwardRef((e,n)=>{let r=(0,X.c)(12),i,a,o;r[0]===e?(i=r[1],a=r[2],o=r[3]):({className:a,children:i,...o}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o);let s;r[4]===a?s=r[5]:(s=t(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,a),r[4]=a,r[5]=s);let c;r[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Q.jsx)(De,{children:(0,Q.jsx)(F,{className:`h-2 w-2 fill-current`})})}),r[6]=c):c=r[6];let l;return r[7]!==i||r[8]!==o||r[9]!==n||r[10]!==s?(l=(0,Q.jsxs)(Ae,{ref:n,className:s,...o,children:[c,i]}),r[7]=i,r[8]=o,r[9]=n,r[10]=s,r[11]=l):l=r[11],l});sn.displayName=Ae.displayName;var cn=Z.forwardRef((e,n)=>{let r=(0,X.c)(11),i,a,o;r[0]===e?(i=r[1],a=r[2],o=r[3]):({className:i,inset:a,...o}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o);let s=a&&`pl-8`,c;r[4]!==i||r[5]!==s?(c=t(`px-2 py-1.5 text-sm font-semibold`,s,i),r[4]=i,r[5]=s,r[6]=c):c=r[6];let l;return r[7]!==o||r[8]!==n||r[9]!==c?(l=(0,Q.jsx)(Fe,{ref:n,className:c,...o}),r[7]=o,r[8]=n,r[9]=c,r[10]=l):l=r[10],l});cn.displayName=Fe.displayName;var ln=Z.forwardRef((e,n)=>{let r=(0,X.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=t(`-mx-1 my-1 h-px bg-muted`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==n||r[7]!==o?(s=(0,Q.jsx)(Oe,{ref:n,className:o,...a}),r[5]=a,r[6]=n,r[7]=o,r[8]=s):s=r[8],s});ln.displayName=Oe.displayName;var un=e=>{let n=(0,X.c)(8),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=t(`ml-auto text-xs tracking-widest opacity-60`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,Q.jsx)(`span`,{className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o};un.displayName=`DropdownMenuShortcut`;function dn(e){let t=(0,X.c)(17),{currentBranch:n,availableBranches:r,isLoadingBranches:a,isCheckingOut:o,onLoadBranches:s,onCheckoutBranch:c}=e,l;t[0]===s?l=t[1]:(l=e=>{e&&s()},t[0]=s,t[1]=l);let u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(O,{className:`h-3.5 w-3.5 shrink-0`}),t[2]=u):u=t[2];let d=n||`Unknown`,f;t[3]===d?f=t[4]:(f=(0,Q.jsx)($t,{asChild:!0,children:(0,Q.jsxs)(D,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs bg-background gap-1.5 border-none text-muted-foreground hover:bg-accent hover:text-accent-foreground`,children:[u,d]})}),t[3]=d,t[4]=f);let p;t[5]!==r||t[6]!==n||t[7]!==o||t[8]!==a||t[9]!==c?(p=a?(0,Q.jsxs)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground flex items-center gap-2`,children:[(0,Q.jsx)(i,{className:`h-3 w-3 animate-spin`}),`Loading branches...`]}):r.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:`No branches found`}):r.map(e=>(0,Q.jsxs)(an,{disabled:e===n||o,onClick:()=>c(e),children:[(0,Q.jsx)(O,{className:`h-3.5 w-3.5 mr-2 shrink-0`}),(0,Q.jsx)(`span`,{className:e===n?`font-semibold text-foreground`:``,children:e}),e===n&&(0,Q.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`current`})]},e)),t[5]=r,t[6]=n,t[7]=o,t[8]=a,t[9]=c,t[10]=p):p=t[10];let m;t[11]===p?m=t[12]:(m=(0,Q.jsx)(rn,{align:`start`,children:p}),t[11]=p,t[12]=m);let h;return t[13]!==l||t[14]!==f||t[15]!==m?(h=(0,Q.jsxs)(Qt,{onOpenChange:l,children:[f,m]}),t[13]=l,t[14]=f,t[15]=m,t[16]=h):h=t[16],h}function fn({threadId:e,currentConversationId:t,refreshKey:n,children:r}){let[i,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(null),[l,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(!1),[h,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>{x(!1)},[n]),(0,Z.useEffect)(()=>{if(!v||!e||b&&!n)return;async function r(){m(!0),_(null);try{let n=(await g(e)).currentConversationId??t,[r,i]=await Promise.allSettled([d(e).catch(e=>{throw console.error(`Thread usage summary failed:`,e),e}),n?K(e,n).catch(e=>{throw console.error(`Conversation usage failed:`,e),e}):Promise.resolve(null)]);if(r.status===`fulfilled`)o(r.value);else throw console.error(`Failed to fetch thread usage summary:`,r.reason),r.reason;if(i?.status===`fulfilled`&&i.value){if(c(i.value),i.value.model?.model){let e=i.value.model.model,t=i.value.model.provider,n=t&&e?`${t}/${e}`:e;console.log(`Fetching model info for:`,n,`(provider:`,t,`model:`,e+`)`),ie(n).then(f).catch(e=>{console.warn(`Failed to fetch model info:`,e)})}}else if(i?.status===`rejected`)throw console.error(`Failed to fetch conversation usage:`,i.reason),i.reason;x(!0)}catch(e){console.error(`[TokenUsageTooltip] Failed to load usage data:`,e),_(`Failed to load usage data`)}finally{m(!1)}}r()},[v,e,t,n]),!e||e===``)return console.log(`[TokenUsageTooltip] No valid threadId, returning children only`),(0,Q.jsx)(Q.Fragment,{children:r});let S=e=>e==null||e===0?`0`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString();return e?(0,Q.jsxs)(Ue,{open:v,onOpenChange:e=>{y(e),!e&&b&&x(!1)},children:[(0,Q.jsx)(We,{asChild:!0,children:r}),(0,Q.jsx)(He,{side:`top`,align:`center`,className:`max-w-xs`,children:(0,Q.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-2`,children:[p&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(q,{className:`h-3 w-3 animate-pulse`}),(0,Q.jsx)(`span`,{children:`Loading usage...`})]}),h&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(q,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:`No usage information for this thread`})]}),!p&&!h&&i&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(q,{className:`h-3 w-3`}),(0,Q.jsxs)(`span`,{className:`font-medium`,children:[S(i.totalTokens),` tokens`]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(a,{className:`h-3 w-3`}),(0,Q.jsxs)(`span`,{children:[i.conversationCount,` chats`]})]})]}),s&&(0,Q.jsxs)(`div`,{className:`border-t border-border pt-2 space-y-1`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-semibold text-foreground`,children:`Current Chat:`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(u,{className:`h-3 w-3`}),(0,Q.jsxs)(`span`,{children:[((e,t)=>{let n=S(e);return t?`${n} (${Math.round(e/t*100)}%)`:n})(s.footprint?.totalTokens??s.usage.totalTokens,typeof l?.contextWindow==`number`?l.contextWindow:typeof l?.context_length==`number`?l.context_length:void 0),` `,`tokens`]})]}),s.model.model&&(0,Q.jsx)(`div`,{className:`text-muted-foreground`,children:s.model.model}),(l?.contextWindow||l?.context_length)&&(0,Q.jsxs)(`div`,{className:`text-muted-foreground`,children:[`Max context:`,` `,S(typeof l.contextWindow==`number`?l.contextWindow:typeof l.context_length==`number`?l.context_length:0),` `,`tokens`]})]}),(0,Q.jsxs)(`div`,{className:`border-t border-border pt-2 flex items-center gap-3 text-[10px] text-muted-foreground`,children:[(0,Q.jsxs)(`span`,{children:[`In: `,S(i.totalInputTokens)]}),(0,Q.jsxs)(`span`,{children:[`Out: `,S(i.totalOutputTokens)]}),(0,Q.jsxs)(`span`,{children:[`Avg: `,S(i.averageTokensPerConversation),`/chat`]})]})]})]})})]}):(0,Q.jsx)(Q.Fragment,{children:r})}function pn(e,t){return`${e.filter(e=>e.sender===`agent`).length}:${t?`streaming`:`idle`}`}function mn(e){if(typeof e?.contextWindow==`number`)return e.contextWindow;if(typeof e?.context_length==`number`)return e.context_length}function hn(e){return e>75?`text-red-500`:e>50?`text-orange-500`:`text-muted-foreground`}function gn(e){let t=(0,X.c)(8),{percentage:n}=e,r=2*Math.PI*7,i=r*(1-Math.min(n,100)/100),a;t[0]===n?a=t[1]:(a=hn(n),t[0]=n,t[1]=a);let o=`h-4 w-4 ${a}`,s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(`circle`,{className:`text-muted-foreground/25`,cx:`10`,cy:`10`,r:7,fill:`none`,stroke:`currentColor`,strokeWidth:`3`}),t[2]=s):s=t[2];let c;t[3]===i?c=t[4]:(c=(0,Q.jsx)(`circle`,{cx:`10`,cy:`10`,r:7,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,strokeDasharray:r,strokeDashoffset:i,transform:`rotate(-90 10 10)`}),t[3]=i,t[4]=c);let l;return t[5]!==o||t[6]!==c?(l=(0,Q.jsxs)(`svg`,{className:o,viewBox:`0 0 20 20`,"aria-hidden":`true`,children:[s,c]}),t[5]=o,t[6]=c,t[7]=l):l=t[7],l}function _n({threadId:e,isStreaming:t=!1,messages:n=[]}){let[r,i]=(0,Z.useState)(),[o,s]=(0,Z.useState)(),c=(0,Z.useMemo)(()=>pn(n,t),[n,t]);return(0,Z.useEffect)(()=>{async function t(){if(!e){i(void 0),s(void 0);return}try{let t=(await g(e)).currentConversationId;if(i(t),!t){s(void 0);return}let n=await K(e,t),r=n.model?.model;if(!r){s(void 0);return}let a=n.model.provider,o=mn(await ie(a?`${a}/${r}`:r));if(!o){s(void 0);return}let c=n.footprint?.totalTokens??n.usage.totalTokens;s(Math.round(c/o*100))}catch(e){console.error(`Failed to fetch thread usage data:`,e),s(void 0)}}t()},[e,c]),!e||e===``?null:(0,Q.jsx)(fn,{threadId:e,currentConversationId:r,refreshKey:c,children:(0,Q.jsxs)(D,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,children:[typeof o==`number`&&o>25?(0,Q.jsx)(gn,{percentage:o}):(0,Q.jsx)(a,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`View token usage`})]})})}var vn=3e4,yn=new Map;function bn(e,t){let n=yn.get(e);if(n)for(let e of n)e(t)}function xn(e,t){let n=yn.get(e);return n||(n=new Set,yn.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&yn.delete(e)}}function Sn(e){let[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(0),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(void 0),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(`Up to date`),[x,S]=(0,Z.useState)(null),[C,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(void 0),[O,k]=(0,Z.useState)(void 0),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(!1),P=(0,Z.useRef)(!0),F=(0,Z.useRef)(void 0),I=(0,Z.useCallback)(e=>{n(e.hasChanges),i(e.changedFilesCount),o(e.hasUnpushedCommits),c(e.currentBranch),v(e.hasRemoteBranch),u(e.isOnGitHub),f(e.remoteUrl),m(e.canCreateRepo),g(e.repoUrl),b(e.status),S(e.defaultBranch??null),T(e.prExists),D(e.prUrl),k(e.prState),j(e.commitsAheadOfDefault??!1)},[]),ee=(0,Z.useRef)(I);ee.current=I;let L=(0,Z.useCallback)(async(t=!1)=>{if(!e)return;let n=setTimeout(()=>N(!0),100);try{let n=`unified-git-status-${e}`;t&&U.invalidate(n);let r=await U.get(n,()=>w(e,t),vn);I(r),bn(e,r)}catch(e){console.error(`Failed to fetch unified git status:`,e)}finally{clearTimeout(n),N(!1)}},[e,I]);return(0,Z.useEffect)(()=>{if(e)return xn(e,e=>{ee.current(e)})},[e]),(0,Z.useEffect)(()=>{if(!e)return;let t=F.current!==e;t&&(F.current=e,P.current=!0),(async()=>{if(P.current){let t=`unified-git-status-${e}`,n=U.getSync(t);n&&I(n),P.current=!1}await L(t)})()},[e,L,I]),{hasChanges:t,changedFilesCount:r,hasUnpushedCommits:a,hasRemoteBranch:_,currentBranch:s,isOnGitHub:l,remoteUrl:d,canCreateRepo:p,repoUrl:h,status:y,defaultBranch:x,prExists:C,prUrl:E,prState:O,commitsAheadOfDefault:A,isRefreshing:M,fetchUnifiedStatus:L}}function Cn(e){let[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1),s=Sn(e);async function c(){if(!(!e||r)){i(!0);try{n((await A(e)).branches)}catch{n([])}finally{i(!1)}}}async function l(t){if(!(!e||t===s.currentBranch)){o(!0);try{await xe(e,t),await s.fetchUnifiedStatus(!0),Ke({title:`Switched to branch "${t}"`})}catch(e){Ke({title:`Failed to switch branch`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{o(!1)}}}return{currentBranch:s.currentBranch,availableBranches:t,isLoadingBranches:r,isCheckingOut:a,loadBranches:c,checkoutBranch:l,fetchUnifiedStatus:s.fetchUnifiedStatus}}function wn(e){let t=(0,X.c)(8),{collapsed:n}=e,{theme:r,setTheme:i}=at();if(n)return null;let a;t[0]!==i||t[1]!==r?(a=()=>i(r===`dark`?`light`:`dark`),t[0]=i,t[1]=r,t[2]=a):a=t[2];let o,s,c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsx)(M,{className:`h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0`}),s=(0,Q.jsx)(ye,{className:`absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100`}),c=(0,Q.jsx)(`span`,{className:`sr-only`,children:`Toggle theme`}),t[3]=o,t[4]=s,t[5]=c):(o=t[3],s=t[4],c=t[5]);let l;return t[6]===a?l=t[7]:(l=(0,Q.jsxs)(D,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:a,children:[o,s,c]}),t[6]=a,t[7]=l),l}function Tn({threadId:e,isStreaming:t=!1,messages:n=[]}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(null),s=Cn(e);return(0,Z.useEffect)(()=>{e&&pe(e).then(o).catch(()=>{})},[e]),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-8 py-2 mt-[-1rem] min-h-[2.25rem]`,children:[e&&(0,Q.jsx)(dn,{currentBranch:s.currentBranch,availableBranches:s.availableBranches,isLoadingBranches:s.isLoadingBranches,isCheckingOut:s.isCheckingOut,onLoadBranches:s.loadBranches,onCheckoutBranch:s.checkoutBranch}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(wn,{collapsed:!1}),(0,Q.jsx)(_n,{threadId:e,isStreaming:t,messages:n}),e&&(0,Q.jsxs)(Ue,{children:[(0,Q.jsx)(We,{asChild:!0,children:(0,Q.jsx)(D,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:async()=>{if(!(!e||r)){i(!0);try{let t=await pe(e);await navigator.clipboard.writeText(t)}finally{i(!1)}}},disabled:r,"aria-label":`Copy repository folder path`,children:(0,Q.jsx)(E,{className:`h-4 w-4`})})}),(0,Q.jsxs)(He,{side:`top`,className:`bg-slate-900 text-white`,children:[(0,Q.jsx)(`div`,{children:`Copy repository folder path`}),a&&(0,Q.jsx)(`div`,{className:`opacity-70 text-xs`,children:a})]})]})]})]})}function En(e,t){if(!(!t||!e.includes(`"run_js"`)))try{let n=JSON.parse(e.trim());if(!Array.isArray(n))return;for(let e of n)e?.type===`tool_use`&&e?.name===`run_js`&&e?.id&&e?.input?.code&&vt(e.id,e.input.code,t)}catch{}}function Dn(){let{state:e,dispatch:t}=Re(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(null),l=(0,Z.useRef)(null),u=(0,Z.useRef)(new Map),{selectedThreadId:d,selectedProjectId:f,messages:p,queuedChatMessages:m,isStreaming:h,processingThreadIds:g}=e;l.current=d;let _=(0,Z.useCallback)((e,n,r)=>{if(u.current.get(e)!==r||(u.current.delete(e),r.stopHandled))return;let i=Be(r.segments)||`...`;if(r.error&&(r.segments.length===0||i===`...`)){let i={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Error: ${r.error}`,contentType:`text`,timestamp:new Date().toISOString(),model:n||`default`,isThinking:!1};t({type:Y.AddMessage,message:i,threadId:e}),t({type:Y.ResetStream,threadId:e}),t({type:Y.RemoveProcessingThread,threadId:e});return}let a={messageId:`msg-${Date.now()}-agent`,sender:`agent`,content:i,contentType:`markdown`,timestamp:new Date().toISOString(),model:n||`default`,isThinking:!1};t({type:Y.AddMessage,message:a,threadId:e}),t({type:Y.ResetStream,threadId:e}),t({type:Y.MarkThreadCompleted,threadId:e}),t({type:Y.RemoveProcessingThread,threadId:e})},[t]),v=(0,Z.useCallback)(()=>{if(!d)return;c(d);let n=u.current.get(d);n&&(n.stopHandled=!0,n.controller.abort(),n.cancel?.(),u.current.delete(d)),ne(d);let r={messageId:`msg-${Date.now()}-stopped`,sender:`agent`,content:`I've stopped working on your request.`,contentType:`text`,timestamp:new Date().toISOString(),model:e.streamingModel||`default`,isThinking:!1};t({type:Y.AddMessage,message:r,threadId:d}),t({type:Y.ResetStream,threadId:d}),t({type:Y.MarkThreadCompleted,threadId:d}),t({type:Y.RemoveProcessingThread,threadId:d})},[d,t,e.streamingModel]);(0,Z.useEffect)(()=>()=>{for(let e of u.current.values())e.controller.abort(),e.cancel?.();u.current.clear()},[]),(0,Z.useEffect)(()=>{if(!d)return;let e=!1;async function n(){try{let n=await se(d);e||t({type:Y.SetMessages,messages:n.messages})}catch(n){console.error(`Failed to load chat history:`,n),e||t({type:Y.SetMessages,messages:[]})}}return n(),()=>{e=!0}},[d,f,t]);let b=(0,Z.useCallback)((e,r,a)=>{let s=u.current.get(e);s&&(s.controller.abort(),s.cancel?.());let c=new AbortController,d={controller:c,cancel:null,segments:[],assistantMessage:``,assistantThinking:``,hasStructuredContent:!1,error:null,stopHandled:!1};return u.current.set(e,d),t({type:Y.ResetStream,threadId:e}),t({type:Y.SetStreaming,isStreaming:!0,threadId:e}),r(c.signal).then(n=>{if(!n||c.signal.aborted){_(e,a,d);return}d.cancel=oe(n,n=>{if(t({type:Y.IncrementStreamEventCount,threadId:e}),n.type===`error`){let t=n.content||`Unknown error occurred`;d.error=t,e===l.current&&i(t);return}if(n.type!==`message`){if(n.type===`toolcall_delta`){n.partial?.content?.[0]?.id&&n.delta&&t({type:Y.UpdateToolCallProgress,toolCallId:n.partial.content[0].id,progress:{toolCallId:n.partial.content[0].id,toolName:n.partial.content[0].name,delta:n.delta,partial:n.partial}});return}if(n.model&&t({type:Y.SetStreamModel,model:n.model,threadId:e}),n.type===`thinking`||n.isThinking){let r=n.content??``;En(r,e),d.assistantThinking+=r,d.segments=ze(d.segments,`thinking`,r),t({type:Y.AppendStreamChunk,chunkType:`thinking`,content:r,segments:d.segments,threadId:e})}else if(n.type===`result`)d.hasStructuredContent=!0,d.assistantMessage=n.content??``,d.segments=Ve(d.segments,n.content??``),t({type:Y.SetStreamContent,content:n.content??``,threadId:e});else{if(d.hasStructuredContent)return;let r=n.content??``;d.assistantMessage+=r,d.segments=ze(d.segments,`content`,r),t({type:Y.AppendStreamChunk,chunkType:`content`,content:r,segments:d.segments,threadId:e})}}},()=>{_(e,a,d)},t=>{if(t.includes(`AbortError`)||t.includes(`canceled`)||t.includes(`BodyStreamBuffer was aborted`)){_(e,a,d);return}d.error=t,e===l.current&&i(t)},n=>{if(t({type:Y.IncrementStreamEventCount,threadId:e}),n.role===`assistant`){let r=n.content??``,i=typeof r==`string`?r:JSON.stringify(r);if(n.isThinking??!1){d.assistantThinking+=i,d.segments=ze(d.segments,`thinking`,i),t({type:Y.AppendStreamChunk,chunkType:`thinking`,content:i,segments:d.segments,threadId:e});return}let a=!1;if(typeof r==`object`&&Array.isArray(r)&&r.length>0)a=!0;else if(typeof i==`string`&&i.trim().startsWith(`[`))try{let e=JSON.parse(i);a=Array.isArray(e)&&e.length>0}catch{}a?(d.hasStructuredContent=!0,d.assistantMessage=i,d.segments=Ve(d.segments,i),t({type:Y.SetStreamContent,content:i,threadId:e})):(d.assistantMessage+=i,d.segments=ze(d.segments,`content`,i),t({type:Y.AppendStreamChunk,chunkType:`content`,content:i,segments:d.segments,threadId:e}))}else if(n.role===`tool`){let r=n.content??``,i=typeof r==`string`?r:JSON.stringify(r);i&&(d.assistantMessage+=i,d.segments=ze(d.segments,`content`,i),t({type:Y.AppendStreamChunk,chunkType:`content`,content:i,segments:d.segments,threadId:e}))}})}).catch(r=>{if(u.current.delete(e),r instanceof Error&&r.name===`AbortError`){t({type:Y.ResetStream,threadId:e});return}if(r instanceof n){t({type:Y.ResetStream,threadId:e}),o(!0);return}if(r instanceof Error&&r.message.includes(`not currently processing`)){t({type:Y.ResetStream,threadId:e});return}let a=r instanceof Error?r.message:`Failed to send message. Please ensure the CLI server is running on localhost:641`;e===l.current&&i(a),console.error(`Failed to subscribe to chat stream:`,r),t({type:Y.ResetStream,threadId:e})}),c},[t,_]);(0,Z.useEffect)(()=>{for(let t of g)u.current.has(t)||e.threadStreamingStates[t]?.isStreaming||b(t,e=>ve(t,e),`default`)},[b,g,e.threadStreamingStates]);let x=(0,Z.useCallback)(async(e,n,r,a,o,s,l)=>{if(!d)return;let u=d;i(null),c(null);let p=`msg-${Date.now()}`,m;try{let e=await V(u,p);e.success&&e.stashed&&e.checkpointRef&&(m=e.checkpointRef)}catch{}let h={messageId:p,sender:`user`,content:e,contentType:`text`,timestamp:new Date().toISOString(),model:n,attachments:r.map(e=>({fileName:e.fileName,content:e.content,mimeType:e.mimeType})),checkpointRef:m};t({type:Y.AddMessage,message:h,threadId:u});let g=e.trim().replace(/\n/g,` `).slice(0,100);if(f&&(y(u,{title:g}).catch(e=>{console.error(`Failed to update thread title:`,e)}),t({type:Y.UpdateThreadTitle,projectId:f,threadId:u,title:g})),s){let r=a??void 0;if(!r&&typeof n==`string`){let e=n.split(/[:/]/)[0]?.trim();e&&(r=e)}if(!r){let e={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Image generation is not available because no provider is configured for the selected model.`,contentType:`text`,timestamp:new Date().toISOString(),model:n,isThinking:!1};t({type:Y.AddMessage,message:e,threadId:u}),t({type:Y.ResetStream,threadId:u});return}t({type:Y.SetStreaming,isStreaming:!0,threadId:u});try{let i=await R(e,n,r,u),a={messageId:`msg-${Date.now()}-agent`,sender:`agent`,content:e,contentType:`text`,timestamp:new Date().toISOString(),model:n,isThinking:!1,generatedImageUrl:i.imageUrl,generatedImageData:i.imageData};t({type:Y.AddMessage,message:a,threadId:u})}catch(e){let r=e instanceof Error?e.message:`Image generation failed`,i={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Error: ${r}`,contentType:`text`,timestamp:new Date().toISOString(),model:n,isThinking:!1};t({type:Y.AddMessage,message:i,threadId:u})}finally{t({type:Y.ResetStream,threadId:u})}return}b(u,t=>ae(u,e,n,r,t,a,o,l),n)},[d,f,t,b]);(0,Z.useEffect)(()=>{let n=e.pendingChatMessage;if(!n||h||n.threadId!==d)return;let r=setTimeout(()=>{t({type:Y.ClearPendingChatMessage}),x(n.message,n.model,[],n.provider)},100);return()=>clearTimeout(r)},[e.pendingChatMessage,h,d,t,x]);let S=(0,Z.useMemo)(()=>d?m.filter(e=>e.threadId===d):[],[d,m]),C=(0,Z.useRef)(!1);return(0,Z.useEffect)(()=>{if(h||!d||S.length===0||C.current)return;let[e]=S;C.current=!0,t({type:Y.RemoveQueuedChatMessage,queuedMessageId:e.id});let n=setTimeout(()=>{x(e.message,e.model,e.attachments,e.provider,e.planMode,e.imageMode,e.ralphMode),C.current=!1},0);return()=>{clearTimeout(n),C.current=!1}},[t,x,h,S,d]),{error:r,setError:i,handleSend:x,handleStop:v,isStreaming:h,selectedThreadId:d,queuedMessagesForThread:S,handleRemoveQueuedMessage:(0,Z.useCallback)(e=>{let n=S.find(t=>t.id===e);t({type:Y.RemoveQueuedChatMessage,queuedMessageId:e}),!(!n||h||p.length>0||!d)&&x(n.message,n.model,n.attachments,n.provider,n.planMode,n.imageMode,n.ralphMode)},[t,x,h,p.length,S,d]),showEmptyBalanceDialog:a,setShowEmptyBalanceDialog:o}}function On(e){let t=(0,X.c)(10),{open:n,onClose:r}=e,i=Ce(),a;t[0]===r?a=t[1]:(a=e=>{e||r()},t[0]=r,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsxs)(Ze,{children:[(0,Q.jsx)(Je,{children:`Balance empty`}),(0,Q.jsx)(qe,{children:`You have no prompts remaining. Purchase additional prompts to continue.`})]}),t[2]=o):o=t[2];let s;t[3]!==i||t[4]!==r?(s=(0,Q.jsxs)(Ye,{children:[o,(0,Q.jsx)(Xe,{children:(0,Q.jsx)(D,{onClick:()=>{r(),i(`/settings/account`)},children:`Go to Account`})})]}),t[3]=i,t[4]=r,t[5]=s):s=t[5];let c;return t[6]!==n||t[7]!==a||t[8]!==s?(c=(0,Q.jsx)(Qe,{open:n,onOpenChange:a,children:s}),t[6]=n,t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function kn(e){let t=(0,X.c)(13),{todos:n}=e,r;t[0]===n?r=t[1]:(r=n.filter(jn),t[0]=n,t[1]=r);let i=r.length,a;t[2]===n.length?a=t[3]:(a=n.length===0&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No todo items.`}),t[2]=n.length,t[3]=a);let o;t[4]===n?o=t[5]:(o=n.map(An),t[4]=n,t[5]=o);let s;t[6]!==i||t[7]!==n.length?(s=n.length>0&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground pt-1`,children:[i,`/`,n.length,` completed`]}),t[6]=i,t[7]=n.length,t[8]=s):s=t[8];let c;return t[9]!==a||t[10]!==o||t[11]!==s?(c=(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[a,o,s]}),t[9]=a,t[10]=o,t[11]=s,t[12]=c):c=t[12],c}function An(e){return(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[e.status===`done`?(0,Q.jsx)(fe,{className:`h-4 w-4 shrink-0 mt-0.5 text-brand`}):e.status===`working`?(0,Q.jsx)(z,{className:`h-4 w-4 shrink-0 mt-0.5 text-yellow-500`}):(0,Q.jsx)(F,{className:`h-4 w-4 shrink-0 mt-0.5 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:e.status===`done`?`line-through text-muted-foreground`:`text-foreground`,children:e.description})]},e.id)}function jn(e){return e.status===`done`}function Mn(){let e=(0,X.c)(16),{todos:t}=(0,Z.useContext)(ct),[n,r]=(0,Z.useState)(!1),i;e[0]===t?i=e[1]:(i=t.filter(Nn),e[0]=t,e[1]=i);let a=i.length;if(t.length-a<=0)return null;let o,c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>r(!0),c=(0,Q.jsx)(v,{className:`h-4 w-4 shrink-0`}),e[2]=o,e[3]=c):(o=e[2],c=e[3]);let l;e[4]!==a||e[5]!==t.length?(l=(0,Q.jsxs)(D,{variant:`outline`,size:`sm`,className:`gap-2 bg-background ml-2`,onClick:o,children:[c,a,` of `,t.length,` complete`]}),e[4]=a,e[5]=t.length,e[6]=l):l=e[6];let u;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(P,{children:(0,Q.jsx)(x,{children:`Tasks`})}),e[7]=u):u=e[7];let d;e[8]===t?d=e[9]:(d=(0,Q.jsxs)(s,{className:`max-w-md`,children:[u,(0,Q.jsx)(kn,{todos:t})]}),e[8]=t,e[9]=d);let f;e[10]!==n||e[11]!==d?(f=(0,Q.jsx)(ue,{open:n,onOpenChange:r,children:d}),e[10]=n,e[11]=d,e[12]=f):f=e[12];let p;return e[13]!==l||e[14]!==f?(p=(0,Q.jsxs)(Q.Fragment,{children:[l,f]}),e[13]=l,e[14]=f,e[15]=p):p=e[15],p}function Nn(e){return e.status===`done`}function Pn(e){let t=(0,X.c)(36),{messages:n}=e,r;t[0]===n?r=t[1]:(r=n===void 0?[]:n,t[0]=n,t[1]=r);let i=r,{state:a,dispatch:o}=Re(),{isCreatingProject:s,selectedThreadId:c}=a,{handleSend:l,handleStop:u,isStreaming:d,queuedMessagesForThread:f,handleRemoveQueuedMessage:p,showEmptyBalanceDialog:m,setShowEmptyBalanceDialog:h}=Dn(),g=a.pendingChatMessage?.threadId===c,v=d||g,y=i.length>0,{hasChanges:b,changedFilesCount:x}=Sn(c??void 0),{setActiveMainTab:S}=$e(),C;t[2]!==o||t[3]!==c?(C=async()=>{if(c)try{let e=await _(c);o({type:Y.ClearMessages}),console.log(`New conversation started:`,e);let t=await se(c);o({type:Y.SetMessages,messages:t.messages})}catch(e){console.error(`Failed to start new chat:`,e)}},t[2]=o,t[3]=c,t[4]=C):C=t[4];let w=C,T;t[5]===h?T=t[6]:(T=()=>h(!1),t[5]=h,t[6]=T);let E;t[7]!==m||t[8]!==T?(E=(0,Q.jsx)(On,{open:m,onClose:T}),t[7]=m,t[8]=T,t[9]=E):E=t[9];let O;t[10]!==x||t[11]!==w||t[12]!==b||t[13]!==y||t[14]!==S?(O=(y||b)&&(0,Q.jsxs)(`div`,{className:`absolute -top-12 left-0 z-10 ml-8 flex items-center gap-2`,children:[y&&(0,Q.jsxs)(D,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:w,children:[(0,Q.jsx)(he,{className:`h-4 w-4 shrink-0`}),`New Chat`]}),b&&(0,Q.jsxs)(D,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:()=>S(`review`),children:[(0,Q.jsx)(be,{className:`h-4 w-4 shrink-0`}),x,` `,x===1?`File`:`Files`,` Changed`]}),y&&(0,Q.jsx)(Mn,{})]}),t[10]=x,t[11]=w,t[12]=b,t[13]=y,t[14]=S,t[15]=O):O=t[15];let k=!c&&!s,A;t[16]!==v||t[17]!==p||t[18]!==l||t[19]!==u||t[20]!==f||t[21]!==k?(A=(0,Q.jsx)(qt,{onSend:l,onStop:u,isStreaming:v,disabled:k,initialValue:``,queuedMessages:f,onRemoveQueuedMessage:p,isOverlay:!1}),t[16]=v,t[17]=p,t[18]=l,t[19]=u,t[20]=f,t[21]=k,t[22]=A):A=t[22];let j;t[23]!==O||t[24]!==A?(j=(0,Q.jsxs)(`div`,{className:`relative`,children:[O,A]}),t[23]=O,t[24]=A,t[25]=j):j=t[25];let M=c??void 0,N;t[26]!==v||t[27]!==i||t[28]!==M?(N=(0,Q.jsx)(Tn,{threadId:M,isStreaming:v,messages:i}),t[26]=v,t[27]=i,t[28]=M,t[29]=N):N=t[29];let P;t[30]!==N||t[31]!==j?(P=(0,Q.jsxs)(`div`,{className:`relative mx-auto min-w-[400px] w-[90vw] max-w-3xl`,children:[j,N]}),t[30]=N,t[31]=j,t[32]=P):P=t[32];let F;return t[33]!==P||t[34]!==E?(F=(0,Q.jsxs)(Q.Fragment,{children:[E,P]}),t[33]=P,t[34]=E,t[35]=F):F=t[35],F}export{st as _,an as a,nn as c,vt as d,mt as f,ut as g,lt as h,rn as i,tn as l,dt as m,Sn as n,ln as o,ht as p,Qt as r,en as s,Pn as t,$t as u};
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$n as t,Mr as n,Sa as r,aa as i,pa as a,ua as o,wa as s}from"./dialogs-config-B91VQpxo.js";import{C as c,T as l,_ as u,b as d,d as f,f as p,g as m,h,m as g,w as _,x as v,y}from"./react-vendor-nPkCWaAR.js";var b=r(),x=e(s(),1),S=n(),C=d,w=l,T=x.forwardRef((e,n)=>{let r=(0,b.c)(14),i,a,s,c;r[0]===e?(i=r[1],a=r[2],s=r[3],c=r[4]):({className:a,inset:s,children:i,...c}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=s,r[4]=c);let l=s&&`pl-8`,u;r[5]!==a||r[6]!==l?(u=t(`flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground`,l,a),r[5]=a,r[6]=l,r[7]=u):u=r[7];let d;r[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,S.jsx)(o,{className:`ml-auto h-4 w-4`}),r[8]=d):d=r[8];let f;return r[9]!==i||r[10]!==c||r[11]!==n||r[12]!==u?(f=(0,S.jsxs)(_,{ref:n,className:u,...c,children:[i,d]}),r[9]=i,r[10]=c,r[11]=n,r[12]=u,r[13]=f):f=r[13],f});T.displayName=_.displayName;var E=x.forwardRef((e,n)=>{let r=(0,b.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=t(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==n||r[7]!==o?(s=(0,S.jsx)(c,{ref:n,className:o,...a}),r[5]=a,r[6]=n,r[7]=o,r[8]=s):s=r[8],s});E.displayName=c.displayName;var D=x.forwardRef((e,n)=>{let r=(0,b.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=t(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==n||r[7]!==o?(s=(0,S.jsx)(u,{children:(0,S.jsx)(p,{ref:n,className:o,...a})}),r[5]=a,r[6]=n,r[7]=o,r[8]=s):s=r[8],s});D.displayName=p.displayName;var O=x.forwardRef((e,n)=>{let r=(0,b.c)(11),i,a,o;r[0]===e?(i=r[1],a=r[2],o=r[3]):({className:i,inset:a,...o}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o);let s=a&&`pl-8`,c;r[4]!==i||r[5]!==s?(c=t(`relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,s,i),r[4]=i,r[5]=s,r[6]=c):c=r[6];let l;return r[7]!==o||r[8]!==n||r[9]!==c?(l=(0,S.jsx)(g,{ref:n,className:c,...o}),r[7]=o,r[8]=n,r[9]=c,r[10]=l):l=r[10],l});O.displayName=g.displayName;var k=x.forwardRef((e,n)=>{let r=(0,b.c)(14),i,o,s,c;r[0]===e?(i=r[1],o=r[2],s=r[3],c=r[4]):({className:s,children:o,checked:i,...c}=e,r[0]=e,r[1]=i,r[2]=o,r[3]=s,r[4]=c);let l;r[5]===s?l=r[6]:(l=t(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,s),r[5]=s,r[6]=l);let u;r[7]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,S.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,S.jsx)(h,{children:(0,S.jsx)(a,{className:`h-4 w-4`})})}),r[7]=u):u=r[7];let d;return r[8]!==i||r[9]!==o||r[10]!==c||r[11]!==n||r[12]!==l?(d=(0,S.jsxs)(f,{ref:n,className:l,checked:i,...c,children:[u,o]}),r[8]=i,r[9]=o,r[10]=c,r[11]=n,r[12]=l,r[13]=d):d=r[13],d});k.displayName=f.displayName;var A=x.forwardRef((e,n)=>{let r=(0,b.c)(12),a,o,s;r[0]===e?(a=r[1],o=r[2],s=r[3]):({className:o,children:a,...s}=e,r[0]=e,r[1]=a,r[2]=o,r[3]=s);let c;r[4]===o?c=r[5]:(c=t(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,o),r[4]=o,r[5]=c);let l;r[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,S.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,S.jsx)(h,{children:(0,S.jsx)(i,{className:`h-2 w-2 fill-current`})})}),r[6]=l):l=r[6];let u;return r[7]!==a||r[8]!==s||r[9]!==n||r[10]!==c?(u=(0,S.jsxs)(y,{ref:n,className:c,...s,children:[l,a]}),r[7]=a,r[8]=s,r[9]=n,r[10]=c,r[11]=u):u=r[11],u});A.displayName=y.displayName;var j=x.forwardRef((e,n)=>{let r=(0,b.c)(11),i,a,o;r[0]===e?(i=r[1],a=r[2],o=r[3]):({className:i,inset:a,...o}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o);let s=a&&`pl-8`,c;r[4]!==i||r[5]!==s?(c=t(`px-2 py-1.5 text-sm font-semibold text-foreground`,s,i),r[4]=i,r[5]=s,r[6]=c):c=r[6];let l;return r[7]!==o||r[8]!==n||r[9]!==c?(l=(0,S.jsx)(m,{ref:n,className:c,...o}),r[7]=o,r[8]=n,r[9]=c,r[10]=l):l=r[10],l});j.displayName=m.displayName;var M=x.forwardRef((e,n)=>{let r=(0,b.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=t(`-mx-1 my-1 h-px bg-border`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==n||r[7]!==o?(s=(0,S.jsx)(v,{ref:n,className:o,...a}),r[5]=a,r[6]=n,r[7]=o,r[8]=s):s=r[8],s});M.displayName=v.displayName;var N=e=>{let n=(0,b.c)(8),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=t(`ml-auto text-xs tracking-widest text-muted-foreground`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,S.jsx)(`span`,{className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o};N.displayName=`ContextMenuShortcut`;export{w as a,M as i,D as n,O as r,C as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./history-view-Dj4NiScy.js";export{e as ConversationHistoryView,e as default};
|