@n-uf/placement 26.11.28 → 26.11.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +110 -61
  3. package/dist/{chunk-7ASCUAGV.js → chunk-3ZICYLWL.js} +2 -2
  4. package/dist/{chunk-7ASCUAGV.js.map → chunk-3ZICYLWL.js.map} +1 -1
  5. package/dist/{chunk-6GQ3PEZA.js → chunk-5CSWQSH7.js} +197 -18
  6. package/dist/chunk-5CSWQSH7.js.map +1 -0
  7. package/dist/{chunk-3RRCKN74.js → chunk-AE3BWTAE.js} +2 -2
  8. package/dist/chunk-AE3BWTAE.js.map +1 -0
  9. package/dist/{chunk-3P6VOXA6.js → chunk-AVMZIXGO.js} +2 -2
  10. package/dist/{chunk-3P6VOXA6.js.map → chunk-AVMZIXGO.js.map} +1 -1
  11. package/dist/{chunk-WLMJ6JGO.js → chunk-GIBUM6TB.js} +1 -1
  12. package/dist/chunk-GIBUM6TB.js.map +1 -0
  13. package/dist/{chunk-OYGOJWAX.js → chunk-JVAR67OL.js} +2 -2
  14. package/dist/{chunk-WM5FJ3IS.js → chunk-VLTYJHUA.js} +1 -1
  15. package/dist/{chunk-WM5FJ3IS.js.map → chunk-VLTYJHUA.js.map} +1 -1
  16. package/dist/{constructions-DSEjvWMP.d.ts → constructions-Cbz7uEAZ.d.ts} +3 -3
  17. package/dist/desk.d.ts +3 -3
  18. package/dist/desk.js +3 -3
  19. package/dist/dock.d.ts +4 -4
  20. package/dist/dock.js +2 -2
  21. package/dist/dock.js.map +1 -1
  22. package/dist/{float-fit-DRSOU_2y.d.ts → float-fit-DCYxRMru.d.ts} +1 -1
  23. package/dist/{geometry-CkZ6Fcfb.d.ts → geometry-Bf37LbCT.d.ts} +1 -1
  24. package/dist/index.d.ts +4 -4
  25. package/dist/index.js +1 -1
  26. package/dist/index.js.map +1 -1
  27. package/dist/{model-DwojiKKF.d.ts → model-BxFXr9UY.d.ts} +52 -7
  28. package/dist/{model-CPM1Lv65.d.ts → model-X7eUaKlA.d.ts} +2 -2
  29. package/dist/panels.d.ts +5 -5
  30. package/dist/panels.js +3 -3
  31. package/dist/scene-cases.d.ts +59 -15
  32. package/dist/scene-cases.js +114 -21
  33. package/dist/scene-cases.js.map +1 -1
  34. package/dist/scene.d.ts +7 -7
  35. package/dist/scene.js +9 -3
  36. package/dist/stack.d.ts +6 -6
  37. package/dist/stack.js +2 -2
  38. package/dist/{target-CEVCfJd-.d.ts → target-2RYYKkd1.d.ts} +7 -1
  39. package/dist/{targets-BPG7Kf02.d.ts → targets-Du5_4T1u.d.ts} +4 -4
  40. package/dist/targets.d.ts +14 -14
  41. package/dist/targets.js +4 -4
  42. package/dist/targets.js.map +1 -1
  43. package/dist/toolbar.d.ts +11 -11
  44. package/dist/toolbar.js +1 -1
  45. package/package.json +2 -2
  46. package/dist/chunk-3RRCKN74.js.map +0 -1
  47. package/dist/chunk-6GQ3PEZA.js.map +0 -1
  48. package/dist/chunk-WLMJ6JGO.js.map +0 -1
  49. /package/dist/{chunk-OYGOJWAX.js.map → chunk-JVAR67OL.js.map} +0 -0
@@ -5,7 +5,7 @@ import {
5
5
  formMain,
6
6
  formSetsCross,
7
7
  wrapLines
8
- } from "./chunk-3RRCKN74.js";
8
+ } from "./chunk-AE3BWTAE.js";
9
9
  import {
10
10
  COLUMN_REACH,
11
11
  EPS,
@@ -17,12 +17,15 @@ import {
17
17
  overlaps,
18
18
  rect,
19
19
  subtract
20
- } from "./chunk-WM5FJ3IS.js";
20
+ } from "./chunk-VLTYJHUA.js";
21
21
 
22
22
  // src/scene/model.ts
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;
@@ -1497,7 +1522,8 @@ function distinctSlots(c, slots) {
1497
1522
  if (a.zone !== b.zone) return false;
1498
1523
  if (a.home && b.home) return true;
1499
1524
  const [p, q] = [landing(a), landing(b)];
1500
- return Math.abs(a.line - b.line) < EPS && (!p || !q ? p === q : Math.abs(p.x - q.x) + Math.abs(p.y - q.y) + Math.abs(p.width - q.width) + Math.abs(p.height - q.height) < 0.01);
1525
+ const sameLine = a.place.kind === "rail" && b.place.kind === "rail" || Math.abs(a.line - b.line) < EPS;
1526
+ return sameLine && (!p || !q ? p === q : Math.abs(p.x - q.x) + Math.abs(p.y - q.y) + Math.abs(p.width - q.width) + Math.abs(p.height - q.height) < 0.01);
1501
1527
  };
1502
1528
  const wins = (o, j, s, i) => o.home !== s.home ? o.home : j < i;
1503
1529
  return slots.filter((s, i) => !slots.some((o, j) => j !== i && sameMove(o, s) && wins(o, j, s, i)));
@@ -1630,7 +1656,7 @@ function edgeSpec(c, edge) {
1630
1656
  const strip = Math.max(0, Number.isFinite(edge.strip) ? edge.strip : DEFAULT_STRIP);
1631
1657
  const outer = edge.side === "left" ? r.x : edge.side === "right" ? r.x + r.width : edge.side === "top" ? r.y : r.y + r.height;
1632
1658
  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);
1659
+ const across2 = (after) => inward((el.cross > 0 ? Math.max(el.cross, after?.edges[edge.id]?.cross ?? 0) : strip) + data.inward);
1634
1660
  const drawn = el.cross > 0;
1635
1661
  const marker = (s) => {
1636
1662
  const slot = s.result.layout.items[dragged].rect;
@@ -1651,7 +1677,7 @@ function edgeSpec(c, edge) {
1651
1677
  holds: !!ownNow && ownNow.edge === edge.id && !ownNow.floating,
1652
1678
  reserved,
1653
1679
  cards,
1654
- across,
1680
+ across: across2,
1655
1681
  owned: inward(drawn ? el.cross : Math.min(strip, data.place)),
1656
1682
  ownedAlong: null,
1657
1683
  drawn,
@@ -1811,14 +1837,14 @@ function ownership(c, live, alongOf) {
1811
1837
  const roomOf = (s) => {
1812
1838
  const b = bandOf(s);
1813
1839
  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];
1840
+ const across2 = (r) => s.vertical ? [r.x, r.x + r.width] : [r.y, r.y + r.height];
1815
1841
  const rs = taken.get(s).filter((r) => overlaps(r, b));
1816
1842
  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
1843
  const owned = [];
1818
1844
  for (let k = 1; k < ends.length; k++) {
1819
1845
  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]);
1846
+ const over = rs.filter((r) => along(r)[0] <= u + EPS && along(r)[1] >= w - EPS).map(across2);
1847
+ if (w - u > EPS && less([across2(b)], over).reduce((n, [p, q]) => n + q - p, 0) < 1) owned.push([u, w]);
1822
1848
  }
1823
1849
  const half = s.edge ? halfBandOf(s.edge) : null;
1824
1850
  const raw = bodySpans(s.edge);
@@ -1849,9 +1875,9 @@ function ownership(c, live, alongOf) {
1849
1875
  const e = s.edge;
1850
1876
  if (!e) return [];
1851
1877
  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);
1878
+ const across2 = (a, b) => column ? rect(-1e9, a, 2e9, b - a) : rect(a, -1e9, b - a, 2e9);
1879
+ 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));
1880
+ return [...reserved, ...cutsOf(s).bodies.map(([a, b]) => across2(a, b))].filter((b) => area(b) > EPS);
1855
1881
  };
1856
1882
  const drawnBySpec = /* @__PURE__ */ new Map();
1857
1883
  const drawnBesides = (s) => {
@@ -2099,6 +2125,12 @@ function railOuter(c, side) {
2099
2125
  const barOutside = 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 <= placeOuter + EPS : e.rect.x >= placeOuter - EPS));
2100
2126
  return barOutside ? placeOuter : windowEdge;
2101
2127
  }
2128
+ function collapsesAt(c, result, side) {
2129
+ const me = result.layout.items[c.dragged];
2130
+ if (!me || me.floating || me.inMenu || (result.scene.items[c.dragged]?.from ?? 0) < 1 || c.isHome(result) || !c.sound(result.layout)) return false;
2131
+ const sideOf = (edgeId) => edgeId ? result.layout.edges[edgeId]?.side : void 0;
2132
+ return me.rail === side || sideOf(me.rides) === side || sideOf(me.edge) === side;
2133
+ }
2102
2134
  function columnLines(c, side, railLands) {
2103
2135
  const { scene, now, dragged } = c;
2104
2136
  const cols = scene.edges.filter((e) => e.side === side && e.column === true).map((edge) => ({ edge, l: now.edges[edge.id] })).filter((x) => x.l && !x.l.folded && !x.l.rides && x.l.cross > 0).sort((a, b) => a.edge.ring - b.edge.ring).map((x) => ({ edge: x.edge, r: x.l.rect }));
@@ -2120,11 +2152,11 @@ function columnLines(c, side, railLands) {
2120
2152
  const { reach, place, edgePlace } = EDGE_KINDS.columnLine;
2121
2153
  const stage = c.scene.stage;
2122
2154
  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));
2155
+ 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
2156
  const railFirst = railLands && !!c.scene.rails?.[side]?.accepts.includes(c.kind) && !!now.railPlaces[side] && !(now.rails[side]?.segments.length ?? 0);
2125
2157
  const placeOf = (l, i) => {
2126
2158
  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] };
2159
+ 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
2160
  const windowEdge = side === "left" ? stage.x : stage.x + stage.width;
2129
2161
  const boundary = clamp(l.x, stage.x, stage.x + stage.width);
2130
2162
  const band0 = railFirst ? railOuter(c, side) + dir * RAIL_EDGE : boundary;
@@ -2193,7 +2225,8 @@ function railStops(c, side) {
2193
2225
  stops2.push({ y: placeRect.y, ring: firstCol ? rings.before(firstCol) : rings.count });
2194
2226
  }
2195
2227
  const ownRail = now.items[dragged]?.rail === side;
2196
- const lands = (r) => r.layout.items[dragged].rail === side && r.scene !== c.scene;
2228
+ const shown = !!rail && rail.segments.length > 0;
2229
+ const lands = (r) => shown ? collapsesAt(c, r, side) : r.layout.items[dragged].rail === side && r.scene !== c.scene;
2197
2230
  const at = zone;
2198
2231
  return {
2199
2232
  id: virtualEdgeId("rail", side),
@@ -2218,6 +2251,147 @@ function railStops(c, side) {
2218
2251
  };
2219
2252
  }
2220
2253
 
2254
+ // src/scene/targets/rail-strip.ts
2255
+ var across = (side, outer, width) => side === "left" ? [outer, width] : [outer - width, width];
2256
+ function columnStrip(c, side, policy) {
2257
+ const edge = railColumnOf(c.scene, side, c.kind);
2258
+ if (!edge) return null;
2259
+ const own = c.now.items[c.dragged];
2260
+ if (own?.edge === edge.id && (c.scene.items[c.dragged]?.from ?? 0) >= 1) return null;
2261
+ const place = { kind: "rail", side, ring: edge.ring };
2262
+ const moved = moveTo(c.scene, c.dragged, place);
2263
+ if (moved === c.scene) return null;
2264
+ const result = c.settle(use(moved, c.dragged));
2265
+ const el = result.layout.edges[edge.id];
2266
+ if (!el || el.rect.width <= EPS || !collapsesAt(c, result, side)) return null;
2267
+ const r = el.rect;
2268
+ const railWidth = result.layout.items[c.dragged].tab ? r.width : edge.cross.rail ?? 30;
2269
+ const [x, w] = across(side, side === "left" ? r.x : r.x + r.width, policy.railStripWidth ?? Math.max(RAIL_STRIP_MIN, railWidth));
2270
+ 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 }] };
2271
+ }
2272
+ function declaredStrip(c, side, policy) {
2273
+ const template = c.scene.columns?.[side];
2274
+ const spec = c.scene.rails?.[side];
2275
+ if (!template || !spec || !zoneTakes(template, "start", c.kind) || !spec.accepts.includes(c.kind)) return null;
2276
+ const stops2 = railStops(c, side);
2277
+ const slots = (stops2?.slots ?? []).filter((s) => !s.home && s.place.kind === "rail" && collapsesAt(c, s.result, side)).sort((a2, b2) => a2.line - b2.line);
2278
+ if (!stops2 || slots.length === 0) return null;
2279
+ const a = Math.min(...stops2.zones.map((z) => z.a));
2280
+ const b = Math.max(...stops2.zones.map((z) => z.b));
2281
+ const drawn = c.now.rails[side];
2282
+ const outer = drawn && drawn.segments.length > 0 ? side === "left" ? drawn.rect.x : drawn.rect.x + drawn.rect.width : railOuter(c, side);
2283
+ const [x, w] = across(side, outer, policy.railStripWidth ?? Math.max(RAIL_STRIP_MIN, spec.width));
2284
+ const cuts = [a, ...slots.slice(1).map((s, i) => (slots[i].line + s.line) / 2), b];
2285
+ return {
2286
+ side,
2287
+ rect: rect(x, a, w, b - a),
2288
+ slots: slots.map((s, i) => ({ id: s.id, place: s.place, along: [cuts[i], cuts[i + 1]], result: s.result }))
2289
+ };
2290
+ }
2291
+ 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);
2292
+ var largest2 = (rs) => rs.reduce((m, r) => r.width * r.height > m.width * m.height ? r : m);
2293
+ 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);
2294
+ function withRailStrips(c, targets2, refusals2) {
2295
+ const policy = railPolicyOf(c.scene, c.kind);
2296
+ const strips = policy ? ["left", "right"].map((side) => c.scene.rails?.[side] ? declaredStrip(c, side, policy) : columnStrip(c, side, policy)).filter((s) => s !== null) : [];
2297
+ if (!policy || strips.length === 0) return { targets: [...targets2], refusals: [...refusals2], strips: [] };
2298
+ const sides = new Set(strips.map((s) => s.side));
2299
+ const rects = strips.map((s) => s.rect);
2300
+ const out = [];
2301
+ for (const t of targets2) {
2302
+ if (t.place.kind === "rail" && sides.has(t.place.side)) continue;
2303
+ if (t.free || t.place.kind === "none") {
2304
+ out.push(t.free && !policy.floatNearEdge ? clearOfStrips(t, c.dragged, rects) : t);
2305
+ continue;
2306
+ }
2307
+ const was = t.hits ?? [t.hit];
2308
+ const pieces = outside(was, rects);
2309
+ if (pieces.length === 0) {
2310
+ let moved = t.id.startsWith("strip:") || t.place.kind === "column" ? insideStrips(t.hit, strips) : null;
2311
+ let movedPieces = moved ? [moved] : [];
2312
+ if (moved && t.place.kind === "column") {
2313
+ const others = [...targets2.filter((x) => x !== t && !x.free && x.place.kind !== "none" && !(x.place.kind === "rail" && sides.has(x.place.side))).flatMap((x) => x.hits ?? [x.hit]), ...refusals2.map((x) => x.hit)];
2314
+ movedPieces = outside([moved], others);
2315
+ moved = movedPieces.length ? largest2(movedPieces) : null;
2316
+ }
2317
+ if (moved) out.push({ ...withoutHits(t), hit: moved, ...movedPieces.length > 1 ? { hits: movedPieces } : {} });
2318
+ continue;
2319
+ }
2320
+ if (sameRects(pieces, was)) {
2321
+ out.push(t);
2322
+ continue;
2323
+ }
2324
+ out.push({ ...withoutHits(t), hit: largest2(pieces), ...pieces.length > 1 ? { hits: pieces } : {} });
2325
+ }
2326
+ const refused = [];
2327
+ const railEdges = new Set([...sides].map((side) => virtualEdgeId("rail", side)));
2328
+ for (const r of refusals2) {
2329
+ if (railEdges.has(r.edge)) continue;
2330
+ const pieces = outside([r.hit], rects);
2331
+ if (pieces.length) refused.push(pieces.length === 1 && sameRects(pieces, [r.hit]) ? r : { ...r, hit: largest2(pieces) });
2332
+ }
2333
+ const vertical = (r) => {
2334
+ const side = c.scene.edges.find((e) => e.id === r.edge)?.side;
2335
+ return side ? side === "left" || side === "right" : r.edge === virtualEdgeId("rail", "left") || r.edge === virtualEdgeId("rail", "right");
2336
+ };
2337
+ const pos = (r) => vertical(r) ? [r.hit.y, r.hit.x] : [r.hit.x, r.hit.y];
2338
+ const groups = /* @__PURE__ */ new Map();
2339
+ for (const r of refused) groups.set(`${r.edge}
2340
+ ${r.zone}`, [...groups.get(`${r.edge}
2341
+ ${r.zone}`) ?? [], r]);
2342
+ const numbered = /* @__PURE__ */ new Map();
2343
+ for (const group of groups.values())
2344
+ 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 })));
2345
+ const renumbered = refused.map((r) => numbered.get(r) === r.id ? r : { ...r, id: numbered.get(r) });
2346
+ for (const s of strips) {
2347
+ 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);
2348
+ for (const sl of s.slots) {
2349
+ const [a, b] = sl.along;
2350
+ const slot = sl.result.layout.items[c.dragged].rect;
2351
+ const result = sl.result;
2352
+ out.push({
2353
+ id: sl.id,
2354
+ priority: 1,
2355
+ hit: rect(s.rect.x, a, s.rect.width, b - a),
2356
+ armedHit: rect(grown.x, a, grown.width, b - a),
2357
+ arm: "dwell",
2358
+ strip: s.rect,
2359
+ slot,
2360
+ item: c.dragged,
2361
+ place: sl.place,
2362
+ after: () => result
2363
+ });
2364
+ }
2365
+ }
2366
+ return { targets: out, refusals: renumbered, strips: rects };
2367
+ }
2368
+ var withoutHits = (t) => {
2369
+ const { hits: _pieces, ...rest } = t;
2370
+ return rest;
2371
+ };
2372
+ function insideStrips(r, strips) {
2373
+ const s = strips.find((x) => overlaps(x.rect, r));
2374
+ if (!s) return null;
2375
+ 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);
2376
+ }
2377
+ function clearOfStrips(t, dragged, strips) {
2378
+ return {
2379
+ ...t,
2380
+ after(point, grab) {
2381
+ const first = t.after(point, grab);
2382
+ const at = first.layout.items[dragged]?.rect;
2383
+ if (!at) return first;
2384
+ let dx = 0;
2385
+ for (const s of strips) {
2386
+ const r = rect(at.x + dx, at.y, at.width, at.height);
2387
+ if (!overlaps(r, s)) continue;
2388
+ dx += s.x + s.width / 2 < r.x + r.width / 2 ? s.x + s.width - r.x : s.x - (r.x + r.width);
2389
+ }
2390
+ return dx === 0 ? first : t.after({ x: at.x + dx + (grab?.x ?? at.width / 2), y: point.y }, grab);
2391
+ }
2392
+ };
2393
+ }
2394
+
2221
2395
  // src/scene/targets.ts
2222
2396
  function specsOf(c, kind) {
2223
2397
  const { scene } = c;
@@ -2340,7 +2514,9 @@ function generate(scene, dragged, options) {
2340
2514
  const pieces = homeSlot < 0 && homePieces.length ? { hits: [hit, ...homePieces] } : {};
2341
2515
  targets2.push({ id: targetId({ kind: "home", item: dragged }), priority: 1, hit, ...pieces, item: dragged, place: { kind: "home" }, after: homeAfter });
2342
2516
  }
2343
- return { targets: targets2, refusals: refused, lost: [...new Set(lost)].filter((id) => !targets2.some((t) => t.id === id)) };
2517
+ const lostIds = [...new Set(lost)].filter((id) => !targets2.some((t) => t.id === id));
2518
+ const layered = withRailStrips(c, targets2, refused);
2519
+ return { targets: layered.targets, refusals: layered.refusals, lost: lostIds };
2344
2520
  }
2345
2521
  function targets(scene, dragged, options = {}) {
2346
2522
  return generate(scene, dragged, options).targets;
@@ -2373,6 +2549,9 @@ export {
2373
2549
  SIDES,
2374
2550
  ZONES,
2375
2551
  RAIL_MODES,
2552
+ RAIL_VISIBILITIES,
2553
+ RAIL_STRIP_MIN,
2554
+ DEFAULT_RAIL_MAGNET,
2376
2555
  DEFAULT_STRIP,
2377
2556
  DEFAULT_HIT_BAND,
2378
2557
  DEFAULT_FLOAT_SIZE,
@@ -2411,4 +2590,4 @@ export {
2411
2590
  refusals,
2412
2591
  stops
2413
2592
  };
2414
- //# sourceMappingURL=chunk-6GQ3PEZA.js.map
2593
+ //# sourceMappingURL=chunk-5CSWQSH7.js.map