@n-uf/placement 26.11.53 → 26.11.54
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 +75 -1
- package/README.md +27 -58
- package/dist/{chunk-VLTYJHUA.js → chunk-2UVUFEBP.js} +4 -8
- package/dist/{chunk-VLTYJHUA.js.map → chunk-2UVUFEBP.js.map} +1 -1
- package/dist/{geometry-Bf37LbCT.d.ts → geometry-L5gCoiZV.d.ts} +2 -8
- package/dist/index.d.ts +64 -42
- package/dist/index.js +6 -66
- package/dist/index.js.map +1 -1
- package/dist/popup.d.ts +49 -0
- package/dist/popup.js +58 -0
- package/dist/popup.js.map +1 -0
- package/dist/stack.d.ts +529 -228
- package/dist/stack.js +701 -28
- package/dist/stack.js.map +1 -1
- package/dist/tiling.d.ts +48 -5
- package/dist/tiling.js +198 -19
- package/dist/tiling.js.map +1 -1
- package/package.json +9 -36
- package/dist/chunk-2GGJ4GVR.js +0 -9
- package/dist/chunk-2GGJ4GVR.js.map +0 -1
- package/dist/chunk-3ZICYLWL.js +0 -791
- package/dist/chunk-3ZICYLWL.js.map +0 -1
- package/dist/chunk-AE3BWTAE.js +0 -838
- package/dist/chunk-AE3BWTAE.js.map +0 -1
- package/dist/chunk-JVAR67OL.js +0 -172
- package/dist/chunk-JVAR67OL.js.map +0 -1
- package/dist/chunk-NF7RYK3U.js +0 -429
- package/dist/chunk-NF7RYK3U.js.map +0 -1
- package/dist/chunk-R3AAANRY.js +0 -220
- package/dist/chunk-R3AAANRY.js.map +0 -1
- package/dist/chunk-TWI644JK.js +0 -221
- package/dist/chunk-TWI644JK.js.map +0 -1
- package/dist/chunk-ZTH5FCUO.js +0 -4190
- package/dist/chunk-ZTH5FCUO.js.map +0 -1
- package/dist/constructions-Cbz7uEAZ.d.ts +0 -251
- package/dist/desk.d.ts +0 -51
- package/dist/desk.js +0 -111
- package/dist/desk.js.map +0 -1
- package/dist/dock.d.ts +0 -25
- package/dist/dock.js +0 -397
- package/dist/dock.js.map +0 -1
- package/dist/float-fit-DCYxRMru.d.ts +0 -37
- package/dist/lanes-DIwUqchd.d.ts +0 -1321
- package/dist/model-X7eUaKlA.d.ts +0 -337
- package/dist/panels.d.ts +0 -60
- package/dist/panels.js +0 -99
- package/dist/panels.js.map +0 -1
- package/dist/regions-Db_RyT4P.d.ts +0 -48
- package/dist/scene-cases.d.ts +0 -888
- package/dist/scene-cases.js +0 -3149
- package/dist/scene-cases.js.map +0 -1
- package/dist/scene.d.ts +0 -290
- package/dist/scene.js +0 -128
- package/dist/scene.js.map +0 -1
- package/dist/target-BBOCeez2.d.ts +0 -69
- package/dist/targets-C9ZVhmCl.d.ts +0 -621
- package/dist/targets.d.ts +0 -212
- package/dist/targets.js +0 -447
- package/dist/targets.js.map +0 -1
- package/dist/toolbar.d.ts +0 -167
- package/dist/toolbar.js +0 -55
- package/dist/toolbar.js.map +0 -1
package/dist/chunk-3ZICYLWL.js
DELETED
|
@@ -1,791 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
COLUMN_REACH,
|
|
3
|
-
RAIL_EDGE,
|
|
4
|
-
clamp,
|
|
5
|
-
rect
|
|
6
|
-
} from "./chunk-VLTYJHUA.js";
|
|
7
|
-
|
|
8
|
-
// src/panels/model.ts
|
|
9
|
-
var SIDES = ["left", "right"];
|
|
10
|
-
var EDGES = ["top", "bottom"];
|
|
11
|
-
var BAND_SIZE = { min: 120, max: 480, natural: 200 };
|
|
12
|
-
var IDENTITY_VIEW = { x: 0, y: 0, scale: 1 };
|
|
13
|
-
var DEFAULT_PANELS_OPTIONS = {
|
|
14
|
-
giveWay: { order: "oldest", by: "used" },
|
|
15
|
-
floats: "clamp",
|
|
16
|
-
fold: "rail",
|
|
17
|
-
floatVisible: 48,
|
|
18
|
-
pagesMin: 320,
|
|
19
|
-
view: IDENTITY_VIEW,
|
|
20
|
-
bar: 28,
|
|
21
|
-
rail: 36,
|
|
22
|
-
segment: 36,
|
|
23
|
-
railInset: 4,
|
|
24
|
-
tabs: 28,
|
|
25
|
-
bands: {},
|
|
26
|
-
pagesMinHeight: 240,
|
|
27
|
-
reserve: {}
|
|
28
|
-
};
|
|
29
|
-
var FLOAT_HEIGHT = 360;
|
|
30
|
-
var FLOAT_MIN = { width: 160, height: 120 };
|
|
31
|
-
var without = (list, x) => list.filter((y) => y !== x);
|
|
32
|
-
var withOnce = (list, x) => list.includes(x) ? [...list] : [...list, x];
|
|
33
|
-
function whereIs(state, id) {
|
|
34
|
-
for (const side of SIDES) {
|
|
35
|
-
const index = state.sides[side].findIndex((c) => c.panels.includes(id));
|
|
36
|
-
if (index >= 0) return { kind: "column", side, index };
|
|
37
|
-
}
|
|
38
|
-
for (const edge of EDGES) {
|
|
39
|
-
const index = state.bands?.[edge]?.panels.indexOf(id) ?? -1;
|
|
40
|
-
if (index >= 0) return { kind: "band", edge, index };
|
|
41
|
-
}
|
|
42
|
-
const float2 = state.floats.find((f) => f.id === id);
|
|
43
|
-
return float2 ? { kind: "float", float: float2 } : { kind: "none" };
|
|
44
|
-
}
|
|
45
|
-
var tick = (state) => Object.values(state.clock).reduce((m, c) => Math.max(m, c.opened, c.used), 0) + 1;
|
|
46
|
-
var bump = (state, id, opened) => {
|
|
47
|
-
const t = tick(state);
|
|
48
|
-
const was = state.clock[id] ?? { opened: 0, used: 0 };
|
|
49
|
-
return { ...state, clock: { ...state.clock, [id]: { opened: opened ? t : was.opened, used: t } } };
|
|
50
|
-
};
|
|
51
|
-
var defOf = (defs, id) => defs.find((d) => d.id === id);
|
|
52
|
-
function floatSize(def) {
|
|
53
|
-
if (def?.float) return { min: def.float.min, natural: def.float.natural };
|
|
54
|
-
const width = Math.max(FLOAT_MIN.width, def?.width.natural ?? FLOAT_MIN.width);
|
|
55
|
-
return { min: FLOAT_MIN, natural: { width, height: FLOAT_HEIGHT } };
|
|
56
|
-
}
|
|
57
|
-
var bandSize = (def) => ({ ...def?.band ?? BAND_SIZE });
|
|
58
|
-
function bandHeight(defs, band) {
|
|
59
|
-
if (!defs) return band.height;
|
|
60
|
-
const ds = band.panels.map((id) => bandSize(defOf(defs, id)));
|
|
61
|
-
const lo = Math.max(0, ...ds.map((d) => d.min));
|
|
62
|
-
const hi = Math.max(lo, Math.min(...ds.map((d) => d.max)));
|
|
63
|
-
return Math.min(Math.max(Number.isFinite(band.height) ? band.height : lo, lo), hi);
|
|
64
|
-
}
|
|
65
|
-
var withBand = (state, edge, band) => {
|
|
66
|
-
const { bands: _b, ...rest } = state;
|
|
67
|
-
const bands = { ...state.bands };
|
|
68
|
-
if (band && band.panels.length) bands[edge] = band;
|
|
69
|
-
else delete bands[edge];
|
|
70
|
-
return EDGES.some((e) => bands[e]) ? { ...rest, bands } : rest;
|
|
71
|
-
};
|
|
72
|
-
function ownWidth(defs, state, id) {
|
|
73
|
-
const def = defOf(defs, id);
|
|
74
|
-
const w = whereIs(state, id);
|
|
75
|
-
const lo = def?.width.min ?? 0;
|
|
76
|
-
const hi = Math.max(lo, def?.width.max ?? Infinity);
|
|
77
|
-
if (w.kind === "column") return Math.min(Math.max(state.sides[w.side][w.index].width, lo), hi);
|
|
78
|
-
return def?.width.natural ?? lo;
|
|
79
|
-
}
|
|
80
|
-
function createPanels(defs, start) {
|
|
81
|
-
const column = (ids) => {
|
|
82
|
-
const ds = ids.map((id) => defOf(defs, id));
|
|
83
|
-
const lo = Math.max(0, ...ds.map((d) => d?.width.min ?? 0));
|
|
84
|
-
const hi = Math.max(lo, Math.min(...ds.map((d) => d?.width.max ?? Infinity)));
|
|
85
|
-
const natural = Math.max(0, ...ds.map((d) => d?.width.natural ?? 0));
|
|
86
|
-
return { panels: [...ids], width: Math.min(Math.max(natural, lo), hi) };
|
|
87
|
-
};
|
|
88
|
-
const floats = (start.floats ?? []).map((f) => {
|
|
89
|
-
const n = floatSize(defOf(defs, f.id)).natural;
|
|
90
|
-
return { id: f.id, rect: { x: f.x, y: f.y, width: f.width ?? n.width, height: f.height ?? n.height }, ...f.pinned ? { pinned: true } : {} };
|
|
91
|
-
});
|
|
92
|
-
const sides = { left: (start.left ?? []).map(column), right: (start.right ?? []).map(column) };
|
|
93
|
-
const bands = {};
|
|
94
|
-
for (const edge of EDGES) {
|
|
95
|
-
const ids = start[edge] ?? [];
|
|
96
|
-
if (!ids.length) continue;
|
|
97
|
-
const natural = Math.max(0, ...ids.map((id) => bandSize(defOf(defs, id)).natural));
|
|
98
|
-
bands[edge] = { panels: [...ids], height: bandHeight(defs, { panels: ids, height: natural }) };
|
|
99
|
-
}
|
|
100
|
-
const order = [...sides.left, ...sides.right].flatMap((c) => c.panels).concat(EDGES.flatMap((e) => bands[e]?.panels ?? [])).concat(floats.map((f) => f.id));
|
|
101
|
-
const clock = {};
|
|
102
|
-
order.forEach((id, i) => clock[id] = { opened: i + 1, used: i + 1 });
|
|
103
|
-
const s = { sides, floats, folded: [...start.folded ?? []], kept: [...start.kept ?? []], closed: [...start.closed ?? []], clock };
|
|
104
|
-
return EDGES.some((e) => bands[e]) ? { ...s, bands } : s;
|
|
105
|
-
}
|
|
106
|
-
function liftPanel(state, id) {
|
|
107
|
-
const out = (c) => {
|
|
108
|
-
const { active: _a, ...rest } = c;
|
|
109
|
-
return { ...c.active === id ? rest : c, panels: without(c.panels, id) };
|
|
110
|
-
};
|
|
111
|
-
const lift = (cols) => cols.map(out).filter((c) => c.panels.length > 0);
|
|
112
|
-
let s = { ...state, sides: { left: lift(state.sides.left), right: lift(state.sides.right) }, floats: state.floats.filter((f) => f.id !== id) };
|
|
113
|
-
for (const edge of EDGES) {
|
|
114
|
-
const b = s.bands?.[edge];
|
|
115
|
-
if (b?.panels.includes(id)) s = withBand(s, edge, { ...b, panels: without(b.panels, id) });
|
|
116
|
-
}
|
|
117
|
-
return s;
|
|
118
|
-
}
|
|
119
|
-
function open(state, id, at) {
|
|
120
|
-
let s = { ...state, closed: without(state.closed, id) };
|
|
121
|
-
if (at && whereIs(s, id).kind === "none") {
|
|
122
|
-
if ("edge" in at) {
|
|
123
|
-
const b = s.bands?.[at.edge];
|
|
124
|
-
const panels = [...b?.panels ?? [], id];
|
|
125
|
-
s = withBand({ ...s, folded: s.folded.filter((x) => !panels.includes(x)) }, at.edge, { panels, height: b?.height ?? at.height ?? BAND_SIZE.natural });
|
|
126
|
-
} else s = { ...s, sides: { ...s.sides, [at.side]: [...s.sides[at.side], { panels: [id], width: at.width }] } };
|
|
127
|
-
}
|
|
128
|
-
const w = whereIs(s, id);
|
|
129
|
-
if (w.kind === "column" && s.sides[w.side][w.index].show === "tabs") s = { ...s, sides: { ...s.sides, [w.side]: s.sides[w.side].map((c, i) => i === w.index ? { ...c, active: id } : c) } };
|
|
130
|
-
return bump(s, id, true);
|
|
131
|
-
}
|
|
132
|
-
var close = (state, id) => ({ ...state, closed: withOnce(state.closed, id), kept: without(state.kept, id) });
|
|
133
|
-
function focus(state, id) {
|
|
134
|
-
const f = state.floats.find((x) => x.id === id);
|
|
135
|
-
const s = f ? { ...state, floats: [...state.floats.filter((x) => x !== f), f] } : state;
|
|
136
|
-
return bump(s, id, false);
|
|
137
|
-
}
|
|
138
|
-
function toggleFold(state, id) {
|
|
139
|
-
const w = whereIs(state, id);
|
|
140
|
-
if (w.kind === "band") {
|
|
141
|
-
const ids = state.bands[w.edge].panels;
|
|
142
|
-
const shown = ids.filter((x) => !state.closed.includes(x));
|
|
143
|
-
if ((shown.length ? shown : ids).every((x) => state.folded.includes(x))) return bump({ ...state, folded: state.folded.filter((x) => !ids.includes(x)) }, id, false);
|
|
144
|
-
return { ...state, folded: [...state.folded.filter((x) => !ids.includes(x)), ...ids] };
|
|
145
|
-
}
|
|
146
|
-
if (state.folded.includes(id)) return bump({ ...state, folded: without(state.folded, id) }, id, false);
|
|
147
|
-
return { ...state, folded: [...state.folded, id] };
|
|
148
|
-
}
|
|
149
|
-
function keep(state, id, on) {
|
|
150
|
-
if (!on) return { ...state, kept: without(state.kept, id) };
|
|
151
|
-
const k = whereIs(state, id).kind;
|
|
152
|
-
return k === "column" || k === "band" ? { ...state, kept: withOnce(state.kept, id) } : state;
|
|
153
|
-
}
|
|
154
|
-
function dockBand(state, id, edge, index, defs) {
|
|
155
|
-
const s = liftPanel(state, id);
|
|
156
|
-
const b = s.bands?.[edge];
|
|
157
|
-
const panels = [...b?.panels ?? []];
|
|
158
|
-
panels.splice(Math.max(0, Math.min(index, panels.length)), 0, id);
|
|
159
|
-
const height = b?.height ?? bandSize(defs ? defOf(defs, id) : void 0).natural;
|
|
160
|
-
const s1 = withBand(s, edge, { panels, height });
|
|
161
|
-
return bump({ ...s1, folded: s1.folded.filter((x) => !panels.includes(x)), closed: without(s1.closed, id) }, id, false);
|
|
162
|
-
}
|
|
163
|
-
function resizeBand(state, edge, height) {
|
|
164
|
-
const b = state.bands?.[edge];
|
|
165
|
-
if (!b || !Number.isFinite(height)) return state;
|
|
166
|
-
const t = tick(state);
|
|
167
|
-
const clock = { ...state.clock };
|
|
168
|
-
for (const id of b.panels) clock[id] = { opened: clock[id]?.opened ?? 0, used: t };
|
|
169
|
-
return { ...withBand(state, edge, { ...b, height: Math.max(0, height) }), clock };
|
|
170
|
-
}
|
|
171
|
-
function dock(state, id, side, index, options = {}) {
|
|
172
|
-
const w = whereIs(state, id);
|
|
173
|
-
const from = w.kind === "column" ? state.sides[w.side][w.index].width : 0;
|
|
174
|
-
const s = liftPanel(state, id);
|
|
175
|
-
const cols = [...s.sides[side]];
|
|
176
|
-
if (options.into && cols[index]) {
|
|
177
|
-
const panels = [...cols[index].panels];
|
|
178
|
-
const at = typeof options.at === "number" && !Number.isNaN(options.at) ? Math.max(0, Math.min(Math.floor(options.at), panels.length)) : panels.length;
|
|
179
|
-
panels.splice(at, 0, id);
|
|
180
|
-
cols[index] = { ...cols[index], panels, ...cols[index].show === "tabs" ? { active: id } : {} };
|
|
181
|
-
} else {
|
|
182
|
-
const at = Math.max(0, Math.min(index, cols.length));
|
|
183
|
-
cols.splice(at, 0, { panels: [id], width: options.width ?? from });
|
|
184
|
-
}
|
|
185
|
-
return bump({ ...s, sides: { ...s.sides, [side]: cols }, closed: without(s.closed, id) }, id, false);
|
|
186
|
-
}
|
|
187
|
-
function showTabs(state, side, index, on) {
|
|
188
|
-
const col = state.sides[side][index];
|
|
189
|
-
if (!col) return state;
|
|
190
|
-
const { show: _s, ...stack } = col;
|
|
191
|
-
return { ...state, sides: { ...state.sides, [side]: state.sides[side].map((c, i) => i === index ? on ? { ...col, show: "tabs" } : stack : c) } };
|
|
192
|
-
}
|
|
193
|
-
function activate(state, id) {
|
|
194
|
-
const w = whereIs(state, id);
|
|
195
|
-
if (w.kind !== "column") return state;
|
|
196
|
-
const sides = { ...state.sides, [w.side]: state.sides[w.side].map((c, i) => i === w.index ? { ...c, active: id } : c) };
|
|
197
|
-
return bump({ ...state, sides }, id, false);
|
|
198
|
-
}
|
|
199
|
-
function float(state, id, rect2, pinned) {
|
|
200
|
-
const was = state.floats.find((f2) => f2.id === id);
|
|
201
|
-
const on = pinned ?? !!was?.pinned;
|
|
202
|
-
const s = liftPanel(state, id);
|
|
203
|
-
const f = { id, rect: { ...rect2 }, ...on ? { pinned: true } : {} };
|
|
204
|
-
return bump({ ...s, floats: [...s.floats, f], kept: without(s.kept, id), closed: without(s.closed, id) }, id, false);
|
|
205
|
-
}
|
|
206
|
-
var toView = (r, v) => ({ ...r, x: v.x + r.x * v.scale, y: v.y + r.y * v.scale });
|
|
207
|
-
var toPage = (r, v) => ({ ...r, x: (r.x - v.x) / v.scale, y: (r.y - v.y) / v.scale });
|
|
208
|
-
function pin(state, id, on, view = IDENTITY_VIEW, shown) {
|
|
209
|
-
return {
|
|
210
|
-
...state,
|
|
211
|
-
floats: state.floats.map((f) => {
|
|
212
|
-
if (f.id !== id || !!f.pinned === on) return f;
|
|
213
|
-
const seen = shown ? { ...f.rect, x: shown.x, y: shown.y } : f.pinned ? { ...f.rect } : toView(f.rect, view);
|
|
214
|
-
return on ? { id, rect: seen, pinned: true } : { id, rect: toPage(seen, view) };
|
|
215
|
-
})
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
function resizeColumn(state, side, index, width) {
|
|
219
|
-
const col = state.sides[side][index];
|
|
220
|
-
if (!col || !Number.isFinite(width)) return state;
|
|
221
|
-
const t = tick(state);
|
|
222
|
-
const clock = { ...state.clock };
|
|
223
|
-
for (const id of col.panels) clock[id] = { opened: clock[id]?.opened ?? 0, used: t };
|
|
224
|
-
return { ...state, sides: { ...state.sides, [side]: state.sides[side].map((c, i) => i === index ? { ...c, width: Math.max(0, width) } : c) }, clock };
|
|
225
|
-
}
|
|
226
|
-
function resizeFloat(state, id, rect2) {
|
|
227
|
-
if (!state.floats.some((f) => f.id === id)) return state;
|
|
228
|
-
return bump({ ...state, floats: state.floats.map((f) => f.id === id ? { ...f, rect: { ...rect2 } } : f) }, id, false);
|
|
229
|
-
}
|
|
230
|
-
function columnWidth(defs, col) {
|
|
231
|
-
if (!defs) return col.width;
|
|
232
|
-
const ds = col.panels.map((id) => defOf(defs, id));
|
|
233
|
-
const lo = Math.max(0, ...ds.map((d) => d?.width.min ?? 0));
|
|
234
|
-
const hi = Math.max(lo, Math.min(...ds.map((d) => d?.width.max ?? Infinity)));
|
|
235
|
-
return Math.min(Math.max(Number.isFinite(col.width) ? col.width : lo, lo), hi);
|
|
236
|
-
}
|
|
237
|
-
function samePlaces(a, b, defs) {
|
|
238
|
-
const cols = (s) => SIDES.map(
|
|
239
|
-
(side) => s.sides[side].map((c) => `${c.panels.join(",")}@${Math.round(columnWidth(defs, c))}${c.show === "tabs" ? `/tabs:${c.active ?? c.panels[0]}` : ""}`).join("|")
|
|
240
|
-
).join("\u2016");
|
|
241
|
-
const fl = (s) => s.floats.map((f) => `${f.id}@${Math.round(f.rect.x)},${Math.round(f.rect.y)},${Math.round(f.rect.width)},${Math.round(f.rect.height)}${f.pinned ? "p" : ""}`).join("|");
|
|
242
|
-
const bs = (s) => EDGES.map((e) => {
|
|
243
|
-
const b2 = s.bands?.[e];
|
|
244
|
-
return b2 ? `${b2.panels.join(",")}@${Math.round(bandHeight(defs, b2))}` : "";
|
|
245
|
-
}).join("\u2016");
|
|
246
|
-
const set = (l) => [...l].sort().join(",");
|
|
247
|
-
return cols(a) === cols(b) && bs(a) === bs(b) && fl(a) === fl(b) && set(a.folded) === set(b.folded) && set(a.kept) === set(b.kept) && set(a.closed) === set(b.closed);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// src/panels/layout.ts
|
|
251
|
-
function giveWayOrder(cols, order) {
|
|
252
|
-
return [...cols].sort((a, b) => Number(a.kept) - Number(b.kept) || (order === "oldest" ? a.age - b.age : b.age - a.age) || a.index - b.index || SIDES.indexOf(a.side) - SIDES.indexOf(b.side));
|
|
253
|
-
}
|
|
254
|
-
function layoutPanels(defs, state, stage, options = {}) {
|
|
255
|
-
const opt = { ...DEFAULT_PANELS_OPTIONS, ...options };
|
|
256
|
-
const W = stage.width;
|
|
257
|
-
const H = stage.height;
|
|
258
|
-
const closed = new Set(state.closed);
|
|
259
|
-
const folded = new Set(state.folded);
|
|
260
|
-
const kept = new Set(state.kept);
|
|
261
|
-
const by = opt.giveWay.by;
|
|
262
|
-
const ride = opt.fold === "ride";
|
|
263
|
-
const px = (v) => typeof v === "number" && Number.isFinite(v) ? Math.max(0, v) : 0;
|
|
264
|
-
const reserveOpt = opt.reserve ?? {};
|
|
265
|
-
const bandOpts = opt.bands ?? {};
|
|
266
|
-
const minH = typeof opt.pagesMinHeight === "number" ? opt.pagesMinHeight : DEFAULT_PANELS_OPTIONS.pagesMinHeight;
|
|
267
|
-
const res = { top: px(reserveOpt.top), right: px(reserveOpt.right), bottom: px(reserveOpt.bottom), left: px(reserveOpt.left) };
|
|
268
|
-
const bandsIn = [];
|
|
269
|
-
const offNotes = [];
|
|
270
|
-
for (const edge of EDGES) {
|
|
271
|
-
const b = state.bands?.[edge];
|
|
272
|
-
if (!b) continue;
|
|
273
|
-
const panels = b.panels.filter((id) => !closed.has(id));
|
|
274
|
-
if (panels.length === 0) continue;
|
|
275
|
-
const o = bandOpts[edge];
|
|
276
|
-
if (!o) {
|
|
277
|
-
offNotes.push({ code: "band-off", edge, items: panels });
|
|
278
|
-
continue;
|
|
279
|
-
}
|
|
280
|
-
const ds = panels.map((id) => bandSize(defOf(defs, id)));
|
|
281
|
-
const min = Math.max(0, ...ds.map((d) => d.min));
|
|
282
|
-
const max = Math.max(min, Math.min(...ds.map((d) => d.max)));
|
|
283
|
-
const height = clamp(Number.isFinite(b.height) ? b.height : min, min, max);
|
|
284
|
-
const age = Math.max(...panels.map((id) => state.clock[id]?.[by] ?? 0));
|
|
285
|
-
bandsIn.push({ edge, panels, at: panels.map((id) => b.panels.indexOf(id)), min, max, height, hand: panels.every((id) => folded.has(id)), kept: panels.some((id) => kept.has(id)), age, mode: o.mode, span: o.span });
|
|
286
|
-
}
|
|
287
|
-
const bOrder = bandsIn.filter((b) => !b.hand).sort((a, b) => Number(a.kept) - Number(b.kept) || (opt.giveWay.order === "oldest" ? a.age - b.age : b.age - a.age) || EDGES.indexOf(b.edge) - EDGES.indexOf(a.edge));
|
|
288
|
-
const gh = { auto: /* @__PURE__ */ new Set(), heights: /* @__PURE__ */ new Map() };
|
|
289
|
-
const fitH = (list, room) => {
|
|
290
|
-
const order2 = bOrder.filter((b) => list.includes(b));
|
|
291
|
-
const hands = list.length - order2.length;
|
|
292
|
-
const fit2 = (k) => {
|
|
293
|
-
const auto = new Set(order2.slice(0, k));
|
|
294
|
-
const heights = new Map(order2.filter((b) => !auto.has(b)).map((b) => [b, b.height]));
|
|
295
|
-
let excess = [...heights.values()].reduce((a, b) => a + b, 0) + (hands + auto.size) * opt.bar - room;
|
|
296
|
-
for (const b of order2) {
|
|
297
|
-
if (excess <= 0 || auto.has(b)) continue;
|
|
298
|
-
const take = Math.min(excess, b.height - b.min);
|
|
299
|
-
if (take > 0) {
|
|
300
|
-
heights.set(b, b.height - take);
|
|
301
|
-
excess -= take;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
return { auto, heights, excess };
|
|
305
|
-
};
|
|
306
|
-
let g2 = fit2(0);
|
|
307
|
-
for (let k = 1; g2.excess > 0 && k <= order2.length; k++) g2 = fit2(k);
|
|
308
|
-
for (const b of g2.auto) gh.auto.add(b);
|
|
309
|
-
for (const [b, h] of g2.heights) gh.heights.set(b, h);
|
|
310
|
-
};
|
|
311
|
-
const reservedIn = bandsIn.filter((b) => b.mode === "reserved");
|
|
312
|
-
const overlayIn = bandsIn.filter((b) => b.mode === "overlay");
|
|
313
|
-
fitH(reservedIn, H - res.top - res.bottom - Math.max(minH, overlayIn.length * opt.bar));
|
|
314
|
-
const bandH = (b) => b ? gh.heights.get(b) ?? opt.bar : 0;
|
|
315
|
-
const pagesH = H - res.top - res.bottom - reservedIn.reduce((a, b) => a + bandH(b), 0);
|
|
316
|
-
fitH(overlayIn, pagesH - minH);
|
|
317
|
-
const topB = bandsIn.find((b) => b.edge === "top");
|
|
318
|
-
const botB = bandsIn.find((b) => b.edge === "bottom");
|
|
319
|
-
const hT = bandH(topB);
|
|
320
|
-
const hB = bandH(botB);
|
|
321
|
-
const colTop = topB?.span === "full" ? (topB.mode === "overlay" ? res.top : 0) + hT : 0;
|
|
322
|
-
const colBot = botB?.span === "full" ? H - (botB.mode === "overlay" ? res.bottom : 0) - hB : H;
|
|
323
|
-
const CH = Math.max(0, colBot - colTop);
|
|
324
|
-
const cols = [];
|
|
325
|
-
for (const side of SIDES) {
|
|
326
|
-
state.sides[side].forEach((c, index) => {
|
|
327
|
-
const panels = c.panels.filter((id) => !closed.has(id));
|
|
328
|
-
if (panels.length === 0) return;
|
|
329
|
-
const ds = panels.map((id) => defOf(defs, id));
|
|
330
|
-
const min = Math.max(0, ...ds.map((d) => d?.width.min ?? 0));
|
|
331
|
-
const max = Math.max(min, Math.min(...ds.map((d) => d?.width.max ?? Infinity)));
|
|
332
|
-
const width = clamp(Number.isFinite(c.width) ? c.width : min, min, max);
|
|
333
|
-
const age = Math.max(...panels.map((id) => state.clock[id]?.[by] ?? 0));
|
|
334
|
-
const tabs = c.show === "tabs" ? { show: "tabs", active: c.active !== void 0 && panels.includes(c.active) ? c.active : panels[0] } : {};
|
|
335
|
-
cols.push({ side, index, panels, min, max, width, hand: panels.every((id) => folded.has(id)), kept: panels.some((id) => kept.has(id)), age, ...tabs });
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
const sectionHeights = (c, room) => {
|
|
339
|
-
const out = /* @__PURE__ */ new Map();
|
|
340
|
-
const open0 = c.panels.filter((id) => !folded.has(id));
|
|
341
|
-
const hOf = (id) => defOf(defs, id)?.height;
|
|
342
|
-
const auto = /* @__PURE__ */ new Set();
|
|
343
|
-
if (open0.some((id) => hOf(id))) {
|
|
344
|
-
const last = open0.at(-1);
|
|
345
|
-
const minOf = (id) => hOf(id)?.min ?? opt.bar;
|
|
346
|
-
const fits = () => (c.panels.length - open0.length + auto.size) * opt.bar + open0.filter((id) => !auto.has(id)).reduce((a, id) => a + minOf(id), 0) <= room;
|
|
347
|
-
const rank = (ids) => [...ids].sort((a, b) => {
|
|
348
|
-
const age = (id) => state.clock[id]?.[by] ?? 0;
|
|
349
|
-
return Number(kept.has(a)) - Number(kept.has(b)) || (opt.giveWay.order === "oldest" ? age(a) - age(b) : age(b) - age(a)) || c.panels.indexOf(a) - c.panels.indexOf(b);
|
|
350
|
-
});
|
|
351
|
-
for (const id of rank(open0.filter((x) => x !== last))) {
|
|
352
|
-
if (fits()) break;
|
|
353
|
-
if (minOf(id) > opt.bar) auto.add(id);
|
|
354
|
-
}
|
|
355
|
-
const open2 = open0.filter((id) => !auto.has(id));
|
|
356
|
-
const space = room - (c.panels.length - open2.length) * opt.bar;
|
|
357
|
-
const fixed = open2.filter((id) => id !== last && hOf(id));
|
|
358
|
-
const sharers = open2.filter((id) => id === last || !hOf(id));
|
|
359
|
-
const h = new Map(fixed.map((id) => [id, hOf(id).natural]));
|
|
360
|
-
let rest = space - fixed.reduce((a, id) => a + h.get(id), 0);
|
|
361
|
-
const need = sharers.reduce((a, id) => a + minOf(id), 0);
|
|
362
|
-
for (const id of rank(fixed)) {
|
|
363
|
-
if (rest >= need) break;
|
|
364
|
-
const take = Math.min(need - rest, h.get(id) - minOf(id));
|
|
365
|
-
h.set(id, h.get(id) - take);
|
|
366
|
-
rest += take;
|
|
367
|
-
}
|
|
368
|
-
if (rest >= need) {
|
|
369
|
-
let pool = [...sharers];
|
|
370
|
-
let left = rest;
|
|
371
|
-
for (; ; ) {
|
|
372
|
-
const share2 = left / pool.length;
|
|
373
|
-
const under = pool.filter((id) => minOf(id) > share2);
|
|
374
|
-
if (under.length === 0) {
|
|
375
|
-
for (const id of pool) h.set(id, share2);
|
|
376
|
-
break;
|
|
377
|
-
}
|
|
378
|
-
for (const id of under) h.set(id, minOf(id));
|
|
379
|
-
left -= under.reduce((a, id) => a + minOf(id), 0);
|
|
380
|
-
pool = pool.filter((id) => !under.includes(id));
|
|
381
|
-
}
|
|
382
|
-
} else {
|
|
383
|
-
const lastH = Math.max(0, Math.min(minOf(last), rest));
|
|
384
|
-
for (const id of sharers) h.set(id, id === last ? lastH : Math.max(0, rest - lastH) / (sharers.length - 1));
|
|
385
|
-
}
|
|
386
|
-
for (const id of c.panels) out.set(id, folded.has(id) ? { height: opt.bar, folded: "hand" } : auto.has(id) ? { height: opt.bar, folded: "auto" } : { height: Math.max(0, h.get(id)), folded: null });
|
|
387
|
-
return out;
|
|
388
|
-
}
|
|
389
|
-
const bars = c.panels.length - open0.length;
|
|
390
|
-
const share = Math.max(0, (room - bars * opt.bar) / open0.length);
|
|
391
|
-
for (const id of c.panels) out.set(id, folded.has(id) ? { height: opt.bar, folded: "hand" } : { height: share, folded: null });
|
|
392
|
-
return out;
|
|
393
|
-
};
|
|
394
|
-
const order = giveWayOrder(
|
|
395
|
-
cols.filter((c) => !c.hand),
|
|
396
|
-
opt.giveWay.order
|
|
397
|
-
);
|
|
398
|
-
const fit = (k) => {
|
|
399
|
-
const auto = new Set(order.slice(0, k));
|
|
400
|
-
const open2 = (side) => cols.some((c) => c.side === side && !c.hand && !auto.has(c));
|
|
401
|
-
const railed = (side) => cols.some((c) => c.side === side && (auto.has(c) || c.hand && !(ride && open2(side))));
|
|
402
|
-
const widths = new Map(order.filter((c) => !auto.has(c)).map((c) => [c, c.width]));
|
|
403
|
-
let excess = [...widths.values()].reduce((a, b) => a + b, 0) + SIDES.filter(railed).length * opt.rail + opt.pagesMin + res.left + res.right - W;
|
|
404
|
-
for (const c of order) {
|
|
405
|
-
if (excess <= 0 || auto.has(c)) continue;
|
|
406
|
-
const take = Math.min(excess, c.width - c.min);
|
|
407
|
-
if (take > 0) {
|
|
408
|
-
widths.set(c, c.width - take);
|
|
409
|
-
excess -= take;
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
return { auto, widths, excess };
|
|
413
|
-
};
|
|
414
|
-
let g = fit(0);
|
|
415
|
-
for (let k = 1; g.excess > 0 && k <= order.length; k++) g = fit(k);
|
|
416
|
-
const notes = [];
|
|
417
|
-
for (const c of order) {
|
|
418
|
-
const w = g.widths.get(c);
|
|
419
|
-
if (w !== void 0 && w < c.width) notes.push({ code: "column-shrunk", side: c.side, column: c.index, items: c.panels, from: c.width, to: w });
|
|
420
|
-
}
|
|
421
|
-
for (const c of order) if (g.auto.has(c)) notes.push({ code: c.kept ? "kept-folded" : "column-folded", side: c.side, column: c.index, items: c.panels });
|
|
422
|
-
const items = /* @__PURE__ */ new Map();
|
|
423
|
-
const placedCols = [];
|
|
424
|
-
const rails = {};
|
|
425
|
-
let x0 = 0;
|
|
426
|
-
let x1 = W;
|
|
427
|
-
for (const side of SIDES) {
|
|
428
|
-
const mine = cols.filter((c) => c.side === side);
|
|
429
|
-
const open2 = mine.filter((c) => !c.hand && !g.auto.has(c));
|
|
430
|
-
const host = ride ? open2[0] : void 0;
|
|
431
|
-
const riders = host ? mine.filter((c) => c.hand) : [];
|
|
432
|
-
const inRail = mine.filter((c) => c.hand && !riders.includes(c) || g.auto.has(c));
|
|
433
|
-
if (inRail.length) {
|
|
434
|
-
const r = side === "left" ? rect(0, colTop, opt.rail, CH) : rect(W - opt.rail, colTop, opt.rail, CH);
|
|
435
|
-
const segments = inRail.flatMap((c) => c.panels).map((id, i) => ({ id, rect: rect(r.x, colTop + opt.railInset + i * opt.segment, opt.rail, opt.segment) }));
|
|
436
|
-
rails[side] = { side, rect: r, segments };
|
|
437
|
-
for (const s of segments) {
|
|
438
|
-
const c = inRail.find((x) => x.panels.includes(s.id));
|
|
439
|
-
items.set(s.id, { rect: s.rect, kind: "segment", layer: 0, hidden: true, folded: c.hand ? "hand" : "auto", kept: kept.has(s.id), pinned: false, floating: false, side, column: c.index });
|
|
440
|
-
}
|
|
441
|
-
if (side === "left") x0 = opt.rail;
|
|
442
|
-
else x1 = W - opt.rail;
|
|
443
|
-
}
|
|
444
|
-
const at = /* @__PURE__ */ new Map();
|
|
445
|
-
for (const c of mine) {
|
|
446
|
-
const w = g.widths.get(c);
|
|
447
|
-
if (w === void 0 || riders.includes(c)) continue;
|
|
448
|
-
if (side === "left") {
|
|
449
|
-
at.set(c, rect(x0, colTop, w, CH));
|
|
450
|
-
x0 += w;
|
|
451
|
-
} else {
|
|
452
|
-
x1 -= w;
|
|
453
|
-
at.set(c, rect(x1, colTop, w, CH));
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
const riding = riders.flatMap((c) => c.panels.map((id) => ({ id, c })));
|
|
457
|
-
const top = riding.length * opt.bar;
|
|
458
|
-
for (const c of mine) {
|
|
459
|
-
const w = g.widths.get(c);
|
|
460
|
-
const folded1 = c.hand ? "hand" : g.auto.has(c) ? "auto" : null;
|
|
461
|
-
const base = { side, index: c.index, width: c.width, min: c.min, max: c.max, folded: folded1, kept: c.kept, panels: c.panels };
|
|
462
|
-
if (riders.includes(c)) {
|
|
463
|
-
const hr = at.get(host);
|
|
464
|
-
const first = riding.findIndex((x) => x.c === c);
|
|
465
|
-
c.panels.forEach(
|
|
466
|
-
(id, i) => items.set(id, { rect: rect(hr.x, colTop + (first + i) * opt.bar, hr.width, opt.bar), kind: "bar", layer: 0, hidden: false, folded: "hand", kept: kept.has(id), pinned: false, floating: false, side, column: c.index, rides: host.index })
|
|
467
|
-
);
|
|
468
|
-
placedCols.push({ ...base, rect: rect(hr.x, colTop + first * opt.bar, hr.width, c.panels.length * opt.bar), shrunk: false, rides: host.index });
|
|
469
|
-
continue;
|
|
470
|
-
}
|
|
471
|
-
const r = at.get(c) ?? rect(side === "left" ? x0 : x1, colTop, 0, CH);
|
|
472
|
-
const y0 = colTop + (c === host ? top : 0);
|
|
473
|
-
const tabbed = c.show === "tabs";
|
|
474
|
-
const strip = rect(r.x, y0, r.width, opt.tabs);
|
|
475
|
-
const shown = tabbed && w !== void 0 ? { strip, active: c.active } : {};
|
|
476
|
-
placedCols.push({ ...base, rect: r, shrunk: w !== void 0 && w < c.width, ...tabbed ? { show: "tabs" } : {}, ...shown });
|
|
477
|
-
if (w === void 0) continue;
|
|
478
|
-
const panel = (id, to, kind, f, more = {}) => {
|
|
479
|
-
items.set(id, { rect: to, kind, layer: 0, hidden: more.hidden ?? false, folded: f, kept: kept.has(id), pinned: false, floating: false, side, column: c.index, ...more.tab ? { tab: more.tab } : {} });
|
|
480
|
-
};
|
|
481
|
-
if (tabbed) {
|
|
482
|
-
const body = rect(r.x, y0 + opt.tabs, r.width, Math.max(0, colBot - y0 - opt.tabs));
|
|
483
|
-
const shade = folded.has(c.active);
|
|
484
|
-
const tw = r.width / c.panels.length;
|
|
485
|
-
c.panels.forEach((id, i) => {
|
|
486
|
-
const tab = rect(r.x + i * tw, y0, tw, opt.tabs);
|
|
487
|
-
if (id === c.active) panel(id, shade ? strip : body, shade ? "bar" : "column", shade ? "hand" : null, { tab });
|
|
488
|
-
else panel(id, body, "column", folded.has(id) ? "hand" : null, { tab, hidden: true });
|
|
489
|
-
});
|
|
490
|
-
continue;
|
|
491
|
-
}
|
|
492
|
-
const hs = sectionHeights(c, colBot - y0);
|
|
493
|
-
let y = y0;
|
|
494
|
-
for (const id of c.panels) {
|
|
495
|
-
const s = hs.get(id);
|
|
496
|
-
panel(id, rect(r.x, y, r.width, s.height), s.folded ? "bar" : "column", s.folded);
|
|
497
|
-
y += s.height;
|
|
498
|
-
}
|
|
499
|
-
for (const id of c.panels) if (hs.get(id).folded === "auto") notes.push({ code: "section-folded", side, column: c.index, items: [id] });
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
for (const b of bOrder) {
|
|
503
|
-
const h = gh.heights.get(b);
|
|
504
|
-
if (h !== void 0 && h < b.height) notes.push({ code: "band-shrunk", edge: b.edge, items: b.panels, from: b.height, to: h });
|
|
505
|
-
}
|
|
506
|
-
for (const b of bOrder) if (gh.auto.has(b)) notes.push({ code: b.kept ? "kept-folded" : "band-folded", edge: b.edge, items: b.panels });
|
|
507
|
-
const pw = Math.max(0, x1 - x0);
|
|
508
|
-
const pTop = topB?.mode === "reserved" ? hT : 0;
|
|
509
|
-
const pBot = botB?.mode === "reserved" ? H - hB : H;
|
|
510
|
-
const reserved = {};
|
|
511
|
-
const iTop = pTop + res.top + (topB?.mode === "overlay" ? hT : 0);
|
|
512
|
-
const iBot = pBot - res.bottom - (botB?.mode === "overlay" ? hB : 0);
|
|
513
|
-
if (res.top > 0) reserved.top = rect(x0, pTop, pw, res.top);
|
|
514
|
-
if (res.right > 0) reserved.right = rect(x0 + pw - res.right, iTop, res.right, Math.max(0, iBot - iTop));
|
|
515
|
-
if (res.bottom > 0) reserved.bottom = rect(x0, pBot - res.bottom, pw, res.bottom);
|
|
516
|
-
if (res.left > 0) reserved.left = rect(x0, iTop, res.left, Math.max(0, iBot - iTop));
|
|
517
|
-
const pages = rect(x0 + res.left, pTop + res.top, Math.max(0, pw - res.left - res.right), Math.max(0, pBot - res.bottom - pTop - res.top));
|
|
518
|
-
if (pages.width < opt.pagesMin) notes.push({ code: "pages-under-min", width: pages.width, min: opt.pagesMin });
|
|
519
|
-
if ((bandsIn.length || res.top + res.bottom > 0) && pages.height < minH - 1e-9) notes.push({ code: "pages-short", height: pages.height, min: minH });
|
|
520
|
-
const bands = {};
|
|
521
|
-
for (const b of bandsIn) {
|
|
522
|
-
const h = bandH(b);
|
|
523
|
-
const full = b.span === "full";
|
|
524
|
-
const over = b.mode === "overlay";
|
|
525
|
-
const y = b.edge === "top" ? over ? res.top : 0 : over ? H - res.bottom - h : H - h;
|
|
526
|
-
const r = full ? rect(0, y, W, h) : rect(x0, y, pw, h);
|
|
527
|
-
const f = b.hand ? "hand" : gh.auto.has(b) ? "auto" : null;
|
|
528
|
-
const hh = gh.heights.get(b);
|
|
529
|
-
bands[b.edge] = { edge: b.edge, rect: r, height: b.height, min: b.min, max: b.max, folded: f, shrunk: hh !== void 0 && hh < b.height, kept: b.kept, mode: b.mode, span: b.span, panels: b.panels };
|
|
530
|
-
const share = r.width / b.panels.length;
|
|
531
|
-
b.panels.forEach(
|
|
532
|
-
(id, i) => items.set(id, { rect: rect(r.x + i * share, r.y, share, h), kind: f ? "bar" : "band", layer: over ? 5 : 0, hidden: false, folded: f, kept: kept.has(id), pinned: false, floating: false, edge: b.edge, index: b.at[i] })
|
|
533
|
-
);
|
|
534
|
-
}
|
|
535
|
-
state.floats.forEach((f, i) => {
|
|
536
|
-
if (closed.has(f.id)) return;
|
|
537
|
-
const shaded = folded.has(f.id);
|
|
538
|
-
const at = shaded ? { ...f.rect, height: opt.bar } : f.rect;
|
|
539
|
-
const k = f.pinned ? 1 : opt.view.scale;
|
|
540
|
-
const r = { ...at };
|
|
541
|
-
if (opt.floats === "clamp") {
|
|
542
|
-
const lim = floatSize(defOf(defs, f.id)).min;
|
|
543
|
-
r.width = Math.max(lim.width, Math.min(r.width, W));
|
|
544
|
-
if (!shaded) r.height = Math.max(lim.height, Math.min(r.height, H));
|
|
545
|
-
if (r.width !== at.width || r.height !== at.height) notes.push({ code: "float-resized", items: [f.id] });
|
|
546
|
-
r.x = r.width <= W ? clamp(r.x, 0, (W - r.width) / k) : clamp(r.x, (opt.floatVisible - r.width) / k, (W - opt.floatVisible) / k);
|
|
547
|
-
r.y = r.height <= H ? clamp(r.y, 0, (H - r.height) / k) : clamp(r.y, 0, (H - opt.bar) / k);
|
|
548
|
-
if (r.x !== at.x || r.y !== at.y) notes.push({ code: "float-clamped", items: [f.id] });
|
|
549
|
-
}
|
|
550
|
-
const clamped = r.x !== at.x || r.y !== at.y || r.width !== at.width || r.height !== at.height;
|
|
551
|
-
items.set(f.id, {
|
|
552
|
-
rect: f.pinned ? r : toView(r, opt.view),
|
|
553
|
-
kind: shaded ? "bar" : "float",
|
|
554
|
-
layer: 10 + i,
|
|
555
|
-
hidden: false,
|
|
556
|
-
folded: shaded ? "hand" : null,
|
|
557
|
-
kept: false,
|
|
558
|
-
pinned: !!f.pinned,
|
|
559
|
-
floating: true,
|
|
560
|
-
...clamped ? { clamped: true } : {}
|
|
561
|
-
});
|
|
562
|
-
});
|
|
563
|
-
notes.push(...offNotes);
|
|
564
|
-
return { items, columns: placedCols, rails, notes, pages, bands, reserved };
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
// src/panels/targets.ts
|
|
568
|
-
function placeRank(place) {
|
|
569
|
-
switch (place.kind) {
|
|
570
|
-
case "float":
|
|
571
|
-
return 3e3;
|
|
572
|
-
case "band":
|
|
573
|
-
return (place.edge === "top" ? 2e3 : 2500) + Math.min(place.index, 499);
|
|
574
|
-
case "rail":
|
|
575
|
-
return place.side === "left" ? 0 : 1999;
|
|
576
|
-
case "column":
|
|
577
|
-
return place.side === "left" ? 1 + 2 * place.index : 1998 - 2 * place.index;
|
|
578
|
-
case "into": {
|
|
579
|
-
const base = place.side === "left" ? 2 + 2 * place.index : 1997 - 2 * place.index;
|
|
580
|
-
return place.at === void 0 ? base : base - 0.5 + Math.min(Math.max(0, place.at), 499) / 1e3;
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
function homePlace(state, id, options = {}) {
|
|
585
|
-
const w = whereIs(state, id);
|
|
586
|
-
if (w.kind === "float") return { kind: "float" };
|
|
587
|
-
if (w.kind === "none") return null;
|
|
588
|
-
if (w.kind === "band") return { kind: "band", edge: w.edge, index: w.index };
|
|
589
|
-
const col = state.sides[w.side][w.index];
|
|
590
|
-
if (col.panels.length === 1) return { kind: "column", side: w.side, index: w.index };
|
|
591
|
-
return options.stackSlots && col.show !== "tabs" ? { kind: "into", side: w.side, index: w.index, at: col.panels.indexOf(id) } : { kind: "into", side: w.side, index: w.index };
|
|
592
|
-
}
|
|
593
|
-
var cut = (x0, x1, lo, hi) => [Math.max(x0, lo), Math.min(x1, hi)];
|
|
594
|
-
function panelTargets(input) {
|
|
595
|
-
const { defs, state, id, stage } = input;
|
|
596
|
-
const opt = { ...DEFAULT_PANELS_OPTIONS, ...input.options };
|
|
597
|
-
const def = defOf(defs, id);
|
|
598
|
-
const s0 = liftPanel(state, id);
|
|
599
|
-
const l0 = layoutPanels(defs, s0, stage, opt);
|
|
600
|
-
const width = ownWidth(defs, state, id);
|
|
601
|
-
const W = stage.width;
|
|
602
|
-
const H = stage.height;
|
|
603
|
-
const R = COLUMN_REACH;
|
|
604
|
-
const bandOpts = opt.bands ?? {};
|
|
605
|
-
const reserve = opt.reserve ?? {};
|
|
606
|
-
const px = (v) => typeof v === "number" && Number.isFinite(v) ? Math.max(0, v) : 0;
|
|
607
|
-
const out = [];
|
|
608
|
-
const idOf = (place) => {
|
|
609
|
-
switch (place.kind) {
|
|
610
|
-
case "float":
|
|
611
|
-
return "float";
|
|
612
|
-
case "rail":
|
|
613
|
-
return `rail:${place.side}`;
|
|
614
|
-
case "band":
|
|
615
|
-
return s0.bands?.[place.edge] ? `band:${place.edge}:${place.index}` : `band:${place.edge}`;
|
|
616
|
-
case "into":
|
|
617
|
-
return place.at === void 0 ? `into:${place.side}:${place.index}` : `into:${place.side}:${place.index}:${place.at}`;
|
|
618
|
-
default:
|
|
619
|
-
return `${place.kind}:${place.side}:${place.index}`;
|
|
620
|
-
}
|
|
621
|
-
};
|
|
622
|
-
const add = (place, priority, hit, make, free = false, marker) => {
|
|
623
|
-
if (hit.width <= 0 || hit.height <= 0) return;
|
|
624
|
-
if (input.allows && !input.allows(id, place)) return;
|
|
625
|
-
if (place.kind !== "float" && samePlaces(make({ x: 0, y: 0 }, { x: 0, y: 0 }), state, defs)) return;
|
|
626
|
-
out.push({ id: idOf(place), priority, hit, panel: id, place, order: placeRank(place), make, ...free ? { free: true } : {}, ...marker ? { marker } : {} });
|
|
627
|
-
};
|
|
628
|
-
const fullTop = l0.bands.top?.span === "full" ? l0.bands.top.rect : null;
|
|
629
|
-
const fullBot = l0.bands.bottom?.span === "full" ? l0.bands.bottom.rect : null;
|
|
630
|
-
const top = fullTop ? fullTop.y + fullTop.height : 0;
|
|
631
|
-
const CH = Math.max(0, (fullBot ? fullBot.y : H) - top);
|
|
632
|
-
for (const side of SIDES) {
|
|
633
|
-
if (def?.sides && !def.sides.includes(side)) continue;
|
|
634
|
-
const left = side === "left";
|
|
635
|
-
const rail = l0.rails[side];
|
|
636
|
-
const edge = rail ? rail.rect.width : RAIL_EDGE;
|
|
637
|
-
const railHit = rail ? rail.rect : left ? rect(0, top, RAIL_EDGE, CH) : rect(W - RAIL_EDGE, top, RAIL_EDGE, CH);
|
|
638
|
-
add({ kind: "rail", side }, 1, railHit, () => {
|
|
639
|
-
const s = dock(state, id, side, 0, { width });
|
|
640
|
-
return { ...s, folded: [...s.folded.filter((x) => x !== id), id] };
|
|
641
|
-
});
|
|
642
|
-
const open2 = l0.columns.filter((c) => c.side === side && c.folded === null);
|
|
643
|
-
const lo = left ? edge : 0;
|
|
644
|
-
const hi = left ? W : W - edge;
|
|
645
|
-
const band = (x, outer, i) => {
|
|
646
|
-
const [a, b] = outer ? left ? cut(x, x + 2 * R, lo, hi) : cut(x - 2 * R, x, lo, hi) : cut(x - R, x + R, lo, hi);
|
|
647
|
-
add({ kind: "column", side, index: i }, 2, rect(a, top, b - a, CH), () => dock(state, id, side, i, { width }));
|
|
648
|
-
};
|
|
649
|
-
if (open2.length === 0) band(left ? l0.pages.x - px(reserve.left) : l0.pages.x + l0.pages.width + px(reserve.right), true, s0.sides[side].length);
|
|
650
|
-
open2.forEach((c, k) => {
|
|
651
|
-
band(left ? c.rect.x : c.rect.x + c.rect.width, k === 0, c.index);
|
|
652
|
-
const col = s0.sides[side][c.index];
|
|
653
|
-
const into = () => dock(state, id, side, c.index, { into: true });
|
|
654
|
-
const members = input.stackSlots && col.show !== "tabs" ? col.panels.flatMap((p, at) => {
|
|
655
|
-
const r = l0.items.get(p)?.rect;
|
|
656
|
-
return r ? [{ at, rect: r }] : [];
|
|
657
|
-
}) : [];
|
|
658
|
-
if (members.length === 0) {
|
|
659
|
-
add({ kind: "into", side, index: c.index }, 2, c.rect, into);
|
|
660
|
-
return;
|
|
661
|
-
}
|
|
662
|
-
const mid = (r) => r.y + r.height / 2;
|
|
663
|
-
const marker = (make) => {
|
|
664
|
-
const r = layoutPanels(defs, make(), stage, opt).items.get(id)?.rect;
|
|
665
|
-
return rect(c.rect.x, r ? r.y : c.rect.y, c.rect.width, 0);
|
|
666
|
-
};
|
|
667
|
-
const bottom = c.rect.y + c.rect.height;
|
|
668
|
-
members.forEach(({ at, rect: r }, k2) => {
|
|
669
|
-
const prev = members[k2 - 1];
|
|
670
|
-
const y0 = prev ? mid(prev.rect) : c.rect.y;
|
|
671
|
-
const make = () => dock(state, id, side, c.index, { into: true, at });
|
|
672
|
-
add({ kind: "into", side, index: c.index, at }, 2, rect(c.rect.x, y0, c.rect.width, mid(r) - y0), make, false, marker(make));
|
|
673
|
-
});
|
|
674
|
-
const last2 = members.at(-1).rect;
|
|
675
|
-
add({ kind: "into", side, index: c.index }, 2, rect(c.rect.x, mid(last2), c.rect.width, bottom - mid(last2)), into, false, marker(into));
|
|
676
|
-
});
|
|
677
|
-
const last = open2.at(-1);
|
|
678
|
-
if (last) band(left ? last.rect.x + last.rect.width : last.rect.x, false, last.index + 1);
|
|
679
|
-
}
|
|
680
|
-
const home = whereIs(state, id);
|
|
681
|
-
for (const e of EDGES) {
|
|
682
|
-
if (!bandOpts[e] || def?.sides && !def.sides.includes(e)) continue;
|
|
683
|
-
const pb = l0.bands[e];
|
|
684
|
-
const list = s0.bands?.[e]?.panels ?? [];
|
|
685
|
-
const make = (i) => () => dockBand(state, id, e, i, defs);
|
|
686
|
-
if (!pb) {
|
|
687
|
-
if (home.kind === "band" && home.edge === e && !s0.bands?.[e]) continue;
|
|
688
|
-
const p = l0.pages;
|
|
689
|
-
const h = Math.min(2 * opt.bar, p.height);
|
|
690
|
-
add({ kind: "band", edge: e, index: list.length }, 2, rect(p.x, e === "top" ? p.y : p.y + p.height - h, p.width, h), make(list.length));
|
|
691
|
-
continue;
|
|
692
|
-
}
|
|
693
|
-
const m = pb.panels.length;
|
|
694
|
-
const share = pb.rect.width / m;
|
|
695
|
-
for (let k = 0; k <= m; k++) {
|
|
696
|
-
const i = k < m ? list.indexOf(pb.panels[k]) : list.length;
|
|
697
|
-
const a = pb.rect.x + Math.max(0, k - 0.5) * share;
|
|
698
|
-
const b = pb.rect.x + Math.min(m, k + 0.5) * share;
|
|
699
|
-
add({ kind: "band", edge: e, index: i }, 2, rect(a, pb.rect.y, b - a, pb.rect.height), make(i));
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
if (def?.floats !== false) {
|
|
703
|
-
const was = state.floats.find((f) => f.id === id);
|
|
704
|
-
const size = was ? { width: was.rect.width, height: was.rect.height } : floatSize(def).natural;
|
|
705
|
-
const pinned = !!was?.pinned;
|
|
706
|
-
add(
|
|
707
|
-
{ kind: "float" },
|
|
708
|
-
3,
|
|
709
|
-
rect(0, 0, W, H),
|
|
710
|
-
(p, grab) => {
|
|
711
|
-
const at = rect(p.x - grab.x, p.y - grab.y, size.width, size.height);
|
|
712
|
-
const s = float(state, id, pinned ? at : toPage(at, opt.view), pinned);
|
|
713
|
-
const laid = layoutPanels(defs, s, stage, opt).items.get(id).rect;
|
|
714
|
-
const shown = s.folded.includes(id) ? { ...laid, width: at.width, height: at.height } : laid;
|
|
715
|
-
return float(state, id, pinned ? shown : toPage(shown, opt.view), pinned);
|
|
716
|
-
},
|
|
717
|
-
true
|
|
718
|
-
);
|
|
719
|
-
}
|
|
720
|
-
return out.sort((a, b) => a.order - b.order);
|
|
721
|
-
}
|
|
722
|
-
function panelDrop(input, target, p, grab) {
|
|
723
|
-
const opt = { ...DEFAULT_PANELS_OPTIONS, ...input.options };
|
|
724
|
-
const state = target.make(p, grab);
|
|
725
|
-
const layout = layoutPanels(input.defs, state, input.stage, opt);
|
|
726
|
-
const placed = layout.items.get(input.id);
|
|
727
|
-
const key = target.free ? `float:${Math.round(placed.rect.x)},${Math.round(placed.rect.y)}` : target.id;
|
|
728
|
-
return { target: target.id, place: target.place, key, state, layout, slot: placed.rect, hidden: placed.hidden, free: !!target.free };
|
|
729
|
-
}
|
|
730
|
-
function panelStops(targets, options = {}) {
|
|
731
|
-
const stops = [];
|
|
732
|
-
for (const t of targets) {
|
|
733
|
-
if (t.place.kind === "float") {
|
|
734
|
-
if (!options.floats) continue;
|
|
735
|
-
const at = options.floats === true ? { x: t.hit.x + t.hit.width / 2, y: t.hit.y + t.hit.height / 2 } : options.floats.at;
|
|
736
|
-
const grab = options.floats === true ? { x: 0, y: 0 } : options.floats.grab ?? { x: 0, y: 0 };
|
|
737
|
-
stops.push({ id: t.id, place: t.place, state: t.make(at, grab), home: false, order: t.order });
|
|
738
|
-
continue;
|
|
739
|
-
}
|
|
740
|
-
stops.push({ id: t.id, place: t.place, state: t.make({ x: 0, y: 0 }, { x: 0, y: 0 }), home: false, order: t.order });
|
|
741
|
-
}
|
|
742
|
-
const h = options.home;
|
|
743
|
-
const after = h?.place.kind === "float" ? 1 : h?.place.kind === "into" && h.place.at !== void 0 ? 5e-4 : 0.5;
|
|
744
|
-
if (h) stops.push({ id: "home", place: h.place, state: h.state, home: true, order: placeRank(h.place) + after });
|
|
745
|
-
return stops.sort((a, b) => a.order - b.order).map(({ order: _order, ...s }) => s);
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
export {
|
|
749
|
-
SIDES,
|
|
750
|
-
EDGES,
|
|
751
|
-
BAND_SIZE,
|
|
752
|
-
IDENTITY_VIEW,
|
|
753
|
-
DEFAULT_PANELS_OPTIONS,
|
|
754
|
-
FLOAT_HEIGHT,
|
|
755
|
-
FLOAT_MIN,
|
|
756
|
-
whereIs,
|
|
757
|
-
tick,
|
|
758
|
-
defOf,
|
|
759
|
-
floatSize,
|
|
760
|
-
bandSize,
|
|
761
|
-
bandHeight,
|
|
762
|
-
ownWidth,
|
|
763
|
-
createPanels,
|
|
764
|
-
liftPanel,
|
|
765
|
-
open,
|
|
766
|
-
close,
|
|
767
|
-
focus,
|
|
768
|
-
toggleFold,
|
|
769
|
-
keep,
|
|
770
|
-
dockBand,
|
|
771
|
-
resizeBand,
|
|
772
|
-
dock,
|
|
773
|
-
showTabs,
|
|
774
|
-
activate,
|
|
775
|
-
float,
|
|
776
|
-
toView,
|
|
777
|
-
toPage,
|
|
778
|
-
pin,
|
|
779
|
-
resizeColumn,
|
|
780
|
-
resizeFloat,
|
|
781
|
-
columnWidth,
|
|
782
|
-
samePlaces,
|
|
783
|
-
giveWayOrder,
|
|
784
|
-
layoutPanels,
|
|
785
|
-
placeRank,
|
|
786
|
-
homePlace,
|
|
787
|
-
panelTargets,
|
|
788
|
-
panelDrop,
|
|
789
|
-
panelStops
|
|
790
|
-
};
|
|
791
|
-
//# sourceMappingURL=chunk-3ZICYLWL.js.map
|