cli-jaw 2.2.12 → 2.2.13
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/src/agent/error-classifier.js +11 -2
- package/dist/src/agent/error-classifier.js.map +1 -1
- package/dist/src/agent/events/claude.js +7 -1
- package/dist/src/agent/events/claude.js.map +1 -1
- package/dist/src/agent/events/fulltext-bound.js +32 -0
- package/dist/src/agent/events/fulltext-bound.js.map +1 -0
- package/dist/src/agent/events/grok.js +7 -1
- package/dist/src/agent/events/grok.js.map +1 -1
- package/dist/src/agent/events/helpers.js +17 -4
- package/dist/src/agent/events/helpers.js.map +1 -1
- package/dist/src/agent/lifecycle-handler.js +56 -5
- package/dist/src/agent/lifecycle-handler.js.map +1 -1
- package/dist/src/agent/pi-runtime.js +30 -1
- package/dist/src/agent/pi-runtime.js.map +1 -1
- package/dist/src/agent/spawn/exit-drain.js +96 -0
- package/dist/src/agent/spawn/exit-drain.js.map +1 -0
- package/dist/src/agent/spawn/line-buffer.js +26 -0
- package/dist/src/agent/spawn/line-buffer.js.map +1 -0
- package/dist/src/agent/spawn/process-kill.js +31 -0
- package/dist/src/agent/spawn/process-kill.js.map +1 -1
- package/dist/src/agent/spawn.js +80 -23
- package/dist/src/agent/spawn.js.map +1 -1
- package/dist/src/agent/watchdog.js +21 -5
- package/dist/src/agent/watchdog.js.map +1 -1
- package/dist/src/routes/link-preview.js +14 -0
- package/dist/src/routes/link-preview.js.map +1 -1
- package/package.json +3 -1
- package/public/dist/assets/CodeCanvas-CbfPP7Ad.js +3 -0
- package/public/dist/assets/{DocPanel-DtYwv3n3.js → DocPanel-Dz-J_l5M.js} +1 -1
- package/public/dist/assets/MarkdownRenderer-CXrilOsG.js +15 -0
- package/public/dist/assets/MarkdownRenderer-DZVh_xX2.js +1 -0
- package/public/dist/assets/{MilkdownWysiwygEditor-BNoLGbFC.js → MilkdownWysiwygEditor-Em7iC6y9.js} +8 -8
- package/public/dist/assets/{react-dom-AWKMTIe7.js → bounded-set-CFlZiEF4.js} +1 -1
- package/public/dist/assets/manager-DaN201mN.js +13 -0
- package/public/dist/assets/{wiki-link-resolver-BfNXN9px.js → wiki-link-resolver-DyFzBTIQ.js} +1 -1
- package/public/dist/manager/index.html +1 -1
- package/public/manager/src/SidebarRailRouter.tsx +9 -3
- package/public/manager/src/browser-panel/use-embedded-target-sync.ts +19 -1
- package/public/manager/src/code/CodeCanvas.tsx +14 -2
- package/public/manager/src/code/CodeTranscript.tsx +33 -9
- package/public/manager/src/code/CodeWorkbench.tsx +1 -1
- package/public/manager/src/code/code-event-dedupe.ts +27 -3
- package/public/manager/src/code/use-code-transcript-scroll.ts +28 -3
- package/public/manager/src/code/use-throttled-markdown.ts +75 -0
- package/public/manager/src/code/useCodeTranscriptVirtualRows.ts +19 -0
- package/public/manager/src/electron-metrics.tsx +7 -0
- package/public/manager/src/jaw-ceo/useJawCeo.ts +6 -1
- package/public/manager/src/jaw-ceo/useJawCeoVirtualTimeline.ts +5 -0
- package/public/manager/src/lib/bounded-set.ts +15 -0
- package/public/manager/src/lib/fnv1a.ts +14 -0
- package/public/manager/src/notes/rendering/CodeBlock.tsx +13 -4
- package/public/manager/src/notes/rendering/MarkdownRenderer.tsx +14 -2
- package/public/manager/src/notes/rendering/highlight-cache.ts +111 -0
- package/public/manager/src/notes/useNotesExternalSync.ts +6 -1
- package/scripts/bundle-sidecar.sh +8 -0
- package/scripts/check-electron-no-native.cjs +90 -4
- package/scripts/check-native-load.cjs +157 -0
- package/scripts/check-sidecar-smoke.mjs +151 -0
- package/scripts/ensure-native-modules.cjs +222 -18
- package/scripts/release-gates.mjs +29 -0
- package/public/dist/assets/CodeCanvas-BZo3dohZ.js +0 -3
- package/public/dist/assets/MarkdownRenderer-CHacL2M_.js +0 -15
- package/public/dist/assets/MarkdownRenderer-DyrB9FbZ.js +0 -1
- package/public/dist/assets/manager-DL1GygQL.js +0 -13
|
@@ -7,10 +7,16 @@
|
|
|
7
7
|
* rebuild it in-place before build/test steps continue.
|
|
8
8
|
*/
|
|
9
9
|
const { execFileSync } = require('child_process');
|
|
10
|
-
const { existsSync, rmSync } = require('fs');
|
|
10
|
+
const { existsSync, mkdirSync, readFileSync, realpathSync, rmSync, statSync, writeFileSync } = require('fs');
|
|
11
11
|
const { delimiter, dirname, join } = require('path');
|
|
12
|
+
const { createRequire } = require('module');
|
|
13
|
+
const { createHash } = require('crypto');
|
|
14
|
+
const { tmpdir } = require('os');
|
|
12
15
|
|
|
13
16
|
const root = join(__dirname, '..');
|
|
17
|
+
// Resolve symlinks so launching through a symlinked bin shares one lock identity.
|
|
18
|
+
let realRoot = root;
|
|
19
|
+
try { realRoot = realpathSync(root); } catch { /* fall back to the literal path */ }
|
|
14
20
|
const nodeBinDir = dirname(process.execPath);
|
|
15
21
|
|
|
16
22
|
function npmCliCandidates() {
|
|
@@ -85,33 +91,231 @@ function loadBetterSqlite3() {
|
|
|
85
91
|
}
|
|
86
92
|
}
|
|
87
93
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Can the dependency be RESOLVED at all?
|
|
96
|
+
*
|
|
97
|
+
* This is deliberately separate from loading it: resolution failure means the
|
|
98
|
+
* install is missing/pruned, while a resolvable-but-unloadable module means an
|
|
99
|
+
* ABI/native problem. Conflating the two makes a missing install look like an
|
|
100
|
+
* ABI mismatch and triggers a pointless rebuild (defect D1).
|
|
101
|
+
*
|
|
102
|
+
* Resolution is used rather than an existsSync('node_modules') check because
|
|
103
|
+
* other layouts (e.g. Plug'n'Play) resolve without that directory.
|
|
104
|
+
*/
|
|
105
|
+
function canResolveBetterSqlite3() {
|
|
106
|
+
try {
|
|
107
|
+
createRequire(join(root, 'package.json')).resolve('better-sqlite3');
|
|
108
|
+
return true;
|
|
109
|
+
} catch {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Classify a native load failure.
|
|
116
|
+
*
|
|
117
|
+
* @param {unknown} error the error thrown while loading
|
|
118
|
+
* @param {boolean} resolved whether the package could be resolved at all
|
|
119
|
+
* @returns {'missing'|'abi'|'other'}
|
|
120
|
+
*
|
|
121
|
+
* `missing` is the only class that was narrowed; `abi` stays deliberately broad
|
|
122
|
+
* so the pre-existing auto-recovery for real ABI mismatches does not regress.
|
|
123
|
+
*/
|
|
124
|
+
function classifyNativeError(error, resolved) {
|
|
125
|
+
if (!resolved) return 'missing';
|
|
126
|
+
|
|
127
|
+
const err = /** @type {{ code?: string } | null} */ (error);
|
|
128
|
+
const text = String(error && (/** @type {Error} */ (error).stack || /** @type {Error} */ (error).message || error));
|
|
129
|
+
|
|
130
|
+
if (err && err.code === 'MODULE_NOT_FOUND') return 'missing';
|
|
131
|
+
if (
|
|
132
|
+
(err && err.code === 'ERR_DLOPEN_FAILED')
|
|
133
|
+
|| text.includes('NODE_MODULE_VERSION')
|
|
134
|
+
|| text.includes('ERR_DLOPEN_FAILED')
|
|
135
|
+
|| text.includes('better_sqlite3.node')
|
|
136
|
+
|| text.includes('was compiled against a different Node.js version')
|
|
137
|
+
) {
|
|
138
|
+
return 'abi';
|
|
139
|
+
}
|
|
140
|
+
return 'other';
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function runtimeFacts() {
|
|
144
|
+
return `Node ${process.version} (ABI ${process.versions.modules}), ${process.platform}/${process.arch}`;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// ─── cross-process repair lock ──────────────────────
|
|
148
|
+
//
|
|
149
|
+
// Two processes rebuilding in the same directory race over one build/ tree,
|
|
150
|
+
// because node-gyp rebuild is clean + configure + build. jaw can hit this
|
|
151
|
+
// easily: the dashboard, the CLI and the Electron sidecar may all start at once.
|
|
152
|
+
//
|
|
153
|
+
// mkdir is atomic on POSIX and Windows, so it is used as the acquire primitive.
|
|
154
|
+
// No external dependency is taken: this script must run before install
|
|
155
|
+
// completes, so it can only rely on Node built-ins.
|
|
156
|
+
// The lock deliberately lives OUTSIDE node_modules: this script's own failure
|
|
157
|
+
// mode is a missing/pruned dependency tree, and a concurrent npm install can
|
|
158
|
+
// remove that directory while the lock is held. It is keyed by the resolved
|
|
159
|
+
// install root so every entry point into the same installation shares one lock.
|
|
160
|
+
const LOCK_DIR = join(
|
|
161
|
+
tmpdir(),
|
|
162
|
+
`jaw-native-rebuild-${createHash('sha256').update(realRoot).digest('hex').slice(0, 16)}.lock`,
|
|
163
|
+
);
|
|
164
|
+
// Liveness is decided by the owner PID, not by elapsed time: the rebuild runs
|
|
165
|
+
// synchronously (execFileSync blocks the event loop), so a timer-based heartbeat
|
|
166
|
+
// could never fire while the lock is actually held. The age check below is only a
|
|
167
|
+
// backstop for a PID that cannot be probed.
|
|
168
|
+
const LOCK_STALE_MS = 60 * 60 * 1000;
|
|
169
|
+
|
|
170
|
+
/** Block this process without spinning the CPU (this script is synchronous). */
|
|
171
|
+
function sleepSync(ms) {
|
|
172
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function readLockAgeMs() {
|
|
176
|
+
try {
|
|
177
|
+
return Date.now() - statSync(LOCK_DIR).mtimeMs;
|
|
178
|
+
} catch {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Is the process that recorded ownership still alive?
|
|
185
|
+
*
|
|
186
|
+
* @returns {boolean|null} null when liveness cannot be determined
|
|
187
|
+
*/
|
|
188
|
+
function isLockOwnerAlive() {
|
|
189
|
+
let pid;
|
|
190
|
+
try {
|
|
191
|
+
pid = Number.parseInt(readFileSync(join(LOCK_DIR, 'owner'), 'utf8').trim(), 10);
|
|
192
|
+
} catch {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
if (!Number.isInteger(pid) || pid <= 0) return null;
|
|
196
|
+
if (pid === process.pid) return true;
|
|
197
|
+
try {
|
|
198
|
+
// Signal 0 performs the permission/existence check without delivering.
|
|
199
|
+
process.kill(pid, 0);
|
|
200
|
+
return true;
|
|
201
|
+
} catch (error) {
|
|
202
|
+
if (error && error.code === 'EPERM') return true; // alive, owned by another user
|
|
203
|
+
if (error && error.code === 'ESRCH') return false;
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function acquireRepairLock(waitMs) {
|
|
209
|
+
const deadline = Date.now() + waitMs;
|
|
210
|
+
for (;;) {
|
|
211
|
+
try {
|
|
212
|
+
mkdirSync(LOCK_DIR, { recursive: false });
|
|
213
|
+
try {
|
|
214
|
+
writeFileSync(join(LOCK_DIR, 'owner'), String(process.pid));
|
|
215
|
+
} catch { /* ownership record is advisory only */ }
|
|
216
|
+
return true;
|
|
217
|
+
} catch (error) {
|
|
218
|
+
if (!error || error.code !== 'EEXIST') return false;
|
|
219
|
+
|
|
220
|
+
// Reclaim only a lock whose owner is provably gone. A slow but healthy
|
|
221
|
+
// rebuild must never have its lock stolen, so elapsed time alone is
|
|
222
|
+
// not sufficient grounds for reclaiming.
|
|
223
|
+
const ownerAlive = isLockOwnerAlive();
|
|
224
|
+
const age = readLockAgeMs();
|
|
225
|
+
const abandoned = ownerAlive === false
|
|
226
|
+
|| (ownerAlive === null && age !== null && age > LOCK_STALE_MS);
|
|
227
|
+
if (abandoned) {
|
|
228
|
+
console.warn('[jaw:native] reclaiming repair lock abandoned by a dead process');
|
|
229
|
+
try { rmSync(LOCK_DIR, { recursive: true, force: true }); } catch { /* retry below */ }
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
if (Date.now() >= deadline) return false;
|
|
233
|
+
sleepSync(250);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function releaseRepairLock() {
|
|
239
|
+
try { rmSync(LOCK_DIR, { recursive: true, force: true }); } catch { /* best effort */ }
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function reportMissing() {
|
|
243
|
+
console.error('[jaw:native] ❌ dependencies are not installed (cannot resolve better-sqlite3).');
|
|
244
|
+
console.error(`[jaw:native] install root: ${root}`);
|
|
245
|
+
console.error('[jaw:native] run: npm install');
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
module.exports = {
|
|
249
|
+
classifyNativeError,
|
|
250
|
+
// Exposed so the lock contract can be exercised for real rather than
|
|
251
|
+
// asserted against source text.
|
|
252
|
+
__testing: {
|
|
253
|
+
lockDir: LOCK_DIR,
|
|
254
|
+
acquire: acquireRepairLock,
|
|
255
|
+
release: releaseRepairLock,
|
|
256
|
+
},
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
// Importable for tests; only the direct-run path performs any repair.
|
|
260
|
+
if (require.main !== module) return;
|
|
261
|
+
|
|
262
|
+
const resolvedBefore = canResolveBetterSqlite3();
|
|
263
|
+
if (!resolvedBefore) {
|
|
264
|
+
reportMissing();
|
|
265
|
+
process.exit(1);
|
|
96
266
|
}
|
|
97
267
|
|
|
98
268
|
const firstError = loadBetterSqlite3();
|
|
99
269
|
if (!firstError) process.exit(0);
|
|
100
270
|
|
|
101
|
-
|
|
271
|
+
const diagnosis = classifyNativeError(firstError, resolvedBefore);
|
|
272
|
+
|
|
273
|
+
if (diagnosis === 'missing') {
|
|
274
|
+
reportMissing();
|
|
275
|
+
process.exit(1);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (diagnosis === 'other') {
|
|
102
279
|
console.error('[jaw:native] better-sqlite3 load failed with a non-recoverable error.');
|
|
280
|
+
console.error(`[jaw:native] ${runtimeFacts()}`);
|
|
103
281
|
console.error(firstError);
|
|
104
282
|
process.exit(1);
|
|
105
283
|
}
|
|
106
284
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
console.error(
|
|
113
|
-
console.error(secondError);
|
|
285
|
+
// Serialize repair across processes. Waiting is the normal outcome here, not an
|
|
286
|
+
// error: whoever holds the lock is fixing the very thing this process needs.
|
|
287
|
+
const locked = acquireRepairLock(5 * 60 * 1000);
|
|
288
|
+
if (!locked) {
|
|
289
|
+
console.error('[jaw:native] another process is repairing native modules and did not finish in time.');
|
|
290
|
+
console.error(`[jaw:native] if no such process is running, remove: ${LOCK_DIR}`);
|
|
114
291
|
process.exit(1);
|
|
115
292
|
}
|
|
116
293
|
|
|
117
|
-
|
|
294
|
+
// process.exit() skips finally blocks, and a crash skips them too; the stale
|
|
295
|
+
// reclaim above is the backstop, but releasing on exit keeps the common case clean.
|
|
296
|
+
process.on('exit', releaseRepairLock);
|
|
297
|
+
|
|
298
|
+
try {
|
|
299
|
+
// Re-check under the lock: the process we waited for may already have fixed it.
|
|
300
|
+
if (!loadBetterSqlite3()) {
|
|
301
|
+
console.log('[jaw:native] better-sqlite3 was repaired by another process.');
|
|
302
|
+
releaseRepairLock();
|
|
303
|
+
process.exit(0);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
console.warn('[jaw:native] better-sqlite3 load failed — rebuilding native module for current Node runtime...');
|
|
307
|
+
rebuildBetterSqlite3();
|
|
308
|
+
|
|
309
|
+
const secondError = loadBetterSqlite3();
|
|
310
|
+
if (secondError) {
|
|
311
|
+
console.error('[jaw:native] better-sqlite3 is still not loadable after rebuild.');
|
|
312
|
+
console.error(`[jaw:native] ${runtimeFacts()}`);
|
|
313
|
+
console.error(secondError);
|
|
314
|
+
releaseRepairLock();
|
|
315
|
+
process.exit(1);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
console.log('[jaw:native] better-sqlite3 is ready for this Node runtime.');
|
|
319
|
+
} finally {
|
|
320
|
+
releaseRepairLock();
|
|
321
|
+
}
|
|
@@ -428,6 +428,35 @@ const GATES = {
|
|
|
428
428
|
return { ok: true, detail: 'packaged sidecar keeps every runtime dependency' };
|
|
429
429
|
},
|
|
430
430
|
},
|
|
431
|
+
'native-load': {
|
|
432
|
+
description: 'shipped native addons actually dlopen, and spawn-helper stays executable',
|
|
433
|
+
check() {
|
|
434
|
+
const r = run('node', ['scripts/check-native-load.cjs'], { timeout: 60_000 });
|
|
435
|
+
// Exit 3 means nothing was probed. Reporting that as a pass with a
|
|
436
|
+
// substantive detail would be a lie of exactly the kind this gate
|
|
437
|
+
// exists to catch, so say what actually happened.
|
|
438
|
+
if (r.status === 3) {
|
|
439
|
+
return { ok: true, detail: 'SKIPPED — electron/node_modules absent, nothing probed' };
|
|
440
|
+
}
|
|
441
|
+
if (r.status !== 0) {
|
|
442
|
+
return { ok: false, detail: (r.stdout || r.stderr || '').trim().slice(-800) };
|
|
443
|
+
}
|
|
444
|
+
return { ok: true, detail: 'node-pty loads under this runtime' };
|
|
445
|
+
},
|
|
446
|
+
},
|
|
447
|
+
'sidecar-smoke': {
|
|
448
|
+
description: 'critical sidecar modules import from the bundled tree, not just resolve statically',
|
|
449
|
+
check() {
|
|
450
|
+
const r = run('node', ['scripts/check-sidecar-smoke.mjs'], { timeout: 120_000 });
|
|
451
|
+
if (r.status === 3) {
|
|
452
|
+
return { ok: true, detail: 'SKIPPED — sidecar not bundled, nothing imported' };
|
|
453
|
+
}
|
|
454
|
+
if (r.status !== 0) {
|
|
455
|
+
return { ok: false, detail: (r.stdout || r.stderr || '').trim().slice(-800) };
|
|
456
|
+
}
|
|
457
|
+
return { ok: true, detail: 'bundled sidecar imports its critical entry surfaces' };
|
|
458
|
+
},
|
|
459
|
+
},
|
|
431
460
|
'gate-docs': {
|
|
432
461
|
description: 'structure/INDEX.md documents exactly the gates that exist, and each is npm-addressable',
|
|
433
462
|
check() {
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-render-Bjnw0wQ6.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-XQCOJYun.js";import{t}from"./preload-helper-DFYRRz9w.js";import{a as n,i as r,n as i,r as a,t as o}from"./esm-CT1xxdH5.js";import{n as s,t as c}from"./jsx-runtime-gFMgZ0TQ.js";import{t as l}from"./react-dom-AWKMTIe7.js";import{t as u}from"./desktop-bridge-CvdhnJQo.js";var d=e(s(),1),f=l();function p(e){let t=typeof window<`u`?window.location.origin:``,n=typeof window<`u`?window.location.port:``,r=t&&n===String(e)?t:`http://127.0.0.1:${e}`;async function i(e,t,n){let i={method:e};n&&(i.headers={"Content-Type":`application/json`},i.body=JSON.stringify(n));let a=await(await fetch(`${r}${t}`,i)).json();if(!a.ok)throw Error(a.error||`${e} ${t} failed`);return a}return{async listSessions(){return(await i(`GET`,`/api/code/sessions`)).sessions},async listStoredSessions(e={}){let t=e.scope??`all`,n=new URLSearchParams({scope:t});return t===`cwd`&&e.cwd&&n.set(`cwd`,e.cwd),(await i(`GET`,`/api/code/sessions/stored${`?${n.toString()}`}`)).sessions},async listModelOptions(){return i(`GET`,`/api/code/models`)},async setDefaultModel(e){return i(`POST`,`/api/code/model-default`,{modelId:e})},async listModelAssignments(){return i(`GET`,`/api/code/model-assignments`)},async setModelAssignment(e,t){let n=typeof t==`string`?{modelId:t}:t;return i(`PUT`,`/api/code/model-assignments/${encodeURIComponent(e)}`,n)},async clearModelAssignment(e){return i(`DELETE`,`/api/code/model-assignments/${encodeURIComponent(e)}`)},async listModelPresets(){return i(`GET`,`/api/code/model-presets`)},async getGitInfo(e){return await i(`GET`,`/api/code/git-info?cwd=${encodeURIComponent(e)}`)},async loadSession(e,t){return(await i(`POST`,`/api/code/sessions/load`,{sessionId:e,cwd:t})).session},async createSession(e,t){return(await i(`POST`,`/api/code/sessions`,{cwd:e,...t?{model:t}:{}})).session},async sendPrompt(e,t){return i(`POST`,`/api/code/sessions/${e}/prompt`,{text:t})},async cancelPrompt(e){await i(`POST`,`/api/code/sessions/${e}/cancel`)},async closeSession(e){await i(`DELETE`,`/api/code/sessions/${e}`)},async answerPermission(e,t){await i(`POST`,`/api/code/permissions/${e}`,{optionId:t})},async setSessionConfig(e,t,n){await i(`POST`,`/api/code/sessions/${e}/config`,{configId:t,valueId:n})},async extMethod(e,t,n){return(await i(`POST`,`/api/code/sessions/${e}/ext`,{method:t,params:n})).result},async forkSession(e,t){return(await i(`POST`,`/api/code/sessions/${e}/fork`,{cwd:t})).session},async setSessionModel(e,t){await i(`POST`,`/api/code/sessions/${e}/model`,{modelId:t})},pickWorkspace(){return i(`POST`,`/api/code/workspace/pick`)}}}var m=c();function h({client:e,activeSessionId:t,workingDir:n,onSelectSession:r,onLoadSession:i,onNewSession:a}){let[o,s]=(0,d.useState)([]),[c,l]=(0,d.useState)([]),[u,f]=(0,d.useState)(!0),[p,h]=(0,d.useState)(``),[g,_]=(0,d.useState)(``),[v,y]=(0,d.useState)(`all`),b=(0,d.useCallback)(async()=>{f(!0),h(``);let t=e=>e instanceof Error?e.message:String(e),r=v===`cwd`?{scope:`cwd`,cwd:n}:{scope:`all`},[i,a]=await Promise.allSettled([e.listSessions(),e.listStoredSessions(r)]),o=[];if(i.status===`fulfilled`){let e=i.value;s(e.filter(e=>e.status!==`closed`));let n=new Set(e.map(e=>e.sessionId));a.status===`fulfilled`?l(a.value.filter(e=>!n.has(e.sessionId))):(l([]),o.push(`History: ${t(a.reason)}`))}else s([]),o.push(`Live: ${t(i.reason)}`),a.status===`fulfilled`?l(a.value):(l([]),o.push(`History: ${t(a.reason)}`));o.length>0&&h(o.join(` · `)),f(!1)},[e,v,n]);(0,d.useEffect)(()=>{b()},[b]);let x=e=>e.split(`/`).pop()||e,S=e=>{let t=e.replayEvents?.find(e=>e.event===`code_user_message_chunk`)?.update??{},n=t.content;return String(n?.text??t.text??``).split(/\r?\n/)[0]?.replace(/\s+/g,` `).trim()||``},C=e=>e.title?.trim()||S(e)||x(e.cwd)||e.sessionId.slice(0,12)||`Untitled session`,w=e=>x(e.cwd),ee=e=>[e.sessionId,e.title??``,S(e),e.cwd].join(` `).toLowerCase(),T=e=>e.title?.trim()||e.firstMessage?.replace(/\s+/g,` `).trim()||e.sessionId.slice(0,12)||`Untitled session`,E=e=>{if(typeof e.lastModified==`number`)return e.lastModified;if(e.updatedAt){let t=Date.parse(e.updatedAt);if(Number.isFinite(t))return t}return 0},D=e=>{let t=[x(e.cwd)];return e.messageCount!==void 0&&t.push(`${e.messageCount} messages`),t.filter(Boolean).join(` · `)},O=e=>[e.sessionId,e.title??``,e.firstMessage??``,e.cwd].join(` `).toLowerCase(),k=c.filter(e=>!g||O(e).includes(g.toLowerCase())).sort((e,t)=>E(t)-E(e)).slice(0,20),A=k.reduce((e,t)=>{let n=e.find(e=>e.cwd===t.cwd);return n?n.sessions.push(t):e.push({cwd:t.cwd,sessions:[t]}),e},[]),j=p?`Session data could not fully load.`:v===`cwd`?`No sessions for this cwd. Switch to All to browse global history.`:`No JWC sessions found.`;return(0,m.jsxs)(`div`,{className:`code-session-list`,children:[(0,m.jsxs)(`div`,{className:`code-session-list-header`,children:[(0,m.jsx)(`span`,{className:`code-session-list-title`,children:`Sessions`}),(0,m.jsx)(`button`,{type:`button`,className:`code-session-new-btn`,onClick:a,"aria-label":`New code session`,children:`+`})]}),(0,m.jsxs)(`div`,{className:`code-session-view-toggle`,"aria-label":`Session view`,children:[(0,m.jsx)(`button`,{type:`button`,className:`code-session-view-btn${v===`all`?` active`:``}`,onClick:()=>y(`all`),children:`All`}),(0,m.jsx)(`button`,{type:`button`,className:`code-session-view-btn${v===`cwd`?` active`:``}`,onClick:()=>y(`cwd`),children:`This cwd`}),(0,m.jsx)(`button`,{type:`button`,className:`code-session-view-btn${v===`grouped`?` active`:``}`,onClick:()=>y(`grouped`),children:`Group`})]}),v===`cwd`&&(0,m.jsx)(`div`,{className:`code-session-view-hint`,children:x(n)}),p&&(0,m.jsx)(`div`,{className:`code-session-list-error`,role:`status`,children:p}),o.length+c.length>3&&(0,m.jsx)(`input`,{className:`code-session-search`,type:`text`,value:g,onChange:e=>_(e.target.value),placeholder:`Search sessions...`}),u?(0,m.jsx)(`div`,{className:`code-session-list-loading`,children:`Loading...`}):(0,m.jsxs)(m.Fragment,{children:[o.length>0&&(0,m.jsx)(`ul`,{className:`code-session-list-items`,children:o.filter(e=>!g||ee(e).includes(g.toLowerCase())).map(e=>(0,m.jsx)(`li`,{children:(0,m.jsxs)(`button`,{type:`button`,className:`code-session-item ${e.sessionId===t?`active`:``}`,onClick:()=>r(e),children:[(0,m.jsx)(`span`,{className:`code-session-cwd`,children:C(e)}),(0,m.jsx)(`span`,{className:`code-session-meta`,children:w(e)}),(0,m.jsx)(`span`,{className:`code-session-status code-session-status-${e.status}`,children:e.status})]})},e.sessionId))}),k.length>0&&v!==`grouped`&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`code-session-list-divider`,children:`History`}),(0,m.jsx)(`ul`,{className:`code-session-list-items`,children:k.map(e=>(0,m.jsx)(`li`,{children:(0,m.jsxs)(`button`,{type:`button`,className:`code-session-item`,onClick:()=>i(e.sessionId,e.cwd),children:[(0,m.jsx)(`span`,{className:`code-session-cwd`,children:T(e)}),(0,m.jsx)(`span`,{className:`code-session-meta`,children:D(e)}),(0,m.jsx)(`span`,{className:`code-session-status`,children:`stored`})]})},e.sessionId))})]}),k.length>0&&v===`grouped`&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`code-session-list-divider`,children:`History by cwd`}),A.map(e=>(0,m.jsxs)(`section`,{className:`code-session-group`,children:[(0,m.jsxs)(`div`,{className:`code-session-group-title`,title:e.cwd,children:[x(e.cwd),` `,(0,m.jsx)(`span`,{children:e.sessions.length})]}),(0,m.jsx)(`ul`,{className:`code-session-list-items`,children:e.sessions.map(e=>(0,m.jsx)(`li`,{children:(0,m.jsxs)(`button`,{type:`button`,className:`code-session-item`,onClick:()=>i(e.sessionId,e.cwd),children:[(0,m.jsx)(`span`,{className:`code-session-cwd`,children:T(e)}),(0,m.jsx)(`span`,{className:`code-session-meta`,children:D(e)}),(0,m.jsx)(`span`,{className:`code-session-status`,children:`stored`})]})},e.sessionId))})]},e.cwd))]}),o.length===0&&k.length===0&&(0,m.jsx)(`div`,{className:`code-session-list-empty`,children:j})]})]})}function g(e,t){for(let n=e.length-1;n>=0;n--){let r=e[n];if(r?.role===`tool`&&r.toolCallId===t)return n}return-1}function _(e,t){return e?`${e}/${t}`:t}var v=[`allow_once`,`allow_always`,`reject_once`,`reject_always`],y={allow_once:`Allow once`,allow_always:`Always allow`,reject_once:`Deny once`,reject_always:`Always deny`},b={allow_once:`allow-once`,allow_always:`allow-always`,reject_once:`deny-once`,reject_always:`deny-always`},x=[{value:`always-allow`,label:`Always allow`,detail:`Auto-allow gated tools`,tone:`allow`},{value:`ask`,label:`Ask first`,detail:`Review each gated tool`,tone:`ask`},{value:`always-deny`,label:`Always deny`,detail:`Auto-deny gated tools`,tone:`deny`}],S={ask:`Review each gated tool`,"always-allow":`Auto-allow gated tools`,"always-deny":`Auto-deny gated tools`},C={allow_once:/^(allow[_\s-]?once|allow once)$/i,allow_always:/^(allow[_\s-]?always|always allow|always approve)$/i,reject_once:/^(reject[_\s-]?once|deny[_\s-]?once|reject|deny)$/i,reject_always:/^(reject[_\s-]?always|deny[_\s-]?always|always reject|always deny)$/i};function w(e){return[e.kind,e.optionId,e.id,e.name,e.label].map(e=>String(e??``)).join(` `).trim()}function ee(e){let t=e.optionId??e.id;return t==null||t===``?null:String(t)}function T(e,t){let n=e.name??e.label;return n==null||n===``?y[t]:String(n)}function E(e,t){let n=e.find(e=>e.kind===t),r=e.find(e=>e.optionId===t||e.id===t),i=e.find(e=>C[t].test(w(e))),a=n??r??i;if(!a)return null;let o=ee(a);return o?{kind:t,optionId:o,label:T(a,t),raw:a}:null}function D(e){return String(e.toolName??e.title??e.name??`tool`)}function O(e,t){let n={permissionId:e.permissionId,toolName:D(e.toolCall),...t};return{role:`permission`,text:n.error??n.optionLabel??n.decision,permissionAudit:n}}function k(e){if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function A(e){if(!Array.isArray(e))return null;let t=[];for(let n of e){if(typeof n==`string`){n&&t.push(n);continue}if(!n||typeof n!=`object`||Array.isArray(n))continue;let e=n,r=typeof e.type==`string`?e.type.toLowerCase():``,i=e.text;(!r||r===`text`)&&typeof i==`string`&&i&&t.push(i)}return t.length>0?t.join(`
|
|
3
|
-
`):null}function j(e){if(typeof e==`string`)return e;if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=A(t.content);if(n)return n;let r=t.details;if(r&&typeof r==`object`&&!Array.isArray(r)){let e=r.displayContent;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.text;if(typeof t==`string`&&t)return t}}return null}function te(e){return j(e)??k(e)}function M(e){if(typeof e==`string`)return{type:`text`,text:e};if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=typeof t.type==`string`?t.type.toLowerCase():``,r=typeof t.label==`string`?t.label:void 0;if(n===`diff`&&typeof t.diff==`string`)return{type:`diff`,diff:t.diff,...r?{label:r}:{}};if(n===`error`)return{type:`error`,text:k(t.text??t.error??t.message??t),...r?{label:r}:{}};if(n===`args`||n===`arguments`||n===`input`)return{type:`args`,json:t.json??t.args??t.arguments??t.input??t,...r?{label:r}:{}};if(n===`output`)return{type:`output`,text:te(t.text??t.output??t),...r?{label:r}:{}};if(n===`json`)return{type:`json`,json:t.json??t.value??t,...r?{label:r}:{}};if(typeof t.diff==`string`)return{type:`diff`,diff:t.diff,...r?{label:r}:{}};if(typeof t.text==`string`)return{type:`text`,text:t.text,...r?{label:r}:{}};let i=j(t);return i?{type:`text`,text:i,...r?{label:r}:{}}:{type:`json`,json:t,...r?{label:r}:{}}}function N(e,t,n,r){r==null||r===``||(t===`args`||t===`json`?e.push({type:t,label:n,json:r}):e.push({type:t,label:n,text:t===`output`?te(r):k(r)}))}function P(e){let t=[],n=e.content;if(Array.isArray(n))for(let e of n){let n=M(e);n&&t.push(n)}else{let e=M(n);e&&t.push(e)}return N(t,`args`,`Args`,e.args??e.arguments??e.input??e.rawInput),N(t,`output`,`Output`,e.rawOutput??e.output),N(t,`error`,`Error`,e.error??e.errorMessage??e.reason),t}var F={settings:{category:`settings`,popupKind:`settings`},theme:{category:`settings`,popupKind:`settings`},identity:{category:`settings`,popupKind:`settings`},"identity-auto":{category:`settings`,popupKind:`settings`},model:{category:`model`,popupKind:`model`},provider:{category:`provider`,popupKind:`provider`},login:{category:`provider`,popupKind:`provider`}},I={session:`session`,orchestrate:`workflow`,pabcd:`workflow`,goal:`workflow`,mcp:`utility`,move:`utility`,compact:`utility`,dump:`utility`,help:`utility`};function L(e){return e.trim().replace(/^\/+/,``)}function ne(e,t){let n=typeof e.source==`string`?e.source:``,r=typeof e.path==`string`?e.path:``;return n.includes(`skill`)||t.includes(`:`)?`jwc-skill`:n.includes(`custom`)?`jwc-custom`:n.includes(`file`)||r?`jwc-file`:F[t]||I[t]?`jwc-builtin`:`unknown`}function R(e){let t=e.input;if(!t||typeof t!=`object`)return;let n=t.hint;return typeof n==`string`&&n.trim()?n:void 0}function z(e){if(!e||typeof e!=`object`)return null;let t=e,n=L(String(t.name??``));if(!n)return null;let r=F[n],i=r?.category??I[n]??`unknown`,a=ne(t,n),o=t.supported!==!1&&t.disabled!==!0?r?`popup`:i===`unknown`?`pass-through`:`insert`:`unsupported`,s=typeof t.description==`string`&&t.description.trim()?t.description:void 0,c=R(t),l={name:n,displayName:`/${n}`,category:i,actionType:o,source:a,raw:t};return s&&(l.description=s),c&&(l.inputHint=c),r&&(l.popupKind=r.popupKind),o===`unsupported`&&(l.disabledReason=typeof t.disabledReason==`string`&&t.disabledReason.trim()?t.disabledReason:`Unsupported in Code mode`),l}function re(e){let t=Array.isArray(e)?e:[],n=new Set,r=[];for(let e of t){let t=z(e);!t||n.has(t.name)||(n.add(t.name),r.push(t))}return r}function ie(e){return[e.name,e.displayName,e.description??``,e.inputHint??``,e.category,e.source].join(` `).toLowerCase()}function B(e,t){let n=L(t.split(/\s+/)[0]??``).toLowerCase();if(!n)return e;let r=[],i=[];for(let t of e)t.name.toLowerCase().startsWith(n)?r.push(t):ie(t).includes(n)&&i.push(t);return[...r,...i]}function ae({value:e,disabled:t,onChange:n}){let r=x.find(t=>t.value===e)??x[0];return(0,m.jsxs)(`div`,{className:`code-permission-mode-field`,children:[(0,m.jsxs)(`div`,{className:`code-permission-mode-label`,children:[(0,m.jsx)(`span`,{children:`Permission mode`}),(0,m.jsx)(`strong`,{children:`Default: Always allow`})]}),(0,m.jsx)(`div`,{className:`code-permission-mode-list`,role:`listbox`,"aria-label":`Permission mode`,children:x.map(r=>(0,m.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":r.value===e,disabled:t,className:`code-permission-mode-option is-${r.tone}${r.value===e?` is-selected`:``}`,title:r.detail,onClick:()=>n(r.value),children:[(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:r.label}),(0,m.jsx)(`small`,{children:r.detail})]}),r.value===e&&(0,m.jsx)(`em`,{"aria-hidden":`true`,children:`✓`})]},r.value))}),(0,m.jsx)(`p`,{className:`code-permission-mode-note is-${r?.tone??`ask`}`,children:`Automatic modes answer with JWC persistent options and write a transcript audit row.`})]})}function oe(e){return e===`provider`?`Provider`:e===`model`?`Model`:e===`permission`?`Permissions`:e===`session`?`Session`:`Settings`}function V(e){return e===`jwc-cache`?`JWC cache`:`static fallback`}function H({popupKind:e,command:t,modelOptions:n,provider:r,model:i,modelAssignments:a,modelPresets:o,permissionMode:s,disabled:c,activeSessionId:l,error:u,onClose:f,onRefreshProviders:p,onProviderChange:h,onUseModel:g,onUseForNewSessions:_,onSetDefaultModel:v,onSetModelAssignment:y,onClearModelAssignment:b,onPermissionModeChange:x}){let S=(0,d.useRef)(null),C=(0,d.useRef)(null),w=n.providers.find(e=>e.id===r)??n.providers[0],[ee,T]=(0,d.useState)(``),[E,D]=(0,d.useState)(`models`),[O,k]=(0,d.useState)(r),[A,j]=(0,d.useState)(i),[te,M]=(0,d.useState)({}),N=n.providers.find(e=>e.id===O)??w,P=ee.trim().toLowerCase(),F=(0,d.useMemo)(()=>n.providers.filter(e=>P?e.id.toLowerCase().includes(P)||e.models.some(e=>e.toLowerCase().includes(P)):!0),[n.providers,P]),I=(0,d.useMemo)(()=>{let e=N?.models??[];return P?e.filter(e=>e.toLowerCase().includes(P)):e},[N?.models,P]),L=oe(e),ne=(0,d.useMemo)(()=>{let e=n.providers.length;return`${e} authenticated provider${e===1?``:`s`}`},[n.providers.length]),R=!!(l&&O&&A&&!c),z=!!(O&&A&&!c),re=(0,d.useMemo)(()=>[`inherit`,...N?.efforts??[]].map(e=>e===`min`?`minimal`:e).filter((e,t,n)=>e&&n.indexOf(e)===t).map(e=>({value:e,label:e===`inherit`?`inherit`:e===`minimal`?`min`:e})),[N?.efforts]);return(0,d.useEffect)(()=>{S.current?.focus()},[e,t.name]),(0,d.useEffect)(()=>{let e=document.activeElement;return()=>{e?.focus?.()}},[]),(0,d.useEffect)(()=>{e===`model`&&(T(``),k(r),j(i))},[i,e,r]),(0,d.useEffect)(()=>{if(e!==`model`)return;let t=N?.models??[];t.length>0&&!t.includes(A)&&j(t[0]??``)},[A,N?.models,e]),(0,d.useEffect)(()=>{if(e!==`model`||!a)return;let t={};for(let e of a.roles){let n=e.thinkingLevel===`min`?`minimal`:e.thinkingLevel;t[e.role]=n||`inherit`}M(t)},[a,e]),(0,d.useEffect)(()=>{let e=e=>{if(e.key===`Escape`){e.preventDefault(),f();return}if(e.key===`Tab`&&C.current){let t=C.current.querySelectorAll(`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`),n=t[0],r=t[t.length-1];if(!n||!r)return;let i=document.activeElement;e.shiftKey&&i===n?(e.preventDefault(),r.focus()):!e.shiftKey&&i===r&&(e.preventDefault(),n.focus())}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[f]),(0,m.jsx)(`div`,{className:`code-popup-backdrop`,role:`presentation`,onMouseDown:e=>{e.target===e.currentTarget&&f()},children:(0,m.jsxs)(`section`,{ref:C,className:`code-popup`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`code-command-popup-title`,children:[(0,m.jsxs)(`header`,{className:`code-popup-header`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`p`,{className:`code-popup-command`,children:t.displayName}),(0,m.jsx)(`h2`,{id:`code-command-popup-title`,children:L})]}),(0,m.jsx)(`button`,{ref:S,type:`button`,className:`code-popup-close`,onClick:f,"aria-label":`Close popup`,children:`x`})]}),e===`provider`&&(0,m.jsxs)(`div`,{className:`code-popup-section`,children:[(0,m.jsxs)(`div`,{className:`code-popup-section-head`,children:[(0,m.jsx)(`span`,{children:ne}),(0,m.jsx)(`button`,{type:`button`,className:`code-popup-secondary`,disabled:c,onClick:p,children:`Refresh`})]}),n.degraded&&(0,m.jsx)(`p`,{className:`code-popup-warning`,children:n.error??`Provider discovery is degraded.`}),u&&(0,m.jsx)(`p`,{className:`code-popup-error`,children:u}),(0,m.jsx)(`div`,{className:`code-provider-list`,role:`list`,children:n.providers.map(e=>(0,m.jsxs)(`button`,{type:`button`,className:`code-provider-row${e.id===r?` is-selected`:``}`,onClick:()=>h(e.id),disabled:c,children:[(0,m.jsx)(`span`,{className:`code-provider-name`,children:e.id}),(0,m.jsxs)(`span`,{className:`code-provider-meta`,children:[e.models.length,` models · `,V(e.modelSource)]})]},e.id))}),(0,m.jsxs)(`div`,{className:`code-popup-placeholder-actions`,children:[(0,m.jsx)(`button`,{type:`button`,disabled:!0,className:`code-popup-secondary`,children:`Add provider`}),(0,m.jsx)(`button`,{type:`button`,disabled:!0,className:`code-popup-secondary`,children:`Login`}),(0,m.jsx)(`span`,{children:`Provider add/login execution is next slice.`})]})]}),(e===`settings`||e===`permission`)&&(0,m.jsxs)(`div`,{className:`code-popup-section`,children:[(0,m.jsx)(ae,{value:s,disabled:!!c,onChange:x}),e===`settings`&&(0,m.jsxs)(`div`,{className:`code-popup-summary`,children:[(0,m.jsx)(`span`,{children:`Provider`}),(0,m.jsx)(`strong`,{children:r||`-`}),(0,m.jsx)(`span`,{children:`Model`}),(0,m.jsx)(`strong`,{children:i||`-`})]})]}),e===`model`&&(0,m.jsxs)(`div`,{className:`code-popup-section`,children:[u&&(0,m.jsx)(`p`,{className:`code-popup-error`,children:u}),(0,m.jsx)(`div`,{className:`code-model-tablist`,role:`tablist`,"aria-label":`Model settings tabs`,children:[`models`,`roles`,`profiles`].map(e=>(0,m.jsx)(`button`,{type:`button`,role:`tab`,id:`code-model-tab-${e}`,"aria-selected":E===e,"aria-controls":`code-model-panel-${e}`,tabIndex:E===e?0:-1,className:`code-model-tab${E===e?` is-active`:``}`,onClick:()=>D(e),onKeyDown:e=>{if(e.key!==`ArrowRight`&&e.key!==`ArrowLeft`)return;e.preventDefault();let t=[`models`,`roles`,`profiles`],n=e.key===`ArrowRight`?1:t.length-1;D(t[(t.indexOf(E)+n)%t.length]??`models`)},children:e===`models`?`Models`:e===`roles`?`Roles`:`Profiles`},e))}),E===`models`&&(0,m.jsxs)(`div`,{className:`code-popup-tabpanel`,role:`tabpanel`,id:`code-model-panel-models`,"aria-labelledby":`code-model-tab-models`,children:[(0,m.jsxs)(`label`,{className:`code-popup-field`,children:[(0,m.jsx)(`span`,{children:`Search models`}),(0,m.jsx)(`input`,{type:`search`,className:`code-model-search`,placeholder:`Search provider or model`,value:ee,onChange:e=>T(e.target.value),disabled:c})]}),n.usageOrder&&n.usageOrder.length>0&&(0,m.jsxs)(`div`,{className:`code-model-mru-strip`,"aria-label":`Recently used models`,children:[(0,m.jsx)(`span`,{children:`Recently used`}),n.usageOrder.slice(0,3).map(e=>(0,m.jsx)(`strong`,{children:e},e))]}),(0,m.jsxs)(`div`,{className:`code-model-layout`,children:[(0,m.jsx)(`div`,{className:`code-model-providers`,role:`list`,"aria-label":`Providers`,children:F.map(e=>(0,m.jsxs)(`button`,{type:`button`,className:`code-model-provider${e.id===O?` is-selected`:``}`,onClick:()=>{k(e.id),j(e.models[0]??``)},disabled:c,children:[(0,m.jsx)(`span`,{children:e.id}),(0,m.jsx)(`small`,{children:e.models.length})]},e.id))}),(0,m.jsxs)(`div`,{className:`code-model-list`,role:`list`,"aria-label":`Models`,children:[(0,m.jsxs)(`div`,{className:`code-model-list-head`,children:[(0,m.jsx)(`strong`,{children:N?.id??`No provider`}),(0,m.jsxs)(`span`,{children:[I.length,` models · `,V(N?.modelSource)]})]}),I.length===0?(0,m.jsx)(`p`,{className:`code-popup-note`,children:`No models match this search.`}):I.map(e=>{let t=O===r&&e===i,n=e===A;return(0,m.jsxs)(`button`,{type:`button`,className:`code-model-row${t?` is-active`:``}${n?` is-draft`:``}`,onClick:()=>j(e),disabled:c,children:[(0,m.jsx)(`span`,{children:e}),(0,m.jsx)(`small`,{children:t?`Active`:n?`Selected`:`Available`})]},e)})]})]}),(0,m.jsxs)(`div`,{className:`code-popup-action-row`,children:[(0,m.jsxs)(`div`,{className:`code-popup-summary code-popup-summary-compact`,children:[(0,m.jsx)(`span`,{children:`Active`}),(0,m.jsxs)(`strong`,{children:[r||`-`,` / `,i||`-`]}),(0,m.jsx)(`span`,{children:`Selected`}),(0,m.jsxs)(`strong`,{children:[O||`-`,` / `,A||`-`]}),(0,m.jsx)(`span`,{children:`Default`}),(0,m.jsxs)(`strong`,{children:[n.defaultProvider||`-`,` / `,n.defaultModel||`-`]})]}),(0,m.jsxs)(`div`,{className:`code-popup-action-stack`,children:[(0,m.jsx)(`button`,{type:`button`,className:`code-popup-primary`,disabled:!R,onClick:()=>{g(O,A)},children:`Use now`}),(0,m.jsx)(`button`,{type:`button`,className:`code-popup-secondary`,disabled:!z,onClick:()=>{_(O,A)},children:`Use for new sessions`}),(0,m.jsx)(`button`,{type:`button`,className:`code-popup-secondary`,disabled:!z,onClick:()=>{v(O,A)},children:`Set default`})]})]}),!l&&(0,m.jsx)(`p`,{className:`code-popup-note`,children:`Start or load a Code session to apply a live model. Use “Use for new sessions” to set the next session’s model.`})]}),E===`roles`&&(0,m.jsx)(`div`,{className:`code-popup-tabpanel`,role:`tabpanel`,id:`code-model-panel-roles`,"aria-labelledby":`code-model-tab-roles`,children:(0,m.jsxs)(`div`,{className:`code-role-assignment-panel`,"aria-label":`Model role assignments`,children:[(0,m.jsxs)(`div`,{className:`code-role-assignment-head`,children:[(0,m.jsx)(`strong`,{children:`Role assignments`}),(0,m.jsx)(`span`,{children:a?.activeModel.note??`Role assignments do not mutate the active Code session model.`})]}),(0,m.jsx)(`div`,{className:`code-role-assignment-grid`,role:`list`,children:(a?.roles??[]).map(e=>{let t=e.modelId?e.modelId:`Unset`,n=te[e.role]??(e.thinkingLevel===`min`?`minimal`:e.thinkingLevel)??`inherit`,r=!!(O&&A&&!c),i=!!(e.modelId&&!c);return(0,m.jsxs)(`article`,{className:`code-role-card`,role:`listitem`,children:[(0,m.jsxs)(`div`,{className:`code-role-card-head`,children:[(0,m.jsx)(`span`,{className:`code-role-tag`,children:e.tag}),(0,m.jsx)(`strong`,{children:e.name})]}),(0,m.jsx)(`p`,{className:`code-role-path`,children:e.settingsPath}),(0,m.jsx)(`p`,{className:`code-role-model`,title:t,children:t}),(0,m.jsxs)(`label`,{className:`code-role-thinking`,children:[(0,m.jsx)(`span`,{children:`Thinking`}),(0,m.jsx)(`select`,{value:n,disabled:c,onChange:t=>{let n=t.target.value;M(t=>({...t,[e.role]:n}))},children:re.map(e=>(0,m.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,m.jsxs)(`div`,{className:`code-role-actions`,children:[(0,m.jsx)(`button`,{type:`button`,className:`code-popup-secondary`,disabled:!r,onClick:()=>{y(e.role,O,A,n===`inherit`?null:n)},children:`Assign selected`}),(0,m.jsx)(`button`,{type:`button`,className:`code-popup-secondary`,disabled:!i,onClick:()=>{b(e.role)},children:`Clear`})]})]},e.role)})}),!a&&(0,m.jsx)(`p`,{className:`code-popup-note`,children:`Loading role assignments.`})]})}),E===`profiles`&&(0,m.jsx)(`div`,{className:`code-popup-tabpanel`,role:`tabpanel`,id:`code-model-panel-profiles`,"aria-labelledby":`code-model-tab-profiles`,children:(0,m.jsxs)(`div`,{className:`code-model-preset-panel`,"aria-label":`Model profiles and presets`,children:[(0,m.jsxs)(`div`,{className:`code-role-assignment-head`,children:[(0,m.jsx)(`strong`,{children:`Profiles and presets`}),(0,m.jsx)(`span`,{children:o?.applyReason??`Loading JWC profile state.`})]}),(0,m.jsxs)(`div`,{className:`code-model-preset-summary`,children:[(0,m.jsx)(`span`,{children:`Startup profile`}),(0,m.jsx)(`strong`,{children:o?.defaultProfile??`Unset`}),(0,m.jsx)(`span`,{children:`Task presets`}),(0,m.jsx)(`strong`,{children:o?o.taskPresets.length:`-`}),(0,m.jsx)(`span`,{children:`Built-in profiles`}),(0,m.jsx)(`strong`,{children:o?o.builtinProfiles.length:`-`})]}),o&&o.taskPresets.length>0&&(0,m.jsx)(`div`,{className:`code-model-preset-list`,role:`list`,"aria-label":`Task model presets`,children:o.taskPresets.slice(0,4).map(e=>(0,m.jsxs)(`div`,{className:`code-model-preset-row`,role:`listitem`,children:[(0,m.jsx)(`strong`,{children:e.name}),(0,m.jsx)(`span`,{children:e.best?`best ${e.best}`:`best unset`}),(0,m.jsx)(`span`,{children:e.cheap?`cheap ${e.cheap}`:`cheap unset`})]},e.name))}),o&&(0,m.jsx)(`div`,{className:`code-model-profile-chips`,"aria-label":`Built-in profile candidates`,children:o.builtinProfiles.slice(0,8).map(e=>(0,m.jsx)(`span`,{children:e.name},e.name))}),(0,m.jsxs)(`div`,{className:`code-popup-placeholder-actions`,children:[(0,m.jsx)(`button`,{type:`button`,disabled:!0,className:`code-popup-secondary`,children:`Apply profile`}),(0,m.jsx)(`span`,{children:`Profile activation is read-only here; JWC runtime owns credential checks and rollback.`})]})]})})]})]})})}function se(e,t,n){return n<=0?0:(e+t+n)%n}function U(e){return e.disabledReason?`Disabled`:e.actionType===`popup`?e.popupKind?`${e.popupKind} popup`:`Popup`:e.actionType===`pass-through`?`Pass-through`:e.actionType===`unsupported`?`Unsupported`:`Insert`}function ce(e){let[t,n]=(0,d.useState)(0),r=(0,d.useMemo)(()=>B(e.availableCommands,e.inputText).slice(0,10),[e.availableCommands,e.inputText]),i=r[t],a=i?`code-command-option-${i.name.replace(/[^a-z0-9_-]/gi,`-`)}`:void 0;(0,d.useEffect)(()=>{n(0)},[e.inputText,e.availableCommands]),(0,d.useEffect)(()=>{t>=r.length&&n(Math.max(0,r.length-1))},[t,r.length]);let o=t=>{!t||t.disabledReason||e.onCommandSelect(t)};return(0,m.jsxs)(`div`,{className:`code-composer`,children:[e.showCommands&&r.length>0&&(0,m.jsx)(`div`,{className:`code-command-palette`,role:`listbox`,"aria-label":`Code commands`,id:`code-command-palette`,children:r.map((e,r)=>{let i=r===t;return(0,m.jsxs)(`button`,{id:`code-command-option-${e.name.replace(/[^a-z0-9_-]/gi,`-`)}`,type:`button`,role:`option`,"aria-selected":i,"aria-disabled":e.disabledReason?!0:void 0,className:`code-command-item${i?` is-active`:``}${e.disabledReason?` is-disabled`:``}`,onMouseEnter:()=>n(r),onClick:()=>o(e),children:[(0,m.jsxs)(`span`,{className:`code-command-row-main`,children:[(0,m.jsx)(`span`,{className:`code-command-name`,children:e.displayName}),e.description&&(0,m.jsx)(`span`,{className:`code-command-desc`,children:e.description})]}),(0,m.jsxs)(`span`,{className:`code-command-row-meta`,children:[(0,m.jsx)(`span`,{className:`code-command-chip`,children:e.category}),(0,m.jsx)(`span`,{className:`code-command-chip`,children:e.source}),(0,m.jsx)(`span`,{className:`code-command-chip`,children:U(e)})]})]},e.name)})}),(0,m.jsxs)(`div`,{className:`code-composer-input-shell`,children:[(0,m.jsx)(`textarea`,{className:`code-composer-input`,value:e.inputText,onChange:t=>e.onInputChange(t.target.value),onKeyDown:t=>{if(t.key===`Escape`&&e.showCommands){t.preventDefault(),e.onShowCommandsChange(!1);return}if(e.showCommands&&r.length>0){if(t.key===`ArrowDown`){t.preventDefault(),n(e=>se(e,1,r.length));return}if(t.key===`ArrowUp`){t.preventDefault(),n(e=>se(e,-1,r.length));return}if(t.key===`Enter`&&!t.shiftKey){t.preventDefault(),o(i);return}}t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),e.onSubmit())},"aria-controls":e.showCommands?`code-command-palette`:void 0,"aria-activedescendant":e.showCommands?a:void 0,"aria-expanded":e.showCommands,placeholder:`Describe a task or ask a question...`,rows:1,disabled:e.sending}),(0,m.jsx)(`span`,{className:`code-composer-hint`,children:`Enter to send · / for commands`})]}),(0,m.jsx)(`button`,{type:`button`,className:`code-composer-send`,onClick:e.onSubmit,disabled:!e.inputText.trim()||e.sending,"aria-label":`Send prompt`,children:`Send`})]})}function le({permissions:e,onAnswer:t}){return e.length===0?null:(0,m.jsx)(`div`,{className:`code-permissions`,children:e.map(e=>(0,m.jsxs)(`div`,{className:`code-permission-card`,children:[(0,m.jsxs)(`div`,{className:`code-permission-title`,children:[(0,m.jsx)(`span`,{children:`Permission request`}),(0,m.jsx)(`strong`,{children:D(e.toolCall)}),(0,m.jsxs)(`small`,{children:[e.options.length,` JWC options`]})]}),(0,m.jsx)(`div`,{className:`code-permission-actions`,children:v.map(n=>{let r=E(e.options,n),i=b[n];return(0,m.jsx)(`button`,{type:`button`,className:`code-permission-btn is-${i}`,disabled:!r,title:r?r.optionId:`${y[n]} option was not provided by JWC`,onClick:()=>t(e,n),children:r?.label??y[n]},n)})})]},e.permissionId))})}var W=92,ue=6;function de(e){let[{virtualItems:t,totalSize:s},c]=(0,d.useState)({virtualItems:[],totalSize:0}),l=(0,d.useRef)(null);l.current||=new o({count:e.count,getScrollElement:()=>e.scrollElementRef.current,estimateSize:e.estimateSize||(()=>W),overscan:ue,getItemKey:e.getItemKey,indexAttribute:`data-code-transcript-idx`,useAnimationFrameWithResizeObserver:!0,observeElementRect:n,observeElementOffset:r,scrollToFn:i,measureElement:a,onChange:e=>{c({virtualItems:e.getVirtualItems(),totalSize:e.getTotalSize()})}});let u=l.current;return(0,d.useEffect)(()=>u._didMount(),[u]),(0,d.useLayoutEffect)(()=>{u.setOptions({...u.options,count:e.count,getItemKey:e.getItemKey,estimateSize:e.estimateSize||(()=>W)}),u._willUpdate(),c({virtualItems:u.getVirtualItems(),totalSize:u.getTotalSize()})},[e.count,e.estimateSize,e.getItemKey,u]),{measureElement:e=>{e&&u.measureElement(e)},virtualItems:t,totalSize:s}}var fe=(0,d.lazy)(()=>t(()=>import(`./MarkdownRenderer-DyrB9FbZ.js`).then(e=>({default:e.MarkdownRenderer})),__vite__mapDeps([0])));function pe(e,t){let n=e.label??(e.type===`args`?`Args`:e.type===`output`?`Output`:e.type===`error`?`Error`:``),r=`code-tool-${e.type}`,i=e.type===`diff`&&e.diff?e.diff:e.type===`json`||e.type===`args`?JSON.stringify(e.json??e,null,2):e.text??JSON.stringify(e,null,2);return n?(0,m.jsxs)(`div`,{className:`code-tool-section`,children:[(0,m.jsx)(`span`,{className:`code-tool-section-label`,children:n}),(0,m.jsx)(`pre`,{className:r,children:i})]},t):e.type===`diff`&&e.diff?(0,m.jsx)(`pre`,{className:`code-tool-diff`,children:e.diff},t):e.text?(0,m.jsx)(`pre`,{className:`code-tool-text`,children:e.text},t):(0,m.jsx)(`pre`,{className:r,children:i},t)}function me(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||t===`select`||e.isContentEditable}function G(e){return(e.toolContent?.find(e=>typeof e.text==`string`&&e.text.trim())?.text??e.toolOutput??``).replace(/\s+/g,` `).trim().slice(0,240)}function he(e){return e.split(/\r?\n/)[0]?.replace(/\s+/g,` `).trim()??``}function ge(e){let t=e.toolContent?.find(e=>e.type===`args`||e.type===`text`||e.type===`json`);if(!t)return null;if(typeof t.text==`string`){let e=he(t.text);return e?{text:e,...t.type===`args`?{name:`bash`}:/^https?:\/\//.test(e)||e.startsWith(`/`)?{name:`read`}:{}}:null}if(typeof t.json==`string`){let e=he(t.json);return e?{text:e,...t.type===`args`?{name:`bash`}:{}}:null}if(t.json&&typeof t.json==`object`&&!Array.isArray(t.json)){let e=t.json;for(let[t,n]of[[`command`,`bash`],[`cmd`,`bash`],[`path`,`read`],[`url`,`read`],[`file`,`read`],[`query`,`search`]]){let r=e[t];if(typeof r==`string`&&r.trim())return{name:n,text:he(r)}}}return null}function _e(e){let t=he(e.toolName||e.text||`tool`)||`tool`,n=ge(e);return t.includes(`:`)||!n?t:t===`tool`?n.name?`${n.name}: ${n.text}`:n.text:`${t}: ${n.text}`}function ve(e){return e===`pending`?`Pending`:e===`allow_once`?`Allow once`:e===`allow_always`?`Always allow`:e===`reject_once`?`Deny once`:e===`reject_always`?`Always deny`:e===`missing_option`?`Missing JWC option`:e===`answer_error`?`Answer failed`:`Cancelled`}function K(e,t){return`${t}:${e.toolCallId||e.permissionAudit?.permissionId||`${e.role}:${e.text.slice(0,48)}`}`}function ye(e){return e?e.role===`tool`?e.toolStatus===`running`?44:64+Math.min(320,(e.toolOutput?.length??0)/5):e.role===`permission`?72:e.role===`thinking`?48+Math.min(180,e.text.length/8):56+Math.min(420,e.text.length/6):48}function q(e,t,n){return(0,m.jsx)(`div`,{className:`code-message code-message-${e.role}`,children:e.role===`tool`?(()=>{let t=e.toolStatus??`done`,n=t===`failed`||t===`error`,r=n?G(e):``;return(0,m.jsxs)(`details`,{className:`code-tool-card code-tool-${t}`,open:t===`running`||n,children:[(0,m.jsxs)(`summary`,{className:`code-tool-summary`,children:[(0,m.jsx)(`span`,{className:`code-tool-chevron`,children:`>`}),(0,m.jsx)(`span`,{className:`code-tool-name`,children:_e(e)}),(0,m.jsx)(`span`,{className:`code-tool-status`,children:t})]}),r&&(0,m.jsx)(`div`,{className:`code-tool-error-snippet`,children:r}),(e.toolContent?.length??0)>0&&(0,m.jsx)(`div`,{className:`code-tool-content`,children:e.toolContent.map(pe)}),e.toolOutput&&(0,m.jsxs)(`pre`,{className:`code-tool-output`,children:[e.toolOutput.slice(0,2e3),e.toolOutput.length>2e3?`...`:``]})]})})():e.role===`permission`&&e.permissionAudit?(()=>{let t=e.permissionAudit,n=t.decision.startsWith(`allow`)?`is-allow`:t.decision.startsWith(`reject`)?`is-deny`:``;return(0,m.jsxs)(`div`,{className:`code-permission-audit is-${t.decision} ${n}`.trim(),children:[(0,m.jsxs)(`div`,{className:`code-permission-audit-head`,children:[(0,m.jsx)(`span`,{children:`Permission`}),(0,m.jsx)(`strong`,{children:t.toolName}),(0,m.jsx)(`em`,{children:ve(t.decision)})]}),(0,m.jsxs)(`div`,{className:`code-permission-audit-meta`,children:[(0,m.jsxs)(`span`,{children:[`mode `,t.mode]}),(0,m.jsx)(`span`,{children:t.decisionMode}),t.optionId&&(0,m.jsx)(`span`,{children:t.optionId})]}),t.error&&(0,m.jsx)(`div`,{className:`code-permission-audit-error`,children:t.error})]})})():e.role===`thinking`?(0,m.jsxs)(`details`,{className:`code-thinking`,children:[(0,m.jsx)(`summary`,{className:`code-thinking-summary`,children:`Thinking...`}),(0,m.jsx)(`div`,{className:`code-thinking-text`,children:e.text})]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`span`,{className:`code-message-role`,children:e.role===`user`?`You`:`JWC`}),(0,m.jsx)(`div`,{className:`code-message-text`,children:e.role===`assistant`?(0,m.jsx)(d.Suspense,{fallback:(0,m.jsx)(`span`,{children:e.text}),children:(0,m.jsx)(fe,{markdown:e.text,tableMode:`linear`,onLocalFileOpen:n})}):e.text})]})},t)}function J(){return(0,m.jsxs)(`div`,{className:`code-message code-message-assistant`,children:[(0,m.jsx)(`span`,{className:`code-message-role`,children:`JWC`}),(0,m.jsx)(`div`,{className:`code-message-text code-streaming`,children:`Thinking...`})]})}function Y({messages:e,sending:t,workingDir:n,transcriptRef:r,onOpenLocalFile:i}){let a=t&&e[e.length-1]?.role!==`assistant`,o=de({count:e.length+ +!!a,scrollElementRef:r,getItemKey:(0,d.useCallback)(t=>{let n=e[t];return n?K(n,t):`sending-${t}`},[e]),estimateSize:(0,d.useCallback)(t=>ye(e[t]),[e])});function s(e){if(me(e.target))return;let t=r.current;if(!t)return;let n=e.key.toLowerCase(),i=Math.max(160,Math.floor(t.clientHeight*.78));n===`d`||n===`j`||e.key===`PageDown`?(e.preventDefault(),t.scrollBy({top:i,behavior:`smooth`})):n===`u`||n===`k`||e.key===`PageUp`?(e.preventDefault(),t.scrollBy({top:-i,behavior:`smooth`})):e.key===`End`?(e.preventDefault(),t.scrollTo({top:t.scrollHeight,behavior:`smooth`})):e.key===`Home`&&(e.preventDefault(),t.scrollTo({top:0,behavior:`smooth`}))}return(0,m.jsx)(`div`,{className:`code-transcript`,ref:r,role:`log`,"aria-live":`polite`,tabIndex:0,onKeyDown:s,children:e.length===0?(0,m.jsxs)(`div`,{className:`code-transcript-empty`,children:[(0,m.jsx)(`p`,{children:`Start a Code session by typing a prompt below.`}),(0,m.jsxs)(`p`,{className:`code-transcript-cwd`,children:[`cwd: `,n||`not set`]})]}):(0,m.jsx)(`div`,{className:`code-transcript-virtual-spacer`,style:{height:`${o.totalSize}px`},children:o.virtualItems.map(t=>{let n=e[t.index];return(0,m.jsx)(`div`,{ref:o.measureElement,className:`code-transcript-virtual-row`,"data-code-transcript-idx":t.index,style:{transform:`translateY(${t.start}px)`},children:n?q(n,t.index,i):J()},t.key)})})})}function X(e){return e.split(`/`).filter(Boolean).slice(-2).join(`/`)||e}function be({workingDir:e,gitInfo:t,modelOptions:n,sessionTitle:r,usage:i,planEntries:a,onWorkingDirChange:o,cwdLocked:s=!1,workspaceFrozen:c=!1,onPickWorkingDir:l}){let[u,f]=(0,d.useState)(!1),[p,h]=(0,d.useState)(``),g=t?.status?.dirty,_=t?.worktrees.length??0,v=c||s,y=!!(!v&&l&&o);async function b(){if(!(!y||!l)){f(!0),h(``);try{let e=await l();e&&o?.(e)}catch(e){h(e instanceof Error?e.message:String(e))}finally{f(!1)}}}return(0,m.jsxs)(`div`,{className:`code-workspace-header`,children:[(0,m.jsxs)(`div`,{className:`code-workspace-primary`,children:[v?(0,m.jsx)(`span`,{className:`code-workspace-chip`,title:e,"aria-label":`Current Code workspace: ${e}`,children:X(e||`/tmp`)}):(0,m.jsxs)(`button`,{type:`button`,className:`code-workspace-picker`,disabled:!y||u,title:e||`Select Code workspace folder`,"aria-label":`Code workspace: ${e||`not set`}. Choose a folder.`,onClick:()=>void b(),children:[(0,m.jsx)(`span`,{className:`code-workspace-picker-label`,children:X(e||`/tmp`)}),(0,m.jsx)(`span`,{className:`code-workspace-picker-caret`,"aria-hidden":`true`,children:`▾`})]}),!v&&p&&(0,m.jsx)(`span`,{className:`code-workspace-cwd-error`,children:p}),t?.isRepo&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`span`,{className:`code-workspace-pill`,children:[t.branch??`detached`,t.head?` · ${t.head}`:``]}),(0,m.jsx)(`span`,{className:`code-workspace-pill ${g?`is-dirty`:``}`,children:g?`${t.status?.changed??0} changed · ${t.status?.untracked??0} untracked`:`clean`}),(0,m.jsxs)(`span`,{className:`code-workspace-pill`,title:t.currentWorktree?.path??void 0,children:[`worktree `,_]})]}),n?.degraded&&(0,m.jsx)(`span`,{className:`code-workspace-pill is-warning`,title:n.error,children:`provider fallback`})]}),(r||i.contextTokens!==void 0||a.length>0)&&(0,m.jsxs)(`div`,{className:`code-session-header`,children:[r&&(0,m.jsx)(`span`,{className:`code-session-title`,children:r}),i.contextTokens!==void 0&&i.contextLimit?(0,m.jsx)(`span`,{className:`code-context-meter`,title:`${i.contextTokens.toLocaleString()} / ${i.contextLimit.toLocaleString()} tokens${i.cost===void 0?``:` · $${i.cost.toFixed(4)}`}`,children:(0,m.jsx)(`span`,{className:`code-context-bar`,style:{width:`${Math.min(100,i.contextTokens/i.contextLimit*100)}%`}})}):null,a.length>0&&(0,m.jsx)(`div`,{className:`code-plan-entries`,children:a.map((e,t)=>(0,m.jsxs)(`span`,{className:`code-plan-entry code-plan-${e.status}`,children:[e.status===`completed`?`✓`:e.status===`in_progress`?`↻`:`○`,` `,e.title]},t))})]})]})}function xe({label:e,value:t,options:n,disabled:r,title:i,className:a=``,onChange:o}){let s=(0,d.useId)(),c=(0,d.useRef)(null),[l,u]=(0,d.useState)(!1),f=n.find(e=>e.value===t)??n[0],p=Math.max(0,n.findIndex(e=>e.value===f?.value));(0,d.useEffect)(()=>{if(!l)return;let e=e=>{c.current?.contains(e.target)||u(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[l]);let h=e=>{o(e),u(!1)};return(0,m.jsxs)(`div`,{ref:c,className:`code-footer-menu ${a}`.trim(),children:[(0,m.jsxs)(`button`,{type:`button`,className:`code-footer-menu-trigger`,disabled:r,title:i,"aria-label":e,"aria-haspopup":`listbox`,"aria-expanded":l,"aria-controls":s,onClick:()=>u(e=>!e),onKeyDown:e=>{if(!r){if(e.key===`Escape`){u(!1);return}if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=n[(p+(e.key===`ArrowDown`?1:-1)+n.length)%n.length];t&&h(t.value);return}(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u(e=>!e))}},children:[(0,m.jsx)(`span`,{className:`code-footer-label`,children:e}),(0,m.jsx)(`strong`,{children:f?.label??t}),(0,m.jsx)(`span`,{className:`code-footer-chevron`,"aria-hidden":`true`,children:`⌃`})]}),l&&(0,m.jsx)(`div`,{id:s,className:`code-footer-dropup`,role:`listbox`,"aria-label":e,children:n.map(e=>(0,m.jsxs)(`button`,{type:`button`,className:`code-footer-dropup-option${e.value===t?` is-selected`:``}`,role:`option`,"aria-selected":e.value===t,onClick:()=>h(e.value),children:[(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:e.label}),e.detail&&(0,m.jsx)(`small`,{children:e.detail})]}),e.value===t&&(0,m.jsx)(`em`,{"aria-hidden":`true`,children:`✓`})]},e.value))})]})}function Se({provider:e,providerOptions:t,model:n,modelOptions:r,effort:i,effortOptions:a,permissionMode:o,disabled:s,onProviderChange:c,onModelChange:l,onEffortChange:u,onPermissionModeChange:d}){return(0,m.jsxs)(`div`,{className:`code-composer-footer`,children:[(0,m.jsx)(xe,{label:`Permission`,value:o,options:x,disabled:s,title:S[o],onChange:d}),t.length>0&&(0,m.jsx)(xe,{label:`Provider`,value:e,options:t.map(e=>({value:e,label:e})),disabled:s,title:e,onChange:c}),(0,m.jsx)(xe,{label:`Model`,value:n,options:r.map(e=>({value:e,label:e})),disabled:s,title:n,className:`code-footer-field-model`,onChange:l}),a.length>0&&(0,m.jsx)(xe,{label:`Effort`,value:i,options:a.map(e=>({value:e,label:e})),disabled:s,title:i,onChange:u})]})}function Ce(e){return(0,m.jsxs)(`div`,{className:`code-canvas-main`,children:[(0,m.jsx)(be,{gitInfo:e.gitInfo,modelOptions:e.modelOptions,sessionTitle:e.sessionTitle,usage:e.usage,planEntries:e.planEntries,workingDir:e.codeWorkingDir,cwdLocked:!!e.activeSessionId,onWorkingDirChange:e.onWorkingDirChange,workspaceFrozen:e.workspaceFrozen,onPickWorkingDir:e.onPickWorkingDir}),e.childRecovery&&(0,m.jsxs)(`section`,{className:`code-child-recovery`,role:`status`,"aria-live":`polite`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`span`,{children:`JWC child recovery`}),(0,m.jsxs)(`strong`,{children:[`ACP child exited: `,e.childRecovery.code]})]}),(0,m.jsx)(`p`,{children:e.childRecovery.message})]}),e.transportState!==`connected`&&(0,m.jsx)(`section`,{className:`code-transport-status is-${e.transportState}`,role:`status`,"aria-live":`polite`,children:e.transportState===`reconnecting`?`Live updates reconnecting…`:`Live updates disconnected — retrying.`}),(0,m.jsx)(Y,{messages:e.messages,sending:e.sending,workingDir:e.codeWorkingDir,transcriptRef:e.transcriptRef,onOpenLocalFile:e.onOpenLocalFile}),(0,m.jsx)(le,{permissions:e.permissions,onAnswer:e.onPermissionAnswer}),(0,m.jsx)(`div`,{className:`code-composer-dock`,children:(0,m.jsxs)(`div`,{className:`code-composer-surface`,"aria-label":`Code composer controls`,children:[(0,m.jsx)(ce,{inputText:e.inputText,sending:e.sending,showCommands:e.showCommands,availableCommands:e.availableCommands,onInputChange:e.onInputChange,onCommandSelect:e.onCommandSelect,onSubmit:e.onSubmit,onShowCommandsChange:e.onShowCommandsChange}),(0,m.jsx)(Se,{provider:e.provider,providerOptions:e.providerOptions,model:e.model,modelOptions:e.currentModelOptions,effort:e.effort,effortOptions:e.currentEffortOptions,permissionMode:e.permissionMode,disabled:e.disabled,onProviderChange:e.onFooterProviderChange,onModelChange:e.onModelChange,onEffortChange:e.onEffortChange,onPermissionModeChange:e.onPermissionModeChange})]})}),e.activePopup&&(0,m.jsx)(H,{popupKind:e.activePopup.kind,command:e.activePopup.command,modelOptions:e.modelOptions,provider:e.provider,model:e.model,modelAssignments:e.modelAssignments,modelPresets:e.modelPresets,permissionMode:e.permissionMode,disabled:e.disabled,activeSessionId:e.activeSessionId,error:e.error,onClose:e.onClosePopup,onRefreshProviders:e.onRefreshProviders,onProviderChange:e.onProviderChange,onUseModel:e.onUseModel,onUseForNewSessions:e.onUseForNewSessions,onSetDefaultModel:e.onSetDefaultModel,onSetModelAssignment:e.onSetModelAssignment,onClearModelAssignment:e.onClearModelAssignment,onPermissionModeChange:e.onPermissionModeChange})]})}var we={providers:[{id:`anthropic`,models:[`claude-sonnet-4-6`,`claude-opus-5`,`claude-opus-4-8`,`claude-opus-4-7`,`claude-opus-4-6`,`claude-haiku-4-5`,`claude-fable-5`],efforts:[`off`,`min`,`low`,`medium`,`high`,`xhigh`]}],defaultProvider:`anthropic`,defaultModel:`claude-sonnet-4-6`,degraded:!0},Te=re([{name:`/model`,description:`Choose provider, model, roles, thinking, profiles, and MRU state.`,source:`cli-jaw`},{name:`/provider`,description:`Review authenticated JWC providers.`,source:`cli-jaw`},{name:`/settings`,description:`Adjust Code mode session controls.`,source:`cli-jaw`}]);function Ee(e){let t=new Set,n=[];for(let r of[...e,...Te])t.has(r.name)||(t.add(r.name),n.push(r));return n}function De(e,t,n,r){if(r.appendMessage(O(n,{mode:t,decision:`pending`,decisionMode:t===`ask`?`pending`:`automatic`})),t===`ask`){r.enqueuePermission(n);return}let i=t===`always-allow`?`allow_always`:`reject_always`,a=E(n.options,i);if(!a){r.appendMessage(O(n,{mode:t,decision:`missing_option`,decisionMode:`system`,error:`${i} was not provided by JWC for this request.`})),r.enqueuePermission(n);return}(async()=>{try{await e.answerPermission(n.permissionId,a.optionId),r.appendMessage(O(n,{mode:t,decision:i,decisionMode:`automatic`,optionId:a.optionId,optionLabel:a.label}))}catch(e){r.appendMessage(O(n,{mode:t,decision:`answer_error`,decisionMode:`system`,optionId:a.optionId,optionLabel:a.label,error:e instanceof Error?e.message:String(e)}))}})()}async function Oe(e,t,n,r,i){let a=E(n.options,r);if(!a)return i(O(n,{mode:t,decision:`missing_option`,decisionMode:`system`,error:`${r} was not provided by JWC for this request.`})),!1;try{await e.answerPermission(n.permissionId,a.optionId),i(O(n,{mode:t,decision:r,decisionMode:`manual`,optionId:a.optionId,optionLabel:a.label}))}catch(e){i(O(n,{mode:t,decision:`answer_error`,decisionMode:`system`,optionId:a.optionId,optionLabel:a.label,error:e instanceof Error?e.message:String(e)}))}return!0}var ke=new Set([`code_user_message_chunk`,`code_agent_message_chunk`,`code_agent_thought_chunk`]);function Ae(e){let t=e?.content;return String(t?.text??e?.text??``)}function Z(e){let t=e?.messageId;return typeof t==`string`?t.trim():``}function je(e,t){if(!ke.has(e.event)||!t)return null;let n=Z(e.update??{}),r=typeof e.sseEventId==`string`&&e.sseEventId.trim()?e.sseEventId.trim():``,i=n?`msg:${n}`:r?`sse:${r}`:``;return i?`${e.sessionId??``}:${e.event}:${i}:${t}`:null}function Me(e,t){for(let n of t){let t=je(n,Ae(n.update));t&&e.add(t)}}function Ne(e,t,n){let r=je(t,n);return r?e.has(r)?!0:(e.add(r),!1):!1}function Pe(e,t){let n=e.trim(),r=t.trim();return r.length<80?!1:n===r}var Q=80,Fe=.7,Ie=.78,Le=32,Re=8;function ze(e){return e.replace(/\s+/g,` `).trim()}function Be(e){return e.split(/\r?\n/).map(e=>e.replace(/\s+/g,` `).trim()).filter(e=>e.length>=4)}function $(e,t){if(e.length===0)return 0;let n=0;for(let r of e)t.has(r)&&(n+=1);return n/e.length}function Ve(e){let t=ze(e);if(t.length<Le)return[];let n=[];for(let e=0;e<=t.length-Le;e+=Re)n.push(t.slice(e,e+Le));return n}function He(e,t){let n=ze(e),r=ze(t);if(n.length<Q||r.length<Q)return!1;if(r.includes(n))return!0;let i=Be(e),a=new Set(Be(t));if(i.length>=4&&$(i,a)>=Fe)return!0;let o=Ve(n);return o.length<3?!1:$(o,new Set(Ve(r)))>=Ie}function Ue(e,t){return!e||!t?`append`:e===t?`drop`:t.startsWith(e)?`replace`:e.startsWith(t)?`drop`:t.length>=e.length&&He(e,t)?`replace`:e.length>t.length&&He(t,e)?`drop`:`append`}function We(e){let t=e.toLowerCase();return t===`failed`||t===`error`||t===`errored`?`failed`:t===`completed`||t===`done`||t===`success`?`done`:`running`}function Ge(e){let t=[];for(let n of e){let e=n.update??{};if(n.event===`code_user_message_chunk`){let n=e.content,r=String(n?.text??e.text??``),i=Z(e);r&&t.push({role:`user`,text:r,...i?{messageId:i}:{}})}else if(n.event===`code_agent_message_chunk`){let n=e.content,r=String(n?.text??e.text??``);if(!r)continue;let i=Z(e),a=t[t.length-1];if(a?.role===`assistant`){let e=Ue(a.text,r);if(a.messageId&&i&&a.messageId!==i){if(e===`replace`){a.text=r,a.messageId=i;continue}t.push({role:`assistant`,text:r,messageId:i});continue}if(e===`drop`)continue;a.text=e===`replace`?r:a.text+r,i&&!a.messageId&&(a.messageId=i)}else t.push({role:`assistant`,text:r,...i?{messageId:i}:{}})}else if(n.event===`code_agent_thought_chunk`){let n=e.content,r=String(n?.text??e.text??``);if(!r)continue;let i=Z(e),a=t[t.length-1];a?.role===`thinking`&&(!a.messageId||!i||a.messageId===i)?(a.text+=r,i&&!a.messageId&&(a.messageId=i)):t.push({role:`thinking`,text:r,...i?{messageId:i}:{}})}else if(n.event===`code_tool_call`){let n=String(e.title??e.toolName??`tool`),r=String(e.toolCallId??``),i=String(e.status??`pending`),a=P(e);t.push({role:`tool`,text:n,toolName:n,toolCallId:r,toolContent:a,toolStatus:We(i)})}else if(n.event===`code_tool_call_update`){let n=String(e.toolCallId??``),r=String(e.status??``),i=P(e),a=g(t,n);if(a<0)continue;let o={...t[a]};r&&(o.toolStatus=We(r)),i.length>0&&(o.toolContent=i),t[a]=o}}return t}function Ke(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||t===`select`||e.isContentEditable}function qe(e,t,n){let r=(0,d.useRef)(null),i=(0,d.useMemo)(()=>{let t=e[e.length-1];if(!t)return`empty`;let n=t.toolContent?.reduce((e,t)=>e+JSON.stringify(t).length,0)??0;return`${e.length}:${t.role}:${t.text.length}:${t.toolOutput?.length??0}:${n}:${t.toolStatus??``}`},[e]),a=(0,d.useCallback)((e=`smooth`)=>{window.requestAnimationFrame(()=>{let t=r.current;t&&(t.scrollTo({top:t.scrollHeight,behavior:e}),window.setTimeout(()=>{let e=r.current;e&&e.scrollTo({top:e.scrollHeight,behavior:`auto`})},80))})},[]),o=(0,d.useCallback)((e,t=`smooth`)=>{window.requestAnimationFrame(()=>{let n=r.current;n&&n.scrollBy({top:e,behavior:t})})},[]),s=(0,d.useCallback)((e=`smooth`)=>{window.requestAnimationFrame(()=>{let t=r.current;t&&t.scrollTo({top:0,behavior:e})})},[]);return(0,d.useEffect)(()=>{a(e.length>1?`smooth`:`auto`)},[i,e.length,t,a]),(0,d.useEffect)(()=>{let e=e=>{if(e.defaultPrevented||n||e.metaKey||e.ctrlKey||e.altKey||Ke(e.target))return;let t=r.current;if(!t)return;let i=e.key.toLowerCase(),c=Math.max(160,Math.floor(t.clientHeight*.78));i===`d`||i===`j`||e.key===`PageDown`?(e.preventDefault(),o(c)):i===`u`||i===`k`||e.key===`PageUp`?(e.preventDefault(),o(-c)):e.key===`End`?(e.preventDefault(),a(`smooth`)):e.key===`Home`&&(e.preventDefault(),s(`smooth`))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n,o,a,s]),{transcriptRef:r,scrollTranscriptToBottom:a}}function Je(e){return typeof window<`u`&&window.location.port===String(e)?`${window.location.origin}/api/events`:`http://127.0.0.1:${e}/api/events`}function Ye({port:e,sessionId:t,sessionIdRef:n,onEvent:r,onTransport:i}){let a=(0,d.useRef)(r);a.current=r;let o=(0,d.useRef)(i);o.current=i;let s=(0,d.useRef)(t);s.current=t,(0,d.useEffect)(()=>{if(!e)return;let t=new EventSource(Je(e));return t.onopen=()=>{o.current?.(`connected`)},t.onmessage=e=>{try{let t={...JSON.parse(e.data),sseEventId:e.lastEventId||void 0};if(t.topic!==`jwc`)return;let r=t.event===`code_child_exit`,i=n?.current??s.current;if(!i&&!r||!r&&t.sessionId&&t.sessionId!==i)return;a.current(t)}catch{}},t.onerror=()=>{o.current?.(t.readyState===EventSource.CLOSED?`disconnected`:`reconnecting`)},()=>t.close()},[e])}function Xe({port:e,workingDir:t,onWorkingDirChange:n,onOpenLocalFile:r}){let i=(0,d.useMemo)(()=>p(e),[e]),[a,o]=(0,d.useState)(t),[s,c]=(0,d.useState)(null),[l,v]=(0,d.useState)(!1),[y,b]=(0,d.useState)(``),[x,S]=(0,d.useState)(!1),[C,w]=(0,d.useState)([]),[ee,T]=(0,d.useState)([]),[E,D]=(0,d.useState)(Te),[O,k]=(0,d.useState)(!1),[A,j]=(0,d.useState)(null),[te,M]=(0,d.useState)(``),[N,F]=(0,d.useState)(``),[I,L]=(0,d.useState)({}),[ne,R]=(0,d.useState)([]),[z,ie]=(0,d.useState)(`anthropic`),[B,ae]=(0,d.useState)(`claude-sonnet-4-6`),[oe,V]=(0,d.useState)(`high`),[H,se]=(0,d.useState)(`always-allow`),[U,ce]=(0,d.useState)(we),[le,W]=(0,d.useState)(null),[ue,de]=(0,d.useState)(null),[fe,pe]=(0,d.useState)(null),[me,G]=(0,d.useState)(null),[he,ge]=(0,d.useState)(`connected`),[_e,ve]=(0,d.useState)(null),K=(0,d.useRef)(null),ye=(0,d.useRef)(!1),q=(0,d.useRef)(null),J=(0,d.useRef)(null),Y=(0,d.useRef)(new Set),X=(0,d.useRef)(new Set),be=(0,d.useMemo)(()=>B?_(z,B):``,[z,B]),{transcriptRef:xe,scrollTranscriptToBottom:Se}=qe(C,x,!!A);(0,d.useEffect)(()=>{K.current||s||o(t)},[s,t]);let ke=(0,d.useCallback)(e=>{K.current||s||l||(o(e??``),n?.(e))},[s,n,l]),je=(0,d.useCallback)(async()=>{let e=u();if(e?.folder?.pickFolder){let t=await e.folder.pickFolder();if(t.ok&&t.path)return t.path;if(t.error&&t.error!==`cancelled`)throw Error(t.error);return null}let t=await i.pickWorkspace();return t.ok&&t.path?t.path:null},[i]),Q=(0,d.useCallback)(e=>{ce(e);let t=e.providers.find(t=>t.id===e.defaultProvider)??e.providers[0],n=t?.models.includes(e.defaultModel)?e.defaultModel:t?.models[0]??``;ie(t?.id??`anthropic`),ae(n);let r=t?.efforts??[];r.length>0&&V(r.includes(`high`)?`high`:r[0]??``)},[]);(0,d.useEffect)(()=>{K.current=s},[s]),(0,d.useEffect)(()=>{if(typeof document>`u`){ve(null);return}return ve(document.getElementById(`code-session-sidebar-host`)),()=>ve(null)},[]);let Fe=(0,d.useCallback)(async()=>{Q(await i.listModelOptions())},[Q,i]),Ie=(0,d.useCallback)(async()=>{W(await i.listModelAssignments())},[i]);(0,d.useEffect)(()=>{let e=!1;return(async()=>{try{let[t,n,r]=await Promise.all([i.listModelOptions(),i.listModelAssignments(),i.listModelPresets()]);if(e)return;Q(t),W(n),de(r)}catch(t){e||(ce({...we,error:t instanceof Error?t.message:String(t)}),W(null),de(null))}})(),()=>{e=!0}},[Q,i]),(0,d.useEffect)(()=>{if(!a){pe(null);return}let e=!1;return i.getGitInfo(a).then(t=>{e||pe(t)},()=>{e||pe(null)}),()=>{e=!0}},[i,a]),(0,d.useEffect)(()=>{if(ye.current){ye.current=!1;return}c(null),K.current=null,w([]),T([]),R([]),F(``),L({}),S(!1),G(null),X.current=new Set},[a]),Ye({port:e,sessionId:s,sessionIdRef:K,onEvent:(0,d.useCallback)(e=>{let t=e.update??{},n=e.event;if(!(J.current&&e.sessionId===J.current&&n!==`code_child_exit`)){if(n===`code_agent_message_chunk`){let n=Ae(t);if(!n)return;let r=Z(t);if(Ne(X.current,e,n))return;w(e=>{if(Y.current.has(n)&&e[e.length-1]?.role===`user`)return Y.current.delete(n),e;let t=e[e.length-1];if(t?.role===`assistant`&&Pe(t.text,n))return e;if(t?.role===`assistant`){let i=Ue(t.text,n);if(t.messageId&&r&&t.messageId!==r)return i===`replace`?[...e.slice(0,-1),{...t,text:n,messageId:r}]:[...e,{role:`assistant`,text:n,messageId:r}];if(i===`drop`)return e;let a=i===`replace`?n:t.text+n;return[...e.slice(0,-1),{...t,text:a,...r&&!t.messageId?{messageId:r}:{}}]}return[...e,{role:`assistant`,text:n,...r?{messageId:r}:{}}]})}else if(n===`code_user_message_chunk`){let n=Ae(t);if(!n)return;let r=Z(t);if(Ne(X.current,e,n))return;w(e=>{if(q.current===n){let t=-1;for(let r=e.length-1;r>=0;--r){let i=e[r];if(i?.role===`user`&&i.text===n&&i.transient===`pending-user-echo`){t=r;break}}if(t>=0){q.current=null;let i=[...e];return i[t]={role:`user`,text:n,...r?{messageId:r}:{}},i}}return[...e,{role:`user`,text:n,...r?{messageId:r}:{}}]})}else if(n===`code_agent_thought_chunk`){let n=Ae(t);if(!n)return;let r=Z(t);if(Ne(X.current,e,n))return;w(e=>{let t=e[e.length-1];return t?.role===`thinking`&&(!t.messageId||!r||t.messageId===r)?[...e.slice(0,-1),{...t,text:t.text+n,...r&&!t.messageId?{messageId:r}:{}}]:[...e,{role:`thinking`,text:n,...r?{messageId:r}:{}}]})}else if(n===`code_tool_call`){let e=String(t.title??t.toolName??`tool`),n=String(t.toolCallId??``),r=String(t.status??`pending`),i=P(t);w(t=>[...t,{role:`tool`,text:e,toolName:e,toolCallId:n,toolContent:i,toolStatus:We(r)}])}else if(n===`code_tool_call_update`){let e=String(t.toolCallId??``),n=String(t.status??``),r=P(t);w(t=>{let i=g(t,e);if(i<0)return t;let a=[...t],o={...a[i]};return n&&(o.toolStatus=We(n)),r.length>0&&(o.toolContent=r),a[i]=o,a})}else if(n===`code_permission_request`){let t=String(e.permissionId??``),n=e.toolCall??{},r=e.options??[];t&&De(i,H,{permissionId:t,toolCall:n,options:r},{appendMessage:e=>w(t=>[...t,e]),enqueuePermission:e=>T(t=>[...t,e])})}else if(n===`code_session_info_update`){let e=t.title;typeof e==`string`&&F(e)}else if(n===`code_usage_update`){let e={};typeof t.contextTokens==`number`&&(e.contextTokens=t.contextTokens),typeof t.contextLimit==`number`&&(e.contextLimit=t.contextLimit),typeof t.totalCost==`number`&&(e.cost=t.totalCost),L(e)}else if(n===`code_plan`)R((t.entries??[]).filter(e=>e.title).map(e=>({title:String(e.title),status:String(e.status??`pending`)})));else if(n===`code_available_commands_update`)D(Ee(re(t.availableCommands)));else if(n===`code_child_exit`){let t=e.code===null||e.code===void 0?`unknown`:String(e.code),n=`JWC ACP child exited (code ${t}). Active Code sessions were closed. Send the prompt again to start a fresh session, or load a stored session from the sidebar.`;K.current=null,c(null),S(!1),T([]),G({code:t,message:n}),w(e=>[...e,{role:`assistant`,text:n}])}else n===`code_turn_done`?S(!1):n===`code_session_error`&&(w(t=>[...t,{role:`assistant`,text:`Error: ${e.reason??`unknown`}`}]),S(!1));setTimeout(()=>Se(`smooth`),50)}},[i,H,Se]),onTransport:ge});let Le=(0,d.useCallback)(async()=>{let e=y.trim();if(!(!e||x)){J.current=null,S(!0),v(!0),G(null),q.current=e,w(t=>[...t,{role:`user`,text:e,transient:`pending-user-echo`}]),b(``);try{let t=s;if(!t){let e=a||`/tmp`;t=(await i.createSession(e,be||void 0)).sessionId,K.current=t,c(t)}await i.sendPrompt(t,e)}catch(e){q.current=null,w(t=>[...t,{role:`assistant`,text:`Error: ${e instanceof Error?e.message:String(e)}`}]),S(!1)}}},[y,x,s,i,a,be]),Re=(0,d.useCallback)(e=>{b(e),k(e===`/`||e.startsWith(`/`)&&!e.includes(` `))},[]),ze=(0,d.useCallback)(e=>{if(!e.disabledReason){if(e.actionType===`popup`&&e.popupKind){M(``),j({kind:e.popupKind,command:e}),k(!1);return}b(`${e.displayName} `),k(!1)}},[]),Be=(0,d.useCallback)(async(e,t)=>{await Oe(i,H,e,t,e=>w(t=>[...t,e]))&&T(t=>t.filter(t=>t.permissionId!==e.permissionId))},[i,H]),$=(0,d.useCallback)(async(e,t,n)=>{M(``),ie(e),ae(t);let r=n?.closePopup??!0,a=n?.requireActiveSession??!0;if(!s){a&&M(`Start or load a Code session before applying a live model.`);return}try{await i.setSessionModel(s,_(e,t)),r&&j(null)}catch(e){M(e instanceof Error?e.message:String(e))}},[s,i]),Ve=(0,d.useCallback)(async(e,t)=>{M(``);try{Q(await i.setDefaultModel(_(e,t))),Ie()}catch(e){M(e instanceof Error?e.message:String(e))}},[Q,i,Ie]),He=(0,d.useCallback)(async(e,t,n,r)=>{M(``);try{W(await i.setModelAssignment(e,{provider:t,model:n,...r===void 0?{}:{thinkingLevel:r}}))}catch(e){M(e instanceof Error?e.message:String(e))}},[i]),Ke=(0,d.useCallback)(async e=>{M(``);try{W(await i.clearModelAssignment(e))}catch(e){M(e instanceof Error?e.message:String(e))}},[i]),Je=U.providers.find(e=>e.id===z)??U.providers[0],Xe=U.providers.map(e=>e.id),Ze=Je?.models??[],Qe=Je?.efforts??[],$e=e=>{let t=Ge(e.replayEvents??[]);X.current=new Set,Me(X.current,e.replayEvents??[]),Y.current=new Set(t.filter(e=>e.role===`assistant`&&e.text).map(e=>e.text)),K.current=e.sessionId,c(e.sessionId),e.cwd!==a&&(ye.current=!0,o(e.cwd)),w(t),T([]),R([]),F(e.title?.trim()||t.find(e=>e.role===`user`)?.text.split(/\r?\n/)[0]?.replace(/\s+/g,` `).trim()||``),L({}),S(!1),G(null)};if(!e)return(0,m.jsx)(`div`,{className:`code-canvas`,children:(0,m.jsx)(`div`,{className:`code-transcript-empty`,children:(0,m.jsx)(`p`,{children:`Server not available.`})})});let et=(0,m.jsx)(h,{client:i,activeSessionId:s,workingDir:a,onSelectSession:$e,onLoadSession:(e,t)=>{(async()=>{J.current=e,K.current=e,c(e),q.current=null,Y.current=new Set,X.current=new Set,w([]),R([]),F(``),S(!1);try{let n=await i.loadSession(e,t);if(K.current!==e)return;n.title&&F(n.title);let r=Ge(n.replayEvents??[]);X.current=new Set,Me(X.current,n.replayEvents??[]),Y.current=new Set(r.filter(e=>e.role===`assistant`&&e.text).map(e=>e.text)),w(r),S(!1)}catch(t){K.current===e&&(K.current=null,c(null)),w(e=>[...e,{role:`assistant`,text:`Failed to load session: ${t instanceof Error?t.message:String(t)}`}])}finally{J.current===e&&(J.current=null)}})()},onNewSession:()=>{K.current=null,J.current=null,q.current=null,Y.current=new Set,X.current=new Set,c(null),w([]),R([]),F(``),S(!1),v(!1)}}),tt=e=>{ie(e),ae(U.providers.find(t=>t.id===e)?.models[0]??``)},nt=(0,m.jsx)(Ce,{activePopup:A,activeSessionId:s,availableCommands:E,codeWorkingDir:a,currentEffortOptions:Qe,currentModelOptions:Ze,disabled:x,effort:oe,gitInfo:fe,childRecovery:me,transportState:he,inputText:y,messages:C,model:B,modelAssignments:le,modelOptions:U,modelPresets:ue,permissionMode:H,permissions:ee,planEntries:ne,error:te,provider:z,providerOptions:Xe,sending:x,sessionTitle:N,showCommands:O,transcriptRef:xe,usage:I,onClearModelAssignment:Ke,onClosePopup:()=>{M(``),j(null)},onCommandSelect:ze,onEffortChange:e=>{V(e),s&&i.setSessionConfig(s,`thinking`,e)},onFooterProviderChange:e=>{tt(e);let t=U.providers.find(t=>t.id===e),n=t?.models[0]??``;V(t?.efforts.includes(`high`)?`high`:t?.efforts[0]??``),n&&$(e,n,{closePopup:!1,requireActiveSession:!1})},onInputChange:Re,onModelChange:e=>{$(z,e,{closePopup:!1,requireActiveSession:!1})},onPermissionAnswer:Be,onPermissionModeChange:se,onProviderChange:tt,onRefreshProviders:()=>{Fe()},onSetDefaultModel:Ve,onSetModelAssignment:He,onShowCommandsChange:k,onSubmit:()=>{Le()},onUseModel:$,onUseForNewSessions:(e,t)=>{$(e,t,{requireActiveSession:!1,closePopup:!1}),j(null)},onWorkingDirChange:ke,onOpenLocalFile:r,workspaceFrozen:l,onPickWorkingDir:je});return _e?(0,m.jsxs)(m.Fragment,{children:[(0,f.createPortal)((0,m.jsx)(`div`,{className:`code-manager-session-navigator-content`,children:et}),_e),(0,m.jsx)(`div`,{className:`code-canvas code-canvas-workbench`,children:nt})]}):(0,m.jsxs)(`div`,{className:`code-canvas`,children:[(0,m.jsx)(`div`,{className:`code-canvas-sidebar`,children:et}),nt]})}export{Xe as CodeCanvas};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-render-Bjnw0wQ6.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{n as e,r as t,t as n}from"./rolldown-runtime-XQCOJYun.js";import{A as r}from"./vendor-render-DCb9B75Q.js";import{t as i}from"./preload-helper-DFYRRz9w.js";import{i as a,n as o,o as s,r as c,t as l}from"./mermaid-preprocess-0hqEN7sn.js";import{n as u,t as d}from"./jsx-runtime-gFMgZ0TQ.js";import{t as f}from"./copy-text-BDs2wKjA.js";import{A as p,C as m,D as ee,E as h,S as te,T as ne,a as g,b as _,c as v,d as y,f as re,i as ie,k as b,l as ae,n as oe,o as se,p as ce,r as le,s as ue,t as de,u as fe,w as pe,x as me,y as he}from"./wiki-link-resolver-BfNXN9px.js";function ge(e){let t=[],n=String(e||``),r=n.indexOf(`,`),i=0,a=!1;for(;!a;){r===-1&&(r=n.length,a=!0);let e=n.slice(i,r).trim();(e||!a)&&t.push(e),i=r+1,r=n.indexOf(`,`,i)}return t}function _e(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var ve=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ye=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,be={};function xe(e,t){return((t||be).jsx?ye:ve).test(e)}var Se=/[ \t\n\f\r]/g;function Ce(e){return typeof e==`object`?e.type===`text`?we(e.value):!1:we(e)}function we(e){return e.replace(Se,``)===``}var x=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};x.prototype.normal={},x.prototype.property={},x.prototype.space=void 0;function Te(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new x(n,r,t)}function S(e){return e.toLowerCase()}var C=class{constructor(e,t){this.attribute=t,this.property=e}};C.prototype.attribute=``,C.prototype.booleanish=!1,C.prototype.boolean=!1,C.prototype.commaOrSpaceSeparated=!1,C.prototype.commaSeparated=!1,C.prototype.defined=!1,C.prototype.mustUseProperty=!1,C.prototype.number=!1,C.prototype.overloadedBoolean=!1,C.prototype.property=``,C.prototype.spaceSeparated=!1,C.prototype.space=void 0;var w=e({boolean:()=>T,booleanish:()=>E,commaOrSpaceSeparated:()=>A,commaSeparated:()=>k,number:()=>D,overloadedBoolean:()=>De,spaceSeparated:()=>O}),Ee=0,T=j(),E=j(),De=j(),D=j(),O=j(),k=j(),A=j();function j(){return 2**++Ee}var Oe=Object.keys(w),M=class extends C{constructor(e,t,n,r){let i=-1;if(super(e,t),ke(this,`space`,r),typeof n==`number`)for(;++i<Oe.length;){let e=Oe[i];ke(this,Oe[i],(n&w[e])===w[e])}}};M.prototype.defined=!0;function ke(e,t,n){n&&(e[t]=n)}function N(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new M(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[S(r)]=r,n[S(a.attribute)]=r}return new x(t,n,e.space)}var Ae=N({properties:{ariaActiveDescendant:null,ariaAtomic:E,ariaAutoComplete:null,ariaBusy:E,ariaChecked:E,ariaColCount:D,ariaColIndex:D,ariaColSpan:D,ariaControls:O,ariaCurrent:null,ariaDescribedBy:O,ariaDetails:null,ariaDisabled:E,ariaDropEffect:O,ariaErrorMessage:null,ariaExpanded:E,ariaFlowTo:O,ariaGrabbed:E,ariaHasPopup:null,ariaHidden:E,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:O,ariaLevel:D,ariaLive:null,ariaModal:E,ariaMultiLine:E,ariaMultiSelectable:E,ariaOrientation:null,ariaOwns:O,ariaPlaceholder:null,ariaPosInSet:D,ariaPressed:E,ariaReadOnly:E,ariaRelevant:null,ariaRequired:E,ariaRoleDescription:O,ariaRowCount:D,ariaRowIndex:D,ariaRowSpan:D,ariaSelected:E,ariaSetSize:D,ariaSort:null,ariaValueMax:D,ariaValueMin:D,ariaValueNow:D,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function je(e,t){return t in e?e[t]:t}function Me(e,t){return je(e,t.toLowerCase())}var Ne=N({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:k,acceptCharset:O,accessKey:O,action:null,allow:null,allowFullScreen:T,allowPaymentRequest:T,allowUserMedia:T,alt:null,as:null,async:T,autoCapitalize:null,autoComplete:O,autoFocus:T,autoPlay:T,blocking:O,capture:null,charSet:null,checked:T,cite:null,className:O,cols:D,colSpan:null,content:null,contentEditable:E,controls:T,controlsList:O,coords:D|k,crossOrigin:null,data:null,dateTime:null,decoding:null,default:T,defer:T,dir:null,dirName:null,disabled:T,download:De,draggable:E,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:T,formTarget:null,headers:O,height:D,hidden:De,high:D,href:null,hrefLang:null,htmlFor:O,httpEquiv:O,id:null,imageSizes:null,imageSrcSet:null,inert:T,inputMode:null,integrity:null,is:null,isMap:T,itemId:null,itemProp:O,itemRef:O,itemScope:T,itemType:O,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:T,low:D,manifest:null,max:null,maxLength:D,media:null,method:null,min:null,minLength:D,multiple:T,muted:T,name:null,nonce:null,noModule:T,noValidate:T,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:T,optimum:D,pattern:null,ping:O,placeholder:null,playsInline:T,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:T,referrerPolicy:null,rel:O,required:T,reversed:T,rows:D,rowSpan:D,sandbox:O,scope:null,scoped:T,seamless:T,selected:T,shadowRootClonable:T,shadowRootDelegatesFocus:T,shadowRootMode:null,shape:null,size:D,sizes:null,slot:null,span:D,spellCheck:E,src:null,srcDoc:null,srcLang:null,srcSet:null,start:D,step:null,style:null,tabIndex:D,target:null,title:null,translate:null,type:null,typeMustMatch:T,useMap:null,value:E,width:D,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:O,axis:null,background:null,bgColor:null,border:D,borderColor:null,bottomMargin:D,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:T,declare:T,event:null,face:null,frame:null,frameBorder:null,hSpace:D,leftMargin:D,link:null,longDesc:null,lowSrc:null,marginHeight:D,marginWidth:D,noResize:T,noHref:T,noShade:T,noWrap:T,object:null,profile:null,prompt:null,rev:null,rightMargin:D,rules:null,scheme:null,scrolling:E,standby:null,summary:null,text:null,topMargin:D,valueType:null,version:null,vAlign:null,vLink:null,vSpace:D,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:T,disableRemotePlayback:T,prefix:null,property:null,results:D,security:null,unselectable:null},space:`html`,transform:Me}),Pe=N({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:A,accentHeight:D,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:D,amplitude:D,arabicForm:null,ascent:D,attributeName:null,attributeType:null,azimuth:D,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:D,by:null,calcMode:null,capHeight:D,className:O,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:D,diffuseConstant:D,direction:null,display:null,dur:null,divisor:D,dominantBaseline:null,download:T,dx:null,dy:null,edgeMode:null,editable:null,elevation:D,enableBackground:null,end:null,event:null,exponent:D,externalResourcesRequired:null,fill:null,fillOpacity:D,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:k,g2:k,glyphName:k,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:D,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:D,horizOriginX:D,horizOriginY:D,id:null,ideographic:D,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:D,k:D,k1:D,k2:D,k3:D,k4:D,kernelMatrix:A,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:D,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:D,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:D,overlineThickness:D,paintOrder:null,panose1:null,path:null,pathLength:D,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:O,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:D,pointsAtY:D,pointsAtZ:D,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:A,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:A,rev:A,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:A,requiredFeatures:A,requiredFonts:A,requiredFormats:A,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:D,specularExponent:D,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:D,strikethroughThickness:D,string:null,stroke:null,strokeDashArray:A,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:D,strokeOpacity:D,strokeWidth:null,style:null,surfaceScale:D,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:A,tabIndex:D,tableValues:null,target:null,targetX:D,targetY:D,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:A,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:D,underlineThickness:D,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:D,values:null,vAlphabetic:D,vMathematical:D,vectorEffect:null,vHanging:D,vIdeographic:D,version:null,vertAdvY:D,vertOriginX:D,vertOriginY:D,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:D,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:je}),Fe=N({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),Ie=N({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:Me}),Le=N({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),Re={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},ze=/[A-Z]/g,Be=/-[a-z]/g,Ve=/^data[-\w.:]+$/i;function He(e,t){let n=S(t),r=t,i=C;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&Ve.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(Be,We);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!Be.test(e)){let n=e.replace(ze,Ue);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=M}return new i(r,t)}function Ue(e){return`-`+e.toLowerCase()}function We(e){return e.charAt(1).toUpperCase()}var Ge=Te([Ae,Ne,Fe,Ie,Le],`html`),P=Te([Ae,Pe,Fe,Ie,Le],`svg`);function Ke(e){let t=String(e||``).trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function qe(e){return e.join(` `).trim()}var Je=n(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g,u=`
|
|
3
|
-
`,d=`/`,f=`*`,p=``,m=`comment`,ee=`declaration`;function h(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,h=1;function ne(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(u);h=~n?e.length-n:h+e.length}function g(){var e={line:l,column:h};return function(t){return t.position=new _(e),re(),t}}function _(e){this.start=e,this.end={line:l,column:h},this.source=t.source}_.prototype.content=e;function v(n){var r=Error(t.source+`:`+l+`:`+h+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=h,r.source=e,!t.silent)throw r}function y(t){var n=t.exec(e);if(n){var r=n[0];return ne(r),e=e.slice(r.length),n}}function re(){y(i)}function ie(e){var t;for(e||=[];t=b();)t!==!1&&e.push(t);return e}function b(){var t=g();if(!(d!=e.charAt(0)||f!=e.charAt(1))){for(var n=2;p!=e.charAt(n)&&(f!=e.charAt(n)||d!=e.charAt(n+1));)++n;if(n+=2,p===e.charAt(n-1))return v(`End of comment missing`);var r=e.slice(2,n-2);return h+=2,ne(r),e=e.slice(n),h+=2,t({type:m,comment:r})}}function ae(){var e=g(),t=y(a);if(t){if(b(),!y(o))return v(`property missing ':'`);var r=y(s),i=e({type:ee,property:te(t[0].replace(n,p)),value:r?te(r[0].replace(n,p)):p});return y(c),i}}function oe(){var e=[];ie(e);for(var t;t=ae();)t!==!1&&(e.push(t),ie(e));return e}return re(),oe()}function te(e){return e?e.replace(l,p):p}t.exports=h})),Ye=n((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.default=r;var n=t(Je());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),Xe=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),Ze=n(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(Ye()),r=Xe();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),Qe=$e(`end`),F=$e(`start`);function $e(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function et(e){let t=F(e),n=Qe(e);if(t&&n)return{start:t,end:n}}var tt=t(Ze(),1),I={}.hasOwnProperty,nt=new Map,rt=/[A-Z]/g,it=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),at=new Set([`td`,`th`]),ot=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function st(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=_t(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=gt(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?P:Ge,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=ct(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function ct(e,t,n){if(t.type===`element`)return lt(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return ut(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return ft(e,t,n);if(t.type===`mdxjsEsm`)return dt(e,t);if(t.type===`root`)return pt(e,t,n);if(t.type===`text`)return mt(e,t)}function lt(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=P,e.schema=i),e.ancestors.push(t);let a=St(e,t.tagName,!1),o=vt(e,t),s=R(e,t);return it.has(t.tagName)&&(s=s.filter(function(e){return typeof e==`string`?!Ce(e):!0})),ht(e,o,a,t),L(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function ut(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}z(e,t.position)}function dt(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);z(e,t.position)}function ft(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=P,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:St(e,t.name,!0),o=yt(e,t),s=R(e,t);return ht(e,o,a,t),L(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function pt(e,t,n){let r={};return L(r,R(e,t)),e.create(t,e.Fragment,r,n)}function mt(e,t){return t.value}function ht(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function L(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function gt(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function _t(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=F(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function vt(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&I.call(t.properties,i)){let a=bt(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&at.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function yt(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else z(e,t.position);else{let i=r.name,a;if(r.value&&typeof r.value==`object`)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else z(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function R(e,t){let n=[],r=-1,i=e.passKeys?new Map:nt;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=ct(e,a,o);s!==void 0&&n.push(s)}return n}function bt(e,t,n){let r=He(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?_e(n):qe(n)),r.property===`style`){let t=typeof n==`object`?n:xt(e,String(n));return e.stylePropertyNameCase===`css`&&(t=Ct(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?Re[r.property]||r.property:r.attribute,n]}}function xt(e,t){try{return(0,tt.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new p("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=ot+`#cannot-parse-style-attribute`,r}}function St(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=xe(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=xe(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return I.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);z(e)}function z(e,t){let n=new p("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=ot+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function Ct(e){let t={},n;for(n in e)I.call(e,n)&&(t[wt(n)]=e[n]);return t}function wt(e){let t=e.replace(rt,Tt);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function Tt(e){return`-`+e.toLowerCase()}var B={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]};function V(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&b(e.charCodeAt(n+1))&&b(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function Et(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function Dt(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
4
|
-
`}]}function Ot(e,t){let n=t.value?t.value+`
|
|
5
|
-
`:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function kt(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function At(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function jt(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=V(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function Mt(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Nt(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Pt(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function Ft(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Pt(e,t);let i={src:V(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function It(e,t){let n={src:V(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function Lt(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function Rt(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Pt(e,t);let i={href:V(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function zt(e,t){let n={href:V(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function Bt(e,t,n){let r=e.all(t),i=n?Vt(n):Ht(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
6
|
-
`}),e.type===`element`&&e.tagName===`p`&&!i?o.push(...e.children):o.push(e)}let c=r[r.length-1];c&&(i||c.type!==`element`||c.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
7
|
-
`});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function Vt(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=Ht(n[r])}return t}function Ht(e){return e.spread??e.children.length>1}function Ut(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function Wt(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Gt(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function Kt(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function qt(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=F(t.children[1]),o=Qe(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function Jt(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function Yt(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var Xt=9,Zt=32;function Qt(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push($t(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push($t(t.slice(i),i>0,!1)),a.join(``)}function $t(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===Xt||t===Zt;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===Xt||t===Zt;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function en(e,t){let n={type:`text`,value:Qt(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function tn(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var nn={blockquote:Et,break:Dt,code:Ot,delete:kt,emphasis:At,footnoteReference:jt,heading:Mt,html:Nt,imageReference:Ft,image:It,inlineCode:Lt,linkReference:Rt,link:zt,listItem:Bt,list:Ut,paragraph:Wt,root:Gt,strong:Kt,table:qt,tableCell:Yt,tableRow:Jt,text:en,thematicBreak:tn,toml:H,yaml:H,definition:H,footnoteDefinition:H};function H(){}var rn=typeof self==`object`?self:globalThis,an=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o)e[r(t)]=r(n);return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(new rn[e](t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}}return n(new rn[a](o),i)};return r},on=e=>an(new Map,e)(0),U=``,{toString:sn}={},{keys:cn}=Object,W=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=sn.call(e).slice(8,-1);switch(n){case`Array`:return[1,U];case`Object`:return[2,U];case`Date`:return[3,U];case`RegExp`:return[4,U];case`Map`:return[5,U];case`Set`:return[6,U];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:n.includes(`Error`)?[7,n]:[2,n]},G=([e,t])=>e===0&&(t===`function`||t===`symbol`),ln=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=r=>{if(n.has(r))return n.get(r);let[o,s]=W(r);switch(o){case 0:{let t=r;switch(s){case`bigint`:o=8,t=r.toString();break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+s);t=null;break;case`undefined`:return i([-1],r)}return i([o,t],r)}case 1:{if(s){let e=r;return s===`DataView`?e=new Uint8Array(r.buffer):s===`ArrayBuffer`&&(e=new Uint8Array(r)),i([s,[...e]],r)}let e=[],t=i([o,e],r);for(let t of r)e.push(a(t));return t}case 2:{if(s)switch(s){case`BigInt`:return i([s,r.toString()],r);case`Boolean`:case`Number`:case`String`:return i([s,r.valueOf()],r)}if(t&&`toJSON`in r)return a(r.toJSON());let n=[],c=i([o,n],r);for(let t of cn(r))(e||!G(W(r[t])))&&n.push([a(t),a(r[t])]);return c}case 3:return i([o,r.toISOString()],r);case 4:{let{source:e,flags:t}=r;return i([o,{source:e,flags:t}],r)}case 5:{let t=[],n=i([o,t],r);for(let[n,i]of r)(e||!(G(W(n))||G(W(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!G(W(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a},un=(e,{json:t,lossy:n}={})=>{let r=[];return ln(!(t||n),!!t,new Map,r)(e),r},K=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?on(un(e,t)):structuredClone(e):(e,t)=>on(un(e,t));function dn(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function fn(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function pn(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||dn,r=e.options.footnoteBackLabel||fn,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=V(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...K(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
|
|
8
|
-
`},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
|
|
9
|
-
`}]}}var mn={}.hasOwnProperty,hn={};function gn(e,t){let n=t||hn,r=new Map,i=new Map,a={all:s,applyData:vn,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...nn,...n.handlers},one:o,options:n,patch:_n,wrap:bn};return m(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(mn.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=K(n);return r.children=a.all(e),r}return K(e)}return(a.options.unknownHandler||yn)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=xn(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=xn(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function _n(e,t){e.position&&(t.position=et(e))}function vn(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,K(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function yn(e,t){let n=t.data||{},r=`value`in t&&!(mn.call(n,`hProperties`)||mn.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function bn(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
|
|
10
|
-
`});++r<e.length;)r&&n.push({type:`text`,value:`
|
|
11
|
-
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
|
|
12
|
-
`}),n}function xn(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Sn(e,t){let n=gn(e,t),r=n.one(e,void 0),i=pn(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
|
|
13
|
-
`},i)),a}function Cn(e,t){return e&&`run`in e?async function(n,r){let i=Sn(n,{file:r,...t});await e.run(i,r)}:function(n,r){return Sn(n,{file:r,...e||t})}}var q=d(),J=t(u(),1),wn=[],Tn={allowDangerousHtml:!0},En=/^(https?|ircs?|mailto|xmpp)$/i,Dn=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function On(e){let t=kn(e),n=An(e);return jn(t.runSync(t.parse(n),n),e)}function kn(e){let t=e.rehypePlugins||wn,n=e.remarkPlugins||wn,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Tn}:Tn;return me().use(ee).use(n).use(Cn,r).use(t)}function An(e){let t=e.children||``,n=new te;return typeof t==`string`?n.value=t:``+t,n}function jn(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||Mn;for(let e of Dn)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return m(e,l),st(e,{Fragment:q.Fragment,components:i,ignoreInvalidStyle:!0,jsx:q.jsx,jsxs:q.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in B)if(Object.hasOwn(B,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=B[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function Mn(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||En.test(e.slice(0,t))?e:``}var Nn=/[#.]/g;function Pn(e,t){let n=e||``,r={},i=0,a,o;for(;i<n.length;){Nn.lastIndex=i;let e=Nn.exec(n),t=n.slice(i,e?e.index:n.length);t&&(a?a===`#`?r.id=t:Array.isArray(r.className)?r.className.push(t):r.className=[t]:o=t,i+=t.length),e&&(a=e[0],i++)}return{type:`element`,tagName:o||t||`div`,properties:r,children:[]}}function Fn(e,t,n){let r=n?Vn(n):void 0;function i(n,i,...a){let o;if(n==null){o={type:`root`,children:[]};let e=i;a.unshift(e)}else{o=Pn(n,t);let s=o.tagName.toLowerCase(),c=r?r.get(s):void 0;if(o.tagName=c||s,In(i))a.unshift(i);else for(let[t,n]of Object.entries(i))Ln(e,o.properties,t,n)}for(let e of a)Rn(o.children,e);return o.type===`element`&&o.tagName===`template`&&(o.content={type:`root`,children:o.children},o.children=[]),o}return i}function In(e){if(typeof e!=`object`||!e||Array.isArray(e))return!0;if(typeof e.type!=`string`)return!1;let t=e,n=Object.keys(e);for(let e of n){let n=t[e];if(n&&typeof n==`object`){if(!Array.isArray(n))return!0;let e=n;for(let t of e)if(typeof t!=`number`&&typeof t!=`string`)return!0}}return!!(`children`in e&&Array.isArray(e.children))}function Ln(e,t,n,r){let i=He(e,n),a;if(r!=null){if(typeof r==`number`){if(Number.isNaN(r))return;a=r}else a=typeof r==`boolean`?r:typeof r==`string`?i.spaceSeparated?Ke(r):i.commaSeparated?ge(r):i.commaOrSpaceSeparated?Ke(ge(r).join(` `)):zn(i,i.property,r):Array.isArray(r)?[...r]:i.property===`style`?Bn(r):String(r);if(Array.isArray(a)){let e=[];for(let t of a)e.push(zn(i,i.property,t));a=e}i.property===`className`&&Array.isArray(t.className)&&(a=t.className.concat(a)),t[i.property]=a}}function Rn(e,t){if(t!=null)if(typeof t==`number`||typeof t==`string`)e.push({type:`text`,value:String(t)});else if(Array.isArray(t))for(let n of t)Rn(e,n);else if(typeof t==`object`&&`type`in t)t.type===`root`?Rn(e,t.children):e.push(t);else throw Error("Expected node, nodes, or string, got `"+t+"`")}function zn(e,t,n){if(typeof n==`string`){if(e.number&&n&&!Number.isNaN(Number(n)))return Number(n);if((e.boolean||e.overloadedBoolean)&&(n===``||S(n)===S(t)))return!0}return n}function Bn(e){let t=[];for(let[n,r]of Object.entries(e))t.push([n,r].join(`: `));return t.join(`; `)}function Vn(e){let t=new Map;for(let n of e)t.set(n.toLowerCase(),n);return t}var Hn=`altGlyph.altGlyphDef.altGlyphItem.animateColor.animateMotion.animateTransform.clipPath.feBlend.feColorMatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feDistantLight.feDropShadow.feFlood.feFuncA.feFuncB.feFuncG.feFuncR.feGaussianBlur.feImage.feMerge.feMergeNode.feMorphology.feOffset.fePointLight.feSpecularLighting.feSpotLight.feTile.feTurbulence.foreignObject.glyphRef.linearGradient.radialGradient.solidColor.textArea.textPath`.split(`.`),Un=Fn(Ge,`div`),Wn=Fn(P,`g`,Hn),Gn={html:`http://www.w3.org/1999/xhtml`,mathml:`http://www.w3.org/1998/Math/MathML`,svg:`http://www.w3.org/2000/svg`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function Kn(e,t){return qn(e,t||{})||{type:`root`,children:[]}}function qn(e,t){let n=Jn(e,t);return n&&t.afterTransform&&t.afterTransform(e,n),n}function Jn(e,t){switch(e.nodeType){case 1:return $n(e,t);case 3:return Zn(e);case 8:return Qn(e);case 9:return Yn(e,t);case 10:return Xn();case 11:return Yn(e,t);default:return}}function Yn(e,t){return{type:`root`,children:er(e,t)}}function Xn(){return{type:`doctype`}}function Zn(e){return{type:`text`,value:e.nodeValue||``}}function Qn(e){return{type:`comment`,value:e.nodeValue||``}}function $n(e,t){let n=e.namespaceURI,r=n===Gn.svg?Wn:Un,i=n===Gn.html?e.tagName.toLowerCase():e.tagName,a=n===Gn.html&&i===`template`?e.content:e,o=e.getAttributeNames(),s={},c=-1;for(;++c<o.length;)s[o[c]]=e.getAttribute(o[c])||``;return r(i,s,er(a,t))}function er(e,t){let n=e.childNodes,r=[],i=-1;for(;++i<n.length;){let e=qn(n[i],t);e!==void 0&&r.push(e)}return r}var tr=new DOMParser;function nr(e,t){return Kn(t?.fragment?rr(e):tr.parseFromString(e,`text/html`))}function rr(e){let t=document.createElement(`template`);return t.innerHTML=e,t.content}var ir=(function(e,t,n){let r=h(n);if(!e||!e.type||!e.children)throw Error(`Expected parent node`);if(typeof t==`number`){if(t<0||t===1/0)throw Error(`Expected positive finite number as index`)}else if(t=e.children.indexOf(t),t<0)throw Error(`Expected child node or index`);for(;++t<e.children.length;)if(r(e.children[t],t,e))return e.children[t]}),Y=(function(e){if(e==null)return cr;if(typeof e==`string`)return or(e);if(typeof e==`object`)return ar(e);if(typeof e==`function`)return sr(e);throw Error("Expected function, string, or array as `test`")});function ar(e){let t=[],n=-1;for(;++n<e.length;)t[n]=Y(e[n]);return sr(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function or(e){return sr(t);function t(t){return t.tagName===e}}function sr(e){return t;function t(t,n,r){return!!(lr(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function cr(e){return!!(e&&typeof e==`object`&&`type`in e&&e.type===`element`&&`tagName`in e&&typeof e.tagName==`string`)}function lr(e){return typeof e==`object`&&!!e&&`type`in e&&`tagName`in e}var ur=/\n/g,dr=/[\t ]+/g,fr=Y(`br`),pr=Y(Er),mr=Y(`p`),hr=Y(`tr`),gr=Y([`datalist`,`head`,`noembed`,`noframes`,`noscript`,`rp`,`script`,`style`,`template`,`title`,Tr,Dr]),_r=Y(`address.article.aside.blockquote.body.caption.center.dd.dialog.dir.dl.dt.div.figure.figcaption.footer.form,.h1.h2.h3.h4.h5.h6.header.hgroup.hr.html.legend.li.listing.main.menu.nav.ol.p.plaintext.pre.section.ul.xmp`.split(`.`));function vr(e,t){let n=t||{},r=`children`in e?e.children:[],i=_r(e),a=wr(e,{whitespace:n.whitespace||`normal`,breakBefore:!1,breakAfter:!1}),o=[];(e.type===`text`||e.type===`comment`)&&o.push(...xr(e,{whitespace:a,breakBefore:!0,breakAfter:!0}));let s=-1;for(;++s<r.length;)o.push(...yr(r[s],e,{whitespace:a,breakBefore:s?void 0:i,breakAfter:s<r.length-1?fr(r[s+1]):i}));let c=[],l;for(s=-1;++s<o.length;){let e=o[s];typeof e==`number`?l!==void 0&&e>l&&(l=e):e&&(l!==void 0&&l>-1&&c.push(`
|
|
14
|
-
`.repeat(l)||` `),l=-1,c.push(e))}return c.join(``)}function yr(e,t,n){return e.type===`element`?br(e,t,n):e.type===`text`?n.whitespace===`normal`?xr(e,n):Sr(e):[]}function br(e,t,n){let r=wr(e,n),i=e.children||[],a=-1,o=[];if(gr(e))return o;let s,c;for(fr(e)||hr(e)&&ir(t,e,hr)?c=`
|
|
15
|
-
`:mr(e)?(s=2,c=2):_r(e)&&(s=1,c=1);++a<i.length;)o=o.concat(yr(i[a],e,{whitespace:r,breakBefore:a?void 0:s,breakAfter:a<i.length-1?fr(i[a+1]):c}));return pr(e)&&ir(t,e,pr)&&o.push(` `),s&&o.unshift(s),c&&o.push(c),o}function xr(e,t){let n=String(e.value),r=[],i=[],a=0;for(;a<=n.length;){ur.lastIndex=a;let e=ur.exec(n),i=e&&`index`in e?e.index:n.length;r.push(Cr(n.slice(a,i).replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g,``),a===0?t.breakBefore:!0,i===n.length?t.breakAfter:!0)),a=i+1}let o=-1,s;for(;++o<r.length;)r[o].charCodeAt(r[o].length-1)===8203||o<r.length-1&&r[o+1].charCodeAt(0)===8203?(i.push(r[o]),s=void 0):r[o]?(typeof s==`number`&&i.push(s),i.push(r[o]),s=0):(o===0||o===r.length-1)&&i.push(0);return i}function Sr(e){return[String(e.value)]}function Cr(e,t,n){let r=[],i=0,a;for(;i<e.length;){dr.lastIndex=i;let n=dr.exec(e);a=n?n.index:e.length,!i&&!a&&n&&!t&&r.push(``),i!==a&&r.push(e.slice(i,a)),i=n?a+n[0].length:a}return i!==a&&!n&&r.push(``),r.join(` `)}function wr(e,t){if(e.type===`element`){let n=e.properties||{};switch(e.tagName){case`listing`:case`plaintext`:case`xmp`:return`pre`;case`nobr`:return`nowrap`;case`pre`:return n.wrap?`pre-wrap`:`pre`;case`td`:case`th`:return n.noWrap?`nowrap`:t.whitespace;case`textarea`:return`pre-wrap`;default:}}return t.whitespace}function Tr(e){return!!(e.properties||{}).hidden}function Er(e){return e.tagName===`td`||e.tagName===`th`}function Dr(e){return e.tagName===`dialog`&&!(e.properties||{}).open}var Or={},kr=[];function Ar(e){let t=e||Or;return function(e,n){ne(e,`element`,function(e,i){let a=Array.isArray(e.properties.className)?e.properties.className:kr,o=a.includes(`language-math`),s=a.includes(`math-display`),c=a.includes(`math-inline`),l=s;if(!o&&!s&&!c)return;let u=i[i.length-1],d=e;if(e.tagName===`code`&&o&&u&&u.type===`element`&&u.tagName===`pre`&&(d=u,u=i[i.length-2],l=!0),!u)return;let f=vr(d,{whitespace:`pre`}),p;try{p=r.renderToString(f,{...t,displayMode:l,throwOnError:!0})}catch(a){let o=a,s=o.name.toLowerCase();n.message(`Could not render math with KaTeX`,{ancestors:[...i,e],cause:o,place:e.position,ruleId:s,source:`rehype-katex`});try{p=r.renderToString(f,{...t,displayMode:l,strict:`ignore`,throwOnError:!1})}catch{p=[{type:`element`,tagName:`span`,properties:{className:[`katex-error`],style:`color:`+(t.errorColor||`#cc0000`),title:String(a)},children:[{type:`text`,value:f}]}]}}typeof p==`string`&&(p=nr(p,{fragment:!0}).children);let m=u.children.indexOf(d);return u.children.splice(m,1,...p),pe})}}var X={}.hasOwnProperty;function jr(e,t){let n={type:`root`,children:[]},r=Mr({schema:t?{..._,...t}:_,stack:[]},e);return r&&(Array.isArray(r)?r.length===1?n=r[0]:n.children=r:n=r),n}function Mr(e,t){if(t&&typeof t==`object`){let n=t;switch(typeof n.type==`string`?n.type:``){case`comment`:return Nr(e,n);case`doctype`:return Pr(e,n);case`element`:return Fr(e,n);case`root`:return Ir(e,n);case`text`:return Lr(e,n);default:}}}function Nr(e,t){if(e.schema.allowComments){let e=typeof t.value==`string`?t.value:``,n=e.indexOf(`-->`),r={type:`comment`,value:n<0?e:e.slice(0,n)};return Z(r,t),r}}function Pr(e,t){if(e.schema.allowDoctypes){let e={type:`doctype`};return Z(e,t),e}}function Fr(e,t){let n=typeof t.tagName==`string`?t.tagName:``;e.stack.push(n);let r=Rr(e,t.children),i=zr(e,t.properties);e.stack.pop();let a=!1;if(n&&n!==`*`&&(!e.schema.tagNames||e.schema.tagNames.includes(n))&&(a=!0,e.schema.ancestors&&X.call(e.schema.ancestors,n))){let t=e.schema.ancestors[n],r=-1;for(a=!1;++r<t.length;)e.stack.includes(t[r])&&(a=!0)}if(!a)return e.schema.strip&&!e.schema.strip.includes(n)?r:void 0;let o={type:`element`,tagName:n,properties:i,children:r};return Z(o,t),o}function Ir(e,t){let n={type:`root`,children:Rr(e,t.children)};return Z(n,t),n}function Lr(e,t){let n={type:`text`,value:typeof t.value==`string`?t.value:``};return Z(n,t),n}function Rr(e,t){let n=[];if(Array.isArray(t)){let r=t,i=-1;for(;++i<r.length;){let t=Mr(e,r[i]);t&&(Array.isArray(t)?n.push(...t):n.push(t))}}return n}function zr(e,t){let n=e.stack[e.stack.length-1],r=e.schema.attributes,i=e.schema.required,a=r&&X.call(r,n)?r[n]:void 0,o=r&&X.call(r,`*`)?r[`*`]:void 0,s=t&&typeof t==`object`?t:{},c={},l;for(l in s)if(X.call(s,l)){let t=s[l],n=Br(e,Wr(a,l),l,t);n??=Br(e,Wr(o,l),l,t),n!=null&&(c[l]=n)}if(i&&X.call(i,n)){let e=i[n];for(l in e)X.call(e,l)&&!X.call(c,l)&&(c[l]=e[l])}return c}function Br(e,t,n,r){return t?Array.isArray(r)?Vr(e,t,n,r):Hr(e,t,n,r):void 0}function Vr(e,t,n,r){let i=-1,a=[];for(;++i<r.length;){let o=Hr(e,t,n,r[i]);(typeof o==`number`||typeof o==`string`)&&a.push(o)}return a}function Hr(e,t,n,r){if(!(typeof r!=`boolean`&&typeof r!=`number`&&typeof r!=`string`)&&Ur(e,n,r)){if(typeof t==`object`&&t.length>1){let e=!1,n=0;for(;++n<t.length;){let i=t[n];if(i&&typeof i==`object`&&`flags`in i){if(i.test(String(r))){e=!0;break}}else if(i===r){e=!0;break}}if(!e)return}return e.schema.clobber&&e.schema.clobberPrefix&&e.schema.clobber.includes(n)?e.schema.clobberPrefix+r:r}}function Ur(e,t,n){let r=e.schema.protocols&&X.call(e.schema.protocols,t)?e.schema.protocols[t]:void 0;if(!r||r.length===0)return!0;let i=String(n),a=i.indexOf(`:`),o=i.indexOf(`?`),s=i.indexOf(`#`),c=i.indexOf(`/`);if(a<0||c>-1&&a>c||o>-1&&a>o||s>-1&&a>s)return!0;let l=-1;for(;++l<r.length;){let e=r[l];if(a===e.length&&i.slice(0,e.length)===e)return!0}return!1}function Z(e,t){let n=et(t);t.data&&(e.data=K(t.data)),n&&(e.position=n)}function Wr(e,t){let n,r=-1;if(e)for(;++r<e.length;){let i=e[r],a=typeof i==`string`?i:i[0];if(a===t)return i;a===`data*`&&(n=i)}if(t.length>4&&t.slice(0,4).toLowerCase()===`data`)return n}function Gr(e){return function(t){return jr(t,e)}}function Kr(e){he(e,[/\r?\n|\r/g,qr])}function qr(){return{type:`break`}}function Jr(){return function(e){Kr(e)}}function Yr(e){let[t,n]=(0,J.useState)(!1),r=y(e.code,e.language),i=r.language||`text`;async function a(){let t=await f(e.code);if(t.ok){n(!0),window.setTimeout(()=>n(!1),1200);return}console.error(`[notes:code-copy]`,t.error)}return(0,q.jsxs)(`div`,{className:`notes-code-block`,children:[(0,q.jsx)(`div`,{className:`notes-code-header`,children:(0,q.jsx)(`button`,{type:`button`,onClick:()=>void a(),children:t?`Copied`:i})}),(0,q.jsx)(`pre`,{children:(0,q.jsx)(`code`,{className:`hljs language-${i}`,"data-highlighted":r.highlighted?`yes`:`no`,dangerouslySetInnerHTML:{__html:r.html}})})]})}var Xr=100,Zr=null,Q=new Map;async function Qr(){return Zr||=(await i(()=>import(`./mermaid.core-TSG49mwm.js`),__vite__mapDeps([0]))).default,Zr.initialize(c()),Zr}function $r(){return document.documentElement.getAttribute(`data-theme`)??`default`}function ei(e,t){if(Q.set(e,t),Q.size<=Xr)return;let n=Q.keys().next().value;n&&Q.delete(n)}function ti(e){let t=(0,J.useId)().replace(/[^a-zA-Z0-9_-]/g,``),n=(0,J.useMemo)(()=>l(e.code),[e.code]),r=$r(),i=(0,J.useMemo)(()=>`${r}\n${n}`,[n,r]),[c,u]=(0,J.useState)(()=>Q.get(i)??{status:`loading`,sourceKey:i});return(0,J.useEffect)(()=>{let e=!1,r=Q.get(i);if(r)return u(r),()=>{e=!0};async function c(){u(e=>e.status===`ready`&&e.sourceKey===i?e:{status:`loading`,sourceKey:i});try{let r=await Qr(),c=`notes-mermaid-${t}`,l;try{({svg:l}=await r.render(c,n))}catch(e){let t=o(n);if(!t)throw e;({svg:l}=await r.render(`${c}-retry`,t))}if(!e){let e={status:`ready`,sourceKey:i,svg:s(l),wide:a(n)};ei(i,e),u(e)}}catch(t){e||u({status:`error`,sourceKey:i,message:t instanceof Error?t.message:`Mermaid render failed`})}}return c(),()=>{e=!0}},[n,t,i]),c.status===`ready`?(0,q.jsx)(`div`,{className:`notes-mermaid-block is-ready${c.wide?` mermaid-type-wide`:``}`,dangerouslySetInnerHTML:{__html:c.svg}}):c.status===`error`?(0,q.jsxs)(`div`,{className:`notes-mermaid-block is-error`,children:[(0,q.jsx)(`strong`,{children:`Mermaid render failed`}),(0,q.jsx)(`span`,{children:c.message}),(0,q.jsx)(`pre`,{children:(0,q.jsx)(`code`,{children:e.code})})]}):(0,q.jsx)(`div`,{className:`notes-mermaid-block is-loading`,role:`status`,"aria-label":`Diagram loading`,children:`Rendering diagram...`})}function ni(e){return oe(e)}function ri(e,t,n){if(!e)return[e];let r=!!t.notes?.length;if(t.lookup.size===0&&!r)return[e];de.lastIndex=0;let i=[],a=0,o=0,s;for(;(s=de.exec(e))!==null;){let r=s.index,c=r+s[0].length;if(le(e,r))continue;let l=t.lookup.get(s[0])??ie(s[0],t.outgoing,t.notes,r);if(!l)continue;r>a&&i.push(e.slice(a,r));let u=g(l,s[0]),d=`${n}-wl-${o++}`;if(l.status===`resolved`&&l.resolvedPath){let e=l.resolvedPath;i.push((0,J.createElement)(`a`,{key:d,className:`notes-wikilink`,href:`#${encodeURIComponent(e)}`,title:e,"data-notes-wiki-status":l.status,onClick:n=>{n.preventDefault(),t.onNavigate(e)}},u))}else{let e=se(l);i.push((0,J.createElement)(`span`,{key:d,className:`notes-wikilink is-broken`,title:e,"data-notes-wiki-status":l.status,"aria-label":`Broken wikilink: ${s[1]}`},u))}a=c}return a===0?[e]:(a<e.length&&i.push(e.slice(a)),i)}function ii(e,t,n){if(t.lookup.size===0&&!t.notes?.length)return e;let r=[],i=0;return J.Children.forEach(e,(e,a)=>{if(typeof e==`string`){let o=ri(e,t,`${n}-${i++}-${a}`);for(let e of o)r.push(e);return}if(typeof e==`number`||typeof e==`boolean`||e==null){r.push(e);return}if((0,J.isValidElement)(e)){r.push(e);return}r.push(e)}),r}var ai=/^---[ \t]*\r?\n[\s\S]*?\r?\n---[ \t]*(?:\r?\n|$)/;function oi(e){let t=ai.exec(e);if(!t)return{frontmatterRaw:null,body:e};let n=t[0];return{frontmatterRaw:n,body:e.slice(n.length)}}function $(e,t){return t?`${e} ${t}`:e}function si(e){let t=0,n=e=>{if(Array.isArray(e)){e.forEach(n);return}(0,J.isValidElement)(e)&&(e.props.node?.tagName===`tr`&&(t=Math.max(t,J.Children.count(e.props.children))),J.Children.forEach(e.props.children,n))};return J.Children.forEach(e,n),Math.max(1,t)}function ci(e){return e<=1?`minmax(0, 1fr)`:e===2?`max-content minmax(16rem, 1fr)`:e===3?`max-content minmax(12rem, .45fr) minmax(18rem, 1fr)`:`max-content repeat(${e-1}, minmax(12rem, 1fr))`}function li(e){return typeof e==`string`||typeof e==`number`?String(e):Array.isArray(e)?e.map(li).join(``):(0,J.isValidElement)(e)?li(e.props.children):``}function ui(e){return(0,J.isValidElement)(e)?(e.props.className??``).match(/language-([^\s]+)/)?.[1]??`text`:`text`}var di=e=>{},fi=/(?:~\/[^\s)`\]"'<>]+|\/(?:Users|home|tmp|var|opt|private)\/[^\s)`\]"'<>]+)/g,pi=/[.,!?:;]+$/;function mi(e){return e.startsWith(`~/`)||/^\/(?:Users|home|tmp|var|opt|private)\//.test(e)}function hi(e){let t=e.split(`/`).pop()||e;return/\.\w{1,10}$/.test(t)?t:e}function gi(e,t,n){if(!e||!t)return[e];fi.lastIndex=0;let r=[],i=0,a=0,o;for(;(o=fi.exec(e))!==null;){let s=o[0],c=s.replace(pi,``);if(!mi(c))continue;o.index>i&&r.push(e.slice(i,o.index));let l=s.slice(c.length);r.push((0,J.createElement)(`button`,{key:`${n}-lf-${a++}`,type:`button`,className:`markdown-local-file-link`,title:c,onClick:e=>{e.preventDefault(),t(c)}},hi(c))),l&&r.push(l),i=o.index+s.length}return i===0?[e]:(i<e.length&&r.push(e.slice(i)),r)}function _i(e,t,n){if(!t)return e;let r=[],i=0;return J.Children.forEach(e,(e,a)=>{if(typeof e==`string`){let o=gi(e,t,`${n}-${i++}-${a}`);for(let e of o)r.push(e);return}r.push(e)}),r}function vi(e){let t=(0,J.useMemo)(()=>oi(e.markdown).body,[e.markdown]),n=(0,J.useMemo)(()=>({lookup:ni(e.outgoing),outgoing:e.outgoing,notes:e.notes,onNavigate:e.onWikiLinkNavigate??di}),[e.outgoing,e.notes,e.onWikiLinkNavigate]),r=(t,r)=>_i(ii(t,n,r),e.onLocalFileOpen,r),i=e=>t=>{let{children:n,node:i,className:a,id:o,style:s}=t,c=r(n,e);return(0,J.createElement)(e,{className:a,id:o,style:s},c)},a=e=>t=>{let{children:n,node:i,className:a,style:o,align:s}=t,c=r(n,e);return(0,q.jsx)(`span`,{className:$(`markdown-linear-table-cell markdown-linear-table-${e}`,a),style:o,"data-align":s||void 0,children:c})},o={a:({href:e,children:t,node:n,...r})=>{let i=typeof e==`string`&&ue(e)?e:void 0,a=!!(i&&/^https?:\/\//i.test(i));return(0,q.jsx)(`a`,{...r,href:i,target:a?`_blank`:void 0,rel:a?`noreferrer noopener`:void 0,children:t})},code:({className:e,children:t})=>(0,q.jsx)(`code`,{className:e,children:t}),pre:({children:e})=>{let t=ui(e),n=li(e).replace(/\n$/,``);return t===`mermaid`?(0,q.jsx)(ti,{code:n}):(0,q.jsx)(Yr,{code:n,language:t})},img:({src:e,alt:t,...n})=>{let r=typeof e==`string`?ae(e):``;return r?r.endsWith(`.pdf`)?(0,q.jsx)(`iframe`,{src:r,title:t??`PDF embed`,className:`notes-pdf-embed`}):(0,q.jsx)(`img`,{...n,src:r,alt:t??``,loading:`lazy`}):null},p:i(`p`),li:i(`li`),h1:i(`h1`),h2:i(`h2`),h3:i(`h3`),h4:i(`h4`),h5:i(`h5`),h6:i(`h6`),blockquote:i(`blockquote`),td:i(`td`),th:i(`th`),em:i(`em`),strong:i(`strong`),del:i(`del`)};return e.tableMode===`linear`&&(o.table=({children:e,node:t,className:n,style:r})=>{let i={...r,"--markdown-linear-table-grid":ci(si(e))};return(0,q.jsx)(`div`,{className:$(`markdown-linear-table`,n),style:i,role:`list`,children:e})},o.thead=({children:e,node:t,className:n,style:r})=>(0,q.jsx)(`div`,{className:$(`markdown-linear-table-head`,n),style:r,children:e}),o.tbody=({children:e,node:t,className:n,style:r})=>(0,q.jsx)(`div`,{className:$(`markdown-linear-table-body`,n),style:r,children:e}),o.tr=({children:e,node:t,className:n,style:r})=>(0,q.jsx)(`div`,{className:$(`markdown-linear-table-row`,n),style:r,role:`listitem`,children:e}),o.th=a(`th`),o.td=a(`td`)),(0,q.jsx)(On,{skipHtml:!0,urlTransform:fe,remarkPlugins:[ce,Jr,re],rehypePlugins:[[Gr,v],Ar],components:o,children:t})}export{Yr as n,vi as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./MarkdownRenderer-CHacL2M_.js";export{e as MarkdownRenderer};
|