@elixpo/lixsketch 5.4.7 → 5.5.1

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 (218) hide show
  1. package/dist/react/AIRenderer-M4LMJ66J.js +1105 -0
  2. package/dist/react/AIRenderer-M4LMJ66J.js.map +7 -0
  3. package/dist/react/Arrow-BJDAXPMH.js +8 -0
  4. package/dist/react/Arrow-BJDAXPMH.js.map +7 -0
  5. package/dist/react/Circle-KPG7TKIX.js +8 -0
  6. package/dist/react/Circle-KPG7TKIX.js.map +7 -0
  7. package/dist/react/CodeShape-K4DIZAIV.js +8 -0
  8. package/dist/react/CodeShape-K4DIZAIV.js.map +7 -0
  9. package/dist/react/CopyPaste-4CKJRHJ3.js +569 -0
  10. package/dist/react/CopyPaste-4CKJRHJ3.js.map +7 -0
  11. package/dist/react/EraserTrail-PA6IQLQN.js +20 -0
  12. package/dist/react/EraserTrail-PA6IQLQN.js.map +7 -0
  13. package/dist/react/EventDispatcher-SRFH6LQZ.js +463 -0
  14. package/dist/react/EventDispatcher-SRFH6LQZ.js.map +7 -0
  15. package/dist/react/Frame-6UR5XPAX.js +10 -0
  16. package/dist/react/Frame-6UR5XPAX.js.map +7 -0
  17. package/dist/react/FreehandStroke-CK24NUT3.js +8 -0
  18. package/dist/react/FreehandStroke-CK24NUT3.js.map +7 -0
  19. package/dist/react/GraphEngine-QE5B2PMR.js +340 -0
  20. package/dist/react/GraphEngine-QE5B2PMR.js.map +7 -0
  21. package/dist/react/GraphMathParser-2WMTY4IE.js +10 -0
  22. package/dist/react/GraphMathParser-2WMTY4IE.js.map +7 -0
  23. package/dist/react/IconShape-KMIA6T2H.js +10 -0
  24. package/dist/react/IconShape-KMIA6T2H.js.map +7 -0
  25. package/dist/react/ImageShape-CHHGBXUQ.js +10 -0
  26. package/dist/react/ImageShape-CHHGBXUQ.js.map +7 -0
  27. package/dist/react/LayerOrder-XCHF4MSS.js +66 -0
  28. package/dist/react/LayerOrder-XCHF4MSS.js.map +7 -0
  29. package/dist/react/Line-2KOQEEGA.js +10 -0
  30. package/dist/react/Line-2KOQEEGA.js.map +7 -0
  31. package/dist/react/LixScriptParser-JYWJX375.js +1033 -0
  32. package/dist/react/LixScriptParser-JYWJX375.js.map +7 -0
  33. package/dist/react/MermaidFlowchartRenderer-4QBAZ5MB.js +412 -0
  34. package/dist/react/MermaidFlowchartRenderer-4QBAZ5MB.js.map +7 -0
  35. package/dist/react/MermaidSequenceParser-UKG2NSZY.js +8 -0
  36. package/dist/react/MermaidSequenceParser-UKG2NSZY.js.map +7 -0
  37. package/dist/react/MermaidSequenceRenderer-HPLHY5II.js +387 -0
  38. package/dist/react/MermaidSequenceRenderer-HPLHY5II.js.map +7 -0
  39. package/dist/react/Rectangle-6FE7RN6W.js +8 -0
  40. package/dist/react/Rectangle-6FE7RN6W.js.map +7 -0
  41. package/dist/react/ResizeCode-WAMDTKSW.js +2 -0
  42. package/dist/react/ResizeCode-WAMDTKSW.js.map +7 -0
  43. package/dist/react/ResizeShapes-LKEQTITP.js +250 -0
  44. package/dist/react/ResizeShapes-LKEQTITP.js.map +7 -0
  45. package/dist/react/SceneSerializer-4U4B24JM.js +739 -0
  46. package/dist/react/SceneSerializer-4U4B24JM.js.map +7 -0
  47. package/dist/react/Selection-VVUHY5YJ.js +34 -0
  48. package/dist/react/Selection-VVUHY5YJ.js.map +7 -0
  49. package/dist/react/SketchEngine-YA4RG3KX.js +413 -0
  50. package/dist/react/SketchEngine-YA4RG3KX.js.map +7 -0
  51. package/dist/react/TextShape-54ZJ66E3.js +8 -0
  52. package/dist/react/TextShape-54ZJ66E3.js.map +7 -0
  53. package/dist/react/UndoRedo-M2JZUBKN.js +30 -0
  54. package/dist/react/UndoRedo-M2JZUBKN.js.map +7 -0
  55. package/dist/react/ZoomPan-U3TXC5AJ.js +186 -0
  56. package/dist/react/ZoomPan-U3TXC5AJ.js.map +7 -0
  57. package/dist/react/arrowTool-CWEMIRXK.js +17 -0
  58. package/dist/react/arrowTool-CWEMIRXK.js.map +7 -0
  59. package/dist/react/boxicons-5JNJQPUP.woff +0 -0
  60. package/dist/react/boxicons-6NVWQSCQ.eot +0 -0
  61. package/dist/react/boxicons-AQ5N6WP7.woff2 +0 -0
  62. package/dist/react/boxicons-GDR4JU3X.ttf +0 -0
  63. package/dist/react/boxicons-NNFHLMOR.svg +1660 -0
  64. package/dist/react/chunk-2OQXI7QB.js +564 -0
  65. package/dist/react/chunk-2OQXI7QB.js.map +7 -0
  66. package/dist/react/chunk-5OUBTHHO.js +187 -0
  67. package/dist/react/chunk-5OUBTHHO.js.map +7 -0
  68. package/dist/react/chunk-6PFXZKL2.js +628 -0
  69. package/dist/react/chunk-6PFXZKL2.js.map +7 -0
  70. package/dist/react/chunk-6SFNWGGZ.js +453 -0
  71. package/dist/react/chunk-6SFNWGGZ.js.map +7 -0
  72. package/dist/react/chunk-7TZSIR6V.js +210 -0
  73. package/dist/react/chunk-7TZSIR6V.js.map +7 -0
  74. package/dist/react/chunk-AJAZC37E.js +662 -0
  75. package/dist/react/chunk-AJAZC37E.js.map +7 -0
  76. package/dist/react/chunk-BU4D2WYQ.js +1213 -0
  77. package/dist/react/chunk-BU4D2WYQ.js.map +7 -0
  78. package/dist/react/chunk-BZE4CEBG.js +747 -0
  79. package/dist/react/chunk-BZE4CEBG.js.map +7 -0
  80. package/dist/react/chunk-CB2RANCB.js +212 -0
  81. package/dist/react/chunk-CB2RANCB.js.map +7 -0
  82. package/dist/react/chunk-DNAG7ML6.js +128 -0
  83. package/dist/react/chunk-DNAG7ML6.js.map +7 -0
  84. package/dist/react/chunk-HZWLPXFN.js +198 -0
  85. package/dist/react/chunk-HZWLPXFN.js.map +7 -0
  86. package/dist/react/chunk-I6HCCIXB.js +572 -0
  87. package/dist/react/chunk-I6HCCIXB.js.map +7 -0
  88. package/dist/react/chunk-IZ5OGWGW.js +235 -0
  89. package/dist/react/chunk-IZ5OGWGW.js.map +7 -0
  90. package/dist/react/chunk-JJCJNLNN.js +1490 -0
  91. package/dist/react/chunk-JJCJNLNN.js.map +7 -0
  92. package/dist/react/chunk-JQ3IRFDP.js +222 -0
  93. package/dist/react/chunk-JQ3IRFDP.js.map +7 -0
  94. package/dist/react/chunk-L5OARZJ7.js +1134 -0
  95. package/dist/react/chunk-L5OARZJ7.js.map +7 -0
  96. package/dist/react/chunk-LHRTXNVE.js +1600 -0
  97. package/dist/react/chunk-LHRTXNVE.js.map +7 -0
  98. package/dist/react/chunk-Q2GA4MBZ.js +1653 -0
  99. package/dist/react/chunk-Q2GA4MBZ.js.map +7 -0
  100. package/dist/react/chunk-QNSE5BAY.js +519 -0
  101. package/dist/react/chunk-QNSE5BAY.js.map +7 -0
  102. package/dist/react/chunk-QXFBG7OM.js +191 -0
  103. package/dist/react/chunk-QXFBG7OM.js.map +7 -0
  104. package/dist/react/chunk-T6ZVV5ZO.js +714 -0
  105. package/dist/react/chunk-T6ZVV5ZO.js.map +7 -0
  106. package/dist/react/chunk-URB6MY46.js +974 -0
  107. package/dist/react/chunk-URB6MY46.js.map +7 -0
  108. package/dist/react/chunk-VN62KLOC.js +931 -0
  109. package/dist/react/chunk-VN62KLOC.js.map +7 -0
  110. package/dist/react/chunk-VQVEPJSA.js +158 -0
  111. package/dist/react/chunk-VQVEPJSA.js.map +7 -0
  112. package/dist/react/chunk-XISEAGBV.js +1632 -0
  113. package/dist/react/chunk-XISEAGBV.js.map +7 -0
  114. package/dist/react/chunk-YKJUBFHE.js +575 -0
  115. package/dist/react/chunk-YKJUBFHE.js.map +7 -0
  116. package/dist/react/circleTool-NUATSEI2.js +14 -0
  117. package/dist/react/circleTool-NUATSEI2.js.map +7 -0
  118. package/dist/react/codeTool-MHCB2FNB.js +38 -0
  119. package/dist/react/codeTool-MHCB2FNB.js.map +7 -0
  120. package/dist/react/eraserTool-2GS2LQCS.js +103 -0
  121. package/dist/react/eraserTool-2GS2LQCS.js.map +7 -0
  122. package/dist/react/frameTool-PWVKKXSP.js +14 -0
  123. package/dist/react/frameTool-PWVKKXSP.js.map +7 -0
  124. package/dist/react/freehandTool-SLYGASVP.js +14 -0
  125. package/dist/react/freehandTool-SLYGASVP.js.map +7 -0
  126. package/dist/react/iconTool-GPZ7O7NH.js +18 -0
  127. package/dist/react/iconTool-GPZ7O7NH.js.map +7 -0
  128. package/dist/react/imageTool-D5R4XGEU.js +15 -0
  129. package/dist/react/imageTool-D5R4XGEU.js.map +7 -0
  130. package/dist/react/index.js +5349 -0
  131. package/dist/react/index.js.map +7 -0
  132. package/dist/react/laserTool-XVMV63AV.js +239 -0
  133. package/dist/react/laserTool-XVMV63AV.js.map +7 -0
  134. package/dist/react/lineTool-WNI5EMZ5.js +14 -0
  135. package/dist/react/lineTool-WNI5EMZ5.js.map +7 -0
  136. package/dist/react/lixCode-OJMVUXXI.ttf +0 -0
  137. package/dist/react/lixDefault-JEAPAUJL.ttf +0 -0
  138. package/dist/react/lixFancy-BPXYM5CQ.ttf +0 -0
  139. package/dist/react/lixFont-CPKEUDVM.woff2 +0 -0
  140. package/dist/react/rectangleTool-U7DZ6ZTA.js +14 -0
  141. package/dist/react/rectangleTool-U7DZ6ZTA.js.map +7 -0
  142. package/dist/react/styles.css +6627 -0
  143. package/dist/react/textTool-M7S6F3VC.js +21 -0
  144. package/dist/react/textTool-M7S6F3VC.js.map +7 -0
  145. package/package.json +39 -5
  146. package/src/EngineShortcuts.js +83 -27
  147. package/src/core/AIRenderer.js +30 -18
  148. package/src/core/GraphEngine.js +64 -41
  149. package/src/core/MermaidFlowchartRenderer.js +153 -88
  150. package/src/core/MermaidSequenceRenderer.js +168 -93
  151. package/src/core/SceneSerializer.js +86 -2
  152. package/src/core/Selection.js +119 -19
  153. package/src/core/UndoRedo.js +82 -15
  154. package/src/core/ZoomPan.js +15 -5
  155. package/src/index.js +14 -1
  156. package/src/react/LixSketchCanvas.jsx +347 -0
  157. package/src/react/components/AppMenu.jsx +482 -0
  158. package/src/react/components/Footer.jsx +85 -0
  159. package/src/react/components/Toolbar.jsx +140 -0
  160. package/src/react/components/canvas/CanvasLoadingOverlay.jsx +76 -0
  161. package/src/react/components/canvas/ContextMenu.jsx +466 -0
  162. package/src/react/components/canvas/FindBar.jsx +177 -0
  163. package/src/react/components/canvas/ImageSourcePicker.jsx +133 -0
  164. package/src/react/components/canvas/MultiSelectActions.jsx +120 -0
  165. package/src/react/components/canvas/SVGCanvas.jsx +145 -0
  166. package/src/react/components/canvas/SaveStatusIndicator.jsx +29 -0
  167. package/src/react/components/modals/CanvasPropertiesModal.jsx +358 -0
  168. package/src/react/components/modals/CommandPalette.jsx +307 -0
  169. package/src/react/components/modals/ExportImageModal.jsx +287 -0
  170. package/src/react/components/modals/GraphModal.jsx +174 -0
  171. package/src/react/components/modals/HelpModal.jsx +208 -0
  172. package/src/react/components/modals/LixScriptModal.jsx +130 -0
  173. package/src/react/components/modals/ShortcutsModal.jsx +125 -0
  174. package/src/react/components/sidebars/ArrowSidebar.jsx +173 -0
  175. package/src/react/components/sidebars/CircleSidebar.jsx +134 -0
  176. package/src/react/components/sidebars/FrameSidebar.jsx +263 -0
  177. package/src/react/components/sidebars/IconSidebar.jsx +279 -0
  178. package/src/react/components/sidebars/ImageSidebar.jsx +69 -0
  179. package/src/react/components/sidebars/LineSidebar.jsx +109 -0
  180. package/src/react/components/sidebars/PaintbrushSidebar.jsx +119 -0
  181. package/src/react/components/sidebars/RectangleSidebar.jsx +165 -0
  182. package/src/react/components/sidebars/ShapeSidebar.jsx +130 -0
  183. package/src/react/components/sidebars/TextSidebar.jsx +174 -0
  184. package/src/react/hooks/inertStores.js +58 -0
  185. package/src/react/hooks/useSketchEngine.js +76 -0
  186. package/src/react/hooks/useTranslation.js +92 -0
  187. package/src/react/index.js +41 -0
  188. package/src/react/store/useSketchStore.js +234 -0
  189. package/src/react/store/useUIStore.js +196 -0
  190. package/src/react/styles/arrowSidebar.css +263 -0
  191. package/src/react/styles/canvasStroke.css +47 -0
  192. package/src/react/styles/canvasTools.css +769 -0
  193. package/src/react/styles/circleSidebar.css +206 -0
  194. package/src/react/styles/fonts/fonts.css +29 -0
  195. package/src/react/styles/fonts/lixCode.ttf +0 -0
  196. package/src/react/styles/fonts/lixDefault.ttf +0 -0
  197. package/src/react/styles/fonts/lixDocs.ttf +0 -0
  198. package/src/react/styles/fonts/lixFancy.ttf +0 -0
  199. package/src/react/styles/fonts/lixFont.woff2 +0 -0
  200. package/src/react/styles/lineSidebar.css +207 -0
  201. package/src/react/styles/paintbrushSidebar.css +247 -0
  202. package/src/react/styles/squareSidebar.css +206 -0
  203. package/src/react/styles/writeText.css +149 -0
  204. package/src/react/styles.css +175 -0
  205. package/src/react/toolsEnum.js +20 -0
  206. package/src/react/utils/toast.js +18 -0
  207. package/src/shapes/Frame.js +7 -1
  208. package/src/shapes/Line.js +11 -5
  209. package/src/tools/arrowTool.js +30 -4
  210. package/src/tools/circleTool.js +33 -9
  211. package/src/tools/codeTool.js +5 -3
  212. package/src/tools/frameTool.js +47 -7
  213. package/src/tools/freehandTool.js +12 -4
  214. package/src/tools/iconTool.js +7 -1
  215. package/src/tools/imageTool.js +7 -1
  216. package/src/tools/lineTool.js +27 -3
  217. package/src/tools/rectangleTool.js +45 -8
  218. package/src/tools/textTool.js +23 -6
@@ -0,0 +1,628 @@
1
+ "use client";
2
+ import {
3
+ updateAttachedArrows
4
+ } from "./chunk-BZE4CEBG.js";
5
+
6
+ // src/shapes/Line.js
7
+ var rc = rough.svg(svg);
8
+ function getThemeStroke() {
9
+ if (typeof document === "undefined") return "#fff";
10
+ return document.body && document.body.classList.contains("theme-dark") ? "#fff" : "#1a1a2e";
11
+ }
12
+ var lineStrokeWidth = 2;
13
+ var hoveredFrameLine = null;
14
+ var Line = class {
15
+ constructor(startPoint, endPoint, options = {}) {
16
+ this.startPoint = startPoint;
17
+ this.endPoint = endPoint;
18
+ this.options = { ...options };
19
+ this.group = document.createElementNS("http://www.w3.org/2000/svg", "g");
20
+ this.isSelected = false;
21
+ this.anchors = [];
22
+ this.selectionOutline = null;
23
+ this.shapeName = "line";
24
+ this.shapeID = `line-${String(Date.now()).slice(0, 8)}-${Math.floor(Math.random() * 1e4)}`;
25
+ this.group.setAttribute("id", this.shapeID);
26
+ this.isCurved = false;
27
+ this.controlPoint = null;
28
+ this.parentFrame = null;
29
+ this.label = options.label || "";
30
+ this.labelElement = null;
31
+ this.labelColor = options.labelColor || "#e0e0e0";
32
+ this.labelFontSize = options.labelFontSize || 12;
33
+ this._isEditingLabel = false;
34
+ this._hitArea = null;
35
+ this._labelBg = null;
36
+ svg.appendChild(this.group);
37
+ this._setupLabelDblClick();
38
+ this.draw();
39
+ }
40
+ // Add position and dimension properties for frame compatibility
41
+ get x() {
42
+ return Math.min(this.startPoint.x, this.endPoint.x);
43
+ }
44
+ set x(value) {
45
+ const currentX = this.x;
46
+ const dx = value - currentX;
47
+ this.startPoint.x += dx;
48
+ this.endPoint.x += dx;
49
+ if (this.controlPoint) {
50
+ this.controlPoint.x += dx;
51
+ }
52
+ }
53
+ get y() {
54
+ return Math.min(this.startPoint.y, this.endPoint.y);
55
+ }
56
+ set y(value) {
57
+ const currentY = this.y;
58
+ const dy = value - currentY;
59
+ this.startPoint.y += dy;
60
+ this.endPoint.y += dy;
61
+ if (this.controlPoint) {
62
+ this.controlPoint.y += dy;
63
+ }
64
+ }
65
+ get width() {
66
+ return Math.abs(this.endPoint.x - this.startPoint.x);
67
+ }
68
+ set width(value) {
69
+ const centerX = (this.startPoint.x + this.endPoint.x) / 2;
70
+ this.startPoint.x = centerX - value / 2;
71
+ this.endPoint.x = centerX + value / 2;
72
+ }
73
+ get height() {
74
+ return Math.abs(this.endPoint.y - this.startPoint.y);
75
+ }
76
+ set height(value) {
77
+ const centerY = (this.startPoint.y + this.endPoint.y) / 2;
78
+ this.startPoint.y = centerY - value / 2;
79
+ this.endPoint.y = centerY + value / 2;
80
+ }
81
+ initializeCurveControlPoint() {
82
+ const midX = (this.startPoint.x + this.endPoint.x) / 2;
83
+ const midY = (this.startPoint.y + this.endPoint.y) / 2;
84
+ const dx = this.endPoint.x - this.startPoint.x;
85
+ const dy = this.endPoint.y - this.startPoint.y;
86
+ const length = Math.sqrt(dx * dx + dy * dy);
87
+ if (length === 0) {
88
+ this.controlPoint = { x: midX, y: midY - 20 };
89
+ return;
90
+ }
91
+ const perpX = -dy / length;
92
+ const perpY = dx / length;
93
+ const curveOffset = 30;
94
+ this.controlPoint = {
95
+ x: midX + perpX * curveOffset,
96
+ y: midY + perpY * curveOffset
97
+ };
98
+ }
99
+ draw() {
100
+ const childrenToRemove = [];
101
+ const preserveSet = this._skipAnchors ? new Set([...this.anchors, this.selectionOutline].filter(Boolean)) : null;
102
+ for (let i = 0; i < this.group.children.length; i++) {
103
+ const child = this.group.children[i];
104
+ if (child !== this.labelElement && child !== this._hitArea && child !== this._labelBg) {
105
+ if (preserveSet && preserveSet.has(child)) continue;
106
+ childrenToRemove.push(child);
107
+ }
108
+ }
109
+ childrenToRemove.forEach((child) => this.group.removeChild(child));
110
+ const rc2 = rough.svg(svg);
111
+ let lineElement;
112
+ if (this.isCurved && this.controlPoint) {
113
+ const pathData = `M ${this.startPoint.x} ${this.startPoint.y} Q ${this.controlPoint.x} ${this.controlPoint.y} ${this.endPoint.x} ${this.endPoint.y}`;
114
+ lineElement = document.createElementNS("http://www.w3.org/2000/svg", "path");
115
+ lineElement.setAttribute("d", pathData);
116
+ lineElement.setAttribute("stroke", this.options.stroke || getThemeStroke());
117
+ lineElement.setAttribute("stroke-width", this.options.strokeWidth || lineStrokeWidth);
118
+ lineElement.setAttribute("fill", "none");
119
+ lineElement.setAttribute("stroke-linecap", "round");
120
+ if (this.options.strokeDasharray) {
121
+ lineElement.setAttribute("stroke-dasharray", this.options.strokeDasharray);
122
+ }
123
+ } else if (this.isBeingDrawn || this.options.strokeDasharray) {
124
+ lineElement = document.createElementNS("http://www.w3.org/2000/svg", "line");
125
+ lineElement.setAttribute("x1", this.startPoint.x);
126
+ lineElement.setAttribute("y1", this.startPoint.y);
127
+ lineElement.setAttribute("x2", this.endPoint.x);
128
+ lineElement.setAttribute("y2", this.endPoint.y);
129
+ lineElement.setAttribute("stroke", this.options.stroke || getThemeStroke());
130
+ lineElement.setAttribute("stroke-width", this.options.strokeWidth || lineStrokeWidth);
131
+ lineElement.setAttribute("stroke-linecap", "round");
132
+ if (this.options.strokeDasharray) {
133
+ lineElement.setAttribute("stroke-dasharray", this.options.strokeDasharray);
134
+ }
135
+ } else {
136
+ lineElement = rc2.line(
137
+ this.startPoint.x,
138
+ this.startPoint.y,
139
+ this.endPoint.x,
140
+ this.endPoint.y,
141
+ this.options
142
+ );
143
+ }
144
+ this.element = lineElement;
145
+ this.group.appendChild(lineElement);
146
+ if (!this._hitArea) {
147
+ this._hitArea = document.createElementNS("http://www.w3.org/2000/svg", "path");
148
+ this._hitArea.setAttribute("fill", "none");
149
+ this._hitArea.setAttribute("stroke", "transparent");
150
+ this._hitArea.setAttribute("stroke-width", "20");
151
+ this._hitArea.setAttribute("style", "pointer-events: stroke;");
152
+ this.group.appendChild(this._hitArea);
153
+ }
154
+ if (this.isCurved && this.controlPoint) {
155
+ this._hitArea.setAttribute("d", `M ${this.startPoint.x} ${this.startPoint.y} Q ${this.controlPoint.x} ${this.controlPoint.y} ${this.endPoint.x} ${this.endPoint.y}`);
156
+ } else {
157
+ this._hitArea.setAttribute("d", `M ${this.startPoint.x} ${this.startPoint.y} L ${this.endPoint.x} ${this.endPoint.y}`);
158
+ }
159
+ this._updateLabelElement();
160
+ if (this.isSelected) {
161
+ if (this._skipAnchors) {
162
+ this.updateSelectionControls();
163
+ } else {
164
+ this.addAnchors();
165
+ }
166
+ }
167
+ }
168
+ _getMidpoint() {
169
+ if (this.isCurved && this.controlPoint) {
170
+ const t = 0.5;
171
+ const mx = (1 - t) * (1 - t) * this.startPoint.x + 2 * (1 - t) * t * this.controlPoint.x + t * t * this.endPoint.x;
172
+ const my = (1 - t) * (1 - t) * this.startPoint.y + 2 * (1 - t) * t * this.controlPoint.y + t * t * this.endPoint.y;
173
+ return { x: mx, y: my };
174
+ }
175
+ return {
176
+ x: (this.startPoint.x + this.endPoint.x) / 2,
177
+ y: (this.startPoint.y + this.endPoint.y) / 2
178
+ };
179
+ }
180
+ _updateLabelElement() {
181
+ if (!this.label) {
182
+ if (this.labelElement && this.labelElement.parentNode === this.group) {
183
+ this.group.removeChild(this.labelElement);
184
+ this.labelElement = null;
185
+ }
186
+ if (this._labelBg && this._labelBg.parentNode === this.group) {
187
+ this.group.removeChild(this._labelBg);
188
+ this._labelBg = null;
189
+ }
190
+ return;
191
+ }
192
+ if (!this.labelElement) {
193
+ this.labelElement = document.createElementNS("http://www.w3.org/2000/svg", "text");
194
+ this.labelElement.setAttribute("class", "shape-label");
195
+ this.labelElement.setAttribute("pointer-events", "none");
196
+ }
197
+ const mid = this._getMidpoint();
198
+ this.labelElement.setAttribute("x", mid.x);
199
+ this.labelElement.setAttribute("y", mid.y);
200
+ this.labelElement.setAttribute("text-anchor", "middle");
201
+ this.labelElement.setAttribute("dominant-baseline", "central");
202
+ this.labelElement.setAttribute("fill", this.labelColor);
203
+ this.labelElement.setAttribute("font-size", this.labelFontSize);
204
+ this.labelElement.setAttribute("font-family", "lixFont, sans-serif");
205
+ this.labelElement.textContent = this.label;
206
+ const canvasBg = window.getComputedStyle(svg).backgroundColor || "#000";
207
+ if (!this._labelBg) {
208
+ this._labelBg = document.createElementNS("http://www.w3.org/2000/svg", "rect");
209
+ this._labelBg.setAttribute("pointer-events", "none");
210
+ }
211
+ this._labelBg.setAttribute("fill", canvasBg);
212
+ const hPadding = 4;
213
+ const vPadding = 1;
214
+ const charWidth = this.labelFontSize * 0.6;
215
+ const bgW = this.label.length * charWidth + hPadding * 2;
216
+ const bgH = this.labelFontSize + vPadding * 2;
217
+ this._labelBg.setAttribute("x", mid.x - bgW / 2);
218
+ this._labelBg.setAttribute("y", mid.y - bgH / 2);
219
+ this._labelBg.setAttribute("width", bgW);
220
+ this._labelBg.setAttribute("height", bgH);
221
+ this._labelBg.setAttribute("rx", 2);
222
+ if (this._labelBg.parentNode === this.group) this.group.removeChild(this._labelBg);
223
+ if (this.labelElement.parentNode === this.group) this.group.removeChild(this.labelElement);
224
+ this.group.appendChild(this._labelBg);
225
+ this.group.appendChild(this.labelElement);
226
+ }
227
+ _setupLabelDblClick() {
228
+ this.group.addEventListener("dblclick", (e) => {
229
+ e.stopPropagation();
230
+ e.preventDefault();
231
+ this.startLabelEdit();
232
+ });
233
+ }
234
+ startLabelEdit() {
235
+ if (this._isEditingLabel) return;
236
+ this._isEditingLabel = true;
237
+ if (this.labelElement) {
238
+ this.labelElement.setAttribute("visibility", "hidden");
239
+ }
240
+ if (this._labelBg) {
241
+ this._labelBg.setAttribute("visibility", "hidden");
242
+ }
243
+ const mid = this._getMidpoint();
244
+ const ctm = this.group.getScreenCTM();
245
+ if (!ctm) {
246
+ this._isEditingLabel = false;
247
+ return;
248
+ }
249
+ const pt = svg.createSVGPoint();
250
+ pt.x = mid.x;
251
+ pt.y = mid.y;
252
+ const screenMid = pt.matrixTransform(ctm);
253
+ const editW = 160;
254
+ const editH = 28;
255
+ const overlay = document.createElement("div");
256
+ overlay.className = "shape-label-editor";
257
+ overlay.style.cssText = `
258
+ position: fixed; z-index: 10000;
259
+ left: ${screenMid.x - editW / 2}px; top: ${screenMid.y - editH / 2}px;
260
+ width: ${editW}px; height: ${editH}px;
261
+ display: flex; align-items: center; justify-content: center;
262
+ pointer-events: auto;
263
+ `;
264
+ const canvasBg = window.getComputedStyle(svg).backgroundColor || "#000";
265
+ const input = document.createElement("div");
266
+ input.setAttribute("contenteditable", "true");
267
+ input.style.cssText = `
268
+ width: 100%; height: 100%;
269
+ background: ${canvasBg}; border: none;
270
+ outline: none; padding: 2px 6px;
271
+ color: ${this.labelColor}; font-size: ${this.labelFontSize}px;
272
+ font-family: lixFont, sans-serif; text-align: center;
273
+ display: flex; align-items: center; justify-content: center;
274
+ white-space: pre-wrap; word-break: break-word;
275
+ cursor: text;
276
+ `;
277
+ if (this.label) {
278
+ input.textContent = this.label;
279
+ } else {
280
+ input.innerHTML = "&nbsp;";
281
+ }
282
+ overlay.appendChild(input);
283
+ document.body.appendChild(overlay);
284
+ setTimeout(() => {
285
+ input.focus();
286
+ const sel = window.getSelection();
287
+ const range = document.createRange();
288
+ range.selectNodeContents(input);
289
+ sel.removeAllRanges();
290
+ sel.addRange(range);
291
+ }, 10);
292
+ const finishEdit = () => {
293
+ const newText = input.textContent.trim().replace(/\u00A0/g, "");
294
+ this.label = newText;
295
+ this._isEditingLabel = false;
296
+ if (overlay.parentNode) overlay.parentNode.removeChild(overlay);
297
+ if (this.labelElement) this.labelElement.removeAttribute("visibility");
298
+ if (this._labelBg) this._labelBg.removeAttribute("visibility");
299
+ this.draw();
300
+ };
301
+ input.addEventListener("blur", finishEdit);
302
+ input.addEventListener("keydown", (e) => {
303
+ e.stopPropagation();
304
+ if (e.key === "Enter" && !e.shiftKey) {
305
+ e.preventDefault();
306
+ input.blur();
307
+ }
308
+ if (e.key === "Escape") {
309
+ input.textContent = this.label;
310
+ input.blur();
311
+ }
312
+ });
313
+ input.addEventListener("pointerdown", (e) => e.stopPropagation());
314
+ input.addEventListener("pointermove", (e) => e.stopPropagation());
315
+ input.addEventListener("pointerup", (e) => e.stopPropagation());
316
+ }
317
+ setLabel(text, color, fontSize) {
318
+ this.label = text || "";
319
+ if (color) this.labelColor = color;
320
+ if (fontSize) this.labelFontSize = fontSize;
321
+ this.draw();
322
+ }
323
+ updateSelectionControls() {
324
+ if (this.anchors.length === 0) return;
325
+ if (this.anchors[0]) {
326
+ this.anchors[0].setAttribute("cx", this.startPoint.x);
327
+ this.anchors[0].setAttribute("cy", this.startPoint.y);
328
+ }
329
+ if (this.anchors[1]) {
330
+ this.anchors[1].setAttribute("cx", this.endPoint.x);
331
+ this.anchors[1].setAttribute("cy", this.endPoint.y);
332
+ }
333
+ if (this.anchors[2]) {
334
+ const midX = (this.startPoint.x + this.endPoint.x) / 2;
335
+ const midY = (this.startPoint.y + this.endPoint.y) / 2;
336
+ let anchorMidX = midX, anchorMidY = midY;
337
+ if (this.isCurved && this.controlPoint) {
338
+ anchorMidX = 0.25 * this.startPoint.x + 0.5 * this.controlPoint.x + 0.25 * this.endPoint.x;
339
+ anchorMidY = 0.25 * this.startPoint.y + 0.5 * this.controlPoint.y + 0.25 * this.endPoint.y;
340
+ }
341
+ this.anchors[2].setAttribute("cx", anchorMidX);
342
+ this.anchors[2].setAttribute("cy", anchorMidY);
343
+ }
344
+ }
345
+ selectLine() {
346
+ this.isSelected = true;
347
+ this.addAnchors();
348
+ }
349
+ deselectLine() {
350
+ this.isSelected = false;
351
+ this.removeSelection();
352
+ }
353
+ // Update the complete removeSelection method
354
+ removeSelection() {
355
+ this.anchors.forEach((anchor) => {
356
+ if (anchor && anchor.parentNode === this.group) {
357
+ this.group.removeChild(anchor);
358
+ }
359
+ });
360
+ this.anchors = [];
361
+ this.isSelected = false;
362
+ }
363
+ addAnchors() {
364
+ this.anchors.forEach((anchor) => {
365
+ if (anchor && anchor.parentNode === this.group) {
366
+ this.group.removeChild(anchor);
367
+ }
368
+ });
369
+ this.anchors = [];
370
+ const anchorSize = 10 / (currentZoom || 1);
371
+ const anchorStrokeWidth = 2 / (currentZoom || 1);
372
+ const startAnchor = document.createElementNS("http://www.w3.org/2000/svg", "circle");
373
+ startAnchor.setAttribute("cx", this.startPoint.x);
374
+ startAnchor.setAttribute("cy", this.startPoint.y);
375
+ startAnchor.setAttribute("r", anchorSize / 2);
376
+ startAnchor.setAttribute("fill", "#121212");
377
+ startAnchor.setAttribute("stroke", "#5B57D1");
378
+ startAnchor.setAttribute("stroke-width", anchorStrokeWidth);
379
+ startAnchor.setAttribute("vector-effect", "non-scaling-stroke");
380
+ startAnchor.setAttribute("class", "anchor line-anchor");
381
+ startAnchor.style.cursor = "grab";
382
+ startAnchor.style.pointerEvents = "all";
383
+ startAnchor.dataset.index = 0;
384
+ this.group.appendChild(startAnchor);
385
+ this.anchors[0] = startAnchor;
386
+ const endAnchor = document.createElementNS("http://www.w3.org/2000/svg", "circle");
387
+ endAnchor.setAttribute("cx", this.endPoint.x);
388
+ endAnchor.setAttribute("cy", this.endPoint.y);
389
+ endAnchor.setAttribute("r", anchorSize / 2);
390
+ endAnchor.setAttribute("fill", "#121212");
391
+ endAnchor.setAttribute("stroke", "#5B57D1");
392
+ endAnchor.setAttribute("stroke-width", anchorStrokeWidth);
393
+ endAnchor.setAttribute("vector-effect", "non-scaling-stroke");
394
+ endAnchor.setAttribute("class", "anchor line-anchor");
395
+ endAnchor.style.cursor = "grab";
396
+ endAnchor.style.pointerEvents = "all";
397
+ endAnchor.dataset.index = 1;
398
+ this.group.appendChild(endAnchor);
399
+ this.anchors[1] = endAnchor;
400
+ const midX = (this.startPoint.x + this.endPoint.x) / 2;
401
+ const midY = (this.startPoint.y + this.endPoint.y) / 2;
402
+ let anchorMidX = midX, anchorMidY = midY;
403
+ if (this.isCurved && this.controlPoint) {
404
+ anchorMidX = 0.25 * this.startPoint.x + 0.5 * this.controlPoint.x + 0.25 * this.endPoint.x;
405
+ anchorMidY = 0.25 * this.startPoint.y + 0.5 * this.controlPoint.y + 0.25 * this.endPoint.y;
406
+ }
407
+ const middleAnchor = document.createElementNS("http://www.w3.org/2000/svg", "circle");
408
+ middleAnchor.setAttribute("cx", anchorMidX);
409
+ middleAnchor.setAttribute("cy", anchorMidY);
410
+ middleAnchor.setAttribute("r", anchorSize / 2);
411
+ middleAnchor.setAttribute("fill", this.isCurved ? "#5B57D1" : "#121212");
412
+ middleAnchor.setAttribute("stroke", "#5B57D1");
413
+ middleAnchor.setAttribute("stroke-width", anchorStrokeWidth);
414
+ middleAnchor.setAttribute("vector-effect", "non-scaling-stroke");
415
+ middleAnchor.setAttribute("class", "anchor line-middle-anchor");
416
+ middleAnchor.style.cursor = "grab";
417
+ middleAnchor.style.pointerEvents = "all";
418
+ middleAnchor.dataset.index = 2;
419
+ this.group.appendChild(middleAnchor);
420
+ this.anchors[2] = middleAnchor;
421
+ disableAllSideBars();
422
+ lineSideBar.classList.remove("hidden");
423
+ if (window.__showSidebarForShape) window.__showSidebarForShape("line");
424
+ this.updateSidebar();
425
+ }
426
+ isNearAnchor(x, y) {
427
+ if (!this.isSelected) return null;
428
+ const buffer = 15;
429
+ const anchorSize = 10 / (currentZoom || 1);
430
+ for (let i = 0; i < this.anchors.length; i++) {
431
+ const anchor = this.anchors[i];
432
+ if (anchor) {
433
+ const anchorX = parseFloat(anchor.getAttribute("cx"));
434
+ const anchorY = parseFloat(anchor.getAttribute("cy"));
435
+ const distance = Math.sqrt(Math.pow(x - anchorX, 2) + Math.pow(y - anchorY, 2));
436
+ if (distance <= anchorSize / 2 + buffer) {
437
+ return { type: "anchor", index: i };
438
+ }
439
+ }
440
+ }
441
+ return null;
442
+ }
443
+ updatePosition(anchorIndex, newX, newY) {
444
+ if (anchorIndex === 0) {
445
+ this.startPoint.x = newX;
446
+ this.startPoint.y = newY;
447
+ } else if (anchorIndex === 1) {
448
+ this.endPoint.x = newX;
449
+ this.endPoint.y = newY;
450
+ } else if (anchorIndex === 2) {
451
+ if (!this.isCurved) {
452
+ this.isCurved = true;
453
+ }
454
+ this.controlPoint = {
455
+ x: 2 * newX - 0.5 * (this.startPoint.x + this.endPoint.x),
456
+ y: 2 * newY - 0.5 * (this.startPoint.y + this.endPoint.y)
457
+ };
458
+ }
459
+ this.draw();
460
+ }
461
+ updateLineElement() {
462
+ if (this.element && this.element.parentNode) {
463
+ this.element.parentNode.removeChild(this.element);
464
+ }
465
+ const rc2 = rough.svg(svg);
466
+ let lineElement;
467
+ if (this.isCurved && this.controlPoint) {
468
+ const pathData = `M ${this.startPoint.x} ${this.startPoint.y} Q ${this.controlPoint.x} ${this.controlPoint.y} ${this.endPoint.x} ${this.endPoint.y}`;
469
+ lineElement = document.createElementNS("http://www.w3.org/2000/svg", "path");
470
+ lineElement.setAttribute("d", pathData);
471
+ lineElement.setAttribute("stroke", this.options.stroke || getThemeStroke());
472
+ lineElement.setAttribute("stroke-width", this.options.strokeWidth || lineStrokeWidth);
473
+ lineElement.setAttribute("fill", "none");
474
+ lineElement.setAttribute("stroke-linecap", "round");
475
+ if (this.options.strokeDasharray) {
476
+ lineElement.setAttribute("stroke-dasharray", this.options.strokeDasharray);
477
+ }
478
+ } else if (this.options.strokeDasharray) {
479
+ lineElement = document.createElementNS("http://www.w3.org/2000/svg", "line");
480
+ lineElement.setAttribute("x1", this.startPoint.x);
481
+ lineElement.setAttribute("y1", this.startPoint.y);
482
+ lineElement.setAttribute("x2", this.endPoint.x);
483
+ lineElement.setAttribute("y2", this.endPoint.y);
484
+ lineElement.setAttribute("stroke", this.options.stroke || getThemeStroke());
485
+ lineElement.setAttribute("stroke-width", this.options.strokeWidth || lineStrokeWidth);
486
+ lineElement.setAttribute("stroke-linecap", "round");
487
+ lineElement.setAttribute("stroke-dasharray", this.options.strokeDasharray);
488
+ } else {
489
+ lineElement = rc2.line(
490
+ this.startPoint.x,
491
+ this.startPoint.y,
492
+ this.endPoint.x,
493
+ this.endPoint.y,
494
+ this.options
495
+ );
496
+ }
497
+ this.element = lineElement;
498
+ this.group.insertBefore(lineElement, this.group.firstChild);
499
+ }
500
+ updateAnchorPositions() {
501
+ if (this.anchors[0]) {
502
+ this.anchors[0].setAttribute("cx", this.startPoint.x);
503
+ this.anchors[0].setAttribute("cy", this.startPoint.y);
504
+ }
505
+ if (this.anchors[1]) {
506
+ this.anchors[1].setAttribute("cx", this.endPoint.x);
507
+ this.anchors[1].setAttribute("cy", this.endPoint.y);
508
+ }
509
+ if (this.anchors[2]) {
510
+ const midX = (this.startPoint.x + this.endPoint.x) / 2;
511
+ const midY = (this.startPoint.y + this.endPoint.y) / 2;
512
+ let anchorMidX = midX, anchorMidY = midY;
513
+ if (this.isCurved && this.controlPoint) {
514
+ anchorMidX = 0.25 * this.startPoint.x + 0.5 * this.controlPoint.x + 0.25 * this.endPoint.x;
515
+ anchorMidY = 0.25 * this.startPoint.y + 0.5 * this.controlPoint.y + 0.25 * this.endPoint.y;
516
+ }
517
+ this.anchors[2].setAttribute("cx", anchorMidX);
518
+ this.anchors[2].setAttribute("cy", anchorMidY);
519
+ this.anchors[2].setAttribute("fill", this.isCurved ? "#5B57D1" : "#121212");
520
+ }
521
+ }
522
+ // Add move method for dragging the entire line
523
+ move(dx, dy) {
524
+ this.startPoint.x += dx;
525
+ this.startPoint.y += dy;
526
+ this.endPoint.x += dx;
527
+ this.endPoint.y += dy;
528
+ if (this.controlPoint) {
529
+ this.controlPoint.x += dx;
530
+ this.controlPoint.y += dy;
531
+ }
532
+ this.updateLineElement();
533
+ this.updateAnchorPositions();
534
+ if (this._hitArea) {
535
+ if (this.isCurved && this.controlPoint) {
536
+ this._hitArea.setAttribute("d", `M ${this.startPoint.x} ${this.startPoint.y} Q ${this.controlPoint.x} ${this.controlPoint.y} ${this.endPoint.x} ${this.endPoint.y}`);
537
+ } else {
538
+ this._hitArea.setAttribute("d", `M ${this.startPoint.x} ${this.startPoint.y} L ${this.endPoint.x} ${this.endPoint.y}`);
539
+ }
540
+ }
541
+ this._updateLabelElement();
542
+ if (!this.isBeingMovedByFrame) {
543
+ this.updateFrameContainment();
544
+ }
545
+ this.updateAttachedArrows();
546
+ }
547
+ updateAttachedArrows() {
548
+ updateAttachedArrows(this);
549
+ }
550
+ updateFrameContainment() {
551
+ if (this.isBeingMovedByFrame) return;
552
+ let targetFrame = null;
553
+ shapes.forEach((shape) => {
554
+ if (shape.shapeName === "frame" && shape.isShapeInFrame(this)) {
555
+ targetFrame = shape;
556
+ }
557
+ });
558
+ if (this.parentFrame) {
559
+ this.parentFrame.temporarilyRemoveFromFrame(this);
560
+ }
561
+ if (hoveredFrameLine && hoveredFrameLine !== targetFrame) {
562
+ hoveredFrameLine.removeHighlight();
563
+ }
564
+ if (targetFrame && targetFrame !== hoveredFrameLine) {
565
+ targetFrame.highlightFrame();
566
+ }
567
+ hoveredFrameLine = targetFrame;
568
+ }
569
+ contains(x, y) {
570
+ const tolerance = 8 / (currentZoom || 1);
571
+ if (this.isCurved && this.controlPoint) {
572
+ return this.pointToQuadraticBezierDistance(x, y) <= tolerance;
573
+ } else {
574
+ return this.pointToLineDistance(x, y, this.startPoint.x, this.startPoint.y, this.endPoint.x, this.endPoint.y) <= tolerance;
575
+ }
576
+ }
577
+ pointToQuadraticBezierDistance(x, y) {
578
+ let minDistance = Infinity;
579
+ const steps = 50;
580
+ for (let i = 0; i <= steps; i++) {
581
+ const t = i / steps;
582
+ const point = this.getQuadraticBezierPoint(t);
583
+ const distance = Math.sqrt(Math.pow(x - point.x, 2) + Math.pow(y - point.y, 2));
584
+ minDistance = Math.min(minDistance, distance);
585
+ }
586
+ return minDistance;
587
+ }
588
+ getQuadraticBezierPoint(t) {
589
+ if (!this.controlPoint) return this.startPoint;
590
+ const mt = 1 - t;
591
+ return {
592
+ x: mt * mt * this.startPoint.x + 2 * mt * t * this.controlPoint.x + t * t * this.endPoint.x,
593
+ y: mt * mt * this.startPoint.y + 2 * mt * t * this.controlPoint.y + t * t * this.endPoint.y
594
+ };
595
+ }
596
+ pointToLineDistance(x, y, x1, y1, x2, y2) {
597
+ const A = x - x1;
598
+ const B = y - y1;
599
+ const C = x2 - x1;
600
+ const D = y2 - y1;
601
+ const dot = A * C + B * D;
602
+ const lenSq = C * C + D * D;
603
+ let param = -1;
604
+ if (lenSq !== 0) param = dot / lenSq;
605
+ let xx, yy;
606
+ if (param < 0) {
607
+ xx = x1;
608
+ yy = y1;
609
+ } else if (param > 1) {
610
+ xx = x2;
611
+ yy = y2;
612
+ } else {
613
+ xx = x1 + param * C;
614
+ yy = y1 + param * D;
615
+ }
616
+ const dx = x - xx;
617
+ const dy = y - yy;
618
+ return Math.sqrt(dx * dx + dy * dy);
619
+ }
620
+ // No-op: React sidebar handles UI updates via Zustand store
621
+ updateSidebar() {
622
+ }
623
+ };
624
+
625
+ export {
626
+ Line
627
+ };
628
+ //# sourceMappingURL=chunk-6PFXZKL2.js.map