@cardenelabs/cdl 0.30.2 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.js CHANGED
@@ -8826,11 +8826,66 @@ function \u672B\u5C3E\u3092\u8FBA\u306B\u6CBF\u3063\u3066\u305A\u3089\u3059(e, \
8826
8826
  parts.push(`L ${s.x2} ${s.y2}`);
8827
8827
  }
8828
8828
  const \u6298\u308C1\u306F\u76F4\u524D\u306E\u6298\u308C = Math.abs(\u6298\u308C1.x - last.x1) <= 0.5 && Math.abs(\u6298\u308C1.y - last.y1) <= 0.5;
8829
+ if (\u6298\u308C1\u306F\u76F4\u524D\u306E\u6298\u308C) {
8830
+ const \u6298\u308A\u8FD4\u3055\u306A\u3044 = \u76F4\u524D\u306E\u6298\u308C\u3054\u3068\u305A\u3089\u3059(segs, \u6A2A, d, nodes, e);
8831
+ if (\u6298\u308A\u8FD4\u3055\u306A\u3044) return \u6298\u308A\u8FD4\u3055\u306A\u3044;
8832
+ }
8829
8833
  if (!\u6298\u308C1\u306F\u76F4\u524D\u306E\u6298\u308C) parts.push(`L ${round1(\u6298\u308C1.x)} ${round1(\u6298\u308C1.y)}`);
8830
8834
  parts.push(`L ${round1(\u6298\u308C2.x)} ${round1(\u6298\u308C2.y)}`);
8831
8835
  parts.push(`L ${round1(\u7D42\u70B9.x)} ${round1(\u7D42\u70B9.y)}`);
8832
8836
  return parts.join(" ");
8833
8837
  }
8838
+ function \u76F4\u524D\u306E\u6298\u308C\u3054\u3068\u305A\u3089\u3059(segs, \u6A2A, d, nodes, e) {
8839
+ const \u5E73\u884C\u304B = (s) => \u6A2A ? Math.abs(s.x2 - s.x1) < 0.5 && Math.abs(s.y2 - s.y1) > 0.5 : Math.abs(s.y2 - s.y1) < 0.5 && Math.abs(s.x2 - s.x1) > 0.5;
8840
+ let \u5438\u53CE = -1;
8841
+ for (let i = segs.length - 2; i >= 0; i -= 1) {
8842
+ if (\u5E73\u884C\u304B(segs[i])) {
8843
+ \u5438\u53CE = i;
8844
+ break;
8845
+ }
8846
+ }
8847
+ if (\u5438\u53CE < 0) return null;
8848
+ const \u5143\u306E\u9577\u3055 = \u6A2A ? Math.abs(segs[\u5438\u53CE].y2 - segs[\u5438\u53CE].y1) : Math.abs(segs[\u5438\u53CE].x2 - segs[\u5438\u53CE].x1);
8849
+ const \u5411\u304D = \u6A2A ? Math.sign(segs[\u5438\u53CE].y2 - segs[\u5438\u53CE].y1) : Math.sign(segs[\u5438\u53CE].x2 - segs[\u5438\u53CE].x1);
8850
+ const \u5F8C\u306E\u9577\u3055 = \u5143\u306E\u9577\u3055 + \u5411\u304D * d;
8851
+ if (\u5F8C\u306E\u9577\u3055 < ENDPOINT_FAN_RUNUP) return null;
8852
+ const \u305A\u3089\u3059 = (p) => \u6A2A ? { ...p, y: p.y + d } : { ...p, x: p.x + d };
8853
+ const \u65B0segs = segs.map((s, i) => {
8854
+ if (i <= \u5438\u53CE) return s;
8855
+ return {
8856
+ ...s,
8857
+ x1: \u305A\u3089\u3059({ x: s.x1, y: s.y1 }).x,
8858
+ y1: \u305A\u3089\u3059({ x: s.x1, y: s.y1 }).y,
8859
+ x2: \u305A\u3089\u3059({ x: s.x2, y: s.y2 }).x,
8860
+ y2: \u305A\u3089\u3059({ x: s.x2, y: s.y2 }).y,
8861
+ ...s.ctrl ? { ctrl: s.ctrl.map((c) => \u305A\u3089\u3059(c)) } : {}
8862
+ };
8863
+ });
8864
+ \u65B0segs[\u5438\u53CE] = {
8865
+ ...segs[\u5438\u53CE],
8866
+ x2: \u6A2A ? segs[\u5438\u53CE].x2 : segs[\u5438\u53CE].x2 + d,
8867
+ y2: \u6A2A ? segs[\u5438\u53CE].y2 + d : segs[\u5438\u53CE].y2
8868
+ };
8869
+ if (nodes.some(
8870
+ (n) => n.id !== e.from && n.id !== e.to && segmentsCrossRect(
8871
+ \u65B0segs.slice(\u5438\u53CE).map((s) => ({ x1: s.x1, y1: s.y1, x2: s.x2, y2: s.y2 })),
8872
+ nodeRect(n)
8873
+ )
8874
+ )) {
8875
+ return null;
8876
+ }
8877
+ const head = \u65B0segs[0];
8878
+ const parts = [`M ${round1(head.x1)} ${round1(head.y1)}`];
8879
+ for (const s of \u65B0segs) {
8880
+ if (s.cmd === "Q") {
8881
+ const c = s.ctrl?.[0];
8882
+ parts.push(c ? `Q ${round1(c.x)} ${round1(c.y)}, ${round1(s.x2)} ${round1(s.y2)}` : `L ${round1(s.x2)} ${round1(s.y2)}`);
8883
+ continue;
8884
+ }
8885
+ parts.push(`L ${round1(s.x2)} ${round1(s.y2)}`);
8886
+ }
8887
+ return parts.join(" ");
8888
+ }
8834
8889
 
8835
8890
  // src/layout/lanes.ts
8836
8891
  var LANE_POSITION_EPSILON = 1e-9;
@@ -9830,8 +9885,300 @@ function StateDiffCard({
9830
9885
  }
9831
9886
  );
9832
9887
  }
9888
+ var \u6570\u3092\u66F8\u304F = (value) => value.toLocaleString("en-US", { maximumFractionDigits: 12 });
9889
+ function \u6298\u308C\u7DDA\u306E\u76EE\u76DB(values) {
9890
+ let rawMin = values.length > 0 ? Math.min(...values) : 0;
9891
+ let rawMax = values.length > 0 ? Math.max(...values) : 1;
9892
+ if (rawMin === rawMax) {
9893
+ const room = 10 ** Math.floor(Math.log10(Math.abs(rawMin) || 1) - 1);
9894
+ rawMin -= room;
9895
+ rawMax += room;
9896
+ }
9897
+ const roughStep = (rawMax - rawMin) / 4;
9898
+ const power = 10 ** Math.floor(Math.log10(roughStep));
9899
+ const fraction = roughStep / power;
9900
+ const niceFraction = fraction <= 1 ? 1 : fraction <= 2 ? 2 : fraction <= 2.5 ? 2.5 : fraction <= 5 ? 5 : 10;
9901
+ const step = niceFraction * power;
9902
+ const min = Math.floor(rawMin / step) * step;
9903
+ const max = Math.ceil(rawMax / step) * step;
9904
+ const tickCount = Math.round((max - min) / step);
9905
+ const ticks = Array.from({ length: tickCount + 1 }, (_, i) => {
9906
+ const value = min + step * i;
9907
+ return Math.abs(value) < step * 1e-12 ? 0 : value;
9908
+ });
9909
+ return { min, max, ticks };
9910
+ }
9911
+ function ChartLineNode({
9912
+ node,
9913
+ active,
9914
+ stateValues = {},
9915
+ scale: fixedScale,
9916
+ drawing = false,
9917
+ progress = 1
9918
+ }) {
9919
+ const x0 = node.cx - node.w / 2;
9920
+ const y0 = node.cy - node.h / 2;
9921
+ const data = resolveChartData(node.chartData ?? [], stateValues);
9922
+ const PAD_TOP2 = 36;
9923
+ const PAD_RIGHT2 = 40;
9924
+ const PAD_BOTTOM2 = 56;
9925
+ const PAD_LEFT2 = 72;
9926
+ const canvasW = node.w - PAD_LEFT2 - PAD_RIGHT2;
9927
+ const canvasH = node.h - PAD_TOP2 - PAD_BOTTOM2;
9928
+ const scale = fixedScale ?? \u6298\u308C\u7DDA\u306E\u76EE\u76DB(data.map((d) => d.value));
9929
+ const vRange = scale.max - scale.min;
9930
+ const LABEL_ROOM = 20;
9931
+ const plotTop = PAD_TOP2 + LABEL_ROOM;
9932
+ const plotH = Math.max(canvasH - LABEL_ROOM * 2, 1);
9933
+ const POINT_EDGE_ROOM = 24;
9934
+ const plotW = Math.max(canvasW - POINT_EDGE_ROOM * 2, 1);
9935
+ const xAt = (idx) => PAD_LEFT2 + POINT_EDGE_ROOM + (data.length <= 1 ? plotW / 2 : plotW * idx / (data.length - 1));
9936
+ const yAt = (v) => plotTop + plotH - (v - scale.min) / vRange * plotH;
9937
+ const plotBottom = PAD_TOP2 + canvasH;
9938
+ let \u7DDA\u306E\u5168\u9577 = 0;
9939
+ let \u524D\u306E\u70B9;
9940
+ const \u63CF\u753B\u70B9 = data.map((datum, idx) => {
9941
+ const \u4ECA\u306E\u70B9 = { datum, x: xAt(idx), y: yAt(datum.value), \u3053\u3053\u307E\u3067\u306E\u9577\u3055: 0 };
9942
+ if (\u524D\u306E\u70B9) {
9943
+ \u7DDA\u306E\u5168\u9577 += Math.hypot(\u4ECA\u306E\u70B9.x - \u524D\u306E\u70B9.x, \u4ECA\u306E\u70B9.y - \u524D\u306E\u70B9.y);
9944
+ }
9945
+ \u4ECA\u306E\u70B9.\u3053\u3053\u307E\u3067\u306E\u9577\u3055 = \u7DDA\u306E\u5168\u9577;
9946
+ \u524D\u306E\u70B9 = \u4ECA\u306E\u70B9;
9947
+ return \u4ECA\u306E\u70B9;
9948
+ });
9949
+ const points = \u63CF\u753B\u70B9.map((\u70B9) => `${\u70B9.x},${\u70B9.y}`).join(" ");
9950
+ const \u6BB5\u306E\u9032\u307F = \u9032\u307F\u3092\u7573\u3080(drawing, progress);
9951
+ const \u7C92\u3092\u8D70\u3089\u305B\u308B = drawing && node.chartTrace === true;
9952
+ const \u4F38\u3073 = \u7C92\u3092\u8D70\u3089\u305B\u308B ? Math.min(1, \u6BB5\u306E\u9032\u307F / 0.5) : \u6BB5\u306E\u9032\u307F;
9953
+ const \u7C92\u306E\u9032\u307F = \u7C92\u3092\u8D70\u3089\u305B\u308B ? Math.min(1, Math.max(0, (\u6BB5\u306E\u9032\u307F - 0.55) / 0.45)) : \u4F38\u3073;
9954
+ const \u7C92\u304C\u51FA\u308B = \u7C92\u3092\u8D70\u3089\u305B\u308B && \u6BB5\u306E\u9032\u307F >= 0.55 && \u6BB5\u306E\u9032\u307F < 1;
9955
+ const \u5230\u7740\u7A93 = 0.12;
9956
+ let \u7C92\u306E\u4F4D\u7F6E;
9957
+ const \u6700\u521D\u306E\u70B9 = \u63CF\u753B\u70B9[0];
9958
+ if (\u7C92\u304C\u51FA\u308B && \u6700\u521D\u306E\u70B9) {
9959
+ const \u7C92\u307E\u3067\u306E\u9577\u3055 = \u7C92\u306E\u9032\u307F * \u7DDA\u306E\u5168\u9577;
9960
+ let \u533A\u9593\u306E\u524D = \u6700\u521D\u306E\u70B9;
9961
+ let \u533A\u9593\u306E\u5F8C = \u6700\u521D\u306E\u70B9;
9962
+ for (const \u70B9 of \u63CF\u753B\u70B9.slice(1)) {
9963
+ \u533A\u9593\u306E\u5F8C = \u70B9;
9964
+ if (\u70B9.\u3053\u3053\u307E\u3067\u306E\u9577\u3055 >= \u7C92\u307E\u3067\u306E\u9577\u3055) break;
9965
+ \u533A\u9593\u306E\u524D = \u70B9;
9966
+ }
9967
+ const \u533A\u9593\u306E\u59CB\u3081 = \u533A\u9593\u306E\u524D.\u3053\u3053\u307E\u3067\u306E\u9577\u3055;
9968
+ const \u533A\u9593\u306E\u9577\u3055 = \u533A\u9593\u306E\u5F8C.\u3053\u3053\u307E\u3067\u306E\u9577\u3055 - \u533A\u9593\u306E\u59CB\u3081;
9969
+ const \u533A\u9593\u306E\u9032\u307F = \u533A\u9593\u306E\u9577\u3055 === 0 ? 0 : (\u7C92\u307E\u3067\u306E\u9577\u3055 - \u533A\u9593\u306E\u59CB\u3081) / \u533A\u9593\u306E\u9577\u3055;
9970
+ \u7C92\u306E\u4F4D\u7F6E = {
9971
+ x: \u533A\u9593\u306E\u524D.x + (\u533A\u9593\u306E\u5F8C.x - \u533A\u9593\u306E\u524D.x) * \u533A\u9593\u306E\u9032\u307F,
9972
+ y: \u533A\u9593\u306E\u524D.y + (\u533A\u9593\u306E\u5F8C.y - \u533A\u9593\u306E\u524D.y) * \u533A\u9593\u306E\u9032\u307F
9973
+ };
9974
+ }
9975
+ const gridTicks = scale.ticks.map((value) => ({ y: yAt(value), value }));
9976
+ return /* @__PURE__ */ jsxs("g", { transform: `translate(${x0} ${y0})`, children: [
9977
+ gridTicks.map((t, i) => /* @__PURE__ */ jsxs("g", { children: [
9978
+ /* @__PURE__ */ jsx(
9979
+ "line",
9980
+ {
9981
+ x1: PAD_LEFT2,
9982
+ y1: t.y,
9983
+ x2: PAD_LEFT2 + canvasW,
9984
+ y2: t.y,
9985
+ stroke: "var(--cdl-divider, #d4d4d8)",
9986
+ strokeWidth: 0.75,
9987
+ strokeDasharray: "3 3",
9988
+ opacity: 0.65
9989
+ }
9990
+ ),
9991
+ /* @__PURE__ */ jsx(
9992
+ "text",
9993
+ {
9994
+ x: PAD_LEFT2 - 8,
9995
+ y: t.y + 4,
9996
+ fontSize: 11,
9997
+ textAnchor: "end",
9998
+ fill: "var(--cdl-text-dim, #5a6270)",
9999
+ children: \u6570\u3092\u66F8\u304F(t.value)
10000
+ }
10001
+ )
10002
+ ] }, `grid-${i}`)),
10003
+ node.chartFillUnder && data.length > 1 && /* @__PURE__ */ jsxs(Fragment, { children: [
10004
+ /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs(
10005
+ "linearGradient",
10006
+ {
10007
+ id: `chart-line-fill-${node.id}`,
10008
+ gradientUnits: "userSpaceOnUse",
10009
+ x1: 0,
10010
+ y1: plotTop,
10011
+ x2: 0,
10012
+ y2: plotBottom,
10013
+ children: [
10014
+ /* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: "var(--cdl-tone-accent, #2d6a8f)", stopOpacity: 0.22 }),
10015
+ /* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: "var(--cdl-tone-accent, #2d6a8f)", stopOpacity: 0 })
10016
+ ]
10017
+ }
10018
+ ) }),
10019
+ /* @__PURE__ */ jsx(
10020
+ "path",
10021
+ {
10022
+ "data-cdl-role": "chart-line-fill-under",
10023
+ d: `M ${xAt(0)} ${plotBottom} L ${points.replaceAll(",", " ")} L ${xAt(data.length - 1)} ${plotBottom} Z`,
10024
+ fill: `url(#chart-line-fill-${node.id})`,
10025
+ stroke: "none"
10026
+ }
10027
+ )
10028
+ ] }),
10029
+ data.length > 1 && /* @__PURE__ */ jsx(
10030
+ "polyline",
10031
+ {
10032
+ "data-cdl-role": "chart-line",
10033
+ points,
10034
+ fill: "none",
10035
+ stroke: "var(--cdl-tone-accent, #2d6a8f)",
10036
+ strokeWidth: active ? 3 : 2,
10037
+ strokeLinejoin: "round",
10038
+ strokeLinecap: "round",
10039
+ ...\u4F38\u3070\u3059dash(drawing, \u4F38\u3073)
10040
+ }
10041
+ ),
10042
+ \u7C92\u306E\u4F4D\u7F6E && /* @__PURE__ */ jsx(
10043
+ "circle",
10044
+ {
10045
+ "data-cdl-role": "chart-line-trace",
10046
+ cx: \u7C92\u306E\u4F4D\u7F6E.x,
10047
+ cy: \u7C92\u306E\u4F4D\u7F6E.y,
10048
+ r: 4.5,
10049
+ fill: "var(--cdl-now)"
10050
+ }
10051
+ ),
10052
+ \u63CF\u753B\u70B9.map(({ datum: d, x: cx, y: cy, \u3053\u3053\u307E\u3067\u306E\u9577\u3055 }, idx) => {
10053
+ const prev = data[idx - 1]?.value;
10054
+ const next = data[idx + 1]?.value;
10055
+ const isValley = (prev === void 0 || d.value <= prev) && (next === void 0 || d.value <= next);
10056
+ const labelAbove = !isValley;
10057
+ const labelY = labelAbove ? cy - 12 : cy + 18;
10058
+ const \u5230\u7740\u5F8C = \u7DDA\u306E\u5168\u9577 === 0 ? \u7C92\u306E\u9032\u307F : \u7C92\u306E\u9032\u307F - \u3053\u3053\u307E\u3067\u306E\u9577\u3055 / \u7DDA\u306E\u5168\u9577;
10059
+ const \u51FA\u3059 = !drawing || (!\u7C92\u3092\u8D70\u3089\u305B\u308B || \u6BB5\u306E\u9032\u307F >= 0.55) && \u5230\u7740\u5F8C >= 0;
10060
+ const \u5149\u308B = drawing && \u51FA\u3059 && \u5230\u7740\u5F8C < \u5230\u7740\u7A93;
10061
+ const \u5149\u306E\u9032\u307F = \u5149\u308B ? \u5230\u7740\u5F8C / \u5230\u7740\u7A93 : 1;
10062
+ let \u70B9\u3068\u5024;
10063
+ if (\u51FA\u3059) {
10064
+ const \u5149\u306E\u534A\u5F84 = 6 + 16 * \u5149\u306E\u9032\u307F;
10065
+ const \u5024 = /* @__PURE__ */ jsx(
10066
+ "text",
10067
+ {
10068
+ "data-cdl-role": "chart-line-value",
10069
+ x: cx,
10070
+ y: labelY,
10071
+ fontSize: 11,
10072
+ fontWeight: 600,
10073
+ textAnchor: "middle",
10074
+ fill: "var(--cdl-text, #1a1f2a)",
10075
+ children: \u6570\u3092\u66F8\u304F(d.value)
10076
+ }
10077
+ );
10078
+ \u70B9\u3068\u5024 = /* @__PURE__ */ jsxs(Fragment, { children: [
10079
+ \u5149\u308B && // marker の `circle` を数える利用側へ混ぜず、専用 role の等径 ellipse として輪を出す。
10080
+ /* @__PURE__ */ jsx(
10081
+ "ellipse",
10082
+ {
10083
+ "data-cdl-role": "chart-line-arrival-ring",
10084
+ cx,
10085
+ cy,
10086
+ rx: \u5149\u306E\u534A\u5F84,
10087
+ ry: \u5149\u306E\u534A\u5F84,
10088
+ fill: "none",
10089
+ stroke: "var(--cdl-now)",
10090
+ strokeWidth: 2,
10091
+ opacity: 0.85 * (1 - \u5149\u306E\u9032\u307F)
10092
+ }
10093
+ ),
10094
+ /* @__PURE__ */ jsx(
10095
+ "circle",
10096
+ {
10097
+ cx,
10098
+ cy,
10099
+ r: 5,
10100
+ fill: "var(--cdl-node-fill, #ffffff)",
10101
+ stroke: \u5149\u308B ? "var(--cdl-now)" : "var(--cdl-tone-accent, #2d6a8f)",
10102
+ strokeWidth: 2.5
10103
+ }
10104
+ ),
10105
+ /* @__PURE__ */ jsx(
10106
+ "circle",
10107
+ {
10108
+ cx,
10109
+ cy,
10110
+ r: 2.5,
10111
+ fill: \u5149\u308B ? "var(--cdl-now)" : "var(--cdl-tone-accent, #2d6a8f)"
10112
+ }
10113
+ ),
10114
+ node.chartValueRise && \u5149\u308B ? /* @__PURE__ */ jsx(
10115
+ "g",
10116
+ {
10117
+ "data-cdl-role": "chart-line-value-rise",
10118
+ transform: `translate(0 ${8 * (1 - \u5149\u306E\u9032\u307F)})`,
10119
+ children: \u5024
10120
+ }
10121
+ ) : \u5024
10122
+ ] });
10123
+ }
10124
+ return /* @__PURE__ */ jsxs("g", { "data-cdl-unresolved": d.unresolved ? "true" : void 0, children: [
10125
+ \u70B9\u3068\u5024,
10126
+ /* @__PURE__ */ jsx(
10127
+ "text",
10128
+ {
10129
+ x: cx,
10130
+ y: PAD_TOP2 + canvasH + 20,
10131
+ fontSize: 12,
10132
+ textAnchor: "middle",
10133
+ fill: "var(--cdl-text-dim, #5a6270)",
10134
+ children: d.label
10135
+ }
10136
+ )
10137
+ ] }, `pt-${idx}`);
10138
+ })
10139
+ ] });
10140
+ }
10141
+
10142
+ // src/kinds/draw-ratio.ts
10143
+ var DRAW_RATIO_DEFAULT = 1;
10144
+ function \u63CF\u304F\u5272\u5408\u3092\u6B63\u3059(ratio) {
10145
+ if (ratio === void 0) return DRAW_RATIO_DEFAULT;
10146
+ if (!Number.isFinite(ratio)) return DRAW_RATIO_DEFAULT;
10147
+ if (ratio <= 0 || ratio > 1) return DRAW_RATIO_DEFAULT;
10148
+ return ratio;
10149
+ }
10150
+ function \u63CF\u304F\u9032\u307F\u306B\u76F4\u3059(progress, ratio) {
10151
+ const \u5272\u5408 = \u63CF\u304F\u5272\u5408\u3092\u6B63\u3059(ratio);
10152
+ if (\u5272\u5408 === DRAW_RATIO_DEFAULT) return progress;
10153
+ if (!Number.isFinite(progress)) return progress;
10154
+ return Math.min(1, progress / \u5272\u5408);
10155
+ }
10156
+
10157
+ // src/layout/lifeline.ts
10158
+ function lifelineStartYs(nodes) {
10159
+ const topmost = /* @__PURE__ */ new Map();
10160
+ for (const n of nodes) {
10161
+ const cur = topmost.get(n.lane);
10162
+ if (cur === void 0 || n.cy < cur.cy) topmost.set(n.lane, n);
10163
+ }
10164
+ const starts = /* @__PURE__ */ new Map();
10165
+ for (const [laneId, n] of topmost) starts.set(laneId, n.cy + n.h / 2);
10166
+ return starts;
10167
+ }
10168
+ function uniformLifelineEndY(lanes, nodes, starts = lifelineStartYs(nodes)) {
10169
+ const lifelineLanes = lanes.filter((l) => l.lifeline);
10170
+ let deepestStart = Number.NEGATIVE_INFINITY;
10171
+ for (const lane of lifelineLanes) {
10172
+ const start = starts.get(lane.id);
10173
+ if (start !== void 0) deepestStart = Math.max(deepestStart, start);
10174
+ }
10175
+ const footerTops = lifelineFooterNodes(lanes, nodes).map((f) => footerShapeDrawTop(f)).filter((top) => top > deepestStart);
10176
+ if (footerTops.length > 0) return Math.min(...footerTops);
10177
+ return lifelineLanes[0] ? lifelineLanes[0].y + lifelineLanes[0].height : 0;
10178
+ }
9833
10179
 
9834
10180
  // src/render/edge-head.ts
10181
+ var EDGE_HEAD_MUTED_MARKER_ID = "cdl-arrow-muted";
9835
10182
  var EDGE_HEAD_SHAPE = {
9836
10183
  // 何も描かない端。 marker 自体を出さないので `d` は読まれない
9837
10184
  none: { d: "", w: 10, h: 10, refX: 0, filled: false },
@@ -9862,6 +10209,11 @@ function edgeHeadMarkerId(tone, head, small, fill = EDGE_HEAD_FILL_DEFAULT) {
9862
10209
  const \u5857 = fill === EDGE_HEAD_FILL_DEFAULT || !EDGE_HEAD_SHAPE[head].filled ? "" : `-${fill}`;
9863
10210
  return head === EDGE_HEAD_DEFAULT && \u5857 === "" ? `cdl-arrow-${tone}${\u5C0F}` : `cdl-arrow-${tone}-${head}${\u5857}${\u5C0F}`;
9864
10211
  }
10212
+ function edgeHeadMarkerName(tone, head, small, fill) {
10213
+ const \u5B9F\u969B\u306E\u5F62 = head ?? EDGE_HEAD_DEFAULT;
10214
+ if (\u5B9F\u969B\u306E\u5F62 === "none") return void 0;
10215
+ return hasTone(tone) ? edgeHeadMarkerId(tone, \u5B9F\u969B\u306E\u5F62, small, fill ?? EDGE_HEAD_FILL_DEFAULT) : EDGE_HEAD_MUTED_MARKER_ID;
10216
+ }
9865
10217
  function edgeHeadPaint(head, fill, color) {
9866
10218
  const \u5F62 = EDGE_HEAD_SHAPE[head];
9867
10219
  if (!\u5F62.filled) return { fill: "none", stroke: color, strokeWidth: 1.6 };
@@ -9890,13 +10242,8 @@ function CdlEdgeView({
9890
10242
  stateValues
9891
10243
  }) {
9892
10244
  const color = edgeColor(edge);
9893
- const \u7AEF\u306E\u540D\u524D = (h, f) => {
9894
- const \u5F62 = h ?? EDGE_HEAD_DEFAULT;
9895
- if (\u5F62 === "none") return void 0;
9896
- return hasTone(edge.tone) ? edgeHeadMarkerId(edge.tone, \u5F62, !active, f ?? EDGE_HEAD_FILL_DEFAULT) : "cdl-arrow-muted";
9897
- };
9898
- const marker = \u7AEF\u306E\u540D\u524D(edge.head, edge.headFill);
9899
- const tailMarker = edge.tailHead === void 0 ? void 0 : \u7AEF\u306E\u540D\u524D(edge.tailHead, edge.tailHeadFill);
10245
+ const marker = edgeHeadMarkerName(edge.tone, edge.head, !active, edge.headFill);
10246
+ const tailMarker = edge.tailHead === void 0 ? void 0 : edgeHeadMarkerName(edge.tone, edge.tailHead, !active, edge.tailHeadFill);
9900
10247
  const style = edge.style ?? "solid";
9901
10248
  const isDotted = style === "dotted-flow";
9902
10249
  const isPassThrough = isDotted && Boolean(edge.dThrough);
@@ -11469,191 +11816,6 @@ function interpolateColor(template, stateValues, fallback) {
11469
11816
  if (!template) return fallback;
11470
11817
  return interpolate(template, stateValues);
11471
11818
  }
11472
- function ChartLineNode({
11473
- node,
11474
- active,
11475
- stateValues = {},
11476
- drawing = false,
11477
- progress = 1
11478
- }) {
11479
- const x0 = node.cx - node.w / 2;
11480
- const y0 = node.cy - node.h / 2;
11481
- const data = resolveChartData(node.chartData ?? [], stateValues);
11482
- const PAD_TOP2 = 36;
11483
- const PAD_RIGHT2 = 40;
11484
- const PAD_BOTTOM2 = 56;
11485
- const PAD_LEFT2 = 72;
11486
- const canvasW = node.w - PAD_LEFT2 - PAD_RIGHT2;
11487
- const canvasH = node.h - PAD_TOP2 - PAD_BOTTOM2;
11488
- const values = data.map((d) => d.value);
11489
- const vMin = values.length > 0 ? Math.min(...values) : 0;
11490
- const vMax = values.length > 0 ? Math.max(...values) : 1;
11491
- const vRange = vMax - vMin || 1;
11492
- const LABEL_ROOM = 20;
11493
- const plotTop = PAD_TOP2 + LABEL_ROOM;
11494
- const plotH = Math.max(canvasH - LABEL_ROOM * 2, 1);
11495
- const xAt = (idx) => PAD_LEFT2 + (data.length <= 1 ? canvasW / 2 : canvasW * idx / (data.length - 1));
11496
- const yAt = (v) => plotTop + plotH - (v - vMin) / vRange * plotH;
11497
- const points = data.map((d, idx) => `${xAt(idx)},${yAt(d.value)}`).join(" ");
11498
- const \u70B9\u307E\u3067\u306E\u9577\u3055 = [];
11499
- let \u7DDA\u306E\u5168\u9577 = 0;
11500
- let \u524D\u306E\u70B9;
11501
- for (const [idx, datum] of data.entries()) {
11502
- const \u4ECA\u306E\u70B9 = { x: xAt(idx), y: yAt(datum.value) };
11503
- if (\u524D\u306E\u70B9) {
11504
- \u7DDA\u306E\u5168\u9577 += Math.hypot(\u4ECA\u306E\u70B9.x - \u524D\u306E\u70B9.x, \u4ECA\u306E\u70B9.y - \u524D\u306E\u70B9.y);
11505
- }
11506
- \u70B9\u307E\u3067\u306E\u9577\u3055.push(\u7DDA\u306E\u5168\u9577);
11507
- \u524D\u306E\u70B9 = \u4ECA\u306E\u70B9;
11508
- }
11509
- const \u4F38\u3073 = \u9032\u307F\u3092\u7573\u3080(drawing, progress);
11510
- const \u7DDA\u306E\u5148\u304C\u5C4A\u3044\u305F = (idx) => {
11511
- if (!drawing) return true;
11512
- if (data.length <= 1) return true;
11513
- if (\u7DDA\u306E\u5168\u9577 === 0) return true;
11514
- return \u4F38\u3073 >= (\u70B9\u307E\u3067\u306E\u9577\u3055[idx] ?? 0) / \u7DDA\u306E\u5168\u9577;
11515
- };
11516
- const gridCount = 4;
11517
- const gridTicks = Array.from({ length: gridCount + 1 }, (_, i) => {
11518
- const v = vMin + vRange * i / gridCount;
11519
- return { y: yAt(v), value: v };
11520
- });
11521
- return /* @__PURE__ */ jsxs("g", { transform: `translate(${x0} ${y0})`, children: [
11522
- /* @__PURE__ */ jsx(
11523
- "rect",
11524
- {
11525
- "data-cdl-role": "node-body",
11526
- x: 0,
11527
- y: 0,
11528
- width: node.w,
11529
- height: node.h,
11530
- rx: 16,
11531
- fill: "var(--cdl-node-fill, #ffffff)",
11532
- stroke: active ? "var(--cdl-tone-accent, #2d6a8f)" : "var(--cdl-divider, #d4d4d8)",
11533
- strokeWidth: active ? 3 : 1.25
11534
- }
11535
- ),
11536
- gridTicks.map((t, i) => /* @__PURE__ */ jsxs("g", { children: [
11537
- /* @__PURE__ */ jsx(
11538
- "line",
11539
- {
11540
- x1: PAD_LEFT2,
11541
- y1: t.y,
11542
- x2: PAD_LEFT2 + canvasW,
11543
- y2: t.y,
11544
- stroke: "var(--cdl-divider, #d4d4d8)",
11545
- strokeWidth: 0.75,
11546
- strokeDasharray: "3 3",
11547
- opacity: 0.65
11548
- }
11549
- ),
11550
- /* @__PURE__ */ jsx(
11551
- "text",
11552
- {
11553
- x: PAD_LEFT2 - 8,
11554
- y: t.y + 4,
11555
- fontSize: 11,
11556
- textAnchor: "end",
11557
- fill: "var(--cdl-text-dim, #5a6270)",
11558
- children: Math.round(t.value)
11559
- }
11560
- )
11561
- ] }, `grid-${i}`)),
11562
- /* @__PURE__ */ jsx(
11563
- "line",
11564
- {
11565
- x1: PAD_LEFT2,
11566
- y1: plotTop + plotH,
11567
- x2: PAD_LEFT2 + canvasW,
11568
- y2: plotTop + plotH,
11569
- stroke: "var(--cdl-text-mute, #8a8678)",
11570
- strokeWidth: 1.25
11571
- }
11572
- ),
11573
- /* @__PURE__ */ jsx(
11574
- "line",
11575
- {
11576
- x1: PAD_LEFT2,
11577
- y1: plotTop,
11578
- x2: PAD_LEFT2,
11579
- y2: plotTop + plotH,
11580
- stroke: "var(--cdl-text-mute, #8a8678)",
11581
- strokeWidth: 1.25
11582
- }
11583
- ),
11584
- data.length > 1 && /* @__PURE__ */ jsx(
11585
- "polyline",
11586
- {
11587
- "data-cdl-role": "chart-line",
11588
- points,
11589
- fill: "none",
11590
- stroke: "var(--cdl-tone-accent, #2d6a8f)",
11591
- strokeWidth: 2.5,
11592
- strokeLinejoin: "round",
11593
- strokeLinecap: "round",
11594
- ...\u4F38\u3070\u3059dash(drawing, \u4F38\u3073)
11595
- }
11596
- ),
11597
- data.map((d, idx) => {
11598
- const cx = xAt(idx);
11599
- const cy = yAt(d.value);
11600
- const prev = idx > 0 ? data[idx - 1].value : void 0;
11601
- const next = idx < data.length - 1 ? data[idx + 1].value : void 0;
11602
- const isValley = (prev === void 0 || d.value <= prev) && (next === void 0 || d.value <= next);
11603
- const labelAbove = !isValley;
11604
- const labelY = labelAbove ? cy - 12 : cy + 18;
11605
- const \u51FA\u3059 = \u7DDA\u306E\u5148\u304C\u5C4A\u3044\u305F(idx);
11606
- return /* @__PURE__ */ jsxs("g", { "data-cdl-unresolved": d.unresolved ? "true" : void 0, children: [
11607
- \u51FA\u3059 && /* @__PURE__ */ jsxs(Fragment, { children: [
11608
- /* @__PURE__ */ jsx(
11609
- "circle",
11610
- {
11611
- cx,
11612
- cy,
11613
- r: 5,
11614
- fill: "var(--cdl-node-fill, #ffffff)",
11615
- stroke: "var(--cdl-tone-accent, #2d6a8f)",
11616
- strokeWidth: 2.5
11617
- }
11618
- ),
11619
- /* @__PURE__ */ jsx(
11620
- "circle",
11621
- {
11622
- cx,
11623
- cy,
11624
- r: 2.5,
11625
- fill: "var(--cdl-tone-accent, #2d6a8f)"
11626
- }
11627
- ),
11628
- /* @__PURE__ */ jsx(
11629
- "text",
11630
- {
11631
- "data-cdl-role": "chart-line-value",
11632
- x: cx,
11633
- y: labelY,
11634
- fontSize: 11,
11635
- fontWeight: 600,
11636
- textAnchor: "middle",
11637
- fill: "var(--cdl-text, #1a1f2a)",
11638
- children: d.value.toLocaleString()
11639
- }
11640
- )
11641
- ] }),
11642
- /* @__PURE__ */ jsx(
11643
- "text",
11644
- {
11645
- x: cx,
11646
- y: PAD_TOP2 + canvasH + 20,
11647
- fontSize: 12,
11648
- textAnchor: "middle",
11649
- fill: "var(--cdl-text-dim, #5a6270)",
11650
- children: d.label
11651
- }
11652
- )
11653
- ] }, `pt-${idx}`);
11654
- })
11655
- ] });
11656
- }
11657
11819
  function ChartPieNode({
11658
11820
  node,
11659
11821
  active,
@@ -17164,7 +17326,8 @@ function CdlNodeView({
17164
17326
  drawing = false,
17165
17327
  progress,
17166
17328
  stateValues,
17167
- currentPhaseId
17329
+ currentPhaseId,
17330
+ chartLineScale
17168
17331
  }) {
17169
17332
  const value = node.value ? interpolate(node.value, stateValues) : void 0;
17170
17333
  const rows = (node.rows ?? []).map((r) => interpolate(r, stateValues));
@@ -17220,6 +17383,7 @@ function CdlNodeView({
17220
17383
  node: resolvedNode,
17221
17384
  active,
17222
17385
  stateValues,
17386
+ scale: chartLineScale,
17223
17387
  drawing,
17224
17388
  progress
17225
17389
  }
@@ -17461,44 +17625,6 @@ function CdlNodeView({
17461
17625
  }
17462
17626
  );
17463
17627
  }
17464
-
17465
- // src/layout/lifeline.ts
17466
- function lifelineStartYs(nodes) {
17467
- const topmost = /* @__PURE__ */ new Map();
17468
- for (const n of nodes) {
17469
- const cur = topmost.get(n.lane);
17470
- if (cur === void 0 || n.cy < cur.cy) topmost.set(n.lane, n);
17471
- }
17472
- const starts = /* @__PURE__ */ new Map();
17473
- for (const [laneId, n] of topmost) starts.set(laneId, n.cy + n.h / 2);
17474
- return starts;
17475
- }
17476
- function uniformLifelineEndY(lanes, nodes, starts = lifelineStartYs(nodes)) {
17477
- const lifelineLanes = lanes.filter((l) => l.lifeline);
17478
- let deepestStart = Number.NEGATIVE_INFINITY;
17479
- for (const lane of lifelineLanes) {
17480
- const start = starts.get(lane.id);
17481
- if (start !== void 0) deepestStart = Math.max(deepestStart, start);
17482
- }
17483
- const footerTops = lifelineFooterNodes(lanes, nodes).map((f) => footerShapeDrawTop(f)).filter((top) => top > deepestStart);
17484
- if (footerTops.length > 0) return Math.min(...footerTops);
17485
- return lifelineLanes[0] ? lifelineLanes[0].y + lifelineLanes[0].height : 0;
17486
- }
17487
-
17488
- // src/kinds/draw-ratio.ts
17489
- var DRAW_RATIO_DEFAULT = 1;
17490
- function \u63CF\u304F\u5272\u5408\u3092\u6B63\u3059(ratio) {
17491
- if (ratio === void 0) return DRAW_RATIO_DEFAULT;
17492
- if (!Number.isFinite(ratio)) return DRAW_RATIO_DEFAULT;
17493
- if (ratio <= 0 || ratio > 1) return DRAW_RATIO_DEFAULT;
17494
- return ratio;
17495
- }
17496
- function \u63CF\u304F\u9032\u307F\u306B\u76F4\u3059(progress, ratio) {
17497
- const \u5272\u5408 = \u63CF\u304F\u5272\u5408\u3092\u6B63\u3059(ratio);
17498
- if (\u5272\u5408 === DRAW_RATIO_DEFAULT) return progress;
17499
- if (!Number.isFinite(progress)) return progress;
17500
- return Math.min(1, progress / \u5272\u5408);
17501
- }
17502
17628
  function CdlStage({
17503
17629
  laid,
17504
17630
  currentPhase,
@@ -17540,6 +17666,26 @@ function CdlStage({
17540
17666
  };
17541
17667
  }, [laid.phases, currentPhase, laid.edgeReveal]);
17542
17668
  const drawSet = new Set(currentPhase?.draw ?? []);
17669
+ const chartLineScales = useMemo(() => {
17670
+ const nodes = laid.nodes.filter((node) => node.kind === "chart-line");
17671
+ if (nodes.length === 0) return /* @__PURE__ */ new Map();
17672
+ const frames = [
17673
+ // phase index -1 はどの段にも入る前の初期値。
17674
+ computeStateValues(laid, -1, 0),
17675
+ ...laid.phases.flatMap((_, phaseIndex) => [
17676
+ computeStateValues(laid, phaseIndex, 0),
17677
+ computeStateValues(laid, phaseIndex, 1)
17678
+ ])
17679
+ ];
17680
+ const scales = /* @__PURE__ */ new Map();
17681
+ for (const node of nodes) {
17682
+ const values = frames.flatMap(
17683
+ (stateValues2) => resolveChartData(node.chartData ?? [], stateValues2).map((datum) => datum.value)
17684
+ );
17685
+ scales.set(node.id, \u6298\u308C\u7DDA\u306E\u76EE\u76DB(values));
17686
+ }
17687
+ return scales;
17688
+ }, [laid]);
17543
17689
  const \u63CF\u304F\u9032\u307F = \u63CF\u304F\u9032\u307F\u306B\u76F4\u3059(progress, currentPhase?.drawRatio);
17544
17690
  const { lifelineStarts, uniformFooterTop } = useMemo(() => {
17545
17691
  const starts = lifelineStartYs(laid.nodes);
@@ -17548,6 +17694,63 @@ function CdlStage({
17548
17694
  uniformFooterTop: uniformLifelineEndY(laid.lanes, laid.nodes, starts)
17549
17695
  };
17550
17696
  }, [laid]);
17697
+ const edgeHeadMarkers = useMemo(() => {
17698
+ const referenced = /* @__PURE__ */ new Set();
17699
+ const add = (tone, head, fill) => {
17700
+ for (const small of [false, true]) {
17701
+ const id = edgeHeadMarkerName(tone, head, small, fill);
17702
+ if (id !== void 0) referenced.add(id);
17703
+ }
17704
+ };
17705
+ for (const edge of laid.edges) {
17706
+ add(edge.tone, edge.head, edge.headFill);
17707
+ if (edge.tailHead !== void 0) add(edge.tone, edge.tailHead, edge.tailHeadFill);
17708
+ }
17709
+ return Object.entries(TONE).flatMap(
17710
+ ([tone, color]) => [
17711
+ [false, 14],
17712
+ [true, 10]
17713
+ ].flatMap(
17714
+ ([small, size]) => EDGE_HEADS.flatMap(
17715
+ (head) => EDGE_HEAD_FILLS.map((fill) => {
17716
+ const \u5F62 = EDGE_HEAD_SHAPE[head];
17717
+ const id = edgeHeadMarkerId(tone, head, small, fill);
17718
+ if (!referenced.has(id) || \u5F62.d === "") return null;
17719
+ if (fill !== EDGE_HEAD_FILL_DEFAULT && !\u5F62.filled) return null;
17720
+ const \u5857 = edgeHeadPaint(head, fill, color);
17721
+ return /* @__PURE__ */ jsx(
17722
+ "marker",
17723
+ {
17724
+ id,
17725
+ viewBox: `0 0 ${\u5F62.w} ${\u5F62.h}`,
17726
+ refX: \u5F62.refX,
17727
+ refY: \u5F62.h / 2,
17728
+ markerWidth: size * (\u5F62.scale ?? 1) * \u5F62.w / \u5F62.h,
17729
+ markerHeight: size * (\u5F62.scale ?? 1),
17730
+ markerUnits: "userSpaceOnUse",
17731
+ orient: "auto-start-reverse",
17732
+ children: /* @__PURE__ */ jsx(
17733
+ "path",
17734
+ {
17735
+ "data-cdl-role": "edge-arrowhead",
17736
+ "data-cdl-edge-head": head,
17737
+ "data-cdl-edge-head-fill": fill,
17738
+ d: \u5F62.d,
17739
+ fill: \u5857.fill,
17740
+ stroke: \u5857.stroke,
17741
+ strokeWidth: \u5857.strokeWidth,
17742
+ strokeLinecap: \u5857.strokeWidth === void 0 ? void 0 : "round",
17743
+ strokeLinejoin: \u5857.strokeWidth === void 0 ? void 0 : "round"
17744
+ }
17745
+ )
17746
+ },
17747
+ id
17748
+ );
17749
+ })
17750
+ )
17751
+ )
17752
+ );
17753
+ }, [laid]);
17551
17754
  const diagramScale = laid.diagramScale ?? 1;
17552
17755
  return /* @__PURE__ */ jsxs("div", { className: compact ? "px-3 py-3" : "px-6 py-6", style: compact ? void 0 : { minHeight: 460 }, children: [
17553
17756
  /* @__PURE__ */ jsxs(
@@ -17566,55 +17769,11 @@ function CdlStage({
17566
17769
  "data-cdl-type": laid.type,
17567
17770
  children: [
17568
17771
  /* @__PURE__ */ jsxs("defs", { children: [
17569
- Object.entries(TONE).flatMap(
17570
- ([tone, color]) => [["", 14], ["-sm", 10]].flatMap(
17571
- ([suffix, size]) => EDGE_HEADS.flatMap(
17572
- (head) => (
17573
- // 塗り方は形と別の軸 (#578)。 塗らない形では 2 つが同じ名前に畳まれるので、
17574
- // `edgeHeadMarkerId` が返す名前で重複を外す
17575
- EDGE_HEAD_FILLS.map((fill) => {
17576
- const \u5F62 = EDGE_HEAD_SHAPE[head];
17577
- const id = edgeHeadMarkerId(tone, head, suffix === "-sm", fill);
17578
- if (\u5F62.d === "") return null;
17579
- if (fill !== EDGE_HEAD_FILL_DEFAULT && !\u5F62.filled) return null;
17580
- const \u5857 = edgeHeadPaint(head, fill, color);
17581
- return /* @__PURE__ */ jsx(
17582
- "marker",
17583
- {
17584
- id,
17585
- viewBox: `0 0 ${\u5F62.w} ${\u5F62.h}`,
17586
- refX: \u5F62.refX,
17587
- refY: \u5F62.h / 2,
17588
- markerWidth: size * (\u5F62.scale ?? 1) * \u5F62.w / \u5F62.h,
17589
- markerHeight: size * (\u5F62.scale ?? 1),
17590
- markerUnits: "userSpaceOnUse",
17591
- orient: "auto-start-reverse",
17592
- children: /* @__PURE__ */ jsx(
17593
- "path",
17594
- {
17595
- "data-cdl-role": "edge-arrowhead",
17596
- "data-cdl-edge-head": head,
17597
- "data-cdl-edge-head-fill": fill,
17598
- d: \u5F62.d,
17599
- fill: \u5857.fill,
17600
- stroke: \u5857.stroke,
17601
- strokeWidth: \u5857.strokeWidth,
17602
- strokeLinecap: \u5857.strokeWidth === void 0 ? void 0 : "round",
17603
- strokeLinejoin: \u5857.strokeWidth === void 0 ? void 0 : "round"
17604
- }
17605
- )
17606
- },
17607
- id
17608
- );
17609
- })
17610
- )
17611
- )
17612
- )
17613
- ),
17772
+ edgeHeadMarkers,
17614
17773
  /* @__PURE__ */ jsx(
17615
17774
  "marker",
17616
17775
  {
17617
- id: "cdl-arrow-muted",
17776
+ id: EDGE_HEAD_MUTED_MARKER_ID,
17618
17777
  viewBox: "0 0 10 10",
17619
17778
  refX: "9",
17620
17779
  refY: "5",
@@ -17721,7 +17880,8 @@ function CdlStage({
17721
17880
  drawing: \u63CF\u304F,
17722
17881
  progress: \u63CF\u304F ? \u63CF\u304F\u9032\u307F : progress,
17723
17882
  stateValues,
17724
- currentPhaseId: currentPhase?.id
17883
+ currentPhaseId: currentPhase?.id,
17884
+ chartLineScale: chartLineScales.get(node.id)
17725
17885
  }
17726
17886
  );
17727
17887
  return /* @__PURE__ */ jsx("g", { children: view }, node.id);