pi-outpost 0.32.1 → 0.32.3
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/pi-outpost.mjs
CHANGED
|
@@ -11177,19 +11177,19 @@ function getRgbColor(color3, defaultColor = new Uint8ClampedArray(3)) {
|
|
|
11177
11177
|
if (!Array.isArray(color3)) {
|
|
11178
11178
|
return defaultColor;
|
|
11179
11179
|
}
|
|
11180
|
-
const
|
|
11180
|
+
const rgbColor2 = defaultColor || new Uint8ClampedArray(3);
|
|
11181
11181
|
switch (color3.length) {
|
|
11182
11182
|
case 0:
|
|
11183
11183
|
return null;
|
|
11184
11184
|
case 1:
|
|
11185
|
-
ColorSpaceUtils.gray.getRgbItem(color3, 0,
|
|
11186
|
-
return
|
|
11185
|
+
ColorSpaceUtils.gray.getRgbItem(color3, 0, rgbColor2, 0);
|
|
11186
|
+
return rgbColor2;
|
|
11187
11187
|
case 3:
|
|
11188
|
-
ColorSpaceUtils.rgb.getRgbItem(color3, 0,
|
|
11189
|
-
return
|
|
11188
|
+
ColorSpaceUtils.rgb.getRgbItem(color3, 0, rgbColor2, 0);
|
|
11189
|
+
return rgbColor2;
|
|
11190
11190
|
case 4:
|
|
11191
|
-
ColorSpaceUtils.cmyk.getRgbItem(color3, 0,
|
|
11192
|
-
return
|
|
11191
|
+
ColorSpaceUtils.cmyk.getRgbItem(color3, 0, rgbColor2, 0);
|
|
11192
|
+
return rgbColor2;
|
|
11193
11193
|
default:
|
|
11194
11194
|
return defaultColor;
|
|
11195
11195
|
}
|
|
@@ -15076,20 +15076,20 @@ var init_pdf_worker = __esm({
|
|
|
15076
15076
|
stringify: function stringify(text7, replacer2, space) {
|
|
15077
15077
|
var replacerFunction = getReplacerFunction(replacer2);
|
|
15078
15078
|
var rawStrings = [];
|
|
15079
|
-
var
|
|
15079
|
+
var json2 = stringifyWithProperSymbolsConversion(text7, function(key, value) {
|
|
15080
15080
|
var v2 = isCallable(replacerFunction) ? call(replacerFunction, this, $String(key), value) : value;
|
|
15081
15081
|
return !NATIVE_RAW_JSON && isRawJSON(v2) ? MARK2 + (push2(rawStrings, v2.rawJSON) - 1) : v2;
|
|
15082
15082
|
}, space);
|
|
15083
|
-
if (typeof
|
|
15084
|
-
if (ILL_FORMED_UNICODE)
|
|
15085
|
-
if (NATIVE_RAW_JSON) return
|
|
15083
|
+
if (typeof json2 != "string") return json2;
|
|
15084
|
+
if (ILL_FORMED_UNICODE) json2 = replace2(json2, surrogates, fixIllFormedJSON);
|
|
15085
|
+
if (NATIVE_RAW_JSON) return json2;
|
|
15086
15086
|
var result = "";
|
|
15087
|
-
var length =
|
|
15087
|
+
var length = json2.length;
|
|
15088
15088
|
for (var i2 = 0; i2 < length; i2++) {
|
|
15089
|
-
var chr = charAt(
|
|
15089
|
+
var chr = charAt(json2, i2);
|
|
15090
15090
|
if (chr === '"') {
|
|
15091
|
-
var end = parseJSONString(
|
|
15092
|
-
var string3 = slice3(
|
|
15091
|
+
var end = parseJSONString(json2, ++i2).end - 1;
|
|
15092
|
+
var string3 = slice3(json2, i2, end);
|
|
15093
15093
|
result += slice3(string3, 0, MARK_LENGTH) === MARK2 ? rawStrings[slice3(string3, MARK_LENGTH)] : '"' + string3 + '"';
|
|
15094
15094
|
i2 = end;
|
|
15095
15095
|
} else result += chr;
|
|
@@ -18174,9 +18174,9 @@ var init_pdf_worker = __esm({
|
|
|
18174
18174
|
kind
|
|
18175
18175
|
} = imgData;
|
|
18176
18176
|
const rgbaSize = width * height * 4;
|
|
18177
|
-
const
|
|
18178
|
-
const newWidth = width >>
|
|
18179
|
-
const newHeight = height >>
|
|
18177
|
+
const K4 = Math.ceil(Math.log2(rgbaSize / MAX_INT_32));
|
|
18178
|
+
const newWidth = width >> K4;
|
|
18179
|
+
const newHeight = height >> K4;
|
|
18180
18180
|
let rgbaData;
|
|
18181
18181
|
let maxHeight = height;
|
|
18182
18182
|
try {
|
|
@@ -18216,10 +18216,10 @@ var init_pdf_worker = __esm({
|
|
|
18216
18216
|
inverseDecode: this._isMask,
|
|
18217
18217
|
srcPos
|
|
18218
18218
|
}));
|
|
18219
|
-
for (let i2 = 0, ii = h >>
|
|
18220
|
-
const buf = src32.subarray((i2 <<
|
|
18219
|
+
for (let i2 = 0, ii = h >> K4; i2 < ii; i2++) {
|
|
18220
|
+
const buf = src32.subarray((i2 << K4) * width);
|
|
18221
18221
|
for (let j2 = 0; j2 < newWidth; j2++) {
|
|
18222
|
-
dest32[newIndex++] = buf[j2 <<
|
|
18222
|
+
dest32[newIndex++] = buf[j2 << K4];
|
|
18223
18223
|
}
|
|
18224
18224
|
}
|
|
18225
18225
|
}
|
|
@@ -49488,9 +49488,9 @@ var init_pdf_worker = __esm({
|
|
|
49488
49488
|
const flags = outlineDict.get("F") || 0;
|
|
49489
49489
|
const color3 = outlineDict.getArray("C");
|
|
49490
49490
|
const count = outlineDict.get("Count");
|
|
49491
|
-
let
|
|
49491
|
+
let rgbColor2 = blackColor;
|
|
49492
49492
|
if (isNumberArray(color3, 3) && (color3[0] !== 0 || color3[1] !== 0 || color3[2] !== 0)) {
|
|
49493
|
-
|
|
49493
|
+
rgbColor2 = ColorSpaceUtils.rgb.getRgb(color3, 0);
|
|
49494
49494
|
}
|
|
49495
49495
|
const outlineItem = {
|
|
49496
49496
|
action: data.action,
|
|
@@ -49502,7 +49502,7 @@ var init_pdf_worker = __esm({
|
|
|
49502
49502
|
newWindow: data.newWindow,
|
|
49503
49503
|
setOCGState: data.setOCGState,
|
|
49504
49504
|
title: typeof title === "string" ? stringToPDFString(title) : "",
|
|
49505
|
-
color:
|
|
49505
|
+
color: rgbColor2,
|
|
49506
49506
|
count: Number.isInteger(count) ? count : void 0,
|
|
49507
49507
|
bold: !!(flags & 2),
|
|
49508
49508
|
italic: !!(flags & 1),
|
|
@@ -76124,20 +76124,20 @@ var init_pdf = __esm({
|
|
|
76124
76124
|
stringify: function stringify(text7, replacer2, space) {
|
|
76125
76125
|
var replacerFunction = getReplacerFunction(replacer2);
|
|
76126
76126
|
var rawStrings = [];
|
|
76127
|
-
var
|
|
76127
|
+
var json2 = stringifyWithProperSymbolsConversion(text7, function(key, value) {
|
|
76128
76128
|
var v2 = isCallable(replacerFunction) ? call(replacerFunction, this, $String(key), value) : value;
|
|
76129
76129
|
return !NATIVE_RAW_JSON && isRawJSON(v2) ? MARK2 + (push2(rawStrings, v2.rawJSON) - 1) : v2;
|
|
76130
76130
|
}, space);
|
|
76131
|
-
if (typeof
|
|
76132
|
-
if (ILL_FORMED_UNICODE)
|
|
76133
|
-
if (NATIVE_RAW_JSON) return
|
|
76131
|
+
if (typeof json2 != "string") return json2;
|
|
76132
|
+
if (ILL_FORMED_UNICODE) json2 = replace2(json2, surrogates, fixIllFormedJSON);
|
|
76133
|
+
if (NATIVE_RAW_JSON) return json2;
|
|
76134
76134
|
var result = "";
|
|
76135
|
-
var length =
|
|
76135
|
+
var length = json2.length;
|
|
76136
76136
|
for (var i2 = 0; i2 < length; i2++) {
|
|
76137
|
-
var chr = charAt(
|
|
76137
|
+
var chr = charAt(json2, i2);
|
|
76138
76138
|
if (chr === '"') {
|
|
76139
|
-
var end = parseJSONString(
|
|
76140
|
-
var string3 = slice3(
|
|
76139
|
+
var end = parseJSONString(json2, ++i2).end - 1;
|
|
76140
|
+
var string3 = slice3(json2, i2, end);
|
|
76141
76141
|
result += slice3(string3, 0, MARK_LENGTH) === MARK2 ? rawStrings[slice3(string3, MARK_LENGTH)] : '"' + string3 + '"';
|
|
76142
76142
|
i2 = end;
|
|
76143
76143
|
} else result += chr;
|
|
@@ -96787,9 +96787,9 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
|
|
|
96787
96787
|
return false;
|
|
96788
96788
|
}
|
|
96789
96789
|
const diffD = d - this.#min_dist;
|
|
96790
|
-
const
|
|
96791
|
-
const shiftX =
|
|
96792
|
-
const shiftY =
|
|
96790
|
+
const K4 = diffD / d;
|
|
96791
|
+
const shiftX = K4 * diffX;
|
|
96792
|
+
const shiftY = K4 * diffY;
|
|
96793
96793
|
let x0 = x1;
|
|
96794
96794
|
let y0 = y1;
|
|
96795
96795
|
x1 = x22;
|
|
@@ -107313,6 +107313,67 @@ var require_javascript = __commonJS({
|
|
|
107313
107313
|
}
|
|
107314
107314
|
});
|
|
107315
107315
|
|
|
107316
|
+
// ../node_modules/@earendil-works/pi-coding-agent/node_modules/highlight.js/lib/languages/json.js
|
|
107317
|
+
var require_json = __commonJS({
|
|
107318
|
+
"../node_modules/@earendil-works/pi-coding-agent/node_modules/highlight.js/lib/languages/json.js"(exports, module) {
|
|
107319
|
+
function json2(hljs2) {
|
|
107320
|
+
const LITERALS = {
|
|
107321
|
+
literal: "true false null"
|
|
107322
|
+
};
|
|
107323
|
+
const ALLOWED_COMMENTS = [
|
|
107324
|
+
hljs2.C_LINE_COMMENT_MODE,
|
|
107325
|
+
hljs2.C_BLOCK_COMMENT_MODE
|
|
107326
|
+
];
|
|
107327
|
+
const TYPES = [
|
|
107328
|
+
hljs2.QUOTE_STRING_MODE,
|
|
107329
|
+
hljs2.C_NUMBER_MODE
|
|
107330
|
+
];
|
|
107331
|
+
const VALUE_CONTAINER = {
|
|
107332
|
+
end: ",",
|
|
107333
|
+
endsWithParent: true,
|
|
107334
|
+
excludeEnd: true,
|
|
107335
|
+
contains: TYPES,
|
|
107336
|
+
keywords: LITERALS
|
|
107337
|
+
};
|
|
107338
|
+
const OBJECT = {
|
|
107339
|
+
begin: /\{/,
|
|
107340
|
+
end: /\}/,
|
|
107341
|
+
contains: [
|
|
107342
|
+
{
|
|
107343
|
+
className: "attr",
|
|
107344
|
+
begin: /"/,
|
|
107345
|
+
end: /"/,
|
|
107346
|
+
contains: [hljs2.BACKSLASH_ESCAPE],
|
|
107347
|
+
illegal: "\\n"
|
|
107348
|
+
},
|
|
107349
|
+
hljs2.inherit(VALUE_CONTAINER, {
|
|
107350
|
+
begin: /:/
|
|
107351
|
+
})
|
|
107352
|
+
].concat(ALLOWED_COMMENTS),
|
|
107353
|
+
illegal: "\\S"
|
|
107354
|
+
};
|
|
107355
|
+
const ARRAY = {
|
|
107356
|
+
begin: "\\[",
|
|
107357
|
+
end: "\\]",
|
|
107358
|
+
contains: [hljs2.inherit(VALUE_CONTAINER)],
|
|
107359
|
+
// inherit is a workaround for a bug that makes shared modes with endsWithParent compile only the ending of one of the parents
|
|
107360
|
+
illegal: "\\S"
|
|
107361
|
+
};
|
|
107362
|
+
TYPES.push(OBJECT, ARRAY);
|
|
107363
|
+
ALLOWED_COMMENTS.forEach(function(rule) {
|
|
107364
|
+
TYPES.push(rule);
|
|
107365
|
+
});
|
|
107366
|
+
return {
|
|
107367
|
+
name: "JSON",
|
|
107368
|
+
contains: TYPES,
|
|
107369
|
+
keywords: LITERALS,
|
|
107370
|
+
illegal: "\\S"
|
|
107371
|
+
};
|
|
107372
|
+
}
|
|
107373
|
+
module.exports = json2;
|
|
107374
|
+
}
|
|
107375
|
+
});
|
|
107376
|
+
|
|
107316
107377
|
// ../node_modules/@earendil-works/pi-coding-agent/node_modules/highlight.js/lib/languages/kotlin.js
|
|
107317
107378
|
var require_kotlin = __commonJS({
|
|
107318
107379
|
"../node_modules/@earendil-works/pi-coding-agent/node_modules/highlight.js/lib/languages/kotlin.js"(exports, module) {
|
|
@@ -124467,7 +124528,7 @@ function collectShapes(operators2, ops) {
|
|
|
124467
124528
|
const shapes = [];
|
|
124468
124529
|
let ctm = [1, 0, 0, 1, 0, 0];
|
|
124469
124530
|
const stack = [];
|
|
124470
|
-
const
|
|
124531
|
+
const multiply2 = (m2, n) => [
|
|
124471
124532
|
m2[0] * n[0] + m2[2] * n[1],
|
|
124472
124533
|
m2[1] * n[0] + m2[3] * n[1],
|
|
124473
124534
|
m2[0] * n[2] + m2[2] * n[3],
|
|
@@ -124486,7 +124547,7 @@ function collectShapes(operators2, ops) {
|
|
|
124486
124547
|
ctm = stack.pop() ?? ctm;
|
|
124487
124548
|
} else if (op2 === ops.transform) {
|
|
124488
124549
|
const args = operators2.argsArray[index4];
|
|
124489
|
-
if (Array.isArray(args) && args.length >= 6) ctm =
|
|
124550
|
+
if (Array.isArray(args) && args.length >= 6) ctm = multiply2(ctm, args);
|
|
124490
124551
|
} else if (op2 === ops.constructPath) {
|
|
124491
124552
|
const args = operators2.argsArray[index4];
|
|
124492
124553
|
if (args === void 0) continue;
|
|
@@ -124512,7 +124573,7 @@ function collectImages(operators2, ops) {
|
|
|
124512
124573
|
const images = [];
|
|
124513
124574
|
let ctm = [1, 0, 0, 1, 0, 0];
|
|
124514
124575
|
const stack = [];
|
|
124515
|
-
const
|
|
124576
|
+
const multiply2 = (m2, n) => [
|
|
124516
124577
|
m2[0] * n[0] + m2[2] * n[1],
|
|
124517
124578
|
m2[1] * n[0] + m2[3] * n[1],
|
|
124518
124579
|
m2[0] * n[2] + m2[2] * n[3],
|
|
@@ -124531,7 +124592,7 @@ function collectImages(operators2, ops) {
|
|
|
124531
124592
|
continue;
|
|
124532
124593
|
}
|
|
124533
124594
|
if (fn2 === ops.transform) {
|
|
124534
|
-
ctm =
|
|
124595
|
+
ctm = multiply2(ctm, operators2.argsArray[at4]);
|
|
124535
124596
|
continue;
|
|
124536
124597
|
}
|
|
124537
124598
|
if (fn2 !== ops.paintImageXObject && fn2 !== ops.paintInlineImageXObject) continue;
|
|
@@ -138250,12 +138311,12 @@ var require_xml2json = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
138250
138311
|
return options;
|
|
138251
138312
|
}
|
|
138252
138313
|
module.exports = function(xml, userOptions) {
|
|
138253
|
-
var options = validateOptions(userOptions), js = xml2js(xml, options),
|
|
138254
|
-
if ("addParent" in options && options.addParent)
|
|
138314
|
+
var options = validateOptions(userOptions), js = xml2js(xml, options), json2, parentKey = "compact" in options && options.compact ? "_parent" : "parent";
|
|
138315
|
+
if ("addParent" in options && options.addParent) json2 = JSON.stringify(js, function(k2, v2) {
|
|
138255
138316
|
return k2 === parentKey ? "_" : v2;
|
|
138256
138317
|
}, options.spaces);
|
|
138257
|
-
else
|
|
138258
|
-
return
|
|
138318
|
+
else json2 = JSON.stringify(js, null, options.spaces);
|
|
138319
|
+
return json2.replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
138259
138320
|
};
|
|
138260
138321
|
}));
|
|
138261
138322
|
var require_js2xml = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
@@ -138521,15 +138582,15 @@ var require_js2xml = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
138521
138582
|
}));
|
|
138522
138583
|
var require_json2xml = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
138523
138584
|
var js2xml = require_js2xml();
|
|
138524
|
-
module.exports = function(
|
|
138525
|
-
if (
|
|
138585
|
+
module.exports = function(json2, options) {
|
|
138586
|
+
if (json2 instanceof Buffer) json2 = json2.toString();
|
|
138526
138587
|
var js = null;
|
|
138527
|
-
if (typeof
|
|
138528
|
-
js = JSON.parse(
|
|
138588
|
+
if (typeof json2 === "string") try {
|
|
138589
|
+
js = JSON.parse(json2);
|
|
138529
138590
|
} catch (e) {
|
|
138530
138591
|
throw new Error("The JSON structure is invalid");
|
|
138531
138592
|
}
|
|
138532
|
-
else js =
|
|
138593
|
+
else js = json2;
|
|
138533
138594
|
return js2xml(js, options);
|
|
138534
138595
|
};
|
|
138535
138596
|
}));
|
|
@@ -140352,7 +140413,7 @@ var require_ripemd = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
140352
140413
|
var Dh = D3;
|
|
140353
140414
|
var Eh = E;
|
|
140354
140415
|
for (var j2 = 0; j2 < 80; j2++) {
|
|
140355
|
-
var T5 = sum32(rotl32(sum32_4(A5, f2(j2, B4, C2, D3), msg[r[j2] + start],
|
|
140416
|
+
var T5 = sum32(rotl32(sum32_4(A5, f2(j2, B4, C2, D3), msg[r[j2] + start], K4(j2)), s[j2]), E);
|
|
140356
140417
|
A5 = E;
|
|
140357
140418
|
E = D3;
|
|
140358
140419
|
D3 = rotl32(C2, 10);
|
|
@@ -140383,7 +140444,7 @@ var require_ripemd = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
140383
140444
|
else if (j2 <= 63) return x2 & z3 | y2 & ~z3;
|
|
140384
140445
|
else return x2 ^ (y2 | ~z3);
|
|
140385
140446
|
}
|
|
140386
|
-
function
|
|
140447
|
+
function K4(j2) {
|
|
140387
140448
|
if (j2 <= 15) return 0;
|
|
140388
140449
|
else if (j2 <= 31) return 1518500249;
|
|
140389
140450
|
else if (j2 <= 47) return 1859775393;
|
|
@@ -147716,7 +147777,7 @@ var require_jszip_min = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
147716
147777
|
var t2;
|
|
147717
147778
|
return e2 && e2.state ? (e2.total_in = e2.total_out = 0, e2.data_type = i2, (t2 = e2.state).pending = 0, t2.pending_out = 0, t2.wrap < 0 && (t2.wrap = -t2.wrap), t2.status = t2.wrap ? C2 : E, e2.adler = 2 === t2.wrap ? 0 : 1, t2.last_flush = l3, u._tr_init(t2), m2) : R4(e2, _2);
|
|
147718
147779
|
}
|
|
147719
|
-
function
|
|
147780
|
+
function K4(e2) {
|
|
147720
147781
|
var t2 = G2(e2);
|
|
147721
147782
|
return t2 === m2 && (function(e3) {
|
|
147722
147783
|
e3.window_size = 2 * e3.w_size, D3(e3.head), e3.max_lazy_match = h[e3.level].max_lazy, e3.good_match = h[e3.level].good_length, e3.nice_match = h[e3.level].nice_length, e3.max_chain_length = h[e3.level].max_chain, e3.strstart = 0, e3.block_start = 0, e3.lookahead = 0, e3.insert = 0, e3.match_length = e3.prev_length = x2 - 1, e3.match_available = 0, e3.ins_h = 0;
|
|
@@ -147728,7 +147789,7 @@ var require_jszip_min = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
147728
147789
|
if (t2 === g && (t2 = 6), n2 < 0 ? (a2 = 0, n2 = -n2) : 15 < n2 && (a2 = 2, n2 -= 16), i3 < 1 || y2 < i3 || r2 !== v2 || n2 < 8 || 15 < n2 || t2 < 0 || 9 < t2 || s2 < 0 || b2 < s2) return R4(e2, _2);
|
|
147729
147790
|
8 === n2 && (n2 = 9);
|
|
147730
147791
|
var o2 = new H3();
|
|
147731
|
-
return (e2.state = o2).strm = e2, o2.wrap = a2, o2.gzhead = null, o2.w_bits = n2, o2.w_size = 1 << o2.w_bits, o2.w_mask = o2.w_size - 1, o2.hash_bits = i3 + 7, o2.hash_size = 1 << o2.hash_bits, o2.hash_mask = o2.hash_size - 1, o2.hash_shift = ~~((o2.hash_bits + x2 - 1) / x2), o2.window = new c2.Buf8(2 * o2.w_size), o2.head = new c2.Buf16(o2.hash_size), o2.prev = new c2.Buf16(o2.w_size), o2.lit_bufsize = 1 << i3 + 6, o2.pending_buf_size = 4 * o2.lit_bufsize, o2.pending_buf = new c2.Buf8(o2.pending_buf_size), o2.d_buf = 1 * o2.lit_bufsize, o2.l_buf = 3 * o2.lit_bufsize, o2.level = t2, o2.strategy = s2, o2.method = r2,
|
|
147792
|
+
return (e2.state = o2).strm = e2, o2.wrap = a2, o2.gzhead = null, o2.w_bits = n2, o2.w_size = 1 << o2.w_bits, o2.w_mask = o2.w_size - 1, o2.hash_bits = i3 + 7, o2.hash_size = 1 << o2.hash_bits, o2.hash_mask = o2.hash_size - 1, o2.hash_shift = ~~((o2.hash_bits + x2 - 1) / x2), o2.window = new c2.Buf8(2 * o2.w_size), o2.head = new c2.Buf16(o2.hash_size), o2.prev = new c2.Buf16(o2.w_size), o2.lit_bufsize = 1 << i3 + 6, o2.pending_buf_size = 4 * o2.lit_bufsize, o2.pending_buf = new c2.Buf8(o2.pending_buf_size), o2.d_buf = 1 * o2.lit_bufsize, o2.l_buf = 3 * o2.lit_bufsize, o2.level = t2, o2.strategy = s2, o2.method = r2, K4(e2);
|
|
147732
147793
|
}
|
|
147733
147794
|
h = [
|
|
147734
147795
|
new M3(0, 0, 0, 0, function(e2, t2) {
|
|
@@ -147756,7 +147817,7 @@ var require_jszip_min = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
147756
147817
|
new M3(32, 258, 258, 4096, W2)
|
|
147757
147818
|
], r.deflateInit = function(e2, t2) {
|
|
147758
147819
|
return Y3(e2, t2, v2, 15, 8, 0);
|
|
147759
|
-
}, r.deflateInit2 = Y3, r.deflateReset =
|
|
147820
|
+
}, r.deflateInit2 = Y3, r.deflateReset = K4, r.deflateResetKeep = G2, r.deflateSetHeader = function(e2, t2) {
|
|
147760
147821
|
return e2 && e2.state ? 2 !== e2.state.wrap ? _2 : (e2.state.gzhead = t2, m2) : _2;
|
|
147761
147822
|
}, r.deflate = function(e2, t2) {
|
|
147762
147823
|
var r2, n2, i3, s2;
|
|
@@ -148706,7 +148767,7 @@ var require_jszip_min = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
148706
148767
|
for (var n2 = e2.heap[r2], i3 = r2 << 1; i3 <= e2.heap_len && (i3 < e2.heap_len && H3(t2, e2.heap[i3 + 1], e2.heap[i3], e2.depth) && i3++, !H3(t2, n2, e2.heap[i3], e2.depth)); ) e2.heap[r2] = e2.heap[i3], r2 = i3, i3 <<= 1;
|
|
148707
148768
|
e2.heap[r2] = n2;
|
|
148708
148769
|
}
|
|
148709
|
-
function
|
|
148770
|
+
function K4(e2, t2, r2) {
|
|
148710
148771
|
var n2, i3, s2, a2, o2 = 0;
|
|
148711
148772
|
if (0 !== e2.last_lit) for (; n2 = e2.pending_buf[e2.d_buf + 2 * o2] << 8 | e2.pending_buf[e2.d_buf + 2 * o2 + 1], i3 = e2.pending_buf[e2.l_buf + o2], o2++, 0 === n2 ? L2(e2, i3, t2) : (L2(e2, (s2 = A5[i3]) + u + 1, t2), 0 !== (a2 = w[s2]) && P5(e2, i3 -= I3[s2], a2), L2(e2, s2 = N(--n2), r2), 0 !== (a2 = k2[s2]) && P5(e2, n2 -= T5[s2], a2)), o2 < e2.last_lit; ) ;
|
|
148712
148773
|
L2(e2, m2, t2);
|
|
@@ -148775,11 +148836,11 @@ var require_jszip_min = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
148775
148836
|
var t3;
|
|
148776
148837
|
for (X3(e3, e3.dyn_ltree, e3.l_desc.max_code), X3(e3, e3.dyn_dtree, e3.d_desc.max_code), Y3(e3, e3.bl_desc), t3 = c2 - 1; 3 <= t3 && 0 === e3.bl_tree[2 * S3[t3] + 1]; t3--) ;
|
|
148777
148838
|
return e3.opt_len += 3 * (t3 + 1) + 5 + 5 + 4, t3;
|
|
148778
|
-
})(e2), i3 = e2.opt_len + 3 + 7 >>> 3, (s2 = e2.static_len + 3 + 7 >>> 3) <= i3 && (i3 = s2)) : i3 = s2 = r2 + 5, r2 + 4 <= i3 && -1 !== t2 ? J3(e2, t2, r2, n2) : 4 === e2.strategy || s2 === i3 ? (P5(e2, 2 + (n2 ? 1 : 0), 3),
|
|
148839
|
+
})(e2), i3 = e2.opt_len + 3 + 7 >>> 3, (s2 = e2.static_len + 3 + 7 >>> 3) <= i3 && (i3 = s2)) : i3 = s2 = r2 + 5, r2 + 4 <= i3 && -1 !== t2 ? J3(e2, t2, r2, n2) : 4 === e2.strategy || s2 === i3 ? (P5(e2, 2 + (n2 ? 1 : 0), 3), K4(e2, z3, C2)) : (P5(e2, 4 + (n2 ? 1 : 0), 3), (function(e3, t3, r3, n3) {
|
|
148779
148840
|
var i4;
|
|
148780
148841
|
for (P5(e3, t3 - 257, 5), P5(e3, r3 - 1, 5), P5(e3, n3 - 4, 4), i4 = 0; i4 < n3; i4++) P5(e3, e3.bl_tree[2 * S3[i4] + 1], 3);
|
|
148781
148842
|
V3(e3, e3.dyn_ltree, t3 - 1), V3(e3, e3.dyn_dtree, r3 - 1);
|
|
148782
|
-
})(e2, e2.l_desc.max_code + 1, e2.d_desc.max_code + 1, a2 + 1),
|
|
148843
|
+
})(e2, e2.l_desc.max_code + 1, e2.d_desc.max_code + 1, a2 + 1), K4(e2, e2.dyn_ltree, e2.dyn_dtree)), W2(e2), n2 && M3(e2);
|
|
148783
148844
|
}, r._tr_tally = function(e2, t2, r2) {
|
|
148784
148845
|
return e2.pending_buf[e2.d_buf + 2 * e2.last_lit] = t2 >>> 8 & 255, e2.pending_buf[e2.d_buf + 2 * e2.last_lit + 1] = 255 & t2, e2.pending_buf[e2.l_buf + e2.last_lit] = 255 & r2, e2.last_lit++, 0 === t2 ? e2.dyn_ltree[2 * r2]++ : (e2.matches++, t2--, e2.dyn_ltree[2 * (A5[r2] + u + 1)]++, e2.dyn_dtree[2 * N(t2)]++), e2.last_lit === e2.lit_bufsize - 1;
|
|
148785
148846
|
}, r._tr_align = function(e2) {
|
|
@@ -149911,24 +149972,24 @@ var traverse = (node2) => {
|
|
|
149911
149972
|
var findLocationOfText = (node2, text7) => traverse(node2).filter((p) => p.text.includes(text7));
|
|
149912
149973
|
var formatter = new Formatter();
|
|
149913
149974
|
var SPLIT_TOKEN = "\u0275";
|
|
149914
|
-
var replacer = ({ json, patch, patchText, context, keepOriginalStyles = true }) => {
|
|
149915
|
-
const renderedParagraphs = findLocationOfText(
|
|
149975
|
+
var replacer = ({ json: json2, patch, patchText, context, keepOriginalStyles = true }) => {
|
|
149976
|
+
const renderedParagraphs = findLocationOfText(json2, patchText);
|
|
149916
149977
|
if (renderedParagraphs.length === 0) return {
|
|
149917
|
-
element:
|
|
149978
|
+
element: json2,
|
|
149918
149979
|
didFindOccurrence: false
|
|
149919
149980
|
};
|
|
149920
149981
|
for (const renderedParagraph of renderedParagraphs) {
|
|
149921
149982
|
const textJson = patch.children.map((c2) => toJson((0, import_xml6.default)(formatter.format(c2, context)))).map((c2) => c2.elements[0]);
|
|
149922
149983
|
switch (patch.type) {
|
|
149923
149984
|
case PatchType.DOCUMENT: {
|
|
149924
|
-
const parentElement = goToParentElementFromPath(
|
|
149985
|
+
const parentElement = goToParentElementFromPath(json2, renderedParagraph.pathToParagraph);
|
|
149925
149986
|
const elementIndex = getLastElementIndexFromPath(renderedParagraph.pathToParagraph);
|
|
149926
149987
|
parentElement.elements.splice(elementIndex, 1, ...textJson);
|
|
149927
149988
|
break;
|
|
149928
149989
|
}
|
|
149929
149990
|
case PatchType.PARAGRAPH:
|
|
149930
149991
|
default: {
|
|
149931
|
-
const paragraphElement = goToElementFromPath(
|
|
149992
|
+
const paragraphElement = goToElementFromPath(json2, renderedParagraph.pathToParagraph);
|
|
149932
149993
|
replaceTokenInParagraphElement({
|
|
149933
149994
|
paragraphElement,
|
|
149934
149995
|
renderedParagraph,
|
|
@@ -149954,19 +150015,19 @@ var replacer = ({ json, patch, patchText, context, keepOriginalStyles = true })
|
|
|
149954
150015
|
}
|
|
149955
150016
|
}
|
|
149956
150017
|
return {
|
|
149957
|
-
element:
|
|
150018
|
+
element: json2,
|
|
149958
150019
|
didFindOccurrence: true
|
|
149959
150020
|
};
|
|
149960
150021
|
};
|
|
149961
|
-
var goToElementFromPath = (
|
|
149962
|
-
let element =
|
|
150022
|
+
var goToElementFromPath = (json2, path37) => {
|
|
150023
|
+
let element = json2;
|
|
149963
150024
|
for (let i2 = 1; i2 < path37.length; i2++) {
|
|
149964
150025
|
const index4 = path37[i2];
|
|
149965
150026
|
element = element.elements[index4];
|
|
149966
150027
|
}
|
|
149967
150028
|
return element;
|
|
149968
150029
|
};
|
|
149969
|
-
var goToParentElementFromPath = (
|
|
150030
|
+
var goToParentElementFromPath = (json2, path37) => goToElementFromPath(json2, path37.slice(0, path37.length - 1));
|
|
149970
150031
|
var getLastElementIndexFromPath = (path37) => path37[path37.length - 1];
|
|
149971
150032
|
var PatchType = {
|
|
149972
150033
|
/** Replace entire file-level elements (e.g., whole paragraphs) */
|
|
@@ -150006,10 +150067,10 @@ var patchDocument = (function() {
|
|
|
150006
150067
|
binaryContentMap.set(key, binaryValue);
|
|
150007
150068
|
continue;
|
|
150008
150069
|
}
|
|
150009
|
-
const
|
|
150070
|
+
const json2 = toJson(yield value.async("text"));
|
|
150010
150071
|
if (key === "word/document.xml") {
|
|
150011
150072
|
var _json$elements;
|
|
150012
|
-
const document4 = (_json$elements =
|
|
150073
|
+
const document4 = (_json$elements = json2.elements) === null || _json$elements === void 0 ? void 0 : _json$elements.find((i2) => i2.name === "w:document");
|
|
150013
150074
|
if (document4 && document4.attributes) {
|
|
150014
150075
|
for (const ns of [
|
|
150015
150076
|
"mc",
|
|
@@ -150042,7 +150103,7 @@ var patchDocument = (function() {
|
|
|
150042
150103
|
const patchText = `${start}${patchKey}${end}`;
|
|
150043
150104
|
while (true) {
|
|
150044
150105
|
const { didFindOccurrence } = replacer({
|
|
150045
|
-
json,
|
|
150106
|
+
json: json2,
|
|
150046
150107
|
patch: _objectSpread2(_objectSpread2({}, patchValue), {}, { children: patchValue.children.map((element) => {
|
|
150047
150108
|
if (element instanceof ExternalHyperlink) {
|
|
150048
150109
|
const concreteHyperlink = new ConcreteHyperlink(element.options.children, uniqueId());
|
|
@@ -150063,7 +150124,7 @@ var patchDocument = (function() {
|
|
|
150063
150124
|
if (!recursive || !didFindOccurrence) break;
|
|
150064
150125
|
}
|
|
150065
150126
|
}
|
|
150066
|
-
const mediaDatas = imageReplacer.getMediaData(JSON.stringify(
|
|
150127
|
+
const mediaDatas = imageReplacer.getMediaData(JSON.stringify(json2), context.file.Media);
|
|
150067
150128
|
if (mediaDatas.length > 0) {
|
|
150068
150129
|
hasMedia = true;
|
|
150069
150130
|
imageRelationshipAdditions.push({
|
|
@@ -150072,7 +150133,7 @@ var patchDocument = (function() {
|
|
|
150072
150133
|
});
|
|
150073
150134
|
}
|
|
150074
150135
|
}
|
|
150075
|
-
map3.set(key,
|
|
150136
|
+
map3.set(key, json2);
|
|
150076
150137
|
}
|
|
150077
150138
|
for (const { key, mediaDatas } of imageRelationshipAdditions) {
|
|
150078
150139
|
var _map$get;
|
|
@@ -177885,12 +177946,12 @@ var Revisions = class {
|
|
|
177885
177946
|
}
|
|
177886
177947
|
}
|
|
177887
177948
|
/** Rebuild an element from its open tag, its children as `each` maps them, and its close tag. */
|
|
177888
|
-
markInner(element, kind,
|
|
177949
|
+
markInner(element, kind, each2) {
|
|
177889
177950
|
const openEnd = element.xml.indexOf(">") + 1;
|
|
177890
177951
|
if (element.xml[openEnd - 2] === "/") return element.xml;
|
|
177891
177952
|
const closeStart = element.xml.lastIndexOf("</");
|
|
177892
177953
|
const children = childElements(element.xml, openEnd, closeStart);
|
|
177893
|
-
return element.xml.slice(0, openEnd) + children.map(
|
|
177954
|
+
return element.xml.slice(0, openEnd) + children.map(each2).join("") + element.xml.slice(closeStart);
|
|
177894
177955
|
}
|
|
177895
177956
|
markRow(row, kind) {
|
|
177896
177957
|
const openEnd = row.xml.indexOf(">") + 1;
|
|
@@ -186288,18 +186349,18 @@ async function resolveToolsExtension() {
|
|
|
186288
186349
|
}
|
|
186289
186350
|
function rpcResourceArgs(config2, context) {
|
|
186290
186351
|
const args = [];
|
|
186291
|
-
const
|
|
186352
|
+
const each2 = (flag, values) => {
|
|
186292
186353
|
for (const value of values) args.push(flag, value);
|
|
186293
186354
|
};
|
|
186294
186355
|
if (config2.noExtensions) args.push("--no-extensions");
|
|
186295
|
-
|
|
186356
|
+
each2("--extension", [...allExtensionPaths(config2), ...config2.extensionScripts]);
|
|
186296
186357
|
if (config2.noSkills) args.push("--no-skills");
|
|
186297
|
-
|
|
186358
|
+
each2("--skill", [...allSkillPaths(config2), ...context.bundledSkills]);
|
|
186298
186359
|
if (config2.noPromptTemplates) args.push("--no-prompt-templates");
|
|
186299
|
-
|
|
186360
|
+
each2("--prompt-template", config2.promptPaths);
|
|
186300
186361
|
if (config2.tools !== void 0) args.push("--tools", config2.tools.join(","));
|
|
186301
186362
|
if (config2.systemPrompt !== void 0) args.push("--system-prompt", config2.systemPrompt);
|
|
186302
|
-
|
|
186363
|
+
each2("--append-system-prompt", context.appendSystemPrompt);
|
|
186303
186364
|
if (config2.offline) args.push("--offline");
|
|
186304
186365
|
return args;
|
|
186305
186366
|
}
|
|
@@ -187246,7 +187307,7 @@ function rulePatterns(profile, rules, sources) {
|
|
|
187246
187307
|
nodes.push({ id: `${container}-item`, label: parts.join(" \xB7 "), kind: rule.then === "forbidden" ? PATTERN_KINDS.forbiddenItem : PATTERN_KINDS.selectedItem, container });
|
|
187247
187308
|
return;
|
|
187248
187309
|
}
|
|
187249
|
-
const declaration = (profile.relationshipKinds ?? []).find((
|
|
187310
|
+
const declaration = (profile.relationshipKinds ?? []).find((each2) => each2.kind === rule.relationship);
|
|
187250
187311
|
const then = rule.then === "forbidden" ? void 0 : rule.then;
|
|
187251
187312
|
for (const side of ["from", "to"]) {
|
|
187252
187313
|
const when = rule.when?.[side];
|
|
@@ -189431,8 +189492,8 @@ function inspectShape(root2) {
|
|
|
189431
189492
|
}
|
|
189432
189493
|
function serializedBytes(value) {
|
|
189433
189494
|
try {
|
|
189434
|
-
const
|
|
189435
|
-
return
|
|
189495
|
+
const json2 = JSON.stringify(value);
|
|
189496
|
+
return json2 === void 0 ? null : Buffer.byteLength(json2);
|
|
189436
189497
|
} catch {
|
|
189437
189498
|
return null;
|
|
189438
189499
|
}
|
|
@@ -189570,6 +189631,12 @@ var UPLOADS_DIRECTORY = "uploads";
|
|
|
189570
189631
|
function isPdfPath(relPath) {
|
|
189571
189632
|
return path31.extname(relPath).toLowerCase() === ".pdf";
|
|
189572
189633
|
}
|
|
189634
|
+
function isRawImagePath(relPath) {
|
|
189635
|
+
return /^\.(png|jpe?g|gif|webp|svg|avif)$/.test(path31.extname(relPath).toLowerCase());
|
|
189636
|
+
}
|
|
189637
|
+
function rawFileLimit(relPath, pdfMaxBytes) {
|
|
189638
|
+
return isPdfPath(relPath) || isRawImagePath(relPath) ? pdfMaxBytes : MAX_PREVIEW_BYTES;
|
|
189639
|
+
}
|
|
189573
189640
|
var FileBrowserError = class extends Error {
|
|
189574
189641
|
constructor(reason, message) {
|
|
189575
189642
|
super(message);
|
|
@@ -189703,7 +189770,7 @@ async function readFileRaw(root2, relPath, pdfMaxBytes = MAX_PREVIEW_BYTES) {
|
|
|
189703
189770
|
if (!stat.isFile()) {
|
|
189704
189771
|
throw new FileBrowserError("not-found", `"${relPath}" is not a file`);
|
|
189705
189772
|
}
|
|
189706
|
-
const limit =
|
|
189773
|
+
const limit = rawFileLimit(relPath, pdfMaxBytes);
|
|
189707
189774
|
if (stat.size > limit) {
|
|
189708
189775
|
const mb = (limit / (1024 * 1024)).toFixed(0);
|
|
189709
189776
|
throw new FileBrowserError("too-large", `File is larger than the ${mb} MB limit`);
|
|
@@ -192209,8 +192276,12 @@ function finalizeTruncatedResult(prefix, prefixWidth, ellipsis, ellipsisWidth, m
|
|
|
192209
192276
|
return pad3 ? result + " ".repeat(Math.max(0, maxWidth - visibleWidth2)) : result;
|
|
192210
192277
|
}
|
|
192211
192278
|
function graphemeWidth(segment4) {
|
|
192212
|
-
if (segment4 ===
|
|
192213
|
-
|
|
192279
|
+
if (segment4.length === 1) {
|
|
192280
|
+
const code3 = segment4.charCodeAt(0);
|
|
192281
|
+
if (code3 >= 32 && code3 <= 126)
|
|
192282
|
+
return 1;
|
|
192283
|
+
if (code3 === 9)
|
|
192284
|
+
return 3;
|
|
192214
192285
|
}
|
|
192215
192286
|
if (terminalSpacingMarkRegex.test(segment4)) {
|
|
192216
192287
|
return [...segment4].length;
|
|
@@ -192254,8 +192325,9 @@ function visibleWidth(str2) {
|
|
|
192254
192325
|
if (str2.length === 0) {
|
|
192255
192326
|
return 0;
|
|
192256
192327
|
}
|
|
192257
|
-
|
|
192258
|
-
|
|
192328
|
+
const asciiWidth = asciiVisibleWidth(str2);
|
|
192329
|
+
if (asciiWidth !== -1) {
|
|
192330
|
+
return asciiWidth;
|
|
192259
192331
|
}
|
|
192260
192332
|
const cached2 = widthCache.get(str2);
|
|
192261
192333
|
if (cached2 !== void 0) {
|
|
@@ -192265,19 +192337,22 @@ function visibleWidth(str2) {
|
|
|
192265
192337
|
if (str2.includes(" ")) {
|
|
192266
192338
|
clean2 = clean2.replace(/\t/g, " ");
|
|
192267
192339
|
}
|
|
192268
|
-
|
|
192340
|
+
let escapeIndex = clean2.indexOf("\x1B");
|
|
192341
|
+
if (escapeIndex !== -1) {
|
|
192269
192342
|
let stripped = "";
|
|
192270
|
-
let
|
|
192271
|
-
while (
|
|
192272
|
-
const
|
|
192273
|
-
if (
|
|
192274
|
-
|
|
192275
|
-
|
|
192343
|
+
let copyFrom = 0;
|
|
192344
|
+
while (escapeIndex !== -1) {
|
|
192345
|
+
const length = ansiCodeLength(clean2, escapeIndex);
|
|
192346
|
+
if (length > 0) {
|
|
192347
|
+
stripped += clean2.slice(copyFrom, escapeIndex);
|
|
192348
|
+
escapeIndex += length;
|
|
192349
|
+
copyFrom = escapeIndex;
|
|
192350
|
+
} else {
|
|
192351
|
+
escapeIndex++;
|
|
192276
192352
|
}
|
|
192277
|
-
|
|
192278
|
-
i2++;
|
|
192353
|
+
escapeIndex = clean2.indexOf("\x1B", escapeIndex);
|
|
192279
192354
|
}
|
|
192280
|
-
clean2 = stripped;
|
|
192355
|
+
clean2 = stripped + clean2.slice(copyFrom);
|
|
192281
192356
|
}
|
|
192282
192357
|
let width = 0;
|
|
192283
192358
|
for (const { segment: segment4 } of graphemeSegmenter.segment(clean2)) {
|
|
@@ -192381,40 +192456,54 @@ function normalizeTerminalOutput(str2) {
|
|
|
192381
192456
|
return result;
|
|
192382
192457
|
}
|
|
192383
192458
|
function extractAnsiCode(str2, pos) {
|
|
192384
|
-
|
|
192385
|
-
|
|
192459
|
+
const length = ansiCodeLength(str2, pos);
|
|
192460
|
+
return length > 0 ? { code: str2.substring(pos, pos + length), length } : null;
|
|
192461
|
+
}
|
|
192462
|
+
function asciiVisibleWidth(str2) {
|
|
192463
|
+
let width = 0;
|
|
192464
|
+
let i2 = 0;
|
|
192465
|
+
while (i2 < str2.length) {
|
|
192466
|
+
const code3 = str2.charCodeAt(i2);
|
|
192467
|
+
if (code3 >= 32 && code3 <= 126) {
|
|
192468
|
+
width++;
|
|
192469
|
+
i2++;
|
|
192470
|
+
} else if (code3 === 9) {
|
|
192471
|
+
width += 3;
|
|
192472
|
+
i2++;
|
|
192473
|
+
} else if (code3 === 27) {
|
|
192474
|
+
const length = ansiCodeLength(str2, i2);
|
|
192475
|
+
if (length === 0)
|
|
192476
|
+
return -1;
|
|
192477
|
+
i2 += length;
|
|
192478
|
+
} else {
|
|
192479
|
+
return -1;
|
|
192480
|
+
}
|
|
192481
|
+
}
|
|
192482
|
+
return width;
|
|
192483
|
+
}
|
|
192484
|
+
function ansiCodeLength(str2, pos) {
|
|
192485
|
+
if (pos >= str2.length || str2.charCodeAt(pos) !== 27)
|
|
192486
|
+
return 0;
|
|
192386
192487
|
const next = str2[pos + 1];
|
|
192387
192488
|
if (next === "[") {
|
|
192388
|
-
let j2 = pos + 2;
|
|
192389
|
-
|
|
192390
|
-
|
|
192391
|
-
|
|
192392
|
-
return { code: str2.substring(pos, j2 + 1), length: j2 + 1 - pos };
|
|
192393
|
-
return null;
|
|
192394
|
-
}
|
|
192395
|
-
if (next === "]") {
|
|
192396
|
-
let j2 = pos + 2;
|
|
192397
|
-
while (j2 < str2.length) {
|
|
192398
|
-
if (str2[j2] === "\x07")
|
|
192399
|
-
return { code: str2.substring(pos, j2 + 1), length: j2 + 1 - pos };
|
|
192400
|
-
if (str2[j2] === "\x1B" && str2[j2 + 1] === "\\")
|
|
192401
|
-
return { code: str2.substring(pos, j2 + 2), length: j2 + 2 - pos };
|
|
192402
|
-
j2++;
|
|
192489
|
+
for (let j2 = pos + 2; j2 < str2.length; j2++) {
|
|
192490
|
+
const c2 = str2.charCodeAt(j2);
|
|
192491
|
+
if (c2 === 109 || c2 === 71 || c2 === 75 || c2 === 72 || c2 === 74)
|
|
192492
|
+
return j2 + 1 - pos;
|
|
192403
192493
|
}
|
|
192404
|
-
return
|
|
192494
|
+
return 0;
|
|
192405
192495
|
}
|
|
192406
|
-
if (next === "_") {
|
|
192407
|
-
let j2 = pos + 2;
|
|
192408
|
-
|
|
192409
|
-
if (
|
|
192410
|
-
return
|
|
192411
|
-
if (
|
|
192412
|
-
return
|
|
192413
|
-
j2++;
|
|
192496
|
+
if (next === "]" || next === "_") {
|
|
192497
|
+
for (let j2 = pos + 2; j2 < str2.length; j2++) {
|
|
192498
|
+
const c2 = str2.charCodeAt(j2);
|
|
192499
|
+
if (c2 === 7)
|
|
192500
|
+
return j2 + 1 - pos;
|
|
192501
|
+
if (c2 === 27 && str2[j2 + 1] === "\\")
|
|
192502
|
+
return j2 + 2 - pos;
|
|
192414
192503
|
}
|
|
192415
|
-
return
|
|
192504
|
+
return 0;
|
|
192416
192505
|
}
|
|
192417
|
-
return
|
|
192506
|
+
return 0;
|
|
192418
192507
|
}
|
|
192419
192508
|
function parseOsc8Hyperlink(ansiCode) {
|
|
192420
192509
|
if (!ansiCode.startsWith("\x1B]8;")) {
|
|
@@ -192658,15 +192747,16 @@ var AnsiCodeTracker = class {
|
|
|
192658
192747
|
}
|
|
192659
192748
|
};
|
|
192660
192749
|
function updateTrackerFromText(text7, tracker) {
|
|
192661
|
-
let i2 =
|
|
192662
|
-
while (i2
|
|
192663
|
-
const
|
|
192664
|
-
if (
|
|
192665
|
-
tracker.process(
|
|
192666
|
-
i2 +=
|
|
192750
|
+
let i2 = text7.indexOf("\x1B");
|
|
192751
|
+
while (i2 !== -1) {
|
|
192752
|
+
const length = ansiCodeLength(text7, i2);
|
|
192753
|
+
if (length > 0) {
|
|
192754
|
+
tracker.process(text7.substring(i2, i2 + length));
|
|
192755
|
+
i2 += length;
|
|
192667
192756
|
} else {
|
|
192668
192757
|
i2++;
|
|
192669
192758
|
}
|
|
192759
|
+
i2 = text7.indexOf("\x1B", i2);
|
|
192670
192760
|
}
|
|
192671
192761
|
}
|
|
192672
192762
|
function getActiveBackgroundAnsi(text7) {
|
|
@@ -192898,6 +192988,402 @@ function extractSegments(line, beforeEnd, afterStart, afterLen, strictAfter = fa
|
|
|
192898
192988
|
// ../node_modules/@earendil-works/pi-coding-agent/node_modules/@earendil-works/pi-tui/dist/autocomplete.js
|
|
192899
192989
|
var tokenStartRegex = new RegExp(`${autocompleteBoundaryRegex.source}$`, "u");
|
|
192900
192990
|
|
|
192991
|
+
// ../node_modules/@earendil-works/pi-coding-agent/node_modules/@earendil-works/pi-tui/dist/oklab.js
|
|
192992
|
+
var multiply = (m2, [x2, y2, z3]) => m2.map((row) => row[0] * x2 + row[1] * y2 + row[2] * z3);
|
|
192993
|
+
var LINEAR_SRGB_TO_LMS = [
|
|
192994
|
+
[0.4122214694707629, 0.5363325372617349, 0.0514459932675022],
|
|
192995
|
+
[0.2119034958178251, 0.6806995506452344, 0.1073969535369405],
|
|
192996
|
+
[0.0883024591900564, 0.2817188391361215, 0.6299787016738222]
|
|
192997
|
+
];
|
|
192998
|
+
var LMS_TO_LAB = [
|
|
192999
|
+
[0.210454268309314, 0.793617774702305, -0.0040720430116193],
|
|
193000
|
+
[1.9779985324311684, -2.42859224204858, 0.450593709617411],
|
|
193001
|
+
[0.0259040424655478, 0.7827717124575296, -0.8086757549230774]
|
|
193002
|
+
];
|
|
193003
|
+
var LAB_TO_LMS = [
|
|
193004
|
+
[1, 0.3963377773761749, 0.2158037573099136],
|
|
193005
|
+
[1, -0.1055613458156586, -0.0638541728258133],
|
|
193006
|
+
[1, -0.0894841775298119, -1.2914855480194092]
|
|
193007
|
+
];
|
|
193008
|
+
var LMS_TO_LINEAR_SRGB = [
|
|
193009
|
+
[4.076741636075958, -3.307711539258063, 0.2309699031821043],
|
|
193010
|
+
[-1.2684379732850315, 2.609757349287688, -0.341319376002657],
|
|
193011
|
+
[-0.0041960761386756, -0.7034186179359362, 1.7076146940746117]
|
|
193012
|
+
];
|
|
193013
|
+
var SATURATION_FIT = [
|
|
193014
|
+
[
|
|
193015
|
+
[-1.8817031, -0.80936501],
|
|
193016
|
+
[1.19086277, 1.76576728, 0.59662641, 0.75515197, 0.56771245]
|
|
193017
|
+
],
|
|
193018
|
+
[
|
|
193019
|
+
[1.8144408, -1.19445267],
|
|
193020
|
+
[0.73956515, -0.45954404, 0.08285427, 0.12541073, -0.14503204]
|
|
193021
|
+
],
|
|
193022
|
+
[
|
|
193023
|
+
[0.13110758, 1.81333971],
|
|
193024
|
+
[1.35733652, -915799e-8, -1.1513021, -0.50559606, 692167e-8]
|
|
193025
|
+
]
|
|
193026
|
+
];
|
|
193027
|
+
var K1 = 0.206;
|
|
193028
|
+
var K22 = 0.03;
|
|
193029
|
+
var K3 = (1 + K1) / (1 + K22);
|
|
193030
|
+
var oklabToOkhslLightness = (x2) => 0.5 * (K3 * x2 - K1 + Math.sqrt((K3 * x2 - K1) ** 2 + 4 * K22 * K3 * x2));
|
|
193031
|
+
var okhslToOklabLightness = (x2) => (x2 * x2 + K1 * x2) / (K3 * (x2 + K22));
|
|
193032
|
+
var linearToSrgb = (value) => value > 31308e-7 ? 1.055 * value ** (1 / 2.4) - 0.055 : 12.92 * value;
|
|
193033
|
+
var srgbToLinear = (value) => value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
|
|
193034
|
+
function oklabToLinearSrgb(lab) {
|
|
193035
|
+
return multiply(LMS_TO_LINEAR_SRGB, multiply(LAB_TO_LMS, lab).map((value) => value ** 3));
|
|
193036
|
+
}
|
|
193037
|
+
function linearSrgbToOklab(rgb) {
|
|
193038
|
+
return multiply(LMS_TO_LAB, multiply(LINEAR_SRGB_TO_LMS, rgb).map(Math.cbrt));
|
|
193039
|
+
}
|
|
193040
|
+
function rgbToOklab({ r, g, b: b2 }) {
|
|
193041
|
+
return linearSrgbToOklab([r / 255, g / 255, b2 / 255].map(srgbToLinear));
|
|
193042
|
+
}
|
|
193043
|
+
function linearSrgbToRgb(linear) {
|
|
193044
|
+
const [r, g, b2] = linear.map((value) => Math.round(Math.min(1, Math.max(0, linearToSrgb(value))) * 255));
|
|
193045
|
+
return { r, g, b: b2 };
|
|
193046
|
+
}
|
|
193047
|
+
function lmsSlopes(a, b2) {
|
|
193048
|
+
return [LAB_TO_LMS[0], LAB_TO_LMS[1], LAB_TO_LMS[2]].map((row) => row[1] * a + row[2] * b2);
|
|
193049
|
+
}
|
|
193050
|
+
function maxSaturation(a, b2) {
|
|
193051
|
+
const channel = SATURATION_FIT.findIndex(([[x2, y2]], index4) => index4 === 2 || x2 * a + y2 * b2 > 1);
|
|
193052
|
+
const [k0, k1, k2, k3, k4] = SATURATION_FIT[channel][1];
|
|
193053
|
+
const weights = LMS_TO_LINEAR_SRGB[channel];
|
|
193054
|
+
const saturation = k0 + k1 * a + k2 * b2 + k3 * a * a + k4 * a * b2;
|
|
193055
|
+
const slopes = lmsSlopes(a, b2);
|
|
193056
|
+
const base = slopes.map((k5) => 1 + saturation * k5);
|
|
193057
|
+
const dot = (values) => values.reduce((sum, value, index4) => sum + weights[index4] * value, 0);
|
|
193058
|
+
const f2 = dot(base.map((value) => value ** 3));
|
|
193059
|
+
const f1 = dot(base.map((value, index4) => 3 * slopes[index4] * value ** 2));
|
|
193060
|
+
const f22 = dot(base.map((value, index4) => 6 * slopes[index4] ** 2 * value));
|
|
193061
|
+
return saturation - f2 * f1 / (f1 * f1 - 0.5 * f2 * f22);
|
|
193062
|
+
}
|
|
193063
|
+
function cusp(a, b2) {
|
|
193064
|
+
const saturation = maxSaturation(a, b2);
|
|
193065
|
+
const lightness = Math.cbrt(1 / Math.max(...oklabToLinearSrgb([1, saturation * a, saturation * b2])));
|
|
193066
|
+
return [lightness, lightness * saturation];
|
|
193067
|
+
}
|
|
193068
|
+
function maxChroma(a, b2, lightness, [cuspL, cuspC]) {
|
|
193069
|
+
if (lightness <= cuspL)
|
|
193070
|
+
return cuspC * lightness / cuspL;
|
|
193071
|
+
const t = cuspC * (lightness - 1) / (cuspL - 1);
|
|
193072
|
+
const slopes = lmsSlopes(a, b2);
|
|
193073
|
+
const lms = slopes.map((k2) => lightness + t * k2);
|
|
193074
|
+
const cubes = lms.map((value) => value ** 3);
|
|
193075
|
+
const first = lms.map((value, index4) => 3 * slopes[index4] * value ** 2);
|
|
193076
|
+
const second = lms.map((value, index4) => 6 * slopes[index4] ** 2 * value);
|
|
193077
|
+
const dot = (row, values) => row[0] * values[0] + row[1] * values[1] + row[2] * values[2];
|
|
193078
|
+
const steps = LMS_TO_LINEAR_SRGB.map((row) => {
|
|
193079
|
+
const f2 = dot(row, cubes) - 1;
|
|
193080
|
+
const f1 = dot(row, first);
|
|
193081
|
+
const f22 = dot(row, second);
|
|
193082
|
+
const u = f1 / (f1 * f1 - 0.5 * f2 * f22);
|
|
193083
|
+
return u >= 0 ? -f2 * u : Number.MAX_VALUE;
|
|
193084
|
+
});
|
|
193085
|
+
return t + Math.min(...steps);
|
|
193086
|
+
}
|
|
193087
|
+
function chromaStops(L2, a, b2) {
|
|
193088
|
+
const peak = cusp(a, b2);
|
|
193089
|
+
const cMax = maxChroma(a, b2, L2, peak);
|
|
193090
|
+
const k2 = cMax / Math.min(L2 * (peak[1] / peak[0]), (1 - L2) * (peak[1] / (1 - peak[0])));
|
|
193091
|
+
const midS = 0.11516993 + 1 / (7.4477897 + 4.1590124 * b2 + a * (-2.19557347 + 1.75198401 * b2 + a * (-2.13704948 - 10.02301043 * b2 + a * (-4.24894561 + 5.38770819 * b2 + 4.69891013 * a))));
|
|
193092
|
+
const midT = 0.11239642 + 1 / (1.6132032 - 0.68124379 * b2 + a * (0.40370612 + 0.90148123 * b2 + a * (-0.27087943 + 0.6122399 * b2 + a * (299215e-8 - 0.45399568 * b2 - 0.14661872 * a))));
|
|
193093
|
+
const cMid = 0.9 * k2 * Math.sqrt(Math.sqrt(1 / (1 / (L2 * midS) ** 4 + 1 / ((1 - L2) * midT) ** 4)));
|
|
193094
|
+
const c0 = Math.sqrt(1 / (1 / (L2 * 0.4) ** 2 + 1 / ((1 - L2) * 0.8) ** 2));
|
|
193095
|
+
return [c0, cMid, cMax];
|
|
193096
|
+
}
|
|
193097
|
+
function okhslToRgb(hue, saturation, lightness) {
|
|
193098
|
+
const L2 = okhslToOklabLightness(lightness);
|
|
193099
|
+
let lab = [L2, 0, 0];
|
|
193100
|
+
if (L2 > 0 && L2 < 1 && saturation > 0) {
|
|
193101
|
+
const angle = 2 * Math.PI * ((hue % 360 + 360) % 360) / 360;
|
|
193102
|
+
const a = Math.cos(angle);
|
|
193103
|
+
const b2 = Math.sin(angle);
|
|
193104
|
+
const [c0, cMid, cMax] = chromaStops(L2, a, b2);
|
|
193105
|
+
let chroma;
|
|
193106
|
+
if (saturation < 0.8) {
|
|
193107
|
+
const t = 1.25 * saturation;
|
|
193108
|
+
const k1 = 0.8 * c0;
|
|
193109
|
+
chroma = t * k1 / (1 - (1 - k1 / cMid) * t);
|
|
193110
|
+
} else {
|
|
193111
|
+
const t = 5 * (saturation - 0.8);
|
|
193112
|
+
const k1 = 0.2 * cMid ** 2 * 1.25 ** 2 / c0;
|
|
193113
|
+
chroma = cMid + t * k1 / (1 - (1 - k1 / (cMax - cMid)) * t);
|
|
193114
|
+
}
|
|
193115
|
+
lab = [L2, chroma * a, chroma * b2];
|
|
193116
|
+
}
|
|
193117
|
+
return linearSrgbToRgb(oklabToLinearSrgb(lab));
|
|
193118
|
+
}
|
|
193119
|
+
function rgbToOkhsl(rgb) {
|
|
193120
|
+
const [L2, labA, labB] = rgbToOklab(rgb);
|
|
193121
|
+
const chroma = Math.hypot(labA, labB);
|
|
193122
|
+
const lightness = oklabToOkhslLightness(L2);
|
|
193123
|
+
if (chroma < 1e-9 || lightness <= 0 || lightness >= 1)
|
|
193124
|
+
return { h: 0, s: 0, l: lightness };
|
|
193125
|
+
const hue = (Math.atan2(labB, labA) * 180 / Math.PI + 360) % 360;
|
|
193126
|
+
const [c0, cMid, cMax] = chromaStops(L2, labA / chroma, labB / chroma);
|
|
193127
|
+
let saturation;
|
|
193128
|
+
if (chroma < cMid) {
|
|
193129
|
+
const k1 = 0.8 * c0;
|
|
193130
|
+
saturation = 0.8 * (chroma / (k1 + (1 - k1 / cMid) * chroma));
|
|
193131
|
+
} else {
|
|
193132
|
+
const k1 = 0.2 * cMid ** 2 * 1.25 ** 2 / c0;
|
|
193133
|
+
const offset = chroma - cMid;
|
|
193134
|
+
saturation = 0.8 + 0.2 * (offset / (k1 + (1 - k1 / (cMax - cMid)) * offset));
|
|
193135
|
+
}
|
|
193136
|
+
return { h: hue, s: Math.min(1, Math.max(0, saturation)), l: lightness };
|
|
193137
|
+
}
|
|
193138
|
+
|
|
193139
|
+
// ../node_modules/@earendil-works/pi-coding-agent/node_modules/@earendil-works/pi-tui/dist/colors.js
|
|
193140
|
+
function requireFinite(value, name) {
|
|
193141
|
+
if (!Number.isFinite(value))
|
|
193142
|
+
throw new Error(`${name} must be finite`);
|
|
193143
|
+
}
|
|
193144
|
+
function indexedColor(index4) {
|
|
193145
|
+
if (!Number.isInteger(index4) || index4 < 0 || index4 > 255) {
|
|
193146
|
+
throw new Error(`ANSI color index must be an integer from 0 to 255: ${index4}`);
|
|
193147
|
+
}
|
|
193148
|
+
return Object.freeze({ kind: "indexed", index: index4 });
|
|
193149
|
+
}
|
|
193150
|
+
function rgbColor(r, g, b2) {
|
|
193151
|
+
for (const [name, value] of [
|
|
193152
|
+
["r", r],
|
|
193153
|
+
["g", g],
|
|
193154
|
+
["b", b2]
|
|
193155
|
+
]) {
|
|
193156
|
+
requireFinite(value, name);
|
|
193157
|
+
if (value < 0 || value > 255)
|
|
193158
|
+
throw new Error(`${name} must be between 0 and 255: ${value}`);
|
|
193159
|
+
}
|
|
193160
|
+
return Object.freeze({ kind: "rgb", r, g, b: b2 });
|
|
193161
|
+
}
|
|
193162
|
+
function oklchColor(l3, c2, h) {
|
|
193163
|
+
requireFinite(l3, "l");
|
|
193164
|
+
requireFinite(c2, "c");
|
|
193165
|
+
requireFinite(h, "h");
|
|
193166
|
+
if (l3 < 0 || l3 > 1)
|
|
193167
|
+
throw new Error(`l must be between 0 and 1: ${l3}`);
|
|
193168
|
+
if (c2 < 0)
|
|
193169
|
+
throw new Error(`c must not be negative: ${c2}`);
|
|
193170
|
+
return Object.freeze({ kind: "oklch", l: l3, c: c2, h: (h % 360 + 360) % 360 });
|
|
193171
|
+
}
|
|
193172
|
+
var NUMBER_PATTERN = String.raw`[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?`;
|
|
193173
|
+
var OKLCH_PATTERN = new RegExp(`^oklch\\(\\s*(${NUMBER_PATTERN})(%)?\\s+(${NUMBER_PATTERN})\\s+(${NUMBER_PATTERN})(?:deg)?\\s*\\)$`, "i");
|
|
193174
|
+
var OKHSL_PATTERN = new RegExp(`^okhsl\\(\\s*(${NUMBER_PATTERN})(?:deg)?\\s+(${NUMBER_PATTERN})(%)?\\s+(${NUMBER_PATTERN})(%)?\\s*\\)$`, "i");
|
|
193175
|
+
function okhslColor(h, s, l3) {
|
|
193176
|
+
requireFinite(h, "h");
|
|
193177
|
+
requireFinite(s, "s");
|
|
193178
|
+
requireFinite(l3, "l");
|
|
193179
|
+
if (s < 0 || s > 1)
|
|
193180
|
+
throw new Error(`s must be between 0 and 1: ${s}`);
|
|
193181
|
+
if (l3 < 0 || l3 > 1)
|
|
193182
|
+
throw new Error(`l must be between 0 and 1: ${l3}`);
|
|
193183
|
+
const { r, g, b: b2 } = okhslToRgb(h, s, l3);
|
|
193184
|
+
return rgbColor(r, g, b2);
|
|
193185
|
+
}
|
|
193186
|
+
function colorToOkhsl(color3) {
|
|
193187
|
+
return rgbToOkhsl(colorToRgb(color3));
|
|
193188
|
+
}
|
|
193189
|
+
function parseColor(value) {
|
|
193190
|
+
if (typeof value === "number")
|
|
193191
|
+
return indexedColor(value);
|
|
193192
|
+
const hex = /^#([\da-f]{3}|[\da-f]{6})$/i.exec(value);
|
|
193193
|
+
if (hex) {
|
|
193194
|
+
const digits = hex[1].length === 3 ? [...hex[1]].map((digit) => digit + digit).join("") : hex[1];
|
|
193195
|
+
return rgbColor(Number.parseInt(digits.slice(0, 2), 16), Number.parseInt(digits.slice(2, 4), 16), Number.parseInt(digits.slice(4, 6), 16));
|
|
193196
|
+
}
|
|
193197
|
+
const oklch = OKLCH_PATTERN.exec(value);
|
|
193198
|
+
if (oklch) {
|
|
193199
|
+
const lightness = Number.parseFloat(oklch[1]) / (oklch[2] ? 100 : 1);
|
|
193200
|
+
return oklchColor(lightness, Number.parseFloat(oklch[3]), Number.parseFloat(oklch[4]));
|
|
193201
|
+
}
|
|
193202
|
+
const okhsl = OKHSL_PATTERN.exec(value);
|
|
193203
|
+
if (okhsl) {
|
|
193204
|
+
const saturation = Number.parseFloat(okhsl[2]) / (okhsl[3] ? 100 : 1);
|
|
193205
|
+
const lightness = Number.parseFloat(okhsl[4]) / (okhsl[5] ? 100 : 1);
|
|
193206
|
+
return okhslColor(Number.parseFloat(okhsl[1]), saturation, lightness);
|
|
193207
|
+
}
|
|
193208
|
+
throw new Error(`Invalid color value: ${value}`);
|
|
193209
|
+
}
|
|
193210
|
+
var BASIC_COLORS = [
|
|
193211
|
+
{ r: 0, g: 0, b: 0 },
|
|
193212
|
+
{ r: 128, g: 0, b: 0 },
|
|
193213
|
+
{ r: 0, g: 128, b: 0 },
|
|
193214
|
+
{ r: 128, g: 128, b: 0 },
|
|
193215
|
+
{ r: 0, g: 0, b: 128 },
|
|
193216
|
+
{ r: 128, g: 0, b: 128 },
|
|
193217
|
+
{ r: 0, g: 128, b: 128 },
|
|
193218
|
+
{ r: 192, g: 192, b: 192 },
|
|
193219
|
+
{ r: 128, g: 128, b: 128 },
|
|
193220
|
+
{ r: 255, g: 0, b: 0 },
|
|
193221
|
+
{ r: 0, g: 255, b: 0 },
|
|
193222
|
+
{ r: 255, g: 255, b: 0 },
|
|
193223
|
+
{ r: 0, g: 0, b: 255 },
|
|
193224
|
+
{ r: 255, g: 0, b: 255 },
|
|
193225
|
+
{ r: 0, g: 255, b: 255 },
|
|
193226
|
+
{ r: 255, g: 255, b: 255 }
|
|
193227
|
+
];
|
|
193228
|
+
var CUBE_VALUES = [0, 95, 135, 175, 215, 255];
|
|
193229
|
+
var GRAY_VALUES = Array.from({ length: 24 }, (_2, index4) => 8 + index4 * 10);
|
|
193230
|
+
function indexedToRgb(index4) {
|
|
193231
|
+
if (index4 < 16)
|
|
193232
|
+
return { ...BASIC_COLORS[index4] };
|
|
193233
|
+
if (index4 < 232) {
|
|
193234
|
+
const cubeIndex = index4 - 16;
|
|
193235
|
+
return {
|
|
193236
|
+
r: CUBE_VALUES[Math.floor(cubeIndex / 36)],
|
|
193237
|
+
g: CUBE_VALUES[Math.floor(cubeIndex % 36 / 6)],
|
|
193238
|
+
b: CUBE_VALUES[cubeIndex % 6]
|
|
193239
|
+
};
|
|
193240
|
+
}
|
|
193241
|
+
const gray = 8 + (index4 - 232) * 10;
|
|
193242
|
+
return { r: gray, g: gray, b: gray };
|
|
193243
|
+
}
|
|
193244
|
+
function isInSrgbGamut(linear) {
|
|
193245
|
+
const epsilon = 1e-7;
|
|
193246
|
+
return linear.every((channel) => channel >= -epsilon && channel <= 1 + epsilon);
|
|
193247
|
+
}
|
|
193248
|
+
function oklchToRgb({ l: l3, c: c2, h }) {
|
|
193249
|
+
const radians = h * Math.PI / 180;
|
|
193250
|
+
const cos = Math.cos(radians);
|
|
193251
|
+
const sin = Math.sin(radians);
|
|
193252
|
+
const atChroma = (chroma) => oklabToLinearSrgb([l3, chroma * cos, chroma * sin]);
|
|
193253
|
+
const direct = atChroma(c2);
|
|
193254
|
+
if (isInSrgbGamut(direct))
|
|
193255
|
+
return linearSrgbToRgb(direct);
|
|
193256
|
+
let linear = atChroma(0);
|
|
193257
|
+
let low = 0;
|
|
193258
|
+
let high = c2;
|
|
193259
|
+
for (let index4 = 0; index4 < 20; index4++) {
|
|
193260
|
+
const chroma = (low + high) / 2;
|
|
193261
|
+
const candidate = atChroma(chroma);
|
|
193262
|
+
if (isInSrgbGamut(candidate)) {
|
|
193263
|
+
low = chroma;
|
|
193264
|
+
linear = candidate;
|
|
193265
|
+
} else {
|
|
193266
|
+
high = chroma;
|
|
193267
|
+
}
|
|
193268
|
+
}
|
|
193269
|
+
return linearSrgbToRgb(linear);
|
|
193270
|
+
}
|
|
193271
|
+
function colorToRgb(color3) {
|
|
193272
|
+
switch (color3.kind) {
|
|
193273
|
+
case "indexed":
|
|
193274
|
+
return indexedToRgb(color3.index);
|
|
193275
|
+
case "rgb":
|
|
193276
|
+
return { r: color3.r, g: color3.g, b: color3.b };
|
|
193277
|
+
case "oklch":
|
|
193278
|
+
return oklchToRgb(color3);
|
|
193279
|
+
}
|
|
193280
|
+
}
|
|
193281
|
+
function colorToOklch(color3) {
|
|
193282
|
+
if (color3.kind === "oklch")
|
|
193283
|
+
return { l: color3.l, c: color3.c, h: color3.h };
|
|
193284
|
+
const [l3, a, b2] = rgbToOklab(colorToRgb(color3));
|
|
193285
|
+
return { l: l3, c: Math.hypot(a, b2), h: (Math.atan2(b2, a) * 180 / Math.PI + 360) % 360 };
|
|
193286
|
+
}
|
|
193287
|
+
function mixColors(first, second, amount, space = "oklch") {
|
|
193288
|
+
requireFinite(amount, "amount");
|
|
193289
|
+
if (amount < 0 || amount > 1)
|
|
193290
|
+
throw new Error(`amount must be between 0 and 1: ${amount}`);
|
|
193291
|
+
if (space === "srgb") {
|
|
193292
|
+
const a2 = colorToRgb(first);
|
|
193293
|
+
const b3 = colorToRgb(second);
|
|
193294
|
+
return rgbColor(a2.r + (b3.r - a2.r) * amount, a2.g + (b3.g - a2.g) * amount, a2.b + (b3.b - a2.b) * amount);
|
|
193295
|
+
}
|
|
193296
|
+
const a = colorToOklch(first);
|
|
193297
|
+
const b2 = colorToOklch(second);
|
|
193298
|
+
const firstHue = a.c < 1e-7 ? b2.h : a.h;
|
|
193299
|
+
const secondHue = b2.c < 1e-7 ? firstHue : b2.h;
|
|
193300
|
+
const hueDelta = (secondHue - firstHue + 540) % 360 - 180;
|
|
193301
|
+
return oklchColor(a.l + (b2.l - a.l) * amount, a.c + (b2.c - a.c) * amount, firstHue + hueDelta * amount);
|
|
193302
|
+
}
|
|
193303
|
+
function findClosest(values, target) {
|
|
193304
|
+
let closestIndex = 0;
|
|
193305
|
+
let closestDistance = Infinity;
|
|
193306
|
+
for (let index4 = 0; index4 < values.length; index4++) {
|
|
193307
|
+
const distance = Math.abs(target - values[index4]);
|
|
193308
|
+
if (distance < closestDistance) {
|
|
193309
|
+
closestIndex = index4;
|
|
193310
|
+
closestDistance = distance;
|
|
193311
|
+
}
|
|
193312
|
+
}
|
|
193313
|
+
return closestIndex;
|
|
193314
|
+
}
|
|
193315
|
+
function colorDistance(first, second) {
|
|
193316
|
+
const dr2 = first.r - second.r;
|
|
193317
|
+
const dg = first.g - second.g;
|
|
193318
|
+
const db = first.b - second.b;
|
|
193319
|
+
return dr2 * dr2 * 0.299 + dg * dg * 0.587 + db * db * 0.114;
|
|
193320
|
+
}
|
|
193321
|
+
function rgbToAnsi256(color3) {
|
|
193322
|
+
const rIndex = findClosest(CUBE_VALUES, color3.r);
|
|
193323
|
+
const gIndex = findClosest(CUBE_VALUES, color3.g);
|
|
193324
|
+
const bIndex = findClosest(CUBE_VALUES, color3.b);
|
|
193325
|
+
const cubeColor = { r: CUBE_VALUES[rIndex], g: CUBE_VALUES[gIndex], b: CUBE_VALUES[bIndex] };
|
|
193326
|
+
const cubeIndex = 16 + 36 * rIndex + 6 * gIndex + bIndex;
|
|
193327
|
+
const gray = Math.round(0.299 * color3.r + 0.587 * color3.g + 0.114 * color3.b);
|
|
193328
|
+
const grayOffset = findClosest(GRAY_VALUES, gray);
|
|
193329
|
+
const grayValue = GRAY_VALUES[grayOffset];
|
|
193330
|
+
const spread = Math.max(color3.r, color3.g, color3.b) - Math.min(color3.r, color3.g, color3.b);
|
|
193331
|
+
if (spread < 10 && colorDistance(color3, { r: grayValue, g: grayValue, b: grayValue }) < colorDistance(color3, cubeColor)) {
|
|
193332
|
+
return 232 + grayOffset;
|
|
193333
|
+
}
|
|
193334
|
+
return cubeIndex;
|
|
193335
|
+
}
|
|
193336
|
+
function colorAnsi(color3, mode, background) {
|
|
193337
|
+
if (color3.kind === "indexed")
|
|
193338
|
+
return `\x1B[${background ? 48 : 38};5;${color3.index}m`;
|
|
193339
|
+
const rgb = colorToRgb(color3);
|
|
193340
|
+
if (mode === "truecolor") {
|
|
193341
|
+
return `\x1B[${background ? 48 : 38};2;${Math.round(rgb.r)};${Math.round(rgb.g)};${Math.round(rgb.b)}m`;
|
|
193342
|
+
}
|
|
193343
|
+
return `\x1B[${background ? 48 : 38};5;${rgbToAnsi256(rgb)}m`;
|
|
193344
|
+
}
|
|
193345
|
+
function foregroundAnsi(color3, mode) {
|
|
193346
|
+
return colorAnsi(color3, mode, false);
|
|
193347
|
+
}
|
|
193348
|
+
function backgroundAnsi(color3, mode) {
|
|
193349
|
+
return colorAnsi(color3, mode, true);
|
|
193350
|
+
}
|
|
193351
|
+
function styleTextWithAnsi(text7, fgAnsi, bgAnsi, options) {
|
|
193352
|
+
let prefix = "";
|
|
193353
|
+
let suffix = "";
|
|
193354
|
+
if (fgAnsi) {
|
|
193355
|
+
prefix += fgAnsi;
|
|
193356
|
+
suffix = "\x1B[39m";
|
|
193357
|
+
}
|
|
193358
|
+
if (bgAnsi) {
|
|
193359
|
+
prefix += bgAnsi;
|
|
193360
|
+
suffix = `\x1B[49m${suffix}`;
|
|
193361
|
+
}
|
|
193362
|
+
if (options.bold)
|
|
193363
|
+
prefix += "\x1B[1m";
|
|
193364
|
+
if (options.dim)
|
|
193365
|
+
prefix += "\x1B[2m";
|
|
193366
|
+
if (options.bold || options.dim)
|
|
193367
|
+
suffix = `\x1B[22m${suffix}`;
|
|
193368
|
+
if (options.italic) {
|
|
193369
|
+
prefix += "\x1B[3m";
|
|
193370
|
+
suffix = `\x1B[23m${suffix}`;
|
|
193371
|
+
}
|
|
193372
|
+
if (options.underline) {
|
|
193373
|
+
prefix += "\x1B[4m";
|
|
193374
|
+
suffix = `\x1B[24m${suffix}`;
|
|
193375
|
+
}
|
|
193376
|
+
if (options.inverse) {
|
|
193377
|
+
prefix += "\x1B[7m";
|
|
193378
|
+
suffix = `\x1B[27m${suffix}`;
|
|
193379
|
+
}
|
|
193380
|
+
if (options.strikethrough) {
|
|
193381
|
+
prefix += "\x1B[9m";
|
|
193382
|
+
suffix = `\x1B[29m${suffix}`;
|
|
193383
|
+
}
|
|
193384
|
+
return `${prefix}${text7}${suffix}`;
|
|
193385
|
+
}
|
|
193386
|
+
|
|
192901
193387
|
// ../node_modules/@earendil-works/pi-coding-agent/node_modules/@earendil-works/pi-tui/dist/tui.js
|
|
192902
193388
|
import { performance as performance2 } from "node:perf_hooks";
|
|
192903
193389
|
|
|
@@ -193522,17 +194008,18 @@ function parseOscHexChannel(channel) {
|
|
|
193522
194008
|
}
|
|
193523
194009
|
return Math.round(parseInt(channel, 16) / max * 255);
|
|
193524
194010
|
}
|
|
193525
|
-
var
|
|
194011
|
+
var OSC_COLOR_RESPONSE_PATTERN = /^\x1b\](?:(1[01])|4;(\d{1,3}));([^\x07\x1b]*)(?:\x07|\x1b\\)$/i;
|
|
193526
194012
|
var COLOR_SCHEME_REPORT_PATTERN = /^(?:\x1b\[\?997;(1|2)n)+$/;
|
|
193527
|
-
function
|
|
193528
|
-
|
|
193529
|
-
}
|
|
193530
|
-
function parseOsc11BackgroundColor(data) {
|
|
193531
|
-
const match = data.match(OSC11_BACKGROUND_COLOR_RESPONSE_PATTERN);
|
|
194013
|
+
function parseOscColorResponse(data) {
|
|
194014
|
+
const match = data.match(OSC_COLOR_RESPONSE_PATTERN);
|
|
193532
194015
|
if (!match) {
|
|
193533
194016
|
return void 0;
|
|
193534
194017
|
}
|
|
193535
|
-
const
|
|
194018
|
+
const target = match[1] === "10" ? "foreground" : match[1] === "11" ? "background" : Number.parseInt(match[2], 10);
|
|
194019
|
+
return { target, rgb: parseOscColorValue(match[3]) };
|
|
194020
|
+
}
|
|
194021
|
+
function parseOscColorValue(rawValue) {
|
|
194022
|
+
const value = rawValue.trim();
|
|
193536
194023
|
if (value.startsWith("#")) {
|
|
193537
194024
|
const hex = value.slice(1);
|
|
193538
194025
|
if (/^[0-9a-f]{6}$/i.test(hex)) {
|
|
@@ -193589,7 +194076,7 @@ function detectCapabilitiesFromEnvironment(tmuxForwardsHyperlink) {
|
|
|
193589
194076
|
const terminalEmulator = process.env.TERMINAL_EMULATOR?.toLowerCase() || "";
|
|
193590
194077
|
const term = process.env.TERM?.toLowerCase() || "";
|
|
193591
194078
|
const colorTerm = process.env.COLORTERM?.toLowerCase() || "";
|
|
193592
|
-
const hasTrueColorHint = colorTerm === "truecolor" || colorTerm === "24bit";
|
|
194079
|
+
const hasTrueColorHint = colorTerm === "truecolor" || colorTerm === "24bit" || term.endsWith("-direct");
|
|
193593
194080
|
const isWindowsConsole = process.platform === "win32";
|
|
193594
194081
|
if (process.env.TMUX || term.startsWith("tmux")) {
|
|
193595
194082
|
return { images: null, trueColor: hasTrueColorHint, hyperlinks: tmuxForwardsHyperlink() };
|
|
@@ -193652,6 +194139,9 @@ function getCapabilities() {
|
|
|
193652
194139
|
}
|
|
193653
194140
|
return cachedCapabilities;
|
|
193654
194141
|
}
|
|
194142
|
+
function getTerminalColorMode(capabilities = getCapabilities()) {
|
|
194143
|
+
return capabilities.trueColor ? "truecolor" : "256color";
|
|
194144
|
+
}
|
|
193655
194145
|
function setCapabilities(caps) {
|
|
193656
194146
|
cachedCapabilities = caps;
|
|
193657
194147
|
}
|
|
@@ -193766,8 +194256,10 @@ function dispatchMouseEvent(component, event) {
|
|
|
193766
194256
|
const result = component.handleMouse?.(event);
|
|
193767
194257
|
if (!result)
|
|
193768
194258
|
return void 0;
|
|
193769
|
-
if ("target" in result)
|
|
193770
|
-
|
|
194259
|
+
if ("target" in result) {
|
|
194260
|
+
const forwarded = result;
|
|
194261
|
+
return forwarded.focus && component.handleInput ? { ...forwarded, focusTarget: component } : forwarded;
|
|
194262
|
+
}
|
|
193771
194263
|
if (!result.handled && !result.capture && !result.focus)
|
|
193772
194264
|
return void 0;
|
|
193773
194265
|
return {
|
|
@@ -193792,6 +194284,10 @@ function retargetMouseEvent(event, target) {
|
|
|
193792
194284
|
height: target.height
|
|
193793
194285
|
};
|
|
193794
194286
|
}
|
|
194287
|
+
var TERMINAL_PALETTE_SIZE = 16;
|
|
194288
|
+
var TERMINAL_COLOR_REPLY_COUNT = 2 + TERMINAL_PALETTE_SIZE;
|
|
194289
|
+
var TERMINAL_COLOR_QUERY = `\x1B]10;?\x07\x1B]11;?\x07${Array.from({ length: TERMINAL_PALETTE_SIZE }, (_2, index4) => `\x1B]4;${index4};?\x07`).join("")}\x1B[c`;
|
|
194290
|
+
var DEVICE_ATTRIBUTES_RESPONSE_PATTERN = /^\x1b\[\?[\d;]*c$/;
|
|
193795
194291
|
function isFocusable(component) {
|
|
193796
194292
|
return component !== null && "focused" in component;
|
|
193797
194293
|
}
|
|
@@ -193893,8 +194389,11 @@ var TuiBase = class _TuiBase extends Container {
|
|
|
193893
194389
|
clearOnShrink = false;
|
|
193894
194390
|
fullRedrawCount = 0;
|
|
193895
194391
|
stopped = false;
|
|
193896
|
-
|
|
193897
|
-
|
|
194392
|
+
/**
|
|
194393
|
+
* Color queries waiting for their DA1 reply, oldest first. Terminals answer in order, so color
|
|
194394
|
+
* replies belong to the oldest one. Queries stay here after a timeout to collect late replies.
|
|
194395
|
+
*/
|
|
194396
|
+
pendingTerminalColorQueries = [];
|
|
193898
194397
|
terminalColorSchemeListeners = /* @__PURE__ */ new Set();
|
|
193899
194398
|
terminalColorSchemeNotificationsEnabled = false;
|
|
193900
194399
|
/** Directory for debug/crash logs. When undefined, debug logging is disabled and crash dumps fall back to the OS temp directory. */
|
|
@@ -193936,7 +194435,7 @@ var TuiBase = class _TuiBase extends Container {
|
|
|
193936
194435
|
return;
|
|
193937
194436
|
this.showHardwareCursor = enabled;
|
|
193938
194437
|
if (!enabled) {
|
|
193939
|
-
this.
|
|
194438
|
+
this.hideTerminalCursor();
|
|
193940
194439
|
}
|
|
193941
194440
|
this.requestRender();
|
|
193942
194441
|
}
|
|
@@ -194072,7 +194571,7 @@ var TuiBase = class _TuiBase extends Container {
|
|
|
194072
194571
|
if (!options?.nonCapturing && this.isOverlayVisible(entry)) {
|
|
194073
194572
|
this.setFocus(component);
|
|
194074
194573
|
}
|
|
194075
|
-
this.
|
|
194574
|
+
this.hideTerminalCursor();
|
|
194076
194575
|
this.requestRender();
|
|
194077
194576
|
return {
|
|
194078
194577
|
hide: () => {
|
|
@@ -194086,7 +194585,7 @@ var TuiBase = class _TuiBase extends Container {
|
|
|
194086
194585
|
this.setFocus(topVisible?.component ?? entry.preFocus);
|
|
194087
194586
|
}
|
|
194088
194587
|
if (this.overlayStack.length === 0)
|
|
194089
|
-
this.
|
|
194588
|
+
this.hideTerminalCursor();
|
|
194090
194589
|
this.requestRender();
|
|
194091
194590
|
}
|
|
194092
194591
|
},
|
|
@@ -194165,9 +194664,14 @@ var TuiBase = class _TuiBase extends Container {
|
|
|
194165
194664
|
this.setFocus(topVisible?.component ?? overlay.preFocus);
|
|
194166
194665
|
}
|
|
194167
194666
|
if (this.overlayStack.length === 0)
|
|
194168
|
-
this.
|
|
194667
|
+
this.hideTerminalCursor();
|
|
194169
194668
|
this.requestRender();
|
|
194170
194669
|
}
|
|
194670
|
+
/** Hide the cursor while running. After stop(), the shell owns the cursor and it must stay visible. */
|
|
194671
|
+
hideTerminalCursor() {
|
|
194672
|
+
if (!this.stopped)
|
|
194673
|
+
this.terminal.hideCursor();
|
|
194674
|
+
}
|
|
194171
194675
|
/** Check if there are any visible overlays */
|
|
194172
194676
|
hasOverlay() {
|
|
194173
194677
|
return this.overlayStack.some((o) => this.isOverlayVisible(o));
|
|
@@ -194348,7 +194852,7 @@ var TuiBase = class _TuiBase extends Container {
|
|
|
194348
194852
|
}, delay);
|
|
194349
194853
|
}
|
|
194350
194854
|
handleTerminalInput(data) {
|
|
194351
|
-
if (this.
|
|
194855
|
+
if (this.consumeTerminalColorResponse(data)) {
|
|
194352
194856
|
return;
|
|
194353
194857
|
}
|
|
194354
194858
|
if (this.consumeTerminalColorSchemeReport(data)) {
|
|
@@ -194408,27 +194912,48 @@ var TuiBase = class _TuiBase extends Container {
|
|
|
194408
194912
|
this.requestImmediateRender();
|
|
194409
194913
|
}
|
|
194410
194914
|
}
|
|
194411
|
-
|
|
194412
|
-
|
|
194915
|
+
consumeTerminalColorResponse(data) {
|
|
194916
|
+
const query = this.pendingTerminalColorQueries[0];
|
|
194917
|
+
if (!query) {
|
|
194413
194918
|
return false;
|
|
194414
194919
|
}
|
|
194415
|
-
if (
|
|
194920
|
+
if (DEVICE_ATTRIBUTES_RESPONSE_PATTERN.test(data)) {
|
|
194921
|
+
this.pendingTerminalColorQueries.shift();
|
|
194922
|
+
this.completeTerminalColorQuery(query);
|
|
194923
|
+
return true;
|
|
194924
|
+
}
|
|
194925
|
+
const response = parseOscColorResponse(data);
|
|
194926
|
+
if (!response) {
|
|
194416
194927
|
return false;
|
|
194417
194928
|
}
|
|
194418
|
-
const rgb =
|
|
194419
|
-
|
|
194420
|
-
|
|
194421
|
-
|
|
194422
|
-
|
|
194423
|
-
|
|
194424
|
-
|
|
194425
|
-
|
|
194426
|
-
|
|
194427
|
-
query.
|
|
194428
|
-
|
|
194929
|
+
const { target, rgb } = response;
|
|
194930
|
+
const key = String(target);
|
|
194931
|
+
if (!query.deliver || query.replied.has(key)) {
|
|
194932
|
+
return true;
|
|
194933
|
+
}
|
|
194934
|
+
query.replied.add(key);
|
|
194935
|
+
if (target === "foreground") {
|
|
194936
|
+
query.foreground = rgb;
|
|
194937
|
+
} else if (target === "background") {
|
|
194938
|
+
query.background = rgb;
|
|
194939
|
+
} else if (target < TERMINAL_PALETTE_SIZE) {
|
|
194940
|
+
query.palette[target] = rgb;
|
|
194941
|
+
}
|
|
194942
|
+
if (query.replied.size === TERMINAL_COLOR_REPLY_COUNT) {
|
|
194943
|
+
this.completeTerminalColorQuery(query);
|
|
194429
194944
|
}
|
|
194430
194945
|
return true;
|
|
194431
194946
|
}
|
|
194947
|
+
terminalColorQueryResult(query) {
|
|
194948
|
+
const palette = query.palette.every((color3) => color3 !== void 0) ? query.palette : void 0;
|
|
194949
|
+
return { foreground: query.foreground, background: query.background, palette };
|
|
194950
|
+
}
|
|
194951
|
+
completeTerminalColorQuery(query) {
|
|
194952
|
+
const deliver = query.deliver;
|
|
194953
|
+
query.deliver = void 0;
|
|
194954
|
+
clearTimeout(query.timer);
|
|
194955
|
+
deliver?.(this.terminalColorQueryResult(query));
|
|
194956
|
+
}
|
|
194432
194957
|
consumeTerminalColorSchemeReport(data) {
|
|
194433
194958
|
const scheme = parseTerminalColorSchemeReport(data);
|
|
194434
194959
|
if (!scheme) {
|
|
@@ -194637,56 +195162,27 @@ var TuiBase = class _TuiBase extends Container {
|
|
|
194637
195162
|
return null;
|
|
194638
195163
|
}
|
|
194639
195164
|
/**
|
|
194640
|
-
* Query the terminal's
|
|
194641
|
-
*
|
|
194642
|
-
*
|
|
195165
|
+
* Query the terminal's theme colors: the default foreground (OSC 10), the default background
|
|
195166
|
+
* (OSC 11), and ANSI colors 0-15 (OSC 4), followed by a DA1 request that marks the end of the
|
|
195167
|
+
* replies. Resolves when the DA1 reply or all color replies arrive, or when the timeout expires.
|
|
195168
|
+
* Colors the terminal did not report are undefined; the palette is only set when all 16 arrived.
|
|
195169
|
+
* @param timeoutMs Query timeout in milliseconds, for terminals that do not answer DA1 either.
|
|
195170
|
+
* @param onLateReply Receives the replies if the query completes after the timeout, e.g. over slow links.
|
|
194643
195171
|
*/
|
|
194644
|
-
|
|
195172
|
+
queryTerminalColors({ timeoutMs, onLateReply }) {
|
|
194645
195173
|
return new Promise((resolve2) => {
|
|
194646
195174
|
const query = {
|
|
194647
|
-
|
|
194648
|
-
|
|
195175
|
+
palette: Array.from({ length: TERMINAL_PALETTE_SIZE }, () => void 0),
|
|
195176
|
+
replied: /* @__PURE__ */ new Set(),
|
|
195177
|
+
deliver: resolve2,
|
|
194649
195178
|
timer: void 0
|
|
194650
195179
|
};
|
|
194651
195180
|
query.timer = setTimeout(() => {
|
|
194652
|
-
|
|
194653
|
-
|
|
194654
|
-
}
|
|
194655
|
-
query.settled = true;
|
|
194656
|
-
query.timer = void 0;
|
|
194657
|
-
query.resolve?.(void 0);
|
|
194658
|
-
query.resolve = void 0;
|
|
195181
|
+
query.deliver = onLateReply;
|
|
195182
|
+
resolve2(this.terminalColorQueryResult(query));
|
|
194659
195183
|
}, timeoutMs);
|
|
194660
|
-
this.
|
|
194661
|
-
this.
|
|
194662
|
-
this.terminal.write("\x1B]11;?\x07");
|
|
194663
|
-
});
|
|
194664
|
-
}
|
|
194665
|
-
/**
|
|
194666
|
-
* Query the terminal's color-scheme preference with DSR (`CSI ? 996 n`).
|
|
194667
|
-
* Terminals that support the color palette notification protocol reply with
|
|
194668
|
-
* `CSI ? 997 ; 1 n` for dark or `CSI ? 997 ; 2 n` for light.
|
|
194669
|
-
*/
|
|
194670
|
-
queryTerminalColorScheme({ timeoutMs }) {
|
|
194671
|
-
return new Promise((resolve2) => {
|
|
194672
|
-
let settled = false;
|
|
194673
|
-
let timer;
|
|
194674
|
-
let unsubscribe = () => {
|
|
194675
|
-
};
|
|
194676
|
-
const settle = (scheme) => {
|
|
194677
|
-
if (settled)
|
|
194678
|
-
return;
|
|
194679
|
-
settled = true;
|
|
194680
|
-
if (timer) {
|
|
194681
|
-
clearTimeout(timer);
|
|
194682
|
-
timer = void 0;
|
|
194683
|
-
}
|
|
194684
|
-
unsubscribe();
|
|
194685
|
-
resolve2(scheme);
|
|
194686
|
-
};
|
|
194687
|
-
unsubscribe = this.onTerminalColorSchemeChange(settle);
|
|
194688
|
-
timer = setTimeout(() => settle(void 0), timeoutMs);
|
|
194689
|
-
this.terminal.write("\x1B[?996n");
|
|
195184
|
+
this.pendingTerminalColorQueries.push(query);
|
|
195185
|
+
this.terminal.write(TERMINAL_COLOR_QUERY);
|
|
194690
195186
|
});
|
|
194691
195187
|
}
|
|
194692
195188
|
};
|
|
@@ -195045,6 +195541,7 @@ function findWordForward(text7, cursor, options) {
|
|
|
195045
195541
|
var graphemeSegmenter2 = getGraphemeSegmenter();
|
|
195046
195542
|
var wordSegmenter3 = getWordSegmenter();
|
|
195047
195543
|
var unquotedAutocompleteSuffixRegex = new RegExp(`(?:(?!${autocompleteSeparatorRegex.source}).)*`, "u");
|
|
195544
|
+
var autocompleteTokenStartSource = `${autocompleteBoundaryRegex.source}[([{<\`]*`;
|
|
195048
195545
|
|
|
195049
195546
|
// ../node_modules/@earendil-works/pi-coding-agent/node_modules/@earendil-works/pi-tui/dist/layout-node.js
|
|
195050
195547
|
var LAYOUT_NODE = /* @__PURE__ */ Symbol.for("@earendil-works/pi-tui/layout-node");
|
|
@@ -196463,6 +196960,61 @@ function getScrollViewsAt(frame, x2, y2) {
|
|
|
196463
196960
|
return result.map((entry) => entry.scrollView);
|
|
196464
196961
|
}
|
|
196465
196962
|
|
|
196963
|
+
// ../node_modules/@earendil-works/pi-coding-agent/node_modules/@earendil-works/pi-tui/dist/wheel-scroll.js
|
|
196964
|
+
var BURST_GAP_MS = 5;
|
|
196965
|
+
var GESTURE_GAP_MS = 200;
|
|
196966
|
+
var REFERENCE_GAP_MS = 100;
|
|
196967
|
+
var MAX_AUTO_LINES = 6;
|
|
196968
|
+
function terminalAcceleratesWheel() {
|
|
196969
|
+
const env2 = process.env;
|
|
196970
|
+
return process.platform === "darwin" && env2.SSH_CONNECTION === void 0 && env2.SSH_CLIENT === void 0 && env2.SSH_TTY === void 0;
|
|
196971
|
+
}
|
|
196972
|
+
var WheelScrollAccelerator = class {
|
|
196973
|
+
lines;
|
|
196974
|
+
accelerate;
|
|
196975
|
+
lastTime = Number.NEGATIVE_INFINITY;
|
|
196976
|
+
lastDirection = 0;
|
|
196977
|
+
averageGap;
|
|
196978
|
+
carry = 0;
|
|
196979
|
+
constructor(lines = "auto", accelerate = !terminalAcceleratesWheel()) {
|
|
196980
|
+
this.lines = lines;
|
|
196981
|
+
this.accelerate = accelerate;
|
|
196982
|
+
}
|
|
196983
|
+
setLines(lines) {
|
|
196984
|
+
this.lines = lines;
|
|
196985
|
+
this.reset();
|
|
196986
|
+
}
|
|
196987
|
+
/** Return the positive line count for a wheel event in `direction` at time `now` (milliseconds). */
|
|
196988
|
+
next(direction, now) {
|
|
196989
|
+
if (this.lines !== "auto")
|
|
196990
|
+
return Number.isFinite(this.lines) ? Math.max(1, Math.floor(this.lines)) : 1;
|
|
196991
|
+
if (!this.accelerate)
|
|
196992
|
+
return 1;
|
|
196993
|
+
const gap = now - this.lastTime;
|
|
196994
|
+
const sameGesture = direction === this.lastDirection && gap <= GESTURE_GAP_MS;
|
|
196995
|
+
this.lastTime = now;
|
|
196996
|
+
this.lastDirection = direction;
|
|
196997
|
+
if (!sameGesture) {
|
|
196998
|
+
this.averageGap = void 0;
|
|
196999
|
+
this.carry = 0;
|
|
197000
|
+
return 1;
|
|
197001
|
+
}
|
|
197002
|
+
if (gap < BURST_GAP_MS)
|
|
197003
|
+
return 1;
|
|
197004
|
+
this.averageGap = this.averageGap === void 0 ? gap : (this.averageGap + gap) / 2;
|
|
197005
|
+
const lines = Math.min(MAX_AUTO_LINES, Math.max(1, REFERENCE_GAP_MS / this.averageGap)) + this.carry;
|
|
197006
|
+
const whole = Math.floor(lines);
|
|
197007
|
+
this.carry = lines - whole;
|
|
197008
|
+
return whole;
|
|
197009
|
+
}
|
|
197010
|
+
reset() {
|
|
197011
|
+
this.lastTime = Number.NEGATIVE_INFINITY;
|
|
197012
|
+
this.lastDirection = 0;
|
|
197013
|
+
this.averageGap = void 0;
|
|
197014
|
+
this.carry = 0;
|
|
197015
|
+
}
|
|
197016
|
+
};
|
|
197017
|
+
|
|
196466
197018
|
// ../node_modules/@earendil-works/pi-coding-agent/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js
|
|
196467
197019
|
var ENTER_ALT_SCREEN = "\x1B[?1049h";
|
|
196468
197020
|
var EXIT_ALT_SCREEN = "\x1B[?1049l";
|
|
@@ -196522,7 +197074,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
196522
197074
|
mousePressPoint;
|
|
196523
197075
|
mousePressMoved = false;
|
|
196524
197076
|
lastComponentClick;
|
|
196525
|
-
|
|
197077
|
+
wheelScroll;
|
|
196526
197078
|
mouseEnabled;
|
|
196527
197079
|
searchMatchStyle;
|
|
196528
197080
|
searchCurrentMatchStyle;
|
|
@@ -196544,7 +197096,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
196544
197096
|
};
|
|
196545
197097
|
this.implicitScrollView = new ScrollView(this.implicitDocument, { follow: "end", primary: true });
|
|
196546
197098
|
this.flashes = new AltScreenFlashContainer(() => this.requestRender());
|
|
196547
|
-
this.
|
|
197099
|
+
this.wheelScroll = new WheelScrollAccelerator(options.wheelScrollLines ?? 1);
|
|
196548
197100
|
this.mouseEnabled = options.mouse ?? true;
|
|
196549
197101
|
this.searchMatchStyle = options.searchMatchStyle ?? ((text7) => `\x1B[4m${text7}\x1B[24m`);
|
|
196550
197102
|
this.searchCurrentMatchStyle = options.searchCurrentMatchStyle ?? ((text7) => `\x1B[1;7m${text7}\x1B[22;27m`);
|
|
@@ -196562,6 +197114,9 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
196562
197114
|
get isFollowingOutput() {
|
|
196563
197115
|
return this.getPrimaryScrollView().isFollowingEnd;
|
|
196564
197116
|
}
|
|
197117
|
+
setWheelScrollLines(lines) {
|
|
197118
|
+
this.wheelScroll.setLines(lines);
|
|
197119
|
+
}
|
|
196565
197120
|
getCopyOnSelect() {
|
|
196566
197121
|
return this.copyOnSelect;
|
|
196567
197122
|
}
|
|
@@ -196921,9 +197476,9 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
196921
197476
|
return { consume: true };
|
|
196922
197477
|
const wheelEvent = this.parseWheelEvent(data);
|
|
196923
197478
|
if (wheelEvent) {
|
|
196924
|
-
const
|
|
196925
|
-
|
|
196926
|
-
});
|
|
197479
|
+
const lines = this.wheelScroll.next(wheelEvent.direction, performance.now());
|
|
197480
|
+
const wheelDelta = wheelEvent.direction * ((wheelEvent.button & 8) !== 0 ? lines * ALT_WHEEL_SCROLL_MULTIPLIER : lines);
|
|
197481
|
+
const event = this.createMouseEvent("wheel", wheelEvent.button, wheelEvent.x, wheelEvent.y, { wheelDelta });
|
|
196927
197482
|
const overlay = this.dispatchMouseToOverlay(event);
|
|
196928
197483
|
const result = overlay.result ?? (overlay.hit ? void 0 : this.dispatchMouseToLayout(event));
|
|
196929
197484
|
if (result) {
|
|
@@ -196933,7 +197488,7 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
196933
197488
|
}
|
|
196934
197489
|
if (this.shouldDeferViewportInputToOverlay())
|
|
196935
197490
|
return void 0;
|
|
196936
|
-
this.routeWheel(wheelEvent);
|
|
197491
|
+
this.routeWheel(wheelEvent, wheelDelta);
|
|
196937
197492
|
return { consume: true };
|
|
196938
197493
|
}
|
|
196939
197494
|
const mouseEvent = this.parseSgrMouseEvent(data);
|
|
@@ -197196,11 +197751,8 @@ var TuiAltScreen = class extends TuiBase {
|
|
|
197196
197751
|
}
|
|
197197
197752
|
return void 0;
|
|
197198
197753
|
}
|
|
197199
|
-
|
|
197200
|
-
|
|
197201
|
-
}
|
|
197202
|
-
routeWheel(event) {
|
|
197203
|
-
let remaining = event.direction * this.getWheelScrollLines(event.button);
|
|
197754
|
+
routeWheel(event, delta) {
|
|
197755
|
+
let remaining = delta;
|
|
197204
197756
|
const seen = /* @__PURE__ */ new Set();
|
|
197205
197757
|
for (const scrollView of this.currentLayout ? getScrollViewsAt(this.currentLayout, event.x, event.y) : []) {
|
|
197206
197758
|
seen.add(scrollView);
|
|
@@ -198566,6 +199118,7 @@ var import_go = __toESM(require_go(), 1);
|
|
|
198566
199118
|
var import_groovy = __toESM(require_groovy(), 1);
|
|
198567
199119
|
var import_java = __toESM(require_java(), 1);
|
|
198568
199120
|
var import_javascript = __toESM(require_javascript(), 1);
|
|
199121
|
+
var import_json = __toESM(require_json(), 1);
|
|
198569
199122
|
var import_kotlin = __toESM(require_kotlin(), 1);
|
|
198570
199123
|
var import_lua = __toESM(require_lua(), 1);
|
|
198571
199124
|
var import_nix = __toESM(require_nix(), 1);
|
|
@@ -198582,6 +199135,7 @@ var eagerLanguages = {
|
|
|
198582
199135
|
java: import_java.default,
|
|
198583
199136
|
go: import_go.default,
|
|
198584
199137
|
javascript: import_javascript.default,
|
|
199138
|
+
json: import_json.default,
|
|
198585
199139
|
cpp: import_cpp.default,
|
|
198586
199140
|
typescript: import_typescript.default,
|
|
198587
199141
|
php: import_php.default,
|
|
@@ -198603,113 +199157,477 @@ for (const [name, language] of Object.entries(eagerLanguages)) {
|
|
|
198603
199157
|
import_core.default.registerLanguage(name, language);
|
|
198604
199158
|
}
|
|
198605
199159
|
|
|
198606
|
-
// ../node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.js
|
|
198607
|
-
var
|
|
198608
|
-
|
|
198609
|
-
|
|
198610
|
-
|
|
198611
|
-
|
|
199160
|
+
// ../node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/system-theme.js
|
|
199161
|
+
var SYSTEM_THEME_NAME = "system";
|
|
199162
|
+
var FAMILIES = {
|
|
199163
|
+
neutral: { hue: 231.49, saturation: { min: 0.02, max: 0.08 }, slot: 8 },
|
|
199164
|
+
blue: { hue: 231.49, saturation: { min: 0.1, max: 0.68 }, slot: 4 },
|
|
199165
|
+
green: { hue: 158.68, saturation: { min: 0.1, max: 0.76 }, slot: 2 },
|
|
199166
|
+
red: { hue: 20, saturation: { min: 0.1, max: 0.92 }, slot: 1 },
|
|
199167
|
+
yellow: { hue: 82.36, saturation: { min: 0.5, max: 1 }, slot: 3 },
|
|
199168
|
+
orange: { hue: 52, saturation: { min: 0.12, max: 0.85 }, slot: 3 },
|
|
199169
|
+
violet: { hue: 295, saturation: { min: 0.2, max: 0.6 }, slot: 5 },
|
|
199170
|
+
calamine: { hue: 202.43, saturation: { min: 0.1, max: 0.74 }, slot: 6 },
|
|
199171
|
+
thinkingSlate: { hue: 231.49, saturation: { min: 0.08, max: 0.2 }, slot: 4 },
|
|
199172
|
+
thinkingBlue: { hue: 231.49, saturation: { min: 0.2, max: 0.45 }, slot: 4 },
|
|
199173
|
+
thinkingPeriwinkle: { hue: 263.25, saturation: { min: 0.3, max: 0.6 }, slot: 6 },
|
|
199174
|
+
thinkingViolet: { hue: 295, saturation: { min: 0.4, max: 0.75 }, slot: 5 },
|
|
199175
|
+
thinkingMagenta: { hue: 337.5, saturation: { min: 0.5, max: 0.85 }, slot: 13 },
|
|
199176
|
+
thinkingRed: { hue: 20, saturation: { min: 0.95, max: 1 }, slot: 1 }
|
|
199177
|
+
};
|
|
199178
|
+
var TOKEN_FAMILIES = {
|
|
199179
|
+
selectedBg: "blue",
|
|
199180
|
+
searchMatchBg: "orange",
|
|
199181
|
+
userMessageBg: "blue",
|
|
199182
|
+
customMessageBg: "violet",
|
|
199183
|
+
toolPendingBg: "neutral",
|
|
199184
|
+
toolSuccessBg: "green",
|
|
199185
|
+
toolErrorBg: "red",
|
|
199186
|
+
text: "neutral",
|
|
199187
|
+
userMessageText: "neutral",
|
|
199188
|
+
customMessageText: "neutral",
|
|
199189
|
+
toolTitle: "neutral",
|
|
199190
|
+
syntaxOperator: "neutral",
|
|
199191
|
+
syntaxPunctuation: "neutral",
|
|
199192
|
+
muted: "neutral",
|
|
199193
|
+
dim: "neutral",
|
|
199194
|
+
thinkingText: "neutral",
|
|
199195
|
+
toolOutput: "neutral",
|
|
199196
|
+
mdLinkUrl: "neutral",
|
|
199197
|
+
mdQuote: "neutral",
|
|
199198
|
+
mdQuoteBorder: "neutral",
|
|
199199
|
+
mdHr: "neutral",
|
|
199200
|
+
mdCodeBlockBorder: "neutral",
|
|
199201
|
+
toolDiffContext: "neutral",
|
|
199202
|
+
syntaxComment: "neutral",
|
|
199203
|
+
scrollbarTrack: "neutral",
|
|
199204
|
+
scrollbarThumb: "neutral",
|
|
199205
|
+
searchMatchText: "neutral",
|
|
199206
|
+
borderMuted: "neutral",
|
|
199207
|
+
accent: "violet",
|
|
199208
|
+
borderAccent: "violet",
|
|
199209
|
+
customMessageLabel: "violet",
|
|
199210
|
+
mdCode: "violet",
|
|
199211
|
+
mdListBullet: "violet",
|
|
199212
|
+
syntaxType: "violet",
|
|
199213
|
+
border: "blue",
|
|
199214
|
+
mdLink: "blue",
|
|
199215
|
+
syntaxKeyword: "blue",
|
|
199216
|
+
syntaxVariable: "calamine",
|
|
199217
|
+
success: "green",
|
|
199218
|
+
mdCodeBlock: "green",
|
|
199219
|
+
toolDiffAdded: "green",
|
|
199220
|
+
bashMode: "green",
|
|
199221
|
+
syntaxNumber: "green",
|
|
199222
|
+
error: "red",
|
|
199223
|
+
toolDiffRemoved: "red",
|
|
199224
|
+
warning: "yellow",
|
|
199225
|
+
mdHeading: "yellow",
|
|
199226
|
+
syntaxFunction: "yellow",
|
|
199227
|
+
syntaxString: "orange",
|
|
199228
|
+
thinkingOff: "neutral",
|
|
199229
|
+
thinkingMinimal: "thinkingSlate",
|
|
199230
|
+
thinkingLow: "thinkingBlue",
|
|
199231
|
+
thinkingMedium: "thinkingPeriwinkle",
|
|
199232
|
+
thinkingHigh: "thinkingViolet",
|
|
199233
|
+
thinkingXhigh: "thinkingMagenta",
|
|
199234
|
+
thinkingMax: "thinkingRed"
|
|
199235
|
+
};
|
|
199236
|
+
var TOKEN_SLOTS = { syntaxString: 2, syntaxNumber: 5, searchMatchBg: 3 };
|
|
199237
|
+
var LEVELS = {
|
|
199238
|
+
panel: {
|
|
199239
|
+
dark: { coefficients: [0.29131, -0.39746, 2.33185, -0.85524, -1.2076, 0.86276], reachable: [0, 0.979] },
|
|
199240
|
+
light: { coefficients: [-3.74073, 27.94549, -78.44258, 112.6798, -79.60015, 22.11277], reachable: [0.348, 1] }
|
|
199241
|
+
},
|
|
199242
|
+
track: {
|
|
199243
|
+
dark: { coefficients: [0.39028, -0.23015, 0.83573, 2.43829, -4.38292, 2.01582], reachable: [0, 0.946] },
|
|
199244
|
+
light: { coefficients: [-5.24921, 38.37322, -107.28833, 152.10005, -106.17127, 29.18061], reachable: [0.368, 1] }
|
|
199245
|
+
},
|
|
199246
|
+
thinking0: {
|
|
199247
|
+
dark: { coefficients: [0.52988, -0.05809, -0.30924, 4.63567, -6.52933, 2.89108], reachable: [0, 0.873] },
|
|
199248
|
+
light: {
|
|
199249
|
+
coefficients: [-28.27749, 182.85284, -469.62416, 603.15916, -384.59976, 97.35147],
|
|
199250
|
+
reachable: [0.51, 1]
|
|
199251
|
+
}
|
|
199252
|
+
},
|
|
199253
|
+
thinking1: {
|
|
199254
|
+
dark: { coefficients: [0.55278, -0.03667, -0.45659, 4.95347, -6.90265, 3.0706], reachable: [0, 0.858] },
|
|
199255
|
+
light: {
|
|
199256
|
+
coefficients: [-37.10484, 235.86282, -596.62344, 754.3633, -474.00763, 118.3551],
|
|
199257
|
+
reachable: [0.535, 1]
|
|
199258
|
+
}
|
|
199259
|
+
},
|
|
199260
|
+
thinking2: {
|
|
199261
|
+
dark: { coefficients: [0.57486, -0.01765, -0.58987, 5.25227, -7.27175, 3.25532], reachable: [0, 0.842] },
|
|
199262
|
+
light: {
|
|
199263
|
+
coefficients: [-59.89653, 377.05024, -945.07843, 1182.03145, -734.96375, 181.68658],
|
|
199264
|
+
reachable: [0.556, 1]
|
|
199265
|
+
}
|
|
199266
|
+
},
|
|
199267
|
+
thinking3: {
|
|
199268
|
+
dark: { coefficients: [0.59621, -62e-5, -0.71148, 5.53588, -7.6392, 3.44606], reachable: [0, 0.827] },
|
|
199269
|
+
light: {
|
|
199270
|
+
coefficients: [-72.07122, 445.84082, -1099.57352, 1353.88793, -829.53392, 202.26164],
|
|
199271
|
+
reachable: [0.58, 1]
|
|
199272
|
+
}
|
|
199273
|
+
},
|
|
199274
|
+
thinking4: {
|
|
199275
|
+
dark: { coefficients: [0.61691, 0.01462, -0.82288, 5.80651, -8.00641, 3.64333], reachable: [0, 0.811] },
|
|
199276
|
+
light: {
|
|
199277
|
+
coefficients: [-110.14338, 674.21488, -1645.75941, 2004.32367, -1215.15899, 293.3183],
|
|
199278
|
+
reachable: [0.6, 1]
|
|
199279
|
+
}
|
|
199280
|
+
},
|
|
199281
|
+
thinking5: {
|
|
199282
|
+
dark: { coefficients: [0.63702, 0.02826, -0.92498, 6.06465, -8.37246, 3.84651], reachable: [0, 0.795] },
|
|
199283
|
+
light: {
|
|
199284
|
+
coefficients: [-175.47701, 1063.54495, -2570.70594, 3098.80776, -1860.15527, 444.76392],
|
|
199285
|
+
reachable: [0.62, 1]
|
|
199286
|
+
}
|
|
199287
|
+
},
|
|
199288
|
+
thinking6: {
|
|
199289
|
+
dark: { coefficients: [0.65658, 0.04044, -1.01835, 6.30989, -8.73529, 4.05439], reachable: [0, 0.779] },
|
|
199290
|
+
light: {
|
|
199291
|
+
coefficients: [-183.81712, 1094.70055, -2602.68539, 3088.71276, -1826.91131, 430.75931],
|
|
199292
|
+
reachable: [0.643, 1]
|
|
199293
|
+
}
|
|
199294
|
+
},
|
|
199295
|
+
subtle: {
|
|
199296
|
+
dark: { coefficients: [0.56762, -0.02475, -0.5383, 5.12628, -7.10931, 3.17324], reachable: [0, 0.848] },
|
|
199297
|
+
light: {
|
|
199298
|
+
coefficients: [-232.85459, 1376.54473, -3249.11801, 3827.91186, -2248.29472, 526.55751],
|
|
199299
|
+
reachable: [0.657, 1]
|
|
199300
|
+
}
|
|
199301
|
+
},
|
|
199302
|
+
thumb: {
|
|
199303
|
+
dark: { coefficients: [0.60323, 278e-5, -0.73328, 5.57157, -7.68067, 3.46933], reachable: [0, 0.823] },
|
|
199304
|
+
light: {
|
|
199305
|
+
coefficients: [-82.89897, 511.01355, -1255.98095, 1540.76821, -940.68087, 228.58523],
|
|
199306
|
+
reachable: [0.586, 1]
|
|
199307
|
+
}
|
|
199308
|
+
},
|
|
199309
|
+
readable: {
|
|
199310
|
+
dark: { coefficients: [0.66937, 0.04704, -1.06871, 6.43941, -8.9332, 4.17229], reachable: [0, 0.77] },
|
|
199311
|
+
light: {
|
|
199312
|
+
coefficients: [-1554.52576, 8733.56817, -19604.93507, 21977.72696, -12300.99599, 2749.81288],
|
|
199313
|
+
reachable: [0.751, 1]
|
|
199314
|
+
}
|
|
199315
|
+
},
|
|
199316
|
+
emphasis: {
|
|
199317
|
+
dark: { coefficients: [0.7303, 0.07695, -1.31626, 7.1681, -10.14436, 4.92846], reachable: [0, 0.712] },
|
|
199318
|
+
light: {
|
|
199319
|
+
coefficients: [-4948.31942, 26870.91986, -58334.48399, 63280.17197, -34298.01053, 7430.30146],
|
|
199320
|
+
reachable: [0.811, 1]
|
|
199321
|
+
}
|
|
199322
|
+
},
|
|
199323
|
+
textOnPanel: {
|
|
199324
|
+
dark: { coefficients: [0.86713, 0.05232, -0.89428, 4.79014, -5.5432, 1.75023], reachable: [0, 0.542] },
|
|
199325
|
+
light: {
|
|
199326
|
+
coefficients: [-8570.89457, 43954.60805, -90084.00702, 92220.6791, -47152.15802, 9632.27113],
|
|
199327
|
+
reachable: [0.867, 1]
|
|
199328
|
+
}
|
|
199329
|
+
},
|
|
199330
|
+
text: {
|
|
199331
|
+
dark: { coefficients: [0.89242, 0.02311, -0.44862, 2.34417, -0.06084, -2.63844], reachable: [0, 0.5] },
|
|
199332
|
+
light: {
|
|
199333
|
+
coefficients: [-2004.67048, 6664.47299, -6060.70202, -1792.61209, 5133.82359, -1939.85583],
|
|
199334
|
+
reachable: [0.894, 1]
|
|
199335
|
+
}
|
|
199336
|
+
}
|
|
199337
|
+
};
|
|
199338
|
+
var TOOL_PANELS = ["toolPendingBg", "toolSuccessBg", "toolErrorBg"];
|
|
199339
|
+
var MESSAGE_PANELS = ["userMessageBg", "customMessageBg"];
|
|
199340
|
+
var PANELS = [
|
|
199341
|
+
"userMessageBg",
|
|
199342
|
+
"toolPendingBg",
|
|
199343
|
+
"toolSuccessBg",
|
|
199344
|
+
"toolErrorBg",
|
|
199345
|
+
"selectedBg",
|
|
199346
|
+
"searchMatchBg",
|
|
199347
|
+
"customMessageBg"
|
|
199348
|
+
];
|
|
199349
|
+
var THINKING = [
|
|
199350
|
+
"thinkingOff",
|
|
199351
|
+
"thinkingMinimal",
|
|
199352
|
+
"thinkingLow",
|
|
199353
|
+
"thinkingMedium",
|
|
199354
|
+
"thinkingHigh",
|
|
199355
|
+
"thinkingXhigh",
|
|
199356
|
+
"thinkingMax"
|
|
199357
|
+
];
|
|
199358
|
+
var THINKING_LEVELS2 = [
|
|
199359
|
+
"thinking0",
|
|
199360
|
+
"thinking1",
|
|
199361
|
+
"thinking2",
|
|
199362
|
+
"thinking3",
|
|
199363
|
+
"thinking4",
|
|
199364
|
+
"thinking5",
|
|
199365
|
+
"thinking6"
|
|
199366
|
+
];
|
|
199367
|
+
var each = (tokens, on3, level) => tokens.map((token) => ({ token, on: on3, level }));
|
|
199368
|
+
var RULES = [
|
|
199369
|
+
...each(PANELS, ["background"], "panel"),
|
|
199370
|
+
{ token: "text", on: ["background"], level: "text" },
|
|
199371
|
+
{ token: "text", on: ["selectedBg"], level: "textOnPanel" },
|
|
199372
|
+
{ token: "userMessageText", on: ["userMessageBg"], level: "textOnPanel" },
|
|
199373
|
+
{ token: "toolTitle", on: TOOL_PANELS, level: "textOnPanel" },
|
|
199374
|
+
...each(["accent", "success", "error", "warning"], ["background", "selectedBg", ...TOOL_PANELS], "readable"),
|
|
199375
|
+
{ token: "muted", on: ["background", "selectedBg", "customMessageBg", ...TOOL_PANELS], level: "readable" },
|
|
199376
|
+
{ token: "dim", on: ["background", "selectedBg", "customMessageBg", ...TOOL_PANELS], level: "subtle" },
|
|
199377
|
+
{ token: "thinkingText", on: ["background"], level: "readable" },
|
|
199378
|
+
{ token: "customMessageText", on: ["customMessageBg", ...TOOL_PANELS], level: "readable" },
|
|
199379
|
+
{
|
|
199380
|
+
token: "customMessageLabel",
|
|
199381
|
+
on: ["background", "customMessageBg", "selectedBg", ...TOOL_PANELS],
|
|
199382
|
+
level: "readable"
|
|
199383
|
+
},
|
|
199384
|
+
{ token: "toolOutput", on: ["background", ...TOOL_PANELS], level: "readable" },
|
|
199385
|
+
...each(["mdHeading", "mdLink", "mdLinkUrl", "mdCode", "mdQuote", "mdCodeBlockBorder", "mdListBullet"], ["background", ...MESSAGE_PANELS], "readable"),
|
|
199386
|
+
{ token: "mdCodeBlock", on: ["background", ...MESSAGE_PANELS, ...TOOL_PANELS], level: "readable" },
|
|
199387
|
+
...each(["toolDiffAdded", "toolDiffRemoved", "toolDiffContext"], ["background", ...TOOL_PANELS], "readable"),
|
|
199388
|
+
...each([
|
|
199389
|
+
"syntaxComment",
|
|
199390
|
+
"syntaxKeyword",
|
|
199391
|
+
"syntaxFunction",
|
|
199392
|
+
"syntaxVariable",
|
|
199393
|
+
"syntaxString",
|
|
199394
|
+
"syntaxNumber",
|
|
199395
|
+
"syntaxType",
|
|
199396
|
+
"syntaxOperator",
|
|
199397
|
+
"syntaxPunctuation"
|
|
199398
|
+
], ["background", ...MESSAGE_PANELS, ...TOOL_PANELS], "readable"),
|
|
199399
|
+
{ token: "searchMatchText", on: ["searchMatchBg"], level: "readable" },
|
|
199400
|
+
...each(["bashMode", "border", "borderAccent"], ["background"], "readable"),
|
|
199401
|
+
{ token: "borderMuted", on: ["background"], level: "subtle" },
|
|
199402
|
+
...each(["mdQuoteBorder", "mdHr"], ["background", ...MESSAGE_PANELS, ...TOOL_PANELS], "readable"),
|
|
199403
|
+
{ token: "scrollbarTrack", on: ["background"], level: "track" },
|
|
199404
|
+
{ token: "scrollbarThumb", on: ["scrollbarTrack"], level: "thumb" },
|
|
199405
|
+
...THINKING.map((token, index4) => ({ token, on: ["background"], level: THINKING_LEVELS2[index4] }))
|
|
199406
|
+
];
|
|
199407
|
+
var READABLE_FLOOR = { dark: "readable", light: "subtle" };
|
|
199408
|
+
var FOREGROUND_LEVEL = "emphasis";
|
|
199409
|
+
var FOREGROUND_TOKENS = ["text", "userMessageText", "toolTitle"];
|
|
199410
|
+
var TEXT_MINIMUM_WCAG_CONTRAST = 4.5;
|
|
199411
|
+
var SOLVE_ORDER = (() => {
|
|
199412
|
+
const order2 = [];
|
|
199413
|
+
const visit2 = (token) => {
|
|
199414
|
+
if (order2.includes(token))
|
|
199415
|
+
return;
|
|
199416
|
+
for (const rule of RULES) {
|
|
199417
|
+
if (rule.token !== token)
|
|
199418
|
+
continue;
|
|
199419
|
+
for (const surface of rule.on)
|
|
199420
|
+
if (surface !== "background")
|
|
199421
|
+
visit2(surface);
|
|
199422
|
+
}
|
|
199423
|
+
order2.push(token);
|
|
199424
|
+
};
|
|
199425
|
+
for (const rule of RULES)
|
|
199426
|
+
visit2(rule.token);
|
|
199427
|
+
return order2;
|
|
199428
|
+
})();
|
|
199429
|
+
function oklabLightness(color3) {
|
|
199430
|
+
return colorToOklch(rgbColor(color3.r, color3.g, color3.b)).l;
|
|
199431
|
+
}
|
|
199432
|
+
function relativeLuminance({ r, g, b: b2 }) {
|
|
199433
|
+
const linear = (channel) => {
|
|
199434
|
+
const value = channel / 255;
|
|
199435
|
+
return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
|
|
199436
|
+
};
|
|
199437
|
+
return 0.2126 * linear(r) + 0.7152 * linear(g) + 0.0722 * linear(b2);
|
|
199438
|
+
}
|
|
199439
|
+
function wcagContrast(first, second) {
|
|
199440
|
+
const a = relativeLuminance(first);
|
|
199441
|
+
const b2 = relativeLuminance(second);
|
|
199442
|
+
return (Math.max(a, b2) + 0.05) / (Math.min(a, b2) + 0.05);
|
|
199443
|
+
}
|
|
199444
|
+
function terminalAppearance(background, foreground) {
|
|
199445
|
+
const white = { r: 255, g: 255, b: 255 };
|
|
199446
|
+
const black = { r: 0, g: 0, b: 0 };
|
|
199447
|
+
const whiteContrast = wcagContrast(white, background);
|
|
199448
|
+
const blackContrast = wcagContrast(black, background);
|
|
199449
|
+
if (foreground) {
|
|
199450
|
+
const foregroundL = oklabLightness(foreground);
|
|
199451
|
+
const backgroundL = oklabLightness(background);
|
|
199452
|
+
if (Math.abs(foregroundL - backgroundL) > 0.05) {
|
|
199453
|
+
const appearance = foregroundL > backgroundL ? "dark" : "light";
|
|
199454
|
+
const best = appearance === "dark" ? whiteContrast : blackContrast;
|
|
199455
|
+
if (best >= TEXT_MINIMUM_WCAG_CONTRAST)
|
|
199456
|
+
return appearance;
|
|
199457
|
+
}
|
|
199458
|
+
}
|
|
199459
|
+
return whiteContrast >= blackContrast ? "dark" : "light";
|
|
199460
|
+
}
|
|
199461
|
+
var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
199462
|
+
function hexOf({ r, g, b: b2 }) {
|
|
199463
|
+
return `#${[r, g, b2].map((channel) => Math.round(channel).toString(16).padStart(2, "0")).join("")}`;
|
|
199464
|
+
}
|
|
199465
|
+
function bellWeight(lightness) {
|
|
199466
|
+
const gaussian = (x2) => Math.exp(-((x2 - 0.5) ** 2) / (2 * 0.25 ** 2));
|
|
199467
|
+
return (gaussian(lightness) - gaussian(0)) / (1 - gaussian(0));
|
|
199468
|
+
}
|
|
199469
|
+
function saturationCurve({ saturation: { min, max } }, lightness) {
|
|
199470
|
+
const floor2 = max > 0 ? min / max : 1;
|
|
199471
|
+
return floor2 + (1 - floor2) * bellWeight(lightness);
|
|
199472
|
+
}
|
|
199473
|
+
function levelTarget(level, appearance, surfaceL) {
|
|
199474
|
+
const curve = LEVELS[level][appearance];
|
|
199475
|
+
if (surfaceL < curve.reachable[0] || surfaceL > curve.reachable[1])
|
|
199476
|
+
return void 0;
|
|
199477
|
+
return curve.coefficients.reduce((sum, coefficient, power) => sum + coefficient * surfaceL ** power, 0);
|
|
199478
|
+
}
|
|
199479
|
+
function generateSystemThemeColors(input) {
|
|
199480
|
+
const saturation = clamp(input.saturation ?? 1, 0, 1);
|
|
199481
|
+
const { background, foreground } = input;
|
|
199482
|
+
if (!background)
|
|
199483
|
+
return indexedColors(saturation, input.appearanceHint);
|
|
199484
|
+
const palette = input.palette?.length === 16 ? input.palette.map(okhslOf) : void 0;
|
|
199485
|
+
const appearance = terminalAppearance(background, foreground);
|
|
199486
|
+
const lighter = appearance === "dark";
|
|
199487
|
+
const extreme = lighter ? 1 : 0;
|
|
199488
|
+
const backgroundL = oklabLightness(background);
|
|
199489
|
+
const paint = (token, oklabL) => {
|
|
199490
|
+
const lightness = oklabToOkhslLightness(oklabL);
|
|
199491
|
+
const family = FAMILIES[TOKEN_FAMILIES[token]];
|
|
199492
|
+
if (!palette) {
|
|
199493
|
+
const { min, max } = family.saturation;
|
|
199494
|
+
return okhslColor(family.hue, (min + (max - min) * bellWeight(lightness)) * saturation, lightness);
|
|
199495
|
+
}
|
|
199496
|
+
return anchored(palette[TOKEN_SLOTS[token] ?? family.slot], family, lightness, saturation);
|
|
199497
|
+
};
|
|
199498
|
+
const target = (level, surfaceL, t) => {
|
|
199499
|
+
const reached = levelTarget(level, appearance, surfaceL);
|
|
199500
|
+
if (reached === void 0 && t === 0)
|
|
199501
|
+
return void 0;
|
|
199502
|
+
const distance = (reached ?? extreme) - surfaceL;
|
|
199503
|
+
const floor2 = (levelTarget(READABLE_FLOOR[appearance], appearance, surfaceL) ?? extreme) - surfaceL;
|
|
199504
|
+
const compressed = Math.abs(distance) > Math.abs(floor2) ? distance - (distance - floor2) * Math.min(t, 1) : distance;
|
|
199505
|
+
return surfaceL + compressed * (1 - Math.max(0, t - 1));
|
|
199506
|
+
};
|
|
199507
|
+
const extremeText = lighter ? { r: 255, g: 255, b: 255 } : { r: 0, g: 0, b: 0 };
|
|
199508
|
+
const readable = (color3) => wcagContrast(extremeText, color3) >= TEXT_MINIMUM_WCAG_CONTRAST;
|
|
199509
|
+
const limitPanel = (token, l3) => {
|
|
199510
|
+
const color3 = paint(token, l3);
|
|
199511
|
+
if (readable(color3))
|
|
199512
|
+
return color3;
|
|
199513
|
+
let [low, high] = [backgroundL, l3];
|
|
199514
|
+
for (let index4 = 0; index4 < 20; index4++) {
|
|
199515
|
+
const middle = (low + high) / 2;
|
|
199516
|
+
if (readable(paint(token, middle)))
|
|
199517
|
+
low = middle;
|
|
199518
|
+
else
|
|
199519
|
+
high = middle;
|
|
199520
|
+
}
|
|
199521
|
+
return paint(token, low);
|
|
199522
|
+
};
|
|
199523
|
+
const solve = (t) => {
|
|
199524
|
+
const colors2 = /* @__PURE__ */ new Map([["background", background]]);
|
|
199525
|
+
for (const token of SOLVE_ORDER) {
|
|
199526
|
+
const targets = [];
|
|
199527
|
+
for (const rule of RULES) {
|
|
199528
|
+
if (rule.token !== token)
|
|
199529
|
+
continue;
|
|
199530
|
+
for (const surface of rule.on) {
|
|
199531
|
+
const value = target(rule.level, oklabLightness(colors2.get(surface) ?? background), t);
|
|
199532
|
+
if (value === void 0 || value < 0 || value > 1)
|
|
199533
|
+
return void 0;
|
|
199534
|
+
targets.push(value);
|
|
199535
|
+
}
|
|
199536
|
+
}
|
|
199537
|
+
const l3 = lighter ? Math.max(...targets) : Math.min(...targets);
|
|
199538
|
+
colors2.set(token, PANELS.includes(token) ? limitPanel(token, l3) : paint(token, l3));
|
|
199539
|
+
}
|
|
199540
|
+
return colors2;
|
|
199541
|
+
};
|
|
199542
|
+
let relaxation = 0;
|
|
199543
|
+
let colors = solve(0);
|
|
199544
|
+
if (!colors) {
|
|
199545
|
+
let [low, high] = [0, 2];
|
|
199546
|
+
colors = solve(high);
|
|
199547
|
+
for (let index4 = 0; index4 < 20; index4++) {
|
|
199548
|
+
const middle = (low + high) / 2;
|
|
199549
|
+
const attempt = solve(middle);
|
|
199550
|
+
if (attempt)
|
|
199551
|
+
[high, colors] = [middle, attempt];
|
|
199552
|
+
else
|
|
199553
|
+
low = middle;
|
|
199554
|
+
}
|
|
199555
|
+
relaxation = high;
|
|
198612
199556
|
}
|
|
198613
|
-
const
|
|
198614
|
-
const
|
|
198615
|
-
const
|
|
198616
|
-
|
|
198617
|
-
|
|
199557
|
+
const solved = colors ?? /* @__PURE__ */ new Map();
|
|
199558
|
+
const surfacesOf = (token) => RULES.filter((rule) => rule.token === token).flatMap((rule) => rule.on.map((surface) => solved.get(surface) ?? background));
|
|
199559
|
+
const result = {};
|
|
199560
|
+
for (const token of Object.keys(TOKEN_FAMILIES)) {
|
|
199561
|
+
const color3 = solved.get(token);
|
|
199562
|
+
result[token] = color3 ? hexOf(color3) : "";
|
|
199563
|
+
}
|
|
199564
|
+
for (const token of FOREGROUND_TOKENS) {
|
|
199565
|
+
const surfaces = surfacesOf(token);
|
|
199566
|
+
let text7 = solved.get(token);
|
|
199567
|
+
if (foreground) {
|
|
199568
|
+
const targets = surfaces.map((surface) => target(FOREGROUND_LEVEL, oklabLightness(surface), relaxation));
|
|
199569
|
+
if (targets.every((value) => value !== void 0 && value >= 0 && value <= 1)) {
|
|
199570
|
+
const needed = lighter ? Math.max(...targets) : Math.min(...targets);
|
|
199571
|
+
const foregroundL = oklabLightness(foreground);
|
|
199572
|
+
if (lighter ? foregroundL >= needed : foregroundL <= needed) {
|
|
199573
|
+
result[token] = "";
|
|
199574
|
+
continue;
|
|
199575
|
+
}
|
|
199576
|
+
text7 = anchored(okhslOf(foreground), FAMILIES.neutral, oklabToOkhslLightness(needed), saturation);
|
|
199577
|
+
}
|
|
199578
|
+
}
|
|
199579
|
+
if (text7)
|
|
199580
|
+
result[token] = hexOf(withTextContrast(text7, surfaces, lighter));
|
|
198618
199581
|
}
|
|
198619
|
-
return {
|
|
198620
|
-
}
|
|
198621
|
-
var CUBE_VALUES = [0, 95, 135, 175, 215, 255];
|
|
198622
|
-
var GRAY_VALUES = Array.from({ length: 24 }, (_2, i2) => 8 + i2 * 10);
|
|
198623
|
-
function findClosestCubeIndex(value) {
|
|
198624
|
-
let minDist = Infinity;
|
|
198625
|
-
let minIdx = 0;
|
|
198626
|
-
for (let i2 = 0; i2 < CUBE_VALUES.length; i2++) {
|
|
198627
|
-
const dist = Math.abs(value - CUBE_VALUES[i2]);
|
|
198628
|
-
if (dist < minDist) {
|
|
198629
|
-
minDist = dist;
|
|
198630
|
-
minIdx = i2;
|
|
198631
|
-
}
|
|
198632
|
-
}
|
|
198633
|
-
return minIdx;
|
|
198634
|
-
}
|
|
198635
|
-
function findClosestGrayIndex(gray) {
|
|
198636
|
-
let minDist = Infinity;
|
|
198637
|
-
let minIdx = 0;
|
|
198638
|
-
for (let i2 = 0; i2 < GRAY_VALUES.length; i2++) {
|
|
198639
|
-
const dist = Math.abs(gray - GRAY_VALUES[i2]);
|
|
198640
|
-
if (dist < minDist) {
|
|
198641
|
-
minDist = dist;
|
|
198642
|
-
minIdx = i2;
|
|
198643
|
-
}
|
|
198644
|
-
}
|
|
198645
|
-
return minIdx;
|
|
198646
|
-
}
|
|
198647
|
-
function colorDistance(r1, g1, b1, r2, g2, b2) {
|
|
198648
|
-
const dr2 = r1 - r2;
|
|
198649
|
-
const dg = g1 - g2;
|
|
198650
|
-
const db = b1 - b2;
|
|
198651
|
-
return dr2 * dr2 * 0.299 + dg * dg * 0.587 + db * db * 0.114;
|
|
199582
|
+
return { colors: result, dim: [], appearance };
|
|
198652
199583
|
}
|
|
198653
|
-
function
|
|
198654
|
-
|
|
198655
|
-
const gIdx = findClosestCubeIndex(g);
|
|
198656
|
-
const bIdx = findClosestCubeIndex(b2);
|
|
198657
|
-
const cubeR = CUBE_VALUES[rIdx];
|
|
198658
|
-
const cubeG = CUBE_VALUES[gIdx];
|
|
198659
|
-
const cubeB = CUBE_VALUES[bIdx];
|
|
198660
|
-
const cubeIndex = 16 + 36 * rIdx + 6 * gIdx + bIdx;
|
|
198661
|
-
const cubeDist = colorDistance(r, g, b2, cubeR, cubeG, cubeB);
|
|
198662
|
-
const gray = Math.round(0.299 * r + 0.587 * g + 0.114 * b2);
|
|
198663
|
-
const grayIdx = findClosestGrayIndex(gray);
|
|
198664
|
-
const grayValue = GRAY_VALUES[grayIdx];
|
|
198665
|
-
const grayIndex = 232 + grayIdx;
|
|
198666
|
-
const grayDist = colorDistance(r, g, b2, grayValue, grayValue, grayValue);
|
|
198667
|
-
const maxC = Math.max(r, g, b2);
|
|
198668
|
-
const minC = Math.min(r, g, b2);
|
|
198669
|
-
const spread = maxC - minC;
|
|
198670
|
-
if (spread < 10 && grayDist < cubeDist) {
|
|
198671
|
-
return grayIndex;
|
|
198672
|
-
}
|
|
198673
|
-
return cubeIndex;
|
|
199584
|
+
function okhslOf({ r, g, b: b2 }) {
|
|
199585
|
+
return colorToOkhsl(rgbColor(r, g, b2));
|
|
198674
199586
|
}
|
|
198675
|
-
function
|
|
198676
|
-
const
|
|
198677
|
-
|
|
199587
|
+
function anchored(source, family, lightness, saturation) {
|
|
199588
|
+
const anchor = saturationCurve(family, source.l);
|
|
199589
|
+
const falloff = anchor > 0 ? Math.min(1, saturationCurve(family, lightness) / anchor) : 1;
|
|
199590
|
+
return okhslColor(source.h, source.s * falloff * saturation, lightness);
|
|
198678
199591
|
}
|
|
198679
|
-
function
|
|
198680
|
-
|
|
198681
|
-
|
|
198682
|
-
|
|
198683
|
-
|
|
198684
|
-
|
|
198685
|
-
|
|
198686
|
-
|
|
198687
|
-
|
|
198688
|
-
|
|
198689
|
-
|
|
198690
|
-
|
|
198691
|
-
|
|
199592
|
+
function withTextContrast(color3, surfaces, lighter) {
|
|
199593
|
+
const meets = (candidate) => surfaces.every((surface) => wcagContrast(candidate, surface) >= TEXT_MINIMUM_WCAG_CONTRAST);
|
|
199594
|
+
if (meets(color3))
|
|
199595
|
+
return color3;
|
|
199596
|
+
const { h, s, l: l3 } = okhslOf(color3);
|
|
199597
|
+
const at4 = (lightness) => okhslColor(h, s, lightness);
|
|
199598
|
+
const extreme = lighter ? 1 : 0;
|
|
199599
|
+
if (!meets(at4(extreme)))
|
|
199600
|
+
return at4(extreme);
|
|
199601
|
+
let [low, high] = [l3, extreme];
|
|
199602
|
+
for (let index4 = 0; index4 < 20; index4++) {
|
|
199603
|
+
const middle = (low + high) / 2;
|
|
199604
|
+
if (meets(at4(middle)))
|
|
199605
|
+
high = middle;
|
|
199606
|
+
else
|
|
199607
|
+
low = middle;
|
|
198692
199608
|
}
|
|
198693
|
-
|
|
199609
|
+
return at4(high);
|
|
198694
199610
|
}
|
|
198695
|
-
function
|
|
198696
|
-
|
|
198697
|
-
|
|
198698
|
-
|
|
198699
|
-
|
|
198700
|
-
|
|
198701
|
-
|
|
198702
|
-
const { r, g, b: b2 } = hexToRgb2(color3);
|
|
198703
|
-
return `\x1B[48;2;${r};${g};${b2}m`;
|
|
198704
|
-
} else {
|
|
198705
|
-
const index4 = hexTo256(color3);
|
|
198706
|
-
return `\x1B[48;5;${index4}m`;
|
|
199611
|
+
function indexedColors(saturation, appearance) {
|
|
199612
|
+
const colors = {};
|
|
199613
|
+
const dim = [];
|
|
199614
|
+
for (const [token, familyName] of Object.entries(TOKEN_FAMILIES)) {
|
|
199615
|
+
if (PANELS.includes(token)) {
|
|
199616
|
+
colors[token] = "";
|
|
199617
|
+
continue;
|
|
198707
199618
|
}
|
|
199619
|
+
const neutral = familyName === "neutral";
|
|
199620
|
+
colors[token] = !neutral && saturation > 0 ? TOKEN_SLOTS[token] ?? FAMILIES[familyName].slot : "";
|
|
199621
|
+
if (neutral && !FOREGROUND_TOKENS.includes(token))
|
|
199622
|
+
dim.push(token);
|
|
198708
199623
|
}
|
|
198709
|
-
|
|
199624
|
+
return { colors, dim, appearance };
|
|
198710
199625
|
}
|
|
199626
|
+
|
|
199627
|
+
// ../node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.js
|
|
199628
|
+
var themeJsonValidator;
|
|
198711
199629
|
function resolveVarRefs(value, vars, visited2 = /* @__PURE__ */ new Set()) {
|
|
198712
|
-
if (typeof value === "number" || value === "" || value.startsWith("#")) {
|
|
199630
|
+
if (typeof value === "number" || value === "" || value.startsWith("#") || /^ok(lch|hsl)\(/i.test(value)) {
|
|
198713
199631
|
return value;
|
|
198714
199632
|
}
|
|
198715
199633
|
if (visited2.has(value)) {
|
|
@@ -198738,50 +199656,135 @@ function withThemeColorFallbacks(colors) {
|
|
|
198738
199656
|
searchMatchText: colors.searchMatchText ?? colors.text
|
|
198739
199657
|
};
|
|
198740
199658
|
}
|
|
199659
|
+
var terminalColors = {};
|
|
199660
|
+
var terminalColorsPending = false;
|
|
199661
|
+
var terminalColorScheme;
|
|
199662
|
+
var GUESSED_DEFAULT_COLORS = {
|
|
199663
|
+
dark: { foreground: parseColor("#e5e5e7"), background: parseColor("#000000") },
|
|
199664
|
+
light: { foreground: parseColor("#000000"), background: parseColor("#ffffff") }
|
|
199665
|
+
};
|
|
199666
|
+
function averageLightness(colors) {
|
|
199667
|
+
const fixed = colors.filter((color3) => color3.kind !== "indexed" || color3.index >= 16);
|
|
199668
|
+
if (fixed.length === 0)
|
|
199669
|
+
return void 0;
|
|
199670
|
+
return fixed.reduce((sum, color3) => sum + colorToOklch(color3).l, 0) / fixed.length;
|
|
199671
|
+
}
|
|
199672
|
+
function detectAppearance(foregrounds, backgrounds) {
|
|
199673
|
+
const fg = averageLightness(foregrounds);
|
|
199674
|
+
const bg = averageLightness(backgrounds);
|
|
199675
|
+
if (fg !== void 0 && bg !== void 0)
|
|
199676
|
+
return bg < fg ? "dark" : "light";
|
|
199677
|
+
if (bg !== void 0)
|
|
199678
|
+
return bg < 0.5 ? "dark" : "light";
|
|
199679
|
+
if (fg !== void 0)
|
|
199680
|
+
return fg > 0.5 ? "dark" : "light";
|
|
199681
|
+
return void 0;
|
|
199682
|
+
}
|
|
198741
199683
|
var Theme = class {
|
|
198742
199684
|
name;
|
|
198743
199685
|
sourcePath;
|
|
198744
199686
|
sourceInfo;
|
|
198745
|
-
fgColors;
|
|
198746
|
-
bgColors;
|
|
198747
199687
|
mode;
|
|
199688
|
+
// Precomputed escape sequences keep fg()/bg() on the render hot path to a lookup and concat.
|
|
199689
|
+
fgAnsi = /* @__PURE__ */ new Map();
|
|
199690
|
+
bgAnsi = /* @__PURE__ */ new Map();
|
|
199691
|
+
// Tokens set to "" have no color of their own; `colors` fills them from the terminal defaults.
|
|
199692
|
+
concreteColors = {};
|
|
199693
|
+
defaultForegroundTokens = [];
|
|
199694
|
+
defaultBackgroundTokens = [];
|
|
199695
|
+
// Foreground tokens rendered faint (SGR 2) on top of their color.
|
|
199696
|
+
dimTokens;
|
|
199697
|
+
ownAppearance;
|
|
199698
|
+
resolvedColors;
|
|
198748
199699
|
constructor(fgColors, bgColors, mode, options = {}) {
|
|
198749
199700
|
this.name = options.name;
|
|
198750
199701
|
this.sourcePath = options.sourcePath;
|
|
198751
199702
|
this.sourceInfo = options.sourceInfo;
|
|
198752
199703
|
this.mode = mode;
|
|
198753
|
-
this.
|
|
198754
|
-
const
|
|
199704
|
+
this.dimTokens = new Set(options.dim);
|
|
199705
|
+
const foregrounds = {
|
|
198755
199706
|
...fgColors,
|
|
198756
199707
|
scrollbarTrack: fgColors.scrollbarTrack ?? fgColors.muted,
|
|
198757
199708
|
scrollbarThumb: fgColors.scrollbarThumb ?? fgColors.text,
|
|
198758
199709
|
thinkingMax: fgColors.thinkingMax ?? fgColors.thinkingXhigh,
|
|
198759
199710
|
searchMatchText: fgColors.searchMatchText ?? fgColors.text
|
|
198760
199711
|
};
|
|
198761
|
-
|
|
198762
|
-
|
|
198763
|
-
|
|
198764
|
-
|
|
198765
|
-
|
|
198766
|
-
|
|
198767
|
-
|
|
199712
|
+
const backgrounds = { ...bgColors, searchMatchBg: bgColors.searchMatchBg ?? bgColors.selectedBg };
|
|
199713
|
+
const concreteForegrounds = [];
|
|
199714
|
+
const concreteBackgrounds = [];
|
|
199715
|
+
const addToken = (token, value, isBackground) => {
|
|
199716
|
+
if (value === "") {
|
|
199717
|
+
(isBackground ? this.defaultBackgroundTokens : this.defaultForegroundTokens).push(token);
|
|
199718
|
+
return isBackground ? "\x1B[49m" : "\x1B[39m";
|
|
199719
|
+
}
|
|
199720
|
+
const color3 = parseColor(value);
|
|
199721
|
+
this.concreteColors[token] = color3;
|
|
199722
|
+
(isBackground ? concreteBackgrounds : concreteForegrounds).push(color3);
|
|
199723
|
+
return isBackground ? backgroundAnsi(color3, mode) : foregroundAnsi(color3, mode);
|
|
198768
199724
|
};
|
|
198769
|
-
for (const [
|
|
198770
|
-
this.
|
|
199725
|
+
for (const [token, value] of Object.entries(foregrounds)) {
|
|
199726
|
+
this.fgAnsi.set(token, addToken(token, value, false));
|
|
199727
|
+
}
|
|
199728
|
+
for (const [token, value] of Object.entries(backgrounds)) {
|
|
199729
|
+
this.bgAnsi.set(token, addToken(token, value, true));
|
|
198771
199730
|
}
|
|
199731
|
+
this.ownAppearance = options.appearance ?? detectAppearance(concreteForegrounds, concreteBackgrounds);
|
|
199732
|
+
}
|
|
199733
|
+
/**
|
|
199734
|
+
* The background the theme is designed for: declared in the theme JSON, detected from its colors,
|
|
199735
|
+
* or, for themes without usable colors, the terminal's appearance.
|
|
199736
|
+
*/
|
|
199737
|
+
get appearance() {
|
|
199738
|
+
return this.ownAppearance ?? getTerminalTheme();
|
|
199739
|
+
}
|
|
199740
|
+
/**
|
|
199741
|
+
* Concrete colors for all tokens. Tokens set to "" (terminal default) use the terminal's reported
|
|
199742
|
+
* default colors, or a guess based on `appearance` when the terminal did not report them. Faint
|
|
199743
|
+
* tokens are approximated by mixing their color toward the background.
|
|
199744
|
+
*/
|
|
199745
|
+
get colors() {
|
|
199746
|
+
const terminal = terminalColors;
|
|
199747
|
+
if (this.resolvedColors?.terminal !== terminal) {
|
|
199748
|
+
const guess = GUESSED_DEFAULT_COLORS[this.appearance];
|
|
199749
|
+
const toColor = (rgb, fallback) => rgb ? rgbColor(rgb.r, rgb.g, rgb.b) : fallback;
|
|
199750
|
+
const foreground = toColor(terminal.foreground, guess.foreground);
|
|
199751
|
+
const background = toColor(terminal.background, guess.background);
|
|
199752
|
+
const colors = { ...this.concreteColors };
|
|
199753
|
+
for (const token of this.defaultForegroundTokens)
|
|
199754
|
+
colors[token] = foreground;
|
|
199755
|
+
for (const token of this.defaultBackgroundTokens)
|
|
199756
|
+
colors[token] = background;
|
|
199757
|
+
for (const token of this.dimTokens) {
|
|
199758
|
+
const color3 = colors[token];
|
|
199759
|
+
if (color3)
|
|
199760
|
+
colors[token] = mixColors(color3, background, 0.4);
|
|
199761
|
+
}
|
|
199762
|
+
this.resolvedColors = { terminal, colors: Object.freeze(colors) };
|
|
199763
|
+
}
|
|
199764
|
+
return this.resolvedColors.colors;
|
|
199765
|
+
}
|
|
199766
|
+
style(text7, options) {
|
|
199767
|
+
const { fg, bg } = options;
|
|
199768
|
+
if (typeof fg === "string" && this.dimTokens.has(fg))
|
|
199769
|
+
options = { ...options, dim: true };
|
|
199770
|
+
return styleTextWithAnsi(text7, fg === void 0 ? void 0 : typeof fg === "string" ? this.tokenAnsi(this.fgAnsi, fg) : foregroundAnsi(fg, this.mode), bg === void 0 ? void 0 : typeof bg === "string" ? this.tokenAnsi(this.bgAnsi, bg) : backgroundAnsi(bg, this.mode), options);
|
|
198772
199771
|
}
|
|
198773
199772
|
fg(color3, text7) {
|
|
198774
|
-
const ansi = this.
|
|
198775
|
-
if (
|
|
198776
|
-
|
|
199773
|
+
const ansi = this.tokenAnsi(this.fgAnsi, color3);
|
|
199774
|
+
if (this.dimTokens.has(color3))
|
|
199775
|
+
return `${ansi}\x1B[2m${text7}\x1B[22;39m`;
|
|
198777
199776
|
return `${ansi}${text7}\x1B[39m`;
|
|
198778
199777
|
}
|
|
198779
199778
|
bg(color3, text7) {
|
|
198780
|
-
const ansi = this.
|
|
198781
|
-
if (!ansi)
|
|
198782
|
-
throw new Error(`Unknown theme background color: ${color3}`);
|
|
199779
|
+
const ansi = this.tokenAnsi(this.bgAnsi, color3);
|
|
198783
199780
|
return `${ansi}${text7}\x1B[49m`;
|
|
198784
199781
|
}
|
|
199782
|
+
tokenAnsi(ansi, token) {
|
|
199783
|
+
const value = ansi.get(token);
|
|
199784
|
+
if (value === void 0)
|
|
199785
|
+
throw new Error(`Unknown theme color: ${token}`);
|
|
199786
|
+
return value;
|
|
199787
|
+
}
|
|
198785
199788
|
bold(text7) {
|
|
198786
199789
|
return source_default.bold(text7);
|
|
198787
199790
|
}
|
|
@@ -198797,17 +199800,13 @@ var Theme = class {
|
|
|
198797
199800
|
strikethrough(text7) {
|
|
198798
199801
|
return source_default.strikethrough(text7);
|
|
198799
199802
|
}
|
|
199803
|
+
/** Opening escape sequence for a foreground token. Faint tokens include SGR 2, which `\x1b[22m` closes. */
|
|
198800
199804
|
getFgAnsi(color3) {
|
|
198801
|
-
const ansi = this.
|
|
198802
|
-
|
|
198803
|
-
throw new Error(`Unknown theme color: ${color3}`);
|
|
198804
|
-
return ansi;
|
|
199805
|
+
const ansi = this.tokenAnsi(this.fgAnsi, color3);
|
|
199806
|
+
return this.dimTokens.has(color3) ? `${ansi}\x1B[2m` : ansi;
|
|
198805
199807
|
}
|
|
198806
199808
|
getBgAnsi(color3) {
|
|
198807
|
-
|
|
198808
|
-
if (!ansi)
|
|
198809
|
-
throw new Error(`Unknown theme background color: ${color3}`);
|
|
198810
|
-
return ansi;
|
|
199809
|
+
return this.tokenAnsi(this.bgAnsi, color3);
|
|
198811
199810
|
}
|
|
198812
199811
|
getColorMode() {
|
|
198813
199812
|
return this.mode;
|
|
@@ -198849,22 +199848,22 @@ function getBuiltinThemes() {
|
|
|
198849
199848
|
}
|
|
198850
199849
|
return BUILTIN_THEMES;
|
|
198851
199850
|
}
|
|
198852
|
-
function parseThemeJson(label,
|
|
199851
|
+
function parseThemeJson(label, json2) {
|
|
198853
199852
|
if (themeJsonValidator)
|
|
198854
|
-
return themeJsonValidator(label,
|
|
198855
|
-
if (typeof
|
|
199853
|
+
return themeJsonValidator(label, json2);
|
|
199854
|
+
if (typeof json2 !== "object" || json2 === null || !("colors" in json2)) {
|
|
198856
199855
|
throw new Error(`Invalid theme "${label}": expected an object with a "colors" map.`);
|
|
198857
199856
|
}
|
|
198858
|
-
return
|
|
199857
|
+
return json2;
|
|
198859
199858
|
}
|
|
198860
199859
|
function parseThemeJsonContent(label, content3) {
|
|
198861
|
-
let
|
|
199860
|
+
let json2;
|
|
198862
199861
|
try {
|
|
198863
|
-
|
|
199862
|
+
json2 = JSON.parse(stripBom(content3));
|
|
198864
199863
|
} catch (error) {
|
|
198865
199864
|
throw new Error(`Failed to parse theme ${label}: ${error}`);
|
|
198866
199865
|
}
|
|
198867
|
-
return parseThemeJson(label,
|
|
199866
|
+
return parseThemeJson(label, json2);
|
|
198868
199867
|
}
|
|
198869
199868
|
function loadThemeJson(name) {
|
|
198870
199869
|
const builtinThemes = getBuiltinThemes();
|
|
@@ -198887,33 +199886,53 @@ function loadThemeJson(name) {
|
|
|
198887
199886
|
const content3 = fs28.readFileSync(themePath, "utf-8");
|
|
198888
199887
|
return parseThemeJsonContent(name, content3);
|
|
198889
199888
|
}
|
|
198890
|
-
|
|
198891
|
-
|
|
198892
|
-
|
|
199889
|
+
var BACKGROUND_TOKENS = /* @__PURE__ */ new Set([
|
|
199890
|
+
"selectedBg",
|
|
199891
|
+
"searchMatchBg",
|
|
199892
|
+
"userMessageBg",
|
|
199893
|
+
"customMessageBg",
|
|
199894
|
+
"toolPendingBg",
|
|
199895
|
+
"toolSuccessBg",
|
|
199896
|
+
"toolErrorBg"
|
|
199897
|
+
]);
|
|
199898
|
+
function splitThemeColors(colors) {
|
|
198893
199899
|
const fgColors = {};
|
|
198894
199900
|
const bgColors = {};
|
|
198895
|
-
const
|
|
198896
|
-
|
|
198897
|
-
"searchMatchBg",
|
|
198898
|
-
"userMessageBg",
|
|
198899
|
-
"customMessageBg",
|
|
198900
|
-
"toolPendingBg",
|
|
198901
|
-
"toolSuccessBg",
|
|
198902
|
-
"toolErrorBg"
|
|
198903
|
-
]);
|
|
198904
|
-
for (const [key, value] of Object.entries(resolvedColors)) {
|
|
198905
|
-
if (bgColorKeys.has(key)) {
|
|
199901
|
+
for (const [key, value] of Object.entries(colors)) {
|
|
199902
|
+
if (BACKGROUND_TOKENS.has(key)) {
|
|
198906
199903
|
bgColors[key] = value;
|
|
198907
199904
|
} else {
|
|
198908
199905
|
fgColors[key] = value;
|
|
198909
199906
|
}
|
|
198910
199907
|
}
|
|
199908
|
+
return { fgColors, bgColors };
|
|
199909
|
+
}
|
|
199910
|
+
function createTheme(themeJson, mode, sourcePath) {
|
|
199911
|
+
const colorMode = mode ?? getTerminalColorMode();
|
|
199912
|
+
const resolvedColors = resolveThemeColors(withThemeColorFallbacks(themeJson.colors), themeJson.vars);
|
|
199913
|
+
const { fgColors, bgColors } = splitThemeColors(resolvedColors);
|
|
198911
199914
|
return new Theme(fgColors, bgColors, colorMode, {
|
|
198912
199915
|
name: themeJson.name,
|
|
198913
|
-
sourcePath
|
|
199916
|
+
sourcePath,
|
|
199917
|
+
appearance: themeJson.appearance
|
|
199918
|
+
});
|
|
199919
|
+
}
|
|
199920
|
+
function createSystemTheme(mode) {
|
|
199921
|
+
const generated = generateSystemThemeColors({
|
|
199922
|
+
...terminalColors,
|
|
199923
|
+
saturation: terminalColorsPending ? 0 : 1,
|
|
199924
|
+
appearanceHint: getTerminalTheme()
|
|
199925
|
+
});
|
|
199926
|
+
const { fgColors, bgColors } = splitThemeColors(generated.colors);
|
|
199927
|
+
return new Theme(fgColors, bgColors, mode ?? getTerminalColorMode(), {
|
|
199928
|
+
name: SYSTEM_THEME_NAME,
|
|
199929
|
+
appearance: generated.appearance,
|
|
199930
|
+
dim: generated.dim
|
|
198914
199931
|
});
|
|
198915
199932
|
}
|
|
198916
199933
|
function loadTheme(name, mode) {
|
|
199934
|
+
if (name === SYSTEM_THEME_NAME)
|
|
199935
|
+
return createSystemTheme(mode);
|
|
198917
199936
|
const registeredTheme = registeredThemes.get(name);
|
|
198918
199937
|
if (registeredTheme) {
|
|
198919
199938
|
return registeredTheme;
|
|
@@ -198928,6 +199947,24 @@ function getThemeByName(name) {
|
|
|
198928
199947
|
return void 0;
|
|
198929
199948
|
}
|
|
198930
199949
|
}
|
|
199950
|
+
function detectColorFgBgTheme(env2 = process.env) {
|
|
199951
|
+
const bg = env2.COLORFGBG?.split(";").at(-1)?.trim();
|
|
199952
|
+
if (!bg || !/^\d{1,2}$/.test(bg))
|
|
199953
|
+
return void 0;
|
|
199954
|
+
const index4 = Number(bg);
|
|
199955
|
+
if (index4 > 15)
|
|
199956
|
+
return void 0;
|
|
199957
|
+
return index4 <= 6 || index4 === 8 ? "dark" : "light";
|
|
199958
|
+
}
|
|
199959
|
+
function detectTerminalTheme(colors = {}, reportedScheme, env2 = process.env) {
|
|
199960
|
+
const { background, foreground } = colors;
|
|
199961
|
+
if (background)
|
|
199962
|
+
return terminalAppearance(background, foreground);
|
|
199963
|
+
return reportedScheme ?? detectColorFgBgTheme(env2) ?? "dark";
|
|
199964
|
+
}
|
|
199965
|
+
function getTerminalTheme() {
|
|
199966
|
+
return detectTerminalTheme(terminalColors, terminalColorScheme);
|
|
199967
|
+
}
|
|
198931
199968
|
var THEME_KEY = /* @__PURE__ */ Symbol.for("@earendil-works/pi-coding-agent:theme");
|
|
198932
199969
|
var theme = new Proxy({}, {
|
|
198933
199970
|
get(_target, prop) {
|
|
@@ -198949,14 +199986,19 @@ function cssBackground(ansi) {
|
|
|
198949
199986
|
function cssColor(ansi) {
|
|
198950
199987
|
return /style="(?:[^"]*;)?color:([^;"]+)/.exec(ansiLinesToHtml([`${ansi}x`]))?.[1];
|
|
198951
199988
|
}
|
|
199989
|
+
function foregroundAnsi2(theme2, role) {
|
|
199990
|
+
try {
|
|
199991
|
+
return theme2.getFgAnsi(role);
|
|
199992
|
+
} catch {
|
|
199993
|
+
return void 0;
|
|
199994
|
+
}
|
|
199995
|
+
}
|
|
198952
199996
|
function lightCounterparts(dark, light) {
|
|
198953
199997
|
const pairs = /* @__PURE__ */ new Map();
|
|
198954
199998
|
if (light === void 0) return pairs;
|
|
198955
|
-
const
|
|
198956
|
-
|
|
198957
|
-
|
|
198958
|
-
const darkCss = cssColor(ansi);
|
|
198959
|
-
const lightAnsi = lightColors.get(role);
|
|
199999
|
+
for (const role of Object.keys(dark.colors)) {
|
|
200000
|
+
const darkCss = cssColor(foregroundAnsi2(dark, role) ?? "");
|
|
200001
|
+
const lightAnsi = foregroundAnsi2(light, role);
|
|
198960
200002
|
const lightCss = lightAnsi === void 0 ? void 0 : cssColor(lightAnsi);
|
|
198961
200003
|
if (darkCss === void 0 || lightCss === void 0 || darkCss === lightCss || pairs.has(darkCss)) continue;
|
|
198962
200004
|
pairs.set(darkCss, lightCss);
|
|
@@ -200602,8 +201644,8 @@ function cacheControlFor(url) {
|
|
|
200602
201644
|
}
|
|
200603
201645
|
|
|
200604
201646
|
// ../server/src/index.ts
|
|
200605
|
-
var VERSION2 = true ? "0.32.
|
|
200606
|
-
var PI_SDK_VERSION = true ? "0.
|
|
201647
|
+
var VERSION2 = true ? "0.32.3" : "dev";
|
|
201648
|
+
var PI_SDK_VERSION = true ? "0.99.1" : readInstalledPiSdkVersion();
|
|
200607
201649
|
var LAUNCH_DIR = process.env.INIT_CWD ?? process.cwd();
|
|
200608
201650
|
function complain(error) {
|
|
200609
201651
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -201032,7 +202074,7 @@ app.get("/files/raw", async (req, reply) => {
|
|
|
201032
202074
|
} catch (error) {
|
|
201033
202075
|
if (error instanceof FileBrowserError) {
|
|
201034
202076
|
if (error.reason === "too-large") {
|
|
201035
|
-
const limit =
|
|
202077
|
+
const limit = rawFileLimit(relPath, config.pdf.maxBytes);
|
|
201036
202078
|
return reply.code(413).send({ error: error.reason, limit });
|
|
201037
202079
|
}
|
|
201038
202080
|
return reply.code(404).send({ error: error.reason });
|