sliced-areas 1.0.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.
@@ -0,0 +1,1067 @@
1
+ /**
2
+ * Stable identifier used by the layout graph to reference an area.
3
+ */
4
+ export type AreaId = string;
5
+ /**
6
+ * External tag used by the host to map content into areas.
7
+ */
8
+ export type AreaTag = string;
9
+ /**
10
+ * Corner identifiers used for drag docking gestures.
11
+ */
12
+ export type CornerId = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
13
+ /**
14
+ * Normalized rectangle in layout space (0..1).
15
+ */
16
+ export type AreaRect = {
17
+ left: number;
18
+ right: number;
19
+ top: number;
20
+ bottom: number;
21
+ };
22
+ /**
23
+ * Internal vertex identifier in the planar graph.
24
+ */
25
+ type VertId = string;
26
+ /**
27
+ * Internal edge identifier in the planar graph.
28
+ */
29
+ type EdgeId = string;
30
+ /**
31
+ * Graph vertex with normalized coordinates.
32
+ */
33
+ export type GraphVert = {
34
+ id: VertId;
35
+ x: number;
36
+ y: number;
37
+ };
38
+ /**
39
+ * Graph edge connecting two vertices, optionally on the border.
40
+ */
41
+ export type GraphEdge = {
42
+ id: EdgeId;
43
+ v1: VertId;
44
+ v2: VertId;
45
+ border: boolean;
46
+ };
47
+ /**
48
+ * Area represented by four ordered vertices.
49
+ */
50
+ export type GraphArea = {
51
+ id: AreaId;
52
+ v1: VertId;
53
+ v2: VertId;
54
+ v3: VertId;
55
+ v4: VertId;
56
+ };
57
+ /**
58
+ * Full planar graph for the layout.
59
+ */
60
+ export type AreasGraph = {
61
+ verts: Record<VertId, GraphVert>;
62
+ edges: Record<EdgeId, GraphEdge>;
63
+ areas: Record<AreaId, GraphArea>;
64
+ };
65
+ /**
66
+ * Serializable layout payload used by the host.
67
+ */
68
+ export type AreasLayout = {
69
+ areas: Array<{
70
+ tag: AreaTag;
71
+ rect: AreaRect;
72
+ }>;
73
+ };
74
+ /**
75
+ * Payload emitted when a corner click is detected.
76
+ */
77
+ export type CornerClickDetail = {
78
+ areaId: AreaId;
79
+ corner: CornerId;
80
+ clientX: number;
81
+ clientY: number;
82
+ };
83
+ /**
84
+ * Alias for normalized rectangle geometry.
85
+ */
86
+ type Rect = AreaRect;
87
+ /**
88
+ * Resolves host content for an area tag.
89
+ */
90
+ export type AreaResolver = (tag: AreaTag) => HTMLElement | null | undefined;
91
+ /**
92
+ * Web component implementing Blender-like area layout behavior.
93
+ */
94
+ export declare class SlicedAreasElement extends HTMLElement {
95
+ /**
96
+ * Current graph model, or null when no layout is active.
97
+ */
98
+ private graph;
99
+ /**
100
+ * Root container for generated layout nodes.
101
+ */
102
+ private rootEl;
103
+ /**
104
+ * Hidden container used to stash detached area nodes.
105
+ */
106
+ private stashEl;
107
+ /**
108
+ * Resize observer to re-render on host size changes.
109
+ */
110
+ private resizeObserver;
111
+ /**
112
+ * Active resize drag state for splitters.
113
+ */
114
+ private dragState;
115
+ /**
116
+ * Active area drag state for move/split/join/swap.
117
+ */
118
+ private areaDragState;
119
+ /**
120
+ * Last pointer position seen during area drag.
121
+ */
122
+ private lastPointer;
123
+ /**
124
+ * Overlay element used to preview drop zones.
125
+ */
126
+ private dropOverlay;
127
+ /**
128
+ * Dimmed overlay used to preview join results.
129
+ */
130
+ private dropShade;
131
+ /**
132
+ * Floating label used during drag interactions.
133
+ */
134
+ private dragLabel;
135
+ /**
136
+ * Snapshot used to revert canceled resize drags.
137
+ */
138
+ private dragSnapshot;
139
+ /**
140
+ * Cached cursor style so it can be restored.
141
+ */
142
+ private dragCursor;
143
+ /**
144
+ * Stored graph when an area is maximized.
145
+ */
146
+ private storedGraph;
147
+ /**
148
+ * Stored tag mapping when an area is maximized.
149
+ */
150
+ private storedTags;
151
+ /**
152
+ * Resolver used to materialize area content.
153
+ */
154
+ private areaResolver;
155
+ /**
156
+ * Cache of resolved area nodes by id.
157
+ */
158
+ private resolvedNodes;
159
+ /**
160
+ * Tag mapping for areas in the current graph.
161
+ */
162
+ private areaTags;
163
+ /**
164
+ * Counter for generating unique vertex ids.
165
+ */
166
+ private vertCounter;
167
+ /**
168
+ * Counter for generating unique edge ids.
169
+ */
170
+ private edgeCounter;
171
+ /**
172
+ * Counter for generating unique area ids.
173
+ */
174
+ private areaCounter;
175
+ /**
176
+ * Returns the current serialized layout.
177
+ *
178
+ * @returns Current layout or null when empty.
179
+ */
180
+ get layout(): AreasLayout | null;
181
+ /**
182
+ * Applies a serialized layout to the component.
183
+ *
184
+ * @param value Layout to apply, or null to clear.
185
+ */
186
+ set layout(value: AreasLayout | null);
187
+ /**
188
+ * Sets a resolver for auto-providing area content.
189
+ *
190
+ * @param resolver Callback for resolving an area tag to a node.
191
+ */
192
+ setResolver(resolver: AreaResolver | null): void;
193
+ /**
194
+ * Initializes internal DOM and observers when connected.
195
+ */
196
+ connectedCallback(): void;
197
+ /**
198
+ * Cleans up observers and listeners when disconnected.
199
+ */
200
+ disconnectedCallback(): void;
201
+ /**
202
+ * Splits an area by zone, optionally using a pointer position.
203
+ *
204
+ * @param sourceAreaId Area to split.
205
+ * @param zone Split direction.
206
+ * @param clientX Pointer X position.
207
+ * @param clientY Pointer Y position.
208
+ */
209
+ split(sourceAreaId: AreaId, zone?: 'left' | 'right' | 'top' | 'bottom', clientX?: number, clientY?: number): void;
210
+ /**
211
+ * Joins two adjacent areas when alignment permits.
212
+ *
213
+ * @param sourceAreaId Area being merged into the target.
214
+ * @param targetAreaId Area that remains after the join.
215
+ */
216
+ join(sourceAreaId: AreaId, targetAreaId: AreaId): void;
217
+ /**
218
+ * Replaces the target area with the source area content.
219
+ *
220
+ * @param sourceAreaId Area providing the content.
221
+ * @param targetAreaId Area to remove.
222
+ */
223
+ replace(sourceAreaId: AreaId, targetAreaId: AreaId): void;
224
+ /**
225
+ * Swaps the ids (and therefore content) between two areas.
226
+ *
227
+ * @param sourceAreaId First area id.
228
+ * @param targetAreaId Second area id.
229
+ */
230
+ swap(sourceAreaId: AreaId, targetAreaId: AreaId): void;
231
+ /**
232
+ * Moves one area into another, producing overlay and remainder areas.
233
+ *
234
+ * @param sourceAreaId Area being moved.
235
+ * @param targetAreaId Area being split to receive the move.
236
+ * @param overlay Target rectangle for the moved area.
237
+ * @param remainder Remaining rectangle for the target area.
238
+ */
239
+ move(sourceAreaId: AreaId, targetAreaId: AreaId, overlay: Rect, remainder: Rect): void;
240
+ /**
241
+ * Removes an area from the layout if possible.
242
+ *
243
+ * @param areaId Area to close.
244
+ */
245
+ close(areaId: AreaId): void;
246
+ /**
247
+ * Updates the tag for a specific area.
248
+ *
249
+ * @param areaId Area to retag.
250
+ * @param tag New tag value.
251
+ */
252
+ retag(areaId: AreaId, tag: AreaTag): void;
253
+ /**
254
+ * Maximizes a single area and stores the previous layout.
255
+ *
256
+ * @param areaId Area to maximize.
257
+ */
258
+ maximize(areaId: AreaId): void;
259
+ /**
260
+ * Restores the layout from a previous maximize action.
261
+ */
262
+ restore(): void;
263
+ /**
264
+ * Creates the root container element if it does not exist.
265
+ */
266
+ private ensureRoot;
267
+ /**
268
+ * Creates the stash container used to hold detached nodes.
269
+ */
270
+ private ensureStash;
271
+ /**
272
+ * Attaches a ResizeObserver to trigger re-rendering.
273
+ */
274
+ private ensureResizeObserver;
275
+ /**
276
+ * Emits a layout change event with serialized data.
277
+ */
278
+ private emitLayoutChange;
279
+ /**
280
+ * Emits a corner click event for docking actions.
281
+ *
282
+ * @param detail Corner click payload.
283
+ */
284
+ private emitCornerClick;
285
+ /**
286
+ * Renders the current graph into positioned DOM nodes.
287
+ */
288
+ private render;
289
+ /**
290
+ * Collects host-provided area nodes keyed by area id.
291
+ *
292
+ * @returns Map of area ids to nodes.
293
+ */
294
+ private collectAreaNodes;
295
+ /**
296
+ * Ensures a DOM node exists for a newly created area.
297
+ *
298
+ * @param newAreaId Area id needing a node.
299
+ * @param sourceAreaId Area id to clone or inherit from.
300
+ * @param cloneSource Whether to clone the source node when possible.
301
+ */
302
+ private ensureAreaNode;
303
+ /**
304
+ * Copies a tag from an existing area when creating a new one.
305
+ *
306
+ * @param newAreaId Area id to assign a tag to.
307
+ * @param sourceAreaId Area id to inherit the tag from.
308
+ */
309
+ private inheritAreaTag;
310
+ /**
311
+ * Builds a graph from a serialized layout payload.
312
+ *
313
+ * @param layout Serialized layout data.
314
+ * @returns Graph representation of the layout.
315
+ */
316
+ private buildGraphFromLayout;
317
+ /**
318
+ * Converts the graph into a serialized layout payload.
319
+ *
320
+ * @param graph Graph to serialize.
321
+ * @returns Layout payload for events.
322
+ */
323
+ private serializeLayout;
324
+ /**
325
+ * Removes tags for areas that no longer exist.
326
+ *
327
+ * @param graph Current graph for validation.
328
+ */
329
+ private pruneAreaTags;
330
+ /**
331
+ * Handles bubbled retag events from area content.
332
+ *
333
+ * @param event Retag event from child content.
334
+ */
335
+ private onRetagRequest;
336
+ /**
337
+ * Normalizes rectangles so the layout spans the unit square.
338
+ *
339
+ * @param rects Rectangles to normalize.
340
+ * @returns Normalized rectangles.
341
+ */
342
+ private normalizeRectsToUnit;
343
+ /**
344
+ * Builds a graph from normalized rectangles.
345
+ *
346
+ * @param rects Rectangles that describe areas.
347
+ * @returns Graph built from the rectangles.
348
+ */
349
+ private buildGraphFromRects;
350
+ /**
351
+ * Creates a single-area graph spanning the full layout.
352
+ *
353
+ * @param areaId Area id for the base graph.
354
+ * @returns Graph with a single area.
355
+ */
356
+ private createBaseGraph;
357
+ /**
358
+ * Splits an area by a zone using a ratio.
359
+ *
360
+ * @param graph Graph to update.
361
+ * @param areaId Area to split.
362
+ * @param zone Split direction.
363
+ * @param ratio Split ratio within the area.
364
+ * @param newAreaId Id for the new area.
365
+ * @returns Updated graph or null when split is invalid.
366
+ */
367
+ private splitAreaByZone;
368
+ /**
369
+ * Splits an area using a pointer position inside the component.
370
+ *
371
+ * @param graph Graph to update.
372
+ * @param areaId Area to split.
373
+ * @param zone Split direction.
374
+ * @param clientX Pointer X position.
375
+ * @param clientY Pointer Y position.
376
+ * @param newAreaId Id for the new area.
377
+ * @returns Updated graph or null when split is invalid.
378
+ */
379
+ private splitAreaAtPointer;
380
+ /**
381
+ * Splits an area along a coordinate on a given axis.
382
+ *
383
+ * @param graph Graph to update.
384
+ * @param areaId Area to split.
385
+ * @param axis Axis to split along.
386
+ * @param splitCoord Coordinate for the split.
387
+ * @param newAreaId Id for the new area.
388
+ * @param keep Which side keeps the original area id.
389
+ * @returns Updated graph or null when split is invalid.
390
+ */
391
+ private splitAreaAt;
392
+ /**
393
+ * Joins two areas, trimming to overlapping ranges as needed.
394
+ *
395
+ * @param graph Graph to update.
396
+ * @param areaAId First area id.
397
+ * @param areaBId Second area id.
398
+ * @returns Updated graph or null when join is invalid.
399
+ */
400
+ private joinAreas;
401
+ /**
402
+ * Trims an area to a range and records created remainder areas.
403
+ *
404
+ * @param graph Graph to update.
405
+ * @param areaId Area to trim.
406
+ * @param axis Axis to trim along.
407
+ * @param rangeStart Range start coordinate.
408
+ * @param rangeEnd Range end coordinate.
409
+ * @returns Updated graph, kept area id, and created remainders.
410
+ */
411
+ private trimAreaToRange;
412
+ /**
413
+ * Applies remainder areas created during a join.
414
+ *
415
+ * @param graph Graph to update.
416
+ * @param remainders Remainder areas created during trimming.
417
+ * @param targetAreaId Target area being joined.
418
+ * @returns Updated graph with remainders processed.
419
+ */
420
+ private processRemainders;
421
+ /**
422
+ * Replaces an area with a new rectangle in the graph.
423
+ *
424
+ * @param graph Graph to update.
425
+ * @param areaId Area to update.
426
+ * @param rect New rectangle.
427
+ * @returns Updated graph.
428
+ */
429
+ private setAreaRect;
430
+ /**
431
+ * Moves an area into an overlay region and shrinks the target.
432
+ *
433
+ * @param graph Graph to update.
434
+ * @param sourceAreaId Area being moved.
435
+ * @param targetAreaId Area receiving the move.
436
+ * @param overlay Rectangle for the moved area.
437
+ * @param remainder Rectangle for the remainder of target.
438
+ * @returns Updated graph or null when invalid.
439
+ */
440
+ private moveArea;
441
+ /**
442
+ * Replaces the target area with the source area rectangle.
443
+ *
444
+ * @param graph Graph to update.
445
+ * @param sourceAreaId Area providing the rectangle.
446
+ * @param targetAreaId Area to remove.
447
+ * @returns Updated graph or null when invalid.
448
+ */
449
+ private replaceArea;
450
+ /**
451
+ * Renames an area id and updates DOM references.
452
+ *
453
+ * @param graph Graph to update.
454
+ * @param fromId Existing area id.
455
+ * @param toId New area id.
456
+ * @returns Updated graph.
457
+ */
458
+ private renameAreaId;
459
+ /**
460
+ * Removes an area node and its cached metadata.
461
+ *
462
+ * @param areaId Area to remove.
463
+ */
464
+ private removeAreaNode;
465
+ /**
466
+ * Detaches an area node without altering tags.
467
+ *
468
+ * @param areaId Area to detach.
469
+ */
470
+ private detachAreaNode;
471
+ /**
472
+ * Joins two areas that are already aligned.
473
+ *
474
+ * @param graph Graph to update.
475
+ * @param areaAId First area id.
476
+ * @param areaBId Second area id.
477
+ * @returns Updated graph or null when join is invalid.
478
+ */
479
+ private joinAreasAligned;
480
+ /**
481
+ * Swaps the ids of two areas in the graph.
482
+ *
483
+ * @param graph Graph to update.
484
+ * @param areaAId First area id.
485
+ * @param areaBId Second area id.
486
+ * @returns Updated graph or null when invalid.
487
+ */
488
+ private swapAreaIds;
489
+ /**
490
+ * Checks whether two areas can be joined.
491
+ *
492
+ * @param areaAId First area id.
493
+ * @param areaBId Second area id.
494
+ * @returns True when join is possible.
495
+ */
496
+ private canJoin;
497
+ /**
498
+ * Checks if two areas align for a join operation.
499
+ *
500
+ * @param graph Graph containing the areas.
501
+ * @param areaA First area.
502
+ * @param areaB Second area.
503
+ * @param dir Expected orientation between areas.
504
+ * @returns True when aligned within tolerance.
505
+ */
506
+ private areAreasAligned;
507
+ /**
508
+ * Determines the orientation between two areas.
509
+ *
510
+ * @param graph Graph containing the areas.
511
+ * @param areaA First area.
512
+ * @param areaB Second area.
513
+ * @returns Orientation of areaB relative to areaA.
514
+ */
515
+ private getOrientation;
516
+ /**
517
+ * Computes alignment offsets between two areas by orientation.
518
+ *
519
+ * @param graph Graph containing the areas.
520
+ * @param areaA First area.
521
+ * @param areaB Second area.
522
+ * @param dir Orientation between the areas.
523
+ * @returns Offset values or null when invalid.
524
+ */
525
+ private getOffsets;
526
+ /**
527
+ * Builds draggable splitter handles for shared edges.
528
+ *
529
+ * @param graph Graph to inspect.
530
+ * @param width Render width in pixels.
531
+ * @param height Render height in pixels.
532
+ * @returns Array of handle elements.
533
+ */
534
+ private buildResizeHandles;
535
+ /**
536
+ * Registers an edge segment for shared edge detection.
537
+ *
538
+ * @param map Edge aggregation map.
539
+ * @param axis Axis of the edge.
540
+ * @param coord Constant coordinate for the edge.
541
+ * @param start Segment start.
542
+ * @param end Segment end.
543
+ */
544
+ private registerEdge;
545
+ /**
546
+ * Computes overlapping segments shared by at least two areas.
547
+ *
548
+ * @param segments Segments to analyze.
549
+ * @returns Shared segments.
550
+ */
551
+ private computeSharedSegments;
552
+ /**
553
+ * Handles pointer down on resize handles and drag targets.
554
+ *
555
+ * @param event Pointer event.
556
+ */
557
+ private onPointerDown;
558
+ /**
559
+ * Handles pointer movement for resize and area drag operations.
560
+ *
561
+ * @param event Pointer event.
562
+ */
563
+ private onPointerMove;
564
+ /**
565
+ * Finalizes drag operations on pointer release.
566
+ *
567
+ * @param event Pointer event.
568
+ */
569
+ private onPointerUp;
570
+ /**
571
+ * Handles key presses for drag modifiers and cancel.
572
+ *
573
+ * @param event Keyboard event.
574
+ */
575
+ private onKeyDown;
576
+ /**
577
+ * Handles key releases for drag modifiers.
578
+ *
579
+ * @param event Keyboard event.
580
+ */
581
+ private onKeyUp;
582
+ /**
583
+ * Cancels an area drag and resets UI state.
584
+ */
585
+ private cancelAreaDrag;
586
+ /**
587
+ * Cancels a resize drag and restores the snapshot.
588
+ */
589
+ private cancelResizeDrag;
590
+ /**
591
+ * Re-evaluates the area drag UI at the last pointer.
592
+ */
593
+ private refreshAreaDrag;
594
+ /**
595
+ * Sets a temporary cursor during drag operations.
596
+ *
597
+ * @param cursor CSS cursor value.
598
+ */
599
+ private setDragCursor;
600
+ /**
601
+ * Restores the cursor to its previous value.
602
+ *
603
+ * @param force Whether to restore even if no cursor is tracked.
604
+ */
605
+ private resetDragCursor;
606
+ /**
607
+ * Deep clones the graph for safe mutation.
608
+ *
609
+ * @param graph Graph to clone.
610
+ * @returns Cloned graph.
611
+ */
612
+ private cloneGraph;
613
+ /**
614
+ * Detaches pointer drag listeners.
615
+ */
616
+ private detachDragListeners;
617
+ /**
618
+ * Detaches keyboard listeners used during drag.
619
+ */
620
+ private detachKeyListener;
621
+ /**
622
+ * Starts an area drag for move/split/join actions.
623
+ *
624
+ * @param event Pointer event.
625
+ * @param areaId Source area id.
626
+ * @param corner Optional corner id for corner drag.
627
+ */
628
+ private startAreaDrag;
629
+ /**
630
+ * Updates area drag state from a pointer event.
631
+ *
632
+ * @param event Pointer event.
633
+ */
634
+ private updateAreaDrag;
635
+ /**
636
+ * Updates area drag state at a specific pointer position.
637
+ *
638
+ * @param clientX Pointer X position.
639
+ * @param clientY Pointer Y position.
640
+ */
641
+ private updateAreaDragAt;
642
+ /**
643
+ * Commits the last area drag action if valid.
644
+ */
645
+ private finishAreaDrag;
646
+ /**
647
+ * Tracks the latest drop target preview for area drag.
648
+ */
649
+ private lastDropTarget;
650
+ /**
651
+ * Shows the drop overlay for join/split/move/replace/swap.
652
+ *
653
+ * @param target Target area and rect.
654
+ * @param zone Zone to highlight.
655
+ * @param mode Drop mode being previewed.
656
+ * @param overlayRect Optional overlay rect override.
657
+ * @param direction Optional join direction.
658
+ */
659
+ private showDropOverlay;
660
+ /**
661
+ * Shows a split overlay with both resulting regions.
662
+ *
663
+ * @param target Target area and rect.
664
+ * @param zone Split zone.
665
+ * @param overlayRect Primary overlay rectangle.
666
+ */
667
+ private showSplitOverlay;
668
+ /**
669
+ * Computes overlay and remainder rectangles for move preview.
670
+ *
671
+ * @param targetRect Target area rectangle.
672
+ * @param zone Move zone.
673
+ * @param clientX Pointer X position.
674
+ * @param clientY Pointer Y position.
675
+ * @returns Overlay and remainder rectangles plus replace flag.
676
+ */
677
+ private getMovePreview;
678
+ /**
679
+ * Hides the drop overlay and clears target state.
680
+ */
681
+ private hideDropOverlay;
682
+ /**
683
+ * Shows shaded regions that would be removed after a join.
684
+ *
685
+ * @param result Resulting rectangle after join.
686
+ * @param sourceRect Source area rectangle.
687
+ * @param targetRect Target area rectangle.
688
+ */
689
+ private showJoinShade;
690
+ /**
691
+ * Hides the join shading overlay.
692
+ */
693
+ private hideJoinShade;
694
+ /**
695
+ * Displays a drag label at the pointer.
696
+ *
697
+ * @param clientX Pointer X position.
698
+ * @param clientY Pointer Y position.
699
+ * @param label Label text.
700
+ */
701
+ private showDragLabel;
702
+ /**
703
+ * Hides the drag label.
704
+ */
705
+ private hideDragLabel;
706
+ /**
707
+ * Returns the split label for a given zone.
708
+ *
709
+ * @param zone Split zone.
710
+ * @returns Label text.
711
+ */
712
+ private getSplitLabel;
713
+ /**
714
+ * Returns the join label for a given direction.
715
+ *
716
+ * @param direction Join direction.
717
+ * @returns Label text.
718
+ */
719
+ private getJoinLabel;
720
+ /**
721
+ * Finds a join target under the pointer, if any.
722
+ *
723
+ * @param sourceAreaId Source area id.
724
+ * @param clientX Pointer X position.
725
+ * @param clientY Pointer Y position.
726
+ * @returns Join target details or null.
727
+ */
728
+ private findJoinTargetAtPoint;
729
+ /**
730
+ * Computes the overlay rectangle for a join preview.
731
+ *
732
+ * @param source Source area rectangle.
733
+ * @param target Target area rectangle.
734
+ * @param orientation Orientation between the areas.
735
+ * @returns Overlay rectangle.
736
+ */
737
+ private getJoinOverlayRect;
738
+ /**
739
+ * Computes the resulting rectangle of a join.
740
+ *
741
+ * @param source Source area rectangle.
742
+ * @param target Target area rectangle.
743
+ * @param orientation Orientation between the areas.
744
+ * @returns Result rectangle.
745
+ */
746
+ private getJoinResultRect;
747
+ /**
748
+ * Subtracts a rectangle from another and returns remaining pieces.
749
+ *
750
+ * @param outer Outer rectangle.
751
+ * @param inner Inner rectangle to subtract.
752
+ * @returns Remaining rectangles.
753
+ */
754
+ private subtractRect;
755
+ /**
756
+ * Finds the area under the given pointer coordinates.
757
+ *
758
+ * @param clientX Pointer X position.
759
+ * @param clientY Pointer Y position.
760
+ * @returns Area id and rect or null when not found.
761
+ */
762
+ private findAreaAtPoint;
763
+ /**
764
+ * Resolves the move zone inside a rectangle by pointer position.
765
+ *
766
+ * @param rect Target rectangle.
767
+ * @param clientX Pointer X position.
768
+ * @param clientY Pointer Y position.
769
+ * @returns Move zone.
770
+ */
771
+ private getMoveZone;
772
+ /**
773
+ * Determines split axis from a drag gesture.
774
+ *
775
+ * @param state Area drag state.
776
+ * @param clientX Pointer X position.
777
+ * @param clientY Pointer Y position.
778
+ * @returns Gesture axis or null when undecided.
779
+ */
780
+ private resolveSplitGesture;
781
+ /**
782
+ * Determines the split zone from a resolved gesture.
783
+ *
784
+ * @param rect Target rectangle.
785
+ * @param clientX Pointer X position.
786
+ * @param clientY Pointer Y position.
787
+ * @param gesture Resolved split gesture.
788
+ * @returns Split zone.
789
+ */
790
+ private getSplitZone;
791
+ /**
792
+ * Determines the split zone given a fixed axis.
793
+ *
794
+ * @param rect Target rectangle.
795
+ * @param clientX Pointer X position.
796
+ * @param clientY Pointer Y position.
797
+ * @param axis Split axis.
798
+ * @returns Split zone.
799
+ */
800
+ private getSplitZoneByAxis;
801
+ /**
802
+ * Checks if a rectangle can be split along an axis.
803
+ *
804
+ * @param rect Target rectangle.
805
+ * @param axis Split axis.
806
+ * @returns True when split is possible.
807
+ */
808
+ private canSplitRect;
809
+ /**
810
+ * Returns the zone rectangle for previews.
811
+ *
812
+ * @param rect Target rectangle.
813
+ * @param zone Zone to extract.
814
+ * @param mode Drop mode.
815
+ * @returns Zone rectangle.
816
+ */
817
+ private getZoneRect;
818
+ /**
819
+ * Computes the overlay rectangle for a split preview.
820
+ *
821
+ * @param rect Target rectangle.
822
+ * @param zone Split zone.
823
+ * @param clientX Pointer X position.
824
+ * @param clientY Pointer Y position.
825
+ * @returns Overlay rectangle.
826
+ */
827
+ private getSplitOverlayRect;
828
+ /**
829
+ * Moves all connected vertices on an edge to a new coordinate.
830
+ *
831
+ * @param graph Graph to update.
832
+ * @param axis Axis of movement.
833
+ * @param fromCoord Current coordinate.
834
+ * @param toCoord Target coordinate.
835
+ * @param rangeStart Range start.
836
+ * @param rangeEnd Range end.
837
+ * @returns Updated graph or null when no movement.
838
+ */
839
+ private moveEdge;
840
+ /**
841
+ * Computes min/max bounds for a draggable edge segment.
842
+ *
843
+ * @param graph Graph to inspect.
844
+ * @param axis Axis of the edge.
845
+ * @param coord Edge coordinate.
846
+ * @param rangeStart Segment start.
847
+ * @param rangeEnd Segment end.
848
+ * @returns Bounds or null when invalid.
849
+ */
850
+ private getEdgeDragBounds;
851
+ /**
852
+ * Computes the rectangle for a graph area.
853
+ *
854
+ * @param graph Graph containing the area.
855
+ * @param area Area to compute.
856
+ * @returns Normalized rectangle.
857
+ */
858
+ private getAreaRect;
859
+ /**
860
+ * Adds a vertex to the vertex map.
861
+ *
862
+ * @param verts Vertex map to update.
863
+ * @param x X coordinate.
864
+ * @param y Y coordinate.
865
+ * @returns New vertex id.
866
+ */
867
+ private addVert;
868
+ /**
869
+ * Adds an edge to the edge map.
870
+ *
871
+ * @param edges Edge map to update.
872
+ * @param v1 First vertex id.
873
+ * @param v2 Second vertex id.
874
+ * @returns New edge id.
875
+ */
876
+ private addEdge;
877
+ /**
878
+ * Generates the next unique vertex id.
879
+ *
880
+ * @param verts Existing vertex map.
881
+ * @returns Unique vertex id.
882
+ */
883
+ private nextVertId;
884
+ /**
885
+ * Generates the next unique edge id.
886
+ *
887
+ * @param edges Existing edge map.
888
+ * @returns Unique edge id.
889
+ */
890
+ private nextEdgeId;
891
+ /**
892
+ * Generates the next unique area id.
893
+ *
894
+ * @returns Unique area id.
895
+ */
896
+ private nextAreaId;
897
+ /**
898
+ * Normalizes the graph and fills any holes.
899
+ *
900
+ * @param graph Graph to normalize.
901
+ * @returns Normalized graph.
902
+ */
903
+ private normalizeGraph;
904
+ /**
905
+ * Normalizes vertices and edges by merging duplicates.
906
+ *
907
+ * @param graph Graph to normalize.
908
+ * @returns Normalized graph.
909
+ */
910
+ private normalizeGraphInternal;
911
+ /**
912
+ * Attempts to fill any uncovered holes in the layout.
913
+ *
914
+ * @param graph Graph to update.
915
+ * @returns Graph with holes filled.
916
+ */
917
+ private fillHoles;
918
+ /**
919
+ * Finds uncovered grid cells in the layout.
920
+ *
921
+ * @param graph Graph to inspect.
922
+ * @returns Hole rectangles.
923
+ */
924
+ private findHoleCells;
925
+ /**
926
+ * Collects and de-duplicates axis coordinates for grid scan.
927
+ *
928
+ * @param rects Rectangles to inspect.
929
+ * @param axis Axis to collect.
930
+ * @returns Sorted coordinates.
931
+ */
932
+ private collectAxisCoords;
933
+ /**
934
+ * Merges adjacent hole cells into larger rectangles.
935
+ *
936
+ * @param cells Hole cells to merge.
937
+ * @returns Merged hole rectangles.
938
+ */
939
+ private mergeHoleCells;
940
+ /**
941
+ * Attempts to align neighbors to cover a hole.
942
+ *
943
+ * @param graph Graph to update.
944
+ * @param hole Hole rectangle.
945
+ * @returns Updated graph and change flag.
946
+ */
947
+ private tryAlignHoleNeighbors;
948
+ /**
949
+ * Collects adjacent neighbors along one side of a hole.
950
+ *
951
+ * @param graph Graph to inspect.
952
+ * @param hole Hole rectangle.
953
+ * @param side Side to check.
954
+ * @returns Neighbor areas and rectangles.
955
+ */
956
+ private collectAdjacentNeighbors;
957
+ /**
958
+ * Splits or trims a neighbor to align with a hole.
959
+ *
960
+ * @param graph Graph to update.
961
+ * @param areaId Neighbor area id.
962
+ * @param hole Hole rectangle.
963
+ * @param side Side of the hole.
964
+ * @returns Updated graph and change flag.
965
+ */
966
+ private alignNeighborToHole;
967
+ /**
968
+ * Checks if a cell is covered by any rectangle.
969
+ *
970
+ * @param rects Rectangles to check.
971
+ * @param cell Cell rectangle.
972
+ * @returns True when covered.
973
+ */
974
+ private isCellCovered;
975
+ /**
976
+ * Finds a plan to fill a hole by expanding neighbors.
977
+ *
978
+ * @param graph Graph to inspect.
979
+ * @param hole Hole rectangle.
980
+ * @returns Fill plan or null when impossible.
981
+ */
982
+ private findHoleFillPlan;
983
+ /**
984
+ * Collects neighbor areas that fully cover one side of a hole.
985
+ *
986
+ * @param graph Graph to inspect.
987
+ * @param hole Hole rectangle.
988
+ * @param side Side to check.
989
+ * @returns Neighbor data or null when none found.
990
+ */
991
+ private collectHoleNeighbors;
992
+ /**
993
+ * Checks whether a hole side is fully covered by segments.
994
+ *
995
+ * @param hole Hole rectangle.
996
+ * @param side Side to check.
997
+ * @param segments Coverage segments.
998
+ * @returns True when side is covered.
999
+ */
1000
+ private isHoleSideCovered;
1001
+ /**
1002
+ * Merges overlapping or touching segments.
1003
+ *
1004
+ * @param segments Segments to merge.
1005
+ * @returns Merged segments.
1006
+ */
1007
+ private mergeSegments;
1008
+ /**
1009
+ * Expands a rectangle into a hole from a given side.
1010
+ *
1011
+ * @param rect Neighbor rectangle.
1012
+ * @param hole Hole rectangle.
1013
+ * @param side Side to expand from.
1014
+ * @returns Expanded rectangle.
1015
+ */
1016
+ private expandRectIntoHole;
1017
+ /**
1018
+ * Detects overlapping areas in the graph.
1019
+ *
1020
+ * @param graph Graph to inspect.
1021
+ * @returns List of overlaps.
1022
+ */
1023
+ private findOverlaps;
1024
+ /**
1025
+ * Throws a detailed error for overlapping areas.
1026
+ *
1027
+ * @param graph Graph containing overlaps.
1028
+ * @param overlaps Overlap data.
1029
+ * @throws Error when overlaps are found.
1030
+ */
1031
+ private throwOverlapError;
1032
+ /**
1033
+ * Throws a detailed error for unfillable holes.
1034
+ *
1035
+ * @param graph Graph containing holes.
1036
+ * @param holes Hole rectangles.
1037
+ * @throws Error when holes are found.
1038
+ */
1039
+ private throwHoleError;
1040
+ /**
1041
+ * Formats a rectangle to fixed precision for diagnostics.
1042
+ *
1043
+ * @param rect Rectangle to format.
1044
+ * @returns Formatted rectangle.
1045
+ */
1046
+ private formatRect;
1047
+ /**
1048
+ * Collects vertices connected along a straight edge segment.
1049
+ *
1050
+ * @param graph Graph to inspect.
1051
+ * @param axis Axis of the edge.
1052
+ * @param coord Edge coordinate.
1053
+ * @param rangeStart Segment start.
1054
+ * @param rangeEnd Segment end.
1055
+ * @returns Set of connected vertex ids.
1056
+ */
1057
+ private collectConnectedVerts;
1058
+ }
1059
+ /**
1060
+ * Global tag name mapping for the custom element.
1061
+ */
1062
+ declare global {
1063
+ interface HTMLElementTagNameMap {
1064
+ 'sliced-areas': SlicedAreasElement;
1065
+ }
1066
+ }
1067
+ export {};