@cardenelabs/dragon 0.37.0 → 0.40.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.
Files changed (48) hide show
  1. package/README.md +38 -1
  2. package/dist/cli.cjs +2403 -550
  3. package/dist/cli.cjs.map +1 -1
  4. package/dist/cli.js +2408 -555
  5. package/dist/cli.js.map +1 -1
  6. package/dist/export.cjs +2252 -537
  7. package/dist/export.cjs.map +1 -1
  8. package/dist/export.d.cts +3 -1
  9. package/dist/export.d.ts +3 -1
  10. package/dist/export.js +2257 -542
  11. package/dist/export.js.map +1 -1
  12. package/dist/index.cjs +2387 -495
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +11 -154
  15. package/dist/index.d.ts +11 -154
  16. package/dist/index.js +2387 -496
  17. package/dist/index.js.map +1 -1
  18. package/dist/ink-B_7OXxtb.d.cts +360 -0
  19. package/dist/ink-B_7OXxtb.d.ts +360 -0
  20. package/dist/player.global.js +2 -2
  21. package/package.json +1 -1
  22. package/src/cli.ts +9 -0
  23. package/src/export/index.ts +4 -1
  24. package/src/field-messages.ts +8 -0
  25. package/src/figure-text.ts +28 -0
  26. package/src/index.ts +3 -0
  27. package/src/layout/architecture.ts +123 -44
  28. package/src/layout/git.ts +728 -0
  29. package/src/layout/measure.ts +10 -0
  30. package/src/layout/scene.ts +300 -19
  31. package/src/layout/sequence.ts +29 -11
  32. package/src/layout/state.ts +82 -62
  33. package/src/look/values.ts +57 -4
  34. package/src/messages.ts +47 -4
  35. package/src/parser.ts +142 -7
  36. package/src/player.ts +44 -0
  37. package/src/printer.ts +16 -4
  38. package/src/render/git.ts +161 -0
  39. package/src/render/ink.ts +104 -0
  40. package/src/render/parts.ts +103 -36
  41. package/src/render/svg.ts +63 -15
  42. package/src/schema.ts +47 -13
  43. package/src/schemas/diagram.schema.json +75 -8
  44. package/src/schemas/validate-diagram.js +1 -1
  45. package/src/timeline.ts +18 -3
  46. package/src/words.ts +19 -3
  47. package/dist/schema-B2MTRv66.d.cts +0 -133
  48. package/dist/schema-B2MTRv66.d.ts +0 -133
package/dist/export.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { mkdirSync, writeFileSync, rmSync, readFileSync } from 'fs';
2
- import { join, dirname } from 'path';
2
+ import { join as join$1, dirname } from 'path';
3
3
  import { createRequire } from 'module';
4
4
  import { readFile } from 'fs/promises';
5
5
 
@@ -264,7 +264,11 @@ var TYPE = {
264
264
  stepTitle: text(15, 700),
265
265
  stepBody: text(13.5, 500),
266
266
  stepNo: text(13, 700, "mono"),
267
- button: text(14, 700)
267
+ button: text(14, 700),
268
+ /** 枝分かれの図 (#3164) の、丸の中の commit の名札と、丸の外に添える hash と一言 */
269
+ gitId: text(11, 700),
270
+ gitHash: text(10.5, 600, "mono"),
271
+ gitNote: text(10.5, 650)
268
272
  };
269
273
  var LOOK = {
270
274
  /** 部品どうしの最小の隙間 */
@@ -274,7 +278,11 @@ var LOOK = {
274
278
  box: { h: 72, minW: 92, padX: 12, radius: 12, icon: 24, iconRadius: 7, iconY: -16, iconScale: 0.74, nameY: 12, subY: 27 },
275
279
  region: { pad: 18, gap: 10, radius: 14, inset: 14, icon: 24, iconRadius: 7, iconScale: 0.68, nameY: 58, line: 16, minH: 108 },
276
280
  architecture: { columns: 4, columnGap: 56, maxColumnGap: 160, rowGap: 44, labelRoom: 16 },
277
- sequence: { columnGap: 40, labelRoom: 16, firstRow: 22, rowGap: 14, stepGap: 8, minPitch: 40, tail: 18, selfW: 34, selfH: 18 },
281
+ /**
282
+ * 時系列図。線の名前の札は、構成図と状態遷移図より線に寄せる (`labelOffset` は線から札の真ん中まで)。
283
+ * 札と線の離れが図の他の空きと同じ 6 になり、行を詰めても札がどの線の名前かが分かる (#3177)。
284
+ */
285
+ sequence: { columnGap: 40, labelRoom: 16, labelOffset: 16, firstRow: 10, rowGap: 6, stepGap: 6, minPitch: 32, tail: 10, selfW: 34, selfH: 18 },
278
286
  /**
279
287
  * 状態遷移図 (#3163)。状態は `columns` つずつ並べて次の段へ折り返し、段の間 (`rowGap`) の真ん中を、段をまたぐ線が通る。
280
288
  * `start` と `end` は始まりと終わりの印の半径と、印の中の丸の半径。`drop` は最初の状態の上端から始まりの印の中心まで、
@@ -304,17 +312,60 @@ var LOOK = {
304
312
  done: { r: 6.5, inset: 13 },
305
313
  pastLabel: 0.85
306
314
  },
315
+ /**
316
+ * 枝分かれの図 (#3164)。見本帳の試作 (`scenes/git.js`) の寸法を写す。
317
+ * commit は列ごとに `pitch` ずつ右へ並べ、一番上でない帯の commit は列の半分だけ右へずらす。`x0` は最初の列の真ん中の x の下限、
318
+ * `textGap` は隣の列の hash と一言の間に空ける最小の隙間。`r` は丸の半径、`orphan` はどの札からも辿れなくなった commit の点線の丸の半径。
319
+ * `topLine` と `line` は帯の上端から丸を並べる線まで (一番上の帯と、それより下の帯)、`topBelow` と `below` は線から帯の下端まで。
320
+ * `bare` は線の名前を下に置かない帯の、線から帯の下端まで。
321
+ * hash と一言は一番上の帯では丸の上に、ほかの帯では丸の下に置き、`above` と `under` は丸の真ん中から丸に近い行の基準線まで、`lineStep` は行の間。
322
+ * 札は丸の上に段を重ねて置き、`tagTop` と `tag` は丸の真ん中から 1 段目の札の真ん中まで (一番上の帯と、ほかの帯)、`row` は札の段の間。
323
+ * 札の段が 2 段より多い commit がある帯は、多い段の分だけ線を下げる。
324
+ * `turn` は枝へ分かれる線と枝から入る線が曲がり終えて横へ進むまでの長さ、`samples` は曲がりを区切る点の数、`boxGap` は commit の並びと箱の間。
325
+ * `labelUnder` はほかの帯で、丸の真ん中から線の名前の札の上端まで。`colors` は帯の色を上から配る順
326
+ */
327
+ git: {
328
+ x0: 120,
329
+ pitch: 90,
330
+ textGap: 12,
331
+ r: 12,
332
+ orphan: 13.5,
333
+ topLine: 120,
334
+ line: 90,
335
+ topBelow: 30,
336
+ below: 82,
337
+ bare: 62,
338
+ above: 18,
339
+ under: 27,
340
+ lineStep: 13,
341
+ tagTop: 58,
342
+ tag: 30,
343
+ row: 22,
344
+ turn: 60,
345
+ samples: 12,
346
+ boxGap: 24,
347
+ labelUnder: 50,
348
+ colors: ["blue", "violet", "green", "amber", "rose"]
349
+ },
307
350
  /** `bend` は線の曲がりを丸める半径 (#3171) */
308
351
  edge: { inset: 3, arrow: 6, arrowHalf: 3.5, parallel: 5, ghostDash: 5, flowDash: 9, bend: 12 },
309
- label: { h: 20, padX: 9, radius: 10, offset: 22, side: 14, search: 4, searchMax: 400, soft: 6 },
352
+ /** `touch` は線の名前と、同じ時刻に見えている段の番号の丸の間に空ける最小の隙間 (#3175) */
353
+ label: { h: 20, padX: 9, radius: 10, offset: 22, side: 14, search: 4, searchMax: 400, soft: 6, touch: 2 },
310
354
  action: { h: 22, padX: 10, radius: 11 },
311
355
  badge: { r: 9.5, ring: 9, inset: 4, along: 14, short: 44 },
312
356
  carrier: { envW: 24, envH: 17, coinR: 6.5, coinIn: 3.8, tagH: 18, tagPadX: 8, samples: 16 },
357
+ /**
358
+ * 運ぶ物の置き場 (#3176)。運ぶ物を出し入れする箱は、絵柄の右に点線の枠を持ち、運ぶ物は着いた後と走り出す前にそこで待つ。
359
+ * `gap` は絵柄と枠の間、`pad` は枠と運ぶ物の間、`spread` は枠の中に横に並べた運ぶ物の間、`h` と `radius` は枠の高さと角の丸み。
360
+ * `clear` は状態遷移図の右上の済んだ印と枠の間に空ける最小の隙間。`lifeline` は時系列図で生存線と運ぶ物の間、
361
+ * `mark` は状態遷移図の始まりの印と、その左で走り出しを待つ運ぶ物の間
362
+ */
363
+ slot: { gap: 6, pad: 3, spread: 4, h: 24, radius: 7, clear: 2, lifeline: 5, mark: 4 },
313
364
  /**
314
365
  * `trail` は状態遷移図の帯の最後の、通った状態の点 (#3171)。`r` は点の半径、`step` は点の中心どうしの間、`now` は変わった値の欄の名前の横の点の半径と、名前からの離れ
315
366
  */
316
367
  strip: { h: 72, line: 44, pad: 12, icon: 24, titleX: 44, fieldGap: 22, sepInset: 14, tagGap: 6, tagH: 15, tagPadX: 7, nameY: 22, valueY: 43, trail: { r: 5.4, step: 16 }, now: { r: 3, gap: 7 } },
317
- stroke: { hair: 1, edge: 1.7, edgeOn: 2.25, arrow: 1.5, flow: 1.3, halo: 7, on: 1.75, glyph: 2, lifeline: 1.2, envelope: 1.5, badgeRing: 1.5, path: 1.6, end: 1.6, done: 1.2, trail: 1.2 },
368
+ stroke: { git: 2.25, gitOrphan: 1.5, slot: 1.2, hair: 1, edge: 1.7, edgeOn: 2.25, arrow: 1.5, flow: 1.3, halo: 7, on: 1.75, glyph: 2, lifeline: 1.2, envelope: 1.5, badgeRing: 1.5, path: 1.6, end: 1.6, done: 1.2, trail: 1.2 },
318
369
  shadow: { near: 0.8, far: 4, nearY: 1, farY: 3 },
319
370
  mini: { w: 168, pad: 8, title: 14, inset: 12, radius: 10 },
320
371
  /**
@@ -328,7 +379,7 @@ var LOOK = {
328
379
  */
329
380
  follow: { aspect: 0.75, minH: 320, fitMinH: 160, ease: 0.6, narrow: 440, badgeRoom: 8, headRoom: 10, head: { pad: 8, h: 40, nameY: 17, subY: 31 } },
330
381
  /** 色を混ぜる割合 (%) */
331
- mix: { icon: 14, regionIcon: 16, regionIconEdge: 34, cap: 12, capEdge: 42, badgePast: 14, badgePastEdge: 70, mini: 62, miniBand: 16, miniBandEdge: 36, view: 6, side: 4, sideEdge: 36, ghostEdge: 60, path: 55, past: 72 },
382
+ mix: { slot: 45, icon: 14, regionIcon: 16, regionIconEdge: 34, cap: 12, capEdge: 42, badgePast: 14, badgePastEdge: 70, mini: 62, miniBand: 16, miniBandEdge: 36, view: 6, side: 4, sideEdge: 36, ghostEdge: 60, path: 55, past: 72 },
332
383
  /** 字の並びの基準線を、置きたい高さの真ん中からどれだけ下げるか */
333
384
  baseline: { label: 3.8, badge: 3.5, carrier: 3.7, stripTitle: 4.5, tag: 3.6, action: 3.8, mark: 4 },
334
385
  /** 浮いて出る物が下から上がる長さと、弾んで出る物の始まりの大きさ */
@@ -376,6 +427,8 @@ var EASE = {
376
427
  };
377
428
 
378
429
  // src/figure-text.ts
430
+ var spaced = (word) => /[0-9A-Za-z]$/u.test(word) ? `${word} ` : word;
431
+ var capital = (text2) => text2.charAt(0).toUpperCase() + text2.slice(1);
379
432
  var FIGURE_TEXT = {
380
433
  ja: {
381
434
  cannotDraw: (detail) => `\u56F3\u3092\u63CF\u3051\u306A\u3044: ${detail}`,
@@ -390,7 +443,14 @@ var FIGURE_TEXT = {
390
443
  sideFrom: (count) => `${count} \u3064\u306E\u72B6\u614B\u304B\u3089\u5165\u308C\u308B`,
391
444
  trail: "\u901A\u3063\u305F\u72B6\u614B",
392
445
  start: "\u59CB\u307E\u308A",
393
- end: "\u7D42\u308F\u308A"
446
+ end: "\u7D42\u308F\u308A",
447
+ badgeName: (no) => `\u6BB5\u306E\u756A\u53F7 ${no}`,
448
+ quoted: (text2) => `\u300C${text2}\u300D`,
449
+ iconOf: (box) => `\u300C${box} \u306E\u7D75\u67C4\u300D`,
450
+ coin: "\u300C\u786C\u8CA8\u300D",
451
+ envelope: "\u300C\u5C01\u7B52\u300D",
452
+ textsOverlap: (a, b) => `${spaced(a)}\u3068${spaced(b)}\u304C\u91CD\u306A\u308B`,
453
+ lineCrosses: (from, to, text2) => `\u7DDA ${from} \u2192 ${to} \u304C${spaced(text2)}\u3092\u6A2A\u5207\u308B`
394
454
  },
395
455
  en: {
396
456
  cannotDraw: (detail) => `Cannot draw the diagram: ${detail}`,
@@ -405,7 +465,14 @@ var FIGURE_TEXT = {
405
465
  sideFrom: (count) => `Enterable from ${count} ${count === 1 ? "state" : "states"}`,
406
466
  trail: "States passed",
407
467
  start: "Start",
408
- end: "End"
468
+ end: "End",
469
+ badgeName: (no) => `step number ${no}`,
470
+ quoted: (text2) => `"${text2}"`,
471
+ iconOf: (box) => `the icon of "${box}"`,
472
+ coin: "the coin",
473
+ envelope: "the envelope",
474
+ textsOverlap: (a, b) => capital(`${a} and ${b} overlap`),
475
+ lineCrosses: (from, to, text2) => `The line ${from} \u2192 ${to} crosses ${text2}`
409
476
  }
410
477
  };
411
478
 
@@ -420,6 +487,10 @@ function textWidth(text2, style) {
420
487
  for (const ch of text2) sum += advance(ch, family);
421
488
  return sum * style.size / EM;
422
489
  }
490
+ function textBox(text2, x, y, style, anchor = "start") {
491
+ const w = textWidth(text2, style);
492
+ return { x: anchor === "middle" ? x - w / 2 : x, y: y - style.size * 0.8, w, h: style.size };
493
+ }
423
494
 
424
495
  // src/layout/scene.ts
425
496
  function edgesOf(diagram) {
@@ -454,11 +525,93 @@ function boxWidth(diagram, id, withActions) {
454
525
  }
455
526
  return Math.max(LOOK.box.minW, Math.max(...lines) + LOOK.box.padX * 2);
456
527
  }
528
+ function carrierHalf(carry) {
529
+ const C = LOOK.carrier;
530
+ if (carry.kind === "tag") return [(textWidth(carry.text, hasWide(carry.text) ? TYPE.carrierJa : TYPE.carrier) + C.tagPadX * 2) / 2, C.tagH / 2];
531
+ if (carry.kind === "coin") return [C.coinR, C.coinR];
532
+ return [C.envW / 2, C.envH / 2];
533
+ }
534
+ var roomWidth = (room) => room.main + room.coin + (room.main > 0 && room.coin > 0 ? LOOK.slot.spread : 0);
535
+ function slotRooms(diagram) {
536
+ const rooms = /* @__PURE__ */ new Map();
537
+ const ids = new Set(diagram.boxes.map((b) => b.id));
538
+ for (const step of diagram.steps) {
539
+ for (const event of step.events) {
540
+ if (event.type !== "edge" || event.carry.kind === "none") continue;
541
+ const who = event.carry.kind === "coin" ? "coin" : "main";
542
+ const w = carrierHalf(event.carry)[0] * 2;
543
+ for (const id of [event.from, event.to]) {
544
+ if (!ids.has(id)) continue;
545
+ const room = rooms.get(id) ?? { main: 0, coin: 0 };
546
+ room[who] = Math.max(room[who], w);
547
+ rooms.set(id, room);
548
+ }
549
+ }
550
+ }
551
+ return rooms;
552
+ }
553
+ function slotBoxWidth(room, icon, right) {
554
+ if (!room) return 0;
555
+ return (icon ? LOOK.box.icon + LOOK.slot.gap : 0) + roomWidth(room) + LOOK.slot.pad * 2 + LOOK.box.padX + right;
556
+ }
557
+ function placeSlot(box, room, right = LOOK.box.padX) {
558
+ if (!room) return;
559
+ const B = LOOK.box;
560
+ const S2 = LOOK.slot;
561
+ const w = roomWidth(room) + S2.pad * 2;
562
+ const lead = box.icon ? B.icon + S2.gap : 0;
563
+ const left = Math.max(box.x + B.padX, Math.min(box.cx - (lead + w) / 2, box.x + box.w - right - (lead + w)));
564
+ if (box.icon) box.iconX = left + B.icon / 2;
565
+ box.slot = { x: left + lead, y: box.cy + B.iconY - S2.h / 2, w, h: S2.h };
566
+ }
567
+ function seatCarriers(edges, boxes, rooms) {
568
+ const S2 = LOOK.slot;
569
+ const seat = (id, carry) => {
570
+ const box = boxes.get(id);
571
+ const room = rooms.get(id);
572
+ if (!box?.slot || !room) return void 0;
573
+ const inner = box.slot.x + S2.pad;
574
+ const y = box.slot.y + box.slot.h / 2;
575
+ if (room.main > 0 && room.coin > 0) return carry.kind === "coin" ? [inner + room.main + S2.spread + room.coin / 2, y] : [inner + room.main / 2, y];
576
+ return [box.slot.x + box.slot.w / 2, y];
577
+ };
578
+ for (const edge2 of edges) {
579
+ if (edge2.carry.kind === "none") continue;
580
+ const settle = seat(edge2.to, edge2.carry);
581
+ const wait = seat(edge2.from, edge2.carry);
582
+ if (settle) edge2.settle = settle;
583
+ if (wait) edge2.wait = wait;
584
+ }
585
+ }
457
586
  function gapBetween(a, b) {
458
587
  const dx = Math.max(b.x - (a.x + a.w), a.x - (b.x + b.w));
459
588
  const dy = Math.max(b.y - (a.y + a.h), a.y - (b.y + b.h));
460
589
  return Math.max(dx, dy);
461
590
  }
591
+ function crossesRect(points, rect, inset = 0) {
592
+ const x0 = rect.x + inset;
593
+ const y0 = rect.y + inset;
594
+ const x1 = rect.x + rect.w - inset;
595
+ const y1 = rect.y + rect.h - inset;
596
+ if (x1 <= x0 || y1 <= y0) return false;
597
+ for (let i = 1; i < points.length; i++) {
598
+ const [ax, ay] = points[i - 1];
599
+ const [bx, by] = points[i];
600
+ const dx = bx - ax;
601
+ const dy = by - ay;
602
+ let lo = 0;
603
+ let hi = 1;
604
+ const cut = (p, q) => {
605
+ if (p === 0) return q > 0;
606
+ const r = q / p;
607
+ if (p < 0) lo = Math.max(lo, r);
608
+ else hi = Math.min(hi, r);
609
+ return lo < hi;
610
+ };
611
+ if (cut(-dx, ax - x0) && cut(dx, x1 - ax) && cut(-dy, ay - y0) && cut(dy, y1 - ay)) return true;
612
+ }
613
+ return false;
614
+ }
462
615
  function longest(points) {
463
616
  let best = { a: points[0], b: points[1] ?? points[0], length: -1 };
464
617
  for (let i = 1; i < points.length; i++) {
@@ -489,34 +642,122 @@ function pathLength(points) {
489
642
  }
490
643
  return sum;
491
644
  }
492
- function badgeOnPath(points) {
645
+ function loopUnder(box) {
646
+ const { w, h, samples } = LOOK.state.loop;
647
+ const bottom = box.y + box.h;
648
+ const p0 = [box.cx + w / 2, bottom];
649
+ const c1 = [box.cx + w * 3 / 4, bottom + h * 4 / 3];
650
+ const c2 = [box.cx - w * 3 / 4, bottom + h * 4 / 3];
651
+ const p3 = [box.cx - w / 2, bottom + LOOK.edge.inset];
652
+ return Array.from({ length: samples + 1 }, (_, k) => {
653
+ const t = k / samples;
654
+ const u = 1 - t;
655
+ const at2 = (i) => u * u * u * p0[i] + 3 * u * u * t * c1[i] + 3 * u * t * t * c2[i] + t * t * t * p3[i];
656
+ return [at2(0), at2(1)];
657
+ });
658
+ }
659
+ function loopBadge(points) {
660
+ const right = Math.max(...points.map(([px]) => px));
661
+ const top = points[0][1];
662
+ const deep = Math.max(...points.map(([, py]) => py));
663
+ return [right + LOOK.badge.r + LOOK.badge.inset, top + (deep - top) * LOOK.state.loop.badgeAt];
664
+ }
665
+ function loopLabelBase(points, w) {
666
+ return { x: (points[0]?.[0] ?? 0) - LOOK.state.loop.w / 2 - w / 2, y: Math.max(...points.map(([, y]) => y)) + LOOK.label.soft };
667
+ }
668
+ var LOOP_ROOM = LOOK.state.loop.h + LOOK.label.soft * 2 + LOOK.label.h;
669
+ function badgeOnPath(points, taken = [], lines = []) {
670
+ const length = pathLength(points);
671
+ const first = length < LOOK.badge.short ? Math.min(LOOK.badge.r + 1, length / 2) : LOOK.badge.along;
672
+ const apart = LOOK.badge.r * 2 + LOOK.badge.inset;
673
+ for (let d = first; d <= length; d += 1) {
674
+ const p = along(points, d);
675
+ if (taken.every(([x, y]) => Math.hypot(p[0] - x, p[1] - y) >= apart)) return p;
676
+ }
677
+ return besideLine(points, first, taken, lines) ?? along(points, first);
678
+ }
679
+ function besideLine(points, at2, taken, lines) {
493
680
  const length = pathLength(points);
494
- return along(points, length < LOOK.badge.short ? length / 2 : LOOK.badge.along);
681
+ const [px, py] = along(points, at2);
682
+ const [ax, ay] = along(points, Math.max(0, at2 - 1));
683
+ const [bx, by] = along(points, Math.min(length, at2 + 1));
684
+ const n = Math.hypot(bx - ax, by - ay);
685
+ if (n === 0) return void 0;
686
+ const [nx, ny] = [-(by - ay) / n, (bx - ax) / n];
687
+ const size = LOOK.badge.r * 2;
688
+ for (const margin of [LOOK.edge.arrowHalf, 0]) {
689
+ for (let s = 1; s <= size + LOOK.badge.inset; s++) {
690
+ for (const sign of [1, -1]) {
691
+ const c = [px + nx * s * sign, py + ny * s * sign];
692
+ const free = taken.every(([x, y]) => Math.max(Math.abs(c[0] - x), Math.abs(c[1] - y)) >= size + 1);
693
+ if (free && lines.every((line) => !crossesRect(line, badgeRect(c), -margin))) return c;
694
+ }
695
+ }
696
+ }
697
+ return void 0;
698
+ }
699
+ var lineKey = (edge2) => edge2.points.map(([x, y]) => `${Math.round(x * 10)},${Math.round(y * 10)}`).join(" ");
700
+ function lineBadges(edges, steps, at2 = (edge2, taken, lines) => badgeOnPath(edge2.points, taken, lines)) {
701
+ const out = /* @__PURE__ */ new Map();
702
+ const taken = [];
703
+ const placed = /* @__PURE__ */ new Map();
704
+ for (let s = 0; s < steps; s++) {
705
+ const edge2 = edges.find((e) => e.step === s && e.points.length > 0);
706
+ if (!edge2) continue;
707
+ const key = lineKey(edge2);
708
+ const before = placed.get(key);
709
+ if (before) {
710
+ out.set(s, { point: before, edge: edge2 });
711
+ continue;
712
+ }
713
+ const lines = edges.filter((e) => e.points.length > 1 && lineKey(e) !== key).map((e) => e.points);
714
+ const point = at2(edge2, taken, lines);
715
+ taken.push(point);
716
+ placed.set(key, point);
717
+ out.set(s, { point, edge: edge2 });
718
+ }
719
+ return out;
720
+ }
721
+ function replaceSameSpot(badges2) {
722
+ const same2 = (a, b) => Math.hypot(a.x - b.x, a.y - b.y) <= 0.5;
723
+ return badges2.map((badge2) => {
724
+ const next = badges2.filter((other) => other.step > badge2.step && same2(other, badge2)).sort((a, b) => a.step - b.step)[0];
725
+ return next ? { ...badge2, until: next.step } : badge2;
726
+ });
495
727
  }
728
+ var badgeRect = ([x, y]) => ({ x: x - LOOK.badge.r, y: y - LOOK.badge.r, w: LOOK.badge.r * 2, h: LOOK.badge.r * 2 });
729
+ var markText = (e) => [e.x + LOOK.state.text, e.y + LOOK.baseline.mark];
496
730
  var labelStyle = (text2) => hasWide(text2) ? TYPE.labelJa : TYPE.label;
731
+ var OPPOSITE = { above: "below", below: "above", left: "right", right: "left" };
497
732
  function placeLabel(request, obstacles) {
498
733
  const w = textWidth(request.text, labelStyle(request.text)) + LOOK.label.padX * 2;
499
734
  const h = LOOK.label.h;
500
735
  const segment = longest(request.points);
501
736
  const mx = (segment.a[0] + segment.b[0]) / 2;
502
737
  const my = (segment.a[1] + segment.b[1]) / 2;
503
- const side2 = request.side ?? (segment.vertical ? "right" : "above");
504
- const { offset, side: sideGap } = LOOK.label;
505
- const base = side2 === "above" ? { x: mx - w / 2, y: my - offset - h / 2, w, h } : side2 === "below" ? { x: mx - w / 2, y: my + offset - h / 2, w, h } : side2 === "left" ? { x: mx - sideGap - w, y: my - h / 2, w, h } : { x: mx + sideGap, y: my - h / 2, w, h };
506
- const away = side2 === "above" ? [0, -1] : side2 === "below" ? [0, 1] : side2 === "left" ? [-1, 0] : [1, 0];
507
- const slideAxis = [Math.abs(away[1]), Math.abs(away[0])];
508
- const slideMax = side2 === "above" || side2 === "below" ? w : h * 4;
509
- const clear = (rect) => obstacles.hard.every((box) => gapBetween(rect, box) >= LOOK.gap) && obstacles.soft.every((other) => gapBetween(rect, other) >= LOOK.label.soft);
738
+ const preferred = request.side ?? (segment.vertical ? "right" : "above");
739
+ const { side: sideGap } = LOOK.label;
740
+ const offset = request.offset ?? LOOK.label.offset;
741
+ const baseOf = (side2) => side2 === "above" ? { x: mx - w / 2, y: my - offset - h / 2, w, h } : side2 === "below" ? { x: mx - w / 2, y: my + offset - h / 2, w, h } : side2 === "left" ? { x: mx - sideGap - w, y: my - h / 2, w, h } : { x: mx + sideGap, y: my - h / 2, w, h };
742
+ const first = request.base ? { ...request.base, w, h } : baseOf(preferred);
743
+ const sides = request.flip ? [preferred, OPPOSITE[preferred]] : [preferred];
744
+ const clear = (rect) => obstacles.hard.every((box) => gapBetween(rect, box) >= LOOK.gap) && obstacles.soft.every((other) => gapBetween(rect, other) >= LOOK.label.soft) && (obstacles.touch ?? []).every((mark) => gapBetween(rect, mark) >= LOOK.label.touch) && (obstacles.lines ?? []).every((line) => !crossesRect(line, rect, -2));
510
745
  const { search, searchMax } = LOOK.label;
511
746
  for (let d = 0; d <= searchMax; d += search) {
512
- for (let s = 0; s <= slideMax; s += search) {
513
- for (const sign of s === 0 ? [1] : [1, -1]) {
514
- const rect = { x: base.x + away[0] * d + slideAxis[0] * s * sign, y: base.y + away[1] * d + slideAxis[1] * s * sign, w, h };
515
- if (clear(rect)) return { ...rect, step: request.step, event: request.event, text: request.text, family: labelStyle(request.text).family, color: request.color };
747
+ for (const side2 of sides) {
748
+ const base = side2 === preferred ? first : baseOf(side2);
749
+ const away = side2 === "above" ? [0, -1] : side2 === "below" ? [0, 1] : side2 === "left" ? [-1, 0] : [1, 0];
750
+ const slideAxis = [Math.abs(away[1]), Math.abs(away[0])];
751
+ const slideMax = request.slide ?? (side2 === "above" || side2 === "below" ? w : h * 4);
752
+ for (let s = 0; s <= slideMax; s += search) {
753
+ for (const sign of s === 0 ? [1] : [1, -1]) {
754
+ const rect = { x: base.x + away[0] * d + slideAxis[0] * s * sign, y: base.y + away[1] * d + slideAxis[1] * s * sign, w, h };
755
+ if (clear(rect)) return { ...rect, step: request.step, event: request.event, text: request.text, family: labelStyle(request.text).family, color: request.color };
756
+ }
516
757
  }
517
758
  }
518
759
  }
519
- return { ...base, step: request.step, event: request.event, text: request.text, family: labelStyle(request.text).family, color: request.color };
760
+ return { ...first, step: request.step, event: request.event, text: request.text, family: labelStyle(request.text).family, color: request.color };
520
761
  }
521
762
  function fieldWidth(diagram, name) {
522
763
  let value = 0;
@@ -571,6 +812,8 @@ function shiftContent(layout, dx, dy) {
571
812
  move(box);
572
813
  box.cx += dx;
573
814
  box.cy += dy;
815
+ if (box.slot) move(box.slot);
816
+ if (box.iconX !== void 0) box.iconX += dx;
574
817
  }
575
818
  for (const region of layout.regions) {
576
819
  region.y += dy;
@@ -584,6 +827,7 @@ function shiftContent(layout, dx, dy) {
584
827
  for (const edge2 of layout.edges) {
585
828
  edge2.points = edge2.points.map(([px, py]) => [px + dx, py + dy]);
586
829
  if (edge2.settle) edge2.settle = [edge2.settle[0] + dx, edge2.settle[1] + dy];
830
+ if (edge2.wait) edge2.wait = [edge2.wait[0] + dx, edge2.wait[1] + dy];
587
831
  }
588
832
  for (const label2 of layout.labels) move(label2);
589
833
  for (const path2 of layout.paths) {
@@ -617,11 +861,11 @@ function cornerBadge(events, step, layout) {
617
861
  for (const event of events) {
618
862
  const id = event.type === "swap" || event.type === "action" ? event.box : void 0;
619
863
  const box2 = layout.boxes.find((b) => b.id === id);
620
- if (box2) return { step, x: box2.x + inset, y: box2.y + inset, color: box2.color };
864
+ if (box2) return { step, x: box2.x, y: box2.y, color: box2.color };
621
865
  }
622
866
  if (layout.strip && events.some((event) => event.type === "strip")) return { step, x: layout.strip.x + inset, y: layout.strip.y + inset, color: "slate" };
623
867
  const box = layout.boxes[0];
624
- return { step, x: box.x + inset, y: box.y + inset, color: box.color };
868
+ return { step, x: box.x, y: box.y, color: box.color };
625
869
  }
626
870
 
627
871
  // src/layout/architecture.ts
@@ -720,7 +964,8 @@ function arrange(diagram, groups, slots, rooms) {
720
964
  const regionColor = regionColors(diagram);
721
965
  const edges = edgesOf(diagram);
722
966
  const columnCount = Math.max(1, ...[...slots.values()].map((s) => s.col + 1));
723
- const widths = new Map(diagram.boxes.map((b) => [b.id, boxWidth(diagram, b.id, true)]));
967
+ const carriedIn = slotRooms(diagram);
968
+ const widths = new Map(diagram.boxes.map((b) => [b.id, Math.max(boxWidth(diagram, b.id, true), slotBoxWidth(carriedIn.get(b.id), b.icon !== void 0, B.padX))]));
724
969
  const colW = Array.from({ length: columnCount }, (_, c) => Math.max(B.minW, ...[...slots].filter(([, s]) => s.col === c).map(([id]) => widths.get(id) ?? B.minW)));
725
970
  const between = Array.from({ length: Math.max(0, columnCount - 1) }, () => A.columnGap);
726
971
  for (const { edge: edge2 } of edges) {
@@ -735,7 +980,13 @@ function arrange(diagram, groups, slots, rooms) {
735
980
  const headerW = Math.max(0, ...headers.map((h) => h ? h.w + R.inset * 2 : 0));
736
981
  const colLeft = [];
737
982
  for (let c = 0; c < columnCount; c++) colLeft.push(c === 0 ? margin + (headerW > 0 ? headerW : R.pad) : colLeft[c - 1] + colW[c - 1] + between[c - 1]);
738
- const center = (c) => colLeft[c] + colW[c] / 2;
983
+ const center2 = (c) => colLeft[c] + colW[c] / 2;
984
+ const looped = new Set(edges.filter(({ edge: edge2 }) => edge2.from === edge2.to).map(({ edge: edge2 }) => edge2.from));
985
+ const loopRows = new Set([...looped].flatMap((id) => {
986
+ const slot = slots.get(id);
987
+ return slot ? [`${slot.group}:${slot.row}`] : [];
988
+ }));
989
+ const loopRoom = (g, row) => loopRows.has(`${g}:${row}`) ? LOOP_ROOM : 0;
739
990
  const boxes = [];
740
991
  const bands = [];
741
992
  let cursor = margin;
@@ -743,12 +994,14 @@ function arrange(diagram, groups, slots, rooms) {
743
994
  const rows = Math.max(1, ...group.members.map((id) => (slots.get(id)?.row ?? 0) + 1));
744
995
  const room = rooms[g];
745
996
  const top = cursor + R.pad + room.top;
997
+ const rowTop = [0];
998
+ for (let r = 1; r < rows; r++) rowTop.push(rowTop[r - 1] + B.h + A.rowGap + loopRoom(g, r - 1));
746
999
  for (const id of group.members) {
747
1000
  const slot = slots.get(id);
748
1001
  const source = diagram.boxes.find((b) => b.id === id);
749
1002
  const w = widths.get(id) ?? B.minW;
750
- const cx = center(slot.col);
751
- const y = top + slot.row * (B.h + A.rowGap);
1003
+ const cx = center2(slot.col);
1004
+ const y = top + rowTop[slot.row];
752
1005
  boxes.push({
753
1006
  id,
754
1007
  name: source?.name ?? id,
@@ -763,29 +1016,36 @@ function arrange(diagram, groups, slots, rooms) {
763
1016
  cy: y + B.h / 2
764
1017
  });
765
1018
  }
766
- const contentBottom = top + rows * B.h + (rows - 1) * A.rowGap;
1019
+ const contentBottom2 = top + rowTop[rows - 1] + B.h + loopRoom(g, rows - 1);
767
1020
  const header = headers[g];
768
- const h = Math.max(contentBottom + R.pad + room.bottom - cursor, header ? header.h + R.inset * 2 : 0, group.region ? R.minH : 0);
1021
+ const h = Math.max(contentBottom2 + R.pad + room.bottom - cursor, header ? header.h + R.inset * 2 : 0, group.region ? R.minH : 0);
769
1022
  bands.push({ group: g, y: cursor, h, rows });
770
1023
  cursor += h + R.gap;
771
1024
  });
772
1025
  const bandsBottom = cursor - R.gap;
1026
+ for (const box of boxes) placeSlot(box, carriedIn.get(box.id));
773
1027
  const byId = new Map(boxes.map((b) => [b.id, b]));
774
1028
  const bandOf = (id) => bands[slots.get(id)?.group ?? 0];
775
- const blocked = (points, a, b) => boxes.some((box) => {
776
- if (box.id === a || box.id === b) return false;
777
- const pad2 = LOOK.label.search;
1029
+ const crosses = (points, rect, pad2) => {
778
1030
  for (let i = 1; i < points.length; i++) {
779
1031
  const [x1, y1] = points[i - 1];
780
1032
  const [x2, y2] = points[i];
781
- if (Math.min(x1, x2) <= box.x + box.w + pad2 && Math.max(x1, x2) >= box.x - pad2 && Math.min(y1, y2) <= box.y + box.h + pad2 && Math.max(y1, y2) >= box.y - pad2) return true;
1033
+ if (Math.min(x1, x2) <= rect.x + rect.w + pad2 && Math.max(x1, x2) >= rect.x - pad2 && Math.min(y1, y2) <= rect.y + rect.h + pad2 && Math.max(y1, y2) >= rect.y - pad2) return true;
782
1034
  }
783
1035
  return false;
1036
+ };
1037
+ const loopZones = [...looped].flatMap((id) => {
1038
+ const box = byId.get(id);
1039
+ return box ? [{ x: box.x, y: box.y + box.h, w: box.w, h: LOOP_ROOM }] : [];
784
1040
  });
1041
+ const onLoop = (points) => loopZones.some((zone) => crosses(points, zone, 0));
1042
+ const blocked = (points, a, b) => boxes.some((box) => box.id !== a && box.id !== b && crosses(points, box, LOOK.label.search)) || onLoop(points);
785
1043
  const laneBelow = (id) => {
786
1044
  const box = byId.get(id);
787
1045
  const band2 = bandOf(id);
788
- return (slots.get(id)?.row ?? 0) < band2.rows - 1 ? box.y + box.h + A.rowGap / 2 : Math.min(box.y + box.h + R.pad / 2, band2.y + band2.h - LOOK.edge.inset);
1046
+ const slot = slots.get(id);
1047
+ const under = box.y + box.h + (slot ? loopRoom(slot.group, slot.row) : 0);
1048
+ return (slot?.row ?? 0) < band2.rows - 1 ? under + A.rowGap / 2 : Math.min(under + R.pad / 2, band2.y + band2.h - LOOK.edge.inset);
789
1049
  };
790
1050
  const laneAbove = (id) => {
791
1051
  const box = byId.get(id);
@@ -793,9 +1053,11 @@ function arrange(diagram, groups, slots, rooms) {
793
1053
  return (slots.get(id)?.row ?? 0) > 0 ? box.y - A.rowGap / 2 : Math.max(box.y - R.pad / 2, band2.y + LOOK.edge.inset);
794
1054
  };
795
1055
  const inset = LOOK.edge.inset;
1056
+ const gapX = (col, toRight) => toRight ? colLeft[col] + colW[col] + (between[col] ?? A.columnGap) / 2 : colLeft[col] - (between[col - 1] ?? A.columnGap) / 2;
796
1057
  const route = (from, to) => {
797
1058
  const a = byId.get(from);
798
1059
  const b = byId.get(to);
1060
+ if (from === to) return loopUnder(a);
799
1061
  const sa = slots.get(from);
800
1062
  const sb = slots.get(to);
801
1063
  if (sa.group === sb.group && sa.row === sb.row) {
@@ -805,13 +1067,22 @@ function arrange(diagram, groups, slots, rooms) {
805
1067
  [right2 ? b.x - inset : b.x + b.w + inset, b.cy]
806
1068
  ];
807
1069
  if (!blocked(straight, from, to)) return straight;
808
- const lane2 = laneBelow(from);
809
- return [
1070
+ const below = laneBelow(from);
1071
+ const under = [
810
1072
  [a.cx, a.y + a.h],
811
- [a.cx, lane2],
812
- [b.cx, lane2],
1073
+ [a.cx, below],
1074
+ [b.cx, below],
813
1075
  [b.cx, b.y + b.h + inset]
814
1076
  ];
1077
+ if (!onLoop(under)) return under;
1078
+ const above = laneAbove(from);
1079
+ const over = [
1080
+ [a.cx, a.y],
1081
+ [a.cx, above],
1082
+ [b.cx, above],
1083
+ [b.cx, b.y - inset]
1084
+ ];
1085
+ return onLoop(over) ? under : over;
815
1086
  }
816
1087
  const down = b.cy > a.cy;
817
1088
  const leave = [a.cx, down ? a.y + a.h : a.y];
@@ -819,7 +1090,7 @@ function arrange(diagram, groups, slots, rooms) {
819
1090
  if (sa.col === sb.col) {
820
1091
  const straight = [leave, enter];
821
1092
  if (!blocked(straight, from, to)) return straight;
822
- const x = a.x + a.w + (between[sa.col] ?? A.columnGap) / 2;
1093
+ const x = gapX(sa.col, true);
823
1094
  return [
824
1095
  [a.x + a.w, a.cy],
825
1096
  [x, a.cy],
@@ -834,21 +1105,34 @@ function arrange(diagram, groups, slots, rooms) {
834
1105
  [[right ? a.x + a.w : a.x, a.cy], [b.cx, a.cy], enter],
835
1106
  [leave, [a.cx, lane], [b.cx, lane], enter]
836
1107
  ];
1108
+ if (looped.has(from) || looped.has(to)) {
1109
+ const ax = gapX(sa.col, right);
1110
+ const bx = gapX(sb.col, !right);
1111
+ const out = [
1112
+ [right ? a.x + a.w : a.x, a.cy],
1113
+ [ax, a.cy]
1114
+ ];
1115
+ const side2 = [right ? b.x - inset : b.x + b.w + inset, b.cy];
1116
+ candidates.push(
1117
+ [...out, [ax, b.cy], side2],
1118
+ [...out, [ax, lane], [b.cx, lane], enter],
1119
+ [leave, [a.cx, lane], [bx, lane], [bx, b.cy], side2],
1120
+ [...out, [ax, lane], [bx, lane], [bx, b.cy], side2]
1121
+ );
1122
+ }
837
1123
  return candidates.find((points) => !blocked(points, from, to)) ?? candidates[2];
838
1124
  };
839
- const sceneEdges = edges.map(({ step, event, edge: edge2 }) => {
840
- const target = byId.get(edge2.to);
841
- return {
842
- step,
843
- event,
844
- from: edge2.from,
845
- to: edge2.to,
846
- points: route(edge2.from, edge2.to),
847
- color: edgeColor(edge2, colors),
848
- carry: edge2.carry,
849
- settle: [target.cx, target.cy + B.iconY]
850
- };
851
- });
1125
+ const sceneEdges = edges.map(({ step, event, edge: edge2 }) => ({
1126
+ step,
1127
+ event,
1128
+ from: edge2.from,
1129
+ to: edge2.to,
1130
+ points: route(edge2.from, edge2.to),
1131
+ color: edgeColor(edge2, colors),
1132
+ carry: edge2.carry
1133
+ }));
1134
+ seatCarriers(sceneEdges, byId, carriedIn);
1135
+ const outward = /* @__PURE__ */ new Map();
852
1136
  for (const edge2 of sceneEdges) {
853
1137
  if (edge2.points.length !== 2) continue;
854
1138
  const back = sceneEdges.some((other) => other.from === edge2.to && other.to === edge2.from && other.points.length === 2);
@@ -857,6 +1141,7 @@ function arrange(diagram, groups, slots, rooms) {
857
1141
  const flat = Math.abs(q[1] - p[1]) < Math.abs(q[0] - p[0]);
858
1142
  const d = (edge2.from < edge2.to ? 1 : -1) * LOOK.edge.parallel;
859
1143
  edge2.points = edge2.points.map(([x, y]) => flat ? [x, y + d] : [x + d, y]);
1144
+ outward.set(edge2, flat ? d > 0 ? "below" : "above" : d > 0 ? "right" : "left");
860
1145
  }
861
1146
  const regions = [];
862
1147
  groups.forEach((group, g) => {
@@ -876,15 +1161,20 @@ function arrange(diagram, groups, slots, rooms) {
876
1161
  header: { x: margin + R.inset, y: band2.y + R.inset, w: header.w, h: header.h }
877
1162
  });
878
1163
  });
1164
+ const badgeAt = (edge2, taken, lines2) => edge2.from === edge2.to ? loopBadge(edge2.points) : badgeOnPath(edge2.points, taken, lines2);
1165
+ const early = lineBadges(sceneEdges, diagram.steps.length, badgeAt);
879
1166
  const labels = [];
880
1167
  for (const edge2 of sceneEdges) {
881
1168
  const source = diagram.steps[edge2.step]?.events[edge2.event];
882
1169
  if (source?.type !== "edge" || source.label === void 0) continue;
1170
+ const seen = [...early].filter(([s]) => s <= edge2.step).map(([, b]) => badgeRect(b.point));
883
1171
  const soft = [...regions.map((r) => r.header), ...labels.filter((l) => l.step === edge2.step)];
1172
+ const side2 = source.labelSide ?? outward.get(edge2);
1173
+ const below = edge2.from === edge2.to ? { side: "below", base: loopLabelBase(edge2.points, textWidth(source.label, labelStyle(source.label)) + LOOK.label.padX * 2) } : void 0;
884
1174
  labels.push(
885
1175
  placeLabel(
886
- { step: edge2.step, event: edge2.event, text: source.label, points: edge2.points, color: edge2.color, ...source.labelSide ? { side: source.labelSide } : {} },
887
- { hard: boxes, soft }
1176
+ { step: edge2.step, event: edge2.event, text: source.label, points: edge2.points, color: edge2.color, ...below ?? (side2 ? { side: side2 } : { flip: true }) },
1177
+ { hard: boxes, soft, touch: seen }
888
1178
  )
889
1179
  );
890
1180
  }
@@ -894,16 +1184,19 @@ function arrange(diagram, groups, slots, rooms) {
894
1184
  const contentRight = Math.max(...boxes.map((b) => b.x + b.w + R.pad), ...labels.map((l) => l.x + l.w + LOOK.label.soft), ...sceneEdges.flatMap((e) => e.points.map((p) => p[0] + R.pad)));
895
1185
  const width = Math.max(contentRight + margin, stripNeed(diagram) + margin * 2);
896
1186
  for (const region of regions) region.w = width - margin * 2;
897
- const strip2 = layoutStrip(diagram, margin, bandsBottom + gap, width - margin * 2);
1187
+ const contentBottom = Math.max(bandsBottom, ...labels.map((l) => l.y + l.h));
1188
+ const strip2 = layoutStrip(diagram, margin, contentBottom + gap, width - margin * 2);
898
1189
  layout.width = width;
899
- layout.height = (strip2 ? strip2.y + strip2.h : bandsBottom) + margin;
1190
+ layout.height = (strip2 ? strip2.y + strip2.h : contentBottom) + margin;
900
1191
  if (strip2) layout.strip = strip2;
901
- layout.badges = diagram.steps.map((step, s) => {
902
- const edge2 = sceneEdges.find((e) => e.step === s);
903
- if (!edge2) return cornerBadge(step.events, s, layout);
904
- const [x, y] = badgeOnPath(edge2.points);
905
- return { step: s, x, y, color: edge2.color };
906
- });
1192
+ const lines = lineBadges(sceneEdges, diagram.steps.length, badgeAt);
1193
+ layout.badges = replaceSameSpot(
1194
+ diagram.steps.map((step, s) => {
1195
+ const line = lines.get(s);
1196
+ if (!line) return cornerBadge(step.events, s, layout);
1197
+ return { step: s, x: line.point[0], y: line.point[1], color: line.edge.color };
1198
+ })
1199
+ );
907
1200
  return layout;
908
1201
  }
909
1202
  function grow(layout, groups, slots, rooms) {
@@ -930,6 +1223,494 @@ function grow(layout, groups, slots, rooms) {
930
1223
  }
931
1224
  return grown;
932
1225
  }
1226
+ var STATE_ENDS = ["start", "finish"];
1227
+ var HEAD = "HEAD";
1228
+
1229
+ // src/layout/git.ts
1230
+ var isGitLayout = (layout) => layout.kind === "git";
1231
+ function walk(diagram) {
1232
+ const branches = (diagram.git?.branches ?? []).map((b) => b.id);
1233
+ const lane = (id) => {
1234
+ if (!branches.includes(id)) branches.push(id);
1235
+ };
1236
+ for (const step of diagram.steps) for (const e of step.events) if (e.type === "commit" || e.type === "branch") lane(e.branch);
1237
+ const tips = new Map(branches.map((b) => [b, null]));
1238
+ let headAt = null;
1239
+ let attached = null;
1240
+ const made = [];
1241
+ const byId = /* @__PURE__ */ new Map();
1242
+ const links = [];
1243
+ const moves = [];
1244
+ const tags = [];
1245
+ const rows = /* @__PURE__ */ new Map();
1246
+ const most = /* @__PURE__ */ new Map();
1247
+ const shown = /* @__PURE__ */ new Map();
1248
+ const names = [...branches, HEAD];
1249
+ const at2 = new Map(names.map((n) => [n, []]));
1250
+ const heads = [];
1251
+ const visible2 = (ref) => ref === HEAD ? attached === null ? headAt : null : tips.get(ref) ?? null;
1252
+ const freeRow = (commit2) => {
1253
+ const list = rows.get(commit2) ?? [];
1254
+ const free = list.indexOf(null);
1255
+ return free < 0 ? list.length : free;
1256
+ };
1257
+ const settle = (step, event, change, lineFor) => {
1258
+ const before = new Map(names.map((n) => [n, visible2(n)]));
1259
+ const headBefore = headAt;
1260
+ change();
1261
+ const changed = names.filter((n) => before.get(n) !== visible2(n));
1262
+ const leaving = changed.map((ref) => {
1263
+ const slot = shown.get(ref);
1264
+ if (slot) {
1265
+ rows.get(slot.commit)[slot.row] = null;
1266
+ shown.delete(ref);
1267
+ }
1268
+ return { ref, slot };
1269
+ });
1270
+ for (const { ref, slot } of leaving) {
1271
+ const from = slot ?? (ref === HEAD && headBefore !== null ? { commit: headBefore, row: freeRow(headBefore) } : void 0);
1272
+ const target = visible2(ref);
1273
+ let to;
1274
+ if (target !== null) {
1275
+ to = { commit: target, row: freeRow(target) };
1276
+ const list = rows.get(target) ?? [];
1277
+ list[to.row] = ref;
1278
+ rows.set(target, list);
1279
+ most.set(target, Math.max(most.get(target) ?? 0, list.filter((r) => r !== null).length));
1280
+ shown.set(ref, to);
1281
+ }
1282
+ moves.push({ ref, step, event, ...from ? { from } : {}, ...to ? { to } : {}, line: ref === lineFor });
1283
+ }
1284
+ };
1285
+ const prune = (step, event) => {
1286
+ const reach = /* @__PURE__ */ new Set();
1287
+ const stack = [...tips.values(), headAt].filter((c) => c !== null);
1288
+ while (stack.length > 0) {
1289
+ const id = stack.pop();
1290
+ if (reach.has(id)) continue;
1291
+ reach.add(id);
1292
+ stack.push(...byId.get(id)?.parents ?? []);
1293
+ }
1294
+ for (const c of made) if (!reach.has(c.id) && c.orphan === void 0) c.orphan = { step, event };
1295
+ };
1296
+ diagram.steps.forEach((step, s) => {
1297
+ step.events.forEach((e, k) => {
1298
+ if (e.type === "commit") commit(e, s, k);
1299
+ else if (e.type === "branch") {
1300
+ if (!byId.has(e.from)) return;
1301
+ if (laneOf(e.from) !== e.branch) links.push({ kind: "branch", from: e.from, to: e.branch, step: s, event: k });
1302
+ settle(s, k, () => {
1303
+ tips.set(e.branch, e.from);
1304
+ attached = e.branch;
1305
+ headAt = e.from;
1306
+ });
1307
+ } else if (e.type === "edge") {
1308
+ const ref = e.from;
1309
+ if (ref !== HEAD && !tips.has(ref) || !byId.has(e.to)) return;
1310
+ settle(
1311
+ s,
1312
+ k,
1313
+ () => {
1314
+ if (ref === HEAD) {
1315
+ attached = null;
1316
+ headAt = e.to;
1317
+ return;
1318
+ }
1319
+ tips.set(ref, e.to);
1320
+ if (attached === ref) headAt = e.to;
1321
+ else if (attached === null && headAt === e.to) attached = ref;
1322
+ },
1323
+ ref
1324
+ );
1325
+ } else return;
1326
+ prune(s, k);
1327
+ });
1328
+ for (const n of names) at2.get(n)?.push(n === HEAD ? headAt : tips.get(n) ?? null);
1329
+ heads.push(attached);
1330
+ for (const n of names) {
1331
+ const slot = shown.get(n);
1332
+ if (slot) tags.push({ ref: n, step: s, slot });
1333
+ }
1334
+ });
1335
+ function laneOf(id) {
1336
+ return byId.get(id)?.branch;
1337
+ }
1338
+ function commit(e, s, k) {
1339
+ if (byId.has(e.id)) return;
1340
+ const copy = e.copy !== void 0 && byId.has(e.copy) ? e.copy : void 0;
1341
+ const base = copy !== void 0 && attached === null && headAt !== null ? headAt : tips.get(e.branch) ?? null;
1342
+ const joined = e.merge !== void 0 && e.merge !== e.branch ? tips.get(e.merge) ?? void 0 : void 0;
1343
+ const parents = [...new Set([base, joined].filter((c2) => c2 !== null && c2 !== void 0))];
1344
+ const c = {
1345
+ id: e.id,
1346
+ branch: e.branch,
1347
+ parents,
1348
+ ...joined !== void 0 && joined !== base ? { joined } : {},
1349
+ ...copy !== void 0 ? { copy } : {},
1350
+ ...e.hash !== void 0 ? { hash: e.hash } : {},
1351
+ ...e.note !== void 0 ? { note: e.note } : {},
1352
+ step: s,
1353
+ event: k
1354
+ };
1355
+ made.push(c);
1356
+ byId.set(c.id, c);
1357
+ for (const p of parents) links.push({ kind: "parent", from: p, to: c.id, step: s, event: k });
1358
+ if (copy !== void 0) links.push({ kind: "copy", from: copy, to: c.id, step: s, event: k });
1359
+ const first = attached === null && headAt === null;
1360
+ settle(s, k, () => {
1361
+ if (copy === void 0) {
1362
+ tips.set(e.branch, c.id);
1363
+ if (attached === e.branch) headAt = c.id;
1364
+ } else if (attached === null) headAt = c.id;
1365
+ if (first) {
1366
+ attached = e.branch;
1367
+ headAt = c.id;
1368
+ }
1369
+ });
1370
+ }
1371
+ const refs = names.map((name) => ({ name, at: at2.get(name) ?? [], ...name === HEAD ? { attached: heads } : {} }));
1372
+ return { branches, made, links, moves, refs, tags, rows: most };
1373
+ }
1374
+ function cubic(p0, c1, c2, p3) {
1375
+ const n = LOOK.git.samples;
1376
+ return Array.from({ length: n }, (_, k) => {
1377
+ const t = (k + 1) / n;
1378
+ const u = 1 - t;
1379
+ const at2 = (i) => u * u * u * p0[i] + 3 * u * u * t * c1[i] + 3 * u * t * t * c2[i] + t * t * t * p3[i];
1380
+ return [at2(0), at2(1)];
1381
+ });
1382
+ }
1383
+ function elbow(from, to) {
1384
+ if (Math.abs(from[1] - to[1]) < 0.5) return [from, to];
1385
+ return from[1] > to[1] ? [from, [from[0], to[1]], to] : [from, [to[0], from[1]], to];
1386
+ }
1387
+ function fork(p, tx, ty) {
1388
+ const sign = ty > p.cy ? 1 : -1;
1389
+ const p0 = [p.cx, p.cy + sign * p.r];
1390
+ const turn = Math.max(0, Math.min(LOOK.git.turn, tx - p.cx));
1391
+ const p3 = [p.cx + turn, ty];
1392
+ const curve = cubic(p0, [p0[0], p0[1] + (ty - p0[1]) * 0.7], [p.cx + turn * 0.2, ty], p3);
1393
+ return [p0, ...curve, ...tx > p3[0] ? [[tx, ty]] : []];
1394
+ }
1395
+ function join(p, c) {
1396
+ const sign = c.cy < p.cy ? 1 : -1;
1397
+ const p0 = [p.cx + p.r, p.cy];
1398
+ const p3 = [c.cx, c.cy + sign * c.r];
1399
+ const turn = Math.max(0, Math.min(LOOK.git.turn, c.cx - p0[0]));
1400
+ const h = [c.cx - turn, p.cy];
1401
+ const curve = cubic(h, [c.cx - turn * 0.2, p.cy], [c.cx, p3[1] + (p.cy - p3[1]) * 0.7], p3);
1402
+ return [p0, ...h[0] > p0[0] ? [h] : [], ...curve];
1403
+ }
1404
+ function copyLine(p, c) {
1405
+ if (Math.abs(p.cy - c.cy) < 0.5) {
1406
+ const top = p.cy - p.r;
1407
+ const lift = LOOK.git.turn * 0.7;
1408
+ return [[p.cx, top], ...cubic([p.cx, top], [p.cx, top - lift], [c.cx, top - lift], [c.cx, top])];
1409
+ }
1410
+ const sign = c.cy < p.cy ? -1 : 1;
1411
+ const p0 = [p.cx, p.cy + sign * p.r];
1412
+ const p3 = [c.cx, c.cy - sign * c.r];
1413
+ const mid = (p3[1] - p0[1]) * 0.5;
1414
+ return [p0, ...cubic(p0, [p0[0], p0[1] + mid], [p3[0], p3[1] - mid], p3)];
1415
+ }
1416
+ function layoutGit(diagram) {
1417
+ const { margin, gap, box: B, region: R, git: G, carrier: C } = LOOK;
1418
+ const walked = walk(diagram);
1419
+ const notes = new Map((diagram.git?.branches ?? []).map((b) => [b.id, b.note]));
1420
+ const laneIndex = new Map(walked.branches.map((id, i) => [id, i]));
1421
+ const colorOf2 = (branch) => G.colors[(laneIndex.get(branch) ?? 0) % G.colors.length];
1422
+ const col = /* @__PURE__ */ new Map();
1423
+ const laneLast = /* @__PURE__ */ new Map();
1424
+ for (const c of walked.made) {
1425
+ const k = Math.max(0, ...c.parents.map((p) => (col.get(p) ?? -1) + 1), (laneLast.get(c.branch) ?? -1) + 1);
1426
+ col.set(c.id, k);
1427
+ laneLast.set(c.branch, k);
1428
+ }
1429
+ const linesOf = (c) => [
1430
+ ...c.hash !== void 0 ? [{ text: c.hash, style: TYPE.gitHash }] : [],
1431
+ ...c.note !== void 0 ? [{ text: c.note, style: TYPE.gitNote }] : []
1432
+ ];
1433
+ const textW = (c) => Math.max(0, ...linesOf(c).map((line) => textWidth(line.text, line.style)));
1434
+ const tagW = (ref) => textWidth(ref, hasWide(ref) ? TYPE.carrierJa : TYPE.carrier) + C.tagPadX * 2;
1435
+ const refWidth = Math.max(0, ...walked.refs.map((r) => tagW(r.name)));
1436
+ const pitch = Math.max(G.pitch, ...walked.made.map((c) => textW(c) + G.textGap), refWidth + G.textGap);
1437
+ const headers = walked.branches.map((id) => ({ w: Math.max(R.icon, textWidth(id, TYPE.regionName), textWidth(notes.get(id) ?? "", TYPE.regionNote)) }));
1438
+ const headerRight = margin + R.inset + Math.max(0, ...headers.map((h) => h.w));
1439
+ const firstHalf = Math.max(G.r, ...walked.made.filter((c) => col.get(c.id) === 0 && laneIndex.get(c.branch) === 0).map((c) => textW(c) / 2), refWidth / 2);
1440
+ const x0 = Math.max(G.x0, headerRight + gap + firstHalf);
1441
+ const named = new Set(
1442
+ walked.moves.flatMap((mv) => {
1443
+ const source = diagram.steps[mv.step]?.events[mv.event];
1444
+ return mv.line && mv.to && source?.type === "edge" && source.label !== void 0 ? [walked.made.find((c) => c.id === mv.to?.commit)?.branch ?? ""] : [];
1445
+ })
1446
+ );
1447
+ const extraRows = (branch) => Math.max(0, ...walked.made.filter((c) => c.branch === branch).map((c) => (walked.rows.get(c.id) ?? 0) - 2)) * G.row;
1448
+ const topText = walked.made.some((c) => laneIndex.get(c.branch) === 0 && linesOf(c).length > 0);
1449
+ const lanes = [];
1450
+ let y = margin;
1451
+ walked.branches.forEach((id, i) => {
1452
+ const top = i === 0;
1453
+ const tagBase = top && topText ? G.tagTop : G.tag;
1454
+ const line = y + (top ? G.topLine - (G.tagTop - tagBase) : G.line) + extraRows(id);
1455
+ const h = line - y + (top ? G.topBelow : named.has(id) ? G.below : G.bare);
1456
+ lanes.push({ id, x: margin, y, w: 0, h, line, color: colorOf2(id), tagBase });
1457
+ y += h + R.gap;
1458
+ });
1459
+ const lanesBottom = y - R.gap;
1460
+ const laneOf = new Map(lanes.map((l) => [l.id, l]));
1461
+ const commits = walked.made.map((c) => {
1462
+ const lane = laneOf.get(c.branch);
1463
+ const isTop = laneIndex.get(c.branch) === 0;
1464
+ const cx = x0 + pitch * (col.get(c.id) ?? 0) + (isTop ? 0 : pitch / 2);
1465
+ const cy = lane.line;
1466
+ const lines = linesOf(c);
1467
+ const baselines = lines.map((_, k) => isTop ? cy - G.above - (lines.length - 1 - k) * G.lineStep : cy + G.under + k * G.lineStep);
1468
+ const boxes2 = lines.map((line, k) => textBox(line.text, cx, baselines[k], line.style, "middle"));
1469
+ const text2 = boxes2.length === 0 ? void 0 : { ...union(boxes2), lines: lines.map((line) => line.text), baselines };
1470
+ const color = c.copy !== void 0 ? colorOf2(walked.made.find((m) => m.id === c.copy)?.branch ?? c.branch) : colorOf2(c.branch);
1471
+ return {
1472
+ id: c.id,
1473
+ branch: c.branch,
1474
+ color,
1475
+ cx,
1476
+ cy,
1477
+ r: G.r,
1478
+ step: c.step,
1479
+ event: c.event,
1480
+ parents: c.parents,
1481
+ ...c.copy !== void 0 ? { copy: c.copy } : {},
1482
+ ...c.hash !== void 0 ? { hash: c.hash } : {},
1483
+ ...c.note !== void 0 ? { note: c.note } : {},
1484
+ ...text2 ? { text: text2 } : {},
1485
+ ...c.orphan ? { orphan: c.orphan.step, orphanEvent: c.orphan.event } : {}
1486
+ };
1487
+ });
1488
+ const placed = new Map(commits.map((c) => [c.id, c]));
1489
+ const links = walked.links.flatMap((l) => {
1490
+ const from = placed.get(l.from);
1491
+ if (!from) return [];
1492
+ if (l.kind === "branch") {
1493
+ if (!walked.made.some((c) => c.branch === l.to)) return [];
1494
+ const lane = laneOf.get(l.to);
1495
+ return [{ ...l, points: fork(from, from.cx + G.turn, lane.line), color: colorOf2(l.to) }];
1496
+ }
1497
+ const to = placed.get(l.to);
1498
+ const made = walked.made.find((m) => m.id === l.to);
1499
+ let points;
1500
+ if (l.kind === "copy") points = copyLine(from, to);
1501
+ else if (Math.abs(from.cy - to.cy) < 0.5) points = [[from.cx + from.r, from.cy], [to.cx - to.r, to.cy]];
1502
+ else if (made?.joined === l.from) points = join(from, to);
1503
+ else points = fork(from, to.cx - to.r, to.cy);
1504
+ return [{ ...l, points, color: to.color }];
1505
+ });
1506
+ const tagRect = (ref, slot) => {
1507
+ const c = placed.get(slot.commit);
1508
+ const base = laneOf.get(c.branch)?.tagBase ?? G.tag;
1509
+ const w = tagW(ref);
1510
+ return { x: c.cx - w / 2, y: c.cy - base - slot.row * G.row - C.tagH / 2, w, h: C.tagH };
1511
+ };
1512
+ const center2 = (r) => [r.x + r.w / 2, r.y + r.h / 2];
1513
+ const moves = walked.moves.map((m) => {
1514
+ const from = m.from ? tagRect(m.ref, m.from) : void 0;
1515
+ const to = m.to ? tagRect(m.ref, m.to) : void 0;
1516
+ const source = diagram.steps[m.step]?.events[m.event];
1517
+ const carried = m.line && source?.type === "edge" && source.carry.kind !== "none" && !(source.carry.kind === "tag" && source.carry.text === source.from);
1518
+ return {
1519
+ ref: m.ref,
1520
+ step: m.step,
1521
+ event: m.event,
1522
+ ...from ? { from } : {},
1523
+ ...to ? { to } : {},
1524
+ ...m.to ? { target: m.to.commit } : {},
1525
+ ...carried ? { carried: true } : {},
1526
+ ...m.line && from && to ? { line: elbow(center2(from), center2(to)) } : {},
1527
+ color: "slate"
1528
+ };
1529
+ });
1530
+ const tags = walked.tags.map((t) => ({ ...tagRect(t.ref, t.slot), ref: t.ref, step: t.step }));
1531
+ const colors = boxColors(diagram);
1532
+ const right = Math.max(
1533
+ x0,
1534
+ ...commits.flatMap((c) => [c.cx + c.r, ...c.text ? [c.text.x + c.text.w] : []]),
1535
+ ...tags.map((t) => t.x + t.w),
1536
+ ...moves.flatMap((m) => [m.from, m.to].flatMap((r) => r ? [r.x + r.w] : []))
1537
+ );
1538
+ const boxX = right + G.boxGap;
1539
+ const firstCy = (lanes[1] ?? lanes[0])?.line ?? margin + B.h / 2;
1540
+ const boxes = diagram.boxes.map((b, i) => {
1541
+ const w = boxWidth(diagram, b.id, true);
1542
+ const cy = firstCy + i * (B.h + gap);
1543
+ return {
1544
+ id: b.id,
1545
+ name: b.name,
1546
+ ...b.sub !== void 0 ? { sub: b.sub } : {},
1547
+ ...b.icon !== void 0 ? { icon: b.icon } : {},
1548
+ color: colors.get(b.id) ?? "slate",
1549
+ x: boxX,
1550
+ y: cy - B.h / 2,
1551
+ w,
1552
+ h: B.h,
1553
+ cx: boxX + w / 2,
1554
+ cy
1555
+ };
1556
+ });
1557
+ const regions = lanes.map((lane, i) => {
1558
+ const note = notes.get(lane.id);
1559
+ return {
1560
+ id: lane.id,
1561
+ lines: [lane.id],
1562
+ ...note !== void 0 ? { note } : {},
1563
+ icon: "branch",
1564
+ color: lane.color,
1565
+ x: lane.x,
1566
+ y: lane.y,
1567
+ w: 0,
1568
+ h: lane.h,
1569
+ header: { x: lane.x + R.inset, y: lane.y + R.inset, w: headers[i]?.w ?? 0, h: R.nameY - R.inset + (note !== void 0 ? R.line : 0) + gap / 2 }
1570
+ };
1571
+ });
1572
+ const layout = {
1573
+ kind: "git",
1574
+ width: 0,
1575
+ height: 0,
1576
+ regions,
1577
+ boxes,
1578
+ lifelines: [],
1579
+ edges: [],
1580
+ labels: [],
1581
+ actions: [],
1582
+ badges: [],
1583
+ paths: [],
1584
+ ends: [],
1585
+ lanes,
1586
+ commits,
1587
+ links,
1588
+ tags,
1589
+ refs: walked.refs,
1590
+ moves
1591
+ };
1592
+ layout.badges = badgesOf(diagram, layout);
1593
+ layout.labels = labelsOf(diagram, layout);
1594
+ const contentRight = Math.max(right, ...boxes.map((b) => b.x + b.w), ...layout.labels.map((l) => l.x + l.w)) + R.pad;
1595
+ const width = Math.max(contentRight + margin, stripNeed(diagram) + margin * 2);
1596
+ for (const region of regions) region.w = width - margin * 2;
1597
+ for (const lane of lanes) lane.w = width - margin * 2;
1598
+ const bottom = Math.max(lanesBottom, ...boxes.map((b) => b.y + b.h), ...layout.labels.map((l) => l.y + l.h));
1599
+ const strip2 = layoutStrip(diagram, margin, bottom + gap, width - margin * 2);
1600
+ layout.width = width;
1601
+ layout.height = (strip2 ? strip2.y + strip2.h : bottom) + margin;
1602
+ if (strip2) layout.strip = strip2;
1603
+ layout.badges = badgesOf(diagram, layout);
1604
+ return layout;
1605
+ }
1606
+ function union(rects) {
1607
+ const x = Math.min(...rects.map((r) => r.x));
1608
+ const y = Math.min(...rects.map((r) => r.y));
1609
+ return { x, y, w: Math.max(...rects.map((r) => r.x + r.w)) - x, h: Math.max(...rects.map((r) => r.y + r.h)) - y };
1610
+ }
1611
+ function firstMark(layout, step) {
1612
+ const marks = [
1613
+ ...layout.links.filter((l) => l.step === step && l.kind !== "copy").map((l) => ({ event: l.event, points: l.points, color: l.color })),
1614
+ ...layout.moves.flatMap((m) => {
1615
+ const target = layout.commits.find((c) => c.id === m.target);
1616
+ return m.step === step && m.line && target ? [{ event: m.event, target, color: target.color }] : [];
1617
+ })
1618
+ ].sort((a, b) => a.event - b.event);
1619
+ return marks[0];
1620
+ }
1621
+ function besideCommit(c, taken, avoid) {
1622
+ const { r, inset } = LOOK.badge;
1623
+ const d = c.r + inset + r;
1624
+ const apart = r * 2 + inset;
1625
+ const spots = [
1626
+ [c.cx + d, c.cy],
1627
+ [c.cx, c.cy + d],
1628
+ [c.cx - d, c.cy],
1629
+ [c.cx, c.cy - d]
1630
+ ];
1631
+ return spots.find((p) => taken.every(([x, y]) => Math.hypot(p[0] - x, p[1] - y) >= apart) && avoid.every((a) => gapBetween(badgeRect(p), a) >= LOOK.label.touch));
1632
+ }
1633
+ function clearOnPath(points, taken, avoid) {
1634
+ const { r, inset, along: start, short } = LOOK.badge;
1635
+ const length = pathLength(points);
1636
+ const first = length < short ? Math.min(r + 1, length / 2) : start;
1637
+ const apart = r * 2 + inset;
1638
+ for (let d = first; d <= length; d += 1) {
1639
+ const p = along(points, d);
1640
+ const rect = badgeRect(p);
1641
+ if (taken.every(([x, y]) => Math.hypot(p[0] - x, p[1] - y) >= apart) && avoid.every((a) => gapBetween(rect, a) >= LOOK.label.touch)) return p;
1642
+ }
1643
+ return void 0;
1644
+ }
1645
+ function badgesOf(diagram, layout) {
1646
+ const { inset } = LOOK.badge;
1647
+ const taken = [];
1648
+ const all = [...layout.links.map((l) => l.points), ...layout.moves.flatMap((m) => m.line ? [m.line] : [])];
1649
+ const out = [];
1650
+ const avoid = [
1651
+ ...layout.tags,
1652
+ ...layout.commits.flatMap((c) => [{ x: c.cx - c.r, y: c.cy - c.r, w: c.r * 2, h: c.r * 2 }, ...c.text ? [c.text] : []])
1653
+ ];
1654
+ diagram.steps.forEach((step, s) => {
1655
+ const mark = firstMark(layout, s);
1656
+ const near = mark?.target ? besideCommit(mark.target, taken, avoid) : void 0;
1657
+ if (mark && (mark.points || near)) {
1658
+ const points = mark.points;
1659
+ const point = near ?? (points ? clearOnPath(points, taken, avoid) ?? badgeOnPath(points, taken, all.filter((p) => p !== points)) : [0, 0]);
1660
+ taken.push(point);
1661
+ out.push({ step: s, x: point[0], y: point[1], color: mark.color });
1662
+ return;
1663
+ }
1664
+ const box = step.events.flatMap((e) => e.type === "swap" || e.type === "action" ? [e.box] : []).map((id) => layout.boxes.find((b) => b.id === id))[0];
1665
+ if (box) {
1666
+ out.push({ step: s, x: box.x, y: box.y, color: box.color });
1667
+ return;
1668
+ }
1669
+ if (layout.strip && step.events.some((e) => e.type === "strip")) {
1670
+ out.push({ step: s, x: layout.strip.x + inset, y: layout.strip.y + inset, color: "slate" });
1671
+ return;
1672
+ }
1673
+ const tip = layout.commits.find((c) => c.id === layout.refs[0]?.at[s]);
1674
+ const spot = tip ? besideCommit(tip, taken, avoid) : void 0;
1675
+ if (tip && spot) {
1676
+ taken.push(spot);
1677
+ out.push({ step: s, x: spot[0], y: spot[1], color: tip.color });
1678
+ return;
1679
+ }
1680
+ const before = out[out.length - 1];
1681
+ const lane = layout.lanes[0];
1682
+ out.push(before ? { ...before, step: s } : { step: s, x: (lane?.x ?? 0) + (lane?.w ?? 0) - inset - LOOK.badge.r, y: (lane?.y ?? 0) + inset + LOOK.badge.r, color: lane?.color ?? "slate" });
1683
+ });
1684
+ return replaceSameSpot(out);
1685
+ }
1686
+ function labelsOf(diagram, layout) {
1687
+ const G = LOOK.git;
1688
+ const labels = [];
1689
+ const circles = layout.commits.map((c) => ({ x: c.cx - c.r, y: c.cy - c.r, w: c.r * 2, h: c.r * 2 }));
1690
+ const texts = layout.commits.flatMap((c) => c.text ? [c.text] : []);
1691
+ const headers = layout.regions.map((r) => r.header);
1692
+ for (const move of layout.moves) {
1693
+ const source = diagram.steps[move.step]?.events[move.event];
1694
+ if (source?.type !== "edge" || source.label === void 0 || !move.line) continue;
1695
+ const target = layout.commits.find((c) => c.id === source.to);
1696
+ if (!target) continue;
1697
+ const top = layout.lanes[0]?.id === target.branch;
1698
+ const w = textWidth(source.label, hasWide(source.label) ? TYPE.labelJa : TYPE.label) + LOOK.label.padX * 2;
1699
+ const [mx] = move.line.reduce((sum, p) => [sum[0] + p[0] / move.line.length, 0], [0, 0]);
1700
+ const rows = Math.max(0, ...layout.tags.filter((t) => t.step === move.step && Math.abs(t.x + t.w / 2 - target.cx) < 0.5).map((t) => target.cy - t.y));
1701
+ const side2 = source.labelSide ?? (top ? "above" : "below");
1702
+ const base = source.labelSide !== void 0 ? void 0 : top ? { x: mx - w / 2, y: target.cy - Math.max(rows, (layout.lanes[0]?.tagBase ?? G.tag) + LOOK.carrier.tagH / 2) - LOOK.label.soft - LOOK.label.h } : { x: mx - w / 2, y: target.cy + G.labelUnder };
1703
+ const seen = layout.badges.filter((b) => b.step <= move.step).map((b) => badgeRect([b.x, b.y]));
1704
+ const tags = layout.tags.filter((t) => t.step === move.step);
1705
+ labels.push(
1706
+ placeLabel(
1707
+ { step: move.step, event: move.event, text: source.label, points: move.line, color: move.color, side: side2, ...base ? { base } : {} },
1708
+ { hard: [...circles, ...layout.boxes], soft: [...texts, ...tags, ...headers, ...labels.filter((l) => l.step === move.step)], touch: seen }
1709
+ )
1710
+ );
1711
+ }
1712
+ return labels;
1713
+ }
933
1714
 
934
1715
  // src/layout/sequence.ts
935
1716
  function layoutSequence(diagram) {
@@ -998,8 +1779,8 @@ function layoutSequence(diagram) {
998
1779
  const side2 = event.labelSide ?? "above";
999
1780
  const self = event.from === event.to;
1000
1781
  const named = event.label !== void 0;
1001
- above = named && side2 === "above" ? L.offset + L.h / 2 : gap;
1002
- under = self ? Q.selfH + gap : named && side2 === "below" ? L.offset + L.h / 2 : gap;
1782
+ above = named && side2 === "above" ? Q.labelOffset + L.h / 2 : gap;
1783
+ under = self ? Q.selfH + gap : named && side2 === "below" ? Q.labelOffset + L.h / 2 : gap;
1003
1784
  } else {
1004
1785
  above = LOOK.action.h / 2;
1005
1786
  under = LOOK.action.h / 2;
@@ -1021,7 +1802,17 @@ function layoutSequence(diagram) {
1021
1802
  [xt - dir * LOOK.edge.inset, y]
1022
1803
  ];
1023
1804
  const color = edgeColor(event, colors);
1024
- edges.push({ step: s, event: e, from: event.from, to: event.to, points, color, carry: event.carry });
1805
+ const seats = {};
1806
+ if (event.carry.kind !== "none") {
1807
+ const reach = LOOK.slot.lifeline + carrierHalf(event.carry)[0];
1808
+ const [p0, p1] = points;
1809
+ const [q0, q1] = points.slice(-2);
1810
+ const out = Math.sign(p1[0] - p0[0]) || 1;
1811
+ const into = Math.sign(q1[0] - q0[0]) || -1;
1812
+ seats.wait = [xf - out * reach, p0[1]];
1813
+ seats.settle = [xt + into * reach, q1[1]];
1814
+ }
1815
+ edges.push({ step: s, event: e, from: event.from, to: event.to, points, color, carry: event.carry, ...seats });
1025
1816
  if (event.label !== void 0) {
1026
1817
  requests.push({
1027
1818
  step: s,
@@ -1029,7 +1820,8 @@ function layoutSequence(diagram) {
1029
1820
  text: event.label,
1030
1821
  points,
1031
1822
  color,
1032
- ...event.labelSide ? { side: event.labelSide } : xf === xt ? { side: "right" } : {}
1823
+ ...event.labelSide ? { side: event.labelSide } : xf === xt ? { side: "right" } : {},
1824
+ offset: Q.labelOffset
1033
1825
  });
1034
1826
  }
1035
1827
  } else {
@@ -1041,10 +1833,12 @@ function layoutSequence(diagram) {
1041
1833
  });
1042
1834
  const bottom = (first ? headBottom : y + below) + Q.tail;
1043
1835
  const lifelines = order.map((id, i) => ({ id, x: xs[i], y1: headBottom, y2: bottom }));
1836
+ const early = lineBadges(edges, diagram.steps.length);
1044
1837
  const labels = [];
1045
1838
  for (const request of requests) {
1839
+ const seen = [...early].filter(([s]) => s <= request.step).map(([, b]) => badgeRect(b.point));
1046
1840
  const soft = [...labels.filter((l) => l.step === request.step), ...actions];
1047
- labels.push(placeLabel(request, { hard: boxes, soft }));
1841
+ labels.push(placeLabel(request, { hard: boxes, soft, touch: seen }));
1048
1842
  }
1049
1843
  const layout = { kind: "sequence", width: 0, height: 0, regions: [], boxes, lifelines, edges, labels, actions, badges: [], paths: [], ends: [] };
1050
1844
  const lefts = [...boxes.map((b) => b.x), ...labels.map((l) => l.x), ...actions.map((a) => a.x)];
@@ -1060,19 +1854,17 @@ function layoutSequence(diagram) {
1060
1854
  return layout;
1061
1855
  }
1062
1856
  function badges(diagram, layout) {
1063
- return diagram.steps.map((step, s) => {
1064
- const edge2 = layout.edges.find((e) => e.step === s);
1065
- if (edge2) {
1066
- const [x, y] = badgeOnPath(edge2.points);
1067
- return { step: s, x, y, color: edge2.color };
1068
- }
1857
+ const lines = lineBadges(layout.edges, diagram.steps.length);
1858
+ const placed = diagram.steps.map((step, s) => {
1859
+ const line = lines.get(s);
1860
+ if (line) return { step: s, x: line.point[0], y: line.point[1], color: line.edge.color };
1069
1861
  const action2 = layout.actions.find((a) => a.step === s);
1070
1862
  const lifeline2 = action2 && layout.lifelines.find((l) => l.id === action2.box);
1071
1863
  if (action2 && lifeline2) return { step: s, x: lifeline2.x, y: action2.y + action2.h / 2, color: action2.color };
1072
1864
  return cornerBadge(step.events, s, layout);
1073
1865
  });
1866
+ return replaceSameSpot(placed);
1074
1867
  }
1075
- var STATE_ENDS = ["start", "finish"];
1076
1868
 
1077
1869
  // src/layout/state.ts
1078
1870
  var isEnd = (id) => STATE_ENDS.includes(id);
@@ -1087,12 +1879,6 @@ function visitOrder(diagram) {
1087
1879
  }
1088
1880
  return order;
1089
1881
  }
1090
- function carrierHalf(carry) {
1091
- const C = LOOK.carrier;
1092
- if (carry.kind === "tag") return (textWidth(carry.text, hasWide(carry.text) ? TYPE.carrierJa : TYPE.carrier) + C.tagPadX * 2) / 2;
1093
- if (carry.kind === "coin") return C.coinR;
1094
- return C.envW / 2;
1095
- }
1096
1882
  var same = (a, b) => a.from === b.from && a.to === b.to;
1097
1883
  function layoutState(diagram, lang) {
1098
1884
  const { box: B, state: T, margin, gap } = LOOK;
@@ -1109,7 +1895,11 @@ function layoutState(diagram, lang) {
1109
1895
  const source = diagram.boxes.find((b) => b.id === id);
1110
1896
  return G.pad * 2 + B.icon + G.gap + Math.max(textWidth(source?.name ?? id, TYPE.boxName), textWidth(source?.sub ?? "", TYPE.boxSub));
1111
1897
  };
1112
- const widths = new Map(diagram.boxes.map((b) => [b.id, ghosts.includes(b.id) ? ghostWidth(b.id) : boxWidth(diagram, b.id, true)]));
1898
+ const carriedIn = slotRooms(diagram);
1899
+ const doneSide = Math.max(B.padX, T.done.inset + T.done.r + LOOK.slot.clear);
1900
+ const widths = new Map(
1901
+ diagram.boxes.map((b) => [b.id, ghosts.includes(b.id) ? ghostWidth(b.id) : Math.max(boxWidth(diagram, b.id, true), slotBoxWidth(carriedIn.get(b.id), b.icon !== void 0, doneSide))])
1902
+ );
1113
1903
  const columnCount = Math.max(1, Math.min(T.columns, walked.length));
1114
1904
  const rowCount = Math.max(1, Math.ceil(walked.length / T.columns));
1115
1905
  const slot = new Map(
@@ -1130,7 +1920,7 @@ function layoutState(diagram, lang) {
1130
1920
  }
1131
1921
  const colLeft = [];
1132
1922
  for (let c = 0; c < columnCount; c++) colLeft.push(c === 0 ? margin : colLeft[c - 1] + colW[c - 1] + between[c - 1]);
1133
- const center = (c) => colLeft[c] + colW[c] / 2;
1923
+ const center2 = (c) => colLeft[c] + colW[c] / 2;
1134
1924
  const isGhost = (id) => ghosts.includes(id);
1135
1925
  const enteringFrom = new Set(notTaken.filter((p) => isGhost(p.to) && !isGhost(p.from) && !isEnd(p.from)).map((p) => p.from));
1136
1926
  const notes = [words.sideNote, ...enteringFrom.size > 0 ? [words.sideFrom(enteringFrom.size)] : []];
@@ -1160,8 +1950,9 @@ function layoutState(diagram, lang) {
1160
1950
  };
1161
1951
  const boxes = walked.map((id) => {
1162
1952
  const s = slot.get(id);
1163
- return boxOf(id, center(s.col), rowY(s.row), false);
1953
+ return boxOf(id, center2(s.col), rowY(s.row), false);
1164
1954
  });
1955
+ for (const box of boxes) placeSlot(box, carriedIn.get(box.id), doneSide);
1165
1956
  const byId = new Map(boxes.map((b) => [b.id, b]));
1166
1957
  const below = (box) => boxes.some((other) => other !== box && Math.abs(other.cx - box.cx) < 0.5 && other.y > box.y);
1167
1958
  const ends = [];
@@ -1232,20 +2023,6 @@ function layoutState(diagram, lang) {
1232
2023
  };
1233
2024
  const exitX = (box) => starts && box === first ? box.cx + T.side.entry : box.cx;
1234
2025
  const finishOf = (id) => ends.find((e) => e.kind === "finish" && e.box === id);
1235
- const loopOf = (box) => {
1236
- const { w, h, samples } = T.loop;
1237
- const bottom2 = box.y + box.h;
1238
- const p0 = [box.cx + w / 2, bottom2];
1239
- const c1 = [box.cx + w * 3 / 4, bottom2 + h * 4 / 3];
1240
- const c2 = [box.cx - w * 3 / 4, bottom2 + h * 4 / 3];
1241
- const p3 = [box.cx - w / 2, bottom2 + inset];
1242
- return Array.from({ length: samples + 1 }, (_, k) => {
1243
- const t = k / samples;
1244
- const u = 1 - t;
1245
- const at2 = (i) => u * u * u * p0[i] + 3 * u * u * t * c1[i] + 3 * u * t * t * c2[i] + t * t * t * p3[i];
1246
- return [at2(0), at2(1)];
1247
- });
1248
- };
1249
2026
  const route = (from, to) => {
1250
2027
  if (from === "start") {
1251
2028
  const start = ends.find((e) => e.kind === "start");
@@ -1262,7 +2039,7 @@ function layoutState(diagram, lang) {
1262
2039
  }
1263
2040
  const b = byId.get(to);
1264
2041
  if (!b) return [];
1265
- if (from === to) return loopOf(a);
2042
+ if (from === to) return loopUnder(a);
1266
2043
  if (b.ghost && !a.ghost) {
1267
2044
  const sx = exitX(a);
1268
2045
  const ex = entryOf(from, b);
@@ -1273,15 +2050,18 @@ function layoutState(diagram, lang) {
1273
2050
  return between2(a, b);
1274
2051
  };
1275
2052
  const settleOf = (edge2) => {
1276
- const target = byId.get(edge2.to);
1277
- if (target) return [target.cx, target.cy + B.iconY];
1278
2053
  const end = edge2.to === "finish" ? finishOf(edge2.from) : void 0;
1279
2054
  if (!end) return void 0;
1280
2055
  const from = byId.get(edge2.from);
1281
- return from && Math.abs(end.x - from.cx) < 0.5 ? [end.x - end.r - gap - carrierHalf(edge2.carry), end.y] : [end.x, end.y + end.r + gap + LOOK.carrier.tagH / 2];
2056
+ return from && Math.abs(end.x - from.cx) < 0.5 ? [end.x - end.r - gap - carrierHalf(edge2.carry)[0], end.y] : [end.x, end.y + end.r + gap + LOOK.carrier.tagH / 2];
2057
+ };
2058
+ const waitOf = (edge2) => {
2059
+ const start = edge2.from === "start" ? ends.find((e) => e.kind === "start") : void 0;
2060
+ return start ? [start.x - start.r - LOOK.slot.mark - carrierHalf(edge2.carry)[0], start.y] : void 0;
1282
2061
  };
1283
2062
  const sceneEdges = steps.map(({ step, event, edge: edge2 }) => {
1284
2063
  const settle = settleOf(edge2);
2064
+ const wait = edge2.carry.kind === "none" ? void 0 : waitOf(edge2);
1285
2065
  return {
1286
2066
  step,
1287
2067
  event,
@@ -1290,49 +2070,67 @@ function layoutState(diagram, lang) {
1290
2070
  points: route(edge2.from, edge2.to),
1291
2071
  color: colorOf(edge2, colors),
1292
2072
  carry: edge2.carry,
1293
- ...settle ? { settle } : {}
2073
+ ...settle ? { settle } : {},
2074
+ ...wait ? { wait } : {}
1294
2075
  };
1295
2076
  });
2077
+ seatCarriers(sceneEdges, byId, carriedIn);
2078
+ const outward = /* @__PURE__ */ new Map();
1296
2079
  for (const e of sceneEdges) {
1297
2080
  if (e.points.length !== 2 || !sceneEdges.some((o) => o.from === e.to && o.to === e.from && o.points.length === 2)) continue;
1298
2081
  const [p, q] = e.points;
1299
2082
  const flat = Math.abs(q[1] - p[1]) < Math.abs(q[0] - p[0]);
1300
2083
  const d = (e.from < e.to ? 1 : -1) * LOOK.edge.parallel;
1301
2084
  e.points = e.points.map(([x, y]) => flat ? [x, y + d] : [x + d, y]);
2085
+ outward.set(e, flat ? d > 0 ? "below" : "above" : d > 0 ? "right" : "left");
1302
2086
  }
1303
2087
  const paths = notTaken.map((p) => ({ from: p.from, to: p.to, points: route(p.from, p.to) }));
2088
+ const badgeAt = (edge2, taken, lines2) => edge2.from === edge2.to ? loopBadge(edge2.points) : badgeOnPath(edge2.points, taken, lines2);
1304
2089
  const labels = [];
1305
- const soft = side2 ? [{ x: side2.x, y: side2.y, w: T.side.pad + titleW, h: side2.h }] : [];
2090
+ const marks = ends.flatMap((e) => e.text === "" ? [] : [textBox(e.text, ...markText(e), TYPE.regionNote)]);
2091
+ const badgeRects = [...lineBadges(sceneEdges, diagram.steps.length, badgeAt).values()].map((b) => badgeRect(b.point));
2092
+ const soft = [...side2 ? [{ x: side2.x, y: side2.y, w: T.side.pad + titleW, h: side2.h }] : [], ...marks];
2093
+ const others = (own) => [...sceneEdges.map((o) => o.points), ...paths.map((o) => o.points)].filter((line) => line !== own);
1306
2094
  for (const e of sceneEdges) {
1307
2095
  const source = diagram.steps[e.step]?.events[e.event];
1308
2096
  if (source?.type !== "edge" || source.label === void 0) continue;
1309
- const style = labelStyle(source.label);
1310
- if (e.from === e.to) {
1311
- const w = textWidth(source.label, style) + LOOK.label.padX * 2;
1312
- const bottom2 = Math.max(...e.points.map(([, y]) => y));
1313
- labels.push({ step: e.step, event: e.event, text: source.label, family: style.family, color: e.color, x: (e.points[0]?.[0] ?? 0) - T.loop.w / 2 - w / 2, y: bottom2 + LOOK.label.soft, w, h: LOOK.label.h });
2097
+ const loop = e.from === e.to;
2098
+ const key = lineKey(e);
2099
+ const named = labels.filter((l) => l.text === source.label && sceneEdges.some((o) => o.step === l.step && o.event === l.event && lineKey(o) === key));
2100
+ const same2 = named[named.length - 1];
2101
+ if (same2) {
2102
+ same2.until = e.step;
2103
+ labels.push({ x: same2.x, y: same2.y, w: same2.w, h: same2.h, step: e.step, event: e.event, text: same2.text, family: same2.family, color: e.color });
1314
2104
  continue;
1315
2105
  }
1316
- const side22 = source.labelSide ?? (e.to === "finish" ? "left" : void 0);
2106
+ const w = textWidth(source.label, labelStyle(source.label)) + LOOK.label.padX * 2;
2107
+ const below2 = loop ? { side: "below", base: loopLabelBase(e.points, w) } : {};
2108
+ const side22 = source.labelSide ?? (e.to === "finish" ? "left" : outward.get(e));
1317
2109
  labels.push(
1318
2110
  placeLabel(
1319
- { step: e.step, event: e.event, text: source.label, points: e.points, color: e.color, ...side22 ? { side: side22 } : {} },
1320
- { hard: boxes, soft: [...soft, ...labels.filter((l) => l.step === e.step)] }
2111
+ { step: e.step, event: e.event, text: source.label, points: e.points, color: e.color, ...side22 ? { side: side22 } : loop ? {} : { flip: true }, ...below2 },
2112
+ { hard: boxes, soft: [...soft, ...labels], touch: badgeRects, lines: others(e.points) }
1321
2113
  )
1322
2114
  );
1323
2115
  }
2116
+ const placed = [];
1324
2117
  notTaken.forEach((p, i) => {
1325
2118
  const path2 = paths[i];
1326
2119
  if (p.label === void 0 || path2.points.length === 0) return;
1327
2120
  const style = labelStyle(p.label);
1328
2121
  const into = byId.get(p.to)?.ghost === true && byId.get(p.from)?.ghost !== true;
1329
- const rect = into ? { x: path2.points[0][0] + LOOK.label.soft, y: lane + LOOK.label.soft, w: textWidth(p.label, style) + LOOK.label.padX * 2, h: LOOK.label.h } : placeLabel({ step: -1, event: i, text: p.label, points: path2.points, color: "slate" }, { hard: boxes, soft });
2122
+ const x0 = path2.points[0][0];
2123
+ const lead = into ? { side: "below", base: { x: x0 + LOOK.label.soft, y: lane + LOOK.label.soft }, slide: Math.max(...path2.points.map(([x]) => Math.abs(x - x0))) } : {};
2124
+ const rect = placeLabel({ step: -1, event: i, text: p.label, points: path2.points, color: "slate", ...lead }, { hard: boxes, soft: [...soft, ...labels, ...placed], touch: badgeRects, lines: others(path2.points) });
2125
+ placed.push(rect);
1330
2126
  path2.label = { x: rect.x, y: rect.y, w: rect.w, h: rect.h, text: p.label, family: style.family };
1331
2127
  });
1332
2128
  const layout = { kind: "state", width: 0, height: 0, regions: [], boxes, lifelines: [], edges: sceneEdges, labels, actions: [], badges: [], paths, ends, ...side2 ? { side: side2 } : {} };
1333
2129
  const lefts = [...boxes.map((b) => b.x), ...labels.map((l) => l.x), ...paths.flatMap((p) => p.label ? [p.label.x] : [])];
2130
+ const tops = [...labels.map((l) => l.y), ...paths.flatMap((p) => p.label ? [p.label.y] : [])];
1334
2131
  const shift = Math.max(0, margin - Math.min(...lefts));
1335
- if (shift > 0) shiftContent(layout, shift, 0);
2132
+ const drop = tops.length > 0 ? Math.max(0, margin - Math.min(...tops)) : 0;
2133
+ if (shift > 0 || drop > 0) shiftContent(layout, shift, drop);
1336
2134
  const endRight = (e) => e.x + (e.text === "" ? e.r : T.text + textWidth(e.text, TYPE.regionNote));
1337
2135
  const rights = [
1338
2136
  ...boxes.map((b) => b.x + b.w),
@@ -1350,18 +2148,14 @@ function layoutState(diagram, lang) {
1350
2148
  layout.width = width;
1351
2149
  layout.height = (strip2 ? strip2.y + strip2.h : bottom) + margin;
1352
2150
  if (strip2) layout.strip = strip2;
1353
- layout.badges = diagram.steps.map((step, s) => {
1354
- const edge2 = sceneEdges.find((e) => e.step === s && e.points.length > 0);
1355
- if (!edge2) return cornerBadge(step.events, s, layout);
1356
- if (edge2.from === edge2.to) {
1357
- const right = Math.max(...edge2.points.map(([px]) => px));
1358
- const top = edge2.points[0][1];
1359
- const deep = Math.max(...edge2.points.map(([, py]) => py));
1360
- return { step: s, x: right + LOOK.badge.r + LOOK.badge.inset, y: top + (deep - top) * T.loop.badgeAt, color: edge2.color };
1361
- }
1362
- const [x, y] = badgeOnPath(edge2.points);
1363
- return { step: s, x, y, color: edge2.color };
1364
- });
2151
+ const placedBadges = lineBadges(sceneEdges, diagram.steps.length, badgeAt);
2152
+ layout.badges = replaceSameSpot(
2153
+ diagram.steps.map((step, s) => {
2154
+ const line = placedBadges.get(s);
2155
+ if (!line) return cornerBadge(step.events, s, layout);
2156
+ return { step: s, x: line.point[0], y: line.point[1], color: line.edge.color };
2157
+ })
2158
+ );
1365
2159
  return layout;
1366
2160
  }
1367
2161
  function colorOf(edge2, colors) {
@@ -1401,6 +2195,8 @@ var ja = {
1401
2195
  const: (value) => `${value} \u306B\u3059\u308B`,
1402
2196
  not: (allowed) => allowed ? `${allowed.field} \u306E\u6B04\u306F kind \u304C ${allowed.kind} \u306E\u6642\u3060\u3051\u66F8\u3051\u308B` : "\u3053\u306E\u6B04\u306E\u7D44\u307F\u5408\u308F\u305B\u306F\u66F8\u3051\u306A\u3044",
1403
2197
  reserved: (names) => `${names.join(" \u3068 ")} \u306F\u72B6\u614B\u9077\u79FB\u56F3\u306E\u59CB\u307E\u308A\u3068\u7D42\u308F\u308A\u306E\u5370\u306E\u540D\u524D\u3067\u3001\u7BB1\u306E\u540D\u672D\u306B\u4F7F\u3048\u306A\u3044`,
2198
+ kindOnly: (types, kind) => `${types.join(" \u3068 ")} \u306E\u51FA\u6765\u4E8B\u306F kind \u304C ${kind} \u306E\u6642\u3060\u3051\u66F8\u3051\u308B`,
2199
+ hex: (min, max) => `0 \u304B\u3089 9 \u3068 a \u304B\u3089 f \u306E\u5B57\u3067 ${min} \u304B\u3089 ${max} \u5B57\u306B\u3059\u308B`,
1404
2200
  anyOf: (fields) => fields.length > 0 ? `${fields.join(" \u304B ")} \u306E${fields.length === 2 ? "\u3069\u3061\u3089\u304B" : "\u3069\u308C\u304B"}\u306E\u6B04\u304C\u8981\u308B` : "\u66F8\u3051\u308B\u5F62\u306E\u3069\u308C\u306B\u3082\u5408\u308F\u306A\u3044",
1405
2201
  oneOf: "\u66F8\u3051\u308B\u5F62\u306E\u3069\u308C\u304B 1 \u3064\u3060\u3051\u306B\u5408\u308F\u305B\u308B",
1406
2202
  discriminator: (tag, values) => `${tag} \u306F ${values.join(" / ")} \u306E\u3069\u308C\u304B\u306B\u3059\u308B`,
@@ -1418,6 +2214,8 @@ var en = {
1418
2214
  const: (value) => `Use ${value}`,
1419
2215
  not: (allowed) => allowed ? `The ${allowed.field} field is allowed only when kind is ${allowed.kind}` : "This combination of fields is not allowed",
1420
2216
  reserved: (names) => `${names.join(" and ")} name the start and end marks of a state diagram and cannot be box ids`,
2217
+ kindOnly: (types, kind) => `${types.join(" and ")} events are allowed only when kind is ${kind}`,
2218
+ hex: (min, max) => `Use ${min} to ${max} characters of 0-9 and a-f`,
1421
2219
  anyOf: (fields) => fields.length > 0 ? `Write one of the ${fields.join(" or ")} fields` : "Does not match any of the allowed shapes",
1422
2220
  oneOf: "Match exactly one of the allowed shapes",
1423
2221
  discriminator: (tag, values) => `${tag} is one of ${values.join(" / ")}`,
@@ -1432,10 +2230,10 @@ function ucs2length(str) {
1432
2230
  return length;
1433
2231
  }
1434
2232
  var validate_diagram_default = validate10;
1435
- var schema11 = { "properties": { "version": { "description": "\u5F62\u5F0F\u306E\u7248", "type": "integer", "minimum": 1 }, "kind": { "description": "\u56F3\u306E\u7A2E\u985E", "enum": ["sequence", "architecture", "state"] }, "title": { "$ref": "#/definitions/text" }, "view": { "description": "\u898B\u305B\u65B9\u3002\u66F8\u304B\u306A\u3051\u308C\u3070\u5B57\u306E\u5927\u304D\u3055\u3067\u9078\u3076\u3002fixed \u306F\u5168\u4F53\u3092\u6B62\u3081\u3066\u4E2D\u3060\u3051\u52D5\u304B\u3057\u3001follow \u306F\u5BC4\u3063\u3066\u52D5\u304B\u3057\u5168\u4F53\u56F3\u3067\u4ECA\u3069\u3053\u304B\u3092\u793A\u3059", "enum": ["fixed", "follow"] }, "regions": { "type": "array", "items": { "$ref": "#/definitions/region" } }, "boxes": { "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/box" } }, "strip": { "$ref": "#/definitions/strip" }, "steps": { "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/step" } }, "sequence": { "$ref": "#/definitions/sequence" }, "state": { "$ref": "#/definitions/state" } }};
2233
+ var schema11 = { "properties": { "version": { "description": "\u5F62\u5F0F\u306E\u7248", "type": "integer", "minimum": 1 }, "kind": { "description": "\u56F3\u306E\u7A2E\u985E", "enum": ["sequence", "architecture", "state", "git"] }, "title": { "$ref": "#/definitions/text" }, "view": { "description": "\u898B\u305B\u65B9\u3002\u66F8\u304B\u306A\u3051\u308C\u3070\u5B57\u306E\u5927\u304D\u3055\u3067\u9078\u3076\u3002fixed \u306F\u5168\u4F53\u3092\u6B62\u3081\u3066\u4E2D\u3060\u3051\u52D5\u304B\u3057\u3001follow \u306F\u5BC4\u3063\u3066\u52D5\u304B\u3057\u5168\u4F53\u56F3\u3067\u4ECA\u3069\u3053\u304B\u3092\u793A\u3059", "enum": ["fixed", "follow"] }, "regions": { "type": "array", "items": { "$ref": "#/definitions/region" } }, "boxes": { "type": "array", "items": { "$ref": "#/definitions/box" } }, "strip": { "$ref": "#/definitions/strip" }, "steps": { "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/step" } }, "sequence": { "$ref": "#/definitions/sequence" }, "state": { "$ref": "#/definitions/state" }, "git": { "$ref": "#/definitions/git" } }};
1436
2234
  var func2 = Object.prototype.hasOwnProperty;
1437
2235
  var func3 = ucs2length;
1438
- var schema17 = { "enum": ["blue", "amber", "green", "violet", "rose", "slate", "coin"] };
2236
+ var schema28 = { "enum": ["blue", "amber", "green", "violet", "rose", "slate", "coin"] };
1439
2237
  var pattern0 = new RegExp("^[^\\s\\[\\]\u300C\u300D=:]+$", "u");
1440
2238
  function validate11(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
1441
2239
  let vErrors = null;
@@ -1539,7 +2337,7 @@ function validate11(data, { instancePath = "", parentData, parentDataProperty, r
1539
2337
  if (data.color !== void 0) {
1540
2338
  let data3 = data.color;
1541
2339
  if (!(data3 === "blue" || data3 === "amber" || data3 === "green" || data3 === "violet" || data3 === "rose" || data3 === "slate" || data3 === "coin")) {
1542
- const err9 = { instancePath: instancePath + "/color", schemaPath: "#/definitions/color/enum", keyword: "enum", params: { allowedValues: schema17.enum }, message: "must be equal to one of the allowed values" };
2340
+ const err9 = { instancePath: instancePath + "/color", schemaPath: "#/definitions/color/enum", keyword: "enum", params: { allowedValues: schema28.enum }, message: "must be equal to one of the allowed values" };
1543
2341
  if (vErrors === null) {
1544
2342
  vErrors = [err9];
1545
2343
  } else {
@@ -1684,7 +2482,7 @@ function validate13(data, { instancePath = "", parentData, parentDataProperty, r
1684
2482
  if (data.color !== void 0) {
1685
2483
  let data3 = data.color;
1686
2484
  if (!(data3 === "blue" || data3 === "amber" || data3 === "green" || data3 === "violet" || data3 === "rose" || data3 === "slate" || data3 === "coin")) {
1687
- const err9 = { instancePath: instancePath + "/color", schemaPath: "#/definitions/color/enum", keyword: "enum", params: { allowedValues: schema17.enum }, message: "must be equal to one of the allowed values" };
2485
+ const err9 = { instancePath: instancePath + "/color", schemaPath: "#/definitions/color/enum", keyword: "enum", params: { allowedValues: schema28.enum }, message: "must be equal to one of the allowed values" };
1688
2486
  if (vErrors === null) {
1689
2487
  vErrors = [err9];
1690
2488
  } else {
@@ -1861,8 +2659,9 @@ function validate15(data, { instancePath = "", parentData, parentDataProperty, r
1861
2659
  validate15.errors = vErrors;
1862
2660
  return errors === 0;
1863
2661
  }
1864
- var schema33 = { "oneOf": [{ "description": "\u7DDA\u3002\u904B\u3076\u7269\u3092\u8F09\u305B\u3066\u9001\u308B\u5074\u304B\u3089\u53D7\u3051\u308B\u5074\u3078\u8D70\u308B", "type": "object", "additionalProperties": false, "required": ["type", "from", "to", "carry"], "properties": { "type": { "const": "edge" }, "from": { "$ref": "#/definitions/id" }, "to": { "$ref": "#/definitions/id" }, "label": { "$ref": "#/definitions/text" }, "carry": { "$ref": "#/definitions/carry" }, "labelSide": { "description": "\u7DDA\u306E\u540D\u524D\u3092\u7F6E\u304F\u5074 (\u5BC4\u305B\u306E\u6307\u793A)", "enum": ["above", "below", "left", "right"] } } }, { "description": "\u7BB1\u306E\u4E2D\u306E\u51E6\u7406", "type": "object", "additionalProperties": false, "required": ["type", "box", "label"], "properties": { "type": { "const": "action" }, "box": { "$ref": "#/definitions/id" }, "label": { "$ref": "#/definitions/text" } } }, { "description": "\u7BB1\u306E\u4E0B\u306E\u5C0F\u3055\u306A\u5B57\u306E\u66F8\u304D\u63DB\u3048", "type": "object", "additionalProperties": false, "required": ["type", "box", "text"], "properties": { "type": { "const": "swap" }, "box": { "$ref": "#/definitions/id" }, "text": { "$ref": "#/definitions/text" } } }, { "description": "\u4E2D\u8EAB\u306E\u5E2F\u306E\u6B04\u306E\u5024\u3068\u672D", "type": "object", "additionalProperties": false, "required": ["type", "field"], "anyOf": [{ "required": ["value"] }, { "required": ["tag"] }], "properties": { "type": { "const": "strip" }, "field": { "$ref": "#/definitions/text" }, "value": { "$ref": "#/definitions/text" }, "tag": { "$ref": "#/definitions/text" } } }] };
1865
- var schema37 = { "properties": { "kind": { "enum": ["envelope", "tag", "coin", "none"] }}};
2662
+ var schema44 = { "oneOf": [{ "description": "\u7DDA\u3002\u904B\u3076\u7269\u3092\u8F09\u305B\u3066\u9001\u308B\u5074\u304B\u3089\u53D7\u3051\u308B\u5074\u3078\u8D70\u308B", "type": "object", "additionalProperties": false, "required": ["type", "from", "to", "carry"], "properties": { "type": { "const": "edge" }, "from": { "$ref": "#/definitions/id" }, "to": { "$ref": "#/definitions/id" }, "label": { "$ref": "#/definitions/text" }, "carry": { "$ref": "#/definitions/carry" }, "labelSide": { "description": "\u7DDA\u306E\u540D\u524D\u3092\u7F6E\u304F\u5074 (\u5BC4\u305B\u306E\u6307\u793A)", "enum": ["above", "below", "left", "right"] } } }, { "description": "\u7BB1\u306E\u4E2D\u306E\u51E6\u7406", "type": "object", "additionalProperties": false, "required": ["type", "box", "label"], "properties": { "type": { "const": "action" }, "box": { "$ref": "#/definitions/id" }, "label": { "$ref": "#/definitions/text" } } }, { "description": "\u7BB1\u306E\u4E0B\u306E\u5C0F\u3055\u306A\u5B57\u306E\u66F8\u304D\u63DB\u3048", "type": "object", "additionalProperties": false, "required": ["type", "box", "text"], "properties": { "type": { "const": "swap" }, "box": { "$ref": "#/definitions/id" }, "text": { "$ref": "#/definitions/text" } } }, { "description": "commit \u3092\u7A4D\u3080\u3002\u679D\u5206\u304B\u308C\u306E\u56F3\u3060\u3051\u304C\u66F8\u3051\u308B\u3002\u7A4D\u3093\u3060\u679D\u306E\u672D\u3068\u3001\u305D\u306E\u679D\u3092\u6307\u3059 HEAD \u304C\u9032\u3080\u3002\u5F53\u3066\u76F4\u3057 (copy) \u306F\u679D\u306E\u672D\u3092\u52D5\u304B\u3055\u305A\u3001merge commit (merge) \u306F\u53D6\u308A\u8FBC\u3080\u679D\u306E\u5148\u7AEF\u3082\u89AA\u306B\u6301\u3064", "type": "object", "additionalProperties": false, "required": ["type", "id", "branch"], "properties": { "type": { "const": "commit" }, "id": { "$ref": "#/definitions/id" }, "branch": { "$ref": "#/definitions/id" }, "copy": { "$ref": "#/definitions/id" }, "merge": { "$ref": "#/definitions/id" }, "hash": { "$ref": "#/definitions/hash" }, "note": { "$ref": "#/definitions/text" } } }, { "description": "\u679D\u3092\u5207\u308B\u3002\u679D\u5206\u304B\u308C\u306E\u56F3\u3060\u3051\u304C\u66F8\u3051\u308B\u3002\u679D\u306E\u672D\u3092 from \u306E commit \u3078\u7F6E\u304D\u3001HEAD \u3092\u305D\u306E\u679D\u3078\u79FB\u3059", "type": "object", "additionalProperties": false, "required": ["type", "branch", "from"], "properties": { "type": { "const": "branch" }, "branch": { "$ref": "#/definitions/id" }, "from": { "$ref": "#/definitions/id" } } }, { "description": "\u4E2D\u8EAB\u306E\u5E2F\u306E\u6B04\u306E\u5024\u3068\u672D", "type": "object", "additionalProperties": false, "required": ["type", "field"], "anyOf": [{ "required": ["value"] }, { "required": ["tag"] }], "properties": { "type": { "const": "strip" }, "field": { "$ref": "#/definitions/text" }, "value": { "$ref": "#/definitions/text" }, "tag": { "$ref": "#/definitions/text" } } }] };
2663
+ var pattern11 = new RegExp("^[0-9a-f]{4,40}$", "u");
2664
+ var schema48 = { "properties": { "kind": { "enum": ["envelope", "tag", "coin", "none"] }}};
1866
2665
  function validate19(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
1867
2666
  let vErrors = null;
1868
2667
  let errors = 0;
@@ -1989,7 +2788,7 @@ function validate19(data, { instancePath = "", parentData, parentDataProperty, r
1989
2788
  if (data.kind !== void 0) {
1990
2789
  let data1 = data.kind;
1991
2790
  if (!(data1 === "envelope" || data1 === "tag" || data1 === "coin" || data1 === "none")) {
1992
- const err8 = { instancePath: instancePath + "/kind", schemaPath: "#/properties/kind/enum", keyword: "enum", params: { allowedValues: schema37.properties.kind.enum }, message: "must be equal to one of the allowed values" };
2791
+ const err8 = { instancePath: instancePath + "/kind", schemaPath: "#/properties/kind/enum", keyword: "enum", params: { allowedValues: schema48.properties.kind.enum }, message: "must be equal to one of the allowed values" };
1993
2792
  if (vErrors === null) {
1994
2793
  vErrors = [err8];
1995
2794
  } else {
@@ -2182,7 +2981,7 @@ function validate18(data, { instancePath = "", parentData, parentDataProperty, r
2182
2981
  if (data.labelSide !== void 0) {
2183
2982
  let data5 = data.labelSide;
2184
2983
  if (!(data5 === "above" || data5 === "below" || data5 === "left" || data5 === "right")) {
2185
- const err13 = { instancePath: instancePath + "/labelSide", schemaPath: "#/oneOf/0/properties/labelSide/enum", keyword: "enum", params: { allowedValues: schema33.oneOf[0].properties.labelSide.enum }, message: "must be equal to one of the allowed values" };
2984
+ const err13 = { instancePath: instancePath + "/labelSide", schemaPath: "#/oneOf/0/properties/labelSide/enum", keyword: "enum", params: { allowedValues: schema44.oneOf[0].properties.labelSide.enum }, message: "must be equal to one of the allowed values" };
2186
2985
  if (vErrors === null) {
2187
2986
  vErrors = [err13];
2188
2987
  } else {
@@ -2408,13 +3207,10 @@ function validate18(data, { instancePath = "", parentData, parentDataProperty, r
2408
3207
  }
2409
3208
  errors++;
2410
3209
  }
2411
- } else if (tag0 === "strip") {
2412
- const _errs39 = errors;
2413
- let valid15 = false;
2414
- const _errs40 = errors;
3210
+ } else if (tag0 === "commit") {
2415
3211
  if (data && typeof data == "object" && !Array.isArray(data)) {
2416
- if (data.value === void 0) {
2417
- const err35 = { instancePath, schemaPath: "#/oneOf/3/anyOf/0/required", keyword: "required", params: { missingProperty: "value" }, message: "must have required property 'value'" };
3212
+ if (data.type === void 0) {
3213
+ const err35 = { instancePath, schemaPath: "#/oneOf/3/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property 'type'" };
2418
3214
  if (vErrors === null) {
2419
3215
  vErrors = [err35];
2420
3216
  } else {
@@ -2422,76 +3218,60 @@ function validate18(data, { instancePath = "", parentData, parentDataProperty, r
2422
3218
  }
2423
3219
  errors++;
2424
3220
  }
2425
- }
2426
- var _valid0 = _errs40 === errors;
2427
- valid15 = valid15 || _valid0;
2428
- if (!valid15) {
2429
- const _errs41 = errors;
2430
- if (data && typeof data == "object" && !Array.isArray(data)) {
2431
- if (data.tag === void 0) {
2432
- const err36 = { instancePath, schemaPath: "#/oneOf/3/anyOf/1/required", keyword: "required", params: { missingProperty: "tag" }, message: "must have required property 'tag'" };
2433
- if (vErrors === null) {
2434
- vErrors = [err36];
2435
- } else {
2436
- vErrors.push(err36);
2437
- }
2438
- errors++;
2439
- }
2440
- }
2441
- var _valid0 = _errs41 === errors;
2442
- valid15 = valid15 || _valid0;
2443
- }
2444
- if (!valid15) {
2445
- const err37 = { instancePath, schemaPath: "#/oneOf/3/anyOf", keyword: "anyOf", params: {}, message: "must match a schema in anyOf" };
2446
- if (vErrors === null) {
2447
- vErrors = [err37];
2448
- } else {
2449
- vErrors.push(err37);
2450
- }
2451
- errors++;
2452
- } else {
2453
- errors = _errs39;
2454
- if (vErrors !== null) {
2455
- if (_errs39) {
2456
- vErrors.length = _errs39;
2457
- } else {
2458
- vErrors = null;
2459
- }
2460
- }
2461
- }
2462
- if (data && typeof data == "object" && !Array.isArray(data)) {
2463
- if (data.type === void 0) {
2464
- const err38 = { instancePath, schemaPath: "#/oneOf/3/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property 'type'" };
3221
+ if (data.id === void 0) {
3222
+ const err36 = { instancePath, schemaPath: "#/oneOf/3/required", keyword: "required", params: { missingProperty: "id" }, message: "must have required property 'id'" };
2465
3223
  if (vErrors === null) {
2466
- vErrors = [err38];
3224
+ vErrors = [err36];
2467
3225
  } else {
2468
- vErrors.push(err38);
3226
+ vErrors.push(err36);
2469
3227
  }
2470
3228
  errors++;
2471
3229
  }
2472
- if (data.field === void 0) {
2473
- const err39 = { instancePath, schemaPath: "#/oneOf/3/required", keyword: "required", params: { missingProperty: "field" }, message: "must have required property 'field'" };
3230
+ if (data.branch === void 0) {
3231
+ const err37 = { instancePath, schemaPath: "#/oneOf/3/required", keyword: "required", params: { missingProperty: "branch" }, message: "must have required property 'branch'" };
2474
3232
  if (vErrors === null) {
2475
- vErrors = [err39];
3233
+ vErrors = [err37];
2476
3234
  } else {
2477
- vErrors.push(err39);
3235
+ vErrors.push(err37);
2478
3236
  }
2479
3237
  errors++;
2480
3238
  }
2481
3239
  for (const key3 in data) {
2482
- if (!(key3 === "type" || key3 === "field" || key3 === "value" || key3 === "tag")) {
2483
- const err40 = { instancePath, schemaPath: "#/oneOf/3/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key3 }, message: "must NOT have additional properties" };
3240
+ if (!(key3 === "type" || key3 === "id" || key3 === "branch" || key3 === "copy" || key3 === "merge" || key3 === "hash" || key3 === "note")) {
3241
+ const err38 = { instancePath, schemaPath: "#/oneOf/3/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key3 }, message: "must NOT have additional properties" };
2484
3242
  if (vErrors === null) {
2485
- vErrors = [err40];
3243
+ vErrors = [err38];
2486
3244
  } else {
2487
- vErrors.push(err40);
3245
+ vErrors.push(err38);
2488
3246
  }
2489
3247
  errors++;
2490
3248
  }
2491
3249
  }
2492
3250
  if (data.type !== void 0) {
2493
- if ("strip" !== data.type) {
2494
- const err41 = { instancePath: instancePath + "/type", schemaPath: "#/oneOf/3/properties/type/const", keyword: "const", params: { allowedValue: "strip" }, message: "must be equal to constant" };
3251
+ if ("commit" !== data.type) {
3252
+ const err39 = { instancePath: instancePath + "/type", schemaPath: "#/oneOf/3/properties/type/const", keyword: "const", params: { allowedValue: "commit" }, message: "must be equal to constant" };
3253
+ if (vErrors === null) {
3254
+ vErrors = [err39];
3255
+ } else {
3256
+ vErrors.push(err39);
3257
+ }
3258
+ errors++;
3259
+ }
3260
+ }
3261
+ if (data.id !== void 0) {
3262
+ let data13 = data.id;
3263
+ if (typeof data13 === "string") {
3264
+ if (!pattern0.test(data13)) {
3265
+ const err40 = { instancePath: instancePath + "/id", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
3266
+ if (vErrors === null) {
3267
+ vErrors = [err40];
3268
+ } else {
3269
+ vErrors.push(err40);
3270
+ }
3271
+ errors++;
3272
+ }
3273
+ } else {
3274
+ const err41 = { instancePath: instancePath + "/id", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
2495
3275
  if (vErrors === null) {
2496
3276
  vErrors = [err41];
2497
3277
  } else {
@@ -2500,11 +3280,11 @@ function validate18(data, { instancePath = "", parentData, parentDataProperty, r
2500
3280
  errors++;
2501
3281
  }
2502
3282
  }
2503
- if (data.field !== void 0) {
2504
- let data13 = data.field;
2505
- if (typeof data13 === "string") {
2506
- if (func3(data13) < 1) {
2507
- const err42 = { instancePath: instancePath + "/field", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
3283
+ if (data.branch !== void 0) {
3284
+ let data14 = data.branch;
3285
+ if (typeof data14 === "string") {
3286
+ if (!pattern0.test(data14)) {
3287
+ const err42 = { instancePath: instancePath + "/branch", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
2508
3288
  if (vErrors === null) {
2509
3289
  vErrors = [err42];
2510
3290
  } else {
@@ -2513,7 +3293,7 @@ function validate18(data, { instancePath = "", parentData, parentDataProperty, r
2513
3293
  errors++;
2514
3294
  }
2515
3295
  } else {
2516
- const err43 = { instancePath: instancePath + "/field", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
3296
+ const err43 = { instancePath: instancePath + "/branch", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
2517
3297
  if (vErrors === null) {
2518
3298
  vErrors = [err43];
2519
3299
  } else {
@@ -2522,11 +3302,11 @@ function validate18(data, { instancePath = "", parentData, parentDataProperty, r
2522
3302
  errors++;
2523
3303
  }
2524
3304
  }
2525
- if (data.value !== void 0) {
2526
- let data14 = data.value;
2527
- if (typeof data14 === "string") {
2528
- if (func3(data14) < 1) {
2529
- const err44 = { instancePath: instancePath + "/value", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
3305
+ if (data.copy !== void 0) {
3306
+ let data15 = data.copy;
3307
+ if (typeof data15 === "string") {
3308
+ if (!pattern0.test(data15)) {
3309
+ const err44 = { instancePath: instancePath + "/copy", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
2530
3310
  if (vErrors === null) {
2531
3311
  vErrors = [err44];
2532
3312
  } else {
@@ -2535,7 +3315,7 @@ function validate18(data, { instancePath = "", parentData, parentDataProperty, r
2535
3315
  errors++;
2536
3316
  }
2537
3317
  } else {
2538
- const err45 = { instancePath: instancePath + "/value", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
3318
+ const err45 = { instancePath: instancePath + "/copy", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
2539
3319
  if (vErrors === null) {
2540
3320
  vErrors = [err45];
2541
3321
  } else {
@@ -2544,11 +3324,11 @@ function validate18(data, { instancePath = "", parentData, parentDataProperty, r
2544
3324
  errors++;
2545
3325
  }
2546
3326
  }
2547
- if (data.tag !== void 0) {
2548
- let data15 = data.tag;
2549
- if (typeof data15 === "string") {
2550
- if (func3(data15) < 1) {
2551
- const err46 = { instancePath: instancePath + "/tag", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
3327
+ if (data.merge !== void 0) {
3328
+ let data16 = data.merge;
3329
+ if (typeof data16 === "string") {
3330
+ if (!pattern0.test(data16)) {
3331
+ const err46 = { instancePath: instancePath + "/merge", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
2552
3332
  if (vErrors === null) {
2553
3333
  vErrors = [err46];
2554
3334
  } else {
@@ -2557,7 +3337,7 @@ function validate18(data, { instancePath = "", parentData, parentDataProperty, r
2557
3337
  errors++;
2558
3338
  }
2559
3339
  } else {
2560
- const err47 = { instancePath: instancePath + "/tag", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
3340
+ const err47 = { instancePath: instancePath + "/merge", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
2561
3341
  if (vErrors === null) {
2562
3342
  vErrors = [err47];
2563
3343
  } else {
@@ -2566,39 +3346,354 @@ function validate18(data, { instancePath = "", parentData, parentDataProperty, r
2566
3346
  errors++;
2567
3347
  }
2568
3348
  }
3349
+ if (data.hash !== void 0) {
3350
+ let data17 = data.hash;
3351
+ if (typeof data17 === "string") {
3352
+ if (!pattern11.test(data17)) {
3353
+ const err48 = { instancePath: instancePath + "/hash", schemaPath: "#/definitions/hash/pattern", keyword: "pattern", params: { pattern: "^[0-9a-f]{4,40}$" }, message: 'must match pattern "^[0-9a-f]{4,40}$"' };
3354
+ if (vErrors === null) {
3355
+ vErrors = [err48];
3356
+ } else {
3357
+ vErrors.push(err48);
3358
+ }
3359
+ errors++;
3360
+ }
3361
+ } else {
3362
+ const err49 = { instancePath: instancePath + "/hash", schemaPath: "#/definitions/hash/type", keyword: "type", params: { type: "string" }, message: "must be string" };
3363
+ if (vErrors === null) {
3364
+ vErrors = [err49];
3365
+ } else {
3366
+ vErrors.push(err49);
3367
+ }
3368
+ errors++;
3369
+ }
3370
+ }
3371
+ if (data.note !== void 0) {
3372
+ let data18 = data.note;
3373
+ if (typeof data18 === "string") {
3374
+ if (func3(data18) < 1) {
3375
+ const err50 = { instancePath: instancePath + "/note", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
3376
+ if (vErrors === null) {
3377
+ vErrors = [err50];
3378
+ } else {
3379
+ vErrors.push(err50);
3380
+ }
3381
+ errors++;
3382
+ }
3383
+ } else {
3384
+ const err51 = { instancePath: instancePath + "/note", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
3385
+ if (vErrors === null) {
3386
+ vErrors = [err51];
3387
+ } else {
3388
+ vErrors.push(err51);
3389
+ }
3390
+ errors++;
3391
+ }
3392
+ }
2569
3393
  } else {
2570
- const err48 = { instancePath, schemaPath: "#/oneOf/3/type", keyword: "type", params: { type: "object" }, message: "must be object" };
3394
+ const err52 = { instancePath, schemaPath: "#/oneOf/3/type", keyword: "type", params: { type: "object" }, message: "must be object" };
2571
3395
  if (vErrors === null) {
2572
- vErrors = [err48];
3396
+ vErrors = [err52];
2573
3397
  } else {
2574
- vErrors.push(err48);
3398
+ vErrors.push(err52);
2575
3399
  }
2576
3400
  errors++;
2577
3401
  }
2578
- } else {
2579
- const err49 = { instancePath, schemaPath: "#/discriminator", keyword: "discriminator", params: { error: "mapping", tag: "type", tagValue: tag0 }, message: 'value of tag "type" must be in oneOf' };
2580
- if (vErrors === null) {
2581
- vErrors = [err49];
2582
- } else {
2583
- vErrors.push(err49);
2584
- }
2585
- errors++;
2586
- }
2587
- } else {
2588
- const err50 = { instancePath, schemaPath: "#/discriminator", keyword: "discriminator", params: { error: "tag", tag: "type", tagValue: tag0 }, message: 'tag "type" must be string' };
2589
- if (vErrors === null) {
2590
- vErrors = [err50];
2591
- } else {
2592
- vErrors.push(err50);
2593
- }
2594
- errors++;
2595
- }
2596
- } else {
2597
- const err51 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
2598
- if (vErrors === null) {
2599
- vErrors = [err51];
2600
- } else {
2601
- vErrors.push(err51);
3402
+ } else if (tag0 === "branch") {
3403
+ if (data && typeof data == "object" && !Array.isArray(data)) {
3404
+ if (data.type === void 0) {
3405
+ const err53 = { instancePath, schemaPath: "#/oneOf/4/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property 'type'" };
3406
+ if (vErrors === null) {
3407
+ vErrors = [err53];
3408
+ } else {
3409
+ vErrors.push(err53);
3410
+ }
3411
+ errors++;
3412
+ }
3413
+ if (data.branch === void 0) {
3414
+ const err54 = { instancePath, schemaPath: "#/oneOf/4/required", keyword: "required", params: { missingProperty: "branch" }, message: "must have required property 'branch'" };
3415
+ if (vErrors === null) {
3416
+ vErrors = [err54];
3417
+ } else {
3418
+ vErrors.push(err54);
3419
+ }
3420
+ errors++;
3421
+ }
3422
+ if (data.from === void 0) {
3423
+ const err55 = { instancePath, schemaPath: "#/oneOf/4/required", keyword: "required", params: { missingProperty: "from" }, message: "must have required property 'from'" };
3424
+ if (vErrors === null) {
3425
+ vErrors = [err55];
3426
+ } else {
3427
+ vErrors.push(err55);
3428
+ }
3429
+ errors++;
3430
+ }
3431
+ for (const key4 in data) {
3432
+ if (!(key4 === "type" || key4 === "branch" || key4 === "from")) {
3433
+ const err56 = { instancePath, schemaPath: "#/oneOf/4/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key4 }, message: "must NOT have additional properties" };
3434
+ if (vErrors === null) {
3435
+ vErrors = [err56];
3436
+ } else {
3437
+ vErrors.push(err56);
3438
+ }
3439
+ errors++;
3440
+ }
3441
+ }
3442
+ if (data.type !== void 0) {
3443
+ if ("branch" !== data.type) {
3444
+ const err57 = { instancePath: instancePath + "/type", schemaPath: "#/oneOf/4/properties/type/const", keyword: "const", params: { allowedValue: "branch" }, message: "must be equal to constant" };
3445
+ if (vErrors === null) {
3446
+ vErrors = [err57];
3447
+ } else {
3448
+ vErrors.push(err57);
3449
+ }
3450
+ errors++;
3451
+ }
3452
+ }
3453
+ if (data.branch !== void 0) {
3454
+ let data20 = data.branch;
3455
+ if (typeof data20 === "string") {
3456
+ if (!pattern0.test(data20)) {
3457
+ const err58 = { instancePath: instancePath + "/branch", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
3458
+ if (vErrors === null) {
3459
+ vErrors = [err58];
3460
+ } else {
3461
+ vErrors.push(err58);
3462
+ }
3463
+ errors++;
3464
+ }
3465
+ } else {
3466
+ const err59 = { instancePath: instancePath + "/branch", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
3467
+ if (vErrors === null) {
3468
+ vErrors = [err59];
3469
+ } else {
3470
+ vErrors.push(err59);
3471
+ }
3472
+ errors++;
3473
+ }
3474
+ }
3475
+ if (data.from !== void 0) {
3476
+ let data21 = data.from;
3477
+ if (typeof data21 === "string") {
3478
+ if (!pattern0.test(data21)) {
3479
+ const err60 = { instancePath: instancePath + "/from", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
3480
+ if (vErrors === null) {
3481
+ vErrors = [err60];
3482
+ } else {
3483
+ vErrors.push(err60);
3484
+ }
3485
+ errors++;
3486
+ }
3487
+ } else {
3488
+ const err61 = { instancePath: instancePath + "/from", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
3489
+ if (vErrors === null) {
3490
+ vErrors = [err61];
3491
+ } else {
3492
+ vErrors.push(err61);
3493
+ }
3494
+ errors++;
3495
+ }
3496
+ }
3497
+ } else {
3498
+ const err62 = { instancePath, schemaPath: "#/oneOf/4/type", keyword: "type", params: { type: "object" }, message: "must be object" };
3499
+ if (vErrors === null) {
3500
+ vErrors = [err62];
3501
+ } else {
3502
+ vErrors.push(err62);
3503
+ }
3504
+ errors++;
3505
+ }
3506
+ } else if (tag0 === "strip") {
3507
+ const _errs71 = errors;
3508
+ let valid27 = false;
3509
+ const _errs72 = errors;
3510
+ if (data && typeof data == "object" && !Array.isArray(data)) {
3511
+ if (data.value === void 0) {
3512
+ const err63 = { instancePath, schemaPath: "#/oneOf/5/anyOf/0/required", keyword: "required", params: { missingProperty: "value" }, message: "must have required property 'value'" };
3513
+ if (vErrors === null) {
3514
+ vErrors = [err63];
3515
+ } else {
3516
+ vErrors.push(err63);
3517
+ }
3518
+ errors++;
3519
+ }
3520
+ }
3521
+ var _valid0 = _errs72 === errors;
3522
+ valid27 = valid27 || _valid0;
3523
+ if (!valid27) {
3524
+ const _errs73 = errors;
3525
+ if (data && typeof data == "object" && !Array.isArray(data)) {
3526
+ if (data.tag === void 0) {
3527
+ const err64 = { instancePath, schemaPath: "#/oneOf/5/anyOf/1/required", keyword: "required", params: { missingProperty: "tag" }, message: "must have required property 'tag'" };
3528
+ if (vErrors === null) {
3529
+ vErrors = [err64];
3530
+ } else {
3531
+ vErrors.push(err64);
3532
+ }
3533
+ errors++;
3534
+ }
3535
+ }
3536
+ var _valid0 = _errs73 === errors;
3537
+ valid27 = valid27 || _valid0;
3538
+ }
3539
+ if (!valid27) {
3540
+ const err65 = { instancePath, schemaPath: "#/oneOf/5/anyOf", keyword: "anyOf", params: {}, message: "must match a schema in anyOf" };
3541
+ if (vErrors === null) {
3542
+ vErrors = [err65];
3543
+ } else {
3544
+ vErrors.push(err65);
3545
+ }
3546
+ errors++;
3547
+ } else {
3548
+ errors = _errs71;
3549
+ if (vErrors !== null) {
3550
+ if (_errs71) {
3551
+ vErrors.length = _errs71;
3552
+ } else {
3553
+ vErrors = null;
3554
+ }
3555
+ }
3556
+ }
3557
+ if (data && typeof data == "object" && !Array.isArray(data)) {
3558
+ if (data.type === void 0) {
3559
+ const err66 = { instancePath, schemaPath: "#/oneOf/5/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property 'type'" };
3560
+ if (vErrors === null) {
3561
+ vErrors = [err66];
3562
+ } else {
3563
+ vErrors.push(err66);
3564
+ }
3565
+ errors++;
3566
+ }
3567
+ if (data.field === void 0) {
3568
+ const err67 = { instancePath, schemaPath: "#/oneOf/5/required", keyword: "required", params: { missingProperty: "field" }, message: "must have required property 'field'" };
3569
+ if (vErrors === null) {
3570
+ vErrors = [err67];
3571
+ } else {
3572
+ vErrors.push(err67);
3573
+ }
3574
+ errors++;
3575
+ }
3576
+ for (const key5 in data) {
3577
+ if (!(key5 === "type" || key5 === "field" || key5 === "value" || key5 === "tag")) {
3578
+ const err68 = { instancePath, schemaPath: "#/oneOf/5/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key5 }, message: "must NOT have additional properties" };
3579
+ if (vErrors === null) {
3580
+ vErrors = [err68];
3581
+ } else {
3582
+ vErrors.push(err68);
3583
+ }
3584
+ errors++;
3585
+ }
3586
+ }
3587
+ if (data.type !== void 0) {
3588
+ if ("strip" !== data.type) {
3589
+ const err69 = { instancePath: instancePath + "/type", schemaPath: "#/oneOf/5/properties/type/const", keyword: "const", params: { allowedValue: "strip" }, message: "must be equal to constant" };
3590
+ if (vErrors === null) {
3591
+ vErrors = [err69];
3592
+ } else {
3593
+ vErrors.push(err69);
3594
+ }
3595
+ errors++;
3596
+ }
3597
+ }
3598
+ if (data.field !== void 0) {
3599
+ let data23 = data.field;
3600
+ if (typeof data23 === "string") {
3601
+ if (func3(data23) < 1) {
3602
+ const err70 = { instancePath: instancePath + "/field", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
3603
+ if (vErrors === null) {
3604
+ vErrors = [err70];
3605
+ } else {
3606
+ vErrors.push(err70);
3607
+ }
3608
+ errors++;
3609
+ }
3610
+ } else {
3611
+ const err71 = { instancePath: instancePath + "/field", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
3612
+ if (vErrors === null) {
3613
+ vErrors = [err71];
3614
+ } else {
3615
+ vErrors.push(err71);
3616
+ }
3617
+ errors++;
3618
+ }
3619
+ }
3620
+ if (data.value !== void 0) {
3621
+ let data24 = data.value;
3622
+ if (typeof data24 === "string") {
3623
+ if (func3(data24) < 1) {
3624
+ const err72 = { instancePath: instancePath + "/value", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
3625
+ if (vErrors === null) {
3626
+ vErrors = [err72];
3627
+ } else {
3628
+ vErrors.push(err72);
3629
+ }
3630
+ errors++;
3631
+ }
3632
+ } else {
3633
+ const err73 = { instancePath: instancePath + "/value", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
3634
+ if (vErrors === null) {
3635
+ vErrors = [err73];
3636
+ } else {
3637
+ vErrors.push(err73);
3638
+ }
3639
+ errors++;
3640
+ }
3641
+ }
3642
+ if (data.tag !== void 0) {
3643
+ let data25 = data.tag;
3644
+ if (typeof data25 === "string") {
3645
+ if (func3(data25) < 1) {
3646
+ const err74 = { instancePath: instancePath + "/tag", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
3647
+ if (vErrors === null) {
3648
+ vErrors = [err74];
3649
+ } else {
3650
+ vErrors.push(err74);
3651
+ }
3652
+ errors++;
3653
+ }
3654
+ } else {
3655
+ const err75 = { instancePath: instancePath + "/tag", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
3656
+ if (vErrors === null) {
3657
+ vErrors = [err75];
3658
+ } else {
3659
+ vErrors.push(err75);
3660
+ }
3661
+ errors++;
3662
+ }
3663
+ }
3664
+ } else {
3665
+ const err76 = { instancePath, schemaPath: "#/oneOf/5/type", keyword: "type", params: { type: "object" }, message: "must be object" };
3666
+ if (vErrors === null) {
3667
+ vErrors = [err76];
3668
+ } else {
3669
+ vErrors.push(err76);
3670
+ }
3671
+ errors++;
3672
+ }
3673
+ } else {
3674
+ const err77 = { instancePath, schemaPath: "#/discriminator", keyword: "discriminator", params: { error: "mapping", tag: "type", tagValue: tag0 }, message: 'value of tag "type" must be in oneOf' };
3675
+ if (vErrors === null) {
3676
+ vErrors = [err77];
3677
+ } else {
3678
+ vErrors.push(err77);
3679
+ }
3680
+ errors++;
3681
+ }
3682
+ } else {
3683
+ const err78 = { instancePath, schemaPath: "#/discriminator", keyword: "discriminator", params: { error: "tag", tag: "type", tagValue: tag0 }, message: 'tag "type" must be string' };
3684
+ if (vErrors === null) {
3685
+ vErrors = [err78];
3686
+ } else {
3687
+ vErrors.push(err78);
3688
+ }
3689
+ errors++;
3690
+ }
3691
+ } else {
3692
+ const err79 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
3693
+ if (vErrors === null) {
3694
+ vErrors = [err79];
3695
+ } else {
3696
+ vErrors.push(err79);
2602
3697
  }
2603
3698
  errors++;
2604
3699
  }
@@ -2887,62 +3982,207 @@ function validate26(data, { instancePath = "", parentData, parentDataProperty, r
2887
3982
  if (!pattern0.test(data1)) {
2888
3983
  const err5 = { instancePath: instancePath + "/to", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
2889
3984
  if (vErrors === null) {
2890
- vErrors = [err5];
3985
+ vErrors = [err5];
3986
+ } else {
3987
+ vErrors.push(err5);
3988
+ }
3989
+ errors++;
3990
+ }
3991
+ } else {
3992
+ const err6 = { instancePath: instancePath + "/to", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
3993
+ if (vErrors === null) {
3994
+ vErrors = [err6];
3995
+ } else {
3996
+ vErrors.push(err6);
3997
+ }
3998
+ errors++;
3999
+ }
4000
+ }
4001
+ if (data.label !== void 0) {
4002
+ let data2 = data.label;
4003
+ if (typeof data2 === "string") {
4004
+ if (func3(data2) < 1) {
4005
+ const err7 = { instancePath: instancePath + "/label", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
4006
+ if (vErrors === null) {
4007
+ vErrors = [err7];
4008
+ } else {
4009
+ vErrors.push(err7);
4010
+ }
4011
+ errors++;
4012
+ }
4013
+ } else {
4014
+ const err8 = { instancePath: instancePath + "/label", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
4015
+ if (vErrors === null) {
4016
+ vErrors = [err8];
4017
+ } else {
4018
+ vErrors.push(err8);
4019
+ }
4020
+ errors++;
4021
+ }
4022
+ }
4023
+ } else {
4024
+ const err9 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
4025
+ if (vErrors === null) {
4026
+ vErrors = [err9];
4027
+ } else {
4028
+ vErrors.push(err9);
4029
+ }
4030
+ errors++;
4031
+ }
4032
+ validate26.errors = vErrors;
4033
+ return errors === 0;
4034
+ }
4035
+ function validate25(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
4036
+ let vErrors = null;
4037
+ let errors = 0;
4038
+ if (data && typeof data == "object" && !Array.isArray(data)) {
4039
+ if (data.paths === void 0) {
4040
+ const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "paths" }, message: "must have required property 'paths'" };
4041
+ if (vErrors === null) {
4042
+ vErrors = [err0];
4043
+ } else {
4044
+ vErrors.push(err0);
4045
+ }
4046
+ errors++;
4047
+ }
4048
+ for (const key0 in data) {
4049
+ if (!(key0 === "paths")) {
4050
+ const err1 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
4051
+ if (vErrors === null) {
4052
+ vErrors = [err1];
4053
+ } else {
4054
+ vErrors.push(err1);
4055
+ }
4056
+ errors++;
4057
+ }
4058
+ }
4059
+ if (data.paths !== void 0) {
4060
+ let data0 = data.paths;
4061
+ if (Array.isArray(data0)) {
4062
+ if (data0.length < 1) {
4063
+ const err2 = { instancePath: instancePath + "/paths", schemaPath: "#/properties/paths/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
4064
+ if (vErrors === null) {
4065
+ vErrors = [err2];
4066
+ } else {
4067
+ vErrors.push(err2);
4068
+ }
4069
+ errors++;
4070
+ }
4071
+ const len0 = data0.length;
4072
+ for (let i0 = 0; i0 < len0; i0++) {
4073
+ if (!validate26(data0[i0], { instancePath: instancePath + "/paths/" + i0, parentData: data0, parentDataProperty: i0, rootData })) {
4074
+ vErrors = vErrors === null ? validate26.errors : vErrors.concat(validate26.errors);
4075
+ errors = vErrors.length;
4076
+ }
4077
+ }
4078
+ } else {
4079
+ const err3 = { instancePath: instancePath + "/paths", schemaPath: "#/properties/paths/type", keyword: "type", params: { type: "array" }, message: "must be array" };
4080
+ if (vErrors === null) {
4081
+ vErrors = [err3];
4082
+ } else {
4083
+ vErrors.push(err3);
4084
+ }
4085
+ errors++;
4086
+ }
4087
+ }
4088
+ } else {
4089
+ const err4 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
4090
+ if (vErrors === null) {
4091
+ vErrors = [err4];
4092
+ } else {
4093
+ vErrors.push(err4);
4094
+ }
4095
+ errors++;
4096
+ }
4097
+ validate25.errors = vErrors;
4098
+ return errors === 0;
4099
+ }
4100
+ function validate30(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
4101
+ let vErrors = null;
4102
+ let errors = 0;
4103
+ if (data && typeof data == "object" && !Array.isArray(data)) {
4104
+ if (data.id === void 0) {
4105
+ const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "id" }, message: "must have required property 'id'" };
4106
+ if (vErrors === null) {
4107
+ vErrors = [err0];
4108
+ } else {
4109
+ vErrors.push(err0);
4110
+ }
4111
+ errors++;
4112
+ }
4113
+ for (const key0 in data) {
4114
+ if (!(key0 === "id" || key0 === "note")) {
4115
+ const err1 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
4116
+ if (vErrors === null) {
4117
+ vErrors = [err1];
4118
+ } else {
4119
+ vErrors.push(err1);
4120
+ }
4121
+ errors++;
4122
+ }
4123
+ }
4124
+ if (data.id !== void 0) {
4125
+ let data0 = data.id;
4126
+ if (typeof data0 === "string") {
4127
+ if (!pattern0.test(data0)) {
4128
+ const err2 = { instancePath: instancePath + "/id", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
4129
+ if (vErrors === null) {
4130
+ vErrors = [err2];
2891
4131
  } else {
2892
- vErrors.push(err5);
4132
+ vErrors.push(err2);
2893
4133
  }
2894
4134
  errors++;
2895
4135
  }
2896
4136
  } else {
2897
- const err6 = { instancePath: instancePath + "/to", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
4137
+ const err3 = { instancePath: instancePath + "/id", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
2898
4138
  if (vErrors === null) {
2899
- vErrors = [err6];
4139
+ vErrors = [err3];
2900
4140
  } else {
2901
- vErrors.push(err6);
4141
+ vErrors.push(err3);
2902
4142
  }
2903
4143
  errors++;
2904
4144
  }
2905
4145
  }
2906
- if (data.label !== void 0) {
2907
- let data2 = data.label;
2908
- if (typeof data2 === "string") {
2909
- if (func3(data2) < 1) {
2910
- const err7 = { instancePath: instancePath + "/label", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
4146
+ if (data.note !== void 0) {
4147
+ let data1 = data.note;
4148
+ if (typeof data1 === "string") {
4149
+ if (func3(data1) < 1) {
4150
+ const err4 = { instancePath: instancePath + "/note", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
2911
4151
  if (vErrors === null) {
2912
- vErrors = [err7];
4152
+ vErrors = [err4];
2913
4153
  } else {
2914
- vErrors.push(err7);
4154
+ vErrors.push(err4);
2915
4155
  }
2916
4156
  errors++;
2917
4157
  }
2918
4158
  } else {
2919
- const err8 = { instancePath: instancePath + "/label", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
4159
+ const err5 = { instancePath: instancePath + "/note", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
2920
4160
  if (vErrors === null) {
2921
- vErrors = [err8];
4161
+ vErrors = [err5];
2922
4162
  } else {
2923
- vErrors.push(err8);
4163
+ vErrors.push(err5);
2924
4164
  }
2925
4165
  errors++;
2926
4166
  }
2927
4167
  }
2928
4168
  } else {
2929
- const err9 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
4169
+ const err6 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
2930
4170
  if (vErrors === null) {
2931
- vErrors = [err9];
4171
+ vErrors = [err6];
2932
4172
  } else {
2933
- vErrors.push(err9);
4173
+ vErrors.push(err6);
2934
4174
  }
2935
4175
  errors++;
2936
4176
  }
2937
- validate26.errors = vErrors;
4177
+ validate30.errors = vErrors;
2938
4178
  return errors === 0;
2939
4179
  }
2940
- function validate25(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
4180
+ function validate29(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
2941
4181
  let vErrors = null;
2942
4182
  let errors = 0;
2943
4183
  if (data && typeof data == "object" && !Array.isArray(data)) {
2944
- if (data.paths === void 0) {
2945
- const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "paths" }, message: "must have required property 'paths'" };
4184
+ if (data.branches === void 0) {
4185
+ const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "branches" }, message: "must have required property 'branches'" };
2946
4186
  if (vErrors === null) {
2947
4187
  vErrors = [err0];
2948
4188
  } else {
@@ -2951,7 +4191,7 @@ function validate25(data, { instancePath = "", parentData, parentDataProperty, r
2951
4191
  errors++;
2952
4192
  }
2953
4193
  for (const key0 in data) {
2954
- if (!(key0 === "paths")) {
4194
+ if (!(key0 === "branches")) {
2955
4195
  const err1 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
2956
4196
  if (vErrors === null) {
2957
4197
  vErrors = [err1];
@@ -2961,11 +4201,11 @@ function validate25(data, { instancePath = "", parentData, parentDataProperty, r
2961
4201
  errors++;
2962
4202
  }
2963
4203
  }
2964
- if (data.paths !== void 0) {
2965
- let data0 = data.paths;
4204
+ if (data.branches !== void 0) {
4205
+ let data0 = data.branches;
2966
4206
  if (Array.isArray(data0)) {
2967
4207
  if (data0.length < 1) {
2968
- const err2 = { instancePath: instancePath + "/paths", schemaPath: "#/properties/paths/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
4208
+ const err2 = { instancePath: instancePath + "/branches", schemaPath: "#/properties/branches/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
2969
4209
  if (vErrors === null) {
2970
4210
  vErrors = [err2];
2971
4211
  } else {
@@ -2975,13 +4215,13 @@ function validate25(data, { instancePath = "", parentData, parentDataProperty, r
2975
4215
  }
2976
4216
  const len0 = data0.length;
2977
4217
  for (let i0 = 0; i0 < len0; i0++) {
2978
- if (!validate26(data0[i0], { instancePath: instancePath + "/paths/" + i0, parentData: data0, parentDataProperty: i0, rootData })) {
2979
- vErrors = vErrors === null ? validate26.errors : vErrors.concat(validate26.errors);
4218
+ if (!validate30(data0[i0], { instancePath: instancePath + "/branches/" + i0, parentData: data0, parentDataProperty: i0, rootData })) {
4219
+ vErrors = vErrors === null ? validate30.errors : vErrors.concat(validate30.errors);
2980
4220
  errors = vErrors.length;
2981
4221
  }
2982
4222
  }
2983
4223
  } else {
2984
- const err3 = { instancePath: instancePath + "/paths", schemaPath: "#/properties/paths/type", keyword: "type", params: { type: "array" }, message: "must be array" };
4224
+ const err3 = { instancePath: instancePath + "/branches", schemaPath: "#/properties/branches/type", keyword: "type", params: { type: "array" }, message: "must be array" };
2985
4225
  if (vErrors === null) {
2986
4226
  vErrors = [err3];
2987
4227
  } else {
@@ -2999,7 +4239,7 @@ function validate25(data, { instancePath = "", parentData, parentDataProperty, r
2999
4239
  }
3000
4240
  errors++;
3001
4241
  }
3002
- validate25.errors = vErrors;
4242
+ validate29.errors = vErrors;
3003
4243
  return errors === 0;
3004
4244
  }
3005
4245
  function validate10(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
@@ -3043,11 +4283,9 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
3043
4283
  let ifClause0;
3044
4284
  if (_valid0) {
3045
4285
  const _errs4 = errors;
3046
- const _errs5 = errors;
3047
- const _errs6 = errors;
3048
4286
  if (data && typeof data == "object" && !Array.isArray(data)) {
3049
- if (data.state === void 0 && ("state")) {
3050
- const err2 = {};
4287
+ if (data.sequence === void 0) {
4288
+ const err2 = { instancePath, schemaPath: "#/then/required", keyword: "required", params: { missingProperty: "sequence" }, message: "must have required property 'sequence'" };
3051
4289
  if (vErrors === null) {
3052
4290
  vErrors = [err2];
3053
4291
  } else {
@@ -3055,147 +4293,181 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
3055
4293
  }
3056
4294
  errors++;
3057
4295
  }
3058
- }
3059
- var valid2 = _errs6 === errors;
3060
- if (valid2) {
3061
- const err3 = { instancePath, schemaPath: "#/then/not", keyword: "not", params: {}, message: "must NOT be valid" };
3062
- if (vErrors === null) {
3063
- vErrors = [err3];
3064
- } else {
3065
- vErrors.push(err3);
4296
+ if (data.boxes !== void 0) {
4297
+ let data1 = data.boxes;
4298
+ if (Array.isArray(data1)) {
4299
+ if (data1.length < 1) {
4300
+ const err3 = { instancePath: instancePath + "/boxes", schemaPath: "#/then/properties/boxes/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
4301
+ if (vErrors === null) {
4302
+ vErrors = [err3];
4303
+ } else {
4304
+ vErrors.push(err3);
4305
+ }
4306
+ errors++;
4307
+ }
4308
+ }
3066
4309
  }
3067
- errors++;
3068
- } else {
3069
- errors = _errs5;
3070
- if (vErrors !== null) {
3071
- if (_errs5) {
3072
- vErrors.length = _errs5;
3073
- } else {
3074
- vErrors = null;
4310
+ if (data.steps !== void 0) {
4311
+ let data2 = data.steps;
4312
+ if (Array.isArray(data2)) {
4313
+ const len0 = data2.length;
4314
+ for (let i0 = 0; i0 < len0; i0++) {
4315
+ let data3 = data2[i0];
4316
+ if (data3 && typeof data3 == "object" && !Array.isArray(data3)) {
4317
+ if (data3.events !== void 0) {
4318
+ let data4 = data3.events;
4319
+ if (Array.isArray(data4)) {
4320
+ const len1 = data4.length;
4321
+ for (let i1 = 0; i1 < len1; i1++) {
4322
+ let data5 = data4[i1];
4323
+ if (data5 && typeof data5 == "object" && !Array.isArray(data5)) {
4324
+ if (data5.type !== void 0) {
4325
+ let data6 = data5.type;
4326
+ const _errs12 = errors;
4327
+ const _errs13 = errors;
4328
+ if (!(data6 === "commit" || data6 === "branch")) {
4329
+ const err4 = {};
4330
+ if (vErrors === null) {
4331
+ vErrors = [err4];
4332
+ } else {
4333
+ vErrors.push(err4);
4334
+ }
4335
+ errors++;
4336
+ }
4337
+ var valid10 = _errs13 === errors;
4338
+ if (valid10) {
4339
+ const err5 = { instancePath: instancePath + "/steps/" + i0 + "/events/" + i1 + "/type", schemaPath: "#/definitions/plainSteps/items/properties/events/items/properties/type/not", keyword: "not", params: {}, message: "must NOT be valid" };
4340
+ if (vErrors === null) {
4341
+ vErrors = [err5];
4342
+ } else {
4343
+ vErrors.push(err5);
4344
+ }
4345
+ errors++;
4346
+ } else {
4347
+ errors = _errs12;
4348
+ if (vErrors !== null) {
4349
+ if (_errs12) {
4350
+ vErrors.length = _errs12;
4351
+ } else {
4352
+ vErrors = null;
4353
+ }
4354
+ }
4355
+ }
4356
+ }
4357
+ }
4358
+ }
4359
+ }
4360
+ }
4361
+ }
4362
+ }
3075
4363
  }
3076
4364
  }
3077
- }
3078
- if (data && typeof data == "object" && !Array.isArray(data)) {
3079
- if (data.sequence === void 0) {
3080
- const err4 = { instancePath, schemaPath: "#/then/required", keyword: "required", params: { missingProperty: "sequence" }, message: "must have required property 'sequence'" };
4365
+ if (data.state !== void 0) {
4366
+ const err6 = { instancePath: instancePath + "/state", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
3081
4367
  if (vErrors === null) {
3082
- vErrors = [err4];
4368
+ vErrors = [err6];
3083
4369
  } else {
3084
- vErrors.push(err4);
4370
+ vErrors.push(err6);
3085
4371
  }
3086
4372
  errors++;
3087
4373
  }
3088
- }
3089
- var _valid0 = _errs4 === errors;
3090
- valid0 = _valid0;
3091
- ifClause0 = "then";
3092
- } else {
3093
- const _errs7 = errors;
3094
- const _errs8 = errors;
3095
- const _errs9 = errors;
3096
- if (data && typeof data == "object" && !Array.isArray(data)) {
3097
- if (data.sequence === void 0 && ("sequence")) {
3098
- const err5 = {};
4374
+ if (data.git !== void 0) {
4375
+ const err7 = { instancePath: instancePath + "/git", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
3099
4376
  if (vErrors === null) {
3100
- vErrors = [err5];
4377
+ vErrors = [err7];
3101
4378
  } else {
3102
- vErrors.push(err5);
4379
+ vErrors.push(err7);
3103
4380
  }
3104
4381
  errors++;
3105
4382
  }
3106
4383
  }
3107
- var valid3 = _errs9 === errors;
3108
- if (valid3) {
3109
- const err6 = { instancePath, schemaPath: "#/else/not", keyword: "not", params: {}, message: "must NOT be valid" };
3110
- if (vErrors === null) {
3111
- vErrors = [err6];
3112
- } else {
3113
- vErrors.push(err6);
3114
- }
3115
- errors++;
3116
- } else {
3117
- errors = _errs8;
3118
- if (vErrors !== null) {
3119
- if (_errs8) {
3120
- vErrors.length = _errs8;
3121
- } else {
3122
- vErrors = null;
3123
- }
3124
- }
3125
- }
3126
- const _errs10 = errors;
3127
- let valid4 = true;
3128
- const _errs11 = errors;
4384
+ var _valid0 = _errs4 === errors;
4385
+ valid0 = _valid0;
4386
+ ifClause0 = "then";
4387
+ } else {
4388
+ const _errs20 = errors;
4389
+ const _errs21 = errors;
4390
+ let valid13 = true;
4391
+ const _errs22 = errors;
3129
4392
  if (data && typeof data == "object" && !Array.isArray(data)) {
3130
4393
  if (data.kind === void 0 && ("kind")) {
3131
- const err7 = {};
4394
+ const err8 = {};
3132
4395
  if (vErrors === null) {
3133
- vErrors = [err7];
4396
+ vErrors = [err8];
3134
4397
  } else {
3135
- vErrors.push(err7);
4398
+ vErrors.push(err8);
3136
4399
  }
3137
4400
  errors++;
3138
4401
  } else {
3139
4402
  if (data.kind !== void 0) {
3140
4403
  if ("state" !== data.kind) {
3141
- const err8 = {};
4404
+ const err9 = {};
3142
4405
  if (vErrors === null) {
3143
- vErrors = [err8];
4406
+ vErrors = [err9];
3144
4407
  } else {
3145
- vErrors.push(err8);
4408
+ vErrors.push(err9);
3146
4409
  }
3147
4410
  errors++;
3148
4411
  }
3149
4412
  }
3150
4413
  }
3151
4414
  }
3152
- var _valid1 = _errs11 === errors;
3153
- errors = _errs10;
4415
+ var _valid1 = _errs22 === errors;
4416
+ errors = _errs21;
3154
4417
  if (vErrors !== null) {
3155
- if (_errs10) {
3156
- vErrors.length = _errs10;
4418
+ if (_errs21) {
4419
+ vErrors.length = _errs21;
3157
4420
  } else {
3158
4421
  vErrors = null;
3159
4422
  }
3160
4423
  }
3161
4424
  let ifClause1;
3162
4425
  if (_valid1) {
3163
- const _errs13 = errors;
4426
+ const _errs24 = errors;
3164
4427
  if (data && typeof data == "object" && !Array.isArray(data)) {
3165
4428
  if (data.boxes !== void 0) {
3166
- let data2 = data.boxes;
3167
- if (Array.isArray(data2)) {
3168
- const len0 = data2.length;
3169
- for (let i0 = 0; i0 < len0; i0++) {
3170
- let data3 = data2[i0];
3171
- if (data3 && typeof data3 == "object" && !Array.isArray(data3)) {
3172
- if (data3.id !== void 0) {
3173
- let data4 = data3.id;
3174
- const _errs17 = errors;
3175
- const _errs18 = errors;
3176
- if (!(data4 === "start" || data4 === "finish")) {
3177
- const err9 = {};
4429
+ let data10 = data.boxes;
4430
+ if (Array.isArray(data10)) {
4431
+ if (data10.length < 1) {
4432
+ const err10 = { instancePath: instancePath + "/boxes", schemaPath: "#/else/then/properties/boxes/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
4433
+ if (vErrors === null) {
4434
+ vErrors = [err10];
4435
+ } else {
4436
+ vErrors.push(err10);
4437
+ }
4438
+ errors++;
4439
+ }
4440
+ const len2 = data10.length;
4441
+ for (let i2 = 0; i2 < len2; i2++) {
4442
+ let data11 = data10[i2];
4443
+ if (data11 && typeof data11 == "object" && !Array.isArray(data11)) {
4444
+ if (data11.id !== void 0) {
4445
+ let data12 = data11.id;
4446
+ const _errs28 = errors;
4447
+ const _errs29 = errors;
4448
+ if (!(data12 === "start" || data12 === "finish")) {
4449
+ const err11 = {};
3178
4450
  if (vErrors === null) {
3179
- vErrors = [err9];
4451
+ vErrors = [err11];
3180
4452
  } else {
3181
- vErrors.push(err9);
4453
+ vErrors.push(err11);
3182
4454
  }
3183
4455
  errors++;
3184
4456
  }
3185
- var valid10 = _errs18 === errors;
3186
- if (valid10) {
3187
- const err10 = { instancePath: instancePath + "/boxes/" + i0 + "/id", schemaPath: "#/else/then/properties/boxes/items/properties/id/not", keyword: "not", params: {}, message: "must NOT be valid" };
4457
+ var valid19 = _errs29 === errors;
4458
+ if (valid19) {
4459
+ const err12 = { instancePath: instancePath + "/boxes/" + i2 + "/id", schemaPath: "#/else/then/properties/boxes/items/properties/id/not", keyword: "not", params: {}, message: "must NOT be valid" };
3188
4460
  if (vErrors === null) {
3189
- vErrors = [err10];
4461
+ vErrors = [err12];
3190
4462
  } else {
3191
- vErrors.push(err10);
4463
+ vErrors.push(err12);
3192
4464
  }
3193
4465
  errors++;
3194
4466
  } else {
3195
- errors = _errs17;
4467
+ errors = _errs28;
3196
4468
  if (vErrors !== null) {
3197
- if (_errs17) {
3198
- vErrors.length = _errs17;
4469
+ if (_errs28) {
4470
+ vErrors.length = _errs28;
3199
4471
  } else {
3200
4472
  vErrors = null;
3201
4473
  }
@@ -3206,241 +4478,449 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
3206
4478
  }
3207
4479
  }
3208
4480
  }
4481
+ if (data.steps !== void 0) {
4482
+ let data13 = data.steps;
4483
+ if (Array.isArray(data13)) {
4484
+ const len3 = data13.length;
4485
+ for (let i3 = 0; i3 < len3; i3++) {
4486
+ let data14 = data13[i3];
4487
+ if (data14 && typeof data14 == "object" && !Array.isArray(data14)) {
4488
+ if (data14.events !== void 0) {
4489
+ let data15 = data14.events;
4490
+ if (Array.isArray(data15)) {
4491
+ const len4 = data15.length;
4492
+ for (let i4 = 0; i4 < len4; i4++) {
4493
+ let data16 = data15[i4];
4494
+ if (data16 && typeof data16 == "object" && !Array.isArray(data16)) {
4495
+ if (data16.type !== void 0) {
4496
+ let data17 = data16.type;
4497
+ const _errs36 = errors;
4498
+ const _errs37 = errors;
4499
+ if (!(data17 === "commit" || data17 === "branch")) {
4500
+ const err13 = {};
4501
+ if (vErrors === null) {
4502
+ vErrors = [err13];
4503
+ } else {
4504
+ vErrors.push(err13);
4505
+ }
4506
+ errors++;
4507
+ }
4508
+ var valid27 = _errs37 === errors;
4509
+ if (valid27) {
4510
+ const err14 = { instancePath: instancePath + "/steps/" + i3 + "/events/" + i4 + "/type", schemaPath: "#/definitions/plainSteps/items/properties/events/items/properties/type/not", keyword: "not", params: {}, message: "must NOT be valid" };
4511
+ if (vErrors === null) {
4512
+ vErrors = [err14];
4513
+ } else {
4514
+ vErrors.push(err14);
4515
+ }
4516
+ errors++;
4517
+ } else {
4518
+ errors = _errs36;
4519
+ if (vErrors !== null) {
4520
+ if (_errs36) {
4521
+ vErrors.length = _errs36;
4522
+ } else {
4523
+ vErrors = null;
4524
+ }
4525
+ }
4526
+ }
4527
+ }
4528
+ }
4529
+ }
4530
+ }
4531
+ }
4532
+ }
4533
+ }
4534
+ }
4535
+ }
4536
+ if (data.git !== void 0) {
4537
+ const err15 = { instancePath: instancePath + "/git", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
4538
+ if (vErrors === null) {
4539
+ vErrors = [err15];
4540
+ } else {
4541
+ vErrors.push(err15);
4542
+ }
4543
+ errors++;
4544
+ }
3209
4545
  }
3210
- var _valid1 = _errs13 === errors;
3211
- valid4 = _valid1;
4546
+ var _valid1 = _errs24 === errors;
4547
+ valid13 = _valid1;
3212
4548
  ifClause1 = "then";
3213
4549
  } else {
3214
- const _errs19 = errors;
3215
- const _errs20 = errors;
3216
- const _errs21 = errors;
4550
+ const _errs41 = errors;
4551
+ const _errs42 = errors;
4552
+ let valid29 = true;
4553
+ const _errs43 = errors;
3217
4554
  if (data && typeof data == "object" && !Array.isArray(data)) {
3218
- if (data.state === void 0 && ("state")) {
3219
- const err11 = {};
4555
+ if (data.kind === void 0 && ("kind")) {
4556
+ const err16 = {};
3220
4557
  if (vErrors === null) {
3221
- vErrors = [err11];
4558
+ vErrors = [err16];
3222
4559
  } else {
3223
- vErrors.push(err11);
4560
+ vErrors.push(err16);
3224
4561
  }
3225
4562
  errors++;
4563
+ } else {
4564
+ if (data.kind !== void 0) {
4565
+ if ("git" !== data.kind) {
4566
+ const err17 = {};
4567
+ if (vErrors === null) {
4568
+ vErrors = [err17];
4569
+ } else {
4570
+ vErrors.push(err17);
4571
+ }
4572
+ errors++;
4573
+ }
4574
+ }
3226
4575
  }
3227
4576
  }
3228
- var valid11 = _errs21 === errors;
3229
- if (valid11) {
3230
- const err12 = { instancePath, schemaPath: "#/else/else/not", keyword: "not", params: {}, message: "must NOT be valid" };
3231
- if (vErrors === null) {
3232
- vErrors = [err12];
4577
+ var _valid2 = _errs43 === errors;
4578
+ errors = _errs42;
4579
+ if (vErrors !== null) {
4580
+ if (_errs42) {
4581
+ vErrors.length = _errs42;
3233
4582
  } else {
3234
- vErrors.push(err12);
4583
+ vErrors = null;
3235
4584
  }
3236
- errors++;
4585
+ }
4586
+ let ifClause2;
4587
+ if (_valid2) {
4588
+ const _errs45 = errors;
4589
+ if (data && typeof data == "object" && !Array.isArray(data)) {
4590
+ if (data.git === void 0) {
4591
+ const err18 = { instancePath, schemaPath: "#/else/else/then/required", keyword: "required", params: { missingProperty: "git" }, message: "must have required property 'git'" };
4592
+ if (vErrors === null) {
4593
+ vErrors = [err18];
4594
+ } else {
4595
+ vErrors.push(err18);
4596
+ }
4597
+ errors++;
4598
+ }
4599
+ if (data.state !== void 0) {
4600
+ const err19 = { instancePath: instancePath + "/state", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
4601
+ if (vErrors === null) {
4602
+ vErrors = [err19];
4603
+ } else {
4604
+ vErrors.push(err19);
4605
+ }
4606
+ errors++;
4607
+ }
4608
+ if (data.regions !== void 0) {
4609
+ const err20 = { instancePath: instancePath + "/regions", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
4610
+ if (vErrors === null) {
4611
+ vErrors = [err20];
4612
+ } else {
4613
+ vErrors.push(err20);
4614
+ }
4615
+ errors++;
4616
+ }
4617
+ }
4618
+ var _valid2 = _errs45 === errors;
4619
+ valid29 = _valid2;
4620
+ ifClause2 = "then";
3237
4621
  } else {
3238
- errors = _errs20;
3239
- if (vErrors !== null) {
3240
- if (_errs20) {
3241
- vErrors.length = _errs20;
3242
- } else {
3243
- vErrors = null;
4622
+ const _errs52 = errors;
4623
+ if (data && typeof data == "object" && !Array.isArray(data)) {
4624
+ if (data.boxes !== void 0) {
4625
+ let data22 = data.boxes;
4626
+ if (Array.isArray(data22)) {
4627
+ if (data22.length < 1) {
4628
+ const err21 = { instancePath: instancePath + "/boxes", schemaPath: "#/else/else/else/properties/boxes/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
4629
+ if (vErrors === null) {
4630
+ vErrors = [err21];
4631
+ } else {
4632
+ vErrors.push(err21);
4633
+ }
4634
+ errors++;
4635
+ }
4636
+ }
4637
+ }
4638
+ if (data.steps !== void 0) {
4639
+ let data23 = data.steps;
4640
+ if (Array.isArray(data23)) {
4641
+ const len5 = data23.length;
4642
+ for (let i5 = 0; i5 < len5; i5++) {
4643
+ let data24 = data23[i5];
4644
+ if (data24 && typeof data24 == "object" && !Array.isArray(data24)) {
4645
+ if (data24.events !== void 0) {
4646
+ let data25 = data24.events;
4647
+ if (Array.isArray(data25)) {
4648
+ const len6 = data25.length;
4649
+ for (let i6 = 0; i6 < len6; i6++) {
4650
+ let data26 = data25[i6];
4651
+ if (data26 && typeof data26 == "object" && !Array.isArray(data26)) {
4652
+ if (data26.type !== void 0) {
4653
+ let data27 = data26.type;
4654
+ const _errs60 = errors;
4655
+ const _errs61 = errors;
4656
+ if (!(data27 === "commit" || data27 === "branch")) {
4657
+ const err22 = {};
4658
+ if (vErrors === null) {
4659
+ vErrors = [err22];
4660
+ } else {
4661
+ vErrors.push(err22);
4662
+ }
4663
+ errors++;
4664
+ }
4665
+ var valid42 = _errs61 === errors;
4666
+ if (valid42) {
4667
+ const err23 = { instancePath: instancePath + "/steps/" + i5 + "/events/" + i6 + "/type", schemaPath: "#/definitions/plainSteps/items/properties/events/items/properties/type/not", keyword: "not", params: {}, message: "must NOT be valid" };
4668
+ if (vErrors === null) {
4669
+ vErrors = [err23];
4670
+ } else {
4671
+ vErrors.push(err23);
4672
+ }
4673
+ errors++;
4674
+ } else {
4675
+ errors = _errs60;
4676
+ if (vErrors !== null) {
4677
+ if (_errs60) {
4678
+ vErrors.length = _errs60;
4679
+ } else {
4680
+ vErrors = null;
4681
+ }
4682
+ }
4683
+ }
4684
+ }
4685
+ }
4686
+ }
4687
+ }
4688
+ }
4689
+ }
4690
+ }
4691
+ }
4692
+ }
4693
+ if (data.state !== void 0) {
4694
+ const err24 = { instancePath: instancePath + "/state", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
4695
+ if (vErrors === null) {
4696
+ vErrors = [err24];
4697
+ } else {
4698
+ vErrors.push(err24);
4699
+ }
4700
+ errors++;
4701
+ }
4702
+ if (data.git !== void 0) {
4703
+ const err25 = { instancePath: instancePath + "/git", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
4704
+ if (vErrors === null) {
4705
+ vErrors = [err25];
4706
+ } else {
4707
+ vErrors.push(err25);
4708
+ }
4709
+ errors++;
3244
4710
  }
3245
4711
  }
4712
+ var _valid2 = _errs52 === errors;
4713
+ valid29 = _valid2;
4714
+ ifClause2 = "else";
4715
+ }
4716
+ if (!valid29) {
4717
+ const err26 = { instancePath, schemaPath: "#/else/else/if", keyword: "if", params: { failingKeyword: ifClause2 }, message: 'must match "' + ifClause2 + '" schema' };
4718
+ if (vErrors === null) {
4719
+ vErrors = [err26];
4720
+ } else {
4721
+ vErrors.push(err26);
4722
+ }
4723
+ errors++;
3246
4724
  }
3247
- var _valid1 = _errs19 === errors;
3248
- valid4 = _valid1;
4725
+ var _valid1 = _errs41 === errors;
4726
+ valid13 = _valid1;
3249
4727
  ifClause1 = "else";
3250
4728
  }
3251
- if (!valid4) {
3252
- const err13 = { instancePath, schemaPath: "#/else/if", keyword: "if", params: { failingKeyword: ifClause1 }, message: 'must match "' + ifClause1 + '" schema' };
4729
+ if (!valid13) {
4730
+ const err27 = { instancePath, schemaPath: "#/else/if", keyword: "if", params: { failingKeyword: ifClause1 }, message: 'must match "' + ifClause1 + '" schema' };
3253
4731
  if (vErrors === null) {
3254
- vErrors = [err13];
4732
+ vErrors = [err27];
3255
4733
  } else {
3256
- vErrors.push(err13);
4734
+ vErrors.push(err27);
3257
4735
  }
3258
4736
  errors++;
3259
4737
  }
3260
- var _valid0 = _errs7 === errors;
4738
+ if (data && typeof data == "object" && !Array.isArray(data)) {
4739
+ if (data.sequence !== void 0) {
4740
+ const err28 = { instancePath: instancePath + "/sequence", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
4741
+ if (vErrors === null) {
4742
+ vErrors = [err28];
4743
+ } else {
4744
+ vErrors.push(err28);
4745
+ }
4746
+ errors++;
4747
+ }
4748
+ }
4749
+ var _valid0 = _errs20 === errors;
3261
4750
  valid0 = _valid0;
3262
4751
  ifClause0 = "else";
3263
4752
  }
3264
4753
  if (!valid0) {
3265
- const err14 = { instancePath, schemaPath: "#/if", keyword: "if", params: { failingKeyword: ifClause0 }, message: 'must match "' + ifClause0 + '" schema' };
4754
+ const err29 = { instancePath, schemaPath: "#/if", keyword: "if", params: { failingKeyword: ifClause0 }, message: 'must match "' + ifClause0 + '" schema' };
3266
4755
  if (vErrors === null) {
3267
- vErrors = [err14];
4756
+ vErrors = [err29];
3268
4757
  } else {
3269
- vErrors.push(err14);
4758
+ vErrors.push(err29);
3270
4759
  }
3271
4760
  errors++;
3272
4761
  }
3273
4762
  if (data && typeof data == "object" && !Array.isArray(data)) {
3274
4763
  if (data.version === void 0) {
3275
- const err15 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "version" }, message: "must have required property 'version'" };
4764
+ const err30 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "version" }, message: "must have required property 'version'" };
3276
4765
  if (vErrors === null) {
3277
- vErrors = [err15];
4766
+ vErrors = [err30];
3278
4767
  } else {
3279
- vErrors.push(err15);
4768
+ vErrors.push(err30);
3280
4769
  }
3281
4770
  errors++;
3282
4771
  }
3283
4772
  if (data.kind === void 0) {
3284
- const err16 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "kind" }, message: "must have required property 'kind'" };
4773
+ const err31 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "kind" }, message: "must have required property 'kind'" };
3285
4774
  if (vErrors === null) {
3286
- vErrors = [err16];
4775
+ vErrors = [err31];
3287
4776
  } else {
3288
- vErrors.push(err16);
4777
+ vErrors.push(err31);
3289
4778
  }
3290
4779
  errors++;
3291
4780
  }
3292
4781
  if (data.title === void 0) {
3293
- const err17 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "title" }, message: "must have required property 'title'" };
4782
+ const err32 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "title" }, message: "must have required property 'title'" };
3294
4783
  if (vErrors === null) {
3295
- vErrors = [err17];
4784
+ vErrors = [err32];
3296
4785
  } else {
3297
- vErrors.push(err17);
4786
+ vErrors.push(err32);
3298
4787
  }
3299
4788
  errors++;
3300
4789
  }
3301
4790
  if (data.boxes === void 0) {
3302
- const err18 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "boxes" }, message: "must have required property 'boxes'" };
4791
+ const err33 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "boxes" }, message: "must have required property 'boxes'" };
3303
4792
  if (vErrors === null) {
3304
- vErrors = [err18];
4793
+ vErrors = [err33];
3305
4794
  } else {
3306
- vErrors.push(err18);
4795
+ vErrors.push(err33);
3307
4796
  }
3308
4797
  errors++;
3309
4798
  }
3310
4799
  if (data.steps === void 0) {
3311
- const err19 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "steps" }, message: "must have required property 'steps'" };
4800
+ const err34 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "steps" }, message: "must have required property 'steps'" };
3312
4801
  if (vErrors === null) {
3313
- vErrors = [err19];
4802
+ vErrors = [err34];
3314
4803
  } else {
3315
- vErrors.push(err19);
4804
+ vErrors.push(err34);
3316
4805
  }
3317
4806
  errors++;
3318
4807
  }
3319
4808
  for (const key0 in data) {
3320
4809
  if (!func2.call(schema11.properties, key0)) {
3321
- const err20 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
4810
+ const err35 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
3322
4811
  if (vErrors === null) {
3323
- vErrors = [err20];
4812
+ vErrors = [err35];
3324
4813
  } else {
3325
- vErrors.push(err20);
4814
+ vErrors.push(err35);
3326
4815
  }
3327
4816
  errors++;
3328
4817
  }
3329
4818
  }
3330
4819
  if (data.version !== void 0) {
3331
- let data5 = data.version;
3332
- if (!(typeof data5 == "number" && (!(data5 % 1) && !isNaN(data5)) && isFinite(data5))) {
3333
- const err21 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
4820
+ let data31 = data.version;
4821
+ if (!(typeof data31 == "number" && (!(data31 % 1) && !isNaN(data31)) && isFinite(data31))) {
4822
+ const err36 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
3334
4823
  if (vErrors === null) {
3335
- vErrors = [err21];
4824
+ vErrors = [err36];
3336
4825
  } else {
3337
- vErrors.push(err21);
4826
+ vErrors.push(err36);
3338
4827
  }
3339
4828
  errors++;
3340
4829
  }
3341
- if (typeof data5 == "number" && isFinite(data5)) {
3342
- if (data5 < 1 || isNaN(data5)) {
3343
- const err22 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/minimum", keyword: "minimum", params: { comparison: ">=", limit: 1 }, message: "must be >= 1" };
4830
+ if (typeof data31 == "number" && isFinite(data31)) {
4831
+ if (data31 < 1 || isNaN(data31)) {
4832
+ const err37 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/minimum", keyword: "minimum", params: { comparison: ">=", limit: 1 }, message: "must be >= 1" };
3344
4833
  if (vErrors === null) {
3345
- vErrors = [err22];
4834
+ vErrors = [err37];
3346
4835
  } else {
3347
- vErrors.push(err22);
4836
+ vErrors.push(err37);
3348
4837
  }
3349
4838
  errors++;
3350
4839
  }
3351
4840
  }
3352
4841
  }
3353
4842
  if (data.kind !== void 0) {
3354
- let data6 = data.kind;
3355
- if (!(data6 === "sequence" || data6 === "architecture" || data6 === "state")) {
3356
- const err23 = { instancePath: instancePath + "/kind", schemaPath: "#/properties/kind/enum", keyword: "enum", params: { allowedValues: schema11.properties.kind.enum }, message: "must be equal to one of the allowed values" };
4843
+ let data32 = data.kind;
4844
+ if (!(data32 === "sequence" || data32 === "architecture" || data32 === "state" || data32 === "git")) {
4845
+ const err38 = { instancePath: instancePath + "/kind", schemaPath: "#/properties/kind/enum", keyword: "enum", params: { allowedValues: schema11.properties.kind.enum }, message: "must be equal to one of the allowed values" };
3357
4846
  if (vErrors === null) {
3358
- vErrors = [err23];
4847
+ vErrors = [err38];
3359
4848
  } else {
3360
- vErrors.push(err23);
4849
+ vErrors.push(err38);
3361
4850
  }
3362
4851
  errors++;
3363
4852
  }
3364
4853
  }
3365
4854
  if (data.title !== void 0) {
3366
- let data7 = data.title;
3367
- if (typeof data7 === "string") {
3368
- if (func3(data7) < 1) {
3369
- const err24 = { instancePath: instancePath + "/title", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
4855
+ let data33 = data.title;
4856
+ if (typeof data33 === "string") {
4857
+ if (func3(data33) < 1) {
4858
+ const err39 = { instancePath: instancePath + "/title", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
3370
4859
  if (vErrors === null) {
3371
- vErrors = [err24];
4860
+ vErrors = [err39];
3372
4861
  } else {
3373
- vErrors.push(err24);
4862
+ vErrors.push(err39);
3374
4863
  }
3375
4864
  errors++;
3376
4865
  }
3377
4866
  } else {
3378
- const err25 = { instancePath: instancePath + "/title", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
4867
+ const err40 = { instancePath: instancePath + "/title", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
3379
4868
  if (vErrors === null) {
3380
- vErrors = [err25];
4869
+ vErrors = [err40];
3381
4870
  } else {
3382
- vErrors.push(err25);
4871
+ vErrors.push(err40);
3383
4872
  }
3384
4873
  errors++;
3385
4874
  }
3386
4875
  }
3387
4876
  if (data.view !== void 0) {
3388
- let data8 = data.view;
3389
- if (!(data8 === "fixed" || data8 === "follow")) {
3390
- const err26 = { instancePath: instancePath + "/view", schemaPath: "#/properties/view/enum", keyword: "enum", params: { allowedValues: schema11.properties.view.enum }, message: "must be equal to one of the allowed values" };
4877
+ let data34 = data.view;
4878
+ if (!(data34 === "fixed" || data34 === "follow")) {
4879
+ const err41 = { instancePath: instancePath + "/view", schemaPath: "#/properties/view/enum", keyword: "enum", params: { allowedValues: schema11.properties.view.enum }, message: "must be equal to one of the allowed values" };
3391
4880
  if (vErrors === null) {
3392
- vErrors = [err26];
4881
+ vErrors = [err41];
3393
4882
  } else {
3394
- vErrors.push(err26);
4883
+ vErrors.push(err41);
3395
4884
  }
3396
4885
  errors++;
3397
4886
  }
3398
4887
  }
3399
4888
  if (data.regions !== void 0) {
3400
- let data9 = data.regions;
3401
- if (Array.isArray(data9)) {
3402
- const len1 = data9.length;
3403
- for (let i1 = 0; i1 < len1; i1++) {
3404
- if (!validate11(data9[i1], { instancePath: instancePath + "/regions/" + i1, parentData: data9, parentDataProperty: i1, rootData })) {
4889
+ let data35 = data.regions;
4890
+ if (Array.isArray(data35)) {
4891
+ const len7 = data35.length;
4892
+ for (let i7 = 0; i7 < len7; i7++) {
4893
+ if (!validate11(data35[i7], { instancePath: instancePath + "/regions/" + i7, parentData: data35, parentDataProperty: i7, rootData })) {
3405
4894
  vErrors = vErrors === null ? validate11.errors : vErrors.concat(validate11.errors);
3406
4895
  errors = vErrors.length;
3407
4896
  }
3408
4897
  }
3409
4898
  } else {
3410
- const err27 = { instancePath: instancePath + "/regions", schemaPath: "#/properties/regions/type", keyword: "type", params: { type: "array" }, message: "must be array" };
4899
+ const err42 = { instancePath: instancePath + "/regions", schemaPath: "#/properties/regions/type", keyword: "type", params: { type: "array" }, message: "must be array" };
3411
4900
  if (vErrors === null) {
3412
- vErrors = [err27];
4901
+ vErrors = [err42];
3413
4902
  } else {
3414
- vErrors.push(err27);
4903
+ vErrors.push(err42);
3415
4904
  }
3416
4905
  errors++;
3417
4906
  }
3418
4907
  }
3419
4908
  if (data.boxes !== void 0) {
3420
- let data11 = data.boxes;
3421
- if (Array.isArray(data11)) {
3422
- if (data11.length < 1) {
3423
- const err28 = { instancePath: instancePath + "/boxes", schemaPath: "#/properties/boxes/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
3424
- if (vErrors === null) {
3425
- vErrors = [err28];
3426
- } else {
3427
- vErrors.push(err28);
3428
- }
3429
- errors++;
3430
- }
3431
- const len2 = data11.length;
3432
- for (let i2 = 0; i2 < len2; i2++) {
3433
- if (!validate13(data11[i2], { instancePath: instancePath + "/boxes/" + i2, parentData: data11, parentDataProperty: i2, rootData })) {
4909
+ let data37 = data.boxes;
4910
+ if (Array.isArray(data37)) {
4911
+ const len8 = data37.length;
4912
+ for (let i8 = 0; i8 < len8; i8++) {
4913
+ if (!validate13(data37[i8], { instancePath: instancePath + "/boxes/" + i8, parentData: data37, parentDataProperty: i8, rootData })) {
3434
4914
  vErrors = vErrors === null ? validate13.errors : vErrors.concat(validate13.errors);
3435
4915
  errors = vErrors.length;
3436
4916
  }
3437
4917
  }
3438
4918
  } else {
3439
- const err29 = { instancePath: instancePath + "/boxes", schemaPath: "#/properties/boxes/type", keyword: "type", params: { type: "array" }, message: "must be array" };
4919
+ const err43 = { instancePath: instancePath + "/boxes", schemaPath: "#/properties/boxes/type", keyword: "type", params: { type: "array" }, message: "must be array" };
3440
4920
  if (vErrors === null) {
3441
- vErrors = [err29];
4921
+ vErrors = [err43];
3442
4922
  } else {
3443
- vErrors.push(err29);
4923
+ vErrors.push(err43);
3444
4924
  }
3445
4925
  errors++;
3446
4926
  }
@@ -3452,30 +4932,30 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
3452
4932
  }
3453
4933
  }
3454
4934
  if (data.steps !== void 0) {
3455
- let data14 = data.steps;
3456
- if (Array.isArray(data14)) {
3457
- if (data14.length < 1) {
3458
- const err30 = { instancePath: instancePath + "/steps", schemaPath: "#/properties/steps/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
4935
+ let data40 = data.steps;
4936
+ if (Array.isArray(data40)) {
4937
+ if (data40.length < 1) {
4938
+ const err44 = { instancePath: instancePath + "/steps", schemaPath: "#/properties/steps/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
3459
4939
  if (vErrors === null) {
3460
- vErrors = [err30];
4940
+ vErrors = [err44];
3461
4941
  } else {
3462
- vErrors.push(err30);
4942
+ vErrors.push(err44);
3463
4943
  }
3464
4944
  errors++;
3465
4945
  }
3466
- const len3 = data14.length;
3467
- for (let i3 = 0; i3 < len3; i3++) {
3468
- if (!validate17(data14[i3], { instancePath: instancePath + "/steps/" + i3, parentData: data14, parentDataProperty: i3, rootData })) {
4946
+ const len9 = data40.length;
4947
+ for (let i9 = 0; i9 < len9; i9++) {
4948
+ if (!validate17(data40[i9], { instancePath: instancePath + "/steps/" + i9, parentData: data40, parentDataProperty: i9, rootData })) {
3469
4949
  vErrors = vErrors === null ? validate17.errors : vErrors.concat(validate17.errors);
3470
4950
  errors = vErrors.length;
3471
4951
  }
3472
4952
  }
3473
4953
  } else {
3474
- const err31 = { instancePath: instancePath + "/steps", schemaPath: "#/properties/steps/type", keyword: "type", params: { type: "array" }, message: "must be array" };
4954
+ const err45 = { instancePath: instancePath + "/steps", schemaPath: "#/properties/steps/type", keyword: "type", params: { type: "array" }, message: "must be array" };
3475
4955
  if (vErrors === null) {
3476
- vErrors = [err31];
4956
+ vErrors = [err45];
3477
4957
  } else {
3478
- vErrors.push(err31);
4958
+ vErrors.push(err45);
3479
4959
  }
3480
4960
  errors++;
3481
4961
  }
@@ -3492,12 +4972,18 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
3492
4972
  errors = vErrors.length;
3493
4973
  }
3494
4974
  }
4975
+ if (data.git !== void 0) {
4976
+ if (!validate29(data.git, { instancePath: instancePath + "/git", parentData: data, parentDataProperty: "git", rootData })) {
4977
+ vErrors = vErrors === null ? validate29.errors : vErrors.concat(validate29.errors);
4978
+ errors = vErrors.length;
4979
+ }
4980
+ }
3495
4981
  } else {
3496
- const err32 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
4982
+ const err46 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
3497
4983
  if (vErrors === null) {
3498
- vErrors = [err32];
4984
+ vErrors = [err46];
3499
4985
  } else {
3500
- vErrors.push(err32);
4986
+ vErrors.push(err46);
3501
4987
  }
3502
4988
  errors++;
3503
4989
  }
@@ -3506,17 +4992,17 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
3506
4992
  }
3507
4993
 
3508
4994
  // src/schema.ts
3509
- var EVENT_TYPES = ["edge", "action", "swap", "strip"];
3510
- var ROOT_NOT_ALLOWED = {
3511
- "#/else/not": { field: "sequence", kind: "sequence" },
3512
- "#/then/not": { field: "state", kind: "state" },
3513
- "#/else/else/not": { field: "state", kind: "state" }
3514
- };
4995
+ var EVENT_TYPES = ["edge", "action", "swap", "strip", "commit", "branch"];
4996
+ var ABSENT = "#/definitions/absent/not";
4997
+ var ABSENT_KINDS = { regions: "sequence / architecture / state" };
3515
4998
  var NOT_ALLOWED = {
3516
4999
  carry: { field: "text", kind: "tag" }
3517
5000
  };
3518
5001
  var RESERVED_ID = /\/boxes\/items\/properties\/id\/not$/u;
5002
+ var GIT_EVENT = /\/events\/items\/properties\/type\/not$/u;
5003
+ var GIT_EVENTS = ["commit", "branch"];
3519
5004
  var escape = (key) => key.replaceAll("~", "~0").replaceAll("/", "~1");
5005
+ var HEX = /^\^\[0-9a-f\]\{(\d+),(\d+)\}\$$/u;
3520
5006
  function forbiddenOf(pattern) {
3521
5007
  const inside = /^\^\[\^(.+)\]\+\$$/u.exec(pattern)?.[1];
3522
5008
  if (inside === void 0) return void 0;
@@ -3540,7 +5026,10 @@ function toFieldError(error, errors, m) {
3540
5026
  }
3541
5027
  case "not": {
3542
5028
  if (RESERVED_ID.test(error.schemaPath)) return { pointer: at2, message: m.reserved(STATE_ENDS) };
3543
- const allowed = at2 === "" ? ROOT_NOT_ALLOWED[error.schemaPath] : NOT_ALLOWED[at2.slice(at2.lastIndexOf("/") + 1)];
5029
+ if (GIT_EVENT.test(error.schemaPath)) return { pointer: at2, message: m.kindOnly(GIT_EVENTS, "git") };
5030
+ const last = at2.slice(at2.lastIndexOf("/") + 1);
5031
+ if (error.schemaPath === ABSENT) return { pointer: at2, message: m.not({ field: last, kind: ABSENT_KINDS[last] ?? last }) };
5032
+ const allowed = NOT_ALLOWED[last];
3544
5033
  return { pointer: allowed ? `${at2}/${allowed.field}` : at2, message: m.not(allowed) };
3545
5034
  }
3546
5035
  case "anyOf": {
@@ -3558,8 +5047,10 @@ function toFieldError(error, errors, m) {
3558
5047
  return { pointer: at2, message: m.type(String(params.type)) };
3559
5048
  case "minLength":
3560
5049
  return { pointer: at2, message: m.minLength(Number(params.limit)) };
3561
- case "pattern":
3562
- return { pointer: at2, message: m.pattern(forbiddenOf(String(params.pattern))) };
5050
+ case "pattern": {
5051
+ const hex2 = HEX.exec(String(params.pattern));
5052
+ return { pointer: at2, message: hex2 ? m.hex(Number(hex2[1]), Number(hex2[2])) : m.pattern(forbiddenOf(String(params.pattern))) };
5053
+ }
3563
5054
  case "minItems":
3564
5055
  return { pointer: at2, message: m.minItems(Number(params.limit)) };
3565
5056
  case "minimum":
@@ -3607,7 +5098,15 @@ function plan(step) {
3607
5098
  let arrived;
3608
5099
  let changes = 0;
3609
5100
  step.events.forEach((event, e) => {
3610
- if (event.type === "edge") {
5101
+ if (event.type === "commit" || event.type === "branch") {
5102
+ const a = cursor;
5103
+ const b = a + MOTION.draw;
5104
+ out.edges.push({ event: e, a, b, carries: false, coin: false, named: false });
5105
+ cursor = a + MOTION.stagger;
5106
+ arrived = b;
5107
+ changes = 0;
5108
+ out.busy = Math.max(out.busy, b);
5109
+ } else if (event.type === "edge") {
3611
5110
  const carries = event.carry.kind !== "none";
3612
5111
  const a = cursor;
3613
5112
  const b = a + (carries ? MOTION.drawCarry : MOTION.draw);
@@ -3652,7 +5151,9 @@ function buildTimeline(diagram) {
3652
5151
  for (const edge2 of p.edges) {
3653
5152
  const a = span.start + edge2.a;
3654
5153
  edges.push({ step: s, event: edge2.event, start: a, drawn: span.start + edge2.b, end: span.end });
3655
- if (edge2.carries) departures.push({ step: s, event: edge2.event, who: edge2.coin ? "coin" : "main", a, b: span.start + edge2.b });
5154
+ const event = diagram.steps[s]?.events[edge2.event];
5155
+ const own = diagram.kind === "git" && event?.type === "edge" && event.carry.kind === "tag" && event.carry.text === event.from;
5156
+ if (edge2.carries && !own) departures.push({ step: s, event: edge2.event, who: edge2.coin ? "coin" : "main", a, b: span.start + edge2.b });
3656
5157
  if (edge2.named) named.push({ step: s, event: edge2.event, start: a + MOTION.labelDelay, end: span.end });
3657
5158
  }
3658
5159
  named.forEach((label2, k) => {
@@ -3761,6 +5262,31 @@ var ICONS = {
3761
5262
  block: "M -9 -7 h18 a2 2 0 0 1 2 2 v10 a2 2 0 0 1 -2 2 h-18 a2 2 0 0 1 -2 -2 v-10 a2 2 0 0 1 2 -2 z M -11 -2.5 h22 M -6 2.5 h8"
3762
5263
  };
3763
5264
 
5265
+ // src/render/ink.ts
5266
+ var ALWAYS = [[0, Number.POSITIVE_INFINITY]];
5267
+ var BITE = 0.5;
5268
+ var visible = (item, t) => item.shown.some(([a, b]) => a <= t && t < b);
5269
+ var spotOf = (ink) => ({ text: ink.text, rect: { x: ink.rect.x, y: ink.rect.y, w: ink.rect.w, h: ink.rect.h }, badge: ink.badge === true, ...ink.part ? { part: ink.part } : {} });
5270
+ function findOverlaps(inks, stills, traces = []) {
5271
+ const out = [];
5272
+ stills.forEach((t, step) => {
5273
+ const seen = inks.filter((ink) => visible(ink, t));
5274
+ seen.forEach((a, i) => {
5275
+ for (const b of seen.slice(i + 1)) {
5276
+ const w = Math.min(a.rect.x + a.rect.w, b.rect.x + b.rect.w) - Math.max(a.rect.x, b.rect.x);
5277
+ const h = Math.min(a.rect.y + a.rect.h, b.rect.y + b.rect.h) - Math.max(a.rect.y, b.rect.y);
5278
+ if (w > BITE && h > BITE) out.push({ kind: "texts", step, texts: [a.text, b.text], spots: [spotOf(a), spotOf(b)] });
5279
+ }
5280
+ });
5281
+ const lines = traces.filter((trace) => visible(trace, t));
5282
+ for (const ink of seen) {
5283
+ if (ink.boxed) continue;
5284
+ for (const line of lines) if (crossesRect(line.points, ink.rect, BITE)) out.push({ kind: "line", step, text: ink.text, line: { from: line.from, to: line.to }, spots: [spotOf(ink)] });
5285
+ }
5286
+ });
5287
+ return out;
5288
+ }
5289
+
3764
5290
  // src/render/parts.ts
3765
5291
  var esc = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
3766
5292
  var r1 = (v) => Math.round(v * 100) / 100;
@@ -3797,6 +5323,10 @@ function arrowHead(points) {
3797
5323
  const { arrow: a, arrowHalf: h } = LOOK.edge;
3798
5324
  return `M ${r1(ex - dx * a - dy * h)} ${r1(ey - dy * a + dx * h)} L ${r1(ex)} ${r1(ey)} L ${r1(ex - dx * a + dy * h)} ${r1(ey - dy * a - dx * h)}`;
3799
5325
  }
5326
+ function write(ink, cls, x, y, text2, style, shown = ALWAYS, anchor) {
5327
+ ink?.push({ text: text2, rect: textBox(text2, x, y, style, anchor), shown });
5328
+ return `<text class="${cls}" x="${r1(x)}" y="${r1(y)}"${anchor ? ` text-anchor="${anchor}"` : ""}>${esc(text2)}</text>`;
5329
+ }
3800
5330
  function rangeKf(m, ranges2) {
3801
5331
  const pts = [[0, { opacity: 0 }]];
3802
5332
  for (const [a, b] of ranges2) pts.push([a, { opacity: 0 }, EASE.out], [a + MOTION.fade, { opacity: 1 }], [b - 0.1, { opacity: 1 }, EASE.inOut], [b + 0.25, { opacity: 0 }]);
@@ -3813,21 +5343,22 @@ function activeKf(ctx, on) {
3813
5343
  }
3814
5344
  return rangeKf(ctx.m, ranges2);
3815
5345
  }
3816
- function band(region) {
5346
+ function band(region, ink) {
3817
5347
  const { radius, icon, iconRadius, iconScale, nameY, line } = LOOK.region;
3818
5348
  const { x, y } = region.header;
3819
- const lines = region.lines.map((t, k) => `<text class="dg-bz" x="${r1(x)}" y="${r1(region.y + nameY + k * line)}">${esc(t)}</text>`).join("");
3820
- const note = region.note ? `<text class="dg-bx" x="${r1(x)}" y="${r1(region.y + nameY + region.lines.length * line + 1)}">${esc(region.note)}</text>` : "";
5349
+ const lines = region.lines.map((t, k) => write(ink, "dg-bz", x, region.y + nameY + k * line, t, TYPE.regionName)).join("");
5350
+ const note = region.note ? write(ink, "dg-bx", x, region.y + nameY + region.lines.length * line + 1, region.note, TYPE.regionNote) : "";
3821
5351
  const mark = region.icon && ICONS[region.icon] ? `<rect class="dg-bi" x="${r1(x)}" y="${r1(y)}" width="${icon}" height="${icon}" rx="${iconRadius}"/>${glyph(region.icon, x + icon / 2, y + icon / 2, iconScale)}` : "";
3822
5352
  return `<g style="${cs(region.color)}"><rect class="dg-band" x="${r1(region.x + 0.5)}" y="${r1(region.y + 0.5)}" width="${r1(region.w - 1)}" height="${r1(region.h - 1)}" rx="${radius}"/>${mark}${lines}${note}</g>`;
3823
5353
  }
3824
- function subLines(box, m, changes, y) {
5354
+ function subLines(box, m, changes, y, ink) {
3825
5355
  const seq = [[0, box.sub ?? "", "dg-ss"], ...changes];
3826
5356
  return seq.map(([t, text2, cls], k) => {
3827
5357
  const next = seq[k + 1]?.[0];
3828
5358
  const anim = k === 0 ? next === void 0 ? "" : m.until(next - MOTION.untilFade) : next === void 0 ? m.rise(t) : m.rise(t, next - MOTION.untilFade);
3829
5359
  if (text2 === "") return "";
3830
- return `<g${anim ? ` class="dg-a" style="${anim}"` : ""}><text class="${cls}" x="${r1(box.cx)}" y="${r1(y)}" text-anchor="middle">${esc(text2)}</text></g>`;
5360
+ const shown = [[k === 0 ? 0 : t, next === void 0 ? Number.POSITIVE_INFINITY : next - MOTION.untilFade]];
5361
+ return `<g${anim ? ` class="dg-a" style="${anim}"` : ""}>${write(ink, cls, box.cx, y, text2, cls === "dg-ss" ? TYPE.boxSub : TYPE.boxSubStrong, shown, "middle")}</g>`;
3831
5362
  }).join("");
3832
5363
  }
3833
5364
  function cardFrame(box, ctx, act, y, h) {
@@ -3836,10 +5367,17 @@ function cardFrame(box, ctx, act, y, h) {
3836
5367
  }
3837
5368
  function card(box, ctx, on, changes, lit) {
3838
5369
  const { icon, iconRadius, iconScale, iconY, nameY, subY } = LOOK.box;
3839
- const subs = subLines(box, ctx.m, changes, box.cy + subY);
5370
+ const subs = subLines(box, ctx.m, changes, box.cy + subY, ctx.ink);
3840
5371
  const act = lit ? lit.length > 0 ? rangeKf(ctx.m, lit.map((s) => [s.start, s.end])) : void 0 : on.length > 0 ? activeKf(ctx, on) : void 0;
3841
- const mark = box.icon && ICONS[box.icon] ? `<rect class="dg-ic" x="${r1(box.cx - icon / 2)}" y="${r1(box.cy + iconY - icon / 2)}" width="${icon}" height="${icon}" rx="${iconRadius}"/>${glyph(box.icon, box.cx, box.cy + iconY, iconScale)}` : "";
3842
- return `<g style="${cs(box.color)}">${cardFrame(box, ctx, act, box.y, box.h)}${mark}<text class="dg-sn" x="${r1(box.cx)}" y="${r1(box.cy + nameY)}" text-anchor="middle">${esc(box.name)}</text>${subs}</g>`;
5372
+ const ix = box.iconX ?? box.cx;
5373
+ const slot = box.slot ? `<rect class="dg-slot" x="${r1(box.slot.x)}" y="${r1(box.slot.y)}" width="${r1(box.slot.w)}" height="${r1(box.slot.h)}" rx="${LOOK.slot.radius}"/>` : "";
5374
+ let mark = "";
5375
+ if (box.icon && ICONS[box.icon]) {
5376
+ const rect = { x: ix - icon / 2, y: box.cy + iconY - icon / 2, w: icon, h: icon };
5377
+ ctx.ink.push({ text: `${box.name} \u306E\u7D75\u67C4`, rect, shown: ALWAYS, boxed: true, part: { kind: "icon", box: box.name } });
5378
+ mark = `<rect class="dg-ic" x="${r1(rect.x)}" y="${r1(rect.y)}" width="${icon}" height="${icon}" rx="${iconRadius}"/>${glyph(box.icon, ix, box.cy + iconY, iconScale)}`;
5379
+ }
5380
+ return `<g style="${cs(box.color)}">${cardFrame(box, ctx, act, box.y, box.h)}${slot}${mark}${write(ctx.ink, "dg-sn", box.cx, box.cy + nameY, box.name, TYPE.boxName, ALWAYS, "middle")}${subs}</g>`;
3843
5381
  }
3844
5382
  function headCard(box, ctx, on, changes) {
3845
5383
  const { pad: pad2, h, nameY, subY } = LOOK.follow.head;
@@ -3847,15 +5385,15 @@ function headCard(box, ctx, on, changes) {
3847
5385
  const act = on.length > 0 ? activeKf(ctx, on) : void 0;
3848
5386
  return `<g style="${cs(box.color)}">${cardFrame(box, ctx, act, pad2, h)}<text class="dg-sn" x="${r1(box.cx)}" y="${r1(pad2 + nameY)}" text-anchor="middle">${esc(box.name)}</text>${subs}</g>`;
3849
5387
  }
3850
- function ghostCard(box) {
5388
+ function ghostCard(box, ink) {
3851
5389
  const { icon, iconRadius, iconScale, radius } = LOOK.box;
3852
5390
  const G = LOOK.state.ghost;
3853
5391
  const ix = box.x + G.pad + icon / 2;
3854
5392
  const tx = box.x + G.pad + icon + G.gap;
3855
5393
  const mark = box.icon && ICONS[box.icon] ? `<rect class="dg-ic" x="${r1(ix - icon / 2)}" y="${r1(box.cy - icon / 2)}" width="${icon}" height="${icon}" rx="${iconRadius}"/>${glyph(box.icon, ix, box.cy, iconScale)}` : "";
3856
5394
  const nameY = box.sub ? G.nameY : LOOK.baseline.mark;
3857
- const sub = box.sub ? `<text class="dg-ss" x="${r1(tx)}" y="${r1(box.cy + G.subY)}" text-anchor="start">${esc(box.sub)}</text>` : "";
3858
- return `<g data-ghost="${esc(box.id)}" style="${cs(box.color)}"><rect class="dg-ghost" x="${r1(box.x)}" y="${r1(box.y)}" width="${r1(box.w)}" height="${box.h}" rx="${radius}"/>${mark}<text class="dg-sn" x="${r1(tx)}" y="${r1(box.cy + nameY)}" text-anchor="start">${esc(box.name)}</text>${sub}</g>`;
5395
+ const sub = box.sub ? write(ink, "dg-ss", tx, box.cy + G.subY, box.sub, TYPE.boxSub, ALWAYS, "start") : "";
5396
+ return `<g data-ghost="${esc(box.id)}" style="${cs(box.color)}"><rect class="dg-ghost" x="${r1(box.x)}" y="${r1(box.y)}" width="${r1(box.w)}" height="${box.h}" rx="${radius}"/>${mark}${write(ink, "dg-sn", tx, box.cy + nameY, box.name, TYPE.boxName, ALWAYS, "start")}${sub}</g>`;
3859
5397
  }
3860
5398
  function doneMark(box, at2, ctx) {
3861
5399
  const { r, inset } = LOOK.state.done;
@@ -3863,19 +5401,22 @@ function doneMark(box, at2, ctx) {
3863
5401
  const y = box.y + inset;
3864
5402
  return `<g class="dg-popc dg-a" data-done="${esc(box.id)}" style="${cs(box.color)};${ctx.m.pop(at2)}"><circle class="dg-done" cx="${r1(x)}" cy="${r1(y)}" r="${r}"/>${glyph("check", x, y, 0.5, "dg-done-ck")}</g>`;
3865
5403
  }
3866
- function path(p, color) {
3867
- const label2 = p.label ? `<text class="dg-path-t${p.label.family === "sans" ? " dg-path-tj" : ""}" x="${r1(p.label.x + LOOK.label.padX)}" y="${r1(p.label.y + p.label.h / 2 + LOOK.baseline.label)}">${esc(p.label.text)}</text>` : "";
5404
+ function path(p, color, ink, traces) {
5405
+ traces.push({ from: p.from, to: p.to, points: p.points, shown: ALWAYS });
5406
+ const sans = p.label?.family === "sans";
5407
+ const label2 = p.label ? write(ink, `dg-path-t${sans ? " dg-path-tj" : ""}`, p.label.x + LOOK.label.padX, p.label.y + p.label.h / 2 + LOOK.baseline.label, p.label.text, sans ? TYPE.labelJa : TYPE.label) : "";
3868
5408
  return `<g data-path="${esc(`${p.from}->${p.to}`)}" style="${cs(color)}"><path class="dg-path" d="${pathOf(p.points)}"/><path class="dg-path-h" d="${arrowHead(p.points)}"/>${label2}</g>`;
3869
5409
  }
3870
- function side(s, color) {
5410
+ function side(s, color, ink) {
3871
5411
  const { pad: pad2 } = LOOK.state.side;
3872
5412
  const title = s.y + pad2 + TYPE.regionName.size;
3873
- const notes = s.notes.map((note, k) => `<text class="dg-side-n" x="${r1(s.x + pad2)}" y="${r1(title + LOOK.region.line * (k + 1))}">${esc(note)}</text>`).join("");
3874
- return `<g style="${cs(color)}"><rect class="dg-side" x="${r1(s.x + 0.5)}" y="${r1(s.y + 0.5)}" width="${r1(s.w - 1)}" height="${r1(s.h - 1)}" rx="${LOOK.region.radius}"/><text class="dg-side-t" x="${r1(s.x + pad2)}" y="${r1(title)}">${esc(s.title)}</text>${notes}</g>`;
5413
+ const notes = s.notes.map((note, k) => write(ink, "dg-side-n", s.x + pad2, title + LOOK.region.line * (k + 1), note, TYPE.regionNote)).join("");
5414
+ return `<g style="${cs(color)}"><rect class="dg-side" x="${r1(s.x + 0.5)}" y="${r1(s.y + 0.5)}" width="${r1(s.w - 1)}" height="${r1(s.h - 1)}" rx="${LOOK.region.radius}"/>${write(ink, "dg-side-t", s.x + pad2, title, s.title, TYPE.regionName)}${notes}</g>`;
3875
5415
  }
3876
- function endMark(e, color) {
5416
+ function endMark(e, color, ink) {
3877
5417
  const { end } = LOOK.state;
3878
- const text2 = e.text === "" ? "" : `<text class="dg-mark" x="${r1(e.x + LOOK.state.text)}" y="${r1(e.y + LOOK.baseline.mark)}">${esc(e.text)}</text>`;
5418
+ const at2 = markText(e);
5419
+ const text2 = e.text === "" ? "" : write(ink, "dg-mark", at2[0], at2[1], e.text, TYPE.regionNote);
3879
5420
  const x = r1(e.x);
3880
5421
  const y = r1(e.y);
3881
5422
  if (e.kind === "start") return `<g data-end="start"><circle class="dg-start" cx="${x}" cy="${y}" r="${e.r}"/>${text2}</g>`;
@@ -3887,6 +5428,7 @@ function lifeline(x, y1, y2) {
3887
5428
  }
3888
5429
  function edge(e, time, ctx, past = false) {
3889
5430
  const { m } = ctx;
5431
+ ctx.traces.push({ from: e.from, to: e.to, points: e.points, shown: ALWAYS });
3890
5432
  const d = pathOf(e.points);
3891
5433
  const head = arrowHead(e.points);
3892
5434
  const { start: a, drawn: b, end } = time;
@@ -3930,12 +5472,15 @@ function edge(e, time, ctx, past = false) {
3930
5472
  function label(l, time, ctx) {
3931
5473
  const ja2 = l.family === "sans" ? " dg-capj" : "";
3932
5474
  const { radius } = LOOK.label;
5475
+ ctx.ink.push({ text: l.text, rect: l, shown: [[time.start, time.end]], boxed: true });
5476
+ if (time.after) ctx.ink.push({ text: l.text, rect: textBox(l.text, l.x + l.w / 2, l.y + l.h / 2 + LOOK.baseline.label, l.family === "sans" ? TYPE.labelJa : TYPE.label, "middle"), shown: [[time.after.start, time.after.end]] });
3933
5477
  const x = r1(l.x + l.w / 2);
3934
5478
  const y = r1(l.y + l.h / 2 + LOOK.baseline.label);
3935
5479
  const past = time.after ? `<g class="dg-cap-past${l.family === "sans" ? " dg-cap-pastj" : ""} dg-a" style="${ctx.m.vis(time.after.start, time.after.end)}"><text x="${x}" y="${y}" text-anchor="middle">${esc(l.text)}</text></g>` : "";
3936
5480
  return `${past}<g class="dg-cap${ja2} dg-a" style="${cs(l.color)};${ctx.m.rise(time.start, time.end, true)}"><rect x="${r1(l.x)}" y="${r1(l.y)}" width="${r1(l.w)}" height="${l.h}" rx="${radius}"/><text x="${x}" y="${y}" text-anchor="middle">${esc(l.text)}</text></g>`;
3937
5481
  }
3938
5482
  function action(a, at2, until, ctx) {
5483
+ ctx.ink.push({ text: a.text, rect: a, shown: [[at2, until]], boxed: true });
3939
5484
  return `<g class="dg-act dg-a" style="${cs(a.color)};${ctx.m.rise(at2, until, true)}"><rect x="${r1(a.x)}" y="${r1(a.y)}" width="${r1(a.w)}" height="${a.h}" rx="${LOOK.action.radius}"/><text x="${r1(a.x + a.w / 2)}" y="${r1(a.y + a.h / 2 + LOOK.baseline.action)}" text-anchor="middle">${esc(a.text)}</text></g>`;
3940
5485
  }
3941
5486
  function carrierShape(e, sh) {
@@ -3953,11 +5498,12 @@ var easeInOut = (t) => t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2;
3953
5498
  function carrier(e, time, ctx) {
3954
5499
  const { m } = ctx;
3955
5500
  const n = LOOK.carrier.samples;
3956
- const length = pathLength(e.points);
5501
+ const route = e.wait ? [e.wait, ...e.points] : e.points;
5502
+ const length = pathLength(route);
3957
5503
  const { depart: a, arrive: b, start: from, end: gone } = time;
3958
5504
  const path2 = [];
3959
5505
  for (let k = 0; k <= n; k++) {
3960
- const [x, y] = along(e.points, easeInOut(k / n) * length);
5506
+ const [x, y] = along(route, easeInOut(k / n) * length);
3961
5507
  path2.push([a + (b - a) * k / n, x, y]);
3962
5508
  }
3963
5509
  const first = path2[0];
@@ -3966,6 +5512,12 @@ function carrier(e, time, ctx) {
3966
5512
  const pts = [[0, first[1], first[2]], ...path2];
3967
5513
  if (e.settle) pts.push([Math.min(b + 0.3, Math.max(gone, b + 0.01)), rest[0], rest[1]]);
3968
5514
  pts.push([gone, rest[0], rest[1]], [m.total, rest[0], rest[1]]);
5515
+ const [hx, hy] = carrierHalf(e.carry);
5516
+ const name = e.carry.kind === "tag" ? e.carry.text : e.carry.kind === "coin" ? "\u786C\u8CA8" : "\u5C01\u7B52";
5517
+ const part = e.carry.kind === "tag" ? {} : { part: { kind: e.carry.kind === "coin" ? "coin" : "envelope" } };
5518
+ const box = (p) => ({ x: p[0] - hx, y: p[1] - hy, w: hx * 2, h: hy * 2 });
5519
+ if (a > from) ctx.ink.push({ text: name, rect: box([first[1], first[2]]), shown: [[from, a]], boxed: true, ...part });
5520
+ ctx.ink.push({ text: name, rect: box(rest), shown: [[b, gone]], boxed: true, ...part });
3969
5521
  const fade = gone < m.last ? 0.05 : 0.18;
3970
5522
  return `<g class="dg-a" style="${m.move(pts, m.blink(from + 0.02, gone, fade))}">${carrierShape(e, ctx.sh)}</g>`;
3971
5523
  }
@@ -3975,15 +5527,30 @@ function badge(b, ctx, grey = false) {
3975
5527
  const a = span.start;
3976
5528
  const e = span.end;
3977
5529
  const { r, ring: rr } = LOOK.badge;
5530
+ const shown = { visibility: "visible" };
5531
+ const hidden = { visibility: "hidden" };
5532
+ const swap = b.until === void 0 ? void 0 : ctx.t.steps[b.until].start;
5533
+ const next = swap !== void 0 && swap <= e + 1e-6;
3978
5534
  const fill = m.kf([
3979
- [0, { opacity: 0, transform: "scale(.5)" }],
3980
- [a, { opacity: 0, transform: "scale(.5)" }, EASE.pop],
3981
- [a + 0.35, { opacity: 1, transform: "scale(1)" }],
3982
- [e, { opacity: 1, transform: "scale(1)" }, EASE.inOut],
3983
- [e + 0.4, { opacity: 0, transform: "scale(1)" }],
3984
- [m.total, { opacity: 0, transform: "scale(.5)" }]
5535
+ [0, { opacity: 0, transform: "scale(.5)", ...hidden }],
5536
+ [a, { opacity: 0, transform: "scale(.5)", ...hidden }, EASE.pop],
5537
+ [a + 0.35, { opacity: 1, transform: "scale(1)", ...shown }],
5538
+ [e, { opacity: 1, transform: "scale(1)", ...shown }, EASE.inOut],
5539
+ [e + (next ? MOTION.untilFade : 0.4), { opacity: 0, transform: "scale(1)", ...hidden }],
5540
+ [m.total, { opacity: 0, transform: "scale(.5)", ...hidden }]
5541
+ ]);
5542
+ const pastEnd = swap ?? m.last;
5543
+ const past = next ? m.kf([
5544
+ [0, { opacity: 0, ...hidden }],
5545
+ [m.total, { opacity: 0, ...hidden }]
5546
+ ]) : m.kf([
5547
+ [0, { opacity: 0, ...hidden }],
5548
+ [e, { opacity: 0, ...hidden }, EASE.inOut],
5549
+ [e + 0.4, { opacity: 1, ...shown }],
5550
+ [pastEnd, { opacity: 1, ...shown }, EASE.inOut],
5551
+ ...swap === void 0 ? [] : [[swap + MOTION.untilFade, { opacity: 0, ...hidden }]],
5552
+ [m.total, { opacity: 0, ...hidden }]
3985
5553
  ]);
3986
- const past = m.kf([[0, { opacity: 0 }], [e, { opacity: 0 }, EASE.inOut], [e + 0.4, { opacity: 1 }], [m.last, { opacity: 1 }, EASE.inOut], [m.total, { opacity: 0 }]]);
3987
5554
  const ring = m.kf([
3988
5555
  [0, { opacity: 0, transform: "scale(1)" }],
3989
5556
  [a + 0.05, { opacity: 0, transform: "scale(1)" }],
@@ -3995,6 +5562,7 @@ function badge(b, ctx, grey = false) {
3995
5562
  const y = r1(b.y);
3996
5563
  const ty = r1(b.y + LOOK.baseline.badge);
3997
5564
  const no = b.step + 1;
5565
+ ctx.ink.push({ text: String(no), rect: { x: b.x - r, y: b.y - r, w: r * 2, h: r * 2 }, shown: [[a, pastEnd]], boxed: true, badge: true });
3998
5566
  return `<g class="dg-bd" data-step="${b.step}" style="${cs(b.color)}"><circle class="dg-bdr dg-popc dg-a" cx="${x}" cy="${y}" r="${rr}" style="${ring}"/><g class="dg-a" style="${past}"><circle class="${grey ? "dg-bdp-g" : "dg-bdp"}" cx="${x}" cy="${y}" r="${rr}"/><text class="${grey ? "dg-bdpt-g" : "dg-bdpt"}" x="${x}" y="${ty}" text-anchor="middle">${no}</text></g><g class="dg-popc dg-a" style="${fill}"><circle class="dg-bdf" cx="${x}" cy="${y}" r="${r}"/><text class="dg-bdft" x="${x}" y="${ty}" text-anchor="middle">${no}</text></g></g>`;
3999
5567
  }
4000
5568
  function strip(s, changes, ctx, now = false, arrivals = /* @__PURE__ */ new Map()) {
@@ -4004,7 +5572,7 @@ function strip(s, changes, ctx, now = false, arrivals = /* @__PURE__ */ new Map(
4004
5572
  const parts = [
4005
5573
  `<rect class="dg-strip" x="${r1(s.x + 0.5)}" y="${r1(s.y + 0.5)}" width="${r1(s.w - 1)}" height="${r1(s.h - 1)}" rx="${LOOK.region.radius}" ${sh}/>`,
4006
5574
  `<g style="${cs("slate")}"><rect class="dg-bi" x="${r1(s.x + S2.pad)}" y="${r1(my - S2.icon / 2)}" width="${S2.icon}" height="${S2.icon}" rx="${LOOK.box.iconRadius}"/>${glyph("env", s.x + S2.pad + S2.icon / 2, my, 0.78)}</g>`,
4007
- `<text class="dg-sh" x="${r1(s.x + S2.titleX)}" y="${r1(my + LOOK.baseline.stripTitle)}">${esc(s.title)}</text>`
5575
+ write(ctx.ink, "dg-sh", s.x + S2.titleX, my + LOOK.baseline.stripTitle, s.title, TYPE.stripTitle)
4008
5576
  ];
4009
5577
  s.fields.forEach((field, i) => {
4010
5578
  const prev = s.fields[i - 1];
@@ -4012,7 +5580,7 @@ function strip(s, changes, ctx, now = false, arrivals = /* @__PURE__ */ new Map(
4012
5580
  const sx = field.x - S2.fieldGap / 2;
4013
5581
  parts.push(`<line class="dg-sep" x1="${r1(sx)}" y1="${r1(field.y + S2.sepInset)}" x2="${r1(sx)}" y2="${r1(field.y + S2.h - S2.sepInset)}"/>`);
4014
5582
  }
4015
- parts.push(`<text class="dg-fl" x="${r1(field.x)}" y="${r1(field.y + S2.nameY)}">${esc(field.name)}</text>`);
5583
+ parts.push(write(ctx.ink, "dg-fl", field.x, field.y + S2.nameY, field.name, TYPE.fieldName));
4016
5584
  const list = changes.get(field.name) ?? [];
4017
5585
  const values = list.filter((c) => c.value !== void 0);
4018
5586
  const tags = list.filter((c) => c.tag !== void 0);
@@ -4020,6 +5588,7 @@ function strip(s, changes, ctx, now = false, arrivals = /* @__PURE__ */ new Map(
4020
5588
  const next = values[k + 1]?.at;
4021
5589
  const value = c.value;
4022
5590
  const cls = hasWide(value) ? "dg-fvj" : "dg-fv";
5591
+ ctx.ink.push({ text: value, rect: textBox(value, field.x, field.y + S2.valueY, hasWide(value) ? TYPE.fieldValueJa : TYPE.fieldValue), shown: [[c.at, next === void 0 ? Number.POSITIVE_INFINITY : next - MOTION.untilFade]] });
4023
5592
  const textOf = (c2) => `<text class="${c2}" x="${r1(field.x)}" y="${r1(field.y + S2.valueY)}">${esc(value)}</text>`;
4024
5593
  const text2 = textOf(cls);
4025
5594
  if (!now) {
@@ -4039,6 +5608,7 @@ function strip(s, changes, ctx, now = false, arrivals = /* @__PURE__ */ new Map(
4039
5608
  const x = field.x + (shown ? textWidth(shown, hasWide(shown) ? TYPE.fieldValueJa : TYPE.fieldValue) + S2.tagGap : 0);
4040
5609
  const w = textWidth(tag, TYPE.tag) + S2.tagPadX * 2;
4041
5610
  const y = field.y + S2.valueY - S2.tagH / 2 - LOOK.baseline.tag;
5611
+ ctx.ink.push({ text: tag, rect: { x, y, w, h: S2.tagH }, shown: [[c.at, next === void 0 ? Number.POSITIVE_INFINITY : next - MOTION.untilFade]], boxed: true });
4042
5612
  parts.push(
4043
5613
  `<g class="dg-tg dg-popc dg-a" style="${cs(c.color)};${next === void 0 ? m.pop(c.at) : m.pop(c.at, next - MOTION.untilFade)}"><rect x="${r1(x)}" y="${r1(y)}" width="${r1(w)}" height="${S2.tagH}" rx="${S2.tagH / 2}"/><text x="${r1(x + w / 2)}" y="${r1(y + S2.tagH / 2 + LOOK.baseline.tag)}" text-anchor="middle">${esc(tag)}</text></g>`
4044
5614
  );
@@ -4051,7 +5621,7 @@ function strip(s, changes, ctx, now = false, arrivals = /* @__PURE__ */ new Map(
4051
5621
  const sx = t.x - S2.fieldGap / 2;
4052
5622
  parts.push(`<line class="dg-sep" x1="${r1(sx)}" y1="${r1(t.y + S2.sepInset)}" x2="${r1(sx)}" y2="${r1(t.y + S2.h - S2.sepInset)}"/>`);
4053
5623
  }
4054
- parts.push(`<text class="dg-fl" x="${r1(t.x)}" y="${r1(t.y + S2.nameY)}">${esc(t.title)}</text>`);
5624
+ parts.push(write(ctx.ink, "dg-fl", t.x, t.y + S2.nameY, t.title, TYPE.fieldName));
4055
5625
  const dy = t.y + S2.valueY - TYPE.fieldValue.size / 3;
4056
5626
  t.states.forEach((state, k) => {
4057
5627
  const cx = r1(t.x + S2.trail.r + k * S2.trail.step);
@@ -4063,6 +5633,123 @@ function strip(s, changes, ctx, now = false, arrivals = /* @__PURE__ */ new Map(
4063
5633
  return parts.join("");
4064
5634
  }
4065
5635
 
5636
+ // src/render/git.ts
5637
+ var r12 = (v) => Math.round(v * 100) / 100;
5638
+ var center = (r) => [r.x + r.w / 2, r.y + r.h / 2];
5639
+ function tagShape(text2, sh) {
5640
+ const C = LOOK.carrier;
5641
+ const ja2 = hasWide(text2);
5642
+ const w = textWidth(text2, ja2 ? TYPE.carrierJa : TYPE.carrier) + C.tagPadX * 2;
5643
+ return `<rect class="dg-car" x="${r12(-w / 2)}" y="${ -18 / 2}" width="${r12(w)}" height="${C.tagH}" rx="${C.tagH / 2}" ${sh}/><text class="dg-car-t${ja2 ? " dg-car-tj" : ""}" y="${LOOK.baseline.carrier}" text-anchor="middle">${esc(text2)}</text>`;
5644
+ }
5645
+ function drawGit(layout, diagram, timeline, ctx) {
5646
+ const { m } = ctx;
5647
+ const G = LOOK.git;
5648
+ const timeOf = (step, event) => timeline.edges.find((t) => t.step === step && t.event === event);
5649
+ const links = layout.links.map((l) => {
5650
+ const time = timeOf(l.step, l.event);
5651
+ if (!time) return "";
5652
+ ctx.traces.push({ from: l.from, to: l.to, points: l.points, shown: [[time.start, Number.POSITIVE_INFINITY]] });
5653
+ const d = pathOf(l.points);
5654
+ if (l.kind === "copy") return `<g style="${cs(l.color)}"><path class="dg-git-cp dg-a" d="${d}" style="${m.vis(time.start, m.last)}"/></g>`;
5655
+ const kf = m.kf([
5656
+ [0, { opacity: 0, "stroke-dashoffset": 1 }],
5657
+ [time.start, { opacity: 0, "stroke-dashoffset": 1 }, EASE.inOut],
5658
+ [time.start + 0.05, { opacity: 1 }],
5659
+ [time.drawn, { "stroke-dashoffset": 0 }],
5660
+ [m.last, { opacity: 1, "stroke-dashoffset": 0 }, EASE.inOut],
5661
+ [m.total, { opacity: 0, "stroke-dashoffset": 0 }]
5662
+ ]);
5663
+ return `<g style="${cs(l.color)}"><path class="dg-git-l dg-a" pathLength="1" d="${d}" style="${kf}"/></g>`;
5664
+ }).join("");
5665
+ const commits = layout.commits.map((c) => {
5666
+ const at2 = timeOf(c.step, c.event)?.drawn ?? 0;
5667
+ const ring = { x: c.cx - c.r, y: c.cy - c.r, w: c.r * 2, h: c.r * 2 };
5668
+ ctx.ink.push({ text: c.id, rect: ring, shown: [[at2, Number.POSITIVE_INFINITY]], boxed: true });
5669
+ const lines2 = (c.text?.lines ?? []).map((line, k) => {
5670
+ const hash = k === 0 && c.hash !== void 0;
5671
+ const baseline = c.text?.baselines[k] ?? c.cy;
5672
+ return write(ctx.ink, hash ? "dg-git-h" : "dg-git-n", c.cx, baseline, line, hash ? TYPE.gitHash : TYPE.gitNote, [[at2, Number.POSITIVE_INFINITY]], "middle");
5673
+ }).join("");
5674
+ const id = `<text class="dg-git-id" x="${r12(c.cx)}" y="${r12(c.cy + LOOK.baseline.badge)}" text-anchor="middle">${esc(c.id)}</text>`;
5675
+ const node = `<g class="dg-popc dg-a" style="${m.pop(at2)}"><circle class="dg-git-c" cx="${r12(c.cx)}" cy="${r12(c.cy)}" r="${c.r}" ${ctx.sh}/>${id}</g>`;
5676
+ const text2 = lines2 === "" ? "" : `<g class="dg-a" style="${m.vis(at2)}">${lines2}</g>`;
5677
+ const orphanAt = c.orphan === void 0 ? void 0 : timeOf(c.orphan, c.orphanEvent ?? 0)?.drawn;
5678
+ const orphan = orphanAt === void 0 ? "" : `<g class="dg-a" data-orphan="${esc(c.id)}" style="${m.vis(orphanAt, m.last, { f: 0.5 })}"><circle class="dg-git-old" cx="${r12(c.cx)}" cy="${r12(c.cy)}" r="${G.orphan}"/><text class="dg-git-oldl" x="${r12(c.cx)}" y="${r12(c.cy + LOOK.baseline.badge)}" text-anchor="middle">${esc(c.id)}</text></g>`;
5679
+ return `<g data-commit="${esc(c.id)}" style="${cs(c.color)}">${node}${text2}${orphan}</g>`;
5680
+ }).join("");
5681
+ const lines = layout.moves.flatMap((mv) => {
5682
+ const time = timeOf(mv.step, mv.event);
5683
+ if (!mv.line || !time) return [];
5684
+ const end = timeline.steps[mv.step].end;
5685
+ ctx.traces.push({ from: mv.ref, to: mv.target ?? mv.ref, points: mv.line, shown: [[time.start, end + 0.4]] });
5686
+ const kf = m.kf([
5687
+ [0, { opacity: 0, "stroke-dashoffset": 1 }],
5688
+ [time.start, { opacity: 0, "stroke-dashoffset": 1 }, EASE.inOut],
5689
+ [time.start + 0.05, { opacity: 1 }],
5690
+ [time.drawn, { "stroke-dashoffset": 0 }],
5691
+ [end, { opacity: 1 }, EASE.inOut],
5692
+ [end + 0.4, { opacity: 0 }],
5693
+ [m.total, { opacity: 0, "stroke-dashoffset": 0 }]
5694
+ ]);
5695
+ return [`<g style="${cs(mv.color)}"><path class="dg-e-on dg-a" pathLength="1" d="${pathOf(mv.line)}" style="${kf}"/></g>`];
5696
+ }).join("");
5697
+ const carried = timeline.carriers.flatMap((t) => {
5698
+ const mv = layout.moves.find((x) => x.step === t.step && x.event === t.event && x.line);
5699
+ const source = diagram.steps[t.step]?.events[t.event];
5700
+ if (!mv?.line || source?.type !== "edge") return [];
5701
+ const edge2 = { step: t.step, event: t.event, from: mv.ref, to: mv.target ?? mv.ref, points: mv.line, color: mv.color, carry: source.carry };
5702
+ return [carrier(edge2, { ...t, start: t.depart, end: t.arrive + MOTION.fade }, ctx)];
5703
+ }).join("");
5704
+ const refs = [...new Set(layout.moves.map((mv) => mv.ref))];
5705
+ const tags = refs.map((ref) => tagMotion(ref, layout.moves.filter((mv) => mv.ref === ref), timeOf, ctx)).join("") + carried;
5706
+ return { links, lines, commits, tags };
5707
+ }
5708
+ function tagMotion(ref, list, timeOf, ctx) {
5709
+ const { m } = ctx;
5710
+ const points = [];
5711
+ const fades = [[0, { opacity: 0 }]];
5712
+ let on = false;
5713
+ let rest;
5714
+ const leave = (t) => {
5715
+ if (rest) ctx.ink.push({ text: ref, rect: rest.rect, shown: [[rest.since, t]], boxed: true });
5716
+ rest = void 0;
5717
+ };
5718
+ for (const mv of list) {
5719
+ const time = timeOf(mv.step, mv.event);
5720
+ if (!time) continue;
5721
+ const { start: a, drawn: b } = time;
5722
+ const from = mv.from ? center(mv.from) : void 0;
5723
+ const to = mv.to ? center(mv.to) : void 0;
5724
+ leave(a);
5725
+ if (mv.carried && from && to && on) {
5726
+ points.push([a + MOTION.fade, from[0], from[1]], [b - MOTION.fade, to[0], to[1]]);
5727
+ fades.push([a, { opacity: 1 }, EASE.inOut], [a + MOTION.fade, { opacity: 0 }], [b - MOTION.fade, { opacity: 0 }, EASE.out], [b, { opacity: 1 }]);
5728
+ rest = { rect: mv.to, since: b };
5729
+ continue;
5730
+ }
5731
+ if (from) points.push([a, from[0], from[1]]);
5732
+ if (to) points.push([b, to[0], to[1]]);
5733
+ if (to && !on) {
5734
+ const show = from ? a : b - MOTION.fade;
5735
+ fades.push([show, { opacity: 0 }, EASE.out], [show + MOTION.fade, { opacity: 1 }]);
5736
+ on = true;
5737
+ } else if (!to && on) {
5738
+ fades.push([b, { opacity: 1 }, EASE.inOut], [b + MOTION.untilFade, { opacity: 0 }]);
5739
+ on = false;
5740
+ }
5741
+ if (mv.to) rest = { rect: mv.to, since: b };
5742
+ }
5743
+ leave(Number.POSITIVE_INFINITY);
5744
+ if (points.length === 0) return "";
5745
+ const first = points[0];
5746
+ const last = points[points.length - 1];
5747
+ if (on) fades.push([m.last, { opacity: 1 }, EASE.inOut], [m.total, { opacity: 0 }]);
5748
+ else fades.push([m.total, { opacity: 0 }]);
5749
+ const style = m.move([[0, first[1], first[2]], ...points, [m.total, last[1], last[2]]], fades);
5750
+ return `<g class="dg-a" data-ref="${esc(ref)}" style="${style}">${tagShape(ref, ctx.sh)}</g>`;
5751
+ }
5752
+
4066
5753
  // src/render/motion.ts
4067
5754
  var r2 = (v) => Math.round(v * 100) / 100;
4068
5755
  var Motion = class {
@@ -4170,6 +5857,7 @@ var PART_CSS = [
4170
5857
  `.dg-halo{fill:none;stroke:var(--c);stroke-width:${S.halo};stroke-opacity:.16}`,
4171
5858
  `.dg-on{fill:none;stroke:var(--c);stroke-width:${S.on}}`,
4172
5859
  `.dg-ic{fill:${mix(X.icon)}}`,
5860
+ `.dg-slot{fill:none;stroke:${mix(X.slot, "transparent")};stroke-width:${S.slot};stroke-dasharray:3 3}`,
4173
5861
  `.dg-gl{fill:none;stroke:var(--c);stroke-width:${S.glyph};stroke-linecap:round;stroke-linejoin:round}`,
4174
5862
  `.dg-sn{${font(TYPE.boxName)};fill:var(--ink)}`,
4175
5863
  `.dg-ss{${font(TYPE.boxSub)};fill:var(--mute)}`,
@@ -4186,7 +5874,7 @@ var PART_CSS = [
4186
5874
  ".dg-bd{cursor:pointer}",
4187
5875
  ".dg-bdf{fill:var(--c)}",
4188
5876
  `.dg-bdft{${font(TYPE.badge)};fill:var(--on-c)}`,
4189
- `.dg-bdr{fill:none;stroke:var(--c);stroke-width:${S.badgeRing}}`,
5877
+ `.dg-bdr{fill:none;stroke:var(--c);stroke-width:${S.badgeRing};pointer-events:none}`,
4190
5878
  `.dg-bdp{fill:${mix(X.badgePast)};stroke:${mix(X.badgePastEdge, "transparent")};stroke-width:${S.hair}}`,
4191
5879
  `.dg-bdpt{${font(TYPE.badge)};fill:var(--ct)}`,
4192
5880
  `.dg-bdp-g{fill:var(--surf);stroke:${PAST};stroke-width:${S.hair}}`,
@@ -4232,6 +5920,14 @@ var PART_CSS = [
4232
5920
  `.dg-mark{${font(TYPE.regionNote)};fill:var(--mute)}`,
4233
5921
  `.dg-done{fill:var(--ink);stroke:var(--surf);stroke-width:${S.done}}`,
4234
5922
  `.dg-done-ck{fill:none;stroke:var(--surf);stroke-width:${S.glyph};stroke-linecap:round;stroke-linejoin:round}`,
5923
+ `.dg-git-l{fill:none;stroke:var(--c);stroke-width:${S.git};stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:1 2}`,
5924
+ `.dg-git-cp{fill:none;stroke:var(--c);stroke-width:${S.gitOrphan};stroke-linecap:round;stroke-dasharray:3 3;stroke-opacity:.7}`,
5925
+ `.dg-git-c{fill:var(--surf);stroke:var(--c);stroke-width:${S.git}}`,
5926
+ `.dg-git-id{${font(TYPE.gitId)};fill:var(--ct)}`,
5927
+ `.dg-git-h{${font(TYPE.gitHash)};fill:var(--mute)}`,
5928
+ `.dg-git-n{${font(TYPE.gitNote)};fill:var(--ink2)}`,
5929
+ `.dg-git-old{fill:var(--surf);stroke:var(--c);stroke-width:${S.gitOrphan};stroke-dasharray:3 3;stroke-opacity:.6}`,
5930
+ `.dg-git-oldl{${font(TYPE.gitId)};fill:var(--ct);opacity:.55}`,
4235
5931
  ".dg-vp-bg{fill:var(--bg)}",
4236
5932
  ".dg-vp-frame{fill:none;stroke:var(--hair)}",
4237
5933
  ".dg-hd-bg{fill:var(--bg)}",
@@ -4315,23 +6011,36 @@ function fieldChanges(diagram, timeline, layout) {
4315
6011
  }
4316
6012
  return out;
4317
6013
  }
4318
- function drawSvg(diagram, layout, timeline, palette, theme, follow) {
6014
+ function fadeBefore(l, time, steps) {
6015
+ if (l.until === void 0 || !time.after) return time;
6016
+ const cut = steps[l.until].start;
6017
+ const { after, ...rest } = time;
6018
+ return cut > after.start ? { ...rest, after: { start: after.start, end: Math.min(after.end, cut) } } : rest;
6019
+ }
6020
+ function drawSvg(diagram, layout, timeline, palette, theme, follow, ink = [], traces = []) {
4319
6021
  const id = nameOf(`${JSON.stringify(diagram)}|${palette.id}|${theme}|${follow ? `${follow.width}|${follow.lang}` : ""}`);
4320
6022
  const m = new Motion(`dg${id}`, timeline.total, timeline.last);
4321
- const ctx = { m, t: timeline, sh: `filter="url(#dg-sh-${id})"`, end: timeline.steps[timeline.steps.length - 1].end };
6023
+ const ctx = { m, t: timeline, sh: `filter="url(#dg-sh-${id})"`, end: timeline.steps[timeline.steps.length - 1].end, ink, traces };
4322
6024
  const on = involved(diagram);
4323
6025
  const subs = subChanges(diagram, timeline, layout.kind !== "sequence");
4324
6026
  const L = { band: [], base: [], lit: [], node: [], badge: [], top: [] };
4325
- for (const region of layout.regions) L.band.push(band(region));
6027
+ for (const region of layout.regions) L.band.push(band(region, ink));
4326
6028
  const ghostColor = layout.boxes.find((b) => b.ghost)?.color ?? "slate";
4327
- if (layout.side) L.band.push(side(layout.side, ghostColor));
6029
+ if (layout.side) L.band.push(side(layout.side, ghostColor, ink));
4328
6030
  const boxColor = (id2, ghost) => layout.boxes.find((b) => b.id === id2 && (ghost === void 0 || b.ghost === ghost))?.color;
4329
- for (const p of layout.paths) L.base.push(path(p, boxColor(p.to, true) ?? boxColor(p.from) ?? ghostColor));
4330
- for (const e of layout.ends) L.node.push(endMark(e, ghostColor));
6031
+ for (const p of layout.paths) L.base.push(path(p, boxColor(p.to, true) ?? boxColor(p.from) ?? ghostColor, ink, traces));
6032
+ for (const e of layout.ends) L.node.push(endMark(e, ghostColor, ink));
4331
6033
  const isState = layout.kind === "state";
4332
6034
  const arrivals = new Map((timeline.states ?? []).flatMap((s) => s.lit[0] ? [[s.box, s.lit[0].start]] : []));
4333
6035
  if (layout.strip) L.band.push(strip(layout.strip, fieldChanges(diagram, timeline, layout), ctx, isState, arrivals));
4334
6036
  for (const line of layout.lifelines) L.base.push(lifeline(line.x, line.y1, line.y2));
6037
+ if (isGitLayout(layout)) {
6038
+ const git = drawGit(layout, diagram, timeline, ctx);
6039
+ L.base.push(git.links);
6040
+ L.lit.push(git.lines);
6041
+ L.node.push(git.commits);
6042
+ L.top.push(git.tags);
6043
+ }
4335
6044
  for (const e of layout.edges) {
4336
6045
  const time = timeline.edges.find((t) => t.step === e.step && t.event === e.event);
4337
6046
  if (!time) continue;
@@ -4342,7 +6051,7 @@ function drawSvg(diagram, layout, timeline, palette, theme, follow) {
4342
6051
  const states = new Map((timeline.states ?? []).map((s) => [s.box, s]));
4343
6052
  for (const box of layout.boxes) {
4344
6053
  if (box.ghost) {
4345
- L.node.push(ghostCard(box));
6054
+ L.node.push(ghostCard(box, ink));
4346
6055
  continue;
4347
6056
  }
4348
6057
  const state = states.get(box.id);
@@ -4352,7 +6061,7 @@ function drawSvg(diagram, layout, timeline, palette, theme, follow) {
4352
6061
  for (const b of layout.badges) L.badge.push(badge(b, ctx, isState));
4353
6062
  for (const l of layout.labels) {
4354
6063
  const time = timeline.labels.find((t) => t.step === l.step && t.event === l.event);
4355
- if (time) L.top.push(label(l, time, ctx));
6064
+ if (time) L.top.push(label(l, fadeBefore(l, time, timeline.steps), ctx));
4356
6065
  }
4357
6066
  for (const a of layout.actions) {
4358
6067
  const time = timeline.events.find((t) => t.step === a.step && t.event === a.event);
@@ -4370,14 +6079,14 @@ function drawSvg(diagram, layout, timeline, palette, theme, follow) {
4370
6079
  const css = `.dg-${id}{${FONT_VARS};--T:${timeline.total}s;${paletteVars(palette, theme)}}${PART_CSS}${m.frames.join("")}`;
4371
6080
  return `<svg xmlns="http://www.w3.org/2000/svg" class="dg dg-${id}" viewBox="0 0 ${Math.ceil(view.w)} ${Math.ceil(view.h)}" width="${Math.ceil(view.w)}" height="${Math.ceil(view.h)}" role="img" aria-label="${esc(diagram.title)}" data-dragon="figure" data-view="${follow ? "follow" : "fixed"}"><style>${css}</style><defs>${shadow}</defs>${view.body}</svg>`;
4372
6081
  }
4373
- function union(rects) {
6082
+ function union2(rects) {
4374
6083
  const x = Math.min(...rects.map((r) => r.x));
4375
6084
  const y = Math.min(...rects.map((r) => r.y));
4376
6085
  return { x, y, w: Math.max(...rects.map((r) => r.x + r.w)) - x, h: Math.max(...rects.map((r) => r.y + r.h)) - y };
4377
6086
  }
4378
6087
  function focusOf(layout, diagram, step) {
4379
6088
  const rects = focusParts(layout, diagram, step);
4380
- return rects.length === 0 ? void 0 : union(rects);
6089
+ return rects.length === 0 ? void 0 : union2(rects);
4381
6090
  }
4382
6091
  function badgeFocus(badge2, parts, vw, vh) {
4383
6092
  const room = LOOK.badge.r + LOOK.follow.badgeRoom;
@@ -4385,7 +6094,7 @@ function badgeFocus(badge2, parts, vw, vh) {
4385
6094
  const away = (p) => Math.hypot(Math.max(0, p.x - bx, bx - p.x - p.w), Math.max(0, p.y - by, by - p.y - p.h));
4386
6095
  let held = { x: bx - room, y: by - room, w: room * 2, h: room * 2 };
4387
6096
  for (const p of [...parts].sort((a, b) => away(a) - away(b))) {
4388
- const next = union([held, p]);
6097
+ const next = union2([held, p]);
4389
6098
  if (next.w <= vw && next.h <= vh) held = next;
4390
6099
  }
4391
6100
  return held;
@@ -4483,19 +6192,25 @@ function renderDiagram(input, options = {}) {
4483
6192
  const read = readDiagram(input, { lang });
4484
6193
  if (!read.ok) throw new Error(FIGURE_TEXT[lang].cannotDraw(read.errors.map((e) => `${e.pointer} ${e.message}`).join(" / ")));
4485
6194
  const diagram = read.diagram;
6195
+ const layout = diagram.kind === "sequence" ? layoutSequence(diagram) : diagram.kind === "state" ? layoutState(diagram, lang) : diagram.kind === "git" ? layoutGit(diagram) : layoutArchitecture(diagram);
6196
+ return renderLayout(diagram, layout, buildTimeline(diagram), options);
6197
+ }
6198
+ function renderLayout(diagram, layout, timeline, options = {}) {
4486
6199
  const palette = resolvePalette(options.palette);
4487
6200
  const theme = options.theme === "dark" ? "dark" : "light";
4488
- const layout = diagram.kind === "sequence" ? layoutSequence(diagram) : diagram.kind === "state" ? layoutState(diagram, lang) : layoutArchitecture(diagram);
4489
- const timeline = buildTimeline(diagram);
6201
+ const ink = [];
6202
+ const traces = [];
6203
+ const svg = drawSvg(diagram, layout, timeline, palette, theme, void 0, ink, traces);
4490
6204
  return {
4491
- svg: drawSvg(diagram, layout, timeline, palette, theme),
6205
+ svg,
4492
6206
  palette: palette.id,
4493
6207
  theme,
4494
6208
  ...diagram.view ? { view: diagram.view } : {},
4495
6209
  fonts: { ...FONTS },
4496
6210
  layout,
4497
6211
  timeline,
4498
- diagram
6212
+ diagram,
6213
+ overlaps: findOverlaps(ink, timeline.stills, traces)
4499
6214
  };
4500
6215
  }
4501
6216
 
@@ -4514,7 +6229,7 @@ var pad = (n) => String(n).padStart(2, "0");
4514
6229
  var stepNo = (step, count) => `${pad(step + 1)}/${pad(count)}`;
4515
6230
  var require_ = createRequire(import.meta.url);
4516
6231
  var SCRIPTS = {
4517
- "/mediabunny.js": join(dirname(require_.resolve("mediabunny")), "mediabunny.min.mjs"),
6232
+ "/mediabunny.js": join$1(dirname(require_.resolve("mediabunny")), "mediabunny.min.mjs"),
4518
6233
  "/gifenc.js": require_.resolve("gifenc/dist/gifenc.esm.js")
4519
6234
  };
4520
6235
  var SCALE = 2;
@@ -4736,7 +6451,7 @@ async function fontFaces(chars) {
4736
6451
  const faces = await Promise.all(
4737
6452
  PACKAGES.flatMap(({ family, name }) => {
4738
6453
  const base = dirname(require_2.resolve(`@fontsource-variable/${name}/unicode.json`));
4739
- const table = JSON.parse(readFileSync(join(base, "unicode.json"), "utf8"));
6454
+ const table = JSON.parse(readFileSync(join$1(base, "unicode.json"), "utf8"));
4740
6455
  return Object.entries(table).map(async ([key, list]) => {
4741
6456
  const span = ranges(list);
4742
6457
  const own = chars.filter((char) => {
@@ -4744,7 +6459,7 @@ async function fontFaces(chars) {
4744
6459
  return span.some(([from, to]) => code >= from && code <= to);
4745
6460
  });
4746
6461
  if (!own.length) return "";
4747
- const file = join(base, "files", `${name}-${key.replace(/[[\]]/g, "")}-wght-normal.woff2`);
6462
+ const file = join$1(base, "files", `${name}-${key.replace(/[[\]]/g, "")}-wght-normal.woff2`);
4748
6463
  const woff2 = await subsetFont(await readFile(file), own.join(""), { targetFormat: "woff2", variationAxes: { wght: WEIGHT } });
4749
6464
  const unicode = own.map((char) => hex(char.codePointAt(0) ?? 0)).join(",");
4750
6465
  return `@font-face{font-family:"${family}";font-style:normal;font-display:block;font-weight:${WEIGHT.min} ${WEIGHT.max};src:url(data:font/woff2;base64,${woff2.toString("base64")}) format("woff2");unicode-range:${unicode}}`;
@@ -4829,14 +6544,14 @@ async function exportDiagram(input, options) {
4829
6544
  }
4830
6545
  }
4831
6546
  const files = writeOutputs(options.outDir, options.name ?? "diagram", outputs);
4832
- return { files, view, frames, ...sizeOf(videoSvg) };
6547
+ return { files, view, frames, ...sizeOf(videoSvg), overlaps: rendered.overlaps };
4833
6548
  }
4834
6549
  function writeOutputs(outDir, name, outputs) {
4835
6550
  const created = mkdirSync(outDir, { recursive: true });
4836
6551
  const files = {};
4837
6552
  try {
4838
6553
  for (const [format, data] of outputs) {
4839
- const path2 = join(outDir, `${name}.${format}`);
6554
+ const path2 = join$1(outDir, `${name}.${format}`);
4840
6555
  writeFileSync(path2, data);
4841
6556
  files[format] = path2;
4842
6557
  }