@forgecharts/sdk 1.1.23 → 1.1.27

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.
@@ -0,0 +1,1096 @@
1
+ import React, { useState, useEffect, useRef } from 'react';
2
+ import ReactDOM from 'react-dom';
3
+ import type { DrawingToolType, DrawingType, PointerToolType } from '../../../';
4
+
5
+ // ─── Pointer tools ────────────────────────────────────────────────────────────
6
+
7
+ const POINTER_TOOLS: PointerToolType[] = ['cursor', 'crosshair', 'dot', 'demonstration'];
8
+
9
+ const POINTER_ICONS: Record<PointerToolType, React.ReactNode> = {
10
+ cursor: (
11
+ <svg viewBox="0 0 16 16" width="15" height="15" fill="currentColor">
12
+ <path d="M4 1l8 7-4 1-2 5-2-13z" />
13
+ </svg>
14
+ ),
15
+ crosshair: (
16
+ <svg viewBox="0 0 16 16" width="15" height="15" stroke="currentColor" fill="none" strokeWidth="1.5">
17
+ {/* top arm */}
18
+ <line x1="8" y1="1" x2="8" y2="6" />
19
+ {/* bottom arm */}
20
+ <line x1="8" y1="10" x2="8" y2="15" />
21
+ {/* left arm */}
22
+ <line x1="1" y1="8" x2="6" y2="8" />
23
+ {/* right arm */}
24
+ <line x1="10" y1="8" x2="15" y2="8" />
25
+ </svg>
26
+ ),
27
+ dot: (
28
+ <svg viewBox="0 0 16 16" width="15" height="15" fill="currentColor">
29
+ <circle cx="8" cy="8" r="4" />
30
+ </svg>
31
+ ),
32
+ demonstration: (
33
+ <svg viewBox="0 0 16 16" width="15" height="15" stroke="currentColor" fill="none" strokeWidth="1.6">
34
+ <line x1="8" y1="1" x2="8" y2="4.5" />
35
+ <line x1="8" y1="11.5" x2="8" y2="15" />
36
+ <line x1="1" y1="8" x2="4.5" y2="8" />
37
+ <line x1="11.5" y1="8" x2="15" y2="8" />
38
+ <circle cx="8" cy="8" r="4" />
39
+ </svg>
40
+ ),
41
+ };
42
+
43
+ const POINTER_LABELS: Record<PointerToolType, string> = {
44
+ cursor: 'Arrow',
45
+ crosshair: 'Cross',
46
+ dot: 'Dot',
47
+ demonstration: 'Demonstration',
48
+ };
49
+
50
+ // ─── Lines menu data ──────────────────────────────────────────────────────────
51
+
52
+ interface LineItem {
53
+ tool: string;
54
+ label: string;
55
+ shortcut?: string;
56
+ icon: React.ReactNode;
57
+ }
58
+
59
+ interface LineSection {
60
+ heading: string;
61
+ items: LineItem[];
62
+ }
63
+
64
+ const LINES_SECTIONS: LineSection[] = [
65
+ {
66
+ heading: 'Lines',
67
+ items: [
68
+ {
69
+ tool: 'trendline',
70
+ label: 'Trendline',
71
+ shortcut: 'Alt+T',
72
+ icon: (
73
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.8">
74
+ <line x1="2" y1="14" x2="16" y2="4" />
75
+ <circle cx="2" cy="14" r="1.5" fill="currentColor" stroke="none" />
76
+ <circle cx="16" cy="4" r="1.5" fill="currentColor" stroke="none" />
77
+ </svg>
78
+ ),
79
+ },
80
+ {
81
+ tool: 'ray',
82
+ label: 'Ray',
83
+ icon: (
84
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.8">
85
+ <line x1="2" y1="13" x2="16" y2="5" />
86
+ <circle cx="2" cy="13" r="1.5" fill="currentColor" stroke="none" />
87
+ <polygon points="16,5 14,6.5 14.5,8.5" fill="currentColor" stroke="none" />
88
+ </svg>
89
+ ),
90
+ },
91
+ {
92
+ tool: 'infoLine',
93
+ label: 'Info line',
94
+ icon: (
95
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.8">
96
+ <line x1="1" y1="13" x2="17" y2="5" />
97
+ <polygon points="1,13 3,12 2.5,10" fill="currentColor" stroke="none" />
98
+ <polygon points="17,5 15,6.5 15.5,8.5" fill="currentColor" stroke="none" />
99
+ </svg>
100
+ ),
101
+ },
102
+ {
103
+ tool: 'extendedLine',
104
+ label: 'Extended line',
105
+ icon: (
106
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.8">
107
+ <line x1="2" y1="14" x2="16" y2="4" />
108
+ <circle cx="2" cy="14" r="1.5" fill="currentColor" stroke="none" />
109
+ <polygon points="16,4 14,5.5 14.5,7.5" fill="currentColor" stroke="none" />
110
+ </svg>
111
+ ),
112
+ },
113
+ {
114
+ tool: 'trendAngle',
115
+ label: 'Trend angle',
116
+ icon: (
117
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.8">
118
+ <line x1="2" y1="14" x2="16" y2="4" />
119
+ <path d="M 2 14 A 5 5 0 0 1 7.5 11.8" strokeWidth="1.4" />
120
+ <text x="6.5" y="16" fontSize="5.5" fill="currentColor" stroke="none" fontFamily="sans-serif">θ</text>
121
+ </svg>
122
+ ),
123
+ },
124
+ {
125
+ tool: 'horizontal',
126
+ label: 'Horizontal line',
127
+ shortcut: 'Alt+H',
128
+ icon: (
129
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.8">
130
+ <line x1="1" y1="9" x2="17" y2="9" />
131
+ </svg>
132
+ ),
133
+ },
134
+ {
135
+ tool: 'horizontalRay',
136
+ label: 'Horizontal ray',
137
+ shortcut: 'Alt+J',
138
+ icon: (
139
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.8">
140
+ <line x1="3" y1="9" x2="17" y2="9" />
141
+ <circle cx="3" cy="9" r="1.5" fill="currentColor" stroke="none" />
142
+ <polygon points="17,9 15,7.5 15,10.5" fill="currentColor" stroke="none" />
143
+ </svg>
144
+ ),
145
+ },
146
+ {
147
+ tool: 'vertical',
148
+ label: 'Vertical line',
149
+ shortcut: 'Alt+V',
150
+ icon: (
151
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.8">
152
+ <line x1="9" y1="1" x2="9" y2="17" />
153
+ </svg>
154
+ ),
155
+ },
156
+ {
157
+ tool: 'crossLine',
158
+ label: 'Cross line',
159
+ shortcut: 'Alt+C',
160
+ icon: (
161
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.8">
162
+ <line x1="1" y1="9" x2="17" y2="9" />
163
+ <line x1="9" y1="1" x2="9" y2="17" />
164
+ </svg>
165
+ ),
166
+ },
167
+ ],
168
+ },
169
+ {
170
+ heading: 'Channels',
171
+ items: [
172
+ {
173
+ tool: 'parallelChannel',
174
+ label: 'Parallel channel',
175
+ icon: (
176
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.8">
177
+ <line x1="2" y1="13" x2="16" y2="7" />
178
+ <line x1="2" y1="9" x2="16" y2="3" />
179
+ </svg>
180
+ ),
181
+ },
182
+ {
183
+ tool: 'regressionTrend',
184
+ label: 'Regression trend',
185
+ icon: (
186
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.8">
187
+ <line x1="2" y1="13" x2="16" y2="5" />
188
+ <line x1="2" y1="11" x2="16" y2="3" strokeDasharray="2 2" strokeWidth="1.2" />
189
+ <line x1="2" y1="15" x2="16" y2="7" strokeDasharray="2 2" strokeWidth="1.2" />
190
+ </svg>
191
+ ),
192
+ },
193
+ {
194
+ tool: 'flatTopBottom',
195
+ label: 'Flat top/bottom',
196
+ icon: (
197
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.8">
198
+ <line x1="2" y1="5" x2="16" y2="5" />
199
+ <line x1="2" y1="13" x2="16" y2="9" />
200
+ </svg>
201
+ ),
202
+ },
203
+ {
204
+ tool: 'disjointChannel',
205
+ label: 'Disjoint channel',
206
+ icon: (
207
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.8">
208
+ <line x1="2" y1="12" x2="8" y2="8" />
209
+ <line x1="10" y1="10" x2="16" y2="6" />
210
+ <line x1="2" y1="15" x2="8" y2="11" strokeDasharray="2 2" strokeWidth="1.2" />
211
+ <line x1="10" y1="13" x2="16" y2="9" strokeDasharray="2 2" strokeWidth="1.2" />
212
+ </svg>
213
+ ),
214
+ },
215
+ ],
216
+ },
217
+ {
218
+ heading: 'Pitchforks',
219
+ items: [
220
+ {
221
+ tool: 'pitchfork',
222
+ label: 'Pitchfork',
223
+ icon: (
224
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.8">
225
+ <line x1="9" y1="15" x2="9" y2="6" />
226
+ <line x1="9" y1="6" x2="4" y2="2" />
227
+ <line x1="9" y1="6" x2="14" y2="2" />
228
+ <line x1="4" y1="2" x2="14" y2="2" strokeWidth="1" />
229
+ </svg>
230
+ ),
231
+ },
232
+ {
233
+ tool: 'schiffPitchfork',
234
+ label: 'Schiff pitchfork',
235
+ icon: (
236
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.8">
237
+ <line x1="9" y1="15" x2="9" y2="7" />
238
+ <line x1="9" y1="7" x2="3.5" y2="2" />
239
+ <line x1="9" y1="7" x2="14.5" y2="2" />
240
+ <line x1="3.5" y1="2" x2="14.5" y2="2" strokeWidth="1" />
241
+ <circle cx="9" cy="11" r="1" fill="currentColor" stroke="none" />
242
+ </svg>
243
+ ),
244
+ },
245
+ {
246
+ tool: 'modifiedSchiffPitchfork',
247
+ label: 'Modified Schiff pitchfork',
248
+ icon: (
249
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.8">
250
+ <line x1="9" y1="16" x2="9" y2="8" />
251
+ <line x1="9" y1="8" x2="4" y2="2" />
252
+ <line x1="9" y1="8" x2="14" y2="2" />
253
+ <line x1="4" y1="2" x2="14" y2="2" strokeWidth="1" />
254
+ <line x1="6.5" y1="5" x2="11.5" y2="5" strokeWidth="1" strokeDasharray="1.5 1.5" />
255
+ </svg>
256
+ ),
257
+ },
258
+ {
259
+ tool: 'insidePitchfork',
260
+ label: 'Inside pitchfork',
261
+ icon: (
262
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.8">
263
+ <line x1="9" y1="15" x2="9" y2="9" />
264
+ <line x1="4" y1="2" x2="14" y2="2" strokeWidth="1" />
265
+ <line x1="9" y1="9" x2="4" y2="2" />
266
+ <line x1="9" y1="9" x2="14" y2="2" />
267
+ </svg>
268
+ ),
269
+ },
270
+ ],
271
+ },
272
+ ];
273
+
274
+ const LINES_MENU_TOOLS = new Set<DrawingToolType>(
275
+ LINES_SECTIONS.flatMap((s) => s.items.map((i) => i.tool as DrawingToolType)),
276
+ );
277
+
278
+ const ALL_LINES_ITEMS = LINES_SECTIONS.flatMap((s) => s.items);
279
+ const LINES_ITEM_MAP = new Map<string, LineItem>(ALL_LINES_ITEMS.map((i) => [i.tool, i]));
280
+ const DEFAULT_LINES_TOOL = ALL_LINES_ITEMS[0]?.tool ?? 'trendline';
281
+
282
+ // ─── Fibonacci & Gann menu data ───────────────────────────────────────────────
283
+
284
+ type FibGannTool =
285
+ | 'fibRetracement'
286
+ | 'trendBasedFibExtension'
287
+ | 'fibChannel'
288
+ | 'fibTimeZone'
289
+ | 'fibSpeedResistanceFan'
290
+ | 'trendBasedFibTime'
291
+ | 'fibCircles'
292
+ | 'fibSpiral'
293
+ | 'fibSpeedResistanceArcs'
294
+ | 'fibWedge'
295
+ | 'pitchfan'
296
+ | 'gannBox'
297
+ | 'gannSquareFixed'
298
+ | 'gannSquare'
299
+ | 'gannFan';
300
+
301
+ interface FibGannItem {
302
+ tool: FibGannTool;
303
+ label: string;
304
+ shortcut?: string;
305
+ icon: React.ReactNode;
306
+ }
307
+
308
+ interface FibGannSection {
309
+ heading: string;
310
+ items: FibGannItem[];
311
+ }
312
+
313
+ const FIB_GANN_SECTIONS: FibGannSection[] = [
314
+ {
315
+ heading: 'Fibonacci',
316
+ items: [
317
+ {
318
+ tool: 'fibRetracement',
319
+ label: 'Fib retracement',
320
+ shortcut: 'Alt+F',
321
+ icon: (
322
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.5">
323
+ <line x1="2" y1="3" x2="16" y2="3" />
324
+ <line x1="2" y1="6" x2="16" y2="6" />
325
+ <line x1="2" y1="9" x2="16" y2="9" />
326
+ <line x1="2" y1="12" x2="16" y2="12" />
327
+ <line x1="2" y1="15" x2="16" y2="15" />
328
+ </svg>
329
+ ),
330
+ },
331
+ {
332
+ tool: 'trendBasedFibExtension',
333
+ label: 'Trend-based fib extension',
334
+ icon: (
335
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.5">
336
+ <line x1="2" y1="14" x2="10" y2="6" />
337
+ <line x1="10" y1="6" x2="16" y2="3" strokeDasharray="2 2" strokeWidth="1.2" />
338
+ <line x1="10" y1="9" x2="16" y2="9" strokeWidth="1" />
339
+ <line x1="10" y1="12" x2="16" y2="12" strokeWidth="1" />
340
+ <line x1="10" y1="14" x2="16" y2="14" strokeWidth="1" />
341
+ <circle cx="2" cy="14" r="1.2" fill="currentColor" stroke="none" />
342
+ <circle cx="10" cy="6" r="1.2" fill="currentColor" stroke="none" />
343
+ </svg>
344
+ ),
345
+ },
346
+ {
347
+ tool: 'fibChannel',
348
+ label: 'Fib channel',
349
+ icon: (
350
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.5">
351
+ <line x1="2" y1="14" x2="16" y2="6" />
352
+ <line x1="2" y1="11" x2="16" y2="3" strokeWidth="1" />
353
+ <line x1="2" y1="12.5" x2="16" y2="4.5" strokeWidth="0.8" strokeDasharray="2 2" />
354
+ <line x1="2" y1="9" x2="16" y2="1" strokeWidth="0.8" strokeDasharray="2 2" />
355
+ </svg>
356
+ ),
357
+ },
358
+ {
359
+ tool: 'fibTimeZone',
360
+ label: 'Fib time zone',
361
+ icon: (
362
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.5">
363
+ <line x1="3" y1="2" x2="3" y2="16" />
364
+ <line x1="6" y1="2" x2="6" y2="16" strokeWidth="1" />
365
+ <line x1="10" y1="2" x2="10" y2="16" strokeWidth="1" />
366
+ <line x1="15" y1="2" x2="15" y2="16" strokeWidth="1" />
367
+ </svg>
368
+ ),
369
+ },
370
+ {
371
+ tool: 'fibSpeedResistanceFan',
372
+ label: 'Fib speed resistance fan',
373
+ icon: (
374
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.5">
375
+ <line x1="2" y1="15" x2="16" y2="2" />
376
+ <line x1="2" y1="15" x2="16" y2="6" strokeWidth="1" />
377
+ <line x1="2" y1="15" x2="16" y2="10" strokeWidth="1" />
378
+ <circle cx="2" cy="15" r="1.2" fill="currentColor" stroke="none" />
379
+ </svg>
380
+ ),
381
+ },
382
+ {
383
+ tool: 'trendBasedFibTime',
384
+ label: 'Trend-based fib time',
385
+ icon: (
386
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.5">
387
+ <line x1="2" y1="13" x2="9" y2="5" />
388
+ <line x1="9" y1="2" x2="9" y2="16" strokeWidth="1" />
389
+ <line x1="12" y1="2" x2="12" y2="16" strokeWidth="0.8" />
390
+ <line x1="15" y1="2" x2="15" y2="16" strokeWidth="0.8" />
391
+ </svg>
392
+ ),
393
+ },
394
+ {
395
+ tool: 'fibCircles',
396
+ label: 'Fib circles',
397
+ icon: (
398
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.5">
399
+ <circle cx="5" cy="13" r="2" />
400
+ <circle cx="5" cy="13" r="4.5" strokeWidth="1" />
401
+ <circle cx="5" cy="13" r="7.5" strokeWidth="1" />
402
+ <circle cx="5" cy="13" r="1" fill="currentColor" stroke="none" />
403
+ </svg>
404
+ ),
405
+ },
406
+ {
407
+ tool: 'fibSpiral',
408
+ label: 'Fib spiral',
409
+ icon: (
410
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.5">
411
+ <path d="M 9 9 Q 9 14 14 14 Q 14 4 4 4 Q 4 16 16 16" />
412
+ <circle cx="9" cy="9" r="1" fill="currentColor" stroke="none" />
413
+ </svg>
414
+ ),
415
+ },
416
+ {
417
+ tool: 'fibSpeedResistanceArcs',
418
+ label: 'Fib speed resistance arcs',
419
+ icon: (
420
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.5">
421
+ <path d="M 2 15 A 4 4 0 0 1 6 11" />
422
+ <path d="M 2 15 A 8 8 0 0 1 10 7" strokeWidth="1" />
423
+ <path d="M 2 15 A 13 13 0 0 1 15 2" strokeWidth="1" />
424
+ <circle cx="2" cy="15" r="1.2" fill="currentColor" stroke="none" />
425
+ </svg>
426
+ ),
427
+ },
428
+ {
429
+ tool: 'fibWedge',
430
+ label: 'Fib wedge',
431
+ icon: (
432
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.5">
433
+ <line x1="2" y1="15" x2="16" y2="3" />
434
+ <line x1="2" y1="15" x2="16" y2="8" />
435
+ <line x1="2" y1="15" x2="16" y2="12" strokeWidth="1" />
436
+ <circle cx="2" cy="15" r="1.2" fill="currentColor" stroke="none" />
437
+ </svg>
438
+ ),
439
+ },
440
+ {
441
+ tool: 'pitchfan',
442
+ label: 'Pitchfan',
443
+ icon: (
444
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.5">
445
+ <line x1="2" y1="15" x2="16" y2="3" />
446
+ <line x1="2" y1="15" x2="16" y2="9" strokeWidth="1" />
447
+ <line x1="2" y1="15" x2="16" y2="15" strokeWidth="1" />
448
+ <line x1="8" y1="3" x2="8" y2="15" strokeWidth="0.8" strokeDasharray="2 2" />
449
+ <circle cx="2" cy="15" r="1.2" fill="currentColor" stroke="none" />
450
+ </svg>
451
+ ),
452
+ },
453
+ ],
454
+ },
455
+ {
456
+ heading: 'Gann',
457
+ items: [
458
+ {
459
+ tool: 'gannBox',
460
+ label: 'Gann box',
461
+ icon: (
462
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.5">
463
+ <rect x="2" y="3" width="14" height="12" />
464
+ <line x1="2" y1="3" x2="16" y2="15" strokeWidth="1" />
465
+ <line x1="2" y1="15" x2="16" y2="3" strokeWidth="1" />
466
+ </svg>
467
+ ),
468
+ },
469
+ {
470
+ tool: 'gannSquareFixed',
471
+ label: 'Gann square fixed',
472
+ icon: (
473
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.5">
474
+ <rect x="3" y="3" width="12" height="12" />
475
+ <line x1="3" y1="9" x2="15" y2="9" strokeWidth="0.8" />
476
+ <line x1="9" y1="3" x2="9" y2="15" strokeWidth="0.8" />
477
+ <circle cx="9" cy="9" r="1.2" fill="currentColor" stroke="none" />
478
+ </svg>
479
+ ),
480
+ },
481
+ {
482
+ tool: 'gannSquare',
483
+ label: 'Gann square',
484
+ icon: (
485
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.5">
486
+ <rect x="3" y="3" width="12" height="12" />
487
+ <line x1="3" y1="3" x2="15" y2="15" strokeWidth="1" />
488
+ <line x1="9" y1="3" x2="9" y2="15" strokeWidth="0.8" />
489
+ <line x1="3" y1="9" x2="15" y2="9" strokeWidth="0.8" />
490
+ </svg>
491
+ ),
492
+ },
493
+ {
494
+ tool: 'gannFan',
495
+ label: 'Gann fan',
496
+ icon: (
497
+ <svg viewBox="0 0 18 18" width="16" height="16" stroke="currentColor" fill="none" strokeWidth="1.5">
498
+ <line x1="2" y1="16" x2="16" y2="2" />
499
+ <line x1="2" y1="16" x2="16" y2="6" strokeWidth="1" />
500
+ <line x1="2" y1="16" x2="16" y2="10" strokeWidth="1" />
501
+ <line x1="2" y1="16" x2="16" y2="16" strokeWidth="0.8" />
502
+ <line x1="2" y1="16" x2="6" y2="2" strokeWidth="1" />
503
+ <circle cx="2" cy="16" r="1.2" fill="currentColor" stroke="none" />
504
+ </svg>
505
+ ),
506
+ },
507
+ ],
508
+ },
509
+ ];
510
+
511
+ const FIB_GANN_TOOLS = new Set<DrawingToolType>(
512
+ FIB_GANN_SECTIONS.flatMap((s) => s.items.map((i) => i.tool as DrawingToolType)),
513
+ );
514
+
515
+ const FIB_GANN_ITEM_MAP = new Map<DrawingToolType, FibGannItem>(
516
+ FIB_GANN_SECTIONS.flatMap((s) => s.items.map((i) => [i.tool as DrawingToolType, i])),
517
+ );
518
+
519
+ // ─── Other tools ──────────────────────────────────────────────────────────────
520
+
521
+ type OtherTool = 'rectangle' | 'text';
522
+
523
+ const OTHER_ICONS: Record<OtherTool, React.ReactNode> = {
524
+ rectangle: (
525
+ <svg viewBox="0 0 16 16" width="15" height="15" stroke="currentColor" fill="none" strokeWidth="2">
526
+ <rect x="2" y="4" width="12" height="8" />
527
+ </svg>
528
+ ),
529
+ text: (
530
+ <svg viewBox="0 0 16 16" width="15" height="15" fill="currentColor">
531
+ <text x="3" y="13" fontSize="13" fontFamily="serif" fontWeight="bold">T</text>
532
+ </svg>
533
+ ),
534
+ };
535
+
536
+ const OTHER_LABELS: Record<OtherTool, string> = {
537
+ rectangle: 'Rectangle',
538
+ text: 'Text',
539
+ };
540
+
541
+ const OTHER_TOOL_ORDER: OtherTool[] = ['rectangle', 'text'];
542
+
543
+ // ─── Unified drawing-tool item map (Lines + FibGann + Other) ─────────────────
544
+ // Used by the floating favorites toolbar to look up icons/labels for any tool.
545
+
546
+ const ALL_DRAWING_ITEM_MAP = new Map<DrawingToolType, { label: string; icon: React.ReactNode }>([
547
+ ...ALL_LINES_ITEMS.map((i) => [i.tool as DrawingToolType, i] as [DrawingToolType, { label: string; icon: React.ReactNode }]),
548
+ ...FIB_GANN_SECTIONS.flatMap((s) => s.items).map((i) => [i.tool as DrawingToolType, i] as [DrawingToolType, { label: string; icon: React.ReactNode }]),
549
+ ...OTHER_TOOL_ORDER.map((t) => [t as DrawingToolType, { label: OTHER_LABELS[t], icon: OTHER_ICONS[t] }] as [DrawingToolType, { label: string; icon: React.ReactNode }]),
550
+ ]);
551
+
552
+ // ─── Star icon ────────────────────────────────────────────────────────────────
553
+
554
+ function StarIcon({ filled }: { filled: boolean }): React.ReactElement {
555
+ return (
556
+ <svg
557
+ viewBox="0 0 16 16"
558
+ width="13"
559
+ height="13"
560
+ fill={filled ? '#f5a623' : 'none'}
561
+ stroke={filled ? '#f5a623' : 'currentColor'}
562
+ strokeWidth="1.4"
563
+ strokeLinecap="round"
564
+ strokeLinejoin="round"
565
+ >
566
+ <path d="M8 1.5l1.8 3.6 4 .58-2.9 2.83.68 3.99L8 10.35l-3.58 1.88.68-3.99L2.2 5.68l4-.58z" />
567
+ </svg>
568
+ );
569
+ }
570
+
571
+ // ─── Pointer group ────────────────────────────────────────────────────────────
572
+
573
+ function PointerGroup({
574
+ activeTool,
575
+ onSelectTool,
576
+ }: {
577
+ activeTool: DrawingToolType;
578
+ onSelectTool: (tool: DrawingToolType) => void;
579
+ }): React.ReactElement {
580
+ const [flyoutOpen, setFlyoutOpen] = useState(false);
581
+ const groupRef = useRef<HTMLDivElement>(null);
582
+
583
+ const activePointer: PointerToolType = (POINTER_TOOLS as string[]).includes(activeTool)
584
+ ? (activeTool as PointerToolType)
585
+ : 'cursor';
586
+ const isPointerActive = (POINTER_TOOLS as string[]).includes(activeTool);
587
+
588
+ useEffect(() => {
589
+ if (!flyoutOpen) return;
590
+ const handler = (e: MouseEvent) => {
591
+ if (groupRef.current && !groupRef.current.contains(e.target as Node)) setFlyoutOpen(false);
592
+ };
593
+ document.addEventListener('mousedown', handler);
594
+ return () => document.removeEventListener('mousedown', handler);
595
+ }, [flyoutOpen]);
596
+
597
+ return (
598
+ <div ref={groupRef} className="dt-pointer-group">
599
+ <button
600
+ className={`drawing-tool-btn dt-pointer-main${isPointerActive ? ' is-active' : ''}`}
601
+ title={POINTER_LABELS[activePointer]}
602
+ onClick={() => setFlyoutOpen((o) => !o)}
603
+ >
604
+ {POINTER_ICONS[activePointer]}
605
+ </button>
606
+ <button
607
+ className={`dt-pointer-expand${flyoutOpen ? ' is-open' : ''}`}
608
+ title="Pointer tools"
609
+ onClick={(e) => { e.stopPropagation(); setFlyoutOpen((o) => !o); }}
610
+ >
611
+ <svg viewBox="0 0 6 10" width="5" height="8" fill="currentColor">
612
+ <path d="M1 1l4 4-4 4" stroke="currentColor" strokeWidth="1.4" fill="none" strokeLinecap="round" strokeLinejoin="round" />
613
+ </svg>
614
+ </button>
615
+ {flyoutOpen && (
616
+ <div className="dt-pointer-flyout">
617
+ <div className="dt-flyout-label">Pointer</div>
618
+ {POINTER_TOOLS.map((tool) => (
619
+ <button
620
+ key={tool}
621
+ className={`dt-flyout-item${activeTool === tool ? ' is-active' : ''}`}
622
+ onClick={() => { onSelectTool(tool); setFlyoutOpen(false); }}
623
+ >
624
+ <span className="dt-flyout-icon">{POINTER_ICONS[tool]}</span>
625
+ <span className="dt-flyout-name">{POINTER_LABELS[tool]}</span>
626
+ {activeTool === tool && <span className="dt-flyout-check">✓</span>}
627
+ </button>
628
+ ))}
629
+ </div>
630
+ )}
631
+ </div>
632
+ );
633
+ }
634
+
635
+ // ─── Lines group ──────────────────────────────────────────────────────────────
636
+
637
+ function LinesGroup({
638
+ activeTool,
639
+ favorites,
640
+ onSelectTool,
641
+ onFavoritesChange,
642
+ }: {
643
+ activeTool: DrawingToolType;
644
+ favorites: DrawingToolType[];
645
+ onSelectTool: (tool: DrawingToolType) => void;
646
+ onFavoritesChange: (favs: DrawingToolType[]) => void;
647
+ }): React.ReactElement {
648
+ const [panelOpen, setPanelOpen] = useState(false);
649
+ const groupRef = useRef<HTMLDivElement>(null);
650
+ const isLinesActive = LINES_MENU_TOOLS.has(activeTool);
651
+ const [lastTool, setLastTool] = useState<string>(DEFAULT_LINES_TOOL);
652
+
653
+ const currentItem = (isLinesActive
654
+ ? LINES_ITEM_MAP.get(activeTool as string)
655
+ : LINES_ITEM_MAP.get(lastTool)) ?? LINES_ITEM_MAP.get(DEFAULT_LINES_TOOL)!;
656
+
657
+ useEffect(() => {
658
+ if (!panelOpen) return;
659
+ const handler = (e: MouseEvent) => {
660
+ if (groupRef.current && !groupRef.current.contains(e.target as Node)) setPanelOpen(false);
661
+ };
662
+ document.addEventListener('mousedown', handler);
663
+ return () => document.removeEventListener('mousedown', handler);
664
+ }, [panelOpen]);
665
+
666
+ const toggleFavorite = (tool: DrawingToolType, e: React.MouseEvent) => {
667
+ e.stopPropagation();
668
+ const next = favorites.includes(tool)
669
+ ? favorites.filter((f) => f !== tool)
670
+ : [...favorites, tool];
671
+ onFavoritesChange(next);
672
+ };
673
+
674
+ return (
675
+ <div ref={groupRef} className="dt-lines-group">
676
+ <button
677
+ className={`drawing-tool-btn dt-lines-main${isLinesActive ? ' is-active' : ''}`}
678
+ title={currentItem.label}
679
+ onClick={() => setPanelOpen((o) => !o)}
680
+ >
681
+ {currentItem.icon}
682
+ </button>
683
+ <button
684
+ className={`dt-pointer-expand${panelOpen ? ' is-open' : ''}`}
685
+ title="Lines tools"
686
+ onClick={(e) => { e.stopPropagation(); setPanelOpen((o) => !o); }}
687
+ >
688
+ <svg viewBox="0 0 6 10" width="5" height="8" fill="currentColor">
689
+ <path d="M1 1l4 4-4 4" stroke="currentColor" strokeWidth="1.4" fill="none" strokeLinecap="round" strokeLinejoin="round" />
690
+ </svg>
691
+ </button>
692
+ {panelOpen && (
693
+ <div className="dt-lines-panel">
694
+ {LINES_SECTIONS.map((section) => (
695
+ <div key={section.heading} className="dt-lines-section">
696
+ <div className="dt-lines-heading">{section.heading.toUpperCase()}</div>
697
+ {section.items.map((item) => {
698
+ const isFav = favorites.includes(item.tool as DrawingToolType);
699
+ return (
700
+ <button
701
+ key={item.tool}
702
+ className={`dt-lines-item dt-fibgann-item${activeTool === (item.tool as DrawingToolType) ? ' is-active' : ''}`}
703
+ onClick={() => { setLastTool(item.tool); onSelectTool(item.tool as DrawingToolType); setPanelOpen(false); }}
704
+ >
705
+ <span className="dt-lines-icon">{item.icon}</span>
706
+ <span className="dt-lines-name">{item.label}</span>
707
+ {item.shortcut && <span className="dt-lines-shortcut">{item.shortcut}</span>}
708
+ <button
709
+ className={`dt-star-btn${isFav ? ' is-starred' : ''}`}
710
+ title={isFav ? 'Remove from favorites' : 'Add to favorites'}
711
+ onClick={(e) => toggleFavorite(item.tool as DrawingToolType, e)}
712
+ >
713
+ <StarIcon filled={isFav} />
714
+ </button>
715
+ </button>
716
+ );
717
+ })}
718
+ </div>
719
+ ))}
720
+ </div>
721
+ )}
722
+ </div>
723
+ );
724
+ }
725
+
726
+ // ─── FibGann group ────────────────────────────────────────────────────────────
727
+
728
+ function FibGannGroup({
729
+ activeTool,
730
+ favorites,
731
+ onSelectTool,
732
+ onFavoritesChange,
733
+ }: {
734
+ activeTool: DrawingToolType;
735
+ favorites: DrawingToolType[];
736
+ onSelectTool: (tool: DrawingToolType) => void;
737
+ onFavoritesChange: (favs: DrawingToolType[]) => void;
738
+ }): React.ReactElement {
739
+ const [panelOpen, setPanelOpen] = useState(false);
740
+ const groupRef = useRef<HTMLDivElement>(null);
741
+ const isFibGannActive = FIB_GANN_TOOLS.has(activeTool);
742
+ const [lastTool, setLastTool] = useState<DrawingToolType>('fibRetracement');
743
+
744
+ const currentItem = (isFibGannActive
745
+ ? FIB_GANN_ITEM_MAP.get(activeTool)
746
+ : FIB_GANN_ITEM_MAP.get(lastTool)) ?? FIB_GANN_ITEM_MAP.get('fibRetracement')!;
747
+
748
+ useEffect(() => {
749
+ if (!panelOpen) return;
750
+ const handler = (e: MouseEvent) => {
751
+ if (groupRef.current && !groupRef.current.contains(e.target as Node)) setPanelOpen(false);
752
+ };
753
+ document.addEventListener('mousedown', handler);
754
+ return () => document.removeEventListener('mousedown', handler);
755
+ }, [panelOpen]);
756
+
757
+ const toggleFavorite = (tool: DrawingToolType, e: React.MouseEvent) => {
758
+ e.stopPropagation();
759
+ const next = favorites.includes(tool)
760
+ ? favorites.filter((f) => f !== tool)
761
+ : [...favorites, tool];
762
+ onFavoritesChange(next);
763
+ };
764
+
765
+ return (
766
+ <div ref={groupRef} className="dt-lines-group">
767
+ <button
768
+ className={`drawing-tool-btn dt-lines-main${isFibGannActive ? ' is-active' : ''}`}
769
+ title={currentItem.label}
770
+ onClick={() => setPanelOpen((o) => !o)}
771
+ >
772
+ {currentItem.icon}
773
+ </button>
774
+ <button
775
+ className={`dt-pointer-expand${panelOpen ? ' is-open' : ''}`}
776
+ title="Fibonacci & Gann tools"
777
+ onClick={(e) => { e.stopPropagation(); setPanelOpen((o) => !o); }}
778
+ >
779
+ <svg viewBox="0 0 6 10" width="5" height="8" fill="currentColor">
780
+ <path d="M1 1l4 4-4 4" stroke="currentColor" strokeWidth="1.4" fill="none" strokeLinecap="round" strokeLinejoin="round" />
781
+ </svg>
782
+ </button>
783
+ {panelOpen && (
784
+ <div className="dt-lines-panel dt-fibgann-panel">
785
+ {FIB_GANN_SECTIONS.map((section) => (
786
+ <div key={section.heading} className="dt-lines-section">
787
+ <div className="dt-lines-heading">{section.heading.toUpperCase()}</div>
788
+ {section.items.map((item) => {
789
+ const isFav = favorites.includes(item.tool as DrawingToolType);
790
+ return (
791
+ <button
792
+ key={item.tool}
793
+ className={`dt-lines-item dt-fibgann-item${activeTool === (item.tool as DrawingToolType) ? ' is-active' : ''}`}
794
+ onClick={() => { setLastTool(item.tool as DrawingToolType); onSelectTool(item.tool as DrawingToolType); setPanelOpen(false); }}
795
+ >
796
+ <span className="dt-lines-icon">{item.icon}</span>
797
+ <span className="dt-lines-name">{item.label}</span>
798
+ {item.shortcut && <span className="dt-lines-shortcut">{item.shortcut}</span>}
799
+ <button
800
+ className={`dt-star-btn${isFav ? ' is-starred' : ''}`}
801
+ title={isFav ? 'Remove from favorites' : 'Add to favorites'}
802
+ onClick={(e) => toggleFavorite(item.tool as DrawingToolType, e)}
803
+ >
804
+ <StarIcon filled={isFav} />
805
+ </button>
806
+ </button>
807
+ );
808
+ })}
809
+ </div>
810
+ ))}
811
+ </div>
812
+ )}
813
+ </div>
814
+ );
815
+ }
816
+
817
+ // ─── Favorites floating toolbar ───────────────────────────────────────────────
818
+
819
+ function FavoritesFloatingToolbar({
820
+ favorites,
821
+ activeTool,
822
+ onSelectTool,
823
+ }: {
824
+ favorites: DrawingToolType[];
825
+ activeTool: DrawingToolType;
826
+ onSelectTool: (tool: DrawingToolType) => void;
827
+ }): React.ReactElement | null {
828
+ const [pos, setPos] = useState({ x: 60, y: 60 });
829
+ const [dragging, setDragging] = useState(false);
830
+ const dragOffset = useRef({ x: 0, y: 0 });
831
+
832
+ useEffect(() => {
833
+ if (!dragging) return;
834
+ const onMove = (e: MouseEvent) => {
835
+ setPos({ x: e.clientX - dragOffset.current.x, y: e.clientY - dragOffset.current.y });
836
+ };
837
+ const onUp = () => setDragging(false);
838
+ window.addEventListener('mousemove', onMove);
839
+ window.addEventListener('mouseup', onUp);
840
+ return () => {
841
+ window.removeEventListener('mousemove', onMove);
842
+ window.removeEventListener('mouseup', onUp);
843
+ };
844
+ }, [dragging]);
845
+
846
+ const validFavs = favorites.filter((f) => ALL_DRAWING_ITEM_MAP.has(f));
847
+ if (validFavs.length === 0) return null;
848
+
849
+ return ReactDOM.createPortal(
850
+ <div className="dt-favorites-toolbar" style={{ left: pos.x, top: pos.y }}>
851
+ <div
852
+ className="dt-favorites-handle"
853
+ title="Drag to reposition"
854
+ onMouseDown={(e) => {
855
+ dragOffset.current = { x: e.clientX - pos.x, y: e.clientY - pos.y };
856
+ setDragging(true);
857
+ e.preventDefault();
858
+ }}
859
+ >
860
+ <svg viewBox="0 0 6 12" width="4" height="10" fill="currentColor" opacity="0.5">
861
+ <circle cx="1.5" cy="2" r="1.2" />
862
+ <circle cx="1.5" cy="6" r="1.2" />
863
+ <circle cx="1.5" cy="10" r="1.2" />
864
+ <circle cx="4.5" cy="2" r="1.2" />
865
+ <circle cx="4.5" cy="6" r="1.2" />
866
+ <circle cx="4.5" cy="10" r="1.2" />
867
+ </svg>
868
+ </div>
869
+ {validFavs.map((tool) => {
870
+ const item = ALL_DRAWING_ITEM_MAP.get(tool)!;
871
+ return (
872
+ <button
873
+ key={tool}
874
+ className={`drawing-tool-btn dt-fav-btn${activeTool === tool ? ' is-active' : ''}`}
875
+ title={item.label}
876
+ onClick={() => onSelectTool(tool)}
877
+ >
878
+ {item.icon}
879
+ </button>
880
+ );
881
+ })}
882
+ </div>,
883
+ document.body,
884
+ );
885
+ }
886
+
887
+ // ─── Utility tools ────────────────────────────────────────────────────────────
888
+
889
+ export type VisibilityAction = 'hideDrawings' | 'hideIndicators' | 'hidePositions' | 'hideAll';
890
+
891
+ // Reusable expand chevron SVG
892
+ const ExpandChevron = () => (
893
+ <svg viewBox="0 0 6 10" width="5" height="8" fill="currentColor">
894
+ <path d="M1 1l4 4-4 4" stroke="currentColor" strokeWidth="1.4" fill="none" strokeLinecap="round" strokeLinejoin="round" />
895
+ </svg>
896
+ );
897
+
898
+ // ─── Visibility tool ──────────────────────────────────────────────────────────
899
+
900
+ function VisibilityTool({
901
+ onAction,
902
+ activeAction,
903
+ onDeactivate,
904
+ }: {
905
+ onAction?: (action: VisibilityAction) => void;
906
+ activeAction?: VisibilityAction | null;
907
+ onDeactivate?: () => void;
908
+ }): React.ReactElement {
909
+ const [flyoutOpen, setFlyoutOpen] = useState(false);
910
+ const groupRef = useRef<HTMLDivElement>(null);
911
+
912
+ useEffect(() => {
913
+ if (!flyoutOpen) return;
914
+ const handler = (e: MouseEvent) => {
915
+ if (groupRef.current && !groupRef.current.contains(e.target as Node)) setFlyoutOpen(false);
916
+ };
917
+ document.addEventListener('mousedown', handler);
918
+ return () => document.removeEventListener('mousedown', handler);
919
+ }, [flyoutOpen]);
920
+
921
+ const VISIBILITY_ITEMS: { action: VisibilityAction; label: string }[] = [
922
+ { action: 'hideDrawings', label: 'Hide drawings' },
923
+ { action: 'hideIndicators', label: 'Hide indicators' },
924
+ { action: 'hidePositions', label: 'Hide positions and orders' },
925
+ { action: 'hideAll', label: 'Hide all' },
926
+ ];
927
+
928
+ return (
929
+ <div ref={groupRef} className="dt-pointer-group">
930
+ <button
931
+ className={`drawing-tool-btn dt-pointer-main${activeAction ? ' dt-vis-active' : ''}`}
932
+ title={activeAction ? 'Restore visibility' : 'Visibility'}
933
+ onClick={() => {
934
+ if (activeAction) {
935
+ onDeactivate?.();
936
+ } else {
937
+ setFlyoutOpen((o) => !o);
938
+ }
939
+ }}
940
+ >
941
+ {/* Eye with strikethrough */}
942
+ <svg viewBox="0 0 16 16" width="15" height="15" stroke="currentColor" fill="none" strokeWidth="1.6" strokeLinecap="round">
943
+ <path d="M1 8 Q4 3 8 3 Q12 3 15 8 Q12 13 8 13 Q4 13 1 8" />
944
+ <circle cx="8" cy="8" r="2.2" />
945
+ <line x1="2.5" y1="13.5" x2="13.5" y2="2.5" strokeWidth="1.5" />
946
+ </svg>
947
+ </button>
948
+ <button
949
+ className={`dt-pointer-expand${flyoutOpen ? ' is-open' : ''}`}
950
+ title="Visibility options"
951
+ onClick={(e) => { e.stopPropagation(); setFlyoutOpen((o) => !o); }}
952
+ >
953
+ <ExpandChevron />
954
+ </button>
955
+ {flyoutOpen && (
956
+ <div className="dt-pointer-flyout">
957
+ {VISIBILITY_ITEMS.map(({ action, label }) => (
958
+ <button
959
+ key={action}
960
+ className={`dt-flyout-item${activeAction === action ? ' is-active' : ''}`}
961
+ onClick={() => { onAction?.(action); setFlyoutOpen(false); }}
962
+ >
963
+ <span className="dt-flyout-name">{label}</span>
964
+ {activeAction === action && <span className="dt-flyout-check">✓</span>}
965
+ </button>
966
+ ))}
967
+ </div>
968
+ )}
969
+ </div>
970
+ );
971
+ }
972
+
973
+ // ─── LeftToolbar ──────────────────────────────────────────────────────────────
974
+
975
+ type Props = {
976
+ activeTool: DrawingToolType;
977
+ onSelectTool: (tool: DrawingToolType) => void;
978
+ /** Current drawing-tool favorites, controlled by the parent. */
979
+ drawingFavorites?: DrawingToolType[];
980
+ /** Called when the user stars/unstars a drawing tool. */
981
+ onDrawingFavoritesChange?: (favs: DrawingToolType[]) => void;
982
+ onVisibilityAction?: (action: VisibilityAction) => void;
983
+ visibilityActiveAction?: VisibilityAction | null;
984
+ onVisibilityDeactivate?: () => void;
985
+ onLinkClick?: () => void;
986
+ onDeleteClick?: () => void;
987
+ };
988
+
989
+ export function LeftToolbar({ activeTool, onSelectTool, drawingFavorites, onDrawingFavoritesChange, onVisibilityAction, visibilityActiveAction, onVisibilityDeactivate, onLinkClick, onDeleteClick }: Props): React.ReactElement {
990
+ const [favorites, setFavorites] = useState<DrawingToolType[]>(drawingFavorites ?? []);
991
+
992
+ const handleFavoritesChange = (favs: DrawingToolType[]) => {
993
+ setFavorites(favs);
994
+ onDrawingFavoritesChange?.(favs);
995
+ };
996
+
997
+ return (
998
+ <>
999
+ <div
1000
+ style={{
1001
+ display: 'flex',
1002
+ flexDirection: 'column',
1003
+ alignItems: 'center',
1004
+ gap: 2,
1005
+ padding: '6px 4px',
1006
+ background: 'var(--toolbar-bg)',
1007
+ borderRadius: 8,
1008
+ width: 40,
1009
+ flexShrink: 0,
1010
+ userSelect: 'none',
1011
+ }}
1012
+ >
1013
+ <PointerGroup activeTool={activeTool} onSelectTool={onSelectTool} />
1014
+
1015
+ <LinesGroup
1016
+ activeTool={activeTool}
1017
+ favorites={favorites}
1018
+ onSelectTool={onSelectTool}
1019
+ onFavoritesChange={handleFavoritesChange}
1020
+ />
1021
+
1022
+ <FibGannGroup
1023
+ activeTool={activeTool}
1024
+ favorites={favorites}
1025
+ onSelectTool={onSelectTool}
1026
+ onFavoritesChange={handleFavoritesChange}
1027
+ />
1028
+
1029
+ {OTHER_TOOL_ORDER.map((tool) => {
1030
+ const isFav = favorites.includes(tool as DrawingToolType);
1031
+ return (
1032
+ <div key={tool} className="dt-other-tool-wrap">
1033
+ <button
1034
+ title={OTHER_LABELS[tool]}
1035
+ onClick={() => onSelectTool(tool as DrawingType)}
1036
+ className={`drawing-tool-btn${activeTool === tool ? ' is-active' : ''}`}
1037
+ >
1038
+ {OTHER_ICONS[tool]}
1039
+ </button>
1040
+ <button
1041
+ className={`dt-star-btn dt-other-star${isFav ? ' is-starred' : ''}`}
1042
+ title={isFav ? 'Remove from favorites' : 'Add to favorites'}
1043
+ onClick={() => handleFavoritesChange(
1044
+ isFav
1045
+ ? favorites.filter((f) => f !== (tool as DrawingToolType))
1046
+ : [...favorites, tool as DrawingToolType]
1047
+ )}
1048
+ >
1049
+ <StarIcon filled={isFav} />
1050
+ </button>
1051
+ </div>
1052
+ );
1053
+ })}
1054
+
1055
+ <VisibilityTool
1056
+ {...(onVisibilityAction ? { onAction: onVisibilityAction } : {})}
1057
+ activeAction={visibilityActiveAction ?? null}
1058
+ {...(onVisibilityDeactivate ? { onDeactivate: onVisibilityDeactivate } : {})}
1059
+ />
1060
+
1061
+ {/* Link / sync */}
1062
+ <button
1063
+ className="drawing-tool-btn"
1064
+ title="Link chart"
1065
+ onClick={onLinkClick}
1066
+ >
1067
+ <svg viewBox="0 0 16 16" width="15" height="15" stroke="currentColor" fill="none" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round">
1068
+ <path d="M7 9 A3.5 3.5 0 0 0 9.5 5.5 L11 4 A2.5 2.5 0 1 1 14.5 7.5 L13 9 A3.5 3.5 0 0 1 9.5 10.5" />
1069
+ <path d="M9 7 A3.5 3.5 0 0 0 6.5 10.5 L5 12 A2.5 2.5 0 1 1 1.5 8.5 L3 7 A3.5 3.5 0 0 1 6.5 5.5" />
1070
+ </svg>
1071
+ </button>
1072
+
1073
+ {/* Delete / trash */}
1074
+ <button
1075
+ className="drawing-tool-btn"
1076
+ title="Remove selected drawing"
1077
+ onClick={onDeleteClick}
1078
+ >
1079
+ <svg viewBox="0 0 16 16" width="15" height="15" stroke="currentColor" fill="none" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round">
1080
+ <line x1="2.5" y1="4" x2="13.5" y2="4" />
1081
+ <path d="M5.5 4 V13 A1 1 0 0 0 6.5 14 H9.5 A1 1 0 0 0 10.5 13 V4" />
1082
+ <line x1="6" y1="2" x2="10" y2="2" />
1083
+ <line x1="7" y1="6.5" x2="7" y2="11.5" />
1084
+ <line x1="9" y1="6.5" x2="9" y2="11.5" />
1085
+ </svg>
1086
+ </button>
1087
+ </div>
1088
+
1089
+ <FavoritesFloatingToolbar
1090
+ favorites={favorites}
1091
+ activeTool={activeTool}
1092
+ onSelectTool={onSelectTool}
1093
+ />
1094
+ </>
1095
+ );
1096
+ }