@n-uf/docking 26.11.56 → 26.11.57

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.
@@ -50,7 +50,13 @@ var columnFromTemplate = (t, id, side, ring, items) => ({
50
50
  });
51
51
  var railModeOf = (state, side) => side === "left" || side === "right" ? state.railModes?.[side] === "icons" ? "icons" : "titles" : "icons";
52
52
  var axisOf = (side) => side === "left" || side === "right" ? "column" : "row";
53
- var keepClearFor = (state, who) => (state.keepClear ?? []).filter((c) => who === "floats" || c.for !== "floats").map((c) => ({ x: c.x, y: c.y, width: c.width, height: c.height }));
53
+ var isAnchoredKeepClear = (c) => "region" in c;
54
+ var keepClearFor = (state, layout, who) => {
55
+ const takes = (f) => who === "floats" || f !== "floats";
56
+ const fixed = (state.keepClear ?? []).filter((c) => !isAnchoredKeepClear(c) && takes(c.for)).map((c) => ({ x: c.x, y: c.y, width: c.width, height: c.height }));
57
+ const anchored2 = (layout.keepClear ?? []).filter((c) => takes(c.for)).map((c) => ({ ...c.rect }));
58
+ return anchored2.length === 0 ? fixed : [...fixed, ...anchored2];
59
+ };
54
60
  function railColumnOf(state, side, kind) {
55
61
  if (state.rails?.[side]) return void 0;
56
62
  return state.edges.filter((e) => e.side === side && !e.compact && e.hidden !== true && zoneTakes(e, "start", kind)).reduce((m, e) => !m || e.ring < m.ring ? e : m, void 0);
@@ -261,7 +267,7 @@ function floatShape(item, f) {
261
267
  }
262
268
 
263
269
  // src/solve.ts
264
- import { rect as rect6 } from "@n-uf/placement";
270
+ import { rect as rect7 } from "@n-uf/placement";
265
271
 
266
272
  // src/targets/ids.ts
267
273
  function targetId(parts) {
@@ -744,16 +750,16 @@ function solveEdgeStack(state, edge, ids, length, room, previous) {
744
750
  }
745
751
 
746
752
  // src/solve/bars.ts
747
- function cutEdge(d, edge, area8, cut2) {
753
+ function cutEdge(d, edge, area9, cut2) {
748
754
  const column = axisOf(edge.side) === "column";
749
- const length = column ? area8.height : area8.width;
750
- const room = Math.max(0, column ? area8.width : area8.height);
755
+ const length = column ? area9.height : area9.width;
756
+ const room = Math.max(0, column ? area9.width : area9.height);
751
757
  const cap = d.caps.get(edge.id);
752
758
  const solvedAs = cap === void 0 ? edge : { ...edge, cross: { ...edge.cross, max: Math.min(edge.cross.max, cap) } };
753
759
  const solved = solveEdge(d.state, solvedAs, d.owned.get(edge), length, room, d.prevEdge(edge));
754
- const band = cutEdges(area8, [{ id: edge.id, side: edge.side, size: solved.stack.items.length === 0 ? 0 : solved.stack.cross }]);
760
+ const band = cutEdges(area9, [{ id: edge.id, side: edge.side, size: solved.stack.items.length === 0 ? 0 : solved.stack.cross }]);
755
761
  emit(d, edge, band.bands[edge.id], solved);
756
- return cut2 ? band.rest : area8;
762
+ return cut2 ? band.rest : area9;
757
763
  }
758
764
 
759
765
  // src/solve/floats.ts
@@ -849,7 +855,7 @@ function placeFloat(item, f, region, avoid, content, stage, earlier = [], docked
849
855
  const fit = w > region.width + EPS4 ? { ...fit0, rect: rect2(region.x, fit0.rect.y, w, fit0.rect.height) } : fit0;
850
856
  return { from, fo, form, fit };
851
857
  }
852
- function layFloats(d, stage, content, inset) {
858
+ function layFloats(d, stage, content, inset, chrome) {
853
859
  const { state, notes, items, edges } = d;
854
860
  const avoid = [];
855
861
  for (const l of Object.values(items)) avoid.push(l.rect);
@@ -858,7 +864,7 @@ function layFloats(d, stage, content, inset) {
858
864
  if (axisOf(e.side) === "row" && e.cross > 0) avoid.push(e.rect);
859
865
  if (e.menu) avoid.push(e.menu.rect);
860
866
  }
861
- for (const c of keepClearFor(state, "floats")) avoid.push(c);
867
+ for (const c of chrome) avoid.push(c);
862
868
  const floatRegion2 = rect2(stage.x + px(inset.left), stage.y, Math.max(0, stage.width - px(inset.left) - px(inset.right)), stage.height);
863
869
  const drawn = [];
864
870
  const noForm = /* @__PURE__ */ new Set();
@@ -899,18 +905,55 @@ function layFloats(d, stage, content, inset) {
899
905
  return floats;
900
906
  }
901
907
 
908
+ // src/solve/keep-clear.ts
909
+ import { rect as rect3 } from "@n-uf/placement";
910
+ var regionRect = (region, content) => region === "content" ? content : null;
911
+ var roomFor = (c, region) => {
912
+ const w = c.minRegion?.width;
913
+ const h = c.minRegion?.height;
914
+ return !(Number.isFinite(w) && region.width < w) && !(Number.isFinite(h) && region.height < h);
915
+ };
916
+ function anchoredRect(c, region) {
917
+ if (!(region.width > 0) || !(region.height > 0) || !Number.isFinite(c.size) || c.size <= 0 || !roomFor(c, region)) return null;
918
+ const w = Math.min(c.size, region.width);
919
+ const h = Math.min(c.size, region.height);
920
+ switch (c.side) {
921
+ case "left":
922
+ return rect3(region.x, region.y, w, region.height);
923
+ case "right":
924
+ return rect3(region.x + region.width - w, region.y, w, region.height);
925
+ case "top":
926
+ return rect3(region.x, region.y, region.width, h);
927
+ case "bottom":
928
+ return rect3(region.x, region.y + region.height - h, region.width, h);
929
+ default:
930
+ return null;
931
+ }
932
+ }
933
+ function resolveKeepClear(state, content) {
934
+ const anchored2 = (state.keepClear ?? []).filter(isAnchoredKeepClear);
935
+ if (anchored2.length === 0) return void 0;
936
+ const out = [];
937
+ for (const c of anchored2) {
938
+ const region = regionRect(c.region, content);
939
+ const r = region ? anchoredRect(c, region) : null;
940
+ if (r) out.push({ rect: r, for: c.for === "floats" ? "floats" : "all", ...typeof c.id === "string" ? { id: c.id } : {} });
941
+ }
942
+ return out;
943
+ }
944
+
902
945
  // src/solve/insets.ts
903
- import { EPS as EPS5, rect as rect3 } from "@n-uf/placement";
946
+ import { EPS as EPS5, rect as rect4 } from "@n-uf/placement";
904
947
  function insetOf(d) {
905
948
  const { state } = d;
906
949
  const docked = d.order.some((e) => isSide(e) && e.accepts.length > 0 && d.owned.get(e).some((id) => isDockingPanel(state.items[id])));
907
950
  const inset = state.insetWhen === "docked" && !docked ? {} : state.inset ?? {};
908
951
  return { inset, docked };
909
952
  }
910
- var insideInset = (outer, inset) => rect3(outer.x + px(inset.left), outer.y + px(inset.top), Math.max(0, outer.width - px(inset.left) - px(inset.right)), Math.max(0, outer.height - px(inset.top) - px(inset.bottom)));
911
- function insetReach(area8, f) {
912
- const up = area8.y <= f.outer.y + px(f.inset.top) + EPS5 ? px(f.inset.top) : 0;
913
- const down = area8.y + area8.height >= f.outer.y + f.outer.height - px(f.inset.bottom) - EPS5 ? px(f.inset.bottom) : 0;
953
+ var insideInset = (outer, inset) => rect4(outer.x + px(inset.left), outer.y + px(inset.top), Math.max(0, outer.width - px(inset.left) - px(inset.right)), Math.max(0, outer.height - px(inset.top) - px(inset.bottom)));
954
+ function insetReach(area9, f) {
955
+ const up = area9.y <= f.outer.y + px(f.inset.top) + EPS5 ? px(f.inset.top) : 0;
956
+ const down = area9.y + area9.height >= f.outer.y + f.outer.height - px(f.inset.bottom) - EPS5 ? px(f.inset.bottom) : 0;
914
957
  return { up, down };
915
958
  }
916
959
 
@@ -933,18 +976,18 @@ function contentNotes(d, content) {
933
976
  }
934
977
 
935
978
  // src/solve/sides.ts
936
- import { EPS as EPS8, rect as rect5 } from "@n-uf/placement";
979
+ import { EPS as EPS8, rect as rect6 } from "@n-uf/placement";
937
980
 
938
981
  // src/solve/columns.ts
939
982
  import { EPS as EPS7 } from "@n-uf/placement";
940
983
  import { formCrossMin as formCrossMin3, formMenu as formMenu2, formSetsCross as formSetsCross3 } from "@n-uf/placement/stack";
941
984
  var isChrome = (state, c) => !c.dyn && isSideBar(state, c.edge);
942
- function columnsOf(d, sideEdges, area8, tall) {
985
+ function columnsOf(d, sideEdges, area9, tall) {
943
986
  const { state } = d;
944
987
  return sideEdges.map((edge) => {
945
988
  const side = edge.side;
946
- const solved = solveEdge(state, edge, d.owned.get(edge), tall(edge), Math.max(0, area8.width), d.prevEdge(edge));
947
- const width = solved.stack.items.length === 0 ? 0 : Math.min(solved.stack.cross, area8.width);
989
+ const solved = solveEdge(state, edge, d.owned.get(edge), tall(edge), Math.max(0, area9.width), d.prevEdge(edge));
990
+ const width = solved.stack.items.length === 0 ? 0 : Math.min(solved.stack.cross, area9.width);
948
991
  const visible = d.owned.get(edge).filter((id) => !state.items[id].closed);
949
992
  const dyn = (edge.column === true || edge.giveWay === true) && state.rails?.[side] !== void 0 && visible.length > 0;
950
993
  const forms = (id) => formsOf(state.items[id], "column");
@@ -964,7 +1007,7 @@ function columnsOf(d, sideEdges, area8, tall) {
964
1007
  };
965
1008
  });
966
1009
  }
967
- function giveWay(d, cols, area8, gutter) {
1010
+ function giveWay(d, cols, area9, gutter) {
968
1011
  const { state, previous, fresh, opened } = d;
969
1012
  const ride = state.handFold === "ride";
970
1013
  const cmin = state.contentMin ? px(state.contentMin.width) : void 0;
@@ -986,7 +1029,7 @@ function giveWay(d, cols, area8, gutter) {
986
1029
  let used = 0;
987
1030
  for (const [c, w] of widths) used += w > 0 ? w + (c.edge.outsideInset === true ? 0 : gutter) : 0;
988
1031
  for (const s of railSides) used += railW(s) + gutter;
989
- let excess = cmin === void 0 ? -Infinity : floor === void 0 ? used + cmin - area8.width : Math.max(used - chrome + cmin, used + floor) - area8.width;
1032
+ let excess = cmin === void 0 ? -Infinity : floor === void 0 ? used + cmin - area9.width : Math.max(used - chrome + cmin, used + floor) - area9.width;
990
1033
  for (const c of shrinkOrder) {
991
1034
  if (excess <= EPS7) break;
992
1035
  const w = widths.get(c);
@@ -1026,7 +1069,7 @@ function giveWay(d, cols, area8, gutter) {
1026
1069
  }
1027
1070
  return evaluate(auto);
1028
1071
  }
1029
- function columnRoom(d, cols, area8, f) {
1072
+ function columnRoom(d, cols, area9, f) {
1030
1073
  const { state } = d;
1031
1074
  const cmin = state.contentMin ? px(state.contentMin.width) : void 0;
1032
1075
  const openMin = (ids, least) => Math.max(
@@ -1047,7 +1090,7 @@ function columnRoom(d, cols, area8, f) {
1047
1090
  if (cmin === void 0 || colMins.length === 0) return;
1048
1091
  const allBars = cols.filter((c) => c.width > 0 && isChrome(state, c)).reduce((s, c) => s + c.width + (c.edge.outsideInset === true ? 0 : f.gutter), 0);
1049
1092
  const bars = d.chromeAllowance === void 0 ? allBars : allBars - Math.min(allBars, d.chromeAllowance);
1050
- const width = area8.width - bars - (state.insetWhen === "docked" && !f.docked ? px(state.inset?.left) + px(state.inset?.right) : 0);
1093
+ const width = area9.width - bars - (state.insetWhen === "docked" && !f.docked ? px(state.inset?.left) + px(state.inset?.right) : 0);
1051
1094
  const need = cmin + Math.min(...colMins) + f.gutter;
1052
1095
  d.columnRoom = width >= need - EPS7;
1053
1096
  if (!d.columnRoom) d.notes.push({ code: "no-column-room", width, need });
@@ -1080,7 +1123,7 @@ function giveWayNotes(d, g, cols) {
1080
1123
  }
1081
1124
 
1082
1125
  // src/solve/rails.ts
1083
- import { rect as rect4 } from "@n-uf/placement";
1126
+ import { rect as rect5 } from "@n-uf/placement";
1084
1127
  import { fitStack as fitStack2 } from "@n-uf/placement/stack";
1085
1128
  function riderBars(d, c) {
1086
1129
  const { state } = d;
@@ -1099,12 +1142,12 @@ function layRiders(d, host, riders, top) {
1099
1142
  const bars = riderBars(d, c);
1100
1143
  const y0 = y;
1101
1144
  for (const b of bars) {
1102
- const at = rect4(hr.x, y, hr.width, b.h);
1145
+ const at = rect5(hr.x, y, hr.width, b.h);
1103
1146
  const it = state.items[b.id];
1104
1147
  items[b.id] = { rect: at, ...controlsOf(b.f), kind: it.kind, axis: "column", form: b.form, formKind: b.f?.kind ?? "header", edge: c.edge.id, zone: zoneOf(it), rides: host.edge.id, folded: "hand", foldedBy: "hand" };
1105
1148
  y += b.h;
1106
1149
  }
1107
- edges[c.edge.id] = { side: c.edge.side, ring: finite(c.edge.ring, 0), rect: rect4(hr.x, y0, hr.width, y - y0), cross: 0, menu: null, items: bars.map((b) => b.id), tabs: [], stack: c.solved.stack, free: c.solved.free, rides: host.edge.id, folded: "hand" };
1150
+ edges[c.edge.id] = { side: c.edge.side, ring: finite(c.edge.ring, 0), rect: rect5(hr.x, y0, hr.width, y - y0), cross: 0, menu: null, items: bars.map((b) => b.id), tabs: [], stack: c.solved.stack, free: c.solved.free, rides: host.edge.id, folded: "hand" };
1108
1151
  }
1109
1152
  }
1110
1153
  function layRail(d, side, railRect, railed, g) {
@@ -1144,7 +1187,7 @@ function layRail(d, side, railRect, railed, g) {
1144
1187
  const ri = tileOf(id);
1145
1188
  const p = placed.get(id);
1146
1189
  const form = p ? p.form : ri >= 0 ? ri : forms.length === 0 ? 0 : startOf(it, forms);
1147
- const at = p ? rect4(railRect.x, railRect.y + p.rect.y, railRect.width, p.rect.height) : rect4(railRect.x, y, railRect.width, ri >= 0 ? px(forms[ri].main.natural) : railRect.width);
1190
+ const at = p ? rect5(railRect.x, railRect.y + p.rect.y, railRect.width, p.rect.height) : rect5(railRect.x, y, railRect.width, ri >= 0 ? px(forms[ri].main.natural) : railRect.width);
1148
1191
  const title = forms[form]?.title === true;
1149
1192
  items[id] = { rect: at, ...controlsOf(forms[form]), kind: it.kind, axis: "column", form, formKind: "rail", edge: c.edge.id, zone: zoneOf(it), rail: side, ...title ? { railTitle: side } : {}, folded: g.auto.has(c) ? "auto" : "hand", foldedBy: startOf(it, forms) > 0 ? "hand" : "auto" };
1150
1193
  segments.push({ id, edge: c.edge.id, rect: at });
@@ -1154,26 +1197,26 @@ function layRail(d, side, railRect, railed, g) {
1154
1197
  }
1155
1198
 
1156
1199
  // src/solve/sides.ts
1157
- function laySides(d, sideEdges, area8, f) {
1158
- const H = area8.height;
1159
- const reach = insetReach(area8, f);
1200
+ function laySides(d, sideEdges, area9, f) {
1201
+ const H = area9.height;
1202
+ const reach = insetReach(area9, f);
1160
1203
  const tall = (edge) => H + (edge.outsideInset === true ? reach.up + reach.down : 0);
1161
- const cols = columnsOf(d, sideEdges, area8, tall);
1162
- const g = giveWay(d, cols, area8, f.gutter);
1163
- columnRoom(d, cols, area8, f);
1204
+ const cols = columnsOf(d, sideEdges, area9, tall);
1205
+ const g = giveWay(d, cols, area9, f.gutter);
1206
+ columnRoom(d, cols, area9, f);
1164
1207
  giveWayNotes(d, g, cols);
1165
- const walk = { x0: area8.x, x1: area8.x + area8.width };
1166
- for (const side of ["left", "right"]) laySide(d, side, cols, g, area8, f, walk, reach.up, tall);
1167
- return rect5(walk.x0, area8.y, Math.max(0, walk.x1 - walk.x0), H);
1208
+ const walk = { x0: area9.x, x1: area9.x + area9.width };
1209
+ for (const side of ["left", "right"]) laySide(d, side, cols, g, area9, f, walk, reach.up, tall);
1210
+ return rect6(walk.x0, area9.y, Math.max(0, walk.x1 - walk.x0), H);
1168
1211
  }
1169
1212
  function forced(d, c, length, w) {
1170
1213
  const edge = { ...c.edge, cross: { ...c.edge.cross, min: w, max: w } };
1171
1214
  const { size: _s, ...plain } = edge;
1172
1215
  return solveEdge(d.state, plain, d.owned.get(c.edge), length, w, d.prevEdge(c.edge));
1173
1216
  }
1174
- function laySide(d, side, cols, g, area8, f, walk, upInset, tall) {
1217
+ function laySide(d, side, cols, g, area9, f, walk, upInset, tall) {
1175
1218
  const { state, edges } = d;
1176
- const H = area8.height;
1219
+ const H = area9.height;
1177
1220
  const outsideSideBar = (c) => c.width > 0 && isOutsideSideBar(state, c.edge) && !g.railed(c) && !g.riding(c);
1178
1221
  const all = cols.filter((c) => c.side === side);
1179
1222
  const mine = [...all.filter(outsideSideBar), ...all.filter((c) => !outsideSideBar(c))];
@@ -1188,7 +1231,7 @@ function laySide(d, side, cols, g, area8, f, walk, upInset, tall) {
1188
1231
  let railPlace = null;
1189
1232
  const placeRail = () => {
1190
1233
  const lead = barLaid ? gap : 0;
1191
- return side === "left" ? rect5(walk.x0 - lead, area8.y, railW, H) : rect5(walk.x1 + lead - railW, area8.y, railW, H);
1234
+ return side === "left" ? rect6(walk.x0 - lead, area9.y, railW, H) : rect6(walk.x1 + lead - railW, area9.y, railW, H);
1192
1235
  };
1193
1236
  for (const c of mine) {
1194
1237
  if (!railPlace && !outsideSideBar(c)) {
@@ -1205,7 +1248,7 @@ function laySide(d, side, cols, g, area8, f, walk, upInset, tall) {
1205
1248
  if (outsideSideBar(c)) barLaid = true;
1206
1249
  const base = { side: c.edge.side, ring: finite(c.edge.ring, 0), cross: 0, menu: null, items: zoneSorted(state, c.visible), tabs: [], stack: c.solved.stack, free: c.solved.free };
1207
1250
  if (g.railed(c)) {
1208
- edges[c.edge.id] = { ...base, rect: rect5(railRect.x, area8.y, 0, H), folded: g.auto.has(c) ? "auto" : "hand" };
1251
+ edges[c.edge.id] = { ...base, rect: rect6(railRect.x, area9.y, 0, H), folded: g.auto.has(c) ? "auto" : "hand" };
1209
1252
  continue;
1210
1253
  }
1211
1254
  if (g.riding(c)) continue;
@@ -1214,29 +1257,29 @@ function laySide(d, side, cols, g, area8, f, walk, upInset, tall) {
1214
1257
  let solved = top > 0 || Math.abs(w - c.width) > EPS8 ? forced(d, c, H - top, w) : c.solved;
1215
1258
  let r;
1216
1259
  if (c.edge.outsideInset === true) {
1217
- const y0 = area8.y - upInset;
1260
+ const y0 = area9.y - upInset;
1218
1261
  const h = tall(c.edge);
1219
1262
  if (side === "left") {
1220
- r = rect5(walk.x0 - gap, y0, w, h);
1263
+ r = rect6(walk.x0 - gap, y0, w, h);
1221
1264
  walk.x0 += w;
1222
1265
  } else {
1223
- r = rect5(walk.x1 + gap - w, y0, w, h);
1266
+ r = rect6(walk.x1 + gap - w, y0, w, h);
1224
1267
  walk.x1 -= w;
1225
1268
  }
1226
1269
  if (Math.abs(h - H) > EPS8 || Math.abs(w - c.width) > EPS8) solved = forced(d, c, h, w);
1227
1270
  } else if (side === "left") {
1228
- r = rect5(walk.x0, area8.y + top, w, H - top);
1271
+ r = rect6(walk.x0, area9.y + top, w, H - top);
1229
1272
  walk.x0 += w > 0 ? w + f.gutter : 0;
1230
1273
  if (w > 0) gap = f.gutter;
1231
1274
  } else {
1232
1275
  walk.x1 -= w;
1233
- r = rect5(walk.x1, area8.y + top, w, H - top);
1276
+ r = rect6(walk.x1, area9.y + top, w, H - top);
1234
1277
  walk.x1 -= w > 0 ? f.gutter : 0;
1235
1278
  if (w > 0) gap = f.gutter;
1236
1279
  }
1237
1280
  emit(d, c.edge, r, solved, w < c.width - EPS8 ? { shrunk: true } : {});
1238
1281
  }
1239
- if (host && riders.length > 0) layRiders(d, host, riders, area8.y);
1282
+ if (host && riders.length > 0) layRiders(d, host, riders, area9.y);
1240
1283
  if (railRect) layRail(d, side, railRect, railed, g);
1241
1284
  if (state.rails?.[side]) d.railPlaces[side] = railPlace ?? placeRail();
1242
1285
  }
@@ -1258,29 +1301,29 @@ function solveState(given, options) {
1258
1301
  const l = way ? lay(way.caps, way.notes) : first;
1259
1302
  return ignored.length === 0 ? l : { ...l, notes: [...l.notes, ...ignored.map((edge) => ({ code: "show-in-ignored", edge }))] };
1260
1303
  }
1261
- var withHeightOf = (area8, over2) => rect6(over2.x, area8.y, over2.width, area8.height);
1304
+ var withHeightOf = (area9, over2) => rect7(over2.x, area9.y, over2.width, area9.height);
1262
1305
  function layOut(given, options, caps, gave) {
1263
1306
  const d = createDraft(given, options, caps);
1264
1307
  const { state, order } = d;
1265
- const stage = rect6(finite(state.stage.x, 0), finite(state.stage.y, 0), px(state.stage.width), px(state.stage.height));
1308
+ const stage = rect7(finite(state.stage.x, 0), finite(state.stage.y, 0), px(state.stage.width), px(state.stage.height));
1266
1309
  const { inset, docked } = insetOf(d);
1267
1310
  const reserved = order.filter((e) => e.mode !== "overlay");
1268
1311
  const outsideBar = (e) => !isSide(e) && e.span !== "between" && e.outsideInset === true;
1269
1312
  let outer = stage;
1270
1313
  for (const e of reserved) if (outsideBar(e)) outer = cutEdge(d, e, outer, true);
1271
- let area8 = insideInset(outer, inset);
1272
- for (const e of reserved) if (!isSide(e) && e.span !== "between" && !outsideBar(e)) area8 = cutEdge(d, e, area8, true);
1273
- const wide = area8;
1274
- area8 = laySides(d, reserved.filter(isSide), area8, { inset, gutter: px(state.gutter), docked, outer });
1275
- for (const e of reserved) if (!isSide(e) && e.span === "between") area8 = cutEdge(d, e, area8, true);
1276
- const content = area8;
1314
+ let area9 = insideInset(outer, inset);
1315
+ for (const e of reserved) if (!isSide(e) && e.span !== "between" && !outsideBar(e)) area9 = cutEdge(d, e, area9, true);
1316
+ const wide = area9;
1317
+ area9 = laySides(d, reserved.filter(isSide), area9, { inset, gutter: px(state.gutter), docked, outer });
1318
+ for (const e of reserved) if (!isSide(e) && e.span === "between") area9 = cutEdge(d, e, area9, true);
1319
+ const content = area9;
1277
1320
  let over2 = content;
1278
1321
  for (const e of order) {
1279
1322
  if (e.mode !== "overlay") continue;
1280
1323
  if (isSide(e) || e.span !== "full") over2 = cutEdge(d, e, over2, true);
1281
1324
  else {
1282
1325
  const across2 = e.outsideInset === true ? outer : wide;
1283
- over2 = withHeightOf(cutEdge(d, e, rect6(across2.x, over2.y, across2.width, over2.height), true), over2);
1326
+ over2 = withHeightOf(cutEdge(d, e, rect7(across2.x, over2.y, across2.width, over2.height), true), over2);
1284
1327
  }
1285
1328
  }
1286
1329
  for (const n of gave) {
@@ -1288,13 +1331,14 @@ function layOut(given, options, caps, gave) {
1288
1331
  if (n.code === "bar-shrunk" && d.edges[n.edge]) d.edges[n.edge] = { ...d.edges[n.edge], shrunk: true };
1289
1332
  }
1290
1333
  contentNotes(d, content);
1291
- const floats = layFloats(d, stage, content, inset);
1334
+ const keepClear = resolveKeepClear(state, content);
1335
+ const floats = layFloats(d, stage, content, inset, keepClearFor(state, { keepClear }, "floats"));
1292
1336
  const { items, edges, rails, railPlaces, columnRoom: columnRoom2, notes } = d;
1293
- return { items, edges, content, floats, rails, railPlaces, ...columnRoom2 !== void 0 ? { columnRoom: columnRoom2 } : {}, notes };
1337
+ return { items, edges, content, floats, rails, railPlaces, ...columnRoom2 !== void 0 ? { columnRoom: columnRoom2 } : {}, ...keepClear ? { keepClear } : {}, notes };
1294
1338
  }
1295
1339
 
1296
1340
  // src/dividers.ts
1297
- import { rect as rect7 } from "@n-uf/placement";
1341
+ import { rect as rect8 } from "@n-uf/placement";
1298
1342
  import { dividers as stackDividers, resetBetween as stackReset, resizeBetween as stackResize } from "@n-uf/placement/stack";
1299
1343
  var laid = (state, layout) => layout && stateOf(layout) === state && Object.values(layout.edges).every((e) => inputOf(e.stack) !== void 0) ? layout : solve(state);
1300
1344
  function dividers(state, layout) {
@@ -1303,7 +1347,7 @@ function dividers(state, layout) {
1303
1347
  for (const [edge, e] of Object.entries(lay.edges)) {
1304
1348
  const input = inputOf(e.stack);
1305
1349
  if (!input) continue;
1306
- for (const d of stackDividers(input, e.stack)) out.push({ edge, before: d.before, after: d.after, rect: rect7(e.rect.x + d.rect.x, e.rect.y + d.rect.y, d.rect.width, d.rect.height), range: d.range });
1350
+ for (const d of stackDividers(input, e.stack)) out.push({ edge, before: d.before, after: d.after, rect: rect8(e.rect.x + d.rect.x, e.rect.y + d.rect.y, d.rect.width, d.rect.height), range: d.range });
1307
1351
  }
1308
1352
  return out;
1309
1353
  }
@@ -1359,7 +1403,7 @@ function floatObstacles(state, l, id) {
1359
1403
  if (axisOf(e.side) === "row" && e.cross > 0) rects.push(e.rect);
1360
1404
  if (e.menu) rects.push(e.menu.rect);
1361
1405
  }
1362
- for (const c of keepClearFor(state, "floats")) rects.push(c);
1406
+ for (const c of keepClearFor(state, l, "floats")) rects.push(c);
1363
1407
  return { rects: rects.filter(some), docked };
1364
1408
  }
1365
1409
  function obstacleStop(drawn, obstacles, axis, drag, span) {
@@ -1426,7 +1470,7 @@ function fitAxis(start, length, b, drag, hit) {
1426
1470
  }
1427
1471
  return [a, to - a];
1428
1472
  }
1429
- function fitResize(state, id, rect19, moving) {
1473
+ function fitResize(state, id, rect20, moving) {
1430
1474
  const f = state.floats.find((x2) => x2.id === id);
1431
1475
  const item = Object.hasOwn(state.items, id) ? state.items[id] : void 0;
1432
1476
  if (!f || !item || item.fixed) return null;
@@ -1444,8 +1488,8 @@ function fitResize(state, id, rect19, moving) {
1444
1488
  const { rects: obstacles, docked } = floatObstacles(state, l, id);
1445
1489
  const hit = /* @__PURE__ */ new Set();
1446
1490
  const stops2 = f.stays ? obstacles.slice(docked) : obstacles;
1447
- const [x, width] = fitAxis(rect19.x, rect19.width, { min: min.width, max: max.width, lo: region.x, hi: region.x + region.width, stop: obstacleStop(drawn, stops2, "x", dragX ?? "end", [drawn.y, drawn.y + drawn.height]) }, dragX, hit);
1448
- const [y, height] = fitAxis(rect19.y, rect19.height, { min: min.height, max: max.height, lo: region.y, hi: region.y + region.height, stop: obstacleStop(drawn, stops2, "y", dragY ?? "end", [x, x + width]) }, dragY, hit);
1491
+ const [x, width] = fitAxis(rect20.x, rect20.width, { min: min.width, max: max.width, lo: region.x, hi: region.x + region.width, stop: obstacleStop(drawn, stops2, "x", dragX ?? "end", [drawn.y, drawn.y + drawn.height]) }, dragX, hit);
1492
+ const [y, height] = fitAxis(rect20.y, rect20.height, { min: min.height, max: max.height, lo: region.y, hi: region.y + region.height, stop: obstacleStop(drawn, stops2, "y", dragY ?? "end", [x, x + width]) }, dragY, hit);
1449
1493
  const { anchor: _a, ...plain } = f;
1450
1494
  const placed = placeFloat(item, { ...plain, rect: { x, y, width, height } }, region, obstacles, l.content, state.stage, [], docked).fit.rect;
1451
1495
  if (Math.abs(placed.x - x) > EPS9 || Math.abs(placed.y - y) > EPS9) hit.add("docked");
@@ -1713,8 +1757,8 @@ function orientFloat(state, id, to) {
1713
1757
  const turned = { ...f, rect: { x: f.rect.x, y: f.rect.y, width: size.width, height: size.height }, orient: to };
1714
1758
  return withItem({ ...state, floats: state.floats.map((g, k) => k === i ? turned : g) }, kept);
1715
1759
  }
1716
- function resizeFloat(state, floatId, rect19, moving = { right: true, bottom: true }) {
1717
- const fit = fitResize(state, floatId, rect19, moving);
1760
+ function resizeFloat(state, floatId, rect20, moving = { right: true, bottom: true }) {
1761
+ const fit = fitResize(state, floatId, rect20, moving);
1718
1762
  const i = state.floats.findIndex((f) => f.id === floatId);
1719
1763
  const item = itemOf(state, floatId);
1720
1764
  if (!fit || i < 0 || !item) return state;
@@ -1794,7 +1838,7 @@ function drawnFloatSize(item, f) {
1794
1838
  }
1795
1839
 
1796
1840
  // src/store.ts
1797
- import { EPS as EPS10, rect as rect8 } from "@n-uf/placement";
1841
+ import { EPS as EPS10, rect as rect9 } from "@n-uf/placement";
1798
1842
  var isNum = (x) => typeof x === "number" && Number.isFinite(x);
1799
1843
  var isSize = (x) => isNum(x) && x > 0;
1800
1844
  var isObject = (x) => typeof x === "object" && x !== null && !Array.isArray(x);
@@ -2037,7 +2081,7 @@ function read(data, base) {
2037
2081
  const stays = f.stays === true && !a;
2038
2082
  if (f.stays !== void 0 && !stays) drop(`float:${id}:stays`);
2039
2083
  placed.add(id);
2040
- const r = rect8(f.x, f.y, f.width, f.height);
2084
+ const r = rect9(f.x, f.y, f.width, f.height);
2041
2085
  const drawn = drawnFloatSize(items[id], { rect: r, ...o ? { orient: o } : {} });
2042
2086
  floats.push({ id, rect: clampFloat(r, base.stage, drawn), ...o ? { orient: o } : {}, ...a ? { anchor: a } : {}, ...since !== void 0 ? { since } : {}, ...stays ? { stays: true } : {} });
2043
2087
  }
@@ -2070,10 +2114,10 @@ function read(data, base) {
2070
2114
  }
2071
2115
 
2072
2116
  // src/targets.ts
2073
- import { EPS as EPS20, PLANE, area as area6, clamp as clamp2, contains, overlaps as overlaps7, rect as rect17 } from "@n-uf/placement";
2117
+ import { EPS as EPS20, PLANE, area as area6, clamp as clamp2, contains, overlaps as overlaps7, rect as rect18 } from "@n-uf/placement";
2074
2118
 
2075
2119
  // src/targets/anchor.ts
2076
- import { EPS as EPS11, area, rect as rect9, subtract } from "@n-uf/placement";
2120
+ import { EPS as EPS11, area, rect as rect10, subtract } from "@n-uf/placement";
2077
2121
  var OTHER = { left: "right", right: "left", top: "bottom", bottom: "top" };
2078
2122
  function anchorTargets(state, dragged, options) {
2079
2123
  const none = { targets: [], refusals: [], lost: [] };
@@ -2090,7 +2134,7 @@ function anchorTargets(state, dragged, options) {
2090
2134
  const placed = layout.edges[edge.id]?.rect;
2091
2135
  const slot = layout.items[dragged]?.rect;
2092
2136
  if (placed && slot && area(placed) > EPS11) {
2093
- const pieces = keepClearFor(state, "targets").reduce((ps, c) => ps.flatMap((p) => subtract(p, rect9(c.x, c.y, c.width, c.height))), [placed]).filter((p) => p.width >= 1 && p.height >= 1);
2137
+ const pieces = keepClearFor(state, now, "targets").reduce((ps, c) => ps.flatMap((p) => subtract(p, rect10(c.x, c.y, c.width, c.height))), [placed]).filter((p) => p.width >= 1 && p.height >= 1);
2094
2138
  if (pieces.length > 0) {
2095
2139
  const hit = pieces.reduce((a, p) => area(p) > area(a) ? p : a);
2096
2140
  const result = { state: moved, layout };
@@ -2102,7 +2146,7 @@ function anchorTargets(state, dragged, options) {
2102
2146
  }
2103
2147
 
2104
2148
  // src/targets/edges.ts
2105
- import { EPS as EPS12, area as area2, rect as rect10 } from "@n-uf/placement";
2149
+ import { EPS as EPS12, area as area2, rect as rect11 } from "@n-uf/placement";
2106
2150
  import { formCrossMin as formCrossMin4, formMenu as formMenu3, formSetsCross as formSetsCross4, itemSteps as itemSteps3 } from "@n-uf/placement/stack";
2107
2151
 
2108
2152
  // src/targets/kinds.ts
@@ -2137,7 +2181,7 @@ function reservedRect(state, l, id) {
2137
2181
  const len2 = column ? it.rect.height : it.rect.width;
2138
2182
  const keep = Math.min(len2, Math.max(0, Number.isFinite(f.main.natural) ? f.main.natural : len2));
2139
2183
  const shift = it.zone === "end" ? len2 - keep : it.zone === "center" ? (len2 - keep) / 2 : 0;
2140
- return column ? rect10(it.rect.x, it.rect.y + shift, it.rect.width, keep) : rect10(it.rect.x + shift, it.rect.y, keep, it.rect.height);
2184
+ return column ? rect11(it.rect.x, it.rect.y + shift, it.rect.width, keep) : rect11(it.rect.x + shift, it.rect.y, keep, it.rect.height);
2141
2185
  }
2142
2186
  function slotAt(c, zone, line, id, place, lands, home = false) {
2143
2187
  const result = c.settle(markUsed(moveAmong(c.state, c.dragged, place, c.others), c.dragged));
@@ -2318,7 +2362,7 @@ function edgeSpec(c, edge, as) {
2318
2362
  const marker = (s) => {
2319
2363
  const slot = s.result.layout.items[dragged].rect;
2320
2364
  const e = s.result.layout.edges[edge.id];
2321
- return column ? rect10(e.rect.x, slot.y, e.cross, 0) : rect10(slot.x, e.rect.y, 0, e.cross);
2365
+ return column ? rect11(e.rect.x, slot.y, e.cross, 0) : rect11(slot.x, e.rect.y, 0, e.cross);
2322
2366
  };
2323
2367
  const takes = (zone) => accepts && zoneTakes(edge, zone, kind);
2324
2368
  const tooThick = thickerThan(formsOf(state.items[dragged], axisOf(edge.side)), el.stack.cross);
@@ -2368,9 +2412,9 @@ function placeKey(s, id) {
2368
2412
  });
2369
2413
  }
2370
2414
  function soundness(state, base, dragged) {
2371
- const chrome = keepClearFor(state, "targets");
2372
2415
  const noteKey = (n) => "edge" in n && (n.code === "overflow" || n.code === "too-wide") ? `${n.edge}:${n.code}:${"id" in n ? n.id : ""}` : null;
2373
2416
  const hadNotes = new Set(base.notes.map(noteKey).filter((k) => k !== null));
2417
+ const chrome = keepClearFor(state, {}, "targets");
2374
2418
  return (after) => {
2375
2419
  if (after.notes.some((n) => {
2376
2420
  const k = noteKey(n);
@@ -2392,7 +2436,8 @@ function soundness(state, base, dragged) {
2392
2436
  const me = after.items[dragged];
2393
2437
  if (!me) return true;
2394
2438
  const fixedAfter = Object.entries(after.items).filter(([id, it]) => it.fixed && !(it.inMenu && itemSteps4(state.items[id])) && id !== dragged).map(([id]) => reservedRect(state, after, id));
2395
- return !chrome.some((c) => overlaps2(me.rect, c)) && !fixedAfter.some((f) => overlaps2(me.rect, f));
2439
+ const onChrome = chrome.some((c) => overlaps2(me.rect, c)) || (after.keepClear ?? []).some((c) => c.for !== "floats" && overlaps2(me.rect, c.rect));
2440
+ return !onChrome && !fixedAfter.some((f) => overlaps2(me.rect, f));
2396
2441
  };
2397
2442
  }
2398
2443
  function context(state, dragged, options, others = []) {
@@ -2422,17 +2467,17 @@ function context(state, dragged, options, others = []) {
2422
2467
  }
2423
2468
 
2424
2469
  // src/targets/ownership.ts
2425
- import { EPS as EPS15, area as area3, overlaps as overlaps3, rect as rect12, subtract as subtract2 } from "@n-uf/placement";
2470
+ import { EPS as EPS15, area as area3, overlaps as overlaps3, rect as rect13, subtract as subtract2 } from "@n-uf/placement";
2426
2471
  import { formBody, itemSteps as itemSteps5 } from "@n-uf/placement/stack";
2427
2472
 
2428
2473
  // src/targets/meet.ts
2429
- import { EPS as EPS13, rect as rect11 } from "@n-uf/placement";
2474
+ import { EPS as EPS13, rect as rect12 } from "@n-uf/placement";
2430
2475
  function meet(a, b) {
2431
2476
  const x = Math.max(a.x, b.x);
2432
2477
  const y = Math.max(a.y, b.y);
2433
2478
  const w = Math.min(a.x + a.width, b.x + b.width) - x;
2434
2479
  const h = Math.min(a.y + a.height, b.y + b.height) - y;
2435
- return w > EPS13 && h > EPS13 ? rect11(x, y, w, h) : null;
2480
+ return w > EPS13 && h > EPS13 ? rect12(x, y, w, h) : null;
2436
2481
  }
2437
2482
 
2438
2483
  // src/targets/model.ts
@@ -2444,19 +2489,19 @@ var isBody = (f) => !!f && formBody(f);
2444
2489
  var bandOf = (s) => {
2445
2490
  const a = Math.min(...s.zones.map((z) => z.a));
2446
2491
  const b = Math.max(...s.zones.map((z) => z.b));
2447
- return s.vertical ? rect12(s.owned[0], a, s.owned[1] - s.owned[0], b - a) : rect12(a, s.owned[0], b - a, s.owned[1] - s.owned[0]);
2492
+ return s.vertical ? rect13(s.owned[0], a, s.owned[1] - s.owned[0], b - a) : rect13(a, s.owned[0], b - a, s.owned[1] - s.owned[0]);
2448
2493
  };
2449
2494
  var ownedRectOf = (s) => {
2450
2495
  const b = bandOf(s);
2451
2496
  if (!s.ownedAlong) return b;
2452
2497
  const [a0, a1] = s.ownedAlong;
2453
- return s.vertical ? rect12(b.x, a0, b.width, a1 - a0) : rect12(a0, b.y, a1 - a0, b.height);
2498
+ return s.vertical ? rect13(b.x, a0, b.width, a1 - a0) : rect13(a0, b.y, a1 - a0, b.height);
2454
2499
  };
2455
2500
  function ownedRectsOf(s, along2) {
2456
2501
  if (along2.length === 0) return [];
2457
2502
  const o = ownedRectOf(s);
2458
2503
  if (s.ownedAlong) return [o];
2459
- return along2.map(([a, b]) => s.vertical ? rect12(o.x, a, o.width, b - a) : rect12(a, o.y, b - a, o.height));
2504
+ return along2.map(([a, b]) => s.vertical ? rect13(o.x, a, o.width, b - a) : rect13(a, o.y, b - a, o.height));
2460
2505
  }
2461
2506
  function drawnOf(c, live) {
2462
2507
  const edges = Object.entries(c.now.edges).filter(([id, e]) => area3(e.rect) > EPS15 && c.lay.has(id)).map(([id, e]) => ({ spec: live.find((s) => s.edge?.id === id) ?? null, rect: e.rect, lay: c.lay.get(id) }));
@@ -2469,7 +2514,7 @@ function drawnOf(c, live) {
2469
2514
  const run = me?.rail === side ? rail.segments.filter((g) => g.edge === me.edge).map((g) => g.rect) : [];
2470
2515
  if (run.length === 0) return [{ spec, rect: rail.rect, lay }];
2471
2516
  const top = Math.min(...run.map((r) => r.y));
2472
- const own = rect12(rail.rect.x, top, rail.rect.width, Math.max(...run.map((r) => r.y + r.height)) - top);
2517
+ const own = rect13(rail.rect.x, top, rail.rect.width, Math.max(...run.map((r) => r.y + r.height)) - top);
2473
2518
  const column = live.find((s) => s.kind === "railColumn" && s.edge?.id === me.edge);
2474
2519
  return [...subtract2(rail.rect, own).map((r) => ({ spec, rect: r, lay })), ...column ? [{ spec: column, rect: own, lay: column.lay }] : []];
2475
2520
  });
@@ -2479,7 +2524,7 @@ function homeRectOf(c, ownSpec) {
2479
2524
  const own = c.now.items[c.dragged];
2480
2525
  if (!own || own.floating || !own.edge) return null;
2481
2526
  const o = own.rect;
2482
- const hull3 = (a, b) => rect12(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.max(a.x + a.width, b.x + b.width) - Math.min(a.x, b.x), Math.max(a.y + a.height, b.y + b.height) - Math.min(a.y, b.y));
2527
+ const hull3 = (a, b) => rect13(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.max(a.x + a.width, b.x + b.width) - Math.min(a.x, b.x), Math.max(a.y + a.height, b.y + b.height) - Math.min(a.y, b.y));
2483
2528
  if (own.inMenu) return o;
2484
2529
  if (!ownSpec) {
2485
2530
  const e = c.now.edges[own.edge];
@@ -2487,7 +2532,7 @@ function homeRectOf(c, ownSpec) {
2487
2532
  return e && vanishes && !e.folded && !e.rides && area3(e.rect) > EPS15 ? hull3(o, e.rect) : o;
2488
2533
  }
2489
2534
  const [c0, c1] = ownSpec.across();
2490
- return ownSpec.vertical ? hull3(o, rect12(c0, o.y, c1 - c0, o.height)) : hull3(o, rect12(o.x, c0, o.width, c1 - c0));
2535
+ return ownSpec.vertical ? hull3(o, rect13(c0, o.y, c1 - c0, o.height)) : hull3(o, rect13(o.x, c0, o.width, c1 - c0));
2491
2536
  }
2492
2537
  function ownersOf(c, live, drawn, alongOf) {
2493
2538
  const ownEdge = c.now.items[c.dragged]?.edge;
@@ -2502,14 +2547,14 @@ function ownersOf(c, live, drawn, alongOf) {
2502
2547
  ...live.flatMap((s) => {
2503
2548
  const rects = ownedRectsOf(s, alongOf(s));
2504
2549
  if (!s.thinOwned) return rects.map((r) => ({ spec: s, rect: r, lay: s.lay, place: !s.drawn }));
2505
- const thin = (r) => s.vertical ? rect12(Math.max(r.x, s.thinOwned[0]), r.y, Math.min(r.x + r.width, s.thinOwned[1]) - Math.max(r.x, s.thinOwned[0]), r.height) : rect12(r.x, Math.max(r.y, s.thinOwned[0]), r.width, Math.min(r.y + r.height, s.thinOwned[1]) - Math.max(r.y, s.thinOwned[0]));
2550
+ const thin = (r) => s.vertical ? rect13(Math.max(r.x, s.thinOwned[0]), r.y, Math.min(r.x + r.width, s.thinOwned[1]) - Math.max(r.x, s.thinOwned[0]), r.height) : rect13(r.x, Math.max(r.y, s.thinOwned[0]), r.width, Math.min(r.y + r.height, s.thinOwned[1]) - Math.max(r.y, s.thinOwned[0]));
2506
2551
  return rects.flatMap((r) => [{ spec: s, rect: thin(r), lay: s.lay, place: true }, ...subtract2(r, thin(r)).map((d) => ({ spec: s, rect: d, lay: s.lay, place: true, deep: true }))]);
2507
2552
  }).filter((o) => area3(o.rect) > EPS15),
2508
2553
  // Every seen rect: the edges the tiler doesn't read (folded, riding, taking nothing) among them.
2509
2554
  ...drawn.map((d) => ({ ...d, place: false }))
2510
2555
  ];
2511
2556
  }
2512
- function ownership(c, live, alongOf) {
2557
+ function ownership(c, live, alongOf, aloneOf) {
2513
2558
  const { state, now, dragged } = c;
2514
2559
  const drawn = drawnOf(c, live);
2515
2560
  const owners = ownersOf(c, live, drawn, alongOf);
@@ -2520,15 +2565,15 @@ function ownership(c, live, alongOf) {
2520
2565
  const place = !s.drawn;
2521
2566
  return o.place === place ? !place || o.lay.at < s.lay.at : !o.place;
2522
2567
  };
2523
- const takingRects = (s) => s.drawn ? s.zones.filter((z) => s.slots.some((sl) => sl.ok && sl.zone === z.zone)).map((z) => s.vertical ? rect12(s.owned[0], z.a, s.owned[1] - s.owned[0], z.b - z.a) : rect12(z.a, s.owned[0], z.b - z.a, s.owned[1] - s.owned[0])) : [];
2568
+ const takingRects = (s) => s.drawn ? s.zones.filter((z) => s.slots.some((sl) => sl.ok && sl.zone === z.zone)).map((z) => s.vertical ? rect13(s.owned[0], z.a, s.owned[1] - s.owned[0], z.b - z.a) : rect13(z.a, s.owned[0], z.b - z.a, s.owned[1] - s.owned[0])) : [];
2524
2569
  const thinRectOf = (s) => {
2525
2570
  const b = bandOf(s);
2526
2571
  const [t0, t1] = s.thinOwned;
2527
- return s.vertical ? rect12(t0, b.y, t1 - t0, b.height) : rect12(b.x, t0, b.width, t1 - t0);
2572
+ return s.vertical ? rect13(t0, b.y, t1 - t0, b.height) : rect13(b.x, t0, b.width, t1 - t0);
2528
2573
  };
2529
2574
  const endsOf = (s) => {
2530
2575
  const e = s.edge ? now.edges[s.id] : void 0;
2531
- if (!e || EDGE_KINDS[s.kind].virtual) return null;
2576
+ if (!e) return null;
2532
2577
  const span = s.vertical ? [e.rect.y, e.rect.y + e.rect.height] : [e.rect.x, e.rect.x + e.rect.width];
2533
2578
  return span[1] - span[0] > EPS15 ? span : null;
2534
2579
  };
@@ -2536,33 +2581,39 @@ function ownership(c, live, alongOf) {
2536
2581
  const ends = endsOf(s);
2537
2582
  if (!ends) return [];
2538
2583
  const [lo2, hi] = s.vertical ? [r.y, r.y + r.height] : [r.x, r.x + r.width];
2539
- return less([[lo2, hi]], [ends]).map(([u, w]) => s.vertical ? rect12(r.x, u, r.width, w - u) : rect12(u, r.y, w - u, r.height));
2584
+ return less([[lo2, hi]], [ends]).map(([u, w]) => s.vertical ? rect13(r.x, u, r.width, w - u) : rect13(u, r.y, w - u, r.height));
2540
2585
  };
2541
2586
  const ownSpanOf = (s) => {
2542
2587
  const ends = endsOf(s);
2543
2588
  if (!ends) return null;
2544
2589
  const [o0, o1] = s.owned;
2545
- return s.vertical ? rect12(o0, ends[0], o1 - o0, ends[1] - ends[0]) : rect12(ends[0], o0, ends[1] - ends[0], o1 - o0);
2590
+ return s.vertical ? rect13(o0, ends[0], o1 - o0, ends[1] - ends[0]) : rect13(ends[0], o0, ends[1] - ends[0], o1 - o0);
2591
+ };
2592
+ const heldBySpec = /* @__PURE__ */ new Map();
2593
+ const heldOf = (d) => {
2594
+ let held = heldBySpec.get(d);
2595
+ if (!held) {
2596
+ const span = ownSpanOf(d);
2597
+ heldBySpec.set(d, held = span ? ownedRectsOf(d, alongOf(d)).flatMap((r) => meet(r, span) ?? []) : aloneOf(d));
2598
+ }
2599
+ return held;
2546
2600
  };
2547
2601
  const reachLess = (o, r, s) => {
2548
- const span = ownSpanOf(s);
2549
- if (!o.spec || !span) return [r];
2550
- return pastEnds(o.spec, r).flatMap((p) => meet(p, span) ?? []).reduce((acc, cut2) => acc.flatMap((q) => subtract2(q, cut2)), [r]);
2602
+ const held = heldOf(s);
2603
+ if (!o.spec || held.length === 0) return [r];
2604
+ return pastEnds(o.spec, r).flatMap((p) => held.flatMap((h) => meet(p, h) ?? [])).reduce((acc, cut2) => acc.flatMap((q) => subtract2(q, cut2)), [r]);
2551
2605
  };
2552
2606
  const reachYields = (s) => {
2553
2607
  const past = pastEnds(s, bandOf(s));
2554
2608
  if (past.length === 0) return [];
2555
- return live.filter((d) => d !== s).flatMap((d) => {
2556
- const span = ownSpanOf(d);
2557
- return span ? ownedRectsOf(d, alongOf(d)).flatMap((r) => meet(r, span) ?? []) : [];
2558
- }).flatMap((q) => past.flatMap((p) => meet(p, q) ?? []));
2609
+ return live.filter((d) => d !== s).flatMap((d) => heldOf(d)).flatMap((q) => past.flatMap((p) => meet(p, q) ?? []));
2559
2610
  };
2560
2611
  const taken = new Map(
2561
2612
  live.map((s) => [
2562
2613
  s,
2563
2614
  [
2564
2615
  ...owners.filter((o) => wins(o, s)).flatMap((o) => (o.deep ? takingRects(s).reduce((acc, t) => acc.flatMap((r) => subtract2(r, t)), [o.rect]) : [o.rect]).flatMap((r) => reachLess(o, r, s))),
2565
- ...EDGE_KINDS[s.kind].virtual ? owners.filter((o) => o.spec !== s && !wins(o, s)).flatMap((o) => subtract2(o.rect, ownedRectOf(s))) : [],
2616
+ ...EDGE_KINDS[s.kind].virtual ? owners.filter((o) => o.spec !== s && !wins(o, s)).flatMap((o) => subtract2(o.rect, ownedRectOf(s)).flatMap((r) => reachLess(o, r, s))) : [],
2566
2617
  ...s.thinOwned ? live.filter((d) => d !== s).flatMap((d) => takingRects(d).flatMap((t) => subtract2(t, thinRectOf(s)))) : [],
2567
2618
  ...reachYields(s)
2568
2619
  ]
@@ -2625,7 +2676,7 @@ function ownership(c, live, alongOf) {
2625
2676
  const e = s.edge;
2626
2677
  if (!e) return [];
2627
2678
  const column = axisOf(e.side) === "column";
2628
- const across2 = (a, b) => column ? rect12(-1e9, a, 2e9, b - a) : rect12(a, -1e9, b - a, 2e9);
2679
+ const across2 = (a, b) => column ? rect13(-1e9, a, 2e9, b - a) : rect13(a, -1e9, b - a, 2e9);
2629
2680
  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));
2630
2681
  return [...reserved, ...cutsOf(s).bodies.map(([a, b]) => across2(a, b))].filter((b) => area3(b) > EPS15);
2631
2682
  };
@@ -2639,13 +2690,13 @@ function ownership(c, live, alongOf) {
2639
2690
  }
2640
2691
 
2641
2692
  // src/targets/tiles.ts
2642
- import { EPS as EPS16, area as area4, overlaps as overlaps4, rect as rect13, subtract as subtract3 } from "@n-uf/placement";
2693
+ import { EPS as EPS16, area as area4, overlaps as overlaps4, rect as rect14, subtract as subtract3 } from "@n-uf/placement";
2643
2694
  function tilerOf(spec) {
2644
2695
  const data = EDGE_KINDS[spec.kind];
2645
2696
  const v = spec.vertical;
2646
2697
  const band = (a, b, after) => {
2647
2698
  const [c0, c1] = spec.across(after);
2648
- return v ? rect13(c0, a, c1 - c0, b - a) : rect13(a, c0, b - a, c1 - c0);
2699
+ return v ? rect14(c0, a, c1 - c0, b - a) : rect14(a, c0, b - a, c1 - c0);
2649
2700
  };
2650
2701
  const keepAt = (line, h) => v ? { x: h.x + h.width / 2, y: line } : { x: line, y: h.y + h.height / 2 };
2651
2702
  const tile = (zone, hit, more) => ({ edge: spec.id, spec, edgeKind: spec.kind, vertical: v, zone, hit, ...more });
@@ -2653,7 +2704,7 @@ function tilerOf(spec) {
2653
2704
  const h = t.hit;
2654
2705
  const [h0, h1] = v ? [h.x, h.x + h.width] : [h.y, h.y + h.height];
2655
2706
  const [c0, c1] = [Math.max(h0, spec.owned[0]), Math.min(h1, spec.owned[1])];
2656
- const part = (a, b) => v ? rect13(a, h.y, b - a, h.height) : rect13(h.x, a, h.width, b - a);
2707
+ const part = (a, b) => v ? rect14(a, h.y, b - a, h.height) : rect14(h.x, a, h.width, b - a);
2657
2708
  const beyond = less([[h0, h1]], [spec.owned]);
2658
2709
  if (beyond.length === 0) return [t];
2659
2710
  if (c1 - c0 <= EPS16) return [{ ...t, order: data.overreach }];
@@ -2706,7 +2757,7 @@ function reachStrips(c, spec, room, ends) {
2706
2757
  const pieces = room.filter(inEdge);
2707
2758
  if (!ends || pieces.length === 0) return { pieces: [...room], before: [], after: [] };
2708
2759
  const [c0, c1] = spec.across();
2709
- const bandOf2 = (a, b) => spec.vertical ? rect13(c0, a, c1 - c0, b - a) : rect13(a, c0, b - a, c1 - c0);
2760
+ const bandOf2 = (a, b) => spec.vertical ? rect14(c0, a, c1 - c0, b - a) : rect14(a, c0, b - a, c1 - c0);
2710
2761
  const across2 = c.state.edges.filter((e) => axisOf(e.side) === "column" !== spec.vertical).map((e) => c.now.edges[e.id]);
2711
2762
  const drawnBetween = (a, b) => b - a > EPS16 && across2.some((e) => !!e && e.cross > EPS16 && area4(e.rect) > EPS16 && overlaps4(e.rect, bandOf2(a, b)));
2712
2763
  const first = pieces[0][0];
@@ -2725,7 +2776,7 @@ function tileEdge(c, spec, { cuts, bodies }, lost) {
2725
2776
  const own = spec.own ? v ? [spec.own.y, spec.own.y + spec.own.height] : [spec.own.x, spec.own.x + spec.own.width] : null;
2726
2777
  const { band, keepAt, tile, split } = tilerOf(spec);
2727
2778
  const drawn = spec.edge ? c.now.edges[spec.id]?.rect : void 0;
2728
- const alongLimit = drawn && (v ? drawn.height : drawn.width) > EPS16 ? v ? rect13(-1e9, drawn.y, 2e9, drawn.height) : rect13(drawn.x, -1e9, drawn.width, 2e9) : null;
2779
+ const alongLimit = drawn && (v ? drawn.height : drawn.width) > EPS16 ? v ? rect14(-1e9, drawn.y, 2e9, drawn.height) : rect14(drawn.x, -1e9, drawn.width, 2e9) : null;
2729
2780
  const refused = (zone, hit, reason) => {
2730
2781
  const inEdge = alongLimit ? meet(hit, alongLimit) : hit;
2731
2782
  const shown = inEdge && meet(inEdge, c.state.stage);
@@ -2805,7 +2856,7 @@ function tileEdge(c, spec, { cuts, bodies }, lost) {
2805
2856
  const [a, b] = own;
2806
2857
  const h = band(a, b);
2807
2858
  const o = spec.own;
2808
- const hit = v ? rect13(Math.min(h.x, o.x), a, Math.max(h.x + h.width, o.x + o.width) - Math.min(h.x, o.x), b - a) : rect13(a, Math.min(h.y, o.y), b - a, Math.max(h.y + h.height, o.y + o.height) - Math.min(h.y, o.y));
2859
+ const hit = v ? rect14(Math.min(h.x, o.x), a, Math.max(h.x + h.width, o.x + o.width) - Math.min(h.x, o.x), b - a) : rect14(a, Math.min(h.y, o.y), b - a, Math.max(h.y + h.height, o.y + o.height) - Math.min(h.y, o.y));
2809
2860
  out.push(tile(home?.zone ?? zoneOf(c.state.items[c.dragged]), hit, { kind: "home", id: home ? home.id : targetId({ kind: "home", item: c.dragged }), order: 0, priority: home ? data.priority : 1, keep: null, place: { kind: "home" } }));
2810
2861
  }
2811
2862
  return out;
@@ -2839,7 +2890,7 @@ function placeReach(t, pieces, placed, landed, gone) {
2839
2890
  (p) => t.vertical ? p.y <= h.y + EPS16 && p.y + p.height >= h.y + h.height - EPS16 && (Math.abs(p.x - h.x - h.width) < EPS16 || Math.abs(p.x + p.width - h.x) < EPS16) : p.x <= h.x + EPS16 && p.x + p.width >= h.x + h.width - EPS16 && (Math.abs(p.y - h.y - h.height) < EPS16 || Math.abs(p.y + p.height - h.y) < EPS16)
2840
2891
  );
2841
2892
  if (!joint) continue;
2842
- const merged = t.vertical ? rect13(Math.min(h.x, joint.x), h.y, Math.max(h.x + h.width, joint.x + joint.width) - Math.min(h.x, joint.x), h.height) : rect13(h.x, Math.min(h.y, joint.y), h.width, Math.max(h.y + h.height, joint.y + joint.height) - Math.min(h.y, joint.y));
2893
+ const merged = t.vertical ? rect14(Math.min(h.x, joint.x), h.y, Math.max(h.x + h.width, joint.x + joint.width) - Math.min(h.x, joint.x), h.height) : rect14(h.x, Math.min(h.y, joint.y), h.width, Math.max(h.y + h.height, joint.y + joint.height) - Math.min(h.y, joint.y));
2843
2894
  placed[i] = cover.length > 1 ? withPieces(placed[i], cover.map((r, j) => j === k ? merged : r)) : { ...placed[i], hit: merged };
2844
2895
  return;
2845
2896
  }
@@ -2907,10 +2958,10 @@ function clipTiles(tiles, own, chrome, lost) {
2907
2958
  }
2908
2959
 
2909
2960
  // src/targets/rail-strip.ts
2910
- import { EPS as EPS18, overlaps as overlaps5, rect as rect15, subtract as subtract4 } from "@n-uf/placement";
2961
+ import { EPS as EPS18, overlaps as overlaps5, rect as rect16, subtract as subtract4 } from "@n-uf/placement";
2911
2962
 
2912
2963
  // src/targets/virtual.ts
2913
- import { EPS as EPS17, clamp, rect as rect14 } from "@n-uf/placement";
2964
+ import { EPS as EPS17, clamp, rect as rect15 } from "@n-uf/placement";
2914
2965
  function ringsOf(c, side) {
2915
2966
  const seen = sideRings(c.state.edges, side);
2916
2967
  const kept = c.rest.edges.filter((e) => e.side === side).map((e) => seen.get(e.id) ?? e.ring);
@@ -2988,7 +3039,7 @@ function columnLines(c, side, railLands) {
2988
3039
  ownedAlong: p.owned,
2989
3040
  drawn: false,
2990
3041
  // Where the new column's edge lands: the line itself, inside the stage.
2991
- marker: () => rect14(clamp(l.x, stage.x, stage.x + stage.width), span.y, 0, span.height)
3042
+ marker: () => rect15(clamp(l.x, stage.x, stage.x + stage.width), span.y, 0, span.height)
2992
3043
  };
2993
3044
  });
2994
3045
  }
@@ -3015,7 +3066,7 @@ function ownColumnRun(c, side, rail) {
3015
3066
  const tiles = shown.segments.filter((s) => s.edge === edge.id).map((s) => s.rect);
3016
3067
  if (tiles.length === 0) return null;
3017
3068
  const top = Math.min(...tiles.map((r) => r.y));
3018
- const spec = railColumnSpec(c, edge, rect14(shown.rect.x, top, shown.rect.width, Math.max(...tiles.map((r) => r.y + r.height)) - top));
3069
+ const spec = railColumnSpec(c, edge, rect15(shown.rect.x, top, shown.rect.width, Math.max(...tiles.map((r) => r.y + r.height)) - top));
3019
3070
  if (!spec) return null;
3020
3071
  const stays = ({ layout }) => layout.items[dragged]?.rail === side && layout.items[dragged]?.edge === edge.id;
3021
3072
  return { ...spec, own: null, holds: false, homePriority: EDGE_KINDS.railStop.priority, slots: spec.slots.map((s) => s.home ? { ...s, id: homeId } : { ...s, ok: s.ok && stays(s.result) }) };
@@ -3053,7 +3104,7 @@ function railStops(c, side) {
3053
3104
  } else {
3054
3105
  const firstCol = mine.find((e) => e.column === true);
3055
3106
  const outer = railOuter(c, side);
3056
- zone = rect14(side === "left" ? outer : outer - RAIL_EDGE, placeRect.y, RAIL_EDGE, placeRect.height);
3107
+ zone = rect15(side === "left" ? outer : outer - RAIL_EDGE, placeRect.y, RAIL_EDGE, placeRect.height);
3057
3108
  stops2.push({ y: placeRect.y, ring: firstCol ? rings.before(firstCol) : rings.count });
3058
3109
  }
3059
3110
  const ownRail = now.items[dragged]?.rail === side;
@@ -3084,7 +3135,7 @@ function railStops(c, side) {
3084
3135
  owned: rail && rail.segments.length > 0 ? [at.x, at.x + at.width] : side === "left" ? [at.x, at.x + Math.min(at.width, EDGE_KINDS.railStop.place)] : [at.x + at.width - Math.min(at.width, EDGE_KINDS.railStop.place), at.x + at.width],
3085
3136
  ownedAlong: null,
3086
3137
  drawn: !!rail && rail.segments.length > 0,
3087
- marker: (s) => rect14(at.x, s.result.layout.items[dragged].rect.y, at.width, 0)
3138
+ marker: (s) => rect15(at.x, s.result.layout.items[dragged].rect.y, at.width, 0)
3088
3139
  };
3089
3140
  }
3090
3141
 
@@ -3104,7 +3155,7 @@ function columnStrip(c, side, policy) {
3104
3155
  const r = el.rect;
3105
3156
  const railWidth = result.layout.items[c.dragged].tab ? r.width : edge.cross.rail ?? 30;
3106
3157
  const [x, w] = across(side, side === "left" ? r.x : r.x + r.width, policy.railStripWidth ?? Math.max(RAIL_STRIP_MIN, railWidth));
3107
- return { side, rect: rect15(x, r.y, w, r.height), slots: [{ id: targetId({ kind: "rail", side, ring: edge.ring }), place, along: [r.y, r.y + r.height], result }] };
3158
+ return { side, rect: rect16(x, r.y, w, r.height), slots: [{ id: targetId({ kind: "rail", side, ring: edge.ring }), place, along: [r.y, r.y + r.height], result }] };
3108
3159
  }
3109
3160
  function declaredStrip(c, side, policy) {
3110
3161
  const template = c.state.columns?.[side];
@@ -3121,7 +3172,7 @@ function declaredStrip(c, side, policy) {
3121
3172
  const cuts = [a, ...slots.slice(1).map((s, i) => (slots[i].line + s.line) / 2), b];
3122
3173
  return {
3123
3174
  side,
3124
- rect: rect15(x, a, w, b - a),
3175
+ rect: rect16(x, a, w, b - a),
3125
3176
  slots: slots.map((s, i) => ({ id: s.id, place: s.place, along: [cuts[i], cuts[i + 1]], result: s.result }))
3126
3177
  };
3127
3178
  }
@@ -3206,7 +3257,7 @@ ${r.zone}`) ?? [], r]);
3206
3257
  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 })));
3207
3258
  const renumbered = refused.map((r) => numbered.get(r) === r.id ? r : { ...r, id: numbered.get(r) });
3208
3259
  for (const s of strips) {
3209
- const grown = s.side === "left" ? rect15(s.rect.x, s.rect.y, s.rect.width + policy.magnet, s.rect.height) : rect15(s.rect.x - policy.magnet, s.rect.y, s.rect.width + policy.magnet, s.rect.height);
3260
+ const grown = s.side === "left" ? rect16(s.rect.x, s.rect.y, s.rect.width + policy.magnet, s.rect.height) : rect16(s.rect.x - policy.magnet, s.rect.y, s.rect.width + policy.magnet, s.rect.height);
3210
3261
  for (const sl of s.slots) {
3211
3262
  const [a, b] = sl.along;
3212
3263
  const slot = sl.result.layout.items[c.dragged].rect;
@@ -3214,8 +3265,8 @@ ${r.zone}`) ?? [], r]);
3214
3265
  out.push({
3215
3266
  id: sl.id,
3216
3267
  priority: 1,
3217
- hit: rect15(s.rect.x, a, s.rect.width, b - a),
3218
- armedHit: rect15(grown.x, a, grown.width, b - a),
3268
+ hit: rect16(s.rect.x, a, s.rect.width, b - a),
3269
+ armedHit: rect16(grown.x, a, grown.width, b - a),
3219
3270
  arm: "dwell",
3220
3271
  // Armed, its room opens at once: a host that draws only a marker reads that from this one flag, as for any target.
3221
3272
  opensRoom: true,
@@ -3236,7 +3287,7 @@ var withoutHits = (t) => {
3236
3287
  function insideStrips(r, strips) {
3237
3288
  const s = strips.find((x) => overlaps5(x.rect, r));
3238
3289
  if (!s) return null;
3239
- return s.side === "left" ? rect15(s.rect.x + s.rect.width, r.y, r.width, r.height) : rect15(s.rect.x - r.width, r.y, r.width, r.height);
3290
+ return s.side === "left" ? rect16(s.rect.x + s.rect.width, r.y, r.width, r.height) : rect16(s.rect.x - r.width, r.y, r.width, r.height);
3240
3291
  }
3241
3292
  function clearOfStrips(t, dragged, strips) {
3242
3293
  return {
@@ -3247,7 +3298,7 @@ function clearOfStrips(t, dragged, strips) {
3247
3298
  if (!at) return first;
3248
3299
  let dx = 0;
3249
3300
  for (const s of strips) {
3250
- const r = rect15(at.x + dx, at.y, at.width, at.height);
3301
+ const r = rect16(at.x + dx, at.y, at.width, at.height);
3251
3302
  if (!overlaps5(r, s)) continue;
3252
3303
  dx += s.x + s.width / 2 < r.x + r.width / 2 ? s.x + s.width - r.x : s.x - (r.x + r.width);
3253
3304
  }
@@ -3257,7 +3308,7 @@ function clearOfStrips(t, dragged, strips) {
3257
3308
  }
3258
3309
 
3259
3310
  // src/targets/min-hit.ts
3260
- import { EPS as EPS19, area as area5, rect as rect16, subtract as subtract5 } from "@n-uf/placement";
3311
+ import { EPS as EPS19, area as area5, rect as rect17, subtract as subtract5 } from "@n-uf/placement";
3261
3312
  function kindOf(c, t) {
3262
3313
  const p = parseTargetId(t.id);
3263
3314
  if (!p) return null;
@@ -3279,21 +3330,21 @@ var withPieces2 = (t, ps) => {
3279
3330
  return { ...rest, hit: largest3(ps), ...ps.length > 1 ? { hits: ps } : {} };
3280
3331
  };
3281
3332
  function growths(r, axis, d) {
3282
- const [lo2, hi] = axis === "x" ? [rect16(r.x - d, r.y, d, r.height), rect16(r.x + r.width, r.y, d, r.height)] : [rect16(r.x, r.y - d, r.width, d), rect16(r.x, r.y + r.height, r.width, d)];
3333
+ const [lo2, hi] = axis === "x" ? [rect17(r.x - d, r.y, d, r.height), rect17(r.x + r.width, r.y, d, r.height)] : [rect17(r.x, r.y - d, r.width, d), rect17(r.x, r.y + r.height, r.width, d)];
3283
3334
  const h = d / 2;
3284
- const halves = axis === "x" ? [rect16(r.x - h, r.y, h, r.height), rect16(r.x + r.width, r.y, h, r.height)] : [rect16(r.x, r.y - h, r.width, h), rect16(r.x, r.y + r.height, r.width, h)];
3335
+ const halves = axis === "x" ? [rect17(r.x - h, r.y, h, r.height), rect17(r.x + r.width, r.y, h, r.height)] : [rect17(r.x, r.y - h, r.width, h), rect17(r.x, r.y + r.height, r.width, h)];
3285
3336
  return [[lo2], [hi], halves];
3286
3337
  }
3287
3338
  var union = (a, gs) => {
3288
3339
  const x0 = Math.min(a.x, ...gs.map((g) => g.x));
3289
3340
  const y0 = Math.min(a.y, ...gs.map((g) => g.y));
3290
- return rect16(x0, y0, Math.max(a.x + a.width, ...gs.map((g) => g.x + g.width)) - x0, Math.max(a.y + a.height, ...gs.map((g) => g.y + g.height)) - y0);
3341
+ return rect17(x0, y0, Math.max(a.x + a.width, ...gs.map((g) => g.x + g.width)) - x0, Math.max(a.y + a.height, ...gs.map((g) => g.y + g.height)) - y0);
3291
3342
  };
3292
3343
  function mayGrow(c, targets2, i, grow, minOf, zone, away) {
3293
3344
  const s = c.state.stage;
3294
3345
  for (const g of grow) {
3295
3346
  if (g.x < s.x - EPS19 || g.y < s.y - EPS19 || g.x + g.width > s.x + s.width + EPS19 || g.y + g.height > s.y + s.height + EPS19) return false;
3296
- if ([...keepClearFor(c.state, "targets"), ...away].some((r) => overlaps6(r, g))) return false;
3347
+ if ([...keepClearFor(c.state, c.now, "targets"), ...away].some((r) => overlaps6(r, g))) return false;
3297
3348
  if (zone.reduce((ps, z) => ps.flatMap((p) => subtract5(p, z)), [g]).some((p) => area5(p) > EPS19)) return false;
3298
3349
  }
3299
3350
  return targets2.every((o, j) => {
@@ -3309,7 +3360,7 @@ function partialGrowth(c, targets2, i, l, axis, d, m, minOf, zone, away) {
3309
3360
  let best = null;
3310
3361
  for (const [side] of growths(l, axis, d)) {
3311
3362
  const g = side;
3312
- const strip = (a, b) => axis === "x" ? rect16(g.x, a, g.width, b - a) : rect16(a, g.y, b - a, g.height);
3363
+ const strip = (a, b) => axis === "x" ? rect17(g.x, a, g.width, b - a) : rect17(a, g.y, b - a, g.height);
3313
3364
  const cuts = /* @__PURE__ */ new Set([along2[0], along2[1]]);
3314
3365
  for (const o of targets2)
3315
3366
  for (const p of piecesOf(o))
@@ -3372,7 +3423,7 @@ function withMinHit(c, targets2, refusals2, zones) {
3372
3423
  out[j] = withPieces2(o, grow.reduce((ps, g) => cut(ps, g), [...piecesOf(o)]));
3373
3424
  }
3374
3425
  const g0 = grow[0];
3375
- const span = axis === "x" ? rect16(l.x, g0.y, l.width, g0.height) : rect16(g0.x, l.y, g0.width, l.height);
3426
+ const span = axis === "x" ? rect17(l.x, g0.y, l.width, g0.height) : rect17(g0.x, l.y, g0.width, l.height);
3376
3427
  const grown = union(span, grow);
3377
3428
  const others = piecesOf(out[i]).filter((p) => p !== l);
3378
3429
  out[i] = withPieces2(out[i], [...cut([...others, l], grown), grown]);
@@ -3445,7 +3496,7 @@ function emit2(c, placed) {
3445
3496
  function hull(a, b) {
3446
3497
  const x = Math.min(a.x, b.x);
3447
3498
  const y = Math.min(a.y, b.y);
3448
- return rect17(x, y, Math.max(a.x + a.width, b.x + b.width) - x, Math.max(a.y + a.height, b.y + b.height) - y);
3499
+ return rect18(x, y, Math.max(a.x + a.width, b.x + b.width) - x, Math.max(a.y + a.height, b.y + b.height) - y);
3449
3500
  }
3450
3501
  var thicknessChanges = (now, after) => {
3451
3502
  const a = now.content;
@@ -3463,6 +3514,9 @@ function slotOverMoved(now, lifted, after, slot, dragged, onto) {
3463
3514
  return !!r && (Math.abs(r.x - start.x) > EPS20 || Math.abs(r.y - start.y) > EPS20 || Math.abs(r.width - start.width) > EPS20 || Math.abs(r.height - start.height) > EPS20);
3464
3515
  });
3465
3516
  }
3517
+ function aloneRects(tiles) {
3518
+ return tiles.filter((t) => t.kind !== "refuse" && !(t.kind === "reach" && t.of.kind === "refuse")).map((t) => t.hit);
3519
+ }
3466
3520
  function alongOfSlots(s, tiles) {
3467
3521
  const spans = tiles.filter((t) => t.kind === "slot").map((t) => s.vertical ? [t.hit.y, t.hit.y + t.hit.height] : [t.hit.x, t.hit.x + t.hit.width]).sort((a, b) => a[0] - b[0]);
3468
3522
  const out = [];
@@ -3510,7 +3564,7 @@ function generateShown(state, dragged, options, hidden) {
3510
3564
  const live = specsOf(c, item.kind);
3511
3565
  const alone = new Map(live.map((s) => [s, tileEdge(c, s, { cuts: [], bodies: [] }, [])]));
3512
3566
  const along2 = new Map(live.map((s) => [s, alongOfSlots(s, alone.get(s))]));
3513
- const own = ownership(c, live, (s) => along2.get(s));
3567
+ const own = ownership(c, live, (s) => along2.get(s), (s) => aloneRects(alone.get(s)));
3514
3568
  const lost = [];
3515
3569
  const tiles = live.flatMap((spec) => tileEdge(c, spec, own.cutsOf(spec), lost));
3516
3570
  const ownRect = now.items[dragged];
@@ -3518,7 +3572,7 @@ function generateShown(state, dragged, options, hidden) {
3518
3572
  const homeHit = homeRectOf(c, null);
3519
3573
  if (ownRect && homeEdge && homeHit && !tiles.some((t) => t.order === 0))
3520
3574
  tiles.push({ edge: homeEdge.id, spec: null, edgeKind: edgeKindOf(state, homeEdge), vertical: axisOf(homeEdge.side) === "column", zone: zoneOf(item), order: 0, kind: "home", id: targetId({ kind: "home", item: dragged }), priority: 1, place: { kind: "home" }, hit: homeHit, keep: null });
3521
- const placed = clipTiles(tiles, own, keepClearFor(state, "targets"), lost);
3575
+ const placed = clipTiles(tiles, own, keepClearFor(state, now, "targets"), lost);
3522
3576
  const { targets: targets2, refused, ownHome } = emit2(c, placed);
3523
3577
  const homeAfter = () => ({ state, layout: now });
3524
3578
  if (state.floatKinds.includes(item.kind)) {
@@ -3537,12 +3591,12 @@ function generateShown(state, dragged, options, hidden) {
3537
3591
  place: { kind: "float" },
3538
3592
  after(point, grab) {
3539
3593
  const g = grab ?? { x: size.width / 2, y: size.height / 2 };
3540
- const raw = options.floatFromHeld ? heldRect(state, dragged, size, point, g) : rect17(point.x - g.x, point.y - g.y, size.width, size.height);
3594
+ const raw = options.floatFromHeld ? heldRect(state, dragged, size, point, g) : rect18(point.x - g.x, point.y - g.y, size.width, size.height);
3541
3595
  const first = solve(markUsed(floatAt(state, dragged, raw, options.floatOrient), dragged), prev);
3542
3596
  const fitted = first.items[dragged]?.rect;
3543
3597
  const at = fitted ?? raw;
3544
3598
  const placed2 = (x, y, stays) => {
3545
- const s = floatAt(state, dragged, rect17(x, y, size.width, size.height), options.floatOrient);
3599
+ const s = floatAt(state, dragged, rect18(x, y, size.width, size.height), options.floatOrient);
3546
3600
  return c.settle(markUsed(stays ? { ...s, floats: s.floats.map((f) => f.id === dragged ? { ...f, stays: true } : f) } : s, dragged));
3547
3601
  };
3548
3602
  const hand = heldRect(state, dragged, fitted ?? size, point, g);
@@ -3557,7 +3611,7 @@ function generateShown(state, dragged, options, hidden) {
3557
3611
  });
3558
3612
  }
3559
3613
  (state.blocked ?? []).forEach((b, i) => {
3560
- targets2.push({ id: targetId({ kind: "none", index: i }), priority: 1, hit: rect17(b.x, b.y, b.width, b.height), item: dragged, place: { kind: "none" }, after: homeAfter });
3614
+ targets2.push({ id: targetId({ kind: "none", index: i }), priority: 1, hit: rect18(b.x, b.y, b.width, b.height), item: dragged, place: { kind: "none" }, after: homeAfter });
3561
3615
  });
3562
3616
  const sameAsHome = targets2.filter((t) => t.place.kind === "home" && parseTargetId(t.id)?.kind === "column");
3563
3617
  const homePieces = sameAsHome.flatMap((t) => t.hits ?? [t.hit]);
@@ -3580,7 +3634,7 @@ function generateShown(state, dragged, options, hidden) {
3580
3634
  const held = withMinHit(c, layered.targets, layered.refusals, zones).map((t) => t.roomHit && t.slot ? { ...t, roomHit: hull(t.hit, t.slot) } : t);
3581
3635
  return { targets: held, refusals: layered.refusals.map((r) => ({ ...r, bounds })), lost: lostIds, zones };
3582
3636
  }
3583
- var stageOf = (state) => rect17(state.stage.x, state.stage.y, state.stage.width, state.stage.height);
3637
+ var stageOf = (state) => rect18(state.stage.x, state.stage.y, state.stage.width, state.stage.height);
3584
3638
  function targets(state, dragged, options = {}) {
3585
3639
  return generate(state, dragged, options).targets;
3586
3640
  }
@@ -3639,7 +3693,7 @@ function orderedStops(state, dragged, options) {
3639
3693
  }
3640
3694
 
3641
3695
  // src/lanes.ts
3642
- import { EPS as EPS21, area as area7, clamp as clamp3, rect as rect18, subtract as subtract6 } from "@n-uf/placement";
3696
+ import { EPS as EPS21, area as area7, clamp as clamp3, rect as rect19, subtract as subtract6 } from "@n-uf/placement";
3643
3697
  import { itemSteps as itemSteps6 } from "@n-uf/placement/stack";
3644
3698
  var SPOT_PITCH = 40;
3645
3699
  var SNAP_DISTANCE = 8;
@@ -3650,7 +3704,7 @@ var len = (r, axis) => axis === "x" ? r.width : r.height;
3650
3704
  var hull2 = (a, b) => {
3651
3705
  const x = Math.min(a.x, b.x);
3652
3706
  const y = Math.min(a.y, b.y);
3653
- return rect18(x, y, Math.max(a.x + a.width, b.x + b.width) - x, Math.max(a.y + a.height, b.y + b.height) - y);
3707
+ return rect19(x, y, Math.max(a.x + a.width, b.x + b.width) - x, Math.max(a.y + a.height, b.y + b.height) - y);
3654
3708
  };
3655
3709
  var nonNeg = (v) => Number.isFinite(v) && v > 0 ? v : 0;
3656
3710
  var sameRect = (a, b) => Math.max(Math.abs(a.x - b.x), Math.abs(a.y - b.y), Math.abs(a.width - b.width), Math.abs(a.height - b.height)) < 0.5;
@@ -3815,7 +3869,7 @@ function build(state, dragged, options) {
3815
3869
  const blocked = [
3816
3870
  ...Object.values(seen.edges).filter((e) => e.cross > EPS21).map((e) => e.rect),
3817
3871
  ...Object.entries(seen.items).filter(([id, it]) => id !== dragged && !it.floating && !it.inMenu).map(([, it]) => it.rect),
3818
- ...keepClearFor(state, "targets"),
3872
+ ...keepClearFor(state, seen, "targets"),
3819
3873
  ...rails,
3820
3874
  // A held tile's own rail: every stop is home's in `targets()`, with the new-column lines about its folded column
3821
3875
  // joined to it (the strip beside the rail). A home place takes no float, so it is blocked as `targets()` has it.
@@ -3860,7 +3914,7 @@ function laneRectOver(list, over2, marking) {
3860
3914
  if (!edgeLayout) return { rect: list.every((r) => r.strip) ? list.map((r) => r.hit).reduce(hull2) : list.map((r) => r.hit).reduce(hull2, band) };
3861
3915
  const drawnAt = drawnRect(over2, first.edge);
3862
3916
  if (drawnAt) return { rect: drawnAt };
3863
- const whole = axis === "x" ? rect18(edgeLayout.rect.x, band.y, edgeLayout.rect.width, band.height) : rect18(band.x, edgeLayout.rect.y, band.width, edgeLayout.rect.height);
3917
+ const whole = axis === "x" ? rect19(edgeLayout.rect.x, band.y, edgeLayout.rect.width, band.height) : rect19(band.x, edgeLayout.rect.y, band.width, edgeLayout.rect.height);
3864
3918
  return { rect: clipAtDrawn(whole, axis, marking.crossing(first.edge, over2)), band: whole };
3865
3919
  }
3866
3920
  function drawnIn(layout, id) {
@@ -3954,7 +4008,7 @@ function laneFrom(id, list, drawn, seen, dragged, rs, halves, share, marking, sh
3954
4008
  }) : virtualMarks(id, unique, drawn.items[dragged]);
3955
4009
  return { id, rect: laneRect, axis, spots, refused, marks, ...list.every((r) => r.strip) ? { owns: true } : {} };
3956
4010
  }
3957
- var along = (r, axis, a, b) => axis === "x" ? rect18(a, r.y, b - a, r.height) : rect18(r.x, a, r.width, b - a);
4011
+ var along = (r, axis, a, b) => axis === "x" ? rect19(a, r.y, b - a, r.height) : rect19(r.x, a, r.width, b - a);
3958
4012
  var LINE2 = 2;
3959
4013
  var MIN_BOX = 8;
3960
4014
  var HATCH_END = 8;
@@ -4018,7 +4072,7 @@ function virtualMarks(lane, spots, held) {
4018
4072
  const l = s.landing;
4019
4073
  if (!held || held.floating || !overlaps8(l, held.rect)) return { id: `${lane}/box/${s.id}`, kind: "box", rect: l };
4020
4074
  const x = mid(held.rect, "x") < mid(l, "x") ? l.x + l.width : l.x;
4021
- return { id: `${lane}/line/${s.id}`, kind: "line", rect: rect18(x, l.y, 0, l.height) };
4075
+ return { id: `${lane}/line/${s.id}`, kind: "line", rect: rect19(x, l.y, 0, l.height) };
4022
4076
  });
4023
4077
  }
4024
4078
  function inLane(l, r) {
@@ -4029,7 +4083,7 @@ function inLane(l, r) {
4029
4083
  const y1 = Math.min(m.rect.y + m.rect.height, r.y + r.height);
4030
4084
  if (m.kind === "line") return x1 - x0 >= m.rect.width - EPS21 && y1 - y0 >= m.rect.height - EPS21 ? [m] : [];
4031
4085
  if (x1 - x0 <= EPS21 || y1 - y0 <= EPS21) return [];
4032
- return x1 - x0 >= m.rect.width - EPS21 && y1 - y0 >= m.rect.height - EPS21 ? [m] : [{ ...m, rect: rect18(x0, y0, x1 - x0, y1 - y0) }];
4086
+ return x1 - x0 >= m.rect.width - EPS21 && y1 - y0 >= m.rect.height - EPS21 ? [m] : [{ ...m, rect: rect19(x0, y0, x1 - x0, y1 - y0) }];
4033
4087
  });
4034
4088
  return marks.length === l.marks.length && marks.every((m, i) => m === l.marks[i]) ? l : { ...l, marks };
4035
4089
  }
@@ -4073,11 +4127,11 @@ function settle(lane, drawn, state, dragged, all, emptyLanes = "real", within =
4073
4127
  if (l.axis === "y") {
4074
4128
  const outerRight = side === "right" ? true : side === "left" ? false : Math.abs(piece.x + piece.width - (st.x + st.width)) <= Math.abs(piece.x - st.x);
4075
4129
  const t = Math.min(HATCH_EDGE, piece.width);
4076
- r = rect18(outerRight ? piece.x + piece.width - t : piece.x, piece.y, t, piece.height);
4130
+ r = rect19(outerRight ? piece.x + piece.width - t : piece.x, piece.y, t, piece.height);
4077
4131
  } else {
4078
4132
  const outerBottom = side === "bottom" ? true : side === "top" ? false : Math.abs(piece.y + piece.height - (st.y + st.height)) <= Math.abs(piece.y - st.y);
4079
4133
  const t = Math.min(HATCH_EDGE, piece.height);
4080
- r = rect18(piece.x, outerBottom ? piece.y + piece.height - t : piece.y, piece.width, t);
4134
+ r = rect19(piece.x, outerBottom ? piece.y + piece.height - t : piece.y, piece.width, t);
4081
4135
  }
4082
4136
  marks.push({ id: id.replace("/box/", "/hatch/"), kind: "hatch", rect: r });
4083
4137
  });
@@ -4391,8 +4445,41 @@ function slidingSpots(state, dragged, options, seen, lifted, raws, sample) {
4391
4445
  }
4392
4446
 
4393
4447
  // src/drag.ts
4394
- import { EPS as EPS22 } from "@n-uf/placement";
4448
+ import { EPS as EPS22, area as area8, overlaps as overlaps9, subtract as subtract7 } from "@n-uf/placement";
4395
4449
  var MIN_PIECE = 8;
4450
+ function trimmedBy(marks, cs) {
4451
+ if (cs.length === 0) return [...marks];
4452
+ return marks.flatMap((m) => {
4453
+ const r = m.rect;
4454
+ if (r.width <= EPS22 || r.height <= EPS22) {
4455
+ const across2 = r.height <= EPS22;
4456
+ const at = across2 ? r.y : r.x;
4457
+ let pieces2 = [across2 ? [r.x, r.x + r.width] : [r.y, r.y + r.height]];
4458
+ let touched = false;
4459
+ for (const c of cs) {
4460
+ const [lo2, hi] = across2 ? [c.y, c.y + c.height] : [c.x, c.x + c.width];
4461
+ if (!(at > lo2 + EPS22 && at < hi - EPS22)) continue;
4462
+ const [a, b] = across2 ? [c.x, c.x + c.width] : [c.y, c.y + c.height];
4463
+ pieces2 = pieces2.flatMap(([s2, e2]) => {
4464
+ if (b <= s2 || a >= e2) return [[s2, e2]];
4465
+ touched = true;
4466
+ return [...a > s2 ? [[s2, a]] : [], ...b < e2 ? [[b, e2]] : []];
4467
+ });
4468
+ }
4469
+ if (!touched) return [m];
4470
+ const kept = pieces2.filter(([s2, e2]) => e2 - s2 >= 1);
4471
+ if (kept.length === 0) return [];
4472
+ const [s, e] = kept.reduce((x, y) => y[1] - y[0] > x[1] - x[0] ? y : x);
4473
+ if (Math.abs(s - (across2 ? r.x : r.y)) < EPS22 && Math.abs(e - s - (across2 ? r.width : r.height)) < EPS22) return [m];
4474
+ return [{ ...m, rect: across2 ? { x: s, y: r.y, width: e - s, height: r.height } : { x: r.x, y: s, width: r.width, height: e - s } }];
4475
+ }
4476
+ const over2 = cs.filter((c) => overlaps9(m.rect, c));
4477
+ if (over2.length === 0) return [m];
4478
+ const pieces = over2.reduce((ps, c) => ps.flatMap((p) => subtract7(p, c)), [m.rect]).filter((p) => p.width >= 1 && p.height >= 1);
4479
+ if (pieces.length === 0) return [];
4480
+ return [{ ...m, rect: pieces.reduce((a, p) => area8(p) > area8(a) ? p : a) }];
4481
+ });
4482
+ }
4396
4483
  var ORIGIN2 = { x: 0, y: 0 };
4397
4484
  function dockDrag(state, dragged, options = {}) {
4398
4485
  const base = baseOf(state, dragged, options);
@@ -4455,6 +4542,7 @@ function dockDrag(state, dragged, options = {}) {
4455
4542
  if (frame.guides.length === 0) return [];
4456
4543
  const held = after(frame.held);
4457
4544
  const screen = screenOf(frame);
4545
+ const screenClear = (screen.layout.keepClear ?? []).filter((c) => c.for !== "floats").map((c) => c.rect);
4458
4546
  let near = null;
4459
4547
  const shown = [];
4460
4548
  const drawnThere = (id) => drawnIn(screen.layout, id);
@@ -4470,7 +4558,8 @@ function dockDrag(state, dragged, options = {}) {
4470
4558
  const onScreen2 = drawnThere(g.lane);
4471
4559
  const axis2 = axisOf2.get(g.lane) ?? "x";
4472
4560
  const own = screen.marks.filter((m) => m.lane === g.lane);
4473
- const marks = onScreen2 ? mine.landing ? marksLess(own, axis2, [mine.landing], { suffix: "~l", minBox: MIN_PIECE, lines: "covered" }) : own : mine.marks.filter((m) => m.lane === g.lane);
4561
+ const predicted = mine.marks.filter((m) => m.lane === g.lane);
4562
+ const marks = onScreen2 ? mine.landing ? marksLess(own, axis2, [mine.landing], { suffix: "~l", minBox: MIN_PIECE, lines: "covered" }) : own : trimmedBy(predicted, screenClear);
4474
4563
  near = { lane: g.lane, marks };
4475
4564
  shown.push(near);
4476
4565
  }
@@ -4483,7 +4572,7 @@ function dockDrag(state, dragged, options = {}) {
4483
4572
  const made = shown.filter((s) => s.created).sort((a, b) => axis(a.lane) === axis(b.lane) ? 0 : axis(a.lane) === "x" ? -1 : 1);
4484
4573
  const kept = [];
4485
4574
  for (const s of made) {
4486
- s.marks = marksLess(s.marks, axis(s.lane), [...onScreen, ...kept]);
4575
+ s.marks = marksLess(trimmedBy(s.marks, screenClear), axis(s.lane), [...onScreen, ...kept]);
4487
4576
  kept.push(...s.marks.map((m) => m.rect));
4488
4577
  }
4489
4578
  if (!near) return shown.flatMap((s) => s.marks);
@@ -4512,6 +4601,7 @@ export {
4512
4601
  zonesTaking,
4513
4602
  edgeTakes,
4514
4603
  railModeOf,
4604
+ isAnchoredKeepClear,
4515
4605
  zoneIn,
4516
4606
  namesZone,
4517
4607
  isOutsideSideBar,
@@ -4561,4 +4651,4 @@ export {
4561
4651
  HATCH_EDGE,
4562
4652
  dockDrag
4563
4653
  };
4564
- //# sourceMappingURL=chunk-FSNFXRYM.js.map
4654
+ //# sourceMappingURL=chunk-JBKUC72Z.js.map