@n-uf/placement 26.11.29 → 26.11.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +86 -63
  3. package/dist/{chunk-7ASCUAGV.js → chunk-3ZICYLWL.js} +2 -2
  4. package/dist/{chunk-7ASCUAGV.js.map → chunk-3ZICYLWL.js.map} +1 -1
  5. package/dist/{chunk-PC5UHBW4.js → chunk-5CSWQSH7.js} +30 -22
  6. package/dist/chunk-5CSWQSH7.js.map +1 -0
  7. package/dist/{chunk-3RRCKN74.js → chunk-AE3BWTAE.js} +2 -2
  8. package/dist/chunk-AE3BWTAE.js.map +1 -0
  9. package/dist/{chunk-3P6VOXA6.js → chunk-AVMZIXGO.js} +2 -2
  10. package/dist/{chunk-3P6VOXA6.js.map → chunk-AVMZIXGO.js.map} +1 -1
  11. package/dist/{chunk-WLMJ6JGO.js → chunk-GIBUM6TB.js} +1 -1
  12. package/dist/chunk-GIBUM6TB.js.map +1 -0
  13. package/dist/{chunk-OYGOJWAX.js → chunk-JVAR67OL.js} +2 -2
  14. package/dist/{chunk-WM5FJ3IS.js → chunk-VLTYJHUA.js} +1 -1
  15. package/dist/{chunk-WM5FJ3IS.js.map → chunk-VLTYJHUA.js.map} +1 -1
  16. package/dist/{constructions-DSEjvWMP.d.ts → constructions-Cbz7uEAZ.d.ts} +3 -3
  17. package/dist/desk.d.ts +3 -3
  18. package/dist/desk.js +3 -3
  19. package/dist/dock.d.ts +4 -4
  20. package/dist/dock.js +2 -2
  21. package/dist/dock.js.map +1 -1
  22. package/dist/{float-fit-DRSOU_2y.d.ts → float-fit-DCYxRMru.d.ts} +1 -1
  23. package/dist/{geometry-CkZ6Fcfb.d.ts → geometry-Bf37LbCT.d.ts} +1 -1
  24. package/dist/index.d.ts +4 -4
  25. package/dist/index.js +1 -1
  26. package/dist/index.js.map +1 -1
  27. package/dist/{model-lYlnfQnl.d.ts → model-BxFXr9UY.d.ts} +5 -5
  28. package/dist/{model-CPM1Lv65.d.ts → model-X7eUaKlA.d.ts} +2 -2
  29. package/dist/panels.d.ts +5 -5
  30. package/dist/panels.js +3 -3
  31. package/dist/scene-cases.d.ts +59 -15
  32. package/dist/scene-cases.js +114 -21
  33. package/dist/scene-cases.js.map +1 -1
  34. package/dist/scene.d.ts +7 -7
  35. package/dist/scene.js +3 -3
  36. package/dist/stack.d.ts +6 -6
  37. package/dist/stack.js +2 -2
  38. package/dist/{target-D9PMr9pF.d.ts → target-2RYYKkd1.d.ts} +1 -1
  39. package/dist/{targets-BYRTTwCP.d.ts → targets-Du5_4T1u.d.ts} +4 -4
  40. package/dist/targets.d.ts +14 -14
  41. package/dist/targets.js +4 -4
  42. package/dist/targets.js.map +1 -1
  43. package/dist/toolbar.d.ts +11 -11
  44. package/dist/toolbar.js +1 -1
  45. package/package.json +2 -2
  46. package/dist/chunk-3RRCKN74.js.map +0 -1
  47. package/dist/chunk-PC5UHBW4.js.map +0 -1
  48. package/dist/chunk-WLMJ6JGO.js.map +0 -1
  49. /package/dist/{chunk-OYGOJWAX.js.map → chunk-JVAR67OL.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/dock/model.ts","../src/dock/arrange.ts","../src/dock/parts.ts"],"sourcesContent":["/**\n * The desk's model: panels and documents, the options, the state every construction keeps, and what a layout\n * returns (a placed rect per item). The panels themselves (their titles and natural heights) come from the\n * consumer as a catalog; see `createDesk`.\n */\nimport type { Rect, Size } from \"../geometry\";\n\nexport type Side = \"left\" | \"right\";\n\n/** Gaps and sizes, in stage px. */\nexport const G = 6;\n/** A toolbar bar's height (the pill is 4 px thinner). */\nexport const BAR = 34;\n/** A rail's width. */\nexport const RAIL = 34;\n/** A folded section's (or a shaded palette's) height: its title bar. */\nexport const TITLE = 22;\n/** A tab row's height (navigator sides and drawers). */\nexport const TABS = 28;\n/** The smallest a tiled document may be where a construction promises it (the tiling tree, the strip). */\nexport const DOC_MIN: Size = { width: 240, height: 160 };\n\n/** Items are keyed \"panel:<id>\" and \"doc:<id>\". */\nexport const panelKey = (id: number): string => `panel:${id}`;\nexport const docKey = (id: number): string => `doc:${id}`;\nexport const isPanelKey = (key: string): boolean => key.startsWith(\"panel:\");\nexport const isDocKey = (key: string): boolean => key.startsWith(\"doc:\");\nexport const idOf = (key: string): number => Number(key.slice(key.indexOf(\":\") + 1));\n\n/** A tool panel: its title and the height its content needs (its natural height, title bar included). */\nexport interface PanelSpec {\n readonly id: number;\n readonly title: string;\n readonly natural: number;\n}\n\n/** Where the panels start. Unset parts follow from the sides (see `createDesk`). */\nexport interface DeskStart {\n readonly left: readonly number[];\n readonly right: readonly number[];\n readonly bottom: readonly number[];\n readonly active?: { readonly left: number | null; readonly right: number | null };\n readonly tree?: DeskState[\"tree\"];\n readonly cols?: DeskState[\"cols\"];\n readonly stacks?: DeskState[\"stacks\"];\n}\n\n/** What a desk is made of: its panels, its documents' titles and where the panels start. */\nexport interface DeskSpec {\n readonly panels: readonly PanelSpec[];\n /** A document's title (default \"Document <id>\"). */\n readonly docTitle?: (id: number) => string;\n readonly start: DeskStart;\n /** The panels in the order they were opened (default: as listed); the tiling tree floats the newest first. */\n readonly opened?: readonly number[];\n}\n\n/** The catalog every part reads: a panel's natural height, an item's title and age. */\nexport interface Catalog {\n readonly panelIds: readonly number[];\n readonly natural: (id: number) => number;\n /** An item's title by key (\"panel:<id>\", \"doc:<id>\"); any other key is its own title. */\n readonly title: (key: string) => string;\n /** An item's age: higher is newer (panels in the order they were opened, then the documents). */\n readonly born: (key: string) => number;\n readonly start: Required<DeskStart>;\n}\n\n/** The catalog for a spec (unset start parts filled in). */\nexport function catalogOf(spec: DeskSpec): Catalog {\n const byId = new Map(spec.panels.map((p) => [p.id, p]));\n const opened = spec.opened ?? spec.panels.map((p) => p.id);\n const docTitle = spec.docTitle ?? ((id: number) => `Document ${id}`);\n const { left, right, bottom } = spec.start;\n const rest = [...right, ...bottom];\n const start: Required<DeskStart> = {\n left,\n right,\n bottom,\n active: spec.start.active ?? { left: left[0] ?? null, right: right.at(-1) ?? null },\n tree: spec.start.tree ?? { L: left.map(panelKey), R: rest.map(panelKey), C: [] },\n cols: spec.start.cols ?? [left.map(panelKey), rest.map(panelKey)].filter((c) => c.length > 0),\n stacks: spec.start.stacks ?? { left, right: rest },\n };\n return {\n panelIds: spec.panels.map((p) => p.id),\n natural: (id) => byId.get(id)?.natural ?? TITLE,\n title: (key) => (isPanelKey(key) ? (byId.get(idOf(key))?.title ?? key) : isDocKey(key) ? docTitle(idOf(key)) : key),\n born: (key) => (isDocKey(key) ? 1000 + idOf(key) : opened.indexOf(idOf(key)) + 1),\n start,\n };\n}\n\n/** Where the toolbar floats (top or bottom) and whether the documents keep a band clear for it; the bottom dock's mode. */\nexport interface Options {\n readonly toolbar: \"top\" | \"bottom\";\n readonly toolbarSpace: \"reserved\" | \"overlay\";\n readonly bottom: \"reserved\" | \"overlay\" | \"off\";\n /** The pill's width when its contents need more than the default; unset: the default. */\n readonly toolbarWidth?: number;\n /** The pill holds nothing: it takes no space and isn't shown. */\n readonly toolbarHidden?: boolean;\n}\nexport const DEFAULT_OPTIONS: Options = { toolbar: \"top\", toolbarSpace: \"reserved\", bottom: \"reserved\" };\n\n/** A panel placed freely (torn off, or a palette out of its stack): its top-left corner, null for the default spot. */\nexport interface Free {\n readonly id: number;\n readonly at: { readonly x: number; readonly y: number } | null;\n}\n\n/**\n * Everything any construction keeps. Each construction has its own copy (its own arrangement) and reads only what\n * it uses; the open documents are the same in all of them.\n */\nexport interface DeskState {\n /** Open document ids, in open order. */\n readonly docs: readonly number[];\n readonly focus: number | null;\n /** Panel ids, least recently used first: what folds or shades first when height runs out. */\n readonly recent: readonly number[];\n /** Sections folded (palettes shaded) by hand. */\n readonly folded: readonly number[];\n /** Docks, navigator sides and drawers: the panels on each side, top to bottom (tabs: left to right). */\n readonly left: readonly number[];\n readonly right: readonly number[];\n /** The bottom dock's panels (edge docks only). */\n readonly bottom: readonly number[];\n /** Docks or drawers folded to their rail by hand. */\n readonly closed: readonly Side[];\n /** The side opened last by hand: when width runs out it folds last. */\n readonly opened: Side | null;\n /** The panel showing on each side (navigator, drawers). */\n readonly active: { readonly left: number | null; readonly right: number | null };\n /** Panels torn off a dock, floating (edge docks + tear-off). */\n readonly torn: readonly Free[];\n /** The tiling tree: item keys in the left column, the right column and the centre (dwindle order). */\n readonly tree: { readonly L: readonly string[]; readonly R: readonly string[]; readonly C: readonly string[] };\n /** The scrolling strip: its columns, left to right, each a list of item keys top to bottom. */\n readonly cols: readonly (readonly string[])[];\n /** The strip scrolled by hand, or null: it scrolls to the focus. */\n readonly stripScroll: number | null;\n /** Palettes: the corner stacks, top to bottom, and the ones placed anywhere. */\n readonly stacks: { readonly left: readonly number[]; readonly right: readonly number[] };\n readonly free: readonly Free[];\n}\n\n/** How an item is drawn. */\nexport type Look =\n | \"pill\" // the toolbar floating as a rounded pill\n | \"bar\" // the toolbar as a bar across the top\n | \"section\" // a panel open in a dock\n | \"header\" // a section folded (or a palette shaded) to its title bar\n | \"float\" // a panel floating over the documents\n | \"palette\" // a floating panel that reserves its footprint\n | \"tile\" // a panel tiled like a document\n | \"bare\" // a panel under a tab row: no title bar of its own\n | \"doc\"\n | \"rail\"\n | \"tabs\"\n | \"track\"\n | \"thumb\";\n\n/** Stacking layers, bottom to top. */\nexport const LAYER = { doc: 1, dock: 2, palette: 3, overlay: 4, float: 5, toolbar: 6 } as const;\n\n/** One item as a layout places it. */\nexport interface Placed {\n readonly rect: Rect;\n readonly look: Look;\n readonly layer: number;\n /** Folded away (into a rail, behind a tab): it goes to `rect`, hidden. */\n readonly hidden?: boolean;\n /** Never laid out below this (where the construction promises it). */\n readonly min?: Partial<Size>;\n /** It may lie outside the stage (the strip scrolls). */\n readonly offStage?: boolean;\n /** A rail's icons or a tab row's tabs (panel ids), and the active tab. */\n readonly icons?: readonly number[];\n readonly tabs?: readonly number[];\n readonly active?: number | null;\n /** Drawn with an accent outline (the bottom dock). */\n readonly accent?: boolean;\n /** Drawn with a shadow (it floats over something). */\n readonly shadow?: boolean;\n}\n\n/**\n * How a layout gave way (or what it is worth knowing about it):\n *\n * - `bottom-folded`: the bottom dock folded to its header; `dock-folded`: a side dock folded to its rail (`side`);\n * - `sections-folded`: sections folded to their headers by themselves, least recently used first;\n * - `torn-floating`: panels torn off a dock float (`items`); `torn-shaded`: some shade because they don't fit;\n * - `columns-railed`: the tiling tree's side columns are folded to rails (`side` when only one);\n * - `tiles-float`: tiles that broke a minimum float, newest first (`items`);\n * - `tabs-folded`: a tabbed side folded to icon tabs (`side`); `drawer-over`: a drawer slides over the\n * documents (`side`);\n * - `column-split`: a strip column split in two (`items`); `strip-scrolls`: the strip is wider than the stage;\n * - `stacks-merged`: both palette stacks share one corner; `palettes-shaded`: palettes shaded to title bars;\n * - `palettes-cover`, `docs-room`: how much of the documents palettes cover, and how much room they leave.\n */\nexport type NoteCode =\n | \"bottom-folded\"\n | \"dock-folded\"\n | \"sections-folded\"\n | \"torn-floating\"\n | \"torn-shaded\"\n | \"columns-railed\"\n | \"tiles-float\"\n | \"tabs-folded\"\n | \"drawer-over\"\n | \"column-split\"\n | \"strip-scrolls\"\n | \"stacks-merged\"\n | \"palettes-shaded\"\n | \"palettes-cover\"\n | \"docs-room\";\n\n/**\n * One note on a layout. `code` (and `side`, `items` where they apply) is the contract; `text` says it in English for\n * people, and its wording may change in any release.\n */\nexport interface Note {\n readonly code: NoteCode;\n readonly text: string;\n readonly side?: Side;\n /** The item keys it is about. */\n readonly items?: readonly string[];\n}\n\n/** Where everything is (\"toolbar\", \"panel:<id>\", \"doc:<id>\", \"rail:<side>\", \"tabs:<side>\", \"track\", \"thumb\"), and how it gave way. */\nexport interface Layout {\n readonly items: ReadonlyMap<string, Placed>;\n readonly notes: readonly Note[];\n}\n\n// --- state changes -------------------------------------------------------------------------------------------------\n\n/** The arrangement a catalog starts from, with these documents open (none by default). */\nexport function startState(cat: Catalog, docs: readonly number[] = []): DeskState {\n const st = cat.start;\n const base: DeskState = {\n docs: [],\n focus: null,\n recent: [...cat.panelIds],\n folded: [],\n left: [...st.left],\n right: [...st.right],\n bottom: [...st.bottom],\n closed: [],\n opened: null,\n active: st.active,\n torn: [],\n tree: st.tree,\n cols: st.cols,\n stripScroll: null,\n stacks: st.stacks,\n free: [],\n };\n return withDocs(base, docs, docs.at(-1) ?? null);\n}\n\n/**\n * The same state with these documents open: new ones join the tiling tree's centre (the first one at its front)\n * and get a strip column of their own after the last document column; closed ones leave both.\n */\nexport function withDocs(s: DeskState, docs: readonly number[], focus: number | null): DeskState {\n const keys = docs.map(docKey);\n const gone = (k: string): boolean => isDocKey(k) && !keys.includes(k);\n let C = s.tree.C.filter((k) => !gone(k));\n let cols = s.cols.map((c) => c.filter((k) => !gone(k))).filter((c) => c.length > 0);\n const has = (k: string): boolean => [...s.tree.L, ...s.tree.R, ...C].includes(k);\n for (const k of keys) {\n if (!has(k)) C = C.some(isDocKey) || C.length === 0 ? [...C, k] : [k, ...C];\n if (!cols.some((c) => c.includes(k))) {\n const lastDoc = cols.map((c) => c.some(isDocKey)).lastIndexOf(true);\n const at = lastDoc >= 0 ? lastDoc + 1 : Math.min(1, cols.length);\n cols = [...cols.slice(0, at), [k], ...cols.slice(at)];\n }\n }\n const L = s.tree.L.filter((k) => !gone(k));\n const R = s.tree.R.filter((k) => !gone(k));\n const f = focus !== null && docs.includes(focus) ? focus : (docs.at(-1) ?? null);\n // A new focus: the strip scrolls to it again.\n return { ...s, docs: [...docs], focus: f, tree: { L, R, C }, cols, stripScroll: f === s.focus ? s.stripScroll : null };\n}\n\n/** Panel `id` was used: it is the last to fold when height runs out. */\nexport const touch = (s: DeskState, id: number): DeskState => ({ ...s, recent: [...s.recent.filter((x) => x !== id), id] });\n\n/** Fold or unfold a section (shade or unshade a palette) by hand; unfolding is a use. */\nexport function toggleFold(s: DeskState, id: number): DeskState {\n const folded = s.folded.includes(id);\n const next = { ...s, folded: folded ? s.folded.filter((x) => x !== id) : [...s.folded, id] };\n return folded ? touch(next, id) : next;\n}\n\n/** Fold a dock (or drawer) to its rail by hand, or open it again (then it folds last when width runs out). */\nexport function toggleClosed(s: DeskState, side: Side): DeskState {\n const closed = s.closed.includes(side);\n return closed ? { ...s, closed: s.closed.filter((x) => x !== side), opened: side } : { ...s, closed: [...s.closed, side] };\n}\n\n/** Show panel `id` on its side (navigator, drawers). */\nexport const withActive = (s: DeskState, side: Side, id: number): DeskState => touch({ ...s, active: { ...s.active, [side]: id } }, id);\n\n/** The state with `key` lifted out of wherever it is (before a drop puts it somewhere). */\nexport function liftOut(s: DeskState, key: string): DeskState {\n const dropK = (l: readonly string[]): string[] => l.filter((k) => k !== key);\n const base: DeskState = { ...s, tree: { L: dropK(s.tree.L), R: dropK(s.tree.R), C: dropK(s.tree.C) }, cols: s.cols.map(dropK).filter((c) => c.length > 0) };\n if (!isPanelKey(key)) return base;\n const id = idOf(key);\n const drop = (l: readonly number[]): number[] => l.filter((x) => x !== id);\n return {\n ...base,\n left: drop(s.left),\n right: drop(s.right),\n bottom: drop(s.bottom),\n torn: s.torn.filter((f) => f.id !== id),\n free: s.free.filter((f) => f.id !== id),\n stacks: { left: drop(s.stacks.left), right: drop(s.stacks.right) },\n active: { left: s.active.left === id ? null : s.active.left, right: s.active.right === id ? null : s.active.right },\n };\n}\n","/**\n * The arrangers the desk constructions build on, internal to `./dock`: master and stack for the documents, dwindle\n * for the tiling tree's centre, stacked columns at natural heights, and the minimum-size give-way (the newest tile\n * that breaks a minimum floats). A public `./tiling` will come from a merge with a full split-tree model; these stay\n * the dock's own until then.\n */\nimport type { Rect, Size } from \"../geometry\";\n\n/**\n * Master and stack: the first id takes the left part (`ratio` of the width less the gap), the rest stack on the\n * right in equal rows. One id takes the whole area.\n */\nexport function masterStack<K>(ids: readonly K[], area: Rect, gap: number, ratio = 0.5): Map<K, Rect> {\n const out = new Map<K, Rect>();\n if (ids.length === 0) return out;\n if (ids.length === 1) {\n out.set(ids[0]!, { ...area });\n return out;\n }\n const mw = (area.width - gap) * ratio;\n out.set(ids[0]!, { x: area.x, y: area.y, width: mw, height: area.height });\n const k = ids.length - 1;\n const sh = (area.height - gap * (k - 1)) / k;\n ids.slice(1).forEach((id, i) => out.set(id, { x: area.x + mw + gap, y: area.y + i * (sh + gap), width: area.width - mw - gap, height: sh }));\n return out;\n}\n\n/** Dwindle over an order: each tile but the last splits the space left in two along its longer side. */\nexport function dwindle(area: Rect, n: number, gap: number): Rect[] {\n const out: Rect[] = [];\n let cur = { ...area };\n for (let i = 0; i < n; i++) {\n if (i === n - 1) {\n out.push(cur);\n break;\n }\n if (cur.width >= cur.height) {\n const w = (cur.width - gap) / 2;\n out.push({ x: cur.x, y: cur.y, width: w, height: cur.height });\n cur = { x: cur.x + w + gap, y: cur.y, width: w, height: cur.height };\n } else {\n const h = (cur.height - gap) / 2;\n out.push({ x: cur.x, y: cur.y, width: cur.width, height: h });\n cur = { x: cur.x, y: cur.y + h + gap, width: cur.width, height: h };\n }\n }\n return out;\n}\n\n/**\n * Heights for a column of items stacked in `avail` with gaps: each at its minimum (its natural height), the last\n * taking the rest. When the minimums don't fit, an even share instead, so the ones that break their minimum show.\n */\nexport function columnHeights(avail: number, mins: readonly number[], gap: number): number[] {\n const room = avail - gap * (mins.length - 1);\n const need = mins.reduce((a, b) => a + b, 0);\n if (need > room) return mins.map(() => room / mins.length);\n return mins.map((m, i) => (i === mins.length - 1 ? room - need + m : m));\n}\n\n/**\n * Lengths for items sharing `avail`: each gets at least its minimum, the rest of the room is shared in proportion\n * to the minimums (when the minimums don't fit, each gets its minimum).\n */\nexport function share(avail: number, mins: readonly number[]): number[] {\n const need = mins.reduce((a, b) => a + b, 0);\n const spare = Math.max(0, avail - need);\n return mins.map((m) => m + (need > 0 ? (spare * m) / need : spare / mins.length));\n}\n\n/**\n * The minimum-size give-way: while a tile is laid out below its minimum, the newest tile (highest `age`) floats and\n * the rest are laid out again. Stops when every tile keeps its minimum or one tile is left. `layout` lays out the\n * kept keys; the result says which are kept (in their order) and which float (newest first).\n */\nexport function giveWay<K>(keys: readonly K[], layout: (kept: readonly K[]) => ReadonlyMap<K, Rect>, min: (key: K) => Size, age: (key: K) => number): { kept: K[]; floats: K[] } {\n let kept = [...keys];\n const floats: K[] = [];\n for (;;) {\n const res = layout(kept);\n const broken = [...res].some(([k, r]) => r.width < min(k).width - 0.5 || r.height < min(k).height - 0.5);\n if (!broken || kept.length <= 1) return { kept, floats };\n const newest = kept.reduce((a, b) => (age(b) > age(a) ? b : a));\n kept = kept.filter((k) => k !== newest);\n floats.push(newest);\n }\n}\n","/**\n * The parts the desk constructions are built from, each pure: the toolbar pill, the documents' tiles, natural-height\n * sections (the last open one takes the rest; the least recently used fold to headers), rails, the edge docks'\n * geometry, the tiling tree's columns, the scrolling strip, tabbed sides and floating palettes.\n */\nimport { clampInto, rect, type Rect, type Size } from \"../geometry\";\nimport { columnHeights, dwindle, giveWay, masterStack } from \"./arrange\";\nimport { BAR, DOC_MIN, G, LAYER, RAIL, TABS, TITLE, docKey, idOf, isDocKey, panelKey, type Catalog, type DeskState, type Note, type Options, type Placed, type Side } from \"./model\";\n\nexport type Out = Map<string, Placed>;\n\nexport const plural = (n: number, one: string, many: string): string => `${n} ${n > 1 ? many : one}`;\n\n// --- the toolbar pill and the documents ----------------------------------------------------------------------------\n\n/** The shortest a pill gets (unless there is less room than that). */\nexport const PILL_MIN = 60;\n\n/**\n * The toolbar pill, floating at the top or the bottom of the band [y0, y1] above a region `cx`..`cx + cw`; returns\n * the pill and the band left for the documents (reserved: they keep clear of it; overlay: it floats over them).\n */\nexport function pill(opt: Options, cx: number, cw: number, y0: number, y1: number): { placed: Placed; top: number; bottom: number } {\n const pw = Math.max(PILL_MIN, Math.min(opt.toolbarWidth ?? 320, cw - 24));\n const ph = BAR - 4;\n const atTop = opt.toolbar === \"top\";\n // A hidden pill keeps no band clear, as if it floated.\n const overlay = opt.toolbarSpace === \"overlay\" || !!opt.toolbarHidden;\n return {\n placed: { rect: rect(cx + cw / 2 - pw / 2, atTop ? y0 + G : y1 - G - ph, pw, ph), look: \"pill\", layer: LAYER.toolbar, shadow: overlay, ...(opt.toolbarHidden ? { hidden: true } : {}) },\n top: atTop && !overlay ? y0 + BAR + 2 * G : y0 + G,\n bottom: !atTop && !overlay ? y1 - BAR - 2 * G : y1 - G,\n };\n}\n\n/** The toolbar as a bar across the top of the stage. */\nexport const bar = (W: number): Placed => ({ rect: rect(0, 0, W, BAR), look: \"bar\", layer: LAYER.toolbar });\n\n/** The documents in `r`, master and stack: the first takes 56 % of the width, the rest stack on the right. */\nexport function tiles(out: Out, r: Rect, ids: readonly number[], min?: Size): void {\n for (const [id, rr] of masterStack(ids, r, G, 0.56)) out.set(docKey(id), { rect: rr, look: \"doc\", layer: LAYER.doc, ...(min ? { min } : {}) });\n}\n\n// --- sections and rails --------------------------------------------------------------------------------------------\n\n/**\n * The ones of `ids` to fold, least recently used first, until what stays open fits `avail`. An accordion keeps one\n * section open whatever (`keepOne`); a palette stack shades even its last palette rather than run off the stage.\n */\nfunction lruFold(s: DeskState, ids: readonly number[], avail: number, open: (id: number) => number, closed: number, keepOne = true): number[] {\n const byHand = ids.filter((id) => s.folded.includes(id));\n const auto: number[] = [];\n const isOpen = (id: number): boolean => !byHand.includes(id) && !auto.includes(id);\n const need = (): number => ids.reduce((sum, id) => sum + (isOpen(id) ? open(id) : closed), 0) + G * (ids.length - 1);\n const order = [...s.recent].filter((id) => ids.includes(id));\n for (const id of order) {\n if (need() <= avail || (keepOne && ids.filter(isOpen).length <= 1)) break;\n if (isOpen(id)) auto.push(id);\n }\n return [...byHand, ...auto];\n}\n\n/**\n * Natural-height sections in x, y, w, h: each open section takes its natural height and the last open one takes\n * the rest; the least recently used fold to headers until the open ones fit. Returns how many folded by themselves.\n */\nexport function accordion(cat: Catalog, out: Out, s: DeskState, x: number, y: number, w: number, h: number, ids: readonly number[]): number {\n const folded = lruFold(s, ids, h, cat.natural, TITLE);\n const open = ids.filter((id) => !folded.includes(id));\n const room = h - G * (ids.length - 1) - TITLE * (ids.length - open.length);\n const last = open.at(-1);\n const rest = room - open.reduce((sum, id) => sum + (id === last ? 0 : cat.natural(id)), 0);\n let cy = y;\n for (const id of ids) {\n const i = open.indexOf(id);\n const n = cat.natural(id);\n const hh = i < 0 ? TITLE : id === last ? Math.max(n, rest) : n;\n out.set(panelKey(id), { rect: rect(x, cy, w, hh), look: i >= 0 ? \"section\" : \"header\", layer: LAYER.dock, ...(i >= 0 ? { min: { height: n } } : {}) });\n cy += hh + G;\n }\n return folded.filter((id) => !s.folded.includes(id)).length;\n}\n\n/** A rail of icons at x, y; the rect of its icon `i`. */\nconst railIcon =(x: number, y: number, i: number): Rect => rect(x + 6, y + 10 + i * 32, RAIL - 12, 24);\n\n/** A rail (a column whose panels are all folded) at x, y, h: one icon per panel. */\nexport function rail(out: Out, side: Side, x: number, y: number, h: number, ids: readonly number[], hidden = false): void {\n out.set(`rail:${side}`, { rect: rect(x, y, RAIL, h), look: \"rail\", layer: LAYER.dock, icons: ids, ...(hidden ? { hidden } : {}) });\n}\n\n/** Panels folded into a rail: hidden, each at its icon at `w` × its natural height. */\nexport function intoRail(cat: Catalog, out: Out, x: number, y: number, w: number, ids: readonly number[], side: Side): void {\n ids.forEach((id, i) => {\n const icon = railIcon(x, y, i);\n out.set(panelKey(id), { rect: rect(side === \"left\" ? icon.x : icon.x + icon.width - w, icon.y, w, cat.natural(id)), look: \"section\", layer: LAYER.dock, hidden: true });\n });\n}\n\n// --- edge docks ----------------------------------------------------------------------------------------------------\n\n/**\n * The dock width (rail excluded, its sections 240 px wide after the gap) and the narrowest the documents may get\n * before a dock folds.\n */\nexport const DOCK = 246;\nconst WORK_MIN = 380;\n/** The bottom dock's height when open, and the most of the stage's height it takes. */\nconst BOTTOM = 190;\nconst BOTTOM_SHARE = 0.36;\n\n/** What the edge docks put where: shared by their layouts and their drop targets. */\nexport interface DockGeometry {\n /** The side docks' height (less the bottom dock's in full-width mode). */\n readonly h: number;\n /** The bottom dock's height (its header's when folded; 0 when off). */\n readonly bh: number;\n readonly lOpen: boolean;\n readonly rOpen: boolean;\n /** The right dock's panels (the bottom dock's join them when it is off). */\n readonly right: readonly number[];\n readonly bottomOn: boolean;\n readonly bottomRect: Rect | null;\n /** The documents' band, left to right. */\n readonly x0: number;\n readonly x1: number;\n}\n\n/**\n * The edge docks' give-way: the bottom dock folds to its header when the stage is short, and a whole side dock\n * folds to its rail when the documents would get narrower than WORK_MIN (the right one first, unless it was opened\n * last by hand). `mode`: the bottom dock between the side docks, or across the full width under them.\n */\nexport function dockGeometry(cat: Catalog, s: DeskState, size: Size, opt: Options, mode: \"between\" | \"full\", notes: Note[] = []): DockGeometry {\n const { width: W, height: H } = size;\n const bottomOn = opt.bottom !== \"off\" && s.bottom.length > 0;\n const right = bottomOn ? s.right : [...s.right, ...s.bottom];\n const bottomFolded = bottomOn && (H < 480 || s.bottom.every((id) => s.folded.includes(id)));\n // Open, it is BOTTOM tall, never more than BOTTOM_SHARE of the stage (but never below what its panels need).\n const bh = !bottomOn ? 0 : bottomFolded ? TITLE : Math.max(...s.bottom.map(cat.natural), Math.min(BOTTOM, BOTTOM_SHARE * H));\n if (bottomOn && H < 480) notes.push({ code: \"bottom-folded\", text: \"bottom dock folded to its header\" });\n const full = mode === \"full\";\n const h = full && bottomOn ? H - bh - G : H;\n let lOpen = s.left.length > 0 && !s.closed.includes(\"left\");\n let rOpen = right.length > 0 && !s.closed.includes(\"right\");\n const work = (): number => W - 2 * RAIL - (lOpen ? DOCK : 0) - (rOpen ? DOCK : 0) - 2 * G;\n for (const side of s.opened === \"right\" ? ([\"left\", \"right\"] as const) : ([\"right\", \"left\"] as const)) {\n if (work() >= WORK_MIN) break;\n if (side === \"right\" && rOpen) {\n rOpen = false;\n notes.push({ code: \"dock-folded\", side: \"right\", text: \"right dock folded to its rail\" });\n } else if (side === \"left\" && lOpen) {\n lOpen = false;\n notes.push({ code: \"dock-folded\", side: \"left\", text: \"left dock folded to its rail\" });\n }\n }\n const x0 = RAIL + (lOpen ? DOCK : 0) + G;\n const x1 = W - RAIL - (rOpen ? DOCK : 0) - G;\n const bottomRect = bottomOn ? (full ? rect(G, H - G - bh, W - 2 * G, bh) : rect(x0, H - G - bh, x1 - x0, bh)) : null;\n return { h, bh, lOpen, rOpen, right, bottomOn, bottomRect, x0, x1 };\n}\n\n/** The width of a torn-off panel (its height is its natural height). */\nexport const TORN_W = 200;\n\n// --- the tiling tree -----------------------------------------------------------------------------------------------\n\n/** The smallest a tile may be: a document's minimum, or a panel at its natural height. */\nexport const tileMin = (cat: Catalog, key: string): Size => (isDocKey(key) ? DOC_MIN : { width: 150, height: cat.natural(idOf(key)) });\n/** A side column's width. */\nexport const TREE_COLUMN = 180;\n\n/** The tree's tiles laid out (no floating): the left and right columns, the centre by dwindle. */\nexport function treeTiles(cat: Catalog, tree: DeskState[\"tree\"], area: Rect): Map<string, Rect> {\n const res = new Map<string, Rect>();\n let x0 = area.x;\n let x1 = area.x + area.width;\n // A side column's tiles take their natural height, the last one the rest.\n const column = (list: readonly string[], x: number): void => {\n const heights = columnHeights(area.height, list.map((k) => tileMin(cat, k).height), G);\n let y = area.y;\n list.forEach((k, i) => {\n res.set(k, rect(x, y, TREE_COLUMN, heights[i]!));\n y += heights[i]! + G;\n });\n };\n if (tree.L.length) {\n column(tree.L, x0);\n x0 += TREE_COLUMN + G;\n }\n if (tree.R.length) {\n column(tree.R, x1 - TREE_COLUMN);\n x1 -= TREE_COLUMN + G;\n }\n dwindle(rect(x0, area.y, x1 - x0, area.height), tree.C.length, G).forEach((r, i) => res.set(tree.C[i]!, r));\n return res;\n}\n\n/** The sides of the tree whose column is folded to a rail at the stage's edge (closed by hand, or at a narrow start). */\nexport const treeRails = (s: DeskState): { readonly left: boolean; readonly right: boolean } => ({\n left: s.closed.includes(\"left\") && s.tree.L.length > 0,\n right: s.closed.includes(\"right\") && s.tree.R.length > 0,\n});\n\n/** The area the tree tiles: the stage under the bar, less the rails of folded columns. */\nexport const treeArea = (size: Size, s?: DeskState): Rect => {\n const r = s ? treeRails(s) : { left: false, right: false };\n const x0 = r.left ? RAIL + G : G;\n const x1 = size.width - (r.right ? RAIL + G : G);\n return rect(x0, BAR + G, x1 - x0, size.height - BAR - 2 * G);\n};\n\n/** The tree as tiled: a column folded to its rail tiles nothing. */\nexport const treeShown = (s: DeskState): DeskState[\"tree\"] => {\n const r = treeRails(s);\n return { L: r.left ? [] : s.tree.L, R: r.right ? [] : s.tree.R, C: s.tree.C };\n};\n\n/** Which tiles float: the newest tile that breaks a minimum floats, then the tree is laid out again. */\nexport function treeFloats(cat: Catalog, tree: DeskState[\"tree\"], area: Rect): { tree: DeskState[\"tree\"]; floats: string[] } {\n const only = (kept: readonly string[]): DeskState[\"tree\"] => ({ L: tree.L.filter((k) => kept.includes(k)), R: tree.R.filter((k) => kept.includes(k)), C: tree.C.filter((k) => kept.includes(k)) });\n const { kept, floats } = giveWay(\n [...tree.L, ...tree.R, ...tree.C],\n (k) => treeTiles(cat, only(k), area),\n (k) => tileMin(cat, k),\n cat.born,\n );\n return { tree: only(kept), floats };\n}\n\n// --- tabbed sides --------------------------------------------------------------------------------------------------\n\n/**\n * One side with tabs: the tab row on top, the active panel under it, the others hidden behind it. `float` puts\n * them over the documents (a drawer that slides over).\n */\nexport function tabbed(out: Out, side: Side, ids: readonly number[], active: number | null, x: number, y: number, w: number, h: number, float: boolean): void {\n const shown = active !== null && ids.includes(active) ? active : (ids[0] ?? null);\n out.set(`tabs:${side}`, { rect: rect(x, y, w, TABS), look: \"tabs\", layer: float ? LAYER.float : LAYER.dock, tabs: ids, active: shown, ...(float ? { shadow: true } : {}) });\n for (const id of ids) {\n const r = rect(x, y + TABS, w, h - TABS);\n out.set(panelKey(id), { rect: r, look: \"bare\", layer: float ? LAYER.float : LAYER.dock, ...(id === shown ? {} : { hidden: true }), ...(float ? { shadow: true } : {}) });\n }\n}\n\n/** A side folded to its rail: the tab row and the panels hidden into it. */\nexport function tabbedIntoRail(cat: Catalog, out: Out, side: Side, ids: readonly number[], x: number, y: number, w: number): void {\n out.set(`tabs:${side}`, { rect: rect(side === \"left\" ? x : x + RAIL - w, y, w, TABS), look: \"tabs\", layer: LAYER.dock, tabs: ids, active: null, hidden: true });\n intoRail(cat, out, x, y, w, ids, side);\n}\n\n/** Below these widths a drawer slides over the documents instead of pushing them. */\nexport const DRAWER_DOCK = { left: 760, right: 1040 } as const;\n\n// --- the scrolling strip -------------------------------------------------------------------------------------------\n\nconst STRIP_PANEL_W = 180;\nconst stripDocW =(W: number): number => Math.max(360, Math.min(520, W * 0.5));\nexport const stripMin = (cat: Catalog, k: string): number => (isDocKey(k) ? DOC_MIN.height : cat.natural(idOf(k)));\n\n/** The strip's columns as laid out: a column whose minimums don't fit the height splits in two, recursively. */\nexport function stripColumns(cat: Catalog, cols: readonly (readonly string[])[], h: number, notes: Note[] = []): string[][] {\n const split = (keys: readonly string[]): string[][] => {\n const need = keys.reduce((sum, k) => sum + stripMin(cat, k), 0) + G * (keys.length - 1);\n if (need <= h || keys.length === 1) return [[...keys]];\n const half = Math.ceil(keys.length / 2);\n notes.push({ code: \"column-split\", items: [...keys], text: `${keys.map(cat.title).join(\" + \")} split into two columns` });\n return [...split(keys.slice(0, half)), ...split(keys.slice(half))];\n };\n return cols.flatMap(split);\n}\n\nexport interface StripGeometry {\n readonly cols: string[][];\n /** Each column's left edge on the stage (scroll applied) and width. */\n readonly xs: number[];\n readonly widths: number[];\n readonly y: number;\n readonly h: number;\n /** The whole strip's width, and how far it is scrolled. */\n readonly total: number;\n readonly scroll: number;\n}\n\n/** The strip's columns and scroll: scrolled by hand, else to centre the focused document's column. */\nexport function stripGeometry(cat: Catalog, s: DeskState, size: Size, notes: Note[] = []): StripGeometry {\n const { width: W, height: H } = size;\n const y = BAR + G;\n const h = H - BAR - 2 * G;\n const cols = stripColumns(cat, s.cols, h, notes);\n const widths = cols.map((c) => (c.some(isDocKey) ? stripDocW(W) : STRIP_PANEL_W));\n const total = widths.reduce((a, b) => a + b, 0) + G * (cols.length + 1);\n const want = s.focus !== null ? docKey(s.focus) : null;\n let fi = cols.findIndex((c) => want !== null && c.includes(want));\n if (fi < 0) fi = cols.findIndex((c) => c.some(isDocKey));\n const xsAbs: number[] = [];\n let x = G;\n for (const w of widths) {\n xsAbs.push(x);\n x += w + G;\n }\n const focusX = fi >= 0 ? xsAbs[fi]! + widths[fi]! / 2 : 0;\n const scroll = Math.max(0, Math.min(total - W, s.stripScroll ?? focusX - W / 2));\n return { cols, xs: xsAbs.map((v) => v - scroll), widths, y, h, total, scroll };\n}\n\n// --- floating palettes ---------------------------------------------------------------------------------------------\n\nexport const paletteWidth = (W: number): number => Math.min(200, Math.max(140, W * 0.22));\n/** Narrower than this, both stacks share the right corner. */\nexport const PALETTE_NARROW = 640;\n/** The margin palettes keep from the area's edges when they float over the documents. */\nexport const OVER_MARGIN = 14;\n\n/**\n * Palettes at their natural size, stacked in the top corners of `area` (`m` in from its edges), and the free ones\n * where they were put; a stack too tall for the area shades its least recently used palettes to their title bars.\n */\nexport function palettes(cat: Catalog, s: DeskState, area: Rect, W: number, m: number, notes: Note[] = []): Map<number, { rect: Rect; shaded: boolean }> {\n const pw = paletteWidth(W);\n const avail = area.height - 2 * m;\n const narrow = W < PALETTE_NARROW;\n const stacks = narrow ? [[...s.stacks.left, ...s.stacks.right]] : [s.stacks.left, s.stacks.right];\n if (narrow && s.stacks.left.length && s.stacks.right.length) notes.push({ code: \"stacks-merged\", text: \"both stacks share the right corner\" });\n const out = new Map<number, { rect: Rect; shaded: boolean }>();\n let shaded = 0;\n stacks.forEach((ids, si) => {\n const folded = lruFold(s, ids, avail, cat.natural, TITLE, false);\n shaded += folded.filter((id) => !s.folded.includes(id)).length;\n const x = narrow || si === 1 ? area.x + area.width - m - pw : area.x + m;\n let y = area.y + m;\n for (const id of ids) {\n const h = folded.includes(id) ? TITLE : cat.natural(id);\n out.set(id, { rect: rect(x, y, pw, h), shaded: folded.includes(id) });\n y += h + G;\n }\n });\n for (const f of s.free) {\n const shade = s.folded.includes(f.id);\n const at = f.at ?? { x: area.x + m, y: area.y + m };\n out.set(f.id, { rect: clampInto(rect(at.x, at.y, pw, shade ? TITLE : cat.natural(f.id)), area), shaded: shade });\n }\n if (shaded) notes.push({ code: \"palettes-shaded\", text: `${plural(shaded, \"palette\", \"palettes\")} shaded to ${shaded > 1 ? \"title bars\" : \"a title bar\"}` });\n return out;\n}\n\n/** The stage area palettes and documents share (below or above the pill when it keeps its band). */\nexport function paletteArea(size: Size, opt: Options): { area: Rect } {\n const p = pill(opt, G, size.width - 2 * G, 0, size.height);\n return { area: rect(G, p.top, size.width - 2 * G, p.bottom - p.top) };\n}\n\n/**\n * A floating pill among palettes: in a stretch of its band that no palette crosses, so it never covers one. Of the\n * stretches wide enough for a full-width pill (its minimum plus margins), the one nearest the centre; with none, the\n * widest, the pill shrunk to fit it.\n */\nexport function pillBetween(opt: Options, size: Size, blocks: readonly Rect[]): Placed {\n const band = pill(opt, G, size.width - 2 * G, 0, size.height).placed.rect;\n const spans = blocks\n .filter((r) => r.y < band.y + band.height && r.y + r.height > band.y)\n .map((r) => [r.x - G, r.x + r.width + G] as const)\n .sort((a, b) => a[0] - b[0]);\n const stretches: [number, number][] = [];\n let x = G;\n for (const [b0, b1] of spans) {\n if (b0 > x) stretches.push([x, b0]);\n x = Math.max(x, b1);\n }\n if (size.width - G > x) stretches.push([x, size.width - G]);\n const roomy = stretches.filter(([a, b]) => b - a >= PILL_MIN + 24);\n const mid = size.width / 2;\n const pick =\n roomy.sort((p, q) => Math.abs((p[0] + p[1]) / 2 - mid) - Math.abs((q[0] + q[1]) / 2 - mid))[0] ??\n stretches.sort((p, q) => q[1] - q[0] - (p[1] - p[0]))[0] ??\n ([G, G] as [number, number]);\n const placed = pill(opt, pick[0], pick[1] - pick[0], 0, size.height).placed;\n const room = pick[1] - pick[0];\n // Too little room for even the shortest pill: it shrinks to the room rather than cover a palette.\n return placed.rect.width <= room ? placed : { ...placed, rect: { ...placed.rect, x: pick[0], width: Math.max(0, room) } };\n}\n\n/** The documents' band between the palettes on the left half and those on the right half. */\nexport function aroundDocs(pals: ReadonlyMap<number, { rect: Rect }>, area: Rect): Rect {\n const mid = area.x + area.width / 2;\n const rects = [...pals.values()].map((p) => p.rect);\n const left = rects.filter((r) => r.x + r.width / 2 < mid);\n const right = rects.filter((r) => r.x + r.width / 2 >= mid);\n const x0 = left.length ? Math.max(...left.map((r) => r.x + r.width)) + G : area.x;\n const x1 = right.length ? Math.min(...right.map((r) => r.x)) - G : area.x + area.width;\n return rect(x0, area.y, Math.max(0, x1 - x0), area.height);\n}\n"],"mappings":";;;;;;AAUO,IAAM,IAAI;AAEV,IAAM,MAAM;AAEZ,IAAM,OAAO;AAEb,IAAM,QAAQ;AAEd,IAAM,OAAO;AAEb,IAAM,UAAgB,EAAE,OAAO,KAAK,QAAQ,IAAI;AAGhD,IAAM,WAAW,CAAC,OAAuB,SAAS,EAAE;AACpD,IAAM,SAAS,CAAC,OAAuB,OAAO,EAAE;AAChD,IAAM,aAAa,CAAC,QAAyB,IAAI,WAAW,QAAQ;AACpE,IAAM,WAAW,CAAC,QAAyB,IAAI,WAAW,MAAM;AAChE,IAAM,OAAO,CAAC,QAAwB,OAAO,IAAI,MAAM,IAAI,QAAQ,GAAG,IAAI,CAAC,CAAC;AA0C5E,SAAS,UAAU,MAAyB;AACjD,QAAM,OAAO,IAAI,IAAI,KAAK,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AACtD,QAAM,SAAS,KAAK,UAAU,KAAK,OAAO,IAAI,CAAC,MAAM,EAAE,EAAE;AACzD,QAAM,WAAW,KAAK,aAAa,CAAC,OAAe,YAAY,EAAE;AACjE,QAAM,EAAE,MAAM,OAAO,OAAO,IAAI,KAAK;AACrC,QAAM,OAAO,CAAC,GAAG,OAAO,GAAG,MAAM;AACjC,QAAM,QAA6B;AAAA,IACjC;AAAA,IACA;AAAA,IACA;AAAA,IACA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AE,GAAG,OAAO,MAAM,GAAG,KAAK,CAAC,GAAG,OAAO,KAAK,IAAI,GAAG,IAAI,EAAE,EAAE;AAC1H;AAGO,SAAS,WAAW,MAA2C,MAAkB;AACtF,QAAM,MAAM,KAAK,IAAI,KAAK,QAAQ;AAClC,QAAM,QAAQ,CAAC,GAAG,KAAK,OAAO,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI;AAClD,QAAM,OAAO,MAAM,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,IAAI,GAAG;AACxD,QAAM,QAAQ,MAAM,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,KAAK,GAAG;AAC1D,QAAM,KAAK,KAAK,SAAS,KAAK,IAAI,GAAG,KAAK,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,KAAK;AAChF,QAAM,KAAK,MAAM,SAAS,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,IAAI,KAAK,IAAI,KAAK;AACjF,SAAO,KAAK,IAAI,KAAK,GAAG,KAAK,IAAI,GAAG,KAAK,EAAE,GAAG,KAAK,MAAM;AAC3D;","names":["kept"]}
1
+ {"version":3,"sources":["../src/dock/model.ts","../src/dock/arrange.ts","../src/dock/parts.ts"],"sourcesContent":["/**\n * The desk's model: panels and documents, the options, the state every construction keeps, and what a layout\n * returns (a placed rect per item). The panels themselves (their titles and natural heights) come from the\n * consumer as a catalog; see `createDesk`.\n */\nimport type { Rect, Size } from \"../geometry\";\n\nexport type Side = \"left\" | \"right\";\n\n/** Gaps and sizes, in stage px. */\nexport const G = 6;\n/** A toolbar bar's height (the pill is 4 px thinner). */\nexport const BAR = 34;\n/** A rail's width. */\nexport const RAIL = 34;\n/** A folded section's (or a shaded palette's) height: its title bar. */\nexport const TITLE = 22;\n/** A tab row's height (navigator sides and drawers). */\nexport const TABS = 28;\n/** The smallest a tiled document may be where a construction promises it (the tiling tree, the strip). */\nexport const DOC_MIN: Size = { width: 240, height: 160 };\n\n/** Items are keyed \"panel:<id>\" and \"doc:<id>\". */\nexport const panelKey = (id: number): string => `panel:${id}`;\nexport const docKey = (id: number): string => `doc:${id}`;\nexport const isPanelKey = (key: string): boolean => key.startsWith(\"panel:\");\nexport const isDocKey = (key: string): boolean => key.startsWith(\"doc:\");\nexport const idOf = (key: string): number => Number(key.slice(key.indexOf(\":\") + 1));\n\n/** A tool panel: its title and the height its content needs (its natural height, title bar included). */\nexport interface PanelSpec {\n readonly id: number;\n readonly title: string;\n readonly natural: number;\n}\n\n/** Where the panels start. Unset parts follow from the sides (see `createDesk`). */\nexport interface DeskStart {\n readonly left: readonly number[];\n readonly right: readonly number[];\n readonly bottom: readonly number[];\n readonly active?: { readonly left: number | null; readonly right: number | null };\n readonly tree?: DeskState[\"tree\"];\n readonly cols?: DeskState[\"cols\"];\n readonly stacks?: DeskState[\"stacks\"];\n}\n\n/** What a desk is made of: its panels, its documents' titles and where the panels start. */\nexport interface DeskSpec {\n readonly panels: readonly PanelSpec[];\n /** A document's title (default \"Document <id>\"). */\n readonly docTitle?: (id: number) => string;\n readonly start: DeskStart;\n /** The panels in the order they were opened (default: as listed); the tiling tree floats the newest first. */\n readonly opened?: readonly number[];\n}\n\n/** The catalog every part reads: a panel's natural height, an item's title and age. */\nexport interface Catalog {\n readonly panelIds: readonly number[];\n readonly natural: (id: number) => number;\n /** An item's title by key (\"panel:<id>\", \"doc:<id>\"); any other key is its own title. */\n readonly title: (key: string) => string;\n /** An item's age: higher is newer (panels in the order they were opened, then the documents). */\n readonly born: (key: string) => number;\n readonly start: Required<DeskStart>;\n}\n\n/** The catalog for a spec (unset start parts filled in). */\nexport function catalogOf(spec: DeskSpec): Catalog {\n const byId = new Map(spec.panels.map((p) => [p.id, p]));\n const opened = spec.opened ?? spec.panels.map((p) => p.id);\n const docTitle = spec.docTitle ?? ((id: number) => `Document ${id}`);\n const { left, right, bottom } = spec.start;\n const rest = [...right, ...bottom];\n const start: Required<DeskStart> = {\n left,\n right,\n bottom,\n active: spec.start.active ?? { left: left[0] ?? null, right: right.at(-1) ?? null },\n tree: spec.start.tree ?? { L: left.map(panelKey), R: rest.map(panelKey), C: [] },\n cols: spec.start.cols ?? [left.map(panelKey), rest.map(panelKey)].filter((c) => c.length > 0),\n stacks: spec.start.stacks ?? { left, right: rest },\n };\n return {\n panelIds: spec.panels.map((p) => p.id),\n natural: (id) => byId.get(id)?.natural ?? TITLE,\n title: (key) => (isPanelKey(key) ? (byId.get(idOf(key))?.title ?? key) : isDocKey(key) ? docTitle(idOf(key)) : key),\n born: (key) => (isDocKey(key) ? 1000 + idOf(key) : opened.indexOf(idOf(key)) + 1),\n start,\n };\n}\n\n/** Where the toolbar floats (top or bottom) and whether the documents keep a band clear for it; the bottom dock's mode. */\nexport interface Options {\n readonly toolbar: \"top\" | \"bottom\";\n readonly toolbarSpace: \"reserved\" | \"overlay\";\n readonly bottom: \"reserved\" | \"overlay\" | \"off\";\n /** The pill's width when its contents need more than the default; unset: the default. */\n readonly toolbarWidth?: number;\n /** The pill holds nothing: it takes no space and isn't shown. */\n readonly toolbarHidden?: boolean;\n}\nexport const DEFAULT_OPTIONS: Options = { toolbar: \"top\", toolbarSpace: \"reserved\", bottom: \"reserved\" };\n\n/** A panel placed freely (torn off, or a palette out of its stack): its top-left corner, null for the default spot. */\nexport interface Free {\n readonly id: number;\n readonly at: { readonly x: number; readonly y: number } | null;\n}\n\n/**\n * Everything any construction keeps. Each construction has its own copy (its own arrangement) and reads only what\n * it uses; the open documents are the same in all of them.\n */\nexport interface DeskState {\n /** Open document ids, in open order. */\n readonly docs: readonly number[];\n readonly focus: number | null;\n /** Panel ids, least recently used first: what folds or shades first when height runs out. */\n readonly recent: readonly number[];\n /** Sections folded (palettes shaded) by hand. */\n readonly folded: readonly number[];\n /** Docks, navigator sides and drawers: the panels on each side, top to bottom (tabs: left to right). */\n readonly left: readonly number[];\n readonly right: readonly number[];\n /** The bottom dock's panels (edge docks only). */\n readonly bottom: readonly number[];\n /** Docks or drawers folded to their rail by hand. */\n readonly closed: readonly Side[];\n /** The side opened last by hand: when width runs out it folds last. */\n readonly opened: Side | null;\n /** The panel showing on each side (navigator, drawers). */\n readonly active: { readonly left: number | null; readonly right: number | null };\n /** Panels torn off a dock, floating (edge docks + tear-off). */\n readonly torn: readonly Free[];\n /** The tiling tree: item keys in the left column, the right column and the center (dwindle order). */\n readonly tree: { readonly L: readonly string[]; readonly R: readonly string[]; readonly C: readonly string[] };\n /** The scrolling strip: its columns, left to right, each a list of item keys top to bottom. */\n readonly cols: readonly (readonly string[])[];\n /** The strip scrolled by hand, or null: it scrolls to the focus. */\n readonly stripScroll: number | null;\n /** Palettes: the corner stacks, top to bottom, and the ones placed anywhere. */\n readonly stacks: { readonly left: readonly number[]; readonly right: readonly number[] };\n readonly free: readonly Free[];\n}\n\n/** How an item is drawn. */\nexport type Look =\n | \"pill\" // the toolbar floating as a rounded pill\n | \"bar\" // the toolbar as a bar across the top\n | \"section\" // a panel open in a dock\n | \"header\" // a section folded (or a palette shaded) to its title bar\n | \"float\" // a panel floating over the documents\n | \"palette\" // a floating panel that reserves its footprint\n | \"tile\" // a panel tiled like a document\n | \"bare\" // a panel under a tab row: no title bar of its own\n | \"doc\"\n | \"rail\"\n | \"tabs\"\n | \"track\"\n | \"thumb\";\n\n/** Stacking layers, bottom to top. */\nexport const LAYER = { doc: 1, dock: 2, palette: 3, overlay: 4, float: 5, toolbar: 6 } as const;\n\n/** One item as a layout places it. */\nexport interface Placed {\n readonly rect: Rect;\n readonly look: Look;\n readonly layer: number;\n /** Folded away (into a rail, behind a tab): it goes to `rect`, hidden. */\n readonly hidden?: boolean;\n /** Never laid out below this (where the construction promises it). */\n readonly min?: Partial<Size>;\n /** It may lie outside the stage (the strip scrolls). */\n readonly offStage?: boolean;\n /** A rail's icons or a tab row's tabs (panel ids), and the active tab. */\n readonly icons?: readonly number[];\n readonly tabs?: readonly number[];\n readonly active?: number | null;\n /** Drawn with an accent outline (the bottom dock). */\n readonly accent?: boolean;\n /** Drawn with a shadow (it floats over something). */\n readonly shadow?: boolean;\n}\n\n/**\n * How a layout gave way (or what it is worth knowing about it):\n *\n * - `bottom-folded`: the bottom dock folded to its header; `dock-folded`: a side dock folded to its rail (`side`);\n * - `sections-folded`: sections folded to their headers by themselves, least recently used first;\n * - `torn-floating`: panels torn off a dock float (`items`); `torn-shaded`: some shade because they don't fit;\n * - `columns-railed`: the tiling tree's side columns are folded to rails (`side` when only one);\n * - `tiles-float`: tiles that broke a minimum float, newest first (`items`);\n * - `tabs-folded`: a tabbed side folded to icon tabs (`side`); `drawer-over`: a drawer slides over the\n * documents (`side`);\n * - `column-split`: a strip column split in two (`items`); `strip-scrolls`: the strip is wider than the stage;\n * - `stacks-merged`: both palette stacks share one corner; `palettes-shaded`: palettes shaded to title bars;\n * - `palettes-cover`, `docs-room`: how much of the documents palettes cover, and how much room they leave.\n */\nexport type NoteCode =\n | \"bottom-folded\"\n | \"dock-folded\"\n | \"sections-folded\"\n | \"torn-floating\"\n | \"torn-shaded\"\n | \"columns-railed\"\n | \"tiles-float\"\n | \"tabs-folded\"\n | \"drawer-over\"\n | \"column-split\"\n | \"strip-scrolls\"\n | \"stacks-merged\"\n | \"palettes-shaded\"\n | \"palettes-cover\"\n | \"docs-room\";\n\n/**\n * One note on a layout. `code` (and `side`, `items` where they apply) is the contract; `text` says it in English for\n * people, and its wording may change in any release.\n */\nexport interface Note {\n readonly code: NoteCode;\n readonly text: string;\n readonly side?: Side;\n /** The item keys it is about. */\n readonly items?: readonly string[];\n}\n\n/** Where everything is (\"toolbar\", \"panel:<id>\", \"doc:<id>\", \"rail:<side>\", \"tabs:<side>\", \"track\", \"thumb\"), and how it gave way. */\nexport interface Layout {\n readonly items: ReadonlyMap<string, Placed>;\n readonly notes: readonly Note[];\n}\n\n// --- state changes -------------------------------------------------------------------------------------------------\n\n/** The arrangement a catalog starts from, with these documents open (none by default). */\nexport function startState(cat: Catalog, docs: readonly number[] = []): DeskState {\n const st = cat.start;\n const base: DeskState = {\n docs: [],\n focus: null,\n recent: [...cat.panelIds],\n folded: [],\n left: [...st.left],\n right: [...st.right],\n bottom: [...st.bottom],\n closed: [],\n opened: null,\n active: st.active,\n torn: [],\n tree: st.tree,\n cols: st.cols,\n stripScroll: null,\n stacks: st.stacks,\n free: [],\n };\n return withDocs(base, docs, docs.at(-1) ?? null);\n}\n\n/**\n * The same state with these documents open: new ones join the tiling tree's center (the first one at its front)\n * and get a strip column of their own after the last document column; closed ones leave both.\n */\nexport function withDocs(s: DeskState, docs: readonly number[], focus: number | null): DeskState {\n const keys = docs.map(docKey);\n const gone = (k: string): boolean => isDocKey(k) && !keys.includes(k);\n let C = s.tree.C.filter((k) => !gone(k));\n let cols = s.cols.map((c) => c.filter((k) => !gone(k))).filter((c) => c.length > 0);\n const has = (k: string): boolean => [...s.tree.L, ...s.tree.R, ...C].includes(k);\n for (const k of keys) {\n if (!has(k)) C = C.some(isDocKey) || C.length === 0 ? [...C, k] : [k, ...C];\n if (!cols.some((c) => c.includes(k))) {\n const lastDoc = cols.map((c) => c.some(isDocKey)).lastIndexOf(true);\n const at = lastDoc >= 0 ? lastDoc + 1 : Math.min(1, cols.length);\n cols = [...cols.slice(0, at), [k], ...cols.slice(at)];\n }\n }\n const L = s.tree.L.filter((k) => !gone(k));\n const R = s.tree.R.filter((k) => !gone(k));\n const f = focus !== null && docs.includes(focus) ? focus : (docs.at(-1) ?? null);\n // A new focus: the strip scrolls to it again.\n return { ...s, docs: [...docs], focus: f, tree: { L, R, C }, cols, stripScroll: f === s.focus ? s.stripScroll : null };\n}\n\n/** Panel `id` was used: it is the last to fold when height runs out. */\nexport const touch = (s: DeskState, id: number): DeskState => ({ ...s, recent: [...s.recent.filter((x) => x !== id), id] });\n\n/** Fold or unfold a section (shade or unshade a palette) by hand; unfolding is a use. */\nexport function toggleFold(s: DeskState, id: number): DeskState {\n const folded = s.folded.includes(id);\n const next = { ...s, folded: folded ? s.folded.filter((x) => x !== id) : [...s.folded, id] };\n return folded ? touch(next, id) : next;\n}\n\n/** Fold a dock (or drawer) to its rail by hand, or open it again (then it folds last when width runs out). */\nexport function toggleClosed(s: DeskState, side: Side): DeskState {\n const closed = s.closed.includes(side);\n return closed ? { ...s, closed: s.closed.filter((x) => x !== side), opened: side } : { ...s, closed: [...s.closed, side] };\n}\n\n/** Show panel `id` on its side (navigator, drawers). */\nexport const withActive = (s: DeskState, side: Side, id: number): DeskState => touch({ ...s, active: { ...s.active, [side]: id } }, id);\n\n/** The state with `key` lifted out of wherever it is (before a drop puts it somewhere). */\nexport function liftOut(s: DeskState, key: string): DeskState {\n const dropK = (l: readonly string[]): string[] => l.filter((k) => k !== key);\n const base: DeskState = { ...s, tree: { L: dropK(s.tree.L), R: dropK(s.tree.R), C: dropK(s.tree.C) }, cols: s.cols.map(dropK).filter((c) => c.length > 0) };\n if (!isPanelKey(key)) return base;\n const id = idOf(key);\n const drop = (l: readonly number[]): number[] => l.filter((x) => x !== id);\n return {\n ...base,\n left: drop(s.left),\n right: drop(s.right),\n bottom: drop(s.bottom),\n torn: s.torn.filter((f) => f.id !== id),\n free: s.free.filter((f) => f.id !== id),\n stacks: { left: drop(s.stacks.left), right: drop(s.stacks.right) },\n active: { left: s.active.left === id ? null : s.active.left, right: s.active.right === id ? null : s.active.right },\n };\n}\n","/**\n * The arrangers the desk constructions build on, internal to `./dock`: master and stack for the documents, dwindle\n * for the tiling tree's center, stacked columns at natural heights, and the minimum-size give-way (the newest tile\n * that breaks a minimum floats). A public `./tiling` will come from a merge with a full split-tree model; these stay\n * the dock's own until then.\n */\nimport type { Rect, Size } from \"../geometry\";\n\n/**\n * Master and stack: the first id takes the left part (`ratio` of the width less the gap), the rest stack on the\n * right in equal rows. One id takes the whole area.\n */\nexport function masterStack<K>(ids: readonly K[], area: Rect, gap: number, ratio = 0.5): Map<K, Rect> {\n const out = new Map<K, Rect>();\n if (ids.length === 0) return out;\n if (ids.length === 1) {\n out.set(ids[0]!, { ...area });\n return out;\n }\n const mw = (area.width - gap) * ratio;\n out.set(ids[0]!, { x: area.x, y: area.y, width: mw, height: area.height });\n const k = ids.length - 1;\n const sh = (area.height - gap * (k - 1)) / k;\n ids.slice(1).forEach((id, i) => out.set(id, { x: area.x + mw + gap, y: area.y + i * (sh + gap), width: area.width - mw - gap, height: sh }));\n return out;\n}\n\n/** Dwindle over an order: each tile but the last splits the space left in two along its longer side. */\nexport function dwindle(area: Rect, n: number, gap: number): Rect[] {\n const out: Rect[] = [];\n let cur = { ...area };\n for (let i = 0; i < n; i++) {\n if (i === n - 1) {\n out.push(cur);\n break;\n }\n if (cur.width >= cur.height) {\n const w = (cur.width - gap) / 2;\n out.push({ x: cur.x, y: cur.y, width: w, height: cur.height });\n cur = { x: cur.x + w + gap, y: cur.y, width: w, height: cur.height };\n } else {\n const h = (cur.height - gap) / 2;\n out.push({ x: cur.x, y: cur.y, width: cur.width, height: h });\n cur = { x: cur.x, y: cur.y + h + gap, width: cur.width, height: h };\n }\n }\n return out;\n}\n\n/**\n * Heights for a column of items stacked in `avail` with gaps: each at its minimum (its natural height), the last\n * taking the rest. When the minimums don't fit, an even share instead, so the ones that break their minimum show.\n */\nexport function columnHeights(avail: number, mins: readonly number[], gap: number): number[] {\n const room = avail - gap * (mins.length - 1);\n const need = mins.reduce((a, b) => a + b, 0);\n if (need > room) return mins.map(() => room / mins.length);\n return mins.map((m, i) => (i === mins.length - 1 ? room - need + m : m));\n}\n\n/**\n * Lengths for items sharing `avail`: each gets at least its minimum, the rest of the room is shared in proportion\n * to the minimums (when the minimums don't fit, each gets its minimum).\n */\nexport function share(avail: number, mins: readonly number[]): number[] {\n const need = mins.reduce((a, b) => a + b, 0);\n const spare = Math.max(0, avail - need);\n return mins.map((m) => m + (need > 0 ? (spare * m) / need : spare / mins.length));\n}\n\n/**\n * The minimum-size give-way: while a tile is laid out below its minimum, the newest tile (highest `age`) floats and\n * the rest are laid out again. Stops when every tile keeps its minimum or one tile is left. `layout` lays out the\n * kept keys; the result says which are kept (in their order) and which float (newest first).\n */\nexport function giveWay<K>(keys: readonly K[], layout: (kept: readonly K[]) => ReadonlyMap<K, Rect>, min: (key: K) => Size, age: (key: K) => number): { kept: K[]; floats: K[] } {\n let kept = [...keys];\n const floats: K[] = [];\n for (;;) {\n const res = layout(kept);\n const broken = [...res].some(([k, r]) => r.width < min(k).width - 0.5 || r.height < min(k).height - 0.5);\n if (!broken || kept.length <= 1) return { kept, floats };\n const newest = kept.reduce((a, b) => (age(b) > age(a) ? b : a));\n kept = kept.filter((k) => k !== newest);\n floats.push(newest);\n }\n}\n","/**\n * The parts the desk constructions are built from, each pure: the toolbar pill, the documents' tiles, natural-height\n * sections (the last open one takes the rest; the least recently used fold to headers), rails, the edge docks'\n * geometry, the tiling tree's columns, the scrolling strip, tabbed sides and floating palettes.\n */\nimport { clampInto, rect, type Rect, type Size } from \"../geometry\";\nimport { columnHeights, dwindle, giveWay, masterStack } from \"./arrange\";\nimport { BAR, DOC_MIN, G, LAYER, RAIL, TABS, TITLE, docKey, idOf, isDocKey, panelKey, type Catalog, type DeskState, type Note, type Options, type Placed, type Side } from \"./model\";\n\nexport type Out = Map<string, Placed>;\n\nexport const plural = (n: number, one: string, many: string): string => `${n} ${n > 1 ? many : one}`;\n\n// --- the toolbar pill and the documents ----------------------------------------------------------------------------\n\n/** The shortest a pill gets (unless there is less room than that). */\nexport const PILL_MIN = 60;\n\n/**\n * The toolbar pill, floating at the top or the bottom of the band [y0, y1] above a region `cx`..`cx + cw`; returns\n * the pill and the band left for the documents (reserved: they keep clear of it; overlay: it floats over them).\n */\nexport function pill(opt: Options, cx: number, cw: number, y0: number, y1: number): { placed: Placed; top: number; bottom: number } {\n const pw = Math.max(PILL_MIN, Math.min(opt.toolbarWidth ?? 320, cw - 24));\n const ph = BAR - 4;\n const atTop = opt.toolbar === \"top\";\n // A hidden pill keeps no band clear, as if it floated.\n const overlay = opt.toolbarSpace === \"overlay\" || !!opt.toolbarHidden;\n return {\n placed: { rect: rect(cx + cw / 2 - pw / 2, atTop ? y0 + G : y1 - G - ph, pw, ph), look: \"pill\", layer: LAYER.toolbar, shadow: overlay, ...(opt.toolbarHidden ? { hidden: true } : {}) },\n top: atTop && !overlay ? y0 + BAR + 2 * G : y0 + G,\n bottom: !atTop && !overlay ? y1 - BAR - 2 * G : y1 - G,\n };\n}\n\n/** The toolbar as a bar across the top of the stage. */\nexport const bar = (W: number): Placed => ({ rect: rect(0, 0, W, BAR), look: \"bar\", layer: LAYER.toolbar });\n\n/** The documents in `r`, master and stack: the first takes 56 % of the width, the rest stack on the right. */\nexport function tiles(out: Out, r: Rect, ids: readonly number[], min?: Size): void {\n for (const [id, rr] of masterStack(ids, r, G, 0.56)) out.set(docKey(id), { rect: rr, look: \"doc\", layer: LAYER.doc, ...(min ? { min } : {}) });\n}\n\n// --- sections and rails --------------------------------------------------------------------------------------------\n\n/**\n * The ones of `ids` to fold, least recently used first, until what stays open fits `avail`. An accordion keeps one\n * section open whatever (`keepOne`); a palette stack shades even its last palette rather than run off the stage.\n */\nfunction lruFold(s: DeskState, ids: readonly number[], avail: number, open: (id: number) => number, closed: number, keepOne = true): number[] {\n const byHand = ids.filter((id) => s.folded.includes(id));\n const auto: number[] = [];\n const isOpen = (id: number): boolean => !byHand.includes(id) && !auto.includes(id);\n const need = (): number => ids.reduce((sum, id) => sum + (isOpen(id) ? open(id) : closed), 0) + G * (ids.length - 1);\n const order = [...s.recent].filter((id) => ids.includes(id));\n for (const id of order) {\n if (need() <= avail || (keepOne && ids.filter(isOpen).length <= 1)) break;\n if (isOpen(id)) auto.push(id);\n }\n return [...byHand, ...auto];\n}\n\n/**\n * Natural-height sections in x, y, w, h: each open section takes its natural height and the last open one takes\n * the rest; the least recently used fold to headers until the open ones fit. Returns how many folded by themselves.\n */\nexport function accordion(cat: Catalog, out: Out, s: DeskState, x: number, y: number, w: number, h: number, ids: readonly number[]): number {\n const folded = lruFold(s, ids, h, cat.natural, TITLE);\n const open = ids.filter((id) => !folded.includes(id));\n const room = h - G * (ids.length - 1) - TITLE * (ids.length - open.length);\n const last = open.at(-1);\n const rest = room - open.reduce((sum, id) => sum + (id === last ? 0 : cat.natural(id)), 0);\n let cy = y;\n for (const id of ids) {\n const i = open.indexOf(id);\n const n = cat.natural(id);\n const hh = i < 0 ? TITLE : id === last ? Math.max(n, rest) : n;\n out.set(panelKey(id), { rect: rect(x, cy, w, hh), look: i >= 0 ? \"section\" : \"header\", layer: LAYER.dock, ...(i >= 0 ? { min: { height: n } } : {}) });\n cy += hh + G;\n }\n return folded.filter((id) => !s.folded.includes(id)).length;\n}\n\n/** A rail of icons at x, y; the rect of its icon `i`. */\nconst railIcon =(x: number, y: number, i: number): Rect => rect(x + 6, y + 10 + i * 32, RAIL - 12, 24);\n\n/** A rail (a column whose panels are all folded) at x, y, h: one icon per panel. */\nexport function rail(out: Out, side: Side, x: number, y: number, h: number, ids: readonly number[], hidden = false): void {\n out.set(`rail:${side}`, { rect: rect(x, y, RAIL, h), look: \"rail\", layer: LAYER.dock, icons: ids, ...(hidden ? { hidden } : {}) });\n}\n\n/** Panels folded into a rail: hidden, each at its icon at `w` × its natural height. */\nexport function intoRail(cat: Catalog, out: Out, x: number, y: number, w: number, ids: readonly number[], side: Side): void {\n ids.forEach((id, i) => {\n const icon = railIcon(x, y, i);\n out.set(panelKey(id), { rect: rect(side === \"left\" ? icon.x : icon.x + icon.width - w, icon.y, w, cat.natural(id)), look: \"section\", layer: LAYER.dock, hidden: true });\n });\n}\n\n// --- edge docks ----------------------------------------------------------------------------------------------------\n\n/**\n * The dock width (rail excluded, its sections 240 px wide after the gap) and the narrowest the documents may get\n * before a dock folds.\n */\nexport const DOCK = 246;\nconst WORK_MIN = 380;\n/** The bottom dock's height when open, and the most of the stage's height it takes. */\nconst BOTTOM = 190;\nconst BOTTOM_SHARE = 0.36;\n\n/** What the edge docks put where: shared by their layouts and their drop targets. */\nexport interface DockGeometry {\n /** The side docks' height (less the bottom dock's in full-width mode). */\n readonly h: number;\n /** The bottom dock's height (its header's when folded; 0 when off). */\n readonly bh: number;\n readonly lOpen: boolean;\n readonly rOpen: boolean;\n /** The right dock's panels (the bottom dock's join them when it is off). */\n readonly right: readonly number[];\n readonly bottomOn: boolean;\n readonly bottomRect: Rect | null;\n /** The documents' band, left to right. */\n readonly x0: number;\n readonly x1: number;\n}\n\n/**\n * The edge docks' give-way: the bottom dock folds to its header when the stage is short, and a whole side dock\n * folds to its rail when the documents would get narrower than WORK_MIN (the right one first, unless it was opened\n * last by hand). `mode`: the bottom dock between the side docks, or across the full width under them.\n */\nexport function dockGeometry(cat: Catalog, s: DeskState, size: Size, opt: Options, mode: \"between\" | \"full\", notes: Note[] = []): DockGeometry {\n const { width: W, height: H } = size;\n const bottomOn = opt.bottom !== \"off\" && s.bottom.length > 0;\n const right = bottomOn ? s.right : [...s.right, ...s.bottom];\n const bottomFolded = bottomOn && (H < 480 || s.bottom.every((id) => s.folded.includes(id)));\n // Open, it is BOTTOM tall, never more than BOTTOM_SHARE of the stage (but never below what its panels need).\n const bh = !bottomOn ? 0 : bottomFolded ? TITLE : Math.max(...s.bottom.map(cat.natural), Math.min(BOTTOM, BOTTOM_SHARE * H));\n if (bottomOn && H < 480) notes.push({ code: \"bottom-folded\", text: \"bottom dock folded to its header\" });\n const full = mode === \"full\";\n const h = full && bottomOn ? H - bh - G : H;\n let lOpen = s.left.length > 0 && !s.closed.includes(\"left\");\n let rOpen = right.length > 0 && !s.closed.includes(\"right\");\n const work = (): number => W - 2 * RAIL - (lOpen ? DOCK : 0) - (rOpen ? DOCK : 0) - 2 * G;\n for (const side of s.opened === \"right\" ? ([\"left\", \"right\"] as const) : ([\"right\", \"left\"] as const)) {\n if (work() >= WORK_MIN) break;\n if (side === \"right\" && rOpen) {\n rOpen = false;\n notes.push({ code: \"dock-folded\", side: \"right\", text: \"right dock folded to its rail\" });\n } else if (side === \"left\" && lOpen) {\n lOpen = false;\n notes.push({ code: \"dock-folded\", side: \"left\", text: \"left dock folded to its rail\" });\n }\n }\n const x0 = RAIL + (lOpen ? DOCK : 0) + G;\n const x1 = W - RAIL - (rOpen ? DOCK : 0) - G;\n const bottomRect = bottomOn ? (full ? rect(G, H - G - bh, W - 2 * G, bh) : rect(x0, H - G - bh, x1 - x0, bh)) : null;\n return { h, bh, lOpen, rOpen, right, bottomOn, bottomRect, x0, x1 };\n}\n\n/** The width of a torn-off panel (its height is its natural height). */\nexport const TORN_W = 200;\n\n// --- the tiling tree -----------------------------------------------------------------------------------------------\n\n/** The smallest a tile may be: a document's minimum, or a panel at its natural height. */\nexport const tileMin = (cat: Catalog, key: string): Size => (isDocKey(key) ? DOC_MIN : { width: 150, height: cat.natural(idOf(key)) });\n/** A side column's width. */\nexport const TREE_COLUMN = 180;\n\n/** The tree's tiles laid out (no floating): the left and right columns, the center by dwindle. */\nexport function treeTiles(cat: Catalog, tree: DeskState[\"tree\"], area: Rect): Map<string, Rect> {\n const res = new Map<string, Rect>();\n let x0 = area.x;\n let x1 = area.x + area.width;\n // A side column's tiles take their natural height, the last one the rest.\n const column = (list: readonly string[], x: number): void => {\n const heights = columnHeights(area.height, list.map((k) => tileMin(cat, k).height), G);\n let y = area.y;\n list.forEach((k, i) => {\n res.set(k, rect(x, y, TREE_COLUMN, heights[i]!));\n y += heights[i]! + G;\n });\n };\n if (tree.L.length) {\n column(tree.L, x0);\n x0 += TREE_COLUMN + G;\n }\n if (tree.R.length) {\n column(tree.R, x1 - TREE_COLUMN);\n x1 -= TREE_COLUMN + G;\n }\n dwindle(rect(x0, area.y, x1 - x0, area.height), tree.C.length, G).forEach((r, i) => res.set(tree.C[i]!, r));\n return res;\n}\n\n/** The sides of the tree whose column is folded to a rail at the stage's edge (closed by hand, or at a narrow start). */\nexport const treeRails = (s: DeskState): { readonly left: boolean; readonly right: boolean } => ({\n left: s.closed.includes(\"left\") && s.tree.L.length > 0,\n right: s.closed.includes(\"right\") && s.tree.R.length > 0,\n});\n\n/** The area the tree tiles: the stage under the bar, less the rails of folded columns. */\nexport const treeArea = (size: Size, s?: DeskState): Rect => {\n const r = s ? treeRails(s) : { left: false, right: false };\n const x0 = r.left ? RAIL + G : G;\n const x1 = size.width - (r.right ? RAIL + G : G);\n return rect(x0, BAR + G, x1 - x0, size.height - BAR - 2 * G);\n};\n\n/** The tree as tiled: a column folded to its rail tiles nothing. */\nexport const treeShown = (s: DeskState): DeskState[\"tree\"] => {\n const r = treeRails(s);\n return { L: r.left ? [] : s.tree.L, R: r.right ? [] : s.tree.R, C: s.tree.C };\n};\n\n/** Which tiles float: the newest tile that breaks a minimum floats, then the tree is laid out again. */\nexport function treeFloats(cat: Catalog, tree: DeskState[\"tree\"], area: Rect): { tree: DeskState[\"tree\"]; floats: string[] } {\n const only = (kept: readonly string[]): DeskState[\"tree\"] => ({ L: tree.L.filter((k) => kept.includes(k)), R: tree.R.filter((k) => kept.includes(k)), C: tree.C.filter((k) => kept.includes(k)) });\n const { kept, floats } = giveWay(\n [...tree.L, ...tree.R, ...tree.C],\n (k) => treeTiles(cat, only(k), area),\n (k) => tileMin(cat, k),\n cat.born,\n );\n return { tree: only(kept), floats };\n}\n\n// --- tabbed sides --------------------------------------------------------------------------------------------------\n\n/**\n * One side with tabs: the tab row on top, the active panel under it, the others hidden behind it. `float` puts\n * them over the documents (a drawer that slides over).\n */\nexport function tabbed(out: Out, side: Side, ids: readonly number[], active: number | null, x: number, y: number, w: number, h: number, float: boolean): void {\n const shown = active !== null && ids.includes(active) ? active : (ids[0] ?? null);\n out.set(`tabs:${side}`, { rect: rect(x, y, w, TABS), look: \"tabs\", layer: float ? LAYER.float : LAYER.dock, tabs: ids, active: shown, ...(float ? { shadow: true } : {}) });\n for (const id of ids) {\n const r = rect(x, y + TABS, w, h - TABS);\n out.set(panelKey(id), { rect: r, look: \"bare\", layer: float ? LAYER.float : LAYER.dock, ...(id === shown ? {} : { hidden: true }), ...(float ? { shadow: true } : {}) });\n }\n}\n\n/** A side folded to its rail: the tab row and the panels hidden into it. */\nexport function tabbedIntoRail(cat: Catalog, out: Out, side: Side, ids: readonly number[], x: number, y: number, w: number): void {\n out.set(`tabs:${side}`, { rect: rect(side === \"left\" ? x : x + RAIL - w, y, w, TABS), look: \"tabs\", layer: LAYER.dock, tabs: ids, active: null, hidden: true });\n intoRail(cat, out, x, y, w, ids, side);\n}\n\n/** Below these widths a drawer slides over the documents instead of pushing them. */\nexport const DRAWER_DOCK = { left: 760, right: 1040 } as const;\n\n// --- the scrolling strip -------------------------------------------------------------------------------------------\n\nconst STRIP_PANEL_W = 180;\nconst stripDocW =(W: number): number => Math.max(360, Math.min(520, W * 0.5));\nexport const stripMin = (cat: Catalog, k: string): number => (isDocKey(k) ? DOC_MIN.height : cat.natural(idOf(k)));\n\n/** The strip's columns as laid out: a column whose minimums don't fit the height splits in two, recursively. */\nexport function stripColumns(cat: Catalog, cols: readonly (readonly string[])[], h: number, notes: Note[] = []): string[][] {\n const split = (keys: readonly string[]): string[][] => {\n const need = keys.reduce((sum, k) => sum + stripMin(cat, k), 0) + G * (keys.length - 1);\n if (need <= h || keys.length === 1) return [[...keys]];\n const half = Math.ceil(keys.length / 2);\n notes.push({ code: \"column-split\", items: [...keys], text: `${keys.map(cat.title).join(\" + \")} split into two columns` });\n return [...split(keys.slice(0, half)), ...split(keys.slice(half))];\n };\n return cols.flatMap(split);\n}\n\nexport interface StripGeometry {\n readonly cols: string[][];\n /** Each column's left edge on the stage (scroll applied) and width. */\n readonly xs: number[];\n readonly widths: number[];\n readonly y: number;\n readonly h: number;\n /** The whole strip's width, and how far it is scrolled. */\n readonly total: number;\n readonly scroll: number;\n}\n\n/** The strip's columns and scroll: scrolled by hand, else to center the focused document's column. */\nexport function stripGeometry(cat: Catalog, s: DeskState, size: Size, notes: Note[] = []): StripGeometry {\n const { width: W, height: H } = size;\n const y = BAR + G;\n const h = H - BAR - 2 * G;\n const cols = stripColumns(cat, s.cols, h, notes);\n const widths = cols.map((c) => (c.some(isDocKey) ? stripDocW(W) : STRIP_PANEL_W));\n const total = widths.reduce((a, b) => a + b, 0) + G * (cols.length + 1);\n const want = s.focus !== null ? docKey(s.focus) : null;\n let fi = cols.findIndex((c) => want !== null && c.includes(want));\n if (fi < 0) fi = cols.findIndex((c) => c.some(isDocKey));\n const xsAbs: number[] = [];\n let x = G;\n for (const w of widths) {\n xsAbs.push(x);\n x += w + G;\n }\n const focusX = fi >= 0 ? xsAbs[fi]! + widths[fi]! / 2 : 0;\n const scroll = Math.max(0, Math.min(total - W, s.stripScroll ?? focusX - W / 2));\n return { cols, xs: xsAbs.map((v) => v - scroll), widths, y, h, total, scroll };\n}\n\n// --- floating palettes ---------------------------------------------------------------------------------------------\n\nexport const paletteWidth = (W: number): number => Math.min(200, Math.max(140, W * 0.22));\n/** Narrower than this, both stacks share the right corner. */\nexport const PALETTE_NARROW = 640;\n/** The margin palettes keep from the area's edges when they float over the documents. */\nexport const OVER_MARGIN = 14;\n\n/**\n * Palettes at their natural size, stacked in the top corners of `area` (`m` in from its edges), and the free ones\n * where they were put; a stack too tall for the area shades its least recently used palettes to their title bars.\n */\nexport function palettes(cat: Catalog, s: DeskState, area: Rect, W: number, m: number, notes: Note[] = []): Map<number, { rect: Rect; shaded: boolean }> {\n const pw = paletteWidth(W);\n const avail = area.height - 2 * m;\n const narrow = W < PALETTE_NARROW;\n const stacks = narrow ? [[...s.stacks.left, ...s.stacks.right]] : [s.stacks.left, s.stacks.right];\n if (narrow && s.stacks.left.length && s.stacks.right.length) notes.push({ code: \"stacks-merged\", text: \"both stacks share the right corner\" });\n const out = new Map<number, { rect: Rect; shaded: boolean }>();\n let shaded = 0;\n stacks.forEach((ids, si) => {\n const folded = lruFold(s, ids, avail, cat.natural, TITLE, false);\n shaded += folded.filter((id) => !s.folded.includes(id)).length;\n const x = narrow || si === 1 ? area.x + area.width - m - pw : area.x + m;\n let y = area.y + m;\n for (const id of ids) {\n const h = folded.includes(id) ? TITLE : cat.natural(id);\n out.set(id, { rect: rect(x, y, pw, h), shaded: folded.includes(id) });\n y += h + G;\n }\n });\n for (const f of s.free) {\n const shade = s.folded.includes(f.id);\n const at = f.at ?? { x: area.x + m, y: area.y + m };\n out.set(f.id, { rect: clampInto(rect(at.x, at.y, pw, shade ? TITLE : cat.natural(f.id)), area), shaded: shade });\n }\n if (shaded) notes.push({ code: \"palettes-shaded\", text: `${plural(shaded, \"palette\", \"palettes\")} shaded to ${shaded > 1 ? \"title bars\" : \"a title bar\"}` });\n return out;\n}\n\n/** The stage area palettes and documents share (below or above the pill when it keeps its band). */\nexport function paletteArea(size: Size, opt: Options): { area: Rect } {\n const p = pill(opt, G, size.width - 2 * G, 0, size.height);\n return { area: rect(G, p.top, size.width - 2 * G, p.bottom - p.top) };\n}\n\n/**\n * A floating pill among palettes: in a stretch of its band that no palette crosses, so it never covers one. Of the\n * stretches wide enough for a full-width pill (its minimum plus margins), the one nearest the center; with none, the\n * widest, the pill shrunk to fit it.\n */\nexport function pillBetween(opt: Options, size: Size, blocks: readonly Rect[]): Placed {\n const band = pill(opt, G, size.width - 2 * G, 0, size.height).placed.rect;\n const spans = blocks\n .filter((r) => r.y < band.y + band.height && r.y + r.height > band.y)\n .map((r) => [r.x - G, r.x + r.width + G] as const)\n .sort((a, b) => a[0] - b[0]);\n const stretches: [number, number][] = [];\n let x = G;\n for (const [b0, b1] of spans) {\n if (b0 > x) stretches.push([x, b0]);\n x = Math.max(x, b1);\n }\n if (size.width - G > x) stretches.push([x, size.width - G]);\n const roomy = stretches.filter(([a, b]) => b - a >= PILL_MIN + 24);\n const mid = size.width / 2;\n const pick =\n roomy.sort((p, q) => Math.abs((p[0] + p[1]) / 2 - mid) - Math.abs((q[0] + q[1]) / 2 - mid))[0] ??\n stretches.sort((p, q) => q[1] - q[0] - (p[1] - p[0]))[0] ??\n ([G, G] as [number, number]);\n const placed = pill(opt, pick[0], pick[1] - pick[0], 0, size.height).placed;\n const room = pick[1] - pick[0];\n // Too little room for even the shortest pill: it shrinks to the room rather than cover a palette.\n return placed.rect.width <= room ? placed : { ...placed, rect: { ...placed.rect, x: pick[0], width: Math.max(0, room) } };\n}\n\n/** The documents' band between the palettes on the left half and those on the right half. */\nexport function aroundDocs(pals: ReadonlyMap<number, { rect: Rect }>, area: Rect): Rect {\n const mid = area.x + area.width / 2;\n const rects = [...pals.values()].map((p) => p.rect);\n const left = rects.filter((r) => r.x + r.width / 2 < mid);\n const right = rects.filter((r) => r.x + r.width / 2 >= mid);\n const x0 = left.length ? Math.max(...left.map((r) => r.x + r.width)) + G : area.x;\n const x1 = right.length ? Math.min(...right.map((r) => r.x)) - G : area.x + area.width;\n return rect(x0, area.y, Math.max(0, x1 - x0), area.height);\n}\n"],"mappings":";;;;;;AAUO,IAAM,IAAI;AAEV,IAAM,MAAM;AAEZ,IAAM,OAAO;AAEb,IAAM,QAAQ;AAEd,IAAM,OAAO;AAEb,IAAM,UAAgB,EAAE,OAAO,KAAK,QAAQ,IAAI;AAGhD,IAAM,WAAW,CAAC,OAAuB,SAAS,EAAE;AACpD,IAAM,SAAS,CAAC,OAAuB,OAAO,EAAE;AAChD,IAAM,aAAa,CAAC,QAAyB,IAAI,WAAW,QAAQ;AACpE,IAAM,WAAW,CAAC,QAAyB,IAAI,WAAW,MAAM;AAChE,IAAM,OAAO,CAAC,QAAwB,OAAO,IAAI,MAAM,IAAI,QAAQ,GAAG,IAAI,CAAC,CAAC;AA0C5E,SAAS,UAAU,MAAyB;AACjD,QAAM,OAAO,IAAI,IAAI,KAAK,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AACtD,QAAM,SAAS,KAAK,UAAU,KAAK,OAAO,IAAI,CAAC,MAAM,EAAE,EAAE;AACzD,QAAM,WAAW,KAAK,aAAa,CAAC,OAAe,YAAY,EAAE;AACjE,QAAM,EAAE,MAAM,OAAO,OAAO,IAAI,KAAK;AACrC,QAAM,OAAO,CAAC,GAAG,OAAO,GAAG,MAAM;AACjC,QAAM,QAA6B;AAAA,IACjC;AAAA,IACA;AAAA,IACA;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,MAAM,EAAE,GAAG,OAAO,MAAM,GAAG,KAAK,CAAC,GAAG,OAAO,KAAK,IAAI,GAAG,IAAI,EAAE,EAAE;AAC1H;AAGO,SAAS,WAAW,MAA2C,MAAkB;AACtF,QAAM,MAAM,KAAK,IAAI,KAAK,QAAQ;AAClC,QAAM,QAAQ,CAAC,GAAG,KAAK,OAAO,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI;AAClD,QAAM,OAAO,MAAM,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,IAAI,GAAG;AACxD,QAAM,QAAQ,MAAM,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,KAAK,GAAG;AAC1D,QAAM,KAAK,KAAK,SAAS,KAAK,IAAI,GAAG,KAAK,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,KAAK;AAChF,QAAM,KAAK,MAAM,SAAS,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,IAAI,KAAK,IAAI,KAAK;AACjF,SAAO,KAAK,IAAI,KAAK,GAAG,KAAK,IAAI,GAAG,KAAK,EAAE,GAAG,KAAK,MAAM;AAC3D;","names":["kept"]}
@@ -218,4 +218,4 @@ export {
218
218
  layoutHost,
219
219
  insertions
220
220
  };
221
- //# sourceMappingURL=chunk-WLMJ6JGO.js.map
221
+ //# sourceMappingURL=chunk-GIBUM6TB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/toolbar/index.ts"],"sourcesContent":["/**\n * @n-uf/placement/toolbar: toolbar groups as a pure model. Commands come in groups, each sitting in one of five\n * toolbar areas (the title bar, the top toolbar, a bottom toolbar, a left and a right side toolbar), in one of three\n * zones (start, center, end; top, middle, bottom on a side), in order; or floating. A toolbar is a slot: it never moves\n * itself, its groups do. Group sizes come in as numbers; group ids are the consumer's strings.\n *\n * - A toolbar area lays its zones out along its length: start from the lead, end up to the tail, the center centered on\n * the whole area; when the center would hit the start or end zone it centers in the space between them.\n * - Toolbars never wrap: when room runs out, groups collapse to their grip and » from the trailing end. A group\n * collapsed by hand stays collapsed.\n * - A group drop lands in a zone before all, after all, or between two groups. An empty zone is a target of its\n * own. A group's home is its own place: a drop there changes nothing.\n */\nimport type { Rect } from \"../geometry\";\n\nexport type HostId = \"title\" | \"top\" | \"bottom\" | \"left\" | \"right\";\nexport type ZoneId = \"start\" | \"center\" | \"end\";\nexport type Zones<G extends string = string> = Readonly<Record<ZoneId, readonly G[]>>;\n\n/** Where a group is docked: a host, a zone, and its index there. */\nexport interface Place {\n readonly host: HostId;\n readonly zone: ZoneId;\n readonly index: number;\n}\n\n/** A group floating over the content: its top-left corner, and where it was docked. */\nexport interface Floating<G extends string = string> {\n readonly id: G;\n readonly x: number;\n readonly y: number;\n readonly from: Place | null;\n}\n\nexport type Arrangement<G extends string = string> = Readonly<Record<HostId, Zones<G>>> & {\n /** Groups collapsed to their handle and » by hand. */\n readonly collapsed: readonly G[];\n readonly floating: readonly Floating<G>[];\n};\n\nexport const HOSTS: readonly HostId[] = [\"title\", \"top\", \"bottom\", \"left\", \"right\"];\nexport const ZONES: readonly ZoneId[] = [\"start\", \"center\", \"end\"];\n\nexport const HOST_LABEL: Readonly<Record<HostId, string>> = { title: \"Title bar\", top: \"Top bar\", bottom: \"Bottom bar\", left: \"Left edge\", right: \"Right edge\" };\nexport const zoneLabel = (h: HostId, z: ZoneId): string => (vertical(h) ? { start: \"top\", center: \"middle\", end: \"bottom\" } : { start: \"left\", center: \"centre\", end: \"right\" })[z];\n\n/** The side edges hold their groups in a column. */\nexport const vertical = (h: HostId): boolean => h === \"left\" || h === \"right\";\n\n/** Between two groups (the handle of the second is the separator). */\nexport const GAP = 12;\n/** Between zones. */\nexport const ZONE_GAP = 16;\n\n/** An arrangement from the zones each host has (the rest empty), nothing collapsed or floating. */\nexport function arrangement<G extends string>(p: Partial<Record<HostId, Partial<Record<ZoneId, readonly G[]>>>>): Arrangement<G> {\n const z = (q: Partial<Record<ZoneId, readonly G[]>> = {}): Zones<G> => ({ start: [], center: [], end: [], ...q });\n return { title: z(p.title), top: z(p.top), bottom: z(p.bottom), left: z(p.left), right: z(p.right), collapsed: [], floating: [] };\n}\n\n// --- changes -------------------------------------------------------------------------------------------------------\n\nconst mapHosts = <G extends string>(a: Arrangement<G>, f: (h: HostId, zone: ZoneId, list: readonly G[]) => readonly G[]): Arrangement<G> => ({\n ...a,\n ...(Object.fromEntries(HOSTS.map((h) => [h, Object.fromEntries(ZONES.map((zn) => [zn, f(h, zn, a[h][zn])]))])) as Record<HostId, Zones<G>>),\n});\n\n/** Where `g` is docked (null: floating or absent). */\nexport function hostOf<G extends string>(a: Arrangement<G>, g: G): Place | null {\n for (const h of HOSTS) for (const zn of ZONES) if (a[h][zn].includes(g)) return { host: h, zone: zn, index: a[h][zn].indexOf(g) };\n return null;\n}\n\n/** The arrangement with group `g` lifted out (of its host, or from floating). */\nexport const withoutGroup = <G extends string>(a: Arrangement<G>, g: G): Arrangement<G> => ({ ...mapHosts(a, (_h, _z, l) => l.filter((x) => x !== g)), floating: a.floating.filter((f) => f.id !== g) });\n\n/** The arrangement with `g` docked at place `i` of zone `zone` of host `h` (`i` counts the others). */\nexport function insertGroup<G extends string>(a: Arrangement<G>, g: G, h: HostId, zone: ZoneId, i: number): Arrangement<G> {\n return mapHosts(withoutGroup(a, g), (hh, zz, l) => (hh === h && zz === zone ? [...l.slice(0, i), g, ...l.slice(i)] : l));\n}\n\n/** `g` floating with its top-left corner at (x, y); it remembers where it was docked. */\nexport function floatGroup<G extends string>(a: Arrangement<G>, g: G, x: number, y: number): Arrangement<G> {\n const from = hostOf(a, g) ?? a.floating.find((f) => f.id === g)?.from ?? null;\n const out = withoutGroup(a, g);\n return { ...out, floating: [...out.floating, { id: g, x, y, from }] };\n}\n\n/** `g` at `place`, its index kept within the zone. */\nconst dockAt = <G extends string>(a: Arrangement<G>, g: G, place: Place): Arrangement<G> =>\n insertGroup(a, g, place.host, place.zone, Math.min(place.index, a[place.host][place.zone].filter((x) => x !== g).length));\n\n/** `g` docked again where it floated from, else where `home` (the default arrangement) has it. */\nexport function dockGroup<G extends string>(a: Arrangement<G>, g: G, home: Arrangement<G>): Arrangement<G> {\n const from = a.floating.find((f) => f.id === g)?.from ?? hostOf(home, g);\n return from ? dockAt(a, g, from) : a;\n}\n\n/** `g` back where `home` (the default arrangement) has it, expanded. */\nexport function resetGroup<G extends string>(a: Arrangement<G>, g: G, home: Arrangement<G>): Arrangement<G> {\n const place = hostOf(home, g);\n const out = place ? dockAt(a, g, place) : a;\n return { ...out, collapsed: out.collapsed.filter((x) => x !== g) };\n}\n\n/** `g` moved to host `h`: after its last group (in its last zone that has any), or into its start zone. */\nexport function moveToHost<G extends string>(a: Arrangement<G>, g: G, h: HostId): Arrangement<G> {\n const rest = withoutGroup(a, g);\n const zone = [...ZONES].reverse().find((zn) => rest[h][zn].length > 0) ?? \"start\";\n return insertGroup(a, g, h, zone, rest[h][zone].length);\n}\n\n/** Every group of host `from` moved to host `to`, zone by zone, after the groups there. */\nexport function moveBar<G extends string>(a: Arrangement<G>, from: HostId, to: HostId): Arrangement<G> {\n if (from === to) return a;\n return mapHosts(a, (h, zn, l) => (h === from ? [] : h === to ? [...l, ...a[from][zn]] : l));\n}\n\nexport const toggleCollapsed = <G extends string>(a: Arrangement<G>, g: G): Arrangement<G> => ({ ...a, collapsed: a.collapsed.includes(g) ? a.collapsed.filter((x) => x !== g) : [...a.collapsed, g] });\n\nexport const isEmptyHost = <G extends string>(a: Arrangement<G>, h: HostId): boolean => ZONES.every((zn) => a[h][zn].length === 0);\n\nconst samePlace = (a: Place | null, b: Place | null): boolean => (a === null || b === null ? a === b : a.host === b.host && a.zone === b.zone && a.index === b.index);\n\n/**\n * The same arrangement: the same groups in the same order in every zone of every host, the same groups collapsed,\n * and the same groups floating at the same corner with the same home (in any order: neither list's order means\n * anything). Compared field by field, so how the arrangement was written down (its keys' order) doesn't matter.\n */\nexport function sameArrangement<G extends string>(a: Arrangement<G>, b: Arrangement<G>): boolean {\n const sameList = (x: readonly G[], y: readonly G[]): boolean => x.length === y.length && x.every((g, i) => g === y[i]);\n // Both ways, so a repeated id on one side can't stand in for a missing one ([\"a\", \"a\"] is not [\"a\", \"b\"]).\n const sameSet = (x: readonly G[], y: readonly G[]): boolean => x.length === y.length && x.every((g) => y.includes(g)) && y.every((g) => x.includes(g));\n if (!HOSTS.every((h) => ZONES.every((zn) => sameList(a[h][zn], b[h][zn])))) return false;\n if (!sameSet(a.collapsed, b.collapsed)) return false;\n if (!sameSet(a.floating.map((f) => f.id), b.floating.map((f) => f.id))) return false;\n return a.floating.every((f) => {\n const o = b.floating.find((x) => x.id === f.id);\n return !!o && o.x === f.x && o.y === f.y && samePlace(o.from, f.from);\n });\n}\n\n/** Dropping `g` at `place` changes nothing: it is the group's home, never a target. */\nexport const isOwnPlace = <G extends string>(a: Arrangement<G>, g: G, place: Place): boolean => sameArrangement(insertGroup(a, g, place.host, place.zone, place.index), a);\n\n// --- stored arrangements -------------------------------------------------------------------------------------------\n\n/** An arrangement as stored: version 1. */\nexport interface StoredArrangement<G extends string = string> {\n readonly v: 1;\n readonly hosts: Readonly<Record<HostId, Readonly<Record<ZoneId, readonly G[]>>>>;\n readonly collapsed: readonly G[];\n readonly floating: readonly { readonly id: G; readonly x: number; readonly y: number; readonly from: Place | null }[];\n}\n\n/** What reading a stored arrangement gives: the arrangement, or why it couldn't be read. Never a throw. */\nexport type ArrangementRead<G extends string = string> = { readonly ok: true; readonly arrangement: Arrangement<G> } | { readonly ok: false; readonly error: string };\n\n/** The arrangement as plain data with its version, ready for `JSON.stringify`. */\nexport function storeArrangement<G extends string>(a: Arrangement<G>): StoredArrangement<G> {\n const hosts = Object.fromEntries(HOSTS.map((h) => [h, Object.fromEntries(ZONES.map((zn) => [zn, [...a[h][zn]]]))])) as unknown as Record<HostId, Record<ZoneId, G[]>>;\n return { v: 1, hosts, collapsed: [...a.collapsed], floating: a.floating.map((f) => ({ id: f.id, x: f.x, y: f.y, from: f.from ? { ...f.from } : null })) };\n}\n\n/**\n * A stored arrangement read back from parsed data (`JSON.parse`'s result, not the string). Anything else gives\n * `{ ok: false, error }`, never a throw: an unknown version, a missing host or zone, a value of the wrong kind, a\n * group in two places, or (with `groups`) a group the consumer doesn't have. A group the consumer has but the stored\n * arrangement lacks is no error: the consumer places it (`resetGroup` with its default arrangement, say).\n */\nexport function readArrangement<G extends string = string>(data: unknown, groups?: readonly G[]): ArrangementRead<G> {\n const fail = (error: string): ArrangementRead<G> => ({ ok: false, error });\n const isObject = (x: unknown): x is Record<string, unknown> => typeof x === \"object\" && x !== null && !Array.isArray(x);\n if (!isObject(data)) return fail(\"not an object\");\n // Named without serialising it: a BigInt or a circular value must not throw.\n if (data.v !== 1) return fail(`unknown version ${typeof data.v === \"number\" || typeof data.v === \"string\" ? String(data.v) : typeof data.v} (this reads version 1)`);\n const seen = new Set<string>();\n const ids = (x: unknown, where: string, placed: boolean): G[] | string => {\n if (!Array.isArray(x) || !x.every((g) => typeof g === \"string\")) return `${where} is not a list of group ids`;\n for (const g of x as string[]) {\n if (groups && !(groups as readonly string[]).includes(g)) return `${where} has an unknown group \"${g}\"`;\n if (placed && seen.has(g)) return `group \"${g}\" is in two places`;\n if (placed) seen.add(g);\n }\n return x as G[];\n };\n if (!isObject(data.hosts)) return fail(\"hosts is missing\");\n const hosts = {} as Record<HostId, Zones<G>>;\n for (const h of HOSTS) {\n const zones = data.hosts[h];\n if (!isObject(zones)) return fail(`host ${h} is missing`);\n const out = {} as Record<ZoneId, readonly G[]>;\n for (const zn of ZONES) {\n const list = ids(zones[zn], `${h}.${zn}`, true);\n if (typeof list === \"string\") return fail(list);\n out[zn] = list;\n }\n hosts[h] = out;\n }\n const collapsed = ids(data.collapsed, \"collapsed\", false);\n if (typeof collapsed === \"string\") return fail(collapsed);\n if (!Array.isArray(data.floating)) return fail(\"floating is not a list\");\n const floating: Floating<G>[] = [];\n for (const f of data.floating as unknown[]) {\n if (!isObject(f) || typeof f.id !== \"string\" || typeof f.x !== \"number\" || typeof f.y !== \"number\" || !Number.isFinite(f.x) || !Number.isFinite(f.y)) return fail(\"a floating group is not { id, x, y, from }\");\n const id = ids([f.id], \"floating\", true);\n if (typeof id === \"string\") return fail(id);\n const from = f.from;\n const place = from === null || from === undefined ? null : isObject(from) && HOSTS.includes(from.host as HostId) && ZONES.includes(from.zone as ZoneId) && Number.isInteger(from.index) && (from.index as number) >= 0 ? { host: from.host as HostId, zone: from.zone as ZoneId, index: from.index as number } : undefined;\n if (place === undefined) return fail(`floating group \"${f.id}\" has a bad home`);\n floating.push({ id: id[0]!, x: f.x, y: f.y, from: place });\n }\n return { ok: true, arrangement: { ...hosts, collapsed, floating } };\n}\n\n// --- a host's layout -----------------------------------------------------------------------------------------------\n\n/** A host's room: its length and thickness, and what its ends keep for themselves (window controls, a margin). */\nexport interface HostSpec<G extends string = string> {\n readonly length: number;\n readonly thickness: number;\n readonly lead: number;\n readonly tail: number;\n /**\n * The center zone's minimum length and its margin on each side, counted in the need whether it holds groups or\n * not (an empty center keeps its drop size). Unset: the center counts only its groups.\n */\n readonly center?: { readonly min: number; readonly margin: number };\n /**\n * How long each group keeps its full form when room runs out (default 0): groups with a lower keep collapse\n * first, and among equal keeps the trailing end goes first. A primary group at the end keeps open with a keep of 1.\n */\n readonly keep?: Readonly<Partial<Record<G, number>>>;\n}\n\n/** A group's size in a host, expanded or collapsed: along it (`along`) and across it (`across`). */\nexport type GroupSize<G extends string = string> = (id: G, vertical: boolean, collapsed: boolean) => { along: number; across: number };\n\nexport interface HostLayout<G extends string = string> {\n /** Each group's rect in the host (x along, y across for a horizontal host; transposed on a side). */\n readonly slots: ReadonlyMap<G, Rect>;\n /** Groups shown collapsed (by hand, or because the room ran out). */\n readonly collapsed: readonly G[];\n /** Of those, the ones the room collapsed (from the trailing end). */\n readonly overflow: readonly G[];\n /** The length the groups and the ends take. */\n readonly need: number;\n}\n\n/** How long the host's groups need it to be, collapsing only those in `collapsed`. */\nexport function hostNeed<G extends string>(zones: Zones<G>, collapsed: readonly G[], spec: Pick<HostSpec, \"lead\" | \"tail\" | \"center\">, size: GroupSize<G>, v: boolean): number {\n const lens = ZONES.map((zn) => zones[zn].reduce((s, g) => s + size(g, v, collapsed.includes(g)).along, 0) + GAP * Math.max(0, zones[zn].length - 1));\n const used = ZONES.filter((zn) => zones[zn].length > 0).length;\n const c = spec.center;\n if (!c) return spec.lead + spec.tail + lens.reduce((s, x) => s + x, 0) + ZONE_GAP * Math.max(0, used - 1);\n // The center always counts, at its minimum at least, and its margins keep it apart from the start and end zones.\n return spec.lead + spec.tail + lens[0]! + lens[2]! + Math.max(lens[1]!, c.min) + 2 * c.margin;\n}\n\n/**\n * Lay a host out: zones along its length; when they don't fit, groups collapse, the lowest keep first and, among\n * equal keeps, from the trailing end.\n */\nexport function layoutHost<G extends string>(zones: Zones<G>, h: HostId, spec: HostSpec<G>, size: GroupSize<G>, byHand: readonly G[] = []): HostLayout<G> {\n const v = vertical(h);\n const collapsed = new Set<G>(ZONES.flatMap((zn) => zones[zn]).filter((g) => byHand.includes(g)));\n const overflow: G[] = [];\n const len = (g: G): number => size(g, v, collapsed.has(g)).along;\n const zoneLen = (l: readonly G[]): number => l.reduce((s, g) => s + len(g), 0) + GAP * Math.max(0, l.length - 1);\n const needNow = (): number => hostNeed(zones, [...collapsed], spec, size, v);\n // The lowest keep first; among equal keeps the trailing end first: the end zone's last group, back to the start\n // zone's first (the sort is stable).\n // Own keys only (a group named \"toString\" mustn't read the prototype), and finite numbers only (NaN breaks the sort).\n const keep = (g: G): number => {\n const k = spec.keep && Object.hasOwn(spec.keep, g) ? spec.keep[g] : 0;\n return typeof k === \"number\" && Number.isFinite(k) ? k : 0;\n };\n const order = [...ZONES].reverse().flatMap((zn) => [...zones[zn]].reverse());\n for (const g of order.sort((x, y) => keep(x) - keep(y))) {\n if (needNow() <= spec.length) break;\n if (collapsed.has(g)) continue;\n collapsed.add(g);\n overflow.push(g);\n }\n const a0 = spec.lead;\n const b0 = spec.length - spec.tail;\n const S = zoneLen(zones.start);\n const C = zoneLen(zones.center);\n const E = zoneLen(zones.end);\n const lo = a0 + S + (S > 0 ? ZONE_GAP : 0);\n const hi = b0 - E - (E > 0 ? ZONE_GAP : 0);\n let c0 = spec.length / 2 - C / 2;\n if (c0 < lo || c0 + C > hi) c0 = (lo + hi) / 2 - C / 2;\n const slots = new Map<G, Rect>();\n const place = (l: readonly G[], from: number): void => {\n let at = from;\n for (const g of l) {\n const s = size(g, v, collapsed.has(g));\n const across = (spec.thickness - s.across) / 2;\n slots.set(g, v ? { x: across, y: at, width: s.across, height: s.along } : { x: at, y: across, width: s.along, height: s.across });\n at += s.along + GAP;\n }\n };\n place(zones.start, a0);\n place(zones.center, c0);\n place(zones.end, b0 - E);\n return { slots, collapsed: [...collapsed], overflow, need: needNow() };\n}\n\n// --- insertion points ----------------------------------------------------------------------------------------------\n\n/** A place a dragged group can go: a zone of a host and the index among the others there, and where it is. */\nexport interface Insertion extends Place {\n /** Along the host: the insertion line (between groups); for an empty zone, the zone's middle. */\n readonly at: number;\n /** The stretch of the host it owns (host coordinates). */\n readonly span: readonly [number, number];\n /** An empty zone: it owns all of its stretch, whatever is nearer (it wins while the pointer is inside it). */\n readonly empty: boolean;\n readonly label: string;\n}\n\n/**\n * The insertion points of a host laid out without the dragged group: in each zone before all, between two, after\n * all; each owns the stretch of the host nearest to it. An empty zone owns its own stretch: the host's first third\n * (start), middle third (center) or last third (end), less what its neighbors' groups take. `label` names a group\n * in the \"between\" labels (default: its id).\n */\nexport function insertions<G extends string>(zones: Zones<G>, h: HostId, spec: HostSpec<G>, l: HostLayout<G>, label: (g: G) => string = (g) => g): Insertion[] {\n const v = vertical(h);\n const lo = (r: Rect): number => (v ? r.y : r.x);\n const hi = (r: Rect): number => (v ? r.y + r.height : r.x + r.width);\n const L = spec.length;\n const all = ZONES.flatMap((zn) => zones[zn].map((g) => l.slots.get(g)).filter((r): r is Rect => !!r));\n const first = all.length ? Math.min(...all.map(lo)) : L;\n const last = all.length ? Math.max(...all.map(hi)) : 0;\n const zoneEdge = (zn: ZoneId, end: \"lo\" | \"hi\"): number | null => {\n const rs = zones[zn].map((g) => l.slots.get(g)).filter((r): r is Rect => !!r);\n if (!rs.length) return null;\n return end === \"lo\" ? Math.min(...rs.map(lo)) : Math.max(...rs.map(hi));\n };\n const near: Omit<Insertion, \"span\">[] = [];\n const empties: Insertion[] = [];\n for (const zn of ZONES) {\n const name = `${HOST_LABEL[h]} · ${zoneLabel(h, zn)}`;\n const vis = zones[zn].map((g, i) => ({ g, i, r: l.slots.get(g)! }));\n if (!vis.length) {\n const sEnd = zoneEdge(\"start\", \"hi\");\n const eStart = zoneEdge(\"end\", \"lo\");\n const span: [number, number] =\n zn === \"start\" ? [0, Math.min(L / 3, first - GAP / 2)] : zn === \"end\" ? [Math.max((2 * L) / 3, last + GAP / 2), L] : [Math.max(L / 3, (sEnd ?? 0) + GAP / 2), Math.min((2 * L) / 3, (eStart ?? L) - GAP / 2)];\n if (span[1] - span[0] >= 8) empties.push({ host: h, zone: zn, index: 0, at: (span[0] + span[1]) / 2, span, empty: true, label: name });\n continue;\n }\n near.push({ host: h, zone: zn, index: vis[0]!.i, at: lo(vis[0]!.r) - GAP / 2, empty: false, label: `${name} · before all` });\n for (let k = 1; k < vis.length; k++) near.push({ host: h, zone: zn, index: vis[k]!.i, at: (hi(vis[k - 1]!.r) + lo(vis[k]!.r)) / 2, empty: false, label: `${name} · between ${label(vis[k - 1]!.g)} and ${label(vis[k]!.g)}` });\n near.push({ host: h, zone: zn, index: zones[zn].length, at: hi(vis.at(-1)!.r) + GAP / 2, empty: false, label: `${name} · after all` });\n }\n near.sort((a, b) => a.at - b.at);\n const lines = near.map((p, k) => ({ ...p, span: [k === 0 ? 0 : (near[k - 1]!.at + p.at) / 2, k === near.length - 1 ? L : (p.at + near[k + 1]!.at) / 2] as const }));\n return [...lines, ...empties];\n}\n"],"mappings":";AAwCO,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G,KAAK,GAAG,IAAI,IAAI,CAAC,EAAG,CAAC,IAAI,GAAG,IAAI,CAAC,EAAG,CAAC,KAAK,GAAG,OAAO,OAAO,OAAO,GAAG,IAAI,iBAAc,MAAM,IAAI,IAAI,CAAC,EAAG,CAAC,CAAC,QAAQ,MAAM,IAAI,CAAC,EAAG,CAAC,CAAC,GAAG,CAAC;AAC7N,SAAK,KAAK,EAAE,MAAM,GAAG,MAAM,IAAI,OAAO,MAAM,EAAE,EAAE,QAAQ,IAAI,GAAG,IAAI,GAAG,EAAE,EAAG,CAAC,IAAI,MAAM,GAAG,OAAO,OAAO,OAAO,GAAG,IAAI,kBAAe,CAAC;AAAA,EACvI;AACA,OAAK,KAAK,CAAC,GAAG,MAAM,EAAE,KAAK,EAAE,EAAE;AAC/B,QAAM,QAAQ,KAAK,IAAI,CAAC,GAAG,OAAO,EAAE,GAAG,GAAG,MAAM,CAAC,MAAM,IAAI,KAAK,KAAK,IAAI,CAAC,EAAG,KAAK,EAAE,MAAM,GAAG,MAAM,KAAK,SAAS,IAAI,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC,EAAG,MAAM,CAAC,EAAW,EAAE;AAClK,SAAO,CAAC,GAAG,OAAO,GAAG,OAAO;AAC9B;","names":[]}
@@ -4,7 +4,7 @@ import {
4
4
  bandSize,
5
5
  defOf,
6
6
  floatSize
7
- } from "./chunk-7ASCUAGV.js";
7
+ } from "./chunk-3ZICYLWL.js";
8
8
 
9
9
  // src/panels/store.ts
10
10
  function storePanels(state) {
@@ -169,4 +169,4 @@ export {
169
169
  storePanels,
170
170
  readPanels
171
171
  };
172
- //# sourceMappingURL=chunk-OYGOJWAX.js.map
172
+ //# sourceMappingURL=chunk-JVAR67OL.js.map
@@ -44,4 +44,4 @@ export {
44
44
  COLUMN_REACH,
45
45
  RAIL_EDGE
46
46
  };
47
- //# sourceMappingURL=chunk-WM5FJ3IS.js.map
47
+ //# sourceMappingURL=chunk-VLTYJHUA.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/geometry.ts"],"sourcesContent":["/**\n * The shapes every entry shares. Plain data: a rect is a top-left corner and a size, in whatever px the consumer\n * lays out in (stage, window or host coordinates). The same shape as @n-uf/motion's, so the two compose without\n * either importing the other.\n */\n\nexport interface Rect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport interface Size {\n readonly width: number;\n readonly height: number;\n}\n\nexport interface Point {\n readonly x: number;\n readonly y: number;\n}\n\nexport const rect = (x: number, y: number, width: number, height: number): Rect => ({ x, y, width, height });\n\n/** The area two rects share (0 when apart). */\nexport const overlap = (a: Rect, b: Rect): number =>\n Math.max(0, Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x)) * Math.max(0, Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y));\n\n/** `r` moved (not resized) to lie inside `area`; one larger than the area keeps its top-left corner on the area's. */\nexport const clampInto = (r: Rect, area: Rect): Rect => ({\n ...r,\n x: Math.min(Math.max(r.x, area.x), Math.max(area.x, area.x + area.width - r.width)),\n y: Math.min(Math.max(r.y, area.y), Math.max(area.y, area.y + area.height - r.height)),\n});\n\n/** The centre of a rect. */\nexport const centre = (r: Rect): Point => ({ x: r.x + r.width / 2, y: r.y + r.height / 2 });\n\n/** The tolerance the geometry compares with, px. */\nexport const EPS = 1e-6;\n\n/** A rect that covers any point a page can see (a float target's hit). */\nexport const PLANE: Rect = rect(-1e9, -1e9, 2e9, 2e9);\n\n/** A rect's area (a negative side counts as 0). */\nexport const area = (r: Rect): number => Math.max(0, r.width) * Math.max(0, r.height);\n\n/** Whether two rects share more than `eps` each way (touching edges don't overlap). */\nexport const overlaps = (a: Rect, b: Rect, eps = EPS): boolean =>\n Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x) > eps && Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y) > eps;\n\n/** Whether `p` lies in `r`, its edges included (within `eps`). */\nexport const contains = (r: Rect, p: Point, eps = EPS): boolean => p.x >= r.x - eps && p.x <= r.x + r.width + eps && p.y >= r.y - eps && p.y <= r.y + r.height + eps;\n\n/** `v` within `lo..hi` (`lo` wins when `hi` is under it). */\nexport const clamp = (v: number, lo: number, hi: number): number => Math.min(Math.max(v, lo), Math.max(lo, hi));\n\n/** `r` less `cut`, as disjoint rects: the parts beside the cut whole, then above and below it within its width. */\nexport function subtract(r: Rect, cut: Rect): Rect[] {\n if (!overlaps(r, cut)) return [r];\n const right = r.x + r.width;\n const bottom = r.y + r.height;\n const x0 = Math.max(r.x, cut.x);\n const x1 = Math.min(right, cut.x + cut.width);\n return [\n rect(r.x, r.y, x0 - r.x, r.height),\n rect(x1, r.y, right - x1, r.height),\n rect(x0, r.y, x1 - x0, Math.min(bottom, cut.y) - r.y),\n rect(x0, Math.max(r.y, cut.y + cut.height), x1 - x0, bottom - Math.max(r.y, cut.y + cut.height)),\n ].filter((p) => area(p) > EPS);\n}\n\n/**\n * Hit sizes the targets share: how far a column line's hit reaches on each side of the line, and how deep a side takes\n * a rail drop while it shows no rail, px.\n */\nexport const COLUMN_REACH = 22;\nexport const RAIL_EDGE = 10;\n"],"mappings":";AAuBO,IAAM,OAAO,CAAC,GAAW,GAAW,OAAe,YAA0B,EAAE,GAAG,GAAG,OAAO,OAAO;AAGnG,IAAM,UAAU,CAAC,GAAS,MAC/B,KAAK,IAAI,GAAG,KAAK,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,IAAI,KAAK,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,IAAI,KAAK,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;AAG/I,IAAM,YAAY,CAAC,GAASA,WAAsB;AAAA,EACvD,GAAG;AAAA,EACH,GAAG,KAAK,IAAI,KAAK,IAAI,EAAE,GAAGA,MAAK,CAAC,GAAG,KAAK,IAAIA,MAAK,GAAGA,MAA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K,KAAK,IAAI,EAAE,GAAG,IAAI,CAAC;AAC9B,QAAM,KAAK,KAAK,IAAI,OAAO,IAAI,IAAI,IAAI,KAAK;AAC5C,SAAO;AAAA,IACL,KAAK,EAAE,GAAG,EAAE,GAAG,KAAK,EAAE,GAAG,EAAE,MAAM;AAAA,IACjC,KAAK,IAAI,EAAE,GAAG,QAAQ,IAAI,EAAE,MAAM;AAAA,IAClC,KAAK,IAAI,EAAE,GAAG,KAAK,IAAI,KAAK,IAAI,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;AAAA,IACpD,KAAK,IAAI,KAAK,IAAI,EAAE,GAAG,IAAI,IAAI,IAAI,MAAM,GAAG,KAAK,IAAI,SAAS,KAAK,IAAI,EAAE,GAAG,IAAI,IAAI,IAAI,MAAM,CAAC;AAAA,EACjG,EAAE,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,GAAG;AAC/B;AAMO,IAAM,eAAe;AACrB,IAAM,YAAY;","names":["area"]}
1
+ {"version":3,"sources":["../src/geometry.ts"],"sourcesContent":["/**\n * The shapes every entry shares. Plain data: a rect is a top-left corner and a size, in whatever px the consumer\n * lays out in (stage, window or host coordinates). The same shape as @n-uf/motion's, so the two compose without\n * either importing the other.\n */\n\nexport interface Rect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport interface Size {\n readonly width: number;\n readonly height: number;\n}\n\nexport interface Point {\n readonly x: number;\n readonly y: number;\n}\n\nexport const rect = (x: number, y: number, width: number, height: number): Rect => ({ x, y, width, height });\n\n/** The area two rects share (0 when apart). */\nexport const overlap = (a: Rect, b: Rect): number =>\n Math.max(0, Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x)) * Math.max(0, Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y));\n\n/** `r` moved (not resized) to lie inside `area`; one larger than the area keeps its top-left corner on the area's. */\nexport const clampInto = (r: Rect, area: Rect): Rect => ({\n ...r,\n x: Math.min(Math.max(r.x, area.x), Math.max(area.x, area.x + area.width - r.width)),\n y: Math.min(Math.max(r.y, area.y), Math.max(area.y, area.y + area.height - r.height)),\n});\n\n/** The center of a rect. */\nexport const centre = (r: Rect): Point => ({ x: r.x + r.width / 2, y: r.y + r.height / 2 });\n\n/** The tolerance the geometry compares with, px. */\nexport const EPS = 1e-6;\n\n/** A rect that covers any point a page can see (a float target's hit). */\nexport const PLANE: Rect = rect(-1e9, -1e9, 2e9, 2e9);\n\n/** A rect's area (a negative side counts as 0). */\nexport const area = (r: Rect): number => Math.max(0, r.width) * Math.max(0, r.height);\n\n/** Whether two rects share more than `eps` each way (touching edges don't overlap). */\nexport const overlaps = (a: Rect, b: Rect, eps = EPS): boolean =>\n Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x) > eps && Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y) > eps;\n\n/** Whether `p` lies in `r`, its edges included (within `eps`). */\nexport const contains = (r: Rect, p: Point, eps = EPS): boolean => p.x >= r.x - eps && p.x <= r.x + r.width + eps && p.y >= r.y - eps && p.y <= r.y + r.height + eps;\n\n/** `v` within `lo..hi` (`lo` wins when `hi` is under it). */\nexport const clamp = (v: number, lo: number, hi: number): number => Math.min(Math.max(v, lo), Math.max(lo, hi));\n\n/** `r` less `cut`, as disjoint rects: the parts beside the cut whole, then above and below it within its width. */\nexport function subtract(r: Rect, cut: Rect): Rect[] {\n if (!overlaps(r, cut)) return [r];\n const right = r.x + r.width;\n const bottom = r.y + r.height;\n const x0 = Math.max(r.x, cut.x);\n const x1 = Math.min(right, cut.x + cut.width);\n return [\n rect(r.x, r.y, x0 - r.x, r.height),\n rect(x1, r.y, right - x1, r.height),\n rect(x0, r.y, x1 - x0, Math.min(bottom, cut.y) - r.y),\n rect(x0, Math.max(r.y, cut.y + cut.height), x1 - x0, bottom - Math.max(r.y, cut.y + cut.height)),\n ].filter((p) => area(p) > EPS);\n}\n\n/**\n * Hit sizes the targets share: how far a column line's hit reaches on each side of the line, and how deep a side takes\n * a rail dr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 @@
1
- import { R as Rect, S as Size } from './geometry-CkZ6Fcfb.js';
1
+ import { R as Rect, S as Size } from './geometry-Bf37LbCT.js';
2
2
 
3
3
  /**
4
4
  * The desk's model: panels and documents, the options, the state every construction keeps, and what a layout
@@ -100,7 +100,7 @@ interface DeskState {
100
100
  };
101
101
  /** Panels torn off a dock, floating (edge docks + tear-off). */
102
102
  readonly torn: readonly Free[];
103
- /** The tiling tree: item keys in the left column, the right column and the centre (dwindle order). */
103
+ /** The tiling tree: item keys in the left column, the right column and the center (dwindle order). */
104
104
  readonly tree: {
105
105
  readonly L: readonly string[];
106
106
  readonly R: readonly string[];
@@ -180,7 +180,7 @@ interface Layout {
180
180
  readonly notes: readonly Note[];
181
181
  }
182
182
  /**
183
- * The same state with these documents open: new ones join the tiling tree's centre (the first one at its front)
183
+ * The same state with these documents open: new ones join the tiling tree's center (the first one at its front)
184
184
  * and get a strip column of their own after the last document column; closed ones leave both.
185
185
  */
186
186
  declare function withDocs(s: DeskState, docs: readonly number[], focus: number | null): DeskState;
package/dist/desk.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { P as PanelsOptions, a as PanelDef, b as PanelsState, c as PanelTargetInput, d as PanelTarget, p as panelDrop, e as PanelDrop, l as layoutPanels, f as PanelsLayout } from './targets-BYRTTwCP.js';
2
- import './geometry-CkZ6Fcfb.js';
3
- import './target-D9PMr9pF.js';
1
+ import { P as PanelsOptions, a as PanelDef, b as PanelsState, c as PanelTargetInput, d as PanelTarget, p as panelDrop, e as PanelDrop, l as layoutPanels, f as PanelsLayout } from './targets-Du5_4T1u.js';
2
+ import './geometry-Bf37LbCT.js';
3
+ import './target-2RYYKkd1.js';
4
4
 
5
5
  /**
6
6
  * @n-uf/placement/desk: desk presets as data on `@n-uf/placement/panels`. A preset is options for the panels engine
package/dist/desk.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./chunk-OYGOJWAX.js";
1
+ import "./chunk-JVAR67OL.js";
2
2
  import {
3
3
  createPanels,
4
4
  floatSize,
@@ -6,8 +6,8 @@ import {
6
6
  panelDrop,
7
7
  panelTargets,
8
8
  showTabs
9
- } from "./chunk-7ASCUAGV.js";
10
- import "./chunk-WM5FJ3IS.js";
9
+ } from "./chunk-3ZICYLWL.js";
10
+ import "./chunk-VLTYJHUA.js";
11
11
 
12
12
  // src/desk/index.ts
13
13
  function split(defs, hint = {}) {
package/dist/dock.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { C as Catalog, D as DeskState, N as Note } from './constructions-DSEjvWMP.js';
2
- export { a as Construction, b as ConstructionId, c as DEFAULT_OPTIONS, d as Desk, e as DeskSpec, f as DeskStart, F as Free, G, L as LAYER, g as Layout, h as Look, i as NoteCode, O as Options, P as PanelSpec, j as Placed, S as Side, k as createDesk, l as docKey, m as draggable, n as idOf, o as isDocKey, p as isPanelKey, q as liftOut, r as panelKey, t as toggleClosed, s as toggleFold, u as touch, w as withActive, v as withDocs } from './constructions-DSEjvWMP.js';
3
- import { S as Size } from './geometry-CkZ6Fcfb.js';
1
+ import { C as Catalog, D as DeskState, N as Note } from './constructions-Cbz7uEAZ.js';
2
+ export { a as Construction, b as ConstructionId, c as DEFAULT_OPTIONS, d as Desk, e as DeskSpec, f as DeskStart, F as Free, G, L as LAYER, g as Layout, h as Look, i as NoteCode, O as Options, P as PanelSpec, j as Placed, S as Side, k as createDesk, l as docKey, m as draggable, n as idOf, o as isDocKey, p as isPanelKey, q as liftOut, r as panelKey, t as toggleClosed, s as toggleFold, u as touch, w as withActive, v as withDocs } from './constructions-Cbz7uEAZ.js';
3
+ import { S as Size } from './geometry-Bf37LbCT.js';
4
4
 
5
5
  /**
6
6
  * The parts the desk constructions are built from, each pure: the toolbar pill, the documents' tiles, natural-height
@@ -19,7 +19,7 @@ interface StripGeometry {
19
19
  readonly total: number;
20
20
  readonly scroll: number;
21
21
  }
22
- /** The strip's columns and scroll: scrolled by hand, else to centre the focused document's column. */
22
+ /** The strip's columns and scroll: scrolled by hand, else to center the focused document's column. */
23
23
  declare function stripGeometry(cat: Catalog, s: DeskState, size: Size, notes?: Note[]): StripGeometry;
24
24
 
25
25
  export { Catalog, DeskState, Note, type StripGeometry, stripGeometry };
package/dist/dock.js CHANGED
@@ -47,11 +47,11 @@ import {
47
47
  treeTiles,
48
48
  withActive,
49
49
  withDocs
50
- } from "./chunk-3P6VOXA6.js";
50
+ } from "./chunk-AVMZIXGO.js";
51
51
  import {
52
52
  clampInto,
53
53
  rect
54
- } from "./chunk-WM5FJ3IS.js";
54
+ } from "./chunk-VLTYJHUA.js";
55
55
 
56
56
  // src/dock/constructions.ts
57
57
  function docks(cat, s, size, opt, mode, notes) {