@n-uf/placement 26.11.28 → 26.11.29

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,26 @@
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.29
7
+
8
+ - `./scene`, **rail docking per item kind** (additive; a kind with no policy targets exactly as before):
9
+ - **`Scene.railDrop`**: per kind (the scene's own kind strings), a **`RailDropPolicy`**: `railStripWidth` (default
10
+ the rail's drawn width, at least `RAIL_STRIP_MIN`, 24; 0 turns it off), `railVisibility` (`RailVisibility`:
11
+ `"whileDragging"`, the default, `"always"`, `"never"`, which turns it off; `RAIL_VISIBILITIES` lists them),
12
+ `magnet` (default `DEFAULT_RAIL_MAGNET`, 6 px) and `floatNearEdge` (default true).
13
+ - Each side whose rail takes the kind gets one drop strip at the window's side, even while the rail is empty:
14
+ `rail:<side>:<ring>` targets with `arm: "dwell"` (spring-loading, armed by the drag intent's dwell), `armedHit`
15
+ (the strip grown by the magnet) and `strip` (the rect to draw). The strip owns its rect, home's included; an empty
16
+ column's drop strip moves just inside it. `Target` gains `arm` and `armedHit`, `SceneTarget` gains `strip`.
17
+ - **The side's rail is one concept.** On a side with no declared rail (`Scene.rails`), it is the side's outermost
18
+ column that takes the kind in its start zone ("the column drawn as a rail"): `moveTo(scene, id, { kind: "rail",
19
+ side, ring })` now docks the item at the end of that column's start zone as a collapsed header (folded by hand; a
20
+ rail tile once nothing there sets the width; it was a no-op there), and `stops` lists it for "Move to › Rail".
21
+ - **The strip means "collapse it at this side"**, on every side whose rail takes the kind, whether a rail is drawn
22
+ or not: the drop is `moveTo` that side's rail, landing wherever the scene shows a collapsed panel there (a rail
23
+ tile; under `handFold: "ride"` a rider bar over the side's open column; a header). The slot is that landing.
24
+ - `floatNearEdge: false` keeps a float's landing clear of every strip.
25
+
6
26
  ## 26.11.28
7
27
 
8
28
  - Notes for hosts:
package/README.md CHANGED
@@ -1102,7 +1102,7 @@ facing halves is home's, and is no target of its own. The slot is where the item
1102
1102
  flush after the side's outside toolbar bars), landing where the rail lands. The outermost column line starts where
1103
1103
  it ends. A rail stop takes its place at the side's edge only where one of its slots lands (home's counts); when the
1104
1104
  rail would be covered (every stop refused, a panel riding over it), the outermost column line is laid from the
1105
- window's edge instead.
1105
+ window's edge instead. For a kind with a rail drop policy, the rail is a spring-loaded drop strip instead (below).
1106
1106
  - `none:<i>` (1) over each `scene.blocked` rect, and `home:<id>` (1) over a docked item's own rect: a release there
1107
1107
  commits nothing. A floating item has no home, so a move inside its own rect is a float move. A gap, column line or rail
1108
1108
  drop that would put the item back where it is (the gap beside it, its own column's line) keeps its id but is a home
@@ -1180,6 +1180,32 @@ with `targetId(parts)`, so it never splits strings (an edge id may hold `:`):
1180
1180
  | `placeTargetId(place, item)` | The id `targets` gives the target at a `ScenePlace` (null for `none`). |
1181
1181
  | `virtualEdgeId(kind, side)` | `column:<side>` or `rail:<side>`: the virtual edge a refusal names in `edge`. |
1182
1182
 
1183
+ **Rail docking: a drop strip per kind (`Scene.railDrop`).** A side's rail is one concept: the strip where its collapsed
1184
+ panels show. Where the scene declares it (`Scene.rails[side]`) it is that rail; where it doesn't, it is the side's
1185
+ outermost column that takes the kind in its start zone, drawn as a rail once nothing in it sets its width. A kind with
1186
+ a `RailDropPolicy` reaches it through one drop strip per side, at the window's side, at the rail's real width, even
1187
+ while the rail is empty: its targets are `rail:<side>:<ring>` with `arm: "dwell"`, `armedHit` and `strip`. The drop
1188
+ means "collapse it at this side" and is offered on every side whose rail takes the kind, whether a rail is drawn now or
1189
+ not: it is the same change as "Move to › Rail", `moveTo(scene, id, { kind: "rail", side, ring })`, and lands wherever
1190
+ the scene shows a collapsed panel there. With a rail drawn that is a rail tile; under `handFold: "ride"`, with the
1191
+ side's column open, a rider bar over it; on a side without a declared rail, `moveTo` puts the item at the end of the
1192
+ side's outermost column's start zone as a collapsed header ("the column drawn as a rail"), a rail tile once nothing
1193
+ in that column sets its width. The slot is that landing, so the preview is the drop. The strip
1194
+ owns its rect: every other target and refusal of the drag gives it up, home's included (an item alone in its column
1195
+ reaches its side's rail from its own place), and an empty column's own drop strip moves just inside it. Before the
1196
+ strip arms, a drop there is the float's. A kind with no policy keeps its targets exactly as before; tuning one kind
1197
+ never changes another. The policy's fields, each default with its reason:
1198
+
1199
+ | Field | Default | Why |
1200
+ |---|---|---|
1201
+ | `railStripWidth` | the rail's drawn width, at least `RAIL_STRIP_MIN` (24) | A target at the window's edge is easy to hit when it is wide enough to aim at (Fitts's law); the rail's own width keeps the strip where the panel will land. `0` turns the kind's rail docking off. |
1202
+ | `railVisibility` | `"whileDragging"` | A drop target shows while it can be used. `"always"` draws it at rest too; `"never"` turns rail docking off. |
1203
+ | `magnet` | `DEFAULT_RAIL_MAGNET` (6 px) | Once armed, the strip grows inward so a hand that wobbles keeps it: that grown strip (`armedHit`) is the armed target's band. Moving out past its outer edge disarms it, and re-entering needs a new full dwell. A host draws the growth with no animation under `prefers-reduced-motion: reduce`. |
1204
+ | `floatNearEdge` | `true` | Before the strip arms, a float may sit near the window's edge, as it may anywhere; `false` keeps a float's rect clear of every strip. |
1205
+
1206
+ The time and the keys are the drag intent's (`@n-uf/motion/drag`): `railArmDwellMs` (200 ms) arms a target marked
1207
+ `arm: "dwell"` (spring-loading), and `modifiers` let Shift float anywhere and Alt collapse into the nearest rail.
1208
+
1183
1209
  A gap, column or rail target exists only where the drop keeps the whole scene sound (C29): it adds no `overflow` or
1184
1210
  `too-wide` note to any edge, changes no fixed item's form, squeezes none under its `main.min` anywhere (a between bar
1185
1211
  under a new column included), and lands its slot on no chrome. The rule compares notes: in an edge that already
@@ -23,6 +23,9 @@ import {
23
23
  var SIDES = ["top", "right", "bottom", "left"];
24
24
  var ZONES = ["start", "center", "end"];
25
25
  var RAIL_MODES = ["titles", "icons"];
26
+ var RAIL_VISIBILITIES = ["whileDragging", "always", "never"];
27
+ var RAIL_STRIP_MIN = 24;
28
+ var DEFAULT_RAIL_MAGNET = 6;
26
29
  var DEFAULT_STRIP = 24;
27
30
  var DEFAULT_HIT_BAND = 24;
28
31
  var DEFAULT_FLOAT_SIZE = { width: 280, height: 360 };
@@ -47,6 +50,23 @@ var columnFromTemplate = (t, id, side, ring, items) => ({
47
50
  });
48
51
  var railModeOf = (scene, side) => side === "left" || side === "right" ? scene.railModes?.[side] === "icons" ? "icons" : "titles" : "icons";
49
52
  var axisOf = (side) => side === "left" || side === "right" ? "column" : "row";
53
+ function railColumnOf(scene, side, kind) {
54
+ if (scene.rails?.[side]) return void 0;
55
+ return scene.edges.filter((e) => e.side === side && !e.compact && zoneTakes(e, "start", kind)).reduce((m, e) => !m || e.ring < m.ring ? e : m, void 0);
56
+ }
57
+ function railPolicyOf(scene, kind) {
58
+ const p = Object.hasOwn(scene.railDrop ?? {}, kind) ? scene.railDrop[kind] : void 0;
59
+ if (!p) return null;
60
+ const visibility = p.railVisibility === "always" || p.railVisibility === "never" ? p.railVisibility : "whileDragging";
61
+ const width = p.railStripWidth;
62
+ if (visibility === "never" || width !== void 0 && !(Number.isFinite(width) && width > 0)) return null;
63
+ return {
64
+ railStripWidth: width === void 0 ? null : Math.max(RAIL_STRIP_MIN, width),
65
+ railVisibility: visibility,
66
+ magnet: Number.isFinite(p.magnet) ? Math.max(0, p.magnet) : DEFAULT_RAIL_MAGNET,
67
+ floatNearEdge: p.floatNearEdge !== false
68
+ };
69
+ }
50
70
  var zoneOf = (item) => item?.align === "center" || item?.align === "end" ? item.align : "start";
51
71
  var formsOf = (item, axis) => item.forms[axis] ?? [];
52
72
  var PANEL_FORMS = /* @__PURE__ */ new Set(["open", "header", "rail"]);
@@ -921,10 +941,10 @@ function obstacleStop(drawn, obstacles, axis, drag, span) {
921
941
  if (!drawn || !drag) return none;
922
942
  const lo = (r) => axis === "x" ? r.x : r.y;
923
943
  const len = (r) => axis === "x" ? r.width : r.height;
924
- const across = (r) => axis === "x" ? [r.y, r.y + r.height] : [r.x, r.x + r.width];
944
+ const across2 = (r) => axis === "x" ? [r.y, r.y + r.height] : [r.x, r.x + r.width];
925
945
  let at = none;
926
946
  for (const o of obstacles) {
927
- const [c0, c1] = across(o);
947
+ const [c0, c1] = across2(o);
928
948
  if (c0 >= span[1] - TOUCH || c1 <= span[0] + TOUCH) continue;
929
949
  if (drag === "start" && lo(o) + len(o) <= lo(drawn) + EPS2) at = Math.max(at, lo(o) + len(o));
930
950
  if (drag === "end" && lo(o) >= lo(drawn) + len(drawn) - EPS2) at = Math.min(at, lo(o));
@@ -1082,6 +1102,11 @@ function moveTo(scene, id, place) {
1082
1102
  if (!anchor || out === scene) return out;
1083
1103
  return { ...out, floats: out.floats.map((f) => f.id === id ? { ...f, anchor } : f) };
1084
1104
  }
1105
+ const railColumn = place.kind === "rail" ? railColumnOf(scene, place.side, item.kind) : void 0;
1106
+ if (railColumn) {
1107
+ const docked = moveTo(scene, id, { edge: railColumn.id, zone: "start", at: Infinity });
1108
+ return docked === scene ? scene : withItem(docked, { ...docked.items[id], from: Math.max(1, item.from ?? 0) });
1109
+ }
1085
1110
  if (place.kind === "column" || place.kind === "rail") {
1086
1111
  if (place.kind === "rail" && !scene.rails?.[place.side]?.accepts.includes(item.kind)) return scene;
1087
1112
  const folded = place.kind === "rail" ? { ...item, from: Math.max(1, item.from ?? 0) } : item;
@@ -1486,10 +1511,10 @@ function reservedRect(scene, l, id) {
1486
1511
  const shift = it.zone === "end" ? len - keep2 : it.zone === "center" ? (len - keep2) / 2 : 0;
1487
1512
  return column ? rect(it.rect.x, it.rect.y + shift, it.rect.width, keep2) : rect(it.rect.x + shift, it.rect.y, keep2, it.rect.height);
1488
1513
  }
1489
- function slotAt(c, zone, line, id, place, lands, home = false) {
1514
+ function slotAt(c, zone, line, id, place, lands2, home = false) {
1490
1515
  const result = c.settle(use(moveTo(c.scene, c.dragged, place), c.dragged));
1491
1516
  const isHome = home || c.isHome(result);
1492
- return { zone, line, id, place, result, home: isHome, ok: isHome || !!result.layout.items[c.dragged] && lands(result) && c.sound(result.layout) };
1517
+ return { zone, line, id, place, result, home: isHome, ok: isHome || !!result.layout.items[c.dragged] && lands2(result) && c.sound(result.layout) };
1493
1518
  }
1494
1519
  function distinctSlots(c, slots) {
1495
1520
  const landing = (s) => s.result.layout.items[c.dragged]?.rect;
@@ -1550,7 +1575,7 @@ function edgeSlots(c, edge, accepts) {
1550
1575
  const slotId = (zone, k) => targetId(members0.length === 0 ? { kind: "strip", edge: edge.id, zone } : { kind: "gap", edge: edge.id, zone, at: k });
1551
1576
  const firstKind = formsOf(scene.items[dragged], axisOf(edge.side))[0]?.kind;
1552
1577
  const titles = edge.items.filter((id) => base.items[id]?.edge === edge.id && base.items[id].fixed && !!formsOf(scene.items[id], axisOf(edge.side))[base.items[id].form]?.main.grows);
1553
- const lands = ({ layout: after }) => {
1578
+ const lands2 = ({ layout: after }) => {
1554
1579
  const me = after.items[dragged];
1555
1580
  if (me.edge !== edge.id || me.inMenu) return false;
1556
1581
  if (titles.length === 0) return true;
@@ -1590,7 +1615,7 @@ function edgeSlots(c, edge, accepts) {
1590
1615
  const next = members.slice(k).find(shown);
1591
1616
  const before = members.slice(0, k).reverse().find(shown);
1592
1617
  const line = next ? at(occupied(next)) : before ? at(occupied(before)) + len(occupied(before)) : anchorLine[zone];
1593
- const s = { ...slotAt(c, zone, line, slotId(zone, k), { kind: "gap", edge: edge.id, zone, at: k }, lands), order: before0 + members.slice(0, k).filter(aimed).length };
1618
+ const s = { ...slotAt(c, zone, line, slotId(zone, k), { kind: "gap", edge: edge.id, zone, at: k }, lands2), order: before0 + members.slice(0, k).filter(aimed).length };
1594
1619
  const movesFixed = members0.some((id) => {
1595
1620
  const b = base.items[id];
1596
1621
  const a = s.result.layout.items[id];
@@ -1630,7 +1655,7 @@ function edgeSpec(c, edge) {
1630
1655
  const strip = Math.max(0, Number.isFinite(edge.strip) ? edge.strip : DEFAULT_STRIP);
1631
1656
  const outer = edge.side === "left" ? r.x : edge.side === "right" ? r.x + r.width : edge.side === "top" ? r.y : r.y + r.height;
1632
1657
  const inward = (depth) => edge.side === "left" || edge.side === "top" ? [outer, outer + depth] : [outer - depth, outer];
1633
- const across = (after) => inward((el.cross > 0 ? Math.max(el.cross, after?.edges[edge.id]?.cross ?? 0) : strip) + data.inward);
1658
+ const across2 = (after) => inward((el.cross > 0 ? Math.max(el.cross, after?.edges[edge.id]?.cross ?? 0) : strip) + data.inward);
1634
1659
  const drawn = el.cross > 0;
1635
1660
  const marker = (s) => {
1636
1661
  const slot = s.result.layout.items[dragged].rect;
@@ -1651,7 +1676,7 @@ function edgeSpec(c, edge) {
1651
1676
  holds: !!ownNow && ownNow.edge === edge.id && !ownNow.floating,
1652
1677
  reserved,
1653
1678
  cards,
1654
- across,
1679
+ across: across2,
1655
1680
  owned: inward(drawn ? el.cross : Math.min(strip, data.place)),
1656
1681
  ownedAlong: null,
1657
1682
  drawn,
@@ -1811,14 +1836,14 @@ function ownership(c, live, alongOf) {
1811
1836
  const roomOf = (s) => {
1812
1837
  const b = bandOf(s);
1813
1838
  const along = (r) => s.vertical ? [r.y, r.y + r.height] : [r.x, r.x + r.width];
1814
- const across = (r) => s.vertical ? [r.x, r.x + r.width] : [r.y, r.y + r.height];
1839
+ const across2 = (r) => s.vertical ? [r.x, r.x + r.width] : [r.y, r.y + r.height];
1815
1840
  const rs = taken.get(s).filter((r) => overlaps(r, b));
1816
1841
  const ends = [.../* @__PURE__ */ new Set([...along(b), ...rs.flatMap(along)])].filter((x) => x >= along(b)[0] && x <= along(b)[1]).sort((p, q) => p - q);
1817
1842
  const owned = [];
1818
1843
  for (let k = 1; k < ends.length; k++) {
1819
1844
  const [u, w] = [ends[k - 1], ends[k]];
1820
- const over = rs.filter((r) => along(r)[0] <= u + EPS && along(r)[1] >= w - EPS).map(across);
1821
- if (w - u > EPS && less([across(b)], over).reduce((n, [p, q]) => n + q - p, 0) < 1) owned.push([u, w]);
1845
+ const over = rs.filter((r) => along(r)[0] <= u + EPS && along(r)[1] >= w - EPS).map(across2);
1846
+ if (w - u > EPS && less([across2(b)], over).reduce((n, [p, q]) => n + q - p, 0) < 1) owned.push([u, w]);
1822
1847
  }
1823
1848
  const half = s.edge ? halfBandOf(s.edge) : null;
1824
1849
  const raw = bodySpans(s.edge);
@@ -1849,9 +1874,9 @@ function ownership(c, live, alongOf) {
1849
1874
  const e = s.edge;
1850
1875
  if (!e) return [];
1851
1876
  const column = axisOf(e.side) === "column";
1852
- const across = (a, b) => column ? rect(-1e9, a, 2e9, b - a) : rect(a, -1e9, b - a, 2e9);
1853
- const reserved = Object.entries(now.items).filter(([iid, p]) => p.edge === e.id && p.fixed && !p.inMenu && !grows(iid)).map(([, p]) => column ? across(p.rect.y, p.rect.y + p.rect.height) : across(p.rect.x, p.rect.x + p.rect.width));
1854
- return [...reserved, ...cutsOf(s).bodies.map(([a, b]) => across(a, b))].filter((b) => area(b) > EPS);
1877
+ const across2 = (a, b) => column ? rect(-1e9, a, 2e9, b - a) : rect(a, -1e9, b - a, 2e9);
1878
+ const reserved = Object.entries(now.items).filter(([iid, p]) => p.edge === e.id && p.fixed && !p.inMenu && !grows(iid)).map(([, p]) => column ? across2(p.rect.y, p.rect.y + p.rect.height) : across2(p.rect.x, p.rect.x + p.rect.width));
1879
+ return [...reserved, ...cutsOf(s).bodies.map(([a, b]) => across2(a, b))].filter((b) => area(b) > EPS);
1855
1880
  };
1856
1881
  const drawnBySpec = /* @__PURE__ */ new Map();
1857
1882
  const drawnBesides = (s) => {
@@ -2112,7 +2137,7 @@ function columnLines(c, side, railLands) {
2112
2137
  cols.forEach((x) => lines.push({ x: outerX(x.r), ring: rings.before(x.edge), at: atOf(x.edge) - 0.5 }));
2113
2138
  if (cols.length > 0) lines.push({ x: innerX(cols[cols.length - 1].r), ring: rings.after(cols[cols.length - 1].edge), at: atOf(cols[cols.length - 1].edge) + 0.5 });
2114
2139
  else lines.push({ x: side === "left" ? now.content.x : now.content.x + now.content.width, ring: rings.count, at: Math.max(-1, ...scene.edges.filter((e) => e.side === side).map(atOf)) + 0.5 });
2115
- const lands = (r) => {
2140
+ const lands2 = (r) => {
2116
2141
  const me = r.layout.items[dragged];
2117
2142
  const el = me.edge ? r.layout.edges[me.edge] : void 0;
2118
2143
  return !!el && !me.inMenu && !el.folded && !el.rides && r.scene !== c.scene;
@@ -2120,11 +2145,11 @@ function columnLines(c, side, railLands) {
2120
2145
  const { reach, place, edgePlace } = EDGE_KINDS.columnLine;
2121
2146
  const stage = c.scene.stage;
2122
2147
  const dir = side === "left" ? 1 : -1;
2123
- const outside = (x) => Object.values(now.edges).some((e) => e.side === side && e.rect.width > 0 && e.rect.height > 0 && (side === "left" ? e.rect.x + e.rect.width <= x + EPS : e.rect.x >= x - EPS));
2148
+ const outside2 = (x) => Object.values(now.edges).some((e) => e.side === side && e.rect.width > 0 && e.rect.height > 0 && (side === "left" ? e.rect.x + e.rect.width <= x + EPS : e.rect.x >= x - EPS));
2124
2149
  const railFirst = railLands && !!c.scene.rails?.[side]?.accepts.includes(c.kind) && !!now.railPlaces[side] && !(now.rails[side]?.segments.length ?? 0);
2125
2150
  const placeOf = (l, i) => {
2126
2151
  const atEdge = side === "left" ? l.x <= stage.x + EPS : l.x >= stage.x + stage.width - EPS;
2127
- if (i > 0 || outside(l.x) || !(atEdge || railFirst)) return { line: l.x, zone: [l.x - reach, l.x + reach], owned: [l.x - place / 2, l.x + place / 2] };
2152
+ if (i > 0 || outside2(l.x) || !(atEdge || railFirst)) return { line: l.x, zone: [l.x - reach, l.x + reach], owned: [l.x - place / 2, l.x + place / 2] };
2128
2153
  const windowEdge = side === "left" ? stage.x : stage.x + stage.width;
2129
2154
  const boundary = clamp(l.x, stage.x, stage.x + stage.width);
2130
2155
  const band0 = railFirst ? railOuter(c, side) + dir * RAIL_EDGE : boundary;
@@ -2141,7 +2166,7 @@ function columnLines(c, side, railLands) {
2141
2166
  lay: { phase: EDGE_KINDS.columnLine.phase, side, at: l.at },
2142
2167
  vertical: false,
2143
2168
  zones: [{ zone: "start", a: Math.max(p.zone[0], stage.x), b: Math.min(p.zone[1], stage.x + stage.width) }],
2144
- slots: [slotAt(c, "start", p.line, targetId({ kind: "column", side, ring: l.ring }), { kind: "column", side, ring: l.ring }, lands)],
2169
+ slots: [slotAt(c, "start", p.line, targetId({ kind: "column", side, ring: l.ring }), { kind: "column", side, ring: l.ring }, lands2)],
2145
2170
  refuse: () => "no-room",
2146
2171
  own: null,
2147
2172
  holds: false,
@@ -2193,7 +2218,7 @@ function railStops(c, side) {
2193
2218
  stops2.push({ y: placeRect.y, ring: firstCol ? rings.before(firstCol) : rings.count });
2194
2219
  }
2195
2220
  const ownRail = now.items[dragged]?.rail === side;
2196
- const lands = (r) => r.layout.items[dragged].rail === side && r.scene !== c.scene;
2221
+ const lands2 = (r) => r.layout.items[dragged].rail === side && r.scene !== c.scene;
2197
2222
  const at = zone;
2198
2223
  return {
2199
2224
  id: virtualEdgeId("rail", side),
@@ -2203,7 +2228,7 @@ function railStops(c, side) {
2203
2228
  lay: { phase: EDGE_KINDS.railStop.phase, side, at: -1 },
2204
2229
  vertical: true,
2205
2230
  zones: [{ zone: "start", a: at.y, b: at.y + at.height }],
2206
- slots: stops2.map((s) => slotAt(c, "start", s.y, targetId({ kind: "rail", side, ring: s.ring }), { kind: "rail", side, ring: s.ring }, lands, ownRail)),
2231
+ slots: stops2.map((s) => slotAt(c, "start", s.y, targetId({ kind: "rail", side, ring: s.ring }), { kind: "rail", side, ring: s.ring }, lands2, ownRail)),
2207
2232
  refuse: () => "no-room",
2208
2233
  own: null,
2209
2234
  holds: false,
@@ -2218,6 +2243,147 @@ function railStops(c, side) {
2218
2243
  };
2219
2244
  }
2220
2245
 
2246
+ // src/scene/targets/rail-strip.ts
2247
+ var across = (side, outer, width) => side === "left" ? [outer, width] : [outer - width, width];
2248
+ function lands(c, result, side) {
2249
+ const me = result.layout.items[c.dragged];
2250
+ if (!me || me.floating || me.inMenu || (result.scene.items[c.dragged]?.from ?? 0) < 1 || c.isHome(result) || !c.sound(result.layout)) return false;
2251
+ const sideOf = (edgeId) => edgeId ? result.layout.edges[edgeId]?.side : void 0;
2252
+ return me.rail === side || sideOf(me.rides) === side || sideOf(me.edge) === side;
2253
+ }
2254
+ function columnStrip(c, side, policy) {
2255
+ const edge = railColumnOf(c.scene, side, c.kind);
2256
+ if (!edge) return null;
2257
+ const own = c.now.items[c.dragged];
2258
+ if (own?.edge === edge.id && (c.scene.items[c.dragged]?.from ?? 0) >= 1) return null;
2259
+ const place = { kind: "rail", side, ring: edge.ring };
2260
+ const moved = moveTo(c.scene, c.dragged, place);
2261
+ if (moved === c.scene) return null;
2262
+ const result = c.settle(use(moved, c.dragged));
2263
+ const el = result.layout.edges[edge.id];
2264
+ if (!el || el.rect.width <= EPS || !lands(c, result, side)) return null;
2265
+ const r = el.rect;
2266
+ const railWidth = result.layout.items[c.dragged].tab ? r.width : edge.cross.rail ?? 30;
2267
+ const [x, w] = across(side, side === "left" ? r.x : r.x + r.width, policy.railStripWidth ?? Math.max(RAIL_STRIP_MIN, railWidth));
2268
+ return { side, rect: rect(x, r.y, w, r.height), slots: [{ id: targetId({ kind: "rail", side, ring: edge.ring }), place, along: [r.y, r.y + r.height], result }] };
2269
+ }
2270
+ function declaredStrip(c, side, policy) {
2271
+ const template = c.scene.columns?.[side];
2272
+ const spec = c.scene.rails?.[side];
2273
+ if (!template || !spec || !zoneTakes(template, "start", c.kind) || !spec.accepts.includes(c.kind)) return null;
2274
+ const stops2 = railStops(c, side);
2275
+ const slots = (stops2?.slots ?? []).filter((s) => !s.home && s.place.kind === "rail" && lands(c, s.result, side)).sort((a2, b2) => a2.line - b2.line);
2276
+ if (!stops2 || slots.length === 0) return null;
2277
+ const a = Math.min(...stops2.zones.map((z) => z.a));
2278
+ const b = Math.max(...stops2.zones.map((z) => z.b));
2279
+ const drawn = c.now.rails[side];
2280
+ const outer = drawn && drawn.segments.length > 0 ? side === "left" ? drawn.rect.x : drawn.rect.x + drawn.rect.width : railOuter(c, side);
2281
+ const [x, w] = across(side, outer, policy.railStripWidth ?? Math.max(RAIL_STRIP_MIN, spec.width));
2282
+ const cuts = [a, ...slots.slice(1).map((s, i) => (slots[i].line + s.line) / 2), b];
2283
+ return {
2284
+ side,
2285
+ rect: rect(x, a, w, b - a),
2286
+ slots: slots.map((s, i) => ({ id: s.id, place: s.place, along: [cuts[i], cuts[i + 1]], result: s.result }))
2287
+ };
2288
+ }
2289
+ var outside = (pieces, strips) => strips.reduce((acc, s) => acc.flatMap((p) => overlaps(p, s) ? subtract(p, s) : [p]), [...pieces]).filter((p) => p.width >= 1 && p.height >= 1);
2290
+ var largest2 = (rs) => rs.reduce((m, r) => r.width * r.height > m.width * m.height ? r : m);
2291
+ var sameRects = (a, b) => a.length === b.length && a.every((r, i) => r.x === b[i].x && r.y === b[i].y && r.width === b[i].width && r.height === b[i].height);
2292
+ function withRailStrips(c, targets2, refusals2) {
2293
+ const policy = railPolicyOf(c.scene, c.kind);
2294
+ const strips = policy ? ["left", "right"].map((side) => c.scene.rails?.[side] ? declaredStrip(c, side, policy) : columnStrip(c, side, policy)).filter((s) => s !== null) : [];
2295
+ if (!policy || strips.length === 0) return { targets: [...targets2], refusals: [...refusals2], strips: [] };
2296
+ const sides = new Set(strips.map((s) => s.side));
2297
+ const rects = strips.map((s) => s.rect);
2298
+ const out = [];
2299
+ for (const t of targets2) {
2300
+ if (t.place.kind === "rail" && sides.has(t.place.side)) continue;
2301
+ if (t.free || t.place.kind === "none") {
2302
+ out.push(t.free && !policy.floatNearEdge ? clearOfStrips(t, c.dragged, rects) : t);
2303
+ continue;
2304
+ }
2305
+ const was = t.hits ?? [t.hit];
2306
+ const pieces = outside(was, rects);
2307
+ if (pieces.length === 0) {
2308
+ const moved = t.id.startsWith("strip:") ? insideStrips(t.hit, strips) : null;
2309
+ if (moved) out.push({ ...withoutHits(t), hit: moved });
2310
+ continue;
2311
+ }
2312
+ if (sameRects(pieces, was)) {
2313
+ out.push(t);
2314
+ continue;
2315
+ }
2316
+ out.push({ ...withoutHits(t), hit: largest2(pieces), ...pieces.length > 1 ? { hits: pieces } : {} });
2317
+ }
2318
+ const refused = [];
2319
+ const railEdges = new Set([...sides].map((side) => virtualEdgeId("rail", side)));
2320
+ for (const r of refusals2) {
2321
+ if (railEdges.has(r.edge)) continue;
2322
+ const pieces = outside([r.hit], rects);
2323
+ if (pieces.length) refused.push(pieces.length === 1 && sameRects(pieces, [r.hit]) ? r : { ...r, hit: largest2(pieces) });
2324
+ }
2325
+ const vertical = (r) => {
2326
+ const side = c.scene.edges.find((e) => e.id === r.edge)?.side;
2327
+ return side ? side === "left" || side === "right" : r.edge === virtualEdgeId("rail", "left") || r.edge === virtualEdgeId("rail", "right");
2328
+ };
2329
+ const pos = (r) => vertical(r) ? [r.hit.y, r.hit.x] : [r.hit.x, r.hit.y];
2330
+ const groups = /* @__PURE__ */ new Map();
2331
+ for (const r of refused) groups.set(`${r.edge}
2332
+ ${r.zone}`, [...groups.get(`${r.edge}
2333
+ ${r.zone}`) ?? [], r]);
2334
+ const numbered = /* @__PURE__ */ new Map();
2335
+ for (const group of groups.values())
2336
+ group.sort((a, b) => pos(a)[0] - pos(b)[0] || pos(a)[1] - pos(b)[1]).forEach((r, n) => numbered.set(r, targetId({ kind: "refuse", edge: r.edge, zone: r.zone, n })));
2337
+ const renumbered = refused.map((r) => numbered.get(r) === r.id ? r : { ...r, id: numbered.get(r) });
2338
+ for (const s of strips) {
2339
+ const grown = s.side === "left" ? rect(s.rect.x, s.rect.y, s.rect.width + policy.magnet, s.rect.height) : rect(s.rect.x - policy.magnet, s.rect.y, s.rect.width + policy.magnet, s.rect.height);
2340
+ for (const sl of s.slots) {
2341
+ const [a, b] = sl.along;
2342
+ const slot = sl.result.layout.items[c.dragged].rect;
2343
+ const result = sl.result;
2344
+ out.push({
2345
+ id: sl.id,
2346
+ priority: 1,
2347
+ hit: rect(s.rect.x, a, s.rect.width, b - a),
2348
+ armedHit: rect(grown.x, a, grown.width, b - a),
2349
+ arm: "dwell",
2350
+ strip: s.rect,
2351
+ slot,
2352
+ item: c.dragged,
2353
+ place: sl.place,
2354
+ after: () => result
2355
+ });
2356
+ }
2357
+ }
2358
+ return { targets: out, refusals: renumbered, strips: rects };
2359
+ }
2360
+ var withoutHits = (t) => {
2361
+ const { hits: _pieces, ...rest } = t;
2362
+ return rest;
2363
+ };
2364
+ function insideStrips(r, strips) {
2365
+ const s = strips.find((x) => overlaps(x.rect, r));
2366
+ if (!s) return null;
2367
+ return s.side === "left" ? rect(s.rect.x + s.rect.width, r.y, r.width, r.height) : rect(s.rect.x - r.width, r.y, r.width, r.height);
2368
+ }
2369
+ function clearOfStrips(t, dragged, strips) {
2370
+ return {
2371
+ ...t,
2372
+ after(point, grab) {
2373
+ const first = t.after(point, grab);
2374
+ const at = first.layout.items[dragged]?.rect;
2375
+ if (!at) return first;
2376
+ let dx = 0;
2377
+ for (const s of strips) {
2378
+ const r = rect(at.x + dx, at.y, at.width, at.height);
2379
+ if (!overlaps(r, s)) continue;
2380
+ dx += s.x + s.width / 2 < r.x + r.width / 2 ? s.x + s.width - r.x : s.x - (r.x + r.width);
2381
+ }
2382
+ return dx === 0 ? first : t.after({ x: at.x + dx + (grab?.x ?? at.width / 2), y: point.y }, grab);
2383
+ }
2384
+ };
2385
+ }
2386
+
2221
2387
  // src/scene/targets.ts
2222
2388
  function specsOf(c, kind) {
2223
2389
  const { scene } = c;
@@ -2340,7 +2506,9 @@ function generate(scene, dragged, options) {
2340
2506
  const pieces = homeSlot < 0 && homePieces.length ? { hits: [hit, ...homePieces] } : {};
2341
2507
  targets2.push({ id: targetId({ kind: "home", item: dragged }), priority: 1, hit, ...pieces, item: dragged, place: { kind: "home" }, after: homeAfter });
2342
2508
  }
2343
- return { targets: targets2, refusals: refused, lost: [...new Set(lost)].filter((id) => !targets2.some((t) => t.id === id)) };
2509
+ const lostIds = [...new Set(lost)].filter((id) => !targets2.some((t) => t.id === id));
2510
+ const layered = withRailStrips(c, targets2, refused);
2511
+ return { targets: layered.targets, refusals: layered.refusals, lost: lostIds };
2344
2512
  }
2345
2513
  function targets(scene, dragged, options = {}) {
2346
2514
  return generate(scene, dragged, options).targets;
@@ -2373,6 +2541,9 @@ export {
2373
2541
  SIDES,
2374
2542
  ZONES,
2375
2543
  RAIL_MODES,
2544
+ RAIL_VISIBILITIES,
2545
+ RAIL_STRIP_MIN,
2546
+ DEFAULT_RAIL_MAGNET,
2376
2547
  DEFAULT_STRIP,
2377
2548
  DEFAULT_HIT_BAND,
2378
2549
  DEFAULT_FLOAT_SIZE,
@@ -2411,4 +2582,4 @@ export {
2411
2582
  refusals,
2412
2583
  stops
2413
2584
  };
2414
- //# sourceMappingURL=chunk-6GQ3PEZA.js.map
2585
+ //# sourceMappingURL=chunk-PC5UHBW4.js.map