@n-uf/docking 26.11.56 → 26.11.58

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.
@@ -13,7 +13,7 @@ var DEFAULT_FLOAT_SIZE = { width: 280, height: 360 };
13
13
 
14
14
  // src/helpers.ts
15
15
  import { clampInto } from "@n-uf/placement";
16
- import { formFolded } from "@n-uf/placement/stack";
16
+ import { formBody, formFolded, formMenu } from "@n-uf/placement/stack";
17
17
  var insetPx = (v) => Number.isFinite(v) ? Math.max(0, v) : 0;
18
18
  function floatRegion(state, lifted) {
19
19
  const floating = new Set(state.floats.map((f) => f.id));
@@ -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);
@@ -162,7 +168,7 @@ var zoneOf = (item) => item?.align === "center" || item?.align === "end" ? item.
162
168
  var formsOf = (item, axis) => item.forms[axis] ?? [];
163
169
  var controlsOf = (f) => ({ hidden: f?.hides ?? [], ...f?.tiers ? { tiers: f.tiers } : {} });
164
170
  var PANEL_FORMS = /* @__PURE__ */ new Set(["open", "header", "rail"]);
165
- var isDockingPanel = (item) => !item.closed && !item.fixed && PANEL_FORMS.has(formsOf(item, "column")[0]?.kind ?? "");
171
+ var isDockingPanel = (item) => !item.closed && !item.fixed && (item.countsAsDocked ?? PANEL_FORMS.has(formsOf(item, "column")[0]?.kind ?? ""));
166
172
  function isOutsideSideBar(state, e) {
167
173
  return e.outsideInset === true && isSideBar(state, e);
168
174
  }
@@ -175,6 +181,31 @@ function isSideBar(state, e) {
175
181
  return !e.accepts.some((k) => panelKinds.includes(k));
176
182
  }
177
183
  var isSideColumn = (state, e) => (e.side === "left" || e.side === "right") && !e.compact && e.accepts.length > 0 && !isSideBar(state, e);
184
+ var keepsLengths = (state, e) => e.compact === true || e.side === "top" || e.side === "bottom" || isSideBar(state, e);
185
+ function growsOnBar(state, e, id, form) {
186
+ const it = Object.hasOwn(state.items, id) ? state.items[id] : void 0;
187
+ if (!it || it.fixed || !keepsLengths(state, e)) return false;
188
+ const f = formsOf(it, axisOf(e.side))[form];
189
+ return !!f && f.main.grows === true && !formMenu(f);
190
+ }
191
+ function withoutBarGrowth(state, only) {
192
+ let items;
193
+ const view = only !== void 0 ? placingOf(state, only) : viewOf(state).view;
194
+ for (const e of view.edges) {
195
+ if (e.hidden === true || !keepsLengths(view, e)) continue;
196
+ const axis = axisOf(e.side);
197
+ for (const id of e.items) {
198
+ if (only !== void 0 && id !== only) continue;
199
+ const it = Object.hasOwn(state.items, id) ? state.items[id] : void 0;
200
+ const forms = it?.forms[axis];
201
+ if (!it || it.fixed || !forms?.some((f) => f.main.grows === true)) continue;
202
+ const plain = forms.map((f) => f.main.grows === true ? { ...f, main: { min: f.main.min, natural: f.main.natural } } : f);
203
+ items ??= { ...state.items };
204
+ items[id] = { ...it, forms: { ...it.forms, [axis]: plain } };
205
+ }
206
+ }
207
+ return items ? { ...state, items } : state;
208
+ }
178
209
  var floatOrientOf = (item) => {
179
210
  if (item.floatOrient === "row" || item.floatOrient === "column") return item.floatOrient;
180
211
  for (const k of Object.keys(item.forms)) if ((k === "row" || k === "column") && formsOf(item, k).length > 0) return k;
@@ -182,9 +213,10 @@ var floatOrientOf = (item) => {
182
213
  };
183
214
  var sized = (s) => !!s && Number.isFinite(s.width) && Number.isFinite(s.height) && s.width > 0 && s.height > 0;
184
215
  var declaresFloatSizes = (item) => item.floatSizes !== void 0 && item.floatSizes !== null;
216
+ var sizedByHand = (f) => !!f && f.main.grows === true && formBody(f);
185
217
  function naturalFloatSize(item, orient) {
186
218
  const f = formsOf(item, orient)[0];
187
- if (!f || f.main.grows) return void 0;
219
+ if (!f || sizedByHand(f)) return void 0;
188
220
  const main = Number.isFinite(f.main.natural) ? Math.max(0, f.main.natural) : 0;
189
221
  const cross = Number.isFinite(f.cross.natural) ? Math.max(0, f.cross.natural) : 0;
190
222
  if (main <= 0 || cross <= 0) return void 0;
@@ -257,11 +289,11 @@ function floatShape(item, f) {
257
289
  const fm = forms[form];
258
290
  if (orient === "column" && forms.slice(0, form + 1).some(isWrap)) return { form, width: px2(fm.cross.natural), height: px2(fm.main.natural) };
259
291
  if (form > 0) return orient === "column" ? { form, width: w, height: px2(fm.main.natural) } : { form, width: px2(fm.main.natural), height: h };
260
- return { form, ...fm.main.grows || !declaresFloatSizes(item) ? { width: w, height: h } : floatSizeOf(item, orient) };
292
+ return { form, ...sizedByHand(fm) || !declaresFloatSizes(item) ? { width: w, height: h } : floatSizeOf(item, orient) };
261
293
  }
262
294
 
263
295
  // src/solve.ts
264
- import { rect as rect6 } from "@n-uf/placement";
296
+ import { rect as rect7 } from "@n-uf/placement";
265
297
 
266
298
  // src/targets/ids.ts
267
299
  function targetId(parts) {
@@ -429,7 +461,7 @@ import { cutEdges } from "@n-uf/placement/stack";
429
461
 
430
462
  // src/solve/draft.ts
431
463
  import { EPS as EPS2, rect } from "@n-uf/placement";
432
- import { formMain, itemSteps, wrapLines } from "@n-uf/placement/stack";
464
+ import { formMain, formMenu as formMenu2, itemSteps, wrapLines } from "@n-uf/placement/stack";
433
465
  function createDraft(given, options, caps = /* @__PURE__ */ new Map()) {
434
466
  const previous = options.previous;
435
467
  const opened = /* @__PURE__ */ new Set();
@@ -478,7 +510,7 @@ function shapeOf(f, r, axis, cross) {
478
510
  if (!g) return {};
479
511
  return { grip: axis === "column" ? rect(r.x, r.y, r.width, Math.min(g, r.height)) : rect(r.x, r.y, Math.min(g, r.width), r.height) };
480
512
  }
481
- function zoneStarts(state, fit, input) {
513
+ function zoneStarts(state, edge, fit, input) {
482
514
  const column = fit.axis === "column";
483
515
  const at = (r) => column ? r.y : r.x;
484
516
  const out = /* @__PURE__ */ new Map();
@@ -503,6 +535,19 @@ function zoneStarts(state, fit, input) {
503
535
  return !itemSteps(it) && f?.main.grows && len2(p) > formMain(f, "natural", fit.cross) + EPS2;
504
536
  });
505
537
  if (title) lengths.set(title.id, formMain(formsOf(state.items[title.id], "row")[title.form], "natural", fit.cross));
538
+ const growers = drawn.filter((p) => growsOnBar(state, edge, p.id, p.form));
539
+ const growth = /* @__PURE__ */ new Map();
540
+ if (growers.length > 0) {
541
+ for (const p of drawn) {
542
+ const f = formsOf(state.items[p.id], column ? "column" : "row")[p.form];
543
+ if (!f || formMenu2(f) || f.main.grows !== true) continue;
544
+ const n = formMain(f, "natural", fit.cross);
545
+ if (len2(p) > n + EPS2) {
546
+ growth.set(p.id, len2(p) - n);
547
+ lengths.set(p.id, n);
548
+ }
549
+ }
550
+ }
506
551
  const used = drawn.reduce((sum, p) => sum + len2(p), 0) + Math.max(0, drawn.length - 1) * gap;
507
552
  const spare = fit.length - start - end - menu - used;
508
553
  if (spare <= EPS2) return { starts: out, lengths };
@@ -524,14 +569,44 @@ function zoneStarts(state, fit, input) {
524
569
  }
525
570
  };
526
571
  const spaced = (ps) => total(ps) + ps.reduce((sum, p) => sum + room(p), 0);
527
- lay(s, start, true);
528
- const endStart = fit.length - end - menu - spaced(e);
529
- lay(e, endStart, false);
530
- const lo2 = start + spaced(s) + (s.length > 0 ? gap : 0);
531
- const hi = endStart - (e.length > 0 ? gap : 0);
532
- const mid2 = (fit.length - total(c)) / 2;
533
- const clear = mid2 >= lo2 - EPS2 && mid2 + total(c) <= hi + EPS2;
534
- lay(c, title && !clear ? Math.max(lo2, (lo2 + hi - total(c)) / 2) : Math.max(lo2, Math.min(mid2, hi - total(c))), false);
572
+ const barEnd = fit.length - end - menu;
573
+ const layZones = (centerAt) => {
574
+ lay(s, start, true);
575
+ const endStart = barEnd - spaced(e);
576
+ lay(e, endStart, false);
577
+ const lo2 = start + spaced(s) + (s.length > 0 ? gap : 0);
578
+ const hi = endStart - (e.length > 0 ? gap : 0);
579
+ const mid2 = (fit.length - total(c)) / 2;
580
+ const clear = mid2 >= lo2 - EPS2 && mid2 + total(c) <= hi + EPS2;
581
+ const cAt = centerAt ?? (title && !clear ? Math.max(lo2, (lo2 + hi - total(c)) / 2) : Math.max(lo2, Math.min(mid2, hi - total(c))));
582
+ lay(c, cAt, false);
583
+ const spans2 = [
584
+ { ps: s, a: start, b: start + spaced(s) },
585
+ { ps: c, a: cAt, b: cAt + total(c) },
586
+ { ps: e, a: endStart, b: endStart + spaced(e) }
587
+ ];
588
+ return spans2.filter((z) => z.ps.length > 0);
589
+ };
590
+ const spans = layZones();
591
+ if (growers.length > 0) {
592
+ const mine = new Set(growers.map((p) => p.id));
593
+ const add = /* @__PURE__ */ new Map();
594
+ const give = (free, beside) => {
595
+ const takers = beside.filter((p) => mine.has(p.id));
596
+ if (free <= EPS2 || takers.length === 0) return;
597
+ const weights = takers.map((p) => growth.get(p.id) ?? 0);
598
+ const sum = weights.reduce((t, w) => t + w, 0);
599
+ takers.forEach((p, k) => add.set(p.id, (add.get(p.id) ?? 0) + free * (sum > EPS2 ? weights[k] / sum : 1 / takers.length)));
600
+ };
601
+ give(spans[0].a - start, spans[0].ps);
602
+ for (let k = 0; k + 1 < spans.length; k++) give(spans[k + 1].a - spans[k].b - gap, [...spans[k].ps, ...spans[k + 1].ps]);
603
+ give(barEnd - spans[spans.length - 1].b, spans[spans.length - 1].ps);
604
+ if (add.size > 0) {
605
+ for (const [id, v] of add) lengths.set(id, lengths.get(id) + v);
606
+ const middle = spans.find((z) => z.ps === c);
607
+ layZones(middle && !c.some((p) => add.has(p.id)) ? middle.a : void 0);
608
+ }
609
+ }
535
610
  if (title && s[s.length - 1] === title) {
536
611
  const next = [...c, ...e].map((p) => out.get(p.id));
537
612
  const until = next.length ? Math.min(...next) - gap : fit.length - end - menu;
@@ -544,7 +619,7 @@ function emit(d, edge, r, solved, extra = {}) {
544
619
  const column = axisOf(edge.side) === "column";
545
620
  const { stack } = solved;
546
621
  const thick = column ? r.width : r.height;
547
- const { starts, lengths } = zoneStarts(state, stack, solved.input);
622
+ const { starts, lengths } = zoneStarts(state, edge, stack, solved.input);
548
623
  const toStage = (l, id) => {
549
624
  const s = id !== void 0 ? starts.get(id) : void 0;
550
625
  const n = id !== void 0 ? lengths.get(id) : void 0;
@@ -598,7 +673,7 @@ function emit(d, edge, r, solved, extra = {}) {
598
673
 
599
674
  // src/solve/edge.ts
600
675
  import { EPS as EPS3 } from "@n-uf/placement";
601
- import { fitStack, formCompact, formCrossMin as formCrossMin2, formMenu, formSetsCross as formSetsCross2, itemSteps as itemSteps2 } from "@n-uf/placement/stack";
676
+ import { fitStack, formCompact, formCrossMin as formCrossMin2, formMenu as formMenu3, formSetsCross as formSetsCross2, itemSteps as itemSteps2 } from "@n-uf/placement/stack";
602
677
  var stackItemOf = (item, forms, edge, from) => ({
603
678
  id: item.id,
604
679
  forms,
@@ -613,7 +688,7 @@ var stackItemOf = (item, forms, edge, from) => ({
613
688
  var inputs = /* @__PURE__ */ new WeakMap();
614
689
  var inputOf = (stack) => inputs.get(stack);
615
690
  function hasSetter(fit, forms) {
616
- return fit.items.some((p) => !formMenu(forms(p.id)[p.form]) && formSetsCross2(forms(p.id)[p.form]));
691
+ return fit.items.some((p) => !formMenu3(forms(p.id)[p.form]) && formSetsCross2(forms(p.id)[p.form]));
617
692
  }
618
693
  var TRAY_RANK = 100;
619
694
  var startsOf = (input) => new Map(input.items.map((i) => [i.id, i.from ?? 0]));
@@ -719,7 +794,7 @@ function solveEdgeStack(state, edge, ids, length, room, previous) {
719
794
  const items = input.items.map((it) => {
720
795
  const from = it.from ?? 0;
721
796
  if (!itemSteps2(it) || fits(it.forms[from])) return it;
722
- const j = it.forms.findIndex((f, k) => k > from && !formMenu(f) && fits(f));
797
+ const j = it.forms.findIndex((f, k) => k > from && !formMenu3(f) && fits(f));
723
798
  if (j < 0) return it;
724
799
  moved = true;
725
800
  return { ...it, from: j };
@@ -731,7 +806,7 @@ function solveEdgeStack(state, edge, ids, length, room, previous) {
731
806
  }
732
807
  const size = edge.size;
733
808
  if (typeof size === "number" && Number.isFinite(size) && hasSetter(free, formsById)) {
734
- const setters = free.items.filter((p) => !formMenu(formsById(p.id)[p.form]) && formSetsCross2(formsById(p.id)[p.form]));
809
+ const setters = free.items.filter((p) => !formMenu3(formsById(p.id)[p.form]) && formSetsCross2(formsById(p.id)[p.form]));
735
810
  const lo2 = Math.max(px(edge.cross.min), ...setters.map((p) => formCrossMin2(formsById(p.id)[p.form])));
736
811
  const s = Math.min(Math.max(size, lo2), Math.max(lo2, maxOf), room);
737
812
  if (Math.abs(s - free.cross) > EPS3) {
@@ -744,16 +819,16 @@ function solveEdgeStack(state, edge, ids, length, room, previous) {
744
819
  }
745
820
 
746
821
  // src/solve/bars.ts
747
- function cutEdge(d, edge, area8, cut2) {
822
+ function cutEdge(d, edge, area9, cut2) {
748
823
  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);
824
+ const length = column ? area9.height : area9.width;
825
+ const room = Math.max(0, column ? area9.width : area9.height);
751
826
  const cap = d.caps.get(edge.id);
752
827
  const solvedAs = cap === void 0 ? edge : { ...edge, cross: { ...edge.cross, max: Math.min(edge.cross.max, cap) } };
753
828
  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 }]);
829
+ const band = cutEdges(area9, [{ id: edge.id, side: edge.side, size: solved.stack.items.length === 0 ? 0 : solved.stack.cross }]);
755
830
  emit(d, edge, band.bands[edge.id], solved);
756
- return cut2 ? band.rest : area8;
831
+ return cut2 ? band.rest : area9;
757
832
  }
758
833
 
759
834
  // src/solve/floats.ts
@@ -849,7 +924,7 @@ function placeFloat(item, f, region, avoid, content, stage, earlier = [], docked
849
924
  const fit = w > region.width + EPS4 ? { ...fit0, rect: rect2(region.x, fit0.rect.y, w, fit0.rect.height) } : fit0;
850
925
  return { from, fo, form, fit };
851
926
  }
852
- function layFloats(d, stage, content, inset) {
927
+ function layFloats(d, stage, content, inset, chrome) {
853
928
  const { state, notes, items, edges } = d;
854
929
  const avoid = [];
855
930
  for (const l of Object.values(items)) avoid.push(l.rect);
@@ -858,7 +933,7 @@ function layFloats(d, stage, content, inset) {
858
933
  if (axisOf(e.side) === "row" && e.cross > 0) avoid.push(e.rect);
859
934
  if (e.menu) avoid.push(e.menu.rect);
860
935
  }
861
- for (const c of keepClearFor(state, "floats")) avoid.push(c);
936
+ for (const c of chrome) avoid.push(c);
862
937
  const floatRegion2 = rect2(stage.x + px(inset.left), stage.y, Math.max(0, stage.width - px(inset.left) - px(inset.right)), stage.height);
863
938
  const drawn = [];
864
939
  const noForm = /* @__PURE__ */ new Set();
@@ -899,18 +974,55 @@ function layFloats(d, stage, content, inset) {
899
974
  return floats;
900
975
  }
901
976
 
977
+ // src/solve/keep-clear.ts
978
+ import { rect as rect3 } from "@n-uf/placement";
979
+ var regionRect = (region, content) => region === "content" ? content : null;
980
+ var roomFor = (c, region) => {
981
+ const w = c.minRegion?.width;
982
+ const h = c.minRegion?.height;
983
+ return !(Number.isFinite(w) && region.width < w) && !(Number.isFinite(h) && region.height < h);
984
+ };
985
+ function anchoredRect(c, region) {
986
+ if (!(region.width > 0) || !(region.height > 0) || !Number.isFinite(c.size) || c.size <= 0 || !roomFor(c, region)) return null;
987
+ const w = Math.min(c.size, region.width);
988
+ const h = Math.min(c.size, region.height);
989
+ switch (c.side) {
990
+ case "left":
991
+ return rect3(region.x, region.y, w, region.height);
992
+ case "right":
993
+ return rect3(region.x + region.width - w, region.y, w, region.height);
994
+ case "top":
995
+ return rect3(region.x, region.y, region.width, h);
996
+ case "bottom":
997
+ return rect3(region.x, region.y + region.height - h, region.width, h);
998
+ default:
999
+ return null;
1000
+ }
1001
+ }
1002
+ function resolveKeepClear(state, content) {
1003
+ const anchored2 = (state.keepClear ?? []).filter(isAnchoredKeepClear);
1004
+ if (anchored2.length === 0) return void 0;
1005
+ const out = [];
1006
+ for (const c of anchored2) {
1007
+ const region = regionRect(c.region, content);
1008
+ const r = region ? anchoredRect(c, region) : null;
1009
+ if (r) out.push({ rect: r, for: c.for === "floats" ? "floats" : "all", ...typeof c.id === "string" ? { id: c.id } : {} });
1010
+ }
1011
+ return out;
1012
+ }
1013
+
902
1014
  // src/solve/insets.ts
903
- import { EPS as EPS5, rect as rect3 } from "@n-uf/placement";
1015
+ import { EPS as EPS5, rect as rect4 } from "@n-uf/placement";
904
1016
  function insetOf(d) {
905
1017
  const { state } = d;
906
1018
  const docked = d.order.some((e) => isSide(e) && e.accepts.length > 0 && d.owned.get(e).some((id) => isDockingPanel(state.items[id])));
907
1019
  const inset = state.insetWhen === "docked" && !docked ? {} : state.inset ?? {};
908
1020
  return { inset, docked };
909
1021
  }
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;
1022
+ 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)));
1023
+ function insetReach(area9, f) {
1024
+ const up = area9.y <= f.outer.y + px(f.inset.top) + EPS5 ? px(f.inset.top) : 0;
1025
+ const down = area9.y + area9.height >= f.outer.y + f.outer.height - px(f.inset.bottom) - EPS5 ? px(f.inset.bottom) : 0;
914
1026
  return { up, down };
915
1027
  }
916
1028
 
@@ -933,22 +1045,22 @@ function contentNotes(d, content) {
933
1045
  }
934
1046
 
935
1047
  // src/solve/sides.ts
936
- import { EPS as EPS8, rect as rect5 } from "@n-uf/placement";
1048
+ import { EPS as EPS8, rect as rect6 } from "@n-uf/placement";
937
1049
 
938
1050
  // src/solve/columns.ts
939
1051
  import { EPS as EPS7 } from "@n-uf/placement";
940
- import { formCrossMin as formCrossMin3, formMenu as formMenu2, formSetsCross as formSetsCross3 } from "@n-uf/placement/stack";
1052
+ import { formCrossMin as formCrossMin3, formMenu as formMenu4, formSetsCross as formSetsCross3 } from "@n-uf/placement/stack";
941
1053
  var isChrome = (state, c) => !c.dyn && isSideBar(state, c.edge);
942
- function columnsOf(d, sideEdges, area8, tall) {
1054
+ function columnsOf(d, sideEdges, area9, tall) {
943
1055
  const { state } = d;
944
1056
  return sideEdges.map((edge) => {
945
1057
  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);
1058
+ const solved = solveEdge(state, edge, d.owned.get(edge), tall(edge), Math.max(0, area9.width), d.prevEdge(edge));
1059
+ const width = solved.stack.items.length === 0 ? 0 : Math.min(solved.stack.cross, area9.width);
948
1060
  const visible = d.owned.get(edge).filter((id) => !state.items[id].closed);
949
1061
  const dyn = (edge.column === true || edge.giveWay === true) && state.rails?.[side] !== void 0 && visible.length > 0;
950
1062
  const forms = (id) => formsOf(state.items[id], "column");
951
- const setters = solved.free.items.filter((p) => !formMenu2(forms(p.id)[p.form]) && formSetsCross3(forms(p.id)[p.form]));
1063
+ const setters = solved.free.items.filter((p) => !formMenu4(forms(p.id)[p.form]) && formSetsCross3(forms(p.id)[p.form]));
952
1064
  const min = setters.length > 0 ? Math.min(width, Math.max(px(edge.cross.min), ...setters.map((p) => formCrossMin3(forms(p.id)[p.form])))) : width;
953
1065
  return {
954
1066
  edge,
@@ -964,7 +1076,7 @@ function columnsOf(d, sideEdges, area8, tall) {
964
1076
  };
965
1077
  });
966
1078
  }
967
- function giveWay(d, cols, area8, gutter) {
1079
+ function giveWay(d, cols, area9, gutter) {
968
1080
  const { state, previous, fresh, opened } = d;
969
1081
  const ride = state.handFold === "ride";
970
1082
  const cmin = state.contentMin ? px(state.contentMin.width) : void 0;
@@ -986,7 +1098,7 @@ function giveWay(d, cols, area8, gutter) {
986
1098
  let used = 0;
987
1099
  for (const [c, w] of widths) used += w > 0 ? w + (c.edge.outsideInset === true ? 0 : gutter) : 0;
988
1100
  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;
1101
+ let excess = cmin === void 0 ? -Infinity : floor === void 0 ? used + cmin - area9.width : Math.max(used - chrome + cmin, used + floor) - area9.width;
990
1102
  for (const c of shrinkOrder) {
991
1103
  if (excess <= EPS7) break;
992
1104
  const w = widths.get(c);
@@ -1026,7 +1138,7 @@ function giveWay(d, cols, area8, gutter) {
1026
1138
  }
1027
1139
  return evaluate(auto);
1028
1140
  }
1029
- function columnRoom(d, cols, area8, f) {
1141
+ function columnRoom(d, cols, area9, f) {
1030
1142
  const { state } = d;
1031
1143
  const cmin = state.contentMin ? px(state.contentMin.width) : void 0;
1032
1144
  const openMin = (ids, least) => Math.max(
@@ -1047,7 +1159,7 @@ function columnRoom(d, cols, area8, f) {
1047
1159
  if (cmin === void 0 || colMins.length === 0) return;
1048
1160
  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
1161
  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);
1162
+ const width = area9.width - bars - (state.insetWhen === "docked" && !f.docked ? px(state.inset?.left) + px(state.inset?.right) : 0);
1051
1163
  const need = cmin + Math.min(...colMins) + f.gutter;
1052
1164
  d.columnRoom = width >= need - EPS7;
1053
1165
  if (!d.columnRoom) d.notes.push({ code: "no-column-room", width, need });
@@ -1080,7 +1192,7 @@ function giveWayNotes(d, g, cols) {
1080
1192
  }
1081
1193
 
1082
1194
  // src/solve/rails.ts
1083
- import { rect as rect4 } from "@n-uf/placement";
1195
+ import { rect as rect5 } from "@n-uf/placement";
1084
1196
  import { fitStack as fitStack2 } from "@n-uf/placement/stack";
1085
1197
  function riderBars(d, c) {
1086
1198
  const { state } = d;
@@ -1099,12 +1211,12 @@ function layRiders(d, host, riders, top) {
1099
1211
  const bars = riderBars(d, c);
1100
1212
  const y0 = y;
1101
1213
  for (const b of bars) {
1102
- const at = rect4(hr.x, y, hr.width, b.h);
1214
+ const at = rect5(hr.x, y, hr.width, b.h);
1103
1215
  const it = state.items[b.id];
1104
1216
  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
1217
  y += b.h;
1106
1218
  }
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" };
1219
+ 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
1220
  }
1109
1221
  }
1110
1222
  function layRail(d, side, railRect, railed, g) {
@@ -1144,7 +1256,7 @@ function layRail(d, side, railRect, railed, g) {
1144
1256
  const ri = tileOf(id);
1145
1257
  const p = placed.get(id);
1146
1258
  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);
1259
+ 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
1260
  const title = forms[form]?.title === true;
1149
1261
  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
1262
  segments.push({ id, edge: c.edge.id, rect: at });
@@ -1154,26 +1266,26 @@ function layRail(d, side, railRect, railed, g) {
1154
1266
  }
1155
1267
 
1156
1268
  // src/solve/sides.ts
1157
- function laySides(d, sideEdges, area8, f) {
1158
- const H = area8.height;
1159
- const reach = insetReach(area8, f);
1269
+ function laySides(d, sideEdges, area9, f) {
1270
+ const H = area9.height;
1271
+ const reach = insetReach(area9, f);
1160
1272
  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);
1273
+ const cols = columnsOf(d, sideEdges, area9, tall);
1274
+ const g = giveWay(d, cols, area9, f.gutter);
1275
+ columnRoom(d, cols, area9, f);
1164
1276
  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);
1277
+ const walk = { x0: area9.x, x1: area9.x + area9.width };
1278
+ for (const side of ["left", "right"]) laySide(d, side, cols, g, area9, f, walk, reach.up, tall);
1279
+ return rect6(walk.x0, area9.y, Math.max(0, walk.x1 - walk.x0), H);
1168
1280
  }
1169
1281
  function forced(d, c, length, w) {
1170
1282
  const edge = { ...c.edge, cross: { ...c.edge.cross, min: w, max: w } };
1171
1283
  const { size: _s, ...plain } = edge;
1172
1284
  return solveEdge(d.state, plain, d.owned.get(c.edge), length, w, d.prevEdge(c.edge));
1173
1285
  }
1174
- function laySide(d, side, cols, g, area8, f, walk, upInset, tall) {
1286
+ function laySide(d, side, cols, g, area9, f, walk, upInset, tall) {
1175
1287
  const { state, edges } = d;
1176
- const H = area8.height;
1288
+ const H = area9.height;
1177
1289
  const outsideSideBar = (c) => c.width > 0 && isOutsideSideBar(state, c.edge) && !g.railed(c) && !g.riding(c);
1178
1290
  const all = cols.filter((c) => c.side === side);
1179
1291
  const mine = [...all.filter(outsideSideBar), ...all.filter((c) => !outsideSideBar(c))];
@@ -1188,7 +1300,7 @@ function laySide(d, side, cols, g, area8, f, walk, upInset, tall) {
1188
1300
  let railPlace = null;
1189
1301
  const placeRail = () => {
1190
1302
  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);
1303
+ return side === "left" ? rect6(walk.x0 - lead, area9.y, railW, H) : rect6(walk.x1 + lead - railW, area9.y, railW, H);
1192
1304
  };
1193
1305
  for (const c of mine) {
1194
1306
  if (!railPlace && !outsideSideBar(c)) {
@@ -1205,7 +1317,7 @@ function laySide(d, side, cols, g, area8, f, walk, upInset, tall) {
1205
1317
  if (outsideSideBar(c)) barLaid = true;
1206
1318
  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
1319
  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" };
1320
+ edges[c.edge.id] = { ...base, rect: rect6(railRect.x, area9.y, 0, H), folded: g.auto.has(c) ? "auto" : "hand" };
1209
1321
  continue;
1210
1322
  }
1211
1323
  if (g.riding(c)) continue;
@@ -1214,29 +1326,29 @@ function laySide(d, side, cols, g, area8, f, walk, upInset, tall) {
1214
1326
  let solved = top > 0 || Math.abs(w - c.width) > EPS8 ? forced(d, c, H - top, w) : c.solved;
1215
1327
  let r;
1216
1328
  if (c.edge.outsideInset === true) {
1217
- const y0 = area8.y - upInset;
1329
+ const y0 = area9.y - upInset;
1218
1330
  const h = tall(c.edge);
1219
1331
  if (side === "left") {
1220
- r = rect5(walk.x0 - gap, y0, w, h);
1332
+ r = rect6(walk.x0 - gap, y0, w, h);
1221
1333
  walk.x0 += w;
1222
1334
  } else {
1223
- r = rect5(walk.x1 + gap - w, y0, w, h);
1335
+ r = rect6(walk.x1 + gap - w, y0, w, h);
1224
1336
  walk.x1 -= w;
1225
1337
  }
1226
1338
  if (Math.abs(h - H) > EPS8 || Math.abs(w - c.width) > EPS8) solved = forced(d, c, h, w);
1227
1339
  } else if (side === "left") {
1228
- r = rect5(walk.x0, area8.y + top, w, H - top);
1340
+ r = rect6(walk.x0, area9.y + top, w, H - top);
1229
1341
  walk.x0 += w > 0 ? w + f.gutter : 0;
1230
1342
  if (w > 0) gap = f.gutter;
1231
1343
  } else {
1232
1344
  walk.x1 -= w;
1233
- r = rect5(walk.x1, area8.y + top, w, H - top);
1345
+ r = rect6(walk.x1, area9.y + top, w, H - top);
1234
1346
  walk.x1 -= w > 0 ? f.gutter : 0;
1235
1347
  if (w > 0) gap = f.gutter;
1236
1348
  }
1237
1349
  emit(d, c.edge, r, solved, w < c.width - EPS8 ? { shrunk: true } : {});
1238
1350
  }
1239
- if (host && riders.length > 0) layRiders(d, host, riders, area8.y);
1351
+ if (host && riders.length > 0) layRiders(d, host, riders, area9.y);
1240
1352
  if (railRect) layRail(d, side, railRect, railed, g);
1241
1353
  if (state.rails?.[side]) d.railPlaces[side] = railPlace ?? placeRail();
1242
1354
  }
@@ -1258,29 +1370,29 @@ function solveState(given, options) {
1258
1370
  const l = way ? lay(way.caps, way.notes) : first;
1259
1371
  return ignored.length === 0 ? l : { ...l, notes: [...l.notes, ...ignored.map((edge) => ({ code: "show-in-ignored", edge }))] };
1260
1372
  }
1261
- var withHeightOf = (area8, over2) => rect6(over2.x, area8.y, over2.width, area8.height);
1373
+ var withHeightOf = (area9, over2) => rect7(over2.x, area9.y, over2.width, area9.height);
1262
1374
  function layOut(given, options, caps, gave) {
1263
1375
  const d = createDraft(given, options, caps);
1264
1376
  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));
1377
+ const stage = rect7(finite(state.stage.x, 0), finite(state.stage.y, 0), px(state.stage.width), px(state.stage.height));
1266
1378
  const { inset, docked } = insetOf(d);
1267
1379
  const reserved = order.filter((e) => e.mode !== "overlay");
1268
1380
  const outsideBar = (e) => !isSide(e) && e.span !== "between" && e.outsideInset === true;
1269
1381
  let outer = stage;
1270
1382
  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;
1383
+ let area9 = insideInset(outer, inset);
1384
+ for (const e of reserved) if (!isSide(e) && e.span !== "between" && !outsideBar(e)) area9 = cutEdge(d, e, area9, true);
1385
+ const wide = area9;
1386
+ area9 = laySides(d, reserved.filter(isSide), area9, { inset, gutter: px(state.gutter), docked, outer });
1387
+ for (const e of reserved) if (!isSide(e) && e.span === "between") area9 = cutEdge(d, e, area9, true);
1388
+ const content = area9;
1277
1389
  let over2 = content;
1278
1390
  for (const e of order) {
1279
1391
  if (e.mode !== "overlay") continue;
1280
1392
  if (isSide(e) || e.span !== "full") over2 = cutEdge(d, e, over2, true);
1281
1393
  else {
1282
1394
  const across2 = e.outsideInset === true ? outer : wide;
1283
- over2 = withHeightOf(cutEdge(d, e, rect6(across2.x, over2.y, across2.width, over2.height), true), over2);
1395
+ over2 = withHeightOf(cutEdge(d, e, rect7(across2.x, over2.y, across2.width, over2.height), true), over2);
1284
1396
  }
1285
1397
  }
1286
1398
  for (const n of gave) {
@@ -1288,13 +1400,14 @@ function layOut(given, options, caps, gave) {
1288
1400
  if (n.code === "bar-shrunk" && d.edges[n.edge]) d.edges[n.edge] = { ...d.edges[n.edge], shrunk: true };
1289
1401
  }
1290
1402
  contentNotes(d, content);
1291
- const floats = layFloats(d, stage, content, inset);
1403
+ const keepClear = resolveKeepClear(state, content);
1404
+ const floats = layFloats(d, stage, content, inset, keepClearFor(state, { keepClear }, "floats"));
1292
1405
  const { items, edges, rails, railPlaces, columnRoom: columnRoom2, notes } = d;
1293
- return { items, edges, content, floats, rails, railPlaces, ...columnRoom2 !== void 0 ? { columnRoom: columnRoom2 } : {}, notes };
1406
+ return { items, edges, content, floats, rails, railPlaces, ...columnRoom2 !== void 0 ? { columnRoom: columnRoom2 } : {}, ...keepClear ? { keepClear } : {}, notes };
1294
1407
  }
1295
1408
 
1296
1409
  // src/dividers.ts
1297
- import { rect as rect7 } from "@n-uf/placement";
1410
+ import { rect as rect8 } from "@n-uf/placement";
1298
1411
  import { dividers as stackDividers, resetBetween as stackReset, resizeBetween as stackResize } from "@n-uf/placement/stack";
1299
1412
  var laid = (state, layout) => layout && stateOf(layout) === state && Object.values(layout.edges).every((e) => inputOf(e.stack) !== void 0) ? layout : solve(state);
1300
1413
  function dividers(state, layout) {
@@ -1303,7 +1416,7 @@ function dividers(state, layout) {
1303
1416
  for (const [edge, e] of Object.entries(lay.edges)) {
1304
1417
  const input = inputOf(e.stack);
1305
1418
  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 });
1419
+ 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
1420
  }
1308
1421
  return out;
1309
1422
  }
@@ -1359,7 +1472,7 @@ function floatObstacles(state, l, id) {
1359
1472
  if (axisOf(e.side) === "row" && e.cross > 0) rects.push(e.rect);
1360
1473
  if (e.menu) rects.push(e.menu.rect);
1361
1474
  }
1362
- for (const c of keepClearFor(state, "floats")) rects.push(c);
1475
+ for (const c of keepClearFor(state, l, "floats")) rects.push(c);
1363
1476
  return { rects: rects.filter(some), docked };
1364
1477
  }
1365
1478
  function obstacleStop(drawn, obstacles, axis, drag, span) {
@@ -1426,13 +1539,13 @@ function fitAxis(start, length, b, drag, hit) {
1426
1539
  }
1427
1540
  return [a, to - a];
1428
1541
  }
1429
- function fitResize(state, id, rect19, moving) {
1542
+ function fitResize(state, id, rect20, moving) {
1430
1543
  const f = state.floats.find((x2) => x2.id === id);
1431
1544
  const item = Object.hasOwn(state.items, id) ? state.items[id] : void 0;
1432
1545
  if (!f || !item || item.fixed) return null;
1433
1546
  const fo = f.orient ?? floatOrientOf(item);
1434
1547
  const form = formsOf(item, fo)[0];
1435
- if (floatShape(item, f).form !== 0 || form && !form.main.grows) return null;
1548
+ if (floatShape(item, f).form !== 0 || form && !sizedByHand(form)) return null;
1436
1549
  const l = solve(state);
1437
1550
  const drawn = l.items[id]?.rect;
1438
1551
  if (!drawn) return null;
@@ -1444,8 +1557,8 @@ function fitResize(state, id, rect19, moving) {
1444
1557
  const { rects: obstacles, docked } = floatObstacles(state, l, id);
1445
1558
  const hit = /* @__PURE__ */ new Set();
1446
1559
  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);
1560
+ 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);
1561
+ 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
1562
  const { anchor: _a, ...plain } = f;
1450
1563
  const placed = placeFloat(item, { ...plain, rect: { x, y, width, height } }, region, obstacles, l.content, state.stage, [], docked).fit.rect;
1451
1564
  if (Math.abs(placed.x - x) > EPS9 || Math.abs(placed.y - y) > EPS9) hit.add("docked");
@@ -1707,14 +1820,14 @@ function orientFloat(state, id, to) {
1707
1820
  const from = f.orient ?? floatOrientOf(item);
1708
1821
  if (from === to) return state;
1709
1822
  if (!declaresFloatSizes(item)) return { ...state, floats: state.floats.map((g, k) => k === i ? { ...g, orient: to } : g) };
1710
- const grows = formsOf(item, from)[0]?.main.grows === true;
1823
+ const grows = sizedByHand(formsOf(item, from)[0]);
1711
1824
  const kept = withFloatSizes(item, grows && f.rect.width > 0 && f.rect.height > 0 ? { orient: from, size: { width: f.rect.width, height: f.rect.height } } : void 0);
1712
1825
  const size = drawnFloatSize(kept, { rect: { ...f.rect, ...floatSizeOf(kept, to) }, orient: to });
1713
1826
  const turned = { ...f, rect: { x: f.rect.x, y: f.rect.y, width: size.width, height: size.height }, orient: to };
1714
1827
  return withItem({ ...state, floats: state.floats.map((g, k) => k === i ? turned : g) }, kept);
1715
1828
  }
1716
- function resizeFloat(state, floatId, rect19, moving = { right: true, bottom: true }) {
1717
- const fit = fitResize(state, floatId, rect19, moving);
1829
+ function resizeFloat(state, floatId, rect20, moving = { right: true, bottom: true }) {
1830
+ const fit = fitResize(state, floatId, rect20, moving);
1718
1831
  const i = state.floats.findIndex((f) => f.id === floatId);
1719
1832
  const item = itemOf(state, floatId);
1720
1833
  if (!fit || i < 0 || !item) return state;
@@ -1794,7 +1907,7 @@ function drawnFloatSize(item, f) {
1794
1907
  }
1795
1908
 
1796
1909
  // src/store.ts
1797
- import { EPS as EPS10, rect as rect8 } from "@n-uf/placement";
1910
+ import { EPS as EPS10, rect as rect9 } from "@n-uf/placement";
1798
1911
  var isNum = (x) => typeof x === "number" && Number.isFinite(x);
1799
1912
  var isSize = (x) => isNum(x) && x > 0;
1800
1913
  var isObject = (x) => typeof x === "object" && x !== null && !Array.isArray(x);
@@ -2037,7 +2150,7 @@ function read(data, base) {
2037
2150
  const stays = f.stays === true && !a;
2038
2151
  if (f.stays !== void 0 && !stays) drop(`float:${id}:stays`);
2039
2152
  placed.add(id);
2040
- const r = rect8(f.x, f.y, f.width, f.height);
2153
+ const r = rect9(f.x, f.y, f.width, f.height);
2041
2154
  const drawn = drawnFloatSize(items[id], { rect: r, ...o ? { orient: o } : {} });
2042
2155
  floats.push({ id, rect: clampFloat(r, base.stage, drawn), ...o ? { orient: o } : {}, ...a ? { anchor: a } : {}, ...since !== void 0 ? { since } : {}, ...stays ? { stays: true } : {} });
2043
2156
  }
@@ -2070,10 +2183,10 @@ function read(data, base) {
2070
2183
  }
2071
2184
 
2072
2185
  // 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";
2186
+ import { EPS as EPS20, PLANE, area as area6, clamp as clamp2, contains, overlaps as overlaps7, rect as rect18 } from "@n-uf/placement";
2074
2187
 
2075
2188
  // src/targets/anchor.ts
2076
- import { EPS as EPS11, area, rect as rect9, subtract } from "@n-uf/placement";
2189
+ import { EPS as EPS11, area, rect as rect10, subtract } from "@n-uf/placement";
2077
2190
  var OTHER = { left: "right", right: "left", top: "bottom", bottom: "top" };
2078
2191
  function anchorTargets(state, dragged, options) {
2079
2192
  const none = { targets: [], refusals: [], lost: [] };
@@ -2090,7 +2203,7 @@ function anchorTargets(state, dragged, options) {
2090
2203
  const placed = layout.edges[edge.id]?.rect;
2091
2204
  const slot = layout.items[dragged]?.rect;
2092
2205
  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);
2206
+ 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
2207
  if (pieces.length > 0) {
2095
2208
  const hit = pieces.reduce((a, p) => area(p) > area(a) ? p : a);
2096
2209
  const result = { state: moved, layout };
@@ -2102,8 +2215,8 @@ function anchorTargets(state, dragged, options) {
2102
2215
  }
2103
2216
 
2104
2217
  // src/targets/edges.ts
2105
- import { EPS as EPS12, area as area2, rect as rect10 } from "@n-uf/placement";
2106
- import { formCrossMin as formCrossMin4, formMenu as formMenu3, formSetsCross as formSetsCross4, itemSteps as itemSteps3 } from "@n-uf/placement/stack";
2218
+ import { EPS as EPS12, area as area2, rect as rect11 } from "@n-uf/placement";
2219
+ import { formCrossMin as formCrossMin4, formMenu as formMenu5, formSetsCross as formSetsCross4, itemSteps as itemSteps3 } from "@n-uf/placement/stack";
2107
2220
 
2108
2221
  // src/targets/kinds.ts
2109
2222
  var COLUMN_REACH = 22;
@@ -2137,8 +2250,16 @@ function reservedRect(state, l, id) {
2137
2250
  const len2 = column ? it.rect.height : it.rect.width;
2138
2251
  const keep = Math.min(len2, Math.max(0, Number.isFinite(f.main.natural) ? f.main.natural : len2));
2139
2252
  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);
2253
+ 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);
2254
+ }
2255
+ function landedLayout(state, l, dragged, prev) {
2256
+ const it = l.items[dragged];
2257
+ if (!it || it.fixed || it.inMenu || it.floating || !it.edge) return l;
2258
+ const e = state.edges.find((x) => x.id === it.edge);
2259
+ if (!e || !growsOnBar(state, e, dragged, it.form)) return l;
2260
+ return solve(withoutBarGrowth(state, dragged), prev);
2141
2261
  }
2262
+ var solveLanded = (state, dragged, prev) => solve(withoutBarGrowth(state, dragged), prev);
2142
2263
  function slotAt(c, zone, line, id, place, lands, home = false) {
2143
2264
  const result = c.settle(markUsed(moveAmong(c.state, c.dragged, place, c.others), c.dragged));
2144
2265
  const isHome = home || c.isHome(result);
@@ -2227,7 +2348,7 @@ function edgeSlots(c, edge, accepts) {
2227
2348
  };
2228
2349
  const pad = { start: Math.max(0, edge.pad?.start ?? 0), end: Math.max(0, edge.pad?.end ?? 0) };
2229
2350
  const menuLen = el.menu ? len2(el.menu.rect) : 0;
2230
- const occupied = (id) => now.items[id]?.fixed ? reservedRect(state, now, id) : now.items[id].rect;
2351
+ const occupied = (id) => c.room.items[id]?.fixed ? reservedRect(state, c.room, id) : c.room.items[id].rect;
2231
2352
  const shown = (id) => now.items[id]?.edge === edge.id && !now.items[id].inMenu;
2232
2353
  const drawnOf2 = (z) => members0.filter((id) => zoneOf(rest.items[id]) === z && shown(id)).map(occupied);
2233
2354
  const startEnd = (() => {
@@ -2276,7 +2397,7 @@ function edgeSlots(c, edge, accepts) {
2276
2397
  return slots;
2277
2398
  }
2278
2399
  function thickerThan(forms, cross) {
2279
- const shown = forms.filter((f) => !formMenu3(f));
2400
+ const shown = forms.filter((f) => !formMenu5(f));
2280
2401
  return shown.length > 0 && shown.every((f) => !formSetsCross4(f) && formCrossMin4(f) > cross + EPS12);
2281
2402
  }
2282
2403
  var roomReason = (spec, zone) => spec.refuse(zone) === "too-thick" ? "too-thick" : "no-room";
@@ -2293,7 +2414,7 @@ function edgeSpec(c, edge, as) {
2293
2414
  const accepts = edgeTakes(edge, kind);
2294
2415
  if (!accepts && (empty || area2(el.rect) <= EPS12)) return null;
2295
2416
  if (accepts && empty && !opensEmpty(state, edge, kind)) return null;
2296
- const ownNow = now.items[dragged];
2417
+ const ownNow = c.room.items[dragged];
2297
2418
  const ownHere = ownNow && ownNow.edge === edge.id && !ownNow.floating && area2(ownNow.rect) > EPS12 ? ownNow.rect : null;
2298
2419
  const oneEnd = state.foldedColumnDrop === "end" && column && el.tabs.length > 0 && ownNow?.edge !== edge.id && zoneTakes(edge, "start", kind);
2299
2420
  const allSlots = edgeSlots(c, edge, accepts);
@@ -2301,8 +2422,8 @@ function edgeSpec(c, edge, as) {
2301
2422
  const spanOf = (r2) => [at(r2), at(r2) + len2(r2)];
2302
2423
  const grows = (id) => !!formsOf(state.items[id], axisOf(edge.side))[now.items[id].form]?.main.grows;
2303
2424
  const reserved = Object.entries(now.items).filter(([id, p]) => p.edge === edge.id && p.fixed && !p.inMenu && !grows(id)).map(([, p]) => spanOf(p.rect));
2304
- const cards = Object.entries(now.items).filter(([id, p]) => id !== dragged && p.edge === edge.id && !p.fixed && !p.inMenu && !p.floating && area2(p.rect) > EPS12).map(([, p]) => spanOf(p.rect));
2305
- const zones = oneEnd ? [{ zone: "start", a: at(el.rect) - c.reach, b: at(el.rect) + len2(el.rect) + c.reach }] : zoneSpans(state, now, edge, c.reach, (zone) => {
2425
+ const cards = Object.entries(c.room.items).filter(([id, p]) => id !== dragged && p.edge === edge.id && !p.fixed && !p.inMenu && !p.floating && area2(p.rect) > EPS12).map(([, p]) => spanOf(p.rect));
2426
+ const zones = oneEnd ? [{ zone: "start", a: at(el.rect) - c.reach, b: at(el.rect) + len2(el.rect) + c.reach }] : zoneSpans(state, c.room, edge, c.reach, (zone) => {
2306
2427
  const s = slots.find((x) => x.zone === zone && x.place.kind === "gap" && x.place.at === 0);
2307
2428
  const me = s?.result.layout.items[dragged];
2308
2429
  return me && me.edge === edge.id && me.zone === zone ? spanOf(me.rect) : null;
@@ -2318,7 +2439,7 @@ function edgeSpec(c, edge, as) {
2318
2439
  const marker = (s) => {
2319
2440
  const slot = s.result.layout.items[dragged].rect;
2320
2441
  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);
2442
+ return column ? rect11(e.rect.x, slot.y, e.cross, 0) : rect11(slot.x, e.rect.y, 0, e.cross);
2322
2443
  };
2323
2444
  const takes = (zone) => accepts && zoneTakes(edge, zone, kind);
2324
2445
  const tooThick = thickerThan(formsOf(state.items[dragged], axisOf(edge.side)), el.stack.cross);
@@ -2368,9 +2489,9 @@ function placeKey(s, id) {
2368
2489
  });
2369
2490
  }
2370
2491
  function soundness(state, base, dragged) {
2371
- const chrome = keepClearFor(state, "targets");
2372
2492
  const noteKey = (n) => "edge" in n && (n.code === "overflow" || n.code === "too-wide") ? `${n.edge}:${n.code}:${"id" in n ? n.id : ""}` : null;
2373
2493
  const hadNotes = new Set(base.notes.map(noteKey).filter((k) => k !== null));
2494
+ const chrome = keepClearFor(state, {}, "targets");
2374
2495
  return (after) => {
2375
2496
  if (after.notes.some((n) => {
2376
2497
  const k = noteKey(n);
@@ -2392,14 +2513,19 @@ function soundness(state, base, dragged) {
2392
2513
  const me = after.items[dragged];
2393
2514
  if (!me) return true;
2394
2515
  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));
2516
+ const onChrome = chrome.some((c) => overlaps2(me.rect, c)) || (after.keepClear ?? []).some((c) => c.for !== "floats" && overlaps2(me.rect, c.rect));
2517
+ return !onChrome && !fixedAfter.some((f) => overlaps2(me.rect, f));
2396
2518
  };
2397
2519
  }
2520
+ function roomOf2(state, now, prev) {
2521
+ const plain = withoutBarGrowth(state);
2522
+ return plain === state ? now : solve(plain, prev);
2523
+ }
2398
2524
  function context(state, dragged, options, others = []) {
2399
2525
  const item = Object.hasOwn(state.items, dragged) ? state.items[dragged] : void 0;
2400
2526
  if (!item || item.fixed || item.closed) return null;
2401
2527
  const prev = { ...options.previous ? { previous: options.previous } : {}, ...options.fresh ? { fresh: options.fresh } : {} };
2402
- const settle2 = (s) => ({ state: s, layout: solve(s, prev) });
2528
+ const settle2 = (s) => ({ state: s, layout: solveLanded(s, dragged, prev) });
2403
2529
  const now = solve(state, prev);
2404
2530
  const rest = liftItem(state, dragged);
2405
2531
  const base = solve(rest, prev);
@@ -2409,6 +2535,8 @@ function context(state, dragged, options, others = []) {
2409
2535
  others,
2410
2536
  rest,
2411
2537
  now,
2538
+ room: roomOf2(state, now, prev),
2539
+ prev,
2412
2540
  base,
2413
2541
  dragged,
2414
2542
  kind: item.kind,
@@ -2422,17 +2550,17 @@ function context(state, dragged, options, others = []) {
2422
2550
  }
2423
2551
 
2424
2552
  // 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";
2426
- import { formBody, itemSteps as itemSteps5 } from "@n-uf/placement/stack";
2553
+ import { EPS as EPS15, area as area3, overlaps as overlaps3, rect as rect13, subtract as subtract2 } from "@n-uf/placement";
2554
+ import { formBody as formBody2, itemSteps as itemSteps5 } from "@n-uf/placement/stack";
2427
2555
 
2428
2556
  // src/targets/meet.ts
2429
- import { EPS as EPS13, rect as rect11 } from "@n-uf/placement";
2557
+ import { EPS as EPS13, rect as rect12 } from "@n-uf/placement";
2430
2558
  function meet(a, b) {
2431
2559
  const x = Math.max(a.x, b.x);
2432
2560
  const y = Math.max(a.y, b.y);
2433
2561
  const w = Math.min(a.x + a.width, b.x + b.width) - x;
2434
2562
  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;
2563
+ return w > EPS13 && h > EPS13 ? rect12(x, y, w, h) : null;
2436
2564
  }
2437
2565
 
2438
2566
  // src/targets/model.ts
@@ -2440,23 +2568,23 @@ import { EPS as EPS14 } from "@n-uf/placement";
2440
2568
  var less = (spans, away) => away.reduce((acc, [ra, rb]) => acc.flatMap(([a, b]) => rb <= a || ra >= b ? [[a, b]] : [[a, Math.max(a, ra)], [Math.min(b, rb), b]].filter(([u, w]) => w - u > EPS14)), [...spans]);
2441
2569
 
2442
2570
  // src/targets/ownership.ts
2443
- var isBody = (f) => !!f && formBody(f);
2571
+ var isBody = (f) => !!f && formBody2(f);
2444
2572
  var bandOf = (s) => {
2445
2573
  const a = Math.min(...s.zones.map((z) => z.a));
2446
2574
  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]);
2575
+ 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
2576
  };
2449
2577
  var ownedRectOf = (s) => {
2450
2578
  const b = bandOf(s);
2451
2579
  if (!s.ownedAlong) return b;
2452
2580
  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);
2581
+ return s.vertical ? rect13(b.x, a0, b.width, a1 - a0) : rect13(a0, b.y, a1 - a0, b.height);
2454
2582
  };
2455
2583
  function ownedRectsOf(s, along2) {
2456
2584
  if (along2.length === 0) return [];
2457
2585
  const o = ownedRectOf(s);
2458
2586
  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));
2587
+ return along2.map(([a, b]) => s.vertical ? rect13(o.x, a, o.width, b - a) : rect13(a, o.y, b - a, o.height));
2460
2588
  }
2461
2589
  function drawnOf(c, live) {
2462
2590
  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 +2597,7 @@ function drawnOf(c, live) {
2469
2597
  const run = me?.rail === side ? rail.segments.filter((g) => g.edge === me.edge).map((g) => g.rect) : [];
2470
2598
  if (run.length === 0) return [{ spec, rect: rail.rect, lay }];
2471
2599
  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);
2600
+ const own = rect13(rail.rect.x, top, rail.rect.width, Math.max(...run.map((r) => r.y + r.height)) - top);
2473
2601
  const column = live.find((s) => s.kind === "railColumn" && s.edge?.id === me.edge);
2474
2602
  return [...subtract2(rail.rect, own).map((r) => ({ spec, rect: r, lay })), ...column ? [{ spec: column, rect: own, lay: column.lay }] : []];
2475
2603
  });
@@ -2479,7 +2607,7 @@ function homeRectOf(c, ownSpec) {
2479
2607
  const own = c.now.items[c.dragged];
2480
2608
  if (!own || own.floating || !own.edge) return null;
2481
2609
  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));
2610
+ 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
2611
  if (own.inMenu) return o;
2484
2612
  if (!ownSpec) {
2485
2613
  const e = c.now.edges[own.edge];
@@ -2487,7 +2615,7 @@ function homeRectOf(c, ownSpec) {
2487
2615
  return e && vanishes && !e.folded && !e.rides && area3(e.rect) > EPS15 ? hull3(o, e.rect) : o;
2488
2616
  }
2489
2617
  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));
2618
+ return ownSpec.vertical ? hull3(o, rect13(c0, o.y, c1 - c0, o.height)) : hull3(o, rect13(o.x, c0, o.width, c1 - c0));
2491
2619
  }
2492
2620
  function ownersOf(c, live, drawn, alongOf) {
2493
2621
  const ownEdge = c.now.items[c.dragged]?.edge;
@@ -2502,14 +2630,14 @@ function ownersOf(c, live, drawn, alongOf) {
2502
2630
  ...live.flatMap((s) => {
2503
2631
  const rects = ownedRectsOf(s, alongOf(s));
2504
2632
  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]));
2633
+ 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
2634
  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
2635
  }).filter((o) => area3(o.rect) > EPS15),
2508
2636
  // Every seen rect: the edges the tiler doesn't read (folded, riding, taking nothing) among them.
2509
2637
  ...drawn.map((d) => ({ ...d, place: false }))
2510
2638
  ];
2511
2639
  }
2512
- function ownership(c, live, alongOf) {
2640
+ function ownership(c, live, alongOf, aloneOf) {
2513
2641
  const { state, now, dragged } = c;
2514
2642
  const drawn = drawnOf(c, live);
2515
2643
  const owners = ownersOf(c, live, drawn, alongOf);
@@ -2520,15 +2648,15 @@ function ownership(c, live, alongOf) {
2520
2648
  const place = !s.drawn;
2521
2649
  return o.place === place ? !place || o.lay.at < s.lay.at : !o.place;
2522
2650
  };
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])) : [];
2651
+ 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
2652
  const thinRectOf = (s) => {
2525
2653
  const b = bandOf(s);
2526
2654
  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);
2655
+ return s.vertical ? rect13(t0, b.y, t1 - t0, b.height) : rect13(b.x, t0, b.width, t1 - t0);
2528
2656
  };
2529
2657
  const endsOf = (s) => {
2530
2658
  const e = s.edge ? now.edges[s.id] : void 0;
2531
- if (!e || EDGE_KINDS[s.kind].virtual) return null;
2659
+ if (!e) return null;
2532
2660
  const span = s.vertical ? [e.rect.y, e.rect.y + e.rect.height] : [e.rect.x, e.rect.x + e.rect.width];
2533
2661
  return span[1] - span[0] > EPS15 ? span : null;
2534
2662
  };
@@ -2536,33 +2664,39 @@ function ownership(c, live, alongOf) {
2536
2664
  const ends = endsOf(s);
2537
2665
  if (!ends) return [];
2538
2666
  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));
2667
+ 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
2668
  };
2541
2669
  const ownSpanOf = (s) => {
2542
2670
  const ends = endsOf(s);
2543
2671
  if (!ends) return null;
2544
2672
  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);
2673
+ return s.vertical ? rect13(o0, ends[0], o1 - o0, ends[1] - ends[0]) : rect13(ends[0], o0, ends[1] - ends[0], o1 - o0);
2674
+ };
2675
+ const heldBySpec = /* @__PURE__ */ new Map();
2676
+ const heldOf = (d) => {
2677
+ let held = heldBySpec.get(d);
2678
+ if (!held) {
2679
+ const span = ownSpanOf(d);
2680
+ heldBySpec.set(d, held = span ? ownedRectsOf(d, alongOf(d)).flatMap((r) => meet(r, span) ?? []) : aloneOf(d));
2681
+ }
2682
+ return held;
2546
2683
  };
2547
2684
  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]);
2685
+ const held = heldOf(s);
2686
+ if (!o.spec || held.length === 0) return [r];
2687
+ return pastEnds(o.spec, r).flatMap((p) => held.flatMap((h) => meet(p, h) ?? [])).reduce((acc, cut2) => acc.flatMap((q) => subtract2(q, cut2)), [r]);
2551
2688
  };
2552
2689
  const reachYields = (s) => {
2553
2690
  const past = pastEnds(s, bandOf(s));
2554
2691
  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) ?? []));
2692
+ return live.filter((d) => d !== s).flatMap((d) => heldOf(d)).flatMap((q) => past.flatMap((p) => meet(p, q) ?? []));
2559
2693
  };
2560
2694
  const taken = new Map(
2561
2695
  live.map((s) => [
2562
2696
  s,
2563
2697
  [
2564
2698
  ...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))) : [],
2699
+ ...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
2700
  ...s.thinOwned ? live.filter((d) => d !== s).flatMap((d) => takingRects(d).flatMap((t) => subtract2(t, thinRectOf(s)))) : [],
2567
2701
  ...reachYields(s)
2568
2702
  ]
@@ -2581,10 +2715,10 @@ function ownership(c, live, alongOf) {
2581
2715
  const rooms = /* @__PURE__ */ new Map();
2582
2716
  const cutsOf = (s) => {
2583
2717
  let room = rooms.get(s);
2584
- if (!room) rooms.set(s, room = roomOf2(s));
2718
+ if (!room) rooms.set(s, room = roomOf3(s));
2585
2719
  return room;
2586
2720
  };
2587
- const roomOf2 = (s) => {
2721
+ const roomOf3 = (s) => {
2588
2722
  const b = bandOf(s);
2589
2723
  const along2 = (r) => s.vertical ? [r.y, r.y + r.height] : [r.x, r.x + r.width];
2590
2724
  const across2 = (r) => s.vertical ? [r.x, r.x + r.width] : [r.y, r.y + r.height];
@@ -2625,7 +2759,7 @@ function ownership(c, live, alongOf) {
2625
2759
  const e = s.edge;
2626
2760
  if (!e) return [];
2627
2761
  const column = axisOf(e.side) === "column";
2628
- const across2 = (a, b) => column ? rect12(-1e9, a, 2e9, b - a) : rect12(a, -1e9, b - a, 2e9);
2762
+ const across2 = (a, b) => column ? rect13(-1e9, a, 2e9, b - a) : rect13(a, -1e9, b - a, 2e9);
2629
2763
  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
2764
  return [...reserved, ...cutsOf(s).bodies.map(([a, b]) => across2(a, b))].filter((b) => area3(b) > EPS15);
2631
2765
  };
@@ -2639,13 +2773,13 @@ function ownership(c, live, alongOf) {
2639
2773
  }
2640
2774
 
2641
2775
  // 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";
2776
+ import { EPS as EPS16, area as area4, overlaps as overlaps4, rect as rect14, subtract as subtract3 } from "@n-uf/placement";
2643
2777
  function tilerOf(spec) {
2644
2778
  const data = EDGE_KINDS[spec.kind];
2645
2779
  const v = spec.vertical;
2646
2780
  const band = (a, b, after) => {
2647
2781
  const [c0, c1] = spec.across(after);
2648
- return v ? rect13(c0, a, c1 - c0, b - a) : rect13(a, c0, b - a, c1 - c0);
2782
+ return v ? rect14(c0, a, c1 - c0, b - a) : rect14(a, c0, b - a, c1 - c0);
2649
2783
  };
2650
2784
  const keepAt = (line, h) => v ? { x: h.x + h.width / 2, y: line } : { x: line, y: h.y + h.height / 2 };
2651
2785
  const tile = (zone, hit, more) => ({ edge: spec.id, spec, edgeKind: spec.kind, vertical: v, zone, hit, ...more });
@@ -2653,7 +2787,7 @@ function tilerOf(spec) {
2653
2787
  const h = t.hit;
2654
2788
  const [h0, h1] = v ? [h.x, h.x + h.width] : [h.y, h.y + h.height];
2655
2789
  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);
2790
+ const part = (a, b) => v ? rect14(a, h.y, b - a, h.height) : rect14(h.x, a, h.width, b - a);
2657
2791
  const beyond = less([[h0, h1]], [spec.owned]);
2658
2792
  if (beyond.length === 0) return [t];
2659
2793
  if (c1 - c0 <= EPS16) return [{ ...t, order: data.overreach }];
@@ -2706,7 +2840,7 @@ function reachStrips(c, spec, room, ends) {
2706
2840
  const pieces = room.filter(inEdge);
2707
2841
  if (!ends || pieces.length === 0) return { pieces: [...room], before: [], after: [] };
2708
2842
  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);
2843
+ const bandOf2 = (a, b) => spec.vertical ? rect14(c0, a, c1 - c0, b - a) : rect14(a, c0, b - a, c1 - c0);
2710
2844
  const across2 = c.state.edges.filter((e) => axisOf(e.side) === "column" !== spec.vertical).map((e) => c.now.edges[e.id]);
2711
2845
  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
2846
  const first = pieces[0][0];
@@ -2725,7 +2859,7 @@ function tileEdge(c, spec, { cuts, bodies }, lost) {
2725
2859
  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
2860
  const { band, keepAt, tile, split } = tilerOf(spec);
2727
2861
  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;
2862
+ 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
2863
  const refused = (zone, hit, reason) => {
2730
2864
  const inEdge = alongLimit ? meet(hit, alongLimit) : hit;
2731
2865
  const shown = inEdge && meet(inEdge, c.state.stage);
@@ -2805,7 +2939,7 @@ function tileEdge(c, spec, { cuts, bodies }, lost) {
2805
2939
  const [a, b] = own;
2806
2940
  const h = band(a, b);
2807
2941
  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));
2942
+ 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
2943
  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
2944
  }
2811
2945
  return out;
@@ -2839,7 +2973,7 @@ function placeReach(t, pieces, placed, landed, gone) {
2839
2973
  (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
2974
  );
2841
2975
  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));
2976
+ 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
2977
  placed[i] = cover.length > 1 ? withPieces(placed[i], cover.map((r, j) => j === k ? merged : r)) : { ...placed[i], hit: merged };
2844
2978
  return;
2845
2979
  }
@@ -2907,10 +3041,10 @@ function clipTiles(tiles, own, chrome, lost) {
2907
3041
  }
2908
3042
 
2909
3043
  // src/targets/rail-strip.ts
2910
- import { EPS as EPS18, overlaps as overlaps5, rect as rect15, subtract as subtract4 } from "@n-uf/placement";
3044
+ import { EPS as EPS18, overlaps as overlaps5, rect as rect16, subtract as subtract4 } from "@n-uf/placement";
2911
3045
 
2912
3046
  // src/targets/virtual.ts
2913
- import { EPS as EPS17, clamp, rect as rect14 } from "@n-uf/placement";
3047
+ import { EPS as EPS17, clamp, rect as rect15 } from "@n-uf/placement";
2914
3048
  function ringsOf(c, side) {
2915
3049
  const seen = sideRings(c.state.edges, side);
2916
3050
  const kept = c.rest.edges.filter((e) => e.side === side).map((e) => seen.get(e.id) ?? e.ring);
@@ -2988,7 +3122,7 @@ function columnLines(c, side, railLands) {
2988
3122
  ownedAlong: p.owned,
2989
3123
  drawn: false,
2990
3124
  // 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)
3125
+ marker: () => rect15(clamp(l.x, stage.x, stage.x + stage.width), span.y, 0, span.height)
2992
3126
  };
2993
3127
  });
2994
3128
  }
@@ -3015,7 +3149,7 @@ function ownColumnRun(c, side, rail) {
3015
3149
  const tiles = shown.segments.filter((s) => s.edge === edge.id).map((s) => s.rect);
3016
3150
  if (tiles.length === 0) return null;
3017
3151
  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));
3152
+ const spec = railColumnSpec(c, edge, rect15(shown.rect.x, top, shown.rect.width, Math.max(...tiles.map((r) => r.y + r.height)) - top));
3019
3153
  if (!spec) return null;
3020
3154
  const stays = ({ layout }) => layout.items[dragged]?.rail === side && layout.items[dragged]?.edge === edge.id;
3021
3155
  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 +3187,7 @@ function railStops(c, side) {
3053
3187
  } else {
3054
3188
  const firstCol = mine.find((e) => e.column === true);
3055
3189
  const outer = railOuter(c, side);
3056
- zone = rect14(side === "left" ? outer : outer - RAIL_EDGE, placeRect.y, RAIL_EDGE, placeRect.height);
3190
+ zone = rect15(side === "left" ? outer : outer - RAIL_EDGE, placeRect.y, RAIL_EDGE, placeRect.height);
3057
3191
  stops2.push({ y: placeRect.y, ring: firstCol ? rings.before(firstCol) : rings.count });
3058
3192
  }
3059
3193
  const ownRail = now.items[dragged]?.rail === side;
@@ -3084,7 +3218,7 @@ function railStops(c, side) {
3084
3218
  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
3219
  ownedAlong: null,
3086
3220
  drawn: !!rail && rail.segments.length > 0,
3087
- marker: (s) => rect14(at.x, s.result.layout.items[dragged].rect.y, at.width, 0)
3221
+ marker: (s) => rect15(at.x, s.result.layout.items[dragged].rect.y, at.width, 0)
3088
3222
  };
3089
3223
  }
3090
3224
 
@@ -3104,7 +3238,7 @@ function columnStrip(c, side, policy) {
3104
3238
  const r = el.rect;
3105
3239
  const railWidth = result.layout.items[c.dragged].tab ? r.width : edge.cross.rail ?? 30;
3106
3240
  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 }] };
3241
+ 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
3242
  }
3109
3243
  function declaredStrip(c, side, policy) {
3110
3244
  const template = c.state.columns?.[side];
@@ -3121,7 +3255,7 @@ function declaredStrip(c, side, policy) {
3121
3255
  const cuts = [a, ...slots.slice(1).map((s, i) => (slots[i].line + s.line) / 2), b];
3122
3256
  return {
3123
3257
  side,
3124
- rect: rect15(x, a, w, b - a),
3258
+ rect: rect16(x, a, w, b - a),
3125
3259
  slots: slots.map((s, i) => ({ id: s.id, place: s.place, along: [cuts[i], cuts[i + 1]], result: s.result }))
3126
3260
  };
3127
3261
  }
@@ -3206,7 +3340,7 @@ ${r.zone}`) ?? [], r]);
3206
3340
  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
3341
  const renumbered = refused.map((r) => numbered.get(r) === r.id ? r : { ...r, id: numbered.get(r) });
3208
3342
  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);
3343
+ 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
3344
  for (const sl of s.slots) {
3211
3345
  const [a, b] = sl.along;
3212
3346
  const slot = sl.result.layout.items[c.dragged].rect;
@@ -3214,8 +3348,8 @@ ${r.zone}`) ?? [], r]);
3214
3348
  out.push({
3215
3349
  id: sl.id,
3216
3350
  priority: 1,
3217
- hit: rect15(s.rect.x, a, s.rect.width, b - a),
3218
- armedHit: rect15(grown.x, a, grown.width, b - a),
3351
+ hit: rect16(s.rect.x, a, s.rect.width, b - a),
3352
+ armedHit: rect16(grown.x, a, grown.width, b - a),
3219
3353
  arm: "dwell",
3220
3354
  // Armed, its room opens at once: a host that draws only a marker reads that from this one flag, as for any target.
3221
3355
  opensRoom: true,
@@ -3236,7 +3370,7 @@ var withoutHits = (t) => {
3236
3370
  function insideStrips(r, strips) {
3237
3371
  const s = strips.find((x) => overlaps5(x.rect, r));
3238
3372
  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);
3373
+ 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
3374
  }
3241
3375
  function clearOfStrips(t, dragged, strips) {
3242
3376
  return {
@@ -3247,7 +3381,7 @@ function clearOfStrips(t, dragged, strips) {
3247
3381
  if (!at) return first;
3248
3382
  let dx = 0;
3249
3383
  for (const s of strips) {
3250
- const r = rect15(at.x + dx, at.y, at.width, at.height);
3384
+ const r = rect16(at.x + dx, at.y, at.width, at.height);
3251
3385
  if (!overlaps5(r, s)) continue;
3252
3386
  dx += s.x + s.width / 2 < r.x + r.width / 2 ? s.x + s.width - r.x : s.x - (r.x + r.width);
3253
3387
  }
@@ -3257,7 +3391,7 @@ function clearOfStrips(t, dragged, strips) {
3257
3391
  }
3258
3392
 
3259
3393
  // src/targets/min-hit.ts
3260
- import { EPS as EPS19, area as area5, rect as rect16, subtract as subtract5 } from "@n-uf/placement";
3394
+ import { EPS as EPS19, area as area5, rect as rect17, subtract as subtract5 } from "@n-uf/placement";
3261
3395
  function kindOf(c, t) {
3262
3396
  const p = parseTargetId(t.id);
3263
3397
  if (!p) return null;
@@ -3279,21 +3413,21 @@ var withPieces2 = (t, ps) => {
3279
3413
  return { ...rest, hit: largest3(ps), ...ps.length > 1 ? { hits: ps } : {} };
3280
3414
  };
3281
3415
  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)];
3416
+ 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
3417
  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)];
3418
+ 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
3419
  return [[lo2], [hi], halves];
3286
3420
  }
3287
3421
  var union = (a, gs) => {
3288
3422
  const x0 = Math.min(a.x, ...gs.map((g) => g.x));
3289
3423
  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);
3424
+ 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
3425
  };
3292
3426
  function mayGrow(c, targets2, i, grow, minOf, zone, away) {
3293
3427
  const s = c.state.stage;
3294
3428
  for (const g of grow) {
3295
3429
  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;
3430
+ if ([...keepClearFor(c.state, c.now, "targets"), ...away].some((r) => overlaps6(r, g))) return false;
3297
3431
  if (zone.reduce((ps, z) => ps.flatMap((p) => subtract5(p, z)), [g]).some((p) => area5(p) > EPS19)) return false;
3298
3432
  }
3299
3433
  return targets2.every((o, j) => {
@@ -3309,7 +3443,7 @@ function partialGrowth(c, targets2, i, l, axis, d, m, minOf, zone, away) {
3309
3443
  let best = null;
3310
3444
  for (const [side] of growths(l, axis, d)) {
3311
3445
  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);
3446
+ const strip = (a, b) => axis === "x" ? rect17(g.x, a, g.width, b - a) : rect17(a, g.y, b - a, g.height);
3313
3447
  const cuts = /* @__PURE__ */ new Set([along2[0], along2[1]]);
3314
3448
  for (const o of targets2)
3315
3449
  for (const p of piecesOf(o))
@@ -3372,7 +3506,7 @@ function withMinHit(c, targets2, refusals2, zones) {
3372
3506
  out[j] = withPieces2(o, grow.reduce((ps, g) => cut(ps, g), [...piecesOf(o)]));
3373
3507
  }
3374
3508
  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);
3509
+ const span = axis === "x" ? rect17(l.x, g0.y, l.width, g0.height) : rect17(g0.x, l.y, g0.width, l.height);
3376
3510
  const grown = union(span, grow);
3377
3511
  const others = piecesOf(out[i]).filter((p) => p !== l);
3378
3512
  out[i] = withPieces2(out[i], [...cut([...others, l], grown), grown]);
@@ -3401,7 +3535,7 @@ function emit2(c, placed) {
3401
3535
  const homeId = targetId({ kind: "home", item: dragged });
3402
3536
  const targets2 = [];
3403
3537
  const refused = [];
3404
- const homeAfter = () => ({ state, layout: now });
3538
+ const homeAfter = () => ({ state, layout: landedLayout(state, now, dragged, c.prev) });
3405
3539
  const pos = (t) => t.vertical ? [t.hit.y, t.hit.x] : [t.hit.x, t.hit.y];
3406
3540
  const rank = /* @__PURE__ */ new Map();
3407
3541
  const edgeOf = (t) => t.spec?.edge ? t.spec : t.edge;
@@ -3445,7 +3579,7 @@ function emit2(c, placed) {
3445
3579
  function hull(a, b) {
3446
3580
  const x = Math.min(a.x, b.x);
3447
3581
  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);
3582
+ 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
3583
  }
3450
3584
  var thicknessChanges = (now, after) => {
3451
3585
  const a = now.content;
@@ -3463,6 +3597,9 @@ function slotOverMoved(now, lifted, after, slot, dragged, onto) {
3463
3597
  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
3598
  });
3465
3599
  }
3600
+ function aloneRects(tiles) {
3601
+ return tiles.filter((t) => t.kind !== "refuse" && !(t.kind === "reach" && t.of.kind === "refuse")).map((t) => t.hit);
3602
+ }
3466
3603
  function alongOfSlots(s, tiles) {
3467
3604
  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
3605
  const out = [];
@@ -3488,14 +3625,14 @@ function generate(state, dragged, options) {
3488
3625
  ...t,
3489
3626
  after: (point, grab) => {
3490
3627
  const a = t.after(point, grab);
3491
- if (a.state === shown) return { state, layout: showsIn ? solve(state, prev) : a.layout };
3628
+ if (a.state === shown) return { state, layout: showsIn ? solveLanded(state, dragged, prev) : a.layout };
3492
3629
  const on = t.place.kind === "gap" ? shown.edges.find((e) => t.place.kind === "gap" && e.id === t.place.edge) : void 0;
3493
3630
  const named = !!on && namesZone(on, state.items[dragged].kind);
3494
3631
  const back = withHiddenOf(state, a.state, lent, dragged, named, rezoned);
3495
3632
  const restored = showsIn ? prune(back) : back;
3496
3633
  const ringOf = new Map(a.state.edges.map((e) => [e.id, e.ring]));
3497
3634
  const renumbered = restored.edges.some((e) => e.hidden !== true && ringOf.get(e.id) !== e.ring);
3498
- const layout = renumbered || showsIn || rezoned.size > 0 ? solve(restored, prev) : a.layout;
3635
+ const layout = renumbered || showsIn || rezoned.size > 0 ? solveLanded(restored, dragged, prev) : a.layout;
3499
3636
  return { state: restored, layout };
3500
3637
  }
3501
3638
  }))
@@ -3510,7 +3647,7 @@ function generateShown(state, dragged, options, hidden) {
3510
3647
  const live = specsOf(c, item.kind);
3511
3648
  const alone = new Map(live.map((s) => [s, tileEdge(c, s, { cuts: [], bodies: [] }, [])]));
3512
3649
  const along2 = new Map(live.map((s) => [s, alongOfSlots(s, alone.get(s))]));
3513
- const own = ownership(c, live, (s) => along2.get(s));
3650
+ const own = ownership(c, live, (s) => along2.get(s), (s) => aloneRects(alone.get(s)));
3514
3651
  const lost = [];
3515
3652
  const tiles = live.flatMap((spec) => tileEdge(c, spec, own.cutsOf(spec), lost));
3516
3653
  const ownRect = now.items[dragged];
@@ -3518,14 +3655,18 @@ function generateShown(state, dragged, options, hidden) {
3518
3655
  const homeHit = homeRectOf(c, null);
3519
3656
  if (ownRect && homeEdge && homeHit && !tiles.some((t) => t.order === 0))
3520
3657
  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);
3658
+ const placed = clipTiles(tiles, own, keepClearFor(state, now, "targets"), lost);
3522
3659
  const { targets: targets2, refused, ownHome } = emit2(c, placed);
3523
- const homeAfter = () => ({ state, layout: now });
3660
+ const homeAfter = () => ({ state, layout: landedLayout(state, now, dragged, c.prev) });
3524
3661
  if (state.floatKinds.includes(item.kind)) {
3525
3662
  const was = state.floats.find((f) => f.id === dragged);
3526
3663
  const fo = options.floatOrient ?? was?.orient ?? floatOrientOf(item);
3527
3664
  const wasOrient = was?.orient ?? floatOrientOf(item);
3528
3665
  const size = options.floatSize ?? (was && wasOrient === fo ? { width: was.rect.width, height: was.rect.height } : floatSizeOf(item, fo));
3666
+ const seenOwn = now.items[dragged];
3667
+ const seenEdge = seenOwn?.edge ? state.edges.find((e) => e.id === seenOwn.edge) : void 0;
3668
+ const grown = seenOwn && seenEdge && growsOnBar(state, seenEdge, dragged, seenOwn.form) && seenOwn.rect.width > 0 && seenOwn.rect.height > 0 ? seenOwn.rect : null;
3669
+ const handOf = (g) => g && grown ? { x: clamp2(g.x / grown.width, 0, 1) * size.width, y: clamp2(g.y / grown.height, 0, 1) * size.height } : g;
3529
3670
  targets2.push({
3530
3671
  id: targetId({ kind: "float", item: dragged }),
3531
3672
  priority: 3,
@@ -3536,13 +3677,13 @@ function generateShown(state, dragged, options, hidden) {
3536
3677
  item: dragged,
3537
3678
  place: { kind: "float" },
3538
3679
  after(point, grab) {
3539
- 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);
3680
+ const g = handOf(grab) ?? { x: size.width / 2, y: size.height / 2 };
3681
+ const raw = options.floatFromHeld ? heldRect(state, dragged, size, point, g) : rect18(point.x - g.x, point.y - g.y, size.width, size.height);
3541
3682
  const first = solve(markUsed(floatAt(state, dragged, raw, options.floatOrient), dragged), prev);
3542
3683
  const fitted = first.items[dragged]?.rect;
3543
3684
  const at = fitted ?? raw;
3544
3685
  const placed2 = (x, y, stays) => {
3545
- const s = floatAt(state, dragged, rect17(x, y, size.width, size.height), options.floatOrient);
3686
+ const s = floatAt(state, dragged, rect18(x, y, size.width, size.height), options.floatOrient);
3546
3687
  return c.settle(markUsed(stays ? { ...s, floats: s.floats.map((f) => f.id === dragged ? { ...f, stays: true } : f) } : s, dragged));
3547
3688
  };
3548
3689
  const hand = heldRect(state, dragged, fitted ?? size, point, g);
@@ -3557,7 +3698,7 @@ function generateShown(state, dragged, options, hidden) {
3557
3698
  });
3558
3699
  }
3559
3700
  (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 });
3701
+ 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
3702
  });
3562
3703
  const sameAsHome = targets2.filter((t) => t.place.kind === "home" && parseTargetId(t.id)?.kind === "column");
3563
3704
  const homePieces = sameAsHome.flatMap((t) => t.hits ?? [t.hit]);
@@ -3580,7 +3721,7 @@ function generateShown(state, dragged, options, hidden) {
3580
3721
  const held = withMinHit(c, layered.targets, layered.refusals, zones).map((t) => t.roomHit && t.slot ? { ...t, roomHit: hull(t.hit, t.slot) } : t);
3581
3722
  return { targets: held, refusals: layered.refusals.map((r) => ({ ...r, bounds })), lost: lostIds, zones };
3582
3723
  }
3583
- var stageOf = (state) => rect17(state.stage.x, state.stage.y, state.stage.width, state.stage.height);
3724
+ var stageOf = (state) => rect18(state.stage.x, state.stage.y, state.stage.width, state.stage.height);
3584
3725
  function targets(state, dragged, options = {}) {
3585
3726
  return generate(state, dragged, options).targets;
3586
3727
  }
@@ -3639,7 +3780,7 @@ function orderedStops(state, dragged, options) {
3639
3780
  }
3640
3781
 
3641
3782
  // src/lanes.ts
3642
- import { EPS as EPS21, area as area7, clamp as clamp3, rect as rect18, subtract as subtract6 } from "@n-uf/placement";
3783
+ import { EPS as EPS21, area as area7, clamp as clamp3, rect as rect19, subtract as subtract6 } from "@n-uf/placement";
3643
3784
  import { itemSteps as itemSteps6 } from "@n-uf/placement/stack";
3644
3785
  var SPOT_PITCH = 40;
3645
3786
  var SNAP_DISTANCE = 8;
@@ -3650,7 +3791,7 @@ var len = (r, axis) => axis === "x" ? r.width : r.height;
3650
3791
  var hull2 = (a, b) => {
3651
3792
  const x = Math.min(a.x, b.x);
3652
3793
  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);
3794
+ 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
3795
  };
3655
3796
  var nonNeg = (v) => Number.isFinite(v) && v > 0 ? v : 0;
3656
3797
  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;
@@ -3754,7 +3895,7 @@ function rawSpot(base, id) {
3754
3895
  function build(state, dragged, options) {
3755
3896
  const seen = solve(state, options.previous ? { previous: options.previous } : {});
3756
3897
  const { targets: ts, refusals: rs } = targetsAndRefusals(state, dragged, options);
3757
- const own = seen.items[dragged];
3898
+ const own = landedLayout(state, seen, dragged, options.previous ? { previous: options.previous } : {}).items[dragged];
3758
3899
  const ownEdge = own && !own.floating && !own.inMenu ? own.edge : void 0;
3759
3900
  const pitch = options.pitch === void 0 ? SPOT_PITCH : options.pitch;
3760
3901
  const raws = [];
@@ -3798,8 +3939,9 @@ function build(state, dragged, options) {
3798
3939
  const marking = {
3799
3940
  pitch,
3800
3941
  natural: (id, axis) => {
3801
- const main = state.items[id]?.forms[axis === "x" ? "row" : "column"]?.[0]?.main;
3802
- return main?.grows ? main.natural : void 0;
3942
+ const it = state.items[id];
3943
+ const main = it?.forms[axis === "x" ? "row" : "column"]?.[0]?.main;
3944
+ return it?.fixed && main?.grows ? main.natural : void 0;
3803
3945
  },
3804
3946
  gap: (edge) => nonNeg(state.edges.find((e) => e.id === edge)?.gap),
3805
3947
  crossing: (edge, over2) => state.edges.filter((e) => e.id !== edge && byLane.has(e.id) && (over2.edges[e.id]?.cross ?? 0) > EPS21 && axisOfEdge(e.id) !== axisOfEdge(edge)).map((e) => over2.edges[e.id].rect)
@@ -3815,7 +3957,7 @@ function build(state, dragged, options) {
3815
3957
  const blocked = [
3816
3958
  ...Object.values(seen.edges).filter((e) => e.cross > EPS21).map((e) => e.rect),
3817
3959
  ...Object.entries(seen.items).filter(([id, it]) => id !== dragged && !it.floating && !it.inMenu).map(([, it]) => it.rect),
3818
- ...keepClearFor(state, "targets"),
3960
+ ...keepClearFor(state, seen, "targets"),
3819
3961
  ...rails,
3820
3962
  // A held tile's own rail: every stop is home's in `targets()`, with the new-column lines about its folded column
3821
3963
  // joined to it (the strip beside the rail). A home place takes no float, so it is blocked as `targets()` has it.
@@ -3860,7 +4002,7 @@ function laneRectOver(list, over2, marking) {
3860
4002
  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
4003
  const drawnAt = drawnRect(over2, first.edge);
3862
4004
  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);
4005
+ 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
4006
  return { rect: clipAtDrawn(whole, axis, marking.crossing(first.edge, over2)), band: whole };
3865
4007
  }
3866
4008
  function drawnIn(layout, id) {
@@ -3954,7 +4096,7 @@ function laneFrom(id, list, drawn, seen, dragged, rs, halves, share, marking, sh
3954
4096
  }) : virtualMarks(id, unique, drawn.items[dragged]);
3955
4097
  return { id, rect: laneRect, axis, spots, refused, marks, ...list.every((r) => r.strip) ? { owns: true } : {} };
3956
4098
  }
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);
4099
+ 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
4100
  var LINE2 = 2;
3959
4101
  var MIN_BOX = 8;
3960
4102
  var HATCH_END = 8;
@@ -4018,7 +4160,7 @@ function virtualMarks(lane, spots, held) {
4018
4160
  const l = s.landing;
4019
4161
  if (!held || held.floating || !overlaps8(l, held.rect)) return { id: `${lane}/box/${s.id}`, kind: "box", rect: l };
4020
4162
  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) };
4163
+ return { id: `${lane}/line/${s.id}`, kind: "line", rect: rect19(x, l.y, 0, l.height) };
4022
4164
  });
4023
4165
  }
4024
4166
  function inLane(l, r) {
@@ -4029,7 +4171,7 @@ function inLane(l, r) {
4029
4171
  const y1 = Math.min(m.rect.y + m.rect.height, r.y + r.height);
4030
4172
  if (m.kind === "line") return x1 - x0 >= m.rect.width - EPS21 && y1 - y0 >= m.rect.height - EPS21 ? [m] : [];
4031
4173
  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) }];
4174
+ return x1 - x0 >= m.rect.width - EPS21 && y1 - y0 >= m.rect.height - EPS21 ? [m] : [{ ...m, rect: rect19(x0, y0, x1 - x0, y1 - y0) }];
4033
4175
  });
4034
4176
  return marks.length === l.marks.length && marks.every((m, i) => m === l.marks[i]) ? l : { ...l, marks };
4035
4177
  }
@@ -4073,11 +4215,11 @@ function settle(lane, drawn, state, dragged, all, emptyLanes = "real", within =
4073
4215
  if (l.axis === "y") {
4074
4216
  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
4217
  const t = Math.min(HATCH_EDGE, piece.width);
4076
- r = rect18(outerRight ? piece.x + piece.width - t : piece.x, piece.y, t, piece.height);
4218
+ r = rect19(outerRight ? piece.x + piece.width - t : piece.x, piece.y, t, piece.height);
4077
4219
  } else {
4078
4220
  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
4221
  const t = Math.min(HATCH_EDGE, piece.height);
4080
- r = rect18(piece.x, outerBottom ? piece.y + piece.height - t : piece.y, piece.width, t);
4222
+ r = rect19(piece.x, outerBottom ? piece.y + piece.height - t : piece.y, piece.width, t);
4081
4223
  }
4082
4224
  marks.push({ id: id.replace("/box/", "/hatch/"), kind: "hatch", rect: r });
4083
4225
  });
@@ -4190,7 +4332,7 @@ function stretches(state, dragged, options, seen, lifted, raws, visit) {
4190
4332
  if (!zone) return null;
4191
4333
  const next = moveTo(state, dragged, { edge: e.id, zone, at: atOf(zone), space: 0 });
4192
4334
  if (next === state) return null;
4193
- const l = solve(next, prev);
4335
+ const l = solveLanded(next, dragged, prev);
4194
4336
  const landed = l.items[dragged];
4195
4337
  if (!landed || landed.inMenu || landed.edge !== e.id) return null;
4196
4338
  const n = neighbors(l, e.id, dragged, axis);
@@ -4241,7 +4383,7 @@ function takeoverSpots(state, dragged, options, seen, lifted, raws, pitch) {
4241
4383
  function landsAt(state, dragged, run, place, x0) {
4242
4384
  const next = moveTo(state, dragged, place);
4243
4385
  if (next === state) return null;
4244
- const layout = solve(next, run.prev);
4386
+ const layout = solveLanded(next, dragged, run.prev);
4245
4387
  const landed = layout.items[dragged];
4246
4388
  const { axis } = run;
4247
4389
  if (!landed || landed.inMenu || landed.edge !== run.e.id || Math.abs(lo(landed.rect, axis) - x0) > 1) return null;
@@ -4257,7 +4399,7 @@ function slidingSpots(state, dragged, options, seen, lifted, raws, sample) {
4257
4399
  const spots = [];
4258
4400
  const absorbed = /* @__PURE__ */ new Set();
4259
4401
  const snapDistance = Number.isFinite(options.snapDistance) && options.snapDistance >= 0 ? options.snapDistance : SNAP_DISTANCE;
4260
- const own = seen.items[dragged];
4402
+ const own = landedLayout(state, seen, dragged, options.previous ? { previous: options.previous } : {}).items[dragged];
4261
4403
  const ownEdge = own && !own.floating && !own.inMenu ? own.edge : void 0;
4262
4404
  stretches(state, dragged, options, seen, lifted, raws, (run) => ({ a, b, w, zones, atOf, spaceAt, before, after }) => {
4263
4405
  const { e, axis, middle, mine } = run;
@@ -4391,8 +4533,41 @@ function slidingSpots(state, dragged, options, seen, lifted, raws, sample) {
4391
4533
  }
4392
4534
 
4393
4535
  // src/drag.ts
4394
- import { EPS as EPS22 } from "@n-uf/placement";
4536
+ import { EPS as EPS22, area as area8, overlaps as overlaps9, subtract as subtract7 } from "@n-uf/placement";
4395
4537
  var MIN_PIECE = 8;
4538
+ function trimmedBy(marks, cs) {
4539
+ if (cs.length === 0) return [...marks];
4540
+ return marks.flatMap((m) => {
4541
+ const r = m.rect;
4542
+ if (r.width <= EPS22 || r.height <= EPS22) {
4543
+ const across2 = r.height <= EPS22;
4544
+ const at = across2 ? r.y : r.x;
4545
+ let pieces2 = [across2 ? [r.x, r.x + r.width] : [r.y, r.y + r.height]];
4546
+ let touched = false;
4547
+ for (const c of cs) {
4548
+ const [lo2, hi] = across2 ? [c.y, c.y + c.height] : [c.x, c.x + c.width];
4549
+ if (!(at > lo2 + EPS22 && at < hi - EPS22)) continue;
4550
+ const [a, b] = across2 ? [c.x, c.x + c.width] : [c.y, c.y + c.height];
4551
+ pieces2 = pieces2.flatMap(([s2, e2]) => {
4552
+ if (b <= s2 || a >= e2) return [[s2, e2]];
4553
+ touched = true;
4554
+ return [...a > s2 ? [[s2, a]] : [], ...b < e2 ? [[b, e2]] : []];
4555
+ });
4556
+ }
4557
+ if (!touched) return [m];
4558
+ const kept = pieces2.filter(([s2, e2]) => e2 - s2 >= 1);
4559
+ if (kept.length === 0) return [];
4560
+ const [s, e] = kept.reduce((x, y) => y[1] - y[0] > x[1] - x[0] ? y : x);
4561
+ if (Math.abs(s - (across2 ? r.x : r.y)) < EPS22 && Math.abs(e - s - (across2 ? r.width : r.height)) < EPS22) return [m];
4562
+ 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 } }];
4563
+ }
4564
+ const over2 = cs.filter((c) => overlaps9(m.rect, c));
4565
+ if (over2.length === 0) return [m];
4566
+ const pieces = over2.reduce((ps, c) => ps.flatMap((p) => subtract7(p, c)), [m.rect]).filter((p) => p.width >= 1 && p.height >= 1);
4567
+ if (pieces.length === 0) return [];
4568
+ return [{ ...m, rect: pieces.reduce((a, p) => area8(p) > area8(a) ? p : a) }];
4569
+ });
4570
+ }
4396
4571
  var ORIGIN2 = { x: 0, y: 0 };
4397
4572
  function dockDrag(state, dragged, options = {}) {
4398
4573
  const base = baseOf(state, dragged, options);
@@ -4455,6 +4630,7 @@ function dockDrag(state, dragged, options = {}) {
4455
4630
  if (frame.guides.length === 0) return [];
4456
4631
  const held = after(frame.held);
4457
4632
  const screen = screenOf(frame);
4633
+ const screenClear = (screen.layout.keepClear ?? []).filter((c) => c.for !== "floats").map((c) => c.rect);
4458
4634
  let near = null;
4459
4635
  const shown = [];
4460
4636
  const drawnThere = (id) => drawnIn(screen.layout, id);
@@ -4470,7 +4646,8 @@ function dockDrag(state, dragged, options = {}) {
4470
4646
  const onScreen2 = drawnThere(g.lane);
4471
4647
  const axis2 = axisOf2.get(g.lane) ?? "x";
4472
4648
  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);
4649
+ const predicted = mine.marks.filter((m) => m.lane === g.lane);
4650
+ const marks = onScreen2 ? mine.landing ? marksLess(own, axis2, [mine.landing], { suffix: "~l", minBox: MIN_PIECE, lines: "covered" }) : own : trimmedBy(predicted, screenClear);
4474
4651
  near = { lane: g.lane, marks };
4475
4652
  shown.push(near);
4476
4653
  }
@@ -4483,7 +4660,7 @@ function dockDrag(state, dragged, options = {}) {
4483
4660
  const made = shown.filter((s) => s.created).sort((a, b) => axis(a.lane) === axis(b.lane) ? 0 : axis(a.lane) === "x" ? -1 : 1);
4484
4661
  const kept = [];
4485
4662
  for (const s of made) {
4486
- s.marks = marksLess(s.marks, axis(s.lane), [...onScreen, ...kept]);
4663
+ s.marks = marksLess(trimmedBy(s.marks, screenClear), axis(s.lane), [...onScreen, ...kept]);
4487
4664
  kept.push(...s.marks.map((m) => m.rect));
4488
4665
  }
4489
4666
  if (!near) return shown.flatMap((s) => s.marks);
@@ -4512,6 +4689,7 @@ export {
4512
4689
  zonesTaking,
4513
4690
  edgeTakes,
4514
4691
  railModeOf,
4692
+ isAnchoredKeepClear,
4515
4693
  zoneIn,
4516
4694
  namesZone,
4517
4695
  isOutsideSideBar,
@@ -4561,4 +4739,4 @@ export {
4561
4739
  HATCH_EDGE,
4562
4740
  dockDrag
4563
4741
  };
4564
- //# sourceMappingURL=chunk-FSNFXRYM.js.map
4742
+ //# sourceMappingURL=chunk-7QOY2URO.js.map