@activecollab/components 2.0.588 → 2.0.590

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 (133) hide show
  1. package/dist/cjs/components/CommandPalette/CommandPalette.js +90 -62
  2. package/dist/cjs/components/CommandPalette/CommandPalette.js.map +1 -1
  3. package/dist/cjs/components/CommandPalette/CommandPalette.styles.js +34 -16
  4. package/dist/cjs/components/CommandPalette/CommandPalette.styles.js.map +1 -1
  5. package/dist/cjs/components/CommandPalette/CommandPaletteCommandItem.js +1 -0
  6. package/dist/cjs/components/CommandPalette/CommandPaletteCommandItem.js.map +1 -1
  7. package/dist/cjs/components/CommandPalette/CommandPaletteHeader.js +40 -9
  8. package/dist/cjs/components/CommandPalette/CommandPaletteHeader.js.map +1 -1
  9. package/dist/cjs/components/CommandPalette/CommandPaletteItem.js +13 -4
  10. package/dist/cjs/components/CommandPalette/CommandPaletteItem.js.map +1 -1
  11. package/dist/cjs/components/CommandPalette/CommandPaletteVirtualList.js +125 -0
  12. package/dist/cjs/components/CommandPalette/CommandPaletteVirtualList.js.map +1 -0
  13. package/dist/cjs/components/CommandPalette/context/SelectedContext.js.map +1 -1
  14. package/dist/cjs/components/GlobalStyle.js +1 -1
  15. package/dist/cjs/components/GlobalStyle.js.map +1 -1
  16. package/dist/cjs/components/ObjectLayout/ObjectLayout.js +5 -1
  17. package/dist/cjs/components/ObjectLayout/ObjectLayout.js.map +1 -1
  18. package/dist/cjs/components/ObjectLayout/Styles.js +17 -10
  19. package/dist/cjs/components/ObjectLayout/Styles.js.map +1 -1
  20. package/dist/cjs/components/PropertyList/PropertyList.js +12 -1
  21. package/dist/cjs/components/PropertyList/PropertyList.js.map +1 -1
  22. package/dist/cjs/components/PropertyList/Styles.js +58 -51
  23. package/dist/cjs/components/PropertyList/Styles.js.map +1 -1
  24. package/dist/cjs/components/Section/Section.js +4 -1
  25. package/dist/cjs/components/Section/Section.js.map +1 -1
  26. package/dist/cjs/components/Section/Styles.js +7 -3
  27. package/dist/cjs/components/Section/Styles.js.map +1 -1
  28. package/dist/cjs/components/TicketPerforation/TicketPerforation.js +7 -5
  29. package/dist/cjs/components/TicketPerforation/TicketPerforation.js.map +1 -1
  30. package/dist/cjs/presentation/whiteboard/elementToolbars.js +192 -1
  31. package/dist/cjs/presentation/whiteboard/elementToolbars.js.map +1 -1
  32. package/dist/cjs/presentation/whiteboard/inspector.js +6 -1
  33. package/dist/cjs/presentation/whiteboard/inspector.js.map +1 -1
  34. package/dist/cjs/presentation/whiteboard/lineElements.js +982 -0
  35. package/dist/cjs/presentation/whiteboard/lineElements.js.map +1 -0
  36. package/dist/cjs/presentation/whiteboard/lineInspector.js +301 -0
  37. package/dist/cjs/presentation/whiteboard/lineInspector.js.map +1 -0
  38. package/dist/cjs/presentation/whiteboard/lineModel.js +596 -0
  39. package/dist/cjs/presentation/whiteboard/lineModel.js.map +1 -0
  40. package/dist/cjs/presentation/whiteboard/outline.js +31 -12
  41. package/dist/cjs/presentation/whiteboard/outline.js.map +1 -1
  42. package/dist/cjs/presentation/whiteboardModern/toolDock.js +11 -17
  43. package/dist/cjs/presentation/whiteboardModern/toolDock.js.map +1 -1
  44. package/dist/esm/components/CommandPalette/CommandPalette.d.ts +13 -3
  45. package/dist/esm/components/CommandPalette/CommandPalette.d.ts.map +1 -1
  46. package/dist/esm/components/CommandPalette/CommandPalette.js +77 -53
  47. package/dist/esm/components/CommandPalette/CommandPalette.js.map +1 -1
  48. package/dist/esm/components/CommandPalette/CommandPalette.styles.d.ts +9 -2
  49. package/dist/esm/components/CommandPalette/CommandPalette.styles.d.ts.map +1 -1
  50. package/dist/esm/components/CommandPalette/CommandPalette.styles.js +30 -14
  51. package/dist/esm/components/CommandPalette/CommandPalette.styles.js.map +1 -1
  52. package/dist/esm/components/CommandPalette/CommandPaletteCommandItem.d.ts.map +1 -1
  53. package/dist/esm/components/CommandPalette/CommandPaletteCommandItem.js +1 -0
  54. package/dist/esm/components/CommandPalette/CommandPaletteCommandItem.js.map +1 -1
  55. package/dist/esm/components/CommandPalette/CommandPaletteHeader.d.ts +3 -1
  56. package/dist/esm/components/CommandPalette/CommandPaletteHeader.d.ts.map +1 -1
  57. package/dist/esm/components/CommandPalette/CommandPaletteHeader.js +40 -9
  58. package/dist/esm/components/CommandPalette/CommandPaletteHeader.js.map +1 -1
  59. package/dist/esm/components/CommandPalette/CommandPaletteItem.d.ts +7 -1
  60. package/dist/esm/components/CommandPalette/CommandPaletteItem.d.ts.map +1 -1
  61. package/dist/esm/components/CommandPalette/CommandPaletteItem.js +14 -5
  62. package/dist/esm/components/CommandPalette/CommandPaletteItem.js.map +1 -1
  63. package/dist/esm/components/CommandPalette/CommandPaletteVirtualList.d.ts +21 -0
  64. package/dist/esm/components/CommandPalette/CommandPaletteVirtualList.d.ts.map +1 -0
  65. package/dist/esm/components/CommandPalette/CommandPaletteVirtualList.js +104 -0
  66. package/dist/esm/components/CommandPalette/CommandPaletteVirtualList.js.map +1 -0
  67. package/dist/esm/components/CommandPalette/context/SelectedContext.d.ts +5 -0
  68. package/dist/esm/components/CommandPalette/context/SelectedContext.d.ts.map +1 -1
  69. package/dist/esm/components/CommandPalette/context/SelectedContext.js.map +1 -1
  70. package/dist/esm/components/GlobalStyle.d.ts.map +1 -1
  71. package/dist/esm/components/GlobalStyle.js +1 -1
  72. package/dist/esm/components/GlobalStyle.js.map +1 -1
  73. package/dist/esm/components/ObjectLayout/ObjectLayout.d.ts +2 -0
  74. package/dist/esm/components/ObjectLayout/ObjectLayout.d.ts.map +1 -1
  75. package/dist/esm/components/ObjectLayout/ObjectLayout.js +5 -1
  76. package/dist/esm/components/ObjectLayout/ObjectLayout.js.map +1 -1
  77. package/dist/esm/components/ObjectLayout/Styles.d.ts +1 -0
  78. package/dist/esm/components/ObjectLayout/Styles.d.ts.map +1 -1
  79. package/dist/esm/components/ObjectLayout/Styles.js +16 -9
  80. package/dist/esm/components/ObjectLayout/Styles.js.map +1 -1
  81. package/dist/esm/components/PropertyList/PropertyList.d.ts +6 -0
  82. package/dist/esm/components/PropertyList/PropertyList.d.ts.map +1 -1
  83. package/dist/esm/components/PropertyList/PropertyList.js +12 -1
  84. package/dist/esm/components/PropertyList/PropertyList.js.map +1 -1
  85. package/dist/esm/components/PropertyList/Styles.d.ts +2 -0
  86. package/dist/esm/components/PropertyList/Styles.d.ts.map +1 -1
  87. package/dist/esm/components/PropertyList/Styles.js +58 -51
  88. package/dist/esm/components/PropertyList/Styles.js.map +1 -1
  89. package/dist/esm/components/Section/Section.d.ts +2 -0
  90. package/dist/esm/components/Section/Section.d.ts.map +1 -1
  91. package/dist/esm/components/Section/Section.js +4 -1
  92. package/dist/esm/components/Section/Section.js.map +1 -1
  93. package/dist/esm/components/Section/Styles.d.ts +3 -1
  94. package/dist/esm/components/Section/Styles.d.ts.map +1 -1
  95. package/dist/esm/components/Section/Styles.js +6 -2
  96. package/dist/esm/components/Section/Styles.js.map +1 -1
  97. package/dist/esm/components/TicketPerforation/TicketPerforation.d.ts +2 -0
  98. package/dist/esm/components/TicketPerforation/TicketPerforation.d.ts.map +1 -1
  99. package/dist/esm/components/TicketPerforation/TicketPerforation.js +7 -5
  100. package/dist/esm/components/TicketPerforation/TicketPerforation.js.map +1 -1
  101. package/dist/esm/presentation/whiteboard/elementToolbars.d.ts +22 -0
  102. package/dist/esm/presentation/whiteboard/elementToolbars.d.ts.map +1 -1
  103. package/dist/esm/presentation/whiteboard/elementToolbars.js +151 -2
  104. package/dist/esm/presentation/whiteboard/elementToolbars.js.map +1 -1
  105. package/dist/esm/presentation/whiteboard/inspector.d.ts +10 -2
  106. package/dist/esm/presentation/whiteboard/inspector.d.ts.map +1 -1
  107. package/dist/esm/presentation/whiteboard/inspector.js +6 -2
  108. package/dist/esm/presentation/whiteboard/inspector.js.map +1 -1
  109. package/dist/esm/presentation/whiteboard/lineElements.d.ts +23 -0
  110. package/dist/esm/presentation/whiteboard/lineElements.d.ts.map +1 -0
  111. package/dist/esm/presentation/whiteboard/lineElements.js +851 -0
  112. package/dist/esm/presentation/whiteboard/lineElements.js.map +1 -0
  113. package/dist/esm/presentation/whiteboard/lineInspector.d.ts +9 -0
  114. package/dist/esm/presentation/whiteboard/lineInspector.d.ts.map +1 -0
  115. package/dist/esm/presentation/whiteboard/lineInspector.js +224 -0
  116. package/dist/esm/presentation/whiteboard/lineInspector.js.map +1 -0
  117. package/dist/esm/presentation/whiteboard/lineModel.d.ts +132 -0
  118. package/dist/esm/presentation/whiteboard/lineModel.d.ts.map +1 -0
  119. package/dist/esm/presentation/whiteboard/lineModel.js +555 -0
  120. package/dist/esm/presentation/whiteboard/lineModel.js.map +1 -0
  121. package/dist/esm/presentation/whiteboard/outline.d.ts +4 -2
  122. package/dist/esm/presentation/whiteboard/outline.d.ts.map +1 -1
  123. package/dist/esm/presentation/whiteboard/outline.js +20 -7
  124. package/dist/esm/presentation/whiteboard/outline.js.map +1 -1
  125. package/dist/esm/presentation/whiteboardModern/toolDock.d.ts +2 -2
  126. package/dist/esm/presentation/whiteboardModern/toolDock.d.ts.map +1 -1
  127. package/dist/esm/presentation/whiteboardModern/toolDock.js +12 -18
  128. package/dist/esm/presentation/whiteboardModern/toolDock.js.map +1 -1
  129. package/dist/index.js +385 -166
  130. package/dist/index.js.map +1 -1
  131. package/dist/index.min.js +1 -1
  132. package/dist/index.min.js.map +1 -1
  133. package/package.json +1 -1
@@ -0,0 +1,596 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.withLineType = exports.splineSegments = exports.roundedPolylinePath = exports.resolveEndpoints = exports.projectOnSamples = exports.pointAtFraction = exports.optionName = exports.lineGeometry = exports.lineEndGlyph = exports.elbowSegmentIndex = exports.elbowRoute = exports.elbowAxis = exports.dashArray = exports.constrainAngle = exports.barIsVertical = exports.anchorPoint = exports.MAX_WAYPOINTS = exports.LineTypeGlyph = exports.LineThicknessGlyph = exports.LinePatternGlyph = exports.LineEndGlyph = exports.LINE_TYPE_OPTIONS = exports.LINE_PATTERN_OPTIONS = exports.LINE_HIT_WIDTH = exports.LINE_END_OPTIONS = exports.LINE_DEFAULT_LENGTH = exports.DEFAULT_LINE_STYLE = exports.DEFAULT_LABEL = exports.CornerRadiusGlyph = exports.ANCHOR_OPTIONS = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
10
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
12
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
13
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
14
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
15
+ // mirrors: new-activecollab-front Whiteboards connection `style` (ArrowFormattingToolbar defaults); corner_radius: no payload yet
16
+
17
+ // mirrors: no payload yet
18
+
19
+ // mirrors: no payload yet
20
+
21
+ // mirrors: new-activecollab-front Whiteboards connectionShape (type, start_element_id, end_element_id, start_anchor, end_anchor, style); line fields, waypoints and label: no payload yet
22
+
23
+ var MAX_WAYPOINTS = exports.MAX_WAYPOINTS = 20;
24
+ var LINE_HIT_WIDTH = exports.LINE_HIT_WIDTH = 10;
25
+ var LINE_DEFAULT_LENGTH = exports.LINE_DEFAULT_LENGTH = 160;
26
+ var LINE_TYPE_OPTIONS = exports.LINE_TYPE_OPTIONS = [{
27
+ id: "line",
28
+ name: "Straight"
29
+ }, {
30
+ id: "curved",
31
+ name: "Curved"
32
+ }, {
33
+ id: "elbow",
34
+ name: "Elbow"
35
+ }];
36
+ var LINE_END_OPTIONS = exports.LINE_END_OPTIONS = [{
37
+ id: "none",
38
+ name: "None"
39
+ }, {
40
+ id: "arrow",
41
+ name: "Arrow"
42
+ }, {
43
+ id: "dot",
44
+ name: "Dot"
45
+ }, {
46
+ id: "square",
47
+ name: "Square"
48
+ }, {
49
+ id: "rotatedSquare",
50
+ name: "Rotated Square"
51
+ }, {
52
+ id: "circle",
53
+ name: "Circle"
54
+ }];
55
+ var LINE_PATTERN_OPTIONS = exports.LINE_PATTERN_OPTIONS = [{
56
+ id: "solid",
57
+ name: "Solid"
58
+ }, {
59
+ id: "dashed",
60
+ name: "Dashed"
61
+ }, {
62
+ id: "dotted",
63
+ name: "Dotted"
64
+ }];
65
+ var ANCHOR_OPTIONS = exports.ANCHOR_OPTIONS = [{
66
+ id: "center",
67
+ name: "Center"
68
+ }, {
69
+ id: "top-left",
70
+ name: "Top Left"
71
+ }, {
72
+ id: "top",
73
+ name: "Top"
74
+ }, {
75
+ id: "top-right",
76
+ name: "Top Right"
77
+ }, {
78
+ id: "right",
79
+ name: "Right"
80
+ }, {
81
+ id: "bottom-right",
82
+ name: "Bottom Right"
83
+ }, {
84
+ id: "bottom",
85
+ name: "Bottom"
86
+ }, {
87
+ id: "bottom-left",
88
+ name: "Bottom Left"
89
+ }, {
90
+ id: "left",
91
+ name: "Left"
92
+ }];
93
+ var optionName = exports.optionName = function optionName(options, id) {
94
+ var _options$find$name, _options$find;
95
+ return (_options$find$name = (_options$find = options.find(function (option) {
96
+ return option.id === id;
97
+ })) === null || _options$find === void 0 ? void 0 : _options$find.name) !== null && _options$find$name !== void 0 ? _options$find$name : "";
98
+ };
99
+ var DEFAULT_LINE_STYLE = exports.DEFAULT_LINE_STYLE = {
100
+ stroke: "default",
101
+ stroke_opacity: 100,
102
+ stroke_width: 2,
103
+ stroke_pattern: "solid",
104
+ arrow_start: "none",
105
+ arrow_end: "none",
106
+ corner_radius: 0
107
+ };
108
+ var DEFAULT_LABEL = exports.DEFAULT_LABEL = {
109
+ text: "",
110
+ position: 0.5,
111
+ font_size: 13,
112
+ bold: false,
113
+ italic: false,
114
+ underline: false,
115
+ strikethrough: false
116
+ };
117
+ var dashArray = exports.dashArray = function dashArray(pattern, width) {
118
+ return pattern === "dashed" ? "".concat(width * 4, " ").concat(width * 3) : pattern === "dotted" ? "".concat(width, " ").concat(width * 2) : undefined;
119
+ };
120
+ var distance = function distance(a, b) {
121
+ return Math.hypot(b.x - a.x, b.y - a.y);
122
+ };
123
+ var towards = function towards(from, to, length) {
124
+ var total = distance(from, to) || 1;
125
+ return {
126
+ x: from.x + (to.x - from.x) * length / total,
127
+ y: from.y + (to.y - from.y) * length / total
128
+ };
129
+ };
130
+ var midpoint = function midpoint(a, b) {
131
+ return {
132
+ x: (a.x + b.x) / 2,
133
+ y: (a.y + b.y) / 2
134
+ };
135
+ };
136
+ var dedupe = function dedupe(points) {
137
+ return points.filter(function (point, index) {
138
+ return index === 0 || distance(points[index - 1], point) > 0.5;
139
+ });
140
+ };
141
+ var anchorPoint = exports.anchorPoint = function anchorPoint(box, anchor, toward) {
142
+ var cx = box.x + box.width / 2;
143
+ var cy = box.y + box.height / 2;
144
+ var left = box.x;
145
+ var right = box.x + box.width;
146
+ var top = box.y;
147
+ var bottom = box.y + box.height;
148
+ switch (anchor) {
149
+ case "top-left":
150
+ return {
151
+ x: left,
152
+ y: top
153
+ };
154
+ case "top":
155
+ return {
156
+ x: cx,
157
+ y: top
158
+ };
159
+ case "top-right":
160
+ return {
161
+ x: right,
162
+ y: top
163
+ };
164
+ case "right":
165
+ return {
166
+ x: right,
167
+ y: cy
168
+ };
169
+ case "bottom-right":
170
+ return {
171
+ x: right,
172
+ y: bottom
173
+ };
174
+ case "bottom":
175
+ return {
176
+ x: cx,
177
+ y: bottom
178
+ };
179
+ case "bottom-left":
180
+ return {
181
+ x: left,
182
+ y: bottom
183
+ };
184
+ case "left":
185
+ return {
186
+ x: left,
187
+ y: cy
188
+ };
189
+ default:
190
+ {
191
+ var dx = toward.x - cx;
192
+ var dy = toward.y - cy;
193
+ var scale = Math.min(dx ? box.width / 2 / Math.abs(dx) : Infinity, dy ? box.height / 2 / Math.abs(dy) : Infinity);
194
+ return Number.isFinite(scale) ? {
195
+ x: cx + dx * scale,
196
+ y: cy + dy * scale
197
+ } : {
198
+ x: cx,
199
+ y: cy
200
+ };
201
+ }
202
+ }
203
+ };
204
+ var elbowAxis = exports.elbowAxis = function elbowAxis(start, end, anchor) {
205
+ if (anchor === "left" || anchor === "right") {
206
+ return "h";
207
+ }
208
+ if (anchor === "top" || anchor === "bottom") {
209
+ return "v";
210
+ }
211
+ return Math.abs(end.x - start.x) >= Math.abs(end.y - start.y) ? "h" : "v";
212
+ };
213
+ var barIsVertical = exports.barIsVertical = function barIsVertical(index, axis) {
214
+ return index % 2 === 0 === (axis === "h");
215
+ };
216
+ var elbowRoute = exports.elbowRoute = function elbowRoute(start, end, bars, axis) {
217
+ var effective = bars.length ? bars : [midpoint(start, end)];
218
+ var points = [start];
219
+ var current = start;
220
+ effective.forEach(function (bar, index) {
221
+ current = barIsVertical(index, axis) ? {
222
+ x: bar.x,
223
+ y: current.y
224
+ } : {
225
+ x: current.x,
226
+ y: bar.y
227
+ };
228
+ points.push(current);
229
+ });
230
+ points.push(barIsVertical(effective.length - 1, axis) ? {
231
+ x: current.x,
232
+ y: end.y
233
+ } : {
234
+ x: end.x,
235
+ y: current.y
236
+ });
237
+ points.push(end);
238
+ return points;
239
+ };
240
+ var roundedPolylinePath = exports.roundedPolylinePath = function roundedPolylinePath(raw, radius) {
241
+ var points = dedupe(raw);
242
+ if (points.length < 2) {
243
+ return "";
244
+ }
245
+ var d = "M ".concat(points[0].x, " ").concat(points[0].y);
246
+ for (var index = 1; index < points.length - 1; index += 1) {
247
+ var before = points[index - 1];
248
+ var corner = points[index];
249
+ var after = points[index + 1];
250
+ var size = Math.min(radius, distance(before, corner) / 2, distance(corner, after) / 2);
251
+ if (size < 0.5) {
252
+ d += " L ".concat(corner.x, " ").concat(corner.y);
253
+ } else {
254
+ var enter = towards(corner, before, size);
255
+ var leave = towards(corner, after, size);
256
+ d += " L ".concat(enter.x, " ").concat(enter.y, " Q ").concat(corner.x, " ").concat(corner.y, " ").concat(leave.x, " ").concat(leave.y);
257
+ }
258
+ }
259
+ var last = points[points.length - 1];
260
+ return "".concat(d, " L ").concat(last.x, " ").concat(last.y);
261
+ };
262
+ var splineSegments = exports.splineSegments = function splineSegments(points) {
263
+ return points.slice(0, -1).map(function (from, index) {
264
+ var _points, _points2;
265
+ var before = (_points = points[index - 1]) !== null && _points !== void 0 ? _points : from;
266
+ var to = points[index + 1];
267
+ var after = (_points2 = points[index + 2]) !== null && _points2 !== void 0 ? _points2 : to;
268
+ return {
269
+ from,
270
+ c1: {
271
+ x: from.x + (to.x - before.x) / 6,
272
+ y: from.y + (to.y - before.y) / 6
273
+ },
274
+ c2: {
275
+ x: to.x - (after.x - from.x) / 6,
276
+ y: to.y - (after.y - from.y) / 6
277
+ },
278
+ to
279
+ };
280
+ });
281
+ };
282
+ var cubicAt = function cubicAt(segment, t) {
283
+ var u = 1 - t;
284
+ var a = u * u * u;
285
+ var b = 3 * u * u * t;
286
+ var c = 3 * u * t * t;
287
+ var e = t * t * t;
288
+ return {
289
+ x: a * segment.from.x + b * segment.c1.x + c * segment.c2.x + e * segment.to.x,
290
+ y: a * segment.from.y + b * segment.c1.y + c * segment.c2.y + e * segment.to.y
291
+ };
292
+ };
293
+ var angleOf = function angleOf(from, to) {
294
+ return Math.atan2(to.y - from.y, to.x - from.x);
295
+ };
296
+ var lineGeometry = exports.lineGeometry = function lineGeometry(line, start, end) {
297
+ if (line.type === "curved" && line.waypoints.curved.length) {
298
+ var segments = splineSegments([start, ...line.waypoints.curved, end]);
299
+ var samples = [start];
300
+ var sampleSegments = [0];
301
+ segments.forEach(function (segment, index) {
302
+ for (var step = 1; step <= 16; step += 1) {
303
+ samples.push(cubicAt(segment, step / 16));
304
+ sampleSegments.push(index);
305
+ }
306
+ });
307
+ var first = segments[0];
308
+ var last = segments[segments.length - 1];
309
+ return {
310
+ d: segments.reduce(function (path, segment) {
311
+ return "".concat(path, " C ").concat(segment.c1.x, " ").concat(segment.c1.y, " ").concat(segment.c2.x, " ").concat(segment.c2.y, " ").concat(segment.to.x, " ").concat(segment.to.y);
312
+ }, "M ".concat(start.x, " ").concat(start.y)),
313
+ samples,
314
+ sampleSegments,
315
+ route: [start, ...line.waypoints.curved, end],
316
+ startAngle: angleOf(first.c1, start),
317
+ endAngle: angleOf(last.c2, end)
318
+ };
319
+ }
320
+ if (line.type === "elbow") {
321
+ var _clean$, _clean;
322
+ var route = elbowRoute(start, end, line.waypoints.elbow, elbowAxis(start, end, line.start_anchor));
323
+ var clean = dedupe(route);
324
+ var _sampleSegments = route.map(function (_, index) {
325
+ return Math.max(0, index - 1);
326
+ });
327
+ return {
328
+ d: roundedPolylinePath(route, line.style.corner_radius),
329
+ samples: route,
330
+ sampleSegments: _sampleSegments,
331
+ route,
332
+ startAngle: angleOf((_clean$ = clean[1]) !== null && _clean$ !== void 0 ? _clean$ : end, start),
333
+ endAngle: angleOf((_clean = clean[clean.length - 2]) !== null && _clean !== void 0 ? _clean : start, end)
334
+ };
335
+ }
336
+ return {
337
+ d: "M ".concat(start.x, " ").concat(start.y, " L ").concat(end.x, " ").concat(end.y),
338
+ samples: [start, end],
339
+ sampleSegments: [0, 0],
340
+ route: [start, end],
341
+ startAngle: angleOf(end, start),
342
+ endAngle: angleOf(start, end)
343
+ };
344
+ };
345
+ var cumulative = function cumulative(samples) {
346
+ return samples.reduce(function (acc, point, index) {
347
+ return [...acc, index === 0 ? 0 : acc[index - 1] + distance(samples[index - 1], point)];
348
+ }, []);
349
+ };
350
+ var pointAtFraction = exports.pointAtFraction = function pointAtFraction(samples, fraction) {
351
+ var lengths = cumulative(samples);
352
+ var target = lengths[lengths.length - 1] * fraction;
353
+ var index = lengths.findIndex(function (length) {
354
+ return length >= target;
355
+ });
356
+ if (index <= 0) {
357
+ return samples[0];
358
+ }
359
+ var span = lengths[index] - lengths[index - 1] || 1;
360
+ var t = (target - lengths[index - 1]) / span;
361
+ return {
362
+ x: samples[index - 1].x + (samples[index].x - samples[index - 1].x) * t,
363
+ y: samples[index - 1].y + (samples[index].y - samples[index - 1].y) * t
364
+ };
365
+ };
366
+ var projectOnSamples = exports.projectOnSamples = function projectOnSamples(samples, sampleSegments, point) {
367
+ var lengths = cumulative(samples);
368
+ var total = lengths[lengths.length - 1] || 1;
369
+ var best = {
370
+ fraction: 0,
371
+ segment: 0,
372
+ point: samples[0],
373
+ gap: Infinity
374
+ };
375
+ for (var index = 1; index < samples.length; index += 1) {
376
+ var a = samples[index - 1];
377
+ var b = samples[index];
378
+ var length = distance(a, b);
379
+ var t = length ? Math.max(0, Math.min(1, ((point.x - a.x) * (b.x - a.x) + (point.y - a.y) * (b.y - a.y)) / (length * length))) : 0;
380
+ var on = {
381
+ x: a.x + (b.x - a.x) * t,
382
+ y: a.y + (b.y - a.y) * t
383
+ };
384
+ var gap = distance(on, point);
385
+ if (gap < best.gap) {
386
+ best = {
387
+ fraction: (lengths[index - 1] + length * t) / total,
388
+ segment: sampleSegments[index],
389
+ point: on,
390
+ gap
391
+ };
392
+ }
393
+ }
394
+ return {
395
+ fraction: best.fraction,
396
+ segment: best.segment,
397
+ point: best.point
398
+ };
399
+ };
400
+ var elbowSegmentIndex = exports.elbowSegmentIndex = function elbowSegmentIndex(route, point) {
401
+ var bestIndex = 0;
402
+ var bestGap = Infinity;
403
+ for (var index = 0; index < route.length - 1; index += 1) {
404
+ var projection = projectOnSamples([route[index], route[index + 1]], [index, index], point);
405
+ var gap = distance(projection.point, point);
406
+ if (gap < bestGap) {
407
+ bestGap = gap;
408
+ bestIndex = index;
409
+ }
410
+ }
411
+ return bestIndex;
412
+ };
413
+ var withLineType = exports.withLineType = function withLineType(line, type, start, end) {
414
+ if (type === "line" || line.waypoints[type].length) {
415
+ return _objectSpread(_objectSpread({}, line), {}, {
416
+ type
417
+ });
418
+ }
419
+ var middle = midpoint(start, end);
420
+ var length = distance(start, end) || 1;
421
+ var bend = Math.min(48, length / 3);
422
+ var seeded = type === "curved" ? {
423
+ x: middle.x + (end.y - start.y) / length * bend,
424
+ y: middle.y - (end.x - start.x) / length * bend
425
+ } : middle;
426
+ return _objectSpread(_objectSpread({}, line), {}, {
427
+ type,
428
+ waypoints: _objectSpread(_objectSpread({}, line.waypoints), {}, {
429
+ [type]: [seeded]
430
+ })
431
+ });
432
+ };
433
+ var constrainAngle = exports.constrainAngle = function constrainAngle(from, to) {
434
+ var length = distance(from, to);
435
+ var step = Math.PI / 4;
436
+ var angle = Math.round(angleOf(from, to) / step) * step;
437
+ return {
438
+ x: Math.round(from.x + Math.cos(angle) * length),
439
+ y: Math.round(from.y + Math.sin(angle) * length)
440
+ };
441
+ };
442
+ var lineEndGlyph = exports.lineEndGlyph = function lineEndGlyph(type, at, angle, width, color) {
443
+ var size = 4 + width * 2;
444
+ var length = 8 + width * 2;
445
+ var spread = Math.PI / 6;
446
+ switch (type) {
447
+ case "arrow":
448
+ return /*#__PURE__*/_react.default.createElement("polygon", {
449
+ points: "".concat(at.x, ",").concat(at.y, " ").concat(at.x - length * Math.cos(angle - spread), ",").concat(at.y - length * Math.sin(angle - spread), " ").concat(at.x - length * Math.cos(angle + spread), ",").concat(at.y - length * Math.sin(angle + spread)),
450
+ style: {
451
+ fill: color
452
+ }
453
+ });
454
+ case "dot":
455
+ return /*#__PURE__*/_react.default.createElement("circle", {
456
+ cx: at.x,
457
+ cy: at.y,
458
+ r: size / 2,
459
+ style: {
460
+ fill: color
461
+ }
462
+ });
463
+ case "square":
464
+ return /*#__PURE__*/_react.default.createElement("rect", {
465
+ x: at.x - size / 2,
466
+ y: at.y - size / 2,
467
+ width: size,
468
+ height: size,
469
+ style: {
470
+ fill: color
471
+ }
472
+ });
473
+ case "rotatedSquare":
474
+ return /*#__PURE__*/_react.default.createElement("rect", {
475
+ x: at.x - size / 2,
476
+ y: at.y - size / 2,
477
+ width: size,
478
+ height: size,
479
+ transform: "rotate(45 ".concat(at.x, " ").concat(at.y, ")"),
480
+ style: {
481
+ fill: color
482
+ }
483
+ });
484
+ case "circle":
485
+ return /*#__PURE__*/_react.default.createElement("circle", {
486
+ cx: at.x,
487
+ cy: at.y,
488
+ r: size / 2,
489
+ strokeWidth: Math.max(1.5, width * 0.75),
490
+ style: {
491
+ fill: "var(--page-paper-main)",
492
+ stroke: color
493
+ }
494
+ });
495
+ default:
496
+ return null;
497
+ }
498
+ };
499
+ var GLYPH_PROPS = {
500
+ width: 20,
501
+ height: 20,
502
+ viewBox: "0 0 20 20",
503
+ fill: "none",
504
+ style: {
505
+ stroke: "currentColor"
506
+ },
507
+ strokeWidth: 1.5,
508
+ strokeLinecap: "round",
509
+ strokeLinejoin: "round"
510
+ };
511
+ var TYPE_PATHS = {
512
+ line: "M3 17 L17 3",
513
+ curved: "M3 16 C 9 16, 11 4, 17 4",
514
+ elbow: "M3 16 H10 V4 H17"
515
+ };
516
+
517
+ // ds-exception: no line-type glyphs in src/components/Icons — Design System task
518
+ var LineTypeGlyph = exports.LineTypeGlyph = function LineTypeGlyph(_ref) {
519
+ var type = _ref.type;
520
+ return /*#__PURE__*/_react.default.createElement("svg", GLYPH_PROPS, /*#__PURE__*/_react.default.createElement("path", {
521
+ d: TYPE_PATHS[type]
522
+ }));
523
+ };
524
+
525
+ // ds-exception: no line-end glyphs in src/components/Icons — Design System task
526
+ var LineEndGlyph = exports.LineEndGlyph = function LineEndGlyph(_ref2) {
527
+ var type = _ref2.type,
528
+ side = _ref2.side;
529
+ var tip = side === "end" ? {
530
+ x: 17,
531
+ y: 10
532
+ } : {
533
+ x: 3,
534
+ y: 10
535
+ };
536
+ return /*#__PURE__*/_react.default.createElement("svg", GLYPH_PROPS, /*#__PURE__*/_react.default.createElement("path", {
537
+ d: "M3 10 H17",
538
+ strokeDasharray: type === "none" ? "2 2" : undefined
539
+ }), lineEndGlyph(type, tip, side === "end" ? 0 : Math.PI, 1.5, "currentColor"));
540
+ };
541
+
542
+ // ds-exception: no stroke-pattern glyphs in src/components/Icons — Design System task
543
+ var LinePatternGlyph = exports.LinePatternGlyph = function LinePatternGlyph(_ref3) {
544
+ var pattern = _ref3.pattern;
545
+ return /*#__PURE__*/_react.default.createElement("svg", _extends({}, GLYPH_PROPS, {
546
+ strokeWidth: 2,
547
+ strokeLinecap: "butt"
548
+ }), /*#__PURE__*/_react.default.createElement("path", {
549
+ d: "M2 10 H18",
550
+ strokeDasharray: dashArray(pattern, 2)
551
+ }));
552
+ };
553
+
554
+ // ds-exception: no stroke-thickness glyphs in src/components/Icons — Design System task
555
+ var LineThicknessGlyph = exports.LineThicknessGlyph = function LineThicknessGlyph(_ref4) {
556
+ var width = _ref4.width;
557
+ return /*#__PURE__*/_react.default.createElement("svg", _extends({}, GLYPH_PROPS, {
558
+ strokeWidth: width
559
+ }), /*#__PURE__*/_react.default.createElement("path", {
560
+ d: "M3 10 H17"
561
+ }));
562
+ };
563
+
564
+ // ds-exception: no corner-radius glyph in src/components/Icons — Design System task
565
+ var CornerRadiusGlyph = exports.CornerRadiusGlyph = function CornerRadiusGlyph(_ref5) {
566
+ var radius = _ref5.radius;
567
+ var size = Math.min(10, radius / 4);
568
+ return /*#__PURE__*/_react.default.createElement("svg", GLYPH_PROPS, /*#__PURE__*/_react.default.createElement("path", {
569
+ d: size ? "M4 17 V".concat(4 + size, " A").concat(size, " ").concat(size, " 0 0 1 ").concat(4 + size, " 4 H17") : "M4 17 V4 H17"
570
+ }));
571
+ };
572
+ var boxCenter = function boxCenter(box) {
573
+ return {
574
+ x: box.x + box.width / 2,
575
+ y: box.y + box.height / 2
576
+ };
577
+ };
578
+ var resolveEndpoints = exports.resolveEndpoints = function resolveEndpoints(line, boxOf) {
579
+ var _line$start_anchor, _bends$, _line$end_anchor, _bends;
580
+ if (line.kind !== "connector") {
581
+ return {
582
+ start: line.start,
583
+ end: line.end
584
+ };
585
+ }
586
+ var from = line.start_element_id ? boxOf(line.start_element_id) : null;
587
+ var to = line.end_element_id ? boxOf(line.end_element_id) : null;
588
+ var fromCenter = from ? boxCenter(from) : line.start;
589
+ var toCenter = to ? boxCenter(to) : line.end;
590
+ var bends = line.type === "curved" ? line.waypoints.curved : [];
591
+ return {
592
+ start: from ? anchorPoint(from, (_line$start_anchor = line.start_anchor) !== null && _line$start_anchor !== void 0 ? _line$start_anchor : "center", (_bends$ = bends[0]) !== null && _bends$ !== void 0 ? _bends$ : toCenter) : line.start,
593
+ end: to ? anchorPoint(to, (_line$end_anchor = line.end_anchor) !== null && _line$end_anchor !== void 0 ? _line$end_anchor : "center", (_bends = bends[bends.length - 1]) !== null && _bends !== void 0 ? _bends : fromCenter) : line.end
594
+ };
595
+ };
596
+ //# sourceMappingURL=lineModel.js.map