pptx-react-viewer 3.10.0 → 3.11.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 (136) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/{AiChatPanel-NSVSBJC7.js → AiChatPanel-A3ZMMVUA.js} +24 -24
  3. package/dist/AiChatPanel-A3ZMMVUA.js.br +0 -0
  4. package/dist/AiChatPanel-A3ZMMVUA.js.gz +0 -0
  5. package/dist/{AiChatPanel-BQSUE2OO.mjs → AiChatPanel-L5H455NZ.mjs} +3 -3
  6. package/dist/AiChatPanel-L5H455NZ.mjs.br +0 -0
  7. package/dist/AiChatPanel-L5H455NZ.mjs.gz +0 -0
  8. package/dist/{Area3DChartScene-2FQHPGNE.mjs → Area3DChartScene-OAD36KIX.mjs} +1 -1
  9. package/dist/{Area3DChartScene-2FQHPGNE.mjs.br → Area3DChartScene-OAD36KIX.mjs.br} +0 -0
  10. package/dist/Area3DChartScene-OAD36KIX.mjs.gz +0 -0
  11. package/dist/{Area3DChartScene-V3W2V7N5.js → Area3DChartScene-R2CKCYCB.js} +2 -2
  12. package/dist/{Area3DChartScene-V3W2V7N5.js.br → Area3DChartScene-R2CKCYCB.js.br} +0 -0
  13. package/dist/Area3DChartScene-R2CKCYCB.js.gz +0 -0
  14. package/dist/{Bar3DChartScene-55XMAUC7.js → Bar3DChartScene-CRRPMXGQ.js} +2 -2
  15. package/dist/Bar3DChartScene-CRRPMXGQ.js.br +0 -0
  16. package/dist/Bar3DChartScene-CRRPMXGQ.js.gz +0 -0
  17. package/dist/{Bar3DChartScene-PSJEVANA.mjs → Bar3DChartScene-XNNXF26T.mjs} +1 -1
  18. package/dist/{Bar3DChartScene-PSJEVANA.mjs.br → Bar3DChartScene-XNNXF26T.mjs.br} +0 -0
  19. package/dist/Bar3DChartScene-XNNXF26T.mjs.gz +0 -0
  20. package/dist/{Line3DChartScene-5KACYRSQ.js → Line3DChartScene-44PLZML2.js} +2 -2
  21. package/dist/Line3DChartScene-44PLZML2.js.br +0 -0
  22. package/dist/Line3DChartScene-44PLZML2.js.gz +0 -0
  23. package/dist/{Line3DChartScene-BUVNUFNO.mjs → Line3DChartScene-MNNPB3LZ.mjs} +1 -1
  24. package/dist/{Line3DChartScene-BUVNUFNO.mjs.br → Line3DChartScene-MNNPB3LZ.mjs.br} +0 -0
  25. package/dist/Line3DChartScene-MNNPB3LZ.mjs.gz +0 -0
  26. package/dist/{Model3DScene-REKMR2L6.mjs → Model3DScene-5MUREFLY.mjs} +1 -1
  27. package/dist/{Model3DScene-REKMR2L6.mjs.br → Model3DScene-5MUREFLY.mjs.br} +0 -0
  28. package/dist/Model3DScene-5MUREFLY.mjs.gz +0 -0
  29. package/dist/{Model3DScene-6U6TN36M.js → Model3DScene-RYPYQPJH.js} +2 -2
  30. package/dist/Model3DScene-RYPYQPJH.js.br +0 -0
  31. package/dist/Model3DScene-RYPYQPJH.js.gz +0 -0
  32. package/dist/{PieChart3DScene-MV3JF7EM.js → PieChart3DScene-GACYCSSQ.js} +2 -2
  33. package/dist/{PieChart3DScene-MV3JF7EM.js.br → PieChart3DScene-GACYCSSQ.js.br} +0 -0
  34. package/dist/PieChart3DScene-GACYCSSQ.js.gz +0 -0
  35. package/dist/{PieChart3DScene-4L2VVIUJ.mjs → PieChart3DScene-KYZSSG5X.mjs} +1 -1
  36. package/dist/PieChart3DScene-KYZSSG5X.mjs.br +0 -0
  37. package/dist/PieChart3DScene-KYZSSG5X.mjs.gz +0 -0
  38. package/dist/{SurfaceChart3DScene-SFIOK3G3.js → SurfaceChart3DScene-RI5G4BHS.js} +2 -2
  39. package/dist/{SurfaceChart3DScene-SFIOK3G3.js.br → SurfaceChart3DScene-RI5G4BHS.js.br} +0 -0
  40. package/dist/SurfaceChart3DScene-RI5G4BHS.js.gz +0 -0
  41. package/dist/{SurfaceChart3DScene-ARE7OBFI.mjs → SurfaceChart3DScene-ZUP4PRUZ.mjs} +1 -1
  42. package/dist/SurfaceChart3DScene-ZUP4PRUZ.mjs.br +0 -0
  43. package/dist/SurfaceChart3DScene-ZUP4PRUZ.mjs.gz +0 -0
  44. package/dist/{chunk-DZ3HWACD.js → chunk-4PL3GBSD.js} +1256 -1256
  45. package/dist/chunk-4PL3GBSD.js.br +0 -0
  46. package/dist/chunk-4PL3GBSD.js.gz +0 -0
  47. package/dist/{chunk-M6GIPAY4.mjs → chunk-5T4Y4QPV.mjs} +1 -1
  48. package/dist/chunk-5T4Y4QPV.mjs.br +0 -0
  49. package/dist/chunk-5T4Y4QPV.mjs.gz +0 -0
  50. package/dist/{chunk-UKPGYJ7G.mjs → chunk-6BNPHEEX.mjs} +998 -549
  51. package/dist/chunk-6BNPHEEX.mjs.br +0 -0
  52. package/dist/chunk-6BNPHEEX.mjs.gz +0 -0
  53. package/dist/{chunk-HYUPPQJW.js → chunk-BX4XVY5X.js} +5 -5
  54. package/dist/chunk-BX4XVY5X.js.br +0 -0
  55. package/dist/chunk-BX4XVY5X.js.gz +0 -0
  56. package/dist/{chunk-XW46A7DN.js → chunk-IK25LY4C.js} +167 -167
  57. package/dist/chunk-IK25LY4C.js.br +0 -0
  58. package/dist/chunk-IK25LY4C.js.gz +0 -0
  59. package/dist/{chunk-2Q2NFPXA.js → chunk-LY5535CF.js} +998 -549
  60. package/dist/chunk-LY5535CF.js.br +0 -0
  61. package/dist/chunk-LY5535CF.js.gz +0 -0
  62. package/dist/{chunk-FHOUTYMB.js → chunk-MRBHJ26I.js} +434 -434
  63. package/dist/chunk-MRBHJ26I.js.br +0 -0
  64. package/dist/chunk-MRBHJ26I.js.gz +0 -0
  65. package/dist/{chunk-KWHURCVT.mjs → chunk-N75WRHON.mjs} +12 -12
  66. package/dist/chunk-N75WRHON.mjs.br +0 -0
  67. package/dist/chunk-N75WRHON.mjs.gz +0 -0
  68. package/dist/{chunk-T4ZRSRQZ.mjs → chunk-SUEZMQRT.mjs} +1 -1
  69. package/dist/chunk-SUEZMQRT.mjs.br +0 -0
  70. package/dist/chunk-SUEZMQRT.mjs.gz +0 -0
  71. package/dist/{chunk-HJZA3O3S.mjs → chunk-VHFPZBUW.mjs} +2 -2
  72. package/dist/chunk-VHFPZBUW.mjs.br +0 -0
  73. package/dist/chunk-VHFPZBUW.mjs.gz +0 -0
  74. package/dist/index.d.ts +30 -17
  75. package/dist/index.js +45 -45
  76. package/dist/index.js.br +0 -0
  77. package/dist/index.js.gz +0 -0
  78. package/dist/index.mjs +5 -5
  79. package/dist/index.mjs.br +0 -0
  80. package/dist/index.mjs.gz +0 -0
  81. package/dist/internals.d.ts +30 -17
  82. package/dist/internals.js +78 -78
  83. package/dist/internals.js.br +0 -0
  84. package/dist/internals.js.gz +0 -0
  85. package/dist/internals.mjs +3 -3
  86. package/dist/internals.mjs.br +0 -0
  87. package/dist/internals.mjs.gz +0 -0
  88. package/dist/viewer/index.d.ts +30 -17
  89. package/dist/viewer/index.js +26 -26
  90. package/dist/viewer/index.js.br +0 -0
  91. package/dist/viewer/index.js.gz +0 -0
  92. package/dist/viewer/index.mjs +5 -5
  93. package/dist/viewer/index.mjs.br +0 -0
  94. package/dist/viewer/index.mjs.gz +0 -0
  95. package/package.json +2 -2
  96. package/dist/AiChatPanel-BQSUE2OO.mjs.br +0 -0
  97. package/dist/AiChatPanel-BQSUE2OO.mjs.gz +0 -0
  98. package/dist/AiChatPanel-NSVSBJC7.js.br +0 -0
  99. package/dist/AiChatPanel-NSVSBJC7.js.gz +0 -0
  100. package/dist/Area3DChartScene-2FQHPGNE.mjs.gz +0 -0
  101. package/dist/Area3DChartScene-V3W2V7N5.js.gz +0 -0
  102. package/dist/Bar3DChartScene-55XMAUC7.js.br +0 -0
  103. package/dist/Bar3DChartScene-55XMAUC7.js.gz +0 -0
  104. package/dist/Bar3DChartScene-PSJEVANA.mjs.gz +0 -0
  105. package/dist/Line3DChartScene-5KACYRSQ.js.br +0 -0
  106. package/dist/Line3DChartScene-5KACYRSQ.js.gz +0 -0
  107. package/dist/Line3DChartScene-BUVNUFNO.mjs.gz +0 -0
  108. package/dist/Model3DScene-6U6TN36M.js.br +0 -0
  109. package/dist/Model3DScene-6U6TN36M.js.gz +0 -0
  110. package/dist/Model3DScene-REKMR2L6.mjs.gz +0 -0
  111. package/dist/PieChart3DScene-4L2VVIUJ.mjs.br +0 -0
  112. package/dist/PieChart3DScene-4L2VVIUJ.mjs.gz +0 -0
  113. package/dist/PieChart3DScene-MV3JF7EM.js.gz +0 -0
  114. package/dist/SurfaceChart3DScene-ARE7OBFI.mjs.br +0 -0
  115. package/dist/SurfaceChart3DScene-ARE7OBFI.mjs.gz +0 -0
  116. package/dist/SurfaceChart3DScene-SFIOK3G3.js.gz +0 -0
  117. package/dist/chunk-2Q2NFPXA.js.br +0 -0
  118. package/dist/chunk-2Q2NFPXA.js.gz +0 -0
  119. package/dist/chunk-DZ3HWACD.js.br +0 -0
  120. package/dist/chunk-DZ3HWACD.js.gz +0 -0
  121. package/dist/chunk-FHOUTYMB.js.br +0 -0
  122. package/dist/chunk-FHOUTYMB.js.gz +0 -0
  123. package/dist/chunk-HJZA3O3S.mjs.br +0 -0
  124. package/dist/chunk-HJZA3O3S.mjs.gz +0 -0
  125. package/dist/chunk-HYUPPQJW.js.br +0 -0
  126. package/dist/chunk-HYUPPQJW.js.gz +0 -0
  127. package/dist/chunk-KWHURCVT.mjs.br +0 -0
  128. package/dist/chunk-KWHURCVT.mjs.gz +0 -0
  129. package/dist/chunk-M6GIPAY4.mjs.br +0 -0
  130. package/dist/chunk-M6GIPAY4.mjs.gz +0 -0
  131. package/dist/chunk-T4ZRSRQZ.mjs.br +0 -0
  132. package/dist/chunk-T4ZRSRQZ.mjs.gz +0 -0
  133. package/dist/chunk-UKPGYJ7G.mjs.br +0 -0
  134. package/dist/chunk-UKPGYJ7G.mjs.gz +0 -0
  135. package/dist/chunk-XW46A7DN.js.br +0 -0
  136. package/dist/chunk-XW46A7DN.js.gz +0 -0
@@ -32079,6 +32079,39 @@ var init_smartart_interpreter_fold_text = __esm({
32079
32079
  init_smartart_node_text_projection();
32080
32080
  }
32081
32081
  });
32082
+ function buildConnectorLabels(connections) {
32083
+ if (!connections || connections.length === 0) {
32084
+ return void 0;
32085
+ }
32086
+ const labels = /* @__PURE__ */ new Map();
32087
+ for (const connection of connections) {
32088
+ if (!connection.label) {
32089
+ continue;
32090
+ }
32091
+ const isParentChildEdge = !connection.type || connection.type === "parOf";
32092
+ if (isParentChildEdge) {
32093
+ labels.set(`${connection.sourceId}>${connection.destId}`, connection.label);
32094
+ }
32095
+ }
32096
+ return labels.size > 0 ? labels : void 0;
32097
+ }
32098
+ function buildChildOrder(connections) {
32099
+ if (!connections || connections.length === 0) {
32100
+ return void 0;
32101
+ }
32102
+ const order = /* @__PURE__ */ new Map();
32103
+ for (const connection of connections) {
32104
+ const isParentChildEdge = !connection.type || connection.type === "parOf";
32105
+ if (isParentChildEdge && typeof connection.srcOrd === "number") {
32106
+ order.set(connection.destId, connection.srcOrd);
32107
+ }
32108
+ }
32109
+ return order.size > 0 ? order : void 0;
32110
+ }
32111
+ var init_smartart_layout_interpreter_connector_order = __esm({
32112
+ "src/core/utils/smartart-layout-interpreter-connector-order.ts"() {
32113
+ }
32114
+ });
32082
32115
  function topLevelSmartArtNodes(nodes) {
32083
32116
  const hasNestedChildren = nodes.some((n) => n.children !== void 0 && n.children.length > 0);
32084
32117
  if (hasNestedChildren) {
@@ -32091,16 +32124,22 @@ function smartArtDescendantsWithText(node, childrenOf) {
32091
32124
  const out = [];
32092
32125
  const walk2 = (current) => {
32093
32126
  for (const child262 of childrenOf.get(current.id) ?? []) {
32094
- if (child262.text.trim().length > 0) {
32095
- out.push(child262);
32096
- }
32127
+ out.push(child262);
32097
32128
  walk2(child262);
32098
32129
  }
32099
32130
  };
32100
32131
  walk2(node);
32101
- return out;
32132
+ let start = 0;
32133
+ while (start < out.length && out[start].text.trim().length === 0) {
32134
+ start++;
32135
+ }
32136
+ let end = out.length - 1;
32137
+ while (end >= start && out[end].text.trim().length === 0) {
32138
+ end--;
32139
+ }
32140
+ return out.slice(start, end + 1);
32102
32141
  }
32103
- function smartArtChildrenOf(nodes) {
32142
+ function smartArtChildrenOf(nodes, connections) {
32104
32143
  const map = /* @__PURE__ */ new Map();
32105
32144
  for (const n of nodes) {
32106
32145
  if (n.children && n.children.length > 0) {
@@ -32114,10 +32153,24 @@ function smartArtChildrenOf(nodes) {
32114
32153
  }
32115
32154
  }
32116
32155
  }
32156
+ const childOrder3 = connections ? buildChildOrder(connections) : void 0;
32157
+ if (childOrder3) {
32158
+ for (const [parentId, list] of map) {
32159
+ if (list.length > 1 && list.some((child262) => childOrder3.has(child262.id))) {
32160
+ map.set(
32161
+ parentId,
32162
+ list.map((node, originalIndex) => ({ node, originalIndex })).sort(
32163
+ (a, b) => (childOrder3.get(a.node.id) ?? a.originalIndex) - (childOrder3.get(b.node.id) ?? b.originalIndex)
32164
+ ).map((entry2) => entry2.node)
32165
+ );
32166
+ }
32167
+ }
32168
+ }
32117
32169
  return map;
32118
32170
  }
32119
32171
  var init_smartart_node_tree_axis = __esm({
32120
32172
  "src/core/utils/smartart-node-tree-axis.ts"() {
32173
+ init_smartart_layout_interpreter_connector_order();
32121
32174
  }
32122
32175
  });
32123
32176
  function polygonBoundingBox(points4) {
@@ -32130,9 +32183,9 @@ function polygonBoundingBox(points4) {
32130
32183
  const maxY = Math.max(...ys);
32131
32184
  return { x: minX, y: minY, width: Math.max(1, maxX - minX), height: Math.max(1, maxY - minY) };
32132
32185
  }
32133
- function interpretedLayoutToElements(result, nodes, containerBounds, bulletEnabled = false) {
32186
+ function interpretedLayoutToElements(result, nodes, containerBounds, bulletEnabled = false, connections) {
32134
32187
  const nodeById = new Map(nodes.map((n) => [n.id, n]));
32135
- const childrenOf = smartArtChildrenOf(nodes);
32188
+ const childrenOf = smartArtChildrenOf(nodes, connections);
32136
32189
  const renderedIds = new Set(
32137
32190
  result.nodes.flatMap((r) => [r.nodeId, ...r.foldedNodeIds ?? []]).filter((id) => Boolean(id))
32138
32191
  );
@@ -32358,39 +32411,6 @@ var init_smartart_hierarchy_child_order = __esm({
32358
32411
  "src/core/utils/smartart-hierarchy-child-order.ts"() {
32359
32412
  }
32360
32413
  });
32361
- function buildConnectorLabels(connections) {
32362
- if (!connections || connections.length === 0) {
32363
- return void 0;
32364
- }
32365
- const labels = /* @__PURE__ */ new Map();
32366
- for (const connection of connections) {
32367
- if (!connection.label) {
32368
- continue;
32369
- }
32370
- const isParentChildEdge = !connection.type || connection.type === "parOf";
32371
- if (isParentChildEdge) {
32372
- labels.set(`${connection.sourceId}>${connection.destId}`, connection.label);
32373
- }
32374
- }
32375
- return labels.size > 0 ? labels : void 0;
32376
- }
32377
- function buildChildOrder(connections) {
32378
- if (!connections || connections.length === 0) {
32379
- return void 0;
32380
- }
32381
- const order = /* @__PURE__ */ new Map();
32382
- for (const connection of connections) {
32383
- const isParentChildEdge = !connection.type || connection.type === "parOf";
32384
- if (isParentChildEdge && typeof connection.srcOrd === "number") {
32385
- order.set(connection.destId, connection.srcOrd);
32386
- }
32387
- }
32388
- return order.size > 0 ? order : void 0;
32389
- }
32390
- var init_smartart_layout_interpreter_connector_order = __esm({
32391
- "src/core/utils/smartart-layout-interpreter-connector-order.ts"() {
32392
- }
32393
- });
32394
32414
  function parsePoints(points4) {
32395
32415
  return points4.trim().split(/\s+/u).filter((pair) => pair.length > 0).map((pair) => {
32396
32416
  const [x, y] = pair.split(",").map(Number);
@@ -32501,163 +32521,6 @@ var init_smartart_layout_interpreter_custom = __esm({
32501
32521
  "src/core/utils/smartart-layout-interpreter-custom.ts"() {
32502
32522
  }
32503
32523
  });
32504
- function arrowHeadPath(tipX, tipY, ux, uy) {
32505
- const bx = tipX - ux * ARROW_HEAD;
32506
- const by = tipY - uy * ARROW_HEAD;
32507
- const px3 = -uy;
32508
- const py = ux;
32509
- const w1x = bx + px3 * ARROW_WING;
32510
- const w1y = by + py * ARROW_WING;
32511
- const w2x = bx - px3 * ARROW_WING;
32512
- const w2y = by - py * ARROW_WING;
32513
- return ` M${w1x},${w1y} L${tipX},${tipY} L${w2x},${w2y}`;
32514
- }
32515
- function endHeads(x0, y0, x1, y1, begSty, endSty) {
32516
- const dx = x1 - x0;
32517
- const dy = y1 - y0;
32518
- const len = Math.hypot(dx, dy);
32519
- if (len < 1e-6) {
32520
- return "";
32521
- }
32522
- const ux = dx / len;
32523
- const uy = dy / len;
32524
- let heads = "";
32525
- if (endSty === "arr") {
32526
- heads += arrowHeadPath(x1, y1, ux, uy);
32527
- }
32528
- if (begSty === "arr") {
32529
- heads += arrowHeadPath(x0, y0, -ux, -uy);
32530
- }
32531
- return heads;
32532
- }
32533
- function straightPath(x0, y0, x1, y1) {
32534
- return `M${x0},${y0} L${x1},${y1}`;
32535
- }
32536
- function elbowPath(x0, y0, x1, y1) {
32537
- if (Math.abs(x1 - x0) >= Math.abs(y1 - y0)) {
32538
- const midX = (x0 + x1) / 2;
32539
- return `M${x0},${y0} L${midX},${y0} L${midX},${y1} L${x1},${y1}`;
32540
- }
32541
- const midY = (y0 + y1) / 2;
32542
- return `M${x0},${y0} L${x0},${midY} L${x1},${midY} L${x1},${y1}`;
32543
- }
32544
- function curvePath(x0, y0, x1, y1, centre) {
32545
- const midX = (x0 + x1) / 2;
32546
- const midY = (y0 + y1) / 2;
32547
- const pull = 1 + 30 / Math.max(1, Math.hypot(midX - centre.x, midY - centre.y));
32548
- const controlX = centre.x + (midX - centre.x) * pull;
32549
- const controlY = centre.y + (midY - centre.y) * pull;
32550
- return `M${x0},${y0} Q${controlX},${controlY} ${x1},${y1}`;
32551
- }
32552
- function connectorPath(x0, y0, x1, y1, centre, routing, begSty, endSty) {
32553
- const body = routing === "bend" ? elbowPath(x0, y0, x1, y1) : routing === "curve" ? curvePath(x0, y0, x1, y1, centre) : straightPath(x0, y0, x1, y1);
32554
- return body + endHeads(x0, y0, x1, y1, begSty, endSty);
32555
- }
32556
- function connectorEndpoints(from, to, horizontal, dim) {
32557
- const fromCx = from.x + from.width / 2;
32558
- const fromCy = from.y + from.height / 2;
32559
- const toCx = to.x + to.width / 2;
32560
- const toCy = to.y + to.height / 2;
32561
- if (dim === "2D") {
32562
- return { x0: fromCx, y0: fromCy, x1: toCx, y1: toCy };
32563
- }
32564
- if (horizontal) {
32565
- const leftFirst = fromCx <= toCx;
32566
- return leftFirst ? { x0: from.x + from.width, y0: fromCy, x1: to.x, y1: toCy } : { x0: from.x, y0: fromCy, x1: to.x + to.width, y1: toCy };
32567
- }
32568
- const topFirst = fromCy <= toCy;
32569
- return topFirst ? { x0: fromCx, y0: from.y + from.height, x1: toCx, y1: to.y } : { x0: fromCx, y0: from.y, x1: toCx, y1: to.y + to.height };
32570
- }
32571
- var ARROW_WING;
32572
- var ARROW_HEAD;
32573
- var init_smartart_layout_interpreter_conn_path = __esm({
32574
- "src/core/utils/smartart-layout-interpreter-conn-path.ts"() {
32575
- ARROW_WING = 4;
32576
- ARROW_HEAD = 7;
32577
- }
32578
- });
32579
- function resolveConstraintDeclaredBy(index, role, type, declaringRole) {
32580
- const candidates = index.entries.get(entryKey(role, type));
32581
- const fromArranger = candidates?.filter(
32582
- (c) => c.declaringRole === declaringRole
32583
- );
32584
- if (!fromArranger || fromArranger.length === 0) {
32585
- return void 0;
32586
- }
32587
- const visiting = /* @__PURE__ */ new Set([entryKey(role, type)]);
32588
- for (const candidate of fromArranger) {
32589
- const value = resolveEntry(index, candidate, visiting);
32590
- if (value !== void 0) {
32591
- return value;
32592
- }
32593
- }
32594
- return void 0;
32595
- }
32596
- function firstConstraintDeclaredBy(index, role, type, declaringRole) {
32597
- const candidates = index.entries.get(entryKey(role, type));
32598
- return candidates?.find((candidate) => candidate.declaringRole === declaringRole)?.constraint;
32599
- }
32600
- var init_smartart_constraint_declared_by = __esm({
32601
- "src/core/utils/smartart-constraint-declared-by.ts"() {
32602
- init_smartart_constraint_solver();
32603
- }
32604
- });
32605
- function isTransitionOnlyChild(node) {
32606
- const origin = node.forEachOrigin;
32607
- if (!origin) {
32608
- return false;
32609
- }
32610
- if (origin.axis?.includes("followSib") || origin.axis?.includes("follow")) {
32611
- return true;
32612
- }
32613
- const pointTypes = origin.pointTypes;
32614
- return (pointTypes?.length ?? 0) > 0 && (pointTypes?.every((type) => type === "sibTrans" || type === "parTrans") ?? false);
32615
- }
32616
- function isContinuationForEach(node) {
32617
- const forEach = node.forEach ?? [];
32618
- if (forEach.length === 0) {
32619
- return false;
32620
- }
32621
- return forEach.every(
32622
- (each) => each.axis?.length === 1 && each.axis[0] === "ch" && (each.start?.[0] ?? 1) > 1
32623
- );
32624
- }
32625
- function hasStructuralDescendant(node) {
32626
- return (node.children ?? []).some(
32627
- (child262) => STRUCTURAL_ALG_TYPES.has(child262.algorithm?.type ?? "") && !isContinuationForEach(child262) || hasStructuralDescendant(child262)
32628
- );
32629
- }
32630
- function mapsSlots(node) {
32631
- const declaredByArranger = (node.allConstraints ?? node.constraints ?? []).some(
32632
- (constraint) => constraint.for === "ch" && SLOT_CONSTRAINTS.has(constraint.type)
32633
- );
32634
- if (declaredByArranger) {
32635
- return true;
32636
- }
32637
- return (node.children ?? []).some(
32638
- (child262) => (child262.constraints ?? []).some((constraint) => SLOT_CONSTRAINTS.has(constraint.type))
32639
- );
32640
- }
32641
- function itemTemplateNodes(node, out) {
32642
- const drivesPoints = node.forEach?.some(
32643
- (each) => each.axis?.length === 1 && each.axis[0] === "ch" && (!each.pointTypes || each.pointTypes.includes("node"))
32644
- );
32645
- const item = node.children?.[0];
32646
- if (drivesPoints && item) {
32647
- out.add(item);
32648
- }
32649
- for (const child262 of node.children ?? []) {
32650
- itemTemplateNodes(child262, out);
32651
- }
32652
- }
32653
- var SLOT_CONSTRAINTS;
32654
- var STRUCTURAL_ALG_TYPES;
32655
- var init_smartart_layout_interpreter_composite_detect = __esm({
32656
- "src/core/utils/smartart-layout-interpreter-composite-detect.ts"() {
32657
- SLOT_CONSTRAINTS = /* @__PURE__ */ new Set(["l", "t", "w", "h", "ctrX", "ctrY"]);
32658
- STRUCTURAL_ALG_TYPES = /* @__PURE__ */ new Set(["lin", "cycle", "pyra", "snake", "hierRoot", "hierChild"]);
32659
- }
32660
- });
32661
32524
  function children2(node, name, localName28) {
32662
32525
  const key2 = Object.keys(node).find((candidate) => localName28(candidate) === name);
32663
32526
  const value = key2 ? node[key2] : void 0;
@@ -32967,11 +32830,19 @@ function selectRange(nodes, start, count) {
32967
32830
  const take = count !== void 0 && count > 0 ? count : nodes.length - zeroBasedStart;
32968
32831
  return nodes.slice(zeroBasedStart, zeroBasedStart + take);
32969
32832
  }
32833
+ function applyPointTypeAndRange(nodes, pointType2, start, count) {
32834
+ const filtered = pointType2 ? nodes.filter((n) => pointTypeMatches(n, pointType2)) : nodes;
32835
+ return selectRange(filtered, start, count);
32836
+ }
32970
32837
  function resolveAxisNodes(nodes, axis, pointTypes, start, count, context) {
32971
32838
  if (axis.length === 0) {
32972
32839
  return void 0;
32973
32840
  }
32974
- if (context === void 0 && axis[0] !== "ch" && axis[0] !== "self") {
32841
+ const rootRelative = context === void 0;
32842
+ if (rootRelative && axis[0] !== "ch" && axis[0] !== "self" && axis[0] !== "root") {
32843
+ return void 0;
32844
+ }
32845
+ if (rootRelative && axis[0] === "root" && axis.length > 1 && axis[1] !== "ch") {
32975
32846
  return void 0;
32976
32847
  }
32977
32848
  const byId = new Map(nodes.map((n) => [n.id, n]));
@@ -32990,16 +32861,30 @@ function resolveAxisNodes(nodes, axis, pointTypes, start, count, context) {
32990
32861
  }
32991
32862
  }
32992
32863
  const roots = nodes.filter((n) => !n.parentId || !byId.has(n.parentId));
32993
- let current = context !== void 0 ? navigateAxisHop(context, axis[0], nodes, childrenOf, parentOf, roots) : roots;
32994
- for (let hop = 0; hop < axis.length; hop += 1) {
32995
- if (hop > 0) {
32996
- current = navigateAxisHop(current, axis[hop], nodes, childrenOf, parentOf, roots);
32997
- }
32998
- const pointType2 = pointTypes?.[hop];
32999
- if (pointType2) {
33000
- current = current.filter((n) => pointTypeMatches(n, pointType2));
33001
- }
33002
- current = selectRange(current, start?.[hop], count?.[hop]);
32864
+ let current;
32865
+ let nextHop;
32866
+ if (context !== void 0) {
32867
+ current = applyPointTypeAndRange(
32868
+ navigateAxisHop(context, axis[0], nodes, childrenOf, parentOf, roots),
32869
+ pointTypes?.[0],
32870
+ start?.[0],
32871
+ count?.[0]
32872
+ );
32873
+ nextHop = 1;
32874
+ } else if (axis[0] === "root" && axis.length > 1) {
32875
+ current = applyPointTypeAndRange(roots, pointTypes?.[1], start?.[1], count?.[1]);
32876
+ nextHop = 2;
32877
+ } else {
32878
+ current = applyPointTypeAndRange(roots, pointTypes?.[0], start?.[0], count?.[0]);
32879
+ nextHop = 1;
32880
+ }
32881
+ for (let hop = nextHop; hop < axis.length; hop += 1) {
32882
+ current = applyPointTypeAndRange(
32883
+ navigateAxisHop(current, axis[hop], nodes, childrenOf, parentOf, roots),
32884
+ pointTypes?.[hop],
32885
+ start?.[hop],
32886
+ count?.[hop]
32887
+ );
33003
32888
  }
33004
32889
  return current;
33005
32890
  }
@@ -33194,14 +33079,178 @@ var init_smartart_layout_interpreter_choose_branch = __esm({
33194
33079
  localName6 = (key2) => key2.split(":").pop() ?? key2;
33195
33080
  }
33196
33081
  });
33197
- function boundedCompositeAlg(raw, nodeCount, context) {
33198
- if (!raw) {
33199
- return void 0;
33082
+ function isTransitionOnlyChild(node) {
33083
+ const origin = node.forEachOrigin;
33084
+ if (!origin) {
33085
+ return false;
33200
33086
  }
33201
- let found;
33202
- const visit = (value) => {
33203
- if (found !== void 0 || !value || typeof value !== "object") {
33204
- return;
33087
+ if (origin.axis?.includes("followSib") || origin.axis?.includes("follow")) {
33088
+ return true;
33089
+ }
33090
+ const pointTypes = origin.pointTypes;
33091
+ return (pointTypes?.length ?? 0) > 0 && (pointTypes?.every((type) => type === "sibTrans" || type === "parTrans") ?? false);
33092
+ }
33093
+ function isContinuationForEach(node) {
33094
+ const forEach = node.forEach ?? [];
33095
+ if (forEach.length === 0) {
33096
+ return false;
33097
+ }
33098
+ return forEach.every(
33099
+ (each) => each.axis?.length === 1 && each.axis[0] === "ch" && (each.start?.[0] ?? 1) > 1
33100
+ );
33101
+ }
33102
+ function hasStructuralDescendant(node) {
33103
+ return (node.children ?? []).some(
33104
+ (child262) => STRUCTURAL_ALG_TYPES.has(child262.algorithm?.type ?? "") && !isContinuationForEach(child262) || hasStructuralDescendant(child262)
33105
+ );
33106
+ }
33107
+ function mapsSlots(node) {
33108
+ const declaredByArranger = (node.allConstraints ?? node.constraints ?? []).some(
33109
+ (constraint) => constraint.for === "ch" && SLOT_CONSTRAINTS.has(constraint.type)
33110
+ );
33111
+ if (declaredByArranger) {
33112
+ return true;
33113
+ }
33114
+ return (node.children ?? []).some(
33115
+ (child262) => (child262.constraints ?? []).some((constraint) => SLOT_CONSTRAINTS.has(constraint.type))
33116
+ );
33117
+ }
33118
+ function itemTemplateNodes(node, out) {
33119
+ const drivesPoints = node.forEach?.some(
33120
+ (each) => each.axis?.length === 1 && each.axis[0] === "ch" && (!each.pointTypes || each.pointTypes.includes("node"))
33121
+ );
33122
+ const item = node.children?.[0];
33123
+ if (drivesPoints && item) {
33124
+ out.add(item);
33125
+ }
33126
+ for (const child262 of node.children ?? []) {
33127
+ itemTemplateNodes(child262, out);
33128
+ }
33129
+ }
33130
+ function isLayoutNodeOrDescendantOf(ancestor, node) {
33131
+ if (ancestor === node) {
33132
+ return true;
33133
+ }
33134
+ return (ancestor.children ?? []).some((child262) => isLayoutNodeOrDescendantOf(child262, node));
33135
+ }
33136
+ var SLOT_CONSTRAINTS;
33137
+ var STRUCTURAL_ALG_TYPES;
33138
+ var init_smartart_layout_interpreter_composite_detect = __esm({
33139
+ "src/core/utils/smartart-layout-interpreter-composite-detect.ts"() {
33140
+ SLOT_CONSTRAINTS = /* @__PURE__ */ new Set(["l", "t", "w", "h", "ctrX", "ctrY"]);
33141
+ STRUCTURAL_ALG_TYPES = /* @__PURE__ */ new Set(["lin", "cycle", "pyra", "snake", "hierRoot", "hierChild"]);
33142
+ }
33143
+ });
33144
+ function findStructuralAlgDepth(raw, crossedNames, nodeCount, context) {
33145
+ if (!raw || typeof raw !== "object") {
33146
+ return void 0;
33147
+ }
33148
+ if (Array.isArray(raw)) {
33149
+ for (const item of raw) {
33150
+ const found = findStructuralAlgDepth(item, crossedNames, nodeCount, context);
33151
+ if (found) {
33152
+ return found;
33153
+ }
33154
+ }
33155
+ return void 0;
33156
+ }
33157
+ for (const [key2, entry2] of Object.entries(raw)) {
33158
+ if (key2.startsWith("@_")) {
33159
+ continue;
33160
+ }
33161
+ const name = localName6(key2);
33162
+ if (name === "alg") {
33163
+ for (const candidate of Array.isArray(entry2) ? entry2 : [entry2]) {
33164
+ const type = candidate && typeof candidate === "object" ? String(candidate["@_type"] ?? "") : "";
33165
+ if (STRUCTURAL_CHOOSE_ALG_TYPES.has(type)) {
33166
+ return { depth: crossedNames.length, crossedNames: [...crossedNames] };
33167
+ }
33168
+ }
33169
+ } else if (name === "layoutNode") {
33170
+ for (const candidate of Array.isArray(entry2) ? entry2 : [entry2]) {
33171
+ if (!candidate || typeof candidate !== "object") {
33172
+ continue;
33173
+ }
33174
+ const crossedName = String(candidate["@_name"] ?? "");
33175
+ const found = findStructuralAlgDepth(
33176
+ candidate,
33177
+ [...crossedNames, crossedName],
33178
+ nodeCount,
33179
+ context
33180
+ );
33181
+ if (found) {
33182
+ return found;
33183
+ }
33184
+ }
33185
+ } else if (name === "choose") {
33186
+ for (const candidate of Array.isArray(entry2) ? entry2 : [entry2]) {
33187
+ if (!candidate || typeof candidate !== "object") {
33188
+ continue;
33189
+ }
33190
+ const winningBranch = nestedChooseBranch(candidate, nodeCount, context);
33191
+ if (winningBranch) {
33192
+ const found = findStructuralAlgDepth(winningBranch, crossedNames, nodeCount, context);
33193
+ if (found) {
33194
+ return found;
33195
+ }
33196
+ }
33197
+ }
33198
+ } else if (entry2 && typeof entry2 === "object") {
33199
+ const found = findStructuralAlgDepth(entry2, crossedNames, nodeCount, context);
33200
+ if (found) {
33201
+ return found;
33202
+ }
33203
+ }
33204
+ }
33205
+ return void 0;
33206
+ }
33207
+ function structuralChooseAlgDepth(node, nodeCount, context) {
33208
+ if (!node.choose || node.choose.length === 0) {
33209
+ return void 0;
33210
+ }
33211
+ for (const choose of node.choose) {
33212
+ const branch = activeBranch(choose, nodeCount, context);
33213
+ if (branch === void 0) {
33214
+ continue;
33215
+ }
33216
+ const found = findStructuralAlgDepth(branch, [], nodeCount, context);
33217
+ if (found) {
33218
+ return found;
33219
+ }
33220
+ }
33221
+ return void 0;
33222
+ }
33223
+ function tunnelsPastOwnCompositeSlot(node, nodeCount, context, itemTemplates) {
33224
+ const looksLikeOwnComposite = node.algorithm?.type === "composite" && !itemTemplates.has(node) && !hasStructuralDescendant(node) && mapsSlots(node);
33225
+ if (!looksLikeOwnComposite) {
33226
+ return false;
33227
+ }
33228
+ const found = structuralChooseAlgDepth(node, nodeCount, context);
33229
+ return found !== void 0 && found.depth >= 2;
33230
+ }
33231
+ var STRUCTURAL_CHOOSE_ALG_TYPES;
33232
+ var init_smartart_layout_interpreter_choose_depth = __esm({
33233
+ "src/core/utils/smartart-layout-interpreter-choose-depth.ts"() {
33234
+ init_smartart_layout_interpreter_choose_branch();
33235
+ init_smartart_layout_interpreter_composite_detect();
33236
+ STRUCTURAL_CHOOSE_ALG_TYPES = /* @__PURE__ */ new Set([
33237
+ "lin",
33238
+ "cycle",
33239
+ "pyra",
33240
+ "snake",
33241
+ "hierChild",
33242
+ "hierRoot"
33243
+ ]);
33244
+ }
33245
+ });
33246
+ function boundedCompositeAlg(raw, nodeCount, context) {
33247
+ if (!raw) {
33248
+ return void 0;
33249
+ }
33250
+ let found;
33251
+ const visit = (value) => {
33252
+ if (found !== void 0 || !value || typeof value !== "object") {
33253
+ return;
33205
33254
  }
33206
33255
  if (Array.isArray(value)) {
33207
33256
  value.forEach(visit);
@@ -33427,6 +33476,13 @@ var init_smartart_layout_interpreter_flow = __esm({
33427
33476
  NODE_POINT_TYPES = /* @__PURE__ */ new Set(["node", "norm", "nonNorm", "asst", "nonAsst", "doc", "all"]);
33428
33477
  }
33429
33478
  });
33479
+ function hasPositionGuard(node) {
33480
+ return node.chooseGuard?.some((guard) => guard.function === "pos") ?? false;
33481
+ }
33482
+ var init_smartart_layout_interpreter_position_family = __esm({
33483
+ "src/core/utils/smartart-layout-interpreter-position-family.ts"() {
33484
+ }
33485
+ });
33430
33486
  function walkWithTreeLocation(node, visit, location = { position: 1, total: 1, depth: 0 }) {
33431
33487
  visit(node, location);
33432
33488
  const children12 = node.children ?? [];
@@ -33490,6 +33546,33 @@ var init_smartart_layout_interpreter_constraints = __esm({
33490
33546
  "src/core/utils/smartart-layout-interpreter-constraints.ts"() {
33491
33547
  }
33492
33548
  });
33549
+ function itemNode(arranger) {
33550
+ return arranger.children?.[0];
33551
+ }
33552
+ function algorithmParam(node, type) {
33553
+ return node.algorithm?.parameters?.find((param) => param.type === type)?.value;
33554
+ }
33555
+ function numericParam(node, type, fallback) {
33556
+ const raw = algorithmParam(node, type);
33557
+ if (raw === void 0) {
33558
+ return fallback;
33559
+ }
33560
+ const parsed = Number(raw);
33561
+ return Number.isFinite(parsed) ? parsed : fallback;
33562
+ }
33563
+ function resolveFlowDirection(arranger, presLayoutVars) {
33564
+ const linDir = algorithmParam(arranger, "linDir");
33565
+ const vertical = linDir === "fromT" || linDir === "fromB";
33566
+ let reverse = linDir === "fromR" || linDir === "fromB";
33567
+ if (presLayoutVars?.direction === "rev") {
33568
+ reverse = !reverse;
33569
+ }
33570
+ return { orientation: vertical ? "vertical" : "horizontal", reverse };
33571
+ }
33572
+ var init_smartart_layout_interpreter_flow_direction = __esm({
33573
+ "src/core/utils/smartart-layout-interpreter-flow-direction.ts"() {
33574
+ }
33575
+ });
33493
33576
  function isMeaningfulAux(node) {
33494
33577
  return (node.constraints?.length ?? 0) > 0 || (node.children?.length ?? 0) > 0;
33495
33578
  }
@@ -33502,26 +33585,38 @@ function discoverArrangement(definition, nodeCount, presLayoutVars, flatNodes) {
33502
33585
  const maxDepth = treeMaxDepth(definition.rootNode);
33503
33586
  const itemTemplates = /* @__PURE__ */ new Set();
33504
33587
  itemTemplateNodes(definition.rootNode, itemTemplates);
33588
+ const blockedSubtreeRoots = [];
33505
33589
  walkWithTreeLocation(definition.rootNode, (node, location) => {
33506
- if (!hierarchy && !chosen && nodeCount !== void 0 && node.choose && node.choose.length > 0 && !isContinuationForEach(node)) {
33507
- const resolvedAlg = chooseAlgorithm(node, nodeCount, {
33590
+ if (!hierarchy && !chosen && nodeCount !== void 0 && node.choose && node.choose.length > 0 && !isContinuationForEach(node) && !blockedSubtreeRoots.some((root) => isLayoutNodeOrDescendantOf(root, node))) {
33591
+ const whenContext = {
33508
33592
  presLayoutVars,
33509
33593
  position: location.position,
33510
33594
  total: location.total,
33511
33595
  depth: location.depth,
33512
33596
  maxDepth,
33513
33597
  nodes: flatNodes
33514
- });
33598
+ };
33599
+ const resolvedAlg = chooseAlgorithm(node, nodeCount, whenContext);
33515
33600
  const type2 = resolvedAlg?.type;
33516
33601
  if (type2 === "hierRoot" || type2 === "hierChild") {
33517
33602
  hierarchy = node.children?.find((child262) => child262.algorithm?.type === type2) ?? node;
33518
33603
  } else {
33519
33604
  const withResolvedAlg = resolvedAlg ? { ...node, algorithm: resolvedAlg } : node;
33520
33605
  const kind2 = type2 ? PRIMARY_ALG[type2] : void 0;
33521
- const arranger = node.children?.find(
33606
+ const rawArranger = node.children?.find(
33522
33607
  (child262) => child262.algorithm?.type === type2 && !isTransitionOnlyChild(child262) && !isContinuationForEach(child262)
33523
- ) ?? withResolvedAlg;
33524
- if (kind2 && STRUCTURAL_ARRANGEMENT_KINDS.has(kind2)) {
33608
+ );
33609
+ const arranger = rawArranger && !hasPositionGuard(rawArranger) ? rawArranger : withResolvedAlg;
33610
+ const tunnelledPastOwnSlot = tunnelsPastOwnCompositeSlot(
33611
+ node,
33612
+ nodeCount,
33613
+ whenContext,
33614
+ itemTemplates
33615
+ );
33616
+ if (tunnelledPastOwnSlot) {
33617
+ blockedSubtreeRoots.push(node);
33618
+ }
33619
+ if (kind2 && STRUCTURAL_ARRANGEMENT_KINDS.has(kind2) && !tunnelledPastOwnSlot) {
33525
33620
  chosen = { kind: kind2, node: arranger };
33526
33621
  } else if (kind2 === "composite" && !itemTemplates.has(arranger) && mapsSlots(arranger)) {
33527
33622
  chosen = { kind: kind2, node: arranger };
@@ -33546,101 +33641,400 @@ function discoverArrangement(definition, nodeCount, presLayoutVars, flatNodes) {
33546
33641
  }
33547
33642
  return;
33548
33643
  }
33549
- if (STRUCTURAL_ARRANGEMENT_KINDS.has(kind)) {
33550
- if (!isContinuationForEach(node)) {
33551
- structural ??= { kind, node };
33552
- }
33553
- return;
33644
+ if (STRUCTURAL_ARRANGEMENT_KINDS.has(kind)) {
33645
+ if (!isContinuationForEach(node)) {
33646
+ structural ??= { kind, node };
33647
+ }
33648
+ return;
33649
+ }
33650
+ if (!aux && isMeaningfulAux(node)) {
33651
+ aux = { kind, node };
33652
+ }
33653
+ });
33654
+ if (hierarchy) {
33655
+ return { kind: "hierarchy", node: hierarchy };
33656
+ }
33657
+ if (chosen) {
33658
+ return chosen;
33659
+ }
33660
+ if (compositeSlot) {
33661
+ return { kind: "composite", node: compositeSlot };
33662
+ }
33663
+ return structural ?? aux;
33664
+ }
33665
+ var PRIMARY_ALG;
33666
+ var STRUCTURAL_ARRANGEMENT_KINDS;
33667
+ var init_smartart_layout_interpreter_model = __esm({
33668
+ "src/core/utils/smartart-layout-interpreter-model.ts"() {
33669
+ init_smartart_layout_interpreter_choose_depth();
33670
+ init_smartart_layout_interpreter_composite_detect();
33671
+ init_smartart_layout_interpreter_flow();
33672
+ init_smartart_layout_interpreter_position_family();
33673
+ init_smartart_layout_interpreter_tree_location();
33674
+ init_smartart_layout_interpreter_constraints();
33675
+ init_smartart_layout_interpreter_position_family();
33676
+ init_smartart_layout_interpreter_flow_direction();
33677
+ PRIMARY_ALG = {
33678
+ lin: "linear",
33679
+ cycle: "cycle",
33680
+ pyra: "pyramid",
33681
+ snake: "snake",
33682
+ composite: "composite",
33683
+ conn: "conn",
33684
+ sp: "spacer",
33685
+ tx: "text"
33686
+ };
33687
+ STRUCTURAL_ARRANGEMENT_KINDS = /* @__PURE__ */ new Set([
33688
+ "linear",
33689
+ "cycle",
33690
+ "pyramid",
33691
+ "snake"
33692
+ ]);
33693
+ }
33694
+ });
33695
+ function resolveReferencedRatio(index, role, types, rules) {
33696
+ for (const type of types) {
33697
+ const candidates = index.entries.get(entryKey(role, type));
33698
+ if (!candidates?.some((entry2) => hasReference(entry2.constraint))) {
33699
+ continue;
33700
+ }
33701
+ const resolved = resolveConstraint(index, role, type);
33702
+ if (resolved !== void 0) {
33703
+ return clampByRules(resolved, rules, type);
33704
+ }
33705
+ }
33706
+ return void 0;
33707
+ }
33708
+ function resolveRatioConstraint(constraints, index, role, types, fallback, rules) {
33709
+ const literal = ratioConstraint(constraints, types, Number.NaN, rules);
33710
+ if (!Number.isNaN(literal)) {
33711
+ return literal;
33712
+ }
33713
+ const relative = resolveReferencedRatio(index, role, types, rules);
33714
+ return relative ?? fallback;
33715
+ }
33716
+ var init_smartart_constraint_ratio_fallback = __esm({
33717
+ "src/core/utils/smartart-constraint-ratio-fallback.ts"() {
33718
+ init_smartart_constraint_solver();
33719
+ init_smartart_layout_interpreter_model();
33720
+ }
33721
+ });
33722
+ function resolveHubToNodeRatio(ringItem, arrangerConstraints) {
33723
+ if (!ringItem?.name) {
33724
+ return void 0;
33725
+ }
33726
+ const match = (arrangerConstraints ?? []).find(
33727
+ (c) => c.type === "w" && c.forName === ringItem.name && c.referenceType === "w" && (c.factor === void 0 || typeof c.factor === "number" && c.factor > 0) && typeof c.referenceForName === "string"
33728
+ );
33729
+ if (!match) {
33730
+ return void 0;
33731
+ }
33732
+ return { hubName: match.referenceForName, factor: match.factor ?? 1 };
33733
+ }
33734
+ function resolveHubGapRatio(itemName, hubRatio, arrangerConstraints) {
33735
+ if (!hubRatio) {
33736
+ return void 0;
33737
+ }
33738
+ const sp = (arrangerConstraints ?? []).find(
33739
+ (c) => c.type === "sp" && typeof c.factor === "number" && typeof c.referenceForName === "string"
33740
+ );
33741
+ if (!sp || typeof sp.factor !== "number") {
33742
+ return void 0;
33743
+ }
33744
+ if (sp.referenceForName === itemName) {
33745
+ return sp.factor;
33746
+ }
33747
+ if (sp.referenceForName === hubRatio.hubName) {
33748
+ return sp.factor / hubRatio.factor;
33749
+ }
33750
+ return void 0;
33751
+ }
33752
+ var init_smartart_layout_interpreter_cycle_hub_ratio = __esm({
33753
+ "src/core/utils/smartart-layout-interpreter-cycle-hub-ratio.ts"() {
33754
+ }
33755
+ });
33756
+ function deriveCompositeSelfChildLayout(item) {
33757
+ if (!item || item.algorithm?.type !== "composite") {
33758
+ return void 0;
33759
+ }
33760
+ const constraints = item.allConstraints ?? item.constraints ?? [];
33761
+ for (const width of constraints) {
33762
+ if (width.type !== "w" || width.for !== "ch" || !width.forName || width.referenceForName !== void 0 || typeof width.factor !== "number" || width.factor <= 0) {
33763
+ continue;
33764
+ }
33765
+ const selfName = width.forName;
33766
+ const isSelfSquare = constraints.some(
33767
+ (c) => c.type === "h" && c.for === "ch" && c.forName === selfName && c.referenceType === "w" && c.referenceFor === "ch" && c.referenceForName === selfName
33768
+ );
33769
+ if (!isSelfSquare) {
33770
+ continue;
33771
+ }
33772
+ const childLeft = constraints.find(
33773
+ (c) => c.type === "l" && c.for === "ch" && c.forName !== void 0 && c.forName !== selfName && c.referenceType === "w" && c.referenceFor === "ch" && c.referenceForName === selfName && typeof c.factor === "number"
33774
+ );
33775
+ const childName = childLeft?.forName;
33776
+ const childWidth = childName ? constraints.find(
33777
+ (c) => c.type === "w" && c.for === "ch" && c.forName === childName && c.referenceForName === void 0 && typeof c.factor === "number"
33778
+ ) : void 0;
33779
+ return {
33780
+ selfName,
33781
+ selfWidthFactor: width.factor,
33782
+ childName,
33783
+ childLeftFactor: childLeft?.factor,
33784
+ childWidthFactor: childWidth?.factor
33785
+ };
33786
+ }
33787
+ return void 0;
33788
+ }
33789
+ function resolveGraphAspectRatio(item, index) {
33790
+ if (!item) {
33791
+ return void 0;
33792
+ }
33793
+ const role = roleOf(item);
33794
+ const resolvedH = resolveConstraint(index, role, "h");
33795
+ const resolvedW = resolveConstraint(index, role, "w");
33796
+ if (resolvedH === void 0 || resolvedW === void 0 || resolvedW <= 0) {
33797
+ return void 0;
33798
+ }
33799
+ return resolvedH / resolvedW;
33800
+ }
33801
+ var init_smartart_layout_interpreter_cycle_item_aspect = __esm({
33802
+ "src/core/utils/smartart-layout-interpreter-cycle-item-aspect.ts"() {
33803
+ init_smartart_constraint_solver();
33804
+ }
33805
+ });
33806
+ function absoluteConstraintPoints(constraint) {
33807
+ if (constraint === void 0 || constraint.factor !== void 0 || constraint.referenceType !== void 0 || typeof constraint.value !== "number" || !Number.isFinite(constraint.value) || constraint.value < 1) {
33808
+ return void 0;
33809
+ }
33810
+ return constraint.value;
33811
+ }
33812
+ function resolveCycleConstraintNode(arrangerNode) {
33813
+ if (arrangerNode.name === "cycle") {
33814
+ return arrangerNode;
33815
+ }
33816
+ for (const child262 of arrangerNode.children ?? []) {
33817
+ if (child262.name === "cycle") {
33818
+ return child262;
33819
+ }
33820
+ }
33821
+ return arrangerNode;
33822
+ }
33823
+ function resolveRingItemNode(constraintNode, arrangerConstraints) {
33824
+ const sibSpName = (arrangerConstraints ?? []).find(
33825
+ (c) => c.type === "sibSp" && typeof c.referenceForName === "string"
33826
+ )?.referenceForName;
33827
+ const named = sibSpName ? (constraintNode.children ?? []).find((child262) => child262.name === sibSpName) : void 0;
33828
+ if (named?.forEachOrigin) {
33829
+ return named;
33830
+ }
33831
+ const repeating = (constraintNode.children ?? []).find((child262) => child262.forEachOrigin);
33832
+ return repeating ?? named ?? itemNode(constraintNode);
33833
+ }
33834
+ function resolveCycleRingParams(arrangerNode, index) {
33835
+ const constraintNode = resolveCycleConstraintNode(arrangerNode);
33836
+ const arrangerConstraints = constraintNode.allConstraints ?? constraintNode.constraints;
33837
+ const item = resolveRingItemNode(constraintNode, arrangerConstraints);
33838
+ const itemConstraints = item?.allConstraints ?? item?.constraints;
33839
+ const literalHeightOverWidth = ratioConstraint(
33840
+ itemConstraints ?? [],
33841
+ ["h"],
33842
+ Number.NaN,
33843
+ item?.rules
33844
+ );
33845
+ const contentLayout = deriveCompositeSelfChildLayout(item);
33846
+ const heightOverWidth = !Number.isNaN(literalHeightOverWidth) ? literalHeightOverWidth : resolveGraphAspectRatio(item, index) ?? resolveRatioConstraint(itemConstraints, index, roleOf(item), ["h"], 1, item?.rules);
33847
+ const hubRatio = resolveHubToNodeRatio(item, arrangerConstraints);
33848
+ const hubGapRatio = resolveHubGapRatio(item?.name, hubRatio, arrangerConstraints);
33849
+ const absoluteHubGap = absoluteConstraintPoints(findConstraint(arrangerConstraints, "sp"));
33850
+ const absolutePoints = absoluteConstraintPoints(findConstraint(arrangerConstraints, "sibSp"));
33851
+ if (absolutePoints !== void 0) {
33852
+ return {
33853
+ minGapRatio: DEFAULT_MIN_GAP_RATIO,
33854
+ heightOverWidth,
33855
+ absoluteGapPx: absolutePoints * POINTS_TO_PIXELS,
33856
+ hubRatio,
33857
+ hubGapRatio,
33858
+ absoluteHubGapPx: absoluteHubGap !== void 0 ? absoluteHubGap * POINTS_TO_PIXELS : void 0,
33859
+ contentLayout
33860
+ };
33861
+ }
33862
+ const minGapRatio = resolveRatioConstraint(
33863
+ arrangerConstraints,
33864
+ index,
33865
+ roleOf(constraintNode),
33866
+ ["sibSp"],
33867
+ DEFAULT_MIN_GAP_RATIO,
33868
+ constraintNode.rules
33869
+ );
33870
+ return {
33871
+ minGapRatio: Math.max(DEFAULT_MIN_GAP_RATIO, minGapRatio),
33872
+ heightOverWidth,
33873
+ hubRatio,
33874
+ absoluteHubGapPx: absoluteHubGap !== void 0 ? absoluteHubGap * POINTS_TO_PIXELS : void 0,
33875
+ contentLayout,
33876
+ hubGapRatio
33877
+ };
33878
+ }
33879
+ var POINTS_TO_PIXELS;
33880
+ var DEFAULT_MIN_GAP_RATIO;
33881
+ var init_smartart_layout_interpreter_cycle_constraints = __esm({
33882
+ "src/core/utils/smartart-layout-interpreter-cycle-constraints.ts"() {
33883
+ init_smartart_constraint_ratio_fallback();
33884
+ init_smartart_constraint_solver();
33885
+ init_smartart_layout_interpreter_constraints();
33886
+ init_smartart_layout_interpreter_cycle_hub_ratio();
33887
+ init_smartart_layout_interpreter_cycle_item_aspect();
33888
+ init_smartart_layout_interpreter_model();
33889
+ init_smartart_layout_interpreter_cycle_hub_ratio();
33890
+ POINTS_TO_PIXELS = 96 / 72;
33891
+ DEFAULT_MIN_GAP_RATIO = 0.5;
33892
+ }
33893
+ });
33894
+ function repositionCycleRingContent(result, contentLayout, flatNodes) {
33895
+ if (!contentLayout?.childName || contentLayout.childLeftFactor === void 0 || contentLayout.childWidthFactor === void 0 || contentLayout.selfWidthFactor <= 0) {
33896
+ return result;
33897
+ }
33898
+ const { selfName, childName, childLeftFactor, childWidthFactor, selfWidthFactor } = contentLayout;
33899
+ const parentIdById = new Map(flatNodes.map((node) => [node.id, node.parentId]));
33900
+ const selfByNodeId = /* @__PURE__ */ new Map();
33901
+ for (const node of result.nodes) {
33902
+ if (node.kind === "circle" && node.itemRoleName === selfName && node.nodeId) {
33903
+ selfByNodeId.set(node.nodeId, node);
33904
+ }
33905
+ }
33906
+ const nodes = result.nodes.map((rendered) => {
33907
+ if (rendered.kind !== "circle" || rendered.itemRoleName !== childName || !rendered.nodeId) {
33908
+ return rendered;
33554
33909
  }
33555
- if (!aux && isMeaningfulAux(node)) {
33556
- aux = { kind, node };
33910
+ const parentId = parentIdById.get(rendered.nodeId);
33911
+ const self = parentId ? selfByNodeId.get(parentId) : void 0;
33912
+ if (!self) {
33913
+ return rendered;
33557
33914
  }
33915
+ const selfW = 2 * (self.rx ?? self.r);
33916
+ const selfH = 2 * (self.ry ?? self.r);
33917
+ const selfLeft = self.cx - selfW / 2;
33918
+ const childW = childWidthFactor / selfWidthFactor * selfW;
33919
+ const childLeft = selfLeft + childLeftFactor * selfW;
33920
+ const cx = childLeft + childW / 2;
33921
+ const cy = self.cy;
33922
+ return {
33923
+ ...rendered,
33924
+ cx,
33925
+ cy,
33926
+ r: Math.min(childW, selfH) / 2,
33927
+ rx: childW / 2,
33928
+ ry: selfH / 2,
33929
+ textX: cx,
33930
+ textY: cy
33931
+ };
33558
33932
  });
33559
- if (hierarchy) {
33560
- return { kind: "hierarchy", node: hierarchy };
33933
+ return { ...result, nodes };
33934
+ }
33935
+ var init_smartart_layout_interpreter_cycle_ring_item = __esm({
33936
+ "src/core/utils/smartart-layout-interpreter-cycle-ring-item.ts"() {
33561
33937
  }
33562
- if (chosen) {
33563
- return chosen;
33938
+ });
33939
+ function arrowHeadPath(tipX, tipY, ux, uy) {
33940
+ const bx = tipX - ux * ARROW_HEAD;
33941
+ const by = tipY - uy * ARROW_HEAD;
33942
+ const px3 = -uy;
33943
+ const py = ux;
33944
+ const w1x = bx + px3 * ARROW_WING;
33945
+ const w1y = by + py * ARROW_WING;
33946
+ const w2x = bx - px3 * ARROW_WING;
33947
+ const w2y = by - py * ARROW_WING;
33948
+ return ` M${w1x},${w1y} L${tipX},${tipY} L${w2x},${w2y}`;
33949
+ }
33950
+ function endHeads(x0, y0, x1, y1, begSty, endSty) {
33951
+ const dx = x1 - x0;
33952
+ const dy = y1 - y0;
33953
+ const len = Math.hypot(dx, dy);
33954
+ if (len < 1e-6) {
33955
+ return "";
33564
33956
  }
33565
- if (compositeSlot) {
33566
- return { kind: "composite", node: compositeSlot };
33957
+ const ux = dx / len;
33958
+ const uy = dy / len;
33959
+ let heads = "";
33960
+ if (endSty === "arr") {
33961
+ heads += arrowHeadPath(x1, y1, ux, uy);
33567
33962
  }
33568
- return structural ?? aux;
33569
- }
33570
- function itemNode(arranger) {
33571
- return arranger.children?.[0];
33963
+ if (begSty === "arr") {
33964
+ heads += arrowHeadPath(x0, y0, -ux, -uy);
33965
+ }
33966
+ return heads;
33572
33967
  }
33573
- function algorithmParam(node, type) {
33574
- return node.algorithm?.parameters?.find((param) => param.type === type)?.value;
33968
+ function straightPath(x0, y0, x1, y1) {
33969
+ return `M${x0},${y0} L${x1},${y1}`;
33575
33970
  }
33576
- function numericParam(node, type, fallback) {
33577
- const raw = algorithmParam(node, type);
33578
- if (raw === void 0) {
33579
- return fallback;
33971
+ function elbowPath(x0, y0, x1, y1) {
33972
+ if (Math.abs(x1 - x0) >= Math.abs(y1 - y0)) {
33973
+ const midX = (x0 + x1) / 2;
33974
+ return `M${x0},${y0} L${midX},${y0} L${midX},${y1} L${x1},${y1}`;
33580
33975
  }
33581
- const parsed = Number(raw);
33582
- return Number.isFinite(parsed) ? parsed : fallback;
33976
+ const midY = (y0 + y1) / 2;
33977
+ return `M${x0},${y0} L${x0},${midY} L${x1},${midY} L${x1},${y1}`;
33583
33978
  }
33584
- function resolveFlowDirection(arranger, presLayoutVars) {
33585
- const linDir = algorithmParam(arranger, "linDir");
33586
- const vertical = linDir === "fromT" || linDir === "fromB";
33587
- let reverse = linDir === "fromR" || linDir === "fromB";
33588
- if (presLayoutVars?.direction === "rev") {
33589
- reverse = !reverse;
33979
+ function curvePath(x0, y0, x1, y1, centre) {
33980
+ const midX = (x0 + x1) / 2;
33981
+ const midY = (y0 + y1) / 2;
33982
+ const pull = 1 + 30 / Math.max(1, Math.hypot(midX - centre.x, midY - centre.y));
33983
+ const controlX = centre.x + (midX - centre.x) * pull;
33984
+ const controlY = centre.y + (midY - centre.y) * pull;
33985
+ return `M${x0},${y0} Q${controlX},${controlY} ${x1},${y1}`;
33986
+ }
33987
+ function connectorPath(x0, y0, x1, y1, centre, routing, begSty, endSty) {
33988
+ const body = routing === "bend" ? elbowPath(x0, y0, x1, y1) : routing === "curve" ? curvePath(x0, y0, x1, y1, centre) : straightPath(x0, y0, x1, y1);
33989
+ return body + endHeads(x0, y0, x1, y1, begSty, endSty);
33990
+ }
33991
+ function connectorEndpoints(from, to, horizontal, dim) {
33992
+ const fromCx = from.x + from.width / 2;
33993
+ const fromCy = from.y + from.height / 2;
33994
+ const toCx = to.x + to.width / 2;
33995
+ const toCy = to.y + to.height / 2;
33996
+ if (dim === "2D") {
33997
+ return { x0: fromCx, y0: fromCy, x1: toCx, y1: toCy };
33590
33998
  }
33591
- return { orientation: vertical ? "vertical" : "horizontal", reverse };
33999
+ if (horizontal) {
34000
+ const leftFirst = fromCx <= toCx;
34001
+ return leftFirst ? { x0: from.x + from.width, y0: fromCy, x1: to.x, y1: toCy } : { x0: from.x, y0: fromCy, x1: to.x + to.width, y1: toCy };
34002
+ }
34003
+ const topFirst = fromCy <= toCy;
34004
+ return topFirst ? { x0: fromCx, y0: from.y + from.height, x1: toCx, y1: to.y } : { x0: fromCx, y0: from.y, x1: toCx, y1: to.y + to.height };
33592
34005
  }
33593
- var PRIMARY_ALG;
33594
- var STRUCTURAL_ARRANGEMENT_KINDS;
33595
- var init_smartart_layout_interpreter_model = __esm({
33596
- "src/core/utils/smartart-layout-interpreter-model.ts"() {
33597
- init_smartart_layout_interpreter_composite_detect();
33598
- init_smartart_layout_interpreter_flow();
33599
- init_smartart_layout_interpreter_tree_location();
33600
- init_smartart_layout_interpreter_constraints();
33601
- PRIMARY_ALG = {
33602
- lin: "linear",
33603
- cycle: "cycle",
33604
- pyra: "pyramid",
33605
- snake: "snake",
33606
- composite: "composite",
33607
- conn: "conn",
33608
- sp: "spacer",
33609
- tx: "text"
33610
- };
33611
- STRUCTURAL_ARRANGEMENT_KINDS = /* @__PURE__ */ new Set([
33612
- "linear",
33613
- "cycle",
33614
- "pyramid",
33615
- "snake"
33616
- ]);
34006
+ var ARROW_WING;
34007
+ var ARROW_HEAD;
34008
+ var init_smartart_layout_interpreter_conn_path = __esm({
34009
+ "src/core/utils/smartart-layout-interpreter-conn-path.ts"() {
34010
+ ARROW_WING = 4;
34011
+ ARROW_HEAD = 7;
33617
34012
  }
33618
34013
  });
33619
- function resolveReferencedRatio(index, role, types, rules) {
33620
- for (const type of types) {
33621
- const candidates = index.entries.get(entryKey(role, type));
33622
- if (!candidates?.some((entry2) => hasReference(entry2.constraint))) {
33623
- continue;
33624
- }
33625
- const resolved = resolveConstraint(index, role, type);
33626
- if (resolved !== void 0) {
33627
- return clampByRules(resolved, rules, type);
34014
+ function resolveConstraintDeclaredBy(index, role, type, declaringRole) {
34015
+ const candidates = index.entries.get(entryKey(role, type));
34016
+ const fromArranger = candidates?.filter(
34017
+ (c) => c.declaringRole === declaringRole
34018
+ );
34019
+ if (!fromArranger || fromArranger.length === 0) {
34020
+ return void 0;
34021
+ }
34022
+ const visiting = /* @__PURE__ */ new Set([entryKey(role, type)]);
34023
+ for (const candidate of fromArranger) {
34024
+ const value = resolveEntry(index, candidate, visiting);
34025
+ if (value !== void 0) {
34026
+ return value;
33628
34027
  }
33629
34028
  }
33630
34029
  return void 0;
33631
34030
  }
33632
- function resolveRatioConstraint(constraints, index, role, types, fallback, rules) {
33633
- const literal = ratioConstraint(constraints, types, Number.NaN, rules);
33634
- if (!Number.isNaN(literal)) {
33635
- return literal;
33636
- }
33637
- const relative = resolveReferencedRatio(index, role, types, rules);
33638
- return relative ?? fallback;
34031
+ function firstConstraintDeclaredBy(index, role, type, declaringRole) {
34032
+ const candidates = index.entries.get(entryKey(role, type));
34033
+ return candidates?.find((candidate) => candidate.declaringRole === declaringRole)?.constraint;
33639
34034
  }
33640
- var init_smartart_constraint_ratio_fallback = __esm({
33641
- "src/core/utils/smartart-constraint-ratio-fallback.ts"() {
34035
+ var init_smartart_constraint_declared_by = __esm({
34036
+ "src/core/utils/smartart-constraint-declared-by.ts"() {
33642
34037
  init_smartart_constraint_solver();
33643
- init_smartart_layout_interpreter_model();
33644
34038
  }
33645
34039
  });
33646
34040
  var INSET;
@@ -33925,7 +34319,7 @@ function presetCornerRadiusFraction(shape) {
33925
34319
  }
33926
34320
  const raw = shape?.adjustments?.find((adjustment) => adjustment.index === 1)?.value;
33927
34321
  if (raw === void 0) {
33928
- return 0.15;
34322
+ return DEFAULT_ROUND_RECT_ADJ_FRACTION;
33929
34323
  }
33930
34324
  return raw > 1 ? raw / 1e5 : raw;
33931
34325
  }
@@ -33939,6 +34333,7 @@ function roundRectCornerInsetPx(shape, widthPx, heightPx) {
33939
34333
  var CIRCLE_PRESETS;
33940
34334
  var POLYGON_PRESETS;
33941
34335
  var ROUND_RECT_PRESETS;
34336
+ var DEFAULT_ROUND_RECT_ADJ_FRACTION;
33942
34337
  var CORNER_ARC_INSET_FACTOR;
33943
34338
  var init_smartart_layout_shape_preset = __esm({
33944
34339
  "src/core/utils/smartart-layout-shape-preset.ts"() {
@@ -33966,6 +34361,7 @@ var init_smartart_layout_shape_preset = __esm({
33966
34361
  "snip2DiagRect",
33967
34362
  "snipRoundRect"
33968
34363
  ]);
34364
+ DEFAULT_ROUND_RECT_ADJ_FRACTION = 16667 / 1e5;
33969
34365
  CORNER_ARC_INSET_FACTOR = 1 - Math.SQRT2 / 2;
33970
34366
  }
33971
34367
  });
@@ -34982,9 +35378,9 @@ function nodeFontBounds(fontRoleCandidate, arranger, index) {
34982
35378
  const fontRoleNode = findFontRoleNode(fontRoleCandidate) ?? fontRoleCandidate;
34983
35379
  const role = fontRoleNode ? roleOf(fontRoleNode) : roleOf(arranger);
34984
35380
  const declared = resolveConstraint(index, role, "primFontSz");
34985
- const ceilingPx = typeof declared === "number" && declared > 0 ? declared * POINTS_TO_PIXELS : DEFAULT_CEILING_PX;
35381
+ const ceilingPx = typeof declared === "number" && declared > 0 ? declared * POINTS_TO_PIXELS2 : DEFAULT_CEILING_PX;
34986
35382
  const floorRuleValues = primFontSzFloorRuleValues(fontRoleNode, arranger, role);
34987
- const floorPx = floorRuleValues.length > 0 ? Math.min(...floorRuleValues) * POINTS_TO_PIXELS : DEFAULT_FLOOR_PX;
35383
+ const floorPx = floorRuleValues.length > 0 ? Math.min(...floorRuleValues) * POINTS_TO_PIXELS2 : DEFAULT_FLOOR_PX;
34988
35384
  return { ceilingPx, floorPx: Math.min(floorPx, ceilingPx), role };
34989
35385
  }
34990
35386
  function itemFontBoundsPx(plan, index) {
@@ -34993,7 +35389,7 @@ function itemFontBoundsPx(plan, index) {
34993
35389
  function primFontSzCeilingPx(plan, index) {
34994
35390
  return itemFontBoundsPx(plan, index).ceilingPx;
34995
35391
  }
34996
- var POINTS_TO_PIXELS;
35392
+ var POINTS_TO_PIXELS2;
34997
35393
  var DEFAULT_CEILING_PX;
34998
35394
  var DEFAULT_FLOOR_PX;
34999
35395
  var DECORATIVE_FONT_ALGORITHM_TYPES;
@@ -35001,7 +35397,7 @@ var init_smartart_layout_item_font_role = __esm({
35001
35397
  "src/core/utils/smartart-layout-item-font-role.ts"() {
35002
35398
  init_smartart_constraint_solver();
35003
35399
  init_smartart_layout_interpreter_model();
35004
- POINTS_TO_PIXELS = 96 / 72;
35400
+ POINTS_TO_PIXELS2 = 96 / 72;
35005
35401
  DEFAULT_CEILING_PX = 12;
35006
35402
  DEFAULT_FLOOR_PX = 6;
35007
35403
  DECORATIVE_FONT_ALGORITHM_TYPES = /* @__PURE__ */ new Set(["sp", "composite", "conn"]);
@@ -35017,12 +35413,13 @@ function measureTextWidth(text22, fontSize, table) {
35017
35413
  }
35018
35414
  return widthPx;
35019
35415
  }
35020
- function wrappedLineCount(text22, maxWidth, fontSize, table) {
35416
+ function greedyWrap(text22, maxWidth, fontSize, table) {
35021
35417
  if (maxWidth <= 0) {
35022
- return Number.POSITIVE_INFINITY;
35418
+ return { lines: Number.POSITIVE_INFINITY, widestLineWidth: 0 };
35023
35419
  }
35024
35420
  const spaceWidth = measureTextWidth(" ", fontSize, table);
35025
35421
  let lines = 0;
35422
+ let widestLineWidth = 0;
35026
35423
  for (const paragraph of text22.split("\n")) {
35027
35424
  const words = paragraph.split(/\s+/u).filter((word) => word.length > 0);
35028
35425
  if (words.length === 0) {
@@ -35035,15 +35432,23 @@ function wrappedLineCount(text22, maxWidth, fontSize, table) {
35035
35432
  const wordWidth = measureTextWidth(word, fontSize, table);
35036
35433
  const extended = lineWidth === 0 ? wordWidth : lineWidth + spaceWidth + wordWidth;
35037
35434
  if (extended > maxWidth && lineWidth > 0) {
35435
+ widestLineWidth = Math.max(widestLineWidth, lineWidth);
35038
35436
  paragraphLines += 1;
35039
35437
  lineWidth = wordWidth;
35040
35438
  } else {
35041
35439
  lineWidth = extended;
35042
35440
  }
35043
35441
  }
35442
+ widestLineWidth = Math.max(widestLineWidth, lineWidth);
35044
35443
  lines += paragraphLines;
35045
35444
  }
35046
- return Math.max(1, lines);
35445
+ return { lines: Math.max(1, lines), widestLineWidth };
35446
+ }
35447
+ function wrappedLineCount(text22, maxWidth, fontSize, table) {
35448
+ return greedyWrap(text22, maxWidth, fontSize, table).lines;
35449
+ }
35450
+ function wrappedWidestLineWidth(text22, maxWidth, fontSize, table) {
35451
+ return greedyWrap(text22, maxWidth, fontSize, table).widestLineWidth;
35047
35452
  }
35048
35453
  function fitsAt(text22, maxWidth, maxHeight, size, table, lineSpacingFactor) {
35049
35454
  return wrappedLineCount(text22, maxWidth, size, table) * size * table.lineHeightRatio * lineSpacingFactor <= maxHeight;
@@ -35094,8 +35499,8 @@ function itemMarginsPx(index, role, table) {
35094
35499
  const topPt = typeof top === "number" ? top : table.marginTopPt;
35095
35500
  const bottomPt = typeof bottom === "number" ? bottom : table.marginBottomPt;
35096
35501
  return {
35097
- horizontal: (leftPt + rightPt) * POINTS_TO_PIXELS2,
35098
- vertical: (topPt + bottomPt) * POINTS_TO_PIXELS2
35502
+ horizontal: (leftPt + rightPt) * POINTS_TO_PIXELS3,
35503
+ vertical: (topPt + bottomPt) * POINTS_TO_PIXELS3
35099
35504
  };
35100
35505
  }
35101
35506
  function proportionalMarginFraction(index, role) {
@@ -35113,7 +35518,7 @@ function proportionalMarginFraction(index, role) {
35113
35518
  return { horizontal: (left ?? 0) + (right ?? 0), vertical: (top ?? 0) + (bottom ?? 0) };
35114
35519
  }
35115
35520
  function snapToWholePoint(sizePx2) {
35116
- return Math.round(sizePx2 / POINTS_TO_PIXELS2) * POINTS_TO_PIXELS2;
35521
+ return Math.round(sizePx2 / POINTS_TO_PIXELS3) * POINTS_TO_PIXELS3;
35117
35522
  }
35118
35523
  function resolveRoleFontSize(roleNode, index, items, fontName) {
35119
35524
  return fitSharedFontSize(
@@ -35168,7 +35573,7 @@ function fitSharedFontSize(bounds, index, items, fontName, naturalAspect) {
35168
35573
  }
35169
35574
  return snapToWholePoint(shared);
35170
35575
  }
35171
- var POINTS_TO_PIXELS2;
35576
+ var POINTS_TO_PIXELS3;
35172
35577
  var init_smartart_layout_item_font_size = __esm({
35173
35578
  "src/core/utils/smartart-layout-item-font-size.ts"() {
35174
35579
  init_font_advance_widths_generated();
@@ -35176,15 +35581,31 @@ var init_smartart_layout_item_font_size = __esm({
35176
35581
  init_smartart_layout_item_font_role();
35177
35582
  init_smartart_text_wrap_fit();
35178
35583
  init_smartart_layout_item_font_role();
35179
- POINTS_TO_PIXELS2 = 96 / 72;
35584
+ POINTS_TO_PIXELS3 = 96 / 72;
35180
35585
  }
35181
35586
  });
35587
+ function extrapolatedIndentPt(descendantSizePt) {
35588
+ const last = DESCENDANT_INDENT_STEPS_PT[DESCENDANT_INDENT_STEPS_PT.length - 1];
35589
+ const tiersBeyond = Math.floor((descendantSizePt - last.maxSz - 1) / 13) + 1;
35590
+ return last.indentPt + tiersBeyond * 4.5;
35591
+ }
35592
+ function descendantIndentPt(descendantSizePt) {
35593
+ for (const step of DESCENDANT_INDENT_STEPS_PT) {
35594
+ if (descendantSizePt <= step.maxSz) {
35595
+ return step.indentPt;
35596
+ }
35597
+ }
35598
+ return extrapolatedIndentPt(descendantSizePt);
35599
+ }
35182
35600
  function paragraphBlockPx(lines, sizePx2, ratio, lineSpacingFactor, spcAftFactor, isLastParagraph) {
35183
35601
  const content = lines * sizePx2 * ratio * lineSpacingFactor;
35184
35602
  return isLastParagraph ? content : content + spcAftFactor * sizePx2 * ratio;
35185
35603
  }
35186
35604
  function itemFits(item, availWidthPx, availHeightPx, rootPx, descendantPx, table, lineSpacingFactor) {
35187
35605
  const hasDescendants = item.descendantTexts.length > 0;
35606
+ if (wrappedWidestLineWidth(item.rootText, availWidthPx, rootPx, table) > availWidthPx) {
35607
+ return false;
35608
+ }
35188
35609
  const rootLines = wrappedLineCount(item.rootText, availWidthPx, rootPx, table);
35189
35610
  let totalPx = paragraphBlockPx(
35190
35611
  rootLines,
@@ -35194,9 +35615,15 @@ function itemFits(item, availWidthPx, availHeightPx, rootPx, descendantPx, table
35194
35615
  ROOT_SPCAFT_FACTOR,
35195
35616
  !hasDescendants
35196
35617
  );
35618
+ const descendantIndentPx = descendantIndentPt(descendantPx / PX_PER_PT) * PX_PER_PT;
35619
+ const descendantWidthPx = Math.max(1, availWidthPx - descendantIndentPx);
35197
35620
  for (let i2 = 0; i2 < item.descendantTexts.length; i2++) {
35198
35621
  const isLast = i2 === item.descendantTexts.length - 1;
35199
- const lines = wrappedLineCount(item.descendantTexts[i2], availWidthPx, descendantPx, table);
35622
+ const text22 = item.descendantTexts[i2];
35623
+ if (wrappedWidestLineWidth(text22, descendantWidthPx, descendantPx, table) > descendantWidthPx) {
35624
+ return false;
35625
+ }
35626
+ const lines = wrappedLineCount(text22, descendantWidthPx, descendantPx, table);
35200
35627
  totalPx += paragraphBlockPx(
35201
35628
  lines,
35202
35629
  descendantPx,
@@ -35210,11 +35637,21 @@ function itemFits(item, availWidthPx, availHeightPx, rootPx, descendantPx, table
35210
35637
  }
35211
35638
  var ROOT_SPCAFT_FACTOR;
35212
35639
  var DESCENDANT_SPCAFT_FACTOR;
35640
+ var PX_PER_PT;
35641
+ var DESCENDANT_INDENT_STEPS_PT;
35213
35642
  var init_smartart_layout_item_font_tier_fit = __esm({
35214
35643
  "src/core/utils/smartart-layout-item-font-tier-fit.ts"() {
35215
35644
  init_smartart_text_wrap_fit();
35216
35645
  ROOT_SPCAFT_FACTOR = 0.35;
35217
35646
  DESCENDANT_SPCAFT_FACTOR = 0.15;
35647
+ PX_PER_PT = 96 / 72;
35648
+ DESCENDANT_INDENT_STEPS_PT = [
35649
+ { maxSz: 11, indentPt: 4.5 },
35650
+ { maxSz: 15, indentPt: 9 },
35651
+ { maxSz: 19, indentPt: 13.5 },
35652
+ { maxSz: 27, indentPt: 18 },
35653
+ { maxSz: 40, indentPt: 22.5 }
35654
+ ];
35218
35655
  }
35219
35656
  });
35220
35657
  function resolveTieredItemFontSize(plan, index, items, fontName, naturalAspect, cornerInsetPx = 0) {
@@ -35225,7 +35662,7 @@ function resolveTieredItemFontSize(plan, index, items, fontName, naturalAspect,
35225
35662
  const table = resolveFontTable(fontName);
35226
35663
  const fixedMargins = itemMarginsPx(index, role, table);
35227
35664
  const proportional = proportionalMarginFraction(index, role);
35228
- const lineSpacingFactor = typeof naturalAspect === "number" ? 1 : SMARTART_LINE_SPACING_FACTOR;
35665
+ const lineSpacingFactor = SMARTART_LINE_SPACING_FACTOR;
35229
35666
  const fitsAtMarginBasis = (rootPx2, marginBasisPx) => {
35230
35667
  const margins = proportional ? {
35231
35668
  horizontal: proportional.horizontal * marginBasisPx,
@@ -35234,8 +35671,7 @@ function resolveTieredItemFontSize(plan, index, items, fontName, naturalAspect,
35234
35671
  for (const item of items) {
35235
35672
  const naturalHeight = typeof naturalAspect === "number" ? Math.min(item.height, item.width * naturalAspect) : item.height;
35236
35673
  const availWidthPx = Math.max(1, item.width - margins.horizontal - 2 * cornerInsetPx);
35237
- const hasDescendants = item.descendantTexts.length > 0;
35238
- const verticalReduction = hasDescendants || cornerInsetPx === 0 ? margins.vertical + cornerInsetPx : 2 * cornerInsetPx;
35674
+ const verticalReduction = margins.vertical + 2 * cornerInsetPx;
35239
35675
  const availHeightPx = Math.max(1, naturalHeight - verticalReduction);
35240
35676
  const descendantPx = rootPx2 * SMARTART_DESCENDANT_FONT_SCALE;
35241
35677
  const fits = itemFits(
@@ -35286,12 +35722,12 @@ function resolveTieredItemFontSize(plan, index, items, fontName, naturalAspect,
35286
35722
  }
35287
35723
  const rounded = snapToWholePoint(rootPx);
35288
35724
  const roundedUp = rounded > rootPx;
35289
- const rootSizePx = roundedUp && !fitsAtMarginBasis(rounded, rootPx) ? Math.floor(rootPx / PX_PER_PT) * PX_PER_PT : rounded;
35725
+ const rootSizePx = roundedUp && !fitsAtMarginBasis(rounded, rootPx) ? Math.floor(rootPx / PX_PER_PT2) * PX_PER_PT2 : rounded;
35290
35726
  const descendantSizePx = snapToWholePoint(rootSizePx * SMARTART_DESCENDANT_FONT_SCALE);
35291
35727
  return { rootSizePx, descendantSizePx };
35292
35728
  }
35293
35729
  var SMARTART_DESCENDANT_FONT_SCALE;
35294
- var PX_PER_PT;
35730
+ var PX_PER_PT2;
35295
35731
  var init_smartart_layout_item_font_tier = __esm({
35296
35732
  "src/core/utils/smartart-layout-item-font-tier.ts"() {
35297
35733
  init_smartart_layout_item_font_role();
@@ -35299,7 +35735,7 @@ var init_smartart_layout_item_font_tier = __esm({
35299
35735
  init_smartart_layout_item_font_tier_fit();
35300
35736
  init_smartart_text_wrap_fit();
35301
35737
  SMARTART_DESCENDANT_FONT_SCALE = 0.78;
35302
- PX_PER_PT = 96 / 72;
35738
+ PX_PER_PT2 = 96 / 72;
35303
35739
  }
35304
35740
  });
35305
35741
  function snakeGridDims(plan, n, w, h2, flowDir) {
@@ -35535,14 +35971,17 @@ function arrangeLinear(plan, flow, nodes, box, palette, style, elementId, index
35535
35971
  n,
35536
35972
  clampRatio
35537
35973
  );
35538
- const crossExtent = aspect ? Math.min(usableCross, Math.max(12, mainExtent * aspect)) : usableCross;
35539
- const crossPos = INSET + (usableCross - crossExtent) / 2;
35540
- const start = INSET + begPad * mainExtent;
35541
35974
  const itemTemplate = itemNode(plan.node);
35542
35975
  const itemShape = findCompositeItemShape(itemTemplate);
35976
+ const naturalAspect = resolveItemSelfAspect(itemTemplate);
35977
+ const crossExtent = aspect ? Math.min(usableCross, Math.max(12, mainExtent * aspect)) : typeof naturalAspect === "number" ? Math.min(
35978
+ usableCross,
35979
+ Math.max(12, mainExtent * (horizontal ? naturalAspect : 1 / naturalAspect))
35980
+ ) : usableCross;
35981
+ const crossPos = INSET + (usableCross - crossExtent) / 2;
35982
+ const start = INSET + begPad * mainExtent;
35543
35983
  const itemW = horizontal ? mainExtent : crossExtent;
35544
35984
  const itemH = horizontal ? crossExtent : mainExtent;
35545
- const naturalAspect = resolveItemSelfAspect(itemTemplate);
35546
35985
  const renderedIds = new Set(flow2.map((node) => node.id));
35547
35986
  const descendantTextsFor = (node) => childrenOf ? foldedDescendantTexts(node, renderedIds, childrenOf) : [];
35548
35987
  const naturalHeightForInset = typeof naturalAspect === "number" ? Math.min(itemH, itemW * naturalAspect) : itemH;
@@ -35926,50 +36365,70 @@ var init_smartart_layout_interpreter_composite_children = __esm({
35926
36365
  init_smartart_node_tree_axis();
35927
36366
  }
35928
36367
  });
36368
+ function resolveOrigin(node, flat) {
36369
+ const origin = node.forEachOrigin;
36370
+ if (!origin?.axis || origin.axis.length === 0) {
36371
+ return [];
36372
+ }
36373
+ return resolveAxisNodes(flat, origin.axis, origin.pointTypes, origin.start, origin.count) ?? [];
36374
+ }
35929
36375
  function resolveAnchoredContent(node, flat) {
35930
36376
  const presOf = node.presentationOf;
35931
36377
  if (!presOf?.axis || presOf.axis.length === 0) {
35932
36378
  return [];
35933
36379
  }
35934
- const origin = node.forEachOrigin;
35935
- if (!origin?.axis || origin.axis.length === 0) {
36380
+ const anchors = resolveOrigin(node, flat);
36381
+ if (!node.forEachOrigin?.axis || node.forEachOrigin.axis.length === 0) {
35936
36382
  return resolveAxisNodes(flat, presOf.axis, presOf.pointTypes, presOf.start, presOf.count) ?? [];
35937
36383
  }
35938
- const anchors = resolveAxisNodes(flat, origin.axis, origin.pointTypes, origin.start, origin.count) ?? [];
35939
36384
  if (anchors.length === 0) {
35940
36385
  return [];
35941
36386
  }
35942
36387
  return resolveAxisNodes(flat, presOf.axis, presOf.pointTypes, presOf.start, presOf.count, anchors) ?? [];
35943
36388
  }
36389
+ function resolveAnchoredContentPerAnchor(node, flat) {
36390
+ const presOf = node.presentationOf;
36391
+ if (!presOf?.axis || presOf.axis.length === 0) {
36392
+ return [];
36393
+ }
36394
+ if (!node.forEachOrigin?.axis || node.forEachOrigin.axis.length === 0) {
36395
+ const content = resolveAnchoredContent(node, flat);
36396
+ return content.length > 0 ? [content] : [];
36397
+ }
36398
+ const anchors = resolveOrigin(node, flat);
36399
+ const groups = [];
36400
+ for (const anchor of anchors) {
36401
+ const content = resolveAxisNodes(flat, presOf.axis, presOf.pointTypes, presOf.start, presOf.count, [
36402
+ anchor
36403
+ ]) ?? [];
36404
+ if (content.length > 0) {
36405
+ groups.push(content);
36406
+ }
36407
+ }
36408
+ return groups;
36409
+ }
35944
36410
  var init_smartart_layout_interpreter_composite_anchor = __esm({
35945
36411
  "src/core/utils/smartart-layout-interpreter-composite-anchor.ts"() {
35946
36412
  init_smartart_layout_interpreter_axis_count();
35947
36413
  }
35948
36414
  });
35949
- function guardAllows(node, flat) {
35950
- if (!node.chooseGuard) {
35951
- return true;
36415
+ function resolveIterationRect(dims, box, iteration, iterationCount) {
36416
+ const container = resolveSlot(dims, box, 1, 1);
36417
+ if (iterationCount <= 1) {
36418
+ return container;
35952
36419
  }
35953
- return evaluateWhen(node.chooseGuard, flat.length, { nodes: flat }) !== false;
35954
- }
35955
- function collectRawCandidates(node, flat, declaringRole, out = []) {
35956
- if (!guardAllows(node, flat)) {
35957
- return out;
35958
- }
35959
- const axis = node.presentationOf?.axis;
35960
- if (axis && axis.length > 0) {
35961
- const content = resolveAnchoredContent(node, flat);
35962
- if (content.length > 0) {
35963
- out.push({ node, declaringRole, content });
35964
- }
35965
- return out;
35966
- }
35967
- const nextRole = roleOf(node);
35968
- for (const child262 of node.children ?? []) {
35969
- collectRawCandidates(child262, flat, nextRole, out);
36420
+ if (container.width >= container.height) {
36421
+ const width = container.width / iterationCount;
36422
+ return { x: container.x + width * iteration, y: container.y, width, height: container.height };
35970
36423
  }
35971
- return out;
36424
+ const height = container.height / iterationCount;
36425
+ return { x: container.x, y: container.y + height * iteration, width: container.width, height };
35972
36426
  }
36427
+ var init_smartart_layout_interpreter_composite_iteration = __esm({
36428
+ "src/core/utils/smartart-layout-interpreter-composite-iteration.ts"() {
36429
+ init_smartart_layout_interpreter_composite_slots();
36430
+ }
36431
+ });
35973
36432
  function contentSignature(content) {
35974
36433
  return content.map((n) => n.id).sort().join(" ");
35975
36434
  }
@@ -35994,13 +36453,59 @@ function resolveGroupedSlots(candidates, box, index) {
35994
36453
  for (const candidate of ordered4) {
35995
36454
  const [slotted] = readSlots([candidate.node], box, index, candidate.declaringRole);
35996
36455
  if (slotted) {
35997
- out.push({ rect: resolveSlot(slotted.dims, box, 1, 1), content: candidate.content });
36456
+ const rect22 = resolveIterationRect(
36457
+ slotted.dims,
36458
+ box,
36459
+ candidate.iteration,
36460
+ candidate.iterationCount
36461
+ );
36462
+ out.push({ rect: rect22, content: candidate.content });
35998
36463
  break;
35999
36464
  }
36000
36465
  }
36001
36466
  }
36002
36467
  return out;
36003
36468
  }
36469
+ var init_smartart_layout_interpreter_composite_group_slots = __esm({
36470
+ "src/core/utils/smartart-layout-interpreter-composite-group-slots.ts"() {
36471
+ init_smartart_layout_interpreter_composite_iteration();
36472
+ init_smartart_layout_interpreter_composite_slots();
36473
+ }
36474
+ });
36475
+ function guardAllows(node, flat, iterationPosition) {
36476
+ if (!node.chooseGuard) {
36477
+ return true;
36478
+ }
36479
+ return node.chooseGuard.every(
36480
+ (guard) => evaluateWhen(guard, flat.length, {
36481
+ nodes: flat,
36482
+ position: iterationPosition?.position,
36483
+ total: iterationPosition?.total
36484
+ }) !== false
36485
+ );
36486
+ }
36487
+ function collectRawCandidates(node, flat, declaringRole, out = []) {
36488
+ const axis = node.presentationOf?.axis;
36489
+ if (axis && axis.length > 0) {
36490
+ const groups = resolveAnchoredContentPerAnchor(node, flat);
36491
+ const iterationPosition = (iteration) => groups.length > 1 ? { position: iteration + 1, total: groups.length } : void 0;
36492
+ groups.forEach((content, iteration) => {
36493
+ if (!guardAllows(node, flat, iterationPosition(iteration))) {
36494
+ return;
36495
+ }
36496
+ out.push({ node, declaringRole, content, iteration, iterationCount: groups.length });
36497
+ });
36498
+ return out;
36499
+ }
36500
+ if (!guardAllows(node, flat, void 0)) {
36501
+ return out;
36502
+ }
36503
+ const nextRole = roleOf(node);
36504
+ for (const child262 of node.children ?? []) {
36505
+ collectRawCandidates(child262, flat, nextRole, out);
36506
+ }
36507
+ return out;
36508
+ }
36004
36509
  function collectChooseAwareSlots(node, flat, box, index, declaringRole) {
36005
36510
  const candidates = collectRawCandidates(node, flat, declaringRole);
36006
36511
  return resolveGroupedSlots(candidates, box, index);
@@ -36035,7 +36540,7 @@ var init_smartart_layout_interpreter_composite_choose = __esm({
36035
36540
  "src/core/utils/smartart-layout-interpreter-composite-choose.ts"() {
36036
36541
  init_smartart_constraint_solver();
36037
36542
  init_smartart_layout_interpreter_composite_anchor();
36038
- init_smartart_layout_interpreter_composite_slots();
36543
+ init_smartart_layout_interpreter_composite_group_slots();
36039
36544
  init_smartart_layout_interpreter_render();
36040
36545
  init_smartart_layout_interpreter_when();
36041
36546
  }
@@ -36273,165 +36778,6 @@ var init_smartart_layout_interpreter_composite = __esm({
36273
36778
  init_smartart_node_tree_axis();
36274
36779
  }
36275
36780
  });
36276
- function resolveHubToNodeRatio(ringItem, arrangerConstraints) {
36277
- if (!ringItem?.name) {
36278
- return void 0;
36279
- }
36280
- const match = (arrangerConstraints ?? []).find(
36281
- (c) => c.type === "w" && c.forName === ringItem.name && c.referenceType === "w" && (c.factor === void 0 || typeof c.factor === "number" && c.factor > 0) && typeof c.referenceForName === "string"
36282
- );
36283
- if (!match) {
36284
- return void 0;
36285
- }
36286
- return { hubName: match.referenceForName, factor: match.factor ?? 1 };
36287
- }
36288
- function resolveHubGapRatio(itemName, hubRatio, arrangerConstraints) {
36289
- if (!hubRatio) {
36290
- return void 0;
36291
- }
36292
- const sp = (arrangerConstraints ?? []).find(
36293
- (c) => c.type === "sp" && typeof c.factor === "number" && typeof c.referenceForName === "string"
36294
- );
36295
- if (!sp || typeof sp.factor !== "number") {
36296
- return void 0;
36297
- }
36298
- if (sp.referenceForName === itemName) {
36299
- return sp.factor;
36300
- }
36301
- if (sp.referenceForName === hubRatio.hubName) {
36302
- return sp.factor / hubRatio.factor;
36303
- }
36304
- return void 0;
36305
- }
36306
- var init_smartart_layout_interpreter_cycle_hub_ratio = __esm({
36307
- "src/core/utils/smartart-layout-interpreter-cycle-hub-ratio.ts"() {
36308
- }
36309
- });
36310
- function deriveCompositeSquareChildAspect(item) {
36311
- if (!item || item.algorithm?.type !== "composite") {
36312
- return void 0;
36313
- }
36314
- const constraints = item.allConstraints ?? item.constraints ?? [];
36315
- for (const width of constraints) {
36316
- if (width.type !== "w" || width.for !== "ch" || !width.forName || width.referenceForName !== void 0 || typeof width.factor !== "number" || width.factor <= 0) {
36317
- continue;
36318
- }
36319
- const childName = width.forName;
36320
- const isSelfSquare = constraints.some(
36321
- (c) => c.type === "h" && c.for === "ch" && c.forName === childName && c.referenceType === "w" && c.referenceFor === "ch" && c.referenceForName === childName
36322
- );
36323
- if (isSelfSquare) {
36324
- return width.factor;
36325
- }
36326
- }
36327
- return void 0;
36328
- }
36329
- function resolveGraphAspectRatio(item, index) {
36330
- if (!item) {
36331
- return void 0;
36332
- }
36333
- const role = roleOf(item);
36334
- const resolvedH = resolveConstraint(index, role, "h");
36335
- const resolvedW = resolveConstraint(index, role, "w");
36336
- if (resolvedH === void 0 || resolvedW === void 0 || resolvedW <= 0) {
36337
- return void 0;
36338
- }
36339
- return resolvedH / resolvedW;
36340
- }
36341
- var init_smartart_layout_interpreter_cycle_item_aspect = __esm({
36342
- "src/core/utils/smartart-layout-interpreter-cycle-item-aspect.ts"() {
36343
- init_smartart_constraint_solver();
36344
- }
36345
- });
36346
- function absoluteConstraintPoints(constraint) {
36347
- if (constraint === void 0 || constraint.factor !== void 0 || constraint.referenceType !== void 0 || typeof constraint.value !== "number" || !Number.isFinite(constraint.value) || constraint.value < 1) {
36348
- return void 0;
36349
- }
36350
- return constraint.value;
36351
- }
36352
- function resolveCycleConstraintNode(arrangerNode) {
36353
- if (arrangerNode.name === "cycle") {
36354
- return arrangerNode;
36355
- }
36356
- for (const child262 of arrangerNode.children ?? []) {
36357
- if (child262.name === "cycle") {
36358
- return child262;
36359
- }
36360
- }
36361
- return arrangerNode;
36362
- }
36363
- function resolveRingItemNode(constraintNode, arrangerConstraints) {
36364
- const sibSpName = (arrangerConstraints ?? []).find(
36365
- (c) => c.type === "sibSp" && typeof c.referenceForName === "string"
36366
- )?.referenceForName;
36367
- const named = sibSpName ? (constraintNode.children ?? []).find((child262) => child262.name === sibSpName) : void 0;
36368
- if (named?.forEachOrigin) {
36369
- return named;
36370
- }
36371
- const repeating = (constraintNode.children ?? []).find((child262) => child262.forEachOrigin);
36372
- return repeating ?? named ?? itemNode(constraintNode);
36373
- }
36374
- function resolveCycleRingParams(arrangerNode, index) {
36375
- const constraintNode = resolveCycleConstraintNode(arrangerNode);
36376
- const arrangerConstraints = constraintNode.allConstraints ?? constraintNode.constraints;
36377
- const item = resolveRingItemNode(constraintNode, arrangerConstraints);
36378
- const itemConstraints = item?.allConstraints ?? item?.constraints;
36379
- const literalHeightOverWidth = ratioConstraint(
36380
- itemConstraints ?? [],
36381
- ["h"],
36382
- Number.NaN,
36383
- item?.rules
36384
- );
36385
- const heightOverWidth = !Number.isNaN(literalHeightOverWidth) ? literalHeightOverWidth : resolveGraphAspectRatio(item, index) ?? resolveRatioConstraint(
36386
- itemConstraints,
36387
- index,
36388
- roleOf(item),
36389
- ["h"],
36390
- deriveCompositeSquareChildAspect(item) ?? 1,
36391
- item?.rules
36392
- );
36393
- const hubRatio = resolveHubToNodeRatio(item, arrangerConstraints);
36394
- const hubGapRatio = resolveHubGapRatio(item?.name, hubRatio, arrangerConstraints);
36395
- const absolutePoints = absoluteConstraintPoints(findConstraint(arrangerConstraints, "sibSp"));
36396
- if (absolutePoints !== void 0) {
36397
- return {
36398
- minGapRatio: DEFAULT_MIN_GAP_RATIO,
36399
- heightOverWidth,
36400
- absoluteGapPx: absolutePoints * POINTS_TO_PIXELS3,
36401
- hubRatio,
36402
- hubGapRatio
36403
- };
36404
- }
36405
- const minGapRatio = resolveRatioConstraint(
36406
- arrangerConstraints,
36407
- index,
36408
- roleOf(constraintNode),
36409
- ["sibSp"],
36410
- DEFAULT_MIN_GAP_RATIO,
36411
- constraintNode.rules
36412
- );
36413
- return {
36414
- minGapRatio: Math.max(DEFAULT_MIN_GAP_RATIO, minGapRatio),
36415
- heightOverWidth,
36416
- hubRatio,
36417
- hubGapRatio
36418
- };
36419
- }
36420
- var POINTS_TO_PIXELS3;
36421
- var DEFAULT_MIN_GAP_RATIO;
36422
- var init_smartart_layout_interpreter_cycle_constraints = __esm({
36423
- "src/core/utils/smartart-layout-interpreter-cycle-constraints.ts"() {
36424
- init_smartart_constraint_ratio_fallback();
36425
- init_smartart_constraint_solver();
36426
- init_smartart_layout_interpreter_constraints();
36427
- init_smartart_layout_interpreter_cycle_hub_ratio();
36428
- init_smartart_layout_interpreter_cycle_item_aspect();
36429
- init_smartart_layout_interpreter_model();
36430
- init_smartart_layout_interpreter_cycle_hub_ratio();
36431
- POINTS_TO_PIXELS3 = 96 / 72;
36432
- DEFAULT_MIN_GAP_RATIO = 0.5;
36433
- }
36434
- });
36435
36781
  function degenerateRingLayout(n, heightOverWidth, box) {
36436
36782
  const boxCentre = { x: box.width / 2, y: box.height / 2 };
36437
36783
  if (n <= 0) {
@@ -36486,22 +36832,18 @@ function ringLayoutForGapFactor(n, stAngDeg, spanDeg, gapFactor, heightOverWidth
36486
36832
  const maxX = Math.max(...xs) + halfW;
36487
36833
  const minY = Math.min(...ys) - halfH;
36488
36834
  const maxY = Math.max(...ys) + halfH;
36489
- const spreadX = Math.max(...xs) - Math.min(...xs);
36490
- const spreadY = Math.max(...ys) - Math.min(...ys);
36491
36835
  const naturalBoundW = Math.max(1e-6, maxX - minX);
36492
36836
  const naturalBoundH = Math.max(1e-6, maxY - minY);
36493
- let scaleX = box.width / naturalBoundW;
36494
- let scaleY = box.height / naturalBoundH;
36495
- if (spreadX < 1e-6 && spreadY >= 1e-6) {
36496
- scaleX = scaleY;
36497
- } else if (spreadY < 1e-6 && spreadX >= 1e-6) {
36498
- scaleY = scaleX;
36499
- }
36837
+ const scale2 = Math.min(box.width / naturalBoundW, box.height / naturalBoundH);
36838
+ const scaleX = scale2;
36839
+ const scaleY = scale2;
36840
+ const offsetX = (box.width - naturalBoundW * scale2) / 2;
36841
+ const offsetY = (box.height - naturalBoundH * scale2) / 2;
36500
36842
  const centers = natural.map((p) => ({
36501
- x: (p.x - minX) * scaleX,
36502
- y: (p.y - minY) * scaleY
36843
+ x: (p.x - minX) * scaleX + offsetX,
36844
+ y: (p.y - minY) * scaleY + offsetY
36503
36845
  }));
36504
- const hubCenter = { x: (0 - minX) * scaleX, y: (0 - minY) * scaleY };
36846
+ const hubCenter = { x: (0 - minX) * scaleX + offsetX, y: (0 - minY) * scaleY + offsetY };
36505
36847
  const naturalHubRadius = Math.max(0, r0 - Math.max(halfW, halfH));
36506
36848
  return {
36507
36849
  centers,
@@ -36512,12 +36854,14 @@ function ringLayoutForGapFactor(n, stAngDeg, spanDeg, gapFactor, heightOverWidth
36512
36854
  hubHalfHeight: naturalHubRadius * scaleY
36513
36855
  };
36514
36856
  }
36515
- function computeCycleRingLayout(n, stAngDeg, spanDeg, minGapRatio, heightOverWidth, box, absoluteGapPx, hubGeometry) {
36857
+ function computeCycleRingLayout(n, stAngDeg, spanDeg, minGapRatio, heightOverWidth, box, absoluteGapPx, hubGeometry, absoluteHubGapPx) {
36516
36858
  const degenerate = degenerateRingLayout(n, heightOverWidth, box);
36517
36859
  if (degenerate) {
36518
36860
  return degenerate;
36519
36861
  }
36520
- if (absoluteGapPx === void 0 || absoluteGapPx <= 0) {
36862
+ const needsGapIteration = absoluteGapPx !== void 0 && absoluteGapPx > 0;
36863
+ const needsHubGapIteration = absoluteHubGapPx !== void 0 && absoluteHubGapPx > 0 && hubGeometry !== void 0;
36864
+ if (!needsGapIteration && !needsHubGapIteration) {
36521
36865
  return ringLayoutForGapFactor(
36522
36866
  n,
36523
36867
  stAngDeg,
@@ -36529,6 +36873,7 @@ function computeCycleRingLayout(n, stAngDeg, spanDeg, minGapRatio, heightOverWid
36529
36873
  );
36530
36874
  }
36531
36875
  let gapFactor = minGapRatio;
36876
+ let hub = hubGeometry;
36532
36877
  for (let iteration = 0; iteration < 20; iteration += 1) {
36533
36878
  const candidate = ringLayoutForGapFactor(
36534
36879
  n,
@@ -36537,16 +36882,21 @@ function computeCycleRingLayout(n, stAngDeg, spanDeg, minGapRatio, heightOverWid
36537
36882
  gapFactor,
36538
36883
  heightOverWidth,
36539
36884
  box,
36540
- hubGeometry
36885
+ hub
36541
36886
  );
36542
- const nextGapFactor = candidate.nodeWidth > 1e-6 ? absoluteGapPx / candidate.nodeWidth : gapFactor;
36543
- if (Math.abs(nextGapFactor - gapFactor) < 1e-9) {
36544
- gapFactor = nextGapFactor;
36887
+ const nextGapFactor = needsGapIteration && candidate.nodeWidth > 1e-6 ? absoluteGapPx / candidate.nodeWidth : gapFactor;
36888
+ const nextHubGapRatio = needsHubGapIteration && candidate.nodeWidth > 1e-6 ? absoluteHubGapPx / candidate.nodeWidth : hub?.gapRatio;
36889
+ const gapConverged = Math.abs(nextGapFactor - gapFactor) < 1e-9;
36890
+ const hubGapConverged = !needsHubGapIteration || Math.abs((nextHubGapRatio ?? 0) - (hub?.gapRatio ?? 0)) < 1e-9;
36891
+ gapFactor = nextGapFactor;
36892
+ if (needsHubGapIteration && hub) {
36893
+ hub = { ...hub, gapRatio: nextHubGapRatio ?? hub.gapRatio };
36894
+ }
36895
+ if (gapConverged && hubGapConverged) {
36545
36896
  break;
36546
36897
  }
36547
- gapFactor = nextGapFactor;
36548
36898
  }
36549
- return ringLayoutForGapFactor(n, stAngDeg, spanDeg, gapFactor, heightOverWidth, box, hubGeometry);
36899
+ return ringLayoutForGapFactor(n, stAngDeg, spanDeg, gapFactor, heightOverWidth, box, hub);
36550
36900
  }
36551
36901
  var DEG_TO_RAD;
36552
36902
  var init_smartart_layout_interpreter_cycle_ring = __esm({
@@ -36557,14 +36907,14 @@ var init_smartart_layout_interpreter_cycle_ring = __esm({
36557
36907
  function arrangeCycle(plan, nodes, box, palette, style, elementId, index = EMPTY_CONSTRAINT_INDEX, hubAlreadyStripped = false) {
36558
36908
  const { width: w, height: h2 } = box;
36559
36909
  const ctx = styleContext(style);
36560
- const { minGapRatio, heightOverWidth, absoluteGapPx, hubRatio, hubGapRatio } = resolveCycleRingParams(plan.node, index);
36910
+ const { minGapRatio, heightOverWidth, absoluteGapPx, hubRatio, hubGapRatio, absoluteHubGapPx } = resolveCycleRingParams(plan.node, index);
36561
36911
  const hasHub = !hubAlreadyStripped && !hubRatio && algorithmParam(plan.node, "ctrShpMap") === "fNode" && nodes.length > 0;
36562
36912
  const hubNode = hasHub ? nodes[0] : void 0;
36563
36913
  const ringNodes = hasHub ? nodes.slice(1) : nodes;
36564
36914
  const n = ringNodes.length;
36565
36915
  const startDeg = numericParam(plan.node, "stAng", 0);
36566
36916
  const spanDeg = numericParam(plan.node, "spanAng", 360);
36567
- const hubGeometry = hubRatio && hubGapRatio !== void 0 ? { factor: hubRatio.factor, gapRatio: hubGapRatio } : void 0;
36917
+ const hubGeometry = hubRatio && (hubGapRatio !== void 0 || absoluteHubGapPx !== void 0) ? { factor: hubRatio.factor, gapRatio: hubGapRatio ?? 0 } : void 0;
36568
36918
  const ring = computeCycleRingLayout(
36569
36919
  n,
36570
36920
  startDeg,
@@ -36573,7 +36923,8 @@ function arrangeCycle(plan, nodes, box, palette, style, elementId, index = EMPTY
36573
36923
  heightOverWidth,
36574
36924
  box,
36575
36925
  absoluteGapPx,
36576
- hubGeometry
36926
+ hubGeometry,
36927
+ absoluteHubGapPx
36577
36928
  );
36578
36929
  const full = Math.abs(spanDeg) >= 360;
36579
36930
  const connectorCount = n > 0 ? full ? n : Math.max(0, n - 1) : 0;
@@ -37087,6 +37438,58 @@ var init_smartart_hierarchy_hanging = __esm({
37087
37438
  init_smartart_hierarchy_shared();
37088
37439
  }
37089
37440
  });
37441
+ function findCompositeDescendant(node) {
37442
+ if (!node) {
37443
+ return void 0;
37444
+ }
37445
+ if (node.algorithm?.type === "composite") {
37446
+ return node;
37447
+ }
37448
+ for (const child262 of node.children ?? []) {
37449
+ const found = findCompositeDescendant(child262);
37450
+ if (found) {
37451
+ return found;
37452
+ }
37453
+ }
37454
+ return void 0;
37455
+ }
37456
+ function findTextBearingChild(compositeNode) {
37457
+ return (compositeNode.children ?? []).find(
37458
+ (child262) => (child262.presentationOf?.axis ?? []).includes("self")
37459
+ );
37460
+ }
37461
+ function resolveCompositeChildGeometry(algorithmNode) {
37462
+ const compositeNode = findCompositeDescendant(algorithmNode);
37463
+ if (!compositeNode) {
37464
+ return void 0;
37465
+ }
37466
+ const child262 = findTextBearingChild(compositeNode);
37467
+ if (!child262?.name) {
37468
+ return void 0;
37469
+ }
37470
+ const constraints = compositeNode.allConstraints ?? compositeNode.constraints ?? [];
37471
+ const widthConstr = constraints.find(
37472
+ (c) => c.type === "w" && c.for === "ch" && c.forName === child262.name && c.referenceType === "w" && c.referenceForName === void 0 && typeof c.factor === "number"
37473
+ );
37474
+ const heightConstr = constraints.find(
37475
+ (c) => c.type === "h" && c.for === "ch" && c.forName === child262.name && c.referenceType === "w" && c.referenceFor === "ch" && c.referenceForName === child262.name && typeof c.factor === "number"
37476
+ );
37477
+ const leftConstr = constraints.find(
37478
+ (c) => c.type === "l" && c.for === "ch" && c.forName === child262.name && c.referenceType === "w" && c.referenceForName === void 0 && typeof c.factor === "number"
37479
+ );
37480
+ if (!widthConstr || !heightConstr || widthConstr.factor === void 0 || widthConstr.factor <= 0) {
37481
+ return void 0;
37482
+ }
37483
+ return {
37484
+ aspectRatio: heightConstr.factor,
37485
+ widthFactor: widthConstr.factor,
37486
+ offsetXRatio: leftConstr?.factor ?? 0
37487
+ };
37488
+ }
37489
+ var init_smartart_hierarchy_composite_child = __esm({
37490
+ "src/core/utils/smartart-hierarchy-composite-child.ts"() {
37491
+ }
37492
+ });
37090
37493
  function transposeNode(node) {
37091
37494
  switch (node.kind) {
37092
37495
  case "rect":
@@ -37151,7 +37554,8 @@ function fitItemBox(box, columns, levels, sibSpRatio, aspectRatio, generationGap
37151
37554
  const heightFit = usableH / (generations + maxHangDepth + Math.max(0, generations - 1) * generationGapRatio + maxHangDepth * HANG_HEIGHT_RATIO);
37152
37555
  const naturalHeight = widthFit * aspectRatio;
37153
37556
  const boxH = clampToNaturalAspect ? Math.min(naturalHeight, heightFit) : heightFit;
37154
- return { boxW: Math.max(1, widthFit), boxH: Math.max(1, boxH) };
37557
+ const boxW = clampToNaturalAspect ? boxH / aspectRatio : widthFit;
37558
+ return { boxW: Math.max(1, boxW), boxH: Math.max(1, boxH) };
37155
37559
  }
37156
37560
  var init_smartart_hierarchy_fit_item_box = __esm({
37157
37561
  "src/core/utils/smartart-hierarchy-fit-item-box.ts"() {
@@ -37175,7 +37579,7 @@ function resolveAspectRatio(constraints) {
37175
37579
  }
37176
37580
  return DEFAULT_ASPECT_RATIO;
37177
37581
  }
37178
- function resolveGenerationGapRatio(constraints, stackingAxis, aspectRatio) {
37582
+ function resolveGenerationGapRatio(constraints, stackingAxis, aspectRatio, compositeChild, compositeAspect) {
37179
37583
  const onStackingAxis = findByReference(constraints, "sp", stackingAxis);
37180
37584
  if (onStackingAxis !== void 0) {
37181
37585
  return onStackingAxis;
@@ -37210,10 +37614,15 @@ function resolveHierarchyOrientation(algorithmNode, index, mode = "std") {
37210
37614
  // See `OUTER_MARGIN_X_RATIO`'s doc comment: a transposed hierarchy
37211
37615
  // needs no outer margin at all on either axis, COM-verified.
37212
37616
  marginXRatio: 0,
37213
- marginYRatio: 0
37617
+ marginYRatio: 0,
37618
+ // A transposed hierarchy declares no `composite` wrapper (see
37619
+ // `smartart-hierarchy-composite-child.ts`'s own module doc comment) -
37620
+ // nothing to correct or offset from.
37621
+ cardOffsetXRatio: 0
37214
37622
  };
37215
37623
  }
37216
- const aspectRatio = resolveAspectRatio(constraints);
37624
+ const compositeChild = resolveCompositeChildGeometry(algorithmNode);
37625
+ const aspectRatio = compositeChild?.aspectRatio ?? resolveAspectRatio(constraints);
37217
37626
  const tailedMargin = mode === "tailed";
37218
37627
  return {
37219
37628
  transposed: false,
@@ -37221,7 +37630,9 @@ function resolveHierarchyOrientation(algorithmNode, index, mode = "std") {
37221
37630
  aspectRatio,
37222
37631
  generationGapRatio: resolveGenerationGapRatio(constraints, "h", aspectRatio),
37223
37632
  marginXRatio: tailedMargin ? 0 : OUTER_MARGIN_X_RATIO,
37224
- marginYRatio: tailedMargin ? 0 : OUTER_MARGIN_Y_RATIO
37633
+ marginYRatio: tailedMargin ? 0 : OUTER_MARGIN_Y_RATIO,
37634
+ compositeWidthFactor: compositeChild?.widthFactor,
37635
+ cardOffsetXRatio: compositeChild?.offsetXRatio ?? 0
37225
37636
  };
37226
37637
  }
37227
37638
  var DEFAULT_ASPECT_RATIO;
@@ -37233,6 +37644,7 @@ var init_smartart_hierarchy_orientation = __esm({
37233
37644
  "src/core/utils/smartart-hierarchy-orientation.ts"() {
37234
37645
  init_smartart_constraint_ratio_fallback();
37235
37646
  init_smartart_constraint_solver();
37647
+ init_smartart_hierarchy_composite_child();
37236
37648
  init_smartart_hierarchy_transpose();
37237
37649
  init_smartart_hierarchy_fit_item_box();
37238
37650
  init_smartart_hierarchy_child_order();
@@ -37251,6 +37663,21 @@ function computeAxisPitch(dimension, margin, itemSize, count) {
37251
37663
  const maxShift = dimension - n * itemSize - gap * (n - 0.5);
37252
37664
  return { pitch, shift: Math.min(rawShift, maxShift) };
37253
37665
  }
37666
+ function centeredAxisPitch(dimension, itemSize, gapRatio, count) {
37667
+ const n = Math.max(1, count);
37668
+ const gap = n > 1 ? itemSize * Math.max(0, gapRatio) : 0;
37669
+ const pitch = itemSize + gap;
37670
+ const span = n * itemSize + Math.max(0, n - 1) * gap;
37671
+ const shift = (dimension - span) / 2;
37672
+ return { pitch, shift };
37673
+ }
37674
+ function compositeFanPitch(dimension, boxW, compositeWidthFactor, cardOffsetXRatio, sibSpRatio, count) {
37675
+ const compositeW = compositeWidthFactor ? boxW / compositeWidthFactor : boxW;
37676
+ const cardOffsetX = cardOffsetXRatio * compositeW;
37677
+ const centred = centeredAxisPitch(dimension, compositeW, sibSpRatio, count);
37678
+ const correction = cardOffsetX + boxW / 2 - centred.pitch / 2;
37679
+ return { pitch: centred.pitch, shift: centred.shift + correction };
37680
+ }
37254
37681
  function translateNode(node, dx, dy) {
37255
37682
  switch (node.kind) {
37256
37683
  case "rect":
@@ -37302,11 +37729,9 @@ function translateResult(result, dx, dy) {
37302
37729
  return { ...result, nodes, connectors };
37303
37730
  }
37304
37731
  var GENERATION_MARGIN_RATIO;
37305
- var FAN_MARGIN_RATIO;
37306
37732
  var init_smartart_hierarchy_pitch = __esm({
37307
37733
  "src/core/utils/smartart-hierarchy-pitch.ts"() {
37308
37734
  GENERATION_MARGIN_RATIO = 0.1675;
37309
- FAN_MARGIN_RATIO = 0.1115;
37310
37735
  }
37311
37736
  });
37312
37737
  function planFan(childCount, perRow, siblingCxs) {
@@ -37665,11 +38090,17 @@ function arrangeHierarchy(nodes, box, palette, style, elementId, presLayoutVars,
37665
38090
  mode !== "tailed"
37666
38091
  );
37667
38092
  const tailedPitch = mode === "tailed";
37668
- const fanMargin = orientation.transposed || tailedPitch ? 0 : boxW * FAN_MARGIN_RATIO;
37669
38093
  const generationMargin = orientation.transposed || tailedPitch ? 0 : boxH * GENERATION_MARGIN_RATIO;
37670
38094
  const fanWidth = tailedPitch ? effectiveBox.width - hangShape.maxHangDepth * HIER_TAIL_OFFSET_RATIO * boxW : effectiveBox.width;
37671
38095
  const fanHeight = tailedPitch ? effectiveBox.height - hangShape.maxHangDepth * (1 + HANG_HEIGHT_RATIO) * boxH : effectiveBox.height;
37672
- const xPitch = computeAxisPitch(fanWidth, fanMargin, boxW, totalLeaves);
38096
+ const xPitch = compositeFanPitch(
38097
+ fanWidth,
38098
+ boxW,
38099
+ orientation.compositeWidthFactor,
38100
+ orientation.cardOffsetXRatio,
38101
+ orientation.sibSpRatio,
38102
+ totalLeaves
38103
+ );
37673
38104
  const yPitch = computeAxisPitch(fanHeight, generationMargin, boxH, depth);
37674
38105
  const cellW = xPitch.pitch;
37675
38106
  const cellH = yPitch.pitch;
@@ -38049,15 +38480,24 @@ function stackRoleContent(content, arrangerRole, original, index) {
38049
38480
  if (original.kind === "rect") {
38050
38481
  return stackAsRect(content, arrangerRole, original, boundingBoxOf(original), index);
38051
38482
  }
38052
- if (original.kind !== "polygon" && (everyRoleIsRect || hasMixedExplicitKinds)) {
38483
+ if (everyRoleIsRect) {
38053
38484
  return stackAsRect(content, arrangerRole, original, boundingBoxOf(original), index);
38054
38485
  }
38055
- if (original.kind !== "polygon") {
38056
- return void 0;
38486
+ if (original.kind === "polygon") {
38487
+ return splitAsUnchangedCopy(content, original);
38488
+ }
38489
+ if (original.kind === "circle") {
38490
+ return hasMixedExplicitKinds ? splitAsUnchangedCopy(content, original) : void 0;
38491
+ }
38492
+ if (hasMixedExplicitKinds) {
38493
+ return stackAsRect(content, arrangerRole, original, boundingBoxOf(original), index);
38057
38494
  }
38495
+ return void 0;
38496
+ }
38497
+ function splitAsUnchangedCopy(content, original) {
38058
38498
  return content.map((entry2, i2) => {
38059
38499
  const fields = splitEntryFields(entry2, `${original.key}-role${i2}`, original);
38060
- const isSelfRole = entry2.role.presentationOf?.axis?.includes("self") ?? false;
38500
+ const isSelfRole = original.kind === "polygon" && (entry2.role.presentationOf?.axis?.includes("self") ?? false);
38061
38501
  const presetOverride = isSelfRole ? original.presetOverride : fields.presetOverride;
38062
38502
  return { ...original, ...fields, presetOverride };
38063
38503
  });
@@ -38489,7 +38929,7 @@ function runArrangement(input) {
38489
38929
  );
38490
38930
  }
38491
38931
  const roots = topLevelSmartArtNodes(nodes);
38492
- const childrenOf = smartArtChildrenOf(nodes);
38932
+ const childrenOf = smartArtChildrenOf(nodes, input.connections);
38493
38933
  const preArranged = plan.kind === "composite" ? roots.length > 0 ? roots : flat : selectArrangedNodes(plan.node, flat, roots);
38494
38934
  const hub = detectHubExpansion(plan.node, preArranged, childrenOf);
38495
38935
  const arranged = hub ? applyChildOrder(hub.satellites, buildChildOrder(input.connections)) : preArranged;
@@ -38537,8 +38977,13 @@ function runArrangement(input) {
38537
38977
  hasAccentSomewhere,
38538
38978
  constraintIndex
38539
38979
  ) : withItemRoles;
38980
+ const withCycleRingContent = plan.kind === "cycle" ? repositionCycleRingContent(
38981
+ withPyramidBands,
38982
+ resolveCycleRingParams(plan.node, constraintIndex).contentLayout,
38983
+ flat
38984
+ ) : withPyramidBands;
38540
38985
  if (!hub) {
38541
- return withPyramidBands;
38986
+ return withCycleRingContent;
38542
38987
  }
38543
38988
  const hubNode = buildHubRenderedNode(
38544
38989
  plan.node,
@@ -38550,7 +38995,7 @@ function runArrangement(input) {
38550
38995
  hub.satellites.length,
38551
38996
  constraintIndex
38552
38997
  );
38553
- return { ...withPyramidBands, nodes: [hubNode, ...withPyramidBands.nodes] };
38998
+ return { ...withCycleRingContent, nodes: [hubNode, ...withCycleRingContent.nodes] };
38554
38999
  }
38555
39000
  function interpretSmartArtLayout(input) {
38556
39001
  const result = runArrangement(input);
@@ -38567,6 +39012,8 @@ var init_smartart_layout_interpreter = __esm({
38567
39012
  init_smartart_hierarchy_child_order();
38568
39013
  init_smartart_layout_interpreter_connector_order();
38569
39014
  init_smartart_layout_interpreter_custom();
39015
+ init_smartart_layout_interpreter_cycle_constraints();
39016
+ init_smartart_layout_interpreter_cycle_ring_item();
38570
39017
  init_smartart_layout_interpreter_dispatch();
38571
39018
  init_smartart_layout_interpreter_flow();
38572
39019
  init_smartart_layout_interpreter_hierarchy();
@@ -38919,7 +39366,8 @@ function computeSmartArtElementsWithoutCache(smartArtData, containerBounds, them
38919
39366
  interpreted,
38920
39367
  nodes,
38921
39368
  containerBounds,
38922
- smartArtData.presLayoutVars?.bulletEnabled
39369
+ smartArtData.presLayoutVars?.bulletEnabled,
39370
+ smartArtData.connections
38923
39371
  );
38924
39372
  }
38925
39373
  }
@@ -50117,13 +50565,14 @@ function nestedLayoutNodes(node, localName28) {
50117
50565
  } else if (name === "if") {
50118
50566
  for (const ifNode of Array.isArray(entry2) ? entry2 : [entry2]) {
50119
50567
  if (ifNode && typeof ifNode === "object") {
50120
- visit(ifNode, origin, parseWhen(ifNode));
50568
+ const when = parseWhen(ifNode);
50569
+ visit(ifNode, origin, when ? [...guard, when] : guard);
50121
50570
  }
50122
50571
  }
50123
50572
  } else if (name === "else") {
50124
50573
  for (const elseNode of Array.isArray(entry2) ? entry2 : [entry2]) {
50125
50574
  if (elseNode && typeof elseNode === "object") {
50126
- visit(elseNode, origin, void 0);
50575
+ visit(elseNode, origin, guard);
50127
50576
  }
50128
50577
  }
50129
50578
  } else {
@@ -50133,7 +50582,7 @@ function nestedLayoutNodes(node, localName28) {
50133
50582
  };
50134
50583
  for (const [key2, value] of Object.entries(node)) {
50135
50584
  if (!key2.startsWith("@_") && localName28(key2) !== "extLst") {
50136
- visit({ [key2]: value }, void 0, void 0);
50585
+ visit({ [key2]: value }, void 0, []);
50137
50586
  }
50138
50587
  }
50139
50588
  return found;
@@ -50304,7 +50753,7 @@ function parseNode(node, localName28) {
50304
50753
  const nested = nestedLayoutNodes(node, localName28).map((entry2) => ({
50305
50754
  ...parseNode(entry2.xml, localName28),
50306
50755
  forEachOrigin: entry2.origin,
50307
- chooseGuard: entry2.guard
50756
+ chooseGuard: entry2.guard.length > 0 ? entry2.guard : void 0
50308
50757
  }));
50309
50758
  const childOrder3 = optionalString4(node["@_chOrder"]);
50310
50759
  const presOf = choosePresentationOf(node, localName28);