@n-uf/docking 26.11.54 → 26.11.56

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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/model.ts","../src/helpers.ts","../src/solve.ts","../src/targets/ids.ts","../src/solve/bar-giveway.ts","../src/solve/order.ts","../src/solve/bars.ts","../src/solve/draft.ts","../src/solve/edge.ts","../src/solve/floats.ts","../src/solve/insets.ts","../src/solve/notes.ts","../src/solve/sides.ts","../src/solve/columns.ts","../src/solve/rails.ts","../src/dividers.ts","../src/changes.ts","../src/float-resize.ts","../src/store.ts","../src/targets.ts","../src/targets/anchor.ts","../src/targets/edges.ts","../src/targets/kinds.ts","../src/targets/filter.ts","../src/targets/ownership.ts","../src/targets/meet.ts","../src/targets/model.ts","../src/targets/tiles.ts","../src/targets/rail-strip.ts","../src/targets/virtual.ts","../src/targets/min-hit.ts","../src/lanes.ts","../src/drag.ts"],"sourcesContent":["/**\n * The state's shapes: one model of a whole window. A state 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 rects (`keepClear`) that\n * floats and drop zones keep clear of. `solve(state)` turns it into a `DockLayout`: every rect a host draws.\n *\n * Plain data in and out, nothing module-global: two windows on one page are two states. No words, no time, no DOM.\n * What the shapes tell on their own (an edge's axis, an item's zone and forms, how it floats) is in `./helpers`.\n */\nimport type { Rect, Size } from \"@n-uf/placement\";\nimport type { CrossLimits, StackFit, StackForm, StackFormKind, StackNote } from \"@n-uf/placement/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, centered 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\";\nexport const FLOAT_ANCHORS: readonly FloatAnchor[] = [\"content-top-left\", \"content-top\", \"content-top-right\", \"content-right\", \"content-bottom-right\", \"content-bottom\", \"content-bottom-left\", \"content-left\"];\n\n/**\n * An anchor with an offset: flush with `at`'s side or corner of the content, then `dx` px to the right and `dy` px down\n * (negative: left, up; default 0). It still follows the content, so a host stores \"the top-right corner, 12 px down\"\n * rather than a pixel position.\n */\nexport interface FloatAnchorOffset {\n readonly at: FloatAnchor;\n readonly dx?: number;\n readonly dy?: number;\n}\n\n/** Where an anchored float sits: an anchor's name, or one with an offset. */\nexport type FloatAnchorAt = FloatAnchor | FloatAnchorOffset;\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 DockItem {\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 * Folded by hand when 1 or more (`foldItem` sets it to 1; default unset): it starts at its first folded form (a panel's\n * `header`, a group's `fold`) among the forms of the axis it lies along, never one step down the ladder, and give-way\n * steps down from there. A stored value past that form keeps its place (a state stored with a later form). With no\n * folded form on that axis it draws unfolded (`canFold`). A float folded by hand is drawn as its bar: that form's\n * 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`. With `stepping` it keeps only\n * the reserved place and changes form like any item.\n */\n readonly fixed?: boolean;\n /**\n * A fixed item that still takes steps (read only with `fixed`; `StackItem.stepping`): it is never dragged, reordered\n * or dropped before, and no hit or slot covers it, but it steps through its own forms (a `controlLadder`), folds and\n * goes into its edge's » menu by the usual give-way order, and comes back in exact reverse, as a movable item with the\n * same forms, `used`, `kept` and `priority` would. It never holds for the title rule; a drop beside it may step it,\n * never squeeze it under its form's `main.min`, and never move it from its place in the order. A declaration of the\n * state like `pushable`: `readDockState` takes it from `base`, `storeDockState` never writes it.\n */\n readonly stepping?: boolean;\n /**\n * A fixed item that yields: a movable item dropped after it in its zone may push it inward along the zone. Left out,\n * a fixed item at a zone's anchor (window controls at a bar's end) keeps its place, so no gap after it is offered; a\n * fixed item with `pushable` at the anchor (a state or page cell at a title bar's end) lets the gap after the run be a\n * stop, a place a toolbar homed after it can be put back in. It keeps its order among the fixed items: no gap is\n * offered between two `pushable` items. The rule is \"a movable item dropped beside me, on my anchor's side, may push\n * me inward\", so in the start zone it is the mirror: the gap before a run of `pushable` items at the edge's start (a\n * title at a title bar's start) is a stop, and a drop there pushes them inward. A declaration of the state like\n * `DockEdge.zoneAccepts`: `readDockState` takes it from `base`, `storeDockState` never writes it.\n */\n readonly pushable?: 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 /**\n * Its zone (default start): the item's own, not its edge's. It lies there where its edge takes its kind there, else in\n * the first zone that does (`zoneIn`). Only a drop that names a zone (a gap in a zone, `moveTo` with `zone`) on an edge\n * offering a choice (`namesZone`: more than one of its zones takes the kind) sets it.\n */\n readonly align?: Zone;\n /**\n * Free space it keeps on its zone's open side, px: before it in a start zone, after it in an end zone (none in a center\n * zone), out of the edge's spare length, so an item dropped partway along a free stretch of a bar stays there. When\n * items ask for more than the spare length, each gets its share. A dock move sets it (`DockPlace.space`) or clears it.\n */\n readonly space?: number;\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 * The length a person asked it to have along its edge, px, per axis: `column` for an item in a side column, `row` for\n * one in a bar (default none; `StackLengths` in `@n-uf/placement/stack`). While it is in a form that grows, `solve`\n * hands it to the edge's stack, which reads it in place of the form's natural: spare length goes in proportion to the\n * asked lengths, a short edge interpolates toward the least. It is per axis, so an item moved to an edge of the other\n * axis never reads it, and it travels with the item when it moves, closes and reopens. It is in ask units, not drawn\n * px: with room to spare a drawn size is the ask times the shared scale, or its least when that is more (a 0 is no length). `resizeBetween` and `resetBetween` set it for\n * the pair only; `resetLengths` clears it; `storeDockState` keeps it. A state that declares none lays\n * out exactly as before.\n */\n readonly lengths?: { readonly column?: number; readonly row?: number };\n /**\n * Its size as a float, per orient: `floatAt` with no rect uses the one for the orient it floats in, and a float drop or\n * a hand resize sets it for the orient the float is in, so a float turned to the other orient (`orientFloat`) takes that\n * orient's size and, turned back, its own again. Without one for an orient, a float takes its first form's natural size\n * along that orient (`floatSizeOf`), or `DEFAULT_FLOAT_SIZE` when that form grows (a panel's card).\n */\n readonly floatSizes?: { readonly row?: Size; readonly column?: 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 * The most a float of it is laid out at, each way (optional, the same shape as `floatMin`, never under it): a larger\n * float rect is drawn at this size, its top-left corner kept (a folded float keeps its bar's height), and `fitResize`\n * stops a resize here (`\"max\"`).\n */\n readonly floatMax?: Size;\n}\n\nexport interface DockEdge {\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. An overlay bar (`mode: \"overlay\"`) lies over the content, between\n * the columns, unless it sets `span: \"full\"` by name: then it runs across the full bars' width, over the side columns\n * too. Left out on an overlay bar, it means the content's width, as it always has.\n */\n readonly span?: \"full\" | \"between\";\n /** The kinds a drop may bring here. Deny by default: an empty list takes nothing (an anchor). */\n readonly accepts: readonly Kind[];\n /** Ids in order, fixed and closed items included. */\n readonly items: readonly string[];\n /** The size it may take across (a column's width, a bar's height), and the rail width when nothing sets it. */\n readonly cross: CrossLimits;\n /** `\"overlay\"` lies over the content instead of shortening it (default `\"reserved\"`). */\n readonly mode?: \"reserved\" | \"overlay\";\n readonly gap?: number;\n readonly pad?: { readonly start?: number; readonly end?: number };\n /** The » entry's length along the edge. */\n readonly menu?: { readonly main: number };\n /**\n * The user's size across (a column dragged wider), clamped to `[max(cross.min, the widest open setter's cross.min),\n * cross.max]`, so an open item's `cross.min` wins over a smaller size. Used only while an item sets the cross size.\n */\n readonly size?: number;\n /** A column drawn as a rail (nothing in it sets its width) shows its closed items too, as tabs marked `closed`. */\n readonly railShowsClosed?: boolean;\n /**\n * An icons-only edge (a thin rail of vertical toolbars along a window side): its items take only their `icons` form\n * (and the » menu after it), stacked, each grip the divider. An item with no `icons` form is left out\n * (`no-icons-form`).\n */\n readonly compact?: boolean;\n /**\n * The kinds each zone takes, narrowing `accepts`: with it, a zone not listed takes nothing. A panel column with\n * `{ start: [\"panel\"], end: [\"group\"] }` has its panels at the top and a tray of toolbars at its foot (the end zone, one\n * toolbar per row): a toolbar in the tray takes only its `wrap` or `icons` form (never the menu), and the panels give\n * way first. An empty edge offers each third of its strip only to the kinds that third's zone takes (the others are\n * refusals). A group never opens such a column on its own: an empty side column offers its strip only to the kinds\n * its start zone takes (a panel gets its top third; a group none, the rail's instead).\n */\n readonly zoneAccepts?: ZoneAccepts;\n /**\n * The zones the edge has, in any order (default all three). `[\"start\"]` makes it one stack along its whole length, as\n * a side rail drawn in order: its whole length offers the start zone's gaps, ordered by position along it, with no\n * center or end gaps and no refusal of a kind it takes; a drop on it names no zone (`namesZone`), so the item keeps\n * its own `align`; and an item whose `align` names a zone it doesn't have lies in its zone (`zoneIn`), its stored\n * `align` unchanged (so it is back in its own zone when lent to a bar through `showIn`). Two zones (`[\"start\", \"end\"]`)\n * split the length between them as three split it in thirds, the boundary at the middle, moved past the cards seen in\n * them. Setting `zones`, even to all three, always splits the length evenly among its zones (each boundary then moved\n * past the cards seen on either side); leaving it out keeps the edge kind's own spans, a column's as the solver lays\n * its zones out. Entries that aren't zones and repeats are ignored; a list with no zone counts as all three. With\n * `zoneAccepts`, a zone takes a kind only where both say so. Like `zoneAccepts`, a declaration: never stored, from\n * `base` on `readDockState`.\n */\n readonly zones?: readonly Zone[];\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 neighboring 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 * `\"side\"`: a static edge whose fixed item (an anchor: page thumbnails) the user may drag to the other side of the\n * edge's axis. `targets` then offers that item one target, `side:<other side>`, over the place the edge takes there\n * (`setSide`); its own place is home. Left out, a fixed item has no targets.\n */\n readonly moves?: \"side\";\n /**\n * `true`: the user may fold this edge's fixed items (an anchor) by hand, like a panel: `foldItem(state, id, true)` shows\n * it in its rail form, `foldItem(state, id, false)` reopens it, and `storeDockState` / `readDockState` keep it folded.\n * Left out, `foldItem` leaves a fixed item as it is.\n */\n readonly foldable?: boolean;\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 (`DockState.contentMin`) or when every member is folded by hand. Its `accepts`,\n * `cross`, `gap`, `pad`, `menu`, `zoneAccepts` and `hitBand` come from `DockState.columns[side]` when the changes make it;\n * with no `hitBand` of its own it reads the template's.\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 * `DockState.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 * On a top or bottom bar (reserved or overlay), it gives way by height: while the content is shorter than\n * `contentMin.height` (overlay bars counted), such bars shrink across toward their minimum (`cross.min`, and each\n * open item's form's `cross.min`), then fold, their items stepping to the next form that fits across (a panel's\n * title bar), unkept before kept, the oldest newest use first, the outer first (`bar-shrunk`, `bar-folded`). Room\n * coming back undoes it in reverse. A bar never draws an item thinner across than its form's `cross.min`.\n */\n readonly giveWay?: boolean;\n /**\n * The default give-way priority of its items (`DockItem.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 * Hidden: kept in the state with its items, but not in the window (a bar a host doesn't draw, a rail it has turned\n * off). View state: the host decides it each time it builds the state, and the store never writes it. A hidden edge\n * takes no room, and everything else lays out exactly as if it weren't in the state; `solve` leaves it and its items\n * out of the layout (no `edges[id]`, no `items[id]`, as for an item placed nowhere), so nothing reads a rect of it.\n * Its items take no part in give-way or folds. It has no targets and no refusals for any kind, no keyboard stops, and\n * its items have none either (dragging one gives nothing); `moveTo` into it is refused as into an edge that doesn't\n * take the kind. Its items stay in it, and `storeDockState` / `readDockState` keep them. A column a drop makes never takes a\n * hidden edge's id; where a drop makes or removes a column on its side, the side is numbered again with the hidden\n * edge back at its own place. Side columns, rails and bars alike. With `showIn`, its items show elsewhere instead.\n */\n readonly hidden?: boolean;\n /**\n * Where a hidden edge's items show while it is hidden: the id of another static edge, shown. Its items are laid out, targeted\n * and stopped as if they sat in that edge after its own items (`solve` reports them there), each that edge takes the\n * kind of, in its own zone where that edge takes it there, else in the first that does; a fixed item, or one whose\n * kind that edge takes nowhere, is left out as without `showIn`. They stay in the hidden edge in the state: a drop that\n * commits a move of one takes it out, to the drop's place; its home, and any drop of another item, leaves them where\n * they are. A moved item keeps its stored zone, unless the drop names one (a gap). `canFold`, `foldItem` and the hand\n * fold read a lent item along the edge it is drawn in. View state like `hidden`: the store never writes it. Naming the\n * edge itself, no edge, another hidden edge or a dynamic column (`column: true`: drops make and delete those) is\n * ignored (`show-in-ignored`). No effect on an edge that isn't hidden.\n */\n readonly showIn?: string;\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 (`DockEdge.zoneAccepts`). */\n readonly zoneAccepts?: ZoneAccepts;\n /**\n * How a gap's hit runs over the open panels of the columns made from it (`DockEdge.hitBand`): a band that many px about\n * each line, or `\"middle\"` (a drop on a panel's upper or lower half means the gap before or after it). Default\n * {@link DEFAULT_HIT_BAND}.\n */\n readonly hitBand?: number | \"middle\";\n}\n\n/** Per zone, the kinds it takes. */\nexport type ZoneAccepts = Readonly<Partial<Record<Zone, readonly Kind[]>>>;\n\n/** How a side's rails show their items: their titles while they fit (the default), or their tiles only. */\nexport type RailMode = \"titles\" | \"icons\";\nexport const RAIL_MODES: readonly RailMode[] = [\"titles\", \"icons\"];\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\n/** When a host draws a side's rail drop strip: while an item of the kind is held (the default), always, or never. */\nexport type RailVisibility = \"whileDragging\" | \"always\" | \"never\";\nexport const RAIL_VISIBILITIES: readonly RailVisibility[] = [\"whileDragging\", \"always\", \"never\"];\n\n/** The least width of a rail drop strip, px: a target at the window's edge stays easy to hit (Fitts's law). */\nexport const RAIL_STRIP_MIN = 24;\n/** How far an armed rail drop strip grows inward by default, px, so a hand that wobbles once armed keeps it. */\nexport const DEFAULT_RAIL_MAGNET = 6;\n/**\n * How long a rail target or a new-column line against the window's left or right edge holds before it shows with its\n * room, ms (`DockDrop.roomHold`, read only by a drag intent): none. It shows, with its room, on the frame the pointer enters it (an aiming pointer),\n * so a toolbar held at the window's edge never jumps away across the column and back. The cost: grazing the window's\n * edge with a held item opens its rail.\n */\nexport const EDGE_ROOM_HOLD = 0;\n\n/**\n * How an item of one kind drops into a side's rail (`DockState.railDrop[kind]`): the geometry of its drop strip. Each kind\n * has its own; a kind with none keeps the rail targets as they were (immediate, no strip).\n *\n * With a policy, each side whose rail can take the kind shows one drop strip at the window's side, at the rail's real\n * width, even while the rail is empty: its targets are `rail:<side>:<ring>` with `arm: \"dwell\"` (spring-loading: the\n * drag intent arms them on a dwell), `armedHit` (the strip grown by `magnet`) and `strip` (the rect to draw). The strip\n * owns its rect: a drop there is the rail's once armed, the float's before. The side's rail is `DockState.rails[side]`\n * where the state declares one, else the side's outermost column that takes the kind in its start zone (\"the column\n * drawn as a rail\"): a drop there docks the item in it as a collapsed header, a rail tile once nothing in it sets its\n * width. The strip means \"collapse it at this side\": the drop is `moveTo` that side's rail, and lands wherever the\n * state shows a collapsed panel there (a rail tile, a rider bar under `handFold: \"ride\"`, a header); the slot is that.\n */\nexport interface RailDropPolicy {\n /**\n * The strip's width, px, from the window's side inward (default: the rail's drawn width). At least\n * {@link RAIL_STRIP_MIN}; 0 turns the kind's rail docking off.\n */\n readonly railStripWidth?: number;\n /** When the host draws the strip (default `\"whileDragging\"`); `\"never\"` turns the kind's rail docking off. */\n readonly railVisibility?: RailVisibility;\n /**\n * How far the strip grows inward once armed, px (default {@link DEFAULT_RAIL_MAGNET}): the armed target's band\n * (`armedHit`). Moving out past its outer edge disarms it, and re-entering the strip needs a new full dwell.\n */\n readonly magnet?: number;\n /** Whether a float may sit inside the strip's area (default true); false keeps a float's rect clear of every strip. */\n readonly floatNearEdge?: boolean;\n}\n\nexport interface DockFloat {\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 (with an offset, `{ at, dx?, dy? }`) until a drop gives it a real rect. */\n readonly anchor?: FloatAnchorAt;\n /** Which of the item's forms it uses (default: the item's `floatOrientOf`). */\n readonly orient?: Orient;\n /**\n * When it was floated, or last placed by the hand over an anchored float, as a sequence: `floatAt` and `moveTo(…,\n * { kind: \"float\" })` give a newly floated item one more than the largest `since` among the state's floats (1 when\n * there are none), and so do a drop at a rect and `resizeFloat` whose new rect lies over an anchored float as drawn;\n * a drop or resize that stays clear of every anchored float, re-anchoring a float that already floats (no rect),\n * `raiseFloat` and `markUsed` keep it. The earlier (smaller `since`, missing counting as 0; among anchored floats then the smaller\n * id) wins the place both want, so a float the hand just placed or grown over an anchored float wins over it.\n */\n readonly since?: number;\n /**\n * The hand left it over content: no clear place kept it under the pointer at its drop, so it lies where the hand put\n * it. `solve` only keeps it inside the stage, never moves it beside what it covers (a `float-covers` note says what\n * it covers). The float target's drop decides it again each time\n * (`DockDrop.after`); `floatAt` with a rect clears it, `resizeFloat`, `orientFloat`, `raiseFloat` and `markUsed` keep\n * it. Ignored with `anchor`.\n */\n readonly stays?: true;\n}\n\n/**\n * A rect the state keeps clear of, and who keeps clear: `\"all\"` (the default) for floats and drop targets alike (a\n * slot or a target's landing never lies on it), `\"floats\"` for floats alone: their placement, drops, opening, a\n * window resize and a resize by hand keep clear of it, while the edges, give-way and every docked target ignore it (a\n * spine the host draws over a column).\n */\nexport type KeepClear = Rect & { readonly for?: \"all\" | \"floats\" };\n\nexport interface DockState {\n /** The window's inner rect. */\n readonly stage: Rect;\n readonly edges: readonly DockEdge[];\n readonly items: Readonly<Record<string, DockItem>>;\n /** Stacking order: the last is on top. */\n readonly floats: readonly DockFloat[];\n /** The kinds that may float. Deny by default. */\n readonly floatKinds: readonly Kind[];\n /**\n * Rects the state keeps clear of (a title the host draws itself, a status line): by default floats and drop targets\n * both; an entry with `for: \"floats\"` (a spine drawn over a column) only floats. See {@link KeepClear}.\n */\n readonly keepClear?: readonly KeepClear[];\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 * Per side (left, right): how its rails show their items (default `\"titles\"`). It covers every rail on the side: a\n * column drawn as a rail (nothing in it sets its width) and the side's rail strip (`rails`). `\"titles\"` offers the\n * items' title rail forms (`StackForm.title`), each stepping down to its tile by the ladder when the rail runs short;\n * `\"icons\"` passes them over, so every item shows its tile. An item with no title form shows its tile either way. A\n * side needs no `rails` entry to have a mode: a column drawn as a rail reads it too. `storeDockState` keeps it.\n */\n readonly railModes?: Partial<Record<\"left\" | \"right\", RailMode>>;\n /**\n * Per item kind: how it drops into a side's rail ({@link RailDropPolicy}), keyed by the state's own kind strings.\n * Tuning one kind never changes another; a kind left out keeps the rail targets it had.\n */\n readonly railDrop?: Readonly<Partial<Record<Kind, RailDropPolicy>>>;\n /**\n * `\"end\"`: no drop changes an item's collapsed state. For an item arriving from elsewhere, collapsed titles are one\n * drop place over their whole length, their tiles included, after the last member: a column drawn as a rail, or on a\n * side with a declared `rails` entry the rail itself (the end of its last folded column). An open item opens that\n * column at full size, a collapsed one becomes the last tile. A tile keeps its place among its own rail's tiles. No\n * rail drop strip (`railDrop`) is offered, and on a declared rail no stop folds an open item. Absent: as before. A\n * declaration, like `zoneAccepts`: never stored.\n */\n readonly foldedColumnDrop?: \"end\";\n /**\n * `\"one\"`: a side has at most one column (`isSideColumn`). A drag offers a new-column line only on a side with no\n * column holding an item once the item is lifted; where the side has one, an item goes into it (by its gaps) or\n * nowhere on that side. A stored layout with two columns on a side is merged by `mergeSideColumns`, which a host calls\n * as it reads one. Absent: as before. A declaration, like `foldedColumnDrop`: never stored.\n */\n readonly sideColumns?: \"one\";\n /**\n * `\"nearest\"`: a bar's zones (start, center, end) meet halfway between the landing rects either side of each boundary,\n * so the pointer picks the zone whose landing is nearest it. Absent: at thirds of the bar's length (each boundary moved\n * past the cards seen beside it, as now). A declaration, like `foldedColumnDrop`: never stored. It moves each zone's\n * extent, so it changes which zone a pointer picks among `targets()` (the hit areas a drag intent reads), and, since a\n * zone left with no room gets no drop, which of a bar's drops exist and where its refused stretches lie. Under a\n * landing model `lanes()` cuts between spots by their landings, not by zones: there it changes which spots and\n * refused stretches a bar has, never the rule that cuts between spots (the cuts follow whichever spots exist).\n */\n readonly barZones?: \"nearest\";\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 * `chromeWidth` (optional, px, at most `width`): a lower floor for chrome. The side edges that hold toolbars, not\n * panels (compact rails and side toolbar bars, `isSideBar`), may take the content down to it while the columns keep\n * their width. A compact rail or side toolbar bar counts only where its side has a column template or a declared rail\n * to tell it from a panel column (`isSideBar`): on a side with neither it is not chrome and gets no floor benefit.\n * A floor of 0 or less lets chrome take all the content. The columns only move aside: a toolbar rail added at an edge\n * narrows the content, not the column. Below the floor a\n * column shrinks, then folds, as without it. The columns alone still leave `width`. Chrome within that allowance is\n * quiet: a content it narrows between the two floors carries no `content-narrow`, and `columnRoom` stays true, so a\n * toolbar rail never flips a host to its narrow layout. `content-narrow` fires when the columns' own need takes the\n * content under `width` (its `min`: `width` less what chrome takes within the allowance), or once it is under the\n * floor. Width only: bars give way by `height` as before.\n */\n readonly contentMin?: { readonly width: number; readonly height: number; readonly chromeWidth?: 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 DockItemLayout {\n /** Stage px. An item in the » menu has the menu entry's rect. */\n readonly rect: Rect;\n readonly kind: Kind;\n /**\n * The axis it lies along, for every item: a placed item's edge's (a bar's items lie along a row, a column's and a\n * rail's along a column, whatever form they took: a bar's icons form is a row), a float's orient. `form` indexes the\n * forms of this axis. Hosts read it here, never from `formKind`.\n */\n readonly axis: Orient;\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 /**\n * Drawn in its title rail form (`StackForm.title`) on a rail of this side: a column drawn as a rail or the side's rail\n * strip. The host turns the title to run along the rail and reads it toward the content: on the left from bottom to\n * top (turned −90°), on the right from top to bottom (+90°), the count at the title's end.\n */\n readonly railTitle?: \"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 /**\n * Why this item is drawn smaller than its first form, read from the state's own state, never inferred from the rects:\n * `\"hand\"` when it is folded by hand (`DockItem.from` over 0, which `foldItem` sets), `\"auto\"` when it gave way (a form\n * below the one it started in, by length or width, a » menu entry included: the same word `folded` uses for a column\n * folded by give-way). Absent when the item shows its first form, is closed, or lies in an icons-only edge in the form\n * that edge gives it. By hand wins: a hand-folded item that gave way further is `\"hand\"`, since expanding it\n * (`foldItem(state, id, false)`) is the user's to do, so a host shows \"Expand\" for `\"hand\"` only. A float is only ever\n * folded by hand. `folded` is about the item's column; this one is about the item.\n */\n readonly foldedBy?: \"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 * The control ids the form it took leaves out (`StackForm.hides`), empty when it hides none or sits in a » menu: a host\n * draws a \"+N\" control with them. `form` already names the variant.\n */\n readonly hidden: readonly string[];\n /**\n * The chosen form's `StackForm.tiers`: each shown control's tier by control id, for a group whose forms `controlLadder`\n * generated; absent for a hand-written form, a `fold`, a `menu` and a » menu entry. Each is always a valid index into\n * the control's own `tiers`. A host draws each control at `tiers[id]` and leaves out the `hidden` ones.\n */\n readonly tiers?: Readonly<Record<string, number>>;\n}\n\n/** An edge as laid out. */\nexport interface DockEdgeLayout {\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 /**\n * Its items in the edge's order: the zones in order (start, center, end), then the order within each zone, the order\n * `solve` lays them in. Exactly the ids `DockLayout.items` draws for this edge (`DockItemLayout.edge`): an item in the\n * » menu keeps its place (`menu.items` names those, so a host wanting the docked ones filters them out), a rail tab is\n * listed, and a closed item is left out (unless it shows as a rail tab). A column folded into its rail or riding lists\n * its members in zone order. Never sort rects to learn it.\n */\n readonly items: readonly string[];\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 size across it asks for: a column's width, a bar's height (`DockEdge.giveWay`). */\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 DockRailLayout {\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 * The segments' fit along the rail, in rail-local px, while any of them offers a title form (titles step down to\n * tiles by the ladder and come back in exact reverse): `solve`'s `previous` reads it; a host needs it not.\n */\n readonly stack?: StackFit;\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 * - `bar-shrunk`, `bar-folded`: give-way by `contentMin.height`, in give-way order: a top or bottom bar with `giveWay`\n * shrank across (`from`, `to`), or its items stepped to the next form that fits (a panel's title bar);\n * - `content-narrow`, `content-short`: the content is still under `contentMin` (overlay bars count against the height).\n * With `contentMin.chromeWidth`, `content-narrow`'s `min` is `contentMin.width` less what chrome takes within its\n * allowance; a host that says \"needs at least …\" reads `contentMin.width`, not the note's `min`.\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 * - `show-in-ignored`: a hidden edge's `showIn` names the edge itself, no edge, another hidden edge or a dynamic\n * column; its items are left out as if it named none.\n */\nexport type DockNote =\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: \"bar-shrunk\"; readonly edge: string; readonly from: number; readonly to: number }\n | { readonly code: \"bar-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 }\n | { readonly code: \"show-in-ignored\"; readonly edge: string };\nexport type DockNoteCode = DockNote[\"code\"];\n\nexport interface DockLayout {\n /** Every item drawn (closed items only when shown as rail tabs). */\n readonly items: Readonly<Record<string, DockItemLayout>>;\n readonly edges: Readonly<Record<string, DockEdgeLayout>>;\n /** What is left for the content (the pages). Overlay edges lie over it. */\n readonly content: Rect;\n /** The floats drawn, in stacking order (the last on top). */\n readonly floats: readonly string[];\n /** The rails shown (a side with a folded column). Hosts draw these. */\n readonly rails: Readonly<Partial<Record<\"left\" | \"right\", DockRailLayout>>>;\n /**\n * Where each side's rail lies, or would lie were one shown, for every side that has a rail (`DockState.rails`), drawn or\n * not: the place a drop into the rail lands (`targets` reads it). Hosts draw `rails`, never `railPlaces`.\n */\n readonly railPlaces: Readonly<Partial<Record<\"left\" | \"right\", Rect>>>;\n /**\n * With `contentMin` and a dynamic column (or, before any exists, a `columns` template): whether one column at its\n * minimum fits beside the content's minimum (`false` with a `no-column-room` note). Anchors and rails don't count:\n * every column can fold into its rail. A host shows its narrow fallback (one panel over the content) while it is `false`.\n */\n readonly columnRoom?: boolean;\n readonly notes: readonly DockNote[];\n}\n\nexport interface SolveOptions {\n /**\n * The layout the state 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. Opened beside items that stayed open in its edge, it\n * counts as the newest (its largest form while it fits; the others give way by the usual rules) and its column is\n * weighed anew. A closed item is not a removed one: opened into an edge whose items were all closed, it comes back as\n * it was, with its age, and its column's folds (kept while it was closed) apply again.\n */\n readonly previous?: DockLayout;\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 * What the state's shapes (`./model`) tell on their own: which zones of an edge take a kind, an edge's axis, an item's\n * zone and forms, whether a side edge is a toolbar bar, and how an item floats (its orient, size and form). Pure.\n */\nimport { clampInto, type Point, type Rect, type Size } from \"@n-uf/placement\";\nimport { formFolded, type StackForm } from \"@n-uf/placement/stack\";\nimport { DEFAULT_FLOAT_SIZE, DEFAULT_HIT_BAND, DEFAULT_RAIL_MAGNET, RAIL_STRIP_MIN, ZONES, type ColumnTemplate, type DockEdge, type FloatAnchor, type FloatAnchorAt, type Kind, type Orient, type RailMode, type RailVisibility, type DockState, type DockItem, type Side, type Zone, type ZoneAccepts } from \"./model\";\n\nconst insetPx = (v: number | undefined): number => (Number.isFinite(v) ? Math.max(0, v!) : 0);\n\n/**\n * The region floats lie in, as `solve` lays them: the stage less the inset at its left and right (none with\n * `insetWhen: \"docked\"` while no panel is docked beside the content), the stage's full height. `lifted`: an item that\n * counts as off its edge, as a held one does.\n */\nexport function floatRegion(state: DockState, lifted?: string): Rect {\n const floating = new Set(state.floats.map((f) => f.id));\n const docked = state.edges.some((e) => (e.side === \"left\" || e.side === \"right\") && e.accepts.length > 0 && e.items.some((id) => id !== lifted && !floating.has(id) && !!state.items[id] && isDockingPanel(state.items[id]!)));\n const inset = state.insetWhen === \"docked\" && !docked ? {} : (state.inset ?? {});\n const { stage } = state;\n return { x: stage.x + insetPx(inset.left), y: stage.y, width: Math.max(0, stage.width - insetPx(inset.left) - insetPx(inset.right)), height: stage.height };\n}\n\n/**\n * Where item `id`, of `size`, held at `grab` (the pointer's offset from its top-left corner) lies with the pointer at\n * `pointer`: the grip under the pointer where it fits, else moved just enough to lie wholly inside the float region (the\n * stage less the inset at its left and right). With `floatFromHeld` the float target starts from this rect, so an item\n * held clear of everything lands where it is drawn.\n */\nexport const heldRect = (state: DockState, id: string, size: Size, pointer: Point, grab: Point): Rect =>\n clampInto({ x: pointer.x - grab.x, y: pointer.y - grab.y, width: size.width, height: size.height }, floatRegion(state, id));\n\n/** The name of a float's anchor, with or without an offset: `\"content-top-right\"` for `{ at: \"content-top-right\", dy: 12 }`. */\nexport const anchorName = (anchor: FloatAnchorAt): FloatAnchor => (typeof anchor === \"string\" ? anchor : anchor.at);\n\n/**\n * Whether `x` is a usable `DockFloat.since`: a number from 0 to `Number.MAX_SAFE_INTEGER`. Past that, one more is the\n * same number, so new floats would tie.\n */\nexport const isSince = (x: unknown): x is number => typeof x === \"number\" && x >= 0 && x <= Number.MAX_SAFE_INTEGER;\n\n/** What the zone tests read of an edge (or a column template): what it takes, per zone, and the zones it has. */\ntype ZoneDecl = { readonly accepts: readonly Kind[]; readonly zoneAccepts?: ZoneAccepts; readonly zones?: readonly Zone[] };\n\n/**\n * The zones an edge has (`DockEdge.zones`), in order: all three unless it lists some. Entries that aren't zones, and\n * repeats, are ignored; a list with no zone in it counts as none given (all three).\n */\nexport const zonesOf = (edge: { readonly zones?: readonly Zone[] }): readonly Zone[] => {\n if (edge.zones === undefined) return ZONES;\n const has = ZONES.filter((z) => edge.zones!.includes(z));\n return has.length > 0 ? has : ZONES;\n};\n\n/**\n * Whether `edge` takes kind `kind` in `zone`: a zone the edge has (`zones`), its `accepts`, narrowed by `zoneAccepts`\n * when given (a zone not listed takes nothing).\n */\nexport const zoneTakes = (edge: ZoneDecl, zone: Zone, kind: Kind): boolean =>\n edge.accepts.includes(kind) && (edge.zones === undefined || zonesOf(edge).includes(zone)) && (edge.zoneAccepts === undefined || !!edge.zoneAccepts[zone]?.includes(kind));\n\n/** The zones of `edge` that take `kind`, in order. */\nexport const zonesTaking = (edge: ZoneDecl, kind: Kind): Zone[] => ZONES.filter((z) => zoneTakes(edge, z, kind));\n\n/**\n * Whether `edge` takes `kind` anywhere: its `accepts` lists it and at least one of its zones takes it (`zoneTakes`). An\n * edge whose zones take nothing for the kind (`zoneAccepts: {}`) takes it nowhere, exactly as one whose `accepts` lacks\n * it: the one test drop targets and refusals ask. The stored form and `readDockState` keep reading `accepts` itself.\n */\nexport const edgeTakes = (edge: ZoneDecl, kind: Kind): boolean => zonesTaking(edge, kind).length > 0;\n\n/**\n * How a gap's hit runs over `edge`'s open panels (`DockEdge.hitBand`): its own, else, for a dynamic column, its side's\n * template's (`ColumnTemplate.hitBand`), else {@link DEFAULT_HIT_BAND}.\n */\nexport const hitBandOf = (state: DockState, edge: DockEdge): number | \"middle\" =>\n edge.hitBand ?? (edge.column === true && (edge.side === \"left\" || edge.side === \"right\") ? state.columns?.[edge.side]?.hitBand : undefined) ?? DEFAULT_HIT_BAND;\n\n/**\n * A dynamic column made from its side's template: every column the state makes (a drop on a column line, `moveTo` a new\n * column, `dockHome`, a stored column `readDockState` reads back) is made here, so each takes every template field\n * (`accepts`, `cross`, `gap`, `pad`, `menu`, `zoneAccepts`, `hitBand`).\n */\nexport const columnFromTemplate = (t: ColumnTemplate, id: string, side: \"left\" | \"right\", ring: number, items: readonly string[]): DockEdge => ({\n id,\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 ...(t.hitBand !== undefined ? { hitBand: t.hitBand } : {}),\n column: true,\n});\n\n/** How the rails of `side` show their items (`DockState.railModes`, default `\"titles\"`); top and bottom have no rails. */\nexport const railModeOf = (state: DockState, side: Side): RailMode => (side === \"left\" || side === \"right\" ? (state.railModes?.[side] === \"icons\" ? \"icons\" : \"titles\") : \"icons\");\n\n/** The axis an edge's stack runs along. */\nexport const axisOf = (side: Side): Orient => (side === \"left\" || side === \"right\" ? \"column\" : \"row\");\n\n/**\n * The rects `who` keeps clear of (`DockState.keepClear`): floats keep clear of every entry; drop targets, slots and\n * landings only of those for `\"all\"` (the default), never of a floats-only one.\n */\nexport const keepClearFor = (state: DockState, who: \"floats\" | \"targets\"): Rect[] =>\n (state.keepClear ?? []).filter((c) => who === \"floats\" || c.for !== \"floats\").map((c) => ({ x: c.x, y: c.y, width: c.width, height: c.height }));\n\n/**\n * The side's rail where the state declares none (`DockState.rails[side]`): its outermost column that takes `kind` in its\n * start zone (not an icons-only edge), which shows as a rail once nothing in it sets its width. Undefined where the side\n * has a declared rail, or no such column.\n */\nexport function railColumnOf(state: DockState, side: \"left\" | \"right\", kind: Kind): DockEdge | undefined {\n if (state.rails?.[side]) return undefined;\n return state.edges\n .filter((e) => e.side === side && !e.compact && e.hidden !== true && zoneTakes(e, \"start\", kind))\n .reduce<DockEdge | undefined>((m, e) => (!m || e.ring < m.ring ? e : m), undefined);\n}\n\n/** The state as the window shows it, and what it lent: see `viewOf`. */\nexport interface StateView {\n /** The state the window shows: no hidden edge; the items a hidden edge lends at the end of the edge it shows them in. */\n readonly view: DockState;\n /** Each lent item's hidden edge, by item id. */\n readonly lent: ReadonlyMap<string, string>;\n /** Hidden edges whose `showIn` is ignored: it names the edge itself, no edge, another hidden edge or a dynamic column. */\n readonly ignored: readonly string[];\n /** The items the view shows in a zone other than their own (`zoneIn`): their stored `align` is not where they lie. */\n readonly rezoned: ReadonlySet<string>;\n}\n\n/**\n * The zone `item` lies in on `edge`: its own (`align`) where the edge takes its kind there, else the first zone that\n * does; one the edge takes nowhere, in its own. A fixed item lies in its own where the edge has that zone (`zones`),\n * else in the edge's first zone, as a movable item lies in a zone the edge has. The item's zone is its own fact, not the edge's: this is where it is laid out and targeted, while its stored `align`\n * stays as it was, so it is back in its own zone on an edge that takes it there.\n */\nexport function zoneIn(edge: DockEdge, item: DockItem): Zone {\n const own = zoneOf(item);\n if (item.fixed) {\n const has = zonesOf(edge);\n return has.includes(own) ? own : (has[0] ?? own);\n }\n if (zoneTakes(edge, own, item.kind)) return own;\n return zonesTaking(edge, item.kind)[0] ?? own;\n}\n\n/**\n * Whether a drop on `edge` names a zone for `kind`: the edge offers a choice, more than one of its zones taking the\n * kind. Only then does the zone a drop gives become the item's `align`; on a one-zone edge (a rail that takes the kind\n * at its start only) the item keeps its own, and lies in that one zone there (`zoneIn`).\n */\nexport const namesZone = (edge: ZoneDecl, kind: Kind): boolean => zonesTaking(edge, kind).length > 1;\n\n/**\n * Whether a hidden edge's `showIn` names an edge it can lend its items to: another static edge of the state, not\n * hidden. A dynamic column (`column: true`) never is: drops make and delete those.\n */\nconst showInOf = (state: DockState, e: DockEdge): DockEdge | undefined => {\n if (e.hidden !== true || e.showIn === undefined) return undefined;\n const to = state.edges.find((x) => x.id === e.showIn);\n return to && to !== e && to.hidden !== true && to.column !== true ? to : undefined;\n};\n\n/**\n * The state as the window shows it (`DockEdge.hidden`, `DockEdge.showIn`): its hidden edges left out, and the items of a hidden\n * edge that names `showIn` lent to that edge, after its own items, each that edge takes the kind of (`edgeTakes`; a\n * fixed item never). Every docked item, lent or not, lies in the zone `zoneIn` gives it: its own where its edge takes\n * it there, else the first zone that does (the view's `align`; the stored one is unchanged). The same object when nothing\n * is hidden and every item lies in its own zone.\n */\nexport function viewOf(state: DockState): StateView {\n const lent = new Map<string, string>();\n const ignored: string[] = [];\n const added = new Map<string, string[]>();\n const hidden = state.edges.some((e) => e.hidden === true);\n if (hidden) {\n for (const e of state.edges) {\n if (e.hidden !== true || e.showIn === undefined) continue;\n const to = showInOf(state, e);\n if (!to) {\n ignored.push(e.id);\n continue;\n }\n for (const id of e.items) {\n const item = Object.hasOwn(state.items, id) ? state.items[id] : undefined;\n if (!item || item.fixed || lent.has(id) || to.items.includes(id) || !edgeTakes(to, item.kind)) continue;\n lent.set(id, e.id);\n added.set(to.id, [...(added.get(to.id) ?? []), id]);\n }\n }\n }\n const edges = hidden ? state.edges.filter((e) => e.hidden !== true).map((e) => (added.has(e.id) ? { ...e, items: [...e.items, ...added.get(e.id)!] } : e)) : state.edges;\n // Each docked item in the zone it lies in.\n const rezoned = new Set<string>();\n let items: Record<string, DockItem> | undefined;\n for (const e of edges) {\n for (const id of e.items) {\n const item = Object.hasOwn(state.items, id) ? state.items[id] : undefined;\n if (!item) continue;\n const zone = zoneIn(e, item);\n if (zone === zoneOf(item)) continue;\n const { align: _a, ...plain } = item;\n items ??= { ...state.items };\n items[id] = zone === \"start\" ? plain : { ...plain, align: zone };\n rezoned.add(id);\n }\n }\n if (!hidden && !items) return { view: state, lent, ignored, rezoned };\n return { view: { ...state, edges, ...(items ? { items } : {}) }, lent, ignored, rezoned };\n}\n\n/** Whether item `id` lies in a hidden edge. */\nexport const inHiddenEdge = (state: DockState, id: string): boolean => state.edges.some((e) => e.hidden === true && e.items.includes(id));\n\n/**\n * `shown`, a state made from `viewOf(state).view` (a drop's result), with `state`'s hidden edges put back where they\n * stood in its edge list, holding their items. The items they lent go back to them, as they were, unless `moved` is\n * one of them: the item a drop committed somewhere, which keeps its new place and leaves its hidden edge. On a side whose\n * shown edges are those it had, nothing is renumbered. On a side where a column was made or removed, each hidden edge\n * goes back by its own ring, before the first shown edge that lay further in than it did, and the side is numbered again\n * from 0 in that order.\n *\n * Every item the view laid out in a zone other than its own (`rezoned`) keeps its stored `align`; so does `moved`, the\n * item a drop committed, unless the drop named a zone (`zoned`: a gap in an edge), whose zone it then takes.\n */\nexport function withHiddenOf(state: DockState, shown: DockState, lent: ReadonlyMap<string, string> = new Map(), moved?: string, zoned = false, rezoned: ReadonlySet<string> = new Set()): DockState {\n if (shown === state) return shown;\n // The lent items that stay lent: out of the edges they were shown in, back into their hidden edges.\n const back = [...lent.keys()].filter((id) => id !== moved);\n const edges = shown.edges.filter((e) => e.hidden !== true).map((e) => (back.some((id) => e.items.includes(id)) ? { ...e, items: e.items.filter((id) => !back.includes(id)) } : e));\n state.edges.forEach((e, i) => {\n if (e.hidden !== true) return;\n const own = moved !== undefined && lent.get(moved) === e.id ? { ...e, items: e.items.filter((id) => id !== moved) } : e;\n edges.splice(Math.min(i, edges.length), 0, own);\n });\n const items: Record<string, DockItem> = back.length > 0 ? { ...shown.items, ...Object.fromEntries(back.map((id) => [id, state.items[id]!])) } : { ...shown.items };\n // The item's zone is its own fact: only a drop that names a zone changes it.\n const keep = new Set([...rezoned].filter((id) => !back.includes(id) && !(id === moved && zoned)));\n if (moved !== undefined && !zoned) keep.add(moved);\n for (const id of keep) {\n const was = Object.hasOwn(state.items, id) ? state.items[id] : undefined;\n const now = Object.hasOwn(items, id) ? items[id] : undefined;\n if (!was || !now || now.align === was.align) continue;\n const { align: _a, ...plain } = now;\n items[id] = was.align === undefined ? plain : { ...plain, align: was.align };\n }\n const ringBefore = new Map(state.edges.filter((e) => e.hidden !== true).map((e) => [e.id, e.ring]));\n for (const side of new Set(state.edges.filter((e) => e.hidden === true).map((e) => e.side))) {\n const was = state.edges.filter((e) => e.side === side && e.hidden !== true).map((e) => e.id).sort();\n const now = edges.filter((e) => e.side === side && e.hidden !== true);\n if (now.length === was.length && now.every((e) => was.includes(e.id))) continue;\n const order = [...now].sort((a, b) => a.ring - b.ring || edges.indexOf(a) - edges.indexOf(b));\n for (const h of edges.filter((e) => e.side === side && e.hidden === true).sort((a, b) => a.ring - b.ring)) {\n const k = order.findIndex((e) => e.hidden !== true && (ringBefore.get(e.id) ?? -Infinity) > h.ring);\n order.splice(k < 0 ? order.length : k, 0, h);\n }\n order.forEach((e, ring) => {\n if (e.ring !== ring) edges[edges.indexOf(e)] = { ...e, ring };\n });\n }\n return { ...shown, edges, items };\n}\n\n/** A kind's rail drop policy with its defaults, or null where it has none or it is turned off (width 0, `\"never\"`). */\nexport function railPolicyOf(state: DockState, kind: Kind): { readonly railStripWidth: number | null; readonly railVisibility: RailVisibility; readonly magnet: number; readonly floatNearEdge: boolean } | null {\n const p = Object.hasOwn(state.railDrop ?? {}, kind) ? state.railDrop![kind] : undefined;\n if (!p) return null;\n const visibility: RailVisibility = p.railVisibility === \"always\" || p.railVisibility === \"never\" ? p.railVisibility : \"whileDragging\";\n const width = p.railStripWidth;\n if (visibility === \"never\" || (width !== undefined && !(Number.isFinite(width) && width > 0))) return null;\n return {\n railStripWidth: width === undefined ? null : Math.max(RAIL_STRIP_MIN, width),\n railVisibility: visibility,\n magnet: Number.isFinite(p.magnet) ? Math.max(0, p.magnet!) : DEFAULT_RAIL_MAGNET,\n floatNearEdge: p.floatNearEdge !== false,\n };\n}\nexport const zoneOf = (item: DockItem | undefined): Zone => (item?.align === \"center\" || item?.align === \"end\" ? item.align : \"start\");\nexport const formsOf = (item: DockItem, axis: Orient): readonly StackForm[] => item.forms[axis] ?? [];\n\n/**\n * What a form tells of its controls, as an item's layout reports it: `hidden` (`StackForm.hides`) and `tiers`\n * (`StackForm.tiers`, left out when the form has none). One reader for every path that lays an item out.\n */\nexport const controlsOf = (f: StackForm | undefined): { hidden: readonly string[]; tiers?: Readonly<Record<string, number>> } => ({ hidden: f?.hides ?? [], ...(f?.tiers ? { tiers: f.tiers } : {}) });\n\nconst PANEL_FORMS: ReadonlySet<string> = new Set([\"open\", \"header\", \"rail\"]);\n/** A panel that counts as docked for `insetWhen: \"docked\"`: not closed, not fixed, its first column form a panel's (open, header or rail). */\nexport const isDockingPanel = (item: DockItem): boolean => !item.closed && !item.fixed && PANEL_FORMS.has(formsOf(item, \"column\")[0]?.kind ?? \"\");\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(state: DockState, e: DockEdge): boolean {\n return e.outsideInset === true && isSideBar(state, 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 (`DockState.columns[side].accepts`, `DockState.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(state: DockState, e: DockEdge): boolean {\n if ((e.side !== \"left\" && e.side !== \"right\") || e.column === true || e.accepts.length === 0) return false;\n const template = state.columns?.[e.side];\n const rail = state.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/** A left or right column: a side edge that takes something, not a compact rail and not a toolbar bar (`isSideBar`). */\nexport const isSideColumn = (state: DockState, e: DockEdge): boolean => (e.side === \"left\" || e.side === \"right\") && !e.compact && e.accepts.length > 0 && !isSideBar(state, e);\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: DockItem): 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\nconst sized = (s: Size | undefined): s is Size => !!s && Number.isFinite(s.width) && Number.isFinite(s.height) && s.width > 0 && s.height > 0;\n\n/**\n * Whether `item` declares `floatSizes` (the per-orient float sizes). Only such an item is sized per orient; one that\n * declares none is framed as before them: a float at its first form keeps its stored rect.\n */\nexport const declaresFloatSizes = (item: DockItem): boolean => item.floatSizes !== undefined && item.floatSizes !== null;\n\n/**\n * The natural size of `item`'s first form along `orient`, a form whose length is its own: its main natural length along\n * `orient` and its cross. Undefined when the item has no form there, or that form grows (a panel's card has no natural\n * float length) or has no size.\n */\nfunction naturalFloatSize(item: DockItem, orient: Orient): Size | undefined {\n const f = formsOf(item, orient)[0];\n if (!f || f.main.grows) return undefined;\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 undefined;\n return orient === \"row\" ? { width: main, height: cross } : { width: cross, height: main };\n}\n\n/** `item`'s usable float sizes by orient (its `floatSizes`); undefined when it has none. */\nexport function floatSizesOf(item: DockItem): { row?: Size; column?: Size } | undefined {\n const out: { row?: Size; column?: Size } = {};\n for (const o of [\"row\", \"column\"] as const) {\n const s = item.floatSizes?.[o];\n if (sized(s)) out[o] = s;\n }\n return out.row || out.column ? out : undefined;\n}\n\n/**\n * A float's size along `orient` (default `floatOrientOf`) when nothing else gives one: the item's `floatSizes` for that\n * orient, else its first form's natural size along `orient`, or `DEFAULT_FLOAT_SIZE` when that form grows (a panel's\n * card has no natural float length) or the item has no form there.\n */\nexport function floatSizeOf(item: DockItem, orient: Orient = floatOrientOf(item)): Size {\n const own = item.floatSizes?.[orient];\n if (sized(own)) return own;\n return naturalFloatSize(item, orient) ?? DEFAULT_FLOAT_SIZE;\n}\n\n/**\n * Why `item`, drawn in form `form` of `forms` (the forms of the axis it lies along), counts as folded\n * (`DockItemLayout.foldedBy`): `\"hand\"` when it is folded by hand and that axis has a folded form (`startOf` over 0),\n * else `\"auto\"` when `form` lies below `start`, the form it started in (it gave way), else undefined. A closed item, or\n * one in its first form, is never folded. Leave `start` out where nothing gives way (a float).\n */\nexport function foldedByOf(item: DockItem, forms: readonly StackForm[], form: number, start?: number, edge?: DockEdge): \"hand\" | \"auto\" | undefined {\n if (item.closed || form < 1) return undefined;\n if (startOf(item, forms, edge) > 0) return \"hand\";\n return start !== undefined && form > start ? \"auto\" : undefined;\n}\n\n/** Whether `item` is folded by hand: its `from` is 1 or more (`foldItem(state, id, true)` sets it). */\nconst foldedByHand = (item: DockItem): boolean => Number.isFinite(item.from) && Math.floor(item.from!) >= 1;\n\n/**\n * Whether `item`, lying on `edge`, folds to its `rail` tile when it has no header or fold: a fixed item on a `foldable`\n * edge (a thumbnail anchor, whose column draws as a rail once it folds). The one rule `solve`, `canFold` and `foldItem` share.\n */\nconst foldsToRail = (item: DockItem, edge: DockEdge | undefined): boolean => !!item.fixed && edge?.foldable === true;\n\n/**\n * The index of the form a hand fold puts `item` in, among `forms`: the first that shows only its bar (`formFolded`: a\n * panel's `header`, its title bar, or a group's `fold`, its grip and »); where it `foldsToRail` on `edge` and has neither, its first `rail` tile.\n * -1 when there is none: a hand fold means nothing on this axis.\n */\nexport function foldedIndex(item: DockItem, forms: readonly StackForm[], edge?: DockEdge): number {\n const bar = forms.findIndex(formFolded);\n return bar >= 0 || !foldsToRail(item, edge) ? bar : forms.findIndex((f) => f.kind === \"rail\");\n}\n\n/**\n * Where `item`'s ladder starts among `forms`, the forms of the axis it lies along (on `edge`, when docked). Not folded\n * by hand: its first form. Folded by hand (`from` 1 or more): its folded form there (`foldedIndex`), or `from` itself\n * where a stored state put it further down; with no folded form there, its first form (a hand fold means nothing).\n * Give-way steps down from there.\n */\nexport function startOf(item: DockItem, forms: readonly StackForm[], edge?: DockEdge): number {\n if (!foldedByHand(item)) return 0;\n const folded = foldedIndex(item, forms, edge);\n return folded < 0 ? 0 : Math.min(Math.max(folded, Math.floor(item.from!)), forms.length - 1);\n}\n\n/**\n * The state as it places item `id`: the window's (`viewOf`) when a hidden edge lends it to another edge, so its edge is\n * the one `solve` draws it in; else `state` itself.\n */\nexport function placingOf(state: DockState, id: string): DockState {\n if (!state.edges.some((e) => e.hidden === true && e.showIn !== undefined && e.items.includes(id))) return state;\n const { view, lent } = viewOf(state);\n return lent.has(id) ? view : state;\n}\n\n/** The axes item `id` lies along: its edge's (the one it is drawn in, when lent), its float's orient; both when it lies nowhere. */\nexport function axesOf(given: DockState, id: string): Orient[] {\n const state = placingOf(given, id);\n const item = state.items[id];\n const edge = state.edges.find((e) => e.items.includes(id));\n if (edge) return [axisOf(edge.side)];\n const float = state.floats.find((f) => f.id === id);\n return float && item ? [float.orient ?? floatOrientOf(item)] : [\"row\", \"column\"];\n}\n\n/**\n * Whether item `id` is folded by hand where it lies, as `solve` draws it: its `from` is 1 or more and it has a folded\n * form on the axis it lies along (`startOf` over 0). A stored `from` with no folded form there is no fold. Every reader\n * of the hand fold asks this, never `from` itself.\n */\nexport function isHandFolded(given: DockState, id: string): boolean {\n const state = placingOf(given, id);\n const item = Object.hasOwn(given.items, id) ? given.items[id] : undefined;\n const edge = state.edges.find((e) => e.items.includes(id));\n return !!item && axesOf(state, id).some((a) => startOf(item, formsOf(item, a), edge) > 0);\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 where that form grows, else `floatSizeOf(item, orient)`: the size kept for\n * that orient (`floatSizes`, which `floatAt` with a rect and a hand resize write), and only without one that form's\n * natural size along its orient. So a toolbar group's float given an\n * explicit size keeps it; one given none fits its content; and one turned to the other orient never keeps the rect it\n * had in the old one. Per-orient sizes apply only to an item that declares `floatSizes` (`declaresFloatSizes`); one\n * that declares none keeps its stored rect at its first form, as before them.\n */\nexport function floatShape(item: DockItem, 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 = startOf(item, forms);\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 // The first form: a form that grows (a panel's card) is the rect's size, the one the user sizes; any other (a toolbar\n // group) is the size kept for its orient (an explicit size stays), else its own natural size (`floatSizeOf`), never a\n // rect left from the other orient. An item that declares no `floatSizes` keeps its stored rect, as before them.\n return { form, ...(fm.main.grows || !declaresFloatSizes(item) ? { width: w, height: h } : floatSizeOf(item, orient)) };\n}\n","/**\n * `solve(state, { previous })`: the whole window's layout from one state.\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; an overlay bar\n * with `span: \"full\"` set by name runs across the full bars' width, over the columns too, at the content's top or\n * bottom.\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 `DockEdge.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 centered 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, and\n * keeps clear of every float with a rect of its own and of the anchored floats floated before it (`since`, then id)\n * too, where room exists; the stacking order plays no part, so `raiseFloat` reshapes nothing. 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** (`DockEdge.column`, on a side with `DockState.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 * 7. **Bars by height** (`DockEdge.giveWay` on a top or bottom bar): while the content is shorter than `contentMin.height`\n * (overlay bars counted), those bars shrink across toward their minimum, then fold one by one to their items' next\n * form that fits across; the state is laid out again under the caps this gives each bar (`barGiveWay`).\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 state always lays out the same.\n *\n * The phases live in `./solve/`: `order` (the laying order), `edge` (one edge's stack), `draft` (drawing an edge),\n * `bars`, `bar-giveway` (bars by height), `insets`, `sides`, `columns` (give-way), `rails` (folded columns), `floats`\n * and `notes`.\n */\nimport { rect, type Rect } from \"@n-uf/placement\";\nimport { viewOf } from \"./helpers\";\nimport { checkEdgeIds } from \"./targets/ids\";\nimport type { DockState, DockLayout, DockNote, SolveOptions } from \"./model\";\nimport { barGiveWay } from \"./solve/bar-giveway\";\nimport { cutEdge } from \"./solve/bars\";\nimport { createDraft } from \"./solve/draft\";\nimport { layFloats } from \"./solve/floats\";\nimport { insetOf, insideInset } from \"./solve/insets\";\nimport { contentNotes } from \"./solve/notes\";\nimport { finite, isSide, px } from \"./solve/order\";\nimport { laySides } from \"./solve/sides\";\n\nexport { layKeys, pushes, type LayKey } from \"./solve/order\";\n\n/** The state each layout `solve` returned was solved from (kept off the layout, so a layout is exactly what it was). */\nconst solvedFrom = new WeakMap<DockLayout, DockState>();\n/** The state `layout` was solved from, or undefined for a layout `solve` didn't return (one stored and read back, say). */\nexport const stateOf = (layout: DockLayout): DockState | undefined => solvedFrom.get(layout);\n\nexport function solve(given: DockState, options: SolveOptions = {}): DockLayout {\n const layout = solveState(given, options);\n solvedFrom.set(layout, given);\n return layout;\n}\n\nfunction solveState(given: DockState, options: SolveOptions): DockLayout {\n checkEdgeIds(given);\n // A hidden edge is not part of the window: the layout is the shown state's, its items placed nowhere, or in the edge\n // its `showIn` names.\n const { view: shown, ignored } = viewOf(given);\n const lay = (caps: ReadonlyMap<string, number>, gave: readonly DockNote[] = []): DockLayout => layOut(shown, options, caps, gave);\n const first = lay(new Map());\n const way = barGiveWay(shown, first, lay);\n const l = way ? lay(way.caps, way.notes) : first;\n return ignored.length === 0 ? l : { ...l, notes: [...l.notes, ...ignored.map((edge): DockNote => ({ code: \"show-in-ignored\", edge }))] };\n}\n\n/** `area`'s top and height on `over`'s left and width. */\nconst withHeightOf = (area: Rect, over: Rect): Rect => rect(over.x, area.y, over.width, area.height);\n\n/** One pass of the layout under height give-way's `caps`, its notes (`gave`) before the content's. */\nfunction layOut(given: DockState, options: SolveOptions, caps: ReadonlyMap<string, number>, gave: readonly DockNote[]): DockLayout {\n const d = createDraft(given, options, caps);\n const { state, order } = d;\n const stage = rect(finite(state.stage.x, 0), finite(state.stage.y, 0), px(state.stage.width), px(state.stage.height));\n const { inset, docked } = insetOf(d);\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: (typeof order)[number]): boolean => !isSide(e) && e.span !== \"between\" && e.outsideInset === true;\n let outer = stage;\n for (const e of reserved) if (outsideBar(e)) outer = cutEdge(d, e, outer, true);\n let area = insideInset(outer, inset);\n for (const e of reserved) if (!isSide(e) && e.span !== \"between\" && !outsideBar(e)) area = cutEdge(d, e, area, true);\n // The width the full bars run across, before the columns: an overlay bar with `span: \"full\"` lies over the columns too.\n const wide = area;\n area = laySides(d, reserved.filter(isSide), area, { inset, gutter: px(state.gutter), docked, outer });\n for (const e of reserved) if (!isSide(e) && e.span === \"between\") area = cutEdge(d, e, area, true);\n const content = area;\n let over = content;\n for (const e of order) {\n if (e.mode !== \"overlay\") continue;\n // An overlay bar lies over the content unless it asks for the full width by name: one with no `span` keeps the\n // content's width, as it always has.\n if (isSide(e) || e.span !== \"full\") over = cutEdge(d, e, over, true);\n // `span: \"full\"`: across the full bars' width (the window's, with `outsideInset`), over the content's height left so\n // far.\n else {\n const across = e.outsideInset === true ? outer : wide;\n over = withHeightOf(cutEdge(d, e, rect(across.x, over.y, across.width, over.height), true), over);\n }\n }\n for (const n of gave) {\n d.notes.push(n);\n if (n.code === \"bar-shrunk\" && d.edges[n.edge]) d.edges[n.edge] = { ...d.edges[n.edge]!, shrunk: true };\n }\n contentNotes(d, content);\n const floats = layFloats(d, stage, content, inset);\n const { items, edges, rails, railPlaces, columnRoom, notes } = d;\n return { items, edges, content, floats, rails, railPlaces, ...(columnRoom !== undefined ? { columnRoom } : {}), notes };\n}\n","/**\n * The one id scheme of the DockState's targets and refusals: every id `targets`, `refusals` and `stops` give is built here,\n * and a host reads one back with `parseTargetId` instead of splitting strings.\n *\n * | Id | What it names | Priority |\n * |---|---|---|\n * | `gap:<edge>:<zone>:<at>` | a slot before the `at`-th item of an edge's zone | 2 |\n * | `strip:<edge>:<zone>` | a zone's one slot on an edge with no members at all | 2 |\n * | `column:<side>:<ring>` | a new column on a side's column line | 2 |\n * | `rail:<side>:<ring>` | docking folded into a side's rail | 1 |\n * | `side:<side>` | a fixed anchor's edge moved to the other side of its axis (`DockEdge.moves: \"side\"`) | 2 |\n * | `home:<item>` | the item's own place (a release there puts it back) | 1 |\n * | `float:<item>` | floating anywhere | 3 |\n * | `none:<i>` | the `i`-th `blocked` rect | 1 |\n * | `refuse:<edge>:<zone>[:<n>]` | a refusal; `:<n>` from a zone's second refused tile on, by where it lies | — |\n *\n * An edge id may hold `:` (the zone and the numbers are read from the right). The virtual edges a refusal can name are\n * `column:<side>` (a side's column lines) and `rail:<side>` (its rail): `virtualEdgeId`.\n */\nimport type { DockState, Side, Zone } from \"../model\";\n\ntype ColumnSide = \"left\" | \"right\";\n\n/** A `DropPlace`, as much of it as an id reads (this module imports no more of the state, so `solve` may use it). */\ntype PlaceLike =\n | { readonly kind: \"gap\"; readonly edge: string; readonly zone: Zone; readonly at: number }\n | { readonly kind: \"column\" | \"rail\"; readonly side: ColumnSide; readonly ring: number }\n | { readonly kind: \"side\"; readonly side: Side }\n | { readonly kind: \"float\" | \"home\" | \"none\" };\n\n/** A target or refusal id, read. */\nexport type TargetIdParts =\n | { readonly kind: \"gap\"; readonly edge: string; readonly zone: Zone; readonly at: number }\n | { readonly kind: \"strip\"; readonly edge: string; readonly zone: Zone }\n | { readonly kind: \"column\" | \"rail\"; readonly side: ColumnSide; readonly ring: number }\n | { readonly kind: \"side\"; readonly side: Side }\n | { readonly kind: \"home\" | \"float\"; readonly item: string }\n | { readonly kind: \"none\"; readonly index: number }\n | { readonly kind: \"refuse\"; readonly edge: string; readonly zone: Zone; readonly n: number };\n\n/** The id of the target or refusal `parts` names. */\nexport function targetId(parts: TargetIdParts): string {\n switch (parts.kind) {\n case \"gap\":\n return `gap:${parts.edge}:${parts.zone}:${parts.at}`;\n case \"strip\":\n return `strip:${parts.edge}:${parts.zone}`;\n case \"column\":\n case \"rail\":\n return `${parts.kind}:${parts.side}:${parts.ring}`;\n case \"side\":\n return `side:${parts.side}`;\n case \"home\":\n case \"float\":\n return `${parts.kind}:${parts.item}`;\n case \"none\":\n return `none:${parts.index}`;\n case \"refuse\":\n return parts.n === 0 ? `refuse:${parts.edge}:${parts.zone}` : `refuse:${parts.edge}:${parts.zone}:${parts.n}`;\n }\n}\n\nconst ZONE = \"(start|center|end)\";\nconst INT = \"(-?\\\\d+)\";\nconst GAP = new RegExp(`^gap:(.+):${ZONE}:${INT}$`);\nconst STRIP = new RegExp(`^strip:(.+):${ZONE}$`);\nconst LINE = new RegExp(`^(column|rail):(left|right):${INT}$`);\nconst SIDE = /^side:(left|right|top|bottom)$/;\nconst ITEM = /^(home|float):(.+)$/;\nconst NONE = new RegExp(`^none:${INT}$`);\nconst REFUSE = new RegExp(`^refuse:(.+):${ZONE}(?::${INT})?$`);\n\n/** What `id` names, or null when it is no id of the scheme. `targetId(parseTargetId(id)!) === id` for every id it reads. */\nexport function parseTargetId(id: string): TargetIdParts | null {\n let m: RegExpExecArray | null;\n if ((m = GAP.exec(id))) return { kind: \"gap\", edge: m[1]!, zone: m[2] as Zone, at: Number(m[3]) };\n if ((m = STRIP.exec(id))) return { kind: \"strip\", edge: m[1]!, zone: m[2] as Zone };\n if ((m = LINE.exec(id))) return { kind: m[1] as \"column\" | \"rail\", side: m[2] as ColumnSide, ring: Number(m[3]) };\n if ((m = SIDE.exec(id))) return { kind: \"side\", side: m[1] as Side };\n if ((m = ITEM.exec(id))) return { kind: m[1] as \"home\" | \"float\", item: m[2]! };\n if ((m = NONE.exec(id))) return { kind: \"none\", index: Number(m[1]) };\n if ((m = REFUSE.exec(id))) return { kind: \"refuse\", edge: m[1]!, zone: m[2] as Zone, n: m[3] === undefined ? 0 : Number(m[3]) };\n return null;\n}\n\n/** The id of a side's virtual edge: its column lines (`column:<side>`) or its rail (`rail:<side>`), as a refusal names it. */\nexport const virtualEdgeId = (kind: \"column\" | \"rail\", side: ColumnSide): string => `${kind}:${side}`;\n\n/** The edge ids that name a side's virtual edges: no real edge may take one. */\nconst RESERVED_EDGE_IDS = new Set(([\"column\", \"rail\"] as const).flatMap((k) => ([\"left\", \"right\"] as const).map((s) => virtualEdgeId(k, s))));\nexport const isReservedEdgeId = (id: string): boolean => RESERVED_EDGE_IDS.has(id);\n\n/** Throws when a real edge of `state` takes a virtual edge's id (`column:<side>`, `rail:<side>`); `solve`, `targets` and `readDockState` check it. */\nexport function checkEdgeIds(state: DockState): void {\n for (const e of state.edges) {\n if (isReservedEdgeId(e.id)) throw new Error(`docking: the edge id \"${e.id}\" is reserved for a side's virtual edge (column:<side>, rail:<side>); name the edge otherwise`);\n }\n}\n\n/**\n * The id `targets` gives the target at `place` for `item`, or null for a place with no fixed id (`none`). A gap's id is\n * its `gap:` one; on an edge with no members its slot is `strip:<edge>:<zone>`.\n */\nexport function placeTargetId(place: PlaceLike, item: string): string | null {\n switch (place.kind) {\n case \"gap\":\n return targetId(place);\n case \"column\":\n case \"rail\":\n return targetId(place);\n case \"side\":\n return targetId({ kind: \"side\", side: place.side });\n case \"float\":\n case \"home\":\n return targetId({ kind: place.kind, item });\n default:\n return null;\n }\n}\n","/**\n * Bars by height: while the content is shorter than `contentMin.height` (overlay bars counted), the top and bottom bars\n * with `giveWay` shrink across toward their minimum, then fold (their items step to the next form that fits across), in\n * give-way order (`giveWayOrder`: unkept before kept, the oldest newest use first, the outer first). It answers with a\n * cap per bar, which `solve` lays the state out again under (`cutEdge` solves each bar at its cap), and the notes.\n * Stateless: room coming back undoes it in reverse.\n */\nimport { EPS } from \"@n-uf/placement\";\nimport { formCrossMin, formSetsCross } from \"@n-uf/placement/stack\";\nimport { formsOf } from \"../helpers\";\nimport type { DockEdge, DockState, DockLayout, DockNote } from \"../model\";\nimport { cutOrder, finite, giveWayOrder, isSide, px, type GiveWayRank } from \"./order\";\n\n/** How far under a bar's thinnest open form a fold's cap lies, so every such form steps down. */\nconst UNDER = 0.5;\n\n/** The content's height less the overlay bars over it. */\nfunction roomOf(state: DockState, l: DockLayout): number {\n const bars = state.edges.filter((e) => e.mode === \"overlay\" && !isSide(e)).reduce((s, e) => s + (l.edges[e.id]?.cross ?? 0), 0);\n return l.content.height - bars;\n}\n\n/** The items a bar draws that set its size across, with their forms' least size across. */\nfunction settersOf(state: DockState, l: DockLayout, edge: DockEdge): number[] {\n return (l.edges[edge.id]?.items ?? []).flatMap((id) => {\n const at = l.items[id];\n const item = state.items[id];\n if (!at || !item || at.inMenu) return [];\n const f = formsOf(item, \"row\")[at.form];\n return f && formSetsCross(f) ? [formCrossMin(f)] : [];\n });\n}\n\n/**\n * The caps and notes of height give-way for `state`, from its first layout `first`; `lay` lays it out under caps. Null\n * when nothing gives way.\n */\nexport function barGiveWay(\n state: DockState,\n first: DockLayout,\n lay: (caps: ReadonlyMap<string, number>) => DockLayout,\n): { caps: Map<string, number>; notes: DockNote[] } | null {\n if (!state.contentMin) return null;\n const minH = px(state.contentMin.height);\n const shortOf = (l: DockLayout): number => minH - roomOf(state, l);\n if (shortOf(first) <= EPS) return null;\n const rankOf = (edge: DockEdge): GiveWayRank => {\n const items = (first.edges[edge.id]?.items ?? []).filter((id) => state.items[id] !== undefined);\n return {\n edge,\n kept: items.some((id) => state.items[id]!.kept === true),\n age: Math.max(-Infinity, ...items.map((id) => finite(state.items[id]!.used, 0))),\n };\n };\n const bars = cutOrder(state.edges)\n .filter((e) => !isSide(e) && e.giveWay === true && (first.edges[e.id]?.cross ?? 0) > EPS)\n .map(rankOf)\n .sort(giveWayOrder)\n .map((r) => r.edge);\n if (bars.length === 0) return null;\n /** Fold caps, by edge id: under the bar's thinnest open form, so its items step down. */\n const folds = new Map<string, number>();\n /** The shrink caps, with `folds` folded, from the layout `l` they make: each bar toward its minimum, in order. */\n const shrinkFrom = (l: DockLayout): { caps: Map<string, number>; notes: DockNote[]; left: number } => {\n const caps = new Map(folds);\n const notes: DockNote[] = [];\n let left = shortOf(l);\n for (const e of bars) {\n if (left <= EPS) break;\n if (folds.has(e.id)) continue;\n const cross = l.edges[e.id]?.cross ?? 0;\n const min = Math.max(px(e.cross.min), ...settersOf(state, l, e));\n const cut = Math.min(left, cross - min);\n if (cut <= EPS) continue;\n caps.set(e.id, cross - cut);\n notes.push({ code: \"bar-shrunk\", edge: e.id, from: cross, to: cross - cut });\n left -= cut;\n }\n return { caps, notes, left };\n };\n let base = first;\n let way = shrinkFrom(base);\n // Still short with every bar at its minimum: fold the bars, one at a time in the same order, each fold re-weighing\n // the shrinks of the rest, until the content fits.\n for (const e of bars) {\n if (way.left <= EPS) break;\n const setters = settersOf(state, first, e);\n if (setters.length === 0) continue;\n folds.set(e.id, Math.min(...setters) - UNDER);\n const l = lay(folds);\n if ((l.edges[e.id]?.cross ?? 0) >= (base.edges[e.id]?.cross ?? 0) - EPS) {\n // Nothing of it could step down: it keeps its size.\n folds.delete(e.id);\n continue;\n }\n base = l;\n way = shrinkFrom(base);\n }\n if (way.caps.size === 0) return null;\n return { caps: way.caps, notes: [...way.notes, ...[...folds.keys()].map((edge): DockNote => ({ code: \"bar-folded\", edge }))] };\n}\n","/**\n * The order `solve` lays edges in, and the small number helpers every phase shares. Internal to the state: `targets`\n * ranks the space each edge owns by the same order (`layKeys`, `pushes`).\n */\nimport { zoneOf } from \"../helpers\";\nimport type { DockEdge, DockState, Zone } from \"../model\";\n\nexport const finite = (x: number | undefined, fallback: number): number => (typeof x === \"number\" && Number.isFinite(x) ? x : fallback);\nexport const px = (x: number | undefined): number => Math.max(0, finite(x, 0));\n\n/** A left or right edge. */\nexport const isSide = (e: DockEdge): boolean => e.side === \"left\" || e.side === \"right\";\n\n/** What give-way weighs an edge by: whether an item of it is kept, its newest use, its ring. */\nexport interface GiveWayRank {\n readonly kept: boolean;\n readonly age: number;\n readonly edge: DockEdge;\n}\n\n/**\n * The give-way order, for columns by width and bars by height alike: unkept before kept, the one whose newest use is\n * oldest first, the outer first. Ties stay as they are (a sort keeps them in order).\n */\nexport const giveWayOrder = (a: GiveWayRank, b: GiveWayRank): number =>\n Number(a.kept) - Number(b.kept) || a.age - b.age || finite(a.edge.ring, 0) - finite(b.edge.ring, 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 DockEdge[]): DockEdge[] {\n const phase = (e: DockEdge): number => (e.side === \"left\" || e.side === \"right\" ? 1 : e.span === \"between\" ? 2 : 0);\n const sideRank = (e: DockEdge): number => (e.side === \"top\" || e.side === \"left\" ? 0 : 1);\n return edges\n .map((e, i) => ({ e, i }))\n .sort((a, b) => phase(a.e) - phase(b.e) || sideRank(a.e) - sideRank(b.e) || finite(a.e.ring, 0) - finite(b.e.ring, 0) || a.i - b.i)\n .map((x) => x.e);\n}\n\n/**\n * Where `solve` lays an edge in its laying order: `phase` 0 full bars outside the inset, 1 the other full bars, 2 the\n * sides, 3 the `between` bars, 4 overlay edges (laid over the content, pushing nothing); `at`, its place in the cut\n * order. Internal to the state: `targets` ranks the space each edge owns by it.\n */\nexport interface LayKey {\n readonly phase: number;\n readonly side: string;\n readonly at: number;\n}\n\n/** Each edge's `LayKey`. */\nexport function layKeys(state: DockState): Map<string, LayKey> {\n const phase = (e: DockEdge): number => (e.mode === \"overlay\" ? 4 : isSide(e) ? 2 : e.span === \"between\" ? 3 : e.outsideInset === true ? 0 : 1);\n return new Map(cutOrder(state.edges).map((e, at) => [e.id, { phase: phase(e), side: e.side, at }]));\n}\n\n/**\n * Whether the edge laid at `a` takes its space before the edge at `b` can, so that filling `a` pushes `b`: a reserved\n * edge of an earlier phase, or one laid before it on the same side (the outer ring). Edges laid independently (the two\n * sides, top and bottom, any overlay edge) push neither way.\n */\nexport function pushes(a: LayKey, b: LayKey): boolean {\n if (a.phase === 4 || b.phase === 4) return false;\n if (a.phase !== b.phase) return a.phase < b.phase;\n return a.side === b.side && a.at < b.at;\n}\n\nconst ZONE_RANK: Record<Zone, number> = { start: 0, center: 1, end: 2 };\n\n/** The ids of an edge in drawing order: its items stably sorted by zone. */\nexport function zoneSorted(state: DockState, ids: readonly string[]): string[] {\n return ids\n .map((id, i) => ({ id, i, z: ZONE_RANK[zoneOf(state.items[id])] }))\n .sort((a, b) => a.z - b.z || a.i - b.i)\n .map((x) => x.id);\n}\n","/**\n * The cut of one edge laid by itself (the full and `between` bars, and every overlay edge): its stack along the area's\n * length, drawn at the area's side as thick as the stack, the area less that thickness after it. A bar that gave way by\n * height (`bar-giveway`) is solved at its cap.\n */\nimport type { Rect } from \"@n-uf/placement\";\nimport { cutEdges } from \"@n-uf/placement/stack\";\nimport { axisOf } from \"../helpers\";\nimport type { DockEdge } from \"../model\";\nimport { emit, type Draft } from \"./draft\";\nimport { solveEdge } from \"./edge\";\n\n/** Lays `edge` at its side of `area`; returns what is left of `area` (all of it when `cut` is false). */\nexport function cutEdge(d: Draft, edge: DockEdge, 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 // Height give-way's cap, when it shrank or folded this bar.\n const cap = d.caps.get(edge.id);\n const solvedAs = cap === undefined ? edge : { ...edge, cross: { ...edge.cross, max: Math.min(edge.cross.max, cap) } };\n const solved = solveEdge(d.state, solvedAs, d.owned.get(edge)!, length, room, d.prevEdge(edge));\n // The edge is one band of the general cut (`cutEdges`), as thick as its stack: none while it lays out nothing.\n const band = cutEdges(area, [{ id: edge.id, side: edge.side, size: solved.stack.items.length === 0 ? 0 : solved.stack.cross }]);\n emit(d, edge, band.bands[edge.id]!, solved);\n return cut ? band.rest : area;\n}\n","/**\n * The layout as `solve` builds it, phase by phase: who owns which item, the notes, and every item and edge drawn so\n * far. `emit` draws one solved edge into it: its items placed by zone, their shapes, its notes and its edge layout.\n */\nimport { EPS, rect, type Rect } from \"@n-uf/placement\";\nimport { formMain, itemSteps, wrapLines, type StackFit, type StackForm, type StackInput } from \"@n-uf/placement/stack\";\nimport { axisOf, controlsOf, foldedByOf, formsOf, zoneOf } from \"../helpers\";\nimport type { DockEdge, DockState, DockEdgeLayout, DockItemLayout, DockLayout, DockNote, DockRailLayout, SolveOptions, Zone } from \"../model\";\nimport type { EdgeSolve } from \"./edge\";\nimport { cutOrder, finite, px } from \"./order\";\n\nexport interface Draft {\n /** The state as solved: an item that has just opened counts as the newest. */\n readonly state: DockState;\n readonly previous: DockLayout | undefined;\n /** Items docked now that were closed or absent in `previous`. */\n readonly opened: ReadonlySet<string>;\n /** `SolveOptions.fresh`. */\n readonly fresh: ReadonlySet<string>;\n /** The edges in cut order. */\n readonly order: readonly DockEdge[];\n /** Each edge's items, the first place in cut order winning. */\n readonly owned: ReadonlyMap<DockEdge, string[]>;\n /** Claims an item for one place: false (with a note) when it is unknown or placed already. */\n readonly claim: (id: string) => boolean;\n /** The edge's layout before, or none when it (or an item in it) is `fresh`. */\n readonly prevEdge: (edge: DockEdge) => DockEdgeLayout | undefined;\n readonly notes: DockNote[];\n readonly items: Record<string, DockItemLayout>;\n readonly edges: Record<string, DockEdgeLayout>;\n readonly rails: Partial<Record<\"left\" | \"right\", DockRailLayout>>;\n readonly railPlaces: Partial<Record<\"left\" | \"right\", Rect>>;\n columnRoom?: boolean;\n /**\n * With a chrome floor (`contentMin.chromeWidth`): how much of the content's width the toolbar edges take within their\n * allowance (`contentMin.width` less the floor, at most). `columnRoom` and `content-narrow` don't count it against\n * the content: a toolbar rail never flips a host to its narrow layout.\n */\n chromeAllowance?: number;\n /** Height give-way: the most a top or bottom bar that gives way may be across, by edge id. */\n readonly caps: ReadonlyMap<string, number>;\n}\n\n/**\n * A new draft of `given`: an item docked now that was closed or absent in `previous` counts as the newest. `caps` are\n * height give-way's caps on bars, by edge id.\n */\nexport function createDraft(given: DockState, options: SolveOptions, caps: ReadonlyMap<string, number> = new Map()): Draft {\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 // A closed item is not a removed one. One that opens into an edge where items stayed open is a request to show it: it\n // counts as the newest there. One that opens into an edge whose items were all closed comes back as it was, with its\n // age (its edge's give-way, kept while it was closed, applies again). Opened together, the newest keep their order\n // among themselves, the one used longer ago still the older.\n const stayedOpen = (e: DockState[\"edges\"][number]): boolean => e.items.some((id) => !opened.has(id) && Object.hasOwn(given.items, id) && !given.items[id]!.closed && !given.items[id]!.fixed);\n const newest = Object.values(given.items).reduce((m, it) => Math.max(m, finite(it.used, 0)), 0) + 1;\n const byAge = [...opened]\n .filter((id) => given.edges.some((e) => e.items.includes(id) && stayedOpen(e)))\n .sort((a, b) => finite(given.items[a]!.used, 0) - finite(given.items[b]!.used, 0) || (a < b ? -1 : 1));\n const state: DockState = byAge.length === 0 ? given : { ...given, items: { ...given.items, ...Object.fromEntries(byAge.map((id, k) => [id, { ...given.items[id]!, used: newest + k }])) } };\n // `fresh` edges, and edges holding a `fresh` item, are solved without `previous`.\n const fresh = new Set(options.fresh ?? []);\n const prevEdge = (edge: DockEdge): DockEdgeLayout | undefined => (!previous || fresh.has(edge.id) || edge.items.some((id) => fresh.has(id)) ? undefined : previous.edges[edge.id]);\n const notes: DockNote[] = [];\n const order = cutOrder(state.edges);\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(state.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<DockEdge, string[]>();\n for (const e of order) owned.set(e, e.items.filter(claim));\n return { state, previous, opened, fresh, order, owned, claim, prevEdge, notes, items: {}, edges: {}, rails: {}, railPlaces: {}, caps };\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/**\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 centered between. Returns the main-axis start per id.\n */\nfunction zoneStarts(state: DockState, 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) => !fit.menu?.items.includes(p.id));\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(state.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 takes no steps and 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 = state.items[p.id]!;\n const f = formsOf(it, \"row\")[p.form];\n return !itemSteps(it) && f?.main.grows && len(p) > formMain(f, \"natural\", fit.cross) + EPS;\n });\n if (title) lengths.set(title.id, formMain(formsOf(state.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 // The free space items keep on their zone's open side (`DockItem.space`: before a start item, after an end item),\n // out of the spare length; when they ask for more than there is, each gets its share.\n const spaceOf = (p: { id: string }): number => {\n const v = state.items[p.id]?.space;\n return Number.isFinite(v) && v! > 0 ? v! : 0;\n };\n const spacing = new Set([...s, ...e].map((p) => p.id));\n const asked = [...s, ...e].reduce((sum, p) => sum + spaceOf(p), 0);\n const share = asked > spare ? spare / asked : 1;\n // A center item keeps no space: it is centered.\n const room = (p: { id: string }): number => (spacing.has(p.id) ? spaceOf(p) * share : 0);\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, lead: boolean): void => {\n let x = from;\n for (const p of ps) {\n if (lead) x += room(p);\n out.set(p.id, x);\n x += len(p) + gap + (lead ? 0 : room(p));\n }\n };\n const spaced = (ps: readonly { id: string }[]): number => total(ps) + ps.reduce((sum, p) => sum + room(p), 0);\n lay(s, start, true);\n const endStart = fit.length - end - menu - spaced(e);\n lay(e, endStart, false);\n const lo = start + spaced(s) + (s.length > 0 ? gap : 0);\n const hi = endStart - (e.length > 0 ? gap : 0);\n // Centered on the edge's middle (so a centered 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, centered 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))), false);\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/** Draws an edge's stack at `r` (its stage rect): its items, notes and edge layout. */\nexport function emit(d: Draft, edge: DockEdge, r: Rect, solved: EdgeSolve, extra: Partial<DockEdgeLayout> = {}): void {\n const { state, notes, items, edges } = d;\n const column = axisOf(edge.side) === \"column\";\n const { stack } = solved;\n const thick = column ? r.width : r.height;\n const { starts, lengths } = zoneStarts(state, 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 = state.items[p.id]!;\n const inMenu = !!stack.menu?.items.includes(p.id);\n const drawnRect = toStage(p.rect, inMenu ? undefined : p.id);\n const f = formsOf(it, column ? \"column\" : \"row\")[p.form];\n const shape = inMenu ? {} : shapeOf(f, drawnRect, column ? \"column\" : \"row\", stack.cross);\n const foldedBy = foldedByOf(it, formsOf(it, column ? \"column\" : \"row\"), p.form, solved.starts.get(p.id), edge);\n items[p.id] = {\n ...shape,\n ...controlsOf(inMenu ? undefined : f),\n rect: drawnRect,\n kind: it.kind,\n axis: column ? \"column\" : \"row\",\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 ...(tabs.has(p.id) && f?.title === true && (edge.side === \"left\" || edge.side === \"right\") ? { railTitle: edge.side } : {}),\n ...(solved.closedTabs.has(p.id) ? { closed: true } : {}),\n ...(foldedBy ? { foldedBy } : {}),\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 // The stack's items are in zone order, the order `emit` drew them in.\n items: stack.items.map((p) => p.id),\n tabs: solved.tabs,\n stack,\n free: solved.free,\n ...extra,\n };\n}\n","/**\n * One edge as a stack (`fitStack`): its free fit, then, for a column, its rail (nothing in it sets the width) or the\n * user's size. A compact edge is icons only.\n */\nimport { EPS } from \"@n-uf/placement\";\nimport { fitStack, formCompact, formCrossMin, formMenu, formSetsCross, itemSteps, type StackFit, type StackForm, type StackInput, type StackItem } from \"@n-uf/placement/stack\";\nimport { axisOf, formsOf, pastWrap, railModeOf, startOf, zoneOf } from \"../helpers\";\nimport type { DockEdge, DockState, DockEdgeLayout, DockItem } from \"../model\";\nimport { finite, px, zoneSorted } from \"./order\";\n\nconst stackItemOf =(item: DockItem, forms: readonly StackForm[], edge: DockEdge, from?: number): StackItem => ({\n id: item.id,\n forms,\n used: finite(item.used, 0),\n ...(item.kept ? { kept: true } : {}),\n // Where its ladder starts: as asked, else its hand fold resolved on this axis (`startOf`: its folded form).\n ...(from !== undefined ? { from } : startOf(item, forms, edge) > 0 ? { from: startOf(item, forms, edge) } : {}),\n ...(item.fixed ? { fixed: true } : {}),\n ...(item.fixed && item.stepping ? { stepping: true } : {}),\n ...(item.lengths ? { lengths: item.lengths } : {}),\n});\n\n/** The input each edge stack `solveEdge` made was solved from: what a divider verb re-solves to move a length. */\nconst inputs = new WeakMap<StackFit, StackInput>();\n/** The input `stack` (an edge's drawn stack from `solve`) was solved from, or undefined for a fit `solve` didn't make. */\nexport const inputOf = (stack: StackFit): StackInput | undefined => inputs.get(stack);\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) => !formMenu(forms(p.id)[p.form]!) && formSetsCross(forms(p.id)[p.form]!));\n}\n\nexport interface EdgeSolve {\n readonly stack: StackFit;\n readonly free: StackFit;\n readonly tabs: readonly string[];\n readonly closedTabs: ReadonlySet<string>;\n readonly input: StackInput;\n /** The form each open item started in (its stack item's `from` in the free fit): one drawn below it gave way. */\n readonly starts: ReadonlyMap<string, number>;\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/** How far a tray toolbar's steps rank after the panels' (its forms' `rank` plus this). */\nconst TRAY_RANK = 100;\n\n/** What every way of solving one edge shares: its items in zone order, their forms with priority, the stack's base. */\ninterface EdgeFrame {\n readonly state: DockState;\n readonly edge: DockEdge;\n readonly column: boolean;\n readonly ordered: readonly string[];\n readonly formsById: (id: string) => readonly StackForm[];\n readonly base: Omit<StackInput, \"items\">;\n readonly previous: DockEdgeLayout | undefined;\n}\n\n/** The form each item of `input` starts in. */\nconst startsOf = (input: StackInput): ReadonlyMap<string, number> => new Map(input.items.map((i) => [i.id, i.from ?? 0]));\n\n/** An icons-only edge: each item starts at its icons form (the » menu may follow); one without is left out. */\nfunction compactEdge(f: EdgeFrame): EdgeSolve {\n const { state, edge, formsById } = f;\n const iconsAt = (id: string): number => {\n const forms = formsById(id);\n for (let j = startOf(state.items[id]!, forms, edge); j < forms.length; j++) if (formCompact(forms[j]!)) return j;\n return forms.findIndex(formCompact);\n };\n const shown = f.ordered.filter((id) => !state.items[id]!.closed && iconsAt(id) >= 0);\n const leftOutIcons = f.ordered.filter((id) => !state.items[id]!.closed && iconsAt(id) < 0);\n const compactInput: StackInput = { ...f.base, ownCross: false, items: shown.map((id) => stackItemOf(state.items[id]!, formsById(id), edge, iconsAt(id))) };\n const stack = fitStack(compactInput, f.previous ? { previous: f.previous.free } : {});\n return { stack, free: stack, tabs: [], closedTabs: new Set(), input: compactInput, starts: startsOf(compactInput), leftOutIcons };\n}\n\n/**\n * A rail (a column in which nothing sets the width): the items with a rail form take it (closed ones too, with\n * `railShowsClosed`); null when no item shown has one.\n */\nfunction railEdge(f: EdgeFrame, free: StackFit, asStackItem: (id: string) => StackItem, starts: ReadonlyMap<string, number>): EdgeSolve | null {\n const { state, edge, formsById } = f;\n const railIndex = (item: DockItem, forms: readonly StackForm[]): number => {\n if (!itemSteps(item)) return -1;\n for (let j = startOf(item, forms, edge); 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(state.items[id]!, formsById(id)) < 0 && pastWrap(formsById(id), startOf(state.items[id]!, formsById(id), edge)) === undefined;\n const shown = f.ordered.filter((id) => {\n const it = state.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 = f.ordered.filter((id) => !state.items[id]!.closed && wrapOnly(id));\n const anyRail = shown.some((id) => railIndex(state.items[id]!, formsById(id)) >= 0);\n if (!anyRail) return null;\n const railInput: StackInput = {\n ...f.base,\n // The side's rail mode: a title rail form is offered only while the side shows titles.\n ...(railModeOf(state, edge.side) === \"titles\" ? { titles: true } : {}),\n items: shown.map((id) => {\n const it = state.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, edge, j >= 0 ? j : pastWrap(forms, startOf(it, forms, edge)));\n }),\n };\n const stack = fitStack(railInput, f.previous ? { previous: f.previous.stack } : {});\n const tabs = stack.items.filter((p) => p.kind === \"rail\").map((p) => p.id);\n const closedTabs = new Set(shown.filter((id) => state.items[id]!.closed));\n return { stack, free, tabs, closedTabs, input: railInput, starts, leftOut };\n}\n\n/** One edge's stack along `length`: the free fit, then the rail or the user's size. */\nexport function solveEdge(state: DockState, edge: DockEdge, ids: readonly string[], length: number, room: number, previous: DockEdgeLayout | undefined): EdgeSolve {\n const solved = solveEdgeStack(state, edge, ids, length, room, previous);\n inputs.set(solved.stack, solved.input);\n return solved;\n}\n\nfunction solveEdgeStack(state: DockState, edge: DockEdge, ids: readonly string[], length: number, room: number, previous: DockEdgeLayout | undefined): EdgeSolve {\n const axis = axisOf(edge.side);\n const column = axis === \"column\";\n const ordered = zoneSorted(state, 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(state.items[id]!.priority ?? edge.priority ?? 0, 0);\n const formsById = (id: string): readonly StackForm[] => {\n const forms = formsOf(state.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 const frame: EdgeFrame = { state, edge, column, ordered, formsById, base, previous };\n if (edge.compact) return compactEdge(frame);\n const open = ordered.filter((id) => !state.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 = state.items[id]!;\n const forms = formsById(id);\n if (!column || !edge.zoneAccepts?.end || zoneOf(it) !== \"end\") return stackItemOf(it, forms, edge);\n const tray = (f: StackForm): boolean => f.kind === \"wrap\" || formCompact(f) || !!f.wrap;\n let first = -1;\n for (let j = startOf(it, forms, edge); 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, edge);\n return stackItemOf(it, forms.slice(0, last + 1).map((f) => ({ ...f, rank: finite(f.rank ?? 0, 0) + TRAY_RANK })), edge, 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 // The forms the items started in, before the rail or the user's size re-solved them: what gave way is read against these.\n const starts = startsOf(input);\n if (column && !hasSetter(free, formsById)) {\n const rail = railEdge(frame, free, asStackItem, starts);\n if (rail) return rail;\n }\n // A bar that gives way (a top or bottom edge with `giveWay`) never draws an item thinner across than its form allows:\n // under its height give-way's cap, such an item starts at its next form that fits (a panel's title bar), counted as\n // given way against the form it started in.\n if (!column && edge.giveWay === true) {\n const fits = (f: StackForm): boolean => !formSetsCross(f) || formCrossMin(f) <= cross.max + EPS;\n let moved = false;\n const items = input.items.map((it): StackItem => {\n const from = it.from ?? 0;\n if (!itemSteps(it) || fits(it.forms[from]!)) return it;\n const j = it.forms.findIndex((f, k) => k > from && !formMenu(f) && fits(f));\n if (j < 0) return it;\n moved = true;\n return { ...it, from: j };\n });\n if (moved) {\n const folded: StackInput = { ...input, items };\n return { stack: fitStack(folded), free, tabs: [], closedTabs: none, input: folded, starts };\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) => !formMenu(formsById(p.id)[p.form]!) && 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, starts };\n }\n }\n return { stack: free, free, tabs: [], closedTabs: none, input, starts };\n}\n","/**\n * The floats: fitted inside the stage less the inset at its left and right, clear of every docked item (fixed ones and\n * » entries included), every bar and the chrome rects (`fitFloat`). An anchored float sits flush with that side or\n * corner of `content` first, then clear of the floats floated before it too, where room exists (`fitBeside`): the\n * anchored ones before it (smaller `since`, then smaller id) and those with a rect of their own floated strictly before\n * it (smaller `since`). The float floated first wins the place both want; one floated later and put there by the hand\n * (a drop, a resize) covers the anchored float, which keeps its place. The stacking order plays no part. A float\n * with `from` over 0 is its bar: its form's natural length along its `orient`, its other size kept.\n */\nimport { EPS, clampInto, overlaps, rect, type Rect, type Size } from \"@n-uf/placement\";\nimport { fitFloat, formFolded, type FloatFit, type StackForm } from \"@n-uf/placement/stack\";\nimport { anchorName, axisOf, controlsOf, keepClearFor, floatOrientOf, floatShape, foldedByOf, formsOf, isSince } from \"../helpers\";\nimport type { FloatAnchor, FloatAnchorAt, Orient, DockFloat, DockItem } from \"../model\";\nimport { shapeOf, type Draft } from \"./draft\";\nimport type { Inset } from \"./insets\";\nimport { finite, px } from \"./order\";\n\n/** When a float was floated, for the order among anchored floats: its `since`, a missing or unusable one 0. */\nconst sinceOf = (f: DockFloat): number => (isSince(f.since) ? f.since : 0);\n\n/** A float's rect flush with `content`'s side or corner, moved by the anchor's offset (`dx` right, `dy` down). */\nfunction anchored(content: Rect, w: number, h: number, given: FloatAnchorAt): Rect {\n const anchor = anchorName(given);\n const dx = typeof given === \"string\" ? 0 : finite(given.dx ?? 0, 0);\n const dy = typeof given === \"string\" ? 0 : finite(given.dy ?? 0, 0);\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 + dx, y + dy, w, h);\n}\n\n/** The floor a float of `item` is laid out at: its `floatMin`, else its form's own minimums, which only stop a shrink. */\nexport function floatFloor(item: DockItem, form: StackForm | undefined, orient: Orient, size: Size): Size {\n const row = orient === \"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 return {\n width: item.floatMin ? px(item.floatMin.width) : Math.min(size.width, px(row ? form?.main.min : form?.cross.min)),\n height: item.floatMin ? px(item.floatMin.height) : Math.min(size.height, px(row ? form?.cross.min : form?.main.min)),\n };\n}\n\n/**\n * The room `region` leaves a float along each axis, clear of what spans it whole: down it, the region less the bars and\n * chrome across its full width at its top and bottom; across it, less what runs its full height at its left and right.\n * What spans only part of it is no limit on the size (a float fits beside it).\n */\nfunction clearSize(region: Rect, avoid: readonly Rect[]): Size {\n const span = (axis: \"x\" | \"y\"): number => {\n const lo = axis === \"y\" ? region.y : region.x;\n const hi = lo + (axis === \"y\" ? region.height : region.width);\n const mid = (lo + hi) / 2;\n let a = lo;\n let b = hi;\n for (const r of avoid) {\n // Across the region whole, the other way.\n const whole = axis === \"y\" ? r.x <= region.x + EPS && r.x + r.width >= region.x + region.width - EPS : r.y <= region.y + EPS && r.y + r.height >= region.y + region.height - EPS;\n const s = axis === \"y\" ? r.y : r.x;\n const e = s + (axis === \"y\" ? r.height : r.width);\n if (!whole || e <= lo || s >= hi) continue;\n if (s + e <= 2 * mid) a = Math.max(a, e);\n else b = Math.min(b, s);\n }\n return Math.max(0, b - a);\n };\n return { width: span(\"x\"), height: span(\"y\") };\n}\n\n/**\n * An anchored float's fit: `fitFloat` clear of `avoid` and of `earlier` (the floats that win over it), the same nearest\n * clear place it finds beside docked items. Where no place is clear of both, it is `fitFloat` clear of `avoid` alone, as\n * if `earlier` were not there: a float may cover an earlier float, never a docked item it could have stayed clear of.\n * With no earlier floats it is exactly `fitFloat(want, region, avoid)`.\n */\nfunction fitBeside(want: Rect, region: Rect, avoid: readonly Rect[], earlier: readonly Rect[]): FloatFit {\n if (earlier.length === 0) return fitFloat(want, region, avoid);\n const both = fitFloat(want, region, [...avoid, ...earlier]);\n return both.covers.length === 0 ? both : fitFloat(want, region, avoid);\n}\n\n/**\n * `r` moved the least it takes to lie clear of `walls` (the bars and the chrome), inside `region`: as the stage's edge\n * clamps a float, each wall it overlaps pushes it out along one axis, the shorter way that clears every wall (one push,\n * or two where two walls meet at a corner). Null where no such push clears them all.\n */\nfunction clearOfWalls(r: Rect, region: Rect, walls: readonly Rect[]): Rect | null {\n const under = (c: Rect): Rect[] => walls.filter((w) => overlaps(c, w, 1e-3));\n if (under(r).length === 0) return r;\n const pushes = (c: Rect): Rect[] =>\n under(c).flatMap((w) =>\n [rect(w.x - c.width, c.y, c.width, c.height), rect(w.x + w.width, c.y, c.width, c.height), rect(c.x, w.y - c.height, c.width, c.height), rect(c.x, w.y + w.height, c.width, c.height)].map((m) => clampInto(m, region)),\n );\n const far = (c: Rect): number => Math.abs(c.x - r.x) + Math.abs(c.y - r.y);\n let best: Rect | null = null;\n for (const a of pushes(r))\n for (const c of under(a).length === 0 ? [a] : pushes(a)) if (under(c).length === 0 && (!best || far(c) < far(best) - 1e-9)) best = c;\n return best;\n}\n\n/**\n * A float the hand left over content: kept inside `region` and pushed the least it takes clear of the bars and chrome\n * (`avoid` past its first `docked` entries; `clearOfWalls`, else `fitFloat` clear of them), then left there over the\n * docked items (`fitFloat`'s `stay`), `covers` naming what it covers in `avoid`.\n */\nfunction fitStays(want: Rect, region: Rect, avoid: readonly Rect[], docked: number): FloatFit {\n const walls = avoid.slice(docked).filter((w) => w.width > 0 && w.height > 0);\n const inside = clampInto(want, region);\n const kept = clearOfWalls(inside, region, walls) ?? fitFloat(want, region, walls).rect;\n const over = fitFloat(kept, region, avoid, { stay: true });\n return { rect: kept, clamped: kept.x !== want.x || kept.y !== want.y, snapped: false, covers: over.covers, searchCapped: false };\n}\n\n/**\n * Where one float of `item` lies, as `solve` lays it (and `fitResize` previews it): its form and size, then `fitFloat`\n * into `region`, clear of `avoid`. Its size is clamped to the room `region` leaves clear of the bars and chrome across\n * it (`clearSize`), never under its floor: only a floor larger than that room covers. The one clamp for a float's rect;\n * `shape.none` is the caller's to handle first. An anchored float is also kept clear of `earlier` (the floats that win\n * over it) where room exists (`fitBeside`); a float with a rect of its own ignores `earlier`. A float the hand left over\n * content (`stays`, with a rect of its own) is kept clear of the bars and chrome only (`avoid` past its first `docked`\n * entries, the docked items): it lies over the docked items it covers (`fitStays`).\n */\nexport function placeFloat(item: DockItem, f: Pick<DockFloat, \"rect\" | \"orient\" | \"anchor\" | \"stays\">, region: Rect, avoid: readonly Rect[], content: Rect, stage: Rect, earlier: readonly Rect[] = [], docked = 0): { from: number; fo: Orient; form: StackForm | undefined; fit: FloatFit } {\n const shape = floatShape(item, f);\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(item);\n const form = formsOf(item, fo)[from];\n // Into that region; a float larger than it is shrunk to fit it, never under its floor. A folded float (its bar) keeps\n // its height. Wider than the region at its floor, it keeps the floor and lies at the region's left edge.\n const floor = floatFloor(item, form, fo, shape);\n // `floatMax` caps it (never under the floor).\n const cap = { width: Number.isFinite(item.floatMax?.width) ? item.floatMax!.width : Infinity, height: Number.isFinite(item.floatMax?.height) ? item.floatMax!.height : Infinity };\n const clear = clearSize(region, avoid);\n const w = Math.max(floor.width, Math.min(shape.width, clear.width, cap.width));\n // A float folded by hand is its bar (a panel's `header`, a group's `fold`): it keeps the bar's own height. Any other\n // form (its first, or a later one a stored state names) fits the region.\n const folded = !!form && formFolded(form);\n const h = folded ? shape.height : Math.max(floor.height, Math.min(shape.height, clear.height, cap.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 = f.anchor ? fitBeside(want, region, avoid, earlier) : f.stays ? fitStays(want, region, avoid, docked) : fitFloat(want, region, avoid);\n const fit = w > region.width + EPS ? { ...fit0, rect: rect(region.x, fit0.rect.y, w, fit0.rect.height) } : fit0;\n return { from, fo, form, fit };\n}\n\n/** Lays every float of the state that isn't placed already; returns their ids in stacking order. */\nexport function layFloats(d: Draft, stage: Rect, content: Rect, inset: Inset): string[] {\n const { state, notes, items, edges } = d;\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 // The docked items come first: a float the hand left over content covers them, never the bars or the chrome.\n const docked = avoid.length;\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 keepClearFor(state, \"floats\")) 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 // The floats drawn, in stacking order; a note for one with no vertical form, in that order too.\n const drawn: DockFloat[] = [];\n const noForm = new Set<string>();\n for (const f of state.floats) {\n if (!d.claim(f.id)) continue;\n const it = state.items[f.id]!;\n if (it.closed) continue;\n // Vertical means icons: an item with only `wrap` forms left has no form for a vertical float.\n if (floatShape(it, f).none) noForm.add(f.id);\n drawn.push(f);\n }\n // Where each lies, apart from the stacking order (so `raiseFloat` reshapes nothing): a float with its own rect, clear of\n // what floats are kept clear of; then the anchored ones, earliest floated first (`since`, then id), each clear of the\n // floats floated before it too, where room exists (`fitBeside`): the anchored ones before it, and the ones with a rect\n // of their own floated strictly before it (a smaller `since`). A float floated later (or as early) is placed over it by\n // the hand, so the anchored float makes no way for it: dropped or grown there, it lies over or under the anchored float\n // by the stacking order, and nothing else moves.\n const placed = new Map<string, ReturnType<typeof placeFloat>>();\n const place = (f: DockFloat, earlier: readonly Rect[] = []): void => {\n placed.set(f.id, placeFloat(state.items[f.id]!, f, floatRegion, avoid, content, stage, earlier, docked));\n };\n const live = drawn.filter((f) => !noForm.has(f.id));\n const own = live.filter((f) => !f.anchor);\n for (const f of own) place(f);\n const anchored = live.filter((f) => f.anchor).sort((a, b) => sinceOf(a) - sinceOf(b) || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));\n anchored.forEach((f, i) => {\n const before = own.filter((o) => sinceOf(o) < sinceOf(f)).map((o) => placed.get(o.id)!.fit.rect);\n place(f, [...before, ...anchored.slice(0, i).map((a) => placed.get(a.id)!.fit.rect)]);\n });\n const floats: string[] = [];\n for (const f of drawn) {\n if (noForm.has(f.id)) {\n notes.push({ code: \"no-vertical-form\", id: f.id });\n continue;\n }\n const it = state.items[f.id]!;\n const { from, fo, form, fit } = placed.get(f.id)!;\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 // A float never gives way: it is folded by hand or not at all.\n const foldedBy = foldedByOf(it, formsOf(it, fo), from);\n items[f.id] = { ...shapeOf(form, fit.rect, fo, fit.rect.width), ...controlsOf(form), rect: fit.rect, kind: it.kind, axis: fo, form: from, formKind: form?.kind ?? \"open\", floating: true, ...(foldedBy ? { foldedBy } : {}) };\n floats.push(f.id);\n }\n return floats;\n}\n","/**\n * The inset: the space kept clear inside the stage's edges, or none with `insetWhen: \"docked\"` while no panel is docked\n * beside the content. `Frame` carries it, with the gutter and the area the outside bars leave, to the side phase.\n */\nimport { EPS, rect, type Rect } from \"@n-uf/placement\";\nimport { isDockingPanel } from \"../helpers\";\nimport type { DockState } from \"../model\";\nimport type { Draft } from \"./draft\";\nimport { isSide, px } from \"./order\";\n\nexport type Inset = NonNullable<DockState[\"inset\"]>;\n\n/** What the side phase reads of the window around it. */\nexport interface Frame {\n /** The inset in force. */\n readonly inset: Inset;\n /** The space after each side edge and rail that takes room. */\n readonly gutter: number;\n /** Whether a panel is docked beside the content (`insetWhen: \"docked\"`). */\n readonly docked: boolean;\n /** The stage less the full bars outside the inset. */\n readonly outer: Rect;\n}\n\n/**\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 */\nexport function insetOf(d: Draft): { inset: Inset; docked: boolean } {\n const { state } = d;\n const docked = d.order.some((e) => isSide(e) && e.accepts.length > 0 && d.owned.get(e)!.some((id) => isDockingPanel(state.items[id]!)));\n const inset = state.insetWhen === \"docked\" && !docked ? {} : (state.inset ?? {});\n return { inset, docked };\n}\n\n/** `outer` less the inset on every side. */\nexport const insideInset = (outer: Rect, inset: Inset): Rect =>\n 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\n/**\n * How far an edge outside the inset (an anchor) runs into the inset above and below `area`, where no reserved bar lies\n * on that side (a bar there keeps it below or above the bar). Outside bars lie beyond the inset already: measured from\n * what they leave.\n */\nexport function insetReach(area: Rect, f: Frame): { up: number; down: number } {\n const up = area.y <= f.outer.y + px(f.inset.top) + EPS ? px(f.inset.top) : 0;\n const down = area.y + area.height >= f.outer.y + f.outer.height - px(f.inset.bottom) - EPS ? px(f.inset.bottom) : 0;\n return { up, down };\n}\n","/** The notes about the content itself: narrower or shorter than `contentMin`, moved since `previous`. */\nimport { EPS, type Rect } from \"@n-uf/placement\";\nimport type { Draft } from \"./draft\";\nimport { isSide, px } from \"./order\";\n\nexport function contentNotes(d: Draft, content: Rect): void {\n const { state, notes, previous } = d;\n if (state.contentMin) {\n // Chrome within its allowance (`contentMin.chromeWidth`) takes the content's width without making it narrow.\n const minW = px(state.contentMin.width) - (d.chromeAllowance ?? 0);\n const minH = px(state.contentMin.height);\n if (content.width < minW - EPS) notes.push({ code: \"content-narrow\", width: content.width, min: minW });\n // Overlay bars lie over the content: what they cover isn't the content's height.\n const bars = d.order.filter((e) => e.mode === \"overlay\" && !isSide(e)).reduce((s, e) => s + (d.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","/**\n * The reserved left and right edges, ring by ring, with column give-way (`./columns`). From the window's side inward:\n * the side's bars outside the inset (toolbar bars, `isOutsideSideBar`), the side's rail, the static column edges outside\n * the inset (anchors), the inset, then the columns, a gutter after each. Folded columns go to the rail or ride\n * (`./rails`).\n */\nimport { EPS, rect, type Rect } from \"@n-uf/placement\";\nimport { isOutsideSideBar } from \"../helpers\";\nimport type { DockEdge } from \"../model\";\nimport { columnRoom, columnsOf, giveWay, giveWayNotes, type Col, type GiveWay } from \"./columns\";\nimport { emit, type Draft } from \"./draft\";\nimport { solveEdge, type EdgeSolve } from \"./edge\";\nimport { insetReach, type Frame } from \"./insets\";\nimport { finite, px, zoneSorted } from \"./order\";\nimport { layRail, layRiders, ridersHeight } from \"./rails\";\n\n/** The side phase's running state across one side: the content's left and right so far, and the gap before the next edge. */\ninterface Walk {\n x0: number;\n x1: number;\n}\n\n/** The side edges laid in `area`; returns the area they leave. */\nexport function laySides(d: Draft, sideEdges: readonly DockEdge[], area: Rect, f: Frame): Rect {\n const H = area.height;\n const reach = insetReach(area, f);\n const tall = (edge: DockEdge): number => H + (edge.outsideInset === true ? reach.up + reach.down : 0);\n const cols = columnsOf(d, sideEdges, area, tall);\n const g = giveWay(d, cols, area, f.gutter);\n columnRoom(d, cols, area, f);\n giveWayNotes(d, g, cols);\n const walk: Walk = { x0: area.x, x1: area.x + area.width };\n for (const side of [\"left\", \"right\"] as const) laySide(d, side, cols, g, area, f, walk, reach.up, tall);\n return rect(walk.x0, area.y, Math.max(0, walk.x1 - walk.x0), H);\n}\n\n/** `c`'s edge re-solved at width `w` and length `length` (its user's size dropped). */\nfunction forced(d: Draft, c: Col, length: number, w: number): EdgeSolve {\n const edge: DockEdge = { ...c.edge, cross: { ...c.edge.cross, min: w, max: w } };\n const { size: _s, ...plain } = edge;\n return solveEdge(d.state, plain, d.owned.get(c.edge)!, length, w, d.prevEdge(c.edge));\n}\n\n/** One side, from the window's side inward: its outside bars, its rail, its anchors, the inset, its columns. */\nfunction laySide(d: Draft, side: \"left\" | \"right\", cols: readonly Col[], g: GiveWay, area: Rect, f: Frame, walk: Walk, upInset: number, tall: (edge: DockEdge) => number): void {\n const { state, edges } = d;\n const H = area.height;\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(state, 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 const ridersTop = ridersHeight(d, riders);\n const railW = px(state.rails?.[side]?.width);\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\" ? f.inset.left : f.inset.right);\n /** Whether one of the side's outside bars is laid already (the rail then lies flush after it). */\n let barLaid = false;\n /** Where the side's rail lies, or would lie were one shown (`railPlaces`). */\n let railPlace: Rect | null = null;\n const placeRail = (): Rect => {\n const lead = barLaid ? gap : 0;\n return side === \"left\" ? rect(walk.x0 - lead, area.y, railW, H) : rect(walk.x1 + lead - railW, area.y, railW, H);\n };\n for (const c of mine) {\n // The side's rail is its outermost panel edge; an anchor lies flush inside it. After the side's outside bars it\n // lies outside the inset too, flush after them, the inset (at least a gutter) then following it and the anchor.\n // With no such bar it lies at the window's side inside the inset, a gutter after it (the hosts' rows).\n if (!railPlace && !outsideSideBar(c)) {\n railPlace = placeRail();\n if (railed.length > 0) {\n railRect = railPlace;\n const lead = barLaid ? gap : 0;\n const after = barLaid ? Math.max(gap, f.gutter) : f.gutter;\n if (side === \"left\") walk.x0 += railPlace.width - lead + after;\n else walk.x1 -= railPlace.width - lead + after;\n gap = after;\n }\n }\n if (outsideSideBar(c)) barLaid = true;\n // A folded column's members are drawn as rail segments, in zone order (`layRail`).\n const base = { side: c.edge.side, ring: finite(c.edge.ring, 0), cross: 0, menu: null, items: zoneSorted(state, c.visible), 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, walk.x1 - walk.x0));\n const top = c === host ? ridersTop : 0;\n let solved = top > 0 || Math.abs(w - c.width) > EPS ? forced(d, c, H - top, w) : c.solved;\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(walk.x0 - gap, y0, w, h);\n walk.x0 += w;\n } else {\n r = rect(walk.x1 + gap - w, y0, w, h);\n walk.x1 -= w;\n }\n if (Math.abs(h - H) > EPS || Math.abs(w - c.width) > EPS) solved = forced(d, c, h, w);\n } else if (side === \"left\") {\n r = rect(walk.x0, area.y + top, w, H - top);\n walk.x0 += w > 0 ? w + f.gutter : 0;\n if (w > 0) gap = f.gutter;\n } else {\n walk.x1 -= w;\n r = rect(walk.x1, area.y + top, w, H - top);\n walk.x1 -= w > 0 ? f.gutter : 0;\n if (w > 0) gap = f.gutter;\n }\n emit(d, c.edge, r, solved, w < c.width - EPS ? { shrunk: true } : {});\n }\n if (host && riders.length > 0) layRiders(d, host, riders, area.y);\n if (railRect) layRail(d, side, railRect, railed, g);\n // A side that can have a rail: where it lies, or would lie (after every outside bar when the side has nothing else).\n if (state.rails?.[side]) d.railPlaces[side] = railPlace ?? placeRail();\n}\n","/**\n * Column give-way: while the content is narrower than `contentMin.width` (after the inset and a gutter after each side\n * edge and rail), dynamic columns shrink toward their minimum, then fold whole into their side's rail, unkept before\n * kept, the oldest newest use first, the outer first, the left first. Under `previous`, what gave way stays so while\n * the content still fits, and room coming back unfolds in the reverse of give-way order.\n */\nimport { EPS, type Rect } from \"@n-uf/placement\";\nimport { formCrossMin, formMenu, formSetsCross, type StackForm } from \"@n-uf/placement/stack\";\nimport { formsOf, isSideBar, startOf } from \"../helpers\";\nimport type { DockEdge, DockState, DockNote } from \"../model\";\nimport type { Draft } from \"./draft\";\nimport { solveEdge, type EdgeSolve } from \"./edge\";\nimport type { Frame } from \"./insets\";\nimport { finite, giveWayOrder, px } from \"./order\";\n\n/**\n * Chrome: a side toolbar edge that never gives way (`isSideBar`, a compact rail included), not a panel column. The one\n * test the chrome floor's allowance and `columnRoom` both read.\n */\nconst isChrome = (state: DockState, c: Col): boolean => !c.dyn && isSideBar(state, c.edge);\n\n/** One left or right edge as give-way weighs it. */\nexport interface Col {\n readonly edge: DockEdge;\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\n/** Give-way's answer: the columns folded by it (in fold order), each other column's width, and how they show. */\nexport interface GiveWay {\n readonly auto: ReadonlySet<Col>;\n readonly widths: ReadonlyMap<Col, number>;\n readonly excess: number;\n /** In the side's rail: folded by give-way, or by hand and not riding. */\n readonly railed: (c: Col) => boolean;\n /** Riding as title bars over the side's first open column (`handFold: \"ride\"`). */\n readonly riding: (c: Col) => boolean;\n /** The columns in shrink order. */\n readonly shrinkOrder: readonly Col[];\n}\n\n/** The side edges solved at the area's height (`tall`: an edge outside the inset runs into it). */\nexport function columnsOf(d: Draft, sideEdges: readonly DockEdge[], area: Rect, tall: (edge: DockEdge) => number): Col[] {\n const { state } = d;\n return sideEdges.map((edge) => {\n const side = edge.side as \"left\" | \"right\";\n const solved = solveEdge(state, edge, d.owned.get(edge)!, tall(edge), Math.max(0, area.width), d.prevEdge(edge));\n const width = solved.stack.items.length === 0 ? 0 : Math.min(solved.stack.cross, area.width);\n const visible = d.owned.get(edge)!.filter((id) => !state.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) && state.rails?.[side] !== undefined && visible.length > 0;\n const forms = (id: string): readonly StackForm[] => formsOf(state.items[id]!, \"column\");\n const setters = solved.free.items.filter((p) => !formMenu(forms(p.id)[p.form]!) && 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) => startOf(state.items[id]!, formsOf(state.items[id]!, \"column\")) > 0),\n kept: visible.some((id) => state.items[id]!.kept === true),\n age: Math.max(-Infinity, ...visible.map((id) => finite(state.items[id]!.used, 0))),\n };\n });\n}\n\n/** Which columns fold and how wide the rest are, in `area` (`gutter` after each column and rail). */\nexport function giveWay(d: Draft, cols: readonly Col[], area: Rect, gutter: number): GiveWay {\n const { state, previous, fresh, opened } = d;\n const ride = state.handFold === \"ride\";\n const cmin = state.contentMin ? px(state.contentMin.width) : undefined;\n // The chrome floor (`contentMin.chromeWidth`), never above `cmin`; a value that isn't a number is no floor.\n const chromeWidth = state.contentMin?.chromeWidth;\n const floor = cmin !== undefined && typeof chromeWidth === \"number\" && Number.isFinite(chromeWidth) ? Math.min(cmin, px(chromeWidth)) : undefined;\n // What chrome takes across (it never gives way, so the same in every weighing), and the part of it within the floor's\n // allowance, which `columnRoom` and `content-narrow` leave out.\n const chrome = floor === undefined ? 0 : cols.filter((c) => isChrome(state, c) && c.width > 0).reduce((s, c) => s + c.width + (c.edge.outsideInset === true ? 0 : gutter), 0);\n if (floor !== undefined) d.chromeAllowance = Math.min(chrome, cmin! - floor);\n const foldOrder = cols\n .filter((c) => c.dyn && !c.hand && c.width > 0)\n .sort((a, b) => giveWayOrder(a, b) || (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 = foldOrder.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(state.rails?.[side]?.width);\n const evaluate = (auto: ReadonlySet<Col>): GiveWay => {\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 // With a chrome floor, the toolbar edges may take the content down to it; the columns alone still leave `cmin`.\n let excess = cmin === undefined ? -Infinity : floor === undefined ? used + cmin - area.width : Math.max(used - chrome + cmin, used + floor) - 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, shrinkOrder };\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(foldOrder.map((c) => [c.edge.id, c]));\n // A column with a `fresh` item (or itself `fresh`) is weighed anew, and so is one an item opens into beside items\n // already open there (a request to show it). A column whose items were all closed and open again is not: a closed\n // item is not a removed one, and its column's give-way, kept while it was closed, applies again.\n const anew = (c: Col): boolean =>\n fresh.has(c.edge.id) || c.visible.some((id) => fresh.has(id)) || (c.visible.some((id) => opened.has(id)) && c.visible.some((id) => !opened.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 foldOrder) {\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 return evaluate(auto);\n}\n\n/**\n * Whether one panel column at its minimum fits beside the content's minimum: a host's narrow fallback (the sheet)\n * reads it (`columnRoom`, with a `no-column-room` note when not). Anchors and rails don't count: every column, an anchor\n * included, can fold into its rail. A side toolbar 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 */\nexport function columnRoom(d: Draft, cols: readonly Col[], area: Rect, f: Frame): void {\n const { state } = d;\n const cmin = state.contentMin ? px(state.contentMin.width) : undefined;\n const openMin = (ids: readonly string[], least: number): number =>\n Math.max(\n least,\n ...ids.map((id) => {\n const form = formsOf(state.items[id]!, \"column\")[0];\n return form && formSetsCross(form) ? formCrossMin(form) : 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 = state.columns?.[s];\n if (!t) return [];\n const takes = Object.values(state.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) return;\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 // With a chrome floor, what they take within its allowance doesn't count: a toolbar rail never takes a column's room.\n const allBars = cols.filter((c) => c.width > 0 && isChrome(state, c)).reduce((s, c) => s + c.width + (c.edge.outsideInset === true ? 0 : f.gutter), 0);\n const bars = d.chromeAllowance === undefined ? allBars : allBars - Math.min(allBars, d.chromeAllowance);\n // With `insetWhen: \"docked\"` and nothing docked now, the column that opens brings the inset with it.\n const width = area.width - bars - (state.insetWhen === \"docked\" && !f.docked ? px(state.inset?.left) + px(state.inset?.right) : 0);\n const need = cmin + Math.min(...colMins) + f.gutter;\n d.columnRoom = width >= need - EPS;\n if (!d.columnRoom) d.notes.push({ code: \"no-column-room\", width, need });\n}\n\n/**\n * The give-way notes: each column shrunk, then each folded, in the order they folded (`previous` unfolds in reverse). A\n * column whose items are all closed keeps its notes from `previous`, at their place in that order: a closed item is not\n * a removed one, and its column's give-way applies again when it opens.\n */\nexport function giveWayNotes(d: Draft, g: GiveWay, cols: readonly Col[]): void {\n const { state, previous } = d;\n const dormant = new Set(cols.filter((c) => c.visible.length === 0 && (c.edge.column === true || c.edge.giveWay === true) && state.rails?.[c.side] !== undefined).map((c) => c.edge.id));\n const before = previous?.notes ?? [];\n const shrunk = new Map<string, DockNote>();\n for (const c of g.shrinkOrder) {\n const w = g.widths.get(c);\n if (w !== undefined && w < c.width - EPS) shrunk.set(c.edge.id, { code: \"column-shrunk\", edge: c.edge.id, from: c.width, to: w });\n }\n const folded = new Map<string, DockNote>([...g.auto].map((c) => [c.edge.id, { code: c.kept ? \"kept-folded\" : \"column-folded\", edge: c.edge.id }]));\n // Kept notes go where they were in `previous`'s order; the others after them, in their own order.\n const merge = (now: Map<string, DockNote>, kept: (n: DockNote) => boolean): void => {\n const order: DockNote[] = [];\n for (const n of before) {\n const edge = kept(n) && \"edge\" in n ? n.edge : undefined;\n if (edge === undefined) continue;\n if (dormant.has(edge)) order.push(n);\n else if (now.has(edge)) {\n order.push(now.get(edge)!);\n now.delete(edge);\n }\n }\n d.notes.push(...order, ...now.values());\n };\n // A shrink is no history to keep: a column shrinks again by the usual order when it opens.\n d.notes.push(...shrunk.values());\n merge(folded, (n) => n.code === \"column-folded\" || n.code === \"kept-folded\");\n}\n","/**\n * Where folded columns go: the side's rail (each folded column's members as rail segments, in ring order) or, with\n * `handFold: \"ride\"`, title bars riding over the side's first open column.\n */\nimport { rect, type Rect } from \"@n-uf/placement\";\nimport { fitStack, type StackFit, type StackForm, type StackInput } from \"@n-uf/placement/stack\";\nimport { controlsOf, formsOf, railModeOf, startOf, zoneOf } from \"../helpers\";\nimport type { Col, GiveWay } from \"./columns\";\nimport type { Draft } from \"./draft\";\nimport { finite, px, zoneSorted } from \"./order\";\n\n/** A riding column's bars: each member's folded form, in zone order. */\nfunction riderBars(d: Draft, c: Col): { id: string; form: number; f: StackForm | undefined; h: number }[] {\n const { state } = d;\n return zoneSorted(state, c.visible).map((id) => {\n const forms = formsOf(state.items[id]!, \"column\");\n const form = forms.length === 0 ? 0 : startOf(state.items[id]!, forms);\n return { id, form, f: forms[form], h: px(forms[form]?.main.natural) };\n });\n}\n\n/** How tall the riders' bars are together: the room the host column leaves them on top. */\nexport const ridersHeight = (d: Draft, riders: readonly Col[]): number => riders.reduce((s, c) => s + riderBars(d, c).reduce((t, b) => t + b.h, 0), 0);\n\n/** Lays the riders' bars over the host column `host` (laid already), from `top` down. */\nexport function layRiders(d: Draft, host: Col, riders: readonly Col[], top: number): void {\n const { state, items, edges } = d;\n const hr = edges[host.edge.id]!.rect;\n let y = top;\n for (const c of riders) {\n const bars = riderBars(d, 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 = state.items[b.id]!;\n items[b.id] = { rect: at, ...controlsOf(b.f), kind: it.kind, axis: \"column\", form: b.form, formKind: b.f?.kind ?? \"header\", edge: c.edge.id, zone: zoneOf(it), rides: host.edge.id, folded: \"hand\", foldedBy: \"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, items: bars.map((b) => b.id), tabs: [], stack: c.solved.stack, free: c.solved.free, rides: host.edge.id, folded: \"hand\" };\n }\n}\n\n/** Lays the side's rail at `railRect`: each railed column's members as segments, in zone order, ring by ring. */\nexport function layRail(d: Draft, side: \"left\" | \"right\", railRect: Rect, railed: readonly Col[], g: GiveWay): void {\n const { state, items } = d;\n const segments: { id: string; edge: string; rect: Rect }[] = [];\n // In zone order, as each column itself shows them (start, center, end), ring by ring.\n const members = railed.flatMap((c) => zoneSorted(state, c.visible).map((id) => ({ id, c })));\n const formsById = (id: string): readonly StackForm[] => formsOf(state.items[id]!, \"column\");\n // An item's tile: its rail form that isn't a title (`StackForm.title`); its title, the rail form just before it.\n const tileOf = (id: string): number => formsById(id).findIndex((f) => f.kind === \"rail\" && f.title !== true);\n const titleOf = (id: string): number => {\n const t = tileOf(id);\n return t > 0 && formsById(id)[t - 1]!.kind === \"rail\" && formsById(id)[t - 1]!.title === true ? t - 1 : -1;\n };\n // With titles shown and offered, the segments are a stack along the rail: title then tile, by the ladder, and back in\n // exact reverse (`stack` carries the history). Every member needs a tile for that; otherwise each takes its tile.\n const titles = railModeOf(state, side) === \"titles\" && members.some((m) => titleOf(m.id) >= 0) && members.every((m) => tileOf(m.id) >= 0);\n let fit: StackFit | undefined;\n if (titles) {\n const input: StackInput = {\n axis: \"column\",\n length: railRect.height,\n cross: { min: railRect.width, max: railRect.width, rail: railRect.width },\n titles: true,\n items: members.map(({ id }) => {\n const it = state.items[id]!;\n const p = finite(it.priority ?? 0, 0);\n // Its rail forms only (no » menu in a rail strip); its priority adds to their ranks.\n const forms = formsById(id).slice(0, tileOf(id) + 1).map((f) => (p === 0 ? f : { ...f, rank: finite(f.rank ?? 0, 0) + p }));\n return { id, forms, used: finite(it.used, 0), ...(it.kept ? { kept: true } : {}), from: titleOf(id) >= 0 ? titleOf(id) : tileOf(id) };\n }),\n };\n // Solved afresh when a member or its column is `fresh`.\n const fresh = members.some((m) => d.fresh.has(m.id) || d.fresh.has(m.c.edge.id));\n const previous = d.previous && !fresh ? d.previous.rails[side]?.stack : undefined;\n fit = fitStack(input, previous ? { previous } : {});\n }\n const placed = new Map(fit?.items.map((p) => [p.id, p]) ?? []);\n let y = railRect.y;\n for (const { id, c } of members) {\n const it = state.items[id]!;\n const forms = formsById(id);\n const ri = tileOf(id);\n const p = placed.get(id);\n const form = p ? p.form : ri >= 0 ? ri : forms.length === 0 ? 0 : startOf(it, forms);\n const at = p ? rect(railRect.x, railRect.y + p.rect.y, railRect.width, p.rect.height) : rect(railRect.x, y, railRect.width, ri >= 0 ? px(forms[ri]!.main.natural) : railRect.width);\n const title = forms[form]?.title === true;\n items[id] = { rect: at, ...controlsOf(forms[form]), kind: it.kind, axis: \"column\", form, formKind: \"rail\", edge: c.edge.id, zone: zoneOf(it), rail: side, ...(title ? { railTitle: side } : {}), folded: g.auto.has(c) ? \"auto\" : \"hand\", foldedBy: startOf(it, forms) > 0 ? \"hand\" : \"auto\" };\n segments.push({ id, edge: c.edge.id, rect: at });\n y += at.height;\n }\n d.rails[side] = { rect: railRect, segments, ...(fit ? { stack: fit } : {}) };\n}\n","/**\n * The dock's verbs over an edge's dividers: `dividers`, `resizeBetween`, `resetBetween` and `resetLengths`. Each is the\n * `@n-uf/placement/stack` verb of the same name run on the edge's stack, with the result written back to the items'\n * `DockItem.lengths`. A divider trades length between the two neighboring open growing items of one edge (a panel, a\n * collapsed item between two open ones giving one divider across it); nothing else in the state moves.\n *\n * The layout is the one `solve` returned for this very `state` object; a verb given none, one that was made for another\n * state (another stage size, an item moved) or one that was stored and read back, solves the state itself. Pure: a state in, a state out (the same object when nothing changed).\n */\nimport { rect, type Rect } from \"@n-uf/placement\";\nimport { dividers as stackDividers, resetBetween as stackReset, resizeBetween as stackResize, type StackFit, type StackInput } from \"@n-uf/placement/stack\";\nimport { axisOf } from \"./helpers\";\nimport type { DockItem, DockLayout, DockState } from \"./model\";\nimport { solve, stateOf } from \"./solve\";\nimport { inputOf } from \"./solve/edge\";\n\n/** One divider of an edge, in stage px: between the open growing items `before` and `after` (ids). */\nexport interface DockDivider {\n /** The edge it lies in. */\n readonly edge: string;\n readonly before: string;\n readonly after: string;\n /**\n * The strip the divider sits on, stage px: it starts where the last item drawn before `after` ends (the far edge of\n * the last collapsed item between the two, or of `before`) and is as thick as the gap to `after` (0 with no gap).\n * A host draws its grab zone around it.\n */\n readonly rect: Rect;\n /** How far it may move each way along the edge, px (`min` ≤ 0 ≤ `max`): where either end reaches its least. */\n readonly range: { readonly min: number; readonly max: number };\n}\n\n/**\n * `layout` when `solve` made it from this very `state` object, else the state solved: a layout made for another state\n * (the stage was another size, an item moved), or one stored and read back, is never used.\n */\nconst laid = (state: DockState, layout: DockLayout | undefined): DockLayout =>\n layout && stateOf(layout) === state && Object.values(layout.edges).every((e) => inputOf(e.stack) !== undefined) ? layout : solve(state);\n\n/** One divider per pair of neighboring open growing items in each edge, edge by edge. A collapsed item has none of its own. */\nexport function dividers(state: DockState, layout?: DockLayout): DockDivider[] {\n const lay = laid(state, layout);\n const out: DockDivider[] = [];\n for (const [edge, e] of Object.entries(lay.edges)) {\n const input = inputOf(e.stack);\n if (!input) continue;\n for (const d of stackDividers(input, e.stack)) out.push({ edge, before: d.before, after: d.after, rect: rect(e.rect.x + d.rect.x, e.rect.y + d.rect.y, d.rect.width, d.rect.height), range: d.range });\n }\n return out;\n}\n\n/** `state` with the lengths `run` wrote on the edge both items are in; the same object when it wrote none. */\nfunction over(state: DockState, layout: DockLayout | undefined, before: string, after: string, run: (input: StackInput, fit: StackFit) => StackInput): DockState {\n const lay = laid(state, layout);\n const edge = lay.items[before]?.edge;\n const e = edge !== undefined && lay.items[after]?.edge === edge ? lay.edges[edge] : undefined;\n const input = e && inputOf(e.stack);\n if (!e || !input) return state;\n const next = run(input, e.stack);\n if (next === input) return state;\n const was = new Map(input.items.map((it) => [it.id, it.lengths]));\n const items: Record<string, DockItem> = { ...state.items };\n for (const it of next.items) if (it.lengths !== was.get(it.id) && items[it.id]) items[it.id] = { ...items[it.id]!, lengths: it.lengths };\n return { ...state, items };\n}\n\n/**\n * Move the divider between the open growing items `before` and `after` of one edge by `delta` px along it: `before` gets\n * longer by `delta` and `after` shorter (a negative `delta` the other way), the edge's total unchanged and nothing else\n * moving. Neither goes under its least (`DockDivider.range`). The same state when nothing changes (not neighbors, an\n * unknown or floating item, a `delta` that isn't a number, or one clamped to 0). The first move writes the length every\n * open growing item of the edge is drawn at, so nothing else shifts.\n */\nexport function resizeBetween(state: DockState, before: string, after: string, delta: number, options: { readonly layout?: DockLayout } = {}): DockState {\n return over(state, options.layout, before, after, (input, fit) => stackResize(input, before, after, delta, { previous: fit }));\n}\n\n/**\n * Give the two items of a divider back the split they would be drawn at if both asked for their natural, their combined\n * length kept and nothing else moving: the double-click action. The same state when they are at that split already.\n */\nexport function resetBetween(state: DockState, before: string, after: string, options: { readonly layout?: DockLayout } = {}): DockState {\n return over(state, options.layout, before, after, (input, fit) => stackReset(input, before, after, { previous: fit }));\n}\n\n/**\n * `state` with every asked length of edge `edgeId`'s axis deleted, back to the split an edge with none has. An item's\n * length for the other axis stays. The same state when no item of the edge had one, or the edge is unknown.\n */\nexport function resetLengths(state: DockState, edgeId: string): DockState {\n const edge = state.edges.find((e) => e.id === edgeId);\n if (!edge) return state;\n const axis = axisOf(edge.side);\n let items: Record<string, DockItem> | undefined;\n for (const id of edge.items) {\n const it = state.items[id];\n if (it?.lengths?.[axis] === undefined) continue;\n const { [axis]: _dropped, ...rest } = it.lengths;\n const { lengths: _lengths, ...bare } = it;\n items ??= { ...state.items };\n items[id] = Object.keys(rest).length > 0 ? { ...bare, lengths: rest } : bare;\n }\n return items ? { ...state, items } : state;\n}\n","/**\n * The state's pure changes. Each returns a new state 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 state\n * given, the same object, so `after === before` says nothing changed.\n *\n * - `moveTo(state, 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. A zone named becomes the item's `align`\n * where the edge offers a choice (`namesZone`: more than one zone takes the kind); on a one-zone edge, or with none\n * named, the item keeps its own and docks in the zone it lies in there (`zoneIn`: its own where the edge takes it\n * there, else the first that does). A new column, a rail and `dockHome` name none either: the item's zone is its own.\n * `{ kind: \"column\", side, ring }` makes a new column from `state.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 (on a side with no declared rail, `DockState.rails`, its rail is its outermost column that takes the\n * kind, \"the column drawn as a rail\": the item docks at the end of its start zone as a collapsed header, folded by\n * hand, a rail tile once nothing there sets the width); `{ 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(state, id, start)`: the place a start state gives the item, for `moveTo`.\n * - `floatAt(state, id, rect?, orient?)`: floats it on top at `rect` (its size becomes its `floatSizes` for the orient\n * it floats in); with no rect, at its `floatSizeOf` size anchored to the content's top-right corner: its `floatSizes`\n * for that orient, else its form's natural size along it (the float's, `orient`, else `floatOrientOf`), else the\n * default size.\n * - `foldItem(state, id, on)`: folded by hand (`from: 1`) draws it in its folded form on the axis it lies along (a\n * panel's `header`, a group's `fold`), and give-way steps down from there; unfolding clears `from`. Where it has no\n * folded form (`canFold` false), folding changes nothing.\n * - `markUsed(state, id)`: the newest age. Under `previous` it reshapes nothing.\n * - `keepItem(state, id, on)`, `openItem(state, id)`, `closeItem(state, id)`, `liftItem(state, id)` (out of every edge\n * and float).\n * - `raiseFloat(state, id)`: a float to the top of the stack; no use, no reshape.\n * - `orientFloat(state, id, orient)`: a float's axis. Its frame takes the size the new orient draws it at\n * (`floatSizeOf`: the size kept for that orient, else the form's natural size), its place and anchor kept; turned\n * back, it has its first orient's size again. An item that declares no `floatSizes` turns keeping its rect, as before\n * the per-orient sizes.\n * - `resizeEdge(state, edge, size)`: the user's size across; a size that isn't a finite number clears it.\n * - `resizeFloat(state, id, rect, moving?)`: a float resized by hand, at `fitResize`'s rect (./float-resize).\n */\nimport { clampInto, type Rect, type Size } from \"@n-uf/placement\";\nimport { fitResize, type ResizeEdges } from \"./float-resize\";\nimport { axesOf, axisOf, columnFromTemplate, declaresFloatSizes, floatOrientOf, placingOf, floatShape, floatSizeOf, floatSizesOf, foldedIndex, formsOf, isHandFolded, isSideColumn, isSince, namesZone, railColumnOf, railModeOf, zoneIn, zoneTakes } from \"./helpers\";\nimport { solve } from \"./solve\";\nimport { RAIL_MODES, type DockEdge, type FloatAnchorAt, type Orient, type RailMode, type DockState, type DockFloat, type DockItem, type Side, type Zone } from \"./model\";\n\n/**\n * Where a docked item goes: before the `at`-th item of `zone` (default the item's own zone) in `edge`, keeping `space`\n * px free on its zone's open side (`DockItem.space`; absent or 0: none). Docked into the room a placed neighbor keeps,\n * it consumes that room: the neighbor keeps what is left and moves only by what the room lacks. (While the edge has\n * spare length to give every room; a squeezed edge shares its spare out, and its items may shift by a few px.)\n */\nexport interface DockPlace {\n readonly kind?: \"gap\";\n readonly edge: string;\n readonly zone?: Zone;\n readonly at: number;\n readonly space?: 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), at an anchor's name or `{ at, dx?, dy? }`. */\n readonly anchor?: FloatAnchorAt;\n /** With `rect` and no anchor: it lies there over what it covers, only kept inside the stage (`DockFloat.stays`). */\n readonly stays?: true;\n}\nexport type Place = DockPlace | ColumnPlace | RailPlace | FloatPlace;\n\nconst withItem = (state: DockState, item: DockItem): DockState => ({ ...state, items: { ...state.items, [item.id]: item } });\nconst itemOf = (state: DockState, id: string): DockItem | undefined => (Object.hasOwn(state.items, id) ? state.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 DockEdge[], sides: ReadonlySet<string>): DockEdge[] {\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(state: DockState): DockState {\n const gone = state.edges.filter((e) => e.column === true && e.items.length === 0);\n if (gone.length === 0) return state;\n const sides = new Set(gone.map((e) => e.side));\n return { ...state, edges: closeRings(state.edges.filter((e) => !gone.includes(e)), sides) };\n}\n\n/**\n * Each side's columns (`isSideColumn`) merged into one, for `DockState.sideColumns: \"one\"`: the outermost column (by ring)\n * keeps its id and takes every other column's items after its own, in ring order; the others are deleted and the side's\n * rings closed up. A side with one column or none is unchanged; the same state comes back when nothing merges. A host\n * calls it as it reads a stored layout, so what it stores is what it shows and what a drag reads.\n */\nexport function mergeSideColumns(state: DockState): DockState {\n let edges = [...state.edges];\n const sides = new Set<string>();\n for (const side of [\"left\", \"right\"] as const) {\n const cols = edges.filter((e) => e.side === side && isSideColumn(state, e)).sort((a, b) => a.ring - b.ring);\n if (cols.length < 2) continue;\n const [keep, ...rest] = cols;\n const merged: DockEdge = { ...keep!, items: [...keep!.items, ...rest.flatMap((e) => e.items)] };\n edges = edges.filter((e) => !rest.includes(e)).map((e) => (e === keep ? merged : e));\n sides.add(side);\n }\n return sides.size === 0 ? state : { ...state, edges: closeRings(edges, sides) };\n}\n\n/**\n * The state with the item out of every edge and every float (a dynamic column it leaves empty is deleted). The room it\n * held goes back to its stretch: the first placed item past it, away from its zone's own end (`DockItem.space`), takes\n * it back, so it stays where it was drawn; the flush items between close up toward the zone's own end. (While the edge\n * has spare length to give every room; a squeezed edge, or items stepping up to wider forms, may shift it by a few px.)\n */\nexport function liftItem(state: DockState, id: string): DockState {\n const inEdge = state.edges.some((e) => e.items.includes(id));\n const inFloat = state.floats.some((f) => f.id === id);\n if (!inEdge && !inFloat) return state;\n let s = state;\n const from = state.edges.find((e) => e.items.includes(id));\n const owner = from ? roomOwner(state, from, from.items.indexOf(id)) : undefined;\n if (from && owner) {\n const length = lengthOn(state, from, id);\n if (length > 0) s = withSpace(s, owner, (state.items[owner]!.space ?? 0) + (state.items[id]?.space ?? 0) + length + nonNegative(from.gap));\n }\n return prune({\n ...s,\n edges: inEdge ? s.edges.map((e) => (e.items.includes(id) ? { ...e, items: e.items.filter((x) => x !== id) } : e)) : s.edges,\n floats: inFloat ? s.floats.filter((f) => f.id !== id) : s.floats,\n });\n}\n\n/**\n * The placed item that absorbs a change at `edge.items[k]`: away from the zone's own end (after the item in a start\n * zone, before it in an end zone), past the flush items that follow it, the first that keeps room (`DockItem.space`:\n * before an item in a start zone, after it in an end zone). The flush items between move with the change; the room\n * owner's room takes it, so it stays where it is. None in a center zone or where no placed item follows in the zone.\n */\nfunction roomOwner(state: DockState, edge: DockEdge, k: number): string | undefined {\n const id = edge.items[k];\n if (id === undefined) return undefined;\n const zone = zoneAt(state, edge, id);\n if (zone === \"center\") return undefined;\n const step = zone === \"start\" ? 1 : -1;\n // The edge's list may hold zones in any order (the solver sorts by zone): another zone's items, and closed items\n // (they take no room), are passed over.\n for (let j = k + step; j >= 0 && j < edge.items.length; j += step) {\n const nb = edge.items[j]!;\n if (zoneAt(state, edge, nb) !== zone || state.items[nb]?.closed) continue;\n if ((state.items[nb]?.space ?? 0) > 0) return nb;\n }\n return undefined;\n}\n\n/** The item's length along `edge` as `state` lays it out (0 where it isn't drawn on that edge). */\nfunction lengthOn(state: DockState, edge: DockEdge, id: string): number {\n const it = solve(state).items[id];\n if (!it || it.inMenu || it.edge !== edge.id) return 0;\n return axisOf(edge.side) === \"column\" ? it.rect.height : it.rect.width;\n}\n\nconst nonNegative = (n: number | undefined): number => (Number.isFinite(n) && n! > 0 ? n! : 0);\n\n/** The state with the item keeping `space` (none at 0 or less). */\nfunction withSpace(state: DockState, id: string, space: number): DockState {\n const { space: _old, ...bare } = state.items[id]!;\n return { ...state, items: { ...state.items, [id]: space > 1e-6 ? { ...bare, space } : bare } };\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. Its id is\n * chosen against the state's edges and `others`: edges kept out of `state` (its hidden ones, when `state` is what the\n * window shows), so it never repeats an id the stored state has.\n */\nfunction newColumn(state: DockState, side: \"left\" | \"right\", kind: string, ring: number, items: readonly string[], others: readonly DockEdge[]): DockEdge | null {\n const t = state.columns?.[side];\n if (!t || !t.accepts.includes(kind)) return null;\n const taken = new Set([...state.edges, ...others].map((e) => e.id));\n let n = 0;\n while (taken.has(`${side}-${n}`)) n++;\n return columnFromTemplate(t, `${side}-${n}`, side, ring, items);\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 state):\n * the numbers column and rail places count in.\n */\nexport function sideRings(edges: readonly DockEdge[], 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 DockEdge[], 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 * `state` 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(state0: DockState, id: string, side: \"left\" | \"right\", ring: number, others: readonly DockEdge[]): DockState | null {\n const state: DockState = { ...state0, edges: closeRings(state0.edges, new Set([side])) };\n const kind = state.items[id]!.kind;\n const mine = state.edges.filter((e) => e.side === side);\n const floor = columnFloor(state.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(state, side, kind, r, [id], others);\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 own zone (`align`): it lies in it where the new column takes it there, else in the first zone\n // that does (`zoneIn`), as in any edge.\n const shifted = state.edges.map((e) => (e.side === side && e.ring >= r ? { ...e, ring: e.ring + 1 } : e));\n return { ...state, edges: closeRings([...shifted, col], new Set([side])) };\n}\n\n/** The zone item `id` lies in on `edge` (`zoneIn`); its own when it is unknown. */\nconst zoneAt = (state: DockState, edge: DockEdge, id: string): Zone => {\n const it = itemOf(state, id);\n return it ? zoneIn(edge, it) : \"start\";\n};\n\n/** The index in `edge.items` where the `at`-th item of `zone` is (or where the zone ends), by the zones items lie in. */\nfunction insertIndex(state: DockState, edge: DockEdge, 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) => zoneAt(state, edge, 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[zoneAt(state, edge, id)] < rank[zone]) idx = i + 1;\n });\n return idx;\n}\n\nexport function moveTo(state: DockState, id: string, place: Place): DockState {\n return moveAmong(state, id, place, []);\n}\n\n/**\n * `moveTo`, with `others`: edges kept out of `state` that a new column's id must not repeat. A drop's result is made on\n * the state the window shows (its hidden edges left out), and its hidden edges are passed here.\n */\nexport function moveAmong(state: DockState, id: string, place: Place, others: readonly DockEdge[]): DockState {\n const item = itemOf(state, id);\n if (!item || item.fixed) return state;\n if (place.kind === \"float\") {\n const out = floatAt(state, id, place.rect);\n const anchor = place.anchor;\n // Left over content by the hand (`DockFloat.stays`): only with a rect of its own.\n const stays = place.stays === true && !anchor && !!place.rect;\n if ((!anchor && !stays) || out === state) return out;\n return { ...out, floats: out.floats.map((f) => (f.id === id ? (anchor ? { ...f, anchor } : { ...f, stays: true as const }) : f)) };\n }\n // A side with no declared rail: its rail is its outermost column that takes the kind (`railColumnOf`), the item docked\n // at the end of the zone it lies in there (its own where the column takes it there, else the first), folded by hand.\n // The rail names no zone: the item keeps its own.\n const railColumn = place.kind === \"rail\" ? railColumnOf(state, place.side, item.kind) : undefined;\n if (railColumn) {\n const docked = moveAmong(state, id, { edge: railColumn.id, at: Infinity }, others);\n return docked === state ? state : withItem(docked, { ...docked.items[id]!, from: Math.max(1, item.from ?? 0) });\n }\n if (place.kind === \"column\" || place.kind === \"rail\") {\n if (place.kind === \"rail\" && !state.rails?.[place.side]?.accepts.includes(item.kind)) return state;\n // Its zone goes with it: `insertColumn` keeps it where the new column takes the kind there.\n // A new column keeps no bar space (`DockItem.space`).\n const { space: _space, ...unspaced } = item;\n const folded: DockItem = place.kind === \"rail\" ? { ...unspaced, from: Math.max(1, item.from ?? 0) } : unspaced;\n const made = insertColumn(withItem(liftItem(state, id), folded), id, place.side, place.ring, others);\n return made ?? state;\n }\n const edge = state.edges.find((e) => e.id === place.edge);\n // A hidden edge takes nothing, as one that doesn't take the kind.\n if (!edge || edge.hidden === true || !edge.accepts.includes(item.kind)) return state;\n // The zone asked for, else the one it lies in there (`zoneIn`: its own, or the first that takes its kind), must take\n // the kind (`zoneAccepts`). The item's zone is its own fact: a zone asked for becomes its `align` only where the edge\n // offers a choice (`namesZone`: more than one of its zones takes the kind). On a one-zone edge (a rail that takes the\n // kind at its start only) it docks in that zone and keeps its own.\n const zone = place.zone ?? zoneIn(edge, item);\n if (!zoneTakes(edge, zone, item.kind)) return state;\n // A dock move keeps the space it names, or none.\n const { space: _space, ...unspaced } = item;\n const { align: _drop, ...rest } = unspaced;\n const kept = Number.isFinite(place.space) && place.space! > 0 ? { space: place.space! } : {};\n const moved: DockItem = { ...(place.zone === undefined || !namesZone(edge, item.kind) ? unspaced : zone === \"start\" ? rest : { ...rest, align: zone }), ...kept };\n const lifted = withItem(liftItem(state, 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 state;\n const k = insertIndex(lifted, target, zone, place.at);\n const into = { ...target, items: [...target.items.slice(0, k), id, ...target.items.slice(k)] };\n const placed: DockState = { ...lifted, edges: lifted.edges.map((e) => (e === target ? into : e)) };\n // Docked into the room a placed neighbor keeps (`DockItem.space`): the dock consumes that room. The item lies flush\n // against its zone's own end of the room (its start in a start zone, its end in an end zone), or where its own `space`\n // puts it, and the neighbor keeps what is left, so it moves only by what the room lacks. A flush neighbor is pushed\n // along by the item.\n const owner = roomOwner(placed, into, k);\n if (!owner) return placed;\n const length = lengthOn(placed, into, id);\n if (length <= 0) return placed;\n const room = placed.items[owner]!.space ?? 0;\n return withSpace(placed, owner, room - (placed.items[id]!.space ?? 0) - length - nonNegative(into.gap));\n}\n\n/**\n * One more than the largest `since` among the state's floats (a missing or unusable one counts as 0); 1 when there are\n * none. Never past `Number.MAX_SAFE_INTEGER`.\n */\nfunction nextSince(state: DockState): number {\n const most = state.floats.reduce((m, f) => Math.max(m, isSince(f.since) ? f.since : 0), 0);\n return Math.min(most + 1, Number.MAX_SAFE_INTEGER);\n}\n\n/** The anchored floats' rects as `state` draws them, remembered per state. */\nconst anchoredDrawn = new WeakMap<DockState, readonly { readonly id: string; readonly rect: Rect }[]>();\n\n/**\n * Whether `r`, where the hand puts float `id`, lies over an anchored float as drawn now. Only then does the hand's float\n * win over it (a renewed `since`): what the hand covers it wins, what it doesn't cover never moves.\n */\nfunction overAnchored(state: DockState, id: string, r: Rect): boolean {\n if (!state.floats.some((f) => f.anchor && f.id !== id)) return false;\n let drawn = anchoredDrawn.get(state);\n if (!drawn) {\n const l = solve(state);\n drawn = state.floats.filter((f) => f.anchor && l.items[f.id]?.floating).map((f) => ({ id: f.id, rect: l.items[f.id]!.rect }));\n anchoredDrawn.set(state, drawn);\n }\n const touch = 1e-3;\n return drawn.some((d) => d.id !== id && Math.min(r.x + r.width, d.rect.x + d.rect.width) - Math.max(r.x, d.rect.x) > touch && Math.min(r.y + r.height, d.rect.y + d.rect.height) - Math.max(r.y, d.rect.y) > touch);\n}\n\nexport function floatAt(state: DockState, id: string, at?: Rect, orient?: Orient): DockState {\n const item = itemOf(state, id);\n if (!item || item.fixed || !state.floatKinds.includes(item.kind)) return state;\n const was = state.floats.find((f) => f.id === id);\n const o: Orient | undefined = orient ?? was?.orient;\n const fo = o ?? floatOrientOf(item);\n const size = floatSizeOf(item, fo);\n // Placed at a rect over an anchored float (a drop: the hand placed it there), it comes after every float there, so it\n // wins over that anchored float (`DockFloat.since`); placed clear of every anchored float, or re-anchored with no\n // rect, a float that floats already keeps its `since`, so nothing it doesn't cover moves.\n const since = was && !(at && overAnchored(state, id, at)) ? was.since : nextSince(state);\n const seq = since !== undefined ? { since } : {};\n const float: DockFloat = at\n ? { id, rect: { x: at.x, y: at.y, width: at.width, height: at.height }, ...(o ? { orient: o } : {}), ...seq }\n : { id, rect: { x: 0, y: 0, width: size.width, height: size.height }, anchor: \"content-top-right\", ...(o ? { orient: o } : {}), ...seq };\n // A float keeps no bar space (`DockItem.space`). Lifted first, as it lies, so the room it held (its own space\n // included) goes back to its stretch.\n const { space: _space, ...unspaced } = item;\n // A rect sets the size for the orient it floats in (`floatSizes`). With no rect, an item that declares none keeps\n // declaring none, framed at its stored rect.\n const set = at && at.width > 0 && at.height > 0 ? { orient: fo, size: { width: at.width, height: at.height } } : undefined;\n const next = set || declaresFloatSizes(item) ? withFloatSizes(unspaced, set) : unspaced;\n const lifted = withItem(liftItem(state, id), next);\n return { ...lifted, floats: [...lifted.floats, float] };\n}\n\n/** `item` with its usable `floatSizes`, and `set`'s size kept for its orient when given. */\nexport function withFloatSizes(item: DockItem, set?: { readonly orient: Orient; readonly size: Size }): DockItem {\n const { floatSizes: _sizes, ...rest } = item;\n const sizes = { ...floatSizesOf(item), ...(set ? { [set.orient]: set.size } : {}) };\n return sizes.row || sizes.column ? { ...rest, floatSizes: sizes } : rest;\n}\n\n/**\n * Whether a hand fold of `id` means anything where it lies now: it has a folded form (a panel's `header`, a group's\n * `fold`; a fixed item on a `foldable` edge, a thumbnail anchor, its `rail` tile) among the forms of the axis it lies\n * along (its edge's, its float's orient; either when it lies nowhere). Where it is false, `foldItem(on)` changes nothing: a\n * host leaves the grip's double-click off. An item folded by hand can always be unfolded.\n */\nexport function canFold(state: DockState, id: string): boolean {\n const item = itemOf(state, id);\n if (!item || (item.fixed && !state.edges.some((e) => e.foldable === true && e.items.includes(id)))) return false;\n // A lent item folds as it is drawn: along the edge it shows in (`placingOf`).\n const edge = placingOf(state, id).edges.find((e) => e.items.includes(id));\n return axesOf(state, id).some((a) => foldedIndex(item, formsOf(item, a), edge) >= 0);\n}\n\nexport function foldItem(state: DockState, id: string, on: boolean): DockState {\n const item = itemOf(state, id);\n // A fixed item folds only on an edge that allows it (`DockEdge.foldable`).\n if (!item || (item.fixed && !state.edges.some((e) => e.foldable === true && e.items.includes(id)))) return state;\n // Folded by hand (`from: 1`): solve draws it in its folded form on the axis it lies along (`startOf`), never one\n // step down the ladder. With no folded form there, a hand fold is nothing.\n if (on) return isHandFolded(state, id) || !canFold(state, id) ? state : withItem(state, { ...item, from: 1 });\n if (item.from === undefined) return state;\n const { from: _f, ...rest } = item;\n return withItem(state, rest);\n}\n\n/** The newest age in the state, plus one. */\nconst nextAge =(state: DockState): number => Object.values(state.items).reduce((m, it) => Math.max(m, Number.isFinite(it.used) ? it.used : 0), 0) + 1;\n\n/**\n * The item made the newest (`used`: the newest age plus one). Idempotent: an item already strictly newer than every\n * other gives back the state itself, so a press on it changes nothing (a tie with another item is not newest, and\n * bumps). A drop's result is marked used the same way.\n */\nexport function markUsed(state: DockState, id: string): DockState {\n const item = itemOf(state, id);\n if (!item) return state;\n const age = (it: DockItem): number => (Number.isFinite(it.used) ? it.used : 0);\n if (Number.isFinite(item.used) && Object.values(state.items).every((it) => it.id === id || age(it) < item.used)) return state;\n return withItem(state, { ...item, used: nextAge(state) });\n}\n\nexport function keepItem(state: DockState, id: string, on: boolean): DockState {\n const item = itemOf(state, id);\n if (!item || !!item.kept === on) return state;\n if (on) return withItem(state, { ...item, kept: true });\n const { kept: _k, ...rest } = item;\n return withItem(state, rest);\n}\n\nexport function openItem(state: DockState, id: string): DockState {\n const item = itemOf(state, id);\n if (!item || !item.closed) return state;\n const { closed: _c, ...rest } = item;\n return withItem(state, rest);\n}\n\nexport function closeItem(state: DockState, id: string): DockState {\n const item = itemOf(state, id);\n if (!item || item.closed || item.fixed) return state;\n return withItem(state, { ...item, closed: true });\n}\n\nexport function raiseFloat(state: DockState, id: string): DockState {\n const i = state.floats.findIndex((f) => f.id === id);\n if (i < 0 || i === state.floats.length - 1) return state;\n return { ...state, floats: [...state.floats.slice(0, i), ...state.floats.slice(i + 1), state.floats[i]!] };\n}\n\nexport function orientFloat(state: DockState, id: string, to: Orient): DockState {\n const i = state.floats.findIndex((f) => f.id === id);\n const item = state.items[id];\n const f = state.floats[i];\n if (!f || !item) return state;\n const from = f.orient ?? floatOrientOf(item);\n if (from === to) return state;\n // An item that declares no `floatSizes` turns as before the per-orient sizes: its rect kept as it is.\n if (!declaresFloatSizes(item)) return { ...state, floats: state.floats.map((g, k) => (k === i ? { ...g, orient: to } : g)) };\n // The orient it leaves keeps the size it is drawn at where the user sizes it (a form that grows), so turning back\n // restores that rect; a toolbar group's size is its form's, known without being kept.\n const grows = formsOf(item, from)[0]?.main.grows === true;\n const kept = withFloatSizes(item, grows && f.rect.width > 0 && f.rect.height > 0 ? { orient: from, size: { width: f.rect.width, height: f.rect.height } } : undefined);\n // The frame takes the size the new orient draws at, where its anchor (if any) already puts it: its place is kept.\n const size = drawnFloatSize(kept, { rect: { ...f.rect, ...floatSizeOf(kept, to) }, orient: to });\n const turned: DockFloat = { ...f, rect: { x: f.rect.x, y: f.rect.y, width: size.width, height: size.height }, orient: to };\n return withItem({ ...state, floats: state.floats.map((g, k) => (k === i ? turned : g)) }, kept);\n}\n\n/**\n * A float resized by hand: the rect `fitResize(state, floatId, rect, moving)` gives (default `moving`: right and\n * bottom), so a host's preview from `fitResize` is what this commits. The float keeps its stacking order and orient,\n * loses its anchor, and the size becomes the item's `floatSizes` for that orient (stored with the state). The state\n * given back where `fitResize` refuses (a toolbar group, a folded float, anything not floating).\n */\nexport function resizeFloat(state: DockState, floatId: string, rect: Rect, moving: ResizeEdges = { right: true, bottom: true }): DockState {\n const fit = fitResize(state, floatId, rect, moving);\n const i = state.floats.findIndex((f) => f.id === floatId);\n const item = itemOf(state, floatId);\n if (!fit || i < 0 || !item) return state;\n const { anchor: _a, ...plain } = state.floats[i]!;\n // A hand resize grown over an anchored float comes after every float there (`DockFloat.since`), so it wins over it;\n // one that stays clear of every anchored float keeps its `since`.\n const renew = overAnchored(state, floatId, fit.rect);\n const float: DockFloat = renew ? { ...plain, rect: fit.rect, since: nextSince(state) } : { ...plain, rect: fit.rect };\n const fo = float.orient ?? floatOrientOf(item);\n return withItem({ ...state, floats: state.floats.map((g, k) => (k === i ? float : g)) }, withFloatSizes(item, { orient: fo, size: { width: fit.rect.width, height: fit.rect.height } }));\n}\n\n/** The user's size across an edge; a size that isn't finite clears it. */\nexport function resizeEdge(state: DockState, edgeId: string, size: number): DockState {\n const edge = state.edges.find((e) => e.id === edgeId);\n if (!edge) return state;\n if (!Number.isFinite(size)) {\n if (edge.size === undefined) return state;\n const { size: _s, ...rest } = edge;\n return { ...state, edges: state.edges.map((e) => (e === edge ? rest : e)) };\n }\n return { ...state, edges: state.edges.map((e) => (e === edge ? { ...e, size } : e)) };\n}\n\n/**\n * The side's rails show their items as `mode` (`DockState.railModes`): their titles while they fit, or their tiles only.\n * Unchanged for a side other than left or right, an unknown mode, or the mode the side has already.\n */\nexport function setRailMode(state: DockState, side: \"left\" | \"right\", mode: RailMode): DockState {\n if ((side !== \"left\" && side !== \"right\") || !RAIL_MODES.includes(mode) || railModeOf(state, side) === mode) return state;\n return { ...state, railModes: { ...state.railModes, [side]: mode } };\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 `markUsed()` on its items afterwards, as a drop does.\n */\nexport function setSide(state: DockState, edgeId: string, side: Side): DockState {\n const edge = state.edges.find((e) => e.id === edgeId);\n if (!edge || edge.side === side || axisOf(edge.side) !== axisOf(side)) return state;\n const moved: DockEdge = { ...edge, side, ring: 0 };\n const others = state.edges.filter((e) => e !== edge).map((e) => (e.side === side ? { ...e, ring: e.ring + 1 } : e));\n return { ...state, edges: closeRings([moved, ...others], new Set([edge.side, side])) };\n}\n\n/**\n * The place `start` (a state as it began: the host's start or reset state) 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 `state` no longer has that isn't a column. `moveTo(state, id, place)` puts it there.\n */\nexport function homeFor(state: DockState, id: string, start: DockState): Place | null {\n for (const e of start.edges) {\n const k = e.items.indexOf(id);\n if (k < 0) continue;\n const own = itemOf(start, id) ?? itemOf(state, 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 = state.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 // The zone it lies in there, by its start `align` (`zoneIn`); the others by where they lie.\n const zone = own ? zoneIn(here, own) : \"start\";\n const now = here.items.filter((x) => x !== id && zoneAt(state, here, 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 state'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 } : f.stays ? { stays: true as const } : {}) };\n return null;\n}\n\n/**\n * Dock, Put back and Reset position: the item where `start` (the loaded state) 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 state given back unchanged when `start` places it nowhere.\n */\nexport function dockHome(state: DockState, id: string, start: DockState): DockState {\n const place = homeFor(state, id, start);\n if (!place) return state;\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(state, id, place);\n const item = itemOf(moved, id);\n if (!item) return state;\n // Home names no zone of its own: the item takes `start`'s zone (`align`) back, as its fold.\n const was = itemOf(start, id);\n const from = was?.from;\n let out = item;\n if (was && out.align !== was.align) {\n const { align: _a, ...plain } = out;\n out = was.align === undefined ? plain : { ...plain, align: was.align };\n }\n if (out.from !== from) {\n const { from: _f, ...plain } = out;\n out = from === undefined ? plain : { ...plain, from };\n }\n return out === item ? moved : withItem(moved, out);\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: DockItem, 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 * `fitResize(state, id, rect, moving)`: the rect a float takes when the user drags some of its edges, clamped in one\n * pass (no iteration) and with the limits that bound it. Hosts call it on every pointer move for the preview; the\n * state change `resizeFloat(state, id, rect, moving)` commits the same rect, so the preview is the commit.\n *\n * It is not `fitFloat`: that one moves a float (never resizes it) to a clear place; this one resizes it with the edges\n * not dragged kept put, and stops a dragged edge before anything `fitFloat` would move it off, so `solve` lays the\n * result exactly where it is asked.\n */\nimport type { Rect } from \"@n-uf/placement\";\nimport { axisOf, keepClearFor, floatOrientOf, floatRegion, floatShape, formsOf } from \"./helpers\";\nimport type { DockState, DockLayout } from \"./model\";\nimport { solve } from \"./solve\";\nimport { floatFloor, placeFloat } from \"./solve/floats\";\n\n/** The edges of a float a resize drags; the others stay put. Left beats right, top beats bottom, when both are set. */\nexport interface ResizeEdges {\n readonly left?: boolean;\n readonly right?: boolean;\n readonly top?: boolean;\n readonly bottom?: boolean;\n}\n\n/**\n * Why a resized float isn't the rect asked for: `\"min\"` its least size (`floatMin`, else its open form's minimums),\n * `\"max\"` its `floatMax`, `\"region\"` the region floats lie in (the stage less the inset at its left and right, its full\n * height), `\"docked\"` what floats are kept clear of (a bar, a docked item, the chrome).\n */\nexport type ResizeLimit = \"min\" | \"max\" | \"region\" | \"docked\";\n\nexport interface FloatResize {\n /** The float's rect: what `resizeFloat` stores and `solve` draws. */\n readonly rect: Rect;\n /** The limits that bound it, in this order: min, max, region, docked. Empty when it is the rect asked for. */\n readonly limits: readonly ResizeLimit[];\n}\n\nconst LIMITS: readonly ResizeLimit[] = [\"min\", \"max\", \"region\", \"docked\"];\nconst EPS = 0.5;\n/** How far `fitFloat` reads two rects as touching rather than overlapping (its own tolerance). */\nconst TOUCH = 1e-3;\nconst fin = (v: number | undefined, d: number): number => (Number.isFinite(v) ? v! : d);\n\n/**\n * What `solve` keeps floats clear of, as laid out now: docked items (» entries included) first, `docked` of them, then\n * bars and their » menus and the chrome.\n */\nfunction floatObstacles(state: DockState, l: DockLayout, id: string): { rects: Rect[]; docked: number } {\n const some = (r: Rect): boolean => r.width > 0 && r.height > 0;\n const rects: Rect[] = [];\n for (const [k, p] of Object.entries(l.items)) if (k !== id && !p.floating && some(p.rect)) rects.push(p.rect);\n const docked = rects.length;\n for (const e of Object.values(l.edges)) {\n if (axisOf(e.side) === \"row\" && e.cross > 0) rects.push(e.rect);\n if (e.menu) rects.push(e.menu.rect);\n }\n for (const c of keepClearFor(state, \"floats\")) rects.push(c);\n return { rects: rects.filter(some), docked };\n}\n\n/**\n * Where the dragged edge of `drawn` along `axis` stops: the nearest obstacle beyond it on that side that lies across\n * `span` (the float's extent on the other axis). An obstacle the float already overlaps (it covers the edge: no clear\n * place existed at the float's size) keeps the edge where it is drawn: growing would cover it more.\n */\nfunction obstacleStop(drawn: Rect | undefined, obstacles: readonly Rect[], axis: \"x\" | \"y\", drag: \"start\" | \"end\" | null, span: readonly [number, number]): number {\n const none = drag === \"start\" ? -Infinity : Infinity;\n if (!drawn || !drag) return none;\n const lo = (r: Rect): number => (axis === \"x\" ? r.x : r.y);\n const len = (r: Rect): number => (axis === \"x\" ? r.width : r.height);\n const across = (r: Rect): [number, number] => (axis === \"x\" ? [r.y, r.y + r.height] : [r.x, r.x + r.width]);\n let at = none;\n for (const o of obstacles) {\n const [c0, c1] = across(o);\n // Across, as tight as `fitFloat` tells touching from covering: an obstacle a fraction of a px across it still stops it.\n if (c0 >= span[1] - TOUCH || c1 <= span[0] + TOUCH) continue;\n const begin = lo(o);\n const finish = begin + len(o);\n const edge = drag === \"start\" ? lo(drawn) : lo(drawn) + len(drawn);\n if (drag === \"start\") {\n if (finish <= edge + EPS) at = Math.max(at, finish);\n // Straddling the edge: the float already covers it (no clear place at its size), and growing past the edge would\n // cover it more, so the edge stays where it is drawn.\n else if (begin < edge - TOUCH) at = edge;\n } else {\n if (begin >= edge - EPS) at = Math.min(at, begin);\n else if (finish > edge + TOUCH) at = edge;\n }\n }\n // It stops growth only: never inside where the edge is drawn now (an obstacle it touches within a fraction of a px).\n return drag === \"start\" ? Math.min(at, lo(drawn)) : Math.max(at, lo(drawn) + len(drawn));\n}\n\n/** One axis: `[start, length]` asked; the bounds; which edge is dragged. The limits that bind go into `hit`. */\nfunction fitAxis(start: number, length: number, b: { min: number; max: number; lo: number; hi: number; stop: number }, drag: \"start\" | \"end\" | null, hit: Set<ResizeLimit>): [number, number] {\n const { min, lo, hi, stop } = b;\n const max = Math.max(min, b.max);\n const raw = fin(length, min);\n // A floor larger than the region: the floor, at the region's start (as `solve` lays it).\n if (min >= hi - lo) {\n hit.add(\"region\");\n return [lo, min];\n }\n // The bound a dragged edge reaches first, with every limit that sits there.\n const bind = (cands: [number, ResizeLimit][], pick: (a: number, b: number) => number): [number, ResizeLimit[]] => {\n const at = cands.reduce((m, [v]) => pick(m, v), cands[0]![0]);\n return [at, cands.filter(([v]) => Math.abs(v - at) <= EPS).map(([, k]) => k)];\n };\n if (drag === \"start\") {\n // The end is kept (moved into the region only when it lies outside it).\n const asked = fin(start, lo) + raw;\n const end = Math.min(hi, Math.max(lo + min, asked));\n if (Math.abs(end - asked) > EPS) hit.add(\"region\");\n const [down, why] = bind([[end - max, \"max\"], [lo, \"region\"], [stop, \"docked\"]], Math.max);\n let from = end - raw;\n if (from > end - min) {\n from = end - min;\n hit.add(\"min\");\n } else if (from < down - TOUCH) {\n // What floats are kept clear of beats the minimum (`solve` keeps a float asked smaller at its size).\n from = why.includes(\"docked\") ? Math.min(down, end) : Math.min(down, end - min);\n for (const k of from === down ? why : ([\"min\"] as ResizeLimit[])) hit.add(k);\n }\n return [from, end - from];\n }\n // The start is kept (moved into the region only when it lies outside it); an axis not dragged keeps its start too.\n const asked = fin(start, lo);\n const a = Math.max(lo, Math.min(hi - min, asked));\n if (Math.abs(a - asked) > EPS) hit.add(\"region\");\n const [up, why] = bind([[a + max, \"max\"], [hi, \"region\"], [stop, \"docked\"]], Math.min);\n let to = a + raw;\n if (to < a + min) {\n to = a + min;\n hit.add(\"min\");\n } else if (to > up + TOUCH) {\n to = why.includes(\"docked\") ? Math.max(up, a) : Math.max(up, a + min);\n for (const k of to === up ? why : ([\"min\"] as ResizeLimit[])) hit.add(k);\n }\n return [a, to - a];\n}\n\n/**\n * The rect float `id` takes for a resize: `rect` is the rect asked for in stage px (the float as drawn, with the\n * `moving` edges where the pointer put them). In one pass: the edges not moving stay put; the size is at least the\n * item's `floatMin` (else its open form's minimums, which only stop a shrink below the size drawn now, as `solve` lays\n * it) and at most its `floatMax`; the float stays in the region floats lie in; every growing edge (a moving one, or the\n * end of an axis not moving) stops at what floats are kept clear of, as drawn now (across first, over its height now;\n * then along, over its new width), and such a stop beats the minimum. The rect is then laid by the one clamp `solve`\n * lays floats with, so `solve(resizeFloat(...))` draws exactly this rect. A float that already covers something (no clear\n * place at its size) may move to a clear place once a resize opens one; the preview is still the commit, and\n * `\"docked\"` says so. Such a float never grows over what it covers: a dragged edge that lies inside an obstacle stays\n * where it is drawn (`\"docked\"`), so a resize never covers more than the float did. `limits` says which of these bound it.\n *\n * Null for anything but a float drawn at its first form when that form grows (a panel's card): a toolbar group's size\n * comes from its forms, and so does a folded float's bar. Pure: it solves the state once, for what is drawn now.\n */\nexport function fitResize(state: DockState, id: string, rect: Rect, moving: ResizeEdges): FloatResize | null {\n const f = state.floats.find((x) => x.id === id);\n const item = Object.hasOwn(state.items, id) ? state.items[id] : undefined;\n if (!f || !item || item.fixed) return null;\n const fo = f.orient ?? floatOrientOf(item);\n const form = formsOf(item, fo)[0];\n if (floatShape(item, f).form !== 0 || (form && !form.main.grows)) return null;\n const l = solve(state);\n const drawn = l.items[id]?.rect;\n if (!drawn) return null;\n // `solve`'s floor: `floatMin` as given, else the form's minimums, which only stop a shrink below the size drawn now.\n const min = floatFloor(item, form, fo, drawn);\n const max = { width: fin(item.floatMax?.width, Infinity), height: fin(item.floatMax?.height, Infinity) };\n const region = floatRegion(state);\n const dragX = moving.left ? \"start\" : moving.right ? \"end\" : null;\n const dragY = moving.top ? \"start\" : moving.bottom ? \"end\" : null;\n const { rects: obstacles, docked } = floatObstacles(state, l, id);\n const hit = new Set<ResizeLimit>();\n // Every growing edge stops at what floats are kept clear of: a dragged one, and the end of an axis not dragged. A float\n // the hand left over content (`stays`) lies over docked items: only the bars and the chrome stop it.\n const stops = f.stays ? obstacles.slice(docked) : obstacles;\n const [x, width] = fitAxis(rect.x, rect.width, { min: min.width, max: max.width, lo: region.x, hi: region.x + region.width, stop: obstacleStop(drawn, stops, \"x\", dragX ?? \"end\", [drawn.y, drawn.y + drawn.height]) }, dragX, hit);\n const [y, height] = fitAxis(rect.y, rect.height, { min: min.height, max: max.height, lo: region.y, hi: region.y + region.height, stop: obstacleStop(drawn, stops, \"y\", dragY ?? \"end\", [x, x + width]) }, dragY, hit);\n // The one clamp `solve` lays floats with: what it gives is what the commit draws.\n const { anchor: _a, ...plain } = f;\n const placed = placeFloat(item, { ...plain, rect: { x, y, width, height } }, region, obstacles, l.content, state.stage, [], docked).fit.rect;\n if (Math.abs(placed.x - x) > EPS || Math.abs(placed.y - y) > EPS) hit.add(\"docked\");\n if (Math.abs(placed.width - width) > EPS || Math.abs(placed.height - height) > EPS) hit.add(\"min\");\n return { rect: placed, limits: LIMITS.filter((k) => hit.has(k)) };\n}\n","/**\n * The state's stored form. `storeDockState(state)` gives plain JSON-safe data; `readDockState(data, base)` reads it back over\n * `base` (the host's state as it starts: its item definitions, edges, kinds and stage) and never throws.\n *\n * ```ts\n * interface StoredDockState {\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 | { at: FloatAnchor; dx?: number; dy?: number }; since?: number; stays?: true }[];\n * items: Record<string, { used: number; kept?: true; from?: number; closed?: true; align?: \"center\" | \"end\"; space?: number; lengths?: { column?: number; row?: number }; floatSizes?: { row?: { width: number; height: number }; column?: { width: number; height: number } } }>;\n * railModes?: { left?: \"titles\" | \"icons\"; right?: \"titles\" | \"icons\" };\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. `DockEdge.hidden` is view state, not stored: the host decides it\n * each time it builds the state (from the window's width, say). A hidden edge's items are stored like any edge's;\n * `hidden` itself is not written, and read back it comes from `base` only (a stored `hidden` is ignored and listed as\n * `edge:<id>:hidden`). `DockEdge.showIn` is the same: never written, from `base` only, a stored one listed as\n * `edge:<id>:showIn`; the items a hidden edge lends are stored in it, as they are. No float has a pinned field: one\n * an old store has is listed and 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; its anchor, with any offset, is kept as stored (an anchored float\n * lies by its anchor, so the clamp never turns it into a pixel position). An unusable anchor is dropped\n * (`float:<id>:anchor`), and so is a bad offset field (`float:<id>:anchor:dx`, `float:<id>:anchor:<field>`). A float's\n * `since` is kept as stored; one that isn't a number from 0 to `Number.MAX_SAFE_INTEGER` is dropped (`float:<id>:since`).\n * A float's `stays` (left over content by the hand) is kept on a float with no anchor; anything but `true` is dropped\n * (`float:<id>:stays`).\n * An item's asked lengths (`DockItem.lengths`) are stored per axis; one entry that isn't a number over 0 (a 0 is no length, so it is not stored), or an axis that\n * isn't `row` or `column`, is dropped (`item:<id>:lengths:<axis>`), a `lengths` that isn't an object too\n * (`item:<id>:lengths`). A store from before has none, and an item then reads with none whatever `base` had: the store\n * is the state's own.\n * A float's size is stored per orient (`floatSizes`); one entry that isn't a size, or an orient that isn't `row` or\n * `column`, is dropped (`item:<id>:floatSizes:<orient>`). A store from before that, with one `floatSize` on an item,\n * reads as `floatSizes` for the orient its float is in (the item's own orient where it floats nowhere), so the size\n * never follows the float to the other orient; a docked item keeps it for its next float-out. On a float whose store\n * declares no `floatSizes` it is dropped (`item:<id>:floatSize`): such a float is framed at its stored rect, which the\n * size would replace.\n */\nimport { EPS, rect, type Size } from \"@n-uf/placement\";\nimport { clampFloat, closeRings, drawnFloatSize, prune, setSide, withFloatSizes } from \"./changes\";\nimport { axisOf, columnFromTemplate, declaresFloatSizes, floatOrientOf, isSince } from \"./helpers\";\nimport { checkEdgeIds, isReservedEdgeId } from \"./targets/ids\";\nimport { FLOAT_ANCHORS, RAIL_MODES, SIDES, type DockEdge, type FloatAnchor, type FloatAnchorAt, type Orient, type RailMode, type DockState, type DockFloat, type DockItem, type Side } from \"./model\";\n\nexport interface StoredDockStateEdge {\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 StoredDockStateFloat {\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 /** An anchor's name, or `{ at, dx?, dy? }`: an anchor with an offset in px. */\n readonly anchor?: FloatAnchorAt;\n /** When it was floated (`DockFloat.since`). */\n readonly since?: number;\n /** The hand left it over content (`DockFloat.stays`). */\n readonly stays?: true;\n}\n\nexport interface StoredDockStateItem {\n readonly used: number;\n readonly kept?: true;\n readonly from?: number;\n readonly closed?: true;\n readonly align?: \"center\" | \"end\";\n /** `DockItem.space`, px. */\n readonly space?: number;\n /** `DockItem.lengths`: the length asked for, per axis. */\n readonly lengths?: { readonly column?: number; readonly row?: number };\n /** `DockItem.floatSizes`: its float size per orient. */\n readonly floatSizes?: { readonly row?: Size; readonly column?: Size };\n /**\n * The old single float size, from a state stored before sizes were kept per orient: `readDockState` reads it as\n * `floatSizes` for the orient its float is in (the item's own where it floats nowhere). `storeDockState` never writes\n * it.\n */\n readonly floatSize?: Size;\n}\n\nexport interface StoredDockState {\n readonly v: 1;\n readonly edges: readonly StoredDockStateEdge[];\n readonly floats: readonly StoredDockStateFloat[];\n readonly items: Readonly<Record<string, StoredDockStateItem>>;\n /** Per side, how its rails show their items (`DockState.railModes`), when the state sets one. */\n readonly railModes?: Readonly<Partial<Record<\"left\" | \"right\", RailMode>>>;\n}\n\nexport interface DockStateRead {\n readonly state: DockState;\n /** What was left out, as listed in the module's docs. */\n readonly dropped: readonly string[];\n /** Set when nothing could be read: `state` is `base`. */\n readonly error?: string;\n}\n\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);\nconst isAnchor = (x: unknown): x is FloatAnchor => FLOAT_ANCHORS.includes(x as FloatAnchor);\n\n/**\n * The float anchor in `v`, as plain data: a name, or `{ at, dx?, dy? }` with its finite offsets; undefined when there is\n * none or it can't be used. `drop` hears what is left out: `\"\"` for the whole anchor (an unknown name, an offset with no\n * valid `at`), `\":dx\"` / `\":dy\"` for an offset that isn't a number, `\":<field>\"` for an unknown field.\n */\nfunction anchorOf(v: unknown, drop?: (what: string) => void): FloatAnchorAt | undefined {\n if (v === undefined) return undefined;\n if (isAnchor(v)) return v;\n if (!isObject(v) || !isAnchor(v.at)) {\n drop?.(\"\");\n return undefined;\n }\n for (const k of Object.keys(v)) if (k !== \"at\" && k !== \"dx\" && k !== \"dy\") drop?.(`:${k}`);\n for (const k of [\"dx\", \"dy\"] as const) if (v[k] !== undefined && !isNum(v[k])) drop?.(`:${k}`);\n return { at: v.at, ...(isNum(v.dx) ? { dx: v.dx } : {}), ...(isNum(v.dy) ? { dy: v.dy } : {}) };\n}\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\n/** The valid rail modes of `v` (left and right only), or null when it has none. */\nfunction railModesOf(v: unknown, drop?: (what: string) => void): Partial<Record<\"left\" | \"right\", RailMode>> | null {\n if (v === undefined) return null;\n if (!isObject(v)) {\n drop?.(\"railModes\");\n return null;\n }\n const out: Partial<Record<\"left\" | \"right\", RailMode>> = {};\n for (const k of Object.keys(v)) {\n const m = v[k];\n if ((k === \"left\" || k === \"right\") && RAIL_MODES.includes(m as RailMode)) out[k] = m as RailMode;\n else drop?.(`railModes:${k}`);\n }\n return Object.keys(out).length > 0 ? out : null;\n}\n\n/** The usable `floatSizes` of `it`, as plain data; undefined when it has none. */\nfunction floatSizesStored(it: DockItem): { row?: Size; column?: Size } | undefined {\n const out: { row?: Size; column?: Size } = {};\n for (const o of [\"row\", \"column\"] as const) {\n const s = it.floatSizes?.[o];\n if (s && isSize(s.width) && isSize(s.height)) out[o] = { width: s.width, height: s.height };\n }\n return out.row || out.column ? out : undefined;\n}\n\n/** The usable `lengths` of `it` (an axis that is a number over 0: a 0 is no length), as plain data; undefined when it has none. */\nfunction lengthStored(it: DockItem): { column?: number; row?: number } | undefined {\n const out: { column?: number; row?: number } = {};\n for (const o of [\"column\", \"row\"] as const) {\n const v = it.lengths?.[o];\n if (isNum(v) && v > EPS) out[o] = v;\n }\n return out.column !== undefined || out.row !== undefined ? out : undefined;\n}\n\nexport function storeDockState(state: DockState): StoredDockState {\n const items = record<StoredDockStateItem>();\n for (const [id, it] of Object.entries(state.items)) {\n if (id === \"__proto__\") continue;\n const sizes = floatSizesStored(it);\n const asked = lengthStored(it);\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 ...(isNum(it.space) && it.space > 0 ? { space: it.space } : {}),\n ...(asked ? { lengths: asked } : {}),\n ...(sizes ? { floatSizes: sizes } : {}),\n };\n }\n const modes = railModesOf(state.railModes);\n return {\n v: 1,\n edges: state.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: state.floats\n .filter((f) => isNum(f.rect.x) && isNum(f.rect.y) && isSize(f.rect.width) && isSize(f.rect.height))\n .map((f) => {\n const anchor = anchorOf(f.anchor);\n return { id: f.id, x: f.rect.x, y: f.rect.y, width: f.rect.width, height: f.rect.height, ...(f.orient ? { orient: f.orient } : {}), ...(anchor ? { anchor } : {}), ...(isSince(f.since) ? { since: f.since } : {}), ...(f.stays === true && !anchor ? { stays: true as const } : {}) };\n }),\n items,\n ...(modes ? { railModes: modes } : {}),\n };\n}\n\nexport function readDockState(data: unknown, base: DockState): DockStateRead {\n checkEdgeIds(base);\n try {\n return read(data, base);\n } catch (e) {\n return { state: base, dropped: [], error: `unreadable: ${e instanceof Error ? e.message : typeof e}` };\n }\n}\n\nconst words = (v: unknown): string => (typeof v === \"number\" ? String(v) : typeof v === \"string\" ? JSON.stringify(v.length > 24 ? `${v.slice(0, 24)}…` : v) : typeof v);\n\n/**\n * The fixed items of `baseIds` that `stored` lacks, put back at their places: leading ones from the start, trailing ones\n * at the end. Fixed items the store has keep the place it gives them, so a stored order round-trips exactly.\n */\nfunction withFixed(baseIds: readonly string[], stored: readonly string[], isFixed: (id: string) => boolean): string[] {\n const out = [...stored];\n const missing = (id: string): boolean => isFixed(id) && !stored.includes(id);\n let tail = baseIds.length;\n while (tail > 0 && isFixed(baseIds[tail - 1]!)) tail--;\n baseIds.forEach((id, i) => {\n if (missing(id) && i < tail) out.splice(Math.min(i, out.length), 0, id);\n });\n return [...out, ...baseIds.slice(tail).filter(missing)];\n}\n\nfunction read(data: unknown, base: DockState): DockStateRead {\n if (!isObject(data)) return { state: base, dropped: [], error: \"not an object\" };\n if (data.v !== 1) return { state: 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\", \"railModes\"].includes(k)) drop(k);\n // The rail modes: the store's per side, over `base`'s.\n const storedModes = railModesOf(data.railModes, drop);\n const railModes = storedModes ? { ...base.railModes, ...storedModes } : base.railModes;\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, DockItem> = { ...base.items };\n // The items whose store has the old single `floatSize`, with it.\n const legacy = new Map<string, Size>();\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, space: _sp, lengths: _len, floatSizes: _ss, ...plain } = b;\n let it: DockItem = { ...plain, used: b.used };\n for (const k of Object.keys(s)) if (![\"used\", \"kept\", \"from\", \"closed\", \"align\", \"space\", \"lengths\", \"floatSize\", \"floatSizes\"].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 // A fixed item keeps `base`'s fold, but on an edge that lets the user fold it (`DockEdge.foldable`).\n const byHand = !b.fixed || base.edges.some((e) => e.foldable === true && e.items.includes(id));\n if (isNum(s.from) && Number.isInteger(s.from) && s.from >= 1 && byHand) it = { ...it, from: s.from };\n else if (s.from !== undefined) drop(`item:${id}:from`);\n if (!byHand && 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 if (isNum(s.space) && s.space > 0 && !b.fixed) it = { ...it, space: s.space };\n else if (s.space !== undefined) drop(`item:${id}:space`);\n if (isObject(s.lengths)) {\n const asked: { column?: number; row?: number } = {};\n for (const k of Object.keys(s.lengths)) {\n const v = s.lengths[k];\n if ((k === \"column\" || k === \"row\") && isNum(v) && v > EPS) asked[k] = v;\n else drop(`item:${id}:lengths:${k}`);\n }\n if (asked.column !== undefined || asked.row !== undefined) it = { ...it, lengths: asked };\n } else if (s.lengths !== undefined) drop(`item:${id}:lengths`);\n const fs = s.floatSize;\n // The old single size moves into `floatSizes` once the floats are read (below): it belongs to the orient its float is\n // in.\n if (isObject(fs) && isSize(fs.width) && isSize(fs.height)) legacy.set(id, { width: fs.width, height: fs.height });\n else if (fs !== undefined) drop(`item:${id}:floatSize`);\n const sizes = s.floatSizes;\n if (isObject(sizes)) {\n const own: { row?: Size; column?: Size } = {};\n for (const k of Object.keys(sizes)) {\n const v = sizes[k];\n if ((k === \"row\" || k === \"column\") && isObject(v) && isSize(v.width) && isSize(v.height)) own[k] = { width: v.width, height: v.height };\n else drop(`item:${id}:floatSizes:${k}`);\n }\n if (own.row || own.column) it = { ...it, floatSizes: own };\n } else if (sizes !== undefined) drop(`item:${id}:floatSizes`);\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: DockEdge[] = [];\n const rings = new Map<string, number>();\n const moves = new Map<string, Side>();\n const anchorMoves = new Map<string, Side>();\n const anchorSizes = new Map<string, number>();\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 // An anchor (a fixed item) listed in an entry other than its own edge's: the entry says where and how big the\n // anchor's edge is (a store that kept the anchor inside a side edge). Its own static edge goes to that side and\n // takes that size; the anchor stays in it. An anchor's edge takes nothing (`accepts: []`); a fixed item of an edge\n // that takes items (a title in its title bar) listed elsewhere is dropped, as before.\n const listed = Array.isArray(e.items) ? (e.items as unknown[]) : [];\n const anchorEdges = base.edges.filter((b) => b.column !== true && b.accepts.length === 0 && b.id !== edge?.id && b.items.some((id) => isFixed(id) && listed.includes(id)));\n for (const b of anchorEdges) {\n const side = SIDES.includes(e.side as Side) ? (e.side as Side) : edge?.side;\n if (side && side !== b.side && axisOf(side) === axisOf(b.side)) anchorMoves.set(b.id, side);\n if (isNum(e.size)) anchorSizes.set(b.id, e.size);\n }\n const describesAnchor = anchorEdges.length > 0;\n if (!edge && describesAnchor) continue;\n // A stored column under a virtual edge's id (`column:<side>`, `rail:<side>`) is dropped, never made.\n if (!edge && e.column === true && (e.side === \"left\" || e.side === \"right\") && base.columns?.[e.side] && !isReservedEdgeId(e.id)) {\n // A column the user made: from its side's template.\n edge = columnFromTemplate(base.columns[e.side]!, e.id, e.side, isNum(e.ring) ? e.ring : Infinity, []);\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 // `hidden` and `showIn` are the host's view state, from `base`: a stored one is ignored.\n if (e.hidden !== undefined) drop(`edge:${edge.id}:hidden`);\n if (e.showIn !== undefined) drop(`edge:${edge.id}:showIn`);\n if (e.side !== undefined && !SIDES.includes(e.side as Side)) drop(`edge:${e.id}:side`);\n else if (!describesAnchor && 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 if (!anchorEdges.some((b) => b.items.includes(id))) 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 // The size of an entry that describes an anchor is the anchor's edge's.\n if (describesAnchor) {\n if (!sizes.has(edge.id)) sizes.set(edge.id, edge.size);\n } else 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 for (const [id, side] of anchorMoves) moves.set(id, side);\n for (const [id, size] of anchorSizes) sizes.set(id, size);\n const floats: DockFloat[] = [];\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\", \"since\", \"stays\"].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 = anchorOf(f.anchor, (what) => drop(`float:${id}:anchor${what}`));\n const since = isSince(f.since) ? f.since : undefined;\n if (f.since !== undefined && since === undefined) drop(`float:${id}:since`);\n const stays = f.stays === true && !a;\n if (f.stays !== undefined && !stays) drop(`float:${id}:stays`);\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 } : {}), ...(since !== undefined ? { since } : {}), ...(stays ? { stays: true as const } : {}) });\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: DockEdge[] = [...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 // A stored old single `floatSize` is the size for the orient its float is in (the item's own where it floats nowhere),\n // unless the store gives that orient a size of its own. On a float whose store declares no `floatSizes` it goes: such\n // a float is framed at its stored rect, which a size would replace. A docked item keeps it for its next float-out.\n for (const [id, size] of legacy) {\n const it = items[id]!;\n const float = floats.find((f) => f.id === id);\n if (float && !declaresFloatSizes(it)) {\n drop(`item:${id}:floatSize`);\n continue;\n }\n const orient = float?.orient ?? floatOrientOf(it);\n if (!it.floatSizes?.[orient]) items[id] = withFloatSizes(it, { orient, size });\n }\n // Empty columns go; the sides' rings close up.\n let state = prune({ ...base, ...(railModes ? { railModes } : {}), items, edges: closeRings(edges, new Set(made.length > 0 || rings.size > 0 ? [\"left\", \"right\"] : [])), floats });\n for (const [id, side] of moves) state = setSide(state, id, side);\n return { state, dropped };\n}\n","/**\n * `targets(state, 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 state\n * a release there commits and its layout, `solve(after.state, { previous })`: the host draws every item from that layout\n * during the preview (C22), so the preview is the result by construction.\n *\n * One model makes every docked target and refusal: **edge → zones → slots → tiles**, then one ordered\n * filter.\n *\n * - **Edges.** Every edge, empty or occupied, and two virtual edges per side: the column lines and the rail.\n * - **Zones.** Each edge's start, center and end zones have an extent along it. Where items keep their length and the\n * zones only align them (bars, compact rails, side toolbar bars) the extents are the edge's thirds; where items fill\n * the edge (panel columns) a zone's extent is the span the solver gives it: a plain column is one zone, a tray column\n * its panels' span and its tray's (`EDGE_KINDS`, the only data keyed on the kind of edge). The outer extents reach\n * `endReach` past the edge's ends.\n * - **The seen geometry.** Every tile is laid in one layout: the committed one, the item in place, as the user sees it\n * (lines, zone extents, ownership, bands). A place counts in the state with the item lifted (a gap's `at`, a column's\n * or rail's `ring`); its `after` is the solved drop. An edge the lift deletes offers nothing: the item's own column\n * collapses into home. A zone where items keep their length reaches over the cards seen in it.\n * - **Slots.** A zone's insertion lines (`gap:<edge>:<zone>:<at>`; on an edge with no members at all a zone has one,\n * `strip:<edge>:<zone>`). The item's own place is an interval, its own rect along the edge (its » entry in the menu):\n * home. The home slot's line lies at both ends of it, so the gaps right beside it are home's (the same move).\n * - **Tiles.** A zone's extent split halfway between its slots' lines (lines that lie past the extent are spread into\n * it); the own interval keeps exactly its length. Panel bodies don't split the tiling: clipping takes them out, and a\n * slot whose tile is all body has no room. Across: the edge's thickness (the larger of seen and after the drop), an\n * empty edge's strip depth (`DockEdge.strip`, default 24, inward), a compact rail's `RAIL_REACH` further inward.\n * - **Filter**, in order: (i) the edge and zone take the kind (`accepts`, `zoneAccepts`), and an empty side column opens\n * only through its start zone; (ii) the drop fits (C29: no » entry, no new overflow or `too-wide`, every fixed item\n * keeps its form, place and least length, a title bar's title its natural width with the toolbar in its first form;\n * the slot covers no chrome or reserved rect). A slot (i) or (ii) removes is a refusal over its own tile, with that\n * reason (`refusals()`). (iii) Space ownership and clipping (`EDGE_KINDS`): owned > virtual > overreach. A zone's\n * room loses its reserved rects and what edges ranked before it own (in `solve`'s laying order); a zone with no room,\n * or a slot with none in reach, isn't offered. Each tile's owned part is cut clear of the tiles before it, of what\n * outranks its edge, of its panel bodies, of every fixed item that doesn't grow and of the chrome; clipping changes a\n * slot's shape, never who owns it, so every piece left is the slot's (`hits`, `hit` the largest); then the virtual\n * edges take what no edge owns; then each overreach takes what is left and joins its owned part where it meets it\n * whole. Refused places own nothing: they take what the surviving tiles and the other edges' seen rects leave. A\n * stretch is owned by what the user sees there; if the owner has no slot there, it refuses. Slots that are the same\n * move are one (home's, where one of them is home). (iv) `blocked` rects are `none:<i>`.\n *\n * Ids: `gap:<edge>:<zone>:<at>` (priority 2), `strip:<edge>:<zone>` (2), `column:<side>:<ring>` (2), `rail:<side>:<ring>`\n * (1), `none:<i>` (1), `float:<id>` (3, free). A slot that would put the item back where it is keeps its id with place\n * `home` (no slot, nothing committed); `home:<id>` (1) is emitted too, over the same tile (its own rect when no slot is\n * its home), for hosts that read it. A floating item has no home: a move inside its own rect is a float move.\n *\n * - `column:<side>:<ring>`: a new column on each column line of a side whose `state.columns[side]` takes the kind\n * (outside the outermost open column, between two, inside the innermost; on a side with none, at the content's\n * edge), up to `COLUMN_REACH` px each way (two lines nearer than that meet halfway), only where the new column shows\n * open (elsewhere refused).\n * - `rail:<side>:<ring>`: docking folded into a side's rail (its rail and its template take the kind), before each\n * folded column's segments and after the last, or, with no rail shown, the outer `RAIL_EDGE` px from the side's\n * outer edge (the window's, an inset's strip included; flush after the side's outside bars), landing where the rail\n * lands (`DockLayout.railPlaces`). A tile of a column folded into the rail, held, also has that column's gaps (`gap:`),\n * to move among its own tiles (over its column's own run of tiles only), and its rail stops are home's, with the rest\n * of the rail. The outermost column line's zone\n * starts where it ends. For a kind with a rail\n * drop policy (`DockState.railDrop`), the side's rail is a drop strip instead, spring-loaded, owning its rect\n * (`./targets/rail-strip`); on a side with no declared rail, its rail is its outermost column that takes the kind,\n * drawn as a rail once the item docks in it folded.\n * - `float:<id>`: when `floatKinds` lists the kind, the whole plane: the landing is the float with the pointer holding\n * it at `grab` (default its middle), in the stage and clear of the docked items, the bars and the chrome while the\n * pointer is still on it there; where no clear place keeps it under the pointer, it lies at the hand over what it\n * covers, marked `stays` (kept inside the stage only, on every later solve). Its orient:\n * `options.floatOrient`, else its float's, else the item's (`floatOrientOf`). Its size: `options.floatSize`, else its\n * float's size where it lands in the orient that float is in, else `floatSizeOf` for the orient it lands in.\n *\n * `stops(state, 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 (`markUsed`). An unknown or closed item has no targets; a fixed item has none either,\n * but on an edge that `moves: \"side\"` (an anchor): `side:<other side>` (2), over the place its edge takes there\n * (`setSide`), and `home:<id>` over its own rect (`./targets/anchor`).\n *\n * The phases live in `./targets/`: `kinds` (`EDGE_KINDS`), `model` (the shapes), `filter` (the drag's context and\n * filter ii), `edges` and `virtual` (generation), `ownership` and `tiles` (filter iii and clipping).\n */\nimport { EPS, PLANE, area, clamp, contains, overlaps, rect, type Rect } from \"@n-uf/placement\";\nimport type { Target } from \"@n-uf/placement\";\nimport { floatAt, markUsed, prune } from \"./changes\";\nimport { axisOf, keepClearFor, floatOrientOf, floatSizeOf, heldRect, inHiddenEdge, namesZone, viewOf, withHiddenOf, zoneOf, zoneTakes } from \"./helpers\";\nimport { EDGE_ROOM_HOLD, type DockEdge, type Orient, type DockState, type DockLayout, type Zone } from \"./model\";\nimport { solve } from \"./solve\";\nimport { anchorTargets } from \"./targets/anchor\";\nimport { edgeSpec } from \"./targets/edges\";\nimport { context } from \"./targets/filter\";\nimport { checkEdgeIds, parseTargetId, targetId } from \"./targets/ids\";\nimport { edgeKindOf, type EdgeKind } from \"./targets/kinds\";\nimport type { Ctx, EdgeSpec, Generated, DropResult, DockRefusal, DockDrop, DockDropOptions, Span, Tile } from \"./targets/model\";\nimport { homeRectOf, ownership } from \"./targets/ownership\";\nimport { clipTiles, tileEdge } from \"./targets/tiles\";\nimport { withRailStrips } from \"./targets/rail-strip\";\nimport { withMinHit } from \"./targets/min-hit\";\nimport { columnLines, ownColumnRun, railStops } from \"./targets/virtual\";\n\nexport { reservedRect, zoneExtents } from \"./targets/edges\";\nexport { parseTargetId, placeTargetId, targetId, virtualEdgeId, type TargetIdParts } from \"./targets/ids\";\nexport { opensEmpty } from \"./targets/kinds\";\nexport type { DropResult, DropPlace, DockRefusal, DockDrop, DockDropOptions } from \"./targets/model\";\n\n/**\n * The edges as the tiler reads them: every real edge, then each side's column lines and rail, only for kinds the side's\n * template opens with (its start zone).\n */\nfunction specsOf(c: Ctx, kind: string): EdgeSpec[] {\n const { state } = c;\n const specs: (EdgeSpec | null)[] = state.edges.map((edge) => edgeSpec(c, edge));\n for (const side of [\"left\", \"right\"] as const) {\n const template = state.columns?.[side];\n if (!template || !zoneTakes(template, \"start\", kind)) continue;\n const rail = state.rails?.[side]?.accepts.includes(kind) ? railStops(c, side) : null;\n // The rail stop keeps its place at the side's boundary only when one of its slots lands (home's counts).\n specs.push(...columnLines(c, side, !!rail?.slots.some((s) => s.ok)));\n specs.push(rail);\n // A tile of the rail held keeps its place among its own column's tiles: that column's run, tiled before the stops.\n if (rail) specs.push(ownColumnRun(c, side, rail));\n }\n return specs.filter((s): s is EdgeSpec => s !== null);\n}\n\n/** The placed tiles as targets and refusals; a zone's refusals numbered by where they lie along the edge. */\nfunction emit(c: Ctx, placed: readonly Tile[]): { targets: DockDrop[]; refused: DockRefusal[]; ownHome: Rect | null } {\n const { state, now, base, dragged } = c;\n const homeId = targetId({ kind: \"home\", item: dragged });\n const targets: DockDrop[] = [];\n const refused: DockRefusal[] = [];\n const homeAfter = (): DropResult => ({ state, layout: now });\n // A zone's refusals are numbered by where they lie along the edge (then across it), not by clipping order, so a\n // refusal keeps its id from one frame to the next. A side's column lines are one edge (one spec per line).\n const pos = (t: Tile): [number, number] => (t.vertical ? [t.hit.y, t.hit.x] : [t.hit.x, t.hit.y]);\n const rank = new Map<Tile, number>();\n const edgeOf = (t: Tile): EdgeSpec | string => (t.spec?.edge ? t.spec : t.edge);\n const byZone = new Map<EdgeSpec | string, Map<Zone, Tile[]>>();\n for (const t of placed) {\n if (t.kind !== \"refuse\") continue;\n const zones = byZone.get(edgeOf(t)) ?? new Map<Zone, Tile[]>();\n byZone.set(edgeOf(t), zones.set(t.zone, [...(zones.get(t.zone) ?? []), t]));\n }\n for (const zones of byZone.values()) for (const group of zones.values()) group.sort((a, b) => pos(a)[0] - pos(b)[0] || pos(a)[1] - pos(b)[1]).forEach((t, n) => rank.set(t, n));\n let ownHome: Rect | null = null;\n for (const t of placed) {\n if (t.kind === \"refuse\") {\n const n = rank.get(t)!;\n refused.push({ id: targetId({ kind: \"refuse\", edge: t.edge, zone: t.zone, n }), edge: t.edge, zone: t.zone, hit: t.hit, ...(t.hits ? { hits: t.hits } : {}), reason: t.reason! });\n continue;\n }\n // Home's own tile when no slot names it: `home:<id>` covers it (below).\n if (t.kind === \"home\" && t.id === homeId) {\n if (t.order === 0) ownHome = t.hit;\n continue;\n }\n // A slot whose tile came in more than one piece (a virtual edge's stretch cut off from its line; the two column\n // lines about the item's own column, one place) is one target: its pieces in `hits`, `hit` the largest.\n const first = targets.findIndex((x) => x.id === t.id);\n if (first >= 0) {\n const was = targets[first]!;\n const pieces = [...(was.hits ?? [was.hit]), ...(t.hits ?? [t.hit])];\n targets[first] = { ...was, hit: pieces.reduce((m, p) => (area(p) > area(m) ? p : m)), hits: pieces };\n continue;\n }\n if (t.kind === \"home\") {\n targets.push({ id: t.id, priority: t.priority, hit: t.hit, ...(t.hits ? { hits: t.hits } : {}), item: dragged, place: { kind: \"home\" }, after: homeAfter });\n continue;\n }\n const result = t.result!;\n // Its slot lies over an item its drop moves: until the room opens the indicator would cover it, so they open together.\n const atEdge = WINDOW_EDGE_KINDS.has(t.edgeKind) && touchesSide(state.stage, t.hits ?? [t.hit]);\n // One that changes an edge's thickness (a side's width, a bar's height) holds in its hit and landing rect (`roomHit`)\n // once its room is open: that is drawn there.\n const thickens = thicknessChanges(now, result.layout);\n const room = t.slot && slotOverMoved(now, base, result.layout, t.slot, dragged, t.edge) ? { opensRoom: true as const, ...(atEdge ? { roomHold: EDGE_ROOM_HOLD } : {}), ...(thickens ? { roomHit: hull(t.hit, t.slot) } : {}) } : {};\n targets.push({ id: t.id, priority: t.priority, hit: t.hit, ...(t.hits ? { hits: t.hits } : {}), ...(t.slot ? { slot: t.slot } : {}), ...(t.marker ? { marker: t.marker } : {}), ...room, item: dragged, place: t.place!, after: () => result });\n }\n return { targets, refused, ownHome };\n}\n\n/** The smallest rect holding both: a hit and its landing rect, with no gap between them where they don't overlap. */\nfunction hull(a: Rect, b: Rect): Rect {\n const x = Math.min(a.x, b.x);\n const y = Math.min(a.y, b.y);\n return rect(x, y, Math.max(a.x + a.width, b.x + b.width) - x, Math.max(a.y + a.height, b.y + b.height) - y);\n}\n\n/**\n * Whether a drop changes an edge's thickness around the content (a side's width, a bar's height): any edge of the\n * content moves.\n */\nconst thicknessChanges = (now: DockLayout, after: DockLayout): boolean => {\n const a = now.content;\n const b = after.content;\n return Math.abs(b.x - a.x) > EPS || Math.abs(b.y - a.y) > EPS || Math.abs(b.x + b.width - (a.x + a.width)) > EPS || Math.abs(b.y + b.height - (a.y + a.height)) > EPS;\n};\n\n/** The edge kinds that run along a side (rails, new-column lines): against the window's edge, their room waits less (`roomHold`). */\nconst WINDOW_EDGE_KINDS: ReadonlySet<EdgeKind> = new Set<EdgeKind>([\"rail\", \"railStop\", \"sideBar\", \"columnLine\"]);\n\n/** Whether any of `pieces` reaches the stage's left or right edge. */\nconst touchesSide = (stage: Rect, pieces: readonly Rect[]): boolean => pieces.some((r) => r.x <= stage.x + EPS || r.x + r.width >= stage.x + stage.width - EPS);\n\n/**\n * Whether `slot` lies over a docked item that a drop on edge `onto` moves: not `dragged`, nor an item of `onto` (they make\n * its gap). An item of the edge `dragged` leaves is measured from `lifted`, the layout with it gone: closing up over its\n * place is no move, being pushed by the drop is. The overlap is tested first: the layouts are at hand, and most items\n * lie clear of the slot.\n */\nfunction slotOverMoved(now: DockLayout, lifted: DockLayout, after: DockLayout, slot: Rect, dragged: string, onto: string): boolean {\n const from = now.items[dragged]?.edge;\n return Object.entries(now.items).some(([id, was]) => {\n if (!overlaps(slot, was.rect) || id === dragged || was.floating || was.edge === onto) return false;\n const r = after.items[id]?.rect;\n const start = (from !== undefined && was.edge === from ? lifted.items[id]?.rect : undefined) ?? was.rect;\n return !!r && (Math.abs(r.x - start.x) > EPS || Math.abs(r.y - start.y) > EPS || Math.abs(r.width - start.width) > EPS || Math.abs(r.height - start.height) > EPS);\n });\n}\n\n/** The stretches along an edge its slot tiles cover (home's and refusals' aside), merged where they meet. */\nfunction alongOfSlots(s: EdgeSpec, tiles: readonly Tile[]): Span[] {\n const spans = tiles\n .filter((t) => t.kind === \"slot\")\n .map((t): Span => (s.vertical ? [t.hit.y, t.hit.y + t.hit.height] : [t.hit.x, t.hit.x + t.hit.width]))\n .sort((a, b) => a[0] - b[0]);\n const out: [number, number][] = [];\n for (const [a, b] of spans) {\n const last = out[out.length - 1];\n if (last && a <= last[1] + 1e-6) last[1] = Math.max(last[1], b);\n else out.push([a, b]);\n }\n return out;\n}\n\n/**\n * The targets of the state the window shows: its hidden edges (`DockEdge.hidden`) left out, so they have no targets or\n * refusals and their items none either. A new column's id is chosen against the hidden edges too (`moveAmong`). Each\n * target's result keeps the hidden edges as they were; a target that commits nothing (home, `none`) gives back `state`\n * itself. Where a result renumbered a side's rings around them (a column made or removed beside a hidden one), its\n * layout is solved again, so it is still the result.\n *\n * Items a hidden edge lends (`DockEdge.showIn`) are dragged as items of the edge they show in. A drop that commits a move of\n * one takes it out of its hidden edge, to the drop's place; every other result gives the lent items back to their\n * hidden edges (and its layout is solved again, where they lent themselves to the result's edges in another order).\n *\n * The targets are made on the state as laid out, each item in the zone it lies in (`zoneIn`). Every result gives each\n * item its own zone back, the dragged one too unless the drop named a zone (a gap), and is solved again.\n */\nfunction generate(state: DockState, dragged: string, options: DockDropOptions): Generated {\n checkEdgeIds(state);\n const { view: shown, lent, rezoned } = viewOf(state);\n if (shown === state) return generateShown(state, dragged, options, []);\n if (inHiddenEdge(state, dragged) && !lent.has(dragged)) return { targets: [], refusals: [], lost: [] };\n const hidden = state.edges.filter((e) => e.hidden === true);\n const g = generateShown(shown, dragged, options, hidden);\n const prev = { ...(options.previous ? { previous: options.previous } : {}), ...(options.fresh ? { fresh: options.fresh } : {}) };\n // With a `showIn`, each result is solved itself: its lent items given back, the edge they showed in maybe gone with\n // the drop, and `solve`'s notes on a `showIn` it ignores.\n const showsIn = hidden.some((e) => e.showIn !== undefined);\n return {\n ...g,\n targets: g.targets.map((t) => ({\n ...t,\n after: (point, grab) => {\n const a = t.after(point, grab);\n // Nothing committed: the state as it was, the same object.\n if (a.state === shown) return { state, layout: showsIn ? solve(state, prev) : a.layout };\n // Only a drop that names a zone (a gap in a zone of an edge offering a choice, `namesZone`) sets the item's zone;\n // every other move keeps its own.\n const on = t.place.kind === \"gap\" ? shown.edges.find((e) => t.place.kind === \"gap\" && e.id === t.place.edge) : undefined;\n const named = !!on && namesZone(on, state.items[dragged]!.kind);\n const back = withHiddenOf(state, a.state, lent, dragged, named, rezoned);\n // A safety net for the stored state: a dynamic column left empty (a hidden one whose last item a drop moved out)\n // goes, as in any change, its side's rings closed up. Lent items never sit in a dynamic column (`viewOf`).\n const restored = showsIn ? prune(back) : back;\n const ringOf = new Map(a.state.edges.map((e) => [e.id, e.ring]));\n const renumbered = restored.edges.some((e) => e.hidden !== true && ringOf.get(e.id) !== e.ring);\n // Where items lie in zones not their own, the result lays them out again from their own zones.\n const layout = renumbered || showsIn || rezoned.size > 0 ? solve(restored, prev) : a.layout;\n return { state: restored, layout };\n },\n })),\n };\n}\n\nfunction generateShown(state: DockState, dragged: string, options: DockDropOptions, hidden: readonly DockEdge[]): Generated {\n // A fixed item takes no gap: on an edge that `moves: \"side\"` it has its `side:` target and home.\n if (Object.hasOwn(state.items, dragged) && state.items[dragged]!.fixed) return anchorTargets(state, dragged, options);\n const ctx = context(state, dragged, options, hidden);\n if (!ctx) return { targets: [], refusals: [], lost: [] };\n const { c, item, prev } = ctx;\n const { now } = c;\n const live = specsOf(c, item.kind);\n // Ownership is ranked among what survives the filter: each edge tiled on its own first, an edge owning its band only\n // along its surviving slots' tiles (a refused stretch owns nothing).\n const alone = new Map(live.map((s) => [s, tileEdge(c, s, { cuts: [], bodies: [] }, [])]));\n const along = new Map(live.map((s) => [s, alongOfSlots(s, alone.get(s)!)]));\n const own = ownership(c, live, (s) => along.get(s)!);\n const lost: string[] = [];\n const tiles: Tile[] = live.flatMap((spec) => tileEdge(c, spec, own.cutsOf(spec), lost));\n // The item's own place is home's even where no edge tiles it: its » entry, or its column, which the lift deletes\n // (the whole column collapses into home).\n const ownRect = now.items[dragged];\n const homeEdge = state.edges.find((e) => e.id === ownRect?.edge);\n const homeHit = homeRectOf(c, null);\n if (ownRect && homeEdge && homeHit && !tiles.some((t) => t.order === 0))\n tiles.push({ edge: homeEdge.id, spec: null, edgeKind: edgeKindOf(state, homeEdge), vertical: axisOf(homeEdge.side) === \"column\", zone: zoneOf(item), order: 0, kind: \"home\", id: targetId({ kind: \"home\", item: dragged }), priority: 1, place: { kind: \"home\" }, hit: homeHit, keep: null });\n const placed = clipTiles(tiles, own, keepClearFor(state, \"targets\"), lost);\n const { targets, refused, ownHome } = emit(c, placed);\n const homeAfter = (): DropResult => ({ state, layout: now });\n\n if (state.floatKinds.includes(item.kind)) {\n const was = state.floats.find((f) => f.id === dragged);\n const fo: Orient = options.floatOrient ?? was?.orient ?? floatOrientOf(item);\n // Its size: the one given, else its float's where it lands in the orient it floats in, else the size for the orient it lands in.\n const wasOrient = was?.orient ?? floatOrientOf(item);\n const size = options.floatSize ?? (was && wasOrient === fo ? { width: was.rect.width, height: was.rect.height } : floatSizeOf(item, fo));\n targets.push({\n id: targetId({ kind: \"float\", item: dragged }),\n priority: 3,\n free: true,\n hit: PLANE,\n // Over the whole plane, but only strictly inside the stage: its edge belongs to the targets drawn against it.\n bounds: stageOf(state),\n item: dragged,\n place: { kind: \"float\" },\n after(point, grab) {\n const g = grab ?? { x: size.width / 2, y: size.height / 2 };\n // Where the pointer puts it, or with `floatFromHeld` where the held item is drawn, before the float is fitted.\n const raw = options.floatFromHeld ? heldRect(state, dragged, size, point, g) : rect(point.x - g.x, point.y - g.y, size.width, size.height);\n const first = solve(markUsed(floatAt(state, dragged, raw, options.floatOrient), dragged), prev);\n const fitted = first.items[dragged]?.rect;\n const at = fitted ?? raw;\n const placed = (x: number, y: number, stays: boolean): DropResult => {\n const s = floatAt(state, dragged, rect(x, y, size.width, size.height), options.floatOrient);\n return c.settle(markUsed(stays ? { ...s, floats: s.floats.map((f) => (f.id === dragged ? { ...f, stays: true as const } : f)) } : s, dragged));\n };\n // \"Doesn't fit\" is decided by the hand: a clear place counts only while the pointer is on the item placed there\n // (on the hand rect as kept inside the stage, so the stage's clamp never counts against it).\n const hand = heldRect(state, dragged, fitted ?? size, point, g);\n const on = { x: clamp(point.x, hand.x, hand.x + hand.width), y: clamp(point.y, hand.y, hand.y + hand.height) };\n const clear = !first.notes.some((n) => n.code === \"float-covers\" && n.id === dragged);\n if (!fitted || (clear && contains(fitted, on))) return placed(at.x, at.y, false);\n // Otherwise it lies at the hand, over what it covers, marked so that no later solve moves it clear.\n const left = placed(hand.x, hand.y, true);\n // (Kept clear of the bars and the chrome there, it may cover nothing: then it is an ordinary float at that rect.)\n const covers = left.layout.notes.some((n) => n.code === \"float-covers\" && n.id === dragged);\n const kept = left.layout.items[dragged]?.rect ?? hand;\n return covers ? left : placed(kept.x, kept.y, false);\n },\n });\n }\n\n // Filter (iv): `blocked` rects take the pointer and commit nothing.\n (state.blocked ?? []).forEach((b, i) => {\n targets.push({ id: targetId({ kind: \"none\", index: i }), priority: 1, hit: rect(b.x, b.y, b.width, b.height), item: dragged, place: { kind: \"none\" }, after: homeAfter });\n });\n\n // `home:<id>`, for hosts that read it: over the item's own rect, inside home's tile (all of it when no slot names it).\n // A new column holding the item alone where its own column is (a column line beside it, as the lift counts rings) is\n // the same move as home: its pieces are home's, under home's id, never a target of their own (a sliver beside home).\n const sameAsHome = targets.filter((t) => t.place.kind === \"home\" && parseTargetId(t.id)?.kind === \"column\");\n const homePieces = sameAsHome.flatMap((t) => t.hits ?? [t.hit]);\n if (sameAsHome.length) targets.splice(0, targets.length, ...targets.filter((t) => !sameAsHome.includes(t)));\n // They join home's slot where one is home (a gap of its edge), else `home:<id>`.\n const homeSlot = targets.findIndex((t) => t.place.kind === \"home\");\n if (homeSlot >= 0 && homePieces.length) {\n const t = targets[homeSlot]!;\n targets[homeSlot] = { ...t, hits: [...(t.hits ?? [t.hit]), ...homePieces] };\n }\n if (ownRect && !ownRect.floating) {\n const hit = ownHome ?? ownRect.rect;\n const pieces = homeSlot < 0 && homePieces.length ? { hits: [hit, ...homePieces] } : {};\n targets.push({ id: targetId({ kind: \"home\", item: dragged }), priority: 1, hit, ...pieces, item: dragged, place: { kind: \"home\" }, after: homeAfter });\n }\n // A slot is lost only where no target carries its id (two lines of one move, about the item's own column, are one).\n const lostIds = [...new Set(lost)].filter((id) => !targets.some((t) => t.id === id));\n // The kind's rail drop strips (`DockState.railDrop`), laid over the rest: each owns its rect.\n const layered = withRailStrips(c, targets, refused);\n // Every target keeps a reachable minimum where the space beside it can be spared (`EDGE_KINDS[kind].minHit`).\n // A target's zone: its tiles with its edge tiled on its own (before any other edge owns a part), its overreach\n // included. It grows to its minimum only inside that.\n const zones = new Map<string, Rect[]>();\n for (const t of [...alone.values()].flat()) if (t.kind !== \"refuse\" && t.id) zones.set(t.id, [...(zones.get(t.id) ?? []), t.hit]);\n // A refusal holds only points strictly inside the stage: its edge belongs to the targets drawn against it.\n const bounds = stageOf(state);\n // A room's hold (`roomHit`) holds the target's hit as it ends up, its minimum included.\n const held = withMinHit(c, layered.targets, layered.refusals, zones).map((t) => (t.roomHit && t.slot ? { ...t, roomHit: hull(t.hit, t.slot) } : t));\n return { targets: held, refusals: layered.refusals.map((r) => ({ ...r, bounds })), lost: lostIds, zones };\n}\n\n/** The stage as a plain rect (a target's or a refusal's `bounds`). */\nconst stageOf = (state: DockState): Rect => rect(state.stage.x, state.stage.y, state.stage.width, state.stage.height);\n\nexport function targets(state: DockState, dragged: string, options: DockDropOptions = {}): DockDrop[] {\n return generate(state, dragged, options).targets;\n}\n\n/** The targets and refusals of one generation (`lanes()` reads both; internal to the package). */\nexport function targetsAndRefusals(state: DockState, dragged: string, options: DockDropOptions = {}): { targets: DockDrop[]; refusals: DockRefusal[] } {\n const g = generate(state, dragged, options);\n return { targets: g.targets, refusals: g.refusals };\n}\n\n/**\n * `refusals(state, dragged, options?)`: the places a drop of `dragged` is refused, so a host can say so at the pointer\n * (\"Can't go here\"; the place itself is never drawn) instead of showing a slot elsewhere: each slot the filter removed, over its own tile,\n * `not-accepted` where the edge or zone doesn't take the kind, `no-room` where the drop wouldn't fit along the edge, `too-thick` where no form of the item fits across it (the bar is thinner than every form but the » menu's). An edge that takes\n * the kind in no zone is one refusal over its drawn rect (fixed items included) less what targets own; every refusal\n * lies in the stage, a zone's inside its edge's ends. A release over a refusal commits nothing: the item goes home.\n */\nexport function refusals(state: DockState, dragged: string, options: DockDropOptions = {}): DockRefusal[] {\n return generate(state, dragged, options).refusals;\n}\n\n/**\n * A refusal in the pick's shape: `refuse: true`, which ranks it at `REFUSAL_RANK` (after every target of priority 1 and\n * 2, so a target wins wherever the two meet or overlap, before the float). Its `priority` is 2 for a pick rule that\n * doesn't know refusals.\n */\nexport interface DockRefusalTarget extends Target {\n readonly refuse: true;\n readonly refusal: DockRefusal;\n}\n\n/**\n * `refusalTargets(refusals)`: each refusal as a target for `@n-uf/motion/drag`'s drag intent (`refuse: true`, its\n * pieces as `hits`). Pass them with the targets: the intent never holds or shows one, a release over one lands nowhere,\n * and the frame's `refused` says which the pointer is over (`refused.refusal` is the `DockRefusal`).\n */\nexport function refusalTargets(list: readonly DockRefusal[]): DockRefusalTarget[] {\n return list.map((r) => ({ id: r.id, priority: 2, hit: r.hit, ...(r.hits ? { hits: r.hits } : {}), ...(r.bounds ? { bounds: r.bounds } : {}), refuse: true, refusal: r }));\n}\n\n/**\n * `targetZones(state, dragged, options?)`: each docked target's zone by id, the space it may grow to its minimum hit in\n * (its tiles with its edge tiled on its own). For the property check.\n */\nexport function targetZones(state: DockState, dragged: string, options: DockDropOptions = {}): ReadonlyMap<string, readonly Rect[]> {\n return generate(state, dragged, options).zones ?? new Map();\n}\n\n/**\n * `lostSlots(state, dragged, options?)`: the ids of slots the filter kept, with room in their zone, that clipping left\n * with no hit. None: the property check holds it at zero.\n */\nexport function lostSlots(state: DockState, dragged: string, options: DockDropOptions = {}): string[] {\n return generate(state, dragged, options).lost;\n}\n\nconst SIDE_RANK: Record<string, number> = { left: 0, top: 1, bottom: 2, right: 3 };\n\n/**\n * `stops(state, 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 *\n * Remembered per state: a state is an immutable value (every change returns a new one), so the stops of one item of one\n * state with the same options are solved once, and asking again (a menu redrawn, every group's list on each render) costs\n * nothing until the state is another object. The options count by value, `previous` by identity. The list is yours: a\n * new array each call, over the same targets.\n */\nexport function stops(state: DockState, dragged: string, options: DockDropOptions = {}): DockDrop[] {\n const key = stopsKey(dragged, options);\n let memo = stopsMemo.get(state);\n if (!memo) stopsMemo.set(state, (memo = new Map()));\n let list = memo.get(key);\n if (!list) {\n // A state asked about with many different options never holds more than this many lists.\n if (memo.size >= STOPS_PER_STATE) memo.clear();\n memo.set(key, (list = orderedStops(state, dragged, options)));\n }\n return [...list];\n}\n\n/** What `stops` has solved, by state object, then by item and options. */\nconst stopsMemo = new WeakMap<DockState, Map<string, readonly DockDrop[]>>();\nconst STOPS_PER_STATE = 512;\nconst layoutIds = new WeakMap<DockLayout, number>();\nlet nextLayoutId = 0;\n\n/** The item and options as one string: the options by value, `previous` by the identity of its layout. */\nfunction stopsKey(dragged: string, o: DockDropOptions): string {\n let prev: number | null = null;\n if (o.previous) {\n prev = layoutIds.get(o.previous) ?? nextLayoutId++;\n layoutIds.set(o.previous, prev);\n }\n return JSON.stringify([dragged, prev, o.endReach ?? null, o.floatOrient ?? null, o.floatSize ? [o.floatSize.width, o.floatSize.height] : null, o.fresh ?? null]);\n}\n\nfunction orderedStops(state: DockState, dragged: string, options: DockDropOptions): DockDrop[] {\n const list = targets(state, dragged, options).filter((t) => t.place.kind !== \"home\" && t.place.kind !== \"none\");\n const sideOf = (t: DockDrop): string => {\n const p = t.place;\n if (p.kind === \"float\") return \"float\";\n if (p.kind === \"column\" || p.kind === \"rail\" || p.kind === \"side\") return p.side;\n if (p.kind === \"gap\") return state.edges.find((e) => e.id === p.edge)?.side ?? \"float\";\n return \"float\";\n };\n const key = (t: DockDrop): [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 * A fixed item's targets. A fixed item never takes a gap; on an edge that `moves: \"side\"` (an anchor: page thumbnails)\n * it has one target, `side:<other side>`, over the place its edge takes on the other side of its axis, and its own\n * place is home.\n */\nimport { EPS, area, rect, subtract, type Rect } from \"@n-uf/placement\";\nimport { markUsed, setSide } from \"../changes\";\nimport { keepClearFor } from \"../helpers\";\nimport type { DockState, Side } from \"../model\";\nimport { solve } from \"../solve\";\nimport { targetId } from \"./ids\";\nimport type { Generated, DropResult, DockDrop, DockDropOptions } from \"./model\";\n\nconst OTHER: Record<Side, Side> = { left: \"right\", right: \"left\", top: \"bottom\", bottom: \"top\" };\n\n/**\n * The anchor's targets. The `side:` target's hit is where its edge lies once moved (`setSide`, then `markUsed`, solved): on\n * the other side the edge is the outermost, so it owns that place over the side's columns (the bars laid before the\n * sides already bound it), clear of the chrome. Its `after` is that drop, so the preview is the landing.\n */\nexport function anchorTargets(state: DockState, dragged: string, options: DockDropOptions): Generated {\n const none: Generated = { targets: [], refusals: [], lost: [] };\n const prev = { ...(options.previous ? { previous: options.previous } : {}), ...(options.fresh ? { fresh: options.fresh } : {}) };\n const now = solve(state, prev);\n const me = now.items[dragged];\n const edge = me?.edge ? state.edges.find((e) => e.id === me.edge) : undefined;\n if (!me || !edge || edge.moves !== \"side\" || me.floating) return none;\n const homeAfter = (): DropResult => ({ state, layout: now });\n const targets: DockDrop[] = [];\n const side = OTHER[edge.side];\n const moved = markUsed(setSide(state, edge.id, side), dragged);\n const layout = solve(moved, prev);\n const placed = layout.edges[edge.id]?.rect;\n const slot = layout.items[dragged]?.rect;\n if (placed && slot && area(placed) > EPS) {\n const pieces = keepClearFor(state, \"targets\").reduce<Rect[]>((ps, c) => ps.flatMap((p) => subtract(p, rect(c.x, c.y, c.width, c.height))), [placed]).filter((p) => p.width >= 1 && p.height >= 1);\n if (pieces.length > 0) {\n const hit = pieces.reduce((a, p) => (area(p) > area(a) ? p : a));\n const result: DropResult = { state: moved, layout };\n targets.push({ id: targetId({ kind: \"side\", side }), priority: 2, hit, ...(pieces.length > 1 ? { hits: pieces } : {}), slot, item: dragged, place: { kind: \"side\", edge: edge.id, side }, after: () => result });\n }\n }\n targets.push({ id: targetId({ kind: \"home\", item: dragged }), priority: 1, hit: me.rect, item: dragged, place: { kind: \"home\" }, after: homeAfter });\n return { targets, refusals: [], lost: [] };\n}\n","/**\n * Generation, the real edges: each edge's zones and their extents, its slots (insertion lines, each with the drop it\n * makes, settled), its reserved stretches and its band across, as the tiler reads them (`EdgeSpec`).\n */\nimport { EPS, area, rect, type Rect } from \"@n-uf/placement\";\nimport { formCrossMin, formMenu, formSetsCross, itemSteps, type StackForm } from \"@n-uf/placement/stack\";\nimport { markUsed, moveAmong, moveTo } from \"../changes\";\nimport { axisOf, edgeTakes, formsOf, zoneOf, zonesOf, zoneTakes } from \"../helpers\";\nimport { DEFAULT_STRIP, ZONES, type DockEdge, type DockState, type DockLayout, type Zone } from \"../model\";\nimport { solve } from \"../solve\";\nimport { targetId } from \"./ids\";\nimport { EDGE_KINDS, edgeKindOf, opensEmpty, type EdgeKind } from \"./kinds\";\nimport type { Ctx, EdgeSpec, DropResult, DockDropOptions, Slot, Span } from \"./model\";\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, centered in the center 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(state: DockState, l: DockLayout, id: string): Rect {\n const it = l.items[id]!;\n const e = it.edge ? l.edges[it.edge] : undefined;\n const f = e ? formsOf(state.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/** A slot for `place` on `line`: its drop, settled; home when it puts the item back (or `home`); `lands`, its edge's rule. */\nexport function slotAt(c: Ctx, zone: Zone, line: number, id: string, place: Slot[\"place\"], lands: (r: DropResult) => boolean, home = false): Slot {\n const result = c.settle(markUsed(moveAmong(c.state, c.dragged, place, c.others), c.dragged));\n const isHome = home || c.isHome(result);\n return { zone, line, id, place, result, home: isHome, ok: isHome || (!!result.layout.items[c.dragged] && lands(result) && c.sound(result.layout)) };\n}\n\n/**\n * Slots that are the same move are one slot: one line and one landing, or both home (both put the item back, wherever\n * their lines lie). Home keeps it where one of them is home (beside a closed member the item lands where it is); else\n * the first (the lowest `at`).\n */\nexport function distinctSlots(c: Ctx, slots: readonly Slot[]): Slot[] {\n const landing = (s: Slot): Rect | undefined => s.result.layout.items[c.dragged]?.rect;\n const sameMove = (a: Slot, b: Slot): boolean => {\n if (a.zone !== b.zone) return false;\n if (a.home && b.home) return true;\n const [p, q] = [landing(a), landing(b)];\n // Two rail stops that land the same (a rider bar at the top, whichever tile's line it was taken from) are one move,\n // wherever their lines lie; other slots are the same move only on one line.\n const sameLine = (a.place.kind === \"rail\" && b.place.kind === \"rail\") || Math.abs(a.line - b.line) < EPS;\n return sameLine && (!p || !q ? p === q : Math.abs(p.x - q.x) + Math.abs(p.y - q.y) + Math.abs(p.width - q.width) + Math.abs(p.height - q.height) < 0.01);\n };\n const wins = (o: Slot, j: number, s: Slot, i: number): boolean => (o.home !== s.home ? o.home : j < i);\n return slots.filter((s, i) => !slots.some((o, j) => j !== i && sameMove(o, s) && wins(o, j, s, i)));\n}\n\n/**\n * The zones of `edge` with their extents along it, for a drag of `kind` (`EDGE_KINDS[...].zoneExtent`). `probe(zone)`:\n * the span an empty zone takes once it holds the item (a `solved` edge's empty zone), or null (then a point at the\n * zone's anchor). The outer extents reach `reach` past the edge's ends. `seen`: the layout as the user sees it.\n *\n * Thirds hold the cards seen in them: a zone's extent reaches over every card of its zone (a fixed item's reserved\n * rect, a title's text), its neighbor's starting past it, so a point over a card is that card's zone.\n */\nfunction zoneSpans(state: DockState, seen: DockLayout, edge: DockEdge, reach: number, probe: (z: Zone) => Span | null): { zone: Zone; a: number; b: number }[] {\n const el = seen.edges[edge.id]!;\n const column = axisOf(edge.side) === \"column\";\n const main0 = column ? el.rect.y : el.rect.x;\n const length = column ? el.rect.height : el.rect.width;\n const thirds = EDGE_KINDS[edgeKindOf(state, edge)].zoneExtent === \"thirds\";\n const at = (r: Rect): Span => (column ? [r.y, r.y + r.height] : [r.x, r.x + r.width]);\n const declared = new Set<Zone>(edge.zoneAccepts ? ZONES.filter((z) => edge.zoneAccepts![z] !== undefined) : [\"start\"]);\n // Each zone's seen cards, end to end.\n const placed = new Map<Zone, Span>();\n for (const [id, it] of Object.entries(seen.items)) {\n if (it.edge !== edge.id || it.inMenu) continue;\n // The zone it is laid out in (`zoneIn`: its own wherever the edge takes it there).\n const z = it.zone ?? zoneOf(state.items[id]);\n const [a, b] = at(thirds && it.fixed ? reservedRect(state, seen, id) : it.rect);\n const was = placed.get(z);\n placed.set(z, was ? [Math.min(was[0], a), Math.max(was[1], b)] : [a, b]);\n declared.add(z);\n }\n const lo = (z: Zone): number => placed.get(z)?.[0] ?? Infinity;\n const hi = (z: Zone): number => placed.get(z)?.[1] ?? -Infinity;\n if (edge.zones !== undefined) {\n // An edge with only some zones (`DockEdge.zones`): its length split between them alone, evenly, each boundary moved past\n // the cards seen on either side of it, as the thirds are. One zone: the whole length, ordered by position along it.\n const has = zonesOf(edge);\n let prev = main0 - reach;\n return has.map((zone, i) => {\n const last = i === has.length - 1;\n const mark = main0 + (length * (i + 1)) / has.length;\n const b = last ? main0 + length + reach : Math.max(prev, Math.min(Math.max(mark, ...has.slice(0, i + 1).map(hi)), ...has.slice(i + 1).map(lo)));\n const span = { zone, a: prev, b };\n prev = b;\n return span;\n });\n }\n if (thirds) {\n // `barZones: \"nearest\"`: each boundary halfway between the landing rects either side of it (a zone's landing beside\n // the boundary: past its last card, else where its first drop lands), so the pointer is in the zone whose landing is\n // nearest. Else at a third of the length.\n const nearest = state.barZones === \"nearest\";\n const landing = (z: Zone, side: \"before\" | \"after\"): Span | null => (placed.has(z) ? (side === \"after\" ? [hi(z), hi(z)] : [lo(z), lo(z)]) : probe(z));\n const between = (l: Zone, r: Zone, fallback: number): number => {\n const a = landing(l, \"after\");\n const b = landing(r, \"before\");\n return nearest && a && b ? (a[1] + b[0]) / 2 : fallback;\n };\n const b1 = Math.min(Math.max(between(\"start\", \"center\", main0 + length / 3), hi(\"start\")), lo(\"center\"), lo(\"end\"));\n const b2 = Math.max(Math.min(between(\"center\", \"end\", main0 + (2 * length) / 3), lo(\"end\")), hi(\"center\"), hi(\"start\"), b1);\n return [\n { zone: \"start\", a: main0 - reach, b: b1 },\n { zone: \"center\", a: b1, b: b2 },\n { zone: \"end\", a: b2, b: main0 + length + reach },\n ];\n }\n // Where items fill the edge: the zones it declares (or its one zone), each where the solver puts its items.\n const anchor: Record<Zone, number> = { start: main0, center: main0 + length / 2, end: main0 + length };\n const spans = ZONES.filter((z) => declared.has(z)).map((zone) => ({ zone, s: placed.get(zone) ?? probe(zone) ?? ([anchor[zone], anchor[zone]] as Span) }));\n return spans.map(({ zone, s }, i) => ({\n zone,\n a: i === 0 ? main0 - reach : (spans[i - 1]!.s[1] + s[0]) / 2,\n b: i === spans.length - 1 ? main0 + length + reach : (s[1] + spans[i + 1]!.s[0]) / 2,\n }));\n}\n\n/**\n * `zoneExtents(state, dragged, edgeId, options?)`: the zones of an edge and their extents along it, as the targets of a\n * drag of `dragged` tile them (the edge's rect as the user sees it, the item in place). For a test or a host that\n * shows the zones.\n */\nexport function zoneExtents(state: DockState, dragged: string, edgeId: string, options: DockDropOptions = {}): { zone: Zone; a: number; b: number }[] {\n const prev = { ...(options.previous ? { previous: options.previous } : {}), ...(options.fresh ? { fresh: options.fresh } : {}) };\n const seen = solve(state, prev);\n const edge = state.edges.find((e) => e.id === edgeId);\n if (!edge || !seen.edges[edgeId]) return [];\n const column = axisOf(edge.side) === \"column\";\n const reach = Math.max(0, Number.isFinite(options.endReach) ? options.endReach! : 0);\n return zoneSpans(state, seen, edge, reach, (zone) => {\n if (!zoneTakes(edge, zone, state.items[dragged]?.kind ?? \"\")) return null;\n const l = solve(markUsed(moveTo(state, dragged, { kind: \"gap\", edge: edgeId, zone, at: 0 }), dragged), prev);\n const me = l.items[dragged];\n return me && me.edge === edgeId && me.zone === zone ? (column ? [me.rect.y, me.rect.y + me.rect.height] : [me.rect.x, me.rect.x + me.rect.width]) : null;\n });\n}\n\n/**\n * An edge's slots: each zone's insertion lines, in the seen geometry (the item in place; its own place is an interval,\n * home's). A slot counts its place among the edge's members with the item lifted (`at`); its drop is solved. What an\n * item takes of the edge for its lines: its rect, or a growing fixed item's natural rect (a title's text), so the\n * length it grew by is free room. A place that would move a protected fixed item of the edge is no slot. Protected: a\n * fixed item in the slot's zone's anchored fixed run (the fixed members contiguous from the zone's anchor with no\n * movable member between: the start zone's from its first member, the end zone's from its last), any fixed item of the\n * center zone, and any fixed item of another zone. A fixed item behind a movable one in the slot's own zone is placed\n * by that movable's size, so a drop there may push it. A fixed item that declares `pushable` is not protected in the\n * anchored run: a drop after it may push it inward, so the gap at the end of a run of them is a slot (the place a toolbar\n * homed after them is put back in); no gap between two of them is (they keep their order).\n */\nfunction edgeSlots(c: Ctx, edge: DockEdge, accepts: boolean): Slot[] {\n const { state, rest, now, base, dragged, kind } = c;\n const el = now.edges[edge.id]!;\n const column = axisOf(edge.side) === \"column\";\n const at = (r: Rect): number => (column ? r.y : r.x);\n const len = (r: Rect): number => (column ? r.height : r.width);\n const main0 = at(el.rect);\n const length = len(el.rect);\n // The edge's members with the item lifted, the places a gap counts.\n const members0 = rest.edges.find((e) => e.id === edge.id)?.items ?? [];\n // `strip:<edge>:<zone>` names a slot only on an edge with no members at all (a zone there has one slot); every other\n // slot, beside closed members or the item's own place too, is named by its gap, so no two slots share an id.\n const slotId = (zone: Zone, k: number): string => targetId(members0.length === 0 ? { kind: \"strip\", edge: edge.id, zone } : { kind: \"gap\", edge: edge.id, zone, at: k });\n // Where a drop lands on this edge: in it, shown (no » entry). A growing fixed item beside it (a title) takes its natural\n // length of the target room, not its grown length (filter (ii), `soundness`): nothing else is asked of a title bar.\n const lands = ({ layout: after }: DropResult): boolean => {\n const me = after.items[dragged]!;\n return me.edge === edge.id && !me.inMenu;\n };\n const pad = { start: Math.max(0, edge.pad?.start ?? 0), end: Math.max(0, edge.pad?.end ?? 0) };\n const menuLen = el.menu ? len(el.menu.rect) : 0;\n const occupied = (id: string): Rect => (now.items[id]?.fixed ? reservedRect(state, now, id) : now.items[id]!.rect);\n const shown = (id: string): boolean => now.items[id]?.edge === edge.id && !now.items[id]!.inMenu;\n const drawnOf = (z: Zone): Rect[] => members0.filter((id) => zoneOf(rest.items[id]) === z && shown(id)).map(occupied);\n const startEnd = ((): number => {\n const s = drawnOf(\"start\");\n return s.length ? at(s[s.length - 1]!) + len(s[s.length - 1]!) : main0 + pad.start;\n })();\n const endStart = ((): number => {\n const e = drawnOf(\"end\");\n return e.length ? at(e[0]!) : main0 + length - pad.end - menuLen;\n })();\n const anchorLine: Record<Zone, number> = { start: main0 + pad.start, center: Math.min(Math.max(main0 + length / 2, startEnd), Math.max(startEnd, endStart)), end: main0 + length - pad.end - menuLen };\n const slots: Slot[] = [];\n // A slot's order: how many of the edge's shown items (fixed ones aside) lie before it, the item taken out.\n const aimed = (id: string): boolean => shown(id) && !now.items[id]!.fixed;\n let earlier = 0;\n for (const zone of ZONES) {\n const members = members0.filter((id) => zoneOf(rest.items[id]) === zone);\n const before0 = earlier;\n earlier += members.filter(aimed).length;\n if (!accepts || !zoneTakes(edge, zone, kind)) continue;\n // The zone's anchored fixed run, read from its anchor (the start zone's first member, the end zone's last) up to its\n // first shown movable member. The center zone has none: every fixed item there keeps the geometric test.\n const fixedHere = (id: string): boolean => !!base.items[id]?.fixed && base.items[id]!.edge === edge.id;\n const fromAnchor = (zone === \"start\" ? members : zone === \"end\" ? [...members].reverse() : []).filter((id) => fixedHere(id) || shown(id));\n const firstMovable = fromAnchor.findIndex((id) => !fixedHere(id));\n const anchored = new Set(firstMovable < 0 ? fromAnchor : fromAnchor.slice(0, firstMovable));\n // A fixed item that declares `pushable` yields in the anchored run: a drop after it may push it inward.\n const pushable = (id: string): boolean => fixedHere(id) && state.items[id]?.pushable === true;\n const isProtected = (id: string): boolean => fixedHere(id) && (zone === \"center\" || zoneOf(rest.items[id]) !== zone || (anchored.has(id) && !pushable(id)));\n for (let k = 0; k <= members.length; k++) {\n const next = members.slice(k).find(shown);\n const before = members.slice(0, k).reverse().find(shown);\n // Pushable items keep their order among the fixed items: no gap between two of them.\n if (before && next && pushable(before) && pushable(next)) continue;\n const line = next ? at(occupied(next)) : before ? at(occupied(before)) + len(occupied(before)) : anchorLine[zone];\n const s = { ...slotAt(c, zone, line, slotId(zone, k), { kind: \"gap\", edge: edge.id, zone, at: k }, lands), order: before0 + members.slice(0, k).filter(aimed).length };\n // A place that would move a protected fixed item (before a title, after the window controls) is no slot: it keeps\n // its place, so no drop ever lands there. A fixed item behind a movable one in this zone may be pushed.\n const movesFixed = members0.some((id) => {\n const b = base.items[id];\n const a = s.result.layout.items[id];\n // (Pushed is not gone: a drop that would take any fixed item out of the layout is no slot either.)\n if (fixedHere(id) && !a) return true;\n if (!isProtected(id)) return false;\n // A fixed item that takes steps (`stepping`) in the » has no place along the edge: \"nothing lands before it\" is\n // read from the order of ids, a drop between it and its zone's anchor.\n if (itemSteps(state.items[id]!) && (a!.inMenu || b!.inMenu)) {\n const i = members.indexOf(id);\n return i >= 0 && anchored.has(id) && (zone === \"end\" ? k > i : k <= i);\n }\n return (Math.abs(a!.rect.x - b!.rect.x) > 0.5 || Math.abs(a!.rect.y - b!.rect.y) > 0.5);\n });\n if (!movesFixed) slots.push(s);\n }\n }\n return slots;\n}\n\n/**\n * Whether the item is thicker than an edge `cross` px across: every form but the » menu's sets no cross size (an `open`\n * panel does, and is clamped) and asks at least `cross.min` across, over `cross`. Then no length makes room for it.\n * The one thickness test of every edge, real or virtual (a new column's line, a rail stop).\n */\nexport function thickerThan(forms: readonly StackForm[], cross: number): boolean {\n const shown = forms.filter((f) => !formMenu(f));\n return shown.length > 0 && shown.every((f) => !formSetsCross(f) && formCrossMin(f) > cross + EPS);\n}\n\n/**\n * Why `zone` of `spec`, which takes the kind, refuses a drop there that doesn't fit: `too-thick` where no form of the\n * item fits across the edge (the spec's own refusal says so), else `no-room` (too short). Every refusal for want of\n * room reads it, so a slot that doesn't fit and a sliver cut off a slot say what the zone says.\n */\nexport const roomReason = (spec: EdgeSpec, zone: Zone): \"too-thick\" | \"no-room\" => (spec.refuse(zone) === \"too-thick\" ? \"too-thick\" : \"no-room\");\n\n/**\n * A real edge as the tiler reads it, in the seen geometry, or null where it offers nothing (home's own rect is added\n * on its own). An edge the lift deletes (the item's own column, or a dynamic column left empty) has no place a drop\n * counts in: the item's own collapses into home.\n */\nexport function edgeSpec(c: Ctx, edge: DockEdge, as?: EdgeKind): EdgeSpec | null {\n const { state, rest, now, dragged, kind } = c;\n const el = now.edges[edge.id];\n // A folded or riding column takes drops through its side's rail and column lines, not here.\n if (!el || el.folded || el.rides || !rest.edges.some((e) => e.id === edge.id)) return null;\n const edgeKind = as ?? edgeKindOf(state, edge);\n const data = EDGE_KINDS[edgeKind];\n const column = axisOf(edge.side) === \"column\";\n const at = (r: Rect): number => (column ? r.y : r.x);\n const len = (r: Rect): number => (column ? r.height : r.width);\n const empty = el.stack.items.every((p) => el.stack.menu?.items.includes(p.id)) && !el.menu;\n // Whether it takes the kind at all: listed in `accepts` and taken by at least one zone. An edge whose zones take\n // nothing for it (`zoneAccepts: {}`, a rail the host doesn't draw) is one that doesn't accept it.\n const accepts = edgeTakes(edge, kind);\n // An edge that takes the kind nowhere and draws nothing has nothing to say; an empty edge opens only as it may.\n if (!accepts && (empty || area(el.rect) <= EPS)) return null;\n if (accepts && empty && !opensEmpty(state, edge, kind)) return null;\n // The item's own rect, where it is seen in this edge (in its » menu, the » entry): home's, whatever else the edge\n // offers.\n const ownNow = now.items[dragged];\n const ownHere = ownNow && ownNow.edge === edge.id && !ownNow.floating && area(ownNow.rect) > EPS ? ownNow.rect : null;\n // A column drawn as a rail, under `DockState.foldedColumnDrop: \"end\"`: for an item arriving from elsewhere its whole length\n // is one place, after its last member. One of its own tiles keeps its gaps, to move among them.\n const oneEnd = state.foldedColumnDrop === \"end\" && column && el.tabs.length > 0 && ownNow?.edge !== edge.id && zoneTakes(edge, \"start\", kind);\n const allSlots = edgeSlots(c, edge, accepts);\n const slots = oneEnd ? allSlots.filter((s) => s.zone === \"start\").sort((a, b) => a.line - b.line).slice(-1) : allSlots;\n const spanOf = (r: Rect): Span => [at(r), at(r) + len(r)];\n // The edge's reserved rects along it (its fixed items; a growing one's natural rect): no slot's tile lies there.\n // A growing one (a title) is not: its text is a stretch of the gap just after it.\n const grows = (id: string): boolean => !!formsOf(state.items[id]!, axisOf(edge.side))[now.items[id]!.form]?.main.grows;\n const reserved: Span[] = Object.entries(now.items)\n .filter(([id, p]) => p.edge === edge.id && p.fixed && !p.inMenu && !grows(id))\n .map(([, p]) => spanOf(p.rect));\n const cards: Span[] = Object.entries(now.items)\n .filter(([id, p]) => id !== dragged && p.edge === edge.id && !p.fixed && !p.inMenu && !p.floating && area(p.rect) > EPS)\n .map(([, p]) => spanOf(p.rect));\n const zones = oneEnd\n ? [{ zone: \"start\" as const, a: at(el.rect) - c.reach, b: at(el.rect) + len(el.rect) + c.reach }]\n : zoneSpans(state, now, edge, c.reach, (zone) => {\n const s = slots.find((x) => x.zone === zone && x.place.kind === \"gap\" && x.place.at === 0);\n const me = s?.result.layout.items[dragged];\n return me && me.edge === edge.id && me.zone === zone ? spanOf(me.rect) : null;\n });\n\n // Across: the band from the edge's outer side, as deep as the edge (seen or after the drop) or an empty edge's strip.\n const r = el.rect;\n const strip = Math.max(0, Number.isFinite(edge.strip) ? edge.strip! : DEFAULT_STRIP);\n const outer = edge.side === \"left\" ? r.x : edge.side === \"right\" ? r.x + r.width : edge.side === \"top\" ? r.y : r.y + r.height;\n const inward = (depth: number): Span => (edge.side === \"left\" || edge.side === \"top\" ? [outer, outer + depth] : [outer - depth, outer]);\n // An empty rail or bar: as deep as a drop draws it (a rail's or a bar's drawn depth), entered over that. An empty column,\n // whose drop draws a whole column, keeps the thin band.\n const thin = edgeKind === \"rail\" || edgeKind === \"bar\" || edgeKind === \"barBetween\";\n const landed = el.cross > 0 || !thin ? 0 : Math.max(0, ...slots.map((s) => s.result.layout.edges[edge.id]?.cross ?? 0));\n const across = (after?: DockLayout): Span => inward((el.cross > 0 ? Math.max(el.cross, after?.edges[edge.id]?.cross ?? 0) : Math.max(strip, landed)) + data.inward);\n // What it owns: its seen thickness; an edge not drawn (empty, or one that shows only once the item lifts) owns the\n // depth a drop draws it at, at its boundary, else a thin band of its place.\n const drawn = el.cross > 0;\n const marker = (s: Slot): Rect => {\n const slot = s.result.layout.items[dragged]!.rect;\n const e = s.result.layout.edges[edge.id]!;\n return column ? rect(e.rect.x, slot.y, e.cross, 0) : rect(slot.x, e.rect.y, 0, e.cross);\n };\n const takes = (zone: Zone): boolean => accepts && zoneTakes(edge, zone, kind);\n // No form of the item fits across the edge: a refusal there is for thickness, not for lack of length.\n const tooThick = thickerThan(formsOf(state.items[dragged]!, axisOf(edge.side)), el.stack.cross);\n return {\n id: edge.id,\n edge,\n kind: edgeKind,\n lay: c.lay.get(edge.id)!,\n vertical: column,\n zones,\n slots,\n refuse: (zone) => (takes(zone) ? (tooThick ? \"too-thick\" : \"no-room\") : accepts || area(el.rect) > EPS ? \"not-accepted\" : null),\n own: ownHere,\n holds: !!ownNow && ownNow.edge === edge.id && !ownNow.floating,\n reserved,\n cards,\n across,\n owned: inward(drawn ? el.cross : landed > 0 ? landed : Math.min(strip, data.place)),\n ...(!drawn && landed > Math.min(strip, data.place) ? { thinOwned: inward(Math.min(strip, data.place)) } : {}),\n ownedAlong: null,\n drawn,\n marker,\n };\n}\n\n/**\n * The run of a column folded into its side's declared rail, as the edge of its own that it is for one of its tiles held:\n * `edgeSpec` of the column drawn where its tiles lie, `run` (the rail's tiles of that column, end to end). Its zones,\n * its slots and its cards are those of the column drawn as a rail, within the run; it reaches no further (no\n * `endReach`), so what lies beside the run in the rail stays with the rail's own stops. It is as deep as the rail, never\n * deeper (a drop that would open the column draws it wider, but a place here stays in the rail), and its zones lie in the\n * run (a tray's end zone is solved where the column would lie open, not in the rail). Null where the column offers\n * nothing (the item alone in it, which the lift deletes).\n */\nexport function railColumnSpec(c: Ctx, edge: DockEdge, run: Rect): EdgeSpec | null {\n const el = c.now.edges[edge.id];\n if (!el) return null;\n const { folded: _folded, ...shown } = el;\n const seen = { ...c, reach: 0, now: { ...c.now, edges: { ...c.now.edges, [edge.id]: { ...shown, rect: run, cross: run.width } } } };\n const spec = edgeSpec(seen, edge, \"railColumn\");\n if (!spec) return null;\n const across: Span = [run.x, run.x + run.width];\n return { ...spec, across: () => across, owned: across };\n}\n","/** The edge kinds and their data (`EDGE_KINDS`): the only place target generation tells edges apart. */\nimport { isSideBar, zoneTakes } from \"../helpers\";\nimport { DEFAULT_HIT_BAND, type DockEdge, type DockState } from \"../model\";\n\n/** How far a column line's hit reaches on each side of the line, px. */\nconst COLUMN_REACH = 22;\n/** How deep a side takes a rail drop while it shows no rail, px. */\nexport const RAIL_EDGE = 10;\n\n/** How far a compact rail's hits reach inward past the rail, px. */\nconst RAIL_REACH = 24;\n\n/** The least a target's largest piece keeps where the space beside it can be spared: 12 px across by 24 px along. */\nconst MIN_HIT = { across: 12, along: 24 } as const;\n\n/**\n * The edge kinds and their data, the only place target generation tells them apart, the virtual edges (the column\n * lines across a side, the stops down its rail) among them.\n * - `zoneExtent`: `thirds` where items keep their length and the zones only align them, `solved` where items fill the\n * edge (each zone's extent is the span the solver gives it), `whole` for an edge of one zone.\n * - `opens`: through which zones an empty edge opens: `any` zone that takes the kind, or only its `start` zone.\n * - `inward`: how far hits reach inward past the edge's thickness (overreach, below).\n * - Space ownership, one ordering: **owned > virtual > overreach**. A drawn edge owns its current rect; an empty edge\n * owns only `place` px of its strip, at the boundary where it would appear (the side's rail likewise, where it lies\n * or would lie, `railPlaces`). Owned rects rank in the order `solve` lays edges out (`layKeys`, `pushes`): an edge\n * laid first, whose filling pushes the other, wins; between edges laid independently a drawn rect wins over an empty\n * edge's band. `layer` orders the owned tiles where they meet. The virtual edges (the column lines) come next and get\n * only space no edge owns. `overreach` orders the parts of tiles past their owned rect (the depth after a drop, an\n * empty strip past its band, a compact rail's inward reach), which yield to the virtual edges and to every other\n * edge's owned rect.\n * - `railColumn`: the run of a column folded into a declared rail, for one of its own tiles held (`railColumnSpec`): a\n * column's edge, tiled before the rail's stops, so what lies beside the run stays the rail's.\n * - `phase`: the laying phase it ranks in (`LayKey.phase`), for the kinds `solve` doesn't lay itself: the rail and a\n * column line rank among the sides (phase 2), where the rail or a new column would be laid; null for the edges\n * `solve` lays (their phase is `layKeys`'s).\n * - `priority`: its targets' priority. `reach`: how far a slot's tile reaches each way from its line, px.\n * - `edgePlace` (column lines): the band the outermost line owns where it can't be centered on its line, at the side's\n * outer boundary: laid inward, right after the rail stop's `RAIL_EDGE` px.\n * - `virtual`: an edge that owns nothing (the column lines). Its refused stretches take only what every other tile\n * leaves.\n * - `minHit`: the least its targets' largest piece keeps (`MIN_HIT`), taken from the space beside it where that can be\n * spared (`./min-hit`).\n */\nexport const EDGE_KINDS = {\n bar: { zoneExtent: \"thirds\", opens: \"any\", inward: 0, place: DEFAULT_HIT_BAND / 2, phase: null, layer: 10, overreach: 30, priority: 2, reach: Infinity, virtual: false, minHit: MIN_HIT },\n sideBar: { zoneExtent: \"thirds\", opens: \"any\", inward: 0, place: DEFAULT_HIT_BAND / 2, phase: null, layer: 11, overreach: 31, priority: 2, reach: Infinity, virtual: false, minHit: MIN_HIT },\n column: { zoneExtent: \"solved\", opens: \"start\", inward: 0, place: DEFAULT_HIT_BAND / 2, phase: null, layer: 12, overreach: 32, priority: 2, reach: Infinity, virtual: false, minHit: MIN_HIT },\n barBetween: { zoneExtent: \"thirds\", opens: \"any\", inward: 0, place: DEFAULT_HIT_BAND / 2, phase: null, layer: 13, overreach: 33, priority: 2, reach: Infinity, virtual: false, minHit: MIN_HIT },\n rail: { zoneExtent: \"thirds\", opens: \"any\", inward: RAIL_REACH, place: DEFAULT_HIT_BAND / 2, phase: null, layer: 14, overreach: 34, priority: 2, reach: Infinity, virtual: false, minHit: MIN_HIT },\n railStop: { zoneExtent: \"whole\", opens: \"any\", inward: 0, place: DEFAULT_HIT_BAND / 2, phase: 2, layer: 9, overreach: 39, priority: 1, reach: Infinity, virtual: false, minHit: MIN_HIT },\n railColumn: { zoneExtent: \"solved\", opens: \"start\", inward: 0, place: DEFAULT_HIT_BAND / 2, phase: null, layer: 8, overreach: 38, priority: 2, reach: Infinity, virtual: false, minHit: MIN_HIT },\n columnLine: { zoneExtent: \"whole\", opens: \"any\", inward: 0, place: DEFAULT_HIT_BAND / 2, edgePlace: DEFAULT_HIT_BAND, phase: 2, layer: 21, overreach: 41, priority: 2, reach: COLUMN_REACH, virtual: true, minHit: MIN_HIT },\n} as const satisfies Record<\n string,\n {\n readonly zoneExtent: \"thirds\" | \"solved\" | \"whole\";\n readonly opens: \"any\" | \"start\";\n readonly inward: number;\n readonly place: number;\n readonly edgePlace?: number;\n readonly layer: number;\n readonly phase: number | null;\n readonly overreach: number;\n readonly priority: 1 | 2;\n readonly reach: number;\n readonly virtual: boolean;\n readonly minHit: { readonly across: number; readonly along: number };\n }\n>;\nexport type EdgeKind = keyof typeof EDGE_KINDS;\n\n/** Which of `EDGE_KINDS` an edge is. */\nexport function edgeKindOf(state: DockState, e: DockEdge): EdgeKind {\n if (e.compact) return \"rail\";\n if (e.side === \"top\" || e.side === \"bottom\") return e.span === \"between\" ? \"barBetween\" : \"bar\";\n return isSideBar(state, e) ? \"sideBar\" : \"column\";\n}\n\n/**\n * Whether an empty `edge` opens to `kind`: an edge opens only through its start zone, so a kind never makes a column of\n * its own where the start zone takes another kind (a group never makes a column of one toolbar: a tray column's tray is\n * its end zone). Edges whose zones only align (bars, rails, side bars) open through any zone that takes the kind.\n */\nexport const opensEmpty = (state: DockState, edge: DockEdge, kind: string): boolean => EDGE_KINDS[edgeKindOf(state, edge)].opens === \"any\" || zoneTakes(edge, \"start\", kind);\n","/**\n * The filter a drop passes, and the context every generator shares: the state now and with the item lifted, how a drop\n * settles, when a drop puts the item back (home), and filter (ii), whether a drop's layout fits the window.\n */\nimport { overlaps } from \"@n-uf/placement\";\nimport { formMain, itemSteps } from \"@n-uf/placement/stack\";\nimport { liftItem, prune } from \"../changes\";\nimport { axisOf, keepClearFor, formsOf, isHandFolded, zoneOf } from \"../helpers\";\nimport { ZONES, type DockEdge, type DockState, type DockItem, type DockLayout, type SolveOptions } from \"../model\";\nimport { layKeys, solve } from \"../solve\";\nimport { reservedRect } from \"./edges\";\nimport type { Ctx, DropResult, DockDropOptions } from \"./model\";\n\n/**\n * Where things are, without ages or the ids of dynamic columns: two states with one key place every item alike. An\n * edge's items count by zone (start, center, end), in their order within it: the list's order across zones places\n * nothing.\n */\nfunction placeKey(s: DockState, id: string): string {\n const it = Object.hasOwn(s.items, id) ? s.items[id] : undefined;\n const byZone = (items: readonly string[]): string[] => ZONES.flatMap((z) => items.filter((x) => zoneOf(s.items[x]) === z));\n return JSON.stringify({\n edges: s.edges.map((e) => JSON.stringify([e.side, e.ring, e.column === true ? \"\" : e.id, byZone(e.items), e.size ?? null])).sort(),\n floats: s.floats.map((f) => [f.id, f.rect, f.anchor ?? null, f.orient ?? null]),\n folded: isHandFolded(s, id),\n align: it?.align ?? \"start\",\n });\n}\n\n/**\n * Filter (ii), fit: a drop may not add an `overflow` or `too-wide` note anywhere, change a fixed item's form (unless it\n * is `stepping`) or squeeze it under its least length (a growing one that takes no steps: its natural length; for target\n * room its `grows` caps there, so a drop beside it lands as beside a fixed item of that length), nor lie over chrome or a drawn fixed item's reserved rect (C29). Each edge adds where a drop on it lands (`lands`).\n */\nfunction soundness(state: DockState, base: DockLayout, dragged: string): (after: DockLayout) => boolean {\n const chrome = keepClearFor(state, \"targets\");\n const noteKey = (n: DockLayout[\"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 return (after) => {\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) return false;\n // A fixed item that takes steps (`stepping`) may step for a drop, into the » too; in a drawn form it keeps its least.\n const steps = itemSteps(state.items[id]!);\n if (!steps && (a.form !== b.form || a.formKind !== b.formKind)) return false;\n if (a.inMenu) continue;\n const f = formsOf(state.items[id]!, axisOf(e.side))[a.form];\n const len = axisOf(e.side) === \"column\" ? a.rect.height : a.rect.width;\n // The target room a fixed item takes: its least, or for one that grows and takes no steps (a title) its natural\n // length. Its growth is spare room, not owned room: it yields that to a landing, never its natural length.\n const holds = !steps && f?.main.grows === true;\n if (f && len < formMain(f, holds ? \"natural\" : \"min\", e.cross) - 0.5) return false;\n }\n const me = after.items[dragged];\n if (!me) return true;\n const fixedAfter = Object.entries(after.items).filter(([id, it]) => it.fixed && !(it.inMenu && itemSteps(state.items[id]!)) && id !== dragged).map(([id]) => reservedRect(state, after, id));\n return !chrome.some((c) => overlaps(me.rect, c)) && !fixedAfter.some((f) => overlaps(me.rect, f));\n };\n}\n\n/**\n * A drag's context: null for an unknown, fixed or closed item (it has no targets). `others`: edges kept out of `state`\n * (its hidden ones) that a drop's new column must not repeat the ids of.\n */\nexport function context(state: DockState, dragged: string, options: DockDropOptions, others: readonly DockEdge[] = []): { c: Ctx; item: DockItem; prev: SolveOptions } | null {\n const item = Object.hasOwn(state.items, dragged) ? state.items[dragged] : undefined;\n if (!item || item.fixed || item.closed) return null;\n const prev = { ...(options.previous ? { previous: options.previous } : {}), ...(options.fresh ? { fresh: options.fresh } : {}) };\n const settle = (s: DockState): DropResult => ({ state: s, layout: solve(s, prev) });\n const now = solve(state, prev);\n const rest = liftItem(state, dragged);\n const base = solve(rest, prev);\n // Every drop prunes the dynamic columns left empty: the place the item is in now counts without them too.\n const here = placeKey(prune(state), dragged);\n const c: Ctx = {\n state,\n others,\n rest,\n now,\n base,\n dragged,\n kind: item.kind,\n reach: Math.max(0, Number.isFinite(options.endReach) ? options.endReach! : 0),\n settle,\n isHome: (r) => placeKey(r.state, dragged) === here,\n sound: soundness(state, base, dragged),\n lay: layKeys(state),\n };\n return { c, item, prev };\n}\n","/**\n * Space ownership (filter iii), in the seen geometry: the committed layout, the item in place, the one the user sees.\n * A stretch is owned by what the user sees there; if the owner has no slot there, it refuses. A drawn edge owns its\n * seen rect (the item's own edge too: its own interval is home's); an edge not drawn (empty, or one that shows only\n * once the item lifts) owns a thin band of its place at its boundary, along its surviving slots' tiles only; the\n * rail likewise. Owned rects rank in the order `solve` lays edges out: one laid before another and pushing it when\n * filled wins (outer before inner, full bars before the sides they push, the rail before its side); between edges laid\n * independently a drawn rect wins over an empty edge's band, two drawn rects yield to each other, and of two bands the\n * one laid first wins. Home's tile is owned before all. A virtual edge owns nothing and yields to every owner.\n */\nimport { EPS, area, overlaps, rect, subtract, type Rect } from \"@n-uf/placement\";\nimport { formBody, itemSteps, type StackForm } from \"@n-uf/placement/stack\";\nimport { axisOf, formsOf, hitBandOf } from \"../helpers\";\nimport { DEFAULT_HIT_BAND, type DockEdge } from \"../model\";\nimport { pushes, type LayKey } from \"../solve\";\nimport { EDGE_KINDS } from \"./kinds\";\nimport { meet } from \"./meet\";\nimport { less, type Ctx, type EdgeSpec, type Room, type Span } from \"./model\";\n\n/** Whether a drawn form shows its body (an open panel's). */\nconst isBody = (f: StackForm | undefined): boolean => !!f && formBody(f);\n\ninterface Owner {\n /** The edge it is, as the tiler reads it; null for an edge the tiler doesn't read (folded, riding, taking nothing). */\n readonly spec: EdgeSpec | null;\n readonly rect: Rect;\n readonly lay: LayKey;\n readonly place: boolean;\n /** An empty rail's or bar's depth past its thin band (`EdgeSpec.thinOwned`): it yields to a drawn edge that takes the item. */\n readonly deep?: true;\n}\n\n/** What clipping reads of ownership. */\nexport interface Ownership {\n readonly owners: readonly Owner[];\n /** Per spec: the rects it yields (the owners that win over it; for a virtual edge, every other owner too). */\n readonly taken: ReadonlyMap<EdgeSpec, readonly Rect[]>;\n /** A zone's room lost to the owners that win over its edge across its whole depth (`cuts`), and its panel bodies. */\n readonly cutsOf: (s: EdgeSpec) => Room;\n /** The panel bodies and reserved rects of an edge, each cut across its whole band (none for a virtual edge). */\n readonly bodies: (s: EdgeSpec) => Rect[];\n /** The fixed items that don't grow, where they are seen. */\n readonly solid: readonly Rect[];\n /**\n * Every edge's seen rect but `s`'s. A refusal owns nothing, so it yields to them: a stretch is owned by what the user\n * sees there.\n */\n readonly drawnBesides: (s: EdgeSpec) => readonly Rect[];\n}\n\nconst bandOf = (s: EdgeSpec): Rect => {\n const a = Math.min(...s.zones.map((z) => z.a));\n const b = Math.max(...s.zones.map((z) => z.b));\n return s.vertical ? rect(s.owned[0], a, s.owned[1] - s.owned[0], b - a) : rect(a, s.owned[0], b - a, s.owned[1] - s.owned[0]);\n};\n\n/** What it owns: its band, limited along it where it owns less than its zones (a column line's place). */\nconst ownedRectOf = (s: EdgeSpec): Rect => {\n const b = bandOf(s);\n if (!s.ownedAlong) return b;\n const [a0, a1] = s.ownedAlong;\n return s.vertical ? rect(b.x, a0, b.width, a1 - a0) : rect(a0, b.y, a1 - a0, b.height);\n};\n\n/**\n * What an edge owns against the others: its owned rect along the stretches its surviving slots tile, `along` (from the\n * edge tiled on its own, before any other edge cuts it). A stretch with no slot of its own, a refused slot's, a zone\n * whose every slot the filter removes, and home's (owned on its own) own nothing; its drawn rect still counts, as\n * every drawn rect does.\n */\nfunction ownedRectsOf(s: EdgeSpec, along: readonly Span[]): Rect[] {\n if (along.length === 0) return [];\n const o = ownedRectOf(s);\n if (s.ownedAlong) return [o];\n return along.map(([a, b]) => (s.vertical ? rect(o.x, a, o.width, b - a) : rect(a, o.y, b - a, o.height)));\n}\n\n/**\n * Every edge's seen rect, with the spec the tiler reads it by (null for an edge it doesn't read), and each side's drawn\n * rail's rect: a drawn rail owns its seen rect as every drawn edge does, so what its stops tile and what they leave\n * (past its last stop, the whole rail for a tile of it, whose stops are all home's) is the rail's, never a column line's.\n * Less the run of the held tile's own column (`ownColumnRun`), which is that column's, tiled before the rail's stops.\n */\nfunction drawnOf(c: Ctx, live: readonly EdgeSpec[]): { spec: EdgeSpec | null; rect: Rect; lay: LayKey }[] {\n const edges = Object.entries(c.now.edges)\n .filter(([id, e]) => area(e.rect) > EPS && c.lay.has(id))\n .map(([id, e]) => ({ spec: live.find((s) => s.edge?.id === id) ?? null, rect: e.rect, lay: c.lay.get(id)! }));\n const rails = ([\"left\", \"right\"] as const).flatMap((side) => {\n const rail = c.now.rails[side];\n if (!rail || rail.segments.length === 0 || area(rail.rect) <= EPS) return [];\n const spec = live.find((s) => s.kind === \"railStop\" && s.lay.side === side) ?? null;\n const lay = spec?.lay ?? { phase: EDGE_KINDS.railStop.phase, side, at: -1 };\n const me = c.now.items[c.dragged];\n const run = me?.rail === side ? rail.segments.filter((g) => g.edge === me.edge).map((g) => g.rect) : [];\n if (run.length === 0) return [{ spec, rect: rail.rect, lay }];\n const top = Math.min(...run.map((r) => r.y));\n const own = rect(rail.rect.x, top, rail.rect.width, Math.max(...run.map((r) => r.y + r.height)) - top);\n // The run is the own column's, as a drawn column is its edge's; the rest of the rail is the rail's.\n const column = live.find((s) => s.kind === \"railColumn\" && s.edge?.id === me!.edge);\n return [...subtract(rail.rect, own).map((r) => ({ spec, rect: r, lay })), ...(column ? [{ spec: column, rect: own, lay: column.lay }] : [])];\n });\n return [...edges, ...rails];\n}\n\n/**\n * Home's tile: the item's own rect and, along it, its edge's band (the own interval across the band). Where the lift\n * deletes its edge (the item alone in its column), the edge collapses into home: its whole seen rect. Null for a\n * floating item.\n */\nexport function homeRectOf(c: Ctx, ownSpec: EdgeSpec | null): Rect | null {\n const own = c.now.items[c.dragged];\n if (!own || own.floating || !own.edge) return null;\n const o = own.rect;\n const hull = (a: Rect, b: Rect): Rect => rect(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.max(a.x + a.width, b.x + b.width) - Math.min(a.x, b.x), Math.max(a.y + a.height, b.y + b.height) - Math.min(a.y, b.y));\n if (own.inMenu) return o;\n if (!ownSpec) {\n const e = c.now.edges[own.edge];\n const vanishes = !c.rest.edges.some((x) => x.id === own.edge);\n return e && vanishes && !e.folded && !e.rides && area(e.rect) > EPS ? hull(o, e.rect) : o;\n }\n const [c0, c1] = ownSpec.across();\n return ownSpec.vertical ? hull(o, rect(c0, o.y, c1 - c0, o.height)) : hull(o, rect(o.x, c0, o.width, c1 - c0));\n}\n\n/** Every owner: home first, then each edge the tiler reads, then every drawn rect. */\nfunction ownersOf(c: Ctx, live: readonly EdgeSpec[], drawn: ReturnType<typeof drawnOf>, alongOf: (s: EdgeSpec) => readonly Span[]): Owner[] {\n const ownEdge = c.now.items[c.dragged]?.edge;\n const ownSpec = (ownEdge && live.find((s) => s.edge?.id === ownEdge)) || null;\n const homeRect = homeRectOf(c, ownSpec);\n return [\n // Home first: its tile is its own, for every edge but its own (which tiles it as its own interval).\n ...(homeRect ? [{ spec: ownSpec, rect: homeRect, lay: { phase: -1, side: \"\", at: -Infinity }, place: false }] : []),\n // Every edge the tiler reads, along each zone with a slot the filter keeps: what it owns, drawn or a band of its\n // place (a column line's band about its line). A zone whose every slot is refused owns nothing against the others\n // (its drawn rect still counts, below).\n ...live\n .flatMap((s): Owner[] => {\n const rects = ownedRectsOf(s, alongOf(s));\n if (!s.thinOwned) return rects.map((r) => ({ spec: s, rect: r, lay: s.lay, place: !s.drawn }));\n // An empty rail or bar: its thin band as any band, the depth past it as a band that yields to a drawn edge taking the item.\n const thin = (r: Rect): Rect => (s.vertical ? rect(Math.max(r.x, s.thinOwned![0]), r.y, Math.min(r.x + r.width, s.thinOwned![1]) - Math.max(r.x, s.thinOwned![0]), r.height) : rect(r.x, Math.max(r.y, s.thinOwned![0]), r.width, Math.min(r.y + r.height, s.thinOwned![1]) - Math.max(r.y, s.thinOwned![0])));\n return rects.flatMap((r) => [{ spec: s, rect: thin(r), lay: s.lay, place: true }, ...subtract(r, thin(r)).map((d) => ({ spec: s, rect: d, lay: s.lay, place: true, deep: true as const }))]);\n })\n .filter((o) => area(o.rect) > EPS),\n // Every seen rect: the edges the tiler doesn't read (folded, riding, taking nothing) among them.\n ...drawn.map((d) => ({ ...d, place: false })),\n ];\n}\n\n/**\n * `alongOf(spec)`: the stretches along each edge its surviving slots tile, from the edge tiled on its own (see\n * `ownedRectsOf`).\n */\nexport function ownership(c: Ctx, live: readonly EdgeSpec[], alongOf: (s: EdgeSpec) => readonly Span[]): Ownership {\n const { state, now, dragged } = c;\n const drawn = drawnOf(c, live);\n const owners = ownersOf(c, live, drawn, alongOf);\n const wins = (o: Owner, s: EdgeSpec): boolean => {\n if (o.spec === s) return false;\n if (pushes(o.lay, s.lay)) return true;\n if (pushes(s.lay, o.lay)) return false;\n const place = !s.drawn;\n return o.place === place ? !place || o.lay.at < s.lay.at : !o.place;\n };\n // A drawn edge's zones that take the item (a slot the filter keeps), across its band: an empty rail's or bar's depth\n // past its thin band never takes them.\n const takingRects = (s: EdgeSpec): Rect[] =>\n s.drawn\n ? s.zones.filter((z) => s.slots.some((sl) => sl.ok && sl.zone === z.zone)).map((z) => (s.vertical ? rect(s.owned[0], z.a, s.owned[1] - s.owned[0], z.b - z.a) : rect(z.a, s.owned[0], z.b - z.a, s.owned[1] - s.owned[0])))\n : [];\n const thinRectOf = (s: EdgeSpec): Rect => {\n const b = bandOf(s);\n const [t0, t1] = s.thinOwned!;\n return s.vertical ? rect(t0, b.y, t1 - t0, b.height) : rect(b.x, t0, b.width, t1 - t0);\n };\n // Reach only adds: the part of an edge's band past its own ends (its `endReach` strips) never takes another real\n // edge's own span (that edge's owned band along its length). There it neither wins over that edge nor keeps its tile.\n const endsOf = (s: EdgeSpec): Span | null => {\n const e = s.edge ? now.edges[s.id] : undefined;\n if (!e || EDGE_KINDS[s.kind].virtual) return null;\n const span: Span = s.vertical ? [e.rect.y, e.rect.y + e.rect.height] : [e.rect.x, e.rect.x + e.rect.width];\n return span[1] - span[0] > EPS ? span : null;\n };\n const pastEnds = (s: EdgeSpec, r: Rect): Rect[] => {\n const ends = endsOf(s);\n if (!ends) return [];\n const [lo, hi] = s.vertical ? [r.y, r.y + r.height] : [r.x, r.x + r.width];\n return less([[lo, hi]], [ends]).map(([u, w]) => (s.vertical ? rect(r.x, u, r.width, w - u) : rect(u, r.y, w - u, r.height)));\n };\n const ownSpanOf = (s: EdgeSpec): Rect | null => {\n const ends = endsOf(s);\n if (!ends) return null;\n const [o0, o1] = s.owned;\n return s.vertical ? rect(o0, ends[0], o1 - o0, ends[1] - ends[0]) : rect(ends[0], o0, ends[1] - ends[0], o1 - o0);\n };\n // `o`'s rect `r` less where its reach crosses `s`'s own span.\n const reachLess = (o: Owner, r: Rect, s: EdgeSpec): Rect[] => {\n const span = ownSpanOf(s);\n if (!o.spec || !span) return [r];\n return pastEnds(o.spec, r).flatMap((p) => meet(p, span) ?? []).reduce<Rect[]>((acc, cut) => acc.flatMap((q) => subtract(q, cut)), [r]);\n };\n // Where `s`'s reach crosses another edge's own span, along that edge's surviving slots.\n const reachYields = (s: EdgeSpec): Rect[] => {\n const past = pastEnds(s, bandOf(s));\n if (past.length === 0) return [];\n return live\n .filter((d) => d !== s)\n .flatMap((d) => {\n const span = ownSpanOf(d);\n return span ? ownedRectsOf(d, alongOf(d)).flatMap((r) => meet(r, span) ?? []) : [];\n })\n .flatMap((q) => past.flatMap((p) => meet(p, q) ?? []));\n };\n // What each edge yields: the owners that win over it (an empty rail's or bar's depth less the zones it takes nothing\n // from), less their reach over its own span; a virtual edge (a column line) also every other owner's rect outside its\n // own band, where its tile is overreach; an empty rail or bar also, past its thin band, the drawn edges' zones that\n // take the item; and its own reach over another edge's own span.\n const taken = new Map<EdgeSpec, readonly Rect[]>(\n live.map((s) => [\n s,\n [\n ...owners.filter((o) => wins(o, s)).flatMap((o) => (o.deep ? takingRects(s).reduce<Rect[]>((acc, t) => acc.flatMap((r) => subtract(r, t)), [o.rect]) : [o.rect]).flatMap((r) => reachLess(o, r, s))),\n ...(EDGE_KINDS[s.kind].virtual ? owners.filter((o) => o.spec !== s && !wins(o, s)).flatMap((o) => subtract(o.rect, ownedRectOf(s))) : []),\n ...(s.thinOwned ? live.filter((d) => d !== s).flatMap((d) => takingRects(d).flatMap((t) => subtract(t, thinRectOf(s)))) : []),\n ...reachYields(s),\n ],\n ]),\n );\n // Half the hit band of an edge's panels, or null where they are split in halves (`hitBand: \"middle\"`, no body).\n const halfBandOf = (e: DockEdge): number | null => {\n const bandOpt = hitBandOf(state, e);\n return bandOpt === \"middle\" ? null : Math.max(0, Number.isFinite(bandOpt) ? bandOpt : DEFAULT_HIT_BAND) / 2;\n };\n // Panel bodies (an open item's), but for `hitBand / 2` at each end: no drop place of their edge.\n const bodySpans = (e: DockEdge | null): Span[] => {\n const half = e ? halfBandOf(e) : null;\n if (!e || half === null) return [];\n const column = axisOf(e.side) === \"column\";\n return Object.entries(now.items)\n .filter(([iid, p]) => p.edge === e.id && iid !== dragged && isBody(formsOf(state.items[iid]!, axisOf(e.side))[p.form]))\n .map(([, p]): Span => (column ? [p.rect.y + half, p.rect.y + p.rect.height - half] : [p.rect.x + half, p.rect.x + p.rect.width - half]))\n .filter(([a, b]) => b - a > EPS);\n };\n // A zone's room: less the stretches where the owners that win over its edge together hold the edge's whole depth (a\n // thinner owner, an empty rail's band over a column, clips its tiles instead). Under 1 px of depth left is none: a\n // sub-pixel strip between two owners (an empty bar's zones, split where the bar's thirds fall) is no room, so no slot\n // lands its tile there. Panel bodies are no drop place, but they don't split the room: the tiles run across them and\n // clipping takes them out (`bodies`), so a card's band beside the item's own place meets the nearest slot past it.\n // A body cuts only beyond half a band of each slot's line, the line where the room puts it: a line under another\n // edge's owned band (the first gap of a column under an empty bar's place band) lies at that band's far side, and its\n // half band reaches into the body from there.\n const rooms = new Map<EdgeSpec, Room>();\n const cutsOf = (s: EdgeSpec): Room => {\n let room = rooms.get(s);\n if (!room) rooms.set(s, (room = roomOf(s)));\n return room;\n };\n const roomOf = (s: EdgeSpec): Room => {\n const b = bandOf(s);\n const along = (r: Rect): Span => (s.vertical ? [r.y, r.y + r.height] : [r.x, r.x + r.width]);\n const across = (r: Rect): Span => (s.vertical ? [r.x, r.x + r.width] : [r.y, r.y + r.height]);\n const rs = taken.get(s)!.filter((r) => overlaps(r, b));\n const ends = [...new Set([...along(b), ...rs.flatMap(along)])].filter((x) => x >= along(b)[0] && x <= along(b)[1]).sort((p, q) => p - q);\n const owned: Span[] = [];\n for (let k = 1; k < ends.length; k++) {\n const [u, w] = [ends[k - 1]!, ends[k]!];\n const over = rs.filter((r) => along(r)[0] <= u + EPS && along(r)[1] >= w - EPS).map(across);\n if (w - u > EPS && less([across(b)], over).reduce((n, [p, q]) => n + q - p, 0) < 1) owned.push([u, w]);\n }\n const half = s.edge ? halfBandOf(s.edge) : null;\n const raw = bodySpans(s.edge);\n if (half === null || raw.length === 0) return { cuts: owned, bodies: raw };\n const merged = owned.reduce<[number, number][]>((m, [u, w]) => {\n const last = m[m.length - 1];\n if (last && u <= last[1] + EPS) last[1] = Math.max(last[1], w);\n else m.push([u, w]);\n return m;\n }, []);\n // A line under a cut goes to the cut's side within the edge's drawn ends, as the tiler puts it (a reach strip past\n // an end takes no line), so a body's half band about it lies where the slot's tile does.\n const [lo, hi] = endsOf(s) ?? along(b);\n const placed = (p: number): number => {\n const cut = merged.find(([u, w]) => p >= u - EPS && p <= w + EPS);\n if (!cut) return p;\n const sides = [...(cut[0] > lo + EPS ? [cut[0]] : []), ...(cut[1] < hi - EPS ? [cut[1]] : [])];\n return sides.length === 0 ? p : sides.reduce((m, x) => (Math.abs(x - p) < Math.abs(m - p) ? x : m));\n };\n const bands = s.slots.map((sl): Span => [placed(sl.line) - half, placed(sl.line) + half]);\n return { cuts: owned, bodies: less(raw, bands) };\n };\n const grows = (id: string): boolean => {\n const it = now.items[id]!;\n const e = it.edge ? now.edges[it.edge] : undefined;\n return !!e && !!formsOf(state.items[id]!, axisOf(e.side))[it.form]?.main.grows;\n };\n // (A fixed item that takes steps, in the » entry, has no rect of its own there.)\n const solid = Object.entries(now.items).filter(([id, it]) => it.fixed && !grows(id) && !(it.inMenu && itemSteps(state.items[id]!))).map(([, it]) => it.rect);\n // Panel bodies (an open item's), but for `hitBand / 2` at each end, aren't drop places of their edge.\n // Nor are its fixed items' reserved rects (a growing title's natural rect): each cut across the edge's whole band.\n const bodies = (s: EdgeSpec): Rect[] => {\n const e = s.edge;\n if (!e) return [];\n const column = axisOf(e.side) === \"column\";\n const across = (a: number, b: number): Rect => (column ? rect(-1e9, a, 2e9, b - a) : rect(a, -1e9, b - a, 2e9));\n const reserved = Object.entries(now.items)\n .filter(([iid, p]) => p.edge === e.id && p.fixed && !p.inMenu && !grows(iid))\n .map(([, p]) => (column ? across(p.rect.y, p.rect.y + p.rect.height) : across(p.rect.x, p.rect.x + p.rect.width)));\n return [...reserved, ...cutsOf(s).bodies.map(([a, b]) => across(a, b))].filter((b) => area(b) > EPS);\n };\n const drawnBySpec = new Map<EdgeSpec, Rect[]>();\n const drawnBesides = (s: EdgeSpec): Rect[] => {\n let rs = drawnBySpec.get(s);\n if (!rs) drawnBySpec.set(s, (rs = drawn.filter((d) => d.spec !== s).map((d) => d.rect)));\n return rs;\n };\n return { owners, taken, cutsOf, bodies, solid, drawnBesides };\n}\n","import { EPS, rect, type Rect } from \"@n-uf/placement\";\n\n/** The part two rects share, or null when it has no area. Shared by the tiler and ownership. */\nexport function meet(a: Rect, b: Rect): Rect | null {\n const x = Math.max(a.x, b.x);\n const y = Math.max(a.y, b.y);\n const w = Math.min(a.x + a.width, b.x + b.width) - x;\n const h = Math.min(a.y + a.height, b.y + b.height) - y;\n return w > EPS && h > EPS ? rect(x, y, w, h) : null;\n}\n","/**\n * The targets' shapes: the public ones (`DockDrop`, `DockRefusal`, `DropPlace`, …) and the tiler's own (an edge\n * as the tiler reads it, its slots and tiles, the context every generator shares).\n */\nimport { EPS, type Point, type Rect, type Size } from \"@n-uf/placement\";\nimport type { Target } from \"@n-uf/placement\";\nimport type { ColumnPlace, RailPlace } from \"../changes\";\nimport type { DockEdge, Orient, DockState, DockLayout, Side, Zone } from \"../model\";\nimport type { LayKey } from \"../solve\";\nimport type { EdgeKind } from \"./kinds\";\n\nexport type DropPlace =\n | { readonly kind: \"gap\"; readonly edge: string; readonly zone: Zone; readonly at: number }\n | ColumnPlace\n | RailPlace\n | { readonly kind: \"side\"; readonly edge: string; readonly side: Side }\n | { readonly kind: \"float\" }\n | { readonly kind: \"home\" }\n | { readonly kind: \"none\" };\n\nexport interface DropResult {\n readonly state: DockState;\n readonly layout: DockLayout;\n}\n\nexport interface DockDrop extends Target {\n /** The item dragged. */\n readonly item: string;\n /**\n * Spring-loaded (a rail drop strip's targets): no target until the pointer dwells in it. Read only by\n * `@n-uf/motion/drag`'s drag intent (`DragTarget.arm`); the landing model and `dockDrag` don't read it.\n */\n readonly arm?: \"dwell\";\n /** With `arm`, its zone once armed (the strip grown by its magnet). */\n readonly armedHit?: Rect;\n /**\n * Its room opens as it shows: set on a target whose slot overlaps an item its drop moves (a rail pushing a column, a\n * new-column line, a bar's strip over the columns), and on a rail drop strip's targets, whose room opens once armed.\n * The drag intent then shows it and makes its room in one frame. Until it shows, a release still lands on it. Read\n * only by the drag intent (`DragTarget.opensRoom`).\n */\n readonly opensRoom?: true;\n /**\n * With `opensRoom`, how long it holds before it shows with its room, ms, in place of the drag intent's `roomAfter`: set\n * to `EDGE_ROOM_HOLD` on a rail target or a new-column line against the window's left or right edge.\n */\n readonly roomHold?: number;\n /**\n * With `opensRoom`, the zone it holds once its room is open: while the target shows with its room open, a drag intent\n * holds it wherever the pointer is in this rect. Set to the smallest rect holding `hit` and the slot (the landing\n * rect) on every target whose drop changes an edge's thickness (a side's width or a bar's height): strips,\n * new-column lines, rails and gaps. A rail drop strip (`armedHit`) doesn't carry it.\n */\n readonly roomHit?: Rect;\n /**\n * Where a release here puts the item. A host tells a home (nothing committed) by `place.kind === \"home\"`, never by the\n * id: a home keeps the id of the first of its edge's places that puts the item back (`gap:<edge>:<zone>:<at>` on a\n * real edge, `rail:<side>:<ring>` on its rail), and `home:<id>` alone covers the item's own rect.\n */\n readonly place: DropPlace;\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 /** A rail target under a kind's `DockState.railDrop` policy: the side's whole drop strip, for the host to draw. */\n readonly strip?: Rect;\n /** The state a release here commits and its layout. Only a float's depends on the pointer. */\n after(point: Point, grab?: Point): DropResult;\n}\n\nexport interface DockDropOptions {\n /** The layout before the drag: every `after` is solved with it, as the drop will be. */\n readonly previous?: DockLayout;\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 /**\n * The float target starts from the held item's rect (`heldRect`), kept inside the float region, before it is fitted, so\n * a host that draws the held item there sees what lands. Default: from the pointer's rect, wherever that lies.\n */\n readonly floatFromHeld?: boolean;\n /** The float's orient for the float target (default: its float's, else the item's `floatOrientOf`). */\n readonly floatOrient?: Orient;\n /** As `solve`'s: edge or item ids solved without `previous`, in every `after` too. */\n readonly fresh?: readonly string[];\n}\n\n/** Where a drop of the dragged item is refused: a host draws nothing there and may say \"Can't go here\" at the pointer. */\nexport interface DockRefusal {\n /**\n * `refuse:<edge>:<zone>`, with `:<n>` after it for a zone's second refused tile and on, numbered by where they lie\n * along the edge (then across it), so an id is stable from one frame to the next.\n */\n readonly id: string;\n readonly edge: string;\n readonly zone: Zone;\n /**\n * Where the pointer means it, never over a target's hit and never past the stage. An edge that takes the kind in no\n * zone gives one refusal (`n = 0`, zone `start`): its drawn rect, fixed items included, less what targets own. A\n * refused zone of an edge that takes the kind elsewhere: the refused slot's tile, inside the edge's ends.\n */\n readonly hit: Rect;\n /**\n * A wholly refused edge left in pieces by what targets own (a target in the middle of a bar): every piece, each at\n * least 1 px each way, `hit` the largest. Absent when the refusal is one rect. The pointer is in the refusal when it is\n * in any piece.\n */\n readonly hits?: readonly Rect[];\n /**\n * `no-room`: the zone takes the kind, but the drop there doesn't fit along the edge (a title bar at the title's\n * natural width, say): no length would be enough. `too-thick`: the zone takes the kind, but no form of the item\n * (the » menu aside) fits across the edge: each sets no cross size and has a `cross.min` over the edge's thickness\n * (a 30 px toolbar on a 28 px bar), so no length would help. `own-place`: the stretch beside an item alone in its\n * zone: there is room, but the zone's only place is the item's own (a release there puts it back). `not-accepted`:\n * the edge or zone doesn't take the kind.\n */\n readonly reason: \"no-room\" | \"too-thick\" | \"own-place\" | \"not-accepted\";\n /**\n * The stage: the refusal holds only points strictly inside it (`Target.bounds`), so a pointer a host clamps exactly\n * onto the window's edge is never in it. Set by `refusals()`; `refusalTargets` passes it on.\n */\n readonly bounds?: Rect;\n}\n\n/** One tile before clipping: a slot's, home's, or a refused slot's. */\nexport interface Tile {\n readonly edge: string;\n /** The edge it tiles, or null for home's own rect where no edge tiles it (its » entry). */\n readonly spec: EdgeSpec | null;\n /** Its edge's kind, set by the edge's description (a virtual edge's too): never read from an edge's id. */\n readonly edgeKind: EdgeKind;\n /** Its edge runs along y. */\n readonly vertical: boolean;\n readonly zone: Zone;\n /** Clipping precedence: lower first. */\n readonly order: number;\n /** `reach`: the overreach of the tile `of` (its part past its edge's owned rect), clipped after the virtual edges. */\n readonly kind: \"slot\" | \"home\" | \"refuse\" | \"reach\";\n readonly of?: Tile;\n readonly id: string;\n readonly priority: 1 | 2 | 3;\n readonly place?: DropPlace;\n readonly result?: DropResult;\n readonly reason?: DockRefusal[\"reason\"];\n /**\n * The one refusal of an edge that takes the kind in no zone: its drawn rect in the stage, fixed items included. Only\n * what targets own is cut from it.\n */\n readonly whole?: boolean;\n readonly hit: Rect;\n /** A slot's tile left in pieces by clipping: every piece (`hit` the largest). */\n readonly hits?: readonly Rect[];\n /** The point the tile must keep through clipping (on its slot's line), or null for a refusal (its largest part). */\n readonly keep: Point | null;\n readonly marker?: Rect;\n readonly slot?: Rect;\n}\n\n/** What one drag can do: its targets and its refusals, from one generation. */\nexport interface Generated {\n readonly targets: DockDrop[];\n readonly refusals: DockRefusal[];\n /** Slots the filter kept, with room in their zone, that end with no hit (none, by the property check). */\n readonly lost: string[];\n /** Each docked target's zone by id: its tiles with its edge tiled on its own (what it may grow to its minimum in). */\n readonly zones?: ReadonlyMap<string, readonly Rect[]>;\n}\n\n/** The context every edge's generator shares. */\nexport interface Ctx {\n readonly state: DockState;\n /** Edges kept out of `state` (its hidden ones): a drop's new column never repeats their ids (`moveAmong`). */\n readonly others: readonly DockEdge[];\n /** The state with the item lifted: what a place counts in (a gap's `at`, a column's or rail's `ring`). */\n readonly rest: DockState;\n /** The seen geometry: the committed layout, the item in place. Every tile lies in it. */\n readonly now: DockLayout;\n /** The layout with the item lifted: read only by the landing rules (fit, a title's natural width, fixed items). */\n readonly base: DockLayout;\n readonly dragged: string;\n readonly kind: string;\n readonly reach: number;\n readonly settle: (s: DockState) => DropResult;\n readonly isHome: (r: DropResult) => boolean;\n /** Whether a drop's layout fits the window (filter ii): what every edge checks; its own landing rule comes on top. */\n readonly sound: (after: DockLayout) => boolean;\n /** Where `solve` lays each edge of the state out. */\n readonly lay: ReadonlyMap<string, LayKey>;\n}\n\n/** A slot: an insertion line along an edge and the drop it makes. */\nexport interface Slot {\n readonly zone: Zone;\n /** Its line along the edge. */\n readonly line: number;\n readonly id: string;\n readonly place: Extract<DropPlace, { kind: \"gap\" }> | ColumnPlace | RailPlace;\n readonly result: DropResult;\n /** A drop here puts the item back where it is. */\n readonly home: boolean;\n /** It passes the filter: home, or the item lands where the slot aims and the window fits. */\n readonly ok: boolean;\n /**\n * A real edge's slot: its place in the order of the edge's shown items, the item taken out (how many of them, across\n * every zone, lie before it). Slots of one order are the same aim, whatever their zone.\n */\n readonly order?: number;\n}\n\n/** `[a, b]` along an edge. */\nexport type Span = readonly [number, number];\n\n/**\n * What an edge's zones lose along it: `cuts`, what other edges own across its whole depth (no room); `bodies`, its\n * panel bodies (no drop place, but the tiles run across them and clipping takes them out).\n */\nexport interface Room {\n readonly cuts: readonly Span[];\n readonly bodies: readonly Span[];\n}\n\n/** Spans along an edge less other spans along it. */\nexport const less = (spans: readonly Span[], away: readonly Span[]): Span[] =>\n away.reduce<Span[]>((acc, [ra, rb]) => acc.flatMap(([a, b]) => (rb <= a || ra >= b ? [[a, b] as Span] : ([[a, Math.max(a, ra)], [Math.min(b, rb), b]] as Span[]).filter(([u, w]) => w - u > EPS))), [...spans]);\n\n/**\n * One edge as the tiler reads it, a real edge or a virtual one alike: its kind (`EDGE_KINDS`), its axis, its zones'\n * extents along it, its slots, the item's own rect on it (its interval along the edge is home's tile), the spans no\n * tile takes, its band across and its markers.\n */\nexport interface EdgeSpec {\n /** The edge id its targets and refusals name (a side's column lines share one, one spec per line). */\n readonly id: string;\n /** The state's edge, or null for a virtual edge. */\n readonly edge: DockEdge | null;\n readonly kind: EdgeKind;\n /** Where `solve` lays it out (`layKeys`): what it owns ranks by this. */\n readonly lay: LayKey;\n /** It runs along y (side edges, the rail), not x (bars, the column lines). */\n readonly vertical: boolean;\n readonly zones: readonly { readonly zone: Zone; readonly a: number; readonly b: number }[];\n readonly slots: readonly Slot[];\n /** Why a stretch of `zone` with no slot is refused, or null where it is no drop place at all. */\n readonly refuse: (zone: Zone) => DockRefusal[\"reason\"] | null;\n /** The item's own rect on this edge, or null. */\n readonly own: Rect | null;\n /** The item lies on this edge now (drawn, or in its » menu): its home slot gets no tile, home is only its own rect. */\n readonly holds: boolean;\n readonly reserved: readonly Span[];\n /**\n * The seen spans of the edge's shown items other than the dragged one (fixed items aside), the items a pointer aims\n * at: tiles split at their midpoints, their leading half before them, their trailing half after them.\n */\n readonly cards: readonly Span[];\n /** The priority of its home tiles where it is not its kind's (the held tile's column in a rail: its home is the rail stop's). */\n readonly homePriority?: 1 | 2;\n /** The band across, `[from, to]`, as deep as the edge is seen or after `after`. */\n readonly across: (after?: DockLayout) => Span;\n /** The part of the band across it owns: its seen thickness, or an undrawn edge's thin band at its boundary. */\n readonly owned: Span;\n /** Along it, what it owns, where that is less than its zones (a column line's band about its line); else null. */\n readonly ownedAlong: Span | null;\n /** It is drawn in the seen geometry; else what it owns is a band of its place (where it lands once filled). */\n readonly drawn: boolean;\n /**\n * An empty rail or bar, which owns the depth a drop draws it at (`owned`): the thin band at its boundary within that.\n * Past the thin band it never takes the zones of a drawn edge that take the item (a drawn rail beside an empty bar,\n * a column's first gap under it, keep their places).\n */\n readonly thinOwned?: Span;\n /** A slot's marker: the zero-thick line where the item's leading edge lands. */\n readonly marker: (s: Slot) => Rect;\n}\n","/**\n * Tiles: each edge's zones split into its slots' tiles (`tileEdge`), then clipped in precedence order (`clipTiles`):\n * each clear of the tiles before it, of what outranks its edge, of the fixed items that don't grow and of the chrome.\n */\nimport { EPS, area, overlaps, rect, subtract, type Point, type Rect } from \"@n-uf/placement\";\nimport { axisOf, zoneOf } from \"../helpers\";\nimport { ZONES, type DockLayout, type Zone } from \"../model\";\nimport { distinctSlots, roomReason } from \"./edges\";\nimport { targetId } from \"./ids\";\nimport { EDGE_KINDS } from \"./kinds\";\nimport { meet } from \"./meet\";\nimport { less, type Ctx, type EdgeSpec, type Room, type DockRefusal, type Slot, type Span, type Tile } from \"./model\";\nimport type { Ownership } from \"./ownership\";\n\n/** How one edge makes its tiles: its band, the point a tile keeps, and a tile's split into owned part and overreach. */\ninterface Tiler {\n readonly band: (a: number, b: number, after?: DockLayout) => Rect;\n readonly keepAt: (line: number, h: Rect) => Point;\n readonly tile: (zone: Zone, hit: Rect, more: Pick<Tile, \"kind\" | \"id\" | \"order\" | \"priority\" | \"keep\"> & Partial<Tile>) => Tile;\n readonly split: (t: Tile) => Tile[];\n}\n\nfunction tilerOf(spec: EdgeSpec): Tiler {\n const data = EDGE_KINDS[spec.kind];\n const v = spec.vertical;\n const band = (a: number, b: number, after?: DockLayout): Rect => {\n const [c0, c1] = spec.across(after);\n return v ? rect(c0, a, c1 - c0, b - a) : rect(a, c0, b - a, c1 - c0);\n };\n // The point a tile keeps through clipping: on its line, in the middle of its band across.\n const keepAt = (line: number, h: Rect): Point => (v ? { x: h.x + h.width / 2, y: line } : { x: line, y: h.y + h.height / 2 });\n const tile: Tiler[\"tile\"] = (zone, hit, more) => ({ edge: spec.id, spec, edgeKind: spec.kind, vertical: v, zone, hit, ...more });\n // A tile's part across that its edge owns, and the rest, its overreach: clipped after the virtual edges, then joined\n // back where it still meets the owned part whole.\n const split = (t: Tile): Tile[] => {\n const h = t.hit;\n const [h0, h1] = v ? [h.x, h.x + h.width] : [h.y, h.y + h.height];\n const [c0, c1] = [Math.max(h0, spec.owned[0]), Math.min(h1, spec.owned[1])];\n const part = (a: number, b: number): Rect => (v ? rect(a, h.y, b - a, h.height) : rect(h.x, a, h.width, b - a));\n const beyond = less([[h0, h1]], [spec.owned]);\n if (beyond.length === 0) return [t];\n if (c1 - c0 <= EPS) return [{ ...t, order: data.overreach }];\n const core: Tile = { ...t, hit: part(c0, c1), keep: t.keep && keepAt(v ? t.keep.y : t.keep.x, part(c0, c1)) };\n return [core, ...beyond.map(([a, b]): Tile => ({ ...t, kind: \"reach\", of: core, order: data.overreach, hit: part(a, b), keep: null }))];\n };\n return { band, keepAt, tile, split };\n}\n\n/**\n * An edge that takes the dragged kind in no zone refuses it outright: one refusal (`refuse:<edge>:start`, `n = 0`) over\n * the edge's drawn rect (`DockLayout.edges[id].rect`, fixed items included), in the stage. Clipping cuts only what the\n * targets own from it, and a rail drop strip still takes its own rect. Null for any other edge (a zone that takes the\n * kind, an edge not drawn, the item's own edge).\n */\nfunction wholeRefusal(c: Ctx, spec: EdgeSpec): Tile | null {\n if (!spec.edge || spec.own || spec.holds || ZONES.some((z) => spec.refuse(z) !== \"not-accepted\")) return null;\n const drawn = c.now.edges[spec.id]?.rect;\n const hit = drawn ? meet(drawn, c.state.stage) : null;\n if (!hit) return null;\n const data = EDGE_KINDS[spec.kind];\n return { edge: spec.id, spec, edgeKind: spec.kind, vertical: spec.vertical, zone: \"start\", hit, kind: \"refuse\", id: \"\", order: data.layer, priority: data.priority, keep: null, reason: \"not-accepted\", whole: true };\n}\n\n/** Whether `spans` keep any length past `away`. */\nconst hasRoom = (spans: readonly Span[], away: readonly Span[]): boolean => less(spans, away).some(([a, b]) => b - a > EPS);\n\n/** Where each slot's line lies in one free piece of a zone: projected into it, or spread in order when lines collide. */\nfunction linesIn(spec: EdgeSpec, z: { a: number; b: number }, mine: readonly Slot[], pieces: readonly Span[], [pa, pb]: Span, own: Span | null): { inPiece: Slot[]; at: number[] } {\n const reserved = spec.reserved;\n // Lines spread into the zone's extent less its reserved rects when they lie past it: their share of the span the lines\n // and the extent cover, laid along the extent's free pieces end to end.\n const lines = mine.map((s) => s.line);\n const lo = Math.min(z.a, ...lines);\n const hi = Math.max(z.b, ...lines);\n const free = less([[z.a, z.b]], reserved);\n const freeLen = free.reduce((n, [a, b]) => n + (b - a), 0);\n const spread = (x: number): number => {\n if (hi - lo <= EPS || freeLen <= EPS) return x;\n let d = ((x - lo) / (hi - lo)) * freeLen;\n for (const [a, b] of free) {\n if (d <= b - a + EPS) return a + Math.min(d, b - a);\n d -= b - a;\n }\n return free[free.length - 1]![1];\n };\n // A line inside the own interval (an empty zone's anchor under the item) goes to the interval's nearer end. Lines\n // inside the extent stay where they are, one inside a reserved rect going to its nearer end.\n const past = lines.some((x) => x < z.a - EPS || x > z.b + EPS);\n const nearer = (p: number, [a, b]: Span): number => (p > a && p < b ? (p - a < b - p ? a : b) : p);\n // A line left outside the zone's pieces (under what another edge owns) goes to the nearest point of one.\n const proj = (x: number): number => {\n const q = reserved.reduce((r, s) => nearer(r, s), past ? spread(x) : x);\n const p = own ? nearer(q, own) : q;\n if (pieces.some(([a, b]) => p >= a - EPS && p <= b + EPS)) return p;\n return pieces.map(([a, b]) => Math.min(Math.max(p, a), b)).reduce((m, y) => (Math.abs(y - p) < Math.abs(m - p) ? y : m));\n };\n // Home's lines are the own interval's ends: each is a line only in the piece it bounds, never projected into another\n // (where it would fall on the other end's point and spread the piece's lines evenly).\n const ownEnd = (s: Slot): boolean => !!own && s.home && (Math.abs(s.line - own[0]) < EPS || Math.abs(s.line - own[1]) < EPS);\n const inPiece = mine\n .filter((s) => (ownEnd(s) ? s.line >= pa - EPS && s.line <= pb + EPS : proj(s.line) >= pa - EPS && proj(s.line) <= pb + EPS))\n .sort((a, b) => proj(a.line) - proj(b.line) || a.line - b.line);\n // Where projection lays two different moves on one point (lines under the item's home or another edge's), the piece's\n // lines are laid out in their order along it instead, one share each.\n const projected = inPiece.map((s) => proj(s.line));\n const at = projected.some((p, i) => i > 0 && p - projected[i - 1]! <= EPS) ? inPiece.map((_, i) => pa + ((i + 0.5) * (pb - pa)) / inPiece.length) : projected;\n return { inPiece, at };\n}\n\n/**\n * Reach only adds: a zone's room split into its own pieces (along the edge's length, `ends`) and the reach strips past\n * the edge's ends that another edge's band cuts off from them (`before` the edge's start, `after` its end). A strip takes\n * no slot's line, so reach never moves a zone's slot out of the zone's own span; the slot at that end of the zone takes\n * it as one more piece of its tile. Past an edge not drawn (an empty bar's band) the strip reaches on; past a drawn edge\n * (a bar holding items) it stops at that edge's side, so there is none. A zone with no room of its own keeps its room\n * as it is, strips and all (a virtual edge, with no `ends`, too).\n */\nfunction reachStrips(c: Ctx, spec: EdgeSpec, room: readonly Span[], ends: Span | null): { pieces: Span[]; before: Span[]; after: Span[] } {\n const inEdge = (s: Span): boolean => !!ends && s[0] < ends[1] - EPS && s[1] > ends[0] + EPS;\n const pieces = room.filter(inEdge);\n if (!ends || pieces.length === 0) return { pieces: [...room], before: [], after: [] };\n const [c0, c1] = spec.across();\n const bandOf = (a: number, b: number): Rect => (spec.vertical ? rect(c0, a, c1 - c0, b - a) : rect(a, c0, b - a, c1 - c0));\n // Whether a drawn edge across this one (a bar across a rail's end, not a column along it) lies over the band between `a` and `b`.\n const across = c.state.edges.filter((e) => (axisOf(e.side) === \"column\") !== spec.vertical).map((e) => c.now.edges[e.id]);\n const drawnBetween = (a: number, b: number): boolean => b - a > EPS && across.some((e) => !!e && e.cross > EPS && area(e.rect) > EPS && overlaps(e.rect, bandOf(a, b)));\n const first = pieces[0]![0];\n const last = pieces[pieces.length - 1]![1];\n return {\n pieces,\n before: room.filter((s) => s[1] <= ends[0] + EPS && !drawnBetween(s[1], first)),\n after: room.filter((s) => s[0] >= ends[1] - EPS && !drawnBetween(last, s[0])),\n };\n}\n\n/**\n * One edge's tiles, every kind alike: each zone's extent less the item's own interval, split halfway between its slots'\n * lines (projected into it), a slot's tile reaching at most its kind's `reach` from its line. A stretch with no slot is\n * refused (`spec.refuse`), a slot the filter removed is refused over its own tile, and the own interval is home's\n * (across, the edge's band and the own rect), named after the home slot when there is one. Where the item has no rect\n * on the edge, home's tile is its slot's.\n */\nexport function tileEdge(c: Ctx, spec: EdgeSpec, { cuts, bodies }: Room, lost: string[]): Tile[] {\n const whole = wholeRefusal(c, spec);\n if (whole) return [whole];\n const data = EDGE_KINDS[spec.kind];\n const v = spec.vertical;\n const own: Span | null = spec.own ? (v ? [spec.own.y, spec.own.y + spec.own.height] : [spec.own.x, spec.own.x + spec.own.width]) : null;\n const { band, keepAt, tile, split } = tilerOf(spec);\n // A zone's refusal keeps its slot's geometry, but never past the edge's ends (no `endReach`) nor past the stage.\n const drawn = spec.edge ? c.now.edges[spec.id]?.rect : undefined;\n const alongLimit = drawn && (v ? drawn.height : drawn.width) > EPS ? (v ? rect(-1e9, drawn.y, 2e9, drawn.height) : rect(drawn.x, -1e9, drawn.width, 2e9)) : null;\n const refused = (zone: Zone, hit: Rect, reason: DockRefusal[\"reason\"]): Tile[] => {\n const inEdge = alongLimit ? meet(hit, alongLimit) : hit;\n const shown = inEdge && meet(inEdge, c.state.stage);\n return shown ? split(tile(zone, shown, { kind: \"refuse\", id: \"\", order: data.layer, priority: data.priority, keep: null, reason })) : [];\n };\n const slots = distinctSlots(c, spec.slots);\n // The edge's reserved spans merged where they touch: a line strictly inside one is wedged between fixed items.\n const runs = [...spec.reserved].sort((p, q) => p[0] - q[0]).reduce<Span[]>((acc, [a, b]) => {\n const last = acc[acc.length - 1];\n if (last && a <= last[1] + EPS) acc[acc.length - 1] = [last[0], Math.max(last[1], b)];\n else acc.push([a, b]);\n return acc;\n }, []);\n const wedged = (line: number): boolean => runs.some(([a, b]) => line > a + EPS && line < b - EPS);\n // Home's slot where the item lies on this edge: its order is the aim that puts the item back.\n const homeSlot = spec.holds && own ? slots.find((s) => s.home && s.order !== undefined) : undefined;\n const ends: Span | null = alongLimit && drawn ? (v ? [drawn.y, drawn.y + drawn.height] : [drawn.x, drawn.x + drawn.width]) : null;\n const out: Tile[] = [];\n for (const z of spec.zones) {\n // The zone's extent less its reserved rects and what other edges own: a zone left with nothing has no slot.\n const room = less([[z.a, z.b]], [...cuts, ...spec.reserved]).filter(([a, b]) => b - a > EPS);\n // Less the own interval, which home owns: a zone wholly under the item's own place has no room left either.\n // Reach only adds: a stretch past the edge's ends cut off from the zone's own room is a reach strip, which takes no\n // line, so the zone's slots lie in its own span; it joins the outermost slot's tile on its side (`reachStrips`).\n const { pieces, before, after } = reachStrips(c, spec, own ? less(room, [own]) : room, ends);\n // Panel bodies don't split the pieces (the tiles run across them, clipping takes them out), but a zone whose room\n // is all bodies has no drop place.\n if (!hasRoom(pieces, bodies)) continue;\n // A slot with no room within its kind's reach of its line isn't offered.\n // On the item's own edge the home slot's line is the own interval itself: it lies at both of its ends, so the gaps\n // right beside the item (the same move as home) are home's. In its » menu the item has no interval: home is only\n // its entry.\n const lined = slots.flatMap((s) => (spec.holds && s.home ? (own ? [{ ...s, line: own[0] }, { ...s, line: own[1] }] : []) : [s]));\n // A slot whose line lies between two fixed items (inside a run of reserved spans, not at its ends) has no place a\n // pointer can aim at: a drop there would push fixed items the pointer never sees apart. It gets no tile, so its\n // order's stretch beside the run stays with the slot at the run's end (the card's leading half is \"before it\").\n const mine = lined.filter((s) => s.zone === z.zone && !wedged(s.line) && pieces.some(([a, b]) => b > s.line - data.reach + EPS && a < s.line + data.reach - EPS));\n const reason = spec.refuse(z.zone);\n for (const [k, [pa, pb]] of pieces.entries()) {\n const { inPiece, at } = linesIn(spec, z, mine, pieces, [pa, pb], own);\n // The reach strips the slot at each end of this piece takes: those before the zone's first piece, after its last.\n const stripsOf = (i: number): Span[] => [...(k === 0 && i === 0 ? before : []), ...(k === pieces.length - 1 && i === inPiece.length - 1 ? after : [])];\n if (inPiece.length === 0) {\n // A stretch of a zone with no slot of its own is refused: home is only over the item's own place, and no stretch\n // is handed to another zone's slot. Beside a lone item (the zone's only slot is home) there is room, but no\n // place other than its own: `own-place`.\n // A stretch out of every slot's reach is no part of this edge.\n // (The zone takes the kind: its refusal is for want of room, `no-room` or `too-thick`.)\n const lone = (reason === \"no-room\" || reason === \"too-thick\") && mine.length === 0 && slots.some((s) => s.zone === z.zone && s.home);\n // (A virtual edge's zone is its slot's reach already: all of it is near.)\n const near = mine.length === 0 || data.virtual || mine.some((s) => pb > s.line - data.reach + EPS && pa < s.line + data.reach - EPS);\n // A virtual edge's stretch cut off from its line by another edge's owned band (the rail stop between a column\n // line and the window's inset) is still that line's: there is room and a slot, so it is no refusal. It joins the\n // nearest fitting slot of the zone as one more piece of its tile (the zone's extent already bounds it).\n const joins = data.virtual ? mine.filter((s) => s.ok && !s.home) : [];\n if (joins.length > 0) {\n const s = joins.reduce((m, x) => (Math.abs(x.line - (pa + pb) / 2) < Math.abs(m.line - (pa + pb) / 2) ? x : m));\n const hit = band(pa, pb, s.result.layout);\n out.push(...split(tile(z.zone, hit, { kind: \"slot\", id: s.id, order: data.layer, priority: data.priority, keep: keepAt(Math.min(Math.max(s.line, pa), pb), hit), place: s.place, result: s.result, marker: spec.marker(s), slot: s.result.layout.items[c.dragged]!.rect })));\n continue;\n }\n if (reason && near) out.push(...refused(z.zone, band(pa, pb), lone ? \"own-place\" : reason));\n continue;\n }\n // Where two neighboring slots meet: at the midpoint of the item between their lines (the one item a pointer\n // aims at there: its leading half is the place before it, its trailing half the place after it), else halfway\n // between the lines.\n // (The item lies between the lines as seen, before projection: a line past the piece, under another edge's band,\n // still bounds it.)\n const meet = (i: number): number => {\n const [lo, hi] = [at[i - 1]!, at[i]!];\n const between = spec.cards.filter(([u, w]) => u >= inPiece[i - 1]!.line - EPS && w <= inPiece[i]!.line + EPS);\n const mid = between.length === 1 ? (between[0]![0] + between[0]![1]) / 2 : NaN;\n return mid > lo + EPS && mid < hi - EPS ? mid : (lo + hi) / 2;\n };\n inPiece.forEach((s, i) => {\n // The meeting points with the neighboring slots, the piece's ends at its ends (the own interval's ends are one),\n // and no further from its line than the kind's reach (a virtual edge's zone is that reach already: an outermost\n // column line's zone runs from the window's edge, past where the line's reach would end).\n const p = at[i]!;\n const lim = data.virtual ? Infinity : data.reach;\n const a = Math.max(i === 0 ? pa : meet(i), p - lim);\n const b = Math.min(i === inPiece.length - 1 ? pb : meet(i + 1), p + lim);\n if (b - a <= EPS) {\n if (s.ok && !s.home) lost.push(s.id);\n return;\n }\n // A tile wholly over panel bodies has no drop place: the slot has no room here, so it isn't offered.\n if (!hasRoom([[a, b]], bodies)) return;\n const homeTile = (id: string, u: number, w: number, line: number): Tile => {\n const hit = band(u, w, s.home ? s.result.layout : undefined);\n return tile(z.zone, hit, { kind: \"home\", id, order: data.layer, priority: spec.homePriority ?? data.priority, keep: keepAt(Math.min(Math.max(line, u), w), hit), place: { kind: \"home\" } });\n };\n if (s.home) {\n for (const [u, w] of [[a, b], ...stripsOf(i)] as Span[]) out.push(...split(homeTile(s.id, u, w, p)));\n return;\n }\n // A slot of home's order in another zone is the same aim as home over the items it faces: their halves are\n // home's; the rest of its tile, the free stretch beside them, is its own (the item re-aligned, its order kept).\n const faced = homeSlot && s.order === homeSlot.order ? spec.cards.filter(([u, w]) => w > a + EPS && u < b - EPS) : [];\n for (const [u, w] of faced) out.push(...split(homeTile(homeSlot!.id, Math.max(u, a), Math.min(w, b), p)));\n for (const [u, w] of [...less([[a, b]], faced), ...stripsOf(i)]) {\n const line = Math.min(Math.max(p, u), w);\n const hit = band(u, w, s.result.layout);\n if (!s.ok) out.push(...refused(z.zone, hit, roomReason(spec, z.zone)));\n else out.push(...split(tile(z.zone, hit, { kind: \"slot\", id: s.id, order: data.layer, priority: data.priority, keep: keepAt(line, hit), place: s.place, result: s.result, marker: spec.marker(s), slot: s.result.layout.items[c.dragged]!.rect })));\n }\n });\n }\n }\n if (own && spec.own) {\n const home = spec.slots.find((s) => s.home);\n // Across the edge's band and the own rect where it lies now: home's wherever the lift moves things (nothing clips\n // it). A slot's id and priority; `home:<id>` (1) when no slot is home.\n const [a, b] = own;\n const h = band(a, b);\n const o = spec.own;\n const hit = v ? rect(Math.min(h.x, o.x), a, Math.max(h.x + h.width, o.x + o.width) - Math.min(h.x, o.x), b - a) : rect(a, Math.min(h.y, o.y), b - a, Math.max(h.y + h.height, o.y + o.height) - Math.min(h.y, o.y));\n out.push(tile(home?.zone ?? zoneOf(c.state.items[c.dragged]), hit, { kind: \"home\", id: home ? home.id : targetId({ kind: \"home\", item: c.dragged }), order: 0, priority: home ? data.priority : 1, keep: null, place: { kind: \"home\" } }));\n }\n return out;\n}\n\nconst clip = (r: Rect, cuts: readonly Rect[]): Rect[] => cuts.reduce<Rect[]>((ps, cut) => ps.flatMap((p) => subtract(p, cut)), [r]);\n/** Every rect a placed tile covers: its pieces, else its hit. */\nconst coverOf = (t: Tile): readonly Rect[] => t.hits ?? [t.hit];\nconst largest = (ps: readonly Rect[]): Rect => ps.reduce((a, p) => (area(p) > area(a) ? p : a));\n/** `t` with these pieces: `hit` the largest, `hits` all of them when there is more than one. */\nconst withPieces = (t: Tile, ps: readonly Rect[]): Tile => {\n const { hits: _h, ...rest } = t;\n return { ...rest, hit: largest(ps), ...(ps.length > 1 ? { hits: ps } : {}) };\n};\n\n/** An overreach tile `t` placed: joined to its owned part where it meets that part whole, or standing in for it. */\nfunction placeReach(t: Tile, pieces: readonly Rect[], placed: Tile[], landed: ReadonlyMap<Tile, number[]>, gone: Set<Tile>): void {\n const of = t.of!;\n const at = landed.get(of) ?? [];\n if (at.length === 0 && gone.has(of)) {\n // Its owned part went whole: the overreach stands in for it, the piece on its line (else its largest).\n const line = t.vertical ? of.keep!.y : of.keep!.x;\n const whole = pieces.filter((p) => p.width >= 1 && p.height >= 1);\n const on = whole.filter((p) => (t.vertical ? p.y <= line + EPS && line <= p.y + p.height + EPS : p.x <= line + EPS && line <= p.x + p.width + EPS));\n const kept = (on.length > 0 ? on : whole).reduce<Rect | null>((a, p) => (!a || area(p) > area(a) ? p : a), null);\n if (kept) {\n placed.push({ ...of, hit: kept });\n gone.delete(of);\n }\n return;\n }\n for (const i of at) {\n // Joined to the first piece of the owned part it meets along that piece's whole length.\n const cover = coverOf(placed[i]!);\n for (let k = 0; k < cover.length; k++) {\n const h = cover[k]!;\n const joint = pieces.find((p) =>\n t.vertical\n ? p.y <= h.y + EPS && p.y + p.height >= h.y + h.height - EPS && (Math.abs(p.x - h.x - h.width) < EPS || Math.abs(p.x + p.width - h.x) < EPS)\n : p.x <= h.x + EPS && p.x + p.width >= h.x + h.width - EPS && (Math.abs(p.y - h.y - h.height) < EPS || Math.abs(p.y + p.height - h.y) < EPS),\n );\n if (!joint) continue;\n const merged = t.vertical\n ? rect(Math.min(h.x, joint.x), h.y, Math.max(h.x + h.width, joint.x + joint.width) - Math.min(h.x, joint.x), h.height)\n : rect(h.x, Math.min(h.y, joint.y), h.width, Math.max(h.y + h.height, joint.y + joint.height) - Math.min(h.y, joint.y));\n placed[i] = cover.length > 1 ? withPieces(placed[i]!, cover.map((r, j) => (j === k ? merged : r))) : { ...placed[i]!, hit: merged };\n return;\n }\n }\n}\n\n/** A refused tile, or the overreach of one. */\nconst isRefused = (t: Tile): boolean => t.kind === \"refuse\" || (t.kind === \"reach\" && t.of!.kind === \"refuse\");\n\n/**\n * Filter (iii), clipping in precedence order: each tile clear of the ones before it, of the other edges' seen rects, of\n * the fixed items that don't grow and of the chrome. Returns the tiles placed;\n * slots whose every part went are added to `lost`.\n *\n * A slot the filter removed owns nothing against other edges: every surviving tile is placed first, in precedence\n * order, and the refused tiles (with their overreach and the clipped-off pieces of slots) then take what is left, in\n * the same order. Within its own edge a refusal keeps its tile: an edge's tiles never overlap each other.\n */\nexport function clipTiles(tiles: readonly Tile[], own: Ownership, chrome: readonly Rect[], lost: string[]): Tile[] {\n const { owners, taken, bodies, solid } = own;\n /** Every other edge's owned rects: what a refusal (which owns nothing) and an overreach yield to. */\n const bySpec = new Map<EdgeSpec | null, Rect[]>();\n const others = (t: Tile): Rect[] => {\n let rs = bySpec.get(t.spec);\n if (!rs) bySpec.set(t.spec, (rs = owners.filter((o) => o.spec !== t.spec).map((o) => o.rect)));\n return rs;\n };\n const besides = (t: Tile): readonly Rect[] => (t.spec ? own.drawnBesides(t.spec) : []);\n const bodiesOf = (t: Tile): Rect[] => (t.spec ? bodies(t.spec) : []);\n const placed: Tile[] = [];\n // A virtual edge's refused stretches (its refused slots, its slots' clipped-off pieces) come after every other tile:\n // they take only what no tile takes, never a real edge's room.\n const later: Tile[] = [];\n // A real edge's refused stretches, placed once every surviving tile is.\n const refused: Tile[] = tiles.filter(isRefused);\n // Where each owned part landed in `placed` (its overreach joins it there), and the slots whose owned part went whole.\n const landed = new Map<Tile, number[]>();\n const gone = new Set<Tile>();\n const place = (t: Tile): void => {\n // Home's tile is the item's own place: nothing clips it.\n if (t.order === 0) {\n placed.push(t);\n return;\n }\n // A wholly refused edge: its drawn rect less only what is placed (the targets, and refusals placed before it), one\n // refusal with every piece of 1 px and more each way (`hits`, `hit` the largest): a target in the middle of a bar\n // leaves the refusal on both sides of it.\n if (t.whole) {\n const pieces = clip(t.hit, placed.flatMap(coverOf)).filter((p) => p.width >= 1 && p.height >= 1);\n if (pieces.length > 0) placed.push(withPieces(t, pieces));\n return;\n }\n const data = EDGE_KINDS[t.edgeKind];\n if (data.virtual && t.kind === \"refuse\") {\n later.push(t);\n return;\n }\n if (t.kind === \"reach\") {\n // Overreach: what the virtual edges and every other edge's owned rect leave, joined to its owned part where it\n // meets that part along the part's whole length. The rest is nobody's (the float's).\n placeReach(t, clip(t.hit, [...placed.flatMap(coverOf), ...others(t), ...bodiesOf(t), ...solid, ...chrome]), placed, landed, gone);\n return;\n }\n // An owned part: clear of the tiles before it, of the owners that win over its edge, its panel bodies, solid items\n // and chrome. A virtual edge's tile: clear of the tiles before it and of every owner. A refusal owns nothing: it\n // yields to every other edge's owned rect too.\n const yields = t.kind === \"refuse\" ? besides(t) : [];\n // Panel bodies are no drop places: they cut slots' tiles, never refusals (an edge that takes nothing, a thumbnail\n // strip, refuses its whole seen rect).\n const cuts = [...placed.flatMap(coverOf), ...((t.spec && taken.get(t.spec)) ?? []), ...yields, ...(data.virtual || t.kind === \"refuse\" ? [] : bodiesOf(t)), ...solid, ...chrome];\n const pieces = clip(t.hit, cuts);\n if (pieces.length === 0) {\n if (t.kind !== \"refuse\") gone.add(t);\n return;\n }\n if (t.kind === \"refuse\") {\n landed.set(t, pieces.map((_, k) => placed.length + k));\n for (const p of pieces) placed.push({ ...t, hit: p });\n return;\n }\n // Clipping changes a slot's shape, never who owns the stretch: whatever is left of its tile stays the slot's, every\n // piece (`hits`, `hit` the largest), so clipping never leaves a hole the float fills nor a refusal in the slot's room.\n // No sliver, after ownership: a piece under 1 px either way is no part of a target (it is refused), and a slot left\n // with no other piece is no target. Under 1 px is no room (as in a zone's room), so the slot isn't lost: its line\n // lay where its neighbors left it no place.\n const solidPieces = pieces.filter((p) => p.width >= 1 && p.height >= 1);\n for (const p of pieces) if (!solidPieces.includes(p)) (data.virtual ? later : refused).push({ ...t, kind: \"refuse\", reason: t.spec ? roomReason(t.spec, t.zone) : \"no-room\", hit: p, keep: null });\n if (solidPieces.length === 0) return;\n landed.set(t, [placed.length]);\n placed.push(withPieces(t, solidPieces));\n };\n const byOrder = (a: Tile, b: Tile): number => a.order - b.order;\n for (const t of tiles.filter((x) => !isRefused(x)).sort(byOrder)) place(t);\n for (const t of refused.sort(byOrder)) place(t);\n // Home is never lost: its own rect carries it.\n for (const t of gone) if (t.kind !== \"home\") lost.push(t.id);\n for (const t of later) for (const p of clip(t.hit, [...placed.flatMap(coverOf), ...besides(t), ...solid, ...chrome])) placed.push({ ...t, hit: p });\n return placed;\n}\n","/**\n * The rail drop strips (`DockState.railDrop`): for a kind with a policy, each side whose rail can take it gets one drop\n * strip at the window's side, at the rail's width (`railStripWidth`), even while the rail is empty. Its targets,\n * `rail:<side>:<ring>`, are spring-loaded (`arm: \"dwell\"`), grow by `magnet` once armed (`armedHit`) and carry the\n * strip to draw (`strip`). The strip owns its rect: every other target and refusal of the drag gives it up (home's\n * too: an item alone in its column reaches its side's rail through the strip), so a drop there is the rail's once armed\n * and the float's before. A target the strip covers whole isn't offered: over the rail, the kind collapses into it.\n *\n * The side's rail is one concept: `DockState.rails[side]` where the state declares one (the strip split along it at its\n * stops, `railStops`), else the side's outermost column that takes the kind in its start zone (`railColumnOf`). The\n * strip means \"collapse it at this side\": its drop is `moveTo` that side's rail, landing wherever the state's hand fold\n * shows a collapsed panel there (a rail tile, a rider bar over the side's open column, a header in its column).\n */\nimport { EPS, overlaps, rect, subtract, type Point, type Rect } from \"@n-uf/placement\";\nimport { markUsed, moveAmong, type RailPlace } from \"../changes\";\nimport { isHandFolded, railColumnOf, railPolicyOf, zoneTakes } from \"../helpers\";\nimport { RAIL_STRIP_MIN } from \"../model\";\nimport { targetId, virtualEdgeId } from \"./ids\";\nimport type { Ctx, DropResult, DockRefusal, DockDrop } from \"./model\";\nimport { collapsesAt, railOuter, railStops } from \"./virtual\";\n\ntype Policy = NonNullable<ReturnType<typeof railPolicyOf>>;\n\n/** One side's strip and its slots along it, each with its stretch and its drop. */\ninterface Strip {\n readonly side: \"left\" | \"right\";\n readonly rect: Rect;\n readonly slots: readonly { readonly id: string; readonly place: RailPlace; readonly along: readonly [number, number]; readonly result: DropResult }[];\n}\n\n/** The strip's x and width: `width` px from the side's outer boundary `outer`, inward. */\nconst across = (side: \"left\" | \"right\", outer: number, width: number): [number, number] => (side === \"left\" ? [outer, width] : [outer - width, width]);\n\n\n/** A side with no declared rail: its rail column, the item docked in it collapsed (`moveTo` its rail). */\nfunction columnStrip(c: Ctx, side: \"left\" | \"right\", policy: Policy): Strip | null {\n const edge = railColumnOf(c.state, side, c.kind);\n if (!edge) return null;\n const own = c.now.items[c.dragged];\n // Already collapsed in this column: every drop into it is home.\n if (own?.edge === edge.id && isHandFolded(c.state, c.dragged)) return null;\n const place: RailPlace = { kind: \"rail\", side, ring: edge.ring };\n const moved = moveAmong(c.state, c.dragged, place, c.others);\n if (moved === c.state) return null;\n const result = c.settle(markUsed(moved, c.dragged));\n const el = result.layout.edges[edge.id];\n if (!el || el.rect.width <= EPS || !collapsesAt(c, result, side)) return null;\n const r = el.rect;\n // The rail's width: the column's drawn as a rail (a tile there), else the width it takes as one.\n const railWidth = result.layout.items[c.dragged]!.tab ? r.width : (edge.cross.rail ?? 30);\n const [x, w] = across(side, side === \"left\" ? r.x : r.x + r.width, policy.railStripWidth ?? Math.max(RAIL_STRIP_MIN, railWidth));\n return { side, rect: rect(x, r.y, w, r.height), slots: [{ id: targetId({ kind: \"rail\", side, ring: edge.ring }), place, along: [r.y, r.y + r.height], result }] };\n}\n\n/** A side with a declared rail (`DockState.rails`): its stops (`railStops`), the strip split halfway between them. */\nfunction declaredStrip(c: Ctx, side: \"left\" | \"right\", policy: Policy): Strip | null {\n const template = c.state.columns?.[side];\n const spec = c.state.rails?.[side];\n if (!template || !spec || !zoneTakes(template, \"start\", c.kind) || !spec.accepts.includes(c.kind)) return null;\n const stops = railStops(c, side);\n // A stop's drop collapses the item at this side wherever the state's `handFold` shows it (in the rail, or riding over\n // the side's open column): the strip means \"collapse it here\", whether a rail is drawn now or not.\n const slots = (stops?.slots ?? []).filter((s) => !s.home && s.place.kind === \"rail\" && collapsesAt(c, s.result, side)).sort((a, b) => a.line - b.line);\n if (!stops || slots.length === 0) return null;\n const a = Math.min(...stops.zones.map((z) => z.a));\n const b = Math.max(...stops.zones.map((z) => z.b));\n const drawn = c.now.rails[side];\n const outer = drawn && drawn.segments.length > 0 ? (side === \"left\" ? drawn.rect.x : drawn.rect.x + drawn.rect.width) : railOuter(c, side);\n const [x, w] = across(side, outer, policy.railStripWidth ?? Math.max(RAIL_STRIP_MIN, spec.width));\n const cuts = [a, ...slots.slice(1).map((s, i) => (slots[i]!.line + s.line) / 2), b];\n return {\n side,\n rect: rect(x, a, w, b - a),\n slots: slots.map((s, i) => ({ id: s.id, place: s.place as RailPlace, along: [cuts[i]!, cuts[i + 1]!] as const, result: s.result })),\n };\n}\n\n/** Pieces of `pieces` left once every strip is taken out; under 1 px either way is no piece. */\nconst outside = (pieces: readonly Rect[], strips: readonly Rect[]): Rect[] =>\n strips.reduce<Rect[]>((acc, s) => acc.flatMap((p) => (overlaps(p, s) ? subtract(p, s) : [p])), [...pieces]).filter((p) => p.width >= 1 && p.height >= 1);\nconst largest = (rs: readonly Rect[]): Rect => rs.reduce((m, r) => (r.width * r.height > m.width * m.height ? r : m));\nconst sameRects = (a: readonly Rect[], b: readonly Rect[]): boolean => a.length === b.length && a.every((r, i) => r.x === b[i]!.x && r.y === b[i]!.y && r.width === b[i]!.width && r.height === b[i]!.height);\n\n/**\n * The drag's targets and refusals with the kind's rail drop strips laid over them (unchanged for a kind with no policy),\n * and the strips.\n */\nexport function withRailStrips(c: Ctx, targets: readonly DockDrop[], refusals: readonly DockRefusal[]): { targets: DockDrop[]; refusals: DockRefusal[]; strips: Rect[] } {\n // A strip means \"collapse it at this side\": under `foldedColumnDrop` no drop changes an item's state.\n const policy = c.state.foldedColumnDrop === \"end\" ? null : railPolicyOf(c.state, c.kind);\n const strips = policy ? ([\"left\", \"right\"] as const).map((side) => (c.state.rails?.[side] ? declaredStrip(c, side, policy) : columnStrip(c, side, policy))).filter((s): s is Strip => s !== null) : [];\n if (!policy || strips.length === 0) return { targets: [...targets], refusals: [...refusals], strips: [] };\n const sides = new Set(strips.map((s) => s.side));\n const rects = strips.map((s) => s.rect);\n const out: DockDrop[] = [];\n /** The new-outermost-column lines moved inside a strip, by side: the inner columns' gaps there give them up. */\n const lines: { side: \"left\" | \"right\"; pieces: Rect[] }[] = [];\n for (const t of targets) {\n // The rail's own tiled stops give way to its strip.\n if (t.place.kind === \"rail\" && sides.has(t.place.side)) continue;\n if (t.free || t.place.kind === \"none\") {\n out.push(t.free && !policy.floatNearEdge ? clearOfStrips(t, c.dragged, rects) : t);\n continue;\n }\n const was = t.hits ?? [t.hit];\n const pieces = outside(was, rects);\n if (pieces.length === 0) {\n // An empty edge's drop strip under the rail's (an empty column, where the side's rail would be too), or the line for\n // a new outermost column on an occupied side (flush, the strip owns the window's edge), moves just inside it: the\n // rail lies outermost, the column opens from beside it, and the column's own gaps lie after.\n let moved = t.id.startsWith(\"strip:\") || t.place.kind === \"column\" ? insideStrips(t.hit, strips) : null;\n let movedPieces: Rect[] = moved ? [moved] : [];\n if (moved && t.place.kind === \"column\") {\n // It keeps the band it owns: a column line beats the inner column it would push, card halves included (ranked\n // by the laying order of the new column it stands for). Moved inside the strip, it gives way only to home, a\n // blocked rect and the other column lines; the inner columns' gaps and refusals on its side give it up below\n // (`lines`), so it is never cut away.\n const others = targets.filter((x) => x !== t && (x.place.kind === \"home\" || x.place.kind === \"column\" || (x.place.kind === \"none\" && !x.free))).flatMap((x) => x.hits ?? [x.hit]);\n movedPieces = outside([moved], others);\n moved = movedPieces.length ? largest(movedPieces) : null;\n if (moved) lines.push({ side: t.place.side, pieces: movedPieces });\n }\n if (moved) out.push({ ...withoutHits(t), hit: moved, ...(movedPieces.length > 1 ? { hits: movedPieces } : {}) });\n continue;\n }\n if (sameRects(pieces, was)) {\n out.push(t);\n continue;\n }\n out.push({ ...withoutHits(t), hit: largest(pieces), ...(pieces.length > 1 ? { hits: pieces } : {}) });\n }\n // The inner columns' gaps (and refusals) on a moved line's side stop short of it: the line owns its band.\n const columnSide = (edge: string): \"left\" | \"right\" | null => {\n const e = c.state.edges.find((x) => x.id === edge);\n return e?.column && (e.side === \"left\" || e.side === \"right\") ? e.side : null;\n };\n const lineCut = (edge: string): Rect[] => lines.filter((l) => l.side === columnSide(edge)).flatMap((l) => l.pieces);\n for (let i = 0; i < out.length; i++) {\n const t = out[i]!;\n if (t.place.kind !== \"gap\") continue;\n const cut = lineCut(t.place.edge);\n if (!cut.length) continue;\n const was = t.hits ?? [t.hit];\n const pieces = outside(was, cut);\n if (sameRects(pieces, was)) continue;\n if (pieces.length === 0) out.splice(i--, 1);\n else out[i] = { ...withoutHits(t), hit: largest(pieces), ...(pieces.length > 1 ? { hits: pieces } : {}) };\n }\n const refused: DockRefusal[] = [];\n // The rail's own refusals go with its stops: the strip offers only the stops that take the drop.\n const railEdges = new Set([...sides].map((side) => virtualEdgeId(\"rail\", side)));\n for (const r of refusals) {\n if (railEdges.has(r.edge)) continue;\n const was = r.hits ?? [r.hit];\n const pieces = outside(was, [...rects, ...lineCut(r.edge)]);\n if (!pieces.length || sameRects(pieces, was)) {\n if (pieces.length) refused.push(r);\n continue;\n }\n // A refusal in pieces (a wholly refused edge) keeps every piece of 1 px and more; any other keeps its largest.\n const kept = r.hits ? pieces.filter((p) => p.width >= 1 && p.height >= 1) : [largest(pieces)];\n const { hits: _h, ...one } = r;\n if (kept.length) refused.push({ ...one, hit: largest(kept), ...(kept.length > 1 ? { hits: kept } : {}) });\n }\n // A zone's refusals stay numbered by where they lie along the edge (then across it), as cut.\n const vertical = (r: DockRefusal): boolean => {\n const side = c.state.edges.find((e) => e.id === r.edge)?.side;\n // A virtual edge: the rail runs down, the column lines across.\n return side ? side === \"left\" || side === \"right\" : r.edge === virtualEdgeId(\"rail\", \"left\") || r.edge === virtualEdgeId(\"rail\", \"right\");\n };\n const pos = (r: DockRefusal): [number, number] => (vertical(r) ? [r.hit.y, r.hit.x] : [r.hit.x, r.hit.y]);\n const groups = new Map<string, DockRefusal[]>();\n for (const r of refused) groups.set(`${r.edge}\\n${r.zone}`, [...(groups.get(`${r.edge}\\n${r.zone}`) ?? []), r]);\n const numbered = new Map<DockRefusal, string>();\n for (const group of groups.values())\n group\n .sort((a, b) => pos(a)[0] - pos(b)[0] || pos(a)[1] - pos(b)[1])\n .forEach((r, n) => numbered.set(r, targetId({ kind: \"refuse\", edge: r.edge, zone: r.zone, n })));\n const renumbered = refused.map((r) => (numbered.get(r) === r.id ? r : { ...r, id: numbered.get(r)! }));\n for (const s of strips) {\n const grown = s.side === \"left\" ? rect(s.rect.x, s.rect.y, s.rect.width + policy.magnet, s.rect.height) : rect(s.rect.x - policy.magnet, s.rect.y, s.rect.width + policy.magnet, s.rect.height);\n for (const sl of s.slots) {\n const [a, b] = sl.along;\n const slot = sl.result.layout.items[c.dragged]!.rect;\n const result = sl.result;\n out.push({\n id: sl.id,\n priority: 1,\n hit: rect(s.rect.x, a, s.rect.width, b - a),\n armedHit: rect(grown.x, a, grown.width, b - a),\n arm: \"dwell\",\n // Armed, its room opens at once: a host that draws only a marker reads that from this one flag, as for any target.\n opensRoom: true,\n strip: s.rect,\n slot,\n item: c.dragged,\n place: sl.place,\n after: () => result,\n });\n }\n }\n return { targets: out, refusals: renumbered, strips: rects };\n}\n\nconst withoutHits = (t: DockDrop): DockDrop => {\n const { hits: _pieces, ...rest } = t;\n return rest;\n};\n\n/** `r` moved inward just past the strip of its side that covers it, or null when none does. */\nfunction insideStrips(r: Rect, strips: readonly Strip[]): Rect | null {\n const s = strips.find((x) => overlaps(x.rect, r));\n if (!s) return null;\n return s.side === \"left\" ? rect(s.rect.x + s.rect.width, r.y, r.width, r.height) : rect(s.rect.x - r.width, r.y, r.width, r.height);\n}\n\n/** The float target with its landing kept clear of every strip (`floatNearEdge: false`): pushed inward past it. */\nfunction clearOfStrips(t: DockDrop, dragged: string, strips: readonly Rect[]): DockDrop {\n return {\n ...t,\n after(point: Point, grab?: Point): DropResult {\n const first = t.after(point, grab);\n const at = first.layout.items[dragged]?.rect;\n if (!at) return first;\n let dx = 0;\n for (const s of strips) {\n const r = rect(at.x + dx, at.y, at.width, at.height);\n if (!overlaps(r, s)) continue;\n // A strip at the left pushes it right, one at the right pushes it left.\n dx += s.x + s.width / 2 < r.x + r.width / 2 ? s.x + s.width - r.x : s.x - (r.x + r.width);\n }\n // The pointer that puts the float's left edge where it lands, moved past the strips (the landing may be clamped).\n return dx === 0 ? first : t.after({ x: at.x + dx + (grab?.x ?? at.width / 2), y: point.y }, grab);\n },\n };\n}\n","/**\n * Generation, the virtual edges of a side: its column lines (a new column on each, along x) and its rail (docking\n * folded into it, along y), tiled as every edge is.\n */\nimport { EPS, clamp, rect, type Rect } from \"@n-uf/placement\";\nimport { sideRings } from \"../changes\";\nimport { formsOf, isHandFolded, isSideColumn, zoneOf } from \"../helpers\";\nimport type { DockEdge } from \"../model\";\nimport { railColumnSpec, slotAt, thickerThan } from \"./edges\";\nimport { targetId, virtualEdgeId } from \"./ids\";\nimport { EDGE_KINDS, RAIL_EDGE } from \"./kinds\";\nimport type { Ctx, EdgeSpec, DropResult, Slot, Span } from \"./model\";\n\n/**\n * A side's rings as a place counts them, with the item lifted, for lines that lie in the seen geometry: `before(e)`,\n * just outside the seen edge `e`; `after(e)`, just inside it. The item's own column, which the lift deletes, counts\n * no ring: both lines about it are one place (home's).\n */\nfunction ringsOf(c: Ctx, side: \"left\" | \"right\"): { before: (e: DockEdge) => number; after: (e: DockEdge) => number; count: number } {\n const seen = sideRings(c.state.edges, side);\n const kept = c.rest.edges.filter((e) => e.side === side).map((e) => seen.get(e.id) ?? e.ring);\n const at = (e: DockEdge): number => seen.get(e.id) ?? e.ring;\n return { before: (e) => kept.filter((r) => r < at(e)).length, after: (e) => kept.filter((r) => r <= at(e)).length, count: kept.length };\n}\n\n/**\n * Where the side's undrawn rail stop starts, across: the window's edge (an inset's strip included), or, with drawn edges\n * of the side lying outside the rail's place (its outside bars), the rail place's outer side, flush after them.\n */\nexport function railOuter(c: Ctx, side: \"left\" | \"right\"): number {\n const { now, state } = c;\n const place = now.railPlaces[side];\n const windowEdge = side === \"left\" ? state.stage.x : state.stage.x + state.stage.width;\n if (!place) return windowEdge;\n const placeOuter = side === \"left\" ? place.x : place.x + place.width;\n const barOutside = Object.values(now.edges).some((e) => e.side === side && e.rect.width > 0 && e.rect.height > 0 && (side === \"left\" ? e.rect.x + e.rect.width <= placeOuter + EPS : e.rect.x >= placeOuter - EPS));\n return barOutside ? placeOuter : windowEdge;\n}\n\n/**\n * The one rule for \"collapse it at this side\": whether a drop's result has the item folded by hand and drawn at `side`,\n * wherever the state's `handFold` shows a collapsed panel there (a tile in a rail, a rider bar over the side's first\n * open column, a header in its column); not home, and the window fits. The rail strip and an occupied rail's stops\n * both land by it.\n */\nexport function collapsesAt(c: Ctx, result: DropResult, side: \"left\" | \"right\"): boolean {\n const me = result.layout.items[c.dragged];\n if (!me || me.floating || me.inMenu || !isHandFolded(result.state, c.dragged) || c.isHome(result) || !c.sound(result.layout)) return false;\n const sideOf = (edgeId: string | undefined): string | undefined => (edgeId ? result.layout.edges[edgeId]?.side : undefined);\n return me.rail === side || sideOf(me.rides) === side || sideOf(me.edge) === side;\n}\n\n/**\n * The side's column lines as an edge (virtual, along x): a slot on each line for a new column there, tiled as every\n * edge is (its kind's `reach` each way at most), down the columns' stretch. The lines lie where the user sees the\n * columns; each counts its ring with the item lifted.\n */\nexport function columnLines(c: Ctx, side: \"left\" | \"right\", railLands: boolean): EdgeSpec[] {\n const { state, now, dragged } = c;\n // `sideColumns: \"one\"`: a side that keeps a column with the item lifted offers no new one. A declared column edge (not a\n // dynamic one, which an empty column loses) is the side's column whether it holds items or not: empty, or emptied by the\n // lift, it keeps its box and a drop there lands in it, so its place is that column's, not a new column's on the same line.\n if (state.sideColumns === \"one\" && c.rest.edges.some((e) => e.side === side && isSideColumn(c.rest, e) && (e.items.length > 0 || e.column !== true))) return [];\n const cols = state.edges\n .filter((e) => e.side === side && e.column === true)\n .map((edge) => ({ edge, l: now.edges[edge.id] }))\n .filter((x) => x.l && !x.l.folded && !x.l.rides && x.l.cross > 0)\n .sort((a, b) => a.edge.ring - b.edge.ring)\n .map((x) => ({ edge: x.edge, r: x.l!.rect }));\n const own = Object.values(now.edges).filter((e) => e.side === side && e.rect.height > 0);\n const span = own[0]?.rect ?? now.content;\n // Rings as the side's edges lie (no ties): a static edge outer to the columns keeps its place.\n const rings = ringsOf(c, side);\n // Each line with the place a new column there would take in `solve`'s laying order: just before the column it lies\n // outside of (which it would push), just after the innermost (or every edge of the side, with no column).\n const lines: { x: number; ring: number; at: number }[] = [];\n const outerX = (r: Rect): number => (side === \"left\" ? r.x : r.x + r.width);\n const innerX = (r: Rect): number => (side === \"left\" ? r.x + r.width : r.x);\n const atOf = (e: DockEdge): number => c.lay.get(e.id)?.at ?? 0;\n cols.forEach((x) => lines.push({ x: outerX(x.r), ring: rings.before(x.edge), at: atOf(x.edge) - 0.5 }));\n if (cols.length > 0) lines.push({ x: innerX(cols[cols.length - 1]!.r), ring: rings.after(cols[cols.length - 1]!.edge), at: atOf(cols[cols.length - 1]!.edge) + 0.5 });\n else lines.push({ x: side === \"left\" ? now.content.x : now.content.x + now.content.width, ring: rings.count, at: Math.max(-1, ...state.edges.filter((e) => e.side === side).map(atOf)) + 0.5 });\n // A new column lands where it shows open.\n const lands = (r: DropResult): boolean => {\n const me = r.layout.items[dragged]!;\n const el = me.edge ? r.layout.edges[me.edge] : undefined;\n return !!el && !me.inMenu && !el.folded && !el.rides && r.state !== c.state;\n };\n const { reach, place, edgePlace } = EDGE_KINDS.columnLine;\n // No column line's zone lies past the stage. The outermost line, with no drawn edge outside it, at the window's edge\n // (a flush window) or where the rail stop lies (the side's outer boundary): its band can't be centered there, half of\n // it past the stage or under the rail stop. It is laid inward instead, its zone running from the window's edge (an\n // inset's strip included): the rail stop keeps `RAIL_EDGE` px at the boundary (where an undrawn rail would land), the\n // line's band of `edgePlace` px follows it inward, and its tile reaches `reach` px on from the band's middle.\n const stage = c.state.stage;\n const dir = side === \"left\" ? 1 : -1;\n const outside = (x: number): boolean =>\n Object.values(now.edges).some((e) => e.side === side && e.rect.width > 0 && e.rect.height > 0 && (side === \"left\" ? e.rect.x + e.rect.width <= x + EPS : e.rect.x >= x - EPS));\n // The rail stop takes its place only when one of its slots lands (`railLands`): a virtual edge with no landing slot\n // owns nothing, so the line is laid from the window's edge then (a panel that would ride over an open column).\n const railFirst = railLands && !!c.state.rails?.[side]?.accepts.includes(c.kind) && !!now.railPlaces[side] && !(now.rails[side]?.segments.length ?? 0);\n const placeOf = (l: { x: number }, i: number): { line: number; zone: Span; owned: Span } => {\n const atEdge = side === \"left\" ? l.x <= stage.x + EPS : l.x >= stage.x + stage.width - EPS;\n if (i > 0 || outside(l.x) || !(atEdge || railFirst)) return { line: l.x, zone: [l.x - reach, l.x + reach], owned: [l.x - place / 2, l.x + place / 2] };\n const windowEdge = side === \"left\" ? stage.x : stage.x + stage.width;\n const boundary = clamp(l.x, stage.x, stage.x + stage.width);\n // With the rail first, its stop holds the outer `RAIL_EDGE` px from the side's outer edge (the window's, an inset's\n // strip included): the line's zone and band start where the stop ends. Without one, from the window's edge.\n const band0 = railFirst ? railOuter(c, side) + dir * RAIL_EDGE : boundary;\n const line = band0 + (dir * edgePlace) / 2;\n const span2 = (a: number, b: number): Span => [Math.min(a, b), Math.max(a, b)];\n return { line, zone: span2(railFirst ? band0 : windowEdge, line + dir * reach), owned: span2(band0, band0 + dir * edgePlace) };\n };\n // No form of the item fits across a column the side can make (as thick as its template's `cross.max` at most): a\n // refusal on a line is for thickness, as on a real edge.\n const most = state.columns?.[side]?.cross.max;\n const tooThick = most !== undefined && thickerThan(formsOf(state.items[dragged]!, \"column\"), most);\n // One spec per line: a new column's place, owning a band of `place` px about its line (ranked where that column would\n // be laid), its slot's tile reaching `reach` each way past it as overreach.\n return lines.map((l, i) => {\n const p = placeOf(l, i);\n return {\n id: virtualEdgeId(\"column\", side),\n edge: null,\n kind: \"columnLine\" as const,\n lay: { phase: EDGE_KINDS.columnLine.phase, side, at: l.at },\n vertical: false,\n zones: [{ zone: \"start\" as const, a: Math.max(p.zone[0], stage.x), b: Math.min(p.zone[1], stage.x + stage.width) }],\n slots: [slotAt(c, \"start\", p.line, targetId({ kind: \"column\", side, ring: l.ring }), { kind: \"column\", side, ring: l.ring }, lands)],\n refuse: () => (tooThick ? (\"too-thick\" as const) : (\"no-room\" as const)),\n own: null,\n holds: false,\n reserved: [],\n cards: [],\n across: (): Span => [span.y, span.y + span.height],\n owned: [span.y, span.y + span.height] as Span,\n ownedAlong: p.owned,\n drawn: false,\n // Where the new column's edge lands: the line itself, inside the stage.\n marker: () => rect(clamp(l.x, stage.x, stage.x + stage.width), span.y, 0, span.height),\n };\n });\n}\n\n/**\n * A declared rail's one place under `foldedColumnDrop`: the end of its last folded column. The item keeps its state: a\n * collapsed one lands as the rail's last tile, an open one opens that column, or there is no place.\n */\nfunction railEnd(c: Ctx, side: \"left\" | \"right\", segments: readonly { readonly edge: string }[], y: number): Slot | null {\n const { state, rest, dragged } = c;\n const edge = [...segments].reverse().map((s) => rest.edges.find((e) => e.id === s.edge)).find((e) => !!e);\n if (!edge) return null;\n const at = edge.items.filter((id) => zoneOf(rest.items[id]) === \"start\").length;\n const place = { kind: \"gap\" as const, edge: edge.id, zone: \"start\" as const, at };\n const collapsed = isHandFolded(state, dragged);\n const lands = ({ layout }: DropResult): boolean => {\n const me = layout.items[dragged]!;\n return !me.inMenu && (collapsed ? me.rail === side : me.edge === edge.id && !me.rail && !me.rides && !layout.edges[edge.id]?.folded);\n };\n return slotAt(c, \"start\", y, targetId(place), place, lands);\n}\n\n/**\n * The held tile's own column in the side's declared rail, as the edge of its own that it is (`railColumnSpec`): the\n * places a column drawn as a rail offers a tile of it (`gap:<edge>:<zone>:<at>`), over the column's own run of tiles\n * only. A tile keeps its place among its own tiles; the rest of the rail (other columns' tiles) stays the rail's stops',\n * which are home's for it. The gaps are real moves only where the tile stays a tile of this rail (a window too narrow\n * for that opens the column instead): there they are refused places, as for any slot that doesn't land. Its home slots\n * (the halves of the run's tiles beside the held one, which are home's as in any column) take the id of the rail's own\n * home stop (`rail`): the one home of the tile in the rail. The held tile's own interval is home's tile (`home:<id>`)\n * as everywhere, so the edge has no interval of its own (`own`, `holds`). Null where the tile is not in the side's rail,\n * or its column offers nothing.\n */\nexport function ownColumnRun(c: Ctx, side: \"left\" | \"right\", rail: EdgeSpec): EdgeSpec | null {\n const { state, now, dragged } = c;\n const me = now.items[dragged];\n const shown = now.rails[side];\n const edge = me?.rail === side ? state.edges.find((e) => e.id === me.edge) : undefined;\n const homeId = rail.slots.find((s) => s.home)?.id;\n if (!shown || !edge || homeId === undefined) return null;\n const tiles = shown.segments.filter((s) => s.edge === edge.id).map((s) => s.rect);\n if (tiles.length === 0) return null;\n const top = Math.min(...tiles.map((r) => r.y));\n const spec = railColumnSpec(c, edge, rect(shown.rect.x, top, shown.rect.width, Math.max(...tiles.map((r) => r.y + r.height)) - top));\n if (!spec) return null;\n const stays = ({ layout }: DropResult): boolean => layout.items[dragged]?.rail === side && layout.items[dragged]?.edge === edge.id;\n return { ...spec, own: null, holds: false, homePriority: EDGE_KINDS.railStop.priority, slots: spec.slots.map((s) => (s.home ? { ...s, id: homeId } : { ...s, ok: s.ok && stays(s.result) })) };\n}\n\n/**\n * The side's rail as an edge (virtual, along y): a slot before each folded column's segments and after the last, or,\n * with no rail shown, one slot `RAIL_EDGE` px deep where the rail lands (`railPlaces`); tiled as every edge is. The\n * stops lie where the user sees the rail; each counts its ring with the item lifted.\n */\nexport function railStops(c: Ctx, side: \"left\" | \"right\"): EdgeSpec | null {\n const { state, now, dragged } = c;\n const rail = now.rails[side];\n const placeRect = now.railPlaces[side];\n if (!placeRect) return null;\n const rings = ringsOf(c, side);\n const seenRings = sideRings(state.edges, side);\n const mine = state.edges.filter((e) => e.side === side).sort((a, b) => (seenRings.get(a.id) ?? 0) - (seenRings.get(b.id) ?? 0));\n const edgeOf = (id: string): DockEdge | undefined => mine.find((e) => e.id === id);\n const ringBefore = (id: string): number => {\n const e = edgeOf(id);\n return e ? rings.before(e) : 0;\n };\n const ringAfter = (id: string): number => {\n const e = edgeOf(id);\n return e ? rings.after(e) : 1;\n };\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: ringBefore(g.edge) });\n const last = groups[groups.length - 1]!;\n stops.push({ y: last.y1, ring: ringAfter(last.edge) });\n } else {\n const firstCol = mine.find((e) => e.column === true);\n // The outer `RAIL_EDGE` px from the side's outer edge: the window's (an inset's strip included), or flush after the\n // side's outside bars.\n const outer = railOuter(c, side);\n zone = rect(side === \"left\" ? outer : outer - RAIL_EDGE, placeRect.y, RAIL_EDGE, placeRect.height);\n stops.push({ y: placeRect.y, ring: firstCol ? rings.before(firstCol) : rings.count });\n }\n // Every stop is home while the item is folded here already. A rail that shows (occupied) offers its stops wherever the\n // item ends up collapsed at this side (`collapsesAt`: its tile, or a rider bar when the lifted item's column reopens\n // over it). With no rail shown, a stop is only the item folded into the rail: a thin band that would otherwise take\n // the side's edge from the column line for a panel that rides.\n const ownRail = now.items[dragged]?.rail === side;\n const shown = !!rail && rail.segments.length > 0;\n const lands = (r: DropResult): boolean => (shown ? collapsesAt(c, r, side) : r.layout.items[dragged]!.rail === side && r.state !== c.state);\n const at = zone;\n // `foldedColumnDrop`: no stop changes the state of an item arriving here. A shown rail is one place, the end of its last\n // folded column; with none shown, only an item already collapsed has a stop.\n const arriving = state.foldedColumnDrop === \"end\" && !ownRail;\n const end = arriving && shown ? railEnd(c, side, rail.segments, at.y + at.height) : null;\n if (arriving && (shown ? !end : !isHandFolded(state, dragged))) return null;\n // No form of the item fits across the rail (its `width`): a refusal on a stop is for thickness, as on a real edge.\n const width = state.rails?.[side]?.width;\n const tooThick = width !== undefined && thickerThan(formsOf(state.items[dragged]!, \"column\"), width);\n return {\n id: virtualEdgeId(\"rail\", side),\n edge: null,\n kind: \"railStop\",\n // The rail lies outside every edge on its side: laid first among them.\n lay: { phase: EDGE_KINDS.railStop.phase, side, at: -1 },\n vertical: true,\n zones: [{ zone: \"start\", a: at.y, b: at.y + at.height }],\n slots: end ? [end] : stops.map((s) => slotAt(c, \"start\", s.y, targetId({ kind: \"rail\", side, ring: s.ring }), { kind: \"rail\", side, ring: s.ring }, lands, ownRail)),\n refuse: () => (tooThick ? \"too-thick\" : \"no-room\"),\n own: null,\n holds: false,\n reserved: [],\n cards: [],\n across: () => [at.x, at.x + at.width],\n // A drawn rail owns its rect; where none shows, a thin band of its place at the side's outer boundary.\n owned: rail && rail.segments.length > 0 ? [at.x, at.x + at.width] : side === \"left\" ? [at.x, at.x + Math.min(at.width, EDGE_KINDS.railStop.place)] : [at.x + at.width - Math.min(at.width, EDGE_KINDS.railStop.place), at.x + at.width],\n ownedAlong: null,\n drawn: !!rail && rail.segments.length > 0,\n marker: (s) => rect(at.x, s.result.layout.items[dragged]!.rect.y, at.width, 0),\n };\n}\n","/**\n * The least a target's hit keeps, so a pointer can reach it (`EDGE_KINDS[kind].minHit`: 12 px across, its narrow\n * side, by 24 px along, its long side). Clipping lays the virtual edges' tiles last, from what the others leave, so a\n * column line beside a rail strip can be left a sliver. After every tile is placed, a target whose largest piece is\n * under its minimum grows into what is beside it, as far as the minimum needs:\n * - only inside its own zone (its tiles with its edge tiled on its own: a column line's band, a gap's tile);\n * - from space no target holds (the float's), and from a target that keeps its own minimum after the cut (the\n * lowest-ranked owner's surplus);\n * - never over home, a drop strip, a `none` rect, a refusal, the chrome or past the stage, and (but for a column line,\n * whose band lies across the columns by design) never over another drawn edge: those don't give way.\n * Where nothing can spare the space the target stays as it is: still a stop, still in \"Move to\".\n */\nimport { EPS, area, rect, subtract, type Rect } from \"@n-uf/placement\";\nimport { keepClearFor } from \"../helpers\";\nimport type { Ctx, DockRefusal, DockDrop } from \"./model\";\nimport { parseTargetId } from \"./ids\";\nimport { EDGE_KINDS, edgeKindOf, type EdgeKind } from \"./kinds\";\n\n/** A hit's least size: its narrow side `across`, its long side `along`, px. */\ninterface MinHit {\n readonly across: number;\n readonly along: number;\n}\n\n/** The kind whose `minHit` a target keeps: its edge's, a column line's or a rail stop's. */\nfunction kindOf(c: Ctx, t: DockDrop): EdgeKind | null {\n const p = parseTargetId(t.id);\n if (!p) return null;\n if (p.kind === \"column\") return \"columnLine\";\n if (p.kind === \"rail\") return \"railStop\";\n if (p.kind === \"gap\" || p.kind === \"strip\") {\n const e = c.state.edges.find((x) => x.id === p.edge);\n return e ? edgeKindOf(c.state, e) : null;\n }\n return null;\n}\n\nconst largest = (ps: readonly Rect[]): Rect => ps.reduce((a, p) => (area(p) > area(a) ? p : a));\n/** Whether `r` keeps `m`: its narrow side at least `across`, its long side at least `along`. */\nconst keepsMinHit = (r: Rect, m: MinHit): boolean => Math.min(r.width, r.height) >= m.across - EPS && Math.max(r.width, r.height) >= m.along - EPS;\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 cut = (ps: readonly Rect[], g: Rect): Rect[] => ps.flatMap((p) => subtract(p, g)).filter((p) => p.width >= 1 && p.height >= 1);\nconst piecesOf = (t: { readonly hit: Rect; readonly hits?: readonly Rect[] }): readonly Rect[] => t.hits ?? [t.hit];\nconst withPieces = <T extends { readonly hit: Rect; readonly hits?: readonly Rect[] }>(t: T, ps: readonly Rect[]): T => {\n const { hits: _h, ...rest } = t;\n return { ...rest, hit: largest(ps), ...(ps.length > 1 ? { hits: ps } : {}) } as T;\n};\n\n/** The ways `r` can grow by `d` on one axis: all on one side, all on the other, or half on each. */\nfunction growths(r: Rect, axis: \"x\" | \"y\", d: number): Rect[][] {\n const [lo, hi] = axis === \"x\" ? [rect(r.x - d, r.y, d, r.height), rect(r.x + r.width, r.y, d, r.height)] : [rect(r.x, r.y - d, r.width, d), rect(r.x, r.y + r.height, r.width, d)];\n const h = d / 2;\n const halves = axis === \"x\" ? [rect(r.x - h, r.y, h, r.height), rect(r.x + r.width, r.y, h, r.height)] : [rect(r.x, r.y - h, r.width, h), rect(r.x, r.y + r.height, r.width, h)];\n return [[lo], [hi], halves];\n}\n\nconst union = (a: Rect, gs: readonly Rect[]): Rect => {\n const x0 = Math.min(a.x, ...gs.map((g) => g.x));\n const y0 = Math.min(a.y, ...gs.map((g) => g.y));\n return rect(x0, y0, Math.max(a.x + a.width, ...gs.map((g) => g.x + g.width)) - x0, Math.max(a.y + a.height, ...gs.map((g) => g.y + g.height)) - y0);\n};\n\n/**\n * Whether `grow` may be taken for target `i` of `targets`: inside the stage, clear of the chrome and of every target\n * that doesn't give way, and every other target it covers keeping its own minimum after the cut.\n */\nfunction mayGrow(c: Ctx, targets: readonly DockDrop[], i: number, grow: readonly Rect[], minOf: (t: DockDrop) => MinHit | null, zone: readonly Rect[], away: readonly Rect[]): boolean {\n const s = c.state.stage;\n for (const g of grow) {\n if (g.x < s.x - EPS || g.y < s.y - EPS || g.x + g.width > s.x + s.width + EPS || g.y + g.height > s.y + s.height + EPS) return false;\n if ([...keepClearFor(c.state, \"targets\"), ...away].some((r) => overlaps(r, g))) return false;\n // Only within its own zone: the tile it had before clipping (its reach included), never past it.\n if (zone.reduce<Rect[]>((ps, z) => ps.flatMap((p) => subtract(p, z)), [g]).some((p) => area(p) > EPS)) return false;\n }\n return targets.every((o, j) => {\n if (j === i || o.free || !piecesOf(o).some((p) => grow.some((g) => overlaps(p, g)))) return true;\n // Home, a drop strip and a `none` rect keep their space.\n if (o.place.kind === \"home\" || o.place.kind === \"none\" || o.strip) return false;\n const m = minOf(o);\n const left = grow.reduce<Rect[]>((ps, g) => cut(ps, g), [...piecesOf(o)]);\n return !!m && left.length > 0 && keepsMinHit(largest(left), m);\n });\n}\n\n/**\n * Growth across over part of `l`'s length: the strip beside it on one side cut where something keeps its space, the\n * longest run left (at least `m.along` long) taken, checked again as a whole. Null when no side has such a run.\n */\nfunction partialGrowth(c: Ctx, targets: readonly DockDrop[], i: number, l: Rect, axis: \"x\" | \"y\", d: number, m: MinHit, minOf: (t: DockDrop) => MinHit | null, zone: readonly Rect[], away: readonly Rect[]): Rect[] | null {\n const along = axis === \"x\" ? ([l.y, l.y + l.height] as const) : ([l.x, l.x + l.width] as const);\n let best: Rect | null = null;\n for (const [side] of growths(l, axis, d)) {\n const g = side!;\n const strip = (a: number, b: number): Rect => (axis === \"x\" ? rect(g.x, a, g.width, b - a) : rect(a, g.y, b - a, g.height));\n // Where along the strip something lies: the seams the strip is cut at.\n const cuts = new Set<number>([along[0], along[1]]);\n for (const o of targets)\n for (const p of piecesOf(o))\n if (overlaps(p, g)) for (const v of axis === \"x\" ? [p.y, p.y + p.height] : [p.x, p.x + p.width]) if (v > along[0] && v < along[1]) cuts.add(v);\n const marks = [...cuts].sort((a, b) => a - b);\n let runStart: number | null = null;\n const runs: [number, number][] = [];\n for (let k = 0; k < marks.length - 1; k++) {\n const ok = mayGrow(c, targets, i, [strip(marks[k]!, marks[k + 1]!)], minOf, zone, away);\n if (ok && runStart === null) runStart = marks[k]!;\n if (!ok && runStart !== null) {\n runs.push([runStart, marks[k]!]);\n runStart = null;\n }\n }\n if (runStart !== null) runs.push([runStart, marks[marks.length - 1]!]);\n for (const [a, b] of runs.sort((p, q) => q[1] - q[0] - (p[1] - p[0]))) {\n if (b - a < m.along - EPS) break;\n const r = strip(a, b);\n if (mayGrow(c, targets, i, [r], minOf, zone, away) && (!best || area(r) > area(best))) best = r;\n break;\n }\n }\n return best ? [best] : null;\n}\n\n/**\n * Every target grown to its kind's minimum where the space beside it can be spared, within its own zone (`zones`, by\n * id: its tiles with its edge tiled on its own, its reach included). A refusal keeps its space (it is a drawn edge's\n * or a zone's \"Can't go here\"), and a target of a real edge never grows over another drawn edge: only a column line,\n * whose band lies across the columns about it by design, may.\n */\nexport function withMinHit(c: Ctx, targets: readonly DockDrop[], refusals: readonly DockRefusal[], zones: ReadonlyMap<string, readonly Rect[]>): DockDrop[] {\n const out = [...targets];\n const refused = refusals.flatMap(piecesOf);\n const minOf = (t: DockDrop): MinHit | null => {\n const k = kindOf(c, t);\n return k ? EDGE_KINDS[k].minHit : null;\n };\n const drawn = Object.entries(c.now.edges).filter(([, e]) => e.rect.width > EPS && e.rect.height > EPS);\n for (let i = 0; i < out.length; i++) {\n const t = out[i]!;\n const m = minOf(t);\n const zone = zones.get(t.id);\n if (!m || !zone || t.free || t.strip || t.place.kind === \"home\" || t.place.kind === \"none\") continue;\n const ownEdge = t.place.kind === \"gap\" ? t.place.edge : (parseTargetId(t.id) as { edge?: string } | null)?.edge;\n // A virtual edge's band lies across the edges about it by design (`EDGE_KINDS[kind].virtual`): only it may grow\n // over another drawn edge.\n const k = kindOf(c, t);\n const away = [...refused, ...(k && EDGE_KINDS[k].virtual ? [] : drawn.filter(([id]) => id !== ownEdge).map(([, e]) => e.rect))];\n let l = largest(piecesOf(t));\n if (keepsMinHit(l, m)) continue;\n // The narrow side to `across`, then the long side to `along`, each where the space can be spared.\n const steps: (\"across\" | \"along\")[] = [\"across\", \"along\"];\n for (const step of steps) {\n const narrowX = l.width <= l.height;\n const axis: \"x\" | \"y\" = step === \"across\" ? (narrowX ? \"x\" : \"y\") : narrowX ? \"y\" : \"x\";\n const size = axis === \"x\" ? l.width : l.height;\n const d = (step === \"across\" ? m.across : m.along) - size;\n if (d <= EPS) continue;\n // The whole length first; across, failing that, the longest stretch of it whose side can be spared (as long as\n // the minimum along): a home band beside the line's end keeps its space, the rest of the line grows.\n let grow = growths(l, axis, d).find((g) => mayGrow(c, out, i, g, minOf, zone, away));\n if (!grow && step === \"across\") grow = partialGrowth(c, out, i, l, axis, d, m, minOf, zone, away) ?? undefined;\n if (!grow) continue;\n for (let j = 0; j < out.length; j++) {\n if (j === i || out[j]!.free) continue;\n const o = out[j]!;\n if (!piecesOf(o).some((p) => grow.some((g) => overlaps(p, g)))) continue;\n out[j] = withPieces(o, grow.reduce<Rect[]>((ps, g) => cut(ps, g), [...piecesOf(o)]));\n }\n // The grown piece: `l` widened over the stretch grown along (all of it, or the part that could be spared). Its\n // other pieces, and what is left of `l`, give that piece up, so no two of its pieces overlap.\n const g0 = grow[0]!;\n const span = axis === \"x\" ? rect(l.x, g0.y, l.width, g0.height) : rect(g0.x, l.y, g0.width, l.height);\n const grown = union(span, grow);\n const others = piecesOf(out[i]!).filter((p) => p !== l);\n out[i] = withPieces(out[i]!, [...cut([...others, l], grown), grown]);\n l = largest(piecesOf(out[i]!));\n }\n }\n return out;\n}\n","/**\n * Lanes: the geometry of a docking drag for a landing model (`@n-uf/motion/drag`'s `createLandingModel`).\n *\n * A lane is one edge that takes the held item (a bar, a rail, a column) or a virtual one (a new column's line, a\n * declared rail). Its spots are the places a drop there lands, in order along it: before, between and after its items,\n * and, on a bar or a toolbar rail, one sliding spot per free stretch between items, which lands exactly where the hand\n * holds it (`DockSpot.slide`; `stretchPositions: \"free\"`, the default); with `stretchPositions: \"pitched\"`, spots at a\n * fixed pitch over those stretches instead (`SPOT_PITCH`), so a toolbar lands close to the hand. Each spot keys where its drop draws the other items (a change between two spots\n * with the same key moves only the held item), and each lane carries its place guides' marks in the layout as drawn.\n * Each spot has a stretch of the lane that picks it. In a panel column, between two spots that share a neighbor (the\n * item `Y` in `X|Y` and `Y|Z`), the boundary is that item's middle as drawn (with a spot held, in that spot's own layout:\n * `dockDrag`'s `spotsOf`, so a column takes a panel by halves of what is seen). On a bar or a toolbar rail, and between any two\n * other spots, it is halfway across the gap between their landings, each in its own layout, so the pointer is at the\n * landing it picks and a toolbar moved along an occupied lane stays at the hand. On a bar or a toolbar rail, two landings\n * that overlap (spots a pitch apart, the pointer inside both) are cut where the item is held (`options.grab`): halfway\n * between the points the pointer would hold in each, so a pointer back at its press point picks the item's own place\n * however far from its middle it was pressed; landings apart are cut halfway across their gap whatever the grab. Cuts are\n * kept inside the lane and in order. The spots come from the same generation and filter as `targets()`, so a spot's\n * landing is exactly what its drop commits. Spot ids are keyed by the lane, zone and neighboring items, so they survive\n * the window resizing and most items opening or moving; virtual lanes are keyed by the column they lie beside, not\n * their ring. Remembered per state and options. The one layout of each held place of the drag (a held frame and its commit)\n * is `dockDrag`'s (./drag), built on these.\n */\nimport { EPS, area, clamp, rect, subtract, type Point, type Rect, type Size } from \"@n-uf/placement\";\nimport { itemSteps } from \"@n-uf/placement/stack\";\nimport { liftItem, moveTo, type DockPlace } from \"./changes\";\nimport { axisOf, keepClearFor, floatRegion } from \"./helpers\";\nimport type { DockEdge, DockState, DockItemLayout, DockLayout, Zone } from \"./model\";\nimport { solve } from \"./solve\";\nimport { parseTargetId, targetsAndRefusals } from \"./targets\";\nimport type { DropResult, DockRefusal, DockDrop, DockDropOptions } from \"./targets/model\";\n\n/** The pitch of the spots over a bar's free stretches, px: a quarter of a typical toolbar's length (158 px in the lab). */\nexport const SPOT_PITCH = 40;\n/** How near a sliding spot's snap point a landing snaps to it, px (`DockLaneOptions.snapDistance`). */\nconst SNAP_DISTANCE = 8;\n/** The grain of a sliding spot's free start, px: whole pixels (`LaneSlide.step`). */\nconst STEP = 1;\n\n/**\n * A sliding spot's range (`DockLaneOptions.stretchPositions: \"free\"`): where the landing's start may lie along the lane,\n * from flush against the neighbor before the stretch to flush against the one after it, and the starts it snaps to.\n */\nexport interface LaneSlide {\n readonly from: number;\n readonly to: number;\n /**\n * Its two ends, the item's own place where it lies here, and every other dock that lands inside, in order. Each is a\n * start that commits what lies there (a taken-over dock as it is), so none is dropped for lying near another, except\n * within twice the snap distance of the item's own place, where home wins.\n */\n readonly snaps: readonly number[];\n /** How near a snap point the landing's start snaps to it, px (`DockLaneOptions.snapDistance`). */\n readonly snapDistance: number;\n /**\n * The grain of a start that snaps to nothing, px: a multiple of `step` (whole px, 1) within `[from, to]`. The one rule\n * `target.after`, a landing model's frame and its release all read, so the frame shows what the drop commits:\n * with `c = clamp(raw, from, to)`, the start is the nearest snap point within `snapDistance` of `c`, else\n * `clamp(round(c / step) * step, from, to)`.\n */\n readonly step: number;\n}\n\n/** One place a drop in a lane lands. */\nexport interface DockSpot {\n /**\n * Stable across solves: `<lane>/<zone>/<item before or ^>|<item after or $>`; an empty edge's `<lane>/<zone>`; a\n * pitched spot `…@<pitches from its neighbor>`; a sliding spot `<lane>/<zone>/<before>|<after>@slide`, named by the\n * stretch; a virtual lane's `<lane>/line` or `<lane>/end`.\n */\n readonly id: string;\n /** Its stretch of the lane, along the lane's axis, inside the lane's range. */\n readonly along: readonly [number, number];\n /** Where the item lands (its rect after the drop). */\n readonly landing: Rect;\n /** The drop: its place and `after()` (the layout after it, the room). */\n readonly target: DockDrop;\n /**\n * The item's own place (a release there changes nothing). A spot's `target.place` is the dock at the spot's listed\n * landing (on the item's own sliding spot its own zone, index and `space`); a sliding spot commits through\n * `target.after(point, grab)`, and the landing release's `home` and `at` say where, never the place kind.\n */\n readonly home?: true;\n /** A spot at a pitch over a free stretch (`DockItem.space`). */\n readonly pitched?: true;\n /**\n * A free stretch as one sliding spot (`stretchPositions: \"free\"`): its drop lands where the pointer holds it, the\n * landing's start at the pointer less the grab, clamped to `[from, to]` and snapped within `snapDistance`, and\n * `target.after(point, grab)` commits that (a dock keeping the `space` that puts it there). Its `landing` is the one at\n * the stretch's point nearest the item's own place (that place where it lies here), else at its start.\n */\n readonly slide?: LaneSlide;\n /**\n * Where its drop draws every item other than the held one, as a key: a change between two spots with the same key\n * moves only the held item; between two with different keys it reflows the window.\n */\n readonly others: string;\n}\n\n/** A stretch of a lane that takes no drop of the item, at least the item's length (a shorter one joins its spots). */\nexport interface LaneRefusal {\n readonly along: readonly [number, number];\n readonly reason: DockRefusal[\"reason\"];\n}\n\n/**\n * A place guide's mark, in the lane's layout as drawn: a `line` across the lane between two items that touch (no room\n * between them but the edge's own gap; as thick as their gap allows, up to 2 px, so zero where they meet and the host\n * strokes it), a `box` over free room the item lands in, and a `hatch` over the part of a neighbor that gives way.\n * Where the free room is shorter than the item (a lane's end, a gap between items wider than the edge's gap), the spot\n * there is drawn as it lands: a box over the free room and a hatch over the rest of its landing (the edge of the\n * neighbor that will move), the two together the landing; with no free room at a lane's end, the hatch alone. A box\n * over another edge's docked items (an empty side rail over a column's outer strip) is a hatch there too: they move\n * aside when the lane opens. Never a box or a line over an item drawn there, nor anything over the held one; nothing in\n * a refused stretch; no two edge lanes' marks overlap (at a corner a lane not drawn gives way to a drawn one, and\n * between two not drawn the bar owns it; a virtual lane, a new column's line or a declared rail, is drawn over what it\n * would push). Marks lie in one layout: as seen the lifted item is drawn nowhere, so its own place is free room in its\n * lane; in a held place's layout (`after(held)`) every lane's marks lie in that layout, the held item where it draws it.\n */\nexport interface DockMark {\n /**\n * Stable while the items either side stay: `<lane>/line/<before>|<after>`, `<lane>/box/<before>|<after>` (`#<n>` for a\n * stretch's later pieces; `:before` or `:after` for the room beside the held item), `<lane>/hatch/<before>|<after>`\n * (`~2` for the second side), `^` and `$` at the lane's ends; a virtual lane's `<lane>/box/<spot id>`. Key a drawing by\n * it.\n */\n readonly id: string;\n readonly kind: \"line\" | \"box\" | \"hatch\";\n readonly rect: Rect;\n /**\n * A box's striped end (`hatch`, `HATCH_END`): the neighbor at that end that gives way when the item lands in the room\n * (it moves away, leaves the lane, or steps down to a shorter form). Data for a host and tests; nothing to show.\n */\n readonly givesWay?: string;\n}\n\nexport interface DockLane {\n /** The edge's id, or a virtual lane's: `column:<side>:<the column it lies outside, or $>`, `rail:<side>`. */\n readonly id: string;\n readonly rect: Rect;\n /** The axis its spots run along. */\n readonly axis: \"x\" | \"y\";\n readonly spots: readonly DockSpot[];\n readonly refused: readonly LaneRefusal[];\n /**\n * Its place guides' marks as seen: in the window as seen, the held item drawn nowhere (its own place is free room).\n * A held frame's marks, and the guides of a frame, are `dockDrag(...).after(held)` and `guides(frame)`'s (./drag).\n */\n readonly marks: readonly DockMark[];\n /**\n * Its rect is its own: a rail drop strip at the window's side (`DockState.railDrop`), which every other target of the drag\n * gives up. A landing model gives it the pointer inside it over any lane it overlaps (a flush column's edge).\n */\n readonly owns?: true;\n}\n\n/** Everything a landing model reads for one drag. */\nexport interface DockRegions {\n readonly lanes: readonly DockLane[];\n /** Refused places outside every lane (\"Can't go here\"). */\n readonly refused: readonly Rect[];\n /**\n * Where a float can land (`floatRegion`: the stage less the float insets), as a landing model's `content`: the open\n * space is it less `blocked`. So the gutter between a column and the pages is open (a release there floats), while\n * every drawn edge, docked item, chrome and drawn rail stays out of it.\n */\n readonly content: Rect;\n /** What the open space excludes: drawn edges, docked items, the chrome, a drawn declared rail, `DockState.blocked`. */\n readonly blocked: readonly Rect[];\n readonly stage: Rect;\n /** Where a float of the item may lie: the stage less the inset at its left and right (`heldRect`'s region). */\n readonly floatRegion: Rect;\n /** The held item's size as it is now. */\n readonly item: Size;\n /** The float target (its `after(point, grab)` is the float landing), or null where the item doesn't float. */\n readonly float: DockDrop | null;\n /** The drag's refusals, from the same generation as the spots (what `refusals()` gives), for a host that shows them. */\n readonly refusals: readonly DockRefusal[];\n}\n\nexport interface DockLaneOptions extends DockDropOptions {\n /**\n * The pitch of a bar's free-stretch spots, px (default `SPOT_PITCH`). 0 or less turns pitched spots off. Under `\"free\"` it only sets the sampling step that checks a\n * stretch's range (every `pitch` px; `SPOT_PITCH` when 0 or less), never a spot of its own.\n */\n readonly pitch?: number;\n /**\n * How a free stretch on a bar or a toolbar rail offers its range of landings, from flush against the neighbor before\n * it to flush against the one after it: `\"free\"` (the default), one sliding spot (`DockSpot.slide`) that lands where\n * the pointer holds the item, snapped to its ends and the item's own place within `snapDistance`; `\"pitched\"`, a\n * spot every `pitch` px, its ends included. Either way a step comes only where the order changes (passing a\n * neighbor), cut as between any two spots.\n */\n readonly stretchPositions?: \"free\" | \"pitched\";\n /** Under `\"free\"`, how near a snap point a landing snaps to it, px (default 8). */\n readonly snapDistance?: number;\n /**\n * Where the pointer holds the item, from its top left corner as it is now, px (what a target's `after(point, grab)`\n * takes): the press's, constant for the drag (each grab is remembered as its own options). It counts along the item's own length only (its longer side as it is now): on a bar or a toolbar rail\n * along that axis the cut between two overlapping landings lies halfway between the points the pointer would hold in\n * each (with landings of one length; at the same share of each), kept within half a pitch of their overlap, so a\n * pointer back at its press point picks the item's own place; landings with a gap between them (either side of a long\n * neighbor) are cut halfway across it whatever the grab, so the pointer is at the landing it picks (R12). Across the\n * item, and in a lane across its length (a rail toolbar over a bar), it is the item's middle, as without a grab. Panel columns take a panel by halves of what is drawn either way. Where another lane's band\n * overlaps the press point (an empty bar's band over a rail's end) that lane can still take the pointer first.\n */\n readonly grab?: { readonly x: number; readonly y: number };\n /**\n * How an empty lane's marks draw it (an empty bar or side rail, or a virtual lane, its room not open): `\"real\"` (the\n * default), boxes at the size it will take, lying over what moves aside (the page, a column); `\"edge\"`, each a thin\n * striped strip (`HATCH_EDGE`) on its window side. Where it lands is the same either way.\n */\n readonly emptyLanes?: EmptyLanes;\n}\n\n/**\n * How a place guide draws an empty lane (an empty bar or side rail, its room not open yet): `\"real\"`, a box at the size\n * the lane will take, over what moves aside; `\"edge\"`, a thin striped strip on the lane's window side. The landing is\n * the same either way ({@link DockLaneOptions.emptyLanes}).\n */\nexport type EmptyLanes = \"real\" | \"edge\";\n\ntype Axis = \"x\" | \"y\";\nconst mid = (r: Rect, axis: Axis): number => (axis === \"x\" ? r.x + r.width / 2 : r.y + r.height / 2);\nconst lo = (r: Rect, axis: Axis): number => (axis === \"x\" ? r.x : r.y);\nconst len = (r: Rect, axis: Axis): number => (axis === \"x\" ? r.width : r.height);\nconst hull = (a: Rect, b: Rect): Rect => {\n const x = Math.min(a.x, b.x);\n const y = Math.min(a.y, b.y);\n return rect(x, y, Math.max(a.x + a.width, b.x + b.width) - x, Math.max(a.y + a.height, b.y + b.height) - y);\n};\nconst nonNeg = (v: number | undefined): number => (Number.isFinite(v) && v! > 0 ? v! : 0);\nconst sameRect = (a: Rect, b: Rect): boolean => Math.max(Math.abs(a.x - b.x), Math.abs(a.y - b.y), Math.abs(a.width - b.width), Math.abs(a.height - b.height)) < 0.5;\nconst ORIGIN = { x: 0, y: 0 };\n\n/** The items drawn on `edge` in `l`, other than `dragged`, in order along `axis`. */\nfunction onEdge(l: DockLayout, edge: string, dragged: string, axis: Axis): { id: string; r: Rect; zone: Zone | undefined }[] {\n return Object.entries(l.items)\n .filter(([id, it]) => id !== dragged && it.edge === edge && !it.inMenu && !it.floating && it.rect.width > EPS && it.rect.height > EPS)\n .map(([id, it]) => ({ id, r: it.rect, zone: it.zone }))\n .sort((a, b) => lo(a.r, axis) - lo(b.r, axis));\n}\n\n/** The items either side of the dragged item on `edge` in `after`: `^` and `$` at the ends. */\nfunction neighbors(after: DockLayout, edge: string, dragged: string, axis: Axis): { before: string; next: string } {\n const me = after.items[dragged];\n const others = onEdge(after, edge, dragged, axis);\n const at = me ? mid(me.rect, axis) : 0;\n return { before: [...others].reverse().find((o) => mid(o.r, axis) < at)?.id ?? \"^\", next: others.find((o) => mid(o.r, axis) >= at)?.id ?? \"$\" };\n}\n\n/**\n * How a neighbor gives way to a drop beside a room, or null where it doesn't: when the item lands, the neighbor\n * `\"leaves\"` the lane (into the menu, a float), `\"steps\"` down to a shorter form than it has `now`, or `\"moves\"` away\n * from the room (its end left of where it was, for the neighbor `before` the room; its start right of it, for the one\n * after; by more than half a pixel). `extent` is its extent along the lane as read (a growing item at its natural\n * length). The one rule the marks (a striped end at each neighbor that gives way) and the stretches (the room a drop\n * makes) read.\n */\nfunction givesWay(\n now: DockItemLayout | undefined,\n after: DockItemLayout | undefined,\n lane: string,\n side: \"before\" | \"after\",\n extent: (r: Rect) => [number, number],\n): \"leaves\" | \"steps\" | \"moves\" | null {\n if (!now) return null;\n if (!after || after.inMenu || after.floating || after.edge !== lane) return \"leaves\";\n const [p0, p1] = extent(now.rect);\n const [q0, q1] = extent(after.rect);\n if (after.form !== now.form && q1 - q0 < p1 - p0 - 0.5) return \"steps\";\n return (side === \"before\" ? p1 - q1 : q0 - p0) > 0.5 ? \"moves\" : null;\n}\n\n/**\n * The layout as seen with the held item lifted (its room given back to its stretch, `lift`): what the window showed\n * before this drop, the one layout stretches and `givesWay` compare a drop with.\n */\nfunction liftedLayout(state: DockState, dragged: string, options: DockLaneOptions): DockLayout {\n return solve(liftItem(state, dragged), options.previous ? { previous: options.previous } : {});\n}\n\n/** A spot of a lane before its stretch is known. */\ninterface Raw {\n readonly lane: string;\n readonly edge: string | null;\n readonly axis: Axis;\n readonly id: string;\n readonly before: string;\n readonly next: string;\n readonly landing: Rect;\n readonly layout: DockLayout;\n readonly target: DockDrop;\n readonly hit: Rect;\n readonly home?: true;\n readonly pitched?: true;\n /** A sliding spot's range, with its landings at either end (what the cuts beside it read). */\n readonly slide?: LaneSlide & { readonly first: Rect; readonly last: Rect };\n /** A rail drop strip's spot (`DockState.railDrop`): its lane is the strip at the window's side, nothing more. */\n readonly strip?: true;\n}\n\n/** Where `layout` draws every item other than `dragged`, as a key (rects to the px; an item in a menu as `m`). */\nfunction othersKey(layout: DockLayout, dragged: string): string {\n return Object.keys(layout.items)\n .filter((id) => id !== dragged)\n .sort()\n .map((id) => {\n const it = layout.items[id]!;\n return it.inMenu ? `${id}:m` : `${id}:${Math.round(it.rect.x)},${Math.round(it.rect.y)},${Math.round(it.rect.width)},${Math.round(it.rect.height)}`;\n })\n .join(\";\");\n}\n\n/** What one state, item and options give, before any spot is held (internal to the package). */\nexport interface Base {\n readonly raws: ReadonlyMap<string, readonly Raw[]>;\n readonly lanes: readonly DockLane[];\n readonly seen: DockLayout;\n readonly refusals: readonly DockRefusal[];\n readonly regions: Omit<DockRegions, \"lanes\">;\n /** The lanes cut by halves of the items drawn (panel columns). */\n readonly halves: ReadonlySet<string>;\n /** Where the pointer holds the item, as a share of its width and height (0.5 each without `options.grab`). */\n readonly share: { readonly x: number; readonly y: number };\n readonly marking: Marking;\n}\n\n/** What a lane's marks read beyond its spots. */\ninterface Marking {\n /** The pitch of a bar's or a toolbar rail's free-stretch spots (0: none). */\n readonly pitch: number;\n /** A growing item's natural length along `axis` (its drawn length past it is free stretch), else undefined. */\n readonly natural: (id: string, axis: Axis) => number | undefined;\n /** The edge's own gap between items, px: room no larger than it between two items is none (they touch). */\n readonly gap: (edge: string) => number;\n /**\n * The edges drawn in `over` standing across `edge`'s axis that take the held item (it has a lane there), their rects:\n * the ones an empty `edge`'s lane gives way to. A drawn edge that refuses the item leaves the corner to `edge`.\n */\n readonly crossing: (edge: string, over: DockLayout) => readonly Rect[];\n}\n\n/**\n * An empty edge's band less the drawn edges across it: along `axis` it stops at each one's side (the ones before its\n * middle cut its start, the others its end). Only a drawn edge that stands across the band's middle line cuts: one that\n * reaches a few pixels into the band (a rail starting below a drawn inner bar the empty band lies over) takes none of\n * the band's length, so its corner stays the band's.\n */\nfunction clipAtDrawn(band: Rect, axis: Axis, cuts: readonly Rect[]): Rect {\n let a = lo(band, axis);\n let b = a + len(band, axis);\n const center = (a + b) / 2;\n const x = axis === \"x\" ? \"y\" : \"x\";\n const line = lo(band, x) + len(band, x) / 2;\n for (const c of cuts) {\n if (!(lo(c, x) < line - EPS && line < lo(c, x) + len(c, x) - EPS)) continue;\n const c0 = lo(c, axis);\n const c1 = c0 + len(c, axis);\n if ((c0 + c1) / 2 <= center) a = Math.max(a, c1);\n else b = Math.min(b, c0);\n }\n return b - a > EPS ? along(band, axis, a, b) : band;\n}\n\nconst memo = new WeakMap<DockState, Map<string, Base>>();\nconst previousIds = new WeakMap<DockLayout, number>();\nlet nextPrevious = 1;\n/** The options as a key: by value, `previous` by identity. */\nfunction keyOf(dragged: string, o: DockLaneOptions): string {\n const { previous, ...rest } = o;\n let p = 0;\n if (previous) {\n if (!previousIds.has(previous)) previousIds.set(previous, nextPrevious++);\n p = previousIds.get(previous)!;\n }\n return `${dragged}\\u0000${p}\\u0000${JSON.stringify(rest)}`;\n}\n\n/**\n * The lanes and regions of a drag of `dragged`: every lane that takes it with its spots and stretches, the refused\n * places outside lanes, the content and what blocks it, the stage, the float region, the item's size and the float\n * target, each lane's marks as seen (at rest, the held item drawn nowhere). Remembered per state and options (`previous`\n * by identity). A held frame's lanes are `dockDrag(...).after(held)`'s (./drag).\n */\nexport function lanes(state: DockState, dragged: string, options: DockLaneOptions = {}): DockRegions {\n const base = baseOf(state, dragged, options);\n return { ...base.regions, lanes: base.lanes };\n}\n\n/** The drag's base, remembered per state and options (`previous` by identity). Internal to the package. */\nexport function baseOf(state: DockState, dragged: string, options: DockLaneOptions = {}): Base {\n const key = keyOf(dragged, options);\n let perState = memo.get(state);\n if (!perState) memo.set(state, (perState = new Map()));\n let base = perState.get(key);\n if (!base) perState.set(key, (base = build(state, dragged, options)));\n return base;\n}\n\n/** A lane's id with its marks in one layout. */\nexport interface LaneMarks {\n readonly lane: string;\n readonly axis: \"x\" | \"y\";\n readonly marks: readonly DockMark[];\n}\n\n/**\n * Every lane's marks in the one layout `layout` (internal to the package): each lane laid out over `layout` as drawn\n * there, the held item drawn where `layout` draws it on an edge (`held`: a spot's layout) or nowhere (the layout as seen,\n * at rest; a float's), each neighbor's giving way judged in `layout` itself, every mark clipped to its lane's rect over\n * `layout` (decision 0002), and the corners settled between the lanes as `layout` draws them. Held on a sliding spot\n * (`\"slide\"`), the room beside the item is a box from `MIN_BOX`: the item lands anywhere in it, so any room is a place.\n */\nexport function marksIn(base: Base, state: DockState, dragged: string, layout: DockLayout, held: false | \"spot\" | \"slide\", emptyLanes: EmptyLanes | undefined): LaneMarks[] {\n const heldEdge = held ? layout.items[dragged] : undefined;\n const on = heldEdge && !heldEdge.floating && !heldEdge.inMenu ? heldEdge.edge : undefined;\n const built = base.lanes.flatMap((l) => {\n const raws = base.raws.get(l.id);\n const again = raws ? laneFrom(l.id, raws, layout, base.seen, dragged, base.refusals, base.halves.has(l.id), base.share, base.marking, l.id === on, l.id === on && held === \"slide\" ? MIN_BOX : undefined) : null;\n return again ? [{ lane: again, over: laneRectOver(raws!, layout, base.marking).rect }] : [];\n });\n const over = built.map(({ lane, over: r }) => ({ ...lane, rect: r }));\n const settled = built.map(({ lane, over: r }) => {\n const s = settle(lane, layout, state, dragged, over, emptyLanes, r);\n return { lane: s.id, axis: s.axis, marks: s.marks };\n });\n return newColumnsGiveWay(settled, (s) => s.lane, state);\n}\n\n/**\n * A lane of no edge (a new column beside one) marks its landing in its own layout, the layout that creates it: it gives\n * way to the marks of the lanes the layout lays out, so every lane's marks share that one layout's room.\n */\nfunction newColumnsGiveWay<L extends { readonly axis: Axis; readonly marks: readonly DockMark[] }>(ls: readonly L[], idOf: (l: L) => string, state: DockState): L[] {\n const hasEdge = (id: string): boolean => state.edges.some((e) => e.id === id);\n // (Not the lines: a joint between two panels lies across the room the new column takes as its column moves aside.)\n const laid = ls.filter((l) => hasEdge(idOf(l))).flatMap((l) => l.marks.filter((m) => m.kind !== \"line\").map((m) => m.rect));\n return ls.map((l) => (hasEdge(idOf(l)) ? l : { ...l, marks: marksLess(l.marks, l.axis, laid) }));\n}\n\n/** The lane `id`'s spots with their stretches cut in `layout` (a panel column by halves of what `layout` draws), or null. Internal. */\nexport function spotsIn(base: Base, id: string, layout: DockLayout, dragged: string): readonly DockSpot[] | null {\n const raws = base.raws.get(id);\n return raws ? (laneFrom(id, raws, layout, base.seen, dragged, base.refusals, base.halves.has(id), base.share, base.marking)?.spots ?? null) : null;\n}\n\n/** The raw spot `id` of the drag (internal): its lane, its target, and the layout its drop draws at rest. */\nexport function rawSpot(base: Base, id: string): { readonly lane: string; readonly target: DockDrop; readonly layout: DockLayout; readonly home?: true; readonly slide?: boolean } | null {\n for (const [lane, list] of base.raws) {\n const r = list.find((x) => x.id === id);\n if (r) return { lane, target: r.target, layout: r.layout, ...(r.home ? { home: true as const } : {}), ...(r.slide ? { slide: true } : {}) };\n }\n return null;\n}\n\nfunction build(state: DockState, dragged: string, options: DockLaneOptions): Base {\n const seen = solve(state, options.previous ? { previous: options.previous } : {});\n const { targets: ts, refusals: rs } = targetsAndRefusals(state, dragged, options);\n const own = seen.items[dragged];\n const ownEdge = own && !own.floating && !own.inMenu ? own.edge : undefined;\n const pitch = options.pitch === undefined ? SPOT_PITCH : options.pitch;\n const raws: Raw[] = [];\n const axisOfEdge = (id: string): Axis => {\n const e = state.edges.find((x) => x.id === id);\n return e && axisOf(e.side) === \"column\" ? \"y\" : \"x\";\n };\n // A virtual lane is keyed by the column it lies outside (or `$`, the side's inner end), not by its ring.\n const columnKey = (side: string, ring: number): string => state.edges.find((e) => e.side === side && e.column === true && e.ring === ring)?.id ?? \"$\";\n for (const t of ts) {\n if (t.free) continue;\n const p = t.place;\n if (p.kind === \"gap\" || (p.kind === \"home\" && ownEdge)) {\n const edge = p.kind === \"gap\" ? p.edge : ownEdge!;\n const axis = axisOfEdge(edge);\n const layout = p.kind === \"home\" ? seen : t.after(ORIGIN, ORIGIN).layout;\n const landing = p.kind === \"home\" ? own!.rect : layout.items[dragged]?.rect;\n if (!landing) continue;\n const zone = p.kind === \"gap\" ? p.zone : (own?.zone ?? \"start\");\n const n = neighbors(layout, edge, dragged, axis);\n const id = n.before === \"^\" && n.next === \"$\" ? `${edge}/${zone}` : `${edge}/${zone}/${n.before}|${n.next}`;\n raws.push({ lane: edge, edge, axis, id, ...n, landing, layout, target: t, hit: t.hit, ...(p.kind === \"home\" ? { home: true as const } : {}) });\n } else if (p.kind === \"column\" || p.kind === \"rail\") {\n const layout = t.after(ORIGIN, ORIGIN).layout;\n const landing = layout.items[dragged]?.rect;\n if (!landing) continue;\n const lane = p.kind === \"column\" ? `column:${p.side}:${columnKey(p.side, p.ring)}` : `rail:${p.side}`;\n // A rail drop strip's lane is the strip at the window's side (`railStripWidth`), even where a column lies there:\n // never its hit band or its landing (the column drawn as a rail), so a plain drop in that column goes by halves.\n const strip = p.kind === \"rail\" && t.strip ? t.strip : undefined;\n raws.push({ lane, edge: null, axis: \"y\", id: `${lane}/${p.kind === \"rail\" ? \"end\" : \"line\"}`, before: \"^\", next: \"$\", landing, layout, target: t, hit: strip ?? t.hit, ...(strip ? { strip: true as const } : {}) });\n }\n }\n // The layout as seen with the held item lifted: solved once per lift, read by every stretch and by the marks.\n const lifted = liftedLayout(state, dragged, options);\n // A bar's free stretches: one sliding spot each, which takes over the docks landing inside it; else spots at `pitch`,\n // each a dock keeping `space` (`DockItem.space`).\n if (options.stretchPositions !== \"pitched\") {\n const { spots, absorbed } = slidingSpots(state, dragged, options, seen, lifted, raws, pitch > 0 ? pitch : SPOT_PITCH);\n for (let i = raws.length - 1; i >= 0; i--) if (absorbed.has(raws[i]!)) raws.splice(i, 1);\n raws.push(...spots);\n } else if (pitch > 0) raws.push(...pitchedSpots(state, dragged, options, seen, lifted, raws, pitch));\n // Over a neighbor itself, the item takes its place and the neighbor gives way, in either mode (`takeoverSpots`).\n raws.push(...takeoverSpots(state, dragged, options, seen, lifted, raws, pitch > 0 ? pitch : SPOT_PITCH));\n const byLane = new Map<string, Raw[]>();\n for (const r of raws) byLane.set(r.lane, [...(byLane.get(r.lane) ?? []), r]);\n // Panel columns take a panel by halves of the panels drawn; bars and toolbar rails by the gap between landings.\n const halves = new Set(state.edges.filter((e) => (e.side === \"left\" || e.side === \"right\") && !e.compact).map((e) => e.id));\n // A growing item's drawn length past its natural one is free stretch for the marks, as it is for pitched spots.\n const marking: Marking = {\n pitch,\n natural: (id, axis) => {\n const main = state.items[id]?.forms[axis === \"x\" ? \"row\" : \"column\"]?.[0]?.main;\n return main?.grows ? main.natural : undefined;\n },\n gap: (edge) => nonNeg(state.edges.find((e) => e.id === edge)?.gap),\n crossing: (edge, over) => state.edges.filter((e) => e.id !== edge && byLane.has(e.id) && (over.edges[e.id]?.cross ?? 0) > EPS && axisOfEdge(e.id) !== axisOfEdge(edge)).map((e) => over.edges[e.id]!.rect),\n };\n // Where the pointer holds the item, as a share of its length now, along its own length only (its longer side): a\n // landing of another length along that axis is held at the same share; across the item, where the share says only\n // where across a thin rail or bar it was pressed, the middle.\n const shareOf = (g: number | undefined, size: number): number => (g === undefined || !Number.isFinite(g) || size <= EPS ? 0.5 : clamp(g / size, 0, 1));\n const w = own?.rect.width ?? 0;\n const h = own?.rect.height ?? 0;\n const share = { x: w >= h ? shareOf(options.grab?.x, w) : 0.5, y: h > w ? shareOf(options.grab?.y, h) : 0.5 };\n const built = [...byLane].map(([id, list]) => laneFrom(id, list, seen, seen, dragged, rs, halves.has(id), share, marking)).filter((l): l is DockLane => !!l);\n // Each lane's marks as seen: the window as seen is one layout (`marksIn`'s rule over it), the held item drawn nowhere.\n // `dockDrag`'s rest reads these.\n const laneList = newColumnsGiveWay(built.map((l) => settle(l, seen, state, dragged, built, options.emptyLanes)), (l) => l.id, state).map((l) => clearOfRail(l, seen, byLane.get(l.id)));\n const onLanes = new Set(laneList.map((l) => l.id));\n const rails = Object.values(seen.rails).flatMap((r) => (r && r.rect.width > EPS && r.rect.height > EPS ? [r.rect] : []));\n const blocked = [\n ...Object.values(seen.edges).filter((e) => e.cross > EPS).map((e) => e.rect),\n ...Object.entries(seen.items).filter(([id, it]) => id !== dragged && !it.floating && !it.inMenu).map(([, it]) => it.rect),\n ...keepClearFor(state, \"targets\"),\n ...rails,\n // A held tile's own rail: every stop is home's in `targets()`, with the new-column lines about its folded column\n // joined to it (the strip beside the rail). A home place takes no float, so it is blocked as `targets()` has it.\n ...(own?.rail ? ts.filter((t) => t.place.kind === \"home\" && parseTargetId(t.id)?.kind === \"rail\").flatMap((t) => t.hits ?? [t.hit]) : []),\n // Spots where a release cancels (`DockState.blocked`): no float lands there.\n ...(state.blocked ?? []),\n ];\n return {\n raws: byLane,\n lanes: laneList,\n seen,\n refusals: rs,\n halves,\n share,\n marking,\n regions: {\n refused: rs.filter((f) => !onLanes.has(f.edge)).flatMap((f) => f.hits ?? [f.hit]),\n content: floatRegion(state, dragged),\n blocked,\n stage: state.stage,\n floatRegion: floatRegion(state, dragged),\n item: own ? { width: own.rect.width, height: own.rect.height } : { width: 0, height: 0 },\n float: ts.find((t) => t.free) ?? null,\n refusals: rs,\n },\n };\n}\n\n/**\n * A new column's lane gives way to the side's drawn rail, as the layout as seen draws it: the rail owns its rect (a\n * column line's zone starts where the rail ends, and the rest of the rail is the rail's, home for a tile of it), so the\n * lane's hit rect is what is left of it less the rail (the largest piece, as a target's `hit` is), never over the rail,\n * though the column's box lands where a lifted tile's rail was. Only the hit rect (what a pointer is in) is cut; the\n * lane's marks are laid in the layout that makes the column. A new column's lane is one whose spots' drops are a\n * `column` place (`raws`: the lane's raw spots).\n */\nfunction clearOfRail(lane: DockLane, seen: DockLayout, raws: readonly Raw[] | undefined): DockLane {\n const place = raws?.[0]?.target.place;\n const rail = place?.kind === \"column\" ? seen.rails[place.side] : undefined;\n if (!rail || rail.segments.length === 0) return lane;\n const pieces = subtract(lane.rect, rail.rect);\n if (pieces.length === 0) return lane;\n const largest = pieces.reduce((m, p) => (area(p) > area(m) ? p : m));\n return largest === lane.rect ? lane : { ...lane, rect: largest };\n}\n\n/**\n * A lane's rect over the layout `over`: the edge as drawn there, else (an empty edge, a virtual lane) the band its drops\n * are drawn at. At a corner an empty edge's lane gives way to a drawn edge across it, as its marks do (`settle`): the\n * band is clipped along its axis to stop at that edge's side, so a pointer on the drawn edge is in that edge's lane.\n * Between two edges not drawn the corner is as it was. `band`: the band whole, for an empty edge.\n *\n * One layout (decision 0002): whether and where the lane gives way is read in `over` itself. Over the layout as seen it\n * is the lane's hit rect; over a state's layout, the rect its marks are clipped to there.\n */\nfunction laneRectOver(list: readonly Raw[], over: DockLayout, marking: Marking): { rect: Rect; band?: Rect } {\n const first = list[0]!;\n const axis = first.axis;\n const edgeLayout = first.edge ? over.edges[first.edge] : undefined;\n const band = list.map((r) => r.landing).reduce(hull);\n if (!edgeLayout) return { rect: list.every((r) => r.strip) ? list.map((r) => r.hit).reduce(hull) : list.map((r) => r.hit).reduce(hull, band) };\n const drawnAt = drawnRect(over, first.edge!);\n if (drawnAt) return { rect: drawnAt };\n const whole = axis === \"x\" ? rect(edgeLayout.rect.x, band.y, edgeLayout.rect.width, band.height) : rect(band.x, edgeLayout.rect.y, band.width, edgeLayout.rect.height);\n return { rect: clipAtDrawn(whole, axis, marking.crossing(first.edge!, over)), band: whole };\n}\n\n/** Whether `layout` draws the edge `id`: open (wider than nothing across), or a column folded into its side's rail. Internal. */\nexport function drawnIn(layout: DockLayout, id: string): boolean {\n return drawnRect(layout, id) !== undefined;\n}\n\n/**\n * Where `layout` draws the edge `id`: its rect when open; when folded into its side's rail, the run of its tiles there (the\n * hull of its segments, as `targets()` cuts it: the rest of the rail is other columns' tiles, or nothing); else undefined.\n */\nfunction drawnRect(layout: DockLayout, id: string): Rect | undefined {\n const e = layout.edges[id];\n if (!e) return undefined;\n if (e.cross > EPS) return e.rect;\n if (!e.folded) return undefined;\n const run = Object.values(layout.rails).flatMap((r) => r?.segments.filter((g) => g.edge === id).map((g) => g.rect) ?? []);\n return run.length > 0 ? run.reduce(hull) : undefined;\n}\n\n/**\n * One lane from its spots: its hit rect and its spots in order with their stretches (both as seen; a panel column cut\n * by halves of what `drawn` draws), its refused stretches, and its marks in `drawn`: the held item among its items where\n * `showsHeld` (a spot's layout that draws it here), else drawn nowhere; each neighbor's giving way judged in `drawn`.\n * `besideFloor`: the shortest room beside the held item that is a box (a sliding spot's: any).\n */\nfunction laneFrom(id: string, list: readonly Raw[], drawn: DockLayout, seen: DockLayout, dragged: string, rs: readonly DockRefusal[], halves: boolean, share: { readonly x: number; readonly y: number }, marking: Marking, showsHeld = false, besideFloor?: number): DockLane | null {\n if (list.length === 0) return null;\n const first = list[0]!;\n const axis = first.axis;\n // The lane's rect as seen, and the band an empty edge's marks are laid over (`settle` cuts them at the drawn edges).\n const { rect: laneRect, band: markBand } = laneRectOver(list, seen, marking);\n // In order; one landing is one spot (the item's own place where it is one of them); one id is one spot.\n // A sliding spot lies in order by its first landing (at its stretch's start), and cuts by its landing at either end.\n const firstOf = (r: Raw): Rect => r.slide?.first ?? r.landing;\n const lastOf = (r: Raw): Rect => r.slide?.last ?? r.landing;\n const sorted = [...list].sort((a, b) => mid(firstOf(a), axis) - mid(firstOf(b), axis) || (a.home ? -1 : b.home ? 1 : 0));\n // On a bar or a toolbar rail the item's own place is one landing for half a pitch around it: another spot landing\n // that near (a center dock beside a place near the middle) is home's, so away and back to the press point is home.\n const homeAt = halves ? undefined : list.find((r) => r.home)?.landing;\n const nearHome = (r: Raw): boolean => !!homeAt && !r.home && !r.slide && Math.abs(lo(r.landing, axis) - lo(homeAt, axis)) < Math.max(0, marking.pitch) / 2;\n // Each against the spots kept so far (not one dropped as home's), the item's own place winning its landing: a dock\n // landing a fraction of a pixel before it (sorted first) never takes its place.\n const unique: Raw[] = [];\n for (const x of sorted) {\n if (nearHome(x)) continue;\n const k = unique.findIndex((y) => (!x.slide && !y.slide && sameRect(y.landing, x.landing)) || y.id === x.id);\n if (k < 0) unique.push(x);\n else if (x.home && !unique[k]!.home && !unique.some((y) => y.id === x.id && y !== unique[k])) unique[k] = x;\n }\n const start = lo(laneRect, axis);\n const end = start + len(laneRect, axis);\n // The cuts are made over the lane's band whole (an empty edge's before its clip at a drawn edge), then the stretches are\n // clipped to the lane: the clip hands the drawn edge only the stretch that lies on it. A spot whose stretch lies there\n // whole is that edge's (the pointer there is in its lane); the spot whose stretch the clip falls in starts at the clip,\n // so the clip leaves no spot with no stretch, and none a pointer off the drawn edge reached goes.\n const whole = markBand ?? laneRect;\n const bandStart = lo(whole, axis);\n const bandEnd = bandStart + len(whole, axis);\n // The cut between two spots. In a panel column (`halves`), between two spots sharing a neighbor, that item's middle in\n // `drawn` (the upper half above it, the lower half below); else halfway across the gap between their landings (each in\n // its own layout), so the pointer is at the landing it picks, or as near one as the other: a toolbar moved along a bar\n // or a rail stays at the hand however wide its neighbors (R12: a long neighbor between two landings puts a gap between\n // them, and halfway across it the pointer is at the landing it picks). Off a panel column, where two landings overlap\n // (spots a pitch apart over a free stretch, the pointer inside both) the cut is measured where the item is held:\n // moved by the grab's share past the middle, so with landings of one length it lies halfway between the points the\n // pointer holds in each, and a pointer at its press point lies on the item's own place. Kept inside the lane and in\n // order.\n const drawnItems = first.edge && halves ? new Map(onEdge(drawn, first.edge, dragged, axis).map((o) => [o.id, o.r])) : new Map<string, Rect>();\n const held = halves ? 0.5 : share[axis];\n const cuts: number[] = [];\n for (let i = 0; i + 1 < unique.length; i++) {\n const a = unique[i]!;\n const b = unique[i + 1]!;\n const shared = a.next === b.before && a.next !== \"$\" ? drawnItems.get(a.next) : undefined;\n // (A sliding spot's facing end: its landing flush against the neighbor between them.)\n const aLanding = lastOf(a);\n const bLanding = firstOf(b);\n const aEnd = lo(aLanding, axis) + len(aLanding, axis);\n const across = (aEnd + lo(bLanding, axis)) / 2;\n // Overlapping landings: at the grab, kept within half a pitch of their overlap (the pointer never further than that\n // from the landing it picks: two spots far apart that overlap a little cut near the overlap, as apart). Apart (a gap\n // between them): halfway across the gap, the grab aside.\n const overlap = lo(bLanding, axis) < aEnd - EPS;\n const slack = Math.max(0, marking.pitch) / 2;\n const atGrab = clamp(across + ((held - 0.5) * (len(aLanding, axis) + len(bLanding, axis))) / 2, lo(bLanding, axis) - slack, aEnd + slack);\n const raw = shared ? mid(shared, axis) : overlap ? atGrab : across;\n cuts.push(clamp(Math.max(raw, cuts[i - 1] ?? bandStart), bandStart, bandEnd));\n }\n const spots: DockSpot[] = unique.flatMap((x, i) => {\n const a = i === 0 ? bandStart : cuts[i - 1]!;\n const b = i === unique.length - 1 ? bandEnd : cuts[i]!;\n const along = [clamp(a, start, end), clamp(b, start, end)] as const;\n // Left out only where the clip took its whole stretch (never the item's own place).\n return along[1] - along[0] > EPS || b - a <= EPS || x.home ? [{ x, along }] : [];\n }).map(({ x, along }) => ({\n id: x.id,\n along,\n landing: x.landing,\n target: x.target,\n ...(x.home ? { home: true as const } : {}),\n ...(x.pitched ? { pitched: true as const } : {}),\n ...(x.slide ? { slide: { from: x.slide.from, to: x.slide.to, snaps: x.slide.snaps, snapDistance: x.slide.snapDistance, step: x.slide.step } } : {}),\n others: othersKey(x.layout, dragged),\n }));\n // The item's length along the lane: its shortest landing here. A refused stretch shorter than it joins its spots.\n const itemLen = Math.min(...unique.map((x) => len(x.landing, axis)));\n const refused: LaneRefusal[] = first.edge\n ? rs\n .filter((f) => f.edge === first.edge)\n .flatMap((f) => (f.hits ?? [f.hit]).map((h) => ({ along: [clamp(lo(h, axis), start, end), clamp(lo(h, axis) + len(h, axis), start, end)] as const, reason: f.reason })))\n .filter((f) => f.along[1] - f.along[0] >= itemLen - EPS)\n : [];\n // The places a drop here lands: its spots' neighbors (`<before>|<after>`), so a mark lies only where one lands.\n const places = new Set(unique.map((x) => `${x.before}|${x.next}`));\n // Marks lie in the layout as drawn, so on the edge as drawn there: a held spot's room can move the whole edge (a bar\n // it leaves empty lets a rail start higher), and its items with it.\n // An edge `drawn` doesn't draw lays its marks along its band in `drawn` too (one layout); the band as seen is the hit\n // rect's only. A column `drawn` folds into its side's rail (zero wide, its items the rail's segments) lays them along\n // that rail: the band it is drawn in there, not the open column's.\n const drawnEdge = first.edge ? drawn.edges[first.edge] : undefined;\n const markRect = (first.edge ? drawnRect(drawn, first.edge) : undefined) ?? laneRectOver(list, drawn, marking).band ?? markBand ?? laneRect;\n // The items as drawn, a growing one (a title filling the bar) at its natural length: what it draws past that is free\n // stretch, as pitched spots take it (the head of a title bar).\n // (Bars and toolbar rails only: a panel filling its column is drawn there.) Off the held lane the lifted item is\n // drawn nowhere on it (it is at the pointer or in another lane): its own place is free stretch like any other.\n const marked = first.edge\n ? onEdge(drawn, first.edge, showsHeld ? \"\" : dragged, axis).map((o) => {\n const n = o.id === dragged || halves ? undefined : marking.natural(o.id, axis);\n return n !== undefined && n < len(o.r, axis) ? { ...o, r: along(o.r, axis, lo(o.r, axis), lo(o.r, axis) + n) } : o;\n })\n : [];\n // Where each place lands (`<before>|<after>`, not a pitched spot's): a short room is drawn as its spot lands. On bars\n // and toolbar rails only; a panel column keeps its lines.\n const landings = new Map<string, { landing: Rect; layout: DockLayout }>();\n // A sliding spot's layout is its stretch's: every landing in it leaves its neighbors in the same forms and places.\n if (!halves) for (const x of unique) if (!x.pitched && !x.home && !landings.has(`${x.before}|${x.next}`)) landings.set(`${x.before}|${x.next}`, { landing: x.landing, layout: x.layout });\n // An item's extent along the lane as marks read it: a growing one at its natural length.\n const extent = (iid: string, r: Rect): [number, number] => {\n const n = halves ? undefined : marking.natural(iid, axis);\n return [lo(r, axis), lo(r, axis) + (n !== undefined && n < len(r, axis) ? n : len(r, axis))];\n };\n // (An edge `drawn` has no trace of, a dynamic column it deletes, marks nothing there: the layout that creates it does.)\n const marks = first.edge && !drawnEdge ? [] : first.edge\n ? edgeMarks(id, markRect, axis, marked, refused, itemLen, (pair) => places.has(pair) || pair.split(\"|\").includes(dragged), dragged, {\n besideMin: besideFloor ?? (halves || marking.pitch <= 0 ? itemLen : marking.pitch),\n gap: marking.gap(first.edge),\n landingOf: (pair) => landings.get(pair),\n // Judged against the layout the marks are drawn in: one layout, the screen's.\n givesWay: (iid, side, after) => givesWay(drawn.items[iid], after.items[iid], id, side, (r) => extent(iid, r)),\n })\n : virtualMarks(id, unique, drawn.items[dragged]);\n return { id, rect: laneRect, axis, spots, refused, marks, ...(list.every((r) => r.strip) ? { owns: true as const } : {}) };\n}\n\n/** A rect spanning `[a, b]` along `axis` and `r` across it. */\nconst along = (r: Rect, axis: Axis, a: number, b: number): Rect => (axis === \"x\" ? rect(a, r.y, b - a, r.height) : rect(r.x, a, r.width, b - a));\nconst LINE = 2;\n\n/** Below this a box piece isn't drawn (a host insets a box 2 px a side). */\nconst MIN_BOX = 8;\n/**\n * The striped end inside a box whose room partly fits, px: a cue that the neighbor there gives way, never a measure\n * (about 6 px drawn, inside a box a host insets 2 px).\n */\nexport const HATCH_END = 8;\n/**\n * A striped column edge's thickness, px: where an empty lane's band lies over items that move aside when it opens\n * (about 6 px drawn, 2 px clear of the window's edge).\n */\nexport const HATCH_EDGE = 8;\n\n/**\n * An edge lane's marks, its items as drawn (the held one included): a box over each free stretch at least the item's\n * length, less its refused stretches. Beside the held item the room left of its free stretch is a box from `besideMin`\n * (a pitch on a bar or a toolbar rail, where the item slides there by a spot a pitch over; the item's length in a\n * panel column), named `:before` or `:after` it so the box keeps its id while the item glides along the stretch. Room\n * that partly fits (from a pitch, shorter than the item; bars and toolbar rails, where its spot's landing is known): a\n * box over it with a striped end (`HATCH_END`) inside it at each side whose neighbor gives way. Room under a pitch\n * (none free but the edge's gap, at a lane's end too): a line at the middle of the gap. Only where a drop lands\n * (`lands(<before>|<after>)`: a spot between those two, or beside the held item): none beside fixed chrome nothing lands\n * next to. A mark never covers an item.\n */\nfunction edgeMarks(\n lane: string,\n laneRect: Rect,\n axis: Axis,\n items: readonly { id: string; r: Rect }[],\n refused: readonly LaneRefusal[],\n itemLen: number,\n lands: (pair: string) => boolean,\n held: string,\n more: {\n readonly besideMin: number;\n readonly gap: number;\n /** The spot between `<before>|<after>`: where the item lands and the layout after its drop. */\n readonly landingOf: (pair: string) => { readonly landing: Rect; readonly layout: DockLayout } | undefined;\n /** Whether a neighbor `side` of a room gives way in `after`, the layout after a drop there (`givesWay`). */\n readonly givesWay: (id: string, side: \"before\" | \"after\", after: DockLayout) => unknown;\n },\n): DockMark[] {\n const { besideMin } = more;\n /** The striped ends inside the box piece `[p, q]` of the room `[a, b]`, at the ends that touch a neighbor that gives way. */\n const hatches = (pair: string, a: number, b: number, p: number, q: number, gl: string | null, gr: string | null): void => {\n if (gl && Math.abs(p - a) < EPS) out.push({ id: `${lane}/hatch/${pair}:before`, kind: \"hatch\", rect: along(laneRect, axis, p, p + Math.min(HATCH_END, (q - p) / 2)), givesWay: gl });\n if (gr && Math.abs(q - b) < EPS) out.push({ id: `${lane}/hatch/${pair}:after`, kind: \"hatch\", rect: along(laneRect, axis, q - Math.min(HATCH_END, (q - p) / 2), q), givesWay: gr });\n };\n const heldAt = items.find((o) => o.id === held);\n const heldSpan: [number, number] | null = heldAt ? [lo(heldAt.r, axis), lo(heldAt.r, axis) + len(heldAt.r, axis)] : null;\n const out: DockMark[] = [];\n const start = lo(laneRect, axis);\n const end = start + len(laneRect, axis);\n const ends = [{ id: \"^\", a: start, b: start }, ...items.map((o) => ({ id: o.id, a: lo(o.r, axis), b: lo(o.r, axis) + len(o.r, axis) })), { id: \"$\", a: end, b: end }];\n const isRefused = (v: number): boolean => refused.some((f) => v >= f.along[0] && v <= f.along[1]);\n for (let i = 0; i + 1 < ends.length; i++) {\n // Kept inside the lane: an item drawn past its end (a rider, a lent edge) leaves no mark outside it.\n const a = clamp(ends[i]!.b, start, end);\n const b = clamp(ends[i + 1]!.a, start, end);\n const pair = `${ends[i]!.id}|${ends[i + 1]!.id}`;\n if (ends[i + 1]!.a < start - EPS || ends[i]!.b > end + EPS || !lands(pair)) continue;\n // Named by what it separates other than the held item (that is the held item's own place, and it moves): a mark\n // keeps its id while the held item hops past it.\n const left = ends[i]!.id === held ? (ends[i - 1]?.id ?? \"^\") : ends[i]!.id;\n const right = ends[i + 1]!.id === held ? (ends[i + 2]?.id ?? \"$\") : ends[i + 1]!.id;\n const named = `${left}|${right}`;\n // The room before or after the held item (the rest of the free stretch it lies in): a box from `besideMin`.\n const beside = ends[i + 1]!.id === held ? \"before\" : ends[i]!.id === held ? \"after\" : null;\n const min = beside ? Math.min(itemLen, besideMin) : itemLen;\n // The neighbors that give way when the item lands in this room (`givesWay`: it moves away, leaves the lane or steps\n // down to a shorter form), each a striped end (`HATCH_END`) inside the room's box at its side, whether or not the\n // room as seen is shorter than the item; where none does, the box is plain. Nothing is drawn on the neighbor. Not\n // beside the held item (its own place), not in a refused stretch.\n const spot = !beside && named === pair && items.length > 0 && !isRefused((a + b) / 2) ? more.landingOf(pair) : undefined;\n const gl = spot && left !== \"^\" && more.givesWay(left, \"before\", spot.layout) ? left : null;\n const gr = spot && right !== \"$\" && more.givesWay(right, \"after\", spot.layout) ? right : null;\n if (b - a < min - EPS) {\n // Room that partly fits (at least a pitch, shorter than the item): a box over the free room, its striped ends at\n // the neighbors that give way. Under a pitch, a line (below: no free room).\n if (spot && b - a >= besideMin - EPS) {\n // Less what a refused stretch takes, and never under the held item.\n let ps: [number, number][] = [[a, b]];\n for (const f of refused) ps = ps.flatMap(([p, q]): [number, number][] => [[p, Math.min(q, f.along[0])], [Math.max(p, f.along[1]), q]]);\n if (heldSpan) ps = ps.flatMap(([p, q]): [number, number][] => [[p, Math.min(q, heldSpan[0])], [Math.max(p, heldSpan[1]), q]]);\n ps = ps.filter(([p, q]) => q - p >= MIN_BOX - EPS);\n ps.forEach(([p, q], k) => {\n out.push({ id: `${lane}/box/${pair}${k ? `#${k}` : \"\"}`, kind: \"box\", rect: along(laneRect, axis, p, q) });\n hatches(pair, a, b, p, q, gl, gr);\n });\n if (ps.length > 0) continue;\n }\n // As thick as the gap allows, up to `LINE`: zero between items with no gap (the host strokes it). Also at an end\n // of the lane next to an item where nothing above draws it, unless refused there; none where the lane holds\n // nothing, and none beside the held item (its own edge, not a place).\n const t = Math.max(0, Math.min(LINE, b - a)) / 2;\n if (items.length > 0 && named === pair && !isRefused((a + b) / 2)) out.push({ id: `${lane}/line/${pair}`, kind: \"line\", rect: along(laneRect, axis, (a + b) / 2 - t, (a + b) / 2 + t) });\n continue;\n }\n // The free stretch less its refused parts: one box per piece the item still fits in.\n let pieces: [number, number][] = [[a, b]];\n for (const f of refused) pieces = pieces.flatMap(([p, q]) => [[p, Math.min(q, f.along[0])] as [number, number], [Math.max(p, f.along[1]), q] as [number, number]]).filter(([p, q]) => q - p > EPS);\n let k = 0;\n for (const [p, q] of pieces) {\n if (q - p < min - EPS) continue;\n // Beside the held item, named by its side of it; else the held item between two free stretches would name both\n // alike (the one after it is the second).\n const base = `${lane}/box/${named}${beside ? `:${beside}` : \"\"}${k++ ? `#${k - 1}` : \"\"}`;\n out.push({ id: out.some((m) => m.id === base) ? `${base}~2` : base, kind: \"box\", rect: along(laneRect, axis, p, q) });\n hatches(pair, a, b, p, q, gl, gr);\n }\n }\n return out;\n}\n\n/**\n * A virtual lane's marks: a box at each landing; where the held item is drawn over it, a line instead, along the\n * landing's side away from the item.\n */\nfunction virtualMarks(lane: string, spots: readonly Raw[], held: { rect: Rect; floating?: boolean } | undefined): DockMark[] {\n return spots.map((s) => {\n const l = s.landing;\n if (!held || held.floating || !overlaps(l, held.rect)) return { id: `${lane}/box/${s.id}`, kind: \"box\" as const, rect: l };\n const x = mid(held.rect, \"x\") < mid(l, \"x\") ? l.x + l.width : l.x;\n return { id: `${lane}/line/${s.id}`, kind: \"line\" as const, rect: rect(x, l.y, 0, l.height) };\n });\n}\n\n/**\n * The lane with its marks clipped to `r`, its rect in the layout they are drawn in, the pieces left empty dropped; a\n * line (a joint, kept whole or not at all) is kept only if it lies inside. The lane itself when nothing changes.\n */\nfunction inLane(l: DockLane, r: Rect): DockLane {\n const marks = l.marks.flatMap((m): DockMark[] => {\n const x0 = Math.max(m.rect.x, r.x);\n const y0 = Math.max(m.rect.y, r.y);\n const x1 = Math.min(m.rect.x + m.rect.width, r.x + r.width);\n const y1 = Math.min(m.rect.y + m.rect.height, r.y + r.height);\n if (m.kind === \"line\") return x1 - x0 >= m.rect.width - EPS && y1 - y0 >= m.rect.height - EPS ? [m] : [];\n if (x1 - x0 <= EPS || y1 - y0 <= EPS) return [];\n return x1 - x0 >= m.rect.width - EPS && y1 - y0 >= m.rect.height - EPS ? [m] : [{ ...m, rect: rect(x0, y0, x1 - x0, y1 - y0) }];\n });\n return marks.length === l.marks.length && marks.every((m, i) => m === l.marks[i]) ? l : { ...l, marks };\n}\n\n/**\n * A lane's marks against the others in `drawn`, so no two lanes' guides overlap and each follows the layout:\n * - At a corner, a lane not drawn (an empty bar or rail, a virtual lane: only the band its drops would draw at) gives\n * way to a drawn edge across it; between two not drawn, a bar owns the corner (as it does once drawn).\n * - A lane not drawn is drawn by `emptyLanes`: `\"real\"`, its boxes as they are, at the size it will take, over what\n * moves aside (the page, a column's panels); `\"edge\"`, each box a thin striped strip (`HATCH_EDGE`) on its window\n * side. Either way never over an item docked in a bar or a toolbar rail (it stays where it is): cut around it.\n * - Every mark first lies inside its lane's rect in the layout the marks are drawn in (`inLane`, `within`): a mark shows\n * where a drop goes, and a drop is possible only where the lane takes the pointer. So the corner rules above compare\n * lanes by what each really covers. As seen, that is the lane's rect. In a held frame every lane is drawn in the held\n * spot's own layout, where the drop may move its edge (a rail starting higher once a bar is left empty, a column\n * pushed aside by a rail that opens): every lane is clipped to its rect over the spot's layout (`laneRectOver` that\n * layout, `within`); its hit `rect`, for the landing model, stays as seen.\n */\nfunction settle(lane: DockLane, drawn: DockLayout, state: DockState, dragged: string, all: readonly DockLane[], emptyLanes: \"real\" | \"edge\" = \"real\", within: Rect = lane.rect): DockLane {\n const l = inLane(lane, within);\n const edgeOf = (id: string) => state.edges.find((e) => e.id === id);\n const isDrawn = (id: string): boolean => !!edgeOf(id) && drawnIn(drawn, id);\n const across = (side: string | undefined): Axis => (side === \"top\" || side === \"bottom\" ? \"x\" : \"y\");\n const cuts: Rect[] = [];\n if (!isDrawn(l.id)) {\n for (const e of state.edges) {\n const de = e.id !== l.id && across(e.side) !== l.axis ? drawnRect(drawn, e.id) : undefined;\n if (de) cuts.push(de);\n }\n if (l.axis === \"y\") for (const o of all) if (o.id !== l.id && o.axis === \"x\" && !isDrawn(o.id)) cuts.push(o.rect);\n }\n const empty = !isDrawn(l.id);\n // What an empty lane's marks never cover: items docked in a bar or a toolbar rail (they don't move aside when it opens,\n // unlike the page or a column's panels).\n const barOrRail = (edge: string | undefined): boolean => {\n const e = edge ? edgeOf(edge) : undefined;\n return !!e && (e.side === \"top\" || e.side === \"bottom\" || !!e.compact);\n };\n const stays = empty\n ? Object.entries(drawn.items)\n .filter(([id, it]) => id !== dragged && it.edge !== l.id && barOrRail(it.edge) && !it.floating && !it.inMenu && it.rect.width > EPS && it.rect.height > EPS)\n .map(([, it]) => it.rect)\n : [];\n if (cuts.length === 0 && !(empty && (emptyLanes === \"edge\" || l.marks.some((m) => m.kind === \"box\" && stays.some((s) => overlaps(m.rect, s)))))) return l;\n const cut = (r: Rect, cs: readonly Rect[]): [number, number][] => piecesLess(r, l.axis, cs);\n const marks: DockMark[] = [];\n for (const m of l.marks) {\n const kept = cut(m.rect, m.kind === \"box\" ? [...cuts, ...stays] : cuts);\n if (m.kind === \"line\") {\n // A line is kept whole or not at all (it marks a joint).\n if (kept.length === 1 && Math.abs(kept[0]![1] - kept[0]![0] - len(m.rect, l.axis)) < EPS) marks.push(m);\n continue;\n }\n kept.forEach(([p, q], i) => {\n const piece = along(m.rect, l.axis, p, q);\n const id = i ? `${m.id}~c${i}` : m.id;\n // A lane drawn, or an empty one drawn at its real size: the box as it is (an empty lane's lies over what moves\n // aside: the page, a column).\n if (m.kind !== \"box\" || !empty || emptyLanes === \"real\") return void marks.push({ ...m, id, rect: piece });\n // `\"edge\"`: a thin striped strip (`HATCH_EDGE`) on the lane's window side, its own side where it has one (an edge's,\n // a virtual lane's `<kind>:<side>`), else the side nearer the stage's edge.\n const side = edgeOf(l.id)?.side ?? (/^(rail|column):/.test(l.id) ? l.id.split(\":\")[1] : undefined);\n const st = state.stage;\n let r: Rect;\n if (l.axis === \"y\") {\n const outerRight = side === \"right\" ? true : side === \"left\" ? false : Math.abs(piece.x + piece.width - (st.x + st.width)) <= Math.abs(piece.x - st.x);\n const t = Math.min(HATCH_EDGE, piece.width);\n r = rect(outerRight ? piece.x + piece.width - t : piece.x, piece.y, t, piece.height);\n } else {\n const outerBottom = side === \"bottom\" ? true : side === \"top\" ? false : Math.abs(piece.y + piece.height - (st.y + st.height)) <= Math.abs(piece.y - st.y);\n const t = Math.min(HATCH_EDGE, piece.height);\n r = rect(piece.x, outerBottom ? piece.y + piece.height - t : piece.y, piece.width, t);\n }\n marks.push({ id: id.replace(\"/box/\", \"/hatch/\"), kind: \"hatch\", rect: r });\n });\n }\n return { ...l, marks };\n}\n\n/** `r`'s pieces along `axis` less `cs`: each one that crosses it (overlaps it across `axis`) takes its span along `axis`. */\nfunction piecesLess(r: Rect, axis: Axis, cs: readonly Rect[]): [number, number][] {\n const span = (x: Rect): [number, number] => [lo(x, axis), lo(x, axis) + len(x, axis)];\n const crosses = (c: Rect): boolean => (axis === \"x\" ? c.y < r.y + r.height - EPS && r.y < c.y + c.height - EPS : c.x < r.x + r.width - EPS && r.x < c.x + c.width - EPS);\n let ps: [number, number][] = [span(r)];\n for (const c of cs) {\n if (!crosses(c)) continue;\n const [c0, c1] = span(c);\n ps = ps.flatMap(([p, q]): [number, number][] => [[p, Math.min(q, c0)], [Math.max(p, c1), q]]).filter(([p, q]) => q - p > EPS);\n }\n return ps;\n}\n\n/**\n * The one rect subtraction for marks (internal to the package; the guides' and the sweep's too): marks less the rects\n * `cs` they overlap, along `axis`, a box or a hatch into its pieces (the first keeps its id, the others `<id><suffix><n>`).\n * Marks `cs` doesn't overlap stay as they are. Options:\n * - `suffix` (default `~c`, `settle`'s): the later pieces' id suffix;\n * - `minBox` (default 0): a box piece the cut leaves this long or shorter is dropped (before the pieces are numbered);\n * - `lines` (default `\"whole\"`): a line is kept whole or not at all (`\"whole\"`: dropped where any rect cuts it;\n * `\"covered\"`: dropped only where the rects cover it).\n */\nexport function marksLess<M extends DockMark>(marks: readonly M[], axis: Axis, cs: readonly Rect[], options: { readonly suffix?: string; readonly minBox?: number; readonly lines?: \"whole\" | \"covered\" } = {}): M[] {\n const suffix = options.suffix ?? \"~c\";\n const minBox = options.minBox ?? 0;\n return marks.flatMap((m): M[] => {\n const over = cs.filter((c) => overlaps(m.rect, c));\n if (over.length === 0) return [m];\n const kept = piecesLess(m.rect, axis, over);\n if (m.kind === \"line\") return (options.lines === \"covered\" ? kept.length > 0 : kept.length === 1 && Math.abs(kept[0]![1] - kept[0]![0] - len(m.rect, axis)) < EPS) ? [m] : [];\n return kept.filter(([p, q]) => m.kind !== \"box\" || q - p > minBox).map(([p, q], i) => ({ ...m, id: i ? `${m.id}${suffix}${i}` : m.id, rect: along(m.rect, axis, p, q) }));\n });\n}\n\nconst overlaps = (a: Rect, b: Rect): boolean => a.x < b.x + b.width - EPS && b.x < a.x + a.width - EPS && a.y < b.y + b.height - EPS && b.y < a.y + a.height - EPS;\n\n/**\n * Spots at `pitch` over the free stretches of a bar or a toolbar rail (a compact edge), along its axis: the room a drop\n * between two items makes (`stretches`; an empty one: its whole length less its padding), a start-zone dock keeping `space` before it where the\n * stretch follows a start item (or the edge's start), an end-zone dock keeping `space` after it where it precedes an end\n * item (or the edge's end). Kept only where the drop lands where it was aimed (within 1 px) and not on another spot's\n * landing. A stretch too short for the item has none, nor one bounded on both sides by zones the item cannot dock in\n * (no start-zone item or edge start before it, no end-zone item or edge end after it: no zone can take it).\n */\nfunction pitchedSpots(state: DockState, dragged: string, options: DockLaneOptions, seen: DockLayout, lifted: DockLayout, raws: readonly Raw[], pitch: number): Raw[] {\n const out: Raw[] = [];\n stretches(state, dragged, options, seen, lifted, raws, (run) => {\n const { e, axis, gap, middle } = run;\n const taken = run.mine.map((r) => r.landing);\n /**\n * One spot: a dock in `zone` before its `at`-th item keeping `space` (`DockPlace.space`), kept if it lands at `x0`\n * (within 1 px), every fixed item stays put, and it is not on another spot's landing. `flush` names the neighbor a\n * stretch's end lies against. Whether it was kept.\n */\n const emit = (zone: Zone, at: number, space: number, x0: number, flush?: string): boolean => {\n const hit = landsAt(state, dragged, run, { edge: e.id, zone, at, space }, x0);\n if (!hit) return false;\n const { next, layout } = hit;\n const landed = layout.items[dragged]!;\n // A stretch's end lies against its neighbor as dropped.\n const nb = flush !== undefined ? layout.items[flush] : undefined;\n if (nb && Math.abs(lo(nb.rect, axis) + len(nb.rect, axis) + gap - lo(landed.rect, axis)) > 1 && Math.abs(lo(landed.rect, axis) + len(landed.rect, axis) + gap - lo(nb.rect, axis)) > 1) return false;\n const n = neighbors(layout, e.id, dragged, axis);\n if (taken.some((r) => Math.abs(lo(r, axis) - lo(landed.rect, axis)) < pitch / 2)) return true;\n taken.push(landed.rect);\n const result = { state: next, layout };\n const kept = Math.round(next.items[dragged]?.space ?? 0);\n const target: DockDrop = { id: `pitch:${e.id}:${zone}:${at}:${Math.round(space)}`, priority: 2, hit: landed.rect, slot: landed.rect, item: dragged, place: { kind: \"gap\", edge: e.id, zone, at }, after: () => result };\n // Keyed by its neighbors and how many pitches it keeps from the one it is spaced from (a stretch's end keeping\n // some: the neighbor it lies against): stable while they stay.\n const id = `${e.id}/${zone}/${n.before}|${n.next}@${flush !== undefined && kept > 0 ? `to:${flush}` : Math.round(kept / pitch)}`;\n out.push({ lane: e.id, edge: e.id, axis, id, ...n, landing: landed.rect, layout, target, hit: landed.rect, pitched: true });\n return true;\n };\n return ({ a, b, w, zones, atOf, spaceAt, before, after }) => {\n // The stretch's two ends, the item flush against each neighbor (or the edge's end), the near zone first. Each is a\n // spot of the stretch's own: on the held item's own stretch the plain dock beside a neighbor is its own place.\n const end = (x0: number, order: readonly Zone[], flush: string): void => {\n for (const zone of order) if (spaceAt(zone, x0) >= -EPS && emit(zone, atOf(zone), Math.max(0, spaceAt(zone, x0)), x0, flush)) return;\n };\n end(a, zones, before?.id ?? \"^\");\n if (b - w > a + EPS) end(b - w, [...zones].reverse(), after?.id ?? \"$\");\n if (b - a < w + pitch) return;\n for (let x0 = a + pitch; x0 + w <= b - pitch + EPS; x0 += pitch) {\n const zone: Zone = x0 + w / 2 < middle ? \"start\" : \"end\";\n if (!zones.includes(zone)) continue;\n emit(zone, atOf(zone), spaceAt(zone, x0), x0);\n }\n };\n });\n return out;\n}\n\n/** One bar or toolbar rail as its free stretches read it: the held item's length on it, its gap, middle and fixed items. */\ninterface StretchEdge {\n readonly e: DockEdge;\n readonly axis: Axis;\n /** The held item's length here: a landing on this edge (a stretch's own `w` is its length on a drop there). */\n readonly w: number;\n readonly gap: number;\n readonly middle: number;\n /** The spots this edge already has (from `targets()`). */\n readonly mine: readonly Raw[];\n /** Fixed items (a title, window controls) as drawn: they keep their place, so a dock that would move one is none. */\n readonly fixed: readonly { readonly id: string; readonly r: Rect }[];\n readonly prev: { readonly previous?: DockLayout };\n}\n\n/**\n * One free stretch: `[a, b]` along the edge between its neighbors, the room a drop there makes (flush after the neighbor\n * before it, flush before the one after it, each in the form the drop leaves it in), the zones a dock there takes, and\n * its place.\n */\ninterface Stretch {\n /** The neighbors either side, as the drop finds them (the held item lifted), drawn as seen. */\n readonly before: { readonly id: string; readonly r: Rect } | undefined;\n readonly after: { readonly id: string; readonly r: Rect } | undefined;\n readonly a: number;\n readonly b: number;\n /** The held item's length on a drop here (the form the drop leaves it in). */\n readonly w: number;\n /** A start dock follows a start item or the edge's start; an end dock precedes an end item or the edge's end. */\n readonly zones: readonly Zone[];\n /** A dock in this stretch: before the zone's items that come after the stretch. */\n readonly atOf: (zone: Zone) => number;\n /** The space that puts the item at `x0`: from the stretch's start in a start zone, to its end in an end zone. */\n readonly spaceAt: (zone: Zone, x0: number) => number;\n}\n\n/**\n * Every free stretch of every bar and toolbar rail (a compact edge) that has spots, in order along each: between the\n * items as the drop finds them, the layout with the held item lifted. Its room goes back to its stretch (a placed\n * neighbor stays where it is drawn, `lift`), so every other item lies where the person sees it. A stretch is the room\n * a drop there makes, not only the room as seen: where the edge has no room for the item beside a neighbor's form as\n * seen, the drop steps that neighbor (or another item) down to a shorter form, and the stretch runs from flush after\n * the neighbor before it to flush before the one after it as the drop leaves them. `lifted` is `liftedLayout`'s, solved\n * once per lift. `visit` is called once per edge and gives what to do with each of its stretches.\n */\nfunction stretches(state: DockState, dragged: string, options: DockLaneOptions, seen: DockLayout, lifted: DockLayout, raws: readonly Raw[], visit: (edge: StretchEdge) => (stretch: Stretch) => void): void {\n if (!state.items[dragged]) return;\n const prev = options.previous ? { previous: options.previous } : {};\n const base = lifted;\n for (const e of state.edges) {\n const bar = e.side === \"top\" || e.side === \"bottom\";\n if (!bar && !e.compact) continue;\n const axis: Axis = bar ? \"x\" : \"y\";\n const mine = raws.filter((r) => r.edge === e.id);\n const drawn = base.edges[e.id] ?? seen.edges[e.id];\n if (mine.length === 0 || !drawn) continue;\n const gap = nonNeg(e.gap);\n const others = onEdge(base, e.id, dragged, axis);\n const zoneOf = (o: (typeof others)[number]): Zone => o.zone ?? \"start\";\n const w = len(mine[0]!.landing, axis);\n const each = visit({ e, axis, w, gap, middle: mid(drawn.rect, axis), mine, fixed: others.filter((o) => state.items[o.id]?.fixed), prev });\n /** A growing item's drawn length past its natural one (a title filling the bar): a dock beside it can take that. */\n const slack = (o: (typeof others)[number] | undefined): number => {\n const main = o ? state.items[o.id]?.forms[axis === \"x\" ? \"row\" : \"column\"]?.[0]?.main : undefined;\n return o && main?.grows ? Math.max(0, len(o.r, axis) - main.natural) : 0;\n };\n /** `[a, b]` between `before` and `after` as they lie in `l`: flush after the one, flush before the other. */\n const ends = (l: DockLayout, before: (typeof others)[number] | undefined, after: (typeof others)[number] | undefined): { a: number; b: number } | null => {\n const at = (o: (typeof others)[number]): Rect | null => {\n const it = l.items[o.id];\n return it && it.edge === e.id && !it.inMenu && !it.floating ? it.rect : null;\n };\n const rb = before ? at(before) : undefined;\n const ra = after ? at(after) : undefined;\n if (rb === null || ra === null) return null;\n const el = l.edges[e.id]?.rect ?? drawn.rect;\n return {\n a: before && rb ? lo(rb, axis) + len(rb, axis) - slack({ ...before, r: rb }) + gap : lo(el, axis) + nonNeg(e.pad?.start),\n // (Not before a growing item: a dock there keeps no space, the item it precedes takes all that is spare.)\n b: ra ? lo(ra, axis) - gap : lo(el, axis) + len(el, axis) - nonNeg(e.pad?.end),\n };\n };\n for (let i = 0; i <= others.length; i++) {\n const before = others[i - 1];\n const after = others[i];\n const zones: Zone[] = [...(!before || zoneOf(before) === \"start\" ? [\"start\" as const] : []), ...(!after || zoneOf(after) === \"end\" ? [\"end\" as const] : [])];\n const atOf = (zone: Zone): number => others.slice(0, i).filter((o) => zoneOf(o) === zone).length;\n // The room the drop makes, not only the room as seen: a dock here keeping no space, laid out, its neighbors in the\n // forms it leaves them in (a neighbor steps down to a shorter form where the edge has no room for the item beside\n // its form as seen) and the item in its own. The forms don't depend on the space a dock keeps (space comes out of\n // the spare length), so every dock in the stretch finds them so. As seen where no such dock lands here. A dock\n // pushes the neighbors on its zone's open side that keep no room for it; that is no room made, so at an end with\n // no zone of its own (after a start item: the stretch's end; before an end item: its start) a neighbor that gives\n // way by moving (`givesWay`) leaves the end where it is seen.\n const probe = ((): { a: number; b: number; w: number; layout: DockLayout } | null => {\n const zone = zones[0];\n if (!zone) return null;\n const next = moveTo(state, dragged, { edge: e.id, zone, at: atOf(zone), space: 0 });\n if (next === state) return null;\n const l = solve(next, prev);\n const landed = l.items[dragged];\n if (!landed || landed.inMenu || landed.edge !== e.id) return null;\n const n = neighbors(l, e.id, dragged, axis);\n if (n.before !== (before?.id ?? \"^\") || n.next !== (after?.id ?? \"$\")) return null;\n const r = ends(l, before, after);\n return r && { ...r, w: len(landed.rect, axis), layout: l };\n })();\n const seenEnds = ends(base, before, after)!;\n const pushed = (o: (typeof others)[number] | undefined, side: \"before\" | \"after\"): boolean =>\n !!o && !!probe && givesWay(base.items[o.id], probe.layout.items[o.id], e.id, side, (r) => [lo(r, axis), lo(r, axis) + len(r, axis) - slack({ ...o, r })]) === \"moves\";\n const a = probe && (zones.includes(\"start\") || !pushed(before, \"before\")) ? probe.a : seenEnds.a;\n const b = probe && (zones.includes(\"end\") || !pushed(after, \"after\")) ? probe.b : seenEnds.b;\n const wi = probe?.w ?? w;\n each({ before, after, a, b, w: wi, zones, atOf, spaceAt: (zone, x0) => (zone === \"start\" ? x0 - a : b - (x0 + wi)) });\n }\n }\n}\n\n/**\n * Where the pointer stops decides: over a stretch's free room a dock consumes the room (its ends and pitched or sliding\n * spots, the neighbors staying put), and over a neighbor itself the item takes that neighbor's place and the neighbor\n * gives way by the item's length. These are the takeover spots, one per neighbor of a stretch on its zone's side: the\n * item at the start of the start-zone item after the stretch, or at the end of the end-zone item before it, keeping the\n * space that puts it there (the neighbor keeps no room, `moveTo`). So passing a neighbor longer than the room beside\n * it, the landings either side are never further apart than the item, and the item stays at the hand. Kept where it\n * lands there with every fixed item kept and not on another spot's landing.\n */\nfunction takeoverSpots(state: DockState, dragged: string, options: DockLaneOptions, seen: DockLayout, lifted: DockLayout, raws: readonly Raw[], pitch: number): Raw[] {\n const out: Raw[] = [];\n stretches(state, dragged, options, seen, lifted, raws, (run) => {\n const { e, axis } = run;\n const taken = [...run.mine.map((r) => r.landing)];\n const emit = (zone: Zone, at: number, space: number, x0: number, nb: string): void => {\n const hit = landsAt(state, dragged, run, { edge: e.id, zone, at, space }, x0);\n if (!hit) return;\n const { next, layout } = hit;\n const landed = layout.items[dragged]!;\n if (taken.some((r) => Math.abs(lo(r, axis) - lo(landed.rect, axis)) < pitch / 2)) return;\n taken.push(landed.rect);\n const n = neighbors(layout, e.id, dragged, axis);\n const result = { state: next, layout };\n const target: DockDrop = { id: `pitch:${e.id}:${zone}:${at}:in:${nb}`, priority: 2, hit: landed.rect, slot: landed.rect, item: dragged, place: { kind: \"gap\", edge: e.id, zone, at }, after: () => result };\n out.push({ lane: e.id, edge: e.id, axis, id: `${e.id}/${zone}/${n.before}|${n.next}@in:${nb}`, ...n, landing: landed.rect, layout, target, hit: landed.rect });\n };\n return ({ w, zones, atOf, spaceAt, before, after }) => {\n const zoneOf = (id: string): Zone => (state.items[id]?.align as Zone | undefined) ?? \"start\";\n // The item at the start of the start-zone neighbor after the stretch.\n if (after && zones.includes(\"start\") && zoneOf(after.id) === \"start\" && !state.items[after.id]?.fixed) {\n const x0 = lo(after.r, axis);\n emit(\"start\", atOf(\"start\"), Math.max(0, spaceAt(\"start\", x0)), x0, after.id);\n }\n // The item at the end of the end-zone neighbor before it.\n if (before && zones.includes(\"end\") && zoneOf(before.id) === \"end\" && !state.items[before.id]?.fixed) {\n const x0 = lo(before.r, axis) + len(before.r, axis) - w;\n emit(\"end\", atOf(\"end\"), Math.max(0, spaceAt(\"end\", x0)), x0, before.id);\n }\n };\n });\n return out;\n}\n\n/** The dock `place` on `run`'s edge, if it lands the item's start at `x0` (within 1 px) with every fixed item kept. */\nfunction landsAt(state: DockState, dragged: string, run: StretchEdge, place: DockPlace, x0: number): { next: DockState; layout: DockLayout } | null {\n const next = moveTo(state, dragged, place);\n if (next === state) return null;\n const layout = solve(next, run.prev);\n const landed = layout.items[dragged];\n const { axis } = run;\n if (!landed || landed.inMenu || landed.edge !== run.e.id || Math.abs(lo(landed.rect, axis) - x0) > 1) return null;\n // A fixed item that takes steps (`stepping`) may step for the dock; one that goes into the » has no place to keep.\n const kept = (f: StretchEdge[\"fixed\"][number]): boolean => {\n const it = layout.items[f.id];\n if (it?.inMenu && itemSteps(state.items[f.id]!)) return true;\n return !!it && Math.abs(lo(it.rect, axis) - lo(f.r, axis)) <= 1;\n };\n if (!run.fixed.every(kept)) return null;\n return { next, layout };\n}\n\n/**\n * One sliding spot per free stretch of a bar or a toolbar rail (`stretchPositions: \"free\"`): the same stretches as\n * `pitchedSpots` (between the items as the drop finds them with the held item lifted, in the forms the drop leaves them\n * in, a start zone after a start item or the edge's start, an end zone before an end item or the edge's end), as one\n * range of landings from flush against the neighbor\n * before it to flush against the one after it. A landing is a dock keeping the `space` that puts the item there: in the\n * start zone left of the edge's middle, the end zone right of it (the other where the stretch has only one). The range\n * holds the landings that land where they were aimed (within 1 px) with every fixed item kept, checked at its ends and\n * every `sample` px between. The docks that land inside it with its neighbors either side (the item's own place, a plain\n * dock, a center dock) are taken over: each is a snap point that commits that dock as it is, so a center dock's snap\n * moves its center neighbor by design (the center zone re-centers its items), where a plain dock leaves its neighbors\n * put. A stretch is the room the drop makes (`stretches`: a neighbor stepping down to a shorter form counts). One\n * shorter than the item has none, nor one bounded on both sides by zones the item cannot dock in (no\n * start-zone item or edge start before it, no end-zone item or edge end after it: no zone can take it); next to a center\n * item a stretch still has one wherever a zone can take the item, and its plain docks stay spots of their own where it\n * has none.\n */\nfunction slidingSpots(state: DockState, dragged: string, options: DockLaneOptions, seen: DockLayout, lifted: DockLayout, raws: readonly Raw[], sample: number): { spots: Raw[]; absorbed: Set<Raw> } {\n const spots: Raw[] = [];\n const absorbed = new Set<Raw>();\n const snapDistance = Number.isFinite(options.snapDistance) && options.snapDistance! >= 0 ? options.snapDistance! : SNAP_DISTANCE;\n const own = seen.items[dragged];\n const ownEdge = own && !own.floating && !own.inMenu ? own.edge : undefined;\n stretches(state, dragged, options, seen, lifted, raws, (run) => ({ a, b, w, zones, atOf, spaceAt, before, after }) => {\n const { e, axis, middle, mine } = run;\n // (A stretch shorter than the item still offers its start, flush after the neighbor before it, where a dock there\n // lands: a point, below, as a pitched stretch's end gives it.)\n if (zones.length === 0) return;\n {\n /** The dock that lands the item's start at `x0`: its place, state and layout, or null where it lands elsewhere. */\n const land = (x0: number): { place: DockPlace; result: DropResult } | null => {\n const near: Zone = x0 + w / 2 < middle ? \"start\" : \"end\";\n for (const zone of [near, near === \"start\" ? (\"end\" as const) : (\"start\" as const)]) {\n if (!zones.includes(zone)) continue;\n const space = spaceAt(zone, x0);\n if (space < -EPS) continue;\n const place: DockPlace = { edge: e.id, zone, at: atOf(zone), space: Math.max(0, space) };\n const hit = landsAt(state, dragged, run, place, x0);\n if (hit) return { place, result: { state: hit.next, layout: hit.layout } };\n }\n return null;\n };\n // The range: the landings that land where aimed, at its ends and every `sample` px between.\n const tries = [a];\n for (let x0 = a + sample; x0 < b - w - EPS; x0 += sample) tries.push(x0);\n if (b - w > a + EPS) tries.push(b - w);\n const ok = tries.map((x0) => ({ x0, hit: land(x0) })).filter((t) => t.hit);\n if (ok.length === 0) return;\n const from = ok[0]!.x0;\n const to = ok.at(-1)!.x0;\n const bId = before?.id ?? \"^\";\n const nId = after?.id ?? \"$\";\n // Room for the item at a single start (no room past it, or a range under a pixel, the grain a free start lands on:\n // `STEP`) is a point, no range: a plain dock there, as a pitched stretch's end gives, unless one lands there already\n // (the item's own place, say), which stays a spot of its own. Every landing a room offers has a spot.\n if (to - from < STEP) {\n if (mine.some((r) => !r.slide && Math.abs(lo(r.landing, axis) - from) <= 1)) return;\n // Its zone as a pitched stretch's end takes it: the start zone first (flush after the neighbor before it).\n const firstZone = ((): { place: DockPlace; result: DropResult } | null => {\n for (const zone of zones) {\n const space = spaceAt(zone, from);\n if (space < -EPS) continue;\n const place: DockPlace = { edge: e.id, zone, at: atOf(zone), space: Math.max(0, space) };\n const hit = landsAt(state, dragged, run, place, from);\n if (hit) return { place, result: { state: hit.next, layout: hit.layout } };\n }\n return null;\n })();\n const { place, result } = firstZone ?? ok[0]!.hit!;\n const landed = result.layout.items[dragged]!.rect;\n const n = neighbors(result.layout, e.id, dragged, axis);\n const zone = place.zone as Zone;\n const isHome = ownEdge === e.id && !!own && Math.abs(lo(own.rect, axis) - lo(landed, axis)) <= 1 && Math.abs(len(own.rect, axis) - len(landed, axis)) <= 1;\n const target: DockDrop = { id: `pitch:${e.id}:${zone}:${place.at}:${Math.round(place.space ?? 0)}`, priority: 2, hit: landed, slot: landed, item: dragged, place: { kind: \"gap\", edge: e.id, zone, at: place.at }, after: () => result };\n // Its id: the plain dock's, or where a dock between the same neighbors has that one (landing elsewhere, the item\n // in another form), a pitched spot's (`@<pitches kept>`).\n const plain = `${e.id}/${zone}/${n.before}|${n.next}`;\n const id = mine.some((r) => r.id === plain) ? `${plain}@${Math.round((place.space ?? 0) / sample)}` : plain;\n spots.push({ lane: e.id, edge: e.id, axis, id, ...n, landing: landed, layout: result.layout, target, hit: landed, ...(isHome ? { home: true as const } : {}) });\n return;\n }\n // The docks landing inside it, its neighbors either side: snap points that commit as they are.\n const inside = mine.filter((r) => !r.slide && r.before === bId && r.next === nId && Math.abs(len(r.landing, axis) - w) <= 1 && lo(r.landing, axis) >= from - 1 && lo(r.landing, axis) <= to + 1);\n for (const r of inside) absorbed.add(r);\n const homeRaw = inside.find((r) => r.home);\n // Snap points are keyed by what they commit: a taken-over dock as it is (`raw`), else the plain dock at that start.\n // Two points are one only where they lie on the same start, the taken-over dock then winning (the item's own place\n // first), so a dock that lies near an end without lying on it keeps its own point and stays reachable.\n const points: { at: number; raw?: Raw }[] = [];\n const put = (at: number, raw?: Raw): void => {\n const same = points.find((p) => Math.abs(p.at - at) < 1e-6);\n if (!same) points.push({ at, ...(raw ? { raw } : {}) });\n else if (raw && !same.raw) same.raw = raw;\n };\n put(from);\n put(to);\n for (const r of [...inside].sort((p, q) => (p.home ? -1 : q.home ? 1 : 0))) put(lo(r.landing, axis), r);\n // The item's own place wins near it: no other snap point within twice the snap distance of it, so every start\n // within the snap distance of home snaps home (a press, a wobble and a release is home).\n const homeAt = homeRaw ? lo(homeRaw.landing, axis) : undefined;\n const kept = points.filter((p) => homeAt === undefined || Math.abs(p.at - homeAt) < 1e-6 || Math.abs(p.at - homeAt) > 2 * snapDistance).sort((p, q) => p.at - q.at);\n const snaps = kept.map((p) => p.at);\n /** The taken-over dock that commits at `x0`, if `x0` is a snap point of one. */\n const dockAt = (x0: number): Raw | undefined => kept.find((p) => Math.abs(p.at - x0) < 1e-6)?.raw;\n const shape = ok[0]!.hit!.result.layout.items[dragged]!.rect;\n const at = (x0: number): Rect => along(shape, axis, x0, x0 + w);\n /** The nearest snap point to `x0` within the snap distance, else `x0`. */\n const snapped = (x0: number): number => {\n let best = x0;\n let d = Infinity;\n for (const q of snaps) if (Math.abs(q - x0) <= snapDistance && Math.abs(q - x0) < d) [best, d] = [q, Math.abs(q - x0)];\n return best;\n };\n /** The start a pointer holding the item at `raw` lands at: `LaneSlide.step`'s rule, read by the landing model too. */\n const startAt = (raw: number): number => {\n const c = clamp(raw, from, to);\n const s = snapped(c);\n return snaps.includes(s) ? s : clamp(Math.round(c / STEP) * STEP, from, to);\n };\n const results = new Map<string, DropResult>();\n /** What a drop with the item's start at `x0` commits: a taken-over dock's own drop there, else the dock to `x0`. */\n const commitAt = (x0: number): DropResult => {\n const r = dockAt(x0);\n const k = `${r ? \"dock \" : \"\"}${Math.round(x0 * 1000) / 1000}`;\n const known = results.get(k);\n if (known) return known;\n const result = r ? r.target.after(ORIGIN, ORIGIN) : (land(x0)?.result ?? ok.reduce((p, q) => (Math.abs(q.x0 - x0) < Math.abs(p.x0 - x0) ? q : p)).hit!.result);\n results.set(k, result);\n return result;\n };\n // The landing as listed: at the item's own place where it lies here, else the stretch's point nearest it, else\n // its start.\n const rest = homeRaw ? lo(homeRaw.landing, axis) : ownEdge === e.id && own ? snapped(clamp(lo(own.rect, axis), from, to)) : from;\n const restResult = commitAt(rest);\n // Its place is the dock at that landing: the item's own (its zone and index) where it rests at home, a taken-over\n // dock's own, else the plain dock there.\n const ownZone = own?.zone as Zone | undefined;\n const restPlace = ((): { zone?: Zone; at: number; space?: number } | undefined => {\n if (homeRaw) return ownZone && zones.includes(ownZone) ? { zone: ownZone, at: atOf(ownZone), space: Math.max(0, spaceAt(ownZone, rest)) } : land(rest)?.place;\n const p = dockAt(rest)?.target.place;\n return p && p.kind === \"gap\" ? p : land(rest)?.place;\n })();\n const landing = homeRaw ? homeRaw.landing : (restResult.layout.items[dragged]?.rect ?? at(rest));\n // The grab's share along the item's own length (its longer side, as it is now); across it, the middle.\n const ownLen = own ? Math.max(own.rect.width, own.rect.height) : 0;\n const long: Axis = own && own.rect.width >= own.rect.height ? \"x\" : \"y\";\n const target: DockDrop = {\n id: `slide:${e.id}:${bId}|${nId}`,\n priority: 2,\n hit: hull(at(from), at(to)),\n slot: landing,\n item: dragged,\n place: { kind: \"gap\", edge: e.id, zone: restPlace?.zone ?? zones[0]!, at: restPlace?.at ?? atOf(zones[0]!), ...(restPlace?.space ? { space: restPlace.space } : {}) },\n after: (point: Point, grab?: Point) => {\n const g = grab ? grab[long] : ownLen / 2;\n const share = axis === long && ownLen > EPS && Number.isFinite(g) ? clamp(g / ownLen, 0, 1) : 0.5;\n return commitAt(startAt((axis === \"x\" ? point.x : point.y) - share * w));\n },\n };\n const zone = zones[0]!;\n spots.push({\n lane: e.id,\n edge: e.id,\n axis,\n id: `${e.id}/${zone}/${bId}|${nId}@slide`,\n before: bId,\n next: nId,\n landing,\n layout: restResult.layout,\n target,\n hit: target.hit,\n ...(homeRaw ? { home: true as const } : {}),\n slide: { from, to, snaps, snapDistance, step: STEP, first: at(from), last: at(to) },\n });\n }\n });\n return { spots, absorbed };\n}\n","/**\n * One layout for a drag's held frame and its commit: `dockDrag(state, dragged, options)` gives the drag's hit-testing\n * data (`regions`, as seen) and `after(held)`, THE layout of a held place of the drag. While its room is open, a held frame\n * draws every item, the landing and every guide from `after(held)` (docs/docking.md, \"What a held frame draws\"), and a\n * release commits exactly `after(held).state`.\n *\n * - **A held place** (`DockHeld`) is where a release now lands: a lane's spot with the pointer (`point`; a sliding spot\n * lands where the hand holds it, the one sliding rule `LaneSlide` states), or the float at the pointer. No held place\n * (`null`) is rest: the drag lands nowhere (home, refused, nowhere), and the layout is the window as seen, the held item\n * drawn nowhere.\n * - **`after(held)`**: the dock state a release commits and its layout (`solve` with the drag's `previous`, as the commit\n * solves it), the held item's rect there (`landing`, null at rest), every lane's marks in that one layout (`marks`),\n * and for a spot the held lane's spots with their stretches in that layout (`spots`: a panel column by halves of what\n * it draws, the hit data along a held lane). Remembered per held place.\n * - **`shown(frame)`**: the layout a landing frame draws: `after(frame.held).layout` while `frame.room` is open, else\n * the window at rest.\n * - **`guides(frame)`**: the place guides of a landing frame, each lane's from the held place it names (rule B): a lane's\n * guide is drawn in the layout on screen (`shown(frame)`), less the landing the pointer would take there; only a lane\n * that isn't drawn on screen takes the layout that creates it (its would-land held place's for the Near lane, its one\n * spot's for any other), and gives up where it meets a lane drawn on screen (between two such, the bar keeps the\n * corner). Under \"all\", the Near lane's marks win where they meet another lane's: the others are cut there.\n *\n * The shapes fit `@n-uf/motion/drag`'s landing model as they are (`regions`, `home`, `landingOf`, `spotsOf`; the frame's\n * `held` and `guides`), though neither package imports the other: `createLandingModel({ ...drag, preview })` is the whole\n * wiring.\n */\nimport { EPS, type Point, type Rect } from \"@n-uf/placement\";\nimport type { DockLayout, DockState } from \"./model\";\nimport { baseOf, drawnIn, marksIn, marksLess, rawSpot, spotsIn, type DockLaneOptions, type DockMark, type DockRegions, type DockSpot, type LaneMarks } from \"./lanes\";\nimport type { DockDrop, DropResult } from \"./targets/model\";\n\n/** A held place of a drag: where a release now lands (`@n-uf/motion/drag`'s `LandingHeld` fits it). `null` is rest (it lands nowhere). */\nexport type DockHeld =\n | {\n readonly kind: \"spot\";\n /** The spot's id (`DockSpot.id`). */\n readonly spot: string;\n /** The pointer, in the regions' space: where a sliding spot's landing starts (`LaneSlide`); a fixed spot ignores it. */\n readonly point: Point;\n }\n | {\n readonly kind: \"float\";\n /** The pointer: the float lands where it holds the item (`DockDrop.after(point, grab)`). */\n readonly point: Point;\n };\n\n/** A lane's mark in one layout, with its lane. */\nexport interface DockLaneMark extends DockMark {\n readonly lane: string;\n}\n\n/** THE layout of a held place of a drag: what a release commits, and what its held frame draws while its room is open. */\nexport interface DockAfter extends DropResult {\n /** The held item's rect in `layout`, or null at rest (and where a float can't land). */\n readonly landing: Rect | null;\n /** Every lane's marks in `layout`: no two lanes' overlap, none covers an item drawn there or the landing. */\n readonly marks: readonly DockLaneMark[];\n /** A spot's: its lane's spots with their stretches cut in `layout` (along a held lane, the spot ranges as drawn). */\n readonly spots?: readonly DockSpot[];\n}\n\n/** A place guide as a frame draws it: a lane's mark in the layout its guide stands for. */\nexport type DockGuide = DockLaneMark;\n\n/** One lane a frame shows guides for, with the held place its guide stands for (`@n-uf/motion/drag`'s `LandingGuideRef`). */\nexport interface DockGuideRef {\n readonly lane: string;\n readonly held: DockHeld | null;\n}\n\n/** What `guides` reads of a landing frame: the held place on screen, whether its room is open, and each lane shown with the held place its guide stands for. */\nexport interface DockGuideFrame {\n readonly held: DockHeld | null;\n /**\n * The room is open (`@n-uf/motion/drag`'s `LandingFrame.room`, a boolean): the host draws the window as `held` lays it\n * out. A host that draws the window at rest while a spot is held (a mode that never makes room) passes false.\n */\n readonly room: boolean;\n readonly guides: readonly DockGuideRef[];\n}\n\n/** A drag of one item: its hit-testing data as seen, and the one layout of each of its held places. */\nexport interface DockDrag {\n /** Hit-testing only: lanes (hit rect, spots' stretches, refused stretches), refused places, blocked, content, as seen. */\n readonly regions: DockRegions;\n /**\n * The item's own place at the lift: the lane and spot `lanes()` marks `home` (a docked item's). Absent for a float (a\n * lift with no home place). Fits the landing model's `home` option, so `createLandingModel({ ...drag, preview })` is the\n * whole wiring; a host that wants another home passes its own after the spread.\n */\n readonly home?: { readonly lane: string; readonly spot: string };\n /** THE layout of `held` (rest for null): the dock state it commits, its layout, landing, marks and, for a spot, its lane's spots. */\n after(held: DockHeld | null): DockAfter;\n /** `after(held).landing`: the one rect a landing model reads (its trail gate, its frame's landing). */\n landingOf(held: DockHeld): Rect | null;\n /** `after({ spot }).spots` of a spot: its lane's spots with their stretches in the spot's layout, or null. */\n spotsOf(spot: string): readonly DockSpot[] | null;\n /**\n * The layout a frame draws, the one every guide of the frame is cut in: `after(frame.held).layout` while\n * `frame.room` is open, else the window at rest (what the host draws at rest). Only a spot held in a lane has a room\n * (`LandingFrame.room`: a docked item's gap opens as the item lands there); a float has none: its gap closes on\n * release (decision 0003's float exception), so the window stays at rest and `after(float)` is only what a release\n * commits. A null held place is rest. A host that draws no room for a spot (a mode that never makes one) passes room false.\n */\n shown(frame: Pick<DockGuideFrame, \"held\" | \"room\">): DockLayout;\n /** The guides of a frame, cut in `shown(frame)`: each lane's marks from the held place it names, the Near lane's winning where they meet. */\n guides(frame: DockGuideFrame): DockGuide[];\n}\n\n/** A box piece a cut at the landing leaves this short or shorter along its lane is no room: not drawn, px. */\nconst MIN_PIECE = 8;\nconst ORIGIN = { x: 0, y: 0 };\n\n/**\n * The drag of `dragged` in `state`: `lanes()`'s regions as seen, and `after(held)`, THE layout of each held place. The\n * options are `lanes()`'s (`previous` is the committed layout at the lift, the one every solve and the commit read;\n * `grab` the press's). The work at the lift is remembered per dock state and options, as `lanes()`'s is; each held place's layout\n * is remembered by the drag.\n */\nexport function dockDrag(state: DockState, dragged: string, options: DockLaneOptions = {}): DockDrag {\n const base = baseOf(state, dragged, options);\n const regions: DockRegions = { ...base.regions, lanes: base.lanes };\n const grab = options.grab;\n const byResult = new WeakMap<DropResult, DockAfter>();\n const fixed = new Map<string, DockAfter>();\n const axisOf = new Map(base.lanes.map((l) => [l.id, l.axis] as const));\n const flat = (ls: readonly LaneMarks[]): DockLaneMark[] => ls.flatMap((l) => l.marks.map((m) => ({ ...m, lane: l.lane })));\n // At rest: the window as seen, its lanes' marks as `lanes()` gives them (one layout, the held item drawn nowhere).\n const rest: DockAfter = { state, layout: base.seen, landing: null, marks: flat(base.lanes.map((l) => ({ lane: l.id, axis: l.axis, marks: l.marks }))) };\n /** One float frame remembered: a still pointer solves nothing. */\n let lastFloat: { x: number; y: number; after: DockAfter } | null = null;\n\n const of = (result: DropResult, spot: { lane: string; slide?: boolean } | null): DockAfter => {\n const known = byResult.get(result);\n if (known) return known;\n const it = result.layout.items[dragged];\n const landing = it && !it.inMenu && (spot ? !it.floating : it.floating) ? it.rect : null;\n const spots = spot ? spotsIn(base, spot.lane, result.layout, dragged) : null;\n const out: DockAfter = { ...result, landing, marks: flat(marksIn(base, state, dragged, result.layout, spot ? (spot.slide ? \"slide\" : \"spot\") : false, options.emptyLanes)), ...(spots ? { spots } : {}) };\n byResult.set(result, out);\n return out;\n };\n\n const after = (held: DockHeld | null): DockAfter => {\n if (!held) return rest;\n if (held.kind === \"float\") {\n const float: DockDrop | null = base.regions.float;\n if (!float) return rest;\n if (lastFloat && lastFloat.x === held.point.x && lastFloat.y === held.point.y) return lastFloat.after;\n const a = of(float.after(held.point, grab), null);\n lastFloat = { x: held.point.x, y: held.point.y, after: a };\n return a;\n }\n const raw = rawSpot(base, held.spot);\n if (!raw) return rest;\n // A sliding spot commits where the hand holds it (its drops remembered per start); any other spot its one drop\n // (solved once, at the lift), remembered by its id.\n if (raw.slide) return of(raw.target.after(held.point, grab), raw);\n let a = fixed.get(held.spot);\n if (!a) fixed.set(held.spot, (a = of(raw.target.after(ORIGIN, ORIGIN), raw)));\n return a;\n };\n\n /**\n * An empty edge lane's marks in the layout that creates it: its one spot's drop (a sliding spot's at rest), where that\n * drop draws the lane, its room whole (the held item, landing elsewhere or nowhere, drawn nowhere on it; once the lane\n * is Near its would-land held place draws the landing). Null for a lane with more than one spot, a virtual lane, or one no\n * drop draws.\n */\n const createdMemo = new Map<string, DockLaneMark[] | null>();\n const created = (lane: string): DockLaneMark[] | null => {\n if (createdMemo.has(lane)) return createdMemo.get(lane)!;\n const l = base.lanes.find((x) => x.id === lane);\n // (`emptyLanes: \"edge\"` draws an empty lane as its thin strip on screen: nothing to create.)\n const raw = l && options.emptyLanes !== \"edge\" && l.spots.length === 1 && state.edges.some((e) => e.id === lane) ? rawSpot(base, l.spots[0]!.id) : null;\n // (Drawn there open, or folded into its side's rail.)\n const out = raw && drawnIn(raw.layout, lane) ? flat(marksIn(base, state, dragged, raw.layout, false, options.emptyLanes)).filter((m) => m.lane === lane) : null;\n createdMemo.set(lane, out && out.length > 0 ? out : null);\n return createdMemo.get(lane)!;\n };\n\n const landingOf = (held: DockHeld): Rect | null => after(held).landing;\n const spotsOf = (spot: string): readonly DockSpot[] | null => {\n const raw = rawSpot(base, spot);\n return raw && !raw.slide ? (after({ kind: \"spot\", spot, point: ORIGIN }).spots ?? null) : raw ? spotsIn(base, raw.lane, raw.layout, dragged) : null;\n };\n\n /**\n * What a frame draws, the one rule `shown` and `guides` read: `after(held)` while the room is open, else the window at\n * rest (a float's landing kept: the held copy lies there).\n */\n const screenOf = (frame: Pick<DockGuideFrame, \"held\" | \"room\">): DockAfter => {\n const held = after(frame.held);\n if (frame.room || held === rest) return held;\n return held.landing ? { ...rest, landing: held.landing } : rest;\n };\n const shownLayout = (frame: Pick<DockGuideFrame, \"held\" | \"room\">): DockLayout => screenOf(frame).layout;\n\n const guides = (frame: DockGuideFrame): DockGuide[] => {\n if (frame.guides.length === 0) return [];\n const held = after(frame.held);\n const screen = screenOf(frame);\n // The Near lane: the one shown with another held place than the screen's (a would-land held place), at most one.\n let near: { lane: string; marks: DockLaneMark[] } | null = null;\n const shown: { lane: string; marks: DockLaneMark[]; created?: true }[] = [];\n // Drawn on screen: open, or a column folded into its side's rail (its items the rail's segments).\n const drawnThere = (id: string): boolean => drawnIn(screen.layout, id);\n for (const g of frame.guides) {\n const mine = after(g.held);\n if (mine === held) {\n // Rule B: a lane the screen doesn't draw (an empty edge with no band there) is drawn in the layout that creates\n // it, its one spot's; every other lane in the screen's layout. A lane of no edge (a new column beside one) marks its\n // spots' landings, each in its own layout: it too is drawn as the layout that creates it, and gives way like one.\n // (A dynamic column the screen deletes, emptied by the lift, has no edge there: not drawn either.)\n const own = screen.marks.filter((m) => m.lane === g.lane);\n const edgeless = !state.edges.some((e) => e.id === g.lane);\n const made = edgeless ? own : !drawnThere(g.lane) ? created(g.lane) : null;\n shown.push(made ? { lane: g.lane, marks: made, created: true } : { lane: g.lane, marks: own });\n continue;\n }\n // Rule B: a lane drawn on screen is drawn there, less the landing the pointer would take in it; a lane the screen\n // doesn't draw is drawn in the layout that creates it.\n const onScreen = drawnThere(g.lane);\n const axis = axisOf.get(g.lane) ?? \"x\";\n // (A box part the landing leaves `MIN_PIECE` px or shorter is no room; a line goes only where the landing covers it.)\n const own = screen.marks.filter((m) => m.lane === g.lane);\n const marks = onScreen ? (mine.landing ? marksLess(own, axis, [mine.landing], { suffix: \"~l\", minBox: MIN_PIECE, lines: \"covered\" }) : own) : mine.marks.filter((m) => m.lane === g.lane);\n near = { lane: g.lane, marks };\n shown.push(near);\n }\n // A lane drawn in the layout that creates it gives way wherever the screen draws something: another lane's mark, a\n // drawn bar or toolbar rail (its items stay put when the lane opens; a column moves aside, so the guide may lie over\n // it), a side rail's segments (its folded columns' tabs), or the held landing. Between two such lanes the bar keeps\n // the corner (the bars first, each cut by the ones before).\n const drawnStays = [\n ...state.edges\n .filter((e) => (e.side === \"top\" || e.side === \"bottom\" || !!e.compact) && (screen.layout.edges[e.id]?.cross ?? 0) > EPS)\n .map((e) => screen.layout.edges[e.id]!.rect),\n ...Object.values(screen.layout.rails).flatMap((r) => r?.segments.filter((g) => g.id !== dragged).map((g) => g.rect) ?? []),\n ];\n // (The landing term is the only cut where a column the lift deletes is created in its own layout over a column\n // landing beside it: two columns on a side.)\n const onScreen = [...shown.filter((s) => !s.created && s !== near).flatMap((s) => s.marks.map((m) => m.rect)), ...drawnStays, ...(screen.landing ? [screen.landing] : [])];\n const axis = (id: string): \"x\" | \"y\" => axisOf.get(id) ?? \"x\";\n const made = shown.filter((s) => s.created).sort((a, b) => (axis(a.lane) === axis(b.lane) ? 0 : axis(a.lane) === \"x\" ? -1 : 1));\n const kept: Rect[] = [];\n for (const s of made) {\n s.marks = marksLess(s.marks, axis(s.lane), [...onScreen, ...kept]);\n kept.push(...s.marks.map((m) => m.rect));\n }\n if (!near) return shown.flatMap((s) => s.marks);\n // The Near lane's marks win where they meet another lane's: the others are cut there.\n const cut = near.marks.map((m) => m.rect);\n return shown.flatMap((s) => (s === near ? s.marks : marksLess(s.marks, axis(s.lane), cut)));\n };\n\n // The item's own place: the first spot `lanes()` marks home (absent for a float).\n const home = base.lanes.flatMap((l) => l.spots.filter((s) => s.home).map((s) => ({ lane: l.id, spot: s.id })))[0];\n return { regions, ...(home ? { home } : {}), after, landingOf, spotsOf, shown: shownLayout, guides };\n}\n"],"mappings":";AAgBO,IAAM,QAAyB,CAAC,OAAO,SAAS,UAAU,MAAM;AAIhE,IAAM,QAAyB,CAAC,SAAS,UAAU,KAAK;AAYxD,IAAM,gBAAwC,CAAC,oBAAoB,eAAe,qBAAqB,iBAAiB,wBAAwB,kBAAkB,uBAAuB,cAAc;AA+RvM,IAAM,aAAkC,CAAC,UAAU,OAAO;AAY1D,IAAM,oBAA+C,CAAC,iBAAiB,UAAU,OAAO;AAGxF,IAAM,iBAAiB;AAEvB,IAAM,sBAAsB;AAO5B,IAAM,iBAAiB;AAiWvB,IAAM,gBAAgB;AAEtB,IAAM,mBAAmB;AAEzB,IAAM,qBAA2B,EAAE,OAAO,KAAK,QAAQ,IAAI;;;ACxrBlE,SAAS,iBAAmD;AAC5D,SAAS,kBAAkC;AAG3C,IAAM,UAAU,CAAC,MAAmC,OAAO,SAAS,CAAC,IAAI,KAAK,IAAI,GAAG,CAAE,IAAI;AAOpF,SAAS,YAAY,OAAkB,QAAuB;AACnE,QAAM,WAAW,IAAI,IAAI,MAAM,OAAO,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;AACtD,QAAM,SAAS,MAAM,MAAM,KAAK,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,SAAS,YAAY,EAAE,QAAQ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AO,EAAE,QAAQ,UAAU,EAAE,OAAO,KAAK,EAAE,IAAI,GAAGA,IAAG,CAAE;AAAA,EAC5F;AAGA,QAAM,OAAO,KAAK,MAAM,QAAQ,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;AAChH,SAAO,EAAE,SAAS,GAAI,OAAO,EAAE,KAAK,IAAI,CAAC,GAAI,OAAO,WAAW,SAAS,OAAO,aAAa,OAAO;AACrG;","names":["px","rect","cut","EPS","len","EPS","lo","mid","drawnRect","EPS","formCrossMin","formSetsCross","itemSteps","formSetsCross","itemSteps","formCrossMin","EPS","lo","sized","area","cut","EPS","clampInto","rect","formFolded","rect","lo","mid","EPS","pushes","clampInto","over","formFolded","floatRegion","anchored","EPS","rect","rect","area","EPS","EPS","EPS","EPS","rect","EPS","formCrossMin","formMenu","formSetsCross","area","formMenu","formSetsCross","formCrossMin","auto","EPS","rect","fitStack","rect","fitStack","area","rect","EPS","area","over","rect","across","columnRoom","rect","rect","clampInto","EPS","lo","len","across","asked","why","rect","x","stops","_space","unspaced","f","rect","clampInto","EPS","rect","EPS","sizes","rect","EPS","area","clamp","overlaps","rect","EPS","rect","targets","EPS","rect","EPS","area","rect","formCrossMin","formMenu","formSetsCross","itemSteps","len","rect","EPS","lo","len","drawnOf","anchored","itemSteps","formMenu","formSetsCross","formCrossMin","EPS","r","area","across","rect","overlaps","formMain","itemSteps","itemSteps","len","formMain","overlaps","settle","EPS","area","overlaps","rect","subtract","itemSteps","EPS","rect","EPS","rect","along","area","EPS","subtract","hull","lo","cut","roomOf","across","overlaps","over","itemSteps","EPS","area","overlaps","rect","subtract","rect","EPS","lo","bandOf","across","area","overlaps","meet","mid","cut","subtract","pieces","EPS","overlaps","rect","subtract","EPS","rect","EPS","outside","rect","stops","EPS","rect","stops","a","b","overlaps","subtract","largest","targets","refusals","cut","EPS","area","rect","subtract","largest","area","EPS","overlaps","subtract","withPieces","lo","rect","targets","along","refusals","emit","targets","area","rect","EPS","overlaps","along","placed","clamp","memo","EPS","area","clamp","rect","subtract","itemSteps","hull","rect","EPS","over","laid","clamp","subtract","largest","area","across","along","LINE","isRefused","k","overlaps","cut","emit","zoneOf","itemSteps","zone","place","target","at","EPS","ORIGIN","axisOf","a","own","made","onScreen","axis","EPS","cut"]}