@n-uf/docking 26.11.54 → 26.11.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +76 -0
- package/README.md +2 -2
- package/dist/{chunk-KGNFLHSC.js → chunk-4V35LE5X.js} +459 -257
- package/dist/chunk-4V35LE5X.js.map +1 -0
- package/dist/{lanes-CGg4iMPw.d.ts → drag-yfr_Ng9Q.d.ts} +138 -26
- package/dist/index.d.ts +60 -4
- package/dist/index.js +11 -1
- package/dist/testing.d.ts +19 -22
- package/dist/testing.js +14 -18
- package/dist/testing.js.map +1 -1
- package/package.json +8 -6
- package/dist/chunk-KGNFLHSC.js.map +0 -1
|
@@ -558,14 +558,14 @@ function emit(d, edge, r, solved, extra = {}) {
|
|
|
558
558
|
for (const p of stack.items) {
|
|
559
559
|
const it = state.items[p.id];
|
|
560
560
|
const inMenu = p.kind === "menu";
|
|
561
|
-
const
|
|
561
|
+
const drawnRect2 = toStage(p.rect, inMenu ? void 0 : p.id);
|
|
562
562
|
const f = formsOf(it, column ? "column" : "row")[p.form];
|
|
563
|
-
const shape = inMenu ? {} : shapeOf(f,
|
|
563
|
+
const shape = inMenu ? {} : shapeOf(f, drawnRect2, column ? "column" : "row", stack.cross);
|
|
564
564
|
const foldedBy = foldedByOf(it, formsOf(it, column ? "column" : "row"), p.form, solved.starts.get(p.id), edge);
|
|
565
565
|
items[p.id] = {
|
|
566
566
|
...shape,
|
|
567
567
|
...controlsOf(inMenu ? void 0 : f),
|
|
568
|
-
rect:
|
|
568
|
+
rect: drawnRect2,
|
|
569
569
|
kind: it.kind,
|
|
570
570
|
axis: column ? "column" : "row",
|
|
571
571
|
form: p.form,
|
|
@@ -606,8 +606,11 @@ var stackItemOf = (item, forms, edge, from) => ({
|
|
|
606
606
|
...item.kept ? { kept: true } : {},
|
|
607
607
|
// Where its ladder starts: as asked, else its hand fold resolved on this axis (`startOf`: its folded form).
|
|
608
608
|
...from !== void 0 ? { from } : startOf(item, forms, edge) > 0 ? { from: startOf(item, forms, edge) } : {},
|
|
609
|
-
...item.fixed ? { fixed: true } : {}
|
|
609
|
+
...item.fixed ? { fixed: true } : {},
|
|
610
|
+
...item.lengths ? { lengths: item.lengths } : {}
|
|
610
611
|
});
|
|
612
|
+
var inputs = /* @__PURE__ */ new WeakMap();
|
|
613
|
+
var inputOf = (stack) => inputs.get(stack);
|
|
611
614
|
function hasSetter(fit, forms) {
|
|
612
615
|
return fit.items.some((p) => p.kind !== "menu" && formSetsCross2(forms(p.id)[p.form]));
|
|
613
616
|
}
|
|
@@ -659,6 +662,11 @@ function railEdge(f, free, asStackItem, starts) {
|
|
|
659
662
|
return { stack, free, tabs, closedTabs, input: railInput, starts, leftOut };
|
|
660
663
|
}
|
|
661
664
|
function solveEdge(state, edge, ids, length, room, previous) {
|
|
665
|
+
const solved = solveEdgeStack(state, edge, ids, length, room, previous);
|
|
666
|
+
inputs.set(solved.stack, solved.input);
|
|
667
|
+
return solved;
|
|
668
|
+
}
|
|
669
|
+
function solveEdgeStack(state, edge, ids, length, room, previous) {
|
|
662
670
|
const axis = axisOf(edge.side);
|
|
663
671
|
const column = axis === "column";
|
|
664
672
|
const ordered = zoneSorted(state, ids);
|
|
@@ -1210,7 +1218,14 @@ function laySide(d, side, cols, g, area7, f, walk, upInset, tall) {
|
|
|
1210
1218
|
}
|
|
1211
1219
|
|
|
1212
1220
|
// src/solve.ts
|
|
1221
|
+
var solvedFrom = /* @__PURE__ */ new WeakMap();
|
|
1222
|
+
var stateOf = (layout) => solvedFrom.get(layout);
|
|
1213
1223
|
function solve(given, options = {}) {
|
|
1224
|
+
const layout = solveState(given, options);
|
|
1225
|
+
solvedFrom.set(layout, given);
|
|
1226
|
+
return layout;
|
|
1227
|
+
}
|
|
1228
|
+
function solveState(given, options) {
|
|
1214
1229
|
checkEdgeIds(given);
|
|
1215
1230
|
const { view: shown, ignored } = viewOf(given);
|
|
1216
1231
|
const lay = (caps, gave = []) => layOut(shown, options, caps, gave);
|
|
@@ -1219,7 +1234,7 @@ function solve(given, options = {}) {
|
|
|
1219
1234
|
const l = way ? lay(way.caps, way.notes) : first;
|
|
1220
1235
|
return ignored.length === 0 ? l : { ...l, notes: [...l.notes, ...ignored.map((edge) => ({ code: "show-in-ignored", edge }))] };
|
|
1221
1236
|
}
|
|
1222
|
-
var withHeightOf = (area7,
|
|
1237
|
+
var withHeightOf = (area7, over2) => rect6(over2.x, area7.y, over2.width, area7.height);
|
|
1223
1238
|
function layOut(given, options, caps, gave) {
|
|
1224
1239
|
const d = createDraft(given, options, caps);
|
|
1225
1240
|
const { state, order } = d;
|
|
@@ -1235,13 +1250,13 @@ function layOut(given, options, caps, gave) {
|
|
|
1235
1250
|
area7 = laySides(d, reserved.filter(isSide), area7, { inset, gutter: px(state.gutter), docked, outer });
|
|
1236
1251
|
for (const e of reserved) if (!isSide(e) && e.span === "between") area7 = cutEdge(d, e, area7, true);
|
|
1237
1252
|
const content = area7;
|
|
1238
|
-
let
|
|
1253
|
+
let over2 = content;
|
|
1239
1254
|
for (const e of order) {
|
|
1240
1255
|
if (e.mode !== "overlay") continue;
|
|
1241
|
-
if (isSide(e) || e.span !== "full")
|
|
1256
|
+
if (isSide(e) || e.span !== "full") over2 = cutEdge(d, e, over2, true);
|
|
1242
1257
|
else {
|
|
1243
1258
|
const across2 = e.outsideInset === true ? outer : wide;
|
|
1244
|
-
|
|
1259
|
+
over2 = withHeightOf(cutEdge(d, e, rect6(across2.x, over2.y, across2.width, over2.height), true), over2);
|
|
1245
1260
|
}
|
|
1246
1261
|
}
|
|
1247
1262
|
for (const n of gave) {
|
|
@@ -1254,6 +1269,55 @@ function layOut(given, options, caps, gave) {
|
|
|
1254
1269
|
return { items, edges, content, floats, rails, railPlaces, ...columnRoom2 !== void 0 ? { columnRoom: columnRoom2 } : {}, notes };
|
|
1255
1270
|
}
|
|
1256
1271
|
|
|
1272
|
+
// src/dividers.ts
|
|
1273
|
+
import { rect as rect7 } from "@n-uf/placement";
|
|
1274
|
+
import { dividers as stackDividers, resetBetween as stackReset, resizeBetween as stackResize } from "@n-uf/placement/stack";
|
|
1275
|
+
var laid = (state, layout) => layout && stateOf(layout) === state && Object.values(layout.edges).every((e) => inputOf(e.stack) !== void 0) ? layout : solve(state);
|
|
1276
|
+
function dividers(state, layout) {
|
|
1277
|
+
const lay = laid(state, layout);
|
|
1278
|
+
const out = [];
|
|
1279
|
+
for (const [edge, e] of Object.entries(lay.edges)) {
|
|
1280
|
+
const input = inputOf(e.stack);
|
|
1281
|
+
if (!input) continue;
|
|
1282
|
+
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 });
|
|
1283
|
+
}
|
|
1284
|
+
return out;
|
|
1285
|
+
}
|
|
1286
|
+
function over(state, layout, before, after, run) {
|
|
1287
|
+
const lay = laid(state, layout);
|
|
1288
|
+
const edge = lay.items[before]?.edge;
|
|
1289
|
+
const e = edge !== void 0 && lay.items[after]?.edge === edge ? lay.edges[edge] : void 0;
|
|
1290
|
+
const input = e && inputOf(e.stack);
|
|
1291
|
+
if (!e || !input) return state;
|
|
1292
|
+
const next = run(input, e.stack);
|
|
1293
|
+
if (next === input) return state;
|
|
1294
|
+
const was = new Map(input.items.map((it) => [it.id, it.lengths]));
|
|
1295
|
+
const items = { ...state.items };
|
|
1296
|
+
for (const it of next.items) if (it.lengths !== was.get(it.id) && items[it.id]) items[it.id] = { ...items[it.id], lengths: it.lengths };
|
|
1297
|
+
return { ...state, items };
|
|
1298
|
+
}
|
|
1299
|
+
function resizeBetween(state, before, after, delta, options = {}) {
|
|
1300
|
+
return over(state, options.layout, before, after, (input, fit) => stackResize(input, before, after, delta, { previous: fit }));
|
|
1301
|
+
}
|
|
1302
|
+
function resetBetween(state, before, after, options = {}) {
|
|
1303
|
+
return over(state, options.layout, before, after, (input, fit) => stackReset(input, before, after, { previous: fit }));
|
|
1304
|
+
}
|
|
1305
|
+
function resetLengths(state, edgeId) {
|
|
1306
|
+
const edge = state.edges.find((e) => e.id === edgeId);
|
|
1307
|
+
if (!edge) return state;
|
|
1308
|
+
const axis = axisOf(edge.side);
|
|
1309
|
+
let items;
|
|
1310
|
+
for (const id of edge.items) {
|
|
1311
|
+
const it = state.items[id];
|
|
1312
|
+
if (it?.lengths?.[axis] === void 0) continue;
|
|
1313
|
+
const { [axis]: _dropped, ...rest } = it.lengths;
|
|
1314
|
+
const { lengths: _lengths, ...bare } = it;
|
|
1315
|
+
items ??= { ...state.items };
|
|
1316
|
+
items[id] = Object.keys(rest).length > 0 ? { ...bare, lengths: rest } : bare;
|
|
1317
|
+
}
|
|
1318
|
+
return items ? { ...state, items } : state;
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1257
1321
|
// src/changes.ts
|
|
1258
1322
|
import { clampInto as clampInto2 } from "@n-uf/placement";
|
|
1259
1323
|
|
|
@@ -1336,7 +1400,7 @@ function fitAxis(start, length, b, drag, hit) {
|
|
|
1336
1400
|
}
|
|
1337
1401
|
return [a, to - a];
|
|
1338
1402
|
}
|
|
1339
|
-
function fitResize(state, id,
|
|
1403
|
+
function fitResize(state, id, rect19, moving) {
|
|
1340
1404
|
const f = state.floats.find((x2) => x2.id === id);
|
|
1341
1405
|
const item = Object.hasOwn(state.items, id) ? state.items[id] : void 0;
|
|
1342
1406
|
if (!f || !item || item.fixed) return null;
|
|
@@ -1353,8 +1417,8 @@ function fitResize(state, id, rect18, moving) {
|
|
|
1353
1417
|
const dragY = moving.top ? "start" : moving.bottom ? "end" : null;
|
|
1354
1418
|
const obstacles = floatObstacles(state, l, id);
|
|
1355
1419
|
const hit = /* @__PURE__ */ new Set();
|
|
1356
|
-
const [x, width] = fitAxis(
|
|
1357
|
-
const [y, height] = fitAxis(
|
|
1420
|
+
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, obstacles, "x", dragX ?? "end", [drawn.y, drawn.y + drawn.height]) }, dragX, hit);
|
|
1421
|
+
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, obstacles, "y", dragY ?? "end", [x, x + width]) }, dragY, hit);
|
|
1358
1422
|
const { anchor: _a, ...plain } = f;
|
|
1359
1423
|
const placed = placeFloat(item, { ...plain, rect: { x, y, width, height } }, region, obstacles, l.content, state.stage).fit.rect;
|
|
1360
1424
|
if (Math.abs(placed.x - x) > EPS9 || Math.abs(placed.y - y) > EPS9) hit.add("docked");
|
|
@@ -1609,8 +1673,8 @@ function orientFloat(state, id, to) {
|
|
|
1609
1673
|
const turned = { ...f, rect: { x: f.rect.x, y: f.rect.y, width: size.width, height: size.height }, orient: to };
|
|
1610
1674
|
return withItem({ ...state, floats: state.floats.map((g, k) => k === i ? turned : g) }, kept);
|
|
1611
1675
|
}
|
|
1612
|
-
function resizeFloat(state, floatId,
|
|
1613
|
-
const fit = fitResize(state, floatId,
|
|
1676
|
+
function resizeFloat(state, floatId, rect19, moving = { right: true, bottom: true }) {
|
|
1677
|
+
const fit = fitResize(state, floatId, rect19, moving);
|
|
1614
1678
|
const i = state.floats.findIndex((f) => f.id === floatId);
|
|
1615
1679
|
const item = itemOf(state, floatId);
|
|
1616
1680
|
if (!fit || i < 0 || !item) return state;
|
|
@@ -1689,7 +1753,7 @@ function drawnFloatSize(item, f) {
|
|
|
1689
1753
|
}
|
|
1690
1754
|
|
|
1691
1755
|
// src/store.ts
|
|
1692
|
-
import { rect as
|
|
1756
|
+
import { EPS as EPS10, rect as rect8 } from "@n-uf/placement";
|
|
1693
1757
|
var isNum = (x) => typeof x === "number" && Number.isFinite(x);
|
|
1694
1758
|
var isSize = (x) => isNum(x) && x > 0;
|
|
1695
1759
|
var isObject = (x) => typeof x === "object" && x !== null && !Array.isArray(x);
|
|
@@ -1728,11 +1792,20 @@ function floatSizesStored(it) {
|
|
|
1728
1792
|
}
|
|
1729
1793
|
return out.row || out.column ? out : void 0;
|
|
1730
1794
|
}
|
|
1795
|
+
function lengthStored(it) {
|
|
1796
|
+
const out = {};
|
|
1797
|
+
for (const o of ["column", "row"]) {
|
|
1798
|
+
const v = it.lengths?.[o];
|
|
1799
|
+
if (isNum(v) && v > EPS10) out[o] = v;
|
|
1800
|
+
}
|
|
1801
|
+
return out.column !== void 0 || out.row !== void 0 ? out : void 0;
|
|
1802
|
+
}
|
|
1731
1803
|
function storeDockState(state) {
|
|
1732
1804
|
const items = record();
|
|
1733
1805
|
for (const [id, it] of Object.entries(state.items)) {
|
|
1734
1806
|
if (id === "__proto__") continue;
|
|
1735
1807
|
const sizes = floatSizesStored(it);
|
|
1808
|
+
const asked = lengthStored(it);
|
|
1736
1809
|
items[id] = {
|
|
1737
1810
|
used: isNum(it.used) ? it.used : 0,
|
|
1738
1811
|
...it.kept ? { kept: true } : {},
|
|
@@ -1740,6 +1813,7 @@ function storeDockState(state) {
|
|
|
1740
1813
|
...it.closed ? { closed: true } : {},
|
|
1741
1814
|
...it.align === "center" || it.align === "end" ? { align: it.align } : {},
|
|
1742
1815
|
...isNum(it.space) && it.space > 0 ? { space: it.space } : {},
|
|
1816
|
+
...asked ? { lengths: asked } : {},
|
|
1743
1817
|
...sizes ? { floatSizes: sizes } : {}
|
|
1744
1818
|
};
|
|
1745
1819
|
}
|
|
@@ -1797,9 +1871,9 @@ function read(data, base) {
|
|
|
1797
1871
|
continue;
|
|
1798
1872
|
}
|
|
1799
1873
|
const b = base.items[id];
|
|
1800
|
-
const { kept: _k, from: _f, closed: _c, align: _a, space: _sp, floatSizes: _ss, ...plain } = b;
|
|
1874
|
+
const { kept: _k, from: _f, closed: _c, align: _a, space: _sp, lengths: _len, floatSizes: _ss, ...plain } = b;
|
|
1801
1875
|
let it = { ...plain, used: b.used };
|
|
1802
|
-
for (const k of Object.keys(s)) if (!["used", "kept", "from", "closed", "align", "space", "floatSize", "floatSizes"].includes(k)) drop(`item:${id}:${k}`);
|
|
1876
|
+
for (const k of Object.keys(s)) if (!["used", "kept", "from", "closed", "align", "space", "lengths", "floatSize", "floatSizes"].includes(k)) drop(`item:${id}:${k}`);
|
|
1803
1877
|
if (isNum(s.used)) it = { ...it, used: s.used };
|
|
1804
1878
|
else if (s.used !== void 0) drop(`item:${id}:used`);
|
|
1805
1879
|
if (s.kept === true) it = { ...it, kept: true };
|
|
@@ -1815,6 +1889,15 @@ function read(data, base) {
|
|
|
1815
1889
|
if (b.fixed && b.align) it = { ...it, align: b.align };
|
|
1816
1890
|
if (isNum(s.space) && s.space > 0 && !b.fixed) it = { ...it, space: s.space };
|
|
1817
1891
|
else if (s.space !== void 0) drop(`item:${id}:space`);
|
|
1892
|
+
if (isObject(s.lengths)) {
|
|
1893
|
+
const asked = {};
|
|
1894
|
+
for (const k of Object.keys(s.lengths)) {
|
|
1895
|
+
const v = s.lengths[k];
|
|
1896
|
+
if ((k === "column" || k === "row") && isNum(v) && v > EPS10) asked[k] = v;
|
|
1897
|
+
else drop(`item:${id}:lengths:${k}`);
|
|
1898
|
+
}
|
|
1899
|
+
if (asked.column !== void 0 || asked.row !== void 0) it = { ...it, lengths: asked };
|
|
1900
|
+
} else if (s.lengths !== void 0) drop(`item:${id}:lengths`);
|
|
1818
1901
|
const fs = s.floatSize;
|
|
1819
1902
|
if (isObject(fs) && isSize(fs.width) && isSize(fs.height)) legacy.set(id, { width: fs.width, height: fs.height });
|
|
1820
1903
|
else if (fs !== void 0) drop(`item:${id}:floatSize`);
|
|
@@ -1911,7 +1994,7 @@ function read(data, base) {
|
|
|
1911
1994
|
const since = isSince(f.since) ? f.since : void 0;
|
|
1912
1995
|
if (f.since !== void 0 && since === void 0) drop(`float:${id}:since`);
|
|
1913
1996
|
placed.add(id);
|
|
1914
|
-
const r =
|
|
1997
|
+
const r = rect8(f.x, f.y, f.width, f.height);
|
|
1915
1998
|
const drawn = drawnFloatSize(items[id], { rect: r, ...o ? { orient: o } : {} });
|
|
1916
1999
|
floats.push({ id, rect: clampFloat(r, base.stage, drawn), ...o ? { orient: o } : {}, ...a ? { anchor: a } : {}, ...since !== void 0 ? { since } : {} });
|
|
1917
2000
|
}
|
|
@@ -1944,10 +2027,10 @@ function read(data, base) {
|
|
|
1944
2027
|
}
|
|
1945
2028
|
|
|
1946
2029
|
// src/targets.ts
|
|
1947
|
-
import { EPS as
|
|
2030
|
+
import { EPS as EPS20, PLANE, area as area6, overlaps as overlaps6, rect as rect17 } from "@n-uf/placement";
|
|
1948
2031
|
|
|
1949
2032
|
// src/targets/anchor.ts
|
|
1950
|
-
import { EPS as
|
|
2033
|
+
import { EPS as EPS11, area, rect as rect9, subtract } from "@n-uf/placement";
|
|
1951
2034
|
var OTHER = { left: "right", right: "left", top: "bottom", bottom: "top" };
|
|
1952
2035
|
function anchorTargets(state, dragged, options) {
|
|
1953
2036
|
const none = { targets: [], refusals: [], lost: [] };
|
|
@@ -1963,8 +2046,8 @@ function anchorTargets(state, dragged, options) {
|
|
|
1963
2046
|
const layout = solve(moved, prev);
|
|
1964
2047
|
const placed = layout.edges[edge.id]?.rect;
|
|
1965
2048
|
const slot = layout.items[dragged]?.rect;
|
|
1966
|
-
if (placed && slot && area(placed) >
|
|
1967
|
-
const pieces = keepClearFor(state, "targets").reduce((ps, c) => ps.flatMap((p) => subtract(p,
|
|
2049
|
+
if (placed && slot && area(placed) > EPS11) {
|
|
2050
|
+
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);
|
|
1968
2051
|
if (pieces.length > 0) {
|
|
1969
2052
|
const hit = pieces.reduce((a, p) => area(p) > area(a) ? p : a);
|
|
1970
2053
|
const result = { state: moved, layout };
|
|
@@ -1976,7 +2059,7 @@ function anchorTargets(state, dragged, options) {
|
|
|
1976
2059
|
}
|
|
1977
2060
|
|
|
1978
2061
|
// src/targets/edges.ts
|
|
1979
|
-
import { EPS as
|
|
2062
|
+
import { EPS as EPS12, area as area2, rect as rect10 } from "@n-uf/placement";
|
|
1980
2063
|
import { formCrossMin as formCrossMin4, formMain as formMain2, formSetsCross as formSetsCross4 } from "@n-uf/placement/stack";
|
|
1981
2064
|
|
|
1982
2065
|
// src/targets/kinds.ts
|
|
@@ -1991,6 +2074,7 @@ var EDGE_KINDS = {
|
|
|
1991
2074
|
barBetween: { zoneExtent: "thirds", opens: "any", inward: 0, place: DEFAULT_HIT_BAND / 2, phase: null, layer: 13, overreach: 33, priority: 2, reach: Infinity, virtual: false, minHit: MIN_HIT },
|
|
1992
2075
|
rail: { zoneExtent: "thirds", opens: "any", inward: RAIL_REACH, place: DEFAULT_HIT_BAND / 2, phase: null, layer: 14, overreach: 34, priority: 2, reach: Infinity, virtual: false, minHit: MIN_HIT },
|
|
1993
2076
|
railStop: { zoneExtent: "whole", opens: "any", inward: 0, place: DEFAULT_HIT_BAND / 2, phase: 2, layer: 9, overreach: 39, priority: 1, reach: Infinity, virtual: false, minHit: MIN_HIT },
|
|
2077
|
+
railColumn: { zoneExtent: "solved", opens: "start", inward: 0, place: DEFAULT_HIT_BAND / 2, phase: null, layer: 8, overreach: 38, priority: 2, reach: Infinity, virtual: false, minHit: MIN_HIT },
|
|
1994
2078
|
columnLine: { zoneExtent: "whole", opens: "any", inward: 0, place: DEFAULT_HIT_BAND / 2, edgePlace: DEFAULT_HIT_BAND, phase: 2, layer: 21, overreach: 41, priority: 2, reach: COLUMN_REACH, virtual: true, minHit: MIN_HIT }
|
|
1995
2079
|
};
|
|
1996
2080
|
function edgeKindOf(state, e) {
|
|
@@ -2010,7 +2094,7 @@ function reservedRect(state, l, id) {
|
|
|
2010
2094
|
const len2 = column ? it.rect.height : it.rect.width;
|
|
2011
2095
|
const keep = Math.min(len2, Math.max(0, Number.isFinite(f.main.natural) ? f.main.natural : len2));
|
|
2012
2096
|
const shift = it.zone === "end" ? len2 - keep : it.zone === "center" ? (len2 - keep) / 2 : 0;
|
|
2013
|
-
return column ?
|
|
2097
|
+
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);
|
|
2014
2098
|
}
|
|
2015
2099
|
function slotAt(c, zone, line, id, place, lands, home = false) {
|
|
2016
2100
|
const result = c.settle(markUsed(moveAmong(c.state, c.dragged, place, c.others), c.dragged));
|
|
@@ -2023,7 +2107,7 @@ function distinctSlots(c, slots) {
|
|
|
2023
2107
|
if (a.zone !== b.zone) return false;
|
|
2024
2108
|
if (a.home && b.home) return true;
|
|
2025
2109
|
const [p, q] = [landing(a), landing(b)];
|
|
2026
|
-
const sameLine = a.place.kind === "rail" && b.place.kind === "rail" || Math.abs(a.line - b.line) <
|
|
2110
|
+
const sameLine = a.place.kind === "rail" && b.place.kind === "rail" || Math.abs(a.line - b.line) < EPS12;
|
|
2027
2111
|
return sameLine && (!p || !q ? p === q : Math.abs(p.x - q.x) + Math.abs(p.y - q.y) + Math.abs(p.width - q.width) + Math.abs(p.height - q.height) < 0.01);
|
|
2028
2112
|
};
|
|
2029
2113
|
const wins = (o, j, s, i) => o.home !== s.home ? o.home : j < i;
|
|
@@ -2157,31 +2241,31 @@ function edgeSlots(c, edge, accepts) {
|
|
|
2157
2241
|
}
|
|
2158
2242
|
function thickerThan(forms, cross) {
|
|
2159
2243
|
const shown = forms.filter((f) => f.kind !== "menu");
|
|
2160
|
-
return shown.length > 0 && shown.every((f) => !formSetsCross4(f) && formCrossMin4(f) > cross +
|
|
2244
|
+
return shown.length > 0 && shown.every((f) => !formSetsCross4(f) && formCrossMin4(f) > cross + EPS12);
|
|
2161
2245
|
}
|
|
2162
2246
|
var roomReason = (spec, zone) => spec.refuse(zone) === "too-thick" ? "too-thick" : "no-room";
|
|
2163
|
-
function edgeSpec(c, edge) {
|
|
2247
|
+
function edgeSpec(c, edge, as) {
|
|
2164
2248
|
const { state, rest, now, dragged, kind } = c;
|
|
2165
2249
|
const el = now.edges[edge.id];
|
|
2166
2250
|
if (!el || el.folded || el.rides || !rest.edges.some((e) => e.id === edge.id)) return null;
|
|
2167
|
-
const edgeKind = edgeKindOf(state, edge);
|
|
2251
|
+
const edgeKind = as ?? edgeKindOf(state, edge);
|
|
2168
2252
|
const data = EDGE_KINDS[edgeKind];
|
|
2169
2253
|
const column = axisOf(edge.side) === "column";
|
|
2170
2254
|
const at = (r2) => column ? r2.y : r2.x;
|
|
2171
2255
|
const len2 = (r2) => column ? r2.height : r2.width;
|
|
2172
2256
|
const empty = el.stack.items.every((p) => p.kind === "menu") && !el.menu;
|
|
2173
2257
|
const accepts = edgeTakes(edge, kind);
|
|
2174
|
-
if (!accepts && (empty || area2(el.rect) <=
|
|
2258
|
+
if (!accepts && (empty || area2(el.rect) <= EPS12)) return null;
|
|
2175
2259
|
if (accepts && empty && !opensEmpty(state, edge, kind)) return null;
|
|
2176
2260
|
const ownNow = now.items[dragged];
|
|
2177
|
-
const ownHere = ownNow && ownNow.edge === edge.id && !ownNow.floating && area2(ownNow.rect) >
|
|
2261
|
+
const ownHere = ownNow && ownNow.edge === edge.id && !ownNow.floating && area2(ownNow.rect) > EPS12 ? ownNow.rect : null;
|
|
2178
2262
|
const oneEnd = state.foldedColumnDrop === "end" && column && el.tabs.length > 0 && ownNow?.edge !== edge.id && zoneTakes(edge, "start", kind);
|
|
2179
2263
|
const allSlots = edgeSlots(c, edge, accepts);
|
|
2180
2264
|
const slots = oneEnd ? allSlots.filter((s) => s.zone === "start").sort((a, b) => a.line - b.line).slice(-1) : allSlots;
|
|
2181
2265
|
const spanOf = (r2) => [at(r2), at(r2) + len2(r2)];
|
|
2182
2266
|
const grows = (id) => !!formsOf(state.items[id], axisOf(edge.side))[now.items[id].form]?.main.grows;
|
|
2183
2267
|
const reserved = Object.entries(now.items).filter(([id, p]) => p.edge === edge.id && p.fixed && !p.inMenu && !grows(id)).map(([, p]) => spanOf(p.rect));
|
|
2184
|
-
const cards = Object.entries(now.items).filter(([id, p]) => id !== dragged && p.edge === edge.id && !p.fixed && !p.inMenu && !p.floating && area2(p.rect) >
|
|
2268
|
+
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));
|
|
2185
2269
|
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) => {
|
|
2186
2270
|
const s = slots.find((x) => x.zone === zone && x.place.kind === "gap" && x.place.at === 0);
|
|
2187
2271
|
const me = s?.result.layout.items[dragged];
|
|
@@ -2198,7 +2282,7 @@ function edgeSpec(c, edge) {
|
|
|
2198
2282
|
const marker = (s) => {
|
|
2199
2283
|
const slot = s.result.layout.items[dragged].rect;
|
|
2200
2284
|
const e = s.result.layout.edges[edge.id];
|
|
2201
|
-
return column ?
|
|
2285
|
+
return column ? rect10(e.rect.x, slot.y, e.cross, 0) : rect10(slot.x, e.rect.y, 0, e.cross);
|
|
2202
2286
|
};
|
|
2203
2287
|
const takes = (zone) => accepts && zoneTakes(edge, zone, kind);
|
|
2204
2288
|
const tooThick = thickerThan(formsOf(state.items[dragged], axisOf(edge.side)), el.stack.cross);
|
|
@@ -2210,7 +2294,7 @@ function edgeSpec(c, edge) {
|
|
|
2210
2294
|
vertical: column,
|
|
2211
2295
|
zones,
|
|
2212
2296
|
slots,
|
|
2213
|
-
refuse: (zone) => takes(zone) ? tooThick ? "too-thick" : "no-room" : accepts || area2(el.rect) >
|
|
2297
|
+
refuse: (zone) => takes(zone) ? tooThick ? "too-thick" : "no-room" : accepts || area2(el.rect) > EPS12 ? "not-accepted" : null,
|
|
2214
2298
|
own: ownHere,
|
|
2215
2299
|
holds: !!ownNow && ownNow.edge === edge.id && !ownNow.floating,
|
|
2216
2300
|
reserved,
|
|
@@ -2223,6 +2307,16 @@ function edgeSpec(c, edge) {
|
|
|
2223
2307
|
marker
|
|
2224
2308
|
};
|
|
2225
2309
|
}
|
|
2310
|
+
function railColumnSpec(c, edge, run) {
|
|
2311
|
+
const el = c.now.edges[edge.id];
|
|
2312
|
+
if (!el) return null;
|
|
2313
|
+
const { folded: _folded, ...shown } = el;
|
|
2314
|
+
const seen = { ...c, reach: 0, now: { ...c.now, edges: { ...c.now.edges, [edge.id]: { ...shown, rect: run, cross: run.width } } } };
|
|
2315
|
+
const spec = edgeSpec(seen, edge, "railColumn");
|
|
2316
|
+
if (!spec) return null;
|
|
2317
|
+
const across2 = [run.x, run.x + run.width];
|
|
2318
|
+
return { ...spec, across: () => across2, owned: across2 };
|
|
2319
|
+
}
|
|
2226
2320
|
|
|
2227
2321
|
// src/targets/filter.ts
|
|
2228
2322
|
import { overlaps } from "@n-uf/placement";
|
|
@@ -2288,58 +2382,58 @@ function context(state, dragged, options, others = []) {
|
|
|
2288
2382
|
}
|
|
2289
2383
|
|
|
2290
2384
|
// src/targets/ownership.ts
|
|
2291
|
-
import { EPS as
|
|
2385
|
+
import { EPS as EPS15, area as area3, overlaps as overlaps2, rect as rect12, subtract as subtract2 } from "@n-uf/placement";
|
|
2292
2386
|
import { formBody } from "@n-uf/placement/stack";
|
|
2293
2387
|
|
|
2294
2388
|
// src/targets/meet.ts
|
|
2295
|
-
import { EPS as
|
|
2389
|
+
import { EPS as EPS13, rect as rect11 } from "@n-uf/placement";
|
|
2296
2390
|
function meet(a, b) {
|
|
2297
2391
|
const x = Math.max(a.x, b.x);
|
|
2298
2392
|
const y = Math.max(a.y, b.y);
|
|
2299
2393
|
const w = Math.min(a.x + a.width, b.x + b.width) - x;
|
|
2300
2394
|
const h = Math.min(a.y + a.height, b.y + b.height) - y;
|
|
2301
|
-
return w >
|
|
2395
|
+
return w > EPS13 && h > EPS13 ? rect11(x, y, w, h) : null;
|
|
2302
2396
|
}
|
|
2303
2397
|
|
|
2304
2398
|
// src/targets/model.ts
|
|
2305
|
-
import { EPS as
|
|
2306
|
-
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 >
|
|
2399
|
+
import { EPS as EPS14 } from "@n-uf/placement";
|
|
2400
|
+
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]);
|
|
2307
2401
|
|
|
2308
2402
|
// src/targets/ownership.ts
|
|
2309
2403
|
var isBody = (f) => !!f && formBody(f);
|
|
2310
2404
|
var bandOf = (s) => {
|
|
2311
2405
|
const a = Math.min(...s.zones.map((z) => z.a));
|
|
2312
2406
|
const b = Math.max(...s.zones.map((z) => z.b));
|
|
2313
|
-
return s.vertical ?
|
|
2407
|
+
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]);
|
|
2314
2408
|
};
|
|
2315
2409
|
var ownedRectOf = (s) => {
|
|
2316
2410
|
const b = bandOf(s);
|
|
2317
2411
|
if (!s.ownedAlong) return b;
|
|
2318
2412
|
const [a0, a1] = s.ownedAlong;
|
|
2319
|
-
return s.vertical ?
|
|
2413
|
+
return s.vertical ? rect12(b.x, a0, b.width, a1 - a0) : rect12(a0, b.y, a1 - a0, b.height);
|
|
2320
2414
|
};
|
|
2321
2415
|
function ownedRectsOf(s, along2) {
|
|
2322
2416
|
if (along2.length === 0) return [];
|
|
2323
2417
|
const o = ownedRectOf(s);
|
|
2324
2418
|
if (s.ownedAlong) return [o];
|
|
2325
|
-
return along2.map(([a, b]) => s.vertical ?
|
|
2419
|
+
return along2.map(([a, b]) => s.vertical ? rect12(o.x, a, o.width, b - a) : rect12(a, o.y, b - a, o.height));
|
|
2326
2420
|
}
|
|
2327
2421
|
function drawnOf(c, live) {
|
|
2328
|
-
return Object.entries(c.now.edges).filter(([id, e]) => area3(e.rect) >
|
|
2422
|
+
return 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) }));
|
|
2329
2423
|
}
|
|
2330
2424
|
function homeRectOf(c, ownSpec) {
|
|
2331
2425
|
const own = c.now.items[c.dragged];
|
|
2332
2426
|
if (!own || own.floating || !own.edge) return null;
|
|
2333
2427
|
const o = own.rect;
|
|
2334
|
-
const hull3 = (a, b) =>
|
|
2428
|
+
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));
|
|
2335
2429
|
if (own.inMenu) return o;
|
|
2336
2430
|
if (!ownSpec) {
|
|
2337
2431
|
const e = c.now.edges[own.edge];
|
|
2338
2432
|
const vanishes = !c.rest.edges.some((x) => x.id === own.edge);
|
|
2339
|
-
return e && vanishes && !e.folded && !e.rides && area3(e.rect) >
|
|
2433
|
+
return e && vanishes && !e.folded && !e.rides && area3(e.rect) > EPS15 ? hull3(o, e.rect) : o;
|
|
2340
2434
|
}
|
|
2341
2435
|
const [c0, c1] = ownSpec.across();
|
|
2342
|
-
return ownSpec.vertical ? hull3(o,
|
|
2436
|
+
return ownSpec.vertical ? hull3(o, rect12(c0, o.y, c1 - c0, o.height)) : hull3(o, rect12(o.x, c0, o.width, c1 - c0));
|
|
2343
2437
|
}
|
|
2344
2438
|
function ownersOf(c, live, drawn, alongOf) {
|
|
2345
2439
|
const ownEdge = c.now.items[c.dragged]?.edge;
|
|
@@ -2354,9 +2448,9 @@ function ownersOf(c, live, drawn, alongOf) {
|
|
|
2354
2448
|
...live.flatMap((s) => {
|
|
2355
2449
|
const rects = ownedRectsOf(s, alongOf(s));
|
|
2356
2450
|
if (!s.thinOwned) return rects.map((r) => ({ spec: s, rect: r, lay: s.lay, place: !s.drawn }));
|
|
2357
|
-
const thin = (r) => s.vertical ?
|
|
2451
|
+
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]));
|
|
2358
2452
|
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 }))]);
|
|
2359
|
-
}).filter((o) => area3(o.rect) >
|
|
2453
|
+
}).filter((o) => area3(o.rect) > EPS15),
|
|
2360
2454
|
// Every seen rect: the edges the tiler doesn't read (folded, riding, taking nothing) among them.
|
|
2361
2455
|
...drawn.map((d) => ({ ...d, place: false }))
|
|
2362
2456
|
];
|
|
@@ -2372,29 +2466,29 @@ function ownership(c, live, alongOf) {
|
|
|
2372
2466
|
const place = !s.drawn;
|
|
2373
2467
|
return o.place === place ? !place || o.lay.at < s.lay.at : !o.place;
|
|
2374
2468
|
};
|
|
2375
|
-
const takingRects = (s) => s.drawn ? s.zones.filter((z) => s.slots.some((sl) => sl.ok && sl.zone === z.zone)).map((z) => s.vertical ?
|
|
2469
|
+
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])) : [];
|
|
2376
2470
|
const thinRectOf = (s) => {
|
|
2377
2471
|
const b = bandOf(s);
|
|
2378
2472
|
const [t0, t1] = s.thinOwned;
|
|
2379
|
-
return s.vertical ?
|
|
2473
|
+
return s.vertical ? rect12(t0, b.y, t1 - t0, b.height) : rect12(b.x, t0, b.width, t1 - t0);
|
|
2380
2474
|
};
|
|
2381
2475
|
const endsOf = (s) => {
|
|
2382
2476
|
const e = s.edge ? now.edges[s.id] : void 0;
|
|
2383
2477
|
if (!e || EDGE_KINDS[s.kind].virtual) return null;
|
|
2384
2478
|
const span = s.vertical ? [e.rect.y, e.rect.y + e.rect.height] : [e.rect.x, e.rect.x + e.rect.width];
|
|
2385
|
-
return span[1] - span[0] >
|
|
2479
|
+
return span[1] - span[0] > EPS15 ? span : null;
|
|
2386
2480
|
};
|
|
2387
2481
|
const pastEnds = (s, r) => {
|
|
2388
2482
|
const ends = endsOf(s);
|
|
2389
2483
|
if (!ends) return [];
|
|
2390
2484
|
const [lo2, hi] = s.vertical ? [r.y, r.y + r.height] : [r.x, r.x + r.width];
|
|
2391
|
-
return less([[lo2, hi]], [ends]).map(([u, w]) => s.vertical ?
|
|
2485
|
+
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));
|
|
2392
2486
|
};
|
|
2393
2487
|
const ownSpanOf = (s) => {
|
|
2394
2488
|
const ends = endsOf(s);
|
|
2395
2489
|
if (!ends) return null;
|
|
2396
2490
|
const [o0, o1] = s.owned;
|
|
2397
|
-
return s.vertical ?
|
|
2491
|
+
return s.vertical ? rect12(o0, ends[0], o1 - o0, ends[1] - ends[0]) : rect12(ends[0], o0, ends[1] - ends[0], o1 - o0);
|
|
2398
2492
|
};
|
|
2399
2493
|
const reachLess = (o, r, s) => {
|
|
2400
2494
|
const span = ownSpanOf(s);
|
|
@@ -2428,7 +2522,7 @@ function ownership(c, live, alongOf) {
|
|
|
2428
2522
|
const half = e ? halfBandOf(e) : null;
|
|
2429
2523
|
if (!e || half === null) return [];
|
|
2430
2524
|
const column = axisOf(e.side) === "column";
|
|
2431
|
-
return Object.entries(now.items).filter(([iid, p]) => p.edge === e.id && iid !== dragged && isBody(formsOf(state.items[iid], axisOf(e.side))[p.form])).map(([, p]) => column ? [p.rect.y + half, p.rect.y + p.rect.height - half] : [p.rect.x + half, p.rect.x + p.rect.width - half]).filter(([a, b]) => b - a >
|
|
2525
|
+
return Object.entries(now.items).filter(([iid, p]) => p.edge === e.id && iid !== dragged && isBody(formsOf(state.items[iid], axisOf(e.side))[p.form])).map(([, p]) => column ? [p.rect.y + half, p.rect.y + p.rect.height - half] : [p.rect.x + half, p.rect.x + p.rect.width - half]).filter(([a, b]) => b - a > EPS15);
|
|
2432
2526
|
};
|
|
2433
2527
|
const rooms = /* @__PURE__ */ new Map();
|
|
2434
2528
|
const cutsOf = (s) => {
|
|
@@ -2445,23 +2539,23 @@ function ownership(c, live, alongOf) {
|
|
|
2445
2539
|
const owned = [];
|
|
2446
2540
|
for (let k = 1; k < ends.length; k++) {
|
|
2447
2541
|
const [u, w] = [ends[k - 1], ends[k]];
|
|
2448
|
-
const
|
|
2449
|
-
if (w - u >
|
|
2542
|
+
const over2 = rs.filter((r) => along2(r)[0] <= u + EPS15 && along2(r)[1] >= w - EPS15).map(across2);
|
|
2543
|
+
if (w - u > EPS15 && less([across2(b)], over2).reduce((n, [p, q]) => n + q - p, 0) < 1) owned.push([u, w]);
|
|
2450
2544
|
}
|
|
2451
2545
|
const half = s.edge ? halfBandOf(s.edge) : null;
|
|
2452
2546
|
const raw = bodySpans(s.edge);
|
|
2453
2547
|
if (half === null || raw.length === 0) return { cuts: owned, bodies: raw };
|
|
2454
2548
|
const merged = owned.reduce((m, [u, w]) => {
|
|
2455
2549
|
const last = m[m.length - 1];
|
|
2456
|
-
if (last && u <= last[1] +
|
|
2550
|
+
if (last && u <= last[1] + EPS15) last[1] = Math.max(last[1], w);
|
|
2457
2551
|
else m.push([u, w]);
|
|
2458
2552
|
return m;
|
|
2459
2553
|
}, []);
|
|
2460
2554
|
const [lo2, hi] = endsOf(s) ?? along2(b);
|
|
2461
2555
|
const placed = (p) => {
|
|
2462
|
-
const cut2 = merged.find(([u, w]) => p >= u -
|
|
2556
|
+
const cut2 = merged.find(([u, w]) => p >= u - EPS15 && p <= w + EPS15);
|
|
2463
2557
|
if (!cut2) return p;
|
|
2464
|
-
const sides = [...cut2[0] > lo2 +
|
|
2558
|
+
const sides = [...cut2[0] > lo2 + EPS15 ? [cut2[0]] : [], ...cut2[1] < hi - EPS15 ? [cut2[1]] : []];
|
|
2465
2559
|
return sides.length === 0 ? p : sides.reduce((m, x) => Math.abs(x - p) < Math.abs(m - p) ? x : m);
|
|
2466
2560
|
};
|
|
2467
2561
|
const bands = s.slots.map((sl) => [placed(sl.line) - half, placed(sl.line) + half]);
|
|
@@ -2477,9 +2571,9 @@ function ownership(c, live, alongOf) {
|
|
|
2477
2571
|
const e = s.edge;
|
|
2478
2572
|
if (!e) return [];
|
|
2479
2573
|
const column = axisOf(e.side) === "column";
|
|
2480
|
-
const across2 = (a, b) => column ?
|
|
2574
|
+
const across2 = (a, b) => column ? rect12(-1e9, a, 2e9, b - a) : rect12(a, -1e9, b - a, 2e9);
|
|
2481
2575
|
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));
|
|
2482
|
-
return [...reserved, ...cutsOf(s).bodies.map(([a, b]) => across2(a, b))].filter((b) => area3(b) >
|
|
2576
|
+
return [...reserved, ...cutsOf(s).bodies.map(([a, b]) => across2(a, b))].filter((b) => area3(b) > EPS15);
|
|
2483
2577
|
};
|
|
2484
2578
|
const drawnBySpec = /* @__PURE__ */ new Map();
|
|
2485
2579
|
const drawnBesides = (s) => {
|
|
@@ -2491,13 +2585,13 @@ function ownership(c, live, alongOf) {
|
|
|
2491
2585
|
}
|
|
2492
2586
|
|
|
2493
2587
|
// src/targets/tiles.ts
|
|
2494
|
-
import { EPS as
|
|
2588
|
+
import { EPS as EPS16, area as area4, overlaps as overlaps3, rect as rect13, subtract as subtract3 } from "@n-uf/placement";
|
|
2495
2589
|
function tilerOf(spec) {
|
|
2496
2590
|
const data = EDGE_KINDS[spec.kind];
|
|
2497
2591
|
const v = spec.vertical;
|
|
2498
2592
|
const band = (a, b, after) => {
|
|
2499
2593
|
const [c0, c1] = spec.across(after);
|
|
2500
|
-
return v ?
|
|
2594
|
+
return v ? rect13(c0, a, c1 - c0, b - a) : rect13(a, c0, b - a, c1 - c0);
|
|
2501
2595
|
};
|
|
2502
2596
|
const keepAt = (line, h) => v ? { x: h.x + h.width / 2, y: line } : { x: line, y: h.y + h.height / 2 };
|
|
2503
2597
|
const tile = (zone, hit, more) => ({ edge: spec.id, spec, edgeKind: spec.kind, vertical: v, zone, hit, ...more });
|
|
@@ -2505,10 +2599,10 @@ function tilerOf(spec) {
|
|
|
2505
2599
|
const h = t.hit;
|
|
2506
2600
|
const [h0, h1] = v ? [h.x, h.x + h.width] : [h.y, h.y + h.height];
|
|
2507
2601
|
const [c0, c1] = [Math.max(h0, spec.owned[0]), Math.min(h1, spec.owned[1])];
|
|
2508
|
-
const part = (a, b) => v ?
|
|
2602
|
+
const part = (a, b) => v ? rect13(a, h.y, b - a, h.height) : rect13(h.x, a, h.width, b - a);
|
|
2509
2603
|
const beyond = less([[h0, h1]], [spec.owned]);
|
|
2510
2604
|
if (beyond.length === 0) return [t];
|
|
2511
|
-
if (c1 - c0 <=
|
|
2605
|
+
if (c1 - c0 <= EPS16) return [{ ...t, order: data.overreach }];
|
|
2512
2606
|
const core = { ...t, hit: part(c0, c1), keep: t.keep && keepAt(v ? t.keep.y : t.keep.x, part(c0, c1)) };
|
|
2513
2607
|
return [core, ...beyond.map(([a, b]) => ({ ...t, kind: "reach", of: core, order: data.overreach, hit: part(a, b), keep: null }))];
|
|
2514
2608
|
};
|
|
@@ -2522,7 +2616,7 @@ function wholeRefusal(c, spec) {
|
|
|
2522
2616
|
const data = EDGE_KINDS[spec.kind];
|
|
2523
2617
|
return { edge: spec.id, spec, edgeKind: spec.kind, vertical: spec.vertical, zone: "start", hit, kind: "refuse", id: "", order: data.layer, priority: data.priority, keep: null, reason: "not-accepted", whole: true };
|
|
2524
2618
|
}
|
|
2525
|
-
var hasRoom = (spans, away) => less(spans, away).some(([a, b]) => b - a >
|
|
2619
|
+
var hasRoom = (spans, away) => less(spans, away).some(([a, b]) => b - a > EPS16);
|
|
2526
2620
|
function linesIn(spec, z, mine, pieces, [pa, pb], own) {
|
|
2527
2621
|
const reserved = spec.reserved;
|
|
2528
2622
|
const lines = mine.map((s) => s.line);
|
|
@@ -2531,42 +2625,42 @@ function linesIn(spec, z, mine, pieces, [pa, pb], own) {
|
|
|
2531
2625
|
const free = less([[z.a, z.b]], reserved);
|
|
2532
2626
|
const freeLen = free.reduce((n, [a, b]) => n + (b - a), 0);
|
|
2533
2627
|
const spread = (x) => {
|
|
2534
|
-
if (hi - lo2 <=
|
|
2628
|
+
if (hi - lo2 <= EPS16 || freeLen <= EPS16) return x;
|
|
2535
2629
|
let d = (x - lo2) / (hi - lo2) * freeLen;
|
|
2536
2630
|
for (const [a, b] of free) {
|
|
2537
|
-
if (d <= b - a +
|
|
2631
|
+
if (d <= b - a + EPS16) return a + Math.min(d, b - a);
|
|
2538
2632
|
d -= b - a;
|
|
2539
2633
|
}
|
|
2540
2634
|
return free[free.length - 1][1];
|
|
2541
2635
|
};
|
|
2542
|
-
const past = lines.some((x) => x < z.a -
|
|
2636
|
+
const past = lines.some((x) => x < z.a - EPS16 || x > z.b + EPS16);
|
|
2543
2637
|
const nearer = (p, [a, b]) => p > a && p < b ? p - a < b - p ? a : b : p;
|
|
2544
2638
|
const proj = (x) => {
|
|
2545
2639
|
const q = reserved.reduce((r, s) => nearer(r, s), past ? spread(x) : x);
|
|
2546
2640
|
const p = own ? nearer(q, own) : q;
|
|
2547
|
-
if (pieces.some(([a, b]) => p >= a -
|
|
2641
|
+
if (pieces.some(([a, b]) => p >= a - EPS16 && p <= b + EPS16)) return p;
|
|
2548
2642
|
return pieces.map(([a, b]) => Math.min(Math.max(p, a), b)).reduce((m, y) => Math.abs(y - p) < Math.abs(m - p) ? y : m);
|
|
2549
2643
|
};
|
|
2550
|
-
const ownEnd = (s) => !!own && s.home && (Math.abs(s.line - own[0]) <
|
|
2551
|
-
const inPiece = mine.filter((s) => ownEnd(s) ? s.line >= pa -
|
|
2644
|
+
const ownEnd = (s) => !!own && s.home && (Math.abs(s.line - own[0]) < EPS16 || Math.abs(s.line - own[1]) < EPS16);
|
|
2645
|
+
const inPiece = mine.filter((s) => ownEnd(s) ? s.line >= pa - EPS16 && s.line <= pb + EPS16 : proj(s.line) >= pa - EPS16 && proj(s.line) <= pb + EPS16).sort((a, b) => proj(a.line) - proj(b.line) || a.line - b.line);
|
|
2552
2646
|
const projected = inPiece.map((s) => proj(s.line));
|
|
2553
|
-
const at = projected.some((p, i) => i > 0 && p - projected[i - 1] <=
|
|
2647
|
+
const at = projected.some((p, i) => i > 0 && p - projected[i - 1] <= EPS16) ? inPiece.map((_, i) => pa + (i + 0.5) * (pb - pa) / inPiece.length) : projected;
|
|
2554
2648
|
return { inPiece, at };
|
|
2555
2649
|
}
|
|
2556
2650
|
function reachStrips(c, spec, room, ends) {
|
|
2557
|
-
const inEdge = (s) => !!ends && s[0] < ends[1] -
|
|
2651
|
+
const inEdge = (s) => !!ends && s[0] < ends[1] - EPS16 && s[1] > ends[0] + EPS16;
|
|
2558
2652
|
const pieces = room.filter(inEdge);
|
|
2559
2653
|
if (!ends || pieces.length === 0) return { pieces: [...room], before: [], after: [] };
|
|
2560
2654
|
const [c0, c1] = spec.across();
|
|
2561
|
-
const bandOf2 = (a, b) => spec.vertical ?
|
|
2655
|
+
const bandOf2 = (a, b) => spec.vertical ? rect13(c0, a, c1 - c0, b - a) : rect13(a, c0, b - a, c1 - c0);
|
|
2562
2656
|
const across2 = c.state.edges.filter((e) => axisOf(e.side) === "column" !== spec.vertical).map((e) => c.now.edges[e.id]);
|
|
2563
|
-
const drawnBetween = (a, b) => b - a >
|
|
2657
|
+
const drawnBetween = (a, b) => b - a > EPS16 && across2.some((e) => !!e && e.cross > EPS16 && area4(e.rect) > EPS16 && overlaps3(e.rect, bandOf2(a, b)));
|
|
2564
2658
|
const first = pieces[0][0];
|
|
2565
2659
|
const last = pieces[pieces.length - 1][1];
|
|
2566
2660
|
return {
|
|
2567
2661
|
pieces,
|
|
2568
|
-
before: room.filter((s) => s[1] <= ends[0] +
|
|
2569
|
-
after: room.filter((s) => s[0] >= ends[1] -
|
|
2662
|
+
before: room.filter((s) => s[1] <= ends[0] + EPS16 && !drawnBetween(s[1], first)),
|
|
2663
|
+
after: room.filter((s) => s[0] >= ends[1] - EPS16 && !drawnBetween(last, s[0]))
|
|
2570
2664
|
};
|
|
2571
2665
|
}
|
|
2572
2666
|
function tileEdge(c, spec, { cuts, bodies }, lost) {
|
|
@@ -2577,7 +2671,7 @@ function tileEdge(c, spec, { cuts, bodies }, lost) {
|
|
|
2577
2671
|
const own = spec.own ? v ? [spec.own.y, spec.own.y + spec.own.height] : [spec.own.x, spec.own.x + spec.own.width] : null;
|
|
2578
2672
|
const { band, keepAt, tile, split } = tilerOf(spec);
|
|
2579
2673
|
const drawn = spec.edge ? c.now.edges[spec.id]?.rect : void 0;
|
|
2580
|
-
const alongLimit = drawn && (v ? drawn.height : drawn.width) >
|
|
2674
|
+
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;
|
|
2581
2675
|
const refused = (zone, hit, reason) => {
|
|
2582
2676
|
const inEdge = alongLimit ? meet(hit, alongLimit) : hit;
|
|
2583
2677
|
const shown = inEdge && meet(inEdge, c.state.stage);
|
|
@@ -2586,27 +2680,27 @@ function tileEdge(c, spec, { cuts, bodies }, lost) {
|
|
|
2586
2680
|
const slots = distinctSlots(c, spec.slots);
|
|
2587
2681
|
const runs = [...spec.reserved].sort((p, q) => p[0] - q[0]).reduce((acc, [a, b]) => {
|
|
2588
2682
|
const last = acc[acc.length - 1];
|
|
2589
|
-
if (last && a <= last[1] +
|
|
2683
|
+
if (last && a <= last[1] + EPS16) acc[acc.length - 1] = [last[0], Math.max(last[1], b)];
|
|
2590
2684
|
else acc.push([a, b]);
|
|
2591
2685
|
return acc;
|
|
2592
2686
|
}, []);
|
|
2593
|
-
const wedged = (line) => runs.some(([a, b]) => line > a +
|
|
2687
|
+
const wedged = (line) => runs.some(([a, b]) => line > a + EPS16 && line < b - EPS16);
|
|
2594
2688
|
const homeSlot = spec.holds && own ? slots.find((s) => s.home && s.order !== void 0) : void 0;
|
|
2595
2689
|
const ends = alongLimit && drawn ? v ? [drawn.y, drawn.y + drawn.height] : [drawn.x, drawn.x + drawn.width] : null;
|
|
2596
2690
|
const out = [];
|
|
2597
2691
|
for (const z of spec.zones) {
|
|
2598
|
-
const room = less([[z.a, z.b]], [...cuts, ...spec.reserved]).filter(([a, b]) => b - a >
|
|
2692
|
+
const room = less([[z.a, z.b]], [...cuts, ...spec.reserved]).filter(([a, b]) => b - a > EPS16);
|
|
2599
2693
|
const { pieces, before, after } = reachStrips(c, spec, own ? less(room, [own]) : room, ends);
|
|
2600
2694
|
if (!hasRoom(pieces, bodies)) continue;
|
|
2601
2695
|
const lined = slots.flatMap((s) => spec.holds && s.home ? own ? [{ ...s, line: own[0] }, { ...s, line: own[1] }] : [] : [s]);
|
|
2602
|
-
const mine = lined.filter((s) => s.zone === z.zone && !wedged(s.line) && pieces.some(([a, b]) => b > s.line - data.reach +
|
|
2696
|
+
const mine = lined.filter((s) => s.zone === z.zone && !wedged(s.line) && pieces.some(([a, b]) => b > s.line - data.reach + EPS16 && a < s.line + data.reach - EPS16));
|
|
2603
2697
|
const reason = spec.refuse(z.zone);
|
|
2604
2698
|
for (const [k, [pa, pb]] of pieces.entries()) {
|
|
2605
2699
|
const { inPiece, at } = linesIn(spec, z, mine, pieces, [pa, pb], own);
|
|
2606
2700
|
const stripsOf = (i) => [...k === 0 && i === 0 ? before : [], ...k === pieces.length - 1 && i === inPiece.length - 1 ? after : []];
|
|
2607
2701
|
if (inPiece.length === 0) {
|
|
2608
2702
|
const lone = (reason === "no-room" || reason === "too-thick") && mine.length === 0 && slots.some((s) => s.zone === z.zone && s.home);
|
|
2609
|
-
const near = mine.length === 0 || data.virtual || mine.some((s) => pb > s.line - data.reach +
|
|
2703
|
+
const near = mine.length === 0 || data.virtual || mine.some((s) => pb > s.line - data.reach + EPS16 && pa < s.line + data.reach - EPS16);
|
|
2610
2704
|
const joins = data.virtual ? mine.filter((s) => s.ok && !s.home) : [];
|
|
2611
2705
|
if (joins.length > 0) {
|
|
2612
2706
|
const s = joins.reduce((m, x) => Math.abs(x.line - (pa + pb) / 2) < Math.abs(m.line - (pa + pb) / 2) ? x : m);
|
|
@@ -2619,29 +2713,29 @@ function tileEdge(c, spec, { cuts, bodies }, lost) {
|
|
|
2619
2713
|
}
|
|
2620
2714
|
const meet2 = (i) => {
|
|
2621
2715
|
const [lo2, hi] = [at[i - 1], at[i]];
|
|
2622
|
-
const between = spec.cards.filter(([u, w]) => u >= inPiece[i - 1].line -
|
|
2716
|
+
const between = spec.cards.filter(([u, w]) => u >= inPiece[i - 1].line - EPS16 && w <= inPiece[i].line + EPS16);
|
|
2623
2717
|
const mid2 = between.length === 1 ? (between[0][0] + between[0][1]) / 2 : NaN;
|
|
2624
|
-
return mid2 > lo2 +
|
|
2718
|
+
return mid2 > lo2 + EPS16 && mid2 < hi - EPS16 ? mid2 : (lo2 + hi) / 2;
|
|
2625
2719
|
};
|
|
2626
2720
|
inPiece.forEach((s, i) => {
|
|
2627
2721
|
const p = at[i];
|
|
2628
2722
|
const lim = data.virtual ? Infinity : data.reach;
|
|
2629
2723
|
const a = Math.max(i === 0 ? pa : meet2(i), p - lim);
|
|
2630
2724
|
const b = Math.min(i === inPiece.length - 1 ? pb : meet2(i + 1), p + lim);
|
|
2631
|
-
if (b - a <=
|
|
2725
|
+
if (b - a <= EPS16) {
|
|
2632
2726
|
if (s.ok && !s.home) lost.push(s.id);
|
|
2633
2727
|
return;
|
|
2634
2728
|
}
|
|
2635
2729
|
if (!hasRoom([[a, b]], bodies)) return;
|
|
2636
2730
|
const homeTile = (id, u, w, line) => {
|
|
2637
2731
|
const hit = band(u, w, s.home ? s.result.layout : void 0);
|
|
2638
|
-
return tile(z.zone, hit, { kind: "home", id, order: data.layer, priority: data.priority, keep: keepAt(Math.min(Math.max(line, u), w), hit), place: { kind: "home" } });
|
|
2732
|
+
return tile(z.zone, hit, { kind: "home", id, order: data.layer, priority: spec.homePriority ?? data.priority, keep: keepAt(Math.min(Math.max(line, u), w), hit), place: { kind: "home" } });
|
|
2639
2733
|
};
|
|
2640
2734
|
if (s.home) {
|
|
2641
2735
|
for (const [u, w] of [[a, b], ...stripsOf(i)]) out.push(...split(homeTile(s.id, u, w, p)));
|
|
2642
2736
|
return;
|
|
2643
2737
|
}
|
|
2644
|
-
const faced = homeSlot && s.order === homeSlot.order ? spec.cards.filter(([u, w]) => w > a +
|
|
2738
|
+
const faced = homeSlot && s.order === homeSlot.order ? spec.cards.filter(([u, w]) => w > a + EPS16 && u < b - EPS16) : [];
|
|
2645
2739
|
for (const [u, w] of faced) out.push(...split(homeTile(homeSlot.id, Math.max(u, a), Math.min(w, b), p)));
|
|
2646
2740
|
for (const [u, w] of [...less([[a, b]], faced), ...stripsOf(i)]) {
|
|
2647
2741
|
const line = Math.min(Math.max(p, u), w);
|
|
@@ -2657,7 +2751,7 @@ function tileEdge(c, spec, { cuts, bodies }, lost) {
|
|
|
2657
2751
|
const [a, b] = own;
|
|
2658
2752
|
const h = band(a, b);
|
|
2659
2753
|
const o = spec.own;
|
|
2660
|
-
const hit = v ?
|
|
2754
|
+
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));
|
|
2661
2755
|
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" } }));
|
|
2662
2756
|
}
|
|
2663
2757
|
return out;
|
|
@@ -2675,7 +2769,7 @@ function placeReach(t, pieces, placed, landed, gone) {
|
|
|
2675
2769
|
if (at.length === 0 && gone.has(of)) {
|
|
2676
2770
|
const line = t.vertical ? of.keep.y : of.keep.x;
|
|
2677
2771
|
const whole = pieces.filter((p) => p.width >= 1 && p.height >= 1);
|
|
2678
|
-
const on = whole.filter((p) => t.vertical ? p.y <= line +
|
|
2772
|
+
const on = whole.filter((p) => t.vertical ? p.y <= line + EPS16 && line <= p.y + p.height + EPS16 : p.x <= line + EPS16 && line <= p.x + p.width + EPS16);
|
|
2679
2773
|
const kept = (on.length > 0 ? on : whole).reduce((a, p) => !a || area4(p) > area4(a) ? p : a, null);
|
|
2680
2774
|
if (kept) {
|
|
2681
2775
|
placed.push({ ...of, hit: kept });
|
|
@@ -2688,10 +2782,10 @@ function placeReach(t, pieces, placed, landed, gone) {
|
|
|
2688
2782
|
for (let k = 0; k < cover.length; k++) {
|
|
2689
2783
|
const h = cover[k];
|
|
2690
2784
|
const joint = pieces.find(
|
|
2691
|
-
(p) => t.vertical ? p.y <= h.y +
|
|
2785
|
+
(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)
|
|
2692
2786
|
);
|
|
2693
2787
|
if (!joint) continue;
|
|
2694
|
-
const merged = t.vertical ?
|
|
2788
|
+
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));
|
|
2695
2789
|
placed[i] = cover.length > 1 ? withPieces(placed[i], cover.map((r, j) => j === k ? merged : r)) : { ...placed[i], hit: merged };
|
|
2696
2790
|
return;
|
|
2697
2791
|
}
|
|
@@ -2759,10 +2853,10 @@ function clipTiles(tiles, own, chrome, lost) {
|
|
|
2759
2853
|
}
|
|
2760
2854
|
|
|
2761
2855
|
// src/targets/rail-strip.ts
|
|
2762
|
-
import { EPS as
|
|
2856
|
+
import { EPS as EPS18, overlaps as overlaps4, rect as rect15, subtract as subtract4 } from "@n-uf/placement";
|
|
2763
2857
|
|
|
2764
2858
|
// src/targets/virtual.ts
|
|
2765
|
-
import { EPS as
|
|
2859
|
+
import { EPS as EPS17, clamp, rect as rect14 } from "@n-uf/placement";
|
|
2766
2860
|
function ringsOf(c, side) {
|
|
2767
2861
|
const seen = sideRings(c.state.edges, side);
|
|
2768
2862
|
const kept = c.rest.edges.filter((e) => e.side === side).map((e) => seen.get(e.id) ?? e.ring);
|
|
@@ -2775,7 +2869,7 @@ function railOuter(c, side) {
|
|
|
2775
2869
|
const windowEdge = side === "left" ? state.stage.x : state.stage.x + state.stage.width;
|
|
2776
2870
|
if (!place) return windowEdge;
|
|
2777
2871
|
const placeOuter = side === "left" ? place.x : place.x + place.width;
|
|
2778
|
-
const barOutside = Object.values(now.edges).some((e) => e.side === side && e.rect.width > 0 && e.rect.height > 0 && (side === "left" ? e.rect.x + e.rect.width <= placeOuter +
|
|
2872
|
+
const barOutside = Object.values(now.edges).some((e) => e.side === side && e.rect.width > 0 && e.rect.height > 0 && (side === "left" ? e.rect.x + e.rect.width <= placeOuter + EPS17 : e.rect.x >= placeOuter - EPS17));
|
|
2779
2873
|
return barOutside ? placeOuter : windowEdge;
|
|
2780
2874
|
}
|
|
2781
2875
|
function collapsesAt(c, result, side) {
|
|
@@ -2806,10 +2900,10 @@ function columnLines(c, side, railLands) {
|
|
|
2806
2900
|
const { reach, place, edgePlace } = EDGE_KINDS.columnLine;
|
|
2807
2901
|
const stage = c.state.stage;
|
|
2808
2902
|
const dir = side === "left" ? 1 : -1;
|
|
2809
|
-
const outside2 = (x) => Object.values(now.edges).some((e) => e.side === side && e.rect.width > 0 && e.rect.height > 0 && (side === "left" ? e.rect.x + e.rect.width <= x +
|
|
2903
|
+
const outside2 = (x) => Object.values(now.edges).some((e) => e.side === side && e.rect.width > 0 && e.rect.height > 0 && (side === "left" ? e.rect.x + e.rect.width <= x + EPS17 : e.rect.x >= x - EPS17));
|
|
2810
2904
|
const railFirst = railLands && !!c.state.rails?.[side]?.accepts.includes(c.kind) && !!now.railPlaces[side] && !(now.rails[side]?.segments.length ?? 0);
|
|
2811
2905
|
const placeOf = (l, i) => {
|
|
2812
|
-
const atEdge = side === "left" ? l.x <= stage.x +
|
|
2906
|
+
const atEdge = side === "left" ? l.x <= stage.x + EPS17 : l.x >= stage.x + stage.width - EPS17;
|
|
2813
2907
|
if (i > 0 || outside2(l.x) || !(atEdge || railFirst)) return { line: l.x, zone: [l.x - reach, l.x + reach], owned: [l.x - place / 2, l.x + place / 2] };
|
|
2814
2908
|
const windowEdge = side === "left" ? stage.x : stage.x + stage.width;
|
|
2815
2909
|
const boundary = clamp(l.x, stage.x, stage.x + stage.width);
|
|
@@ -2840,7 +2934,7 @@ function columnLines(c, side, railLands) {
|
|
|
2840
2934
|
ownedAlong: p.owned,
|
|
2841
2935
|
drawn: false,
|
|
2842
2936
|
// Where the new column's edge lands: the line itself, inside the stage.
|
|
2843
|
-
marker: () =>
|
|
2937
|
+
marker: () => rect14(clamp(l.x, stage.x, stage.x + stage.width), span.y, 0, span.height)
|
|
2844
2938
|
};
|
|
2845
2939
|
});
|
|
2846
2940
|
}
|
|
@@ -2857,6 +2951,21 @@ function railEnd(c, side, segments, y) {
|
|
|
2857
2951
|
};
|
|
2858
2952
|
return slotAt(c, "start", y, targetId(place), place, lands);
|
|
2859
2953
|
}
|
|
2954
|
+
function ownColumnRun(c, side, rail) {
|
|
2955
|
+
const { state, now, dragged } = c;
|
|
2956
|
+
const me = now.items[dragged];
|
|
2957
|
+
const shown = now.rails[side];
|
|
2958
|
+
const edge = me?.rail === side ? state.edges.find((e) => e.id === me.edge) : void 0;
|
|
2959
|
+
const homeId = rail.slots.find((s) => s.home)?.id;
|
|
2960
|
+
if (!shown || !edge || homeId === void 0) return null;
|
|
2961
|
+
const tiles = shown.segments.filter((s) => s.edge === edge.id).map((s) => s.rect);
|
|
2962
|
+
if (tiles.length === 0) return null;
|
|
2963
|
+
const top = Math.min(...tiles.map((r) => r.y));
|
|
2964
|
+
const spec = railColumnSpec(c, edge, rect14(shown.rect.x, top, shown.rect.width, Math.max(...tiles.map((r) => r.y + r.height)) - top));
|
|
2965
|
+
if (!spec) return null;
|
|
2966
|
+
const stays = ({ layout }) => layout.items[dragged]?.rail === side && layout.items[dragged]?.edge === edge.id;
|
|
2967
|
+
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) }) };
|
|
2968
|
+
}
|
|
2860
2969
|
function railStops(c, side) {
|
|
2861
2970
|
const { state, now, dragged } = c;
|
|
2862
2971
|
const rail = now.rails[side];
|
|
@@ -2890,7 +2999,7 @@ function railStops(c, side) {
|
|
|
2890
2999
|
} else {
|
|
2891
3000
|
const firstCol = mine.find((e) => e.column === true);
|
|
2892
3001
|
const outer = railOuter(c, side);
|
|
2893
|
-
zone =
|
|
3002
|
+
zone = rect14(side === "left" ? outer : outer - RAIL_EDGE, placeRect.y, RAIL_EDGE, placeRect.height);
|
|
2894
3003
|
stops2.push({ y: placeRect.y, ring: firstCol ? rings.before(firstCol) : rings.count });
|
|
2895
3004
|
}
|
|
2896
3005
|
const ownRail = now.items[dragged]?.rail === side;
|
|
@@ -2921,7 +3030,7 @@ function railStops(c, side) {
|
|
|
2921
3030
|
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],
|
|
2922
3031
|
ownedAlong: null,
|
|
2923
3032
|
drawn: !!rail && rail.segments.length > 0,
|
|
2924
|
-
marker: (s) =>
|
|
3033
|
+
marker: (s) => rect14(at.x, s.result.layout.items[dragged].rect.y, at.width, 0)
|
|
2925
3034
|
};
|
|
2926
3035
|
}
|
|
2927
3036
|
|
|
@@ -2937,11 +3046,11 @@ function columnStrip(c, side, policy) {
|
|
|
2937
3046
|
if (moved === c.state) return null;
|
|
2938
3047
|
const result = c.settle(markUsed(moved, c.dragged));
|
|
2939
3048
|
const el = result.layout.edges[edge.id];
|
|
2940
|
-
if (!el || el.rect.width <=
|
|
3049
|
+
if (!el || el.rect.width <= EPS18 || !collapsesAt(c, result, side)) return null;
|
|
2941
3050
|
const r = el.rect;
|
|
2942
3051
|
const railWidth = result.layout.items[c.dragged].tab ? r.width : edge.cross.rail ?? 30;
|
|
2943
3052
|
const [x, w] = across(side, side === "left" ? r.x : r.x + r.width, policy.railStripWidth ?? Math.max(RAIL_STRIP_MIN, railWidth));
|
|
2944
|
-
return { side, rect:
|
|
3053
|
+
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 }] };
|
|
2945
3054
|
}
|
|
2946
3055
|
function declaredStrip(c, side, policy) {
|
|
2947
3056
|
const template = c.state.columns?.[side];
|
|
@@ -2958,7 +3067,7 @@ function declaredStrip(c, side, policy) {
|
|
|
2958
3067
|
const cuts = [a, ...slots.slice(1).map((s, i) => (slots[i].line + s.line) / 2), b];
|
|
2959
3068
|
return {
|
|
2960
3069
|
side,
|
|
2961
|
-
rect:
|
|
3070
|
+
rect: rect15(x, a, w, b - a),
|
|
2962
3071
|
slots: slots.map((s, i) => ({ id: s.id, place: s.place, along: [cuts[i], cuts[i + 1]], result: s.result }))
|
|
2963
3072
|
};
|
|
2964
3073
|
}
|
|
@@ -3043,7 +3152,7 @@ ${r.zone}`) ?? [], r]);
|
|
|
3043
3152
|
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 })));
|
|
3044
3153
|
const renumbered = refused.map((r) => numbered.get(r) === r.id ? r : { ...r, id: numbered.get(r) });
|
|
3045
3154
|
for (const s of strips) {
|
|
3046
|
-
const grown = s.side === "left" ?
|
|
3155
|
+
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);
|
|
3047
3156
|
for (const sl of s.slots) {
|
|
3048
3157
|
const [a, b] = sl.along;
|
|
3049
3158
|
const slot = sl.result.layout.items[c.dragged].rect;
|
|
@@ -3051,8 +3160,8 @@ ${r.zone}`) ?? [], r]);
|
|
|
3051
3160
|
out.push({
|
|
3052
3161
|
id: sl.id,
|
|
3053
3162
|
priority: 1,
|
|
3054
|
-
hit:
|
|
3055
|
-
armedHit:
|
|
3163
|
+
hit: rect15(s.rect.x, a, s.rect.width, b - a),
|
|
3164
|
+
armedHit: rect15(grown.x, a, grown.width, b - a),
|
|
3056
3165
|
arm: "dwell",
|
|
3057
3166
|
// Armed, its room opens at once: a host that draws only a marker reads that from this one flag, as for any target.
|
|
3058
3167
|
opensRoom: true,
|
|
@@ -3073,7 +3182,7 @@ var withoutHits = (t) => {
|
|
|
3073
3182
|
function insideStrips(r, strips) {
|
|
3074
3183
|
const s = strips.find((x) => overlaps4(x.rect, r));
|
|
3075
3184
|
if (!s) return null;
|
|
3076
|
-
return s.side === "left" ?
|
|
3185
|
+
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);
|
|
3077
3186
|
}
|
|
3078
3187
|
function clearOfStrips(t, dragged, strips) {
|
|
3079
3188
|
return {
|
|
@@ -3084,7 +3193,7 @@ function clearOfStrips(t, dragged, strips) {
|
|
|
3084
3193
|
if (!at) return first;
|
|
3085
3194
|
let dx = 0;
|
|
3086
3195
|
for (const s of strips) {
|
|
3087
|
-
const r =
|
|
3196
|
+
const r = rect15(at.x + dx, at.y, at.width, at.height);
|
|
3088
3197
|
if (!overlaps4(r, s)) continue;
|
|
3089
3198
|
dx += s.x + s.width / 2 < r.x + r.width / 2 ? s.x + s.width - r.x : s.x - (r.x + r.width);
|
|
3090
3199
|
}
|
|
@@ -3094,7 +3203,7 @@ function clearOfStrips(t, dragged, strips) {
|
|
|
3094
3203
|
}
|
|
3095
3204
|
|
|
3096
3205
|
// src/targets/min-hit.ts
|
|
3097
|
-
import { EPS as
|
|
3206
|
+
import { EPS as EPS19, area as area5, rect as rect16, subtract as subtract5 } from "@n-uf/placement";
|
|
3098
3207
|
function kindOf(c, t) {
|
|
3099
3208
|
const p = parseTargetId(t.id);
|
|
3100
3209
|
if (!p) return null;
|
|
@@ -3107,8 +3216,8 @@ function kindOf(c, t) {
|
|
|
3107
3216
|
return null;
|
|
3108
3217
|
}
|
|
3109
3218
|
var largest3 = (ps) => ps.reduce((a, p) => area5(p) > area5(a) ? p : a);
|
|
3110
|
-
var keepsMinHit = (r, m) => Math.min(r.width, r.height) >= m.across -
|
|
3111
|
-
var overlaps5 = (a, b) => Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x) >
|
|
3219
|
+
var keepsMinHit = (r, m) => Math.min(r.width, r.height) >= m.across - EPS19 && Math.max(r.width, r.height) >= m.along - EPS19;
|
|
3220
|
+
var overlaps5 = (a, b) => Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x) > EPS19 && Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y) > EPS19;
|
|
3112
3221
|
var cut = (ps, g) => ps.flatMap((p) => subtract5(p, g)).filter((p) => p.width >= 1 && p.height >= 1);
|
|
3113
3222
|
var piecesOf = (t) => t.hits ?? [t.hit];
|
|
3114
3223
|
var withPieces2 = (t, ps) => {
|
|
@@ -3116,22 +3225,22 @@ var withPieces2 = (t, ps) => {
|
|
|
3116
3225
|
return { ...rest, hit: largest3(ps), ...ps.length > 1 ? { hits: ps } : {} };
|
|
3117
3226
|
};
|
|
3118
3227
|
function growths(r, axis, d) {
|
|
3119
|
-
const [lo2, hi] = axis === "x" ? [
|
|
3228
|
+
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)];
|
|
3120
3229
|
const h = d / 2;
|
|
3121
|
-
const halves = axis === "x" ? [
|
|
3230
|
+
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)];
|
|
3122
3231
|
return [[lo2], [hi], halves];
|
|
3123
3232
|
}
|
|
3124
3233
|
var union = (a, gs) => {
|
|
3125
3234
|
const x0 = Math.min(a.x, ...gs.map((g) => g.x));
|
|
3126
3235
|
const y0 = Math.min(a.y, ...gs.map((g) => g.y));
|
|
3127
|
-
return
|
|
3236
|
+
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);
|
|
3128
3237
|
};
|
|
3129
3238
|
function mayGrow(c, targets2, i, grow, minOf, zone, away) {
|
|
3130
3239
|
const s = c.state.stage;
|
|
3131
3240
|
for (const g of grow) {
|
|
3132
|
-
if (g.x < s.x -
|
|
3241
|
+
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;
|
|
3133
3242
|
if ([...keepClearFor(c.state, "targets"), ...away].some((r) => overlaps5(r, g))) return false;
|
|
3134
|
-
if (zone.reduce((ps, z) => ps.flatMap((p) => subtract5(p, z)), [g]).some((p) => area5(p) >
|
|
3243
|
+
if (zone.reduce((ps, z) => ps.flatMap((p) => subtract5(p, z)), [g]).some((p) => area5(p) > EPS19)) return false;
|
|
3135
3244
|
}
|
|
3136
3245
|
return targets2.every((o, j) => {
|
|
3137
3246
|
if (j === i || o.free || !piecesOf(o).some((p) => grow.some((g) => overlaps5(p, g)))) return true;
|
|
@@ -3146,7 +3255,7 @@ function partialGrowth(c, targets2, i, l, axis, d, m, minOf, zone, away) {
|
|
|
3146
3255
|
let best = null;
|
|
3147
3256
|
for (const [side] of growths(l, axis, d)) {
|
|
3148
3257
|
const g = side;
|
|
3149
|
-
const strip = (a, b) => axis === "x" ?
|
|
3258
|
+
const strip = (a, b) => axis === "x" ? rect16(g.x, a, g.width, b - a) : rect16(a, g.y, b - a, g.height);
|
|
3150
3259
|
const cuts = /* @__PURE__ */ new Set([along2[0], along2[1]]);
|
|
3151
3260
|
for (const o of targets2)
|
|
3152
3261
|
for (const p of piecesOf(o))
|
|
@@ -3166,7 +3275,7 @@ function partialGrowth(c, targets2, i, l, axis, d, m, minOf, zone, away) {
|
|
|
3166
3275
|
}
|
|
3167
3276
|
if (runStart !== null) runs.push([runStart, marks[marks.length - 1]]);
|
|
3168
3277
|
for (const [a, b] of runs.sort((p, q) => q[1] - q[0] - (p[1] - p[0]))) {
|
|
3169
|
-
if (b - a < m.along -
|
|
3278
|
+
if (b - a < m.along - EPS19) break;
|
|
3170
3279
|
const r = strip(a, b);
|
|
3171
3280
|
if (mayGrow(c, targets2, i, [r], minOf, zone, away) && (!best || area5(r) > area5(best))) best = r;
|
|
3172
3281
|
break;
|
|
@@ -3181,7 +3290,7 @@ function withMinHit(c, targets2, refusals2, zones) {
|
|
|
3181
3290
|
const k = kindOf(c, t);
|
|
3182
3291
|
return k ? EDGE_KINDS[k].minHit : null;
|
|
3183
3292
|
};
|
|
3184
|
-
const drawn = Object.entries(c.now.edges).filter(([, e]) => e.rect.width >
|
|
3293
|
+
const drawn = Object.entries(c.now.edges).filter(([, e]) => e.rect.width > EPS19 && e.rect.height > EPS19);
|
|
3185
3294
|
for (let i = 0; i < out.length; i++) {
|
|
3186
3295
|
const t = out[i];
|
|
3187
3296
|
const m = minOf(t);
|
|
@@ -3198,7 +3307,7 @@ function withMinHit(c, targets2, refusals2, zones) {
|
|
|
3198
3307
|
const axis = step === "across" ? narrowX ? "x" : "y" : narrowX ? "y" : "x";
|
|
3199
3308
|
const size = axis === "x" ? l.width : l.height;
|
|
3200
3309
|
const d = (step === "across" ? m.across : m.along) - size;
|
|
3201
|
-
if (d <=
|
|
3310
|
+
if (d <= EPS19) continue;
|
|
3202
3311
|
let grow = growths(l, axis, d).find((g) => mayGrow(c, out, i, g, minOf, zone, away));
|
|
3203
3312
|
if (!grow && step === "across") grow = partialGrowth(c, out, i, l, axis, d, m, minOf, zone, away) ?? void 0;
|
|
3204
3313
|
if (!grow) continue;
|
|
@@ -3209,7 +3318,7 @@ function withMinHit(c, targets2, refusals2, zones) {
|
|
|
3209
3318
|
out[j] = withPieces2(o, grow.reduce((ps, g) => cut(ps, g), [...piecesOf(o)]));
|
|
3210
3319
|
}
|
|
3211
3320
|
const g0 = grow[0];
|
|
3212
|
-
const span = axis === "x" ?
|
|
3321
|
+
const span = axis === "x" ? rect16(l.x, g0.y, l.width, g0.height) : rect16(g0.x, l.y, g0.width, l.height);
|
|
3213
3322
|
const grown = union(span, grow);
|
|
3214
3323
|
const others = piecesOf(out[i]).filter((p) => p !== l);
|
|
3215
3324
|
out[i] = withPieces2(out[i], [...cut([...others, l], grown), grown]);
|
|
@@ -3229,6 +3338,7 @@ function specsOf(c, kind) {
|
|
|
3229
3338
|
const rail = state.rails?.[side]?.accepts.includes(kind) ? railStops(c, side) : null;
|
|
3230
3339
|
specs.push(...columnLines(c, side, !!rail?.slots.some((s) => s.ok)));
|
|
3231
3340
|
specs.push(rail);
|
|
3341
|
+
if (rail) specs.push(ownColumnRun(c, side, rail));
|
|
3232
3342
|
}
|
|
3233
3343
|
return specs.filter((s) => s !== null);
|
|
3234
3344
|
}
|
|
@@ -3281,22 +3391,22 @@ function emit2(c, placed) {
|
|
|
3281
3391
|
function hull(a, b) {
|
|
3282
3392
|
const x = Math.min(a.x, b.x);
|
|
3283
3393
|
const y = Math.min(a.y, b.y);
|
|
3284
|
-
return
|
|
3394
|
+
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);
|
|
3285
3395
|
}
|
|
3286
3396
|
var thicknessChanges = (now, after) => {
|
|
3287
3397
|
const a = now.content;
|
|
3288
3398
|
const b = after.content;
|
|
3289
|
-
return Math.abs(b.x - a.x) >
|
|
3399
|
+
return Math.abs(b.x - a.x) > EPS20 || Math.abs(b.y - a.y) > EPS20 || Math.abs(b.x + b.width - (a.x + a.width)) > EPS20 || Math.abs(b.y + b.height - (a.y + a.height)) > EPS20;
|
|
3290
3400
|
};
|
|
3291
3401
|
var WINDOW_EDGE_KINDS = /* @__PURE__ */ new Set(["rail", "railStop", "sideBar", "columnLine"]);
|
|
3292
|
-
var touchesSide = (stage, pieces) => pieces.some((r) => r.x <= stage.x +
|
|
3402
|
+
var touchesSide = (stage, pieces) => pieces.some((r) => r.x <= stage.x + EPS20 || r.x + r.width >= stage.x + stage.width - EPS20);
|
|
3293
3403
|
function slotOverMoved(now, lifted, after, slot, dragged, onto) {
|
|
3294
3404
|
const from = now.items[dragged]?.edge;
|
|
3295
3405
|
return Object.entries(now.items).some(([id, was]) => {
|
|
3296
3406
|
if (!overlaps6(slot, was.rect) || id === dragged || was.floating || was.edge === onto) return false;
|
|
3297
3407
|
const r = after.items[id]?.rect;
|
|
3298
3408
|
const start = (from !== void 0 && was.edge === from ? lifted.items[id]?.rect : void 0) ?? was.rect;
|
|
3299
|
-
return !!r && (Math.abs(r.x - start.x) >
|
|
3409
|
+
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);
|
|
3300
3410
|
});
|
|
3301
3411
|
}
|
|
3302
3412
|
function alongOfSlots(s, tiles) {
|
|
@@ -3373,15 +3483,15 @@ function generateShown(state, dragged, options, hidden) {
|
|
|
3373
3483
|
place: { kind: "float" },
|
|
3374
3484
|
after(point, grab) {
|
|
3375
3485
|
const g = grab ?? { x: size.width / 2, y: size.height / 2 };
|
|
3376
|
-
const raw = options.floatFromHeld ? heldRect(state, dragged, size, point, g) :
|
|
3486
|
+
const raw = options.floatFromHeld ? heldRect(state, dragged, size, point, g) : rect17(point.x - g.x, point.y - g.y, size.width, size.height);
|
|
3377
3487
|
const first = solve(markUsed(floatAt(state, dragged, raw, options.floatOrient), dragged), prev);
|
|
3378
3488
|
const at = first.items[dragged]?.rect ?? raw;
|
|
3379
|
-
return c.settle(markUsed(floatAt(state, dragged,
|
|
3489
|
+
return c.settle(markUsed(floatAt(state, dragged, rect17(at.x, at.y, size.width, size.height), options.floatOrient), dragged));
|
|
3380
3490
|
}
|
|
3381
3491
|
});
|
|
3382
3492
|
}
|
|
3383
3493
|
(state.blocked ?? []).forEach((b, i) => {
|
|
3384
|
-
targets2.push({ id: targetId({ kind: "none", index: i }), priority: 1, hit:
|
|
3494
|
+
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 });
|
|
3385
3495
|
});
|
|
3386
3496
|
const sameAsHome = targets2.filter((t) => t.place.kind === "home" && parseTargetId(t.id)?.kind === "column");
|
|
3387
3497
|
const homePieces = sameAsHome.flatMap((t) => t.hits ?? [t.hit]);
|
|
@@ -3404,7 +3514,7 @@ function generateShown(state, dragged, options, hidden) {
|
|
|
3404
3514
|
const held = withMinHit(c, layered.targets, layered.refusals, zones).map((t) => t.roomHit && t.slot ? { ...t, roomHit: hull(t.hit, t.slot) } : t);
|
|
3405
3515
|
return { targets: held, refusals: layered.refusals.map((r) => ({ ...r, bounds })), lost: lostIds, zones };
|
|
3406
3516
|
}
|
|
3407
|
-
var stageOf = (state) =>
|
|
3517
|
+
var stageOf = (state) => rect17(state.stage.x, state.stage.y, state.stage.width, state.stage.height);
|
|
3408
3518
|
function targets(state, dragged, options = {}) {
|
|
3409
3519
|
return generate(state, dragged, options).targets;
|
|
3410
3520
|
}
|
|
@@ -3463,7 +3573,7 @@ function orderedStops(state, dragged, options) {
|
|
|
3463
3573
|
}
|
|
3464
3574
|
|
|
3465
3575
|
// src/lanes.ts
|
|
3466
|
-
import { EPS as
|
|
3576
|
+
import { EPS as EPS21, clamp as clamp2, rect as rect18 } from "@n-uf/placement";
|
|
3467
3577
|
var SPOT_PITCH = 40;
|
|
3468
3578
|
var SNAP_DISTANCE = 8;
|
|
3469
3579
|
var STEP = 1;
|
|
@@ -3473,13 +3583,13 @@ var len = (r, axis) => axis === "x" ? r.width : r.height;
|
|
|
3473
3583
|
var hull2 = (a, b) => {
|
|
3474
3584
|
const x = Math.min(a.x, b.x);
|
|
3475
3585
|
const y = Math.min(a.y, b.y);
|
|
3476
|
-
return
|
|
3586
|
+
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);
|
|
3477
3587
|
};
|
|
3478
3588
|
var nonNeg = (v) => Number.isFinite(v) && v > 0 ? v : 0;
|
|
3479
3589
|
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;
|
|
3480
3590
|
var ORIGIN = { x: 0, y: 0 };
|
|
3481
3591
|
function onEdge(l, edge, dragged, axis) {
|
|
3482
|
-
return Object.entries(l.items).filter(([id, it]) => id !== dragged && it.edge === edge && !it.inMenu && !it.floating && it.rect.width >
|
|
3592
|
+
return Object.entries(l.items).filter(([id, it]) => id !== dragged && it.edge === edge && !it.inMenu && !it.floating && it.rect.width > EPS21 && it.rect.height > EPS21).map(([id, it]) => ({ id, r: it.rect, zone: it.zone })).sort((a, b) => lo(a.r, axis) - lo(b.r, axis));
|
|
3483
3593
|
}
|
|
3484
3594
|
function neighbors(after, edge, dragged, axis) {
|
|
3485
3595
|
const me = after.items[dragged];
|
|
@@ -3511,19 +3621,19 @@ function clipAtDrawn(band, axis, cuts) {
|
|
|
3511
3621
|
const x = axis === "x" ? "y" : "x";
|
|
3512
3622
|
const line = lo(band, x) + len(band, x) / 2;
|
|
3513
3623
|
for (const c of cuts) {
|
|
3514
|
-
if (!(lo(c, x) < line -
|
|
3624
|
+
if (!(lo(c, x) < line - EPS21 && line < lo(c, x) + len(c, x) - EPS21)) continue;
|
|
3515
3625
|
const c0 = lo(c, axis);
|
|
3516
3626
|
const c1 = c0 + len(c, axis);
|
|
3517
3627
|
if ((c0 + c1) / 2 <= center) a = Math.max(a, c1);
|
|
3518
3628
|
else b = Math.min(b, c0);
|
|
3519
3629
|
}
|
|
3520
|
-
return b - a >
|
|
3630
|
+
return b - a > EPS21 ? along(band, axis, a, b) : band;
|
|
3521
3631
|
}
|
|
3522
3632
|
var memo = /* @__PURE__ */ new WeakMap();
|
|
3523
3633
|
var previousIds = /* @__PURE__ */ new WeakMap();
|
|
3524
3634
|
var nextPrevious = 1;
|
|
3525
3635
|
function keyOf(dragged, o) {
|
|
3526
|
-
const { previous,
|
|
3636
|
+
const { previous, ...rest } = o;
|
|
3527
3637
|
let p = 0;
|
|
3528
3638
|
if (previous) {
|
|
3529
3639
|
if (!previousIds.has(previous)) previousIds.set(previous, nextPrevious++);
|
|
@@ -3532,40 +3642,47 @@ function keyOf(dragged, o) {
|
|
|
3532
3642
|
return `${dragged}\0${p}\0${JSON.stringify(rest)}`;
|
|
3533
3643
|
}
|
|
3534
3644
|
function lanes(state, dragged, options = {}) {
|
|
3645
|
+
const base = baseOf(state, dragged, options);
|
|
3646
|
+
return { ...base.regions, lanes: base.lanes };
|
|
3647
|
+
}
|
|
3648
|
+
function baseOf(state, dragged, options = {}) {
|
|
3535
3649
|
const key = keyOf(dragged, options);
|
|
3536
3650
|
let perState = memo.get(state);
|
|
3537
3651
|
if (!perState) memo.set(state, perState = /* @__PURE__ */ new Map());
|
|
3538
3652
|
let base = perState.get(key);
|
|
3539
3653
|
if (!base) perState.set(key, base = build(state, dragged, options));
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
const [
|
|
3544
|
-
const
|
|
3545
|
-
const
|
|
3654
|
+
return base;
|
|
3655
|
+
}
|
|
3656
|
+
function marksIn(base, state, dragged, layout, held, emptyLanes) {
|
|
3657
|
+
const heldEdge = held ? layout.items[dragged] : void 0;
|
|
3658
|
+
const on = heldEdge && !heldEdge.floating && !heldEdge.inMenu ? heldEdge.edge : void 0;
|
|
3659
|
+
const built = base.lanes.flatMap((l) => {
|
|
3546
3660
|
const raws = base.raws.get(l.id);
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
if (!again) return asDrawn(l);
|
|
3550
|
-
return l.id === heldLane ? again : { ...asDrawn(l), marks: again.marks };
|
|
3661
|
+
const again = raws ? laneFrom(l.id, raws, layout, base.seen, dragged, base.refusals, base.halves.has(l.id), base.share, base.marking, l.id === on, l.id === on && held === "slide" ? MIN_BOX : void 0) : null;
|
|
3662
|
+
return again ? [{ lane: again, over: laneRectOver(raws, layout, base.marking).rect }] : [];
|
|
3551
3663
|
});
|
|
3552
|
-
const
|
|
3553
|
-
const
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
return { ...l, marks: marksLess(base.lanes[i].marks, l.axis, heldMarks) };
|
|
3559
|
-
})
|
|
3560
|
-
};
|
|
3664
|
+
const over2 = built.map(({ lane, over: r }) => ({ ...lane, rect: r }));
|
|
3665
|
+
const settled = built.map(({ lane, over: r }) => {
|
|
3666
|
+
const s = settle(lane, layout, state, dragged, over2, emptyLanes, r);
|
|
3667
|
+
return { lane: s.id, axis: s.axis, marks: s.marks };
|
|
3668
|
+
});
|
|
3669
|
+
return newColumnsGiveWay(settled, (s) => s.lane, state);
|
|
3561
3670
|
}
|
|
3562
|
-
function
|
|
3563
|
-
|
|
3564
|
-
const
|
|
3565
|
-
return
|
|
3671
|
+
function newColumnsGiveWay(ls, idOf, state) {
|
|
3672
|
+
const hasEdge = (id) => state.edges.some((e) => e.id === id);
|
|
3673
|
+
const laid2 = ls.filter((l) => hasEdge(idOf(l))).flatMap((l) => l.marks.filter((m) => m.kind !== "line").map((m) => m.rect));
|
|
3674
|
+
return ls.map((l) => hasEdge(idOf(l)) ? l : { ...l, marks: marksLess(l.marks, l.axis, laid2) });
|
|
3675
|
+
}
|
|
3676
|
+
function spotsIn(base, id, layout, dragged) {
|
|
3677
|
+
const raws = base.raws.get(id);
|
|
3678
|
+
return raws ? laneFrom(id, raws, layout, base.seen, dragged, base.refusals, base.halves.has(id), base.share, base.marking)?.spots ?? null : null;
|
|
3566
3679
|
}
|
|
3567
|
-
function
|
|
3568
|
-
|
|
3680
|
+
function rawSpot(base, id) {
|
|
3681
|
+
for (const [lane, list] of base.raws) {
|
|
3682
|
+
const r = list.find((x) => x.id === id);
|
|
3683
|
+
if (r) return { lane, target: r.target, layout: r.layout, ...r.home ? { home: true } : {}, ...r.slide ? { slide: true } : {} };
|
|
3684
|
+
}
|
|
3685
|
+
return null;
|
|
3569
3686
|
}
|
|
3570
3687
|
function build(state, dragged, options) {
|
|
3571
3688
|
const seen = solve(state, options.previous ? { previous: options.previous } : {});
|
|
@@ -3618,21 +3735,18 @@ function build(state, dragged, options) {
|
|
|
3618
3735
|
return main?.grows ? main.natural : void 0;
|
|
3619
3736
|
},
|
|
3620
3737
|
gap: (edge) => nonNeg(state.edges.find((e) => e.id === edge)?.gap),
|
|
3621
|
-
|
|
3622
|
-
crossing: (edge, over) => state.edges.filter((e) => e.id !== edge && byLane.has(e.id) && (over.edges[e.id]?.cross ?? 0) > EPS20 && axisOfEdge(e.id) !== axisOfEdge(edge)).map((e) => over.edges[e.id].rect)
|
|
3738
|
+
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)
|
|
3623
3739
|
};
|
|
3624
|
-
const shareOf = (g, size) => g === void 0 || !Number.isFinite(g) || size <=
|
|
3740
|
+
const shareOf = (g, size) => g === void 0 || !Number.isFinite(g) || size <= EPS21 ? 0.5 : clamp2(g / size, 0, 1);
|
|
3625
3741
|
const w = own?.rect.width ?? 0;
|
|
3626
3742
|
const h = own?.rect.height ?? 0;
|
|
3627
3743
|
const share = { x: w >= h ? shareOf(options.grab?.x, w) : 0.5, y: h > w ? shareOf(options.grab?.y, h) : 0.5 };
|
|
3628
3744
|
const built = [...byLane].map(([id, list]) => laneFrom(id, list, seen, seen, dragged, rs, halves.has(id), share, marking)).filter((l) => !!l);
|
|
3629
|
-
const
|
|
3630
|
-
const laneList = options.emptyLanes === "edge" ? settled : predict(settled, byLane, { seen, refusals: rs, halves, share, marking }, state, dragged, built, options.emptyLanes);
|
|
3631
|
-
const predicted = new Set(laneList.filter((l, i) => l !== settled[i]).map((l) => l.id));
|
|
3745
|
+
const laneList = newColumnsGiveWay(built.map((l) => settle(l, seen, state, dragged, built, options.emptyLanes)), (l) => l.id, state);
|
|
3632
3746
|
const onLanes = new Set(laneList.map((l) => l.id));
|
|
3633
|
-
const rails = Object.values(seen.rails).flatMap((r) => r && r.rect.width >
|
|
3747
|
+
const rails = Object.values(seen.rails).flatMap((r) => r && r.rect.width > EPS21 && r.rect.height > EPS21 ? [r.rect] : []);
|
|
3634
3748
|
const blocked = [
|
|
3635
|
-
...Object.values(seen.edges).filter((e) => e.cross >
|
|
3749
|
+
...Object.values(seen.edges).filter((e) => e.cross > EPS21).map((e) => e.rect),
|
|
3636
3750
|
...Object.entries(seen.items).filter(([id, it]) => id !== dragged && !it.floating && !it.inMenu).map(([, it]) => it.rect),
|
|
3637
3751
|
...keepClearFor(state, "targets"),
|
|
3638
3752
|
...rails,
|
|
@@ -3647,7 +3761,6 @@ function build(state, dragged, options) {
|
|
|
3647
3761
|
halves,
|
|
3648
3762
|
share,
|
|
3649
3763
|
marking,
|
|
3650
|
-
predicted,
|
|
3651
3764
|
regions: {
|
|
3652
3765
|
refused: rs.filter((f) => !onLanes.has(f.edge)).flatMap((f) => f.hits ?? [f.hit]),
|
|
3653
3766
|
content: floatRegion(state, dragged),
|
|
@@ -3660,23 +3773,33 @@ function build(state, dragged, options) {
|
|
|
3660
3773
|
}
|
|
3661
3774
|
};
|
|
3662
3775
|
}
|
|
3663
|
-
function laneRectOver(list,
|
|
3776
|
+
function laneRectOver(list, over2, marking) {
|
|
3664
3777
|
const first = list[0];
|
|
3665
3778
|
const axis = first.axis;
|
|
3666
|
-
const edgeLayout = first.edge ?
|
|
3779
|
+
const edgeLayout = first.edge ? over2.edges[first.edge] : void 0;
|
|
3667
3780
|
const band = list.map((r) => r.landing).reduce(hull2);
|
|
3668
3781
|
if (!edgeLayout) return { rect: list.every((r) => r.strip) ? list.map((r) => r.hit).reduce(hull2) : list.map((r) => r.hit).reduce(hull2, band) };
|
|
3669
|
-
const
|
|
3670
|
-
|
|
3671
|
-
const
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3782
|
+
const drawnAt = drawnRect(over2, first.edge);
|
|
3783
|
+
if (drawnAt) return { rect: drawnAt };
|
|
3784
|
+
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);
|
|
3785
|
+
return { rect: clipAtDrawn(whole, axis, marking.crossing(first.edge, over2)), band: whole };
|
|
3786
|
+
}
|
|
3787
|
+
function drawnIn(layout, id) {
|
|
3788
|
+
return drawnRect(layout, id) !== void 0;
|
|
3789
|
+
}
|
|
3790
|
+
function drawnRect(layout, id) {
|
|
3791
|
+
const e = layout.edges[id];
|
|
3792
|
+
if (!e) return void 0;
|
|
3793
|
+
if (e.cross > EPS21) return e.rect;
|
|
3794
|
+
if (!e.folded) return void 0;
|
|
3795
|
+
const run = Object.values(layout.rails).flatMap((r) => r?.segments.filter((g) => g.edge === id).map((g) => g.rect) ?? []);
|
|
3796
|
+
return run.length > 0 ? run.reduce(hull2) : void 0;
|
|
3797
|
+
}
|
|
3798
|
+
function laneFrom(id, list, drawn, seen, dragged, rs, halves, share, marking, showsHeld = false, besideFloor) {
|
|
3676
3799
|
if (list.length === 0) return null;
|
|
3677
3800
|
const first = list[0];
|
|
3678
3801
|
const axis = first.axis;
|
|
3679
|
-
const { rect: laneRect, band: markBand } = laneRectOver(list, seen,
|
|
3802
|
+
const { rect: laneRect, band: markBand } = laneRectOver(list, seen, marking);
|
|
3680
3803
|
const firstOf = (r) => r.slide?.first ?? r.landing;
|
|
3681
3804
|
const lastOf = (r) => r.slide?.last ?? r.landing;
|
|
3682
3805
|
const sorted = [...list].sort((a, b) => mid(firstOf(a), axis) - mid(firstOf(b), axis) || (a.home ? -1 : b.home ? 1 : 0));
|
|
@@ -3705,7 +3828,7 @@ function laneFrom(id, list, drawn, seen, dragged, rs, halves, share, marking, he
|
|
|
3705
3828
|
const bLanding = firstOf(b);
|
|
3706
3829
|
const aEnd = lo(aLanding, axis) + len(aLanding, axis);
|
|
3707
3830
|
const across2 = (aEnd + lo(bLanding, axis)) / 2;
|
|
3708
|
-
const overlap = lo(bLanding, axis) < aEnd -
|
|
3831
|
+
const overlap = lo(bLanding, axis) < aEnd - EPS21;
|
|
3709
3832
|
const slack = Math.max(0, marking.pitch) / 2;
|
|
3710
3833
|
const atGrab = clamp2(across2 + (held - 0.5) * (len(aLanding, axis) + len(bLanding, axis)) / 2, lo(bLanding, axis) - slack, aEnd + slack);
|
|
3711
3834
|
const raw = shared ? mid(shared, axis) : overlap ? atGrab : across2;
|
|
@@ -3715,7 +3838,7 @@ function laneFrom(id, list, drawn, seen, dragged, rs, halves, share, marking, he
|
|
|
3715
3838
|
const a = i === 0 ? bandStart : cuts[i - 1];
|
|
3716
3839
|
const b = i === unique.length - 1 ? bandEnd : cuts[i];
|
|
3717
3840
|
const along2 = [clamp2(a, start, end), clamp2(b, start, end)];
|
|
3718
|
-
return along2[1] - along2[0] >
|
|
3841
|
+
return along2[1] - along2[0] > EPS21 || b - a <= EPS21 || x.home ? [{ x, along: along2 }] : [];
|
|
3719
3842
|
}).map(({ x, along: along2 }) => ({
|
|
3720
3843
|
id: x.id,
|
|
3721
3844
|
along: along2,
|
|
@@ -3727,11 +3850,11 @@ function laneFrom(id, list, drawn, seen, dragged, rs, halves, share, marking, he
|
|
|
3727
3850
|
others: othersKey(x.layout, dragged)
|
|
3728
3851
|
}));
|
|
3729
3852
|
const itemLen = Math.min(...unique.map((x) => len(x.landing, axis)));
|
|
3730
|
-
const refused = first.edge ? rs.filter((f) => f.edge === first.edge).flatMap((f) => (f.hits ?? [f.hit]).map((h) => ({ along: [clamp2(lo(h, axis), start, end), clamp2(lo(h, axis) + len(h, axis), start, end)], reason: f.reason }))).filter((f) => f.along[1] - f.along[0] >= itemLen -
|
|
3853
|
+
const refused = first.edge ? rs.filter((f) => f.edge === first.edge).flatMap((f) => (f.hits ?? [f.hit]).map((h) => ({ along: [clamp2(lo(h, axis), start, end), clamp2(lo(h, axis) + len(h, axis), start, end)], reason: f.reason }))).filter((f) => f.along[1] - f.along[0] >= itemLen - EPS21) : [];
|
|
3731
3854
|
const places = new Set(unique.map((x) => `${x.before}|${x.next}`));
|
|
3732
3855
|
const drawnEdge = first.edge ? drawn.edges[first.edge] : void 0;
|
|
3733
|
-
const markRect =
|
|
3734
|
-
const marked = first.edge ? onEdge(drawn, first.edge,
|
|
3856
|
+
const markRect = (first.edge ? drawnRect(drawn, first.edge) : void 0) ?? laneRectOver(list, drawn, marking).band ?? markBand ?? laneRect;
|
|
3857
|
+
const marked = first.edge ? onEdge(drawn, first.edge, showsHeld ? "" : dragged, axis).map((o) => {
|
|
3735
3858
|
const n = o.id === dragged || halves ? void 0 : marking.natural(o.id, axis);
|
|
3736
3859
|
return n !== void 0 && n < len(o.r, axis) ? { ...o, r: along(o.r, axis, lo(o.r, axis), lo(o.r, axis) + n) } : o;
|
|
3737
3860
|
}) : [];
|
|
@@ -3743,17 +3866,16 @@ function laneFrom(id, list, drawn, seen, dragged, rs, halves, share, marking, he
|
|
|
3743
3866
|
const n = halves ? void 0 : marking.natural(iid, axis);
|
|
3744
3867
|
return [lo(r, axis), lo(r, axis) + (n !== void 0 && n < len(r, axis) ? n : len(r, axis))];
|
|
3745
3868
|
};
|
|
3746
|
-
const marks = first.edge ? edgeMarks(id, markRect, axis, marked, refused, itemLen, (pair) => places.has(pair) || pair.split("|").includes(dragged), dragged, {
|
|
3747
|
-
besideMin: halves || marking.pitch <= 0 ? itemLen : marking.pitch,
|
|
3869
|
+
const marks = first.edge && !drawnEdge ? [] : first.edge ? edgeMarks(id, markRect, axis, marked, refused, itemLen, (pair) => places.has(pair) || pair.split("|").includes(dragged), dragged, {
|
|
3870
|
+
besideMin: besideFloor ?? (halves || marking.pitch <= 0 ? itemLen : marking.pitch),
|
|
3748
3871
|
gap: marking.gap(first.edge),
|
|
3749
3872
|
landingOf: (pair) => landings.get(pair),
|
|
3750
|
-
// Judged against the layout the marks are drawn in
|
|
3751
|
-
|
|
3752
|
-
givesWay: (iid, side, after) => givesWay((spotHeld ? marking.lifted : drawn).items[iid], after.items[iid], id, side, (r) => extent(iid, r))
|
|
3873
|
+
// Judged against the layout the marks are drawn in: one layout, the screen's.
|
|
3874
|
+
givesWay: (iid, side, after) => givesWay(drawn.items[iid], after.items[iid], id, side, (r) => extent(iid, r))
|
|
3753
3875
|
}) : virtualMarks(id, unique, drawn.items[dragged]);
|
|
3754
3876
|
return { id, rect: laneRect, axis, spots, refused, marks, ...list.every((r) => r.strip) ? { owns: true } : {} };
|
|
3755
3877
|
}
|
|
3756
|
-
var along = (r, axis, a, b) => axis === "x" ?
|
|
3878
|
+
var along = (r, axis, a, b) => axis === "x" ? rect18(a, r.y, b - a, r.height) : rect18(r.x, a, r.width, b - a);
|
|
3757
3879
|
var LINE2 = 2;
|
|
3758
3880
|
var MIN_BOX = 8;
|
|
3759
3881
|
var HATCH_END = 8;
|
|
@@ -3761,8 +3883,8 @@ var HATCH_EDGE = 8;
|
|
|
3761
3883
|
function edgeMarks(lane, laneRect, axis, items, refused, itemLen, lands, held, more) {
|
|
3762
3884
|
const { besideMin } = more;
|
|
3763
3885
|
const hatches = (pair, a, b, p, q, gl, gr) => {
|
|
3764
|
-
if (gl && Math.abs(p - a) <
|
|
3765
|
-
if (gr && Math.abs(q - b) <
|
|
3886
|
+
if (gl && Math.abs(p - a) < EPS21) out.push({ id: `${lane}/hatch/${pair}:before`, kind: "hatch", rect: along(laneRect, axis, p, p + Math.min(HATCH_END, (q - p) / 2)), givesWay: gl });
|
|
3887
|
+
if (gr && Math.abs(q - b) < EPS21) out.push({ id: `${lane}/hatch/${pair}:after`, kind: "hatch", rect: along(laneRect, axis, q - Math.min(HATCH_END, (q - p) / 2), q), givesWay: gr });
|
|
3766
3888
|
};
|
|
3767
3889
|
const heldAt = items.find((o) => o.id === held);
|
|
3768
3890
|
const heldSpan = heldAt ? [lo(heldAt.r, axis), lo(heldAt.r, axis) + len(heldAt.r, axis)] : null;
|
|
@@ -3775,7 +3897,7 @@ function edgeMarks(lane, laneRect, axis, items, refused, itemLen, lands, held, m
|
|
|
3775
3897
|
const a = clamp2(ends[i].b, start, end);
|
|
3776
3898
|
const b = clamp2(ends[i + 1].a, start, end);
|
|
3777
3899
|
const pair = `${ends[i].id}|${ends[i + 1].id}`;
|
|
3778
|
-
if (ends[i + 1].a < start -
|
|
3900
|
+
if (ends[i + 1].a < start - EPS21 || ends[i].b > end + EPS21 || !lands(pair)) continue;
|
|
3779
3901
|
const left = ends[i].id === held ? ends[i - 1]?.id ?? "^" : ends[i].id;
|
|
3780
3902
|
const right = ends[i + 1].id === held ? ends[i + 2]?.id ?? "$" : ends[i + 1].id;
|
|
3781
3903
|
const named = `${left}|${right}`;
|
|
@@ -3784,12 +3906,12 @@ function edgeMarks(lane, laneRect, axis, items, refused, itemLen, lands, held, m
|
|
|
3784
3906
|
const spot = !beside && named === pair && items.length > 0 && !isRefused2((a + b) / 2) ? more.landingOf(pair) : void 0;
|
|
3785
3907
|
const gl = spot && left !== "^" && more.givesWay(left, "before", spot.layout) ? left : null;
|
|
3786
3908
|
const gr = spot && right !== "$" && more.givesWay(right, "after", spot.layout) ? right : null;
|
|
3787
|
-
if (b - a < min -
|
|
3788
|
-
if (spot && b - a >= besideMin -
|
|
3909
|
+
if (b - a < min - EPS21) {
|
|
3910
|
+
if (spot && b - a >= besideMin - EPS21) {
|
|
3789
3911
|
let ps = [[a, b]];
|
|
3790
3912
|
for (const f of refused) ps = ps.flatMap(([p, q]) => [[p, Math.min(q, f.along[0])], [Math.max(p, f.along[1]), q]]);
|
|
3791
3913
|
if (heldSpan) ps = ps.flatMap(([p, q]) => [[p, Math.min(q, heldSpan[0])], [Math.max(p, heldSpan[1]), q]]);
|
|
3792
|
-
ps = ps.filter(([p, q]) => q - p >= MIN_BOX -
|
|
3914
|
+
ps = ps.filter(([p, q]) => q - p >= MIN_BOX - EPS21);
|
|
3793
3915
|
ps.forEach(([p, q], k2) => {
|
|
3794
3916
|
out.push({ id: `${lane}/box/${pair}${k2 ? `#${k2}` : ""}`, kind: "box", rect: along(laneRect, axis, p, q) });
|
|
3795
3917
|
hatches(pair, a, b, p, q, gl, gr);
|
|
@@ -3801,10 +3923,10 @@ function edgeMarks(lane, laneRect, axis, items, refused, itemLen, lands, held, m
|
|
|
3801
3923
|
continue;
|
|
3802
3924
|
}
|
|
3803
3925
|
let pieces = [[a, b]];
|
|
3804
|
-
for (const f of refused) pieces = pieces.flatMap(([p, q]) => [[p, Math.min(q, f.along[0])], [Math.max(p, f.along[1]), q]]).filter(([p, q]) => q - p >
|
|
3926
|
+
for (const f of refused) pieces = pieces.flatMap(([p, q]) => [[p, Math.min(q, f.along[0])], [Math.max(p, f.along[1]), q]]).filter(([p, q]) => q - p > EPS21);
|
|
3805
3927
|
let k = 0;
|
|
3806
3928
|
for (const [p, q] of pieces) {
|
|
3807
|
-
if (q - p < min -
|
|
3929
|
+
if (q - p < min - EPS21) continue;
|
|
3808
3930
|
const base = `${lane}/box/${named}${beside ? `:${beside}` : ""}${k++ ? `#${k - 1}` : ""}`;
|
|
3809
3931
|
out.push({ id: out.some((m) => m.id === base) ? `${base}~2` : base, kind: "box", rect: along(laneRect, axis, p, q) });
|
|
3810
3932
|
hatches(pair, a, b, p, q, gl, gr);
|
|
@@ -3817,7 +3939,7 @@ function virtualMarks(lane, spots, held) {
|
|
|
3817
3939
|
const l = s.landing;
|
|
3818
3940
|
if (!held || held.floating || !overlaps7(l, held.rect)) return { id: `${lane}/box/${s.id}`, kind: "box", rect: l };
|
|
3819
3941
|
const x = mid(held.rect, "x") < mid(l, "x") ? l.x + l.width : l.x;
|
|
3820
|
-
return { id: `${lane}/line/${s.id}`, kind: "line", rect:
|
|
3942
|
+
return { id: `${lane}/line/${s.id}`, kind: "line", rect: rect18(x, l.y, 0, l.height) };
|
|
3821
3943
|
});
|
|
3822
3944
|
}
|
|
3823
3945
|
function inLane(l, r) {
|
|
@@ -3826,22 +3948,22 @@ function inLane(l, r) {
|
|
|
3826
3948
|
const y0 = Math.max(m.rect.y, r.y);
|
|
3827
3949
|
const x1 = Math.min(m.rect.x + m.rect.width, r.x + r.width);
|
|
3828
3950
|
const y1 = Math.min(m.rect.y + m.rect.height, r.y + r.height);
|
|
3829
|
-
if (m.kind === "line") return x1 - x0 >= m.rect.width -
|
|
3830
|
-
if (x1 - x0 <=
|
|
3831
|
-
return x1 - x0 >= m.rect.width -
|
|
3951
|
+
if (m.kind === "line") return x1 - x0 >= m.rect.width - EPS21 && y1 - y0 >= m.rect.height - EPS21 ? [m] : [];
|
|
3952
|
+
if (x1 - x0 <= EPS21 || y1 - y0 <= EPS21) return [];
|
|
3953
|
+
return x1 - x0 >= m.rect.width - EPS21 && y1 - y0 >= m.rect.height - EPS21 ? [m] : [{ ...m, rect: rect18(x0, y0, x1 - x0, y1 - y0) }];
|
|
3832
3954
|
});
|
|
3833
3955
|
return marks.length === l.marks.length && marks.every((m, i) => m === l.marks[i]) ? l : { ...l, marks };
|
|
3834
3956
|
}
|
|
3835
3957
|
function settle(lane, drawn, state, dragged, all, emptyLanes = "real", within = lane.rect) {
|
|
3836
3958
|
const l = inLane(lane, within);
|
|
3837
3959
|
const edgeOf = (id) => state.edges.find((e) => e.id === id);
|
|
3838
|
-
const isDrawn = (id) => !!edgeOf(id) && (drawn
|
|
3960
|
+
const isDrawn = (id) => !!edgeOf(id) && drawnIn(drawn, id);
|
|
3839
3961
|
const across2 = (side) => side === "top" || side === "bottom" ? "x" : "y";
|
|
3840
3962
|
const cuts = [];
|
|
3841
3963
|
if (!isDrawn(l.id)) {
|
|
3842
3964
|
for (const e of state.edges) {
|
|
3843
|
-
const de =
|
|
3844
|
-
if (
|
|
3965
|
+
const de = e.id !== l.id && across2(e.side) !== l.axis ? drawnRect(drawn, e.id) : void 0;
|
|
3966
|
+
if (de) cuts.push(de);
|
|
3845
3967
|
}
|
|
3846
3968
|
if (l.axis === "y") {
|
|
3847
3969
|
for (const o of all) if (o.id !== l.id && o.axis === "x" && !isDrawn(o.id)) cuts.push(o.rect);
|
|
@@ -3852,14 +3974,14 @@ function settle(lane, drawn, state, dragged, all, emptyLanes = "real", within =
|
|
|
3852
3974
|
const e = edge ? edgeOf(edge) : void 0;
|
|
3853
3975
|
return !!e && (e.side === "top" || e.side === "bottom" || !!e.compact);
|
|
3854
3976
|
};
|
|
3855
|
-
const stays = empty ? Object.entries(drawn.items).filter(([id, it]) => id !== dragged && it.edge !== l.id && barOrRail(it.edge) && !it.floating && !it.inMenu && it.rect.width >
|
|
3977
|
+
const stays = empty ? Object.entries(drawn.items).filter(([id, it]) => id !== dragged && it.edge !== l.id && barOrRail(it.edge) && !it.floating && !it.inMenu && it.rect.width > EPS21 && it.rect.height > EPS21).map(([, it]) => it.rect) : [];
|
|
3856
3978
|
if (cuts.length === 0 && !(empty && (emptyLanes === "edge" || l.marks.some((m) => m.kind === "box" && stays.some((s) => overlaps7(m.rect, s)))))) return l;
|
|
3857
3979
|
const cut2 = (r, cs) => piecesLess(r, l.axis, cs);
|
|
3858
3980
|
const marks = [];
|
|
3859
3981
|
for (const m of l.marks) {
|
|
3860
3982
|
const kept = cut2(m.rect, m.kind === "box" ? [...cuts, ...stays] : cuts);
|
|
3861
3983
|
if (m.kind === "line") {
|
|
3862
|
-
if (kept.length === 1 && Math.abs(kept[0][1] - kept[0][0] - len(m.rect, l.axis)) <
|
|
3984
|
+
if (kept.length === 1 && Math.abs(kept[0][1] - kept[0][0] - len(m.rect, l.axis)) < EPS21) marks.push(m);
|
|
3863
3985
|
continue;
|
|
3864
3986
|
}
|
|
3865
3987
|
kept.forEach(([p, q], i) => {
|
|
@@ -3872,11 +3994,11 @@ function settle(lane, drawn, state, dragged, all, emptyLanes = "real", within =
|
|
|
3872
3994
|
if (l.axis === "y") {
|
|
3873
3995
|
const outerRight = side === "right" ? true : side === "left" ? false : Math.abs(piece.x + piece.width - (st.x + st.width)) <= Math.abs(piece.x - st.x);
|
|
3874
3996
|
const t = Math.min(HATCH_EDGE, piece.width);
|
|
3875
|
-
r =
|
|
3997
|
+
r = rect18(outerRight ? piece.x + piece.width - t : piece.x, piece.y, t, piece.height);
|
|
3876
3998
|
} else {
|
|
3877
3999
|
const outerBottom = side === "bottom" ? true : side === "top" ? false : Math.abs(piece.y + piece.height - (st.y + st.height)) <= Math.abs(piece.y - st.y);
|
|
3878
4000
|
const t = Math.min(HATCH_EDGE, piece.height);
|
|
3879
|
-
r =
|
|
4001
|
+
r = rect18(piece.x, outerBottom ? piece.y + piece.height - t : piece.y, piece.width, t);
|
|
3880
4002
|
}
|
|
3881
4003
|
marks.push({ id: id.replace("/box/", "/hatch/"), kind: "hatch", rect: r });
|
|
3882
4004
|
});
|
|
@@ -3885,55 +4007,27 @@ function settle(lane, drawn, state, dragged, all, emptyLanes = "real", within =
|
|
|
3885
4007
|
}
|
|
3886
4008
|
function piecesLess(r, axis, cs) {
|
|
3887
4009
|
const span = (x) => [lo(x, axis), lo(x, axis) + len(x, axis)];
|
|
3888
|
-
const crosses = (c) => axis === "x" ? c.y < r.y + r.height -
|
|
4010
|
+
const crosses = (c) => axis === "x" ? c.y < r.y + r.height - EPS21 && r.y < c.y + c.height - EPS21 : c.x < r.x + r.width - EPS21 && r.x < c.x + c.width - EPS21;
|
|
3889
4011
|
let ps = [span(r)];
|
|
3890
4012
|
for (const c of cs) {
|
|
3891
4013
|
if (!crosses(c)) continue;
|
|
3892
4014
|
const [c0, c1] = span(c);
|
|
3893
|
-
ps = ps.flatMap(([p, q]) => [[p, Math.min(q, c0)], [Math.max(p, c1), q]]).filter(([p, q]) => q - p >
|
|
4015
|
+
ps = ps.flatMap(([p, q]) => [[p, Math.min(q, c0)], [Math.max(p, c1), q]]).filter(([p, q]) => q - p > EPS21);
|
|
3894
4016
|
}
|
|
3895
4017
|
return ps;
|
|
3896
4018
|
}
|
|
3897
|
-
function marksLess(marks, axis, cs) {
|
|
4019
|
+
function marksLess(marks, axis, cs, options = {}) {
|
|
4020
|
+
const suffix = options.suffix ?? "~c";
|
|
4021
|
+
const minBox = options.minBox ?? 0;
|
|
3898
4022
|
return marks.flatMap((m) => {
|
|
3899
|
-
const
|
|
3900
|
-
if (
|
|
3901
|
-
const kept = piecesLess(m.rect, axis,
|
|
3902
|
-
if (m.kind === "line") return kept.length === 1 && Math.abs(kept[0][1] - kept[0][0] - len(m.rect, axis)) <
|
|
3903
|
-
return kept.map(([p, q], i) => ({ ...m, id: i ? `${m.id}
|
|
4023
|
+
const over2 = cs.filter((c) => overlaps7(m.rect, c));
|
|
4024
|
+
if (over2.length === 0) return [m];
|
|
4025
|
+
const kept = piecesLess(m.rect, axis, over2);
|
|
4026
|
+
if (m.kind === "line") return (options.lines === "covered" ? kept.length > 0 : kept.length === 1 && Math.abs(kept[0][1] - kept[0][0] - len(m.rect, axis)) < EPS21) ? [m] : [];
|
|
4027
|
+
return kept.filter(([p, q]) => m.kind !== "box" || q - p > minBox).map(([p, q], i) => ({ ...m, id: i ? `${m.id}${suffix}${i}` : m.id, rect: along(m.rect, axis, p, q) }));
|
|
3904
4028
|
});
|
|
3905
4029
|
}
|
|
3906
|
-
|
|
3907
|
-
const whole = /* @__PURE__ */ new Map();
|
|
3908
|
-
for (const l of settled) {
|
|
3909
|
-
const raws = byLane.get(l.id);
|
|
3910
|
-
if (!raws || l.spots.length !== 1 || !state.edges.some((e) => e.id === l.id) || (base.seen.edges[l.id]?.cross ?? 0) > EPS20) continue;
|
|
3911
|
-
const held = raws.find((r) => r.id === l.spots[0].id);
|
|
3912
|
-
if (!held || (held.layout.edges[l.id]?.cross ?? 0) <= EPS20) continue;
|
|
3913
|
-
const again = heldLaneIn(l.id, raws, held, base, dragged);
|
|
3914
|
-
if (!again) continue;
|
|
3915
|
-
const after = settle(again, held.layout, state, dragged, built, emptyLanes, laneRectOver(raws, held.layout, base.seen, base.marking).rect).marks;
|
|
3916
|
-
whole.set(l.id, after.length === 0 && l.marks.length > 0 ? l.marks : after);
|
|
3917
|
-
}
|
|
3918
|
-
if (whole.size === 0) return [...settled];
|
|
3919
|
-
const order = [...settled].filter((l) => whole.has(l.id)).sort((a, b) => a.axis === b.axis ? 0 : a.axis === "x" ? -1 : 1);
|
|
3920
|
-
const final = new Map(settled.filter((l) => !whole.has(l.id)).map((l) => [l.id, l.marks]));
|
|
3921
|
-
const meets = /* @__PURE__ */ new Map();
|
|
3922
|
-
for (const l of order) {
|
|
3923
|
-
const mine = whole.get(l.id);
|
|
3924
|
-
const others = [...final].filter(([id, ms]) => id !== l.id && ms.some((m) => mine.some((x) => overlaps7(x.rect, m.rect))));
|
|
3925
|
-
meets.set(l.id, others.map(([id]) => id));
|
|
3926
|
-
final.set(l.id, marksLess(mine, l.axis, others.flatMap(([, ms]) => ms.map((m) => m.rect))));
|
|
3927
|
-
}
|
|
3928
|
-
return settled.map((l) => {
|
|
3929
|
-
const marks = final.get(l.id);
|
|
3930
|
-
const mine = whole.get(l.id);
|
|
3931
|
-
if (!mine) return l;
|
|
3932
|
-
const corners = meets.get(l.id);
|
|
3933
|
-
return corners.length > 0 ? { ...l, marks, entry: mine, corners } : { ...l, marks };
|
|
3934
|
-
});
|
|
3935
|
-
}
|
|
3936
|
-
var overlaps7 = (a, b) => a.x < b.x + b.width - EPS20 && b.x < a.x + a.width - EPS20 && a.y < b.y + b.height - EPS20 && b.y < a.y + a.height - EPS20;
|
|
4030
|
+
var overlaps7 = (a, b) => a.x < b.x + b.width - EPS21 && b.x < a.x + a.width - EPS21 && a.y < b.y + b.height - EPS21 && b.y < a.y + a.height - EPS21;
|
|
3937
4031
|
function pitchedSpots(state, dragged, options, seen, lifted, raws, pitch) {
|
|
3938
4032
|
const out = [];
|
|
3939
4033
|
stretches(state, dragged, options, seen, lifted, raws, (run) => {
|
|
@@ -3958,12 +4052,12 @@ function pitchedSpots(state, dragged, options, seen, lifted, raws, pitch) {
|
|
|
3958
4052
|
};
|
|
3959
4053
|
return ({ a, b, w, zones, atOf, spaceAt, before, after }) => {
|
|
3960
4054
|
const end = (x0, order, flush) => {
|
|
3961
|
-
for (const zone of order) if (spaceAt(zone, x0) >= -
|
|
4055
|
+
for (const zone of order) if (spaceAt(zone, x0) >= -EPS21 && emit3(zone, atOf(zone), Math.max(0, spaceAt(zone, x0)), x0, flush)) return;
|
|
3962
4056
|
};
|
|
3963
4057
|
end(a, zones, before?.id ?? "^");
|
|
3964
|
-
if (b - w > a +
|
|
4058
|
+
if (b - w > a + EPS21) end(b - w, [...zones].reverse(), after?.id ?? "$");
|
|
3965
4059
|
if (b - a < w + pitch) return;
|
|
3966
|
-
for (let x0 = a + pitch; x0 + w <= b - pitch +
|
|
4060
|
+
for (let x0 = a + pitch; x0 + w <= b - pitch + EPS21; x0 += pitch) {
|
|
3967
4061
|
const zone = x0 + w / 2 < middle ? "start" : "end";
|
|
3968
4062
|
if (!zones.includes(zone)) continue;
|
|
3969
4063
|
emit3(zone, atOf(zone), spaceAt(zone, x0), x0);
|
|
@@ -4093,7 +4187,7 @@ function slidingSpots(state, dragged, options, seen, lifted, raws, sample) {
|
|
|
4093
4187
|
for (const zone2 of [near, near === "start" ? "end" : "start"]) {
|
|
4094
4188
|
if (!zones.includes(zone2)) continue;
|
|
4095
4189
|
const space = spaceAt(zone2, x0);
|
|
4096
|
-
if (space < -
|
|
4190
|
+
if (space < -EPS21) continue;
|
|
4097
4191
|
const place = { edge: e.id, zone: zone2, at: atOf(zone2), space: Math.max(0, space) };
|
|
4098
4192
|
const hit = landsAt(state, dragged, run, place, x0);
|
|
4099
4193
|
if (hit) return { place, result: { state: hit.next, layout: hit.layout } };
|
|
@@ -4101,8 +4195,8 @@ function slidingSpots(state, dragged, options, seen, lifted, raws, sample) {
|
|
|
4101
4195
|
return null;
|
|
4102
4196
|
};
|
|
4103
4197
|
const tries = [a];
|
|
4104
|
-
for (let x0 = a + sample; x0 < b - w -
|
|
4105
|
-
if (b - w > a +
|
|
4198
|
+
for (let x0 = a + sample; x0 < b - w - EPS21; x0 += sample) tries.push(x0);
|
|
4199
|
+
if (b - w > a + EPS21) tries.push(b - w);
|
|
4106
4200
|
const ok = tries.map((x0) => ({ x0, hit: land(x0) })).filter((t) => t.hit);
|
|
4107
4201
|
if (ok.length === 0) return;
|
|
4108
4202
|
const from = ok[0].x0;
|
|
@@ -4114,7 +4208,7 @@ function slidingSpots(state, dragged, options, seen, lifted, raws, sample) {
|
|
|
4114
4208
|
const firstZone = (() => {
|
|
4115
4209
|
for (const zone3 of zones) {
|
|
4116
4210
|
const space = spaceAt(zone3, from);
|
|
4117
|
-
if (space < -
|
|
4211
|
+
if (space < -EPS21) continue;
|
|
4118
4212
|
const place2 = { edge: e.id, zone: zone3, at: atOf(zone3), space: Math.max(0, space) };
|
|
4119
4213
|
const hit = landsAt(state, dragged, run, place2, from);
|
|
4120
4214
|
if (hit) return { place: place2, result: { state: hit.next, layout: hit.layout } };
|
|
@@ -4191,7 +4285,7 @@ function slidingSpots(state, dragged, options, seen, lifted, raws, sample) {
|
|
|
4191
4285
|
place: { kind: "gap", edge: e.id, zone: restPlace?.zone ?? zones[0], at: restPlace?.at ?? atOf(zones[0]), ...restPlace?.space ? { space: restPlace.space } : {} },
|
|
4192
4286
|
after: (point, grab) => {
|
|
4193
4287
|
const g = grab ? grab[long] : ownLen / 2;
|
|
4194
|
-
const share = axis === long && ownLen >
|
|
4288
|
+
const share = axis === long && ownLen > EPS21 && Number.isFinite(g) ? clamp2(g / ownLen, 0, 1) : 0.5;
|
|
4195
4289
|
return commitAt(startAt((axis === "x" ? point.x : point.y) - share * w));
|
|
4196
4290
|
}
|
|
4197
4291
|
};
|
|
@@ -4215,6 +4309,109 @@ function slidingSpots(state, dragged, options, seen, lifted, raws, sample) {
|
|
|
4215
4309
|
return { spots, absorbed };
|
|
4216
4310
|
}
|
|
4217
4311
|
|
|
4312
|
+
// src/drag.ts
|
|
4313
|
+
import { EPS as EPS22 } from "@n-uf/placement";
|
|
4314
|
+
var MIN_PIECE = 8;
|
|
4315
|
+
var ORIGIN2 = { x: 0, y: 0 };
|
|
4316
|
+
function dockDrag(state, dragged, options = {}) {
|
|
4317
|
+
const base = baseOf(state, dragged, options);
|
|
4318
|
+
const regions = { ...base.regions, lanes: base.lanes };
|
|
4319
|
+
const grab = options.grab;
|
|
4320
|
+
const byResult = /* @__PURE__ */ new WeakMap();
|
|
4321
|
+
const fixed = /* @__PURE__ */ new Map();
|
|
4322
|
+
const axisOf2 = new Map(base.lanes.map((l) => [l.id, l.axis]));
|
|
4323
|
+
const flat = (ls) => ls.flatMap((l) => l.marks.map((m) => ({ ...m, lane: l.lane })));
|
|
4324
|
+
const rest = { state, layout: base.seen, landing: null, marks: flat(base.lanes.map((l) => ({ lane: l.id, axis: l.axis, marks: l.marks }))) };
|
|
4325
|
+
let lastFloat = null;
|
|
4326
|
+
const of = (result, spot) => {
|
|
4327
|
+
const known = byResult.get(result);
|
|
4328
|
+
if (known) return known;
|
|
4329
|
+
const it = result.layout.items[dragged];
|
|
4330
|
+
const landing = it && !it.inMenu && (spot ? !it.floating : it.floating) ? it.rect : null;
|
|
4331
|
+
const spots = spot ? spotsIn(base, spot.lane, result.layout, dragged) : null;
|
|
4332
|
+
const out = { ...result, landing, marks: flat(marksIn(base, state, dragged, result.layout, spot ? spot.slide ? "slide" : "spot" : false, options.emptyLanes)), ...spots ? { spots } : {} };
|
|
4333
|
+
byResult.set(result, out);
|
|
4334
|
+
return out;
|
|
4335
|
+
};
|
|
4336
|
+
const after = (held) => {
|
|
4337
|
+
if (!held) return rest;
|
|
4338
|
+
if (held.kind === "float") {
|
|
4339
|
+
const float = base.regions.float;
|
|
4340
|
+
if (!float) return rest;
|
|
4341
|
+
if (lastFloat && lastFloat.x === held.point.x && lastFloat.y === held.point.y) return lastFloat.after;
|
|
4342
|
+
const a2 = of(float.after(held.point, grab), null);
|
|
4343
|
+
lastFloat = { x: held.point.x, y: held.point.y, after: a2 };
|
|
4344
|
+
return a2;
|
|
4345
|
+
}
|
|
4346
|
+
const raw = rawSpot(base, held.spot);
|
|
4347
|
+
if (!raw) return rest;
|
|
4348
|
+
if (raw.slide) return of(raw.target.after(held.point, grab), raw);
|
|
4349
|
+
let a = fixed.get(held.spot);
|
|
4350
|
+
if (!a) fixed.set(held.spot, a = of(raw.target.after(ORIGIN2, ORIGIN2), raw));
|
|
4351
|
+
return a;
|
|
4352
|
+
};
|
|
4353
|
+
const createdMemo = /* @__PURE__ */ new Map();
|
|
4354
|
+
const created = (lane) => {
|
|
4355
|
+
if (createdMemo.has(lane)) return createdMemo.get(lane);
|
|
4356
|
+
const l = base.lanes.find((x) => x.id === lane);
|
|
4357
|
+
const raw = l && options.emptyLanes !== "edge" && l.spots.length === 1 && state.edges.some((e) => e.id === lane) ? rawSpot(base, l.spots[0].id) : null;
|
|
4358
|
+
const out = raw && drawnIn(raw.layout, lane) ? flat(marksIn(base, state, dragged, raw.layout, false, options.emptyLanes)).filter((m) => m.lane === lane) : null;
|
|
4359
|
+
createdMemo.set(lane, out && out.length > 0 ? out : null);
|
|
4360
|
+
return createdMemo.get(lane);
|
|
4361
|
+
};
|
|
4362
|
+
const landingOf = (held) => after(held).landing;
|
|
4363
|
+
const spotsOf = (spot) => {
|
|
4364
|
+
const raw = rawSpot(base, spot);
|
|
4365
|
+
return raw && !raw.slide ? after({ kind: "spot", spot, point: ORIGIN2 }).spots ?? null : raw ? spotsIn(base, raw.lane, raw.layout, dragged) : null;
|
|
4366
|
+
};
|
|
4367
|
+
const screenOf = (frame) => {
|
|
4368
|
+
const held = after(frame.held);
|
|
4369
|
+
if (frame.room || held === rest) return held;
|
|
4370
|
+
return held.landing ? { ...rest, landing: held.landing } : rest;
|
|
4371
|
+
};
|
|
4372
|
+
const shownLayout = (frame) => screenOf(frame).layout;
|
|
4373
|
+
const guides = (frame) => {
|
|
4374
|
+
if (frame.guides.length === 0) return [];
|
|
4375
|
+
const held = after(frame.held);
|
|
4376
|
+
const screen = screenOf(frame);
|
|
4377
|
+
let near = null;
|
|
4378
|
+
const shown = [];
|
|
4379
|
+
const drawnThere = (id) => drawnIn(screen.layout, id);
|
|
4380
|
+
for (const g of frame.guides) {
|
|
4381
|
+
const mine = after(g.held);
|
|
4382
|
+
if (mine === held) {
|
|
4383
|
+
const own2 = screen.marks.filter((m) => m.lane === g.lane);
|
|
4384
|
+
const edgeless = !state.edges.some((e) => e.id === g.lane);
|
|
4385
|
+
const made2 = edgeless ? own2 : !drawnThere(g.lane) ? created(g.lane) : null;
|
|
4386
|
+
shown.push(made2 ? { lane: g.lane, marks: made2, created: true } : { lane: g.lane, marks: own2 });
|
|
4387
|
+
continue;
|
|
4388
|
+
}
|
|
4389
|
+
const onScreen2 = drawnThere(g.lane);
|
|
4390
|
+
const axis2 = axisOf2.get(g.lane) ?? "x";
|
|
4391
|
+
const own = screen.marks.filter((m) => m.lane === g.lane);
|
|
4392
|
+
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);
|
|
4393
|
+
near = { lane: g.lane, marks };
|
|
4394
|
+
shown.push(near);
|
|
4395
|
+
}
|
|
4396
|
+
const drawnStays = [
|
|
4397
|
+
...state.edges.filter((e) => (e.side === "top" || e.side === "bottom" || !!e.compact) && (screen.layout.edges[e.id]?.cross ?? 0) > EPS22).map((e) => screen.layout.edges[e.id].rect),
|
|
4398
|
+
...Object.values(screen.layout.rails).flatMap((r) => r?.segments.filter((g) => g.id !== dragged).map((g) => g.rect) ?? [])
|
|
4399
|
+
];
|
|
4400
|
+
const onScreen = [...shown.filter((s) => !s.created && s !== near).flatMap((s) => s.marks.map((m) => m.rect)), ...drawnStays, ...screen.landing ? [screen.landing] : []];
|
|
4401
|
+
const axis = (id) => axisOf2.get(id) ?? "x";
|
|
4402
|
+
const made = shown.filter((s) => s.created).sort((a, b) => axis(a.lane) === axis(b.lane) ? 0 : axis(a.lane) === "x" ? -1 : 1);
|
|
4403
|
+
const kept = [];
|
|
4404
|
+
for (const s of made) {
|
|
4405
|
+
s.marks = marksLess(s.marks, axis(s.lane), [...onScreen, ...kept]);
|
|
4406
|
+
kept.push(...s.marks.map((m) => m.rect));
|
|
4407
|
+
}
|
|
4408
|
+
if (!near) return shown.flatMap((s) => s.marks);
|
|
4409
|
+
const cut2 = near.marks.map((m) => m.rect);
|
|
4410
|
+
return shown.flatMap((s) => s === near ? s.marks : marksLess(s.marks, axis(s.lane), cut2));
|
|
4411
|
+
};
|
|
4412
|
+
return { regions, after, landingOf, spotsOf, shown: shownLayout, guides };
|
|
4413
|
+
}
|
|
4414
|
+
|
|
4218
4415
|
export {
|
|
4219
4416
|
SIDES,
|
|
4220
4417
|
ZONES,
|
|
@@ -4246,6 +4443,10 @@ export {
|
|
|
4246
4443
|
virtualEdgeId,
|
|
4247
4444
|
placeTargetId,
|
|
4248
4445
|
solve,
|
|
4446
|
+
dividers,
|
|
4447
|
+
resizeBetween,
|
|
4448
|
+
resetBetween,
|
|
4449
|
+
resetLengths,
|
|
4249
4450
|
fitResize,
|
|
4250
4451
|
mergeSideColumns,
|
|
4251
4452
|
liftItem,
|
|
@@ -4275,6 +4476,7 @@ export {
|
|
|
4275
4476
|
SPOT_PITCH,
|
|
4276
4477
|
lanes,
|
|
4277
4478
|
HATCH_END,
|
|
4278
|
-
HATCH_EDGE
|
|
4479
|
+
HATCH_EDGE,
|
|
4480
|
+
dockDrag
|
|
4279
4481
|
};
|
|
4280
|
-
//# sourceMappingURL=chunk-
|
|
4482
|
+
//# sourceMappingURL=chunk-4V35LE5X.js.map
|