@libs-ui/components-draw-line 0.2.306 → 0.2.307-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.
@@ -5,11 +5,11 @@ import { Subject, takeUntil, tap } from 'rxjs';
5
5
 
6
6
  class MoCanvasCalculatorBranchUtil {
7
7
  /**
8
- *
9
- * above, left a + b; opposite = true a - b;
10
- *
11
- * under, right a - b; opposite = true a + b
12
- */
8
+ *
9
+ * above, left a + b; opposite = true a - b;
10
+ *
11
+ * under, right a - b; opposite = true a + b
12
+ */
13
13
  static mathOperatorsCalculation(direction, a, b, opposite) {
14
14
  switch (direction) {
15
15
  case 'left':
@@ -32,7 +32,7 @@ class MoCanvasCalculatorBranchUtil {
32
32
 
33
33
  class MoCanvasCalculatorDirectionElementUtil {
34
34
  static checkUpDownLeftRight(firstPoint, endPoint, direction) {
35
- const distance = ((firstPoint ?? 0) - (endPoint ?? 0));
35
+ const distance = (firstPoint ?? 0) - (endPoint ?? 0);
36
36
  if (distance === 0) {
37
37
  return 'center';
38
38
  }
@@ -99,17 +99,16 @@ class MoCanvasCalculatorDirectionElementUtil {
99
99
  }
100
100
  /**Tránh khối phía bên phải */
101
101
  static byPassElementOnRightSide(startX, startY, endY, lineCurve, elementBlockRoad, directionX, separatedPoints, key, coordLX) {
102
- const topElementBlockRoad = (elementBlockRoad.y ?? 0);
102
+ const topElementBlockRoad = elementBlockRoad.y ?? 0;
103
103
  const bottomElementBlockRoad = (elementBlockRoad.y ?? 0) + (elementBlockRoad.height ?? 0);
104
104
  const directionY = this.checkUpDownLeftRight(startY, endY, 'y');
105
105
  const Q1 = this.drawLineQ({ x: startX, y: startY ?? 0 }, `${directionX}-${directionY === 'under' ? 'under' : 'above'}`, lineCurve, lineCurve);
106
106
  const L1 = {
107
107
  x: Q1.x ?? 0,
108
- y: (directionY === 'under' ? bottomElementBlockRoad : topElementBlockRoad)
108
+ y: directionY === 'under' ? bottomElementBlockRoad : topElementBlockRoad,
109
109
  };
110
110
  if (MoCanvasConnectNavigationNewElementUtil.START_MODE !== 'bottom-left') {
111
- if ((directionY === 'under' && bottomElementBlockRoad - (Q1.y ?? 0) <= 0)
112
- || (directionY === 'above' && topElementBlockRoad - (Q1.y ?? 0) >= 0)) {
111
+ if ((directionY === 'under' && bottomElementBlockRoad - (Q1.y ?? 0) <= 0) || (directionY === 'above' && topElementBlockRoad - (Q1.y ?? 0) >= 0)) {
113
112
  L1.y = Q1.y ?? 0;
114
113
  }
115
114
  if (Math.abs((L1.y ?? 0) - endY) <= 10) {
@@ -126,19 +125,19 @@ class MoCanvasCalculatorDirectionElementUtil {
126
125
  pathByPassQ: `${pathQ1} ${pathQ2}`,
127
126
  endPath: {
128
127
  x: Q2.x ?? 0,
129
- y: Q2.y ?? 0
130
- }
128
+ y: Q2.y ?? 0,
129
+ },
131
130
  };
132
131
  }
133
132
  /**Tránh khối phía bên trên */
134
133
  static byPassElementOnTopBottomSide(startX, startY, endX, lineCurve, elementBlockRoad, directionY, separatedPoints, key) {
135
- const leftElementBlockRoad = (elementBlockRoad.x ?? 0);
134
+ const leftElementBlockRoad = elementBlockRoad.x ?? 0;
136
135
  const rightElementBlockRoad = (elementBlockRoad.x ?? 0) + (elementBlockRoad.width ?? 0);
137
136
  const directionX = this.checkUpDownLeftRight(startX, endX, 'x') === 'left' ? 'left' : 'right'; // xem nên tránh sang trái hay phải
138
137
  const Q1 = this.drawLineQ({ x: startX, y: startY ?? 0 }, `${directionY}-${directionX}`, lineCurve, lineCurve);
139
138
  const L1 = {
140
- x: (directionX === 'left' ? leftElementBlockRoad : rightElementBlockRoad),
141
- y: Q1.y ?? 0
139
+ x: directionX === 'left' ? leftElementBlockRoad : rightElementBlockRoad,
140
+ y: Q1.y ?? 0,
142
141
  };
143
142
  if ((directionX === 'right' && rightElementBlockRoad - (Q1.x ?? 0) <= 0) || (directionX === 'left' && leftElementBlockRoad - (Q1.x ?? 0) >= 0)) {
144
143
  L1.x = Q1.x ?? 0;
@@ -156,8 +155,8 @@ class MoCanvasCalculatorDirectionElementUtil {
156
155
  pathByPassQ: `${pathQ1} ${pathQ2}`,
157
156
  endPath: {
158
157
  x: Q2.x ?? 0,
159
- y: Q2.y ?? 0
160
- }
158
+ y: Q2.y ?? 0,
159
+ },
161
160
  };
162
161
  }
163
162
  // kiểm tra đường thẳng và khối có cắt nhau không
@@ -165,15 +164,15 @@ class MoCanvasCalculatorDirectionElementUtil {
165
164
  const minimumDistanceFromBlock = 8;
166
165
  start += minimumDistanceFromBlock + 1; // tránh khối xuất phát vào list
167
166
  const listPointsOfLine = range(start, end + 1);
168
- const elementBlockRoad = obstacleRect.filter(item => {
167
+ const elementBlockRoad = obstacleRect.filter((item) => {
169
168
  const left = (item.x ?? 0) - minimumDistanceFromBlock;
170
169
  const right = (item.x ?? 0) + (item.width ?? 0) + minimumDistanceFromBlock;
171
170
  const top = (item.y ?? 0) - minimumDistanceFromBlock;
172
171
  const bottom = (item.y ?? 0) + (item.height ?? 0) + minimumDistanceFromBlock;
173
- if (direction === 'x' && listPointsOfLine.find(el => (left <= el && el <= right)) && (top <= xOrYOfLine && xOrYOfLine <= bottom)) {
172
+ if (direction === 'x' && listPointsOfLine.find((el) => left <= el && el <= right) && top <= xOrYOfLine && xOrYOfLine <= bottom) {
174
173
  return true;
175
174
  }
176
- if (direction === 'y' && listPointsOfLine.find(el => (top <= el && el <= bottom)) && (left <= xOrYOfLine && xOrYOfLine <= right)) {
175
+ if (direction === 'y' && listPointsOfLine.find((el) => top <= el && el <= bottom) && left <= xOrYOfLine && xOrYOfLine <= right) {
177
176
  return true;
178
177
  }
179
178
  return false;
@@ -185,9 +184,9 @@ class MoCanvasCalculatorDirectionElementUtil {
185
184
  return elementBlockRoad;
186
185
  }
187
186
  if (direction === 'y') {
188
- return elementBlockRoad.reduce((a, b) => (Math.abs(((a.y ?? 0) - start))) < (Math.abs(((b.y ?? 0) - start))) ? a : b);
187
+ return elementBlockRoad.reduce((a, b) => (Math.abs((a.y ?? 0) - start) < Math.abs((b.y ?? 0) - start) ? a : b));
189
188
  }
190
- return elementBlockRoad.reduce((a, b) => (Math.abs(((a.x ?? 0) - start))) < (Math.abs(((b.x ?? 0) - start))) ? a : b);
189
+ return elementBlockRoad.reduce((a, b) => (Math.abs((a.x ?? 0) - start) < Math.abs((b.x ?? 0) - start) ? a : b));
191
190
  }
192
191
  // kiểm tra hướng thẳng vẽ về điểm end xem có bị chắn bởi khối nào không, nếu có thì phải lùi lại điểm end nhé.
193
192
  static checkBlocksElementStraightY(startX, startY, endPosition, obstacleRect) {
@@ -195,7 +194,7 @@ class MoCanvasCalculatorDirectionElementUtil {
195
194
  if (!elementBlockRoad || !elementBlockRoad.length) {
196
195
  return;
197
196
  }
198
- return elementBlockRoad.reduce((a, b) => (Math.abs((a.x ?? 0 - startX))) < (Math.abs((b.x ?? 0 - startX))) ? a : b);
197
+ return elementBlockRoad.reduce((a, b) => (Math.abs(a.x ?? 0 - startX) < Math.abs(b.x ?? 0 - startX) ? a : b));
199
198
  }
200
199
  // kiểm tra hướng ngang vẽ về điểm end xem có bị chắn bởi khối nào không, nếu có thì phải lùi lại điểm end nhé.
201
200
  static checkBlocksElementX(startX, startY, endPosition, obstacleRect) {
@@ -203,7 +202,7 @@ class MoCanvasCalculatorDirectionElementUtil {
203
202
  if (!elementBlockRoad || !elementBlockRoad.length) {
204
203
  return;
205
204
  }
206
- return elementBlockRoad.reduce((a, b) => (Math.abs(((a.y ?? 0) - startY))) < (Math.abs(((b.y ?? 0) - startY))) ? a : b);
205
+ return elementBlockRoad.reduce((a, b) => (Math.abs((a.y ?? 0) - startY) < Math.abs((b.y ?? 0) - startY) ? a : b));
207
206
  }
208
207
  // kiểm tra hướng sang phải là tránh khối
209
208
  static checkAndAvoidBlocksLeft(startX, startY, lineCurve, endPosition, obstacleRect, separatedPoints) {
@@ -214,10 +213,10 @@ class MoCanvasCalculatorDirectionElementUtil {
214
213
  return coordLX;
215
214
  }
216
215
  const directionX = MoCanvasCalculatorDirectionElementUtil.checkUpDownLeftRight(startX, endPosition.x, 'x');
217
- const specificXElement = directionX === 'right' ? (elementBlockRoad.x ?? 0) : ((elementBlockRoad.x ?? 0) + (elementBlockRoad.width ?? 0));
218
- coordLX.x = specificXElement + (MoCanvasConnectNavigationNewElementUtil.ELEMENT_MARGIN_BETWEEN_BRANCH_DEFAULT / 2) + (lineCurve / 2);
216
+ const specificXElement = directionX === 'right' ? (elementBlockRoad.x ?? 0) : (elementBlockRoad.x ?? 0) + (elementBlockRoad.width ?? 0);
217
+ coordLX.x = specificXElement + MoCanvasConnectNavigationNewElementUtil.ELEMENT_MARGIN_BETWEEN_BRANCH_DEFAULT / 2 + lineCurve / 2;
219
218
  if (directionX === 'right') {
220
- coordLX.x = specificXElement - (MoCanvasConnectNavigationNewElementUtil.ELEMENT_MARGIN_BETWEEN_BRANCH_DEFAULT / 2) - (lineCurve / 2);
219
+ coordLX.x = specificXElement - MoCanvasConnectNavigationNewElementUtil.ELEMENT_MARGIN_BETWEEN_BRANCH_DEFAULT / 2 - lineCurve / 2;
221
220
  }
222
221
  let startXBypassElement = coordLX.x;
223
222
  if ((directionX === 'left' && startX - (coordLX.x ?? 0) <= 0) || (directionX === 'right' && startX - (coordLX.x ?? 0) >= 0)) {
@@ -226,7 +225,8 @@ class MoCanvasCalculatorDirectionElementUtil {
226
225
  }
227
226
  let lineByPassBlock = [];
228
227
  let { endPath } = MoCanvasCalculatorDirectionElementUtil.byPassElementOnRightSide(startXBypassElement ?? 0, coordLX.y ?? 0, endPosition.y, lineCurve, elementBlockRoad, directionX, lineByPassBlock, undefined, coordLX.x);
229
- if (MoCanvasConnectNavigationNewElementUtil.START_MODE === 'bottom-left' && elementBlockRoad.x + (elementBlockRoad.width) / 2 === endPosition.x && Math.abs(endPosition.y - elementBlockRoad.y) <= 20) { // check xem khối chắn có phải là khối đích hay không?
228
+ if (MoCanvasConnectNavigationNewElementUtil.START_MODE === 'bottom-left' && elementBlockRoad.x + elementBlockRoad.width / 2 === endPosition.x && Math.abs(endPosition.y - elementBlockRoad.y) <= 20) {
229
+ // check xem khối chắn có phải là khối đích hay không?
230
230
  lineByPassBlock = [];
231
231
  const data = MoCanvasCalculatorDirectionElementUtil.byPassElementOnRightSideNewMode(startXBypassElement ?? 0, coordLX.y ?? 0, endPosition.y, lineByPassBlock, undefined, coordLX.x);
232
232
  endPath = data.endPath;
@@ -243,20 +243,20 @@ class MoCanvasCalculatorDirectionElementUtil {
243
243
  if (!elementBlockRoad) {
244
244
  const elementBlockRoadStraightLineY = this.checkBlocksElementStraightY((coordLX.x ?? 0) + 10, coordLX.y ?? 0, endPosition, obstacleRect); // tính điểm end_x dự kiến theo trường hợp đẹp nhất xem nó có chắn bởi khối nào khi kéo xuống không
245
245
  if (elementBlockRoadStraightLineY && (elementBlockRoadStraightLineY.x ?? 0) > startX) {
246
- let toX = (elementBlockRoadStraightLineY.x ?? 0) - (MoCanvasConnectNavigationNewElementUtil.ELEMENT_MARGIN_BETWEEN_BRANCH_DEFAULT / 2) - (lineCurve / 2);
247
- if (((elementBlockRoadStraightLineY?.x ?? 0) - startX) < MoCanvasConnectNavigationNewElementUtil.ELEMENT_MARGIN_BETWEEN_BRANCH_DEFAULT) {
248
- toX = (elementBlockRoadStraightLineY.x ?? 0) - (((elementBlockRoadStraightLineY?.x ?? 0) - startX) / 2);
246
+ let toX = (elementBlockRoadStraightLineY.x ?? 0) - MoCanvasConnectNavigationNewElementUtil.ELEMENT_MARGIN_BETWEEN_BRANCH_DEFAULT / 2 - lineCurve / 2;
247
+ if ((elementBlockRoadStraightLineY?.x ?? 0) - startX < MoCanvasConnectNavigationNewElementUtil.ELEMENT_MARGIN_BETWEEN_BRANCH_DEFAULT) {
248
+ toX = (elementBlockRoadStraightLineY.x ?? 0) - ((elementBlockRoadStraightLineY?.x ?? 0) - startX) / 2;
249
249
  }
250
250
  coordLX.x = toX;
251
251
  }
252
252
  separatedPoints.push({ start: { x: startX, y: startY }, end: coordLX, mode: 'horizontal', id: 'checkAndAvoidBlocks', name: 'end' });
253
253
  return {
254
254
  path: pathPre ? `${pathPre} L ${coordLX.x} ${coordLX.y}` : `L ${coordLX.x} ${coordLX.y}`,
255
- endPath: coordLX
255
+ endPath: coordLX,
256
256
  };
257
257
  }
258
258
  const directionX = MoCanvasCalculatorDirectionElementUtil.checkUpDownLeftRight(startX, endPosition.x, 'x');
259
- coordLX.x = (elementBlockRoad.x ?? 0) - (MoCanvasConnectNavigationNewElementUtil.ELEMENT_MARGIN_BETWEEN_BRANCH_DEFAULT / 2) - (lineCurve / 2);
259
+ coordLX.x = (elementBlockRoad.x ?? 0) - MoCanvasConnectNavigationNewElementUtil.ELEMENT_MARGIN_BETWEEN_BRANCH_DEFAULT / 2 - lineCurve / 2;
260
260
  let separatedPointsByPassElementOnRightSide = [];
261
261
  const { pathByPassQ, endPath } = MoCanvasCalculatorDirectionElementUtil.byPassElementOnRightSide(coordLX.x, coordLX.y ?? 0, endPosition.y, lineCurve, elementBlockRoad, directionX, separatedPointsByPassElementOnRightSide, 'checkAndAvoidBlocks', coordLX.x);
262
262
  let line = pathPre ? `${pathPre} L ${coordLX.x} ${coordLX.y} ${pathByPassQ}` : `L ${coordLX.x} ${coordLX.y} ${pathByPassQ}`;
@@ -265,14 +265,14 @@ class MoCanvasCalculatorDirectionElementUtil {
265
265
  if (!elementBlockRoadPre) {
266
266
  const elementBlockRoadStraightLineY = this.checkBlocksElementStraightY((endPosition.x ?? 0) + 10, endPath.y ?? 0, endPosition, obstacleRect);
267
267
  if (elementBlockRoadStraightLineY) {
268
- const XNew = (elementBlockRoadStraightLineY.x ?? 0) - (MoCanvasConnectNavigationNewElementUtil.ELEMENT_MARGIN_BETWEEN_BRANCH_DEFAULT / 2) - (lineCurve / 2);
268
+ const XNew = (elementBlockRoadStraightLineY.x ?? 0) - MoCanvasConnectNavigationNewElementUtil.ELEMENT_MARGIN_BETWEEN_BRANCH_DEFAULT / 2 - lineCurve / 2;
269
269
  if (XNew < (endPath.x ?? 0)) {
270
270
  separatedPointsByPassElementOnRightSide = [];
271
271
  separatedPoints.push({ start: { x: startX, y: startY }, end: coordLX, mode: 'horizontal', id: 'checkAndAvoidBlocks', name: 'u' });
272
272
  line = pathPre ? `${pathPre} L ${coordLX.x} ${coordLX.y}` : `L ${coordLX.x} ${coordLX.y}`;
273
273
  return {
274
274
  path: line,
275
- endPath: coordLX
275
+ endPath: coordLX,
276
276
  };
277
277
  }
278
278
  }
@@ -282,7 +282,7 @@ class MoCanvasCalculatorDirectionElementUtil {
282
282
  const data = this.checkAndAvoidBlocks(endPath.x ?? 0, endPath.y ?? 0, lineCurve, endPosition, obstacleRect, separatedPoints, `${line}`);
283
283
  return {
284
284
  path: data.path,
285
- endPath: data.endPath
285
+ endPath: data.endPath,
286
286
  };
287
287
  }
288
288
  // kiểm tra hướng thẳng và tránh khối
@@ -293,14 +293,14 @@ class MoCanvasCalculatorDirectionElementUtil {
293
293
  separatedPoints.push({ start: { x: startX, y: startY }, end: coordLX, mode: 'horizontal', id: 'k' });
294
294
  return {
295
295
  path: pathPre ?? '',
296
- endPath: { x: startX, y: startY }
296
+ endPath: { x: startX, y: startY },
297
297
  };
298
298
  }
299
299
  if (!elementBlockRoad) {
300
300
  separatedPoints.push({ start: { x: startX, y: startY }, end: coordLX, mode: 'horizontal', id: 'r' });
301
301
  return {
302
302
  path: pathPre ? `${pathPre} L ${coordLX.x} ${coordLX.y}` : `L ${coordLX.x} ${coordLX.y}`,
303
- endPath: coordLX
303
+ endPath: coordLX,
304
304
  };
305
305
  }
306
306
  const y = directionY === 'above' ? (elementBlockRoad.y ?? 0) + (elementBlockRoad.height ?? 0) : (elementBlockRoad.y ?? 0);
@@ -312,7 +312,7 @@ class MoCanvasCalculatorDirectionElementUtil {
312
312
  const data = this.checkAndAvoidBlocksY(endPath.x ?? 0, endPath.y ?? 0, lineCurve, endPosition, directionY, obstacleRect, separatedPoints, `${line}`);
313
313
  return {
314
314
  path: data.path,
315
- endPath: data.endPath
315
+ endPath: data.endPath,
316
316
  };
317
317
  }
318
318
  // kiểm tra hướng thẳng và tránh khối
@@ -321,11 +321,11 @@ class MoCanvasCalculatorDirectionElementUtil {
321
321
  const coordLX = { x: startX, y: endPosition.y };
322
322
  const elementBlockRoad = MoCanvasCalculatorDirectionElementUtil.checkLinePassBlockHorizontal(startY, endPosition.y, startX, 'y', obstacleRect);
323
323
  if (!elementBlockRoad) {
324
- const elementBlockRoadStraightLineX = MoCanvasCalculatorDirectionElementUtil.checkBlocksElementX(coordLX.x ?? 0, (coordLX.y ?? 0), endPosition, obstacleRect);
324
+ const elementBlockRoadStraightLineX = MoCanvasCalculatorDirectionElementUtil.checkBlocksElementX(coordLX.x ?? 0, coordLX.y ?? 0, endPosition, obstacleRect);
325
325
  if (elementBlockRoadStraightLineX) {
326
- const topElementBlockRoad = (elementBlockRoadStraightLineX.y ?? 0);
326
+ const topElementBlockRoad = elementBlockRoadStraightLineX.y ?? 0;
327
327
  const bottomElementBlockRoad = (elementBlockRoadStraightLineX.y ?? 0) + (elementBlockRoadStraightLineX.height ?? 0);
328
- let toY = (directionY === 'under' ? topElementBlockRoad : bottomElementBlockRoad);
328
+ let toY = directionY === 'under' ? topElementBlockRoad : bottomElementBlockRoad;
329
329
  toY = MoCanvasCalculatorBranchUtil.mathOperatorsCalculation(directionY, toY, lineCurve * 2);
330
330
  if (toY > startY && MoCanvasConnectNavigationNewElementUtil.START_MODE !== 'bottom-left') {
331
331
  coordLX.y = toY;
@@ -334,11 +334,11 @@ class MoCanvasCalculatorDirectionElementUtil {
334
334
  separatedPoints.push({ start: { x: startX, y: startY }, end: coordLX, mode: 'horizontal', id: key, name: 'a' });
335
335
  return {
336
336
  path: pathPre ? `${pathPre} L ${coordLX.x} ${coordLX.y}` : `L ${coordLX.x} ${coordLX.y}`,
337
- endPath: coordLX
337
+ endPath: coordLX,
338
338
  };
339
339
  }
340
340
  const y = directionY === 'above' ? (elementBlockRoad.y ?? 0) + (elementBlockRoad.height ?? 0) : (elementBlockRoad.y ?? 0);
341
- const elementBlockRoadStraightLineX = MoCanvasCalculatorDirectionElementUtil.checkBlocksElementX(coordLX.x ?? 0, (coordLX.y ?? 0), endPosition, obstacleRect);
341
+ const elementBlockRoadStraightLineX = MoCanvasCalculatorDirectionElementUtil.checkBlocksElementX(coordLX.x ?? 0, coordLX.y ?? 0, endPosition, obstacleRect);
342
342
  let ignoreBypassElement = false;
343
343
  if (elementBlockRoadStraightLineX && elementBlockRoadStraightLineX.id === elementBlockRoad.id) {
344
344
  ignoreBypassElement = true;
@@ -354,7 +354,7 @@ class MoCanvasCalculatorDirectionElementUtil {
354
354
  separatedPoints.push({ start: coordLX, end, mode: 'horizontal', id: key, name: 'c' });
355
355
  return {
356
356
  path: line,
357
- endPath: end
357
+ endPath: end,
358
358
  };
359
359
  }
360
360
  end = endPath;
@@ -363,7 +363,7 @@ class MoCanvasCalculatorDirectionElementUtil {
363
363
  const data = this.checkAndAvoidBlocksYLeft(end.x ?? 0, end.y ?? 0, lineCurve, endPosition, directionY, obstacleRect, separatedPoints, `${line}`);
364
364
  return {
365
365
  path: data.path,
366
- endPath: data.endPath
366
+ endPath: data.endPath,
367
367
  };
368
368
  }
369
369
  static byPassElementOnRightSideNewMode(startX, startY, endY, separatedPoints, key, coordLX) {
@@ -372,7 +372,7 @@ class MoCanvasCalculatorDirectionElementUtil {
372
372
  separatedPoints.push({ start: start, end: end, mode: 'horizontal', id: key, name: 'q2r' });
373
373
  return {
374
374
  pathByPassQ: ``,
375
- endPath: end
375
+ endPath: end,
376
376
  };
377
377
  }
378
378
  }
@@ -381,7 +381,7 @@ class MoCanvasConnectNavigationBottomLeftElementUtil {
381
381
  static lineLeft(pointNext, pointStart, start, lineCurve, obstacleRect, separatedPoints) {
382
382
  const endPositionOrigin = {
383
383
  x: pointNext.x,
384
- y: pointNext.y
384
+ y: pointNext.y,
385
385
  };
386
386
  const endPosition = cloneDeep(endPositionOrigin);
387
387
  const directionStartY = MoCanvasCalculatorDirectionElementUtil.checkUpDownLeftRight(start.y, endPositionOrigin.y, 'y');
@@ -389,12 +389,12 @@ class MoCanvasConnectNavigationBottomLeftElementUtil {
389
389
  if (directionStartY === 'above') {
390
390
  const startQL = { lx: start.x - lineCurve, ly: (start.y ?? 0) + lineCurve };
391
391
  const line = {
392
- start: { x: (start.x ?? 0), y: start.y ?? 0 },
393
- end: { x: startQL.lx ?? 0, y: startQL.ly ?? 0 }
392
+ start: { x: start.x ?? 0, y: start.y ?? 0 },
393
+ end: { x: startQL.lx ?? 0, y: startQL.ly ?? 0 },
394
394
  };
395
395
  newPosition = {
396
396
  x: pointStart.x - (lineCurve + 10),
397
- y: MoCanvasCalculatorBranchUtil.mathOperatorsCalculation(directionStartY, line.end.y, lineCurve, true)
397
+ y: MoCanvasCalculatorBranchUtil.mathOperatorsCalculation(directionStartY, line.end.y, lineCurve, true),
398
398
  };
399
399
  separatedPoints.push({ start: line.start, end: line.end, mode: 'vertical-single-curve', id: '1' }); // line vẽ đi khỏi khối đầu tiên
400
400
  separatedPoints.push({ start: line.end, end: newPosition, mode: 'horizontal-single-curve', id: '1' }); // line vẽ đi khỏi khối đầu tiên
@@ -407,14 +407,14 @@ class MoCanvasConnectNavigationBottomLeftElementUtil {
407
407
  return;
408
408
  }
409
409
  if (Math.abs((straightLine.endPath.x ?? 0) - endPositionOrigin.x) < lineCurve) {
410
- const listLine = separatedPoints.filter(item => item.id === 'checkAndAvoidBlocksYLeft');
411
- const elements = listLine.filter(item => item.start.x === straightLine.endPath.x || item.end.x === straightLine.endPath.x);
412
- elements.forEach(item => {
410
+ const listLine = separatedPoints.filter((item) => item.id === 'checkAndAvoidBlocksYLeft');
411
+ const elements = listLine.filter((item) => item.start.x === straightLine.endPath.x || item.end.x === straightLine.endPath.x);
412
+ elements.forEach((item) => {
413
413
  if (item.start.x === straightLine.endPath.x) {
414
- item.start.x = MoCanvasCalculatorBranchUtil.mathOperatorsCalculation(directionStartX, item.start.x, (lineCurve));
414
+ item.start.x = MoCanvasCalculatorBranchUtil.mathOperatorsCalculation(directionStartX, item.start.x, lineCurve);
415
415
  }
416
416
  if (item.end.x === straightLine.endPath.x) {
417
- item.end.x = MoCanvasCalculatorBranchUtil.mathOperatorsCalculation(directionStartX, item.end.x, (lineCurve));
417
+ item.end.x = MoCanvasCalculatorBranchUtil.mathOperatorsCalculation(directionStartX, item.end.x, lineCurve);
418
418
  }
419
419
  });
420
420
  }
@@ -423,7 +423,7 @@ class MoCanvasConnectNavigationBottomLeftElementUtil {
423
423
  const directionNextX = MoCanvasCalculatorDirectionElementUtil.checkUpDownLeftRight(straightLine.endPath.x ?? 0, endPositionOrigin.x, 'x');
424
424
  const coordQ1 = MoCanvasCalculatorDirectionElementUtil.drawLineQ({ x: straightLine.endPath.x ?? 0, y: straightLine.endPath.y ?? 0 }, `${directionStartY}-${directionNextX}`, lineCurve, lineCurve); // tính đoạn cong từ đường ngang sang đường thẳng
425
425
  const elementBlockRoadX = (elementBlockRoad?.x ?? 0) + (elementBlockRoad?.width ?? 0);
426
- if (elementBlockRoad && Math.abs((elementBlockRoadX) - (straightLine.endPath.x ?? 0)) <= lineCurve * 2) {
426
+ if (elementBlockRoad && Math.abs(elementBlockRoadX - (straightLine.endPath.x ?? 0)) <= lineCurve * 2) {
427
427
  coordQ1.x1 = straightLine.endPath.x ?? 0;
428
428
  coordQ1.y1 = straightLine.endPath.y ?? 0;
429
429
  coordQ1.x = straightLine.endPath.x ?? 0;
@@ -437,11 +437,11 @@ class MoCanvasConnectNavigationBottomLeftElementUtil {
437
437
  separatedPoints.push({ start: straightLine.endPath, end: endPosition, mode: 'vertical', id: '6a ' + directionStartY });
438
438
  return;
439
439
  }
440
- const end = { x: (coordQ1.x ?? 0), y: coordQ1.y ?? 0 };
440
+ const end = { x: coordQ1.x ?? 0, y: coordQ1.y ?? 0 };
441
441
  separatedPoints.push(...pathHorizontal);
442
442
  separatedPoints.push({ start: straightLine.endPath, end: end, mode: 'vertical-single-curve', id: '6a ' + directionStartY }); // góc cong từ đường thẳng sang ngang
443
443
  if (endPath.x === endPosition.x && endPath.y < endPosition.y) {
444
- const itemLast = pathHorizontal.find(item => item.end.x === endPath.x);
444
+ const itemLast = pathHorizontal.find((item) => item.end.x === endPath.x);
445
445
  if (itemLast) {
446
446
  itemLast.end.x = endPosition.x + 50;
447
447
  endPath.x = itemLast.end.x;
@@ -452,25 +452,25 @@ class MoCanvasConnectNavigationBottomLeftElementUtil {
452
452
  static rightLeft(elementNext, start, lineCurve, obstacleRect, separatedPoints) {
453
453
  const endPosition = {
454
454
  x: elementNext.x,
455
- y: elementNext.y
455
+ y: elementNext.y,
456
456
  };
457
457
  // vẽ 1 đường thẳng từ điểm start ra ngoài đã
458
458
  const end = { x: (start.x ?? 0) + 10, y: (start.y ?? 0) + 10 };
459
- separatedPoints.push({ start: { x: (start.x ?? 0), y: start.y ?? 0 }, end: end, mode: 'vertical-single-curve', id: '1' });
459
+ separatedPoints.push({ start: { x: start.x ?? 0, y: start.y ?? 0 }, end: end, mode: 'vertical-single-curve', id: '1' });
460
460
  const endPositionX = cloneDeep(endPosition);
461
461
  endPositionX.x -= 50;
462
462
  let separatedPointsCheckAndAvoidBlocks = [];
463
- let { endPath } = MoCanvasCalculatorDirectionElementUtil.checkAndAvoidBlocks(end.x ?? 0, (end.y ?? 0), lineCurve, endPositionX, obstacleRect, separatedPointsCheckAndAvoidBlocks);
463
+ let { endPath } = MoCanvasCalculatorDirectionElementUtil.checkAndAvoidBlocks(end.x ?? 0, end.y ?? 0, lineCurve, endPositionX, obstacleRect, separatedPointsCheckAndAvoidBlocks);
464
464
  if (Math.abs((start.x ?? 0) - endPosition.x) < 10 || end.x > endPath.x) {
465
465
  endPath = {
466
466
  x: end.x,
467
- y: end.y
467
+ y: end.y,
468
468
  };
469
469
  separatedPointsCheckAndAvoidBlocks = [];
470
470
  }
471
471
  if (Math.abs((endPath.y ?? 0) - endPosition.y) < 15) {
472
- const element = separatedPointsCheckAndAvoidBlocks.find(item => (item.end.y === endPath.y && item.end.x === endPath.x));
473
- const elementQR = separatedPointsCheckAndAvoidBlocks.find(item => (item.end.y === element?.start.y && item.end.x === element.start.x));
472
+ const element = separatedPointsCheckAndAvoidBlocks.find((item) => item.end.y === endPath.y && item.end.x === endPath.x);
473
+ const elementQR = separatedPointsCheckAndAvoidBlocks.find((item) => item.end.y === element?.start.y && item.end.x === element.start.x);
474
474
  if (element) {
475
475
  element.start.y = endPosition.y;
476
476
  element.end.y = endPosition.y;
@@ -493,7 +493,7 @@ class MoCanvasConnectNavigationBottomLeftElementUtil {
493
493
  const coordQ1 = MoCanvasCalculatorDirectionElementUtil.drawLineQ({ x: endPath.x ?? 0, y: endPath.y ?? 0 }, `right-${directionY === 'above' ? 'above' : 'under'}`, lineCurve, lineCurve); // tính đoạn cong từ đường ngang sang đường thẳng
494
494
  const endPositionY = cloneDeep(endPosition);
495
495
  endPositionY.y = MoCanvasCalculatorBranchUtil.mathOperatorsCalculation(directionY, endPositionY.y, lineCurve);
496
- separatedPoints.push({ start: { x: endPath.x ?? 0, y: endPath.y }, end: { x: coordQ1.x ?? 0, y: (coordQ1.y ?? 0) }, mode: 'horizontal-single-curve', id: 'g' });
496
+ separatedPoints.push({ start: { x: endPath.x ?? 0, y: endPath.y }, end: { x: coordQ1.x ?? 0, y: coordQ1.y ?? 0 }, mode: 'horizontal-single-curve', id: 'g' });
497
497
  let avoidBlocksYLine = [];
498
498
  const straightLine = MoCanvasCalculatorDirectionElementUtil.checkAndAvoidBlocksY(coordQ1.x ?? 0, coordQ1.y ?? 0, lineCurve, endPositionY, directionY, obstacleRect, avoidBlocksYLine);
499
499
  if (directionY === 'under' && (coordQ1.y ?? 0) > endPositionY.y) {
@@ -505,8 +505,8 @@ class MoCanvasConnectNavigationBottomLeftElementUtil {
505
505
  straightLine.endPath = { x: coordQ1.x ?? 0, y: coordQ1.y ?? 0 };
506
506
  }
507
507
  if (Math.abs((straightLine.endPath.x ?? 0) - endPosition.x) < 15) {
508
- const elements = avoidBlocksYLine.filter(item => item.start.x === straightLine.endPath.x || item.end.x === straightLine.endPath.x);
509
- elements.forEach(item => {
508
+ const elements = avoidBlocksYLine.filter((item) => item.start.x === straightLine.endPath.x || item.end.x === straightLine.endPath.x);
509
+ elements.forEach((item) => {
510
510
  if (item.start.x === straightLine.endPath.x) {
511
511
  item.start.x += 30;
512
512
  }
@@ -530,12 +530,14 @@ class MoCanvasConnectNavigationNewElementUtil {
530
530
  static drawLineConnect(elementFrom, elementNext, obstacleRect, separatedPoints, curve) {
531
531
  let start_x = (elementFrom.x ?? 0) + (elementFrom.width ?? 0); // điểm out luôn ở phía bên phải
532
532
  let start_y = (elementFrom.y ?? 0) + (elementFrom.height ?? 0) / 2; // điểm out luôn ở phía bên phải
533
- if (MoCanvasConnectNavigationNewElementUtil.START_MODE === 'bottom-top') { // điểm out luôn ở phía bên dưới
534
- start_x = (elementFrom.x ?? 0) + ((elementFrom.width ?? 0) / 2);
533
+ if (MoCanvasConnectNavigationNewElementUtil.START_MODE === 'bottom-top') {
534
+ // điểm out luôn phía bên dưới
535
+ start_x = (elementFrom.x ?? 0) + (elementFrom.width ?? 0) / 2;
535
536
  start_y = (elementFrom.y ?? 0) + (elementFrom.height ?? 0);
536
537
  }
537
- if (MoCanvasConnectNavigationNewElementUtil.START_MODE === 'bottom-left') { // điểm out luôn ở phía bên dưới
538
- start_x = (elementFrom.x ?? 0) + ((elementFrom.width ?? 0) / 2);
538
+ if (MoCanvasConnectNavigationNewElementUtil.START_MODE === 'bottom-left') {
539
+ // điểm out luôn phía bên dưới
540
+ start_x = (elementFrom.x ?? 0) + (elementFrom.width ?? 0) / 2;
539
541
  start_y = (elementFrom.y ?? 0) + (elementFrom.height ?? 0);
540
542
  }
541
543
  const M_start = { x: start_x, y: start_y };
@@ -567,8 +569,8 @@ class MoCanvasConnectNavigationNewElementUtil {
567
569
  }
568
570
  static lineConnectRight(elementNext, start, lineCurve, obstacleRect, separatedPoints) {
569
571
  const endPosition = {
570
- x: (elementNext.x ?? 0) - (lineCurve * 3),
571
- y: (elementNext.y ?? 0) + (elementNext.height ?? 0) / 2
572
+ x: (elementNext.x ?? 0) - lineCurve * 3,
573
+ y: (elementNext.y ?? 0) + (elementNext.height ?? 0) / 2,
572
574
  };
573
575
  const endPositionX = cloneDeep(endPosition);
574
576
  let separatedPointsCheckAndAvoidBlocks = [];
@@ -577,7 +579,7 @@ class MoCanvasConnectNavigationNewElementUtil {
577
579
  path = '';
578
580
  endPath = {
579
581
  x: start.x,
580
- y: start.y
582
+ y: start.y,
581
583
  };
582
584
  separatedPointsCheckAndAvoidBlocks = [];
583
585
  }
@@ -589,7 +591,7 @@ class MoCanvasConnectNavigationNewElementUtil {
589
591
  separatedPoints.push({ start: endPath, end: LEnd, mode: 'horizontal', id: 'f' });
590
592
  return {
591
593
  dPath: `${path} L ${LEnd.x} ${LEnd.y}`,
592
- endPath: LEnd
594
+ endPath: LEnd,
593
595
  };
594
596
  }
595
597
  let lineCurveSubY = lineCurve;
@@ -618,21 +620,21 @@ class MoCanvasConnectNavigationNewElementUtil {
618
620
  const lineClose = this.closeLine({ x: coordQ2.x ?? 0, y: coordQ2.y ?? 0 }, endPosition, lineCurve, elementNext, separatedPoints);
619
621
  return {
620
622
  dPath: `${path} ${pathQ1} ${straightLine.path} ${pathQ2} ${lineClose}`,
621
- endPath: straightLine.endPath
623
+ endPath: straightLine.endPath,
622
624
  };
623
625
  }
624
626
  static lineConnectLeft(elementNext, elementFrom, start, lineCurve, obstacleRect, separatedPoints) {
625
627
  const endPositionOrigin = {
626
- x: (elementNext.x ?? 0) - (lineCurve * 1.5),
627
- y: (elementNext.y ?? 0) + (elementNext.height ?? 0) / 2
628
+ x: (elementNext.x ?? 0) - lineCurve * 1.5,
629
+ y: (elementNext.y ?? 0) + (elementNext.height ?? 0) / 2,
628
630
  };
629
631
  const endPosition = cloneDeep(endPositionOrigin);
630
632
  const directionStartY = MoCanvasCalculatorDirectionElementUtil.checkUpDownLeftRight(start.y, endPositionOrigin.y, 'y');
631
- const endY = (directionStartY === 'under' || directionStartY === 'center') ? (elementNext.y ?? 0) : (elementNext.y ?? 0) + (elementNext.height ?? 0);
632
- endPosition.y = MoCanvasCalculatorBranchUtil.mathOperatorsCalculation(directionStartY, endY, (lineCurve * 2));
633
+ const endY = directionStartY === 'under' || directionStartY === 'center' ? (elementNext.y ?? 0) : (elementNext.y ?? 0) + (elementNext.height ?? 0);
634
+ endPosition.y = MoCanvasCalculatorBranchUtil.mathOperatorsCalculation(directionStartY, endY, lineCurve * 2);
633
635
  const pathQ = MoCanvasCalculatorDirectionElementUtil.drawLineQ({ x: (start.x ?? 0) + 10, y: start.y ?? 0 }, `right-${directionStartY === 'under' ? 'under' : 'above'}`, lineCurve, lineCurve);
634
- const startQL = { lx: pathQ.x, ly: MoCanvasCalculatorBranchUtil.mathOperatorsCalculation(directionStartY, (pathQ.y ?? 0), ((elementFrom.height ?? 0) / 2), true) };
635
- separatedPoints.push({ start: { x: (start.x ?? 0), y: start.y ?? 0 }, end: { x: pathQ.x ?? 0, y: pathQ.y ?? 0 }, mode: 'horizontal-single-curve', id: '1' });
636
+ const startQL = { lx: pathQ.x, ly: MoCanvasCalculatorBranchUtil.mathOperatorsCalculation(directionStartY, pathQ.y ?? 0, (elementFrom.height ?? 0) / 2, true) };
637
+ separatedPoints.push({ start: { x: start.x ?? 0, y: start.y ?? 0 }, end: { x: pathQ.x ?? 0, y: pathQ.y ?? 0 }, mode: 'horizontal-single-curve', id: '1' });
636
638
  separatedPoints.push({ start: { x: pathQ.x ?? 0, y: pathQ.y ?? 0 }, end: { x: startQL.lx ?? 0, y: startQL.ly }, mode: 'horizontal', id: '2' });
637
639
  if (directionStartY === 'center') {
638
640
  const coordQ1 = MoCanvasCalculatorDirectionElementUtil.drawLineQ({ x: startQL.lx ?? 0, y: startQL.ly ?? 0 }, `above-left`, lineCurve, lineCurve); // tính đoạn cong từ đường ngang sang đường thẳng
@@ -653,7 +655,7 @@ class MoCanvasConnectNavigationNewElementUtil {
653
655
  if ((directionStartY === 'under' && startQL.ly > endPosition.y) || (directionStartY === 'above' && startQL.ly < endPosition.y) || startQL.ly === endPosition.y) {
654
656
  let condition = true;
655
657
  while (condition) {
656
- const checkAndAvoidBlocksYLeft = separatedPoints.findIndex(item => item.id === "checkAndAvoidBlocksYLeft");
658
+ const checkAndAvoidBlocksYLeft = separatedPoints.findIndex((item) => item.id === 'checkAndAvoidBlocksYLeft');
657
659
  if (checkAndAvoidBlocksYLeft !== -1) {
658
660
  separatedPoints.splice(checkAndAvoidBlocksYLeft, 1);
659
661
  }
@@ -664,7 +666,7 @@ class MoCanvasConnectNavigationNewElementUtil {
664
666
  straightLine.path = '';
665
667
  straightLine.endPath = {
666
668
  x: startQL.lx ?? 0,
667
- y: startQL.ly ?? 0
669
+ y: startQL.ly ?? 0,
668
670
  };
669
671
  }
670
672
  if (endPosition.x === straightLine.endPath.x) {
@@ -677,7 +679,7 @@ class MoCanvasConnectNavigationNewElementUtil {
677
679
  const directionNextX = MoCanvasCalculatorDirectionElementUtil.checkUpDownLeftRight(straightLine.endPath.x ?? 0, endPositionOrigin.x, 'x');
678
680
  const coordQ1 = MoCanvasCalculatorDirectionElementUtil.drawLineQ({ x: straightLine.endPath.x ?? 0, y: straightLine.endPath.y ?? 0 }, `${directionStartY}-${directionNextX}`, lineCurve, lineCurve); // tính đoạn cong từ đường ngang sang đường thẳng
679
681
  const elementBlockRoadX = (elementBlockRoad?.x ?? 0) + (elementBlockRoad?.width ?? 0);
680
- if (elementBlockRoad && Math.abs((elementBlockRoadX) - (straightLine.endPath.x ?? 0)) <= lineCurve * 2) {
682
+ if (elementBlockRoad && Math.abs(elementBlockRoadX - (straightLine.endPath.x ?? 0)) <= lineCurve * 2) {
681
683
  coordQ1.x1 = straightLine.endPath.x ?? 0;
682
684
  coordQ1.y1 = straightLine.endPath.y ?? 0;
683
685
  coordQ1.x = straightLine.endPath.x ?? 0;
@@ -703,7 +705,7 @@ class MoCanvasConnectNavigationNewElementUtil {
703
705
  const line = { x: start.x, y: start.y };
704
706
  const endPoint = {
705
707
  x: elementNext.x,
706
- y: end.y
708
+ y: end.y,
707
709
  };
708
710
  let pathQ1 = '';
709
711
  if (Math.abs(start.y - end.y) > lineCurve) {
@@ -724,23 +726,23 @@ class MoCanvasConnectNavigationNewElementUtil {
724
726
  static lineConnectLeftWithBottomStart(elementNext, elementFrom, start, lineCurve, obstacleRect, separatedPoints) {
725
727
  const endPositionOrigin = {
726
728
  x: (elementNext.x ?? 0) + (elementNext.width ?? 0) / 2,
727
- y: (elementNext.y ?? 0) - (lineCurve)
729
+ y: (elementNext.y ?? 0) - lineCurve,
728
730
  };
729
731
  const endPosition = cloneDeep(endPositionOrigin);
730
732
  const directionStartY = MoCanvasCalculatorDirectionElementUtil.checkUpDownLeftRight(start.y, endPositionOrigin.y, 'y');
731
- const endY = (elementNext.y ?? 0);
733
+ const endY = elementNext.y ?? 0;
732
734
  console.log('directionStartY', directionStartY);
733
735
  if (directionStartY === 'under') {
734
- endPosition.y = endY - (lineCurve * 3);
736
+ endPosition.y = endY - lineCurve * 3;
735
737
  }
736
738
  const startQL = { lx: start.x, ly: (start.y ?? 0) + lineCurve };
737
739
  const line = {
738
- start: { x: (start.x ?? 0), y: start.y ?? 0 },
739
- end: { x: startQL.lx ?? 0, y: startQL.ly ?? 0 }
740
+ start: { x: start.x ?? 0, y: start.y ?? 0 },
741
+ end: { x: startQL.lx ?? 0, y: startQL.ly ?? 0 },
740
742
  };
741
- const newEnd = { x: elementFrom.x - (lineCurve * 2), y: line.end.y - lineCurve };
743
+ const newEnd = { x: elementFrom.x - lineCurve * 2, y: line.end.y - lineCurve };
742
744
  if (directionStartY === 'above') {
743
- line.end = { x: (start.x ?? 0) - lineCurve, y: (start.y ?? 0) + (lineCurve * 2) };
745
+ line.end = { x: (start.x ?? 0) - lineCurve, y: (start.y ?? 0) + lineCurve * 2 };
744
746
  separatedPoints.push({ start: line.end, end: newEnd, mode: 'horizontal-single-curve', id: '1' });
745
747
  }
746
748
  separatedPoints.push({ start: line.start, end: line.end, mode: 'vertical-single-curve', id: '1' }); // line vẽ đi khỏi khối đầu tiên
@@ -765,13 +767,13 @@ class MoCanvasConnectNavigationNewElementUtil {
765
767
  if (directionStartX === 'center' && directionStartY === 'under') {
766
768
  this.closeLineWithLineTopBottom({ x: straightLine.endPath.x ?? 0, y: straightLine.endPath.y ?? 0 }, endPositionOrigin, lineCurve, elementNext, separatedPoints);
767
769
  return {
768
- dPath: ``
770
+ dPath: ``,
769
771
  };
770
772
  }
771
773
  if ((directionStartY === 'under' && startQL.ly > endPosition.y) || (directionStartY === 'above' && startQL.ly < endPosition.y) || startQL.ly === endPosition.y) {
772
774
  let condition = true;
773
775
  while (condition) {
774
- const checkAndAvoidBlocksYLeft = separatedPoints.findIndex(item => item.id === "checkAndAvoidBlocksYLeft");
776
+ const checkAndAvoidBlocksYLeft = separatedPoints.findIndex((item) => item.id === 'checkAndAvoidBlocksYLeft');
775
777
  if (checkAndAvoidBlocksYLeft !== -1) {
776
778
  separatedPoints.splice(checkAndAvoidBlocksYLeft, 1);
777
779
  }
@@ -782,7 +784,7 @@ class MoCanvasConnectNavigationNewElementUtil {
782
784
  straightLine.path = '';
783
785
  straightLine.endPath = {
784
786
  x: startQL.lx ?? 0,
785
- y: startQL.ly ?? 0
787
+ y: startQL.ly ?? 0,
786
788
  };
787
789
  }
788
790
  // kiểm tra ngay khi cua có vướng ai không rồi hẵng vẽ Q1
@@ -790,7 +792,7 @@ class MoCanvasConnectNavigationNewElementUtil {
790
792
  const directionNextX = MoCanvasCalculatorDirectionElementUtil.checkUpDownLeftRight(straightLine.endPath.x ?? 0, endPositionOrigin.x, 'x');
791
793
  const coordQ1 = MoCanvasCalculatorDirectionElementUtil.drawLineQ({ x: straightLine.endPath.x ?? 0, y: straightLine.endPath.y ?? 0 }, `${directionStartY}-${directionNextX}`, lineCurve, lineCurve); // tính đoạn cong từ đường ngang sang đường thẳng
792
794
  const elementBlockRoadX = (elementBlockRoad?.x ?? 0) + (elementBlockRoad?.width ?? 0);
793
- if (elementBlockRoad && Math.abs((elementBlockRoadX) - (straightLine.endPath.x ?? 0)) <= lineCurve * 2) {
795
+ if (elementBlockRoad && Math.abs(elementBlockRoadX - (straightLine.endPath.x ?? 0)) <= lineCurve * 2) {
794
796
  coordQ1.x1 = straightLine.endPath.x ?? 0;
795
797
  coordQ1.y1 = straightLine.endPath.y ?? 0;
796
798
  coordQ1.x = straightLine.endPath.x ?? 0;
@@ -810,7 +812,7 @@ class MoCanvasConnectNavigationNewElementUtil {
810
812
  return;
811
813
  }
812
814
  separatedPoints.push(...pathHorizontal);
813
- separatedPoints.push({ start: straightLine.endPath, end: { x: (coordQ1.x ?? 0 - 10), y: coordQ1.y ?? 0 }, mode: 'vertical-single-curve', id: '6a ' + directionStartY });
815
+ separatedPoints.push({ start: straightLine.endPath, end: { x: coordQ1.x ?? 0 - 10, y: coordQ1.y ?? 0 }, mode: 'vertical-single-curve', id: '6a ' + directionStartY });
814
816
  this.closeLineWithLineTopBottom({ x: endPath.x ?? 0, y: endPath.y ?? 0 }, endPositionOrigin, lineCurve, elementNext, separatedPoints);
815
817
  return {
816
818
  dPath: ``,
@@ -825,7 +827,7 @@ class MoCanvasConnectNavigationNewElementUtil {
825
827
  const line = { x: start.x, y: start.y };
826
828
  const endPoint = {
827
829
  x: end.x,
828
- y: elementNext.y
830
+ y: elementNext.y,
829
831
  };
830
832
  const pathQ1 = '';
831
833
  if (Math.abs(start.x - end.x) > lineCurve) {
@@ -842,20 +844,20 @@ class MoCanvasConnectNavigationNewElementUtil {
842
844
  static lineConnectRightWithBottomStart(elementNext, start, lineCurve, obstacleRect, separatedPoints) {
843
845
  const endPosition = {
844
846
  x: (elementNext.x ?? 0) + (elementNext.width ?? 0) / 2,
845
- y: (elementNext.y ?? 0) - (lineCurve)
847
+ y: (elementNext.y ?? 0) - lineCurve,
846
848
  };
847
849
  // vẽ 1 đường thẳng từ điểm start ra ngoài đã
848
850
  const end = { x: (start.x ?? 0) + 10, y: (start.y ?? 0) + 20 };
849
- separatedPoints.push({ start: { x: (start.x ?? 0), y: start.y ?? 0 }, end: end, mode: 'vertical-single-curve', id: '1' });
851
+ separatedPoints.push({ start: { x: start.x ?? 0, y: start.y ?? 0 }, end: end, mode: 'vertical-single-curve', id: '1' });
850
852
  const endPositionX = cloneDeep(endPosition);
851
853
  endPositionX.x -= 10;
852
854
  let separatedPointsCheckAndAvoidBlocks = [];
853
- let { path, endPath } = MoCanvasCalculatorDirectionElementUtil.checkAndAvoidBlocks(end.x ?? 0, (end.y ?? 0), lineCurve, endPositionX, obstacleRect, separatedPointsCheckAndAvoidBlocks);
855
+ let { path, endPath } = MoCanvasCalculatorDirectionElementUtil.checkAndAvoidBlocks(end.x ?? 0, end.y ?? 0, lineCurve, endPositionX, obstacleRect, separatedPointsCheckAndAvoidBlocks);
854
856
  if (Math.abs((start.x ?? 0) - endPosition.x) < 10) {
855
857
  path = '';
856
858
  endPath = {
857
859
  x: start.x,
858
- y: start.y
860
+ y: start.y,
859
861
  };
860
862
  separatedPointsCheckAndAvoidBlocks = [];
861
863
  }
@@ -869,7 +871,7 @@ class MoCanvasConnectNavigationNewElementUtil {
869
871
  this.closeLineWithLineTopBottom(LEnd, endPosition, lineCurve, elementNext, separatedPoints);
870
872
  return {
871
873
  dPath: `${path} L ${LEnd.x} ${LEnd.y}`,
872
- endPath: LEnd
874
+ endPath: LEnd,
873
875
  };
874
876
  }
875
877
  const coordQ1 = MoCanvasCalculatorDirectionElementUtil.drawLineQ({ x: endPath.x ?? 0, y: endPath.y ?? 0 }, `right-${directionY === 'above' ? 'above' : 'under'}`, lineCurve, lineCurve); // tính đoạn cong từ đường ngang sang đường thẳng
@@ -880,7 +882,7 @@ class MoCanvasConnectNavigationNewElementUtil {
880
882
  if (elementBlockRoadStraightLineY) {
881
883
  coordQ1.x = (elementBlockRoadStraightLineY.x ?? 0) + (elementBlockRoadStraightLineY.width ?? 0) + lineCurve;
882
884
  }
883
- separatedPoints.push({ start: { x: endPath.x ?? 0, y: endPath.y }, end: { x: coordQ1.x ?? 0, y: (coordQ1.y ?? 0) }, mode: 'horizontal-single-curve', id: 'g' });
885
+ separatedPoints.push({ start: { x: endPath.x ?? 0, y: endPath.y }, end: { x: coordQ1.x ?? 0, y: coordQ1.y ?? 0 }, mode: 'horizontal-single-curve', id: 'g' });
884
886
  let avoidBlocksYLine = [];
885
887
  const straightLine = MoCanvasCalculatorDirectionElementUtil.checkAndAvoidBlocksY(coordQ1.x ?? 0, coordQ1.y ?? 0, lineCurve, endPositionY, directionY, obstacleRect, avoidBlocksYLine);
886
888
  if (directionY === 'under' && (coordQ1.y ?? 0) > endPositionY.y) {
@@ -910,20 +912,23 @@ class LibsUiComponentsDrawLineDirective {
910
912
  outDrawLineFunctionControl = new EventEmitter();
911
913
  outConnected = new EventEmitter();
912
914
  ngAfterViewInit() {
913
- this.svgElement = this.svgElement || document.createElementNS("http://www.w3.org/2000/svg", "svg");
915
+ this.svgElement = this.svgElement || document.createElementNS('http://www.w3.org/2000/svg', 'svg');
914
916
  this.elementRef.nativeElement.append(this.svgElement);
915
- this.outDrawLineFunctionControl.emit({
917
+ this.outDrawLineFunctionControl.emit(this.FunctionsControl);
918
+ }
919
+ get FunctionsControl() {
920
+ return {
916
921
  setData: this.setData.bind(this),
917
922
  setReachablePointRange: this.setReachablePointRange.bind(this),
918
923
  removeLine: this.removeLine.bind(this),
919
924
  removeReachablePointRange: this.removeReachablePointRange.bind(this),
920
- updateViewBox: this.updateViewBox.bind(this)
921
- });
925
+ updateViewBox: this.updateViewBox.bind(this),
926
+ };
922
927
  }
923
928
  setData(data) {
924
929
  const newData = [];
925
- data.forEach(item => {
926
- if (this.dataDraw.find(dataDraw => dataDraw.id === item.id && item.points.start.x === dataDraw.points.start.x && item.points.start.y === dataDraw.points.start.y && item.points.end.x === dataDraw.points.end.x && item.points.end.y === dataDraw.points.end.y)) {
930
+ data.forEach((item) => {
931
+ if (this.dataDraw.find((dataDraw) => dataDraw.id === item.id && item.points.start.x === dataDraw.points.start.x && item.points.start.y === dataDraw.points.start.y && item.points.end.x === dataDraw.points.end.x && item.points.end.y === dataDraw.points.end.y)) {
927
932
  return;
928
933
  }
929
934
  const itemClone = cloneDeep(item);
@@ -935,8 +940,8 @@ class LibsUiComponentsDrawLineDirective {
935
940
  }
936
941
  setReachablePointRange(data) {
937
942
  const newData = [];
938
- data.forEach(item => {
939
- if (this.dataReachablePointRange.find(dataDraw => dataDraw.id === item.id || item.x === dataDraw.x && item.y === dataDraw.y)) {
943
+ data.forEach((item) => {
944
+ if (this.dataReachablePointRange.find((dataDraw) => dataDraw.id === item.id || (item.x === dataDraw.x && item.y === dataDraw.y))) {
940
945
  return;
941
946
  }
942
947
  const itemClone = cloneDeep(item);
@@ -947,26 +952,26 @@ class LibsUiComponentsDrawLineDirective {
947
952
  this.startProcessDataReachablePointRange(newData);
948
953
  }
949
954
  removeLine(id, points) {
950
- const dataDrawById = this.dataDraw.filter(item => item.id === id);
955
+ const dataDrawById = this.dataDraw.filter((item) => item.id === id);
951
956
  if (!dataDrawById?.length) {
952
957
  return;
953
958
  }
954
959
  const removeByItem = (item) => {
955
960
  this.removeElementOfPoints(item.points);
956
- item.points.separatedPoints?.forEach(separatedPoints => this.removeElementOfPoints(separatedPoints));
961
+ item.points.separatedPoints?.forEach((separatedPoints) => this.removeElementOfPoints(separatedPoints));
957
962
  };
958
963
  if (!points?.length) {
959
- dataDrawById.forEach(item => removeByItem(item));
960
- this.dataDraw = this.dataDraw.filter(item => item.id !== id);
964
+ dataDrawById.forEach((item) => removeByItem(item));
965
+ this.dataDraw = this.dataDraw.filter((item) => item.id !== id);
961
966
  this.updateViewBox();
962
967
  return;
963
968
  }
964
- points.forEach(point => {
965
- const dataDrawRemoveByPoint = dataDrawById.find(item => item.points.start.x === point.start.x && item.points.start.y === point.start.y && item.points.end.x === point.end.x && item.points.end.y === point.end.y);
969
+ points.forEach((point) => {
970
+ const dataDrawRemoveByPoint = dataDrawById.find((item) => item.points.start.x === point.start.x && item.points.start.y === point.start.y && item.points.end.x === point.end.x && item.points.end.y === point.end.y);
966
971
  if (dataDrawRemoveByPoint) {
967
972
  dataDrawRemoveByPoint.isRemove = true;
968
973
  removeByItem(dataDrawRemoveByPoint);
969
- this.dataDraw = this.dataDraw.filter(item => item.id !== id && !item.isRemove);
974
+ this.dataDraw = this.dataDraw.filter((item) => item.id !== id && !item.isRemove);
970
975
  }
971
976
  });
972
977
  this.updateViewBox();
@@ -976,21 +981,21 @@ class LibsUiComponentsDrawLineDirective {
976
981
  if (!ids.length) {
977
982
  return;
978
983
  }
979
- ids.forEach(id => {
980
- const itemRemove = this.dataReachablePointRange?.find(item => item.id === id);
984
+ ids.forEach((id) => {
985
+ const itemRemove = this.dataReachablePointRange?.find((item) => item.id === id);
981
986
  if (!itemRemove) {
982
987
  return;
983
988
  }
984
989
  itemRemove.onDestroyEvent?.next();
985
990
  itemRemove.element?.remove();
986
- this.dataReachablePointRange = this.dataReachablePointRange?.filter(item => item.id !== id);
991
+ this.dataReachablePointRange = this.dataReachablePointRange?.filter((item) => item.id !== id);
987
992
  });
988
993
  }
989
994
  startProcessDataRow(dataDraw) {
990
995
  this.zone.runOutsideAngular(() => {
991
- dataDraw.forEach(item => {
996
+ dataDraw.forEach((item) => {
992
997
  const { pathElement, arrowElement, circleStartElement, circleEndElement } = this.createPathAndArrowElement(item.id);
993
- item.points.obstacleRect?.forEach(data => this.addRect('rect', data));
998
+ item.points.obstacleRect?.forEach((data) => this.addRect('rect', data));
994
999
  item.points.pathElement = pathElement;
995
1000
  item.points.arrowElement = arrowElement;
996
1001
  if (item.startCircle) {
@@ -1009,12 +1014,12 @@ class LibsUiComponentsDrawLineDirective {
1009
1014
  }
1010
1015
  startProcessDataReachablePointRange(data) {
1011
1016
  this.zone.runOutsideAngular(() => {
1012
- data.forEach(item => {
1017
+ data.forEach((item) => {
1013
1018
  item.onDestroyEvent = new Subject();
1014
1019
  item.element = this.createPathAndArrowElement(item.id).circleEndElement;
1015
1020
  this.svgElement.append(item.element);
1016
1021
  this.updateAttributeCircle(item.element, item.id, item, item.style);
1017
- this.onDrawLineEnd.pipe(takeUntil(item.onDestroyEvent), takeUntil(this.onDestroy)).subscribe(eventData => {
1022
+ this.onDrawLineEnd.pipe(takeUntil(item.onDestroyEvent), takeUntil(this.onDestroy)).subscribe((eventData) => {
1018
1023
  const { dataLine, event } = eventData;
1019
1024
  if (!checkMouseOverInContainer(event, item.element) || !dataLine.ref || !item.ref) {
1020
1025
  return;
@@ -1023,7 +1028,7 @@ class LibsUiComponentsDrawLineDirective {
1023
1028
  eventData.dataLine.idConnected = item.id;
1024
1029
  this.outConnected.emit({
1025
1030
  dataLine: dataLine.ref,
1026
- dataReachablePointRange: item.ref
1031
+ dataReachablePointRange: item.ref,
1027
1032
  });
1028
1033
  });
1029
1034
  });
@@ -1048,7 +1053,7 @@ class LibsUiComponentsDrawLineDirective {
1048
1053
  curve = curve ?? 10;
1049
1054
  }
1050
1055
  const preLengthSeparatedPoints = points.separatedPoints?.length;
1051
- points.separatedPoints?.forEach(separatedPoints => this.removeElementOfPoints(separatedPoints));
1056
+ points.separatedPoints?.forEach((separatedPoints) => this.removeElementOfPoints(separatedPoints));
1052
1057
  points.separatedPoints = [];
1053
1058
  MoCanvasConnectNavigationNewElementUtil.START_MODE = 'right-left';
1054
1059
  if (data.startEndMode) {
@@ -1067,10 +1072,10 @@ class LibsUiComponentsDrawLineDirective {
1067
1072
  return;
1068
1073
  }
1069
1074
  let path = '';
1070
- points.separatedPoints.forEach(separatedPoints => {
1075
+ points.separatedPoints.forEach((separatedPoints) => {
1071
1076
  path += this.buildPathAndDrawSeparatedPoints(data, separatedPoints, separatedPoints.mode || mode);
1072
1077
  });
1073
- const pathElement = document.createElementNS("http://www.w3.org/2000/svg", "path");
1078
+ const pathElement = document.createElementNS('http://www.w3.org/2000/svg', 'path');
1074
1079
  this.svgElement.append(pathElement);
1075
1080
  points.pathElement = pathElement;
1076
1081
  const styleConfig = {
@@ -1079,7 +1084,7 @@ class LibsUiComponentsDrawLineDirective {
1079
1084
  strokeWidth: data.lineStyle?.strokeWidth ?? '1px',
1080
1085
  fill: data.lineStyle?.fill ?? 'none',
1081
1086
  curve: data.lineStyle?.curve ?? 10,
1082
- distancePoint: data.lineStyle?.distancePoint ?? 10
1087
+ distancePoint: data.lineStyle?.distancePoint ?? 10,
1083
1088
  };
1084
1089
  points.pathElement?.setAttribute('stroke', styleConfig.stroke);
1085
1090
  points.pathElement?.setAttribute('fill', styleConfig.fill);
@@ -1103,14 +1108,14 @@ class LibsUiComponentsDrawLineDirective {
1103
1108
  yPoints.add(points.start.y);
1104
1109
  yPoints.add(points.end.y);
1105
1110
  };
1106
- this.dataDraw?.forEach(item => {
1111
+ this.dataDraw?.forEach((item) => {
1107
1112
  const points = item.points;
1108
1113
  addPoints(points);
1109
- points.separatedPoints?.forEach(separatedPoints => addPoints(separatedPoints));
1110
- points.obstacleRect?.forEach(obstacleRect => {
1114
+ points.separatedPoints?.forEach((separatedPoints) => addPoints(separatedPoints));
1115
+ points.obstacleRect?.forEach((obstacleRect) => {
1111
1116
  addPoints({
1112
1117
  start: { x: obstacleRect.x - (obstacleRect.gapXObstacleRect || 8), y: obstacleRect.y - (obstacleRect.gapYObstacleRect || 8) },
1113
- end: { x: obstacleRect.x + obstacleRect.width + (obstacleRect.gapXObstacleRect || 8) * 2, y: obstacleRect.y + obstacleRect.height + (obstacleRect.gapYObstacleRect || 8) * 2 }
1118
+ end: { x: obstacleRect.x + obstacleRect.width + (obstacleRect.gapXObstacleRect || 8) * 2, y: obstacleRect.y + obstacleRect.height + (obstacleRect.gapYObstacleRect || 8) * 2 },
1114
1119
  });
1115
1120
  });
1116
1121
  });
@@ -1132,8 +1137,8 @@ class LibsUiComponentsDrawLineDirective {
1132
1137
  if (!obstacleRects.length) {
1133
1138
  return;
1134
1139
  }
1135
- const elementStart = obstacleRects.find(item => this.isPointInsideSquare(points.start, item));
1136
- const elementEnd = obstacleRects.find(item => this.isPointInsideSquare(points.end, item));
1140
+ const elementStart = obstacleRects.find((item) => this.isPointInsideSquare(points.start, item));
1141
+ const elementEnd = obstacleRects.find((item) => this.isPointInsideSquare(points.end, item));
1137
1142
  if (this.viewBoxConfig?.marginBetweenElement) {
1138
1143
  MoCanvasConnectNavigationNewElementUtil.ELEMENT_MARGIN_BETWEEN_BRANCH_DEFAULT = this.viewBoxConfig?.marginBetweenElement ?? 32;
1139
1144
  }
@@ -1147,7 +1152,7 @@ class LibsUiComponentsDrawLineDirective {
1147
1152
  strokeWidth: data.lineStyle?.strokeWidth ?? '1px',
1148
1153
  fill: data.lineStyle?.fill ?? 'none',
1149
1154
  curve: data.lineStyle?.curve ?? 10,
1150
- distancePoint: data.lineStyle?.distancePoint ?? 10
1155
+ distancePoint: data.lineStyle?.distancePoint ?? 10,
1151
1156
  };
1152
1157
  points.pathElement?.setAttribute('stroke', styleConfig.stroke);
1153
1158
  points.pathElement?.setAttribute('fill', styleConfig.fill);
@@ -1156,7 +1161,7 @@ class LibsUiComponentsDrawLineDirective {
1156
1161
  points.pathElement?.setAttribute('stroke-dasharray', styleConfig.strokeDasharray);
1157
1162
  }
1158
1163
  let { curve, distancePoint } = styleConfig;
1159
- mode = mode || "quart-in";
1164
+ mode = mode || 'quart-in';
1160
1165
  if (mode !== 'quart-in') {
1161
1166
  curve = curve ?? 10;
1162
1167
  distancePoint = distancePoint ?? 10;
@@ -1180,7 +1185,7 @@ class LibsUiComponentsDrawLineDirective {
1180
1185
  this.drawRectAndInitEvent(data, mode);
1181
1186
  }
1182
1187
  calculatorDistancePointAndCurve(points, distancePoint, curve, mode) {
1183
- if ((!mode.includes('vertical') && !mode.includes('horizontal'))) {
1188
+ if (!mode.includes('vertical') && !mode.includes('horizontal')) {
1184
1189
  return { curve, distancePoint };
1185
1190
  }
1186
1191
  const gapX = Math.abs(points.start.x - points.end.x);
@@ -1218,15 +1223,25 @@ class LibsUiComponentsDrawLineDirective {
1218
1223
  }
1219
1224
  drawBalancedCurve(dPath, points) {
1220
1225
  dPath.M = { x: points.start.x, y: points.start.y };
1221
- dPath.Q = [{ x: points.start.x + (points.end.x - points.start.x) / 4, y: points.start.y + (points.end.y - points.start.y) / 2 }, { x: points.start.x + (points.end.x - points.start.x) / 2, y: points.start.y + (points.end.y - points.start.y) / 2 }];
1222
- dPath.Q2 = [{ x: points.end.x - (points.end.x - points.start.x) / 4, y: points.start.y + (points.end.y - points.start.y) / 2 }, { x: points.end.x, y: points.end.y }];
1226
+ dPath.Q = [
1227
+ { x: points.start.x + (points.end.x - points.start.x) / 4, y: points.start.y + (points.end.y - points.start.y) / 2 },
1228
+ { x: points.start.x + (points.end.x - points.start.x) / 2, y: points.start.y + (points.end.y - points.start.y) / 2 },
1229
+ ];
1230
+ dPath.Q2 = [
1231
+ { x: points.end.x - (points.end.x - points.start.x) / 4, y: points.start.y + (points.end.y - points.start.y) / 2 },
1232
+ { x: points.end.x, y: points.end.y },
1233
+ ];
1223
1234
  }
1224
1235
  drawBendBothEndsCurve(dPath, points) {
1225
1236
  const pointXCurve = (points.start.x + points.end.x) * 0.5;
1226
1237
  const pointControl1 = { x: pointXCurve, y: points.start.y };
1227
1238
  const pointControl2 = { x: pointXCurve, y: points.end.y };
1228
1239
  dPath.M = { x: points.start.x, y: points.start.y };
1229
- dPath.C = [{ x: pointControl1.x, y: pointControl1.y }, { x: pointControl2.x, y: pointControl2.y }, { x: points.end.x, y: points.end.y }];
1240
+ dPath.C = [
1241
+ { x: pointControl1.x, y: pointControl1.y },
1242
+ { x: pointControl2.x, y: pointControl2.y },
1243
+ { x: points.end.x, y: points.end.y },
1244
+ ];
1230
1245
  }
1231
1246
  buildDAttributeByPointEndModeHorizontal(dPath, points, distancePoint, curve, mode) {
1232
1247
  if (!mode.includes('horizontal')) {
@@ -1236,17 +1251,23 @@ class LibsUiComponentsDrawLineDirective {
1236
1251
  const multiplierY = points.start.y < points.end.y ? 1 : -1;
1237
1252
  const reverseMultiplier = -1;
1238
1253
  dPath.M = { x: points.start.x, y: points.start.y };
1239
- dPath.L = { x: points.end.x + ((distancePoint * 2 + curve) * multiplierX), y: points.start.y };
1254
+ dPath.L = { x: points.end.x + (distancePoint * 2 + curve) * multiplierX, y: points.start.y };
1240
1255
  if (mode.includes('horizontal-single')) {
1241
- dPath.L.x = points.end.x + (curve * multiplierX);
1256
+ dPath.L.x = points.end.x + curve * multiplierX;
1242
1257
  }
1243
- dPath.Q = [{ x: dPath.L.x + (curve * multiplierX * reverseMultiplier), y: points.start.y }, { x: dPath.L.x + (curve * multiplierX * reverseMultiplier), y: points.start.y + (curve * multiplierY) }];
1244
- dPath.L2 = { x: dPath.Q[1].x, y: points.end.y + (curve * multiplierY * reverseMultiplier) };
1258
+ dPath.Q = [
1259
+ { x: dPath.L.x + curve * multiplierX * reverseMultiplier, y: points.start.y },
1260
+ { x: dPath.L.x + curve * multiplierX * reverseMultiplier, y: points.start.y + curve * multiplierY },
1261
+ ];
1262
+ dPath.L2 = { x: dPath.Q[1].x, y: points.end.y + curve * multiplierY * reverseMultiplier };
1245
1263
  if (mode.includes('horizontal-single')) {
1246
1264
  dPath.L2 = points.end;
1247
1265
  }
1248
1266
  if (mode === 'horizontal') {
1249
- dPath.Q2 = [{ x: dPath.L2.x, y: points.end.y }, { x: dPath.L2.x + (distancePoint * multiplierX * reverseMultiplier), y: points.end.y }];
1267
+ dPath.Q2 = [
1268
+ { x: dPath.L2.x, y: points.end.y },
1269
+ { x: dPath.L2.x + distancePoint * multiplierX * reverseMultiplier, y: points.end.y },
1270
+ ];
1250
1271
  dPath.L3 = { x: points.end.x, y: points.end.y };
1251
1272
  }
1252
1273
  }
@@ -1258,23 +1279,29 @@ class LibsUiComponentsDrawLineDirective {
1258
1279
  const multiplierY = points.start.y < points.end.y ? 1 : -1;
1259
1280
  const reverseMultiplier = -1;
1260
1281
  dPath.M = points.start;
1261
- dPath.L = { x: points.start.x, y: points.start.y + (distancePoint * multiplierY) };
1282
+ dPath.L = { x: points.start.x, y: points.start.y + distancePoint * multiplierY };
1262
1283
  if (mode.includes('vertical-single')) {
1263
- dPath.L.y = points.end.y + (distancePoint * multiplierY * reverseMultiplier);
1284
+ dPath.L.y = points.end.y + distancePoint * multiplierY * reverseMultiplier;
1264
1285
  }
1265
- dPath.Q = [{ x: dPath.L.x, y: dPath.L.y + (curve * multiplierY) }, { x: dPath.L.x + (curve * multiplierX * reverseMultiplier), y: dPath.L.y + (curve * multiplierY) }];
1266
- dPath.L2 = { x: points.end.x + ((curve * 2) * multiplierX), y: dPath.Q[1].y };
1286
+ dPath.Q = [
1287
+ { x: dPath.L.x, y: dPath.L.y + curve * multiplierY },
1288
+ { x: dPath.L.x + curve * multiplierX * reverseMultiplier, y: dPath.L.y + curve * multiplierY },
1289
+ ];
1290
+ dPath.L2 = { x: points.end.x + curve * 2 * multiplierX, y: dPath.Q[1].y };
1267
1291
  if (mode.includes('vertical-single')) {
1268
1292
  dPath.L2 = points.end;
1269
1293
  }
1270
1294
  if (mode === 'vertical') {
1271
- dPath.Q2 = [{ x: points.end.x, y: dPath.L2.y }, { x: points.end.x, y: dPath.L2.y + (curve * multiplierY) }];
1295
+ dPath.Q2 = [
1296
+ { x: points.end.x, y: dPath.L2.y },
1297
+ { x: points.end.x, y: dPath.L2.y + curve * multiplierY },
1298
+ ];
1272
1299
  dPath.L3 = { x: points.end.x, y: points.end.y };
1273
1300
  }
1274
1301
  }
1275
1302
  builDAttributeToString(dAttribute) {
1276
1303
  let dString = '';
1277
- Object.keys(dAttribute).forEach(key => {
1304
+ Object.keys(dAttribute).forEach((key) => {
1278
1305
  const data = get(dAttribute, key);
1279
1306
  if (Array.isArray(data)) {
1280
1307
  const [point1, point2, point3] = data;
@@ -1296,7 +1323,7 @@ class LibsUiComponentsDrawLineDirective {
1296
1323
  stroke: data.arrowStyle?.stroke ?? 'none',
1297
1324
  strokeWidth: data.arrowStyle?.strokeWidth ?? '0',
1298
1325
  width: data.arrowStyle?.width ?? 6,
1299
- height: data.arrowStyle?.height ?? 8
1326
+ height: data.arrowStyle?.height ?? 8,
1300
1327
  };
1301
1328
  const pointEnd = cloneDeep(points.end);
1302
1329
  const arrowElement = points.arrowElement;
@@ -1344,7 +1371,7 @@ class LibsUiComponentsDrawLineDirective {
1344
1371
  getDirection(points, startEndMode) {
1345
1372
  let pointStart = { ...points.start };
1346
1373
  if (points.separatedPoints) {
1347
- const lineToEnd = points.separatedPoints.find(item => item.end.x === points.end.x && item.end.y === points.end.y);
1374
+ const lineToEnd = points.separatedPoints.find((item) => item.end.x === points.end.x && item.end.y === points.end.y);
1348
1375
  if (lineToEnd) {
1349
1376
  pointStart = lineToEnd.start;
1350
1377
  }
@@ -1389,7 +1416,7 @@ class LibsUiComponentsDrawLineDirective {
1389
1416
  preEvent = dragMouseEvent;
1390
1417
  pointEnd.x += movementX;
1391
1418
  pointEnd.y += movementY;
1392
- if (data.points?.obstacleRect?.length && data.points?.obstacleRect.some(obstacleRect => this.checkPointIncludeRect(pointEnd, obstacleRect))) {
1419
+ if (data.points?.obstacleRect?.length && data.points?.obstacleRect.some((obstacleRect) => this.checkPointIncludeRect(pointEnd, obstacleRect))) {
1393
1420
  return;
1394
1421
  }
1395
1422
  points.end.x = pointEnd.x;
@@ -1401,15 +1428,19 @@ class LibsUiComponentsDrawLineDirective {
1401
1428
  getDragEventByElement({
1402
1429
  elementMouseDown: points.arrowElement,
1403
1430
  functionMouseUp: functionMouseUp,
1404
- onDestroy: this.onDestroy
1405
- }).pipe(tap(handlerDrag), takeUntil(points.onDestroyEvent)).subscribe();
1431
+ onDestroy: this.onDestroy,
1432
+ })
1433
+ .pipe(tap(handlerDrag), takeUntil(points.onDestroyEvent))
1434
+ .subscribe();
1406
1435
  }
1407
1436
  if (points.circleEndElement) {
1408
1437
  getDragEventByElement({
1409
1438
  elementMouseDown: points.circleEndElement,
1410
1439
  functionMouseUp: functionMouseUp,
1411
1440
  onDestroy: this.onDestroy,
1412
- }).pipe(tap(handlerDrag), takeUntil(points.onDestroyEvent)).subscribe();
1441
+ })
1442
+ .pipe(tap(handlerDrag), takeUntil(points.onDestroyEvent))
1443
+ .subscribe();
1413
1444
  }
1414
1445
  }
1415
1446
  checkPointIncludeRect(point, obstacleRect) {
@@ -1418,18 +1449,18 @@ class LibsUiComponentsDrawLineDirective {
1418
1449
  x: obstacleRect.x - (obstacleRect.gapXObstacleRect || gapDefault),
1419
1450
  y: obstacleRect.y - (obstacleRect.gapYObstacleRect || gapDefault),
1420
1451
  width: obstacleRect.width + (obstacleRect.gapXObstacleRect || gapDefault) * 2,
1421
- height: obstacleRect.height + (obstacleRect.gapYObstacleRect || gapDefault) * 2
1452
+ height: obstacleRect.height + (obstacleRect.gapYObstacleRect || gapDefault) * 2,
1422
1453
  };
1423
- if ((obstacleRect.x <= point.x && point.x <= obstacleRect.x + obstacleRect.width) && (obstacleRect.y <= point.y && point.y <= obstacleRect.y + obstacleRect.height)) {
1454
+ if (obstacleRect.x <= point.x && point.x <= obstacleRect.x + obstacleRect.width && obstacleRect.y <= point.y && point.y <= obstacleRect.y + obstacleRect.height) {
1424
1455
  return true;
1425
1456
  }
1426
1457
  return false;
1427
1458
  }
1428
1459
  createPathAndArrowElement(name) {
1429
- const pathElement = document.createElementNS("http://www.w3.org/2000/svg", "path");
1430
- const arrowElement = document.createElementNS("http://www.w3.org/2000/svg", "polyline");
1431
- const circleStartElement = document.createElementNS("http://www.w3.org/2000/svg", "circle");
1432
- const circleEndElement = document.createElementNS("http://www.w3.org/2000/svg", "circle");
1460
+ const pathElement = document.createElementNS('http://www.w3.org/2000/svg', 'path');
1461
+ const arrowElement = document.createElementNS('http://www.w3.org/2000/svg', 'polyline');
1462
+ const circleStartElement = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
1463
+ const circleEndElement = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
1433
1464
  pathElement.setAttribute('name', name);
1434
1465
  arrowElement.setAttribute('name', name);
1435
1466
  this.svgElement.append(pathElement);
@@ -1440,7 +1471,7 @@ class LibsUiComponentsDrawLineDirective {
1440
1471
  if (!this.drawRectDebug) {
1441
1472
  return;
1442
1473
  }
1443
- const circle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
1474
+ const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
1444
1475
  circle.setAttribute('name', name);
1445
1476
  circle.setAttribute('cx', `${point.x}`);
1446
1477
  circle.setAttribute('cy', `${point.y}`);
@@ -1452,14 +1483,14 @@ class LibsUiComponentsDrawLineDirective {
1452
1483
  if (!this.drawRectDebug) {
1453
1484
  return;
1454
1485
  }
1455
- Array.from(this.svgElement.getElementsByTagName('circle'))?.forEach(item => item.remove());
1486
+ Array.from(this.svgElement.getElementsByTagName('circle'))?.forEach((item) => item.remove());
1456
1487
  }
1457
1488
  addRect(name, rect) {
1458
1489
  if (!this.drawRectDebug) {
1459
1490
  return;
1460
1491
  }
1461
- const rectElement = document.createElementNS("http://www.w3.org/2000/svg", "rect");
1462
- const textElement = document.createElementNS("http://www.w3.org/2000/svg", "text");
1492
+ const rectElement = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
1493
+ const textElement = document.createElementNS('http://www.w3.org/2000/svg', 'text');
1463
1494
  rectElement.setAttribute('name', name);
1464
1495
  rectElement.setAttribute('x', `${rect.x}`);
1465
1496
  rectElement.setAttribute('y', `${rect.y}`);
@@ -1476,17 +1507,17 @@ class LibsUiComponentsDrawLineDirective {
1476
1507
  if (!this.drawRectDebug) {
1477
1508
  return;
1478
1509
  }
1479
- Array.from(this.svgElement.getElementsByTagName('rect'))?.forEach(item => item.remove());
1480
- Array.from(this.svgElement.getElementsByTagName('text'))?.forEach(item => item.remove());
1510
+ Array.from(this.svgElement.getElementsByTagName('rect'))?.forEach((item) => item.remove());
1511
+ Array.from(this.svgElement.getElementsByTagName('text'))?.forEach((item) => item.remove());
1481
1512
  }
1482
1513
  buildPathAndDrawSeparatedPoints(data, points, mode) {
1483
1514
  let dPath = {};
1484
1515
  const styleConfig = {
1485
1516
  curve: data.lineStyle?.curve ?? 10,
1486
- distancePoint: data.lineStyle?.distancePoint ?? 10
1517
+ distancePoint: data.lineStyle?.distancePoint ?? 10,
1487
1518
  };
1488
1519
  let { curve, distancePoint } = styleConfig;
1489
- mode = mode || "quart-in";
1520
+ mode = mode || 'quart-in';
1490
1521
  if (mode !== 'quart-in') {
1491
1522
  curve = curve ?? 10;
1492
1523
  distancePoint = distancePoint ?? 10;
@@ -1517,7 +1548,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
1517
1548
  type: Directive,
1518
1549
  args: [{
1519
1550
  // eslint-disable-next-line @angular-eslint/directive-selector
1520
- selector: "[LibsUiComponentsDrawLineDirective]",
1551
+ selector: '[LibsUiComponentsDrawLineDirective]',
1521
1552
  standalone: true,
1522
1553
  }]
1523
1554
  }], propDecorators: { viewBoxConfig: [{