@n-uf/placement 26.11.46 → 26.11.48

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,74 @@
3
3
  Versions are calendar versions, `YY.M.R` (year, month of the release, counter within the month), shared with
4
4
  `@n-uf/motion`: both packages carry the same version, and a release bumps both.
5
5
 
6
+ ## 26.11.48
7
+
8
+ A place guide at every spot that says only "you can drop here", and a fix to the grab's cut (R12). With
9
+ `@n-uf/motion` 26.11.48.
10
+
11
+ Host notes:
12
+ - `LaneMark.kind` and `LandingCaseGuide.kind` gain `"hatch"`: a host with an exhaustive `switch` adds a case. A hatch is
13
+ a cue, never a measure: a striped end inside a box (`HATCH_END`), or a thin striped edge (`HATCH_EDGE`) along a band's
14
+ window side. Draw it in the guides' color, never the accent; inset boxes and ends 2 px, keep a thin edge's thickness,
15
+ and keep every guide 2 px inside the window.
16
+ - Mark ids gain suffixes: `:before` / `:after` (a room box beside the held item, a striped end's side of its box),
17
+ `#<n>` for pieces. Key drawings by id as before; don't parse them.
18
+ - As seen (no `spot`) the lifted item is drawn nowhere, so its own place is free room in its lane. Draw the held lane's
19
+ guides from `lanes()` with `spot` (a landing model's `regionsFor`), where every lane's marks lie in that spot's layout.
20
+ - Pass the press's grab to `lanes()` (both calls, as since 26.11.46): the new `landing-grip-*` rows need it.
21
+
22
+ Changes:
23
+ - `./scene`, **the grab moves no hop past a long neighbor** (fix, R12): 26.11.46 and 26.11.47 cut every pair of spots
24
+ on a bar or a toolbar rail at the grab, so a toolbar held by its grip hopped a long neighbor early on a bar and late
25
+ on a rail (the landing up to about 90 px from the pointer). Landings with a gap between them are cut halfway across
26
+ it, whatever the grab; only overlapping landings (spots a pitch apart) are cut at the grab, kept within half a pitch
27
+ of their overlap, so a pointer back at its press point still lands home.
28
+ - `./scene`, **a mark at every spot but the held one's** (fix): the room beside the held item is a box from a pitch
29
+ (was: only from the item's length, so blank); a growing item on a bar or a toolbar rail (a title filling its bar)
30
+ counts at its natural length, so its slack is marked; the lifted item's own place is free room in its lane as seen;
31
+ with a held spot whose room moves a whole edge, marks lie on the edge as drawn.
32
+ - `./scene`, **the cues** (additive kind `hatch`): room that fits is a box; room that partly fits (from a pitch,
33
+ shorter than the item) is a box with a fixed striped end inside it (`HATCH_END`) at each side whose neighbor gives
34
+ way, nothing drawn on the neighbor; room under a pitch, or none (touching items, a lane's end flush), is a 2 px line.
35
+ A panel column keeps its lines. No mark covers a docked item, the held item or a float; nothing in a refused stretch.
36
+ - `./scene`, **guides follow the layout drawn** (fix): no two edge lanes' marks overlap (at a corner a lane not drawn
37
+ gives way to a drawn one; between two not drawn the bar owns it). A virtual lane is drawn over what it would push.
38
+ - `./scene`, **`LaneOptions.emptyLanes`** (additive, `"real" | "edge"`, default `"real"`): how an empty lane is drawn.
39
+ `"real"`: a box at its real size, the band it would open (an empty side rail's lies over the column's outer strip,
40
+ which moves aside); `"edge"`: a thin striped strip (`HATCH_EDGE`) on the lane's window side (its own side where it
41
+ has one). Either way its lane (the hit strip) stays one rail wide, and its marks are cut around every item docked in
42
+ a bar or a toolbar rail: an empty lane's box never covers a toolbar.
43
+ - `./scene`, **home within half a pitch** (fix): on a bar or a toolbar rail, the item's own place is one landing for
44
+ half a pitch around it; another spot landing that near (a center dock beside a place near the bar's middle) is
45
+ home's, so away and back to the press point lands home. Panel columns are unchanged.
46
+ - `./scene`, **a rail drop strip's lane is the strip** (fix, `Scene.railDrop`): a side's rail lane was the hull of its
47
+ hit and landing, the whole column where one is docked there, over the column's own lane; it is now the strip at the
48
+ window's side (`railStripWidth`), so a plain drop in that column goes by halves (R8). It is marked `Lane.owns`
49
+ (additive): the strip owns its rect, and a landing model gives it the pointer inside it over a column it overlaps
50
+ (a flush window's), once the pointer came into it, so a panel settled in the strip lands in the rail.
51
+ - `./scene/cases`, **absolute R12 rows** (additive): `landing-grip-past-long-neighbor`, `landing-grip-across-items` and
52
+ `landing-grip-up-the-rail` slide a toolbar held by its grip past or across neighbors at 0.15 px/ms, within 48 px of
53
+ the pointer (56 on the frame before a hop, `LandingCase.moving.trailBeforeHop`, additive). They need `GRIP_SINCE`
54
+ (26.11.48): a host on an older version skips them; on 26.11.46 or 26.11.47 they fail.
55
+
56
+ ## 26.11.47
57
+
58
+ Landing rows for hosts with their own geometry, and a docs correction. No layout, target or `lanes()` change. Host
59
+ notes: a host whose window differs from a row's (its own gaps or paddings) returns `before` from `play`, its layout at
60
+ the press; without it the back-home rows compare with the row's window as before.
61
+
62
+ - `./scene/cases`, **`LandingCase.home`** and **`LandingPlay.before`** (additive): `home` checks that after the release
63
+ the item lies where it lay at the press, on the same edge, in the same order there and at the same rect, against the
64
+ play's `before` (else the row's scene as solved). `landing-back-home-bar` and `landing-back-home-rail` use it instead
65
+ of pixel values of the row's window, so a host whose rail has a gap no longer fails the rail row by that gap.
66
+ `landingIssues` takes `before` as an optional fourth argument; the reference host reports it.
67
+ - `./scene`, **`Scene.barZones`** (docs): what it does under a landing model, which the 26.11.45 notes didn't say. It
68
+ moves each zone's extent, so it changes which zone a pointer picks among `targets()` and, since a zone left with no
69
+ room gets no drop, which of a bar's drops exist and where its refused stretches lie. `lanes()` cuts between spots by
70
+ their landings, not by zones: under a landing model it changes which spots, refused stretches and place guides a
71
+ bar has, never the rule that cuts between spots (the cuts follow whichever spots exist). It is not needed for the
72
+ landing model.
73
+
6
74
  ## 26.11.46
7
75
 
8
76
  A fix for hosts on the landing model. Host notes: pass the drag's grab to `lanes()` (`{ previous, grab }`, and the
package/README.md CHANGED
@@ -999,7 +999,11 @@ what it shows and what a drag reads. A declaration, never stored.
999
999
 
1000
1000
  **Nearest bar zones.** With `Scene.barZones: "nearest"`, a bar's start, center and end zones meet halfway between the
1001
1001
  landing rects either side of each boundary, not at thirds, so the pointer picks the zone whose landing is nearest it. A
1002
- declaration, never stored.
1002
+ declaration, never stored. It moves each zone's extent: it changes which zone a pointer picks among `targets()` (what a
1003
+ drag intent reads) and, since a zone left with no room gets no drop, which of a bar's drops exist and where its refused
1004
+ stretches lie. Under a landing model `lanes()` cuts between spots by their landings, not by zones, so there it changes
1005
+ which spots and refused stretches (and so which place guides) a bar has, never the rule that cuts between spots (the
1006
+ cuts follow whichever spots exist).
1003
1007
 
1004
1008
  **Space kept on a zone's open side.** `SceneItem.space` is free space an item keeps before it in a start zone or after it
1005
1009
  in an end zone, out of the edge's spare length (shared out when items ask for more). A dock move sets it with
@@ -1021,9 +1025,11 @@ drag of `id`:
1021
1025
  moved along an occupied bar stays at the hand (within half the difference of its and its neighbor's lengths, plus
1022
1026
  the 6 px margin). Pass `options.grab`, where the pointer holds the item (its offset from the item's top left, as a
1023
1027
  target's `after(point, grab)` takes it; the press's, constant for the drag, in both calls, with and without `spot`):
1024
- on a bar or a toolbar rail along the item's own length that gap is then measured at the grab, halfway between the
1025
- points the pointer would hold in each landing (with landings of one length), so a pointer brought back to its press
1026
- point picks the item's own place however far from its middle it was pressed. Across the item, and in a lane across
1028
+ on a bar or a toolbar rail along the item's own length, two landings that overlap (spots a pitch apart) are then cut
1029
+ at the grab, halfway between the points the pointer would hold in each (with landings of one length, kept within half
1030
+ a pitch of their overlap), so a pointer brought back to its press point picks the item's own place however far from
1031
+ its middle it was pressed; landings with a gap between them (either side of a long neighbor) are cut halfway across
1032
+ it whatever the grab, so the pointer is at the landing it picks. Across the item, and in a lane across
1027
1033
  its length (a rail toolbar over a bar), the middle counts, as without a grab. Without it the item's middle is the
1028
1034
  grab, and a toolbar pressed near one end can come back to a free-stretch spot beside its own place. Panel columns cut
1029
1035
  by halves whatever the grab. One case it doesn't settle: where another lane's band overlaps the press point (an
@@ -1031,15 +1037,30 @@ drag of `id`:
1031
1037
  order. A spot's `others` keys where its drop draws every item but
1032
1038
  the held one: a change between two spots with the same key moves only the held item, so a model gates only changes
1033
1039
  between spots whose keys differ (that reflow the window).
1034
- - `marks` per lane, the place guides in the layout as drawn (the held spot's, with `options.spot`): a `line` across the
1035
- lane between two items too close for the item between them, and at a lane's end next to an item; a `box` over each
1036
- free stretch it fits in (a virtual lane: a box at its landing, a line beside it where the held item is drawn over
1037
- it). Only where a drop lands (a spot between those two items, or beside the held one), so none beside fixed chrome
1038
- nothing lands next to. Never over an item drawn on the lane, the held one included, nor a line in a refused stretch. Each mark has an
1039
- `id` (`<lane>/line/<before>|<after>`, `<lane>/box/<before>|<after>`, `^` and `$` at the ends) that stays while its
1040
- neighbors stay, so a host keys its drawing by it.
1040
+ - `marks` per lane, the place guides in the layout as drawn: a mark at every place a drop lands but the held one's.
1041
+ - A `box` over each free stretch the item fits in. Beside the held item, the room left of its stretch is a box from
1042
+ a pitch on a bar or a toolbar rail (`:before` or `:after` the item in its id, so it keeps it while the item glides).
1043
+ A growing item there (a title filling its bar) counts at its natural length, so its slack is free room.
1044
+ - Room that partly fits (from a pitch, shorter than the item) is a `box` over the free room with a fixed striped end
1045
+ inside it (`hatch`, `HATCH_END`) at each side whose neighbor gives way (`:before` or `:after` in its id); nothing
1046
+ is drawn on the neighbor. Room under a pitch, or none (touching items, a lane's end flush), is a `line`; a panel
1047
+ column keeps its lines. A hatch is a cue, never a measure of the landing.
1048
+ - An empty lane (`options.emptyLanes`): `"real"` (default) a box at its real size, the band it would open (an empty
1049
+ side rail's over a column's outer strip, which moves aside); `"edge"` a thin striped strip (`HATCH_EDGE`) on its
1050
+ window side. Either way cut around every item docked in a bar or a toolbar rail.
1051
+ - Never a box or a line over an item drawn there, nothing over the held item, nothing in a refused stretch, and no
1052
+ two edge lanes' marks overlap: at a corner a lane not drawn (an empty bar or rail) gives way to a drawn one, and
1053
+ between two not drawn the bar owns it. A virtual lane (a new column's line, a declared rail) is drawn over what it
1054
+ would push, and may overlap another lane's marks there.
1055
+ - As seen (no `spot`), the lifted item is drawn nowhere, so its own place is free room in its lane. With
1056
+ `options.spot`, every lane's marks lie in that spot's layout (the held item there, its room open, an edge moved by
1057
+ it): a host draws the held lane's guides from the `lanes()` call with `spot` (a landing model's `regionsFor`).
1058
+ - A virtual lane: a box at its landing, a line beside it where the held item is drawn over it. Only where a drop
1059
+ lands, so none beside fixed chrome nothing lands next to. Each mark has an `id` (`<lane>/line/<before>|<after>`,
1060
+ `<lane>/box/<before>|<after>`, `<lane>/hatch/<before>|<after>`, `^` and `$` at the ends, with the suffixes above)
1061
+ that stays while its neighbors stay, so a host keys its drawing by it.
1041
1062
  - `refused` stretches per lane, each at least the item's length (a shorter one joins its spots), and refused places
1042
- outside lanes;
1063
+ outside lanes, less where a lane lies (the lane takes the pointer there);
1043
1064
  - the `content`, and what `blocked` takes out of it (drawn edges, docked items, the chrome, a drawn declared rail, the
1044
1065
  scene's `blocked` spots, where a release cancels): the open space;
1045
1066
  - the stage, the `floatRegion` (the stage less the inset at its left and right, as `heldRect` keeps a held item), the
@@ -1048,7 +1069,7 @@ drag of `id`:
1048
1069
  host has every target and refusal of the lift from one call.
1049
1070
 
1050
1071
  A bar's free stretches, and a toolbar rail's (a compact edge, along its length), get spots at `SPOT_PITCH` (40 px;
1051
- `options.pitch`), each a dock keeping `space`, so a toolbar lands close to the hand; an empty bar gets them over its whole length less its padding. Where a stretch is too short for the
1072
+ `options.pitch`), each a dock keeping `space`, so a toolbar lands close to the hand; an empty bar gets them over its whole length less its padding. The item's own place is one landing for half a pitch around it, so away and back to the press point is home. Where a stretch is too short for the
1052
1073
  item, or lies next to a center item, it has none, so coverage is not universal: a point next to a center item that
1053
1074
  doesn't fit beside it can still be far from its landing (452 px at worst in the sweep scenes).
1054
1075
 
@@ -1665,8 +1686,11 @@ never shown, how far the landing may trail the pointer, or no further than the s
1665
1686
  margin), on the last frame and in the layout after the release. They cover the rail repro, the window's edge (on it
1666
1687
  and up to 48 px past it docks, beyond is nowhere), a fast pass over a bar, lane to lane at a corner, a fast hand along
1667
1688
  a free stretch and across docked items, and a toolbar taken away by one end and brought back to its press point,
1668
- which lands home. A host implements `play(row)`: its frames (`LandingCaseFrame`) and the layout
1669
- after. `runLandingCases(rows, host)` says what differs. Placement doesn't import motion, so the reference host takes
1689
+ which lands home. A host implements `play(row)`: its frames (`LandingCaseFrame`), the layout after and, where its
1690
+ geometry differs from the row's window (its own gaps or paddings), `before`, its layout at the press (taken before the
1691
+ pointer moves, never after the release): a row's `home` (the item ends where it lay at the press: same edge, same order,
1692
+ same rect) compares with it, so no pixel value of the row's window is asserted. `runLandingCases(rows, host)` says what
1693
+ differs. Placement doesn't import motion, so the reference host takes
1670
1694
  the model as an input, as the scene host takes the pick rule:
1671
1695
 
1672
1696
  ```ts
@@ -1682,7 +1706,10 @@ expect(lanesRatchet({ skipped, baseline: 0, today: new Date().toISOString().slic
1682
1706
  Every landing row carries `requires: { lanes: { since } }`: `LANES_SINCE`, the first version with `lanes()` (26.11.45;
1683
1707
  26.11.21 to 26.11.44, `LAST_WITHOUT_LANES`, shipped without it), or a later one where the row needs more: the rows
1684
1708
  that bring an item back to its press point need `GRAB_SINCE` (26.11.46, `lanes()` taking the grab), and pass only on a
1685
- host that passes its grab to `lanes()`. A host that says it runs an older `version` skips a row. The skipped count is a ratchet (`lanesRatchet`): it may not exceed the
1709
+ host that passes its grab to `lanes()`; the rows that slide a toolbar held by its grip past or across neighbors, on a
1710
+ bar and up a rail (`landing-grip-*`), need `GRIP_SINCE` (26.11.48, the grab moving no hop past a long neighbor) and
1711
+ bound the landing absolutely: within `moving.trail` (48 px) of the pointer, `moving.trailBeforeHop` (56) on the single
1712
+ frame before a hop (R12). A host that says it runs an older `version` skips a row. The skipped count is a ratchet (`lanesRatchet`): it may not exceed the
1686
1713
  baseline the host's suite recorded, and from `LANES_DEADLINE` (2026-12-31) or at the breaking release, whichever comes
1687
1714
  first, every row runs.
1688
1715
 
@@ -2145,7 +2145,7 @@ function context(scene, dragged, options, others = []) {
2145
2145
  const item = Object.hasOwn(scene.items, dragged) ? scene.items[dragged] : void 0;
2146
2146
  if (!item || item.fixed || item.closed) return null;
2147
2147
  const prev = { ...options.previous ? { previous: options.previous } : {}, ...options.fresh ? { fresh: options.fresh } : {} };
2148
- const settle = (s) => ({ scene: s, layout: solve(s, prev) });
2148
+ const settle2 = (s) => ({ scene: s, layout: solve(s, prev) });
2149
2149
  const now = solve(scene, prev);
2150
2150
  const rest = lift(scene, dragged);
2151
2151
  const base = solve(rest, prev);
@@ -2159,7 +2159,7 @@ function context(scene, dragged, options, others = []) {
2159
2159
  dragged,
2160
2160
  kind: item.kind,
2161
2161
  reach: Math.max(0, Number.isFinite(options.endReach) ? options.endReach : 0),
2162
- settle,
2162
+ settle: settle2,
2163
2163
  isHome: (r) => placeKey(r.scene, dragged) === here,
2164
2164
  sound: soundness(scene, base, dragged),
2165
2165
  lay: layKeys(scene)
@@ -3323,8 +3323,14 @@ function lanes(scene, dragged, options = {}) {
3323
3323
  if (!found) return { ...base.regions, lanes: base.lanes };
3324
3324
  const [heldLane, list] = found;
3325
3325
  const held = list.find((r) => r.id === options.spot);
3326
- const lane = laneFrom(heldLane, list, held.layout, base.seen, dragged, base.refusals, base.halves.has(heldLane), base.share);
3327
- return { ...base.regions, lanes: base.lanes.map((l) => l.id === heldLane && lane ? lane : l) };
3326
+ const rebuilt = base.lanes.map((l) => {
3327
+ const raws = base.raws.get(l.id);
3328
+ if (!raws) return l;
3329
+ const again = laneFrom(l.id, raws, held.layout, base.seen, dragged, base.refusals, base.halves.has(l.id), base.share, base.marking, l.id === heldLane);
3330
+ if (!again) return l;
3331
+ return l.id === heldLane ? again : { ...l, marks: again.marks };
3332
+ });
3333
+ return { ...base.regions, lanes: rebuilt.map((l) => settle(l, held.layout, scene, dragged, rebuilt, options.emptyLanes)) };
3328
3334
  }
3329
3335
  function build(scene, dragged, options) {
3330
3336
  const seen = solve(scene, options.previous ? { previous: options.previous } : {});
@@ -3356,18 +3362,28 @@ function build(scene, dragged, options) {
3356
3362
  const landing = layout.items[dragged]?.rect;
3357
3363
  if (!landing) continue;
3358
3364
  const lane = p.kind === "column" ? `column:${p.side}:${columnKey(p.side, p.ring)}` : `rail:${p.side}`;
3359
- raws.push({ lane, edge: null, axis: "y", id: `${lane}/${p.kind === "rail" ? "end" : "line"}`, before: "^", next: "$", landing, layout, target: t, hit: t.hit });
3365
+ const strip = p.kind === "rail" && t.strip ? t.strip : void 0;
3366
+ raws.push({ lane, edge: null, axis: "y", id: `${lane}/${p.kind === "rail" ? "end" : "line"}`, before: "^", next: "$", landing, layout, target: t, hit: strip ?? t.hit, ...strip ? { strip: true } : {} });
3360
3367
  }
3361
3368
  }
3362
3369
  if (pitch > 0) raws.push(...pitchedSpots(scene, dragged, options, seen, raws, pitch));
3363
3370
  const byLane = /* @__PURE__ */ new Map();
3364
3371
  for (const r of raws) byLane.set(r.lane, [...byLane.get(r.lane) ?? [], r]);
3365
3372
  const halves = new Set(scene.edges.filter((e) => (e.side === "left" || e.side === "right") && !e.compact).map((e) => e.id));
3373
+ const marking = {
3374
+ pitch,
3375
+ natural: (id, axis) => {
3376
+ const main = scene.items[id]?.forms[axis === "x" ? "row" : "column"]?.[0]?.main;
3377
+ return main?.grows ? main.natural : void 0;
3378
+ },
3379
+ gap: (edge) => nonNeg(scene.edges.find((e) => e.id === edge)?.gap)
3380
+ };
3366
3381
  const shareOf = (g, size) => g === void 0 || !Number.isFinite(g) || size <= EPS ? 0.5 : clamp(g / size, 0, 1);
3367
3382
  const w = own?.rect.width ?? 0;
3368
3383
  const h = own?.rect.height ?? 0;
3369
3384
  const share = { x: w >= h ? shareOf(options.grab?.x, w) : 0.5, y: h > w ? shareOf(options.grab?.y, h) : 0.5 };
3370
- const laneList = [...byLane].map(([id, list]) => laneFrom(id, list, seen, seen, dragged, rs, halves.has(id), share)).filter((l) => !!l);
3385
+ const built = [...byLane].map(([id, list]) => laneFrom(id, list, seen, seen, dragged, rs, halves.has(id), share, marking)).filter((l) => !!l);
3386
+ const laneList = built.map((l) => settle(l, seen, scene, dragged, built, options.emptyLanes));
3371
3387
  const onLanes = new Set(laneList.map((l) => l.id));
3372
3388
  const rails = Object.values(seen.rails).flatMap((r) => r && r.rect.width > EPS && r.rect.height > EPS ? [r.rect] : []);
3373
3389
  const blocked = [
@@ -3385,6 +3401,7 @@ function build(scene, dragged, options) {
3385
3401
  refusals: rs,
3386
3402
  halves,
3387
3403
  share,
3404
+ marking,
3388
3405
  regions: {
3389
3406
  refused: rs.filter((f) => !onLanes.has(f.edge)).flatMap((f) => f.hits ?? [f.hit]),
3390
3407
  content: seen.content,
@@ -3397,7 +3414,7 @@ function build(scene, dragged, options) {
3397
3414
  }
3398
3415
  };
3399
3416
  }
3400
- function laneFrom(id, list, drawn, seen, dragged, rs, halves, share) {
3417
+ function laneFrom(id, list, drawn, seen, dragged, rs, halves, share, marking, heldHere = false) {
3401
3418
  if (list.length === 0) return null;
3402
3419
  const first = list[0];
3403
3420
  const axis = first.axis;
@@ -3406,9 +3423,12 @@ function laneFrom(id, list, drawn, seen, dragged, rs, halves, share) {
3406
3423
  let laneRect;
3407
3424
  if (edgeLayout && edgeLayout.cross > EPS) laneRect = edgeLayout.rect;
3408
3425
  else if (edgeLayout) laneRect = axis === "x" ? rect(edgeLayout.rect.x, band.y, edgeLayout.rect.width, band.height) : rect(band.x, edgeLayout.rect.y, band.width, edgeLayout.rect.height);
3426
+ else if (list.every((r) => r.strip)) laneRect = list.map((r) => r.hit).reduce(hull2);
3409
3427
  else laneRect = list.map((r) => r.hit).reduce(hull2, band);
3410
3428
  const sorted = [...list].sort((a, b) => mid(a.landing, axis) - mid(b.landing, axis) || (a.home ? -1 : b.home ? 1 : 0));
3411
- const unique = sorted.filter((x, i) => !sorted.slice(0, i).some((y) => sameRect(y.landing, x.landing) || y.id === x.id));
3429
+ const homeAt = halves ? void 0 : list.find((r) => r.home)?.landing;
3430
+ const nearHome = (r) => !!homeAt && !r.home && Math.abs(lo(r.landing, axis) - lo(homeAt, axis)) < Math.max(0, marking.pitch) / 2;
3431
+ const unique = sorted.filter((x, i) => !nearHome(x) && !sorted.slice(0, i).some((y) => sameRect(y.landing, x.landing) || y.id === x.id));
3412
3432
  const start = lo(laneRect, axis);
3413
3433
  const end = start + len(laneRect, axis);
3414
3434
  const drawnItems = first.edge && halves ? new Map(onEdge(drawn, first.edge, dragged, axis).map((o) => [o.id, o.r])) : /* @__PURE__ */ new Map();
@@ -3418,7 +3438,12 @@ function laneFrom(id, list, drawn, seen, dragged, rs, halves, share) {
3418
3438
  const a = unique[i];
3419
3439
  const b = unique[i + 1];
3420
3440
  const shared = a.next === b.before && a.next !== "$" ? drawnItems.get(a.next) : void 0;
3421
- const raw = shared ? mid(shared, axis) : (lo(a.landing, axis) + len(a.landing, axis) + lo(b.landing, axis)) / 2 + (held - 0.5) * (len(a.landing, axis) + len(b.landing, axis)) / 2;
3441
+ const aEnd = lo(a.landing, axis) + len(a.landing, axis);
3442
+ const across2 = (aEnd + lo(b.landing, axis)) / 2;
3443
+ const overlap = lo(b.landing, axis) < aEnd - EPS;
3444
+ const slack = Math.max(0, marking.pitch) / 2;
3445
+ const atGrab = clamp(across2 + (held - 0.5) * (len(a.landing, axis) + len(b.landing, axis)) / 2, lo(b.landing, axis) - slack, aEnd + slack);
3446
+ const raw = shared ? mid(shared, axis) : overlap ? atGrab : across2;
3422
3447
  cuts.push(clamp(Math.max(raw, cuts[i - 1] ?? start), start, end));
3423
3448
  }
3424
3449
  const spots = unique.map((x, i) => ({
@@ -3433,12 +3458,37 @@ function laneFrom(id, list, drawn, seen, dragged, rs, halves, share) {
3433
3458
  const itemLen = Math.min(...unique.map((x) => len(x.landing, axis)));
3434
3459
  const refused = first.edge ? rs.filter((f) => f.edge === first.edge).flatMap((f) => (f.hits ?? [f.hit]).map((h) => ({ along: [clamp(lo(h, axis), start, end), clamp(lo(h, axis) + len(h, axis), start, end)], reason: f.reason }))).filter((f) => f.along[1] - f.along[0] >= itemLen - EPS) : [];
3435
3460
  const places = new Set(unique.map((x) => `${x.before}|${x.next}`));
3436
- const marks = first.edge ? edgeMarks(id, laneRect, axis, onEdge(drawn, first.edge, "", axis), refused, itemLen, (pair) => places.has(pair) || pair.split("|").includes(dragged), dragged) : virtualMarks(id, unique, drawn.items[dragged]);
3437
- return { id, rect: laneRect, axis, spots, refused, marks };
3461
+ const drawnEdge = first.edge ? drawn.edges[first.edge] : void 0;
3462
+ const markRect = drawnEdge && drawnEdge.cross > EPS ? drawnEdge.rect : laneRect;
3463
+ const marked = first.edge ? onEdge(drawn, first.edge, heldHere ? "" : dragged, axis).map((o) => {
3464
+ const n = o.id === dragged || halves ? void 0 : marking.natural(o.id, axis);
3465
+ return n !== void 0 && n < len(o.r, axis) ? { ...o, r: along(o.r, axis, lo(o.r, axis), lo(o.r, axis) + n) } : o;
3466
+ }) : [];
3467
+ const landings = /* @__PURE__ */ new Map();
3468
+ if (!halves) {
3469
+ for (const x of unique) if (!x.pitched && !x.home && !landings.has(`${x.before}|${x.next}`)) landings.set(`${x.before}|${x.next}`, { landing: x.landing, layout: x.layout });
3470
+ }
3471
+ const extent = (iid, r) => {
3472
+ const n = halves ? void 0 : marking.natural(iid, axis);
3473
+ return [lo(r, axis), lo(r, axis) + (n !== void 0 && n < len(r, axis) ? n : len(r, axis))];
3474
+ };
3475
+ const marks = first.edge ? edgeMarks(id, markRect, axis, marked, refused, itemLen, (pair) => places.has(pair) || pair.split("|").includes(dragged), dragged, {
3476
+ besideMin: halves || marking.pitch <= 0 ? itemLen : marking.pitch,
3477
+ gap: marking.gap(first.edge),
3478
+ landingOf: (pair) => landings.get(pair),
3479
+ extent
3480
+ }) : virtualMarks(id, unique, drawn.items[dragged]);
3481
+ return { id, rect: laneRect, axis, spots, refused, marks, ...list.every((r) => r.strip) ? { owns: true } : {} };
3438
3482
  }
3439
3483
  var along = (r, axis, a, b) => axis === "x" ? rect(a, r.y, b - a, r.height) : rect(r.x, a, r.width, b - a);
3440
3484
  var LINE2 = 2;
3441
- function edgeMarks(lane, laneRect, axis, items, refused, itemLen, lands, held) {
3485
+ var MIN_BOX = 8;
3486
+ var HATCH_END = 8;
3487
+ var HATCH_EDGE = 8;
3488
+ function edgeMarks(lane, laneRect, axis, items, refused, itemLen, lands, held, more) {
3489
+ const { besideMin } = more;
3490
+ const heldAt = items.find((o) => o.id === held);
3491
+ const heldSpan = heldAt ? [lo(heldAt.r, axis), lo(heldAt.r, axis) + len(heldAt.r, axis)] : null;
3442
3492
  const out = [];
3443
3493
  const start = lo(laneRect, axis);
3444
3494
  const end = start + len(laneRect, axis);
@@ -3452,7 +3502,38 @@ function edgeMarks(lane, laneRect, axis, items, refused, itemLen, lands, held) {
3452
3502
  const left = ends[i].id === held ? ends[i - 1]?.id ?? "^" : ends[i].id;
3453
3503
  const right = ends[i + 1].id === held ? ends[i + 2]?.id ?? "$" : ends[i + 1].id;
3454
3504
  const named = `${left}|${right}`;
3455
- if (b - a < itemLen - EPS) {
3505
+ const beside = ends[i + 1].id === held ? "before" : ends[i].id === held ? "after" : null;
3506
+ const min = beside ? Math.min(itemLen, besideMin) : itemLen;
3507
+ if (b - a < min - EPS) {
3508
+ const spot = !beside && named === pair && items.length > 0 && !isRefused2((a + b) / 2) && b - a >= besideMin - EPS ? more.landingOf(pair) : void 0;
3509
+ if (spot) {
3510
+ const own = (iid) => {
3511
+ const it = spot.layout.items[iid];
3512
+ return it && !it.inMenu && !it.floating && it.edge === lane ? more.extent(iid, it.rect) : null;
3513
+ };
3514
+ let gl = left !== "^" && (() => {
3515
+ const o = own(left);
3516
+ return !o || a - o[1] > 0.5;
3517
+ })();
3518
+ let gr = right !== "$" && (() => {
3519
+ const o = own(right);
3520
+ return !o || o[0] - b > 0.5;
3521
+ })();
3522
+ if (!gl && !gr) {
3523
+ if (right !== "$") gr = true;
3524
+ else if (left !== "^") gl = true;
3525
+ }
3526
+ let ps = [[a, b]];
3527
+ for (const f of refused) ps = ps.flatMap(([p, q]) => [[p, Math.min(q, f.along[0])], [Math.max(p, f.along[1]), q]]);
3528
+ if (heldSpan) ps = ps.flatMap(([p, q]) => [[p, Math.min(q, heldSpan[0])], [Math.max(p, heldSpan[1]), q]]);
3529
+ ps = ps.filter(([p, q]) => q - p >= MIN_BOX - EPS);
3530
+ ps.forEach(([p, q], k2) => {
3531
+ out.push({ id: `${lane}/box/${pair}${k2 ? `#${k2}` : ""}`, kind: "box", rect: along(laneRect, axis, p, q) });
3532
+ if (gl && Math.abs(p - a) < EPS) out.push({ id: `${lane}/hatch/${pair}:before`, kind: "hatch", rect: along(laneRect, axis, p, p + Math.min(HATCH_END, (q - p) / 2)) });
3533
+ if (gr && Math.abs(q - b) < EPS) out.push({ id: `${lane}/hatch/${pair}:after`, kind: "hatch", rect: along(laneRect, axis, q - Math.min(HATCH_END, (q - p) / 2), q) });
3534
+ });
3535
+ if (ps.length > 0) continue;
3536
+ }
3456
3537
  const t = Math.max(0, Math.min(LINE2, b - a)) / 2;
3457
3538
  if (items.length > 0 && named === pair && !isRefused2((a + b) / 2)) out.push({ id: `${lane}/line/${pair}`, kind: "line", rect: along(laneRect, axis, (a + b) / 2 - t, (a + b) / 2 + t) });
3458
3539
  continue;
@@ -3461,8 +3542,8 @@ function edgeMarks(lane, laneRect, axis, items, refused, itemLen, lands, held) {
3461
3542
  for (const f of refused) pieces = pieces.flatMap(([p, q]) => [[p, Math.min(q, f.along[0])], [Math.max(p, f.along[1]), q]]).filter(([p, q]) => q - p > EPS);
3462
3543
  let k = 0;
3463
3544
  for (const [p, q] of pieces) {
3464
- if (q - p < itemLen - EPS) continue;
3465
- const base = `${lane}/box/${named}${k++ ? `#${k - 1}` : ""}`;
3545
+ if (q - p < min - EPS) continue;
3546
+ const base = `${lane}/box/${named}${beside ? `:${beside}` : ""}${k++ ? `#${k - 1}` : ""}`;
3466
3547
  out.push({ id: out.some((m) => m.id === base) ? `${base}~2` : base, kind: "box", rect: along(laneRect, axis, p, q) });
3467
3548
  }
3468
3549
  }
@@ -3476,6 +3557,66 @@ function virtualMarks(lane, spots, held) {
3476
3557
  return { id: `${lane}/line/${s.id}`, kind: "line", rect: rect(x, l.y, 0, l.height) };
3477
3558
  });
3478
3559
  }
3560
+ function settle(l, drawn, scene, dragged, all, emptyLanes = "real") {
3561
+ const edgeOf = (id) => scene.edges.find((e) => e.id === id);
3562
+ const isDrawn = (id) => !!edgeOf(id) && (drawn.edges[id]?.cross ?? 0) > EPS;
3563
+ const across2 = (side) => side === "top" || side === "bottom" ? "x" : "y";
3564
+ const cuts = [];
3565
+ if (!isDrawn(l.id)) {
3566
+ for (const e of scene.edges) {
3567
+ const de = drawn.edges[e.id];
3568
+ if (e.id !== l.id && de && de.cross > EPS && across2(e.side) !== l.axis) cuts.push(de.rect);
3569
+ }
3570
+ if (l.axis === "y") {
3571
+ for (const o of all) if (o.id !== l.id && o.axis === "x" && !isDrawn(o.id)) cuts.push(o.rect);
3572
+ }
3573
+ }
3574
+ const empty = !isDrawn(l.id);
3575
+ const barOrRail = (edge) => {
3576
+ const e = edge ? edgeOf(edge) : void 0;
3577
+ return !!e && (e.side === "top" || e.side === "bottom" || !!e.compact);
3578
+ };
3579
+ const stays = empty ? Object.entries(drawn.items).filter(([id, it]) => id !== dragged && it.edge !== l.id && barOrRail(it.edge) && !it.floating && !it.inMenu && it.rect.width > EPS && it.rect.height > EPS).map(([, it]) => it.rect) : [];
3580
+ if (cuts.length === 0 && !(empty && (emptyLanes === "edge" || l.marks.some((m) => m.kind === "box" && stays.some((s) => overlaps3(m.rect, s)))))) return l;
3581
+ const span = (r) => [lo(r, l.axis), lo(r, l.axis) + len(r, l.axis)];
3582
+ const crosses = (r, c) => l.axis === "x" ? c.y < r.y + r.height - EPS && r.y < c.y + c.height - EPS : c.x < r.x + r.width - EPS && r.x < c.x + c.width - EPS;
3583
+ const cut2 = (r, cs) => {
3584
+ let ps = [span(r)];
3585
+ for (const c of cs) {
3586
+ if (!crosses(r, c)) continue;
3587
+ const [c0, c1] = span(c);
3588
+ ps = ps.flatMap(([p, q]) => [[p, Math.min(q, c0)], [Math.max(p, c1), q]]).filter(([p, q]) => q - p > EPS);
3589
+ }
3590
+ return ps;
3591
+ };
3592
+ const marks = [];
3593
+ for (const m of l.marks) {
3594
+ const kept = cut2(m.rect, m.kind === "box" ? [...cuts, ...stays] : cuts);
3595
+ if (m.kind === "line") {
3596
+ if (kept.length === 1 && Math.abs(kept[0][1] - kept[0][0] - len(m.rect, l.axis)) < EPS) marks.push(m);
3597
+ continue;
3598
+ }
3599
+ kept.forEach(([p, q], i) => {
3600
+ const piece = along(m.rect, l.axis, p, q);
3601
+ const id = i ? `${m.id}~c${i}` : m.id;
3602
+ if (m.kind !== "box" || !empty || emptyLanes === "real") return void marks.push({ ...m, id, rect: piece });
3603
+ const side = edgeOf(l.id)?.side ?? (/^(rail|column):/.test(l.id) ? l.id.split(":")[1] : void 0);
3604
+ const st = scene.stage;
3605
+ let r;
3606
+ if (l.axis === "y") {
3607
+ const outerRight = side === "right" ? true : side === "left" ? false : Math.abs(piece.x + piece.width - (st.x + st.width)) <= Math.abs(piece.x - st.x);
3608
+ const t = Math.min(HATCH_EDGE, piece.width);
3609
+ r = rect(outerRight ? piece.x + piece.width - t : piece.x, piece.y, t, piece.height);
3610
+ } else {
3611
+ const outerBottom = side === "bottom" ? true : side === "top" ? false : Math.abs(piece.y + piece.height - (st.y + st.height)) <= Math.abs(piece.y - st.y);
3612
+ const t = Math.min(HATCH_EDGE, piece.height);
3613
+ r = rect(piece.x, outerBottom ? piece.y + piece.height - t : piece.y, piece.width, t);
3614
+ }
3615
+ marks.push({ id: id.replace("/box/", "/hatch/"), kind: "hatch", rect: r });
3616
+ });
3617
+ }
3618
+ return { ...l, marks };
3619
+ }
3479
3620
  var overlaps3 = (a, b) => a.x < b.x + b.width - EPS && b.x < a.x + a.width - EPS && a.y < b.y + b.height - EPS && b.y < a.y + a.height - EPS;
3480
3621
  function pitchedSpots(scene, dragged, options, seen, raws, pitch) {
3481
3622
  const out = [];
@@ -3598,6 +3739,8 @@ export {
3598
3739
  refusalTargets,
3599
3740
  stops,
3600
3741
  SPOT_PITCH,
3601
- lanes
3742
+ lanes,
3743
+ HATCH_END,
3744
+ HATCH_EDGE
3602
3745
  };
3603
- //# sourceMappingURL=chunk-A4DQQX7W.js.map
3746
+ //# sourceMappingURL=chunk-IDWMDPY7.js.map