@celljs/ta-glance 4.30.0 → 4.31.0

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.
@@ -1,3 +1,40 @@
1
+ // ../ta-protocol/esm/common/glance-protocol.js
2
+ var NAME = "@celljs/ta-glance";
3
+ var LANGUAGE = "ta-glance";
4
+ var GLANCE_ICONS = [
5
+ "Zap",
6
+ "Gauge",
7
+ "Timer",
8
+ "Cpu",
9
+ "MemoryStick",
10
+ "HardDrive",
11
+ "TrendingUp",
12
+ "TrendingDown",
13
+ "Code",
14
+ "GitBranch",
15
+ "Bug",
16
+ "FlaskConical",
17
+ "Package",
18
+ "SquareTerminal",
19
+ "Database",
20
+ "Server",
21
+ "Globe",
22
+ "Shield",
23
+ "Lock",
24
+ "KeyRound",
25
+ "Users",
26
+ "MessageCircle",
27
+ "Smartphone",
28
+ "Laptop",
29
+ "Rocket",
30
+ "Wrench",
31
+ "Lightbulb",
32
+ "Coins",
33
+ "Calendar",
34
+ "FileText",
35
+ "Sparkles"
36
+ ];
37
+
1
38
  // ../ta-protocol/esm/common/ta-extension-host.js
2
39
  var TA_WEBHOOK_MAX_BYTES = 256 * 1024;
3
40
  var TA_HOST_EVENT = "ta:host";
@@ -108,12 +145,14 @@ var TaAskUtil;
108
145
  }
109
146
  })(TaAskUtil || (TaAskUtil = {}));
110
147
 
111
- // web-src/glance-json.ts
148
+ // ../ta-protocol/esm/common/glance-json.js
112
149
  var GlanceJson;
113
- ((GlanceJson) => {
150
+ (function(GlanceJson2) {
114
151
  const TRIES = 40;
115
152
  const CONTROLS = { "\n": "\\n", "\r": "\\r", "\t": "\\t" };
116
153
  const CURLY = "“”";
154
+ const FULL_WIDTH = { ":": ":", ",": "," };
155
+ const WORDS = { true: "true", false: "false", null: "null", True: "true", False: "false", None: "null" };
117
156
  function parse(text) {
118
157
  const source = text.trim().replace(/,\s*([}\]])/g, "$1");
119
158
  if (!source) {
@@ -121,12 +160,12 @@ var GlanceJson;
121
160
  }
122
161
  try {
123
162
  return JSON.parse(source);
124
- } catch {
163
+ } catch (_a) {
125
164
  const balanced = balance(source);
126
165
  if (!balanced.open.length && !balanced.inString) {
127
166
  try {
128
167
  return JSON.parse(balanced.text.replace(/,\s*([}\]])/g, "$1"));
129
- } catch {}
168
+ } catch (_b) {}
130
169
  }
131
170
  }
132
171
  let end = source.length;
@@ -135,13 +174,13 @@ var GlanceJson;
135
174
  if (closed !== undefined) {
136
175
  try {
137
176
  return JSON.parse(closed);
138
- } catch {}
177
+ } catch (_c) {}
139
178
  }
140
179
  end = Math.max(source.lastIndexOf(",", end - 1), source.lastIndexOf("{", end - 1) + 1, source.lastIndexOf("[", end - 1) + 1);
141
180
  }
142
181
  return;
143
182
  }
144
- GlanceJson.parse = parse;
183
+ GlanceJson2.parse = parse;
145
184
  function close(text) {
146
185
  const balanced = balance(text);
147
186
  if (!balanced || !balanced.open.length && !balanced.inString && balanced.text === text) {
@@ -159,8 +198,11 @@ var GlanceJson;
159
198
  return body + open.reverse().join("");
160
199
  }
161
200
  function balance(text) {
201
+ var _a, _b;
202
+ var _c, _d, _e;
162
203
  const open = [];
163
204
  let inString = false;
205
+ let quote = "";
164
206
  let escaped = false;
165
207
  let last = "";
166
208
  let out = "";
@@ -169,8 +211,25 @@ var GlanceJson;
169
211
  if (inString) {
170
212
  if (escaped) {
171
213
  escaped = false;
214
+ if (char === "'") {
215
+ out = `${out.slice(0, -1)}'`;
216
+ continue;
217
+ }
172
218
  } else if (char === "\\") {
173
219
  escaped = true;
220
+ } else if (quote === "'") {
221
+ if (char === "'" && ends(text, index)) {
222
+ inString = false;
223
+ last = '"';
224
+ out += '"';
225
+ } else if (char === '"') {
226
+ out += "\\\"";
227
+ } else if (char < " ") {
228
+ out += (_c = CONTROLS[char]) !== null && _c !== undefined ? _c : `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`;
229
+ } else {
230
+ out += char;
231
+ }
232
+ continue;
174
233
  } else if (char === '"' || char === CURLY[1]) {
175
234
  if (char === '"' && !ends(text, index)) {
176
235
  out += "\\\"";
@@ -185,7 +244,7 @@ var GlanceJson;
185
244
  out += '"';
186
245
  continue;
187
246
  } else if (char < " ") {
188
- out += CONTROLS[char] ?? `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`;
247
+ out += (_d = CONTROLS[char]) !== null && _d !== undefined ? _d : `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`;
189
248
  continue;
190
249
  }
191
250
  out += char;
@@ -195,15 +254,47 @@ var GlanceJson;
195
254
  out += char;
196
255
  continue;
197
256
  }
198
- const starts = char === '"' || CURLY.includes(char) || char === "{" || char === "[";
257
+ if (char === "/" && (text[index + 1] === "/" || text[index + 1] === "*")) {
258
+ const end = text[index + 1] === "/" ? text.indexOf(`
259
+ `, index) : text.indexOf("*/", index + 2);
260
+ index = end < 0 ? text.length : text[index + 1] === "/" ? end - 1 : end + 1;
261
+ continue;
262
+ }
263
+ const number = (_a = /^-?\d+(?:\.\d*)?(?:[eE][+-]?\d*)?/.exec(text.slice(index, index + 64))) === null || _a === undefined ? undefined : _a[0];
264
+ if (number) {
265
+ if (/["}\]\w.]/.test(last)) {
266
+ out += ",";
267
+ }
268
+ out += number;
269
+ last = "0";
270
+ index += number.length - 1;
271
+ continue;
272
+ }
273
+ const word = (_b = /^[A-Za-z_$][\w$]*/.exec(text.slice(index, index + 64))) === null || _b === undefined ? undefined : _b[0];
274
+ const starts = char === '"' || char === "'" || CURLY.includes(char) || char === "{" || char === "[" || !!word;
199
275
  if (starts && /["}\]\w.]/.test(last)) {
200
276
  out += ",";
201
277
  }
202
- if (char === '"' || CURLY.includes(char)) {
278
+ if (char === '"' || char === "'" || CURLY.includes(char)) {
203
279
  inString = true;
280
+ quote = char === "'" ? "'" : '"';
204
281
  out += '"';
205
282
  continue;
206
283
  }
284
+ if (word) {
285
+ const cut = index + word.length === text.length && Object.keys(WORDS).some((each) => each !== word && each.startsWith(word));
286
+ if (!cut) {
287
+ out += (_e = WORDS[word]) !== null && _e !== undefined ? _e : `"${word}"`;
288
+ last = '"';
289
+ }
290
+ index += word.length - 1;
291
+ continue;
292
+ }
293
+ if (FULL_WIDTH[char]) {
294
+ out += FULL_WIDTH[char];
295
+ last = FULL_WIDTH[char];
296
+ continue;
297
+ }
207
298
  if (char === "{" || char === "[") {
208
299
  open.push(char === "{" ? "}" : "]");
209
300
  } else if (char === "}" || char === "]") {
@@ -221,49 +312,12 @@ var GlanceJson;
221
312
  for (let next = index + 1;next < text.length; next++) {
222
313
  const char = text[next];
223
314
  if (char > " ") {
224
- return ",:}]".includes(char) || (char === '"' || CURLY.includes(char)) && /[\r\n]/.test(text.slice(index + 1, next));
315
+ return ",:}]/:,".includes(char) || (char === '"' || char === "'" || CURLY.includes(char)) && /[\r\n]/.test(text.slice(index + 1, next));
225
316
  }
226
317
  }
227
318
  return true;
228
319
  }
229
- })(GlanceJson ||= {});
230
-
231
- // web-src/glance-protocol.ts
232
- var NAME = "@celljs/ta-glance";
233
- var LANGUAGE = "ta-glance";
234
- var GLANCE_ICONS = [
235
- "Zap",
236
- "Gauge",
237
- "Timer",
238
- "Cpu",
239
- "MemoryStick",
240
- "HardDrive",
241
- "TrendingUp",
242
- "TrendingDown",
243
- "Code",
244
- "GitBranch",
245
- "Bug",
246
- "FlaskConical",
247
- "Package",
248
- "SquareTerminal",
249
- "Database",
250
- "Server",
251
- "Globe",
252
- "Shield",
253
- "Lock",
254
- "KeyRound",
255
- "Users",
256
- "MessageCircle",
257
- "Smartphone",
258
- "Laptop",
259
- "Rocket",
260
- "Wrench",
261
- "Lightbulb",
262
- "Coins",
263
- "Calendar",
264
- "FileText",
265
- "Sparkles"
266
- ];
320
+ })(GlanceJson || (GlanceJson = {}));
267
321
 
268
322
  // ../ta-protocol/esm/common/figure-protocol.js
269
323
  var TaFigure;
@@ -287,11 +341,11 @@ ${JSON.stringify(spec)}
287
341
  TaFigure2.markdown = markdown;
288
342
  })(TaFigure || (TaFigure = {}));
289
343
 
290
- // web-src/glance-mermaid.ts
344
+ // ../ta-protocol/esm/common/glance-mermaid.js
291
345
  var SYNTAX = /[()[\]{}"<>|;#&@]/;
292
346
  var NODE = /(^|[\s;&>|-])([\w\u00c0-\uffff]+)(?:\[(?!["[(/\\])(.*?)\]|\((?!["([])(.*?)\)|\{(?!["{])(.*?)\})(?=\s*(?:$|;|&|-|=|\.|~|<|:::))/g;
293
347
  var GlanceMermaid;
294
- ((GlanceMermaid) => {
348
+ (function(GlanceMermaid2) {
295
349
  function repair(source) {
296
350
  const body = source.trim().replace(/^\x60{3,}\s*mermaid[^\n]*\n/i, "").replace(/\n\x60{3,}\s*$/, "");
297
351
  if (!/^\s*(?:graph|flowchart)\b/i.test(body)) {
@@ -299,7 +353,8 @@ var GlanceMermaid;
299
353
  }
300
354
  return body.split(`
301
355
  `).map((line) => line.replace(NODE, (whole, before, name, square, round, curly) => {
302
- const label = square ?? round ?? curly ?? "";
356
+ var _a, _b;
357
+ const label = (_b = (_a = square !== null && square !== undefined ? square : round) !== null && _a !== undefined ? _a : curly) !== null && _b !== undefined ? _b : "";
303
358
  const open = square !== undefined ? "[" : round !== undefined ? "(" : "{";
304
359
  const close = square !== undefined ? "]" : round !== undefined ? ")" : "}";
305
360
  const shown = label.replace(/\\n/g, "<br/>");
@@ -310,10 +365,10 @@ var GlanceMermaid;
310
365
  })).join(`
311
366
  `);
312
367
  }
313
- GlanceMermaid.repair = repair;
314
- })(GlanceMermaid ||= {});
368
+ GlanceMermaid2.repair = repair;
369
+ })(GlanceMermaid || (GlanceMermaid = {}));
315
370
 
316
- // web-src/glance-spec.ts
371
+ // ../ta-protocol/esm/common/glance-spec.js
317
372
  var ITEMS = 12;
318
373
  var FOLDED = 40;
319
374
  var POINTS = 24;
@@ -322,6 +377,10 @@ var BLOCKS = 8;
322
377
  var OPTIONS = 8;
323
378
  var TEXT = 400;
324
379
  var MARKDOWN = 8000;
380
+ var BOARD_COLUMNS = 6;
381
+ var CELLS = 24;
382
+ var BOARD_ROWS = 8;
383
+ var CELL_LINES = 6;
325
384
  var STATUSES = ["done", "partial", "failed", "blocked", "info"];
326
385
  var QUIET = ["done", "info"];
327
386
  var TONES = ["good", "bad", "warn", "neutral"];
@@ -377,49 +436,55 @@ function icon(value) {
377
436
  return /^[A-Z][A-Za-z0-9]{0,39}$/.test(name) ? name : undefined;
378
437
  }
379
438
  function withIcon(value) {
380
- const name = icon(value?.icon);
439
+ const name = icon(value === null || value === undefined ? undefined : value.icon);
381
440
  return name ? { icon: name } : {};
382
441
  }
383
442
  function strings(value, max = ITEMS) {
384
- return items(value, (item) => text(item) ?? text(object(item)?.label) ?? text(object(item)?.text), max);
443
+ return items(value, (item) => {
444
+ var _a, _b;
445
+ var _c, _d;
446
+ return (_d = (_c = text(item)) !== null && _c !== undefined ? _c : text((_a = object(item)) === null || _a === undefined ? undefined : _a.label)) !== null && _d !== undefined ? _d : text((_b = object(item)) === null || _b === undefined ? undefined : _b.text);
447
+ }, max);
385
448
  }
386
449
  function numbers(value, max = POINTS) {
387
450
  return items(value, number, max);
388
451
  }
389
452
  function amount(entry) {
390
453
  const value = object(entry);
391
- const label = text(value?.label);
392
- const shown = number(value?.value);
454
+ const label = text(value === null || value === undefined ? undefined : value.label);
455
+ const shown = number(value === null || value === undefined ? undefined : value.value);
393
456
  return label && shown !== undefined ? { label, value: shown } : undefined;
394
457
  }
395
458
  function series(entry) {
459
+ var _a, _b;
396
460
  const value = object(entry);
397
- const values = numbers(Array.isArray(entry) ? entry : value?.values ?? value?.data);
398
- const label = text(value?.label ?? value?.name);
461
+ const values = numbers(Array.isArray(entry) ? entry : (_a = value === null || value === undefined ? undefined : value.values) !== null && _a !== undefined ? _a : value === null || value === undefined ? undefined : value.data);
462
+ const label = text((_b = value === null || value === undefined ? undefined : value.label) !== null && _b !== undefined ? _b : value === null || value === undefined ? undefined : value.name);
399
463
  return values.length ? { values, ...label ? { label } : {} } : undefined;
400
464
  }
401
465
  function stat(item) {
402
466
  const value = object(item);
403
- const label = text(value?.label);
404
- const shown = text(value?.value);
467
+ const label = text(value === null || value === undefined ? undefined : value.label);
468
+ const shown = text(value === null || value === undefined ? undefined : value.value);
405
469
  if (!label || shown === undefined) {
406
470
  return;
407
471
  }
408
- const tone = oneOf(value?.tone, TONES);
409
- const delta = text(value?.delta);
410
- const trend = numbers(value?.trend);
472
+ const tone = oneOf(value === null || value === undefined ? undefined : value.tone, TONES);
473
+ const delta = text(value === null || value === undefined ? undefined : value.delta);
474
+ const trend = numbers(value === null || value === undefined ? undefined : value.trend);
411
475
  return { label, value: shown, ...tone ? { tone } : {}, ...delta ? { delta } : {}, ...withIcon(value), ...trend.length > 1 ? { trend } : {} };
412
476
  }
413
477
  function change(item) {
478
+ var _a, _b, _c;
414
479
  const value = object(item);
415
- const path = text(value?.path ?? value?.file ?? item);
480
+ const path = text((_b = (_a = value === null || value === undefined ? undefined : value.path) !== null && _a !== undefined ? _a : value === null || value === undefined ? undefined : value.file) !== null && _b !== undefined ? _b : item);
416
481
  if (!path) {
417
482
  return;
418
483
  }
419
- const kind = oneOf(value?.kind, ["add", "edit", "delete"]) ?? "edit";
420
- const add = number(value?.add);
421
- const del = number(value?.del);
422
- const note = text(value?.note);
484
+ const kind = (_c = oneOf(value === null || value === undefined ? undefined : value.kind, ["add", "edit", "delete"])) !== null && _c !== undefined ? _c : "edit";
485
+ const add = number(value === null || value === undefined ? undefined : value.add);
486
+ const del = number(value === null || value === undefined ? undefined : value.del);
487
+ const note = text(value === null || value === undefined ? undefined : value.note);
423
488
  return {
424
489
  path,
425
490
  kind,
@@ -429,40 +494,89 @@ function change(item) {
429
494
  };
430
495
  }
431
496
  function step(item, partial) {
497
+ var _a, _b, _c, _d;
432
498
  const value = object(item);
433
- const shown = text(value?.text ?? value?.label ?? value?.title ?? item);
434
- return shown ? { text: shown, status: oneOf(value?.status, STEPS) ?? (partial ? "todo" : "done") } : undefined;
499
+ const shown = text((_c = (_b = (_a = value === null || value === undefined ? undefined : value.text) !== null && _a !== undefined ? _a : value === null || value === undefined ? undefined : value.label) !== null && _b !== undefined ? _b : value === null || value === undefined ? undefined : value.title) !== null && _c !== undefined ? _c : item);
500
+ return shown ? { text: shown, status: (_d = oneOf(value === null || value === undefined ? undefined : value.status, STEPS)) !== null && _d !== undefined ? _d : partial ? "todo" : "done" } : undefined;
435
501
  }
436
502
  function option(item) {
503
+ var _a;
437
504
  const value = object(item);
438
- const label = text(value?.label ?? item);
505
+ const label = text((_a = value === null || value === undefined ? undefined : value.label) !== null && _a !== undefined ? _a : item);
439
506
  if (!label) {
440
507
  return;
441
508
  }
442
- const detail = text(value?.detail);
509
+ const detail = text(value === null || value === undefined ? undefined : value.detail);
443
510
  return {
444
511
  label,
445
512
  ...detail ? { detail } : {},
446
- pros: strings(value?.pros, 4),
447
- cons: strings(value?.cons, 4),
448
- ...value?.recommended === true ? { recommended: true } : {},
513
+ pros: strings(value === null || value === undefined ? undefined : value.pros, 4),
514
+ cons: strings(value === null || value === undefined ? undefined : value.cons, 4),
515
+ ...(value === null || value === undefined ? undefined : value.recommended) === true ? { recommended: true } : {},
449
516
  ...withIcon(value)
450
517
  };
451
518
  }
452
519
  function note(item) {
520
+ var _a, _b;
453
521
  const value = object(item);
454
- const shown = text(value?.text ?? item);
455
- return shown ? { text: shown, tone: oneOf(value?.tone, NOTES) ?? "info", ...withIcon(value) } : undefined;
522
+ const shown = text((_a = value === null || value === undefined ? undefined : value.text) !== null && _a !== undefined ? _a : item);
523
+ return shown ? { text: shown, tone: (_b = oneOf(value === null || value === undefined ? undefined : value.tone, NOTES)) !== null && _b !== undefined ? _b : "info", ...withIcon(value) } : undefined;
456
524
  }
457
525
  function listItem(entry) {
526
+ var _a, _b;
458
527
  const value = object(entry);
459
- const shown = text(entry) ?? text(value?.text) ?? text(value?.label);
528
+ const shown = (_b = (_a = text(entry)) !== null && _a !== undefined ? _a : text(value === null || value === undefined ? undefined : value.text)) !== null && _b !== undefined ? _b : text(value === null || value === undefined ? undefined : value.label);
460
529
  return shown ? { text: shown, ...withIcon(value) } : undefined;
461
530
  }
531
+ function pair(value, max) {
532
+ const [first, second] = Array.isArray(value) ? value.map(number) : [];
533
+ return first !== undefined && second !== undefined && first >= 1 && second >= 1 ? [Math.min(Math.round(first), max[0]), Math.min(Math.round(second), max[1])] : undefined;
534
+ }
535
+ function cellLines(value) {
536
+ const written = typeof value === "string" ? value.split(`
537
+ `) : value;
538
+ return items(written, (line) => text(line, 80), CELL_LINES);
539
+ }
540
+ function cell(entry) {
541
+ var _a, _b, _c, _d, _e;
542
+ if (typeof entry === "string" || typeof entry === "number") {
543
+ return { lines: cellLines(String(entry)) };
544
+ }
545
+ const value = object(entry);
546
+ if (!value) {
547
+ return;
548
+ }
549
+ const title = text((_b = (_a = value.title) !== null && _a !== undefined ? _a : value.label) !== null && _b !== undefined ? _b : value.name, 40);
550
+ const corner = text((_c = value.corner) !== null && _c !== undefined ? _c : value.tag, 16);
551
+ const tone = oneOf(value.tone, TONES);
552
+ const at = pair(value.at, [Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY]);
553
+ const span = pair(value.span, [BOARD_ROWS, BOARD_COLUMNS]);
554
+ return {
555
+ lines: cellLines((_e = (_d = value.lines) !== null && _d !== undefined ? _d : value.items) !== null && _e !== undefined ? _e : value.text),
556
+ ...title ? { title } : {},
557
+ ...corner ? { corner } : {},
558
+ ...tone && tone !== "neutral" ? { tone } : {},
559
+ ...value.mark === true ? { mark: true } : {},
560
+ ...at ? { at } : {},
561
+ ...span && span[0] * span[1] > 1 ? { span } : {}
562
+ };
563
+ }
564
+ function boardColumns(cells) {
565
+ const area = cells.reduce((sum, one) => sum + (one.span ? one.span[0] * one.span[1] : 1), 0);
566
+ return area <= 4 ? area : Math.ceil(Math.sqrt(area));
567
+ }
568
+ function within(one, cols) {
569
+ const { at, span, ...rest } = one;
570
+ const kept = at && at[0] <= BOARD_ROWS && at[1] <= cols ? at : undefined;
571
+ const room = cols - (kept ? kept[1] : 1) + 1;
572
+ const taken = span ? [span[0], Math.min(span[1], room)] : undefined;
573
+ return { ...rest, ...kept ? { at: kept } : {}, ...taken && taken[0] * taken[1] > 1 ? { span: taken } : {} };
574
+ }
462
575
  function point(item) {
576
+ var _a, _b, _c, _d;
463
577
  const value = object(item);
464
- const head = text(value?.title ?? value?.label);
465
- const body = text(value?.detail ?? value?.note ?? value?.text ?? value?.description);
578
+ const head = text((_a = value === null || value === undefined ? undefined : value.title) !== null && _a !== undefined ? _a : value === null || value === undefined ? undefined : value.label);
579
+ const body = text((_d = (_c = (_b = value === null || value === undefined ? undefined : value.detail) !== null && _b !== undefined ? _b : value === null || value === undefined ? undefined : value.note) !== null && _c !== undefined ? _c : value === null || value === undefined ? undefined : value.text) !== null && _d !== undefined ? _d : value === null || value === undefined ? undefined : value.description);
466
580
  if (!value || !head) {
467
581
  return note(value ? { text: body } : item);
468
582
  }
@@ -473,8 +587,9 @@ function isPath(value) {
473
587
  }
474
588
  var LABELS = { before: "Before", after: "After" };
475
589
  function block(item, partial, labels) {
590
+ var _a;
476
591
  const made = blockOf(item, partial, labels);
477
- const fold = object(item)?.fold;
592
+ const fold = (_a = object(item)) === null || _a === undefined ? undefined : _a.fold;
478
593
  const words = fold === true ? "" : text(fold, 40);
479
594
  return made && words !== undefined ? { ...made, fold: words } : made;
480
595
  }
@@ -526,123 +641,149 @@ var KINDS = {
526
641
  followups: "next",
527
642
  markdown: "details",
528
643
  detail: "details",
529
- plot: "figure"
644
+ plot: "figure",
645
+ grid: "board",
646
+ matrix: "board",
647
+ palaces: "board",
648
+ houses: "board",
649
+ paipan: "board"
530
650
  };
531
651
  function mended(value, named, type) {
652
+ var _a, _b, _c, _d, _e, _f, _g;
532
653
  const list = [value.items, value.list, value.entries, value[named], value[type]].find(Array.isArray);
533
- const words = text(value.text) ?? text(value.content) ?? text(value.body);
654
+ const words = (_b = (_a = text(value.text)) !== null && _a !== undefined ? _a : text(value.content)) !== null && _b !== undefined ? _b : text(value.body);
534
655
  return {
535
656
  ...value,
536
657
  ...list ? { items: list } : type === "notes" && words ? { items: [words] } : {},
537
- markdown: value.markdown ?? value.content ?? value.text ?? value.body,
538
- mermaid: value.mermaid ?? value.code ?? value.source
658
+ markdown: (_e = (_d = (_c = value.markdown) !== null && _c !== undefined ? _c : value.content) !== null && _d !== undefined ? _d : value.text) !== null && _e !== undefined ? _e : value.body,
659
+ mermaid: (_g = (_f = value.mermaid) !== null && _f !== undefined ? _f : value.code) !== null && _g !== undefined ? _g : value.source
539
660
  };
540
661
  }
541
662
  function blockOf(item, partial, labels) {
663
+ var _a, _b, _c, _d, _e, _f;
542
664
  const raw = object(item);
543
- const named = typeof raw?.type === "string" ? raw.type.trim().toLowerCase().replace(/[\s_]+/g, "-") : undefined;
544
- const kind = named && typeof raw?.mermaid === "string" ? "diagram" : named && (KINDS[named] ?? named);
665
+ const named = typeof (raw === null || raw === undefined ? undefined : raw.type) === "string" ? raw.type.trim().toLowerCase().replace(/[\s_]+/g, "-") : undefined;
666
+ const kind = named && typeof (raw === null || raw === undefined ? undefined : raw.mermaid) === "string" ? "diagram" : named && ((_a = KINDS[named]) !== null && _a !== undefined ? _a : named);
545
667
  const value = raw && named && kind ? mended(raw, named, kind) : raw;
546
668
  const type = kind;
547
- const unit = text(value?.unit, 16);
669
+ const unit = text(value === null || value === undefined ? undefined : value.unit, 16);
548
670
  switch (type) {
549
671
  case "stats": {
550
- const list = items(value?.items, stat).slice(0, 6);
672
+ const list = items(value === null || value === undefined ? undefined : value.items, stat).slice(0, 6);
551
673
  return list.length ? { type, items: list, ...passed(list, CHECKS) ? { checks: true } : {} } : undefined;
552
674
  }
553
675
  case "changes": {
554
- const raw2 = Array.isArray(value?.items) ? value.items : [];
555
- const pathless = (entry) => typeof entry === "string" ? !isPath(entry) : !!object(entry) && !text(object(entry)?.path ?? object(entry)?.file);
676
+ const raw2 = Array.isArray(value === null || value === undefined ? undefined : value.items) ? value.items : [];
677
+ const pathless = (entry) => {
678
+ var _a2, _b2;
679
+ var _c2;
680
+ return typeof entry === "string" ? !isPath(entry) : !!object(entry) && !text((_c2 = (_a2 = object(entry)) === null || _a2 === undefined ? undefined : _a2.path) !== null && _c2 !== undefined ? _c2 : (_b2 = object(entry)) === null || _b2 === undefined ? undefined : _b2.file);
681
+ };
556
682
  if (raw2.length && raw2.every(pathless)) {
557
683
  const list2 = items(raw2, point);
558
684
  return list2.length ? { type: "notes", items: list2 } : undefined;
559
685
  }
560
- const list = items(value?.items, change, FOLDED);
686
+ const list = items(value === null || value === undefined ? undefined : value.items, change, FOLDED);
561
687
  return list.length ? { type, items: list } : undefined;
562
688
  }
563
689
  case "steps": {
564
- const list = items(value?.items, (entry) => step(entry, partial));
690
+ const list = items(value === null || value === undefined ? undefined : value.items, (entry) => step(entry, partial));
565
691
  return list.length ? { type, items: list } : undefined;
566
692
  }
567
693
  case "compare": {
568
- const list = items(value?.items, (entry) => {
694
+ const list = items(value === null || value === undefined ? undefined : value.items, (entry) => {
569
695
  const measure = object(entry);
570
- const label = text(measure?.label);
571
- const before = number(measure?.before);
572
- const after = number(measure?.after);
696
+ const label = text(measure === null || measure === undefined ? undefined : measure.label);
697
+ const before = number(measure === null || measure === undefined ? undefined : measure.before);
698
+ const after = number(measure === null || measure === undefined ? undefined : measure.after);
573
699
  return label && before !== undefined && after !== undefined ? { label, before, after } : undefined;
574
700
  });
575
- const better = oneOf(value?.better, ["lower", "higher"]) ?? "lower";
701
+ const better = (_b = oneOf(value === null || value === undefined ? undefined : value.better, ["lower", "higher"])) !== null && _b !== undefined ? _b : "lower";
576
702
  if (list.length) {
577
703
  return { type, better, items: list, ...unit ? { unit } : {} };
578
704
  }
579
- const rows = items(value?.items, (entry) => {
705
+ const rows = items(value === null || value === undefined ? undefined : value.items, (entry) => {
580
706
  const measure = object(entry);
581
- const label = text(measure?.label);
582
- const before = text(measure?.before);
583
- const after = text(measure?.after);
584
- return label && (before || after) ? [label, before ?? "", after ?? ""] : undefined;
707
+ const label = text(measure === null || measure === undefined ? undefined : measure.label);
708
+ const before = text(measure === null || measure === undefined ? undefined : measure.before);
709
+ const after = text(measure === null || measure === undefined ? undefined : measure.after);
710
+ return label && (before || after) ? [label, before !== null && before !== undefined ? before : "", after !== null && after !== undefined ? after : ""] : undefined;
585
711
  });
586
712
  return rows.length ? { type: "table", columns: ["", labels.before, labels.after], rows } : undefined;
587
713
  }
588
714
  case "bars": {
589
- const list = items(value?.items, amount, FOLDED);
715
+ const list = items(value === null || value === undefined ? undefined : value.items, amount, FOLDED);
590
716
  return list.length ? { type, items: list, ...unit ? { unit } : {} } : undefined;
591
717
  }
592
718
  case "line": {
593
- const points = items(value?.items, amount, POINTS);
594
- const lines = points.length ? [{ values: points.map((point2) => point2.value) }] : Array.isArray(value?.series) ? items(value.series, series, SERIES) : [series(value)].filter((line) => !!line);
595
- const labels2 = points.length ? points.map((point2) => point2.label) : strings(value?.labels, POINTS);
596
- const better = oneOf(value?.better, ["lower", "higher"]);
719
+ const points = items(value === null || value === undefined ? undefined : value.items, amount, POINTS);
720
+ const lines = points.length ? [{ values: points.map((point2) => point2.value) }] : Array.isArray(value === null || value === undefined ? undefined : value.series) ? items(value.series, series, SERIES) : [series(value)].filter((line) => !!line);
721
+ const labels2 = points.length ? points.map((point2) => point2.label) : strings(value === null || value === undefined ? undefined : value.labels, POINTS);
722
+ const better = oneOf(value === null || value === undefined ? undefined : value.better, ["lower", "higher"]);
597
723
  const drawn = lines.filter((line) => partial || line.values.length > 1);
598
724
  return drawn.length ? { type, labels: labels2, series: drawn, ...unit ? { unit } : {}, ...better ? { better } : {} } : undefined;
599
725
  }
600
726
  case "share": {
601
- const list = items(value?.items, amount, 6).filter((part) => part.value > 0);
727
+ const list = items(value === null || value === undefined ? undefined : value.items, amount, 6).filter((part) => part.value > 0);
602
728
  return list.length ? { type, items: list, ...unit ? { unit } : {} } : undefined;
603
729
  }
604
730
  case "flow": {
605
- const list = items(value?.items, listItem);
731
+ const list = items(value === null || value === undefined ? undefined : value.items, listItem);
606
732
  return list.length ? { type, items: list } : undefined;
607
733
  }
608
734
  case "diagram": {
609
- const mermaid = text(value?.mermaid, MARKDOWN);
735
+ const mermaid = text(value === null || value === undefined ? undefined : value.mermaid, MARKDOWN);
610
736
  return mermaid ? { type, mermaid: GlanceMermaid.repair(mermaid) } : undefined;
611
737
  }
612
738
  case "table": {
613
- const columns = items(value?.columns, (column) => text(column) ?? (typeof column === "string" ? "" : undefined), 6);
614
- const rows = items(value?.rows, (row) => Array.isArray(row) ? columns.map((_, index) => text(row[index]) ?? "") : undefined, FOLDED);
739
+ const columns = items(value === null || value === undefined ? undefined : value.columns, (column) => {
740
+ var _a2;
741
+ return (_a2 = text(column)) !== null && _a2 !== undefined ? _a2 : typeof column === "string" ? "" : undefined;
742
+ }, 6);
743
+ const rows = items(value === null || value === undefined ? undefined : value.rows, (row) => Array.isArray(row) ? columns.map((_, index) => {
744
+ var _a2;
745
+ return (_a2 = text(row[index])) !== null && _a2 !== undefined ? _a2 : "";
746
+ }) : undefined, FOLDED);
615
747
  return columns.length && rows.length ? { type, columns, rows } : undefined;
616
748
  }
749
+ case "board": {
750
+ const cells = items((_c = value === null || value === undefined ? undefined : value.cells) !== null && _c !== undefined ? _c : value === null || value === undefined ? undefined : value.items, cell, CELLS);
751
+ if (!cells.length) {
752
+ return;
753
+ }
754
+ const written = number((_d = value === null || value === undefined ? undefined : value.cols) !== null && _d !== undefined ? _d : value === null || value === undefined ? undefined : value.columns);
755
+ const cols = Math.min(BOARD_COLUMNS, Math.max(1, Math.round(written !== null && written !== undefined ? written : boardColumns(cells))));
756
+ return { type, cols, cells: cells.map((one) => within(one, cols)) };
757
+ }
617
758
  case "options": {
618
- const list = items(value?.items, option).slice(0, OPTIONS);
619
- const question = text(value?.question);
620
- return list.length ? { type, items: list, ...question ? { question } : {}, ...value?.multi === true ? { multi: true } : {} } : undefined;
759
+ const list = items(value === null || value === undefined ? undefined : value.items, option).slice(0, OPTIONS);
760
+ const question = text(value === null || value === undefined ? undefined : value.question);
761
+ return list.length ? { type, items: list, ...question ? { question } : {}, ...(value === null || value === undefined ? undefined : value.multi) === true ? { multi: true } : {} } : undefined;
621
762
  }
622
763
  case "notes": {
623
- const list = items(value?.items, note).sort((a, b) => NOTES.indexOf(a.tone) - NOTES.indexOf(b.tone));
764
+ const list = items(value === null || value === undefined ? undefined : value.items, note).sort((a, b) => NOTES.indexOf(a.tone) - NOTES.indexOf(b.tone));
624
765
  return list.length ? { type, items: list } : undefined;
625
766
  }
626
767
  case "next": {
627
- const list = items(value?.items, listItem).slice(0, 3);
768
+ const list = items(value === null || value === undefined ? undefined : value.items, listItem).slice(0, 3);
628
769
  return list.length ? { type, items: list } : undefined;
629
770
  }
630
771
  case "figure": {
631
- const own = Object.fromEntries(Object.entries(raw ?? {}).filter(([key]) => key !== "type" && key !== "fold"));
632
- const markdown = TaFigure.markdown(own.figure ?? own.markdown ?? own);
772
+ const own = Object.fromEntries(Object.entries(raw !== null && raw !== undefined ? raw : {}).filter(([key]) => key !== "type" && key !== "fold"));
773
+ const markdown = TaFigure.markdown((_f = (_e = own.figure) !== null && _e !== undefined ? _e : own.markdown) !== null && _f !== undefined ? _f : own);
633
774
  return markdown ? { type, markdown } : undefined;
634
775
  }
635
776
  case "details": {
636
- const markdown = text(value?.markdown, MARKDOWN);
637
- const title = text(value?.title);
777
+ const markdown = text(value === null || value === undefined ? undefined : value.markdown, MARKDOWN);
778
+ const title = text(value === null || value === undefined ? undefined : value.title);
638
779
  return markdown ? { type, markdown, ...title ? { title } : {} } : undefined;
639
780
  }
640
781
  default: {
641
- const list = items(value?.items, point);
782
+ const list = items(value === null || value === undefined ? undefined : value.items, point);
642
783
  if (list.length) {
643
784
  return { type: "notes", items: list };
644
785
  }
645
- const markdown = text(value?.markdown, MARKDOWN);
786
+ const markdown = text(value === null || value === undefined ? undefined : value.markdown, MARKDOWN);
646
787
  if (!markdown) {
647
788
  return;
648
789
  }
@@ -652,6 +793,7 @@ function blockOf(item, partial, labels) {
652
793
  }
653
794
  }
654
795
  function loose(card) {
796
+ var _a, _b;
655
797
  const out = [];
656
798
  for (const [key, entries] of Object.entries(card)) {
657
799
  const type = key === "files" ? "changes" : key;
@@ -659,19 +801,20 @@ function loose(card) {
659
801
  out.push({ type, items: entries, ...type === "options" ? { question: card.question } : {} });
660
802
  }
661
803
  }
662
- const words = text(card.summary) ?? text(card.text) ?? text(card.message);
804
+ const words = (_b = (_a = text(card.summary)) !== null && _a !== undefined ? _a : text(card.text)) !== null && _b !== undefined ? _b : text(card.message);
663
805
  return out.length || !words ? out : [{ type: "notes", items: [words] }];
664
806
  }
665
807
  var LISTS = ["stats", "changes", "steps", "flow", "options", "notes", "next"];
666
808
  var PLACE = { stats: -1, notes: 1, next: 2, details: 3 };
667
809
  function place(block2) {
668
- return block2.fold !== undefined ? 3 : PLACE[block2.type] ?? 0;
810
+ var _a;
811
+ return block2.fold !== undefined ? 3 : (_a = PLACE[block2.type]) !== null && _a !== undefined ? _a : 0;
669
812
  }
670
813
  function placed(blocks) {
671
814
  return blocks.map((block2, index) => ({ block: block2, index })).sort((a, b) => place(a.block) - place(b.block) || a.index - b.index).map((entry) => entry.block);
672
815
  }
673
816
  var GlanceSpec;
674
- ((GlanceSpec) => {
817
+ (function(GlanceSpec2) {
675
818
  function read(value, partial = false, labels = LABELS) {
676
819
  const card = Array.isArray(value) ? { blocks: value } : object(value);
677
820
  if (!card) {
@@ -686,8 +829,8 @@ var GlanceSpec;
686
829
  }
687
830
  return { blocks, ...status ? { status } : {}, ...title ? { title } : {} };
688
831
  }
689
- GlanceSpec.read = read;
690
- })(GlanceSpec ||= {});
832
+ GlanceSpec2.read = read;
833
+ })(GlanceSpec || (GlanceSpec = {}));
691
834
 
692
835
  // web-src/glance-ask.ts
693
836
  var GlanceAsk;
@@ -792,6 +935,7 @@ Blocks, 1 to 3 of them, the most important first (Ta puts stats on top and notes
792
935
  - {"type":"diagram","mermaid":"graph LR; A-->B"}: relations a flow cannot show, under 12 nodes.
793
936
  - {"type":"figure","ta-plot":{…}}: a plot (or "ta-3d": a 3D figure) the card speaks of, the JSON of that block, drawn in the card.
794
937
  - {"type":"table","columns":["",""],"rows":[["",""]]}: a few rows that compare things on several points, the first column naming each row (columns ["", "Before", "After"] for before and after in words); cells of a few words, never sentences, and no row for what is fine.
938
+ - {"type":"board","cols":3,"cells":[{"title":"SE 4","corner":"Du","lines":["Fu","Yin"],"mark":true}]}: a chart laid out in a grid, as charts of fortune are (the nine palaces, the twelve houses round a middle, the four pillars, the six lines of a hexagram) or a seating plan: the cells fill it row by row; one may sit "at":[row,col] taking "span":[rows,cols] (the middle of twelve houses on 4 columns: at [2,2], span [2,2], the others then in reading order round it); title on top, corner a small tag, lines a few short words each, mark the cell that matters, tone good | bad | warn.
795
939
  - {"type":"options","question":"Which one?","items":[{"label":"A","detail":"one line","pros":["..."],"cons":["..."],"recommended":true}]}: when the user must choose; each is a button that answers with its label. Add "multi": true when they may choose several. Several things to decide at once: an options block for each, in the same card; the user picks in all of them and sends the choices together.
796
940
  - {"type":"notes","items":[{"text":"...","tone":"risk"}]}: risks, caveats, what the user must do, at most 3, a line each; tone risk | info | todo.
797
941
  - {"type":"next","items":["Run the e2e tests"]}: at most 3 things the user may well ask next, each a button that sends it.