@n-uf/placement 26.11.24 → 26.11.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +74 -0
- package/README.md +66 -28
- package/dist/{chunk-LPMZ2FFR.js → chunk-3P6VOXA6.js} +2 -2
- package/dist/chunk-3P6VOXA6.js.map +1 -0
- package/dist/{chunk-CJA6LRHN.js → chunk-7ASCUAGV.js} +5 -7
- package/dist/chunk-7ASCUAGV.js.map +1 -0
- package/dist/{chunk-RL3QB5SM.js → chunk-KGZCYLQN.js} +10 -10
- package/dist/chunk-KGZCYLQN.js.map +1 -0
- package/dist/{chunk-2H3CSPEH.js → chunk-OYGOJWAX.js} +2 -2
- package/dist/{chunk-XUC5BU4N.js → chunk-SZKU7CRX.js} +575 -499
- package/dist/chunk-SZKU7CRX.js.map +1 -0
- package/dist/chunk-WM5FJ3IS.js +47 -0
- package/dist/chunk-WM5FJ3IS.js.map +1 -0
- package/dist/{constructions-VDK_mwmz.d.ts → constructions-DSEjvWMP.d.ts} +1 -1
- package/dist/desk.d.ts +3 -3
- package/dist/desk.js +3 -3
- package/dist/dock.d.ts +3 -3
- package/dist/dock.js +2 -2
- package/dist/geometry-CkZ6Fcfb.d.ts +48 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +21 -3
- package/dist/index.js.map +1 -1
- package/dist/{model-DPTu2EtG.d.ts → model-mm16NrSX.d.ts} +1 -1
- package/dist/panels.d.ts +5 -4
- package/dist/panels.js +6 -5
- package/dist/scene-cases.d.ts +4 -4
- package/dist/scene-cases.js +15 -16
- package/dist/scene-cases.js.map +1 -1
- package/dist/scene.d.ts +5 -39
- package/dist/scene.js +3 -3
- package/dist/stack.d.ts +4 -4
- package/dist/stack.js +2 -2
- package/dist/stack.js.map +1 -1
- package/dist/{target-D3PiLg44.d.ts → target-C-HJjPcz.d.ts} +1 -1
- package/dist/{targets-B6eLC-52.d.ts → targets-CBpO_LEy.d.ts} +4 -6
- package/dist/{targets-DwwIWPpN.d.ts → targets-CDR5Towj.d.ts} +74 -60
- package/dist/targets.d.ts +4 -4
- package/dist/targets.js +6 -7
- package/dist/targets.js.map +1 -1
- package/dist/toolbar.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunk-CJA6LRHN.js.map +0 -1
- package/dist/chunk-LPMZ2FFR.js.map +0 -1
- package/dist/chunk-QMTNB2C3.js +0 -17
- package/dist/chunk-QMTNB2C3.js.map +0 -1
- package/dist/chunk-RL3QB5SM.js.map +0 -1
- package/dist/chunk-XUC5BU4N.js.map +0 -1
- package/dist/geometry-mL-GTRti.d.ts +0 -28
- /package/dist/{chunk-2H3CSPEH.js.map → chunk-OYGOJWAX.js.map} +0 -0
|
@@ -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. A group never opens such a column on its own: an empty edge offers its strip only to the kinds its start\n * zone takes.\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). */\n readonly rails: Readonly<Partial<Record<\"left\" | \"right\", SceneRailLayout>>>;\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 { 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\";\n\nconst EPS = 1e-6;\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. */\nexport function 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\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. */\nexport function 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 */\nexport function 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. */\nexport function 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 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 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 (!railRect && railed.length > 0 && !outsideSideBar(c)) {\n const w = railW(side);\n const lead = barLaid ? gap : 0;\n const after = barLaid ? Math.max(gap, gutter) : gutter;\n if (side === \"left\") {\n railRect = rect(x0 - lead, area.y, w, H);\n x0 += w - lead + after;\n } else {\n railRect = rect(x1 + lead - w, area.y, w, H);\n x1 -= w - lead + after;\n }\n gap = after;\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 }\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, ...(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. */\nexport const 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 */\nexport function 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 * - `gap:<edge>:<zone>:<at>` (priority 2): for every edge whose `accepts` lists the dragged item's kind (deny by\n * default, C25), a target before the `at`-th item of each zone (start, center, end) and at each zone's end, so an\n * empty center or end zone can be opened. Only where the item fits (C29): after the drop it isn't in the » menu, the\n * edge doesn't overflow, nothing in the edge is newly `too-wide`, every fixed item of the edge keeps its form and its\n * place (a growing one may give up its spare length), and its slot covers no chrome. The hit is the edge's stretch\n * between the neighbouring gaps (split halfway between their insertion lines; over an open item's body only a\n * `hitBand` around the line), across the larger of the edge's thickness before and after the drop (a compact edge's\n * reaching `RAIL_REACH` further inward), the first and last reaching `endReach` px past the edge's ends. Other edges'\n * rects, as they are now and with the item lifted, trim it: one across from the edge at its end along the edge, one\n * beside it at its side. It is cut clear of every fixed item that doesn't grow and of the chrome rects (a gap whose\n * line lies inside one has no target); a growing fixed item (a title) is not cut out, so a pointer over it picks the\n * nearest gap. `marker` is the insertion line after the drop, across the edge; `slot` the item's rect after the drop.\n * A horizontal bar (top or bottom, not compact) has a hit per zone by thirds: its left third is the leading (start)\n * zone's, the middle the center zone's, the right the trailing (end) zone's, each split among its own gaps (their\n * lines taken inside the third). A title bar (a bar with a fixed item that grows) is a constrained host: a gap there\n * is a target only when the item lands in its first form, nothing in the bar changes form for it, and the title keeps\n * its natural width.\n * - `strip:<bar>:<zone>` (2): an empty horizontal bar that accepts the kind: its strip along the content in thirds, one\n * target per zone that takes the kind.\n * - `strip:<edge>` (2): an empty edge that accepts the kind (its start zone takes it): a strip `Edge.strip` px (default\n * 24) deep along its side, inside the content and clear of overlay edges, so never over a docked edge or a panel's\n * body (a compact rail's strip alone stays at the window edge, its own place); a gap hit that spans it trims its ends,\n * and under 1 px left it has no target. Home covers all of the dragged item's own rect: a strip (a `rail:` strip\n * too) keeps only what lies outside it. `after` shows the edge holding the item.\n * - `float:<id>` (3, free): when `floatKinds` lists the kind. The hit covers the whole plane; the landing is the float\n * with the pointer holding it at `grab` (default its middle), in the stage and clear of the docked items, the bars\n * and the chrome. Its orient: `options.floatOrient`, else its float's, else the item's (`floatOrientOf`). Its size:\n * `options.floatSize`, else its float's size, else `floatSizeOf` (the item's `floatSize`, else its form's natural\n * size along that orient, else the default).\n * - `column:<side>:<ring>` (2): 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), `COLUMN_REACH` px each way, only where the new column shows open.\n * - `rail:<side>:<ring>` (1): 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 a strip `RAIL_EDGE` px deep where the rail lands (flush after its\n * outside toolbar bars, `isOutsideSideBar`, else at the window's side less the inset) when no rail shows.\n * - `none:<i>` (1): over each `scene.blocked` rect. It takes the pointer, and a release there commits nothing.\n * - `home:<id>` (1): over a docked item's own rect (or its » entry); a floating item has none, so a move inside its own\n * rect is a float move. A release there commits nothing. A gap, column line or rail drop that\n * would put the item back where it is (the gap beside it, its own column's line, its own side's rail) keeps its id but\n * is a home too: place `home`, no slot, nothing committed.\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 { rect, type Point, type Rect, type Size } from \"../geometry\";\nimport type { Target } from \"../targets/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, isOutsideSideBar, zoneOf, zoneTakes, zonesTaking, type Edge, type Orient, type Scene, type SceneLayout, type Zone } from \"./model\";\nimport { solve } from \"./solve\";\n\nconst ZONE_ORDER: Record<Zone, number> = { start: 0, center: 1, end: 2 };\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\nconst EPS = 1e-6;\n/** A zone that covers any pointer the page can see. */\nexport const PLANE: Rect = rect(-1e9, -1e9, 2e9, 2e9);\n\nconst area = (r: Rect): number => Math.max(0, r.width) * Math.max(0, r.height);\nconst overlaps = (a: Rect, b: Rect): boolean => Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x) > EPS && Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y) > EPS;\nconst contains = (r: Rect, p: Point): boolean => p.x >= r.x - EPS && p.x <= r.x + r.width + EPS && p.y >= r.y - EPS && p.y <= r.y + r.height + EPS;\n\n/** How far a compact rail's gap hits reach inward past the rail, px. */\nconst RAIL_REACH = 24;\n\n/** `hit` with every blocker cut out: for each blocker it overlaps, the largest of the four parts beside it. Null when nothing is left. */\nexport function cutAway(hit: Rect, blockers: readonly Rect[]): Rect | null {\n let h = hit;\n for (const b of blockers) {\n if (!overlaps(h, b)) continue;\n const right = h.x + h.width;\n const bottom = h.y + h.height;\n const parts = [\n rect(h.x, h.y, Math.min(right, b.x) - h.x, h.height),\n rect(Math.max(h.x, b.x + b.width), h.y, right - Math.max(h.x, b.x + b.width), h.height),\n rect(h.x, h.y, h.width, Math.min(bottom, b.y) - h.y),\n rect(h.x, Math.max(h.y, b.y + b.height), h.width, bottom - Math.max(h.y, b.y + b.height)),\n ].filter((p) => area(p) > EPS);\n if (parts.length === 0) return null;\n h = parts.reduce((a, p) => (area(p) > area(a) ? p : a));\n }\n return area(h) > EPS ? h : null;\n}\n\n/**\n * `hit` with every blocker cut out: for each blocker it overlaps, the largest of the four parts beside the blocker that\n * still holds `keep`. Null when `keep` is inside a blocker or nothing is left.\n */\nexport function cutClear(hit: Rect, blockers: readonly Rect[], keep: Point): Rect | null {\n let h = hit;\n for (const b of blockers) {\n if (!overlaps(h, b)) continue;\n const right = h.x + h.width;\n const bottom = h.y + h.height;\n const parts = [\n rect(h.x, h.y, Math.min(right, b.x) - h.x, h.height),\n rect(Math.max(h.x, b.x + b.width), h.y, right - Math.max(h.x, b.x + b.width), h.height),\n rect(h.x, h.y, h.width, Math.min(bottom, b.y) - h.y),\n rect(h.x, Math.max(h.y, b.y + b.height), h.width, bottom - Math.max(h.y, b.y + b.height)),\n ].filter((p) => area(p) > EPS && contains(p, keep));\n if (parts.length === 0) return null;\n h = parts.reduce((a, p) => (area(p) > area(a) ? p : a));\n }\n return area(h) > EPS ? h : null;\n}\n\n/** The least a gap keeps along its edge where home takes its place: this much, or all its slice when shorter (px). */\nconst GAP_KEEP = 16;\n\n/**\n * Home is offered only over the item's own place: its hit is the item's rect and half a band (`DEFAULT_HIT_BAND / 2`)\n * each way along the edge, across the full thickness of its gaps' hits, wherever the home gaps' slices were. Home never\n * removes a gap: every other gap hit on that edge it would cover keeps at least `GAP_KEEP` px of its slice (or all of\n * it, when shorter), at home's end, or for one inside the item's own rect at its own place (beside the item's centre,\n * which home always keeps), and home gives that up. The rest of the home gaps' slices goes to the gap beside it in the\n * same zone (each extended to meet it, never over another gap); a stretch with no such neighbour has no target (a\n * pointer there shows nothing, and a release goes home), and home never grows back over it.\n */\nfunction homeOnlyOverItsPlace(out: SceneTarget[], now: SceneLayout): void {\n const dragged = out[0]?.item;\n const mine = dragged !== undefined ? now.items[dragged] : undefined;\n const side = mine?.edge ? now.edges[mine.edge]?.side : undefined;\n if (!mine || !side) return;\n const column = side === \"left\" || side === \"right\";\n const r = mine.rect;\n const band = DEFAULT_HIT_BAND / 2;\n const edgeOf = (t: SceneTarget): string | undefined => (t.id.startsWith(\"gap:\") ? t.id.split(\":\")[1] : undefined);\n const zoneOfId = (t: SceneTarget): string | undefined => (t.id.startsWith(\"gap:\") ? t.id.split(\":\")[2] : undefined);\n const span = (x: SceneTarget): [number, number] => (column ? [x.hit.y, x.hit.y + x.hit.height] : [x.hit.x, x.hit.x + x.hit.width]);\n const cross = (x: SceneTarget): [number, number] => (column ? [x.hit.x, x.hit.x + x.hit.width] : [x.hit.y, x.hit.y + x.hit.height]);\n const make = (x: SceneTarget, from: number, to: number, c?: [number, number]): SceneTarget => {\n const [c0, c1] = c ?? cross(x);\n return { ...x, hit: column ? rect(c0, from, c1 - c0, to - from) : rect(from, c0, to - from, c1 - c0) };\n };\n const homes = out.filter((t) => t.place.kind === \"home\" && edgeOf(t) === mine.edge);\n const mid = column ? r.y + r.height / 2 : r.x + r.width / 2;\n let h0 = (column ? r.y : r.x) - band;\n let h1 = (column ? r.y + r.height : r.x + r.width) + band;\n const c0 = Math.min(...homes.map((h) => cross(h)[0]));\n const c1 = Math.max(...homes.map((h) => cross(h)[1]));\n const first = homes[0];\n // One home target, where the first home gap was in the list (none when no gap beside the item is its home: the\n // `home:<id>` target over its rect is, and the gaps are still kept clear of the item's centre).\n for (const h of homes.slice(1)) out.splice(out.indexOf(h), 1);\n const at = first ? out.indexOf(first) : -1;\n if (first) out.splice(at, 1);\n // Every other gap on the edge that home would cover keeps a slice of its own, and home gives it up.\n for (let i = 0; i < out.length; i++) {\n const x = out[i]!;\n if (x.place.kind !== \"gap\" || edgeOf(x) !== mine.edge) continue;\n const [s0, s1] = span(x);\n if (s1 <= h0 + EPS || s0 >= h1 - EPS) continue;\n const keep = Math.min(GAP_KEEP, s1 - s0);\n if (s0 < h0) {\n // Across home's start: it keeps what lies before home, and at least `keep`.\n const e = Math.min(s1, Math.max(h0, s0 + keep));\n out[i] = make(x, s0, e);\n h0 = Math.max(h0, e);\n } else if (s1 > h1) {\n const b = Math.max(s0, Math.min(h1, s1 - keep));\n out[i] = make(x, b, s1);\n h1 = Math.min(h1, b);\n } else {\n // Inside home: a slice at its own place, never over the item's centre.\n // At its own line (where its marker says the item would land), within its slice.\n const line = x.marker ? (column ? x.marker.y : x.marker.x) : (s0 + s1) / 2;\n let a = Math.min(Math.max(line - keep / 2, s0), s1 - keep);\n // Over the centre: moved just beside it, on the side its slice mostly lies.\n if (a <= mid + 1 && a + keep >= mid - 1) a = (s0 + s1) / 2 < mid ? mid - 1 - keep : mid + 1;\n out[i] = make(x, a, a + keep);\n if (a + keep <= mid + EPS) h0 = Math.max(h0, a + keep);\n else h1 = Math.min(h1, a);\n }\n }\n // What each home slice gives up goes to its same-zone neighbour that meets it there (never over another gap), else\n // to nothing.\n const others = (x: SceneTarget) => out.filter((y) => y !== x && y.place.kind === \"gap\" && edgeOf(y) === mine.edge).map(span);\n for (const h of homes) {\n const [a0, a1] = span(h);\n const near = out.filter((x) => x.place.kind === \"gap\" && edgeOf(x) === mine.edge && zoneOfId(x) === zoneOfId(h));\n const before = near.find((x) => Math.abs(span(x)[1] - a0) < 1);\n const after = near.find((x) => Math.abs(span(x)[0] - a1) < 1);\n if (before && a0 < h0 - EPS) {\n const stop = Math.min(a1, h0, ...others(before).filter(([b]) => b >= span(before)[1] - EPS).map(([b]) => b));\n if (stop > span(before)[1]) out[out.indexOf(before)] = make(before, span(before)[0], stop);\n }\n if (after && a1 > h1 + EPS) {\n const stop = Math.max(a0, h1, ...others(after).filter(([, e]) => e <= span(after)[0] + EPS).map(([, e]) => e));\n if (stop < span(after)[0]) out[out.indexOf(after)] = make(after, stop, span(after)[1]);\n }\n }\n if (first && h1 - h0 > EPS) out.splice(Math.min(at, out.length), 0, make(first, h0, h1, [c0, c1]));\n}\n\nexport function targets(scene: Scene, dragged: string, options: SceneTargetOptions = {}): SceneTarget[] {\n const item = Object.hasOwn(scene.items, dragged) ? scene.items[dragged] : undefined;\n if (!item || item.fixed || item.closed) return [];\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 reach = Math.max(0, Number.isFinite(options.endReach) ? options.endReach! : 0);\n const chrome = scene.chrome ?? [];\n // No hit covers a non-growing fixed item (window controls, a readout) of any edge, where it is drawn now and with the\n // item lifted out, nor chrome. A growing fixed item (a title filling its bar) may lie under hits: the pointer over it\n // picks the nearest gap (just after it). The slot never covers any fixed item's reserved rect (`sound`), and a drop\n // shrinks a growing one toward its natural size (to its `min` if the room needs it).\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 fixedRects = (l: SceneLayout): Rect[] => Object.entries(l.items).filter(([id, it]) => it.fixed && !grows(l, id)).map(([, it]) => it.rect);\n const blockers = [...fixedRects(now), ...fixedRects(base), ...chrome];\n const out: SceneTarget[] = [];\n\n const docked: SceneTarget[] = [];\n for (const edge of rest.edges) {\n if (!edge.accepts.includes(item.kind)) continue;\n docked.push(...edgeTargets(scene, rest, now, base, edge, dragged, reach, blockers, chrome, settle));\n }\n for (const side of [\"left\", \"right\"] as const) {\n // A new column only for kinds its template's start zone takes: a group never opens a panel column on its own.\n const template = scene.columns?.[side];\n if (!template || !zoneTakes(template, \"start\", item.kind)) continue;\n docked.push(...columnTargets(scene, rest, base, side, dragged, blockers, settle));\n if (scene.rails?.[side]?.accepts.includes(item.kind)) docked.push(...railTargets(scene, rest, base, side, dragged, blockers, settle));\n }\n // A drop that puts the item back where it is (the gap beside it, its own column's line, its own rail) is its home: it\n // commits nothing and shows no slot.\n const here = placeKey(scene, dragged);\n const ownRail = now.items[dragged]?.rail;\n // C29 across the whole scene: a drop may not add an `overflow` or `too-wide` note to any edge, change any fixed item's\n // form, or squeeze one under its `main.min`, anywhere; nor land on chrome.\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 // Its least length: `main.min`, or a wrap form's rows at the edge's cross size.\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 // The slot never lies over chrome, nor over a fixed item's reserved (natural) rect after the drop.\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 for (const t of docked) {\n const p = t.place;\n const own = (p.kind === \"rail\" && p.side === ownRail) || placeKey(t.after({ x: 0, y: 0 }).scene, dragged) === here;\n if (own) out.push({ id: t.id, priority: t.priority, hit: t.hit, item: dragged, place: { kind: \"home\" }, after: () => ({ scene, layout: now }) });\n else if (sound(t.after({ x: 0, y: 0 }).layout)) out.push(t);\n }\n homeOnlyOverItsPlace(out, now);\n // A compact rail's inward reach never covers another edge's gap (a column's tray, say): where it would, the hit keeps\n // only the rail's own thickness.\n const edgeOfGap = (t: SceneTarget): Edge | undefined => (t.place.kind === \"gap\" ? rest.edges.find((e) => e.id === (t.place as { edge: string }).edge) : undefined);\n const plainGapHits = out.filter((t) => t.id.startsWith(\"gap:\") && !edgeOfGap(t)?.compact).map((t) => t.hit);\n for (let i = 0; i < out.length; i++) {\n const t = out[i]!;\n const e = edgeOfGap(t);\n if (!t.id.startsWith(\"gap:\") || !e?.compact || !plainGapHits.some((h) => overlaps(h, t.hit))) continue;\n const h = t.hit;\n const core =\n e.side === \"left\"\n ? rect(h.x, h.y, h.width - RAIL_REACH, h.height)\n : e.side === \"right\"\n ? rect(h.x + RAIL_REACH, h.y, h.width - RAIL_REACH, h.height)\n : e.side === \"top\"\n ? rect(h.x, h.y, h.width, h.height - RAIL_REACH)\n : rect(h.x, h.y + RAIL_REACH, h.width, h.height - RAIL_REACH);\n out[i] = { ...t, hit: core };\n }\n // An empty edge's strip lies inside the content (a full-span bar's edge rect runs over the columns; its strip never\n // does), and never swallows a gap: a gap hit spanning it across trims its start or end (a bar's strip along the top\n // would otherwise cover the columns' first gaps); a gap across its middle is left to the smaller-hit tie-break, so a\n // strip with room is never cut down to a part. A strip with nothing left has no target.\n const gapHits = out.filter((t) => t.id.startsWith(\"gap:\")).map((t) => t.hit);\n const c = base.content;\n for (let i = out.length - 1; i >= 0; i--) {\n const t = out[i]!;\n const e = edgeOfGap(t);\n if (!t.id.startsWith(\"strip:\") || !e) continue;\n const vertical = e.side === \"left\" || e.side === \"right\";\n const x0 = Math.max(t.hit.x, c.x);\n const y0 = Math.max(t.hit.y, c.y);\n const x1 = Math.min(t.hit.x + t.hit.width, c.x + c.width);\n const y1 = Math.min(t.hit.y + t.hit.height, c.y + c.height);\n // Nor over an overlay edge lying on the content (where an empty bar runs under an overlay column).\n const docks = [...Object.entries(base.edges), ...Object.entries(now.edges).filter(([id]) => id !== now.items[dragged]?.edge)]\n .filter(([id, d]) => id !== e.id && area(d.rect) > EPS)\n .map(([, d]) => d.rect);\n // Nor over the dragged item's own place: home always covers all of the item's own rect. A strip there keeps only\n // what lies outside it (at home's end), never a slice through home; the strip of the item's own edge, which the\n // item alone fills, then means home anyway, and what is left of it under 1 px has no target (below).\n const mineNow = now.items[dragged];\n if (mineNow?.edge && !mineNow.floating) docks.push(mineNow.rect);\n // A compact rail's strip stays at the window edge, outside the columns it lies beyond (as a rail target's strip does\n // while no rail shows): that thin stretch along the window's side is the rail's own.\n const h = e.compact ? t.hit : x1 - x0 > EPS && y1 - y0 > EPS ? cutAway(rect(x0, y0, x1 - x0, y1 - y0), docks) : null;\n if (!h) {\n out.splice(i, 1);\n continue;\n }\n let [a0, a1] = vertical ? [h.y, h.y + h.height] : [h.x, h.x + h.width];\n for (const g of gapHits) {\n if (!overlaps(g, h)) continue;\n // Only a gap that spans the strip across trims it; a thinner one overlapping it wins by the tie-break.\n const spans = vertical ? g.x <= h.x + EPS && g.x + g.width >= h.x + h.width - EPS : g.y <= h.y + EPS && g.y + g.height >= h.y + h.height - EPS;\n if (!spans) continue;\n const [g0, g1] = vertical ? [g.y, g.y + g.height] : [g.x, g.x + g.width];\n if (g0 <= a0 + EPS && g1 > a0) a0 = Math.min(a1, g1);\n else if (g1 >= a1 - EPS && g0 < a1) a1 = Math.max(a0, g0);\n }\n // No sliver: a strip under 1 px along its edge has no target.\n if (a1 - a0 < 1) out.splice(i, 1);\n else {\n const hit = vertical ? rect(h.x, a0, h.width, a1 - a0) : rect(a0, h.y, a1 - a0, h.height);\n if (hit.x !== t.hit.x || hit.y !== t.hit.y || hit.width !== t.hit.width || hit.height !== t.hit.height) out[i] = { ...t, hit };\n }\n }\n // A rail's strip (no rail shown) never lies over the dragged item's own rect either: home covers all of it. Cut clear\n // of it, under 1 px across, it has no target.\n const mineHere = now.items[dragged];\n if (mineHere?.edge && !mineHere.floating) {\n for (let i = out.length - 1; i >= 0; i--) {\n const t = out[i]!;\n if (t.place.kind !== \"rail\" || !overlaps(t.hit, mineHere.rect)) continue;\n const h = cutAway(t.hit, [mineHere.rect]);\n if (!h || h.width < 1 || h.height < 1) out.splice(i, 1);\n else out[i] = { ...t, hit: h };\n }\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 out.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 (scene.blocked ?? []).forEach((b, i) => {\n out.push({ id: `none:${i}`, priority: 1, hit: rect(b.x, b.y, b.width, b.height), item: dragged, place: { kind: \"none\" }, after: () => ({ scene, layout: now }) });\n });\n\n // A docked item's own place is its home. A floating item has none: a move inside its own rect is a float move.\n const own = now.items[dragged];\n if (own && !own.floating) out.push({ id: `home:${dragged}`, priority: 1, hit: own.rect, item: dragged, place: { kind: \"home\" }, after: () => ({ scene, layout: now }) });\n return out;\n}\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/** Where things are, without ages or the ids of dynamic columns: two scenes with one key place every item alike. */\nfunction placeKey(s: Scene, id: string): string {\n const it = Object.hasOwn(s.items, id) ? s.items[id] : undefined;\n return JSON.stringify({\n edges: s.edges.map((e) => JSON.stringify([e.side, e.ring, e.column === true ? \"\" : e.id, 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/** How far a column line's hit reaches on each side of the line, px; how deep a side's edge takes a rail drop when it has no rail. */\nexport const COLUMN_REACH = 22;\nexport const RAIL_EDGE = 10;\n\n/** The open dynamic columns of a side in `base`, outer first, with their ring in `rest`. */\nfunction openColumns(rest: Scene, base: SceneLayout, side: \"left\" | \"right\"): { edge: Edge; r: Rect }[] {\n return 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}\n\n/** The side's columns' stretch down the stage: the open columns', else the content's. */\nfunction sideSpan(base: SceneLayout, side: \"left\" | \"right\"): { y: number; height: number } {\n const own = Object.values(base.edges).filter((e) => e.side === side && e.rect.height > 0);\n const r = own[0]?.rect ?? base.content;\n return { y: r.y, height: r.height };\n}\n\n/**\n * `column:<side>:<ring>` (priority 2): a new column on every column line of a side (outside its outermost open column,\n * between two, inside the innermost; on a side with none, at the content's edge), when `scene.columns[side]` takes the\n * kind. The hit is `COLUMN_REACH` px on each side of the line, down the columns' stretch. Only where the new column\n * shows open.\n */\nfunction columnTargets(scene: Scene, rest: Scene, base: SceneLayout, side: \"left\" | \"right\", dragged: string, blockers: readonly Rect[], settle: (s: Scene) => SceneAfter): SceneTarget[] {\n const cols = openColumns(rest, base, side);\n const span = sideSpan(base, side);\n // Rings as the side's edges lie (no ties): a static edge outer to the columns keeps its place, so no line offers a\n // ring outside it (`insertColumn` keeps a new column inside it).\n const rings = sideRings(rest.edges, side);\n const ringOf = (e: Edge): number => rings.get(e.id) ?? e.ring;\n const inner = rings.size;\n const lines: { x: number; ring: 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 cols.forEach((c) => lines.push({ x: outerX(c.r), ring: ringOf(c.edge) }));\n if (cols.length > 0) lines.push({ x: innerX(cols[cols.length - 1]!.r), ring: ringOf(cols[cols.length - 1]!.edge) + 1 });\n else lines.push({ x: side === \"left\" ? base.content.x : base.content.x + base.content.width, ring: inner });\n const out: SceneTarget[] = [];\n for (const line of lines) {\n const place: ColumnPlace = { kind: \"column\", side, ring: line.ring };\n const result = settle(use(moveTo(scene, dragged, place), dragged));\n const me = result.layout.items[dragged];\n const el = me?.edge ? result.layout.edges[me.edge] : undefined;\n if (!me || !el || me.inMenu || el.folded || el.rides || result.scene === scene) continue;\n const keep = { x: line.x, y: span.y + span.height / 2 };\n const hit = cutClear(rect(line.x - COLUMN_REACH, span.y, 2 * COLUMN_REACH, span.height), blockers, keep);\n if (!hit) continue;\n out.push({ id: `column:${side}:${line.ring}`, priority: 2, hit, slot: me.rect, marker: rect(line.x, span.y, 0, span.height), item: dragged, place, after: () => result });\n }\n return out;\n}\n\n/**\n * `rail:<side>:<ring>` (priority 1): docking folded into the side's rail, when its rail and its column template take the\n * kind: before each folded column's segments and after the last (the rail split halfway between them), or, with no\n * rail shown, a strip `RAIL_EDGE` px deep where the rail lands (after the side's outside toolbar bars). The drop makes a column at that ring with the item\n * folded by hand, so it lands as a segment.\n */\nfunction railTargets(scene: Scene, rest: Scene, base: SceneLayout, side: \"left\" | \"right\", dragged: string, blockers: readonly Rect[], settle: (s: Scene) => SceneAfter): SceneTarget[] {\n const rail = base.rails[side];\n // Rings as the side's edges lie (no ties), as `insertColumn` counts them.\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 span = sideSpan(base, side);\n const firstCol = mine.find((e) => e.column === true);\n // Where `solve` lays the rail: flush after the side's bars outside the inset when it has any (they lie outermost),\n // else at the window's side less the inset.\n const bars = new Set(rest.edges.filter((e) => e.side === side && isOutsideSideBar(rest, e)).map((e) => e.id));\n const inner = Object.entries(base.edges)\n .filter(([id, e]) => bars.has(id) && e.rect.height > 0 && e.rect.width > 0)\n .map(([, e]) => (side === \"left\" ? e.rect.x + e.rect.width : e.rect.x));\n const pad = Number.isFinite(rest.inset?.[side]) ? Math.max(0, rest.inset![side]!) : 0;\n const x =\n inner.length > 0\n ? side === \"left\"\n ? Math.max(...inner)\n : Math.min(...inner)\n : side === \"left\"\n ? rest.stage.x + pad\n : rest.stage.x + rest.stage.width - pad;\n zone = rect(side === \"left\" ? x : x - RAIL_EDGE, span.y, RAIL_EDGE, span.height);\n stops.push({ y: span.y, ring: firstCol ? ringOf(firstCol.id) : mine.length });\n }\n const out: SceneTarget[] = [];\n stops.forEach((s, i) => {\n const from = i === 0 ? zone.y : (stops[i - 1]!.y + s.y) / 2;\n const to = i === stops.length - 1 ? zone.y + zone.height : (s.y + stops[i + 1]!.y) / 2;\n if (to - from <= EPS) return;\n const place: RailPlace = { kind: \"rail\", side, ring: s.ring };\n const result = settle(use(moveTo(scene, dragged, place), dragged));\n const me = result.layout.items[dragged];\n if (!me || me.rail !== side || result.scene === scene) return;\n const hit = cutClear(rect(zone.x, from, zone.width, to - from), blockers, { x: zone.x + zone.width / 2, y: Math.min(Math.max(s.y, from), to) });\n if (!hit) return;\n out.push({ id: `rail:${side}:${s.ring}`, priority: 1, hit, slot: me.rect, marker: rect(zone.x, me.rect.y, zone.width, 0), item: dragged, place, after: () => result });\n });\n return out;\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 /** `refuse:<edge>:<zone>`. */\n readonly id: string;\n readonly edge: string;\n readonly zone: Zone;\n /** Where the pointer means it; never over a target's hit. */\n readonly hit: Rect;\n /** `no-room`: the zone takes the kind, but no gap of it fits (a title bar at the title's natural width, say). `not-accepted`: the edge or zone doesn't take the kind. */\n readonly reason: \"no-room\" | \"not-accepted\";\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. A bar's zone (its third, as `targets` picks zones)\n * that has no target is refused: `no-room` when the zone takes the kind, `not-accepted` when it or the bar doesn't; a\n * left or right edge that doesn't take the kind is refused as a whole (zone `start`). Each hit is cut clear of every\n * target's hit (the float target aside), so a pointer over one has no target there but the float. A release over a\n * refusal commits nothing: the item goes home.\n */\nexport function refusals(scene: Scene, dragged: string, options: SceneTargetOptions = {}): SceneRefusal[] {\n const item = Object.hasOwn(scene.items, dragged) ? scene.items[dragged] : undefined;\n if (!item || item.fixed || item.closed) return [];\n const prev = { ...(options.previous ? { previous: options.previous } : {}), ...(options.fresh ? { fresh: options.fresh } : {}) };\n const ts = targets(scene, dragged, options).filter((t) => !t.free);\n const base = solve(lift(scene, dragged), prev);\n const hits = ts.map((t) => t.hit);\n const out: SceneRefusal[] = [];\n const add = (edge: string, zone: Zone, hit: Rect, reason: SceneRefusal[\"reason\"]): void => {\n const clear = cutAway(hit, hits);\n if (clear) out.push({ id: `refuse:${edge}:${zone}`, edge, zone, hit: clear, reason });\n };\n for (const e of scene.edges) {\n const r = base.edges[e.id]?.rect;\n if (!r || r.width <= EPS || r.height <= EPS) continue;\n const bar = (e.side === \"top\" || e.side === \"bottom\") && !e.compact;\n if (!bar) {\n if (!e.accepts.includes(item.kind)) add(e.id, \"start\", r, \"not-accepted\");\n continue;\n }\n ZONES.forEach((zone, k) => {\n const third = rect(r.x + (r.width * k) / 3, r.y, r.width / 3, r.height);\n const mine = ts.some((t) => (t.place.kind === \"gap\" || t.place.kind === \"home\") && t.id.startsWith(`gap:${e.id}:`) && overlaps(t.hit, third));\n if (mine) return;\n add(e.id, zone, third, zoneTakes(e, zone, item.kind) ? \"no-room\" : \"not-accepted\");\n });\n }\n return out;\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\n/** One edge's gap or strip targets. `rest` is the scene with the dragged item lifted out and `base` its layout. */\nfunction edgeTargets(scene: Scene, rest: Scene, now: SceneLayout, base: SceneLayout, edge: Edge, dragged: string, reach: number, blockers: readonly Rect[], chrome: readonly Rect[], settle: (s: Scene) => SceneAfter): SceneTarget[] {\n const el = base.edges[edge.id];\n // A folded or riding column takes drops through its side's rail and column lines, not gaps.\n if (!el || el.folded || el.rides) return [];\n const column = axisOf(edge.side) === \"column\";\n const restEdge = rest.edges.find((e) => e.id === edge.id)!;\n const fixedIds = restEdge.items.filter((id) => rest.items[id]?.fixed && base.items[id]?.edge === edge.id);\n const tooWideBefore = new Set(base.notes.flatMap((n) => (\"edge\" in n && n.edge === edge.id && n.code === \"too-wide\" ? [n.id] : [])));\n // A bar's leading, center and trailing zones are picked by thirds of the bar (Revision 8).\n const thirds = !column && !edge.compact;\n const natural = (id: string, form: number): number => {\n const f = formsOf(scene.items[id]!, \"row\")[form];\n return f ? formMain(f, \"natural\", el.cross) : 0;\n };\n // A title bar: a bar with a fixed item that grows (the title).\n const titles = thirds ? fixedIds.filter((id) => !!formsOf(scene.items[id]!, \"row\")[base.items[id]!.form]?.main.grows) : [];\n const titled = titles.length > 0;\n\n /** Whether a drop's layout leaves room for the item in this edge (C29). */\n const fits = (after: SceneLayout): boolean => {\n const me = after.items[dragged];\n if (!me || me.edge !== edge.id || me.inMenu) return false;\n for (const n of after.notes) {\n if (!(\"edge\" in n) || n.edge !== edge.id) continue;\n if (n.code === \"overflow\") return false;\n if (n.code === \"too-wide\" && !tooWideBefore.has(n.id)) return false;\n }\n for (const id of fixedIds) {\n const a = after.items[id];\n const b = base.items[id]!;\n if (!a || a.form !== b.form || a.formKind !== b.formKind || Math.abs(a.rect.x - b.rect.x) > 0.5 || Math.abs(a.rect.y - b.rect.y) > 0.5) return false;\n }\n if (titled) {\n // A title bar is a constrained host: the toolbar fits in its first form, nothing there gives way for it, and the\n // title keeps its natural width.\n if (me.form !== 0) return false;\n for (const id of restEdge.items) {\n const a = after.items[id];\n const b = base.items[id];\n if (!a || !b || b.edge !== edge.id) continue;\n if (titles.includes(id) ? a.rect.width < natural(id, a.form) - 0.5 : a.form !== b.form || !!a.inMenu !== !!b.inMenu) return false;\n }\n }\n return !chrome.some((c) => overlaps(me.rect, c));\n };\n const markerOf = (after: SceneLayout): Rect => {\n const slot = after.items[dragged]!.rect;\n const e = after.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 // Other edges' rects stop a gap's hit, with the item lifted and as they are now (a neighbour that moves once the item\n // is lifted keeps its panels clear of the hit too); the dragged item's own edge counts only as lifted (as it is now it\n // may lie where its neighbours move to). A compact rail's inward reach may lie over the columns of its own side (the\n // columns' gaps are cut out of it afterwards).\n const ownNow = now.items[dragged]?.edge;\n const otherOf = (edges: SceneLayout[\"edges\"], skip?: string): Rect[] =>\n Object.entries(edges)\n .filter(([id, e]) => id !== edge.id && id !== skip && e.rect.width > EPS && e.rect.height > EPS && !(edge.compact && e.side === edge.side))\n .map(([, e]) => e.rect);\n const otherEdges = otherOf(base.edges);\n const nowEdges = otherOf(now.edges, ownNow);\n /**\n * `h` trimmed clear of each rect in `others`, never dropped. A rect across from the edge's own rect (a bar above a\n * column) trims the hit's end along the edge; one beside it (a neighbouring column) trims the hit's side across.\n * `besideOnly` (the edges as they are now, which the lift may have moved onto this edge's rect) trims only across.\n */\n const own = el.rect;\n const trimOff = (h: Rect, others: readonly Rect[], k: Point, besideOnly = false): Rect => {\n let [a0, a1] = column ? [h.y, h.y + h.height] : [h.x, h.x + h.width];\n let [c0, c1] = column ? [h.x, h.x + h.width] : [h.y, h.y + h.height];\n const km = column ? k.y : k.x;\n const kc = column ? k.x : k.y;\n const [w0, w1] = column ? [own.x, own.x + own.width] : [own.y, own.y + own.height];\n for (const o of others) {\n const [o0, o1] = column ? [o.y, o.y + o.height] : [o.x, o.x + o.width];\n const [p0, p1] = column ? [o.x, o.x + o.width] : [o.y, o.y + o.height];\n if (Math.min(a1, o1) - Math.max(a0, o0) <= EPS || Math.min(c1, p1) - Math.max(c0, p0) <= EPS) continue;\n const across = !besideOnly && Math.min(w1, p1) - Math.max(w0, p0) > EPS;\n if (!across) {\n if (p1 <= kc + EPS) c0 = Math.max(c0, p1);\n else if (p0 >= kc - EPS) c1 = Math.min(c1, p0);\n } else if (o1 <= km + EPS) a0 = Math.max(a0, o1);\n else if (o0 >= km - EPS) a1 = Math.min(a1, o0);\n }\n return column ? rect(c0, a0, Math.max(0, c1 - c0), Math.max(0, a1 - a0)) : rect(a0, c0, Math.max(0, a1 - a0), Math.max(0, c1 - c0));\n };\n const target = (id: string, place: Extract<ScenePlace, { kind: \"gap\" }>, hit: Rect, keep: Point, solved?: SceneAfter): SceneTarget | null => {\n const result = solved ?? settle(use(moveTo(scene, dragged, place), dragged));\n if (!fits(result.layout)) return null;\n // A gap's hit (its end reach included) never enters another edge's rect: a column's top gap stops at the bar above.\n // Along the edge only, from the keep point (inside the edge's own rect); a neighbour beside it trims the hit across.\n const clear = cutClear(id.startsWith(\"gap:\") ? trimOff(trimOff(hit, otherEdges, keep), nowEdges, keep, true) : hit, blockers, keep);\n if (!clear) return null;\n return { id, priority: 2, hit: clear, slot: result.layout.items[dragged]!.rect, marker: markerOf(result.layout), item: dragged, place, after: () => result };\n };\n\n const drawn = base.edges[edge.id]!.stack.items.filter((p) => p.kind !== \"menu\").map((p) => p.id);\n if (drawn.length === 0 && !el.menu) {\n // An empty edge: one strip inside the content along its side.\n const depth = Math.max(0, Number.isFinite(edge.strip) ? edge.strip! : DEFAULT_STRIP);\n const r = el.rect;\n const hit =\n edge.side === \"left\"\n ? rect(r.x, r.y, depth, r.height)\n : edge.side === \"right\"\n ? rect(r.x + r.width - depth, r.y, depth, r.height)\n : edge.side === \"top\"\n ? rect(r.x, r.y, r.width, depth)\n : rect(r.x, r.y + r.height - depth, r.width, depth);\n const keep = { x: hit.x + hit.width / 2, y: hit.y + hit.height / 2 };\n if (thirds) {\n // An empty bar: its strip (along the content) in thirds, one target per zone that takes the kind.\n const c = base.content;\n const x0 = Math.max(hit.x, c.x);\n const x1 = Math.min(hit.x + hit.width, c.x + c.width);\n if (x1 - x0 <= EPS) return [];\n const w = (x1 - x0) / 3;\n const out: SceneTarget[] = [];\n ZONES.forEach((zone, k) => {\n if (!zoneTakes(edge, zone, scene.items[dragged]!.kind)) return;\n const part = rect(x0 + k * w, hit.y, w, hit.height);\n const t = target(`strip:${edge.id}:${zone}`, { kind: \"gap\", edge: edge.id, zone, at: 0 }, part, { x: part.x + part.width / 2, y: part.y + part.height / 2 });\n if (t) out.push(t);\n });\n return out;\n }\n // A kind never opens an edge on its own unless its start zone takes it: a group's drag gets no strip for an empty\n // panel column (whose tray is its end zone), only the compact rail's at the window edge.\n if (!zoneTakes(edge, \"start\", scene.items[dragged]!.kind)) return [];\n const t = target(`strip:${edge.id}`, { kind: \"gap\", edge: edge.id, zone: \"start\", at: 0 }, hit, keep);\n return t ? [t] : [];\n }\n\n // Each gap's insertion line along the edge, in the layout without the dragged item.\n const main0 = column ? el.rect.y : el.rect.x;\n const length = column ? el.rect.height : el.rect.width;\n const at = (r: Rect): number => (column ? r.y : r.x);\n const len = (r: Rect): number => (column ? r.height : r.width);\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 // What an item takes of the edge for its gaps' lines: its rect, or a growing fixed item's natural rect (a title's text),\n // so the length it grew by is free room the gaps after it reach into.\n const occupied = (id: string): Rect => (base.items[id]?.fixed ? reservedRect(scene, base, id) : base.items[id]!.rect);\n const drawnOf = (z: Zone): Rect[] => restEdge.items.filter((id) => zoneOf(rest.items[id]) === z && base.items[id]?.edge === edge.id && !base.items[id]!.inMenu).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 empty: 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 gaps: { zone: Zone; at: number; line: number }[] = [];\n // Only the zones that take the dragged item's kind (`zoneAccepts`) offer gaps.\n for (const zone of zonesTaking(edge, scene.items[dragged]!.kind)) {\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((id) => base.items[id]?.edge === edge.id && !base.items[id]!.inMenu);\n const before = members\n .slice(0, k)\n .reverse()\n .find((id) => base.items[id]?.edge === edge.id && !base.items[id]!.inMenu);\n const line = next ? at(occupied(next)) : before ? at(occupied(before)) + len(occupied(before)) : empty[zone];\n gaps.push({ zone, at: k, line });\n }\n }\n // Gaps on one line are one place to the pointer: the first (in zone order) takes it. In a bar each zone has its third,\n // so only a zone's own gaps merge.\n const sorted = gaps\n .map((g, i) => ({ ...g, i }))\n .sort((a, b) => (thirds ? ZONE_ORDER[a.zone] - ZONE_ORDER[b.zone] : 0) || a.line - b.line || a.i - b.i)\n .filter((g, i, all) => i === 0 || (thirds && g.zone !== all[i - 1]!.zone) || Math.abs(g.line - all[i - 1]!.line) > EPS);\n const out: SceneTarget[] = [];\n // The gaps a drop may take: solved once each; the hits are split among these only, so a refused gap leaves no hole.\n const live = sorted\n .map((g) => {\n const place = { kind: \"gap\" as const, edge: edge.id, zone: g.zone, at: g.at };\n return { ...g, place, result: settle(use(moveTo(scene, dragged, place), dragged)) };\n })\n .filter((g) => fits(g.result.layout));\n // `hitBand`: the edge's whole length is split among its gaps, halfway between their insertion lines (free space and\n // short items such as toolbars belong to the nearest gap), except over a panel's body (an `open` form): a number is a\n // band that many px around each line there, so the middle of a panel is no gap. `\"middle\"` splits panels too.\n const bandOpt = edge.hitBand ?? DEFAULT_HIT_BAND;\n const band = bandOpt === \"middle\" ? Infinity : Math.max(0, Number.isFinite(bandOpt) ? bandOpt : DEFAULT_HIT_BAND);\n const bodies = Number.isFinite(band)\n ? Object.values(base.items)\n .filter((p) => p.edge === edge.id && p.formKind === \"open\")\n .map((p) => ({ a: at(p.rect), b: at(p.rect) + len(p.rect) }))\n : [];\n // A compact rail's hits reach a little way inward past its edge, so a pointer just inside the rail still catches it.\n const inward = edge.compact ? RAIL_REACH : 0;\n // The edge's solid items along it (fixed items that don't grow), as the lift leaves them.\n const solidSpans = fixedIds\n .filter((id) => !formsOf(scene.items[id]!, axisOf(edge.side))[base.items[id]!.form]?.main.grows)\n .map((id) => ({ a: at(base.items[id]!.rect), b: at(base.items[id]!.rect) + len(base.items[id]!.rect) }));\n live.forEach((g, i) => {\n let from = i === 0 ? -Infinity : (live[i - 1]!.line + g.line) / 2;\n let to = i === live.length - 1 ? Infinity : (g.line + live[i + 1]!.line) / 2;\n if (thirds) {\n // A bar: the zone's third, split among the zone's own gaps; the outer thirds reach past the bar's ends.\n const k = ZONE_ORDER[g.zone];\n const prev = live[i - 1]?.zone === g.zone ? live[i - 1] : undefined;\n const next = live[i + 1]?.zone === g.zone ? live[i + 1] : undefined;\n // The nearest gap to the pointer within the third. When the zone's lines run past its third (long toolbars, or a\n // center zone reaching into a side's third), they are spread proportionally inside it, so every gap of the zone\n // keeps a slice of its own.\n const a0 = main0 + (length * k) / 3;\n const b0 = main0 + (length * (k + 1)) / 3;\n const lines = live.filter((x) => x.zone === g.zone).map((x) => x.line);\n // The part of the third free of the edge's solid items (window controls, a readout): the lines are spread inside\n // it only, never over a blocker the hits are cut clear of.\n const first = Math.min(...lines);\n const last = Math.max(...lines);\n const a1 = Math.max(a0, ...solidSpans.filter((s) => s.b <= first + EPS).map((s) => s.b));\n const b1 = Math.min(b0, ...solidSpans.filter((s) => s.a >= last - EPS).map((s) => s.a));\n const [a, b] = b1 - a1 > EPS ? [a1, b1] : [a0, b0];\n const span0 = Math.min(a, ...lines);\n const span1 = Math.max(b, ...lines);\n const inThird = (x: number): number => (span1 - span0 > EPS ? a + ((x - span0) / (span1 - span0)) * (b - a) : x);\n const lo = k === 0 ? -Infinity : a0;\n const hi = k === 2 ? Infinity : b0;\n from = Math.max(lo, prev ? (inThird(prev.line) + inThird(g.line)) / 2 : lo);\n to = Math.min(hi, next ? (inThird(g.line) + inThird(next.line)) / 2 : hi);\n }\n // Over a panel's body, only `band / 2` from its edge.\n for (const p of bodies) {\n if (p.b <= g.line + EPS && p.b > from) from = Math.max(from, p.b - band / 2);\n if (p.a >= g.line - EPS && p.a < to) to = Math.min(to, p.a + band / 2);\n }\n // Only a hit that reaches the edge's end goes on past it, as far as `endReach` (a tray's gap at the foot never\n // covers the panels at the top).\n from = from <= main0 + pad.start + EPS ? main0 - reach : from;\n to = to >= main0 + length - pad.end - menuLen - EPS ? main0 + length + reach : to;\n from = Math.max(from, main0 - reach);\n to = Math.min(to, main0 + length + reach);\n if (to - from <= EPS) return;\n // Across: from the edge's outer side, the larger of its thickness now and after the drop, and a rail's inward reach.\n const thick = Math.max(el.cross, g.result.layout.edges[edge.id]?.cross ?? 0) + inward;\n const r = el.rect;\n const hit = column\n ? rect(edge.side === \"left\" ? r.x : r.x + r.width - (thick - inward) - inward, from, thick, to - from)\n : rect(from, edge.side === \"top\" ? r.y : r.y + r.height - (thick - inward) - inward, to - from, thick);\n const line = Math.min(Math.max(g.line, from), to);\n // The point a hit must keep: on the gap's line, across in the middle of the edge's own rect as it is now.\n const keep = column ? { x: r.x + r.width / 2, y: line } : { x: line, y: r.y + r.height / 2 };\n const t = target(`gap:${edge.id}:${g.zone}:${g.at}`, g.place, hit, keep, g.result);\n if (t) out.push(t);\n });\n return out;\n}\n"],"mappings":";;;;;;;;;;;;;;AAeO,IAAM,QAAyB,CAAC,OAAO,SAAS,UAAU,MAAM;AAIhE,IAAM,QAAyB,CAAC,SAAS,UAAU,KAAK;AAoKxD,IAAM,YAAY,CAAC,MAAiF,MAAY,SACrH,KAAK,QAAQ,SAAS,IAAI,MAAM,KAAK,gBAAgB,UAAa,CAAC,CAAC,KAAK,YAAY,IAAI,GAAG,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