@n-uf/placement 26.11.25 → 26.11.27

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.
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/scene/model.ts","../src/scene/solve.ts","../src/scene/changes.ts","../src/scene/store.ts","../src/scene/targets.ts"],"sourcesContent":["/**\n * The scene's shapes: one model of a whole window. A scene is a stage (the window's inner rect), the edges along its\n * sides (bars and columns, each a stack of items), the items, the floats above the content, and the chrome that\n * floats and drop zones keep clear of. `solve(scene)` turns it into a `SceneLayout`: every rect a host draws.\n *\n * Plain data in and out, nothing module-global: two windows on one page are two scenes. No words, no time, no DOM.\n */\nimport type { Rect, Size } from \"../geometry\";\nimport type { CrossLimits, StackFit, StackForm, StackFormKind, StackNote } from \"../stack\";\n\n/** The host's kinds of item, such as \"panel\" and \"group\". An edge takes only the kinds it lists. */\nexport type Kind = string;\n\n/** A side of the stage. Left and right edges are columns (they run down); top and bottom edges are bars (they run across). */\nexport type Side = \"top\" | \"right\" | \"bottom\" | \"left\";\nexport const SIDES: readonly Side[] = [\"top\", \"right\", \"bottom\", \"left\"];\n\n/** Where an item sits along its edge: packed from the start, centred in the spare length, or packed from the end. */\nexport type Zone = \"start\" | \"center\" | \"end\";\nexport const ZONES: readonly Zone[] = [\"start\", \"center\", \"end\"];\n\n/** A float that follows the content: flush with that side or corner of `layout.content` until a drop gives it a real rect. */\nexport type FloatAnchor =\n | \"content-top-left\"\n | \"content-top\"\n | \"content-top-right\"\n | \"content-right\"\n | \"content-bottom-right\"\n | \"content-bottom\"\n | \"content-bottom-left\"\n | \"content-left\";\n\n/** Along which axis an item lies: a column runs down, a row (a bar) runs across. */\nexport type Orient = \"column\" | \"row\";\n\nexport interface SceneItem {\n readonly id: string;\n readonly kind: Kind;\n /**\n * Its forms along a column and along a row (a bar), largest first, as `./stack` takes them. An item with no forms for\n * an axis can't be laid out along it (`no-forms`).\n */\n readonly forms: { readonly column?: readonly StackForm[]; readonly row?: readonly StackForm[] };\n /** How recently it was used: the smaller, the longer ago, the sooner it gives way. */\n readonly used: number;\n /** Kept: gives way after every item that isn't. */\n readonly kept?: boolean;\n /**\n * The first form it may take, an index into the forms of the axis it lies along (default 0). Folding by hand sets it\n * (`fold`). A float with `from` over 0 is drawn as its bar: that form's natural length, at the float's place.\n */\n readonly from?: number;\n /**\n * Reserved room: a title, window controls, a page readout. It never changes form (it keeps `forms[from]`), is never\n * reordered, never dragged, and no hit or slot covers it. Its length may shrink to its form's `main.min` and grow\n * with spare room when the form `grows`; window controls have `min` equal to `natural`.\n */\n readonly fixed?: boolean;\n /** Closed: it keeps its place in its edge (or its float rect) but takes no room and has no targets. */\n readonly closed?: boolean;\n /** Its zone in its edge (default start). */\n readonly align?: Zone;\n /**\n * Its give-way priority in its edge (default: the edge's `priority`, else 0). When an edge runs short, items step down\n * their forms (row, wrap in a column, icons, then the edge's » menu) lowest priority first, ties to the one used longest\n * ago; room coming back brings them up in the exact reverse order, each to its remembered form. It adds to every one\n * of its forms' `rank` (`./stack`), so a host may still rank single forms. Give the controls that must stay out of the\n * menu the highest priority.\n */\n readonly priority?: number;\n /**\n * Its size as a float: `floatAt` with no rect uses it, and a float drop sets it. Without it, a float takes its first\n * form's natural size along its orient (`floatSizeOf`), or `DEFAULT_FLOAT_SIZE` when that form grows (a panel's card).\n */\n readonly floatSize?: Size;\n /**\n * Which of its forms it uses as a float when the float names no `orient` (`floatOrientOf`). Default: the axis of its\n * first form, the first of `forms.row` / `forms.column` it declares (a group declared row first floats as a row).\n */\n readonly floatOrient?: Orient;\n /**\n * The least a float of it is shrunk to: a float larger than the region floats lie in is laid out at\n * `max(floatMin, min(its size, the region))` each way. A floor wider than the region keeps it at the region's left\n * edge; one taller than the stage keeps it at the stage's top and runs past its bottom. A folded float (its header\n * form) keeps its height. Without it, a shrink stops at the form's own minimums.\n */\n readonly floatMin?: Size;\n}\n\nexport interface Edge {\n readonly id: string;\n readonly side: Side;\n /** 0 is the outermost on its side (a title bar outside a toolbar). */\n readonly ring: number;\n /**\n * Top and bottom bars only: across the whole stage (`\"full\"`, the default) or between the side columns\n * (`\"between\"`). Left and right edges ignore it.\n */\n readonly span?: \"full\" | \"between\";\n /** The kinds a drop may bring here. Deny by default: an empty list takes nothing (an anchor). */\n readonly accepts: readonly Kind[];\n /** Ids in order, fixed and closed items included. */\n readonly items: readonly string[];\n /** The size it may take across (a column's width, a bar's height), and the rail width when nothing sets it. */\n readonly cross: CrossLimits;\n /** `\"overlay\"` lies over the content instead of shortening it (default `\"reserved\"`). */\n readonly mode?: \"reserved\" | \"overlay\";\n readonly gap?: number;\n readonly pad?: { readonly start?: number; readonly end?: number };\n /** The » entry's length along the edge. */\n readonly menu?: { readonly main: number };\n /**\n * The user's size across (a column dragged wider), clamped to `[max(cross.min, the widest open setter's cross.min),\n * cross.max]`, so an open item's `cross.min` wins over a smaller size. Used only while an item sets the cross size.\n */\n readonly size?: number;\n /** A column drawn as a rail (nothing in it sets its width) shows its closed items too, as tabs marked `closed`. */\n readonly railShowsClosed?: boolean;\n /**\n * An icons-only edge (a thin rail of vertical toolbars along a window side): its items take only their `icons` form\n * (and the » menu after it), stacked, each grip the divider. An item with no `icons` form is left out\n * (`no-icons-form`).\n */\n readonly compact?: boolean;\n /**\n * The kinds each zone takes, narrowing `accepts`: with it, a zone not listed takes nothing. A panel column with\n * `{ start: [\"panel\"], end: [\"group\"] }` has its panels at the top and a tray of toolbars at its foot (the end zone, one\n * toolbar per row): a toolbar in the tray takes only its `wrap` or `icons` form (never the menu), and the panels give\n * way first. An empty edge offers each third of its strip only to the kinds that third's zone takes (the others are\n * refusals). A group never opens such a column on its own: an empty side column offers its strip only to the kinds\n * its start zone takes (a panel gets its top third; a group none, the rail's instead).\n */\n readonly zoneAccepts?: ZoneAccepts;\n /** The drop strip's depth while the edge is empty, px (default {@link DEFAULT_STRIP}). */\n readonly strip?: number;\n /**\n * How a gap's hit runs along the edge. The gaps always split the edge halfway between neighbouring insertion lines, so\n * free space and short items (a toolbar, a closed or folded panel) are covered end to end. A number: over an open\n * item's body only (a panel), the hit narrows to a band that many px around the line, so the middle of a panel is no\n * gap and the pointer falls through to the float target, or to none. `\"middle\"`: no band, so panels are split too.\n * Default {@link DEFAULT_HIT_BAND}.\n */\n readonly hitBand?: number | \"middle\";\n /**\n * A dynamic column (left and right only): made by a drop on a column line, deleted when it holds no item, folded whole\n * into its side's rail by give-way (`Scene.contentMin`) or when every member is folded by hand. Its `accepts`,\n * `cross`, `gap`, `pad` and `menu` come from `Scene.columns[side]` when the changes make it.\n */\n readonly column?: boolean;\n /**\n * An anchor edge (a left or right edge that takes nothing, holding a fixed item such as a thumbnail strip) lies outside\n * `Scene.inset` and the gutter: at the window's side, the inset after it, toward the content. A full top or bottom bar\n * with it lies at the window's edge, full width, the inset after it; the side edges then run between such bars (an\n * anchor through the inset beside them). On a left or right side, from the window's side inward: its toolbar bars\n * with it (`isOutsideSideBar`), the side's rail, its anchors, the inset, the columns.\n */\n readonly outsideInset?: boolean;\n /**\n * A static left or right edge that gives way like a dynamic column: it shrinks toward its minimum, then folds whole\n * into its side's rail, in give-way order with the columns (its items' ages). It is never deleted.\n */\n readonly giveWay?: boolean;\n /**\n * The default give-way priority of its items (`SceneItem.priority` wins; default 0): a title bar given a lower one has\n * its toolbars step down before an item moved in from another bar would.\n */\n readonly priority?: number;\n}\n\n/** What a side's new columns are made from. */\nexport interface ColumnTemplate {\n readonly accepts: readonly Kind[];\n readonly cross: CrossLimits;\n readonly gap?: number;\n readonly pad?: { readonly start?: number; readonly end?: number };\n readonly menu?: { readonly main: number };\n /** The kinds each zone takes in the columns made from it (`Edge.zoneAccepts`). */\n readonly zoneAccepts?: ZoneAccepts;\n}\n\n/** Per zone, the kinds it takes. */\nexport type ZoneAccepts = Readonly<Partial<Record<Zone, readonly Kind[]>>>;\n\n/** Whether `edge` takes kind `kind` in `zone`: its `accepts`, narrowed by `zoneAccepts` when given (a zone not listed takes nothing). */\nexport const zoneTakes = (edge: { readonly accepts: readonly Kind[]; readonly zoneAccepts?: ZoneAccepts }, zone: Zone, kind: Kind): boolean =>\n edge.accepts.includes(kind) && (edge.zoneAccepts === undefined || !!edge.zoneAccepts[zone]?.includes(kind));\n\n/** The zones of `edge` that take `kind`, in order. */\nexport const zonesTaking = (edge: { readonly accepts: readonly Kind[]; readonly zoneAccepts?: ZoneAccepts }, kind: Kind): Zone[] => ZONES.filter((z) => zoneTakes(edge, z, kind));\n\n/** A side's one rail strip: folded columns show in it as segments, in ring order. */\nexport interface RailSpec {\n /** Its width, px. */\n readonly width: number;\n /** The kinds a drop on the rail may bring (it docks folded). */\n readonly accepts: readonly Kind[];\n}\n\nexport interface SceneFloat {\n readonly id: string;\n /** Its rect in stage px (it never scrolls with the content). With `anchor`, only its size counts. */\n readonly rect: Rect;\n /** Follow the content's side or corner until a drop gives it a real rect. */\n readonly anchor?: FloatAnchor;\n /** Which of the item's forms it uses (default: the item's `floatOrientOf`). */\n readonly orient?: Orient;\n}\n\nexport interface Scene {\n /** The window's inner rect. */\n readonly stage: Rect;\n readonly edges: readonly Edge[];\n readonly items: Readonly<Record<string, SceneItem>>;\n /** Stacking order: the last is on top. */\n readonly floats: readonly SceneFloat[];\n /** The kinds that may float. Deny by default. */\n readonly floatKinds: readonly Kind[];\n /** Rects that floats and drop zones keep clear of (a title the host draws itself, a status line). */\n readonly chrome?: readonly Rect[];\n /** Spots where a release cancels: `targets` gives a `none` target over each. */\n readonly blocked?: readonly Rect[];\n /** Per side (left, right): what a new column is made from. A side without one gets no new columns. */\n readonly columns?: Partial<Record<\"left\" | \"right\", ColumnTemplate>>;\n /** Per side (left, right): its rail. A side without one keeps folded columns as columns. */\n readonly rails?: Partial<Record<\"left\" | \"right\", RailSpec>>;\n /**\n * The least the content may be. While the content is narrower than `width`, dynamic columns shrink toward their\n * minimum, then fold whole into their side's rail: unkept before kept, the one whose newest use is oldest first, the\n * outer first, the left first. Under `height`, a `content-short` note.\n */\n readonly contentMin?: { readonly width: number; readonly height: number };\n /**\n * How a column folded by hand shows (default `\"bar\"`): `\"bar\"` sends it to its side's rail; `\"ride\"` draws each of its\n * members as a title bar over the first open column of its side (stacked, in zone order), at that column's width,\n * taking no width of their own.\n */\n readonly handFold?: \"bar\" | \"ride\";\n /**\n * Space kept clear inside the stage's edges, px (default 0 each). Floats are clamped into the stage less its left and\n * right (the stage's full height), and shrunk to fit that region when larger.\n */\n readonly inset?: { readonly top?: number; readonly right?: number; readonly bottom?: number; readonly left?: number };\n /**\n * When `inset` applies (default `\"always\"`): `\"docked\"` keeps it only while a panel is docked beside the content (an\n * open panel column or a rail showing panels: a left or right edge that takes something, with an item that isn't\n * closed or fixed and whose first column form is `open`, `header` or `rail`). Bars, toolbar groups and an anchor\n * never count, wherever they sit; with no panel there, the content is the whole stage.\n */\n readonly insetWhen?: \"always\" | \"docked\";\n /** Space after each left or right edge and each rail that takes room, toward the content, px (default 0). */\n readonly gutter?: number;\n}\n\n/** An item as laid out. */\nexport interface SceneItemLayout {\n /** Stage px. An item in the » menu has the menu entry's rect. */\n readonly rect: Rect;\n readonly kind: Kind;\n /** The form it took: an index into the forms of its axis. */\n readonly form: number;\n readonly formKind: StackFormKind;\n /** Docked: its edge and zone. */\n readonly edge?: string;\n readonly zone?: Zone;\n readonly floating?: boolean;\n readonly inMenu?: boolean;\n /** A rail tab (its column is a rail). */\n readonly tab?: boolean;\n /** A closed item shown as a rail tab (`railShowsClosed`). */\n readonly closed?: boolean;\n readonly fixed?: boolean;\n /** Drawn as a segment of this side's rail (its column is folded). */\n readonly rail?: \"left\" | \"right\";\n /** Drawn as a title bar riding on this column (`handFold: \"ride\"`). */\n readonly rides?: string;\n /** Its column folded: by hand (every member folded) or by give-way. */\n readonly folded?: \"hand\" | \"auto\";\n /** A `wrap` form: the word indexes per row (the words wrap beside the grip, a hanging indent). */\n readonly rows?: readonly (readonly number[])[];\n /** Its grip: a `wrap` form's lead cell at the start of row one, or a form's `grip` strip (an icons strip's, on top). */\n readonly grip?: Rect;\n}\n\n/** An edge as laid out. */\nexport interface SceneEdgeLayout {\n readonly side: Side;\n readonly ring: number;\n /** Stage px: the strip it takes (zero across when nothing is drawn in it). */\n readonly rect: Rect;\n /** Its size across. */\n readonly cross: number;\n /** Its » entry and the items in it, or null. */\n readonly menu: { readonly rect: Rect; readonly items: readonly string[] } | null;\n /** The ids drawn as rail tabs, in order (empty unless the column is a rail). */\n readonly tabs: readonly string[];\n /**\n * The stack fits behind it, in stack-local px: `stack` is the one drawn, `free` the first fit (before `size` or the\n * rail re-solved it). `solve`'s `previous` reads both; a host needs neither.\n */\n readonly stack: StackFit;\n readonly free: StackFit;\n /** A dynamic column folded into its side's rail (its rect is zero wide there): by hand or by give-way. */\n readonly folded?: \"hand\" | \"auto\";\n /** Shrunk by give-way below the width it asks for. */\n readonly shrunk?: boolean;\n /** Riding on this column (its rect is the bars'). */\n readonly rides?: string;\n}\n\n/** A side's rail as laid out. */\nexport interface SceneRailLayout {\n readonly rect: Rect;\n /** One per member of each folded column, in ring order. */\n readonly segments: readonly { readonly id: string; readonly edge: string; readonly rect: Rect }[];\n}\n\n/**\n * Why the layout looks as it does:\n * - a stack's note with its `edge` (`form-down`, `to-menu`, `too-wide`, `no-forms`, `overflow`);\n * - `unknown-item`: an id in an edge or a float that `items` lacks (left out);\n * - `twice`: an item placed in two places (the first in cut order wins, edges before floats);\n * - `float-clamped`, `float-moved`: a float was moved into the stage, or clear of what it would cover;\n * - `float-covers`: no clear place exists, and it covers the least it can.\n * - `column-shrunk`, `column-folded`, `kept-folded`: give-way by `contentMin.width`, in give-way order;\n * - `content-narrow`, `content-short`: the content is still under `contentMin` (overlay bars count against the height).\n * - `no-column-room`: not even one column at its minimum fits beside `contentMin.width` (`layout.columnRoom` false):\n * `width` is the room the stage leaves, `need` the content's minimum plus that column and its gutter.\n * - `content-changed`: under `previous`, `content` is not the rect `previous.content` was (`from`, `to`). A host refits\n * its zoom only on this note.\n * - `no-vertical-form`: an item left out of a vertical place (a rail, a vertical float) because only `wrap` forms are\n * left to it (vertical means icons: give a word group an `icons` form).\n */\nexport type SceneNote =\n | ({ readonly edge: string } & StackNote)\n | { readonly code: \"unknown-item\"; readonly id: string }\n | { readonly code: \"twice\"; readonly id: string }\n | { readonly code: \"float-clamped\" | \"float-moved\" | \"float-covers\"; readonly id: string }\n | { readonly code: \"column-shrunk\"; readonly edge: string; readonly from: number; readonly to: number }\n | { readonly code: \"column-folded\" | \"kept-folded\"; readonly edge: string }\n | { readonly code: \"no-column-room\"; readonly width: number; readonly need: number }\n | { readonly code: \"content-narrow\"; readonly width: number; readonly min: number }\n | { readonly code: \"content-short\"; readonly height: number; readonly min: number }\n | { readonly code: \"content-changed\"; readonly from: Rect; readonly to: Rect }\n | { readonly code: \"no-vertical-form\"; readonly id: string; readonly edge?: string }\n | { readonly code: \"no-icons-form\"; readonly id: string; readonly edge: string };\nexport type SceneNoteCode = SceneNote[\"code\"];\n\nexport interface SceneLayout {\n /** Every item drawn (closed items only when shown as rail tabs). */\n readonly items: Readonly<Record<string, SceneItemLayout>>;\n readonly edges: Readonly<Record<string, SceneEdgeLayout>>;\n /** What is left for the content (the pages). Overlay edges lie over it. */\n readonly content: Rect;\n /** The floats drawn, in stacking order (the last on top). */\n readonly floats: readonly string[];\n /** The rails shown (a side with a folded column). Hosts draw these. */\n readonly rails: Readonly<Partial<Record<\"left\" | \"right\", SceneRailLayout>>>;\n /**\n * Where each side's rail lies, or would lie were one shown, for every side that has a rail (`Scene.rails`), drawn or\n * not: the place a drop into the rail lands (`targets` reads it). Hosts draw `rails`, never `railPlaces`.\n */\n readonly railPlaces: Readonly<Partial<Record<\"left\" | \"right\", Rect>>>;\n /**\n * With `contentMin` and a dynamic column (or, before any exists, a `columns` template): whether one column at its\n * minimum fits beside the content's minimum (`false` with a `no-column-room` note). Anchors and rails don't count:\n * every column can fold into its rail. A host shows its narrow fallback (one panel over the content) while it is `false`.\n */\n readonly columnRoom?: boolean;\n readonly notes: readonly SceneNote[];\n}\n\nexport interface SolveOptions {\n /**\n * The layout the scene had before: each edge's fit goes to `fitStack` as `previous`, so a press reshapes nothing. An\n * item docked now that was closed or absent then has just opened: it counts as the newest (its largest form while it\n * fits; the others give way by the usual rules), and its column is weighed anew by give-way.\n */\n readonly previous?: SceneLayout;\n /** Edge or item ids solved without `previous` (an edge, or the edges holding the item; a column weighed anew). */\n readonly fresh?: readonly string[];\n}\n\n/** A drop strip's depth inside the content while an edge is empty, px. */\nexport const DEFAULT_STRIP = 24;\n/** A gap's hit over an open item's body (a panel): a band this many px around the gap's insertion line. */\nexport const DEFAULT_HIT_BAND = 24;\n/** A float's size when neither the item nor the call gives one, px. */\nexport const DEFAULT_FLOAT_SIZE: Size = { width: 280, height: 360 };\n\n/** The axis an edge's stack runs along. */\nexport const axisOf = (side: Side): Orient => (side === \"left\" || side === \"right\" ? \"column\" : \"row\");\nexport const zoneOf = (item: SceneItem | undefined): Zone => (item?.align === \"center\" || item?.align === \"end\" ? item.align : \"start\");\nexport const formsOf = (item: SceneItem, axis: Orient): readonly StackForm[] => item.forms[axis] ?? [];\n\n/**\n * A left or right toolbar bar outside the inset (`isSideBar` with `outsideInset`). It lies outermost on its side,\n * before the side's rail.\n */\nexport function isOutsideSideBar(scene: Scene, e: Edge): boolean {\n return e.outsideInset === true && isSideBar(scene, e);\n}\n\n/**\n * A left or right toolbar bar: told from a column edge by its kinds, it takes something and nothing the side's columns\n * or its rail take (`Scene.columns[side].accepts`, `Scene.rails[side].accepts`); an anchor takes nothing. A side with\n * neither a column template nor a rail has nothing to tell them apart by, so no edge there is a bar.\n */\nexport function isSideBar(scene: Scene, e: Edge): boolean {\n if ((e.side !== \"left\" && e.side !== \"right\") || e.column === true || e.accepts.length === 0) return false;\n const template = scene.columns?.[e.side];\n const rail = scene.rails?.[e.side];\n if (!template && !rail) return false;\n const panelKinds = [...(template?.accepts ?? []), ...(rail?.accepts ?? [])];\n return !e.accepts.some((k) => panelKinds.includes(k));\n}\n\n/**\n * The orient a float of `item` takes when it names none: its `floatOrient`, else the axis of its first form (the first\n * of `forms.row` / `forms.column` it declares with any form), else column.\n */\nexport const floatOrientOf = (item: SceneItem): Orient => {\n if (item.floatOrient === \"row\" || item.floatOrient === \"column\") return item.floatOrient;\n for (const k of Object.keys(item.forms)) if ((k === \"row\" || k === \"column\") && formsOf(item, k).length > 0) return k;\n return \"column\";\n};\n\n/**\n * A float's size when nothing gives one: the item's `floatSize`, else its first form's natural size along `orient`\n * (default `floatOrientOf`), else `DEFAULT_FLOAT_SIZE` when that form grows (a panel's card has no natural float length)\n * or the item has no form there.\n */\nexport function floatSizeOf(item: SceneItem, orient: Orient = floatOrientOf(item)): Size {\n if (item.floatSize) return item.floatSize;\n const f = formsOf(item, orient)[0];\n if (!f || f.main.grows) return DEFAULT_FLOAT_SIZE;\n const main = Number.isFinite(f.main.natural) ? Math.max(0, f.main.natural) : 0;\n const cross = Number.isFinite(f.cross.natural) ? Math.max(0, f.cross.natural) : 0;\n if (main <= 0 || cross <= 0) return DEFAULT_FLOAT_SIZE;\n return orient === \"row\" ? { width: main, height: cross } : { width: cross, height: main };\n}\n\n/** The first form at or after `from` that isn't a `wrap` form (vertical means icons), or undefined when none is. */\nexport function pastWrap(forms: readonly StackForm[], from: number): number | undefined {\n for (let j = Math.max(0, Math.floor(from)); j < forms.length; j++) if (forms[j]!.kind !== \"wrap\" && !forms[j]!.wrap) return j;\n return undefined;\n}\n\n/**\n * How `solve` draws a float: the form it takes (an index into its `orient`'s forms) and its size. A vertical float\n * (`orient: \"column\"`) skips `wrap` forms, which apply only in a column edge: any form it takes after a skipped `wrap`\n * form (its icons) is drawn at that form's natural size, whatever its `from`. An item with only `wrap` forms left has no\n * form there (`none`: `solve` leaves it out with a `no-vertical-form` note), so a word group needs an `icons` form.\n * Otherwise a float with `from` over 0 is its bar (that form's natural length along its orient, its other size kept), and\n * one at its first form is its rect's size.\n */\nexport function floatShape(item: SceneItem, f: { readonly rect: Rect; readonly orient?: Orient }): { form: number; width: number; height: number; none?: true } {\n const orient = f.orient ?? floatOrientOf(item);\n const forms = formsOf(item, orient);\n const px = (v: number): number => (Number.isFinite(v) ? Math.max(0, v) : 0);\n const w = px(f.rect.width);\n const h = px(f.rect.height);\n if (forms.length === 0) return { form: 0, width: w, height: h };\n const asked = Math.min(Math.max(0, Math.floor(Number.isFinite(item.from) ? item.from! : 0)), forms.length - 1);\n const isWrap = (x: StackForm): boolean => x.kind === \"wrap\" || !!x.wrap;\n const skipped = orient === \"column\" ? pastWrap(forms, asked) : asked;\n if (skipped === undefined) return { form: asked, width: w, height: h, none: true };\n const form = skipped;\n const fm = forms[form]!;\n if (orient === \"column\" && forms.slice(0, form + 1).some(isWrap)) return { form, width: px(fm.cross.natural), height: px(fm.main.natural) };\n if (form > 0) return orient === \"column\" ? { form, width: w, height: px(fm.main.natural) } : { form, width: px(fm.main.natural), height: h };\n return { form, width: w, height: h };\n}\n","/**\n * `solve(scene, { previous })`: the whole window's layout from one scene.\n *\n * 1. **The cut.** Reserved edges cut the stage from the outside in: first the full-span bars (top, then bottom, each\n * by ring), across the stage's whole width; then the columns (left, then right, by ring), down the height the full\n * bars left; then the `between` bars, across the width the columns left. What remains is `content`. Overlay edges\n * are cut the same way from a copy of the content, so they lie over it without shortening it.\n * 2. **Each edge is a stack** (`fitStack`): a column along the height it gets, a bar along the width, with each item's\n * `forms.column` or `forms.row`. Items are taken in zone order (start, center, end); `fixed` items keep their form;\n * closed items take no room. In a column, group forms take their own width (`ownCross`). The edge's thickness is\n * the stack's cross size; an edge with nothing in it takes none.\n * 3. **Rail and size.** A column in which nothing sets the width is a rail: its items with a `rail` form are re-solved\n * in it and listed as `tabs` (closed ones too with `railShowsClosed`). Otherwise, with `Edge.size`, the column is\n * re-solved at the user's size, clamped to `[max(cross.min, the widest open setter's cross.min), cross.max]`.\n * 4. **Zones.** When the items leave spare length (nothing grows), start items pack from the start, end items from the\n * end (before the » entry) and center items sit centred on the edge's middle, moved only as far as they must to\n * stay between the other two zones.\n * 5. **Floats** are fitted inside the stage, clear of every docked item (fixed ones and » entries included), every bar\n * and the chrome rects (`fitFloat`). An anchored float sits flush with that side or corner of `content` first. A\n * float with `from` over 0 is its bar: its form's natural length along its `orient`, its other size kept.\n *\n * 6. **Dynamic columns** (`Edge.column`, on a side with `Scene.rails[side]`): while the content is narrower than\n * `contentMin.width` (after `inset` and a `gutter` after each side edge and rail), they shrink toward their minimum\n * (the edge's `cross.min` and the widest open setter's), then fold whole into their side's one rail, unkept before\n * kept, the oldest newest use first, the outer first, the left first. A column whose members are all folded by hand\n * goes to the rail too, or with `handFold: \"ride\"` and one member it rides as a title bar over the side's first open\n * column, at its width, taking none. The rail lies just outside the side's first column, its segments (each member's\n * `rail` form) in ring order.\n *\n * `previous` (the layout before) gives each edge's fits to `fitStack` as `previous`, so a change of ages alone (a press)\n * changes no rect; columns folded or shrunk by give-way stay so while the content still fits, and room coming back\n * unfolds them in the reverse of give-way order. Pure: the same scene always lays out the same.\n */\nimport { EPS, rect, type Rect } from \"../geometry\";\nimport { fitFloat } from \"../stack/floats\";\nimport { fitStack } from \"../stack/layout\";\nimport { formCrossMin, formMain, formSetsCross, wrapLines, type StackFit, type StackForm, type StackInput, type StackItem } from \"../stack/model\";\nimport { axisOf, floatOrientOf, floatShape, formsOf, isOutsideSideBar, isSideBar, pastWrap, zoneOf, type Edge, type FloatAnchor, type Scene, type SceneEdgeLayout, type SceneItem, type SceneItemLayout, type SceneLayout, type SceneNote, type SceneRailLayout, type SolveOptions, type Zone } from \"./model\";\nconst finite = (x: number | undefined, fallback: number): number => (typeof x === \"number\" && Number.isFinite(x) ? x : fallback);\nconst px = (x: number | undefined): number => Math.max(0, finite(x, 0));\n\n/** The order edges are cut in: full bars (top, bottom), columns (left, right), between bars (top, bottom); each by ring. */\nfunction cutOrder(edges: readonly Edge[]): Edge[] {\n const phase = (e: Edge): number => (e.side === \"left\" || e.side === \"right\" ? 1 : e.span === \"between\" ? 2 : 0);\n const sideRank = (e: Edge): number => (e.side === \"top\" || e.side === \"left\" ? 0 : 1);\n return edges\n .map((e, i) => ({ e, i }))\n .sort((a, b) => phase(a.e) - phase(b.e) || sideRank(a.e) - sideRank(b.e) || finite(a.e.ring, 0) - finite(b.e.ring, 0) || a.i - b.i)\n .map((x) => x.e);\n}\n\n/**\n * Where `solve` lays an edge in its laying order: `phase` 0 full bars outside the inset, 1 the other full bars, 2 the\n * sides, 3 the `between` bars, 4 overlay edges (laid over the content, pushing nothing); `at`, its place in the cut\n * order. Internal to the scene: `targets` ranks the space each edge owns by it.\n */\nexport interface LayKey {\n readonly phase: number;\n readonly side: string;\n readonly at: number;\n}\n\n/** Each edge's `LayKey`. */\nexport function layKeys(scene: Scene): Map<string, LayKey> {\n const isSide = (e: Edge): boolean => e.side === \"left\" || e.side === \"right\";\n const phase = (e: Edge): number => (e.mode === \"overlay\" ? 4 : isSide(e) ? 2 : e.span === \"between\" ? 3 : e.outsideInset === true ? 0 : 1);\n return new Map(cutOrder(scene.edges).map((e, at) => [e.id, { phase: phase(e), side: e.side, at }]));\n}\n\n/**\n * Whether the edge laid at `a` takes its space before the edge at `b` can, so that filling `a` pushes `b`: a reserved\n * edge of an earlier phase, or one laid before it on the same side (the outer ring). Edges laid independently (the two\n * sides, top and bottom, any overlay edge) push neither way.\n */\nexport function pushes(a: LayKey, b: LayKey): boolean {\n if (a.phase === 4 || b.phase === 4) return false;\n if (a.phase !== b.phase) return a.phase < b.phase;\n return a.side === b.side && a.at < b.at;\n}\n\nconst ZONE_RANK: Record<Zone, number> = { start: 0, center: 1, end: 2 };\n\n/** The ids of an edge in drawing order: its items stably sorted by zone. */\nfunction zoneSorted(scene: Scene, ids: readonly string[]): string[] {\n return ids\n .map((id, i) => ({ id, i, z: ZONE_RANK[zoneOf(scene.items[id])] }))\n .sort((a, b) => a.z - b.z || a.i - b.i)\n .map((x) => x.id);\n}\n\n\nconst stackItemOf = (item: SceneItem, forms: readonly StackForm[], from?: number): StackItem => ({\n id: item.id,\n forms,\n used: finite(item.used, 0),\n ...(item.kept ? { kept: true } : {}),\n ...(from !== undefined ? { from } : item.from !== undefined ? { from: item.from } : {}),\n ...(item.fixed ? { fixed: true } : {}),\n});\n\n/** Whether anything drawn in the fit sets its cross size. */\nfunction hasSetter(fit: StackFit, forms: (id: string) => readonly StackForm[]): boolean {\n return fit.items.some((p) => p.kind !== \"menu\" && formSetsCross(forms(p.id)[p.form]!));\n}\n\ninterface EdgeSolve {\n readonly stack: StackFit;\n readonly free: StackFit;\n readonly tabs: readonly string[];\n readonly closedTabs: ReadonlySet<string>;\n readonly input: StackInput;\n /** Items left out of a rail: they have only `wrap` forms left (`no-vertical-form`). */\n readonly leftOut?: readonly string[];\n /** Items left out of a compact edge: they have no `icons` form (`no-icons-form`). */\n readonly leftOutIcons?: readonly string[];\n}\n\n/**\n * What a drawn item reports of its shape: a `wrap` form's rows (word indexes per row, at the edge's cross size `cross`)\n * and its grip (the lead cell at the start of row one); a form with `grip` (an icons strip) its grip at its start along\n * the axis (a horizontal strip on top in a column).\n */\nfunction shapeOf(f: StackForm | undefined, r: Rect, axis: \"column\" | \"row\", cross: number): { rows?: number[][]; grip?: Rect } {\n if (!f) return {};\n if (f.wrap) {\n const lead = Math.max(0, finite(f.wrap.lead ?? 0, 0));\n const row = Math.max(0, finite(f.wrap.row, 0));\n return { rows: wrapLines(f.wrap, cross).lines, grip: rect(r.x, r.y, lead, Math.min(row, r.height)) };\n }\n const g = typeof f.grip === \"number\" && Number.isFinite(f.grip) && f.grip > 0 ? f.grip : 0;\n if (!g) return {};\n return { grip: axis === \"column\" ? rect(r.x, r.y, r.width, Math.min(g, r.height)) : rect(r.x, r.y, Math.min(g, r.width), r.height) };\n}\n\n/** How far a tray toolbar's steps rank after the panels' (its forms' `rank` plus this). */\nconst TRAY_RANK = 100;\n\n/** One edge's stack along `length`: the free fit, then the rail or the user's size. */\nfunction solveEdge(scene: Scene, edge: Edge, ids: readonly string[], length: number, room: number, previous: SceneEdgeLayout | undefined): EdgeSolve {\n const axis = axisOf(edge.side);\n const column = axis === \"column\";\n const ordered = zoneSorted(scene, ids);\n // An item's give-way priority (its own, else its edge's default) adds to its forms' `rank`: lower steps down first.\n const priorityOf = (id: string): number => finite(scene.items[id]!.priority ?? edge.priority ?? 0, 0);\n const formsById = (id: string): readonly StackForm[] => {\n const forms = formsOf(scene.items[id]!, axis);\n const p = priorityOf(id);\n return p === 0 ? forms : forms.map((f) => ({ ...f, rank: finite(f.rank ?? 0, 0) + p }));\n };\n // Never wider across than the room the cut leaves it.\n const maxOf = Number.isNaN(edge.cross.max) ? Infinity : edge.cross.max;\n const cross = { min: Math.min(px(edge.cross.min), room), max: Math.min(maxOf, room), rail: Math.min(px(edge.cross.rail ?? 30), room) };\n const base: Omit<StackInput, \"items\"> = {\n axis,\n length,\n cross,\n ...(edge.menu ? { menu: edge.menu } : {}),\n ...(edge.gap !== undefined ? { gap: edge.gap } : {}),\n ...(edge.pad ? { pad: edge.pad } : {}),\n ...(column ? { ownCross: true } : {}),\n };\n if (edge.compact) {\n // An icons-only edge: each item starts at its icons form (the » menu may follow); one without is left out.\n const iconsAt = (id: string): number => {\n const forms = formsById(id);\n for (let j = Math.max(0, Math.floor(finite(scene.items[id]!.from, 0))); j < forms.length; j++) if (forms[j]!.kind === \"icons\") return j;\n return forms.findIndex((f) => f.kind === \"icons\");\n };\n const shown = ordered.filter((id) => !scene.items[id]!.closed && iconsAt(id) >= 0);\n const leftOutIcons = ordered.filter((id) => !scene.items[id]!.closed && iconsAt(id) < 0);\n const compactInput: StackInput = { ...base, ownCross: false, items: shown.map((id) => stackItemOf(scene.items[id]!, formsById(id), iconsAt(id))) };\n const stack = fitStack(compactInput, previous ? { previous: previous.free } : {});\n return { stack, free: stack, tabs: [], closedTabs: new Set(), input: compactInput, leftOutIcons };\n }\n const open = ordered.filter((id) => !scene.items[id]!.closed);\n /**\n * A toolbar in a column's tray (the end zone, when `zoneAccepts` lists it) takes only its `wrap` or `icons` form, never\n * the menu, and its steps rank after every other item's, so the panels above give way first.\n */\n const asStackItem = (id: string): StackItem => {\n const it = scene.items[id]!;\n const forms = formsById(id);\n if (!column || !edge.zoneAccepts?.end || zoneOf(it) !== \"end\") return stackItemOf(it, forms);\n const tray = (f: StackForm): boolean => f.kind === \"wrap\" || f.kind === \"icons\" || !!f.wrap;\n let first = -1;\n for (let j = Math.max(0, Math.floor(finite(it.from, 0))); j < forms.length && first < 0; j++) if (tray(forms[j]!)) first = j;\n let last = -1;\n forms.forEach((f, j) => {\n if (tray(f)) last = j;\n });\n if (first < 0) return stackItemOf(it, forms);\n return stackItemOf(it, forms.slice(0, last + 1).map((f) => ({ ...f, rank: finite(f.rank ?? 0, 0) + TRAY_RANK })), first);\n };\n const input: StackInput = { ...base, items: open.map(asStackItem) };\n const free = fitStack(input, previous ? { previous: previous.free } : {});\n const none = new Set<string>();\n if (column && !hasSetter(free, formsById)) {\n // A rail: the items with a rail form take it (closed ones too, with `railShowsClosed`).\n const railIndex = (item: SceneItem, forms: readonly StackForm[]): number => {\n if (item.fixed) return -1;\n for (let j = Math.max(0, Math.floor(finite(item.from, 0))); j < forms.length; j++) if (forms[j]!.kind === \"rail\") return j;\n return -1;\n };\n // Vertical means icons: an item with only `wrap` forms left has no form for a rail, and is left out (noted).\n const wrapOnly = (id: string): boolean => railIndex(scene.items[id]!, formsById(id)) < 0 && pastWrap(formsById(id), finite(scene.items[id]!.from, 0)) === undefined;\n const shown = ordered.filter((id) => {\n const it = scene.items[id]!;\n if (!it.closed && wrapOnly(id)) return false;\n return !it.closed || (edge.railShowsClosed === true && railIndex(it, formsById(id)) >= 0);\n });\n const leftOut = ordered.filter((id) => !scene.items[id]!.closed && wrapOnly(id));\n const anyRail = shown.some((id) => railIndex(scene.items[id]!, formsById(id)) >= 0);\n if (anyRail) {\n const railInput: StackInput = {\n ...base,\n items: shown.map((id) => {\n const it = scene.items[id]!;\n const j = railIndex(it, formsById(id));\n // Vertical means icons: in a rail a group skips its `wrap` forms (a tray toolbar keeps its tray forms, no menu).\n const forms = asStackItem(id).forms;\n return stackItemOf(it, forms, j >= 0 ? j : pastWrap(forms, finite(it.from, 0)));\n }),\n };\n const stack = fitStack(railInput, previous ? { previous: previous.stack } : {});\n const tabs = stack.items.filter((p) => p.kind === \"rail\").map((p) => p.id);\n const closedTabs = new Set(shown.filter((id) => scene.items[id]!.closed));\n return { stack, free, tabs, closedTabs, input: railInput, leftOut };\n }\n }\n const size = edge.size;\n if (typeof size === \"number\" && Number.isFinite(size) && hasSetter(free, formsById)) {\n const setters = free.items.filter((p) => p.kind !== \"menu\" && formSetsCross(formsById(p.id)[p.form]!));\n const lo = Math.max(px(edge.cross.min), ...setters.map((p) => formCrossMin(formsById(p.id)[p.form]!)));\n const s = Math.min(Math.max(size, lo), Math.max(lo, maxOf), room);\n if (Math.abs(s - free.cross) > EPS) {\n const sized: StackInput = { ...input, cross: { ...cross, min: s, max: s } };\n const stack = fitStack(sized, previous ? { previous: previous.stack } : {});\n return { stack, free, tabs: [], closedTabs: none, input: sized };\n }\n }\n return { stack: free, free, tabs: [], closedTabs: none, input };\n}\n\n/**\n * The fit with zones packed: when the drawn items leave spare length, start items pack from the start, end items from\n * the end (before the » entry), center items centred between. Returns the main-axis start per id.\n */\nfunction zoneStarts(scene: Scene, fit: StackFit, input: StackInput): { starts: Map<string, number>; lengths: Map<string, number> } {\n const column = fit.axis === \"column\";\n const at = (r: Rect): number => (column ? r.y : r.x);\n const out = new Map<string, number>();\n const lengths = new Map<string, number>();\n const drawn = fit.items.filter((p) => p.kind !== \"menu\");\n for (const p of drawn) {\n out.set(p.id, at(p.rect));\n lengths.set(p.id, column ? p.rect.height : p.rect.width);\n }\n const len = (p: { id: string }): number => lengths.get(p.id)!;\n const gap = px(input.gap);\n const start = px(input.pad?.start);\n const end = px(input.pad?.end);\n const menu = fit.menu ? (column ? fit.menu.rect.height : fit.menu.rect.width) + (drawn.length > 0 ? gap : 0) : 0;\n const zone = (z: Zone) => drawn.filter((p) => zoneOf(scene.items[p.id]) === z);\n const s = zone(\"start\");\n const c = zone(\"center\");\n const e = zone(\"end\");\n /**\n * A bar's title (a fixed item that grows, in the start zone): the zones are laid with it at its natural length, so\n * a toolbar right after it sits right after its natural rect (leading), and the title then takes the room up to the\n * next item only when nothing follows it in its zone.\n */\n const title = column\n ? undefined\n : s.find((p) => {\n const it = scene.items[p.id]!;\n const f = formsOf(it, \"row\")[p.form];\n return it.fixed && f?.main.grows && len(p) > formMain(f, \"natural\", fit.cross) + EPS;\n });\n if (title) lengths.set(title.id, formMain(formsOf(scene.items[title.id]!, \"row\")[title.form]!, \"natural\", fit.cross));\n const used = drawn.reduce((sum, p) => sum + len(p), 0) + Math.max(0, drawn.length - 1) * gap;\n const spare = fit.length - start - end - menu - used;\n if (spare <= EPS) return { starts: out, lengths };\n const total = (ps: readonly { id: string }[]): number => ps.reduce((sum, p) => sum + len(p), 0) + Math.max(0, ps.length - 1) * gap;\n const lay = (ps: readonly { id: string }[], from: number): void => {\n let x = from;\n for (const p of ps) {\n out.set(p.id, x);\n x += len(p) + gap;\n }\n };\n lay(s, start);\n const endStart = fit.length - end - menu - total(e);\n lay(e, endStart);\n const lo = start + total(s) + (s.length > 0 ? gap : 0);\n const hi = endStart - (e.length > 0 ? gap : 0);\n // Centred on the edge's middle (so a centred readout stays put while the other zones change), kept between them; in\n // a title bar, where the middle isn't clear of the title and the trailing items, centred in the free span instead.\n const mid = (fit.length - total(c)) / 2;\n const clear = mid >= lo - EPS && mid + total(c) <= hi + EPS;\n lay(c, title && !clear ? Math.max(lo, (lo + hi - total(c)) / 2) : Math.max(lo, Math.min(mid, hi - total(c))));\n if (title && s[s.length - 1] === title) {\n // Nothing after the title in its zone: it grows into the room up to the next item.\n const next = [...c, ...e].map((p) => out.get(p.id)!);\n const until = next.length ? Math.min(...next) - gap : fit.length - end - menu;\n lengths.set(title.id, Math.max(len(title), until - out.get(title.id)!));\n }\n return { starts: out, lengths };\n}\n\n/** A float's rect flush with `content`'s side or corner. */\nfunction anchored(content: Rect, w: number, h: number, anchor: FloatAnchor): Rect {\n const left = content.x;\n const right = content.x + content.width - w;\n const midX = content.x + (content.width - w) / 2;\n const top = content.y;\n const bottom = content.y + content.height - h;\n const midY = content.y + (content.height - h) / 2;\n const at: Record<FloatAnchor, [number, number]> = {\n \"content-top-left\": [left, top],\n \"content-top\": [midX, top],\n \"content-top-right\": [right, top],\n \"content-right\": [right, midY],\n \"content-bottom-right\": [right, bottom],\n \"content-bottom\": [midX, bottom],\n \"content-bottom-left\": [left, bottom],\n \"content-left\": [left, midY],\n };\n const [x, y] = at[anchor] ?? at[\"content-top-right\"];\n return rect(x, y, w, h);\n}\n\nexport function solve(given: Scene, options: SolveOptions = {}): SceneLayout {\n const previous = options.previous;\n // Under `previous`, an item docked now that was closed or absent then has just opened: it counts as the newest, so it\n // keeps its largest form while it fits and the others give way by the usual rules.\n const opened = new Set<string>();\n if (previous) {\n for (const e of given.edges) {\n for (const id of e.items) {\n const it = Object.hasOwn(given.items, id) ? given.items[id] : undefined;\n const was = previous.items[id];\n if (it && !it.closed && !it.fixed && (!was || was.closed)) opened.add(id);\n }\n }\n }\n const newest = Object.values(given.items).reduce((m, it) => Math.max(m, finite(it.used, 0)), 0) + 1;\n const scene: Scene = opened.size === 0 ? given : { ...given, items: { ...given.items, ...Object.fromEntries([...opened].map((id) => [id, { ...given.items[id]!, used: newest }])) } };\n // `fresh` edges, and edges holding a `fresh` item, are solved without `previous`.\n const fresh = new Set(options.fresh ?? []);\n const prevEdge = (edge: Edge): SceneEdgeLayout | undefined => (!previous || fresh.has(edge.id) || edge.items.some((id) => fresh.has(id)) ? undefined : previous.edges[edge.id]);\n const notes: SceneNote[] = [];\n const items: Record<string, SceneItemLayout> = {};\n const edges: Record<string, SceneEdgeLayout> = {};\n const stage = rect(finite(scene.stage.x, 0), finite(scene.stage.y, 0), px(scene.stage.width), px(scene.stage.height));\n const order = cutOrder(scene.edges);\n\n // Who is where: the first place in cut order wins (edges before floats).\n const claimed = new Set<string>();\n const claim = (id: string): boolean => {\n if (!Object.hasOwn(scene.items, id)) {\n notes.push({ code: \"unknown-item\", id });\n return false;\n }\n if (claimed.has(id)) {\n notes.push({ code: \"twice\", id });\n return false;\n }\n claimed.add(id);\n return true;\n };\n const owned = new Map<Edge, string[]>();\n for (const e of order) owned.set(e, e.items.filter(claim));\n\n /** Draws an edge's stack at `r` (its stage rect): its items, notes and edge layout. */\n const emit = (edge: Edge, r: Rect, solved: EdgeSolve, extra: Partial<SceneEdgeLayout> = {}): void => {\n const column = axisOf(edge.side) === \"column\";\n const { stack } = solved;\n const thick = column ? r.width : r.height;\n const { starts, lengths } = zoneStarts(scene, stack, solved.input);\n const toStage = (l: Rect, id?: string): Rect => {\n const s = id !== undefined ? starts.get(id) : undefined;\n const n = id !== undefined ? lengths.get(id) : undefined;\n const x = column ? l.x : (s ?? l.x);\n const y = column ? (s ?? l.y) : l.y;\n return rect(r.x + x, r.y + y, column ? l.width : (n ?? l.width), column ? (n ?? l.height) : l.height);\n };\n const tabs = new Set(solved.tabs);\n for (const id of solved.leftOut ?? []) notes.push({ code: \"no-vertical-form\", edge: edge.id, id });\n for (const id of solved.leftOutIcons ?? []) notes.push({ code: \"no-icons-form\", edge: edge.id, id });\n for (const p of stack.items) {\n const it = scene.items[p.id]!;\n const inMenu = p.kind === \"menu\";\n const drawnRect = toStage(p.rect, inMenu ? undefined : p.id);\n const shape = inMenu ? {} : shapeOf(formsOf(it, column ? \"column\" : \"row\")[p.form], drawnRect, column ? \"column\" : \"row\", stack.cross);\n items[p.id] = {\n ...shape,\n rect: drawnRect,\n kind: it.kind,\n form: p.form,\n formKind: p.kind,\n edge: edge.id,\n zone: zoneOf(it),\n ...(inMenu ? { inMenu: true } : {}),\n ...(tabs.has(p.id) ? { tab: true } : {}),\n ...(solved.closedTabs.has(p.id) ? { closed: true } : {}),\n ...(it.fixed ? { fixed: true } : {}),\n };\n }\n for (const n of stack.notes) notes.push({ edge: edge.id, ...n });\n edges[edge.id] = {\n side: edge.side,\n ring: finite(edge.ring, 0),\n rect: r,\n cross: thick,\n menu: stack.menu ? { rect: toStage(stack.menu.rect), items: stack.menu.items } : null,\n tabs: solved.tabs,\n stack,\n free: solved.free,\n ...extra,\n };\n };\n\n const lay = (edge: Edge, area: Rect, cut: boolean): Rect => {\n const column = axisOf(edge.side) === \"column\";\n const length = column ? area.height : area.width;\n const room = Math.max(0, column ? area.width : area.height);\n const solved = solveEdge(scene, edge, owned.get(edge)!, length, room, prevEdge(edge));\n const thick = solved.stack.items.length === 0 ? 0 : Math.min(solved.stack.cross, room);\n const r =\n edge.side === \"top\"\n ? rect(area.x, area.y, area.width, thick)\n : edge.side === \"bottom\"\n ? rect(area.x, area.y + area.height - thick, area.width, thick)\n : edge.side === \"left\"\n ? rect(area.x, area.y, thick, area.height)\n : rect(area.x + area.width - thick, area.y, thick, area.height);\n emit(edge, r, solved);\n if (!cut) return area;\n return edge.side === \"top\"\n ? rect(area.x, area.y + thick, area.width, area.height - thick)\n : edge.side === \"bottom\"\n ? rect(area.x, area.y, area.width, area.height - thick)\n : edge.side === \"left\"\n ? rect(area.x + thick, area.y, area.width - thick, area.height)\n : rect(area.x, area.y, area.width - thick, area.height);\n };\n\n const rails: Partial<Record<\"left\" | \"right\", SceneRailLayout>> = {};\n const railPlaces: Partial<Record<\"left\" | \"right\", Rect>> = {};\n const gutter = px(scene.gutter);\n let columnRoom: boolean | undefined;\n /** The stage less the full bars outside the inset (set before the sides are laid). */\n let outerArea: Rect = stage;\n const isSide = (e: Edge): boolean => e.side === \"left\" || e.side === \"right\";\n // The inset, or none with `insetWhen: \"docked\"` while nothing is docked beside the content: only a panel counts, in a\n // column or a rail (an item there, not closed, whose first column form is a panel's: open, header or rail). Bars,\n // toolbar groups and an anchor (it takes nothing) never do, wherever they sit.\n const PANEL_FORMS = new Set([\"open\", \"header\", \"rail\"]);\n const isPanel = (id: string): boolean => {\n const it = scene.items[id]!;\n return !it.closed && !it.fixed && PANEL_FORMS.has(formsOf(it, \"column\")[0]?.kind ?? \"\");\n };\n const docked = order.some((e) => isSide(e) && e.accepts.length > 0 && owned.get(e)!.some(isPanel));\n const inset = scene.insetWhen === \"docked\" && !docked ? {} : (scene.inset ?? {});\n\n /**\n * The reserved left and right edges, ring by ring, with column give-way: dynamic columns shrink toward their minimum,\n * then fold whole into their side's rail while the content is narrower than `contentMin.width`.\n */\n const laySides = (sideEdges: readonly Edge[], area: Rect): Rect => {\n const H = area.height;\n const ride = scene.handFold === \"ride\";\n interface Col {\n readonly edge: Edge;\n readonly side: \"left\" | \"right\";\n readonly solved: EdgeSolve;\n readonly width: number;\n readonly min: number;\n readonly visible: readonly string[];\n readonly dyn: boolean;\n readonly hand: boolean;\n readonly kept: boolean;\n readonly age: number;\n }\n // An edge outside the inset (an anchor) runs into the inset above and below too, where no reserved bar lies on that\n // side (a bar there keeps it below or above the bar).\n // (Outside bars lie beyond the inset already: measured from what they leave.)\n const upInset = area.y <= outerArea.y + px(inset.top) + EPS ? px(inset.top) : 0;\n const downInset = area.y + area.height >= outerArea.y + outerArea.height - px(inset.bottom) - EPS ? px(inset.bottom) : 0;\n const tall = (edge: Edge): number => H + (edge.outsideInset === true ? upInset + downInset : 0);\n const cols: Col[] = sideEdges.map((edge) => {\n const side = edge.side as \"left\" | \"right\";\n const solved = solveEdge(scene, edge, owned.get(edge)!, tall(edge), Math.max(0, area.width), prevEdge(edge));\n const width = solved.stack.items.length === 0 ? 0 : Math.min(solved.stack.cross, area.width);\n const visible = owned.get(edge)!.filter((id) => !scene.items[id]!.closed);\n // A dynamic column, or a static edge that gives way like one (`giveWay`).\n const dyn = (edge.column === true || edge.giveWay === true) && scene.rails?.[side] !== undefined && visible.length > 0;\n const forms = (id: string): readonly StackForm[] => formsOf(scene.items[id]!, \"column\");\n const setters = solved.free.items.filter((p) => p.kind !== \"menu\" && formSetsCross(forms(p.id)[p.form]!));\n const min = setters.length > 0 ? Math.min(width, Math.max(px(edge.cross.min), ...setters.map((p) => formCrossMin(forms(p.id)[p.form]!)))) : width;\n return {\n edge,\n side,\n solved,\n width,\n min,\n visible,\n dyn,\n hand: dyn && edge.column === true && visible.every((id) => finite(scene.items[id]!.from, 0) >= 1),\n kept: visible.some((id) => scene.items[id]!.kept === true),\n age: Math.max(-Infinity, ...visible.map((id) => finite(scene.items[id]!.used, 0))),\n };\n });\n const cmin = scene.contentMin ? px(scene.contentMin.width) : undefined;\n const order = cols\n .filter((c) => c.dyn && !c.hand && c.width > 0)\n .sort((a, b) => Number(a.kept) - Number(b.kept) || a.age - b.age || finite(a.edge.ring, 0) - finite(b.edge.ring, 0) || (a.side === b.side ? 0 : a.side === \"left\" ? -1 : 1));\n // Under `previous`, the columns that were shrunk shrink first, in the order they did, so ages alone move nothing.\n const shrunkBefore = (previous?.notes ?? []).flatMap((n) => (n.code === \"column-shrunk\" ? [n.edge] : []));\n const rankOf = (c: Col): number => (shrunkBefore.includes(c.edge.id) ? shrunkBefore.indexOf(c.edge.id) : Infinity);\n const shrinkOrder = order.map((c, i) => ({ c, i })).sort((a, b) => (rankOf(a.c) === rankOf(b.c) ? a.i - b.i : rankOf(a.c) < rankOf(b.c) ? -1 : 1)).map((x) => x.c);\n const railW = (side: \"left\" | \"right\"): number => px(scene.rails?.[side]?.width);\n const evaluate = (auto: ReadonlySet<Col>) => {\n // Riders ride over an open panel column (never an anchor), every member of a hand-folded column a bar.\n const openOn = (side: \"left\" | \"right\"): boolean => cols.some((c) => c.side === side && c.dyn && c.edge.column === true && !c.hand && !auto.has(c) && c.width > 0);\n const riding = (c: Col): boolean => ride && c.hand && openOn(c.side);\n const railed = (c: Col): boolean => c.dyn && (auto.has(c) || (c.hand && !riding(c)));\n const widths = new Map(cols.filter((c) => !railed(c) && !riding(c)).map((c) => [c, c.width]));\n const railSides = ([\"left\", \"right\"] as const).filter((s) => cols.some((c) => c.side === s && railed(c)));\n let used = 0;\n // An edge outside the inset has no gutter after it (the inset is there).\n for (const [c, w] of widths) used += w > 0 ? w + (c.edge.outsideInset === true ? 0 : gutter) : 0;\n for (const s of railSides) used += railW(s) + gutter;\n let excess = cmin === undefined ? -Infinity : used + cmin - area.width;\n for (const c of shrinkOrder) {\n if (excess <= EPS) break;\n const w = widths.get(c);\n if (w === undefined) continue;\n const take = Math.min(excess, w - c.min);\n if (take > 0) {\n widths.set(c, w - take);\n excess -= take;\n }\n }\n return { auto, widths, excess, railed, riding, railSides };\n };\n let auto = new Set<Col>();\n if (cmin !== undefined) {\n // Room that came back unfolds in the reverse of the order the columns folded in (the fold notes' order), one at a\n // time, stopping at the first that can't come back: never by age, so a press can't unfold anything.\n const unfold = (): void => {\n for (const c of [...auto].reverse()) {\n const fewer = new Set([...auto].filter((x) => x !== c));\n if (evaluate(fewer).excess <= EPS) auto = fewer;\n else break;\n }\n };\n if (previous) {\n // What gave way before stays folded, in the order it folded, while the content still fits without it coming back.\n const byId = new Map(order.map((c) => [c.edge.id, c]));\n // A column with a just-opened or `fresh` item is weighed anew.\n const anew = (c: Col): boolean => fresh.has(c.edge.id) || c.visible.some((id) => opened.has(id) || fresh.has(id));\n const was = previous.notes.flatMap((n) => ((n.code === \"column-folded\" || n.code === \"kept-folded\") && byId.has(n.edge) && !anew(byId.get(n.edge)!) ? [byId.get(n.edge)!] : []));\n auto = new Set(was);\n if (evaluate(auto).excess <= EPS) unfold();\n }\n // A need for more folds the next in give-way order.\n for (const c of order) {\n if (evaluate(auto).excess <= EPS) break;\n if (!auto.has(c)) auto = new Set([...auto, c]);\n }\n // A fold can make an earlier one needless (a second column into a rail the first already paid for): unfold to a\n // fixpoint, so solving again from this layout changes nothing.\n for (let size = -1; size !== auto.size; ) {\n size = auto.size;\n unfold();\n }\n }\n const g = evaluate(auto);\n // Whether one panel column at its minimum fits beside the content's minimum: a host's narrow fallback (the sheet)\n // reads it. Anchors and rails don't count: every column, an anchor included, can fold into its rail. A side toolbar\n // bar with an item does: it never folds.\n // With no column edge yet (every panel floating), a side's column template says how narrow its column could be: its\n // `cross.min`, or more where the items it takes need more (their form's least width), as a column holding them would.\n // The question is hypothetical (could one column open?), so it is answered as if that column were open: a column\n // folded whole by hand counts at its open minimum, and the floating items a template takes at their open forms.\n // Every column edge with an item counts, whether its side has a rail or not.\n const openMin = (ids: readonly string[], least: number): number =>\n Math.max(\n least,\n ...ids.map((id) => {\n const f = formsOf(scene.items[id]!, \"column\")[0];\n return f && formSetsCross(f) ? formCrossMin(f) : 0;\n }),\n );\n const open = cols.filter((c) => c.edge.column === true && c.visible.length > 0).map((c) => (c.hand ? openMin(c.visible, px(c.edge.cross.min)) : c.min));\n const templates = ([\"left\", \"right\"] as const).flatMap((s) => {\n const t = scene.columns?.[s];\n if (!t) return [];\n const takes = Object.values(scene.items).filter((it) => !it.fixed && !it.closed && t.accepts.includes(it.kind));\n return [openMin(takes.map((it) => it.id), px(t.cross.min))];\n });\n const colMins = open.length > 0 ? open : templates;\n if (cmin !== undefined && colMins.length > 0) {\n // A side toolbar bar never folds: one that lays out an item takes its width (and the gutter after it, unless it\n // lies outside the inset, which the area already leaves out) from the room a column could have.\n const bars = cols\n .filter((c) => c.width > 0 && !c.dyn && isSideBar(scene, c.edge))\n .reduce((s, c) => s + c.width + (c.edge.outsideInset === true ? 0 : gutter), 0);\n // With `insetWhen: \"docked\"` and nothing docked now, the column that opens brings the inset with it.\n const width = area.width - bars - (scene.insetWhen === \"docked\" && !docked ? px(scene.inset?.left) + px(scene.inset?.right) : 0);\n const need = cmin + Math.min(...colMins) + gutter;\n columnRoom = width >= need - EPS;\n if (!columnRoom) notes.push({ code: \"no-column-room\", width, need });\n }\n for (const c of shrinkOrder) {\n const w = g.widths.get(c);\n if (w !== undefined && w < c.width - EPS) notes.push({ code: \"column-shrunk\", edge: c.edge.id, from: c.width, to: w });\n }\n // In the order they folded: `previous` reads it to unfold in reverse.\n for (const c of g.auto) notes.push({ code: c.kept ? \"kept-folded\" : \"column-folded\", edge: c.edge.id });\n\n let x0 = area.x;\n let x1 = area.x + area.width;\n for (const side of [\"left\", \"right\"] as const) {\n // From the window's side inward: the side's bars outside the inset (toolbar bars, `isOutsideSideBar`), the side's\n // rail, the static column edges outside the inset (anchors), the inset, then the columns.\n // Only while it lays out an item: an empty (or all closed) bar draws as nothing, so it changes no order either.\n const outsideSideBar = (c: Col): boolean => c.width > 0 && isOutsideSideBar(scene, c.edge) && !g.railed(c) && !g.riding(c);\n const all = cols.filter((c) => c.side === side);\n const mine = [...all.filter(outsideSideBar), ...all.filter((c) => !outsideSideBar(c))];\n const railed = mine.filter((c) => g.railed(c));\n const riders = mine.filter((c) => g.riding(c));\n const host = mine.find((c) => c.dyn && c.edge.column === true && !c.hand && !g.auto.has(c) && c.width > 0);\n /** A riding column's bars: each member's folded form, in zone order. */\n const riderBars = (c: Col): { id: string; form: number; f: StackForm | undefined; h: number }[] =>\n zoneSorted(scene, c.visible).map((id) => {\n const forms = formsOf(scene.items[id]!, \"column\");\n const form = forms.length === 0 ? 0 : Math.min(Math.max(0, Math.floor(finite(scene.items[id]!.from, 0))), forms.length - 1);\n return { id, form, f: forms[form], h: px(forms[form]?.main.natural) };\n });\n const ridersTop = riders.reduce((s, c) => s + riderBars(c).reduce((t, b) => t + b.h, 0), 0);\n let railRect: Rect | null = null;\n // The gap just outside the next edge: the inset at the window's side, then a gutter. An edge outside the inset\n // (an anchor) lies before that gap, which then follows it.\n let gap = px(side === \"left\" ? inset.left : inset.right);\n /** Whether one of the side's outside bars is laid already (the rail then lies flush after it). */\n let barLaid = false;\n /** Where the side's rail lies, or would lie were one shown (`railPlaces`). */\n let railPlace: Rect | null = null;\n const placeRail = (): Rect => {\n const w = railW(side);\n const lead = barLaid ? gap : 0;\n return side === \"left\" ? rect(x0 - lead, area.y, w, H) : rect(x1 + lead - w, area.y, w, H);\n };\n for (const c of mine) {\n // The side's rail is its outermost panel edge; an anchor lies flush inside it. After the side's outside bars it\n // lies outside the inset too, flush after them, the inset (at least a gutter) then following it and the anchor.\n // With no such bar it lies at the window's side inside the inset, a gutter after it (the hosts' rows).\n if (!railPlace && !outsideSideBar(c)) {\n railPlace = placeRail();\n if (railed.length > 0) {\n railRect = railPlace;\n const lead = barLaid ? gap : 0;\n const after = barLaid ? Math.max(gap, gutter) : gutter;\n if (side === \"left\") x0 += railPlace.width - lead + after;\n else x1 -= railPlace.width - lead + after;\n gap = after;\n }\n }\n if (outsideSideBar(c)) barLaid = true;\n const base = { side: c.edge.side, ring: finite(c.edge.ring, 0), cross: 0, menu: null, tabs: [], stack: c.solved.stack, free: c.solved.free };\n if (g.railed(c)) {\n edges[c.edge.id] = { ...base, rect: rect(railRect!.x, area.y, 0, H), folded: g.auto.has(c) ? \"auto\" : \"hand\" };\n continue;\n }\n if (g.riding(c)) continue;\n // Never wider than the room the edges outside it leave.\n const w = Math.min(g.widths.get(c)!, Math.max(0, x1 - x0));\n const top = c === host ? ridersTop : 0;\n let solved = c.solved;\n if (top > 0 || Math.abs(w - c.width) > EPS) {\n const forced: Edge = { ...c.edge, cross: { ...c.edge.cross, min: w, max: w } };\n const { size: _s, ...plain } = forced;\n solved = solveEdge(scene, plain, owned.get(c.edge)!, H - top, w, prevEdge(c.edge));\n }\n let r: Rect;\n if (c.edge.outsideInset === true) {\n // Outside the inset: at the stage's side, full height; the inset (not a gutter) follows it.\n const y0 = area.y - upInset;\n const h = tall(c.edge);\n if (side === \"left\") {\n r = rect(x0 - gap, y0, w, h);\n x0 += w;\n } else {\n r = rect(x1 + gap - w, y0, w, h);\n x1 -= w;\n }\n if (Math.abs(h - H) > EPS || Math.abs(w - c.width) > EPS) {\n const forced: Edge = { ...c.edge, cross: { ...c.edge.cross, min: w, max: w } };\n const { size: _s, ...plain } = forced;\n solved = solveEdge(scene, plain, owned.get(c.edge)!, h, w, prevEdge(c.edge));\n }\n } else if (side === \"left\") {\n r = rect(x0, area.y + top, w, H - top);\n x0 += w > 0 ? w + gutter : 0;\n if (w > 0) gap = gutter;\n } else {\n x1 -= w;\n r = rect(x1, area.y + top, w, H - top);\n x1 -= w > 0 ? gutter : 0;\n if (w > 0) gap = gutter;\n }\n emit(c.edge, r, solved, w < c.width - EPS ? { shrunk: true } : {});\n }\n if (host && riders.length > 0) {\n const hr = edges[host.edge.id]!.rect;\n let y = area.y;\n for (const c of riders) {\n const bars = riderBars(c);\n const y0 = y;\n for (const b of bars) {\n const at = rect(hr.x, y, hr.width, b.h);\n const it = scene.items[b.id]!;\n items[b.id] = { rect: at, kind: it.kind, form: b.form, formKind: b.f?.kind ?? \"header\", edge: c.edge.id, zone: zoneOf(it), rides: host.edge.id, folded: \"hand\" };\n y += b.h;\n }\n edges[c.edge.id] = { side: c.edge.side, ring: finite(c.edge.ring, 0), rect: rect(hr.x, y0, hr.width, y - y0), cross: 0, menu: null, tabs: [], stack: c.solved.stack, free: c.solved.free, rides: host.edge.id, folded: \"hand\" };\n }\n }\n if (railRect) {\n const segments: { id: string; edge: string; rect: Rect }[] = [];\n let y = railRect.y;\n for (const c of railed) {\n // In zone order, as the column itself shows them: start, center, end.\n for (const id of zoneSorted(scene, c.visible)) {\n const it = scene.items[id]!;\n const forms = formsOf(it, \"column\");\n const ri = forms.findIndex((f) => f.kind === \"rail\");\n const form = ri >= 0 ? ri : Math.min(Math.max(0, Math.floor(finite(it.from, 0))), Math.max(0, forms.length - 1));\n const h = ri >= 0 ? px(forms[ri]!.main.natural) : railRect.width;\n const at = rect(railRect.x, y, railRect.width, h);\n items[id] = { rect: at, kind: it.kind, form, formKind: \"rail\", edge: c.edge.id, zone: zoneOf(it), rail: side, folded: g.auto.has(c) ? \"auto\" : \"hand\" };\n segments.push({ id, edge: c.edge.id, rect: at });\n y += h;\n }\n }\n rails[side] = { rect: railRect, segments };\n }\n // A side that can have a rail: where it lies, or would lie (after every outside bar when the side has nothing else).\n if (scene.rails?.[side]) railPlaces[side] = railPlace ?? placeRail();\n }\n return rect(x0, area.y, Math.max(0, x1 - x0), H);\n };\n\n const reserved = order.filter((e) => e.mode !== \"overlay\");\n // A full top or bottom bar outside the inset lies at the window's edge, full width; the inset follows it.\n const outsideBar = (e: Edge): boolean => !isSide(e) && e.span !== \"between\" && e.outsideInset === true;\n let outer = stage;\n for (const e of reserved) if (outsideBar(e)) outer = lay(e, outer, true);\n outerArea = outer;\n let area = rect(outer.x + px(inset.left), outer.y + px(inset.top), Math.max(0, outer.width - px(inset.left) - px(inset.right)), Math.max(0, outer.height - px(inset.top) - px(inset.bottom)));\n for (const e of reserved) if (!isSide(e) && e.span !== \"between\" && !outsideBar(e)) area = lay(e, area, true);\n area = laySides(reserved.filter(isSide), area);\n for (const e of reserved) if (!isSide(e) && e.span === \"between\") area = lay(e, area, true);\n const content = area;\n let over = content;\n for (const e of order) if (e.mode === \"overlay\") over = lay(e, over, true);\n if (scene.contentMin) {\n const minW = px(scene.contentMin.width);\n const minH = px(scene.contentMin.height);\n if (content.width < minW - EPS) notes.push({ code: \"content-narrow\", width: content.width, min: minW });\n const bars = order.filter((e) => e.mode === \"overlay\" && !isSide(e)).reduce((s, e) => s + (edges[e.id]?.cross ?? 0), 0);\n if (content.height - bars < minH - EPS) notes.push({ code: \"content-short\", height: content.height - bars, min: minH });\n }\n if (previous) {\n const was = previous.content;\n const moved = Math.abs(was.x - content.x) > EPS || Math.abs(was.y - content.y) > EPS || Math.abs(was.width - content.width) > EPS || Math.abs(was.height - content.height) > EPS;\n if (moved) notes.push({ code: \"content-changed\", from: was, to: content });\n }\n\n // Floats: clear of every docked item, every bar and the chrome.\n const avoid: Rect[] = [];\n for (const l of Object.values(items)) avoid.push(l.rect);\n for (const e of Object.values(edges)) {\n if (axisOf(e.side) === \"row\" && e.cross > 0) avoid.push(e.rect);\n if (e.menu) avoid.push(e.menu.rect);\n }\n for (const c of scene.chrome ?? []) avoid.push(c);\n // Floats lie within the stage less the inset at its left and right (the sides the columns pad), the stage's full height.\n const floatRegion = rect(stage.x + px(inset.left), stage.y, Math.max(0, stage.width - px(inset.left) - px(inset.right)), stage.height);\n const floats: string[] = [];\n for (const f of scene.floats) {\n if (!claim(f.id)) continue;\n const it = scene.items[f.id]!;\n if (it.closed) continue;\n const shape = floatShape(it, f);\n if (shape.none) {\n // Vertical means icons: an item with only `wrap` forms left has no form for a vertical float.\n notes.push({ code: \"no-vertical-form\", id: f.id });\n continue;\n }\n const from = shape.form;\n // Its orient: the float's, else the item's (`floatOrientOf`: a toolbar group floats as a row).\n const fo = f.orient ?? floatOrientOf(it);\n const form = formsOf(it, fo)[from];\n // Into that region; a float larger than it is shrunk to fit it, never under its floor: the item's `floatMin`, else\n // its form's own minimums. A folded float (its bar) keeps its height. Wider than the region at its floor, it keeps\n // the floor and lies at the region's left edge.\n const row = fo === \"row\";\n // The form's own minimums only stop a shrink (a float asked smaller keeps its size); `floatMin` is laid out as given.\n const floor = {\n width: it.floatMin ? px(it.floatMin.width) : Math.min(shape.width, px(row ? form?.main.min : form?.cross.min)),\n height: it.floatMin ? px(it.floatMin.height) : Math.min(shape.height, px(row ? form?.cross.min : form?.main.min)),\n };\n const w = Math.max(floor.width, Math.min(shape.width, floatRegion.width));\n // Folded means its bar (a `header` form), not any form past the first (a row float, a second open form).\n const folded = form?.kind === \"header\";\n const h = folded ? shape.height : Math.max(floor.height, Math.min(shape.height, floatRegion.height));\n const want = f.anchor ? anchored(content, w, h, f.anchor) : rect(finite(f.rect.x, stage.x), finite(f.rect.y, stage.y), w, h);\n const fit0 = fitFloat(want, floatRegion, avoid);\n const fit = w > floatRegion.width + EPS ? { ...fit0, rect: rect(floatRegion.x, fit0.rect.y, w, fit0.rect.height) } : fit0;\n if (fit.clamped) notes.push({ code: \"float-clamped\", id: f.id });\n if (fit.snapped) notes.push({ code: \"float-moved\", id: f.id });\n if (fit.covers.length > 0) notes.push({ code: \"float-covers\", id: f.id });\n items[f.id] = { ...shapeOf(form, fit.rect, fo, fit.rect.width), rect: fit.rect, kind: it.kind, form: from, formKind: form?.kind ?? \"open\", floating: true };\n floats.push(f.id);\n }\n return { items, edges, content, floats, rails, railPlaces, ...(columnRoom !== undefined ? { columnRoom } : {}), notes };\n}\n","/**\n * The scene's pure changes. Each returns a new scene and leaves the one it was given as it was; a change that can't\n * apply (an unknown item or edge, a fixed item, a kind the edge or the float layer doesn't take) returns the scene\n * given, the same object, so `after === before` says nothing changed.\n *\n * - `moveTo(scene, id, { edge, zone?, at })`: docks the item in that edge, before the `at`-th item of the zone (counting\n * the zone's items without it, closed ones included), or at the zone's end. The zone becomes the item's `align`.\n * `{ kind: \"column\", side, ring }` makes a new column from `scene.columns[side]` at that ring (`Infinity`: the side's\n * inner end, \"Move to › Dock left\"); `{ kind: \"rail\", side, ring }` does the same with the item folded by hand, so it\n * shows in the rail; `{ kind: \"float\", rect?, anchor? }` floats it. A dynamic column an item leaves empty is deleted\n * and its side's rings are closed up.\n * - `homeFor(scene, id, start)`: the place a start scene gives the item, for `moveTo`.\n * - `floatAt(scene, id, rect?, orient?)`: floats it on top at `rect` (its size becomes `floatSize`); with no rect, at\n * its `floatSizeOf` size anchored to the content's top-right corner: its `floatSize`, else its form's natural size\n * along its orient (the float's, `orient`, else `floatOrientOf`), else the default size.\n * - `fold(scene, id, on)`: folded by hand starts it at its second form (`from: 1`); unfolding clears `from`.\n * - `use(scene, id)`: the newest age. Under `previous` it reshapes nothing.\n * - `keep(scene, id, on)`, `open(scene, id)`, `close(scene, id)`.\n * - `raise(scene, id)`: a float to the top of the stack; no use, no reshape.\n * - `orient(scene, id, orient)`: a float's axis.\n * - `resize(scene, edge, size)`: the user's size across; a size that isn't a finite number clears it.\n */\nimport { clampInto, type Rect } from \"../geometry\";\nimport { axisOf, floatOrientOf, floatShape, floatSizeOf, zoneOf, zoneTakes, zonesTaking, type Edge, type FloatAnchor, type Orient, type Scene, type SceneFloat, type SceneItem, type Side, type Zone } from \"./model\";\n\n/** Where a docked item goes: before the `at`-th item of `zone` (default the item's own zone) in `edge`. */\nexport interface DockPlace {\n readonly kind?: \"gap\";\n readonly edge: string;\n readonly zone?: Zone;\n readonly at: number;\n}\n/** A new column on `side` at `ring` (the edges at that ring and inward move in one); `Infinity` is the side's inner end. */\nexport interface ColumnPlace {\n readonly kind: \"column\";\n readonly side: \"left\" | \"right\";\n readonly ring: number;\n}\n/** Docked folded: a new column at `ring` holding the item folded by hand, so it shows in the side's rail. */\nexport interface RailPlace {\n readonly kind: \"rail\";\n readonly side: \"left\" | \"right\";\n readonly ring: number;\n}\n/** Floating at `rect` (or, with none, at its last size anchored to the content). */\nexport interface FloatPlace {\n readonly kind: \"float\";\n readonly rect?: Rect;\n /** Following the content (only its size counts then). */\n readonly anchor?: FloatAnchor;\n}\nexport type Place = DockPlace | ColumnPlace | RailPlace | FloatPlace;\n\nconst withItem = (scene: Scene, item: SceneItem): Scene => ({ ...scene, items: { ...scene.items, [item.id]: item } });\nconst itemOf = (scene: Scene, id: string): SceneItem | undefined => (Object.hasOwn(scene.items, id) ? scene.items[id] : undefined);\n\n/** The side's edges with their rings closed up to 0, 1, 2… in their order (ring, then list order). */\nexport function closeRings(edges: readonly Edge[], sides: ReadonlySet<string>): Edge[] {\n const out = [...edges];\n for (const side of sides) {\n const idx = out.map((e, i) => ({ e, i })).filter((x) => x.e.side === side);\n idx.sort((a, b) => (a.e.ring === b.e.ring ? a.i - b.i : a.e.ring < b.e.ring ? -1 : 1));\n idx.forEach((x, ring) => {\n if (x.e.ring !== ring) out[x.i] = { ...x.e, ring };\n });\n }\n return out;\n}\n\n/** Dynamic columns left with no item are deleted, and their sides' rings closed up. */\nexport function prune(scene: Scene): Scene {\n const gone = scene.edges.filter((e) => e.column === true && e.items.length === 0);\n if (gone.length === 0) return scene;\n const sides = new Set(gone.map((e) => e.side));\n return { ...scene, edges: closeRings(scene.edges.filter((e) => !gone.includes(e)), sides) };\n}\n\n/** The scene with the item out of every edge and every float (a dynamic column it leaves empty is deleted). */\nexport function lift(scene: Scene, id: string): Scene {\n const inEdge = scene.edges.some((e) => e.items.includes(id));\n const inFloat = scene.floats.some((f) => f.id === id);\n if (!inEdge && !inFloat) return scene;\n return prune({\n ...scene,\n edges: inEdge ? scene.edges.map((e) => (e.items.includes(id) ? { ...e, items: e.items.filter((x) => x !== id) } : e)) : scene.edges,\n floats: inFloat ? scene.floats.filter((f) => f.id !== id) : scene.floats,\n });\n}\n\n/** A new column edge from the side's template, or null when the side has none or it doesn't take the kind. */\nfunction newColumn(scene: Scene, side: \"left\" | \"right\", kind: string, ring: number, items: readonly string[]): Edge | null {\n const t = scene.columns?.[side];\n if (!t || !t.accepts.includes(kind)) return null;\n const taken = new Set(scene.edges.map((e) => e.id));\n let n = 0;\n while (taken.has(`${side}-${n}`)) n++;\n return {\n id: `${side}-${n}`,\n side,\n ring,\n accepts: t.accepts,\n items,\n cross: t.cross,\n ...(t.gap !== undefined ? { gap: t.gap } : {}),\n ...(t.pad ? { pad: t.pad } : {}),\n ...(t.menu ? { menu: t.menu } : {}),\n ...(t.zoneAccepts ? { zoneAccepts: t.zoneAccepts } : {}),\n column: true,\n };\n}\n\n/**\n * The rings of a side's edges as they lie, outer first, 0 up with no ties (by ring, then by their order in the scene):\n * the numbers column and rail places count in.\n */\nexport function sideRings(edges: readonly Edge[], side: string): Map<string, number> {\n return new Map(closeRings(edges, new Set([side])).filter((e) => e.side === side).map((e) => [e.id, e.ring]));\n}\n\n/** The first ring a new column may take on `side`: inside every static edge outer to the side's dynamic columns. */\nfunction columnFloor(edges: readonly Edge[], side: string): number {\n const mine = edges.filter((e) => e.side === side).sort((a, b) => a.ring - b.ring);\n let n = 0;\n while (n < mine.length && mine[n]!.column !== true) n++;\n // With no dynamic column, every static edge on the side is outer to the new one.\n return n;\n}\n\n/**\n * `scene` with a new column holding `id` at `ring` on `side` (already lifted out). The side's rings are made distinct\n * first; static edges keep their place, so a new column goes no further out than just inside the static edges outer to\n * the side's dynamic columns (a bar or an anchor at the window edge stays there).\n */\nfunction insertColumn(scene0: Scene, id: string, side: \"left\" | \"right\", ring: number): Scene | null {\n const scene: Scene = { ...scene0, edges: closeRings(scene0.edges, new Set([side])) };\n const kind = scene.items[id]!.kind;\n const mine = scene.edges.filter((e) => e.side === side);\n const floor = columnFloor(scene.edges, side);\n const r = Math.max(floor, Math.min(Number.isNaN(ring) ? Infinity : Math.floor(ring), mine.length === 0 ? 0 : Math.max(...mine.map((e) => e.ring)) + 1));\n const col = newColumn(scene, side, kind, r, [id]);\n if (!col) return null;\n // A kind never opens a column on its own unless the column's start zone takes it (a group never opens a panel column\n // whose tray is its end zone).\n if (!zoneTakes(col, \"start\", kind)) return null;\n // The item keeps its zone when the new column's zone takes it (as `moveTo` into a column that exists), else the first\n // zone that does; `align` follows the zone chosen.\n const item = scene.items[id]!;\n const zone = zoneTakes(col, zoneOf(item), kind) ? zoneOf(item) : (zonesTaking(col, kind)[0] ?? \"start\");\n const { align: _a, ...plain } = item;\n const placed = withItem(scene, zone === \"start\" ? plain : { ...plain, align: zone });\n const shifted = placed.edges.map((e) => (e.side === side && e.ring >= r ? { ...e, ring: e.ring + 1 } : e));\n return { ...placed, edges: closeRings([...shifted, col], new Set([side])) };\n}\n\n/** The index in `edge.items` where the `at`-th item of `zone` is (or where the zone ends). */\nfunction insertIndex(scene: Scene, edge: Edge, zone: Zone, at: number): number {\n const rank = { start: 0, center: 1, end: 2 } as const;\n const inZone = edge.items.map((id, i) => ({ id, i })).filter((x) => zoneOf(itemOf(scene, x.id)) === zone);\n const k = Math.min(Math.max(0, Math.floor(Number.isFinite(at) ? at : inZone.length)), inZone.length);\n if (k < inZone.length) return inZone[k]!.i;\n if (inZone.length > 0) return inZone[inZone.length - 1]!.i + 1;\n // An empty zone: after the last item of an earlier zone, else before the first of a later one.\n let idx = 0;\n edge.items.forEach((id, i) => {\n if (rank[zoneOf(itemOf(scene, id))] < rank[zone]) idx = i + 1;\n });\n return idx;\n}\n\nexport function moveTo(scene: Scene, id: string, place: Place): Scene {\n const item = itemOf(scene, id);\n if (!item || item.fixed) return scene;\n if (place.kind === \"float\") {\n const out = floatAt(scene, id, place.rect);\n const anchor = place.anchor;\n if (!anchor || out === scene) return out;\n return { ...out, floats: out.floats.map((f) => (f.id === id ? { ...f, anchor } : f)) };\n }\n if (place.kind === \"column\" || place.kind === \"rail\") {\n if (place.kind === \"rail\" && !scene.rails?.[place.side]?.accepts.includes(item.kind)) return scene;\n // Its zone goes with it: `insertColumn` keeps it where the new column takes the kind there.\n const folded: SceneItem = place.kind === \"rail\" ? { ...item, from: Math.max(1, item.from ?? 0) } : item;\n const made = insertColumn(withItem(lift(scene, id), folded), id, place.side, place.ring);\n return made ?? scene;\n }\n const edge = scene.edges.find((e) => e.id === place.edge);\n if (!edge || !edge.accepts.includes(item.kind)) return scene;\n // The zone asked for (or the item's own, or the first that takes its kind) must take the kind (`zoneAccepts`).\n const zone = place.zone ?? (zoneTakes(edge, zoneOf(item), item.kind) ? zoneOf(item) : zonesTaking(edge, item.kind)[0]);\n if (!zone || !zoneTakes(edge, zone, item.kind)) return scene;\n const { align: _drop, ...rest } = item;\n const moved: SceneItem = zone === \"start\" ? rest : { ...rest, align: zone };\n const lifted = withItem(lift(scene, id), moved);\n const target = lifted.edges.find((e) => e.id === place.edge);\n // The item's own column, deleted when it was lifted out of it.\n if (!target) return scene;\n const k = insertIndex(lifted, target, zone, place.at);\n return { ...lifted, edges: lifted.edges.map((e) => (e === target ? { ...e, items: [...e.items.slice(0, k), id, ...e.items.slice(k)] } : e)) };\n}\n\nexport function floatAt(scene: Scene, id: string, at?: Rect, orient?: Orient): Scene {\n const item = itemOf(scene, id);\n if (!item || item.fixed || !scene.floatKinds.includes(item.kind)) return scene;\n const was = scene.floats.find((f) => f.id === id);\n const o: Orient | undefined = orient ?? was?.orient;\n const size = floatSizeOf(item, o ?? floatOrientOf(item));\n const float: SceneFloat = at\n ? { id, rect: { x: at.x, y: at.y, width: at.width, height: at.height }, ...(o ? { orient: o } : {}) }\n : { id, rect: { x: 0, y: 0, width: size.width, height: size.height }, anchor: \"content-top-right\", ...(o ? { orient: o } : {}) };\n const next = at && at.width > 0 && at.height > 0 ? { ...item, floatSize: { width: at.width, height: at.height } } : item;\n const lifted = lift(withItem(scene, next), id);\n return { ...lifted, floats: [...lifted.floats, float] };\n}\n\nexport function fold(scene: Scene, id: string, on: boolean): Scene {\n const item = itemOf(scene, id);\n if (!item || item.fixed) return scene;\n if (on) return (item.from ?? 0) >= 1 ? scene : withItem(scene, { ...item, from: 1 });\n if (item.from === undefined) return scene;\n const { from: _f, ...rest } = item;\n return withItem(scene, rest);\n}\n\n/** The newest age in the scene, plus one. */\nconst nextAge =(scene: Scene): number => Object.values(scene.items).reduce((m, it) => Math.max(m, Number.isFinite(it.used) ? it.used : 0), 0) + 1;\n\nexport function use(scene: Scene, id: string): Scene {\n const item = itemOf(scene, id);\n if (!item) return scene;\n return withItem(scene, { ...item, used: nextAge(scene) });\n}\n\nexport function keep(scene: Scene, id: string, on: boolean): Scene {\n const item = itemOf(scene, id);\n if (!item || !!item.kept === on) return scene;\n if (on) return withItem(scene, { ...item, kept: true });\n const { kept: _k, ...rest } = item;\n return withItem(scene, rest);\n}\n\nexport function open(scene: Scene, id: string): Scene {\n const item = itemOf(scene, id);\n if (!item || !item.closed) return scene;\n const { closed: _c, ...rest } = item;\n return withItem(scene, rest);\n}\n\nexport function close(scene: Scene, id: string): Scene {\n const item = itemOf(scene, id);\n if (!item || item.closed || item.fixed) return scene;\n return withItem(scene, { ...item, closed: true });\n}\n\nexport function raise(scene: Scene, id: string): Scene {\n const i = scene.floats.findIndex((f) => f.id === id);\n if (i < 0 || i === scene.floats.length - 1) return scene;\n return { ...scene, floats: [...scene.floats.slice(0, i), ...scene.floats.slice(i + 1), scene.floats[i]!] };\n}\n\nexport function orient(scene: Scene, id: string, to: Orient): Scene {\n const i = scene.floats.findIndex((f) => f.id === id);\n const item = scene.items[id];\n if (i < 0 || !item || (scene.floats[i]!.orient ?? floatOrientOf(item)) === to) return scene;\n return { ...scene, floats: scene.floats.map((f, k) => (k === i ? { ...f, orient: to } : f)) };\n}\n\nexport function resize(scene: Scene, edgeId: string, size: number): Scene {\n const edge = scene.edges.find((e) => e.id === edgeId);\n if (!edge) return scene;\n if (!Number.isFinite(size)) {\n if (edge.size === undefined) return scene;\n const { size: _s, ...rest } = edge;\n return { ...scene, edges: scene.edges.map((e) => (e === edge ? rest : e)) };\n }\n return { ...scene, edges: scene.edges.map((e) => (e === edge ? { ...e, size } : e)) };\n}\n\n/**\n * The edge moved to the other side of its axis (left ⇄ right, top ⇄ bottom), as its side's outermost edge: ring 0, before\n * that side's other edges (whose rings close up behind it; the side it left closes up too). Its items, size and options\n * go with it. Unchanged for an unknown edge, the side it is on, or a side across its axis. Like every change it does not\n * tick the use clock: a host that moves an edge by hand calls `use()` on its items afterwards, as a drop does.\n */\nexport function setSide(scene: Scene, edgeId: string, side: Side): Scene {\n const edge = scene.edges.find((e) => e.id === edgeId);\n if (!edge || edge.side === side || axisOf(edge.side) !== axisOf(side)) return scene;\n const moved: Edge = { ...edge, side, ring: 0 };\n const others = scene.edges.filter((e) => e !== edge).map((e) => (e.side === side ? { ...e, ring: e.ring + 1 } : e));\n return { ...scene, edges: closeRings([moved, ...others], new Set([edge.side, side])) };\n}\n\n/**\n * The place `start` (a scene as it began: the host's start or reset scene) gives an item, for Dock, Put back and Reset\n * position: its zone and place in the same edge (before the first item that followed it there and is still there), a\n * new column at its ring when its column is gone (a column under the same id that holds none of the start column's\n * items is another column), or its float rect (and anchor). Null when `start` places it nowhere\n * or in an edge `scene` no longer has that isn't a column. `moveTo(scene, id, place)` puts it there.\n */\nexport function homeFor(scene: Scene, id: string, start: Scene): Place | null {\n for (const e of start.edges) {\n const k = e.items.indexOf(id);\n if (k < 0) continue;\n const zone = zoneOf(itemOf(start, id) ?? itemOf(scene, id));\n // A dynamic column's id is reused once it is pruned: the edge under that id is home only while it still holds one of\n // the start column's items (the item itself, or another). Static edges match by id.\n const found = scene.edges.find((x) => x.id === e.id);\n const here = found && (e.column !== true || found.items.some((x) => e.items.includes(x))) ? found : undefined;\n if (here) {\n const now = here.items.filter((x) => x !== id && zoneOf(itemOf(scene, x)) === zone);\n const next = e.items.slice(k + 1).find((x) => now.includes(x));\n return { kind: \"gap\", edge: e.id, zone, at: next ? now.indexOf(next) : now.length };\n }\n // Its ring as the start scene's side lay (no ties); `insertColumn` keeps it inside the static edges outer to it.\n if (e.column === true && (e.side === \"left\" || e.side === \"right\")) return { kind: \"column\", side: e.side, ring: sideRings(start.edges, e.side).get(e.id) ?? e.ring };\n return null;\n }\n const f = start.floats.find((x) => x.id === id);\n if (f) return { kind: \"float\", rect: f.rect, ...(f.anchor ? { anchor: f.anchor } : {}) };\n return null;\n}\n\n/**\n * Dock, Put back and Reset position: the item where `start` (the loaded scene) has it, fold included. It goes to\n * `homeFor`'s place and takes `start`'s `from` (unfolded when `start` has none), so a \"Move to › rail\" (which folds it)\n * followed by Dock brings it back open. The scene given back unchanged when `start` places it nowhere.\n */\nexport function dockHome(scene: Scene, id: string, start: Scene): Scene {\n const place = homeFor(scene, id, start);\n if (!place) return scene;\n // An item already at its home place (the only item of its own column, which `moveTo` can't re-dock into) keeps its\n // place and still takes the start fold.\n const moved = moveTo(scene, id, place);\n const item = itemOf(moved, id);\n if (!item) return scene;\n const from = itemOf(start, id)?.from;\n if (item.from === from) return moved;\n const { from: _f, ...plain } = item;\n return withItem(moved, from === undefined ? plain : { ...plain, from });\n}\n\n/**\n * A float's rect moved (never resized) so that what `solve` draws of it lies in the stage: `drawn` is its drawn size (the\n * bar's when it is folded). As in `solve`, one drawn larger than the stage keeps its top-left corner on the stage's.\n */\nexport function clampFloat(r: Rect, stage: Rect, drawn: { readonly width: number; readonly height: number } = r): Rect {\n const at = clampInto({ x: r.x, y: r.y, width: drawn.width, height: drawn.height }, stage);\n return { x: at.x, y: at.y, width: r.width, height: r.height };\n}\n\n/** The size `solve` draws a float at (`floatShape`): its rect's, its bar's when folded, its icons' when vertical. */\nexport function drawnFloatSize(item: SceneItem, f: { readonly rect: Rect; readonly orient?: Orient }): { width: number; height: number } {\n const s = floatShape(item, f);\n return { width: s.width, height: s.height };\n}\n","/**\n * The scene's stored form. `storeScene(scene)` gives plain JSON-safe data; `readScene(data, base)` reads it back over\n * `base` (the host's scene as it starts: its item definitions, edges, kinds and stage) and never throws.\n *\n * ```ts\n * interface StoredScene {\n * v: 1;\n * edges: { id: string; side: Side; ring: number; items: string[]; size?: number; column?: true }[];\n * floats: { id: string; x: number; y: number; width: number; height: number; orient?: \"row\" | \"column\"; anchor?: FloatAnchor }[];\n * items: Record<string, { used: number; kept?: true; from?: number; closed?: true; align?: \"center\" | \"end\"; floatSize?: { width: number; height: number } }>;\n * }\n * ```\n *\n * Nothing about kinds, forms or limits is stored: those are the host's (`base`). An edge is matched by its id: its\n * side, ring and limits come from `base`, its order of items and its `size` from the store; a static edge stored on\n * the other side of its axis is moved there (`setSide`, as its side's outermost edge). Dynamic columns\n * (`column: true`) are the store's: one `base` lacks is made from `base.columns[side]`, its ring is the stored one, and\n * columns left empty are deleted, the rings closed up. No float has a pinned field: one an old store has is listed and\n * ignored.\n *\n * Reading is lenient: anything but an object of version 1 gives `base` back with the reason in `error`. Inside one,\n * whatever can't be used is dropped and listed in `dropped` (an unknown edge `edge:<id>`, an unknown or repeated item,\n * an item an edge doesn't accept `edge:<edge>:<id>`, a fixed item in another edge than `base`'s `edge:<edge>:<id>`, a\n * float of a kind that doesn't float `float:<id>`, a bad field `item:<id>:<field>`, an unknown top-level field\n * `<field>`). A stored edge's order is kept exactly, fixed items where the store put them (in their own edge); a fixed\n * item the store lacks goes back to its base place (trailing ones last). An item the store places nowhere goes where\n * `base` has it, before a stored trailing run of fixed items.\n * A float's rect is clamped into the stage on read.\n */\nimport { rect, type Size } from \"../geometry\";\nimport { clampFloat, closeRings, drawnFloatSize, prune, setSide } from \"./changes\";\nimport { SIDES, axisOf, type Edge, type FloatAnchor, type Orient, type Scene, type SceneFloat, type SceneItem, type Side } from \"./model\";\n\nexport interface StoredSceneEdge {\n readonly id: string;\n readonly side: Side;\n readonly ring: number;\n readonly items: readonly string[];\n readonly size?: number;\n /** A dynamic column: read back from `base.columns[side]` even when `base` doesn't have it. */\n readonly column?: true;\n}\n\nexport interface StoredSceneFloat {\n readonly id: string;\n readonly x: number;\n readonly y: number;\n readonly width: number;\n readonly height: number;\n readonly orient?: Orient;\n readonly anchor?: FloatAnchor;\n}\n\nexport interface StoredSceneItem {\n readonly used: number;\n readonly kept?: true;\n readonly from?: number;\n readonly closed?: true;\n readonly align?: \"center\" | \"end\";\n readonly floatSize?: Size;\n}\n\nexport interface StoredScene {\n readonly v: 1;\n readonly edges: readonly StoredSceneEdge[];\n readonly floats: readonly StoredSceneFloat[];\n readonly items: Readonly<Record<string, StoredSceneItem>>;\n}\n\nexport interface SceneRead {\n readonly scene: Scene;\n /** What was left out, as listed in the module's docs. */\n readonly dropped: readonly string[];\n /** Set when nothing could be read: `scene` is `base`. */\n readonly error?: string;\n}\n\nconst ANCHORS: readonly FloatAnchor[] = [\"content-top-left\", \"content-top\", \"content-top-right\", \"content-right\", \"content-bottom-right\", \"content-bottom\", \"content-bottom-left\", \"content-left\"];\nconst isNum = (x: unknown): x is number => typeof x === \"number\" && Number.isFinite(x);\nconst isSize = (x: unknown): x is number => isNum(x) && x > 0;\nconst isObject = (x: unknown): x is Record<string, unknown> => typeof x === \"object\" && x !== null && !Array.isArray(x);\n/** Records with no prototype, so an id such as `constructor` is only a key; `__proto__` is refused. */\nconst record = <T>(): Record<string, T> => Object.create(null) as Record<string, T>;\n\nexport function storeScene(scene: Scene): StoredScene {\n const items = record<StoredSceneItem>();\n for (const [id, it] of Object.entries(scene.items)) {\n if (id === \"__proto__\") continue;\n items[id] = {\n used: isNum(it.used) ? it.used : 0,\n ...(it.kept ? { kept: true as const } : {}),\n ...(isNum(it.from) && it.from >= 1 ? { from: Math.floor(it.from) } : {}),\n ...(it.closed ? { closed: true as const } : {}),\n ...(it.align === \"center\" || it.align === \"end\" ? { align: it.align } : {}),\n ...(it.floatSize && isSize(it.floatSize.width) && isSize(it.floatSize.height) ? { floatSize: { width: it.floatSize.width, height: it.floatSize.height } } : {}),\n };\n }\n return {\n v: 1,\n edges: scene.edges.map((e) => ({ id: e.id, side: e.side, ring: e.ring, items: [...e.items], ...(isNum(e.size) ? { size: e.size } : {}), ...(e.column === true ? { column: true as const } : {}) })),\n floats: scene.floats\n .filter((f) => isNum(f.rect.x) && isNum(f.rect.y) && isSize(f.rect.width) && isSize(f.rect.height))\n .map((f) => ({ id: f.id, x: f.rect.x, y: f.rect.y, width: f.rect.width, height: f.rect.height, ...(f.orient ? { orient: f.orient } : {}), ...(f.anchor ? { anchor: f.anchor } : {}) })),\n items,\n };\n}\n\nexport function readScene(data: unknown, base: Scene): SceneRead {\n try {\n return read(data, base);\n } catch (e) {\n return { scene: base, dropped: [], error: `unreadable: ${e instanceof Error ? e.message : typeof e}` };\n }\n}\n\nconst words = (v: unknown): string => (typeof v === \"number\" ? String(v) : typeof v === \"string\" ? JSON.stringify(v.length > 24 ? `${v.slice(0, 24)}…` : v) : typeof v);\n\n/**\n * The fixed items of `baseIds` that `stored` lacks, put back at their places: leading ones from the start, trailing ones\n * at the end. Fixed items the store has keep the place it gives them, so a stored order round-trips exactly.\n */\nfunction withFixed(baseIds: readonly string[], stored: readonly string[], isFixed: (id: string) => boolean): string[] {\n const out = [...stored];\n const missing = (id: string): boolean => isFixed(id) && !stored.includes(id);\n let tail = baseIds.length;\n while (tail > 0 && isFixed(baseIds[tail - 1]!)) tail--;\n baseIds.forEach((id, i) => {\n if (missing(id) && i < tail) out.splice(Math.min(i, out.length), 0, id);\n });\n return [...out, ...baseIds.slice(tail).filter(missing)];\n}\n\nfunction read(data: unknown, base: Scene): SceneRead {\n if (!isObject(data)) return { scene: base, dropped: [], error: \"not an object\" };\n if (data.v !== 1) return { scene: base, dropped: [], error: `unknown version ${words(data.v)} (this reads version 1)` };\n const dropped: string[] = [];\n const drop = (what: string): void => {\n if (!dropped.includes(what)) dropped.push(what);\n };\n for (const k of Object.keys(data)) if (![\"v\", \"edges\", \"floats\", \"items\"].includes(k)) drop(k);\n const known = (id: unknown): id is string => typeof id === \"string\" && id !== \"__proto__\" && Object.hasOwn(base.items, id);\n const isFixed = (id: string): boolean => known(id) && base.items[id]!.fixed === true;\n\n // The items' states.\n const items: Record<string, SceneItem> = { ...base.items };\n if (data.items !== undefined && !isObject(data.items)) drop(\"items\");\n else if (isObject(data.items)) {\n for (const id of Object.keys(data.items)) {\n const s = data.items[id];\n if (!known(id) || !isObject(s)) {\n drop(`item:${id}`);\n continue;\n }\n const b = base.items[id]!;\n const { kept: _k, from: _f, closed: _c, align: _a, floatSize: _s, ...plain } = b;\n let it: SceneItem = { ...plain, used: b.used };\n for (const k of Object.keys(s)) if (![\"used\", \"kept\", \"from\", \"closed\", \"align\", \"floatSize\"].includes(k)) drop(`item:${id}:${k}`);\n if (isNum(s.used)) it = { ...it, used: s.used };\n else if (s.used !== undefined) drop(`item:${id}:used`);\n if (s.kept === true) it = { ...it, kept: true };\n else if (s.kept !== undefined && s.kept !== false) drop(`item:${id}:kept`);\n if (isNum(s.from) && Number.isInteger(s.from) && s.from >= 1 && !b.fixed) it = { ...it, from: s.from };\n else if (s.from !== undefined) drop(`item:${id}:from`);\n if (b.fixed && b.from !== undefined) it = { ...it, from: b.from };\n if (s.closed === true && !b.fixed) it = { ...it, closed: true };\n else if (s.closed !== undefined && s.closed !== false) drop(`item:${id}:closed`);\n if (s.align === \"center\" || s.align === \"end\") it = { ...it, align: s.align };\n else if (s.align !== undefined && s.align !== \"start\") drop(`item:${id}:align`);\n if (b.fixed && b.align) it = { ...it, align: b.align };\n const fs = s.floatSize;\n if (isObject(fs) && isSize(fs.width) && isSize(fs.height)) it = { ...it, floatSize: { width: fs.width, height: fs.height } };\n else if (fs !== undefined) drop(`item:${id}:floatSize`);\n items[id] = it;\n }\n }\n\n // Where they are: stored edges by id, then stored floats.\n const placed = new Set<string>();\n const order = new Map<string, string[]>();\n const sizes = new Map<string, number | undefined>();\n const made: Edge[] = [];\n const rings = new Map<string, number>();\n const moves = new Map<string, Side>();\n if (data.edges !== undefined && !Array.isArray(data.edges)) drop(\"edges\");\n for (const e of Array.isArray(data.edges) ? (data.edges as unknown[]) : []) {\n if (!isObject(e) || typeof e.id !== \"string\") {\n drop(\"an edge with no id\");\n continue;\n }\n let edge = base.edges.find((x) => x.id === e.id) ?? made.find((x) => x.id === e.id);\n if (!edge && e.column === true && (e.side === \"left\" || e.side === \"right\") && base.columns?.[e.side]) {\n // A column the user made: from its side's template.\n const t = base.columns[e.side]!;\n edge = { id: e.id, side: e.side, ring: isNum(e.ring) ? e.ring : Infinity, accepts: t.accepts, items: [], cross: t.cross, ...(t.gap !== undefined ? { gap: t.gap } : {}), ...(t.pad ? { pad: t.pad } : {}), ...(t.menu ? { menu: t.menu } : {}), column: true };\n made.push(edge);\n }\n if (!edge || order.has(edge.id)) {\n drop(`edge:${e.id}`);\n continue;\n }\n if (edge.column === true && isNum(e.ring)) rings.set(edge.id, e.ring);\n if (e.side !== undefined && !SIDES.includes(e.side as Side)) drop(`edge:${e.id}:side`);\n else if (edge.column !== true && typeof e.side === \"string\" && e.side !== edge.side && axisOf(e.side as Side) === axisOf(edge.side)) moves.set(edge.id, e.side as Side);\n const ids: string[] = [];\n for (const id of Array.isArray(e.items) ? (e.items as unknown[]) : []) {\n if (!known(id) || placed.has(id)) drop(`edge:${edge.id}:${String(id)}`);\n // A fixed item stays in the edge `base` has it in, at the place the store gives it there; elsewhere it is dropped.\n else if (isFixed(id)) {\n if (edge.items.includes(id) && base.edges.some((x) => x.id === edge.id)) {\n ids.push(id);\n placed.add(id);\n } else drop(`edge:${edge.id}:${id}`);\n }\n else if (!edge.accepts.includes(items[id]!.kind)) drop(`edge:${edge.id}:${id}`);\n else {\n ids.push(id);\n placed.add(id);\n }\n }\n order.set(edge.id, ids);\n if (isNum(e.size)) sizes.set(edge.id, e.size);\n else if (e.size !== undefined) drop(`edge:${edge.id}:size`);\n else sizes.set(edge.id, undefined);\n }\n const floats: SceneFloat[] = [];\n if (data.floats !== undefined && !Array.isArray(data.floats)) drop(\"floats\");\n for (const f of Array.isArray(data.floats) ? (data.floats as unknown[]) : []) {\n if (!isObject(f) || typeof f.id !== \"string\") {\n drop(\"a float with no id\");\n continue;\n }\n const id = f.id;\n if (!known(id) || placed.has(id) || isFixed(id) || !base.floatKinds.includes(items[id]!.kind) || !isNum(f.x) || !isNum(f.y) || !isSize(f.width) || !isSize(f.height)) {\n drop(`float:${id}`);\n continue;\n }\n for (const k of Object.keys(f)) if (k === \"pinned\") drop(`pinned:${id}`);\n else if (![\"id\", \"x\", \"y\", \"width\", \"height\", \"orient\", \"anchor\"].includes(k)) drop(`float:${id}:${k}`);\n const o = f.orient === \"row\" || f.orient === \"column\" ? f.orient : undefined;\n if (f.orient !== undefined && !o) drop(`float:${id}:orient`);\n const a = ANCHORS.includes(f.anchor as FloatAnchor) ? (f.anchor as FloatAnchor) : undefined;\n if (f.anchor !== undefined && !a) drop(`float:${id}:anchor`);\n placed.add(id);\n // Clamped by what solve draws (a folded float's bar), never cut: a reload lands where solve put it.\n const r = rect(f.x, f.y, f.width, f.height);\n const drawn = drawnFloatSize(items[id]!, { rect: r, ...(o ? { orient: o } : {}) });\n floats.push({ id, rect: clampFloat(r, base.stage, drawn), ...(o ? { orient: o } : {}), ...(a ? { anchor: a } : {}) });\n }\n\n // Each base edge: its stored order exactly (fixed items where the store put them), its base items the store placed\n // nowhere before a stored trailing run of fixed items, and fixed items the store lacks at their base places.\n const edges: Edge[] = [...base.edges, ...made].map((edge) => {\n const stored = order.get(edge.id) ?? [];\n const rest = edge.items.filter((id) => !isFixed(id) && !placed.has(id));\n for (const id of rest) placed.add(id);\n let tail = stored.length;\n while (tail > 0 && isFixed(stored[tail - 1]!)) tail--;\n const listed = [...stored.slice(0, tail), ...rest, ...stored.slice(tail)];\n const items1 = withFixed(edge.items, listed, isFixed);\n const size = sizes.has(edge.id) ? sizes.get(edge.id) : edge.size;\n const { size: _s, ...plain } = edge;\n return { ...plain, ring: rings.get(edge.id) ?? edge.ring, items: items1, ...(size !== undefined ? { size } : {}) };\n });\n // Base floats the store placed nowhere keep their base place.\n for (const f of base.floats) if (!placed.has(f.id)) floats.push(f);\n // Empty columns go; the sides' rings close up.\n let scene = prune({ ...base, items, edges: closeRings(edges, new Set(made.length > 0 || rings.size > 0 ? [\"left\", \"right\"] : [])), floats });\n for (const [id, side] of moves) scene = setSide(scene, id, side);\n return { scene, dropped };\n}\n","/**\n * `targets(scene, dragged, { previous, endReach, floatSize })`: every drop target for one dragged item, in the shape\n * `@n-uf/motion/drag` takes (`id`, `priority`, `hit`, `slot?`, `free?`). Each target's `after(point, grab)` is the scene\n * a release there commits and its layout, `solve(after.scene, { previous })`: the host draws every item from that layout\n * during the preview (C22), so the preview is the result by construction.\n *\n * One model makes every docked target and refusal: **edge → zones → slots → tiles**, then one ordered\n * filter.\n *\n * - **Edges.** Every edge, empty or occupied, and two virtual edges per side: the column lines and the rail.\n * - **Zones.** Each edge's start, center and end zones have an extent along it. Where items keep their length and the\n * zones only align them (bars, compact rails, side toolbar bars) the extents are the edge's thirds; where items fill\n * the edge (panel columns) a zone's extent is the span the solver gives it: a plain column is one zone, a tray column\n * its panels' span and its tray's (`EDGE_KINDS`, the only data keyed on the kind of edge). The outer extents reach\n * `endReach` past the edge's ends.\n * - **Slots.** A zone's insertion lines, from the layout with the item lifted (`gap:<edge>:<zone>:<at>`; on an edge with\n * no members at all a zone has one, `strip:<edge>:<zone>`). The item's own place is an interval, its own rect along the edge: home.\n * - **Tiles.** A zone's extent split halfway between its slots' lines (lines that lie past the extent are spread into\n * it); the own interval keeps exactly its length, its neighbours meeting it, and a stretch of a zone with no other\n * slot is home's. Across: the edge's thickness (the larger of now and after the drop), an empty edge's strip depth\n * (`Edge.strip`, default 24, inward), a compact rail's `RAIL_REACH` further inward.\n * - **Filter**, in order: (i) the edge and zone take the kind (`accepts`, `zoneAccepts`), and an empty side column opens\n * only through its start zone; (ii) the drop fits (C29: no » entry, no new overflow or `too-wide`, every fixed item\n * keeps its form, place and least length, a title bar's title its natural width with the toolbar in its first form;\n * the slot covers no chrome or reserved rect). A slot (i) or (ii) removes is a refusal over its own tile, with that\n * reason (`refusals()`). (iii) Space ownership and clipping (`EDGE_KINDS`): owned > virtual > overreach. A zone's\n * room loses its panel bodies, its reserved rects and what edges ranked before it own (in `solve`'s laying order); a\n * zone with no room, or a slot with none in reach, isn't offered. Each tile's owned part is cut clear of the tiles\n * before it, of what outranks its edge, of every fixed item that doesn't grow and of the chrome, keeping the part\n * that holds its slot's line (its other parts refused); then the virtual edges take what no edge owns; then each\n * overreach takes what is left and joins its owned part where it meets it whole. Slots that are the same move are\n * one. (iv) `blocked` rects are `none:<i>`.\n *\n * Ids: `gap:<edge>:<zone>:<at>` (priority 2), `strip:<edge>:<zone>` (2), `column:<side>:<ring>` (2), `rail:<side>:<ring>`\n * (1), `none:<i>` (1), `float:<id>` (3, free). A slot that would put the item back where it is keeps its id with place\n * `home` (no slot, nothing committed); `home:<id>` (1) is emitted too, over the same tile (its own rect when no slot is\n * its home), for hosts that read it. A floating item has no home: a move inside its own rect is a float move.\n *\n * - `column:<side>:<ring>`: a new column on each column line of a side whose `scene.columns[side]` takes the kind\n * (outside the outermost open column, between two, inside the innermost; on a side with none, at the content's\n * edge), up to `COLUMN_REACH` px each way (two lines nearer than that meet halfway), only where the new column shows\n * open (elsewhere refused).\n * - `rail:<side>:<ring>`: docking folded into a side's rail (its rail and its template take the kind), before each\n * folded column's segments and after the last, or, with no rail shown, `RAIL_EDGE` px deep where the rail lands\n * (`SceneLayout.railPlaces`).\n * - `float:<id>`: when `floatKinds` lists the kind, the whole plane: the landing is the float with the pointer holding\n * it at `grab` (default its middle), in the stage and clear of the docked items, the bars and the chrome. Its orient:\n * `options.floatOrient`, else its float's, else the item's (`floatOrientOf`). Its size: `options.floatSize`, else its\n * float's size, else `floatSizeOf`.\n *\n * `stops(scene, id)` orders the same targets (no home, no none) for \"Move to ›\" and the arrow keys.\n *\n * A dropped item counts as just used (`use`). An unknown, fixed or closed item has no targets.\n */\nimport { COLUMN_REACH, EPS, PLANE, RAIL_EDGE, area, contains, overlaps, rect, subtract, type Point, type Rect, type Size } from \"../geometry\";\nimport type { Target } from \"../target\";\nimport { formMain } from \"../stack/model\";\nimport { floatAt, lift, moveTo, sideRings, use, type ColumnPlace, type RailPlace } from \"./changes\";\nimport { DEFAULT_HIT_BAND, DEFAULT_STRIP, ZONES, axisOf, floatOrientOf, floatSizeOf, formsOf, isSideBar, zoneOf, zoneTakes, type Edge, type Orient, type Scene, type SceneLayout, type Zone } from \"./model\";\nimport { layKeys, pushes, solve, type LayKey } from \"./solve\";\n\nexport type ScenePlace =\n | { readonly kind: \"gap\"; readonly edge: string; readonly zone: Zone; readonly at: number }\n | ColumnPlace\n | RailPlace\n | { readonly kind: \"float\" }\n | { readonly kind: \"home\" }\n | { readonly kind: \"none\" };\n\nexport interface SceneAfter {\n readonly scene: Scene;\n readonly layout: SceneLayout;\n}\n\nexport interface SceneTarget extends Target {\n /** The item dragged. */\n readonly item: string;\n readonly place: ScenePlace;\n /** Gaps and strips: the line where the item's leading edge lands, zero thick, across the edge after the drop. */\n readonly marker?: Rect;\n /** The scene a release here commits and its layout. Only a float's depends on the pointer. */\n after(point: Point, grab?: Point): SceneAfter;\n}\n\nexport interface SceneTargetOptions {\n /** The layout before the drag: every `after` is solved with it, as the drop will be. */\n readonly previous?: SceneLayout;\n /** How far the first and last gaps of an edge reach past its ends, px (default 0). */\n readonly endReach?: number;\n /** The float's size for the float target. */\n readonly floatSize?: Size;\n /** The float's orient for the float target (default: its float's, else the item's `floatOrientOf`). */\n readonly floatOrient?: Orient;\n /** As `solve`'s: edge or item ids solved without `previous`, in every `after` too. */\n readonly fresh?: readonly string[];\n}\n\n/** Where a drop of the dragged item is refused: a host shows \"no room here\" at the pointer, with no slot anywhere. */\nexport interface SceneRefusal {\n /**\n * `refuse:<edge>:<zone>`, with `:<n>` after it for a zone's second refused tile and on, numbered by where they lie\n * along the edge (then across it), so an id is stable from one frame to the next.\n */\n readonly id: string;\n readonly edge: string;\n readonly zone: Zone;\n /** Where the pointer means it: the refused slot's tile, never over a target's hit. */\n readonly hit: Rect;\n /**\n * `no-room`: the zone takes the kind, but the drop there doesn't fit (a title bar at the title's natural width, say).\n * `own-place`: the stretch beside an item alone in its zone: there is room, but the zone's only place is the item's\n * own (a release there puts it back). `not-accepted`: the edge or zone doesn't take the kind.\n */\n readonly reason: \"no-room\" | \"own-place\" | \"not-accepted\";\n}\n\n/** How far a compact rail's hits reach inward past the rail, px. */\nconst RAIL_REACH = 24;\n\n/**\n * The edge kinds and their data, the only place target generation tells them apart, the virtual edges (the column\n * lines across a side, the stops down its rail) among them.\n * - `zoneExtent`: `thirds` where items keep their length and the zones only align them, `solved` where items fill the\n * edge (each zone's extent is the span the solver gives it), `whole` for an edge of one zone.\n * - `opens`: through which zones an empty edge opens: `any` zone that takes the kind, or only its `start` zone.\n * - `inward`: how far hits reach inward past the edge's thickness (overreach, below).\n * - Space ownership, one ordering: **owned > virtual > overreach**. A drawn edge owns its current rect; an empty edge\n * owns only `place` px of its strip, at the boundary where it would appear (the side's rail likewise, where it lies\n * or would lie, `railPlaces`). Owned rects rank in the order `solve` lays edges out (`layKeys`, `pushes`): an edge\n * laid first, whose filling pushes the other, wins; between edges laid independently a drawn rect wins over an empty\n * edge's band. `layer` orders the owned tiles where they meet. The virtual edges (the column lines) come next and get\n * only space no edge owns. `overreach` orders the parts of tiles past their owned rect (the depth after a drop, an\n * empty strip past its band, a compact rail's inward reach), which yield to the virtual edges and to every other\n * edge's owned rect.\n * - `phase`: the laying phase it ranks in (`LayKey.phase`), for the kinds `solve` doesn't lay itself: the rail and a\n * column line rank among the sides (phase 2), where the rail or a new column would be laid; null for the edges\n * `solve` lays (their phase is `layKeys`'s).\n * - `priority`: its targets' priority. `reach`: how far a slot's tile reaches each way from its line, px.\n * - `virtual`: an edge that owns nothing (the column lines). Its refused stretches take only what every other tile\n * leaves.\n */\nconst EDGE_KINDS = {\n bar: { zoneExtent: \"thirds\", opens: \"any\", inward: 0, place: DEFAULT_HIT_BAND / 2, phase: null, layer: 10, overreach: 30, priority: 2, reach: Infinity, virtual: false },\n sideBar: { zoneExtent: \"thirds\", opens: \"any\", inward: 0, place: DEFAULT_HIT_BAND / 2, phase: null, layer: 11, overreach: 31, priority: 2, reach: Infinity, virtual: false },\n column: { zoneExtent: \"solved\", opens: \"start\", inward: 0, place: DEFAULT_HIT_BAND / 2, phase: null, layer: 12, overreach: 32, priority: 2, reach: Infinity, virtual: false },\n barBetween: { zoneExtent: \"thirds\", opens: \"any\", inward: 0, place: DEFAULT_HIT_BAND / 2, phase: null, layer: 13, overreach: 33, priority: 2, reach: Infinity, virtual: false },\n rail: { zoneExtent: \"thirds\", opens: \"any\", inward: RAIL_REACH, place: DEFAULT_HIT_BAND / 2, phase: null, layer: 14, overreach: 34, priority: 2, reach: Infinity, virtual: false },\n railStop: { zoneExtent: \"whole\", opens: \"any\", inward: 0, place: DEFAULT_HIT_BAND / 2, phase: 2, layer: 9, overreach: 39, priority: 1, reach: Infinity, virtual: false },\n columnLine: { zoneExtent: \"whole\", opens: \"any\", inward: 0, place: DEFAULT_HIT_BAND / 2, phase: 2, layer: 21, overreach: 41, priority: 2, reach: COLUMN_REACH, virtual: true },\n} as const satisfies Record<\n string,\n {\n readonly zoneExtent: \"thirds\" | \"solved\" | \"whole\";\n readonly opens: \"any\" | \"start\";\n readonly inward: number;\n readonly place: number;\n readonly layer: number;\n readonly phase: number | null;\n readonly overreach: number;\n readonly priority: 1 | 2;\n readonly reach: number;\n readonly virtual: boolean;\n }\n>;\ntype EdgeKind = keyof typeof EDGE_KINDS;\n\n/** Which of `EDGE_KINDS` an edge is. */\nfunction edgeKindOf(scene: Scene, e: Edge): EdgeKind {\n if (e.compact) return \"rail\";\n if (e.side === \"top\" || e.side === \"bottom\") return e.span === \"between\" ? \"barBetween\" : \"bar\";\n return isSideBar(scene, e) ? \"sideBar\" : \"column\";\n}\n\n/**\n * Whether an empty `edge` opens to `kind`: an edge opens only through its start zone, so a kind never makes a column of\n * its own where the start zone takes another kind (a group never makes a column of one toolbar: a tray column's tray is\n * its end zone). Edges whose zones only align (bars, rails, side bars) open through any zone that takes the kind.\n */\nexport const opensEmpty = (scene: Scene, edge: Edge, kind: string): boolean => EDGE_KINDS[edgeKindOf(scene, edge)].opens === \"any\" || zoneTakes(edge, \"start\", kind);\n\n/**\n * What a fixed item reserves in `l`: its drawn rect, or for a form that grows only its natural length, placed by its\n * zone (from its start, from its end in the end zone, centred in the centre zone). No hit or slot ever lies there, so a\n * host that draws \"no drop\" areas reads them from here.\n */\nexport function reservedRect(scene: Scene, l: SceneLayout, id: string): Rect {\n const it = l.items[id]!;\n const e = it.edge ? l.edges[it.edge] : undefined;\n const f = e ? formsOf(scene.items[id]!, axisOf(e.side))[it.form] : undefined;\n if (!e || !f?.main.grows) return it.rect;\n const column = axisOf(e.side) === \"column\";\n const len = column ? it.rect.height : it.rect.width;\n const keep = Math.min(len, Math.max(0, Number.isFinite(f.main.natural) ? f.main.natural : len));\n const shift = it.zone === \"end\" ? len - keep : it.zone === \"center\" ? (len - keep) / 2 : 0;\n return column ? rect(it.rect.x, it.rect.y + shift, it.rect.width, keep) : rect(it.rect.x + shift, it.rect.y, keep, it.rect.height);\n}\n\n/**\n * Where things are, without ages or the ids of dynamic columns: two scenes with one key place every item alike. An\n * edge's items count by zone (start, center, end), in their order within it: the list's order across zones places\n * nothing.\n */\nfunction placeKey(s: Scene, id: string): string {\n const it = Object.hasOwn(s.items, id) ? s.items[id] : undefined;\n const byZone = (items: readonly string[]): string[] => ZONES.flatMap((z) => items.filter((x) => zoneOf(s.items[x]) === z));\n return JSON.stringify({\n edges: s.edges.map((e) => JSON.stringify([e.side, e.ring, e.column === true ? \"\" : e.id, byZone(e.items), e.size ?? null])).sort(),\n floats: s.floats.map((f) => [f.id, f.rect, f.anchor ?? null, f.orient ?? null]),\n from: it?.from ?? 0,\n align: it?.align ?? \"start\",\n });\n}\n\n/** One tile before clipping: a slot's, home's, or a refused slot's. */\ninterface Tile {\n readonly edge: string;\n /** Its spec's `key`. */\n readonly key: string;\n /** Its edge's kind, set by the edge's description (a virtual edge's too): never read from an edge's id. */\n readonly edgeKind: EdgeKind;\n /** Its edge runs along y. */\n readonly vertical: boolean;\n readonly zone: Zone;\n /** Clipping precedence: lower first. */\n readonly order: number;\n /** `reach`: the overreach of the tile `of` (its part past its edge's owned rect), clipped after the virtual edges. */\n readonly kind: \"slot\" | \"home\" | \"refuse\" | \"reach\";\n readonly of?: Tile;\n readonly id: string;\n readonly priority: 1 | 2 | 3;\n readonly place?: ScenePlace;\n readonly result?: SceneAfter;\n readonly reason?: SceneRefusal[\"reason\"];\n readonly hit: Rect;\n /** The point the tile must keep through clipping (on its slot's line), or null for a refusal (its largest part). */\n readonly keep: Point | null;\n readonly marker?: Rect;\n readonly slot?: Rect;\n}\n\n/** What one drag can do: its targets and its refusals, from one generation. */\ninterface Generated {\n readonly targets: SceneTarget[];\n readonly refusals: SceneRefusal[];\n /** Slots the filter kept, with room in their zone, that end with no hit (none, by the property check). */\n readonly lost: string[];\n}\n\n/** The context every edge's generator shares. */\ninterface Ctx {\n readonly scene: Scene;\n readonly rest: Scene;\n readonly now: SceneLayout;\n readonly base: SceneLayout;\n readonly dragged: string;\n readonly kind: string;\n readonly reach: number;\n readonly settle: (s: Scene) => SceneAfter;\n readonly isHome: (r: SceneAfter) => boolean;\n /** Whether a drop's layout fits the window (filter ii): what every edge checks; its own landing rule comes on top. */\n readonly sound: (after: SceneLayout) => boolean;\n /** Where `solve` lays each edge of the scene out. */\n readonly lay: ReadonlyMap<string, LayKey>;\n}\n\n/** A slot: an insertion line along an edge and the drop it makes. */\ninterface Slot {\n readonly zone: Zone;\n /** Its line along the edge. */\n readonly line: number;\n readonly id: string;\n readonly place: Extract<ScenePlace, { kind: \"gap\" }> | ColumnPlace | RailPlace;\n readonly result: SceneAfter;\n /** A drop here puts the item back where it is. */\n readonly home: boolean;\n /** It passes the filter: home, or the item lands where the slot aims and the window fits. */\n readonly ok: boolean;\n}\n\n/**\n * One edge as the tiler reads it, a real edge or a virtual one alike: its kind (`EDGE_KINDS`), its axis, its zones'\n * extents along it, its slots, the item's own rect on it (its interval along the edge is home's tile), the spans no\n * tile takes, its band across and its markers.\n */\ninterface EdgeSpec {\n readonly id: string;\n /** Unique among the specs (a side's column lines share their edge's id, one spec per line). */\n readonly key: string;\n readonly kind: EdgeKind;\n /** Where `solve` lays it out (`layKeys`): what it owns ranks by this. */\n readonly lay: LayKey;\n /** It runs along y (side edges, the rail), not x (bars, the column lines). */\n readonly vertical: boolean;\n readonly zones: readonly { readonly zone: Zone; readonly a: number; readonly b: number }[];\n readonly slots: readonly Slot[];\n /** Why a stretch of `zone` with no slot is refused, or null where it is no drop place at all. */\n readonly refuse: (zone: Zone) => SceneRefusal[\"reason\"] | null;\n /** The item's own rect on this edge, or null. */\n readonly own: Rect | null;\n /** The item lies on this edge now (drawn, or in its » menu): its home slot gets no tile, home is only its own rect. */\n readonly holds: boolean;\n readonly reserved: readonly Span[];\n /** The band across, `[from, to]`, as deep as the edge is now or after `after`. */\n readonly across: (after?: SceneLayout) => Span;\n /** The part of the band across it owns: its current thickness, or an empty edge's thin band at its boundary. */\n readonly owned: Span;\n /** Along it, what it owns, where that is less than its zones (a column line's band about its line); else null. */\n readonly ownedAlong: Span | null;\n /** It draws now; else what it owns is a band of its place (where it lands once filled). */\n readonly drawn: boolean;\n /** A slot's marker: the zero-thick line where the item's leading edge lands. */\n readonly marker: (s: Slot) => Rect;\n}\n\n/** A slot for `place` on `line`: its drop, settled; home when it puts the item back (or `home`); `lands`, its edge's rule. */\nfunction slotAt(c: Ctx, zone: Zone, line: number, id: string, place: Slot[\"place\"], lands: (r: SceneAfter) => boolean, home = false): Slot {\n const result = c.settle(use(moveTo(c.scene, c.dragged, place), c.dragged));\n const isHome = home || c.isHome(result);\n return { zone, line, id, place, result, home: isHome, ok: isHome || (!!result.layout.items[c.dragged] && lands(result) && c.sound(result.layout)) };\n}\n\n/** `[a, b]` along an edge. */\ntype Span = readonly [number, number];\n\n/** Spans along an edge less other spans along it. */\nconst less = (spans: readonly Span[], away: readonly Span[]): Span[] =>\n away.reduce<Span[]>((acc, [ra, rb]) => acc.flatMap(([a, b]) => (rb <= a || ra >= b ? [[a, b] as Span] : ([[a, Math.max(a, ra)], [Math.min(b, rb), b]] as Span[]).filter(([u, w]) => w - u > EPS))), [...spans]);\n\n/**\n * The zones of `edge` with their extents along it, for a drag of `kind` (`EDGE_KINDS[...].zoneExtent`). `probe(zone)`:\n * the span an empty zone takes once it holds the item (a `solved` edge's empty zone), or null (then a point at the\n * zone's anchor). The outer extents reach `reach` past the edge's ends.\n */\nfunction zoneSpans(scene: Scene, base: SceneLayout, edge: Edge, reach: number, probe: (z: Zone) => Span | null): { zone: Zone; a: number; b: number }[] {\n const el = base.edges[edge.id]!;\n const column = axisOf(edge.side) === \"column\";\n const main0 = column ? el.rect.y : el.rect.x;\n const length = column ? el.rect.height : el.rect.width;\n if (EDGE_KINDS[edgeKindOf(scene, edge)].zoneExtent === \"thirds\")\n return ZONES.map((zone, k) => ({ zone, a: k === 0 ? main0 - reach : main0 + (length * k) / 3, b: k === 2 ? main0 + length + reach : main0 + (length * (k + 1)) / 3 }));\n // Where items fill the edge: the zones it declares (or its one zone), each where the solver puts its items.\n const at = (r: Rect): Span => (column ? [r.y, r.y + r.height] : [r.x, r.x + r.width]);\n const declared = new Set<Zone>(edge.zoneAccepts ? ZONES.filter((z) => edge.zoneAccepts![z] !== undefined) : [\"start\"]);\n const placed = new Map<Zone, Span>();\n for (const [id, it] of Object.entries(base.items)) {\n if (it.edge !== edge.id || it.inMenu) continue;\n const z = zoneOf(scene.items[id]);\n const [a, b] = at(it.rect);\n const was = placed.get(z);\n placed.set(z, was ? [Math.min(was[0], a), Math.max(was[1], b)] : [a, b]);\n declared.add(z);\n }\n const anchor: Record<Zone, number> = { start: main0, center: main0 + length / 2, end: main0 + length };\n const spans = ZONES.filter((z) => declared.has(z)).map((zone) => ({ zone, s: placed.get(zone) ?? probe(zone) ?? ([anchor[zone], anchor[zone]] as Span) }));\n return spans.map(({ zone, s }, i) => ({\n zone,\n a: i === 0 ? main0 - reach : (spans[i - 1]!.s[1] + s[0]) / 2,\n b: i === spans.length - 1 ? main0 + length + reach : (s[1] + spans[i + 1]!.s[0]) / 2,\n }));\n}\n\n/**\n * `zoneExtents(scene, dragged, edgeId, options?)`: the zones of an edge and their extents along it, as the targets of a\n * drag of `dragged` tile them (the edge's rect as the lift leaves it). For a test or a host that shows the zones.\n */\nexport function zoneExtents(scene: Scene, dragged: string, edgeId: string, options: SceneTargetOptions = {}): { zone: Zone; a: number; b: number }[] {\n const prev = { ...(options.previous ? { previous: options.previous } : {}), ...(options.fresh ? { fresh: options.fresh } : {}) };\n const rest = lift(scene, dragged);\n const base = solve(rest, prev);\n const edge = rest.edges.find((e) => e.id === edgeId);\n if (!edge || !base.edges[edgeId]) return [];\n const column = axisOf(edge.side) === \"column\";\n const reach = Math.max(0, Number.isFinite(options.endReach) ? options.endReach! : 0);\n return zoneSpans(rest, base, edge, reach, (zone) => {\n if (!zoneTakes(edge, zone, scene.items[dragged]?.kind ?? \"\")) return null;\n const l = solve(use(moveTo(scene, dragged, { kind: \"gap\", edge: edgeId, zone, at: 0 }), dragged), prev);\n const me = l.items[dragged];\n return me && me.edge === edgeId && me.zone === zone ? (column ? [me.rect.y, me.rect.y + me.rect.height] : [me.rect.x, me.rect.x + me.rect.width]) : null;\n });\n}\n\n/** A real edge as the tiler reads it, or null where it offers nothing (home's own rect is added on its own). */\nfunction edgeSpec(c: Ctx, edge: Edge): EdgeSpec | null {\n const { scene, rest, now, base, dragged, kind } = c;\n const el = base.edges[edge.id];\n // A folded or riding column takes drops through its side's rail and column lines, not here.\n if (!el || el.folded || el.rides) return null;\n const edgeKind = edgeKindOf(rest, edge);\n const data = EDGE_KINDS[edgeKind];\n const column = axisOf(edge.side) === \"column\";\n const at = (r: Rect): number => (column ? r.y : r.x);\n const len = (r: Rect): number => (column ? r.height : r.width);\n const main0 = at(el.rect);\n const length = len(el.rect);\n const empty = el.stack.items.every((p) => p.kind === \"menu\") && !el.menu;\n const accepts = edge.accepts.includes(kind);\n // An edge that takes the kind nowhere and draws nothing has nothing to say; an empty edge opens only as it may.\n if (!accepts && (empty || area(el.rect) <= EPS)) return null;\n if (accepts && empty && !opensEmpty(rest, edge, kind)) return null;\n // The item's own rect, where it lies in this edge now: home's, whatever else the edge offers.\n const ownNow = now.items[dragged];\n const ownHere = ownNow && ownNow.edge === edge.id && !ownNow.floating && !ownNow.inMenu ? ownNow.rect : null;\n const restEdge = rest.edges.find((e) => e.id === edge.id)!;\n // `strip:<edge>:<zone>` names a slot only on an edge with no members at all (a zone there has one slot); every other\n // slot, beside closed members or the item's own place too, is named by its gap, so no two slots share an id.\n const slotId = (zone: Zone, at: number): string => (restEdge.items.length === 0 ? `strip:${edge.id}:${zone}` : `gap:${edge.id}:${zone}:${at}`);\n // Where a drop lands on this edge: in it, shown (no » entry); on a title bar (a fixed item that grows), in its first\n // form, the title at its natural width and nothing else changing form or going into the menu.\n const titles = edge.items.filter((id) => base.items[id]?.edge === edge.id && base.items[id]!.fixed && !!formsOf(scene.items[id]!, axisOf(edge.side))[base.items[id]!.form]?.main.grows);\n const lands = ({ layout: after }: SceneAfter): boolean => {\n const me = after.items[dragged]!;\n if (me.edge !== edge.id || me.inMenu) return false;\n if (titles.length === 0) return true;\n if (me.form !== 0) return false;\n return edge.items.every((id) => {\n const a = after.items[id];\n const b = base.items[id];\n if (!a || !b || b.edge !== edge.id || id === dragged) return true;\n if (!titles.includes(id)) return a.form === b.form && !!a.inMenu === !!b.inMenu;\n const f = formsOf(scene.items[id]!, axisOf(edge.side))[a.form];\n return !f || (column ? a.rect.height : a.rect.width) >= formMain(f, \"natural\", after.edges[edge.id]!.cross) - 0.5;\n });\n };\n const pad = { start: Math.max(0, edge.pad?.start ?? 0), end: Math.max(0, edge.pad?.end ?? 0) };\n const menuLen = el.menu ? len(el.menu.rect) : 0;\n\n // Slots: a zone's insertion lines, from the layout with the item lifted. What an item takes of the edge for its lines:\n // its rect, or a growing fixed item's natural rect (a title's text), so the length it grew by is free room.\n const occupied = (id: string): Rect => (base.items[id]?.fixed ? reservedRect(scene, base, id) : base.items[id]!.rect);\n const shown = (id: string): boolean => base.items[id]?.edge === edge.id && !base.items[id]!.inMenu;\n const drawnOf = (z: Zone): Rect[] => restEdge.items.filter((id) => zoneOf(rest.items[id]) === z && shown(id)).map(occupied);\n const startEnd = ((): number => {\n const s = drawnOf(\"start\");\n return s.length ? at(s[s.length - 1]!) + len(s[s.length - 1]!) : main0 + pad.start;\n })();\n const endStart = ((): number => {\n const e = drawnOf(\"end\");\n return e.length ? at(e[0]!) : main0 + length - pad.end - menuLen;\n })();\n const anchorLine: Record<Zone, number> = { start: main0 + pad.start, center: Math.min(Math.max(main0 + length / 2, startEnd), Math.max(startEnd, endStart)), end: main0 + length - pad.end - menuLen };\n const slots: Slot[] = [];\n for (const zone of ZONES) {\n if (!accepts || !zoneTakes(edge, zone, kind)) continue;\n const members = restEdge.items.filter((id) => zoneOf(rest.items[id]) === zone);\n for (let k = 0; k <= members.length; k++) {\n const next = members.slice(k).find(shown);\n const before = members.slice(0, k).reverse().find(shown);\n const line = next ? at(occupied(next)) : before ? at(occupied(before)) + len(occupied(before)) : anchorLine[zone];\n const s = slotAt(c, zone, line, slotId(zone, k), { kind: \"gap\", edge: edge.id, zone, at: k }, lands);\n // A place that would move a fixed item of the edge (before a title, after the window controls) is no slot: a\n // fixed item keeps its place, so no drop ever lands there.\n const movesFixed = restEdge.items.some((id) => {\n const b = base.items[id];\n const a = s.result.layout.items[id];\n return !!b?.fixed && b.edge === edge.id && (!a || Math.abs(a.rect.x - b.rect.x) > 0.5 || Math.abs(a.rect.y - b.rect.y) > 0.5);\n });\n if (!movesFixed) slots.push(s);\n }\n }\n const spanOf = (r: Rect): Span => [at(r), at(r) + len(r)];\n // The edge's reserved rects along it (its fixed items; a growing one's natural rect): no slot's tile lies there.\n // A growing one (a title) is not: its text is a stretch of the gap just after it.\n const grows = (id: string): boolean => !!formsOf(scene.items[id]!, axisOf(edge.side))[base.items[id]!.form]?.main.grows;\n const reserved: Span[] = Object.entries(base.items)\n .filter(([id, p]) => p.edge === edge.id && p.fixed && !p.inMenu && !grows(id))\n .map(([, p]) => spanOf(p.rect));\n const zones = zoneSpans(rest, base, edge, c.reach, (zone) => {\n const s = slots.find((x) => x.zone === zone && x.place.kind === \"gap\" && x.place.at === 0);\n const me = s?.result.layout.items[dragged];\n return me && me.edge === edge.id && me.zone === zone ? spanOf(me.rect) : null;\n });\n\n // Across: the band from the edge's outer side, as deep as the edge (now or after the drop) or an empty edge's strip.\n const r = el.rect;\n const strip = Math.max(0, Number.isFinite(edge.strip) ? edge.strip! : DEFAULT_STRIP);\n const nowCross = now.edges[edge.id]?.cross ?? 0;\n const outer = edge.side === \"left\" ? r.x : edge.side === \"right\" ? r.x + r.width : edge.side === \"top\" ? r.y : r.y + r.height;\n const inward = (depth: number): Span => (edge.side === \"left\" || edge.side === \"top\" ? [outer, outer + depth] : [outer - depth, outer]);\n const across = (after?: SceneLayout): Span => inward((el.cross > 0 || nowCross > 0 ? Math.max(el.cross, nowCross, after?.edges[edge.id]?.cross ?? 0) : strip) + data.inward);\n // What it owns: its current thickness, with the item lifted or as it is now, but the item's own edge only as lifted\n // (the item has left it); an edge with no thickness owns only a thin band of its place, at its boundary.\n const ownCross = ownNow?.edge === edge.id ? el.cross : Math.max(el.cross, nowCross);\n const drawn = ownCross > 0;\n const marker = (s: Slot): Rect => {\n const slot = s.result.layout.items[dragged]!.rect;\n const e = s.result.layout.edges[edge.id]!;\n return column ? rect(e.rect.x, slot.y, e.cross, 0) : rect(slot.x, e.rect.y, 0, e.cross);\n };\n const takes = (zone: Zone): boolean => accepts && zoneTakes(edge, zone, kind);\n return {\n id: edge.id,\n key: edge.id,\n kind: edgeKind,\n lay: c.lay.get(edge.id)!,\n vertical: column,\n zones,\n slots,\n refuse: (zone) => (takes(zone) ? \"no-room\" : accepts || area(el.rect) > EPS ? \"not-accepted\" : null),\n own: ownHere,\n holds: !!ownNow && ownNow.edge === edge.id && !ownNow.floating,\n reserved,\n across,\n owned: inward(drawn ? ownCross : Math.min(strip, data.place)),\n ownedAlong: null,\n drawn,\n marker,\n };\n}\n\n/**\n * One edge's tiles, every kind alike: each zone's extent less the item's own interval, split halfway between its slots'\n * lines (projected into it), a slot's tile reaching at most its kind's `reach` from its line. A stretch with no slot is\n * refused (`spec.refuse`), a slot the filter removed is refused over its own tile, and the own interval is home's\n * (across, the edge's band and the own rect), named after the home slot when there is one. Where the item has no rect\n * on the edge, home's tile is its slot's.\n */\nfunction tileEdge(c: Ctx, spec: EdgeSpec, cuts: readonly Span[], lost: string[]): Tile[] {\n const data = EDGE_KINDS[spec.kind];\n const v = spec.vertical;\n const own: Span | null = spec.own ? (v ? [spec.own.y, spec.own.y + spec.own.height] : [spec.own.x, spec.own.x + spec.own.width]) : null;\n const band = (a: number, b: number, after?: SceneLayout): Rect => {\n const [c0, c1] = spec.across(after);\n return v ? rect(c0, a, c1 - c0, b - a) : rect(a, c0, b - a, c1 - c0);\n };\n // The point a tile keeps through clipping: on its line, in the middle of its band across.\n const keepAt = (line: number, h: Rect): Point => (v ? { x: h.x + h.width / 2, y: line } : { x: line, y: h.y + h.height / 2 });\n type More = Pick<Tile, \"kind\" | \"id\" | \"order\" | \"priority\" | \"keep\"> & Partial<Tile>;\n const tile = (zone: Zone, hit: Rect, more: More): Tile => ({ edge: spec.id, key: spec.key, edgeKind: spec.kind, vertical: v, zone, hit, ...more });\n const refused = (zone: Zone, hit: Rect, reason: SceneRefusal[\"reason\"]): Tile => tile(zone, hit, { kind: \"refuse\", id: \"\", order: data.layer, priority: data.priority, keep: null, reason });\n const reserved = spec.reserved;\n // A tile's part across that its edge owns, and the rest, its overreach: clipped after the virtual edges, then joined\n // back where it still meets the owned part whole.\n const split = (t: Tile): Tile[] => {\n const h = t.hit;\n const [h0, h1] = v ? [h.x, h.x + h.width] : [h.y, h.y + h.height];\n const [c0, c1] = [Math.max(h0, spec.owned[0]), Math.min(h1, spec.owned[1])];\n const part = (a: number, b: number): Rect => (v ? rect(a, h.y, b - a, h.height) : rect(h.x, a, h.width, b - a));\n const beyond = less([[h0, h1]], [spec.owned]);\n if (beyond.length === 0) return [t];\n if (c1 - c0 <= EPS) return [{ ...t, order: data.overreach }];\n const core: Tile = { ...t, hit: part(c0, c1), keep: t.keep && keepAt(v ? t.keep.y : t.keep.x, part(c0, c1)) };\n return [core, ...beyond.map(([a, b]): Tile => ({ ...t, kind: \"reach\", of: core, order: data.overreach, hit: part(a, b), keep: null }))];\n };\n // Slots that are the same move are one slot, the first (the lowest `at`) keeping it: one line and one landing, or\n // both home (both put the item back, wherever their lines lie).\n const landing = (s: Slot): Rect | undefined => s.result.layout.items[c.dragged]?.rect;\n const sameMove = (a: Slot, b: Slot): boolean => {\n if (a.zone !== b.zone) return false;\n if (a.home && b.home) return true;\n const [p, q] = [landing(a), landing(b)];\n return Math.abs(a.line - b.line) < EPS && (!p || !q ? p === q : Math.abs(p.x - q.x) + Math.abs(p.y - q.y) + Math.abs(p.width - q.width) + Math.abs(p.height - q.height) < 0.01);\n };\n const slots = spec.slots.filter((s, i) => !spec.slots.slice(0, i).some((o) => sameMove(o, s)));\n const out: Tile[] = [];\n for (const z of spec.zones) {\n // The zone's extent less its reserved rects and what other edges own: a zone left with nothing has no slot.\n const room = less([[z.a, z.b]], [...cuts, ...reserved]).filter(([a, b]) => b - a > EPS);\n if (room.length === 0) continue;\n // Less the own interval, which home owns: a zone wholly under the item's own place has no room left either.\n const pieces = own ? less(room, [own]) : room;\n // A slot with no room within its kind's reach of its line isn't offered.\n const mine = slots.filter((s) => s.zone === z.zone && !(spec.holds && s.home) && pieces.some(([a, b]) => b > s.line - data.reach + EPS && a < s.line + data.reach - EPS));\n const reason = spec.refuse(z.zone);\n for (const [pa, pb] of pieces) {\n // Lines spread into the zone's extent less its reserved rects when they lie past it: their share of the span\n // the lines and the extent cover, laid along the extent's free pieces end to end.\n const lines = mine.map((s) => s.line);\n const lo = Math.min(z.a, ...lines);\n const hi = Math.max(z.b, ...lines);\n const free = less([[z.a, z.b]], reserved);\n const freeLen = free.reduce((n, [a, b]) => n + (b - a), 0);\n const spread = (x: number): number => {\n if (hi - lo <= EPS || freeLen <= EPS) return x;\n let d = ((x - lo) / (hi - lo)) * freeLen;\n for (const [a, b] of free) {\n if (d <= b - a + EPS) return a + Math.min(d, b - a);\n d -= b - a;\n }\n return free[free.length - 1]![1];\n };\n // A line inside the own interval (an empty zone's anchor under the item) goes to the interval's nearer end.\n // Lines inside the extent stay where they are, one inside a reserved rect going to its nearer end.\n const past = lines.some((x) => x < z.a - EPS || x > z.b + EPS);\n const nearer = (p: number, [a, b]: Span): number => (p > a && p < b ? (p - a < b - p ? a : b) : p);\n // A line left outside the zone's pieces (under what another edge owns) goes to the nearest point of one.\n const proj = (x: number): number => {\n const q = reserved.reduce((r, s) => nearer(r, s), past ? spread(x) : x);\n const p = own ? nearer(q, own) : q;\n if (pieces.some(([a, b]) => p >= a - EPS && p <= b + EPS)) return p;\n return pieces.map(([a, b]) => Math.min(Math.max(p, a), b)).reduce((m, y) => (Math.abs(y - p) < Math.abs(m - p) ? y : m));\n };\n const inPiece = mine.filter((s) => proj(s.line) >= pa - EPS && proj(s.line) <= pb + EPS).sort((a, b) => proj(a.line) - proj(b.line) || a.line - b.line);\n // Where projection lays two different moves on one point (lines under the own place or another edge's), the\n // piece's lines are laid out in their order along it instead, one share each.\n const projected = inPiece.map((s) => proj(s.line));\n const at = projected.some((p, i) => i > 0 && p - projected[i - 1]! <= EPS) ? inPiece.map((_, i) => pa + ((i + 0.5) * (pb - pa)) / inPiece.length) : projected;\n if (inPiece.length === 0) {\n // A stretch of a zone with no slot of its own is refused: home is only over the item's own place, and no stretch\n // is handed to another zone's slot. Beside a lone item (the zone's only slot is home) there is room, but no\n // place other than its own: `own-place`.\n // A stretch out of every slot's reach is no part of this edge.\n const lone = reason === \"no-room\" && mine.length === 0 && slots.some((s) => s.zone === z.zone && s.home);\n const near = mine.length === 0 || mine.some((s) => pb > s.line - data.reach + EPS && pa < s.line + data.reach - EPS);\n if (reason && near) out.push(...split(refused(z.zone, band(pa, pb), lone ? \"own-place\" : reason)));\n continue;\n }\n inPiece.forEach((s, i) => {\n // Halfway between neighbouring lines, the piece's ends at its ends (the own interval's ends are one), and no\n // further from its line than the kind's reach.\n const p = at[i]!;\n const a = Math.max(i === 0 ? pa : (at[i - 1]! + p) / 2, p - data.reach);\n const b = Math.min(i === inPiece.length - 1 ? pb : (p + at[i + 1]!) / 2, p + data.reach);\n if (b - a <= EPS) {\n if (s.ok) lost.push(s.id);\n return;\n }\n const line = Math.min(Math.max(p, a), b);\n const hit = band(a, b, s.result.layout);\n if (!s.ok) out.push(...split(refused(z.zone, hit, \"no-room\")));\n else if (s.home) out.push(...split(tile(z.zone, hit, { kind: \"home\", id: s.id, order: data.layer, priority: data.priority, keep: keepAt(line, hit), place: { kind: \"home\" } })));\n else out.push(...split(tile(z.zone, hit, { kind: \"slot\", id: s.id, order: data.layer, priority: data.priority, keep: keepAt(line, hit), place: s.place, result: s.result, marker: spec.marker(s), slot: s.result.layout.items[c.dragged]!.rect })));\n });\n }\n }\n if (own && spec.own) {\n const home = spec.slots.find((s) => s.home);\n // Across the edge's band and the own rect where it lies now: home's wherever the lift moves things (nothing clips\n // it). A slot's id and priority; `home:<id>` (1) when no slot is home.\n const [a, b] = own;\n const h = band(a, b);\n const o = spec.own;\n const hit = v ? rect(Math.min(h.x, o.x), a, Math.max(h.x + h.width, o.x + o.width) - Math.min(h.x, o.x), b - a) : rect(a, Math.min(h.y, o.y), b - a, Math.max(h.y + h.height, o.y + o.height) - Math.min(h.y, o.y));\n out.push(tile(home?.zone ?? zoneOf(c.scene.items[c.dragged]), hit, { kind: \"home\", id: home ? home.id : `home:${c.dragged}`, order: 0, priority: home ? data.priority : 1, keep: null, place: { kind: \"home\" } }));\n }\n return out;\n}\n\n/**\n * The side's column lines as an edge (virtual, along x): a slot on each line for a new column there, tiled as every\n * edge is (its kind's `reach` each way at most), down the columns' stretch.\n */\nfunction columnLines(c: Ctx, side: \"left\" | \"right\"): EdgeSpec[] {\n const { rest, base, dragged } = c;\n const cols = rest.edges\n .filter((e) => e.side === side && e.column === true)\n .map((edge) => ({ edge, l: base.edges[edge.id] }))\n .filter((x) => x.l && !x.l.folded && !x.l.rides && x.l.cross > 0)\n .sort((a, b) => a.edge.ring - b.edge.ring)\n .map((x) => ({ edge: x.edge, r: x.l!.rect }));\n const own = Object.values(base.edges).filter((e) => e.side === side && e.rect.height > 0);\n const span = own[0]?.rect ?? base.content;\n // Rings as the side's edges lie (no ties): a static edge outer to the columns keeps its place.\n const rings = sideRings(rest.edges, side);\n const ringOf = (e: Edge): number => rings.get(e.id) ?? e.ring;\n // Each line with the place a new column there would take in `solve`'s laying order: just before the column it lies\n // outside of (which it would push), just after the innermost (or every edge of the side, with no column).\n const lines: { x: number; ring: number; at: number }[] = [];\n const outerX = (r: Rect): number => (side === \"left\" ? r.x : r.x + r.width);\n const innerX = (r: Rect): number => (side === \"left\" ? r.x + r.width : r.x);\n const atOf = (e: Edge): number => c.lay.get(e.id)?.at ?? 0;\n cols.forEach((x) => lines.push({ x: outerX(x.r), ring: ringOf(x.edge), at: atOf(x.edge) - 0.5 }));\n if (cols.length > 0) lines.push({ x: innerX(cols[cols.length - 1]!.r), ring: ringOf(cols[cols.length - 1]!.edge) + 1, at: atOf(cols[cols.length - 1]!.edge) + 0.5 });\n else lines.push({ x: side === \"left\" ? base.content.x : base.content.x + base.content.width, ring: rings.size, at: Math.max(-1, ...rest.edges.filter((e) => e.side === side).map(atOf)) + 0.5 });\n // A new column lands where it shows open.\n const lands = (r: SceneAfter): boolean => {\n const me = r.layout.items[dragged]!;\n const el = me.edge ? r.layout.edges[me.edge] : undefined;\n return !!el && !me.inMenu && !el.folded && !el.rides && r.scene !== c.scene;\n };\n const { reach, place } = EDGE_KINDS.columnLine;\n // One spec per line: a new column's place, owning a band of `place` px about its line (ranked where that column would\n // be laid), its slot's tile reaching `reach` each way past it as overreach.\n return lines.map((l) => ({\n id: `column:${side}`,\n key: `column:${side}:${l.ring}`,\n kind: \"columnLine\" as const,\n lay: { phase: EDGE_KINDS.columnLine.phase, side, at: l.at },\n vertical: false,\n zones: [{ zone: \"start\" as const, a: l.x - reach, b: l.x + reach }],\n slots: [slotAt(c, \"start\", l.x, `column:${side}:${l.ring}`, { kind: \"column\", side, ring: l.ring }, lands)],\n refuse: () => \"no-room\" as const,\n own: null,\n holds: false,\n reserved: [],\n across: (): Span => [span.y, span.y + span.height],\n owned: [span.y, span.y + span.height] as Span,\n ownedAlong: [l.x - place / 2, l.x + place / 2] as Span,\n drawn: false,\n marker: (s: Slot) => rect(s.line, span.y, 0, span.height),\n }));\n}\n\n/**\n * The side's rail as an edge (virtual, along y): a slot before each folded column's segments and after the last, or,\n * with no rail shown, one slot `RAIL_EDGE` px deep where the rail lands (`railPlaces`); tiled as every edge is.\n */\nfunction railStops(c: Ctx, side: \"left\" | \"right\"): EdgeSpec | null {\n const { rest, base, now, dragged } = c;\n const rail = base.rails[side];\n const placeRect = base.railPlaces[side];\n if (!placeRect) return null;\n const rings = sideRings(rest.edges, side);\n const mine = rest.edges.filter((e) => e.side === side).sort((a, b) => (rings.get(a.id) ?? 0) - (rings.get(b.id) ?? 0));\n const ringOf = (id: string): number => rings.get(id) ?? 0;\n const stops: { y: number; ring: number }[] = [];\n let zone: Rect;\n if (rail && rail.segments.length > 0) {\n zone = rail.rect;\n const groups: { edge: string; y0: number; y1: number }[] = [];\n for (const s of rail.segments) {\n const g = groups[groups.length - 1];\n if (g && g.edge === s.edge) g.y1 = s.rect.y + s.rect.height;\n else groups.push({ edge: s.edge, y0: s.rect.y, y1: s.rect.y + s.rect.height });\n }\n for (const g of groups) stops.push({ y: g.y0, ring: ringOf(g.edge) });\n const last = groups[groups.length - 1]!;\n stops.push({ y: last.y1, ring: ringOf(last.edge) + 1 });\n } else {\n const firstCol = mine.find((e) => e.column === true);\n zone = rect(side === \"left\" ? placeRect.x : placeRect.x + placeRect.width - RAIL_EDGE, placeRect.y, RAIL_EDGE, placeRect.height);\n stops.push({ y: placeRect.y, ring: firstCol ? ringOf(firstCol.id) : mine.length });\n }\n // Folded into this rail; every stop is home while the item is folded here already.\n const ownRail = now.items[dragged]?.rail === side;\n const lands = (r: SceneAfter): boolean => r.layout.items[dragged]!.rail === side && r.scene !== c.scene;\n const at = zone;\n return {\n id: `rail:${side}`,\n key: `rail:${side}`,\n kind: \"railStop\",\n // The rail lies outside every edge on its side: laid first among them.\n lay: { phase: EDGE_KINDS.railStop.phase, side, at: -1 },\n vertical: true,\n zones: [{ zone: \"start\", a: at.y, b: at.y + at.height }],\n slots: stops.map((s) => slotAt(c, \"start\", s.y, `rail:${side}:${s.ring}`, { kind: \"rail\", side, ring: s.ring }, lands, ownRail)),\n refuse: () => \"no-room\",\n own: null,\n holds: false,\n reserved: [],\n across: () => [at.x, at.x + at.width],\n // A drawn rail owns its rect; where none shows, a thin band of its place at the side's outer boundary.\n owned: rail && rail.segments.length > 0 ? [at.x, at.x + at.width] : side === \"left\" ? [at.x, at.x + Math.min(at.width, EDGE_KINDS.railStop.place)] : [at.x + at.width - Math.min(at.width, EDGE_KINDS.railStop.place), at.x + at.width],\n ownedAlong: null,\n drawn: !!rail && rail.segments.length > 0,\n marker: (s) => rect(at.x, s.result.layout.items[dragged]!.rect.y, at.width, 0),\n };\n}\n\nfunction generate(scene: Scene, dragged: string, options: SceneTargetOptions): Generated {\n const item = Object.hasOwn(scene.items, dragged) ? scene.items[dragged] : undefined;\n if (!item || item.fixed || item.closed) return { targets: [], refusals: [], lost: [] };\n const prev = { ...(options.previous ? { previous: options.previous } : {}), ...(options.fresh ? { fresh: options.fresh } : {}) };\n const settle = (s: Scene): SceneAfter => ({ scene: s, layout: solve(s, prev) });\n const now = solve(scene, prev);\n const rest = lift(scene, dragged);\n const base = solve(rest, prev);\n const chrome = scene.chrome ?? [];\n const here = placeKey(scene, dragged);\n\n // Filter (ii), fit: a drop may not add an `overflow` or `too-wide` note anywhere, change a fixed item's form or least\n // length, nor lie over chrome or a fixed item's reserved rect (C29). Each edge adds where a drop on it lands (`lands`).\n const noteKey = (n: SceneLayout[\"notes\"][number]): string | null => (\"edge\" in n && (n.code === \"overflow\" || n.code === \"too-wide\") ? `${n.edge}:${n.code}:${\"id\" in n ? n.id : \"\"}` : null);\n const hadNotes = new Set(base.notes.map(noteKey).filter((k): k is string => k !== null));\n const sound = (after: SceneLayout): boolean => {\n if (after.notes.some((n) => { const k = noteKey(n); return k !== null && !hadNotes.has(k); })) return false;\n for (const [id, b] of Object.entries(base.items)) {\n if (!b.fixed) continue;\n const a = after.items[id];\n const e = a?.edge ? after.edges[a.edge] : undefined;\n if (!a || !e || a.form !== b.form || a.formKind !== b.formKind) return false;\n const f = formsOf(scene.items[id]!, axisOf(e.side))[a.form];\n const len = axisOf(e.side) === \"column\" ? a.rect.height : a.rect.width;\n if (f && len < formMain(f, \"min\", e.cross) - 0.5) return false;\n }\n const me = after.items[dragged];\n if (!me) return true;\n const fixedAfter = Object.entries(after.items).filter(([id, it]) => it.fixed && id !== dragged).map(([id]) => reservedRect(scene, after, id));\n return !chrome.some((c) => overlaps(me.rect, c)) && !fixedAfter.some((f) => overlaps(me.rect, f));\n };\n const c: Ctx = { scene, rest, now, base, dragged, kind: item.kind, reach: Math.max(0, Number.isFinite(options.endReach) ? options.endReach! : 0), settle, isHome: (r) => placeKey(r.scene, dragged) === here, sound, lay: layKeys(scene) };\n\n // The edges as the tiler reads them: every real edge, then each side's column lines and rail, only for kinds the\n // side's template opens with (its start zone).\n const specs: (EdgeSpec | null)[] = rest.edges.map((edge) => edgeSpec(c, edge));\n for (const side of [\"left\", \"right\"] as const) {\n const template = scene.columns?.[side];\n if (!template || !zoneTakes(template, \"start\", item.kind)) continue;\n specs.push(...columnLines(c, side));\n if (scene.rails?.[side]?.accepts.includes(item.kind)) specs.push(railStops(c, side));\n }\n // Space ownership. A drawn edge owns its current rect, with the item lifted or as it is now (but for the item's own\n // edge as it is now: the item has left it); an empty edge owns a thin band of its place at its boundary; the rail\n // likewise. Owned rects rank in the order `solve` lays edges out: one laid before another and pushing it when filled\n // wins (outer before inner, full bars before the sides they push, the rail before its side); between edges laid\n // independently a drawn rect wins over an empty edge's band, two drawn rects yield to each other, and of two bands\n // the one laid first wins. Home's tile is owned before all. A virtual edge owns nothing and yields to every owner.\n const ownEdge = now.items[dragged]?.edge;\n const live = specs.filter((s): s is EdgeSpec => s !== null);\n const bandOf = (s: EdgeSpec): Rect => {\n const a = Math.min(...s.zones.map((z) => z.a));\n const b = Math.max(...s.zones.map((z) => z.b));\n return s.vertical ? rect(s.owned[0], a, s.owned[1] - s.owned[0], b - a) : rect(a, s.owned[0], b - a, s.owned[1] - s.owned[0]);\n };\n // What it owns: its band, limited along it where it owns less than its zones (a column line's place).\n const ownedRectOf = (s: EdgeSpec): Rect => {\n const b = bandOf(s);\n if (!s.ownedAlong) return b;\n const [a0, a1] = s.ownedAlong;\n return s.vertical ? rect(b.x, a0, b.width, a1 - a0) : rect(a0, b.y, a1 - a0, b.height);\n };\n interface Owner {\n readonly id: string;\n readonly key: string;\n readonly rect: Rect;\n readonly lay: LayKey;\n readonly place: boolean;\n }\n const ownRect = now.items[dragged];\n // Home's tile: the item's own rect, and, along it, its edge's band (the own interval across the band).\n const homeRect = ((): Rect | null => {\n if (!ownRect || ownRect.floating || !ownEdge) return null;\n const o = ownRect.rect;\n const s = live.find((x) => x.id === ownEdge);\n if (!s || ownRect.inMenu) return o;\n const [c0, c1] = s.across();\n return s.vertical ? rect(Math.min(c0, o.x), o.y, Math.max(c1, o.x + o.width) - Math.min(c0, o.x), o.height) : rect(o.x, Math.min(c0, o.y), o.width, Math.max(c1, o.y + o.height) - Math.min(c0, o.y));\n })();\n const owners: Owner[] = [\n // Home first: its tile is its own, for every edge but its own (which tiles it as its own interval).\n ...(homeRect && ownEdge ? [{ id: ownEdge, key: ownEdge, rect: homeRect, lay: { phase: -1, side: \"\", at: -Infinity }, place: false }] : []),\n // Every edge the tiler reads: what it owns, drawn or a band of its place (a column line's band about its line).\n ...live.map((s) => ({ id: s.id, key: s.key, rect: ownedRectOf(s), lay: s.lay, place: !s.drawn })).filter((o) => area(o.rect) > EPS),\n // Every drawn rect, with the item lifted and as it is now (the item's own edge only lifted): the edges the tiler\n // doesn't read (folded, riding, taking nothing) and the ones that move when the item lifts.\n ...[...Object.entries(base.edges), ...Object.entries(now.edges).filter(([id]) => id !== ownEdge)]\n .filter(([id, e]) => area(e.rect) > EPS && c.lay.has(id))\n .map(([id, e]) => ({ id, key: id, rect: e.rect, lay: c.lay.get(id)!, place: false })),\n ];\n const wins = (o: Owner, s: EdgeSpec): boolean => {\n if (o.key === s.key) return false;\n if (pushes(o.lay, s.lay)) return true;\n if (pushes(s.lay, o.lay)) return false;\n const place = !s.drawn;\n return o.place === place ? !place || o.lay.at < s.lay.at : !o.place;\n };\n // What each edge yields: the owners that win over it; a virtual edge (a column line) also every other owner's rect\n // outside its own band, where its tile is overreach.\n const taken = new Map(\n live.map((s) => [\n s.key,\n [\n ...owners.filter((o) => wins(o, s)).map((o) => o.rect),\n ...(EDGE_KINDS[s.kind].virtual ? owners.filter((o) => o.key !== s.key && !wins(o, s)).flatMap((o) => subtract(o.rect, ownedRectOf(s))) : []),\n ],\n ]),\n );\n // Panel bodies (an open item's), but for `hitBand / 2` at each end: no drop place of their edge, so no part of its\n // zones' room.\n const bodySpans = (id: string): Span[] => {\n const e = rest.edges.find((x) => x.id === id);\n const bandOpt = e?.hitBand ?? DEFAULT_HIT_BAND;\n if (!e || bandOpt === \"middle\") return [];\n const column = axisOf(e.side) === \"column\";\n const half = Math.max(0, Number.isFinite(bandOpt) ? bandOpt : DEFAULT_HIT_BAND) / 2;\n return Object.entries(base.items)\n .filter(([iid, p]) => p.edge === id && p.formKind === \"open\" && iid !== dragged)\n .map(([, p]): Span => (column ? [p.rect.y + half, p.rect.y + p.rect.height - half] : [p.rect.x + half, p.rect.x + p.rect.width - half]))\n .filter(([a, b]) => b - a > EPS);\n };\n // A zone's room: less its panel bodies, and less the stretches where the owners that win over its edge together hold\n // the edge's whole depth (a thinner owner, an empty rail's band over a column, clips its tiles instead).\n const cutsOf = (s: EdgeSpec): Span[] => {\n const b = bandOf(s);\n const along = (r: Rect): Span => (s.vertical ? [r.y, r.y + r.height] : [r.x, r.x + r.width]);\n const across = (r: Rect): Span => (s.vertical ? [r.x, r.x + r.width] : [r.y, r.y + r.height]);\n const rs = taken.get(s.key)!.filter((r) => overlaps(r, b));\n const ends = [...new Set([...along(b), ...rs.flatMap(along)])].filter((x) => x >= along(b)[0] && x <= along(b)[1]).sort((p, q) => p - q);\n const owned: Span[] = [];\n for (let k = 1; k < ends.length; k++) {\n const [u, w] = [ends[k - 1]!, ends[k]!];\n const over = rs.filter((r) => along(r)[0] <= u + EPS && along(r)[1] >= w - EPS).map(across);\n if (w - u > EPS && less([across(b)], over).length === 0) owned.push([u, w]);\n }\n return [...owned, ...bodySpans(s.id)];\n };\n const lost: string[] = [];\n const tiles: Tile[] = live.flatMap((spec) => tileEdge(c, spec, cutsOf(spec), lost));\n // The item's own place is home's even where no edge tiles it (its column, deleted by the lift; its » entry).\n const homeEdge = scene.edges.find((e) => e.id === ownRect?.edge);\n if (ownRect && homeEdge && !ownRect.floating && !tiles.some((t) => t.order === 0))\n tiles.push({ edge: homeEdge.id, key: homeEdge.id, edgeKind: edgeKindOf(scene, homeEdge), vertical: axisOf(homeEdge.side) === \"column\", zone: zoneOf(item), order: 0, kind: \"home\", id: `home:${dragged}`, priority: 1, place: { kind: \"home\" }, hit: ownRect.rect, keep: null });\n\n // Filter (iii), clipping in precedence order: each tile clear of the ones before it, of the other edges' rects (with\n // the item lifted, and as they are now), of the fixed items that don't grow and of the chrome.\n const grows = (l: SceneLayout, id: string): boolean => {\n const it = l.items[id]!;\n const e = it.edge ? l.edges[it.edge] : undefined;\n return !!e && !!formsOf(scene.items[id]!, axisOf(e.side))[it.form]?.main.grows;\n };\n const solid = [...new Set([now, base])].flatMap((l) => Object.entries(l.items).filter(([id, it]) => it.fixed && !grows(l, id)).map(([, it]) => it.rect));\n // Panel bodies (an open item's), but for `hitBand / 2` at each end, aren't drop places of their edge.\n // Nor are its fixed items' reserved rects (a growing title's natural rect): each cut across the edge's whole band.\n const bodies = (id: string): Rect[] => {\n const e = rest.edges.find((x) => x.id === id);\n if (!e) return [];\n const column = axisOf(e.side) === \"column\";\n const across = (a: number, b: number): Rect => (column ? rect(-1e9, a, 2e9, b - a) : rect(a, -1e9, b - a, 2e9));\n const reserved = Object.entries(base.items)\n .filter(([iid, p]) => p.edge === id && p.fixed && !p.inMenu && !grows(base, iid))\n .map(([, p]) => (column ? across(p.rect.y, p.rect.y + p.rect.height) : across(p.rect.x, p.rect.x + p.rect.width)));\n return [...reserved, ...bodySpans(id).map(([a, b]) => across(a, b))].filter((b) => area(b) > EPS);\n };\n const placed: Tile[] = [];\n // A virtual edge's refused stretches (its refused slots, its slots' clipped-off pieces) come after every other tile:\n // they take only what no tile takes, never a real edge's room.\n const later: Tile[] = [];\n const clip = (r: Rect, cuts: readonly Rect[]): Rect[] => cuts.reduce<Rect[]>((ps, cut) => ps.flatMap((p) => subtract(p, cut)), [r]);\n // Where each owned part landed in `placed` (its overreach joins it there), and the slots whose owned part went whole.\n const landed = new Map<Tile, number[]>();\n const gone = new Set<Tile>();\n for (const t of [...tiles].sort((a, b) => a.order - b.order)) {\n // Home's tile is the item's own place: nothing clips it.\n if (t.order === 0) {\n placed.push(t);\n continue;\n }\n const data = EDGE_KINDS[t.edgeKind];\n if (data.virtual && t.kind === \"refuse\") {\n later.push(t);\n continue;\n }\n if (t.kind === \"reach\") {\n // Overreach: what the virtual edges and every other edge's owned rect leave, joined to its owned part where it\n // meets that part along the part's whole length. The rest is nobody's (the float's).\n const of = t.of!;\n const pieces = clip(t.hit, [...placed.map((p) => p.hit), ...owners.filter((o) => o.key !== t.key).map((o) => o.rect), ...bodies(t.edge), ...solid, ...chrome]);\n const at = landed.get(of) ?? [];\n if (at.length === 0 && gone.has(of)) {\n // Its owned part went whole: the overreach stands in for it, the piece on its line (else its largest).\n const line = t.vertical ? of.keep!.y : of.keep!.x;\n const on = pieces.filter((p) => (t.vertical ? p.y <= line + EPS && line <= p.y + p.height + EPS : p.x <= line + EPS && line <= p.x + p.width + EPS));\n const kept = (on.length > 0 ? on : pieces).reduce<Rect | null>((a, p) => (!a || area(p) > area(a) ? p : a), null);\n if (kept) {\n placed.push({ ...of, hit: kept });\n gone.delete(of);\n }\n continue;\n }\n for (const i of at) {\n const h = placed[i]!.hit;\n const joint = pieces.find((p) =>\n t.vertical\n ? p.y <= h.y + EPS && p.y + p.height >= h.y + h.height - EPS && (Math.abs(p.x - h.x - h.width) < EPS || Math.abs(p.x + p.width - h.x) < EPS)\n : p.x <= h.x + EPS && p.x + p.width >= h.x + h.width - EPS && (Math.abs(p.y - h.y - h.height) < EPS || Math.abs(p.y + p.height - h.y) < EPS),\n );\n if (!joint) continue;\n const merged = t.vertical\n ? rect(Math.min(h.x, joint.x), h.y, Math.max(h.x + h.width, joint.x + joint.width) - Math.min(h.x, joint.x), h.height)\n : rect(h.x, Math.min(h.y, joint.y), h.width, Math.max(h.y + h.height, joint.y + joint.height) - Math.min(h.y, joint.y));\n placed[i] = { ...placed[i]!, hit: merged };\n break;\n }\n continue;\n }\n // An owned part: clear of the tiles before it, of the owners that win over its edge, its panel bodies, solid items\n // and chrome. A virtual edge's tile: clear of the tiles before it and of every owner.\n const cuts = [...placed.map((p) => p.hit), ...(taken.get(t.key) ?? []), ...(data.virtual ? [] : bodies(t.edge)), ...solid, ...chrome];\n const pieces = clip(t.hit, cuts);\n if (pieces.length === 0) {\n if (t.kind !== \"refuse\") gone.add(t);\n continue;\n }\n if (t.kind === \"refuse\") {\n landed.set(t, pieces.map((_, k) => placed.length + k));\n for (const p of pieces) placed.push({ ...t, hit: p });\n continue;\n }\n // A slot keeps the piece that holds its line (else its largest); its other pieces are refused for its zone, a virtual\n // edge's as a real one's, so clipping never leaves a hole the float fills.\n const held = t.keep ? pieces.filter((p) => contains(p, t.keep!)) : [];\n const kept = (held.length > 0 ? held : pieces).reduce((a, p) => (area(p) > area(a) ? p : a));\n // No sliver: a slot left under 1 px along its edge is no target (its piece is refused).\n const sliver = (t.vertical ? kept.height : kept.width) < 1;\n if (!sliver) {\n landed.set(t, [placed.length]);\n placed.push({ ...t, hit: kept });\n }\n for (const p of pieces) if (sliver || p !== kept) (data.virtual ? later : placed).push({ ...t, kind: \"refuse\", reason: \"no-room\", hit: p, keep: null });\n }\n for (const t of gone) lost.push(t.id);\n for (const t of later) for (const p of clip(t.hit, [...placed.map((q) => q.hit), ...solid, ...chrome])) placed.push({ ...t, hit: p });\n\n const targets: SceneTarget[] = [];\n const refused: SceneRefusal[] = [];\n const homeAfter = (): SceneAfter => ({ scene, layout: now });\n // A zone's refusals are numbered by where they lie along the edge (then across it), not by clipping order, so a\n // refusal keeps its id from one frame to the next.\n const keyOf = (t: Tile): string => `refuse:${t.edge}:${t.zone}`;\n const pos = (t: Tile): [number, number] => (t.vertical ? [t.hit.y, t.hit.x] : [t.hit.x, t.hit.y]);\n const rank = new Map<Tile, number>();\n const byKey = new Map<string, Tile[]>();\n for (const t of placed) if (t.kind === \"refuse\") byKey.set(keyOf(t), [...(byKey.get(keyOf(t)) ?? []), t]);\n for (const group of byKey.values()) group.sort((a, b) => pos(a)[0] - pos(b)[0] || pos(a)[1] - pos(b)[1]).forEach((t, n) => rank.set(t, n));\n let ownHome: Rect | null = null;\n for (const t of placed) {\n if (t.kind === \"refuse\") {\n const n = rank.get(t)!;\n refused.push({ id: n === 0 ? keyOf(t) : `${keyOf(t)}:${n}`, edge: t.edge, zone: t.zone, hit: t.hit, reason: t.reason! });\n continue;\n }\n if (t.kind === \"home\") {\n if (t.order === 0) ownHome = t.hit;\n if (t.id === `home:${dragged}`) continue;\n targets.push({ id: t.id, priority: t.priority, hit: t.hit, item: dragged, place: { kind: \"home\" }, after: homeAfter });\n continue;\n }\n const result = t.result!;\n targets.push({ id: t.id, priority: t.priority, hit: t.hit, ...(t.slot ? { slot: t.slot } : {}), ...(t.marker ? { marker: t.marker } : {}), item: dragged, place: t.place!, after: () => result });\n }\n\n if (scene.floatKinds.includes(item.kind)) {\n const was = scene.floats.find((f) => f.id === dragged);\n const fo: Orient = options.floatOrient ?? was?.orient ?? floatOrientOf(item);\n const size = options.floatSize ?? (was ? { width: was.rect.width, height: was.rect.height } : floatSizeOf(item, fo));\n targets.push({\n id: `float:${dragged}`,\n priority: 3,\n free: true,\n hit: PLANE,\n item: dragged,\n place: { kind: \"float\" },\n after(point, grab) {\n const g = grab ?? { x: size.width / 2, y: size.height / 2 };\n const raw = rect(point.x - g.x, point.y - g.y, size.width, size.height);\n const first = solve(use(floatAt(scene, dragged, raw, options.floatOrient), dragged), prev);\n const at = first.items[dragged]?.rect ?? raw;\n return settle(use(floatAt(scene, dragged, rect(at.x, at.y, size.width, size.height), options.floatOrient), dragged));\n },\n });\n }\n\n // Filter (iv): `blocked` rects take the pointer and commit nothing.\n (scene.blocked ?? []).forEach((b, i) => {\n targets.push({ id: `none:${i}`, priority: 1, hit: rect(b.x, b.y, b.width, b.height), item: dragged, place: { kind: \"none\" }, after: homeAfter });\n });\n\n // `home:<id>`, for hosts that read it: over the item's own rect, inside home's tile (all of it when only it is home's).\n const own = now.items[dragged];\n if (own && !own.floating) targets.push({ id: `home:${dragged}`, priority: 1, hit: ownHome && !targets.some((t) => t.place.kind === \"home\") ? ownHome : own.rect, item: dragged, place: { kind: \"home\" }, after: homeAfter });\n return { targets, refusals: refused, lost };\n}\n\nexport function targets(scene: Scene, dragged: string, options: SceneTargetOptions = {}): SceneTarget[] {\n return generate(scene, dragged, options).targets;\n}\n\n/**\n * `refusals(scene, dragged, options?)`: the places a drop of `dragged` is refused, so a host can say so at the pointer\n * (a tint and \"No room here\") instead of showing a slot elsewhere: each slot the filter removed, over its own tile,\n * `not-accepted` where the edge or zone doesn't take the kind, `no-room` where the drop wouldn't fit. A release over a\n * refusal commits nothing: the item goes home.\n */\nexport function refusals(scene: Scene, dragged: string, options: SceneTargetOptions = {}): SceneRefusal[] {\n return generate(scene, dragged, options).refusals;\n}\n\n/**\n * `lostSlots(scene, dragged, options?)`: the ids of slots the filter kept, with room in their zone, that clipping left\n * with no hit. None: the property check holds it at zero.\n */\nexport function lostSlots(scene: Scene, dragged: string, options: SceneTargetOptions = {}): string[] {\n return generate(scene, dragged, options).lost;\n}\n\nconst SIDE_RANK: Record<string, number> = { left: 0, top: 1, bottom: 2, right: 3 };\n\n/**\n * `stops(scene, id, options?)`: the places for \"Move to ›\" and the arrow keys, in reading order, from the same targets\n * (`home` and `none` left out): the left side outer to inner, the top bars, the bottom bars, the right side inner to\n * outer, floating last. Each stop is a target, so its `after` is the move.\n */\nexport function stops(scene: Scene, dragged: string, options: SceneTargetOptions = {}): SceneTarget[] {\n const list = targets(scene, dragged, options).filter((t) => t.place.kind !== \"home\" && t.place.kind !== \"none\");\n const sideOf = (t: SceneTarget): string => {\n const p = t.place;\n if (p.kind === \"float\") return \"float\";\n if (p.kind === \"column\" || p.kind === \"rail\") return p.side;\n if (p.kind === \"gap\") return scene.edges.find((e) => e.id === p.edge)?.side ?? \"float\";\n return \"float\";\n };\n const key = (t: SceneTarget): [number, number, number] => {\n const side = sideOf(t);\n const r = t.slot ?? t.hit;\n const cx = r.x + r.width / 2;\n const cy = r.y + r.height / 2;\n const rank = side === \"float\" ? 4 : SIDE_RANK[side]!;\n return side === \"left\" ? [rank, cx, cy] : side === \"right\" ? [rank, -cx, cy] : [rank, cy * (side === \"bottom\" ? -1 : 1), cx];\n };\n return list\n .map((t, i) => ({ t, i, k: key(t) }))\n .sort((a, b) => a.k[0] - b.k[0] || a.k[1] - b.k[1] || a.k[2] - b.k[2] || a.i - b.i)\n .map((x) => x.t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAeO,I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