@sendbird/actionbook-core 0.10.10 → 0.10.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -989,503 +989,8 @@ function gfmStrikethrough(options) {
989
989
  }
990
990
  }
991
991
 
992
- // node_modules/micromark-extension-gfm-table/lib/syntax.js
993
- import { markdownLineEnding as markdownLineEnding2, markdownLineEndingOrSpace as markdownLineEndingOrSpace3, markdownSpace as markdownSpace3 } from "micromark-util-character";
994
-
995
- // node_modules/micromark-extension-gfm-table/lib/edit-map.js
996
- var EditMap = class {
997
- /**
998
- * Create a new edit map.
999
- */
1000
- constructor() {
1001
- this.map = [];
1002
- }
1003
- /**
1004
- * Create an edit: a remove and/or add at a certain place.
1005
- *
1006
- * @param {number} index
1007
- * @param {number} remove
1008
- * @param {Array<Event>} add
1009
- * @returns {undefined}
1010
- */
1011
- add(index, remove, add) {
1012
- addImplementation(this, index, remove, add);
1013
- }
1014
- // To do: add this when moving to `micromark`.
1015
- // /**
1016
- // * Create an edit: but insert `add` before existing additions.
1017
- // *
1018
- // * @param {number} index
1019
- // * @param {number} remove
1020
- // * @param {Array<Event>} add
1021
- // * @returns {undefined}
1022
- // */
1023
- // addBefore(index, remove, add) {
1024
- // addImplementation(this, index, remove, add, true)
1025
- // }
1026
- /**
1027
- * Done, change the events.
1028
- *
1029
- * @param {Array<Event>} events
1030
- * @returns {undefined}
1031
- */
1032
- consume(events) {
1033
- this.map.sort(function(a, b) {
1034
- return a[0] - b[0];
1035
- });
1036
- if (this.map.length === 0) {
1037
- return;
1038
- }
1039
- let index = this.map.length;
1040
- const vecs = [];
1041
- while (index > 0) {
1042
- index -= 1;
1043
- vecs.push(events.slice(this.map[index][0] + this.map[index][1]), this.map[index][2]);
1044
- events.length = this.map[index][0];
1045
- }
1046
- vecs.push(events.slice());
1047
- events.length = 0;
1048
- let slice = vecs.pop();
1049
- while (slice) {
1050
- for (const element of slice) {
1051
- events.push(element);
1052
- }
1053
- slice = vecs.pop();
1054
- }
1055
- this.map.length = 0;
1056
- }
1057
- };
1058
- function addImplementation(editMap, at, remove, add) {
1059
- let index = 0;
1060
- if (remove === 0 && add.length === 0) {
1061
- return;
1062
- }
1063
- while (index < editMap.map.length) {
1064
- if (editMap.map[index][0] === at) {
1065
- editMap.map[index][1] += remove;
1066
- editMap.map[index][2].push(...add);
1067
- return;
1068
- }
1069
- index += 1;
1070
- }
1071
- editMap.map.push([at, remove, add]);
1072
- }
1073
-
1074
- // node_modules/micromark-extension-gfm-table/lib/infer.js
1075
- function gfmTableAlign(events, index) {
1076
- let inDelimiterRow = false;
1077
- const align = [];
1078
- while (index < events.length) {
1079
- const event = events[index];
1080
- if (inDelimiterRow) {
1081
- if (event[0] === "enter") {
1082
- if (event[1].type === "tableContent") {
1083
- align.push(events[index + 1][1].type === "tableDelimiterMarker" ? "left" : "none");
1084
- }
1085
- } else if (event[1].type === "tableContent") {
1086
- if (events[index - 1][1].type === "tableDelimiterMarker") {
1087
- const alignIndex = align.length - 1;
1088
- align[alignIndex] = align[alignIndex] === "left" ? "center" : "right";
1089
- }
1090
- } else if (event[1].type === "tableDelimiterRow") {
1091
- break;
1092
- }
1093
- } else if (event[0] === "enter" && event[1].type === "tableDelimiterRow") {
1094
- inDelimiterRow = true;
1095
- }
1096
- index += 1;
1097
- }
1098
- return align;
1099
- }
1100
-
1101
- // node_modules/micromark-extension-gfm-table/lib/syntax.js
1102
- function gfmTable() {
1103
- return {
1104
- flow: {
1105
- null: {
1106
- name: "table",
1107
- tokenize: tokenizeTable,
1108
- resolveAll: resolveTable
1109
- }
1110
- }
1111
- };
1112
- }
1113
- function tokenizeTable(effects, ok2, nok) {
1114
- const self = this;
1115
- let size = 0;
1116
- let sizeB = 0;
1117
- let seen;
1118
- return start;
1119
- function start(code2) {
1120
- let index = self.events.length - 1;
1121
- while (index > -1) {
1122
- const type = self.events[index][1].type;
1123
- if (type === "lineEnding" || // Note: markdown-rs uses `whitespace` instead of `linePrefix`
1124
- type === "linePrefix") index--;
1125
- else break;
1126
- }
1127
- const tail = index > -1 ? self.events[index][1].type : null;
1128
- const next = tail === "tableHead" || tail === "tableRow" ? bodyRowStart : headRowBefore;
1129
- if (next === bodyRowStart && self.parser.lazy[self.now().line]) {
1130
- return nok(code2);
1131
- }
1132
- return next(code2);
1133
- }
1134
- function headRowBefore(code2) {
1135
- effects.enter("tableHead");
1136
- effects.enter("tableRow");
1137
- return headRowStart(code2);
1138
- }
1139
- function headRowStart(code2) {
1140
- if (code2 === 124) {
1141
- return headRowBreak(code2);
1142
- }
1143
- seen = true;
1144
- sizeB += 1;
1145
- return headRowBreak(code2);
1146
- }
1147
- function headRowBreak(code2) {
1148
- if (code2 === null) {
1149
- return nok(code2);
1150
- }
1151
- if (markdownLineEnding2(code2)) {
1152
- if (sizeB > 1) {
1153
- sizeB = 0;
1154
- self.interrupt = true;
1155
- effects.exit("tableRow");
1156
- effects.enter("lineEnding");
1157
- effects.consume(code2);
1158
- effects.exit("lineEnding");
1159
- return headDelimiterStart;
1160
- }
1161
- return nok(code2);
1162
- }
1163
- if (markdownSpace3(code2)) {
1164
- return factorySpace(effects, headRowBreak, "whitespace")(code2);
1165
- }
1166
- sizeB += 1;
1167
- if (seen) {
1168
- seen = false;
1169
- size += 1;
1170
- }
1171
- if (code2 === 124) {
1172
- effects.enter("tableCellDivider");
1173
- effects.consume(code2);
1174
- effects.exit("tableCellDivider");
1175
- seen = true;
1176
- return headRowBreak;
1177
- }
1178
- effects.enter("data");
1179
- return headRowData(code2);
1180
- }
1181
- function headRowData(code2) {
1182
- if (code2 === null || code2 === 124 || markdownLineEndingOrSpace3(code2)) {
1183
- effects.exit("data");
1184
- return headRowBreak(code2);
1185
- }
1186
- effects.consume(code2);
1187
- return code2 === 92 ? headRowEscape : headRowData;
1188
- }
1189
- function headRowEscape(code2) {
1190
- if (code2 === 92 || code2 === 124) {
1191
- effects.consume(code2);
1192
- return headRowData;
1193
- }
1194
- return headRowData(code2);
1195
- }
1196
- function headDelimiterStart(code2) {
1197
- self.interrupt = false;
1198
- if (self.parser.lazy[self.now().line]) {
1199
- return nok(code2);
1200
- }
1201
- effects.enter("tableDelimiterRow");
1202
- seen = false;
1203
- if (markdownSpace3(code2)) {
1204
- return factorySpace(effects, headDelimiterBefore, "linePrefix", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(code2);
1205
- }
1206
- return headDelimiterBefore(code2);
1207
- }
1208
- function headDelimiterBefore(code2) {
1209
- if (code2 === 45 || code2 === 58) {
1210
- return headDelimiterValueBefore(code2);
1211
- }
1212
- if (code2 === 124) {
1213
- seen = true;
1214
- effects.enter("tableCellDivider");
1215
- effects.consume(code2);
1216
- effects.exit("tableCellDivider");
1217
- return headDelimiterCellBefore;
1218
- }
1219
- return headDelimiterNok(code2);
1220
- }
1221
- function headDelimiterCellBefore(code2) {
1222
- if (markdownSpace3(code2)) {
1223
- return factorySpace(effects, headDelimiterValueBefore, "whitespace")(code2);
1224
- }
1225
- return headDelimiterValueBefore(code2);
1226
- }
1227
- function headDelimiterValueBefore(code2) {
1228
- if (code2 === 58) {
1229
- sizeB += 1;
1230
- seen = true;
1231
- effects.enter("tableDelimiterMarker");
1232
- effects.consume(code2);
1233
- effects.exit("tableDelimiterMarker");
1234
- return headDelimiterLeftAlignmentAfter;
1235
- }
1236
- if (code2 === 45) {
1237
- sizeB += 1;
1238
- return headDelimiterLeftAlignmentAfter(code2);
1239
- }
1240
- if (code2 === null || markdownLineEnding2(code2)) {
1241
- return headDelimiterCellAfter(code2);
1242
- }
1243
- return headDelimiterNok(code2);
1244
- }
1245
- function headDelimiterLeftAlignmentAfter(code2) {
1246
- if (code2 === 45) {
1247
- effects.enter("tableDelimiterFiller");
1248
- return headDelimiterFiller(code2);
1249
- }
1250
- return headDelimiterNok(code2);
1251
- }
1252
- function headDelimiterFiller(code2) {
1253
- if (code2 === 45) {
1254
- effects.consume(code2);
1255
- return headDelimiterFiller;
1256
- }
1257
- if (code2 === 58) {
1258
- seen = true;
1259
- effects.exit("tableDelimiterFiller");
1260
- effects.enter("tableDelimiterMarker");
1261
- effects.consume(code2);
1262
- effects.exit("tableDelimiterMarker");
1263
- return headDelimiterRightAlignmentAfter;
1264
- }
1265
- effects.exit("tableDelimiterFiller");
1266
- return headDelimiterRightAlignmentAfter(code2);
1267
- }
1268
- function headDelimiterRightAlignmentAfter(code2) {
1269
- if (markdownSpace3(code2)) {
1270
- return factorySpace(effects, headDelimiterCellAfter, "whitespace")(code2);
1271
- }
1272
- return headDelimiterCellAfter(code2);
1273
- }
1274
- function headDelimiterCellAfter(code2) {
1275
- if (code2 === 124) {
1276
- return headDelimiterBefore(code2);
1277
- }
1278
- if (code2 === null || markdownLineEnding2(code2)) {
1279
- if (!seen || size !== sizeB) {
1280
- return headDelimiterNok(code2);
1281
- }
1282
- effects.exit("tableDelimiterRow");
1283
- effects.exit("tableHead");
1284
- return ok2(code2);
1285
- }
1286
- return headDelimiterNok(code2);
1287
- }
1288
- function headDelimiterNok(code2) {
1289
- return nok(code2);
1290
- }
1291
- function bodyRowStart(code2) {
1292
- effects.enter("tableRow");
1293
- return bodyRowBreak(code2);
1294
- }
1295
- function bodyRowBreak(code2) {
1296
- if (code2 === 124) {
1297
- effects.enter("tableCellDivider");
1298
- effects.consume(code2);
1299
- effects.exit("tableCellDivider");
1300
- return bodyRowBreak;
1301
- }
1302
- if (code2 === null || markdownLineEnding2(code2)) {
1303
- effects.exit("tableRow");
1304
- return ok2(code2);
1305
- }
1306
- if (markdownSpace3(code2)) {
1307
- return factorySpace(effects, bodyRowBreak, "whitespace")(code2);
1308
- }
1309
- effects.enter("data");
1310
- return bodyRowData(code2);
1311
- }
1312
- function bodyRowData(code2) {
1313
- if (code2 === null || code2 === 124 || markdownLineEndingOrSpace3(code2)) {
1314
- effects.exit("data");
1315
- return bodyRowBreak(code2);
1316
- }
1317
- effects.consume(code2);
1318
- return code2 === 92 ? bodyRowEscape : bodyRowData;
1319
- }
1320
- function bodyRowEscape(code2) {
1321
- if (code2 === 92 || code2 === 124) {
1322
- effects.consume(code2);
1323
- return bodyRowData;
1324
- }
1325
- return bodyRowData(code2);
1326
- }
1327
- }
1328
- function resolveTable(events, context) {
1329
- let index = -1;
1330
- let inFirstCellAwaitingPipe = true;
1331
- let rowKind = 0;
1332
- let lastCell = [0, 0, 0, 0];
1333
- let cell = [0, 0, 0, 0];
1334
- let afterHeadAwaitingFirstBodyRow = false;
1335
- let lastTableEnd = 0;
1336
- let currentTable;
1337
- let currentBody;
1338
- let currentCell;
1339
- const map2 = new EditMap();
1340
- while (++index < events.length) {
1341
- const event = events[index];
1342
- const token = event[1];
1343
- if (event[0] === "enter") {
1344
- if (token.type === "tableHead") {
1345
- afterHeadAwaitingFirstBodyRow = false;
1346
- if (lastTableEnd !== 0) {
1347
- flushTableEnd(map2, context, lastTableEnd, currentTable, currentBody);
1348
- currentBody = void 0;
1349
- lastTableEnd = 0;
1350
- }
1351
- currentTable = {
1352
- type: "table",
1353
- start: Object.assign({}, token.start),
1354
- // Note: correct end is set later.
1355
- end: Object.assign({}, token.end)
1356
- };
1357
- map2.add(index, 0, [["enter", currentTable, context]]);
1358
- } else if (token.type === "tableRow" || token.type === "tableDelimiterRow") {
1359
- inFirstCellAwaitingPipe = true;
1360
- currentCell = void 0;
1361
- lastCell = [0, 0, 0, 0];
1362
- cell = [0, index + 1, 0, 0];
1363
- if (afterHeadAwaitingFirstBodyRow) {
1364
- afterHeadAwaitingFirstBodyRow = false;
1365
- currentBody = {
1366
- type: "tableBody",
1367
- start: Object.assign({}, token.start),
1368
- // Note: correct end is set later.
1369
- end: Object.assign({}, token.end)
1370
- };
1371
- map2.add(index, 0, [["enter", currentBody, context]]);
1372
- }
1373
- rowKind = token.type === "tableDelimiterRow" ? 2 : currentBody ? 3 : 1;
1374
- } else if (rowKind && (token.type === "data" || token.type === "tableDelimiterMarker" || token.type === "tableDelimiterFiller")) {
1375
- inFirstCellAwaitingPipe = false;
1376
- if (cell[2] === 0) {
1377
- if (lastCell[1] !== 0) {
1378
- cell[0] = cell[1];
1379
- currentCell = flushCell(map2, context, lastCell, rowKind, void 0, currentCell);
1380
- lastCell = [0, 0, 0, 0];
1381
- }
1382
- cell[2] = index;
1383
- }
1384
- } else if (token.type === "tableCellDivider") {
1385
- if (inFirstCellAwaitingPipe) {
1386
- inFirstCellAwaitingPipe = false;
1387
- } else {
1388
- if (lastCell[1] !== 0) {
1389
- cell[0] = cell[1];
1390
- currentCell = flushCell(map2, context, lastCell, rowKind, void 0, currentCell);
1391
- }
1392
- lastCell = cell;
1393
- cell = [lastCell[1], index, 0, 0];
1394
- }
1395
- }
1396
- } else if (token.type === "tableHead") {
1397
- afterHeadAwaitingFirstBodyRow = true;
1398
- lastTableEnd = index;
1399
- } else if (token.type === "tableRow" || token.type === "tableDelimiterRow") {
1400
- lastTableEnd = index;
1401
- if (lastCell[1] !== 0) {
1402
- cell[0] = cell[1];
1403
- currentCell = flushCell(map2, context, lastCell, rowKind, index, currentCell);
1404
- } else if (cell[1] !== 0) {
1405
- currentCell = flushCell(map2, context, cell, rowKind, index, currentCell);
1406
- }
1407
- rowKind = 0;
1408
- } else if (rowKind && (token.type === "data" || token.type === "tableDelimiterMarker" || token.type === "tableDelimiterFiller")) {
1409
- cell[3] = index;
1410
- }
1411
- }
1412
- if (lastTableEnd !== 0) {
1413
- flushTableEnd(map2, context, lastTableEnd, currentTable, currentBody);
1414
- }
1415
- map2.consume(context.events);
1416
- index = -1;
1417
- while (++index < context.events.length) {
1418
- const event = context.events[index];
1419
- if (event[0] === "enter" && event[1].type === "table") {
1420
- event[1]._align = gfmTableAlign(context.events, index);
1421
- }
1422
- }
1423
- return events;
1424
- }
1425
- function flushCell(map2, context, range, rowKind, rowEnd, previousCell) {
1426
- const groupName = rowKind === 1 ? "tableHeader" : rowKind === 2 ? "tableDelimiter" : "tableData";
1427
- const valueName = "tableContent";
1428
- if (range[0] !== 0) {
1429
- previousCell.end = Object.assign({}, getPoint(context.events, range[0]));
1430
- map2.add(range[0], 0, [["exit", previousCell, context]]);
1431
- }
1432
- const now = getPoint(context.events, range[1]);
1433
- previousCell = {
1434
- type: groupName,
1435
- start: Object.assign({}, now),
1436
- // Note: correct end is set later.
1437
- end: Object.assign({}, now)
1438
- };
1439
- map2.add(range[1], 0, [["enter", previousCell, context]]);
1440
- if (range[2] !== 0) {
1441
- const relatedStart = getPoint(context.events, range[2]);
1442
- const relatedEnd = getPoint(context.events, range[3]);
1443
- const valueToken = {
1444
- type: valueName,
1445
- start: Object.assign({}, relatedStart),
1446
- end: Object.assign({}, relatedEnd)
1447
- };
1448
- map2.add(range[2], 0, [["enter", valueToken, context]]);
1449
- if (rowKind !== 2) {
1450
- const start = context.events[range[2]];
1451
- const end = context.events[range[3]];
1452
- start[1].end = Object.assign({}, end[1].end);
1453
- start[1].type = "chunkText";
1454
- start[1].contentType = "text";
1455
- if (range[3] > range[2] + 1) {
1456
- const a = range[2] + 1;
1457
- const b = range[3] - range[2] - 1;
1458
- map2.add(a, b, []);
1459
- }
1460
- }
1461
- map2.add(range[3] + 1, 0, [["exit", valueToken, context]]);
1462
- }
1463
- if (rowEnd !== void 0) {
1464
- previousCell.end = Object.assign({}, getPoint(context.events, rowEnd));
1465
- map2.add(rowEnd, 0, [["exit", previousCell, context]]);
1466
- previousCell = void 0;
1467
- }
1468
- return previousCell;
1469
- }
1470
- function flushTableEnd(map2, context, index, table2, tableBody) {
1471
- const exits = [];
1472
- const related = getPoint(context.events, index);
1473
- if (tableBody) {
1474
- tableBody.end = Object.assign({}, related);
1475
- exits.push(["exit", tableBody, context]);
1476
- }
1477
- table2.end = Object.assign({}, related);
1478
- exits.push(["exit", table2, context]);
1479
- map2.add(index + 1, 0, exits);
1480
- }
1481
- function getPoint(events, index) {
1482
- const event = events[index];
1483
- const side = event[0] === "enter" ? "start" : "end";
1484
- return event[1][side];
1485
- }
1486
-
1487
992
  // node_modules/micromark-extension-gfm-task-list-item/lib/syntax.js
1488
- import { markdownLineEnding as markdownLineEnding3, markdownLineEndingOrSpace as markdownLineEndingOrSpace4, markdownSpace as markdownSpace4 } from "micromark-util-character";
993
+ import { markdownLineEnding as markdownLineEnding2, markdownLineEndingOrSpace as markdownLineEndingOrSpace3, markdownSpace as markdownSpace3 } from "micromark-util-character";
1489
994
  var tasklistCheck = {
1490
995
  name: "tasklistCheck",
1491
996
  tokenize: tokenizeTasklistCheck
@@ -1516,7 +1021,7 @@ function tokenizeTasklistCheck(effects, ok2, nok) {
1516
1021
  return inside;
1517
1022
  }
1518
1023
  function inside(code2) {
1519
- if (markdownLineEndingOrSpace4(code2)) {
1024
+ if (markdownLineEndingOrSpace3(code2)) {
1520
1025
  effects.enter("taskListCheckValueUnchecked");
1521
1026
  effects.consume(code2);
1522
1027
  effects.exit("taskListCheckValueUnchecked");
@@ -1541,10 +1046,10 @@ function tokenizeTasklistCheck(effects, ok2, nok) {
1541
1046
  return nok(code2);
1542
1047
  }
1543
1048
  function after(code2) {
1544
- if (markdownLineEnding3(code2)) {
1049
+ if (markdownLineEnding2(code2)) {
1545
1050
  return ok2(code2);
1546
1051
  }
1547
- if (markdownSpace4(code2)) {
1052
+ if (markdownSpace3(code2)) {
1548
1053
  return effects.check({
1549
1054
  tokenize: spaceThenNonSpace
1550
1055
  }, ok2, nok)(code2);
@@ -1610,13 +1115,13 @@ function footnoteReferencePeek() {
1610
1115
  function footnoteReference(node, _, state, info) {
1611
1116
  const tracker = state.createTracker(info);
1612
1117
  let value = tracker.move("[^");
1613
- const exit2 = state.enter("footnoteReference");
1118
+ const exit = state.enter("footnoteReference");
1614
1119
  const subexit = state.enter("reference");
1615
1120
  value += tracker.move(
1616
1121
  state.safe(state.associationId(node), { after: "]", before: value })
1617
1122
  );
1618
1123
  subexit();
1619
- exit2();
1124
+ exit();
1620
1125
  value += tracker.move("]");
1621
1126
  return value;
1622
1127
  }
@@ -1649,7 +1154,7 @@ function gfmFootnoteToMarkdown(options) {
1649
1154
  function footnoteDefinition(node, _, state, info) {
1650
1155
  const tracker = state.createTracker(info);
1651
1156
  let value = tracker.move("[^");
1652
- const exit2 = state.enter("footnoteDefinition");
1157
+ const exit = state.enter("footnoteDefinition");
1653
1158
  const subexit = state.enter("label");
1654
1159
  value += tracker.move(
1655
1160
  state.safe(state.associationId(node), { before: value, after: "]" })
@@ -1665,7 +1170,7 @@ function gfmFootnoteToMarkdown(options) {
1665
1170
  )
1666
1171
  );
1667
1172
  }
1668
- exit2();
1173
+ exit();
1669
1174
  return value;
1670
1175
  }
1671
1176
  }
@@ -1713,7 +1218,7 @@ function exitStrikethrough(token) {
1713
1218
  }
1714
1219
  function handleDelete(node, _, state, info) {
1715
1220
  const tracker = state.createTracker(info);
1716
- const exit2 = state.enter("strikethrough");
1221
+ const exit = state.enter("strikethrough");
1717
1222
  let value = tracker.move("~~");
1718
1223
  value += state.containerPhrasing(node, {
1719
1224
  ...tracker.current(),
@@ -1721,310 +1226,15 @@ function handleDelete(node, _, state, info) {
1721
1226
  after: "~"
1722
1227
  });
1723
1228
  value += tracker.move("~~");
1724
- exit2();
1229
+ exit();
1725
1230
  return value;
1726
1231
  }
1727
1232
  function peekDelete() {
1728
1233
  return "~";
1729
1234
  }
1730
1235
 
1731
- // node_modules/markdown-table/index.js
1732
- function defaultStringLength(value) {
1733
- return value.length;
1734
- }
1735
- function markdownTable(table2, options) {
1736
- const settings = options || {};
1737
- const align = (settings.align || []).concat();
1738
- const stringLength = settings.stringLength || defaultStringLength;
1739
- const alignments = [];
1740
- const cellMatrix = [];
1741
- const sizeMatrix = [];
1742
- const longestCellByColumn = [];
1743
- let mostCellsPerRow = 0;
1744
- let rowIndex = -1;
1745
- while (++rowIndex < table2.length) {
1746
- const row2 = [];
1747
- const sizes2 = [];
1748
- let columnIndex2 = -1;
1749
- if (table2[rowIndex].length > mostCellsPerRow) {
1750
- mostCellsPerRow = table2[rowIndex].length;
1751
- }
1752
- while (++columnIndex2 < table2[rowIndex].length) {
1753
- const cell = serialize(table2[rowIndex][columnIndex2]);
1754
- if (settings.alignDelimiters !== false) {
1755
- const size = stringLength(cell);
1756
- sizes2[columnIndex2] = size;
1757
- if (longestCellByColumn[columnIndex2] === void 0 || size > longestCellByColumn[columnIndex2]) {
1758
- longestCellByColumn[columnIndex2] = size;
1759
- }
1760
- }
1761
- row2.push(cell);
1762
- }
1763
- cellMatrix[rowIndex] = row2;
1764
- sizeMatrix[rowIndex] = sizes2;
1765
- }
1766
- let columnIndex = -1;
1767
- if (typeof align === "object" && "length" in align) {
1768
- while (++columnIndex < mostCellsPerRow) {
1769
- alignments[columnIndex] = toAlignment(align[columnIndex]);
1770
- }
1771
- } else {
1772
- const code2 = toAlignment(align);
1773
- while (++columnIndex < mostCellsPerRow) {
1774
- alignments[columnIndex] = code2;
1775
- }
1776
- }
1777
- columnIndex = -1;
1778
- const row = [];
1779
- const sizes = [];
1780
- while (++columnIndex < mostCellsPerRow) {
1781
- const code2 = alignments[columnIndex];
1782
- let before = "";
1783
- let after = "";
1784
- if (code2 === 99) {
1785
- before = ":";
1786
- after = ":";
1787
- } else if (code2 === 108) {
1788
- before = ":";
1789
- } else if (code2 === 114) {
1790
- after = ":";
1791
- }
1792
- let size = settings.alignDelimiters === false ? 1 : Math.max(
1793
- 1,
1794
- longestCellByColumn[columnIndex] - before.length - after.length
1795
- );
1796
- const cell = before + "-".repeat(size) + after;
1797
- if (settings.alignDelimiters !== false) {
1798
- size = before.length + size + after.length;
1799
- if (size > longestCellByColumn[columnIndex]) {
1800
- longestCellByColumn[columnIndex] = size;
1801
- }
1802
- sizes[columnIndex] = size;
1803
- }
1804
- row[columnIndex] = cell;
1805
- }
1806
- cellMatrix.splice(1, 0, row);
1807
- sizeMatrix.splice(1, 0, sizes);
1808
- rowIndex = -1;
1809
- const lines = [];
1810
- while (++rowIndex < cellMatrix.length) {
1811
- const row2 = cellMatrix[rowIndex];
1812
- const sizes2 = sizeMatrix[rowIndex];
1813
- columnIndex = -1;
1814
- const line = [];
1815
- while (++columnIndex < mostCellsPerRow) {
1816
- const cell = row2[columnIndex] || "";
1817
- let before = "";
1818
- let after = "";
1819
- if (settings.alignDelimiters !== false) {
1820
- const size = longestCellByColumn[columnIndex] - (sizes2[columnIndex] || 0);
1821
- const code2 = alignments[columnIndex];
1822
- if (code2 === 114) {
1823
- before = " ".repeat(size);
1824
- } else if (code2 === 99) {
1825
- if (size % 2) {
1826
- before = " ".repeat(size / 2 + 0.5);
1827
- after = " ".repeat(size / 2 - 0.5);
1828
- } else {
1829
- before = " ".repeat(size / 2);
1830
- after = before;
1831
- }
1832
- } else {
1833
- after = " ".repeat(size);
1834
- }
1835
- }
1836
- if (settings.delimiterStart !== false && !columnIndex) {
1837
- line.push("|");
1838
- }
1839
- if (settings.padding !== false && // Don’t add the opening space if we’re not aligning and the cell is
1840
- // empty: there will be a closing space.
1841
- !(settings.alignDelimiters === false && cell === "") && (settings.delimiterStart !== false || columnIndex)) {
1842
- line.push(" ");
1843
- }
1844
- if (settings.alignDelimiters !== false) {
1845
- line.push(before);
1846
- }
1847
- line.push(cell);
1848
- if (settings.alignDelimiters !== false) {
1849
- line.push(after);
1850
- }
1851
- if (settings.padding !== false) {
1852
- line.push(" ");
1853
- }
1854
- if (settings.delimiterEnd !== false || columnIndex !== mostCellsPerRow - 1) {
1855
- line.push("|");
1856
- }
1857
- }
1858
- lines.push(
1859
- settings.delimiterEnd === false ? line.join("").replace(/ +$/, "") : line.join("")
1860
- );
1861
- }
1862
- return lines.join("\n");
1863
- }
1864
- function serialize(value) {
1865
- return value === null || value === void 0 ? "" : String(value);
1866
- }
1867
- function toAlignment(value) {
1868
- const code2 = typeof value === "string" ? value.codePointAt(0) : 0;
1869
- return code2 === 67 || code2 === 99 ? 99 : code2 === 76 || code2 === 108 ? 108 : code2 === 82 || code2 === 114 ? 114 : 0;
1870
- }
1871
-
1872
- // node_modules/mdast-util-gfm-table/lib/index.js
1873
- import { defaultHandlers } from "mdast-util-to-markdown";
1874
- function gfmTableFromMarkdown() {
1875
- return {
1876
- enter: {
1877
- table: enterTable,
1878
- tableData: enterCell,
1879
- tableHeader: enterCell,
1880
- tableRow: enterRow
1881
- },
1882
- exit: {
1883
- codeText: exitCodeText,
1884
- table: exitTable,
1885
- tableData: exit,
1886
- tableHeader: exit,
1887
- tableRow: exit
1888
- }
1889
- };
1890
- }
1891
- function enterTable(token) {
1892
- const align = token._align;
1893
- ok(align, "expected `_align` on table");
1894
- this.enter(
1895
- {
1896
- type: "table",
1897
- align: align.map(function(d) {
1898
- return d === "none" ? null : d;
1899
- }),
1900
- children: []
1901
- },
1902
- token
1903
- );
1904
- this.data.inTable = true;
1905
- }
1906
- function exitTable(token) {
1907
- this.exit(token);
1908
- this.data.inTable = void 0;
1909
- }
1910
- function enterRow(token) {
1911
- this.enter({ type: "tableRow", children: [] }, token);
1912
- }
1913
- function exit(token) {
1914
- this.exit(token);
1915
- }
1916
- function enterCell(token) {
1917
- this.enter({ type: "tableCell", children: [] }, token);
1918
- }
1919
- function exitCodeText(token) {
1920
- let value = this.resume();
1921
- if (this.data.inTable) {
1922
- value = value.replace(/\\([\\|])/g, replace);
1923
- }
1924
- const node = this.stack[this.stack.length - 1];
1925
- ok(node.type === "inlineCode");
1926
- node.value = value;
1927
- this.exit(token);
1928
- }
1929
- function replace($0, $1) {
1930
- return $1 === "|" ? $1 : $0;
1931
- }
1932
- function gfmTableToMarkdown(options) {
1933
- const settings = options || {};
1934
- const padding = settings.tableCellPadding;
1935
- const alignDelimiters = settings.tablePipeAlign;
1936
- const stringLength = settings.stringLength;
1937
- const around = padding ? " " : "|";
1938
- return {
1939
- unsafe: [
1940
- { character: "\r", inConstruct: "tableCell" },
1941
- { character: "\n", inConstruct: "tableCell" },
1942
- // A pipe, when followed by a tab or space (padding), or a dash or colon
1943
- // (unpadded delimiter row), could result in a table.
1944
- { atBreak: true, character: "|", after: "[ :-]" },
1945
- // A pipe in a cell must be encoded.
1946
- { character: "|", inConstruct: "tableCell" },
1947
- // A colon must be followed by a dash, in which case it could start a
1948
- // delimiter row.
1949
- { atBreak: true, character: ":", after: "-" },
1950
- // A delimiter row can also start with a dash, when followed by more
1951
- // dashes, a colon, or a pipe.
1952
- // This is a stricter version than the built in check for lists, thematic
1953
- // breaks, and setex heading underlines though:
1954
- // <https://github.com/syntax-tree/mdast-util-to-markdown/blob/51a2038/lib/unsafe.js#L57>
1955
- { atBreak: true, character: "-", after: "[:|-]" }
1956
- ],
1957
- handlers: {
1958
- inlineCode: inlineCodeWithTable,
1959
- table: handleTable,
1960
- tableCell: handleTableCell,
1961
- tableRow: handleTableRow
1962
- }
1963
- };
1964
- function handleTable(node, _, state, info) {
1965
- return serializeData(handleTableAsData(node, state, info), node.align);
1966
- }
1967
- function handleTableRow(node, _, state, info) {
1968
- const row = handleTableRowAsData(node, state, info);
1969
- const value = serializeData([row]);
1970
- return value.slice(0, value.indexOf("\n"));
1971
- }
1972
- function handleTableCell(node, _, state, info) {
1973
- const exit2 = state.enter("tableCell");
1974
- const subexit = state.enter("phrasing");
1975
- const value = state.containerPhrasing(node, {
1976
- ...info,
1977
- before: around,
1978
- after: around
1979
- });
1980
- subexit();
1981
- exit2();
1982
- return value;
1983
- }
1984
- function serializeData(matrix, align) {
1985
- return markdownTable(matrix, {
1986
- align,
1987
- // @ts-expect-error: `markdown-table` types should support `null`.
1988
- alignDelimiters,
1989
- // @ts-expect-error: `markdown-table` types should support `null`.
1990
- padding,
1991
- // @ts-expect-error: `markdown-table` types should support `null`.
1992
- stringLength
1993
- });
1994
- }
1995
- function handleTableAsData(node, state, info) {
1996
- const children = node.children;
1997
- let index = -1;
1998
- const result = [];
1999
- const subexit = state.enter("table");
2000
- while (++index < children.length) {
2001
- result[index] = handleTableRowAsData(children[index], state, info);
2002
- }
2003
- subexit();
2004
- return result;
2005
- }
2006
- function handleTableRowAsData(node, state, info) {
2007
- const children = node.children;
2008
- let index = -1;
2009
- const result = [];
2010
- const subexit = state.enter("tableRow");
2011
- while (++index < children.length) {
2012
- result[index] = handleTableCell(children[index], node, state, info);
2013
- }
2014
- subexit();
2015
- return result;
2016
- }
2017
- function inlineCodeWithTable(node, parent, state) {
2018
- let value = defaultHandlers.inlineCode(node, parent, state);
2019
- if (state.stack.includes("tableCell")) {
2020
- value = value.replace(/\|/g, "\\$&");
2021
- }
2022
- return value;
2023
- }
2024
- }
2025
-
2026
1236
  // node_modules/mdast-util-gfm-task-list-item/lib/index.js
2027
- import { defaultHandlers as defaultHandlers2 } from "mdast-util-to-markdown";
1237
+ import { defaultHandlers } from "mdast-util-to-markdown";
2028
1238
  function gfmTaskListItemFromMarkdown() {
2029
1239
  return {
2030
1240
  exit: {
@@ -2084,7 +1294,7 @@ function listItemWithTaskListItem(node, parent, state, info) {
2084
1294
  if (checkable) {
2085
1295
  tracker.move(checkbox);
2086
1296
  }
2087
- let value = defaultHandlers2.listItem(node, parent, state, {
1297
+ let value = defaultHandlers.listItem(node, parent, state, {
2088
1298
  ...info,
2089
1299
  ...tracker.current()
2090
1300
  });
@@ -2291,18 +1501,22 @@ function convertBlock(node, depth = 0) {
2291
1501
  }
2292
1502
  case "table": {
2293
1503
  const tbl = node;
2294
- const rows = tbl.children.map((row, rowIdx) => {
2295
- const cells = row.children.map((cell) => {
2296
- const content = cell.children.flatMap((child) => convertInline(child, [], depth + 2));
2297
- return {
2298
- type: "tableCell",
2299
- ...rowIdx === 0 ? { header: true } : {},
2300
- content
2301
- };
2302
- });
2303
- return { type: "tableRow", content: cells };
2304
- });
2305
- return [{ type: "table", content: rows }];
1504
+ const paragraphs = [];
1505
+ for (const row of tbl.children) {
1506
+ const inlines = [];
1507
+ for (let ci = 0; ci < row.children.length; ci++) {
1508
+ if (ci > 0 && inlines.length > 0) {
1509
+ inlines.push({ type: "text", text: " | " });
1510
+ }
1511
+ for (const child of row.children[ci].children) {
1512
+ inlines.push(...convertInline(child, [], depth + 1));
1513
+ }
1514
+ }
1515
+ if (inlines.length > 0) {
1516
+ paragraphs.push({ type: "paragraph", content: inlines });
1517
+ }
1518
+ }
1519
+ return paragraphs;
2306
1520
  }
2307
1521
  default:
2308
1522
  if ("children" in node && Array.isArray(node.children)) {
@@ -2478,14 +1692,22 @@ function blockToMdast(node, depth = 0) {
2478
1692
  return result;
2479
1693
  }
2480
1694
  case "table": {
2481
- const rows = node.content.map((row) => ({
2482
- type: "tableRow",
2483
- children: row.content.map((cell) => ({
2484
- type: "tableCell",
2485
- children: cell.content.flatMap((c) => inlineToMdast(c, depth + 2))
2486
- }))
2487
- }));
2488
- return [{ type: "table", children: rows }];
1695
+ const result = [];
1696
+ for (const row of node.content) {
1697
+ const children = [];
1698
+ for (let ci = 0; ci < row.content.length; ci++) {
1699
+ if (ci > 0 && children.length > 0) {
1700
+ children.push({ type: "text", value: " | " });
1701
+ }
1702
+ for (const cell of row.content[ci].content) {
1703
+ children.push(...inlineToMdast(cell, depth + 1));
1704
+ }
1705
+ }
1706
+ if (children.length > 0) {
1707
+ result.push({ type: "paragraph", children });
1708
+ }
1709
+ }
1710
+ return result;
2489
1711
  }
2490
1712
  case "noteBlock":
2491
1713
  return [];
@@ -2851,11 +2073,10 @@ function jinjaBlockTransform(tree) {
2851
2073
  }
2852
2074
 
2853
2075
  // src/markdown/parser.ts
2854
- var gfmNoAutolink = () => combineExtensions([gfmFootnote(), gfmStrikethrough(), gfmTable(), gfmTaskListItem()]);
2076
+ var gfmNoAutolink = () => combineExtensions([gfmFootnote(), gfmStrikethrough(), gfmTaskListItem()]);
2855
2077
  var gfmNoAutolinkFromMarkdown = () => [
2856
2078
  gfmFootnoteFromMarkdown(),
2857
2079
  gfmStrikethroughFromMarkdown(),
2858
- gfmTableFromMarkdown(),
2859
2080
  gfmTaskListItemFromMarkdown()
2860
2081
  ];
2861
2082
  var MAX_DEPTH4 = 128;
@@ -2923,12 +2144,11 @@ function parseMarkdown(markdown, options) {
2923
2144
  }
2924
2145
 
2925
2146
  // src/markdown/serializer.ts
2926
- import { defaultHandlers as defaultHandlers3, toMarkdown } from "mdast-util-to-markdown";
2147
+ import { defaultHandlers as defaultHandlers2, toMarkdown } from "mdast-util-to-markdown";
2927
2148
  var gfmNoAutolinkToMarkdown = () => ({
2928
2149
  extensions: [
2929
2150
  gfmFootnoteToMarkdown(),
2930
2151
  gfmStrikethroughToMarkdown(),
2931
- gfmTableToMarkdown(),
2932
2152
  gfmTaskListItemToMarkdown()
2933
2153
  ]
2934
2154
  });
@@ -2946,7 +2166,7 @@ function isJinjaTagParagraph(node) {
2946
2166
  function textHandler(node, parent, state, info) {
2947
2167
  const originalUnsafe = state.unsafe;
2948
2168
  state.unsafe = originalUnsafe.filter((p) => !(p.character === "_" && !p.atBreak));
2949
- const result = defaultHandlers3.text(node, parent, state, info);
2169
+ const result = defaultHandlers2.text(node, parent, state, info);
2950
2170
  state.unsafe = originalUnsafe;
2951
2171
  return result;
2952
2172
  }
@@ -2964,11 +2184,11 @@ function listItemHandler(node, parent, state, info) {
2964
2184
  const savedStart = list.start;
2965
2185
  const idx = list.children.indexOf(node);
2966
2186
  list.start = value - idx;
2967
- const result = defaultHandlers3.listItem(node, parent, state, info);
2187
+ const result = defaultHandlers2.listItem(node, parent, state, info);
2968
2188
  list.start = savedStart;
2969
2189
  return result;
2970
2190
  }
2971
- return defaultHandlers3.listItem(node, parent, state, info);
2191
+ return defaultHandlers2.listItem(node, parent, state, info);
2972
2192
  }
2973
2193
  function serializeToMarkdown(doc2) {
2974
2194
  const mdastTree = toMdast(doc2);
@@ -2995,9 +2215,9 @@ function serializeToMarkdown(doc2) {
2995
2215
  link: linkHandler,
2996
2216
  listItem: listItemHandler,
2997
2217
  emphasis: ((node, _parent, state, info) => {
2998
- const exit2 = state.enter("emphasis");
2218
+ const exit = state.enter("emphasis");
2999
2219
  const value = state.containerPhrasing(node, { ...info, before: "_", after: "_" });
3000
- exit2();
2220
+ exit();
3001
2221
  return `__${value}__`;
3002
2222
  }),
3003
2223
  ...resourceTagToMarkdown().handlers,
@@ -5797,6 +5017,428 @@ function actionbookToAST(manual) {
5797
5017
  }
5798
5018
  return EMPTY_DOC;
5799
5019
  }
5020
+
5021
+ // src/graph/builder.ts
5022
+ var idCounter = 0;
5023
+ function nextId() {
5024
+ return `vn_${++idCounter}`;
5025
+ }
5026
+ function resetIds() {
5027
+ idCounter = 0;
5028
+ }
5029
+ function truncate(s, max = 40) {
5030
+ const t = s.trim();
5031
+ return t.length > max ? `${t.slice(0, max - 3)}...` : t;
5032
+ }
5033
+ function inlineSummary2(content, max = 60) {
5034
+ const parts = [];
5035
+ for (const node of content) {
5036
+ if (node.type === "text") {
5037
+ parts.push(node.text);
5038
+ } else if (node.type === "resourceTag") {
5039
+ parts.push(`{{${node.tagType}:${node.text}}}`);
5040
+ } else if (node.type === "jumpPoint") {
5041
+ parts.push(`^${node.id}^`);
5042
+ }
5043
+ }
5044
+ return truncate(parts.join(""), max);
5045
+ }
5046
+ function analyzeInlines(content) {
5047
+ const result = {
5048
+ hasHandoff: false,
5049
+ hasEndCall: false,
5050
+ hasToolCall: false,
5051
+ hasGoto: false,
5052
+ gotoTarget: null,
5053
+ hasJumpPoint: false,
5054
+ jumpPointIds: [],
5055
+ annotations: []
5056
+ };
5057
+ for (const node of content) {
5058
+ if (node.type === "resourceTag") {
5059
+ if (node.tagType === "handoff") {
5060
+ result.hasHandoff = true;
5061
+ result.annotations.push({ kind: "handoff", label: node.text, resourceId: node.resourceId });
5062
+ } else if (node.tagType === "end_call" || node.resourceId === "close-happy-tiger") {
5063
+ result.hasEndCall = true;
5064
+ result.annotations.push({ kind: "end_call", label: node.text, resourceId: node.resourceId });
5065
+ } else {
5066
+ result.hasToolCall = true;
5067
+ result.annotations.push({ kind: "tool", label: node.text, resourceId: node.resourceId });
5068
+ }
5069
+ } else if (node.type === "jumpPoint") {
5070
+ result.hasJumpPoint = true;
5071
+ result.jumpPointIds.push(node.id);
5072
+ } else if (node.type === "text" && node.marks) {
5073
+ for (const m of node.marks) {
5074
+ if (m.type === "link" && m.href.startsWith("#")) {
5075
+ result.hasGoto = true;
5076
+ result.gotoTarget = m.href.slice(1);
5077
+ }
5078
+ }
5079
+ }
5080
+ }
5081
+ return result;
5082
+ }
5083
+ function analyzeBlock(block) {
5084
+ const result = {
5085
+ hasHandoff: false,
5086
+ hasEndCall: false,
5087
+ hasToolCall: false,
5088
+ hasGoto: false,
5089
+ gotoTarget: null,
5090
+ hasJumpPoint: false,
5091
+ jumpPointIds: [],
5092
+ annotations: []
5093
+ };
5094
+ function walk(b) {
5095
+ if ("content" in b && Array.isArray(b.content)) {
5096
+ for (const child of b.content) {
5097
+ if (child.type === "text" || child.type === "resourceTag" || child.type === "jumpPoint" || child.type === "hardBreak") {
5098
+ const a = analyzeInlines([child]);
5099
+ merge(result, a);
5100
+ } else {
5101
+ walk(child);
5102
+ }
5103
+ }
5104
+ }
5105
+ if ("branches" in b && Array.isArray(b.branches)) {
5106
+ for (const branch of b.branches) {
5107
+ if (branch.content) {
5108
+ for (const c of branch.content) walk(c);
5109
+ }
5110
+ }
5111
+ }
5112
+ }
5113
+ walk(block);
5114
+ return result;
5115
+ }
5116
+ function merge(target, source) {
5117
+ if (source.hasHandoff) target.hasHandoff = true;
5118
+ if (source.hasEndCall) target.hasEndCall = true;
5119
+ if (source.hasToolCall) target.hasToolCall = true;
5120
+ if (source.hasGoto) {
5121
+ target.hasGoto = true;
5122
+ target.gotoTarget = source.gotoTarget;
5123
+ }
5124
+ if (source.hasJumpPoint) {
5125
+ target.hasJumpPoint = true;
5126
+ target.jumpPointIds.push(...source.jumpPointIds);
5127
+ }
5128
+ target.annotations.push(...source.annotations);
5129
+ }
5130
+ function isBulletListBranching(block) {
5131
+ if (block.type !== "bulletList") return false;
5132
+ for (const li of block.content) {
5133
+ if (li.content.length > 1) return true;
5134
+ const analysis = analyzeBlock(li);
5135
+ if (analysis.hasHandoff || analysis.hasEndCall || analysis.hasToolCall || analysis.hasGoto) return true;
5136
+ }
5137
+ return false;
5138
+ }
5139
+ function addEdge(ctx, from, to, type, label, branchIndex) {
5140
+ ctx.edges.push({
5141
+ id: `e_${ctx.edgeCounter++}`,
5142
+ from,
5143
+ to,
5144
+ type,
5145
+ label,
5146
+ branchIndex
5147
+ });
5148
+ }
5149
+ function processBlocks(blocks, startBlockIndex, ctx) {
5150
+ let prevLastIds = [];
5151
+ let firstId = null;
5152
+ let contentAccum = null;
5153
+ function flushContent() {
5154
+ if (!contentAccum) return null;
5155
+ const node = {
5156
+ id: nextId(),
5157
+ type: "CONTENT",
5158
+ label: truncate(contentAccum.lines[0] || ""),
5159
+ lines: contentAccum.lines,
5160
+ section: ctx.currentSection,
5161
+ annotations: contentAccum.annotations,
5162
+ sourceBlockRange: { start: contentAccum.startIdx, end: contentAccum.endIdx },
5163
+ gotoTarget: contentAccum.gotoTarget
5164
+ };
5165
+ ctx.nodes.push(node);
5166
+ for (const jpId of contentAccum.jumpPointIds) {
5167
+ ctx.anchorMap[jpId] = node.id;
5168
+ }
5169
+ const nid = node.id;
5170
+ contentAccum = null;
5171
+ for (const pid of prevLastIds) addEdge(ctx, pid, nid, "SEQUENTIAL");
5172
+ if (!firstId) firstId = nid;
5173
+ prevLastIds = [nid];
5174
+ if (node.gotoTarget) {
5175
+ prevLastIds = [];
5176
+ }
5177
+ return nid;
5178
+ }
5179
+ for (let i = 0; i < blocks.length; i++) {
5180
+ const block = blocks[i];
5181
+ const blockIndex = startBlockIndex + i;
5182
+ if (block.type === "blockquote" || block.type === "noteBlock" || block.type === "horizontalRule") {
5183
+ continue;
5184
+ }
5185
+ if (block.type === "codeBlock") {
5186
+ const text2 = textContent(block).trim();
5187
+ if (text2) {
5188
+ if (!contentAccum) {
5189
+ contentAccum = { lines: [], annotations: [], startIdx: blockIndex, endIdx: blockIndex, jumpPointIds: [] };
5190
+ }
5191
+ contentAccum.lines.push(truncate(text2, 60));
5192
+ contentAccum.endIdx = blockIndex;
5193
+ }
5194
+ continue;
5195
+ }
5196
+ if (block.type === "heading") {
5197
+ flushContent();
5198
+ const analysis = analyzeBlock(block);
5199
+ ctx.currentSection = textContent(block).trim() || `Section ${blockIndex}`;
5200
+ for (const jpId of analysis.jumpPointIds) {
5201
+ if (!contentAccum) {
5202
+ contentAccum = { lines: [], annotations: [], startIdx: blockIndex, endIdx: blockIndex, jumpPointIds: [] };
5203
+ }
5204
+ contentAccum.jumpPointIds.push(jpId);
5205
+ }
5206
+ continue;
5207
+ }
5208
+ if (block.type === "paragraph") {
5209
+ const text2 = inlineSummary2(block.content);
5210
+ const analysis = analyzeInlines(block.content);
5211
+ if (analysis.hasHandoff) {
5212
+ flushContent();
5213
+ const node = {
5214
+ id: nextId(),
5215
+ type: "HANDOFF",
5216
+ label: "Handoff",
5217
+ lines: [text2],
5218
+ section: ctx.currentSection,
5219
+ annotations: analysis.annotations,
5220
+ sourceBlockRange: { start: blockIndex, end: blockIndex }
5221
+ };
5222
+ ctx.nodes.push(node);
5223
+ for (const pid of prevLastIds) addEdge(ctx, pid, node.id, "SEQUENTIAL");
5224
+ if (!firstId) firstId = node.id;
5225
+ prevLastIds = [node.id];
5226
+ continue;
5227
+ }
5228
+ if (analysis.hasEndCall) {
5229
+ flushContent();
5230
+ const node = {
5231
+ id: nextId(),
5232
+ type: "END_CONVERSATION",
5233
+ label: "End",
5234
+ lines: [text2],
5235
+ section: ctx.currentSection,
5236
+ annotations: analysis.annotations,
5237
+ sourceBlockRange: { start: blockIndex, end: blockIndex }
5238
+ };
5239
+ ctx.nodes.push(node);
5240
+ for (const pid of prevLastIds) addEdge(ctx, pid, node.id, "SEQUENTIAL");
5241
+ if (!firstId) firstId = node.id;
5242
+ prevLastIds = [node.id];
5243
+ continue;
5244
+ }
5245
+ if (!contentAccum) {
5246
+ contentAccum = { lines: [], annotations: [], startIdx: blockIndex, endIdx: blockIndex, jumpPointIds: [] };
5247
+ }
5248
+ contentAccum.lines.push(text2);
5249
+ contentAccum.annotations.push(...analysis.annotations);
5250
+ contentAccum.endIdx = blockIndex;
5251
+ contentAccum.jumpPointIds.push(...analysis.jumpPointIds);
5252
+ if (analysis.hasGoto) contentAccum.gotoTarget = analysis.gotoTarget ?? void 0;
5253
+ continue;
5254
+ }
5255
+ if (block.type === "orderedList") {
5256
+ const items = block.content;
5257
+ for (const li of items) {
5258
+ const text2 = inlineSummary2(li.content[0]?.content || [], 60);
5259
+ const analysis = analyzeBlock(li);
5260
+ if (analysis.hasHandoff) {
5261
+ flushContent();
5262
+ const node = {
5263
+ id: nextId(),
5264
+ type: "HANDOFF",
5265
+ label: "Handoff",
5266
+ lines: [text2],
5267
+ section: ctx.currentSection,
5268
+ annotations: analysis.annotations,
5269
+ sourceBlockRange: { start: blockIndex, end: blockIndex }
5270
+ };
5271
+ ctx.nodes.push(node);
5272
+ for (const pid of prevLastIds) addEdge(ctx, pid, node.id, "SEQUENTIAL");
5273
+ if (!firstId) firstId = node.id;
5274
+ prevLastIds = [node.id];
5275
+ continue;
5276
+ }
5277
+ if (!contentAccum) {
5278
+ contentAccum = { lines: [], annotations: [], startIdx: blockIndex, endIdx: blockIndex, jumpPointIds: [] };
5279
+ }
5280
+ contentAccum.lines.push(text2);
5281
+ contentAccum.annotations.push(...analysis.annotations);
5282
+ contentAccum.endIdx = blockIndex;
5283
+ contentAccum.jumpPointIds.push(...analysis.jumpPointIds);
5284
+ if (analysis.hasGoto) contentAccum.gotoTarget = analysis.gotoTarget ?? void 0;
5285
+ }
5286
+ continue;
5287
+ }
5288
+ if (block.type === "bulletList") {
5289
+ flushContent();
5290
+ const items = block.content;
5291
+ const isBranching = isBulletListBranching(block);
5292
+ if (!isBranching) {
5293
+ if (!contentAccum) {
5294
+ contentAccum = { lines: [], annotations: [], startIdx: blockIndex, endIdx: blockIndex, jumpPointIds: [] };
5295
+ }
5296
+ for (const li of items) {
5297
+ contentAccum.lines.push(inlineSummary2(li.content[0]?.content || []));
5298
+ }
5299
+ contentAccum.endIdx = blockIndex;
5300
+ continue;
5301
+ }
5302
+ const branchEndIds = [];
5303
+ const branchNodeIds = [];
5304
+ for (let li = 0; li < items.length; li++) {
5305
+ const item = items[li];
5306
+ const firstBlock = item.content[0];
5307
+ const conditionText = firstBlock && (firstBlock.type === "paragraph" || firstBlock.type === "heading") ? inlineSummary2(firstBlock.content || []) : `Branch ${li + 1}`;
5308
+ const condNode = {
5309
+ id: nextId(),
5310
+ type: "BRANCH",
5311
+ label: conditionText,
5312
+ lines: [conditionText],
5313
+ section: ctx.currentSection,
5314
+ annotations: [],
5315
+ sourceBlockRange: { start: blockIndex, end: blockIndex },
5316
+ conditionText
5317
+ };
5318
+ ctx.nodes.push(condNode);
5319
+ branchNodeIds.push(condNode.id);
5320
+ for (const pid of prevLastIds) addEdge(ctx, pid, condNode.id, "BRANCH_TRUE", conditionText, li);
5321
+ if (!firstId) firstId = condNode.id;
5322
+ const subBlocks = firstBlock && (firstBlock.type === "paragraph" || firstBlock.type === "heading") ? item.content.slice(1) : item.content;
5323
+ if (subBlocks.length > 0) {
5324
+ const sub = processBlocks(subBlocks, blockIndex, ctx);
5325
+ if (sub.firstId) {
5326
+ addEdge(ctx, condNode.id, sub.firstId, "SEQUENTIAL");
5327
+ branchEndIds.push(...sub.lastIds);
5328
+ } else {
5329
+ branchEndIds.push(condNode.id);
5330
+ }
5331
+ } else {
5332
+ branchEndIds.push(condNode.id);
5333
+ }
5334
+ }
5335
+ prevLastIds = branchEndIds;
5336
+ continue;
5337
+ }
5338
+ if (block.type === "jinjaIfBlock") {
5339
+ flushContent();
5340
+ const branchNode = {
5341
+ id: nextId(),
5342
+ type: "BRANCH",
5343
+ label: "Jinja If",
5344
+ lines: [],
5345
+ section: ctx.currentSection,
5346
+ annotations: [],
5347
+ sourceBlockRange: { start: blockIndex, end: blockIndex },
5348
+ isJinja: true
5349
+ };
5350
+ ctx.nodes.push(branchNode);
5351
+ for (const pid of prevLastIds) addEdge(ctx, pid, branchNode.id, "SEQUENTIAL");
5352
+ if (!firstId) firstId = branchNode.id;
5353
+ const branchEndIds = [];
5354
+ for (let bi = 0; bi < block.branches.length; bi++) {
5355
+ const branch = block.branches[bi];
5356
+ const isElse = branch.branchType === "else";
5357
+ const edgeType = isElse ? "FALLBACK" : "BRANCH_TRUE";
5358
+ const label = isElse ? "else" : branch.condition || `Branch ${bi + 1}`;
5359
+ const sub = processBlocks(branch.content, blockIndex, ctx);
5360
+ if (sub.firstId) {
5361
+ addEdge(ctx, branchNode.id, sub.firstId, edgeType, label, bi);
5362
+ branchEndIds.push(...sub.lastIds);
5363
+ }
5364
+ }
5365
+ prevLastIds = branchEndIds;
5366
+ continue;
5367
+ }
5368
+ }
5369
+ flushContent();
5370
+ return { firstId, lastIds: prevLastIds };
5371
+ }
5372
+ function buildVizGraph(doc2) {
5373
+ resetIds();
5374
+ const ctx = {
5375
+ nodes: [],
5376
+ edges: [],
5377
+ anchorMap: {},
5378
+ currentSection: "_default",
5379
+ edgeCounter: 0
5380
+ };
5381
+ const startNode = {
5382
+ id: "START",
5383
+ type: "START",
5384
+ label: "Start",
5385
+ lines: [],
5386
+ section: "_default",
5387
+ annotations: [],
5388
+ sourceBlockRange: { start: -1, end: -1 }
5389
+ };
5390
+ ctx.nodes.push(startNode);
5391
+ const result = processBlocks(doc2.content, 0, ctx);
5392
+ if (result.firstId) {
5393
+ addEdge(ctx, "START", result.firstId, "SEQUENTIAL");
5394
+ }
5395
+ for (const lastId of result.lastIds) {
5396
+ const lastNode = ctx.nodes.find((n) => n.id === lastId);
5397
+ if (lastNode && lastNode.type !== "HANDOFF" && lastNode.type !== "END_CONVERSATION") {
5398
+ const endNode = {
5399
+ id: nextId(),
5400
+ type: "END_CONVERSATION",
5401
+ label: "End",
5402
+ lines: [],
5403
+ section: lastNode.section,
5404
+ annotations: [],
5405
+ sourceBlockRange: { start: -1, end: -1 }
5406
+ };
5407
+ ctx.nodes.push(endNode);
5408
+ addEdge(ctx, lastId, endNode.id, "SEQUENTIAL");
5409
+ }
5410
+ }
5411
+ for (const node of ctx.nodes) {
5412
+ if (!node.gotoTarget) continue;
5413
+ const targetNodeId = ctx.anchorMap[node.gotoTarget];
5414
+ if (targetNodeId) {
5415
+ addEdge(ctx, node.id, targetNodeId, "GOTO", node.gotoTarget);
5416
+ } else {
5417
+ addEdge(ctx, node.id, node.id, "BROKEN_REF", node.gotoTarget);
5418
+ }
5419
+ }
5420
+ const sectionMap = /* @__PURE__ */ new Map();
5421
+ for (const n of ctx.nodes) {
5422
+ if (!sectionMap.has(n.section)) sectionMap.set(n.section, []);
5423
+ sectionMap.get(n.section).push(n.id);
5424
+ }
5425
+ const sections = [];
5426
+ for (const [name, nodeIds] of sectionMap) {
5427
+ sections.push({ name, headingBlockIndex: 0, nodeIds });
5428
+ }
5429
+ const nodes = ctx.nodes.map((n) => ({
5430
+ ...n,
5431
+ lines: n.lines,
5432
+ annotations: n.annotations
5433
+ }));
5434
+ const edges = ctx.edges;
5435
+ return {
5436
+ nodes,
5437
+ edges,
5438
+ sections,
5439
+ anchorMap: ctx.anchorMap
5440
+ };
5441
+ }
5800
5442
  export {
5801
5443
  ActionbookConversionError,
5802
5444
  DeserializationError,
@@ -5810,6 +5452,7 @@ export {
5810
5452
  blockquote,
5811
5453
  bold,
5812
5454
  buildDocumentTree,
5455
+ buildVizGraph,
5813
5456
  bulletList,
5814
5457
  chunkByHeading,
5815
5458
  code,