@n-uf/motion 26.11.47 → 26.11.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +49 -0
- package/README.md +26 -424
- package/dist/drag.d.ts +71 -6
- package/dist/drag.js +75 -8
- package/dist/drag.js.map +1 -1
- package/package.json +2 -2
package/dist/drag.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/drag/intent.ts","../src/drag/landing.ts","../src/drag/preview.ts","../src/drag/grip.ts"],"sourcesContent":["import type { Point, Rect } from \"../shapes\";\n\n/**\n * The drag intent model's tuning. Distances in px, speeds in px/ms, times in\n * ms; every value can be overridden per intent (see\n * {@link DragIntentOptions.tuning}).\n */\nexport interface DragTuning {\n /** A mouse press lifts once the pointer has moved this far. */\n readonly lift: number;\n /** A touch press lifts only after it has been held this long… */\n readonly touchHold: number;\n /** …and then moved this far (moving that far before the hold is over is not a drag). */\n readonly touchLift: number;\n /** The pointer's speed is measured over this window and smoothed. */\n readonly speedWindow: number;\n /** Aiming: the smoothed speed is below this… */\n readonly aimSpeed: number;\n /** …or the pointer has stayed within `still` px of one spot for `dwell` ms. */\n readonly still: number;\n readonly dwell: number;\n /** The current target holds while the pointer is within this band of its zone. */\n readonly band: number;\n /** A higher-priority target takes over at once when the pointer is this far inside it. */\n readonly breakthrough: number;\n /**\n * The band and the breakthrough scale with the zones: along each axis they are at most this share of the held\n * zone's extent and of the extent of the zone under the pointer (its `hit`), so a small zone (a 28 px row) can be\n * entered by a direct glide from its neighbor. Below a quarter, the pointer at a quarter of a zone is past them.\n */\n readonly bandShare: number;\n /** A gap between zones shorter than this keeps the current target (for a pointer that aims). */\n readonly gapGrace: number;\n /** Aiming, the shown target moves to another one only once that one has held this long. */\n readonly switchHold: number;\n /**\n * Room is made once the shown target, and the place in it, have held this long, so a pointer moving across targets\n * doesn't reflow the layout under it. A target with `opensRoom` holds this long before it shows, its room with it.\n */\n readonly roomAfter: number;\n /** The pointer has left the item's home once it is outside the home shrunk by this much on every side. */\n readonly homeInset: number;\n /**\n * Spring-loading: a target marked `arm: \"dwell\"` takes the drop only once the pointer has stayed in its zone this long\n * (ms); before that it is no target, so a fast pass, or a drop before it, lands on what lies beneath. 0 arms it at once.\n * Armed, its zone is its `armedHit` (the magnet: its band); moving out past that band's outer edge disarms it, and\n * re-entering needs a new full dwell. It arms only after the pointer has ENTERED its zone during the drag: the point\n * the drag starts at counts as not entered, so a drag that starts inside the zone (a panel's grip under the strip at\n * the window's edge) must leave it and come back before it can arm; entering from over home counts.\n */\n readonly railArmDwellMs: number;\n /**\n * The lift zone, a radius in px about the point the drag was lifted at ({@link DragIntentOptions.lift}, else the first\n * sample): no spring-loaded target arms by dwell inside it. Coming back to where you lifted and pausing is the\n * \"changed my mind\" gesture, so it commits nothing even where a strip lies over the grip (a flush drawer's grip at the\n * window's edge). 16 px is about a grip's size. Elsewhere, home under a strip included, arming works as before, and\n * the rail key forces the rail anywhere, the lift zone too.\n */\n readonly liftZone: number;\n /** The keys that win over geometry while held (see {@link DragModifiers}). */\n readonly modifiers: DragModifiers;\n}\n\n/**\n * A modifier key, by its `KeyboardEvent.key` name, or `\"Mod\"`: ⌘ (Meta) on macOS and Ctrl elsewhere. `\"Mod\"` counts\n * either key as held, so no platform detection is needed.\n */\nexport type ModifierKey = \"Shift\" | \"Alt\" | \"Control\" | \"Meta\" | \"Mod\";\n\n/** The modifier keys held on a sample (a pointer event's `shiftKey`, `altKey`, `ctrlKey`, `metaKey`). */\nexport interface DragKeys {\n readonly shift?: boolean;\n readonly alt?: boolean;\n readonly ctrl?: boolean;\n readonly meta?: boolean;\n}\n\n/**\n * Keys that win over geometry: while `floatKey` is held the drop floats (the `free` target) wherever the pointer is,\n * except over a refusal (the frame is refused) or outside the float's `bounds` (nothing);\n * while `railKey` is held it goes to the nearest target marked `arm` (a side's rail), without reaching it. `floatKey`\n * wins when both are held. `on: false` turns both off.\n */\nexport interface DragModifiers {\n readonly on: boolean;\n readonly floatKey: ModifierKey;\n readonly railKey: ModifierKey;\n}\n\n/**\n * The defaults: a mouse lifts after 5 px, a touch after a 180 ms hold and\n * 8 px; aiming is slower than 0.45 px/ms over 50 ms, or within 12 px for\n * 90 ms; a 10 px band and a 4 px breakthrough, each at most a fifth of the\n * zones' extents, and a 120 ms gap grace; a switch waits 150 ms (the shortest\n * an indicator may show); room after 160 ms. A spring-loaded target arms after\n * 200 ms of dwell (long enough that a pass at travelling speed never arms it,\n * short enough to feel like the platforms' spring-loading); Shift floats, ⌘/Ctrl\n * (`\"Mod\"`) goes to the nearest rail. Alt is left free: an app with a frozen\n * layout uses it to unfreeze temporarily, and a key should have one meaning.\n */\nexport const DRAG_DEFAULTS: DragTuning = {\n lift: 5,\n touchHold: 180,\n touchLift: 8,\n speedWindow: 50,\n aimSpeed: 0.45,\n still: 12,\n dwell: 90,\n band: 10,\n breakthrough: 4,\n bandShare: 0.2,\n gapGrace: 120,\n switchHold: 150,\n roomAfter: 160,\n homeInset: 6,\n railArmDwellMs: 200,\n liftZone: 16,\n modifiers: { on: true, floatKey: \"Shift\", railKey: \"Mod\" },\n};\n\nconst KEY_FIELD: Record<Exclude<ModifierKey, \"Mod\">, keyof DragKeys> = { Shift: \"shift\", Alt: \"alt\", Control: \"ctrl\", Meta: \"meta\" };\n/** Whether `key` is held in `keys` (`\"Mod\"`: ⌘ or Ctrl). */\nconst held = (keys: DragKeys | undefined, key: ModifierKey): boolean =>\n !!keys && (key === \"Mod\" ? !!(keys.meta || keys.ctrl) : !!keys[KEY_FIELD[key]]);\n\n/**\n * A drop target: plain data. `hit` is the zone the pointer can be in;\n * `priority` how precise it is (1 beats 2 beats 3; equal priorities go to the\n * smaller zone). `slot` is where the dragged item would land, `label` what to\n * call it; the model reads neither. A `free` target has no slot (the item\n * floats where it is dropped): no room is made for it. `hits`, when given, is\n * the whole zone as several rects (a zone that isn't one rect, `hit` the\n * largest of them): the pointer is in the zone when it is in any of them.\n *\n * `arm: \"dwell\"` makes it spring-loaded: it is no target until the pointer has\n * dwelt in its zone for `railArmDwellMs`; once armed its zone is `armedHit`\n * when given (a magnet: the zone grown), and leaving that disarms it.\n *\n * `refuse: true` makes it a refusal: a place that takes no drop (a host draws nothing over it, and at most says \"Can't\n * go here\" at the pointer). It takes part in\n * the pick under the pointer at {@link REFUSAL_RANK} (below every target of priority 1 or 2, whatever its own\n * `priority`, above priority 3), but it never becomes the current or the shown target, and a release over it lands\n * nowhere. Where the pick under the pointer is a refusal, no held target's band or gap grace keeps it: nothing shows,\n * and the frame's `refused` says which refusal it is.\n *\n * `bounds`, when given, is the drawn space the zone belongs to (a window's stage): the zone, its band and its gap grace\n * hold only points strictly inside it, so it is half-open toward the outside and a point on `bounds`' boundary or past\n * it is never in it. The window's boundary belongs only to the targets drawn against it: a refusal and a target over\n * the whole plane (the float) carry `bounds`, a gap or a slot doesn't. So a pointer a host clamps onto the window's\n * edge picks a gap whose hit reaches the edge, else nothing (a held target keeps its band), and never a refusal or the\n * float. The rule relies on the host clamping exactly onto the stage's edge (`x + width`, `y + height`): a host that\n * clamps to `width - 0.5` still picks inside the window, the float or a refusal there included.\n *\n * `opensRoom: true` marks a target whose indicator would lie over what its room moves (a side rail that pushes a column\n * aside). Showing it and making its room are then one decision: it shows only once it has held `roomAfter` ms, and the\n * frame that first shows it already has `room`. A sweep across it moves nothing, as for any target, and no frame draws\n * it over the column. Until it shows, a release still lands on it. An armed spring-loaded target has its room at once\n * too: its dwell was the decision. `roomHold` is how long this target holds before that decision, in ms, in place of\n * `roomAfter` (a rail or a new-column line against the window's edge, which a pointer rarely crosses on its way\n * elsewhere, can wait less). A\n * host that draws only a marker and doesn't use `previewPlan`'s room opens the room on\n * `frame.room && frame.shown?.opensRoom`.\n *\n * `roomHit`, with `opensRoom`, is where the target's room draws the item once it is open (its landing rect: an empty\n * rail or bar is entered over its drawn depth). While the target shows with its room open it holds in `hit ∪ roomHit`: wherever\n * the pointer is in `roomHit` and inside its `bounds` too. What lies there is drawn as the room, so a refusal or a\n * target of the same or a lower precision under it doesn't take over, and the frame isn't `refused` there. A more\n * precise target (a lower `priority`) still takes over once the pointer is past `breakthrough` into it, and a held key\n * still wins. Out of both the target is held as any other (its `hit` and band), so once it goes its zone is `hit` again.\n */\nexport interface DragTarget {\n readonly id: string;\n readonly priority: 1 | 2 | 3;\n readonly hit: Rect;\n readonly hits?: readonly Rect[];\n readonly slot?: Rect;\n readonly label?: string;\n readonly free?: boolean;\n readonly arm?: \"dwell\";\n readonly armedHit?: Rect;\n readonly refuse?: true;\n readonly bounds?: Rect;\n readonly opensRoom?: true;\n readonly roomHold?: number;\n readonly roomHit?: Rect;\n}\n\n/**\n * Where a refusal ranks in the pick ({@link targetAt}): an ordering rank, not a priority. Priorities stay the integers\n * 1, 2 and 3; a refusal's tier is `refuse: true`, and the pick orders it by this rank on the same scale: after every\n * target of priority 1 and 2 (a refusal and a real target where they meet or overlap: the target wins, so a gap keeps\n * its end), before priority 3 (the float: over drawn space that takes nothing, the refusal wins over floating).\n * Among refusals the smaller zone wins. `@n-uf/placement` exports the same value for its reference pick.\n */\nexport const REFUSAL_RANK = 2.5;\n\n/** A target's rank in the pick: its `priority`, a refusal's {@link REFUSAL_RANK}. Lower wins. */\nexport const pickRank = (t: Pick<DragTarget, \"priority\" | \"refuse\">): number => (t.refuse === true ? REFUSAL_RANK : t.priority);\n\n/** Whether `point` lies strictly inside `bounds` (none: everywhere). */\nconst within = (bounds: Rect | undefined, point: Point): boolean =>\n !bounds || (point.x > bounds.x && point.x < bounds.x + bounds.width && point.y > bounds.y && point.y < bounds.y + bounds.height);\n\n/** Whether `point` lies in `rect` grown by `margin` px on every side (shrunk, for a negative margin). */\nexport function inRect(rect: Rect, point: Point, margin = 0): boolean {\n return point.x >= rect.x - margin && point.x <= rect.x + rect.width + margin && point.y >= rect.y - margin && point.y <= rect.y + rect.height + margin;\n}\n\n/** How far `point` lies from `rect` (0 inside it). */\nconst distanceTo = (rect: Rect, point: Point): number =>\n Math.hypot(Math.max(rect.x - point.x, 0, point.x - (rect.x + rect.width)), Math.max(rect.y - point.y, 0, point.y - (rect.y + rect.height)));\n\n/** Whether `point` lies in a target's zone (`hits` when it has them, else `hit`), grown by `margin` px, and inside its `bounds`. */\nconst inZone = (t: DragTarget, point: Point, margin = 0): boolean => within(t.bounds, point) && (t.hits ? t.hits.some((r) => inRect(r, point, margin)) : inRect(t.hit, point, margin));\n\n/** A margin per axis: px grown (shrunk, when negative) left and right, and above and below. */\ninterface Margin {\n readonly x: number;\n readonly y: number;\n}\n/**\n * Whether `point` lies in a target's zone grown by `m.x` px left and right and `m.y` px above and below, and inside its\n * `bounds`: a band never reaches past a zone's bounds (the float's band holds nothing outside the window).\n */\nconst inZoneBy = (t: DragTarget, point: Point, m: Margin): boolean =>\n within(t.bounds, point) && (t.hits ?? [t.hit]).some((r) => point.x >= r.x - m.x && point.x <= r.x + r.width + m.x && point.y >= r.y - m.y && point.y <= r.y + r.height + m.y);\n/** `px`, but along each axis at most `share` of each zone's extent (its `hit`) along it. */\nconst scaled = (px: number, share: number, zones: readonly (DragTarget | null)[]): Margin => {\n let x = px;\n let y = px;\n for (const z of zones) {\n if (!z) continue;\n x = Math.min(x, share * z.hit.width);\n y = Math.min(y, share * z.hit.height);\n }\n return { x, y };\n};\nconst negate = (m: Margin): Margin => ({ x: -m.x, y: -m.y });\n\nconst area = (r: Rect): number => r.width * r.height;\n/** A target's zone's area: its `hits` together, else its `hit`. */\nconst zoneArea = (t: DragTarget): number => (t.hits ? t.hits.reduce((s, r) => s + area(r), 0) : area(t.hit));\n\n/**\n * The most precise target under `point`: the lowest rank ({@link pickRank}: the priority, a refusal's\n * {@link REFUSAL_RANK}), then the smallest zone; null when none is. A zone holds its edges (a closed rect), except\n * toward the outside of its `bounds`.\n */\nexport function targetAt<T extends DragTarget>(targets: readonly T[], point: Point): T | null {\n let best: T | null = null;\n for (const t of targets) {\n if (!inZone(t, point)) continue;\n if (!best || pickRank(t) < pickRank(best) || (pickRank(t) === pickRank(best) && zoneArea(t) < zoneArea(best))) best = t;\n }\n return best;\n}\n\n/** What a press does so far: not yet a drag (`wait`), a drag (`lift`), or never one (`refuse`: a touch that moved too soon). */\nexport type LiftDecision = \"wait\" | \"lift\" | \"refuse\";\n\n/**\n * The lift rule for a press that has moved `distance` px in `elapsed` ms. A\n * mouse (or pen) lifts at `lift` px. A touch lifts only after `touchHold` ms,\n * then at `touchLift` px; moving `touchLift` px before the hold is over\n * refuses the drag (the finger is scrolling or swiping).\n */\nexport function liftDecision(press: { readonly touch: boolean; readonly distance: number; readonly elapsed: number }, tuning: Partial<DragTuning> = {}): LiftDecision {\n const t = { ...DRAG_DEFAULTS, ...tuning };\n if (!press.touch) return press.distance >= t.lift ? \"lift\" : \"wait\";\n if (press.elapsed < t.touchHold) return press.distance >= t.touchLift ? \"refuse\" : \"wait\";\n return press.distance >= t.touchLift ? \"lift\" : \"wait\";\n}\n\n/** One update's answer. */\nexport interface DragFrame<T extends DragTarget> {\n /** The target the drop indicator shows, or null. */\n readonly shown: T | null;\n /**\n * The others make room for the shown target: it, and the place in it, have held `roomAfter` ms. For a target with\n * `opensRoom`, or an armed spring-loaded one, from the first frame that shows it.\n */\n readonly room: boolean;\n /**\n * The place the room is made for, or null. Within one target it stays on\n * the old place until a new one has held `roomAfter` ms (see\n * {@link DragIntentOptions.placeOf}).\n */\n readonly roomPlace: string | null;\n /** The pointer is aiming: slow, or nearly still for a moment. */\n readonly aiming: boolean;\n /**\n * The pointer is back inside `home` after it has been outside `home` itself. Never true at the press, nor while the\n * pointer only moves about inside `home`, even near its edge (where `state.leftHome` is already true: that flag is for\n * the indicator's gate and uses `homeInset`; this one does not). Over home no target is shown and a release does\n * nothing, so a host that wants to say \"a drop here returns it\" draws its own indicator for this frame (at the home\n * rect); the intent still shows no target.\n *\n * A docked item's home holds wherever it lies. The home of a floating item (`DragIntentOptions.floating`) is a free\n * placement, ranked like the float: it holds only where the pick there, home ignored, is no refusal and the point is\n * inside the window. Where it doesn't hold this is false and the pick is as anywhere else: over a refusal\n * `refused` says so, and a release lands nowhere.\n */\n readonly atHome: boolean;\n /**\n * A spring-loaded target (`arm: \"dwell\"`) the pointer is in and dwelling on, not armed yet (a host highlights it), or\n * null. Once it arms it is a target like any other and may show.\n */\n readonly arming: T | null;\n /**\n * A key held wins over geometry this frame: `\"float\"` (the float key) or `\"rail\"` (the rail key), else null. The\n * float key chooses the float over dock targets, not over a refusal or outside the window: there it is still\n * `\"float\"` (the key is held), but nothing shows, a release lands nowhere, and over a refusal `refused` says which.\n */\n readonly forced: \"float\" | \"rail\" | null;\n /**\n * The refusal (a target with `refuse: true`) the pointer is over, when it is the pick there: no target shows. A host\n * never draws the refused place; it may say \"Can't go here\" at the pointer. Null otherwise, and while a key forces a target; with the float key\n * held over a refusal it is that refusal (the key doesn't float over refused space).\n */\n readonly refused: T | null;\n /**\n * No target shows, and the pointer has been over a refusal since a target last showed (or since the lift). A refusal\n * hides the shown target at once, and the next one shows only once the pointer aims again, so a pointer that crosses\n * a refusal and is let go at speed over a target beyond it has no indicator drawn. Then this is true, and a release\n * still lands on what is under the pointer (`release`): a host that commits only what it has drawn commits that\n * release too. False whenever a target shows, over the refusal itself (`refused`), and after `hide`.\n *\n * Read it from the frame of an `update` at the release point, called before `release` (as `release` asks anyway), so\n * the last move counts. The field is required: a host or a test mock that builds a `DragFrame` itself must set it.\n */\n readonly refusedSinceShown: boolean;\n /**\n * What a release at this frame's point lands on, by the one check `release` makes (`earlyRelease` included), or null\n * (nowhere, or the item goes home). A host draws the landing from it, so what it draws and what a release lands on\n * never disagree. `createDragIntent` always sets it; it is optional only so a host or a test that builds a frame\n * itself needn't.\n */\n readonly landing?: T | null;\n}\n\n/** What a drag intent knows now. */\nexport interface DragIntentState<T extends DragTarget> {\n /** The pointer's smoothed speed, px/ms. */\n readonly speed: number;\n /** The target under the pointer as the hysteresis holds it, or null. */\n readonly current: T | null;\n /** The target the indicator shows, or null. */\n readonly shown: T | null;\n /** The pointer has left the item's home. */\n readonly leftHome: boolean;\n}\n\nexport interface DragIntentOptions<T extends DragTarget> {\n /** Where the item was lifted from: the indicator stays off until the pointer leaves it, and a release there does nothing. */\n readonly home: Rect;\n /** Where the press that lifted the item was (the grip); default the first sample's point. The lift zone is about it. */\n readonly lift?: Point;\n /**\n * The lift zone as a rect instead of a radius, in the same px as the samples: while a sample is inside it no\n * spring-loaded target arms by dwell, and the `liftZone` radius is not applied. A host passes the part of the grip\n * that a drop strip covers (grip ∩ strip), so a pause back there commits nothing while the rest of the strip, right\n * beside a wide grip, still arms. Absent: the `liftZone` radius about `lift`.\n */\n readonly liftRect?: Rect;\n /**\n * The held item floats, and `home` is its own box. A floating item's own place is a free placement: it ranks like the\n * float target, so home holds only where the pick there, home ignored, is no refusal and the point lies inside the\n * window (no target's `bounds` left with nothing picked). Over a refusal in its box the frame is refused and a\n * release lands nowhere; on or past the window's edge nothing is picked; elsewhere in its box home holds as before.\n * Absent (a docked item): home holds wherever it lies, as its own home target beats a refusal.\n */\n readonly floating?: boolean;\n /**\n * What a release does before the item has settled on a target (no room open for it yet). `\"target\"` (the default): it\n * lands on the shown target, else the target under the pointer, drawn or not, an `opensRoom` target that hasn't shown\n * included. `\"float\"`: what shows is what lands, for a host whose dragged item is the only preview (`previewPlan`'s\n * `\"item\"`): the item is still on the pointer, so it floats there (the `free` target; over a refusal or outside the\n * float's `bounds`, nowhere). `release` is its one reader.\n */\n readonly earlyRelease?: \"target\" | \"float\";\n /** Overrides of {@link DRAG_DEFAULTS}. */\n readonly tuning?: Partial<DragTuning>;\n /**\n * The place within a target the pointer is at (a tab index, a stack\n * position, a pane's edge), unique across targets; default: the target's id.\n * Moving between places of the shown target moves the indicator at once but\n * the room only once the new place has held `roomAfter` ms.\n *\n * - `previous` is the place this target had on the last sample (null if it\n * had none), so a place can hold near its boundary (hysteresis).\n * - A null place is no target: there is no drop at that point of the target.\n * It isn't picked or held, the indicator hides there at once (or shows a\n * target beneath that has a place), no room opens, and a release there\n * lands on a target beneath, else goes home.\n * - It is also asked about the current target while the pointer is just\n * outside its hit zone (within the band, or during the gap grace). Answer\n * the nearest place there: returning null outside the zone drops the band\n * and the grace, so the indicator hides a few px past the edge. Return null\n * only for a part of the target that takes no drop.\n * - It is called on every sample for each target under the pointer and for\n * the current one, so keep it cheap and free of side effects.\n */\n readonly placeOf?: (target: T, point: Point, previous: string | null) => string | null;\n}\n\n/** A drag's intent: feed it the pointer on every frame; it says what the indicator shows and what a release lands on. */\nexport interface DragIntent<T extends DragTarget> {\n /**\n * A pointer sample at `time` (ms), with the targets as they stand (they may\n * be rebuilt between calls: the model follows them by id). Call it once a\n * frame while the item is held, also when the pointer doesn't move: a\n * dwell is time passing. `keys`: the modifier keys held now (see {@link DragModifiers}).\n */\n update(point: Point, time: number, targets: readonly T[], keys?: DragKeys): DragFrame<T>;\n /**\n * What a release at `point` lands on: the shown target whenever one shows\n * (a drop lands where the indicator was), else the target under the\n * pointer, else null (the item goes home). A release over home is null: it\n * does nothing. Feed the release point to `update` first, so a last jump\n * of the pointer counts. With a modifier key held (`keys`), the target the key picks, even over home.\n */\n release(point: Point, targets: readonly T[], keys?: DragKeys): T | null;\n /**\n * Hide the indicator (the view is scrolling under the pointer, say). The\n * aim starts afresh: the next sample never counts as aiming, and a dwell\n * starts again.\n */\n hide(time: number): void;\n /** The item's home moved with the view (it scrolled) by (dx, dy). */\n moveHome(dx: number, dy: number): void;\n readonly state: DragIntentState<T>;\n readonly tuning: DragTuning;\n}\n\n/**\n * The drag intent model: when the drop indicator shows, which target it\n * shows, when the others make room, and what a release lands on. Pure: fed\n * pointer samples and plain-data targets, no DOM and no clock of its own.\n *\n * - The indicator shows only when the pointer has left the item's home, a\n * target is under it, and it is aiming (slow, or nearly still for a\n * moment). Time spent crossing a big target at speed doesn't count.\n * - The most precise target wins (priority, then the smaller zone).\n * - Hysteresis: the current target holds while the pointer is within `band`\n * px of its zone, unless a more precise one is clearly (`breakthrough` px)\n * under the pointer; both scale down for small zones (`bandShare` of the\n * held zone's and the entered zone's extents along each axis), so a small\n * zone is entered by a direct glide; for a pointer that aims, a short gap between zones\n * (`gapGrace` ms) keeps it too.\n * - Leaving the shown target: flying, the indicator hides at once; aiming, it\n * moves to the new target once that has held `switchHold` ms (so no\n * indicator shows for less than that), at once for a breakthrough. A target\n * kept only by the gap grace can keep the indicator, never show it.\n * - Room is made once the shown target has held `roomAfter` ms, never for a\n * free target, and closes at once when it changes. A target with `opensRoom`\n * holds that long before it shows and has its room in the same frame; an\n * armed spring-loaded target has its room as it shows. With its room open,\n * one with a `roomHit` holds wherever the pointer is in that room, over a\n * refusal or a target no more precise than it under the room included.\n * - Where `placeOf` gives a target no place (null), it is no target: it is\n * neither shown nor landed on there.\n * - Spring-loading: a target marked `arm: \"dwell\"` is no target until the\n * pointer has stayed in its zone `railArmDwellMs` (the frame's `arming` says\n * which one it dwells on); then it is armed: its zone is `armedHit` (the\n * magnet) and it shows at once. Leaving that zone disarms it.\n * - Keys win over geometry (`modifiers`): the float key shows the `free` target\n * wherever the pointer is over a dock target or open space inside the float's\n * `bounds`, the rail key the nearest target marked `arm`; a release with the\n * key held lands there. Over a refusal, or outside the float's `bounds`, the\n * float key picks nothing: nothing shows and a release lands nowhere.\n */\nexport function createDragIntent<T extends DragTarget>(options: DragIntentOptions<T>): DragIntent<T> {\n const tuning: DragTuning = { ...DRAG_DEFAULTS, ...options.tuning };\n const placeOf = options.placeOf ?? ((t: T) => t.id);\n // Each target's place on the last sample, by id: its `previous` on the next.\n let lastPlaces = new Map<string, string | null>();\n let home: Rect = { ...options.home };\n let samples: { x: number; y: number; t: number }[] = [];\n let cur: T | null = null;\n let curSince = 0;\n let lastInside = 0;\n let shown: T | null = null;\n let shownSince = 0;\n let place: string | null = null;\n let placeSince = 0;\n let roomPlace: string | null = null;\n let leftHome = false;\n // The pointer has been outside `home` itself (`leftHome` turns on already near its edge): `atHome`'s own memory.\n let wentOut = false;\n let speed = 0;\n let anchor: Point | null = null;\n let stillSince = 0;\n let restart = false;\n // The pointer has been over a refusal since a target last showed (the frame's `refusedSinceShown`).\n let crossedRefusal = false;\n // Spring-loading: the target armed (by id), and the one the pointer dwells on and since when.\n let armedId: string | null = null;\n let armingId: string | null = null;\n let armingSince = 0;\n // The spring-loaded targets (by id) the pointer has been outside of during this drag: only those can arm.\n const wasOutside = new Set<string>();\n // The point the drag was lifted at: no spring-loaded target arms by dwell within `liftZone` of it.\n let liftAt: Point | null = options.lift ? { ...options.lift } : null;\n const same =(a: T | null, b: T | null): boolean => (a === null || b === null ? a === b : a.id === b.id);\n // Targets may be rebuilt between calls: follow the ones held by id.\n const follow = (t: T | null, targets: readonly T[]): T | null => (t ? (targets.find((x) => x.id === t.id) ?? t) : null);\n /** An armed target as it acts: its zone is `armedHit` (the magnet) when it has one. */\n const asArmed = (x: T): T => {\n if (!x.armedHit) return x;\n const { hits: _pieces, ...rest } = x;\n return { ...rest, hit: x.armedHit } as T;\n };\n /** The targets as they act now: a spring-loaded one only once armed, in its armed zone. */\n const acting = (targets: readonly T[]): T[] => targets.filter((x) => x.arm !== \"dwell\" || x.id === armedId).map((x) => (x.id === armedId ? asArmed(x) : x));\n /**\n * The target a held key picks at `p`: the float key the `free` target, the rail key the nearest spring-loaded one.\n * The float key chooses the float over dock targets, not over refusals or outside the window: where the pick at `p`\n * (`has`: a target with a place there, or a refusal) is a refusal, it picks nothing and says which refusal; outside\n * the float's `bounds` (a pointer clamped onto the window's edge) it picks nothing. The rail key's drop lands on the\n * rail, not where the pointer is, so neither applies to it.\n */\n const forcedBy = (keys: DragKeys | undefined, p: Point, targets: readonly T[], has: (x: T) => boolean): { kind: \"float\" | \"rail\"; target: T | null; refused: T | null } | null => {\n const m = tuning.modifiers;\n if (!m.on || !keys) return null;\n if (held(keys, m.floatKey)) {\n const f = targets.find((x) => x.free);\n if (!f) return null;\n const under = targetAt(acting(targets).filter((x) => inZone(x, p) && has(x)), p);\n if (under?.refuse === true) return { kind: \"float\", target: null, refused: under };\n return within(f.bounds, p) ? { kind: \"float\", target: f, refused: null } : { kind: \"float\", target: null, refused: null };\n }\n if (!held(keys, m.railKey)) return null;\n let best: T | null = null;\n let bestD = Infinity;\n for (const x of targets) {\n if (x.arm !== \"dwell\") continue;\n const d = distanceTo(asArmed(x).hit, p);\n if (d < bestD) {\n best = x;\n bestD = d;\n }\n }\n return best ? { kind: \"rail\", target: asArmed(best), refused: null } : null;\n };\n\n /** What a release at `point` lands on, as things stand now: `release`'s answer, and every frame's `landing`. */\n const landAt = (point: Point, given: readonly T[], keys: DragKeys | undefined): T | null => {\n // A key held wins over geometry, home included; the float key over a refusal or outside the window lands nowhere.\n const forced = forcedBy(keys, point, given, (x) => x.refuse === true || placeOf(x, point, lastPlaces.get(x.id) ?? null) !== null);\n if (forced) {\n const ft = forced.target;\n return ft ? (given.find((x) => x.id === ft.id) ?? ft) : null;\n }\n // Over home a release does nothing, except onto an armed spring-loaded target whose zone overlaps home.\n if (inRect(home, point)) {\n const armed = armedId === null ? null : given.find((x) => x.id === armedId);\n return armed && inZone(asArmed(armed), point) && placeOf(armed, point, lastPlaces.get(armed.id) ?? null) !== null ? armed : null;\n }\n const targets = acting(given);\n // Drop = shown: a shown target is kept until it hides (flying out past its band hides it at once).\n const s = shown && !(shown.arm === \"dwell\" && shown.id !== armedId) ? follow(shown, given) : null;\n // The target under the pointer that has a place there (a null place is no drop); a refusal there lands nowhere.\n const under = targetAt(\n targets.filter((x) => inZone(x, point) && (x.refuse === true || placeOf(x, point, lastPlaces.get(x.id) ?? null) !== null)),\n point,\n );\n if (options.earlyRelease === \"float\") {\n // What shows is what lands: a target with a slot only once its room is open; before that the item is still on\n // the pointer, so it floats there. A target with no slot (the item's own place, a blocked one) needs no room.\n const needsNoRoom = (x: T): boolean => x.free === true || !x.slot;\n if (s && (needsNoRoom(s) || roomPlace !== null)) return s;\n if (under?.refuse) return null;\n if (under && !under.free && !under.slot) return given.find((x) => x.id === under.id) ?? under;\n const float = given.find((x) => x.free);\n return float && within(float.bounds, point) ? float : null;\n }\n if (s) return s;\n return under && !under.refuse ? (given.find((x) => x.id === under.id) ?? under) : null;\n };\n\n return {\n tuning,\n get state(): DragIntentState<T> {\n return { speed, current: cur, shown, leftHome };\n },\n update(point, time, given, keys) {\n const p = point;\n const t = time;\n samples.push({ x: p.x, y: p.y, t });\n while (samples.length > 2 && t - samples[0]!.t > tuning.speedWindow) samples.shift();\n const a = samples[0]!;\n speed = speed * 0.5 + (Math.hypot(p.x - a.x, p.y - a.y) / Math.max(1, t - a.t)) * 0.5;\n if (!anchor || Math.hypot(p.x - anchor.x, p.y - anchor.y) > tuning.still) {\n anchor = { x: p.x, y: p.y };\n stillSince = t;\n }\n if (!inRect(home, p, -tuning.homeInset)) leftHome = true;\n const atHome = inRect(home, p);\n if (!atHome) wentOut = true;\n // Each target's place at this point, worked out once per sample; a null place is no target.\n const places = new Map<string, string | null>();\n const placeAt = (x: T): string | null => {\n if (!places.has(x.id)) places.set(x.id, placeOf(x, p, lastPlaces.get(x.id) ?? null));\n return places.get(x.id)!;\n };\n const live = (x: T | null): x is T => x !== null && placeAt(x) !== null;\n // Spring-loading: the armed target holds while the pointer is in its armed zone; a target the pointer dwells in\n // arms once it has held `railArmDwellMs`. A key held wins over both.\n const forced = forcedBy(keys, p, given, (x) => x.refuse === true || live(x));\n if (armedId !== null) {\n const was = given.find((x) => x.id === armedId);\n if (!was || forced || !inZone(asArmed(was), p) || !live(was)) armedId = null;\n }\n // Spring-loading is not gated by `atHome`: a strip that overlaps the item's own place still arms by dwell.\n // A spring-loaded target arms only after the pointer has entered it: one it has been outside of during the drag.\n for (const x of given) if (x.arm === \"dwell\" && !inZone(x, p)) wasOutside.add(x.id);\n // Inside the lift zone nothing arms by dwell (\"changed my mind\"); the rail key still forces the rail.\n // With a `liftRect` the zone is that rect, the radius not applied.\n liftAt ??= { x: p.x, y: p.y };\n const inLiftZone = options.liftRect ? inRect(options.liftRect, p) : Math.hypot(p.x - liftAt.x, p.y - liftAt.y) <= tuning.liftZone;\n const dwelling = forced || inLiftZone ? null : targetAt(given.filter((x) => x.arm === \"dwell\" && x.id !== armedId && wasOutside.has(x.id) && inZone(x, p) && live(x)), p);\n let armedNow = false;\n if (!dwelling || armedId !== null) armingId = null;\n else {\n if (armingId !== dwelling.id) {\n armingId = dwelling.id;\n armingSince = t;\n }\n if (t - armingSince >= tuning.railArmDwellMs) {\n armedId = dwelling.id;\n armingId = null;\n armedNow = true;\n }\n }\n const arming = armingId === null ? null : (given.find((x) => x.id === armingId) ?? null);\n const targets = acting(given);\n // A docked item's home holds wherever it lies (its own home target beats a refusal). A floating item's own place\n // is a free placement, ranked like the float: its home holds only where the pick there, home ignored, is no\n // refusal and not nothing outside a target's `bounds` (past the window). Elsewhere the pick is as anywhere else.\n const underHome = atHome && options.floating ? targetAt(targets.filter((x) => inZone(x, p) && (x.refuse === true || live(x))), p) : null;\n const pastBounds = atHome && options.floating ? targets.some((x) => x.bounds !== undefined && !within(x.bounds, p)) : false;\n const homeHolds = atHome && (!options.floating || (underHome?.refuse !== true && !(underHome === null && pastBounds)));\n // Over home no target is picked, except a spring-loaded one that is armed (its zone overlaps home): home gates\n // geometry, not an armed dwell.\n const pickable = (x: T): boolean => !homeHolds || (x.arm === \"dwell\" && x.id === armedId);\n // A refusal takes part in the pick (it needs no place), but it is never a target: never held, never shown.\n const raw = targetAt(targets.filter((x) => pickable(x) && inZone(x, p) && (x.refuse === true || live(x))), p);\n // A spring-loaded target that isn't armed (any more) is no target: neither held nor shown.\n const disarmed = (x: T | null): boolean => x?.arm === \"dwell\" && x.id !== armedId;\n cur = disarmed(cur) ? null : follow(cur, targets);\n shown = disarmed(shown) ? null : follow(shown, targets);\n if (!live(cur)) cur = null;\n // A target shown with its room open holds in the room it opened (`roomHit`): what lies there is drawn as the room,\n // so a refusal under it is no refusal here.\n const roomHeld = cur && cur.opensRoom === true && cur.roomHit && roomPlace !== null && same(cur, shown) && pickable(cur) && within(cur.bounds, p) && inRect(cur.roomHit, p) ? cur : null;\n const refusedRaw = raw?.refuse === true && !roomHeld ? raw : null;\n // The band about a held zone, and the breakthrough into a zone, scaled with the zones (see `bandShare`).\n const bandOf = (held: T): Margin => scaled(tuning.band, tuning.bandShare, [held, raw && !same(raw, held) ? raw : null]);\n const pastBreakthrough = (x: T): boolean => inZoneBy(x, p, negate(scaled(tuning.breakthrough, tuning.bandShare, [x])));\n // Over a refusal nothing is held: no band and no gap grace keep the current target there.\n let next = refusedRaw ? null : raw;\n if (!refusedRaw && cur && pickable(cur) && (roomHeld !== null || inZoneBy(cur, p, bandOf(cur)))) {\n // Over a `free` target (the float everywhere) there is no edge to hold against: a more precise target takes over\n // once the pointer is in it, so a zone that ends at the window's edge is reached at its very first px. A refusal\n // here lies under the open room: it never takes over.\n const breaks = raw !== null && raw.refuse !== true && !same(raw, cur) && raw.priority < cur.priority && (cur.free === true || pastBreakthrough(raw));\n next = breaks ? raw : cur;\n }\n // The gap grace, like the band, never reaches past a zone's bounds: the float gets no grace outside the window.\n if (!refusedRaw && !next && cur && pickable(cur) && within(cur.bounds, p) && t - lastInside < tuning.gapGrace) next = cur;\n if (next && (inZone(next, p) || same(next, roomHeld))) lastInside = t;\n if (!same(next, cur)) curSince = t;\n cur = next;\n const aiming = !restart && (speed < tuning.aimSpeed || t - stillSince >= tuning.dwell);\n restart = false;\n const show = (s: T | null): void => {\n if (!same(s, shown)) shownSince = t;\n shown = s;\n };\n // Under the pointer (within its band, or in the room it holds), not just kept by the gap grace.\n const under = !!cur && (same(cur, roomHeld) || inZoneBy(cur, p, bandOf(cur)));\n // A target that opens its room as it shows shows only once it has held (`roomHold`, else `roomAfter`): one decision\n // for both, so a sweep moves nothing and the indicator never lies over what the room will move. An armed one has\n // had its dwell.\n const ready = (x: T): boolean => x.opensRoom !== true || x.arm === \"dwell\" || t - curSince >= (x.roomHold ?? tuning.roomAfter);\n // A shown target with no place here is no drop: the indicator hides at once (the switch hold is for targets).\n if (shown && !live(shown)) show(null);\n if (!shown) {\n if (cur && under && leftHome && aiming && ready(cur)) show(cur);\n } else if (same(cur, shown)) {\n // It stays while its target holds; but a pointer flying out past the band hides it at once.\n if (!aiming && !under) show(null);\n else shown = cur;\n } else if (!cur || !aiming) {\n show(null);\n } else if ((cur.priority < shown.priority && (shown.free === true || pastBreakthrough(cur))) || (under && t - curSince >= tuning.switchHold)) {\n // Not ready yet: the old indicator goes, and a release lands on the target under the pointer.\n show(ready(cur) ? cur : null);\n }\n // An armed target shows at once: the dwell was the aim. A key held wins over all of it.\n if (armedNow && cur?.id === armedId && under) show(cur);\n // A key that picks nothing here (the float key over a refusal or outside the window) shows nothing.\n if (forced) {\n if (!same(forced.target, cur)) curSince = t;\n cur = forced.target;\n show(forced.target);\n }\n // The place within the shown target, and the room: after the target and the place have both held; with the target\n // itself where showing it was already that decision (`opensRoom`, an armed target's dwell).\n const at = shown ? placeAt(shown) : null;\n if (at !== place) {\n place = at;\n placeSince = t;\n }\n if (!shown || shown.free) roomPlace = null;\n else if (shown.opensRoom === true || shown.arm === \"dwell\") roomPlace = place;\n else if (t - shownSince >= tuning.roomAfter && t - placeSince >= tuning.roomAfter) roomPlace = place;\n else if (shownSince === t) roomPlace = null;\n lastPlaces = places;\n // A refusal crossed since a target last showed: a release beyond it lands on what is under the pointer, drawn or not.\n // With a key held, the refusal is the one the key's pick met (the float key over a refusal), else none.\n const refused = forced ? forced.refused : refusedRaw;\n if (shown) crossedRefusal = false;\n else if (refused) crossedRefusal = true;\n return { shown, room: roomPlace !== null, roomPlace, aiming, atHome: !forced && wentOut && homeHolds, arming, forced: forced?.kind ?? null, refused, refusedSinceShown: !shown && !refused && crossedRefusal, landing: landAt(p, given, keys) };\n },\n release(point, given, keys) {\n return landAt(point, given, keys);\n },\n hide(time) {\n shown = null;\n cur = null;\n armedId = null;\n armingId = null;\n shownSince = time;\n place = null;\n roomPlace = null;\n lastPlaces = new Map();\n samples = [];\n anchor = null;\n restart = true;\n crossedRefusal = false;\n },\n moveHome(dx, dy) {\n home = { ...home, x: home.x + dx, y: home.y + dy };\n },\n };\n}\n","import type { Point, Rect } from \"../shapes\";\nimport type { DragKeys } from \"./intent\";\nimport type { PlaceGuides } from \"./preview\";\n\n/**\n * The landing model: where a docking drag's item lands, as state rather than a per-frame guess. A host gives it the\n * drag's regions (from `@n-uf/placement/scene`'s `lanes()`: plain data, the shapes below) and each pointer sample; it\n * says the region the pointer is in, the lane and spot held, where the item lands, whether the room is open, and the\n * place guides. Every change comes from where the pointer is and how it moved (margins, a path length, a step size):\n * the model has no waits of its own.\n *\n * - **The stage's edge** is the easiest place to dock: a pointer past the stage by up to `edge` px counts as on its\n * edge, so it lies deep inside a lane drawn against that edge; beyond, it is nowhere.\n * - **A lane holds** while the pointer is inside its rect grown by `exit`, whatever lies under it. Inside, over a spot's\n * stretch it is at that spot; over a refused stretch of the lane, refused (\"Can't go here\"). (Placement's `lanes()`\n * joins a refused stretch shorter than the item to its spots.)\n * - **Entering a lane** needs one of two gates: `path` px of slow pointer path along it inside it (steps of at most\n * `step`), or a still step (at most `still`) once `depth` px inside, the depth counted only from the lane's sides that\n * face into the stage (on the edge it is deep). A fly-through of a thin bar or rail at any angle meets neither, so its\n * room never opens. Inside a lane that touches the held one, past the held lane's exit margin, the held lane holds\n * until that lane's gate passes or the pointer has slid `path` px along it at any speed (across it at most a third as\n * far): lane to lane never passes through the float, and never opens a crossed lane's room.\n * - **Along a lane** the spot changes once the pointer is `spot` px past the boundary; where the change moves another\n * item (the two spots' `others` keys differ), on a step of at most `step`, or once the held landing trails the\n * pointer by more than `trail`: the item chases only as far as it must. A change that moves only the held item\n * follows the hand at any speed. With `regionsFor`, a reflowing change is kept only if, in the new spot's own regions\n * (its room open), the pointer still lies in that spot's stretch: the room shifting the boundary never bounces it.\n * - **Outside every lane:** a refused place, refused; open space (`\"open\"`: the content less what blocks it, the page),\n * the float at its landing; outside the stage (past `edge`), nowhere; else (docked content that takes nothing and\n * refuses nothing) refused.\n * - **Shift** turns a lane or open space into open space (the float), and hides the guides.\n * - **Guides** are the lane's `marks` (lines between items, a box per free stretch, in the layout as drawn), else its\n * spots' landings: the held lane's; else the approached lane's (the nearest within `reach`); over a refused place the\n * nearest lane's at any distance, so the lane behind a refused column shows its guides.\n * - Steps are measured between points that differ, normalized to 125 Hz, so the gates read the same at any input rate.\n * A repeated point keeps the last step; it is still only once the pointer has stayed put for `rest` ms.\n *\n * **The host's part:** call `update` whenever you like: per pointer sample, per animation frame, or both. Call it at\n * least once more after the pointer stops (every frame does), so it can become still, and again with the same point\n * when a key changes. Give `setRegions` the `regionsFor` that answers for the new state.\n */\n\n/** A place a drop in a lane lands: its stretch of the lane and its landing rect. Ids are stable across solves. */\nexport interface LandingSpot {\n readonly id: string;\n readonly along: readonly [number, number];\n readonly landing: Rect;\n /**\n * Where its drop draws every other item, as a key: a change between two spots with the same key moves only the held\n * item. Absent: every change to or from it counts as moving others.\n */\n readonly others?: string;\n}\n/** A place guide's mark: a line between two items, a box over a free stretch, in the layout as drawn. */\nexport interface LandingMark {\n /** Stable while its neighbors stay; absent, the guide is keyed by its lane and place in the list. */\n readonly id?: string;\n readonly kind: \"line\" | \"box\";\n readonly rect: Rect;\n}\nexport interface LandingLane {\n readonly id: string;\n readonly rect: Rect;\n readonly axis: \"x\" | \"y\";\n readonly spots: readonly LandingSpot[];\n readonly refused: readonly { readonly along: readonly [number, number] }[];\n /** Its guides' marks; absent, its spots' landings are the guides. */\n readonly marks?: readonly LandingMark[];\n}\n/** A drag's regions (`lanes()` gives them). */\nexport interface LandingRegions {\n readonly lanes: readonly LandingLane[];\n readonly refused: readonly Rect[];\n readonly content: Rect;\n readonly blocked: readonly Rect[];\n readonly stage: Rect;\n /** The held item's size. */\n readonly item: { readonly width: number; readonly height: number };\n}\n\nexport interface LandingMargins {\n /** Past a held lane's rect before it lets go, px. */\n readonly exit: number;\n /** Past a spot boundary before the spot changes, px. */\n readonly spot: number;\n /** Past the stage that still counts as on its edge, px; beyond, nowhere. */\n readonly edge: number;\n}\nexport interface LandingGates {\n /** Pointer path inside a lane that enters it, px. */\n readonly path: number;\n /** Depth inside a lane where a still step enters it, px. */\n readonly depth: number;\n /** A still step, px per 8 ms. */\n readonly still: number;\n /**\n * The largest step that changes the spot along a lane where the change reflows the window, px per 8 ms; it also\n * bounds the steps the path gate counts (a fast crossing never enters).\n */\n readonly step: number;\n /** How far the held landing may trail the pointer before a fast reflowing change is taken anyway, px. */\n readonly trail: number;\n /**\n * The time a pointer has to stay put before it counts as still, ms, where its last step was already slow (at most\n * `step`) or it is on the stage's edge (a fling there is taken at once); repeated points before it aren't still.\n */\n readonly rest: number;\n /** The time a pointer that last moved fast has to stay put before it counts as still, ms: longer than sample gaps. */\n readonly pause: number;\n}\n/** The approach for near guides: the nearest lane within `reach`, kept until another is `nearer` closer or past `keep`. */\nexport interface LandingApproach {\n readonly reach: number;\n readonly keep: number;\n readonly nearer: number;\n}\n\nexport const LANDING_MARGINS: LandingMargins = { exit: 12, spot: 6, edge: 48 };\n/** A touch: wider margins, the finger's jitter. */\nexport const LANDING_TOUCH_MARGINS: LandingMargins = { exit: 16, spot: 8, edge: 48 };\nexport const LANDING_GATES: LandingGates = { path: 40, depth: 8, still: 1.5, step: 3, trail: 40, rest: 22, pause: 60 };\nexport const LANDING_APPROACH: LandingApproach = { reach: 80, keep: 96, nearer: 16 };\n\nexport interface LandingOptions {\n readonly regions: LandingRegions;\n /** The regions with `spot` held (its room open): the fixed-point check and the stretches while held. Cached per id. */\n readonly regionsFor?: (spot: string) => LandingRegions | null;\n /** The float's landing for a pointer over the document, or null where the item doesn't float. */\n readonly floatLanding?: (point: Point) => Rect | null;\n /** The item's own place at the lift: its lane and spot (the drag starts there, the room open). */\n readonly home?: { readonly lane: string; readonly spot: string };\n readonly margins?: Partial<LandingMargins>;\n readonly gates?: Partial<LandingGates>;\n readonly approach?: Partial<LandingApproach>;\n readonly placeGuides?: PlaceGuides;\n}\n\nexport type LandingRegion = \"lane\" | \"open\" | \"refused\" | \"nowhere\";\n\n/** A guide: a mark of a lane, where to draw it now (a spot's landing is a box). */\nexport interface LandingGuide {\n /** Stable while its neighbors stay: the mark's id, else `<lane>/<spot id>` for a spot's landing. Key a drawing by it. */\n readonly id: string;\n readonly lane: string;\n readonly kind: \"line\" | \"box\";\n readonly rect: Rect;\n}\n\nexport interface LandingFrame {\n readonly region: LandingRegion;\n /** The lane held (also over its refused stretch), or null. */\n readonly lane: string | null;\n /** The spot held, or null. */\n readonly spot: string | null;\n /** Where a release now lands: the spot's landing, or the float's; null where it lands nowhere (the item goes home). */\n readonly landing: Rect | null;\n /** The room is open: a spot is held in a lane, no Shift. */\n readonly room: boolean;\n readonly guides: readonly LandingGuide[];\n /** Shift held: the region is open space wherever it was a lane or open space. */\n readonly shift: boolean;\n}\n\n/** What a release lands: a spot (`home` when it is the item's own place), the float at `rect`, or nothing. */\nexport type LandingRelease = { readonly kind: \"spot\"; readonly lane: string; readonly spot: string; readonly home: boolean } | { readonly kind: \"float\"; readonly rect: Rect } | null;\n\nexport interface LandingModel {\n update(point: Point, time: number, keys?: DragKeys): LandingFrame;\n /** What a release lands, by the last frame: the same answer as its `landing`. */\n release(): LandingRelease;\n /**\n * The regions changed (a resize, a store change, a scroll): spots map by id; a lost one goes to its lane's nearest.\n * Pass the `regionsFor` that answers for the new state; without one, the old one stays (it must then read live state).\n */\n setRegions(regions: LandingRegions, regionsFor?: (spot: string) => LandingRegions | null): void;\n /** The view moved under the pointer: the gates start again, the lane is let go. */\n hide(): void;\n readonly frame: LandingFrame;\n}\n\nconst inside = (r: Rect, p: Point, grow = 0): boolean => p.x >= r.x - grow && p.x <= r.x + r.width + grow && p.y >= r.y - grow && p.y <= r.y + r.height + grow;\nconst strictlyIn = (r: Rect, p: Point): boolean => p.x >= r.x && p.x <= r.x + r.width && p.y >= r.y && p.y <= r.y + r.height;\n/**\n * How deep `p` lies inside `r` (0 on its edge or outside), counted only from the sides of `r` that face into `stage`: a\n * side on the stage's edge is open, as deep as the pointer can go.\n */\nfunction depthIn(r: Rect, p: Point, stage: Rect): number {\n if (!strictlyIn(r, p)) return 0;\n const on = (a: number, b: number): boolean => Math.abs(a - b) < 1;\n const sides = [\n on(r.x, stage.x) ? Infinity : p.x - r.x,\n on(r.x + r.width, stage.x + stage.width) ? Infinity : r.x + r.width - p.x,\n on(r.y, stage.y) ? Infinity : p.y - r.y,\n on(r.y + r.height, stage.y + stage.height) ? Infinity : r.y + r.height - p.y,\n ];\n return Math.max(0, Math.min(...sides));\n}\nconst distanceTo = (r: Rect, p: Point): number => Math.hypot(Math.max(r.x - p.x, 0, p.x - (r.x + r.width)), Math.max(r.y - p.y, 0, p.y - (r.y + r.height)));\nconst alongOf = (lane: LandingLane, p: Point): number => (lane.axis === \"x\" ? p.x : p.y);\nconst acrossOf = (lane: LandingLane, p: Point): number => (lane.axis === \"x\" ? p.y : p.x);\n/** Two rects meet: they overlap or touch (within 1 px), corners included. */\nconst touches = (a: Rect, b: Rect): boolean => a.x <= b.x + b.width + 1 && b.x <= a.x + a.width + 1 && a.y <= b.y + b.height + 1 && b.y <= a.y + a.height + 1;\n/** `p` onto `stage` when it lies past it by at most `reach`; else null (nowhere). */\nfunction ontoStage(stage: Rect, p: Point, reach: number): Point | null {\n if (!inside(stage, p, reach)) return null;\n return { x: Math.min(Math.max(p.x, stage.x), stage.x + stage.width), y: Math.min(Math.max(p.y, stage.y), stage.y + stage.height) };\n}\n\nexport function createLandingModel(options: LandingOptions): LandingModel {\n const margins = { ...LANDING_MARGINS, ...options.margins };\n const gates = { ...LANDING_GATES, ...options.gates };\n const approach = { ...LANDING_APPROACH, ...options.approach };\n const guidesLevel: PlaceGuides = options.placeGuides ?? \"off\";\n let base = options.regions;\n let regionsFor = options.regionsFor;\n const cache = new Map<string, LandingRegions | null>();\n /** The regions with `spot` held: the host's, cached for this lift until `setRegions`. */\n const heldRegions = (spot: string | null): LandingRegions => {\n if (!spot || !regionsFor) return base;\n if (!cache.has(spot)) cache.set(spot, regionsFor(spot));\n return cache.get(spot) ?? base;\n };\n\n let laneId: string | null = options.home?.lane ?? null;\n let spotId: string | null = options.home?.spot ?? null;\n let last: { p: Point; raw: Point; t: number } | null = null;\n /** The last point that differed from the one before, and the step then. */\n let moved: { raw: Point; t: number } | null = null;\n let lastStep = 0;\n /** Path inside each lane since the pointer last entered its rect. */\n const pathIn = new Map<string, number>();\n /** The path along and across each lane at any speed since the pointer entered it (a touching lane's takeover). */\n const slide = new Map<string, { along: number; across: number }>();\n let approached: string | null = null;\n let previous: LandingRegion = laneId ? \"lane\" : \"open\";\n let frame: LandingFrame = { region: previous, lane: laneId, spot: spotId, landing: null, room: !!spotId, guides: [], shift: false };\n\n const laneIn = (regions: LandingRegions, id: string | null): LandingLane | undefined => (id ? regions.lanes.find((l) => l.id === id) : undefined);\n const spotIn = (lane: LandingLane | undefined, id: string | null): LandingSpot | undefined => (lane && id ? lane.spots.find((s) => s.id === id) : undefined);\n\n /** The spot a point along `lane` picks: the spot whose stretch holds it, null over a refused stretch, else the nearest. */\n function pick(lane: LandingLane, a: number): LandingSpot | null {\n if (lane.refused.some((r) => a >= r.along[0] && a <= r.along[1])) return null;\n const hit = lane.spots.find((s) => a >= s.along[0] && a <= s.along[1]);\n if (hit) return hit;\n let best: LandingSpot | null = null;\n let dist = Infinity;\n for (const s of lane.spots) {\n const d = a < s.along[0] ? s.along[0] - a : a - s.along[1];\n if (d < dist) {\n best = s;\n dist = d;\n }\n }\n return best;\n }\n\n /** Along a held lane: the spot after hysteresis, the step gate and the fixed-point check. */\n function along(lane: LandingLane, p: Point, step: number): LandingSpot | null {\n const regions = heldRegions(spotId);\n const held = laneIn(regions, lane.id) ?? lane;\n const a = alongOf(held, p);\n const now = spotIn(held, spotId);\n const cand = pick(held, a);\n if (!cand) return null;\n if (!now || cand.id === now.id) return cand;\n // Past the boundary by the margin, the same everywhere (a wobble within it never flips the spot); where the change\n // moves another item, on a slow enough step. Else the last spot holds.\n const past = a < now.along[0] - margins.spot || a > now.along[1] + margins.spot;\n const reflows = now.others === undefined || now.others !== cand.others;\n if (!past) return now;\n // A fast reflowing change waits for a slow step, unless the held landing already trails the pointer by `trail`: the\n // item chases only as far as it must, so a fast hand across docked items never leaves it far behind.\n if (reflows && step > gates.step && distanceTo(now.landing, p) <= gates.trail) return now;\n // The fixed point: in the candidate's own regions (its room open), the pointer still picks it.\n if (regionsFor && reflows) {\n const theirs = heldRegions(cand.id);\n const lane2 = laneIn(theirs, lane.id);\n if (lane2 && pick(lane2, alongOf(lane2, p))?.id !== cand.id) return now;\n }\n return cand;\n }\n\n function guidesFor(p: Point, region: LandingRegion, shift: boolean): LandingGuide[] {\n if (guidesLevel === \"off\" || shift) return [];\n const regions = heldRegions(spotId);\n const all = (l: LandingLane): LandingGuide[] =>\n l.marks\n ? l.marks.map((m, i) => ({ id: m.id ?? `${l.id}#${i}`, lane: l.id, kind: m.kind, rect: m.rect }))\n : l.spots.map((s) => ({ id: `${l.id}/${s.id}`, lane: l.id, kind: \"box\" as const, rect: s.landing }));\n if (guidesLevel === \"all\") return regions.lanes.flatMap(all);\n if ((region === \"lane\" || region === \"refused\") && laneId) {\n approached = laneId;\n const l = laneIn(regions, laneId);\n return l ? all(l) : [];\n }\n let best: LandingLane | null = null;\n let bestD = Infinity;\n for (const l of regions.lanes) {\n const d = distanceTo(l.rect, p);\n if (d < bestD) {\n best = l;\n bestD = d;\n }\n }\n // Over a refused place: the nearest lane at any distance (the lane behind a refused column).\n if (region === \"refused\") {\n approached = best?.id ?? null;\n return best ? all(best) : [];\n }\n // The approached lane: the nearest within reach, kept until another is clearly nearer or it is past `keep`.\n const kept = laneIn(regions, approached);\n if (kept) {\n const d = distanceTo(kept.rect, p);\n if (d > approach.keep) approached = null;\n else if (best && best.id !== kept.id && bestD + approach.nearer < d) approached = bestD <= approach.reach ? best.id : null;\n } else approached = best && bestD <= approach.reach ? best.id : null;\n const l = laneIn(regions, approached);\n return l ? all(l) : [];\n }\n\n function update(raw: Point, t: number, keys?: DragKeys): LandingFrame {\n // Past the stage by up to `edge`: on its edge. Beyond: nowhere (kept as is).\n const p = ontoStage(heldRegions(spotId).stage, raw, margins.edge) ?? raw;\n // The step: the pointer as it moved (a fling past the edge isn't still) since the last point that differed,\n // normalized to 125 Hz (8 ms). A repeated point (a host updating per frame, or a gap between sparse samples) keeps\n // the last step until the pointer has stayed put for `rest` ms after a slow step or on the stage's edge, else for\n // `pause` ms; only then is it still. A hand moving fast with samples far apart is never still between them.\n let step = 0;\n if (moved && (raw.x !== moved.raw.x || raw.y !== moved.raw.y)) {\n step = (Math.hypot(raw.x - moved.raw.x, raw.y - moved.raw.y) * 8) / Math.max(1, t - moved.t);\n moved = { raw, t };\n lastStep = step;\n } else if (moved) {\n const stage = heldRegions(spotId).stage;\n const onEdge = p.x <= stage.x || p.y <= stage.y || p.x >= stage.x + stage.width || p.y >= stage.y + stage.height;\n const since = t - moved.t;\n step = since >= gates.pause || (since >= gates.rest && (lastStep <= gates.step || onEdge)) ? 0 : lastStep;\n } else {\n // The first point: how the pointer moves is unknown, never still (a lift over a lane's band doesn't enter it).\n moved = { raw, t };\n step = lastStep = Infinity;\n }\n const from = last?.p ?? null;\n // The pointer as it moved: a fling off the stage's edge moves across a lane there though its clamped point doesn't.\n const fromRaw = last?.raw ?? null;\n last = { p, raw, t };\n const shift = !!keys?.shift;\n const regions = heldRegions(spotId);\n // The path inside each lane: the part along the lane of slow steps from a point inside it to another (the step that\n // enters doesn't count, nor a fast one), so a crossing at `step` speed or faster never enters by path at any angle.\n // From a held lane, a touching lane counts the path along it and across it at any speed: a fast slide along it\n // (across it at most a third as far as along) is no crossing.\n const slow = step <= gates.step;\n for (const l of regions.lanes) {\n const was = from && strictlyIn(l.rect, from);\n const go = was ? Math.abs(alongOf(l, p) - alongOf(l, from)) : 0;\n const over = was && fromRaw ? Math.abs(acrossOf(l, raw) - acrossOf(l, fromRaw)) : 0;\n const inL = strictlyIn(l.rect, p);\n pathIn.set(l.id, inL ? (pathIn.get(l.id) ?? 0) + (slow ? go : 0) : 0);\n const s = slide.get(l.id);\n slide.set(l.id, inL ? { along: (s?.along ?? 0) + go, across: (s?.across ?? 0) + over } : { along: 0, across: 0 });\n }\n\n let region: LandingRegion;\n if (!inside(regions.stage, p)) {\n // Outside the stage: nowhere, and the lane is let go.\n region = \"nowhere\";\n laneId = spotId = null;\n } else {\n const held = laneIn(regions, laneId);\n const gate = (l: LandingLane): boolean => (pathIn.get(l.id) ?? 0) >= gates.path || (depthIn(l.rect, p, regions.stage) >= gates.depth && step <= gates.still);\n // Lane to lane: inside a lane touching the held one, past the held lane's exit margin (inside it the held lane holds,\n // P1), the held lane still holds until that lane's gate passes, then that lane takes it. Never the float between\n // them, never a fly-through's room.\n const touching = held ? regions.lanes.find((l) => l.id !== held.id && strictlyIn(l.rect, p) && touches(l.rect, held.rect) && !inside(held.rect, p, margins.exit)) : undefined;\n const sl = touching ? slide.get(touching.id) : undefined;\n const slid = !!sl && sl.along >= gates.path && sl.across * 3 <= sl.along;\n const next = touching && (gate(touching) || slid) ? touching : undefined;\n if (held && !next && (touching || inside(held.rect, p, margins.exit))) {\n const s = along(held, p, step);\n spotId = s?.id ?? spotId;\n region = s ? \"lane\" : \"refused\";\n if (!s) spotId = null;\n } else {\n laneId = spotId = null;\n // Entering: a touching lane at once, else the path gate or the still gate; at a tie, the lane the pointer is\n // deeper in.\n let entered: LandingLane | null = next ?? null;\n if (!entered)\n for (const l of regions.lanes) {\n if (!strictlyIn(l.rect, p)) continue;\n const deep = depthIn(l.rect, p, regions.stage);\n if (gate(l) && (!entered || deep > depthIn(entered.rect, p, regions.stage))) entered = l;\n }\n if (entered) {\n laneId = entered.id;\n const s = pick(entered, alongOf(entered, p));\n spotId = s?.id ?? null;\n region = s ? \"lane\" : \"refused\";\n } else if (regions.refused.some((r) => inside(r, p))) region = \"refused\";\n else if (inside(regions.content, p) && !regions.blocked.some((b) => strictlyIn(b, p))) region = \"open\";\n // Inside a lane not yet entered: what it was (on the way in, the document's float).\n else if (regions.lanes.some((l) => strictlyIn(l.rect, p))) region = previous === \"lane\" ? \"open\" : previous;\n else region = \"refused\";\n }\n }\n previous = region;\n const shown: LandingRegion = shift && (region === \"lane\" || region === \"open\") ? \"open\" : region;\n const r2 = heldRegions(spotId);\n const spot = spotIn(laneIn(r2, laneId), spotId);\n const landing = shown === \"lane\" ? (spot?.landing ?? null) : shown === \"open\" ? (options.floatLanding?.(p) ?? null) : null;\n frame = {\n region: shown,\n lane: laneId,\n spot: shown === \"lane\" ? spotId : null,\n landing,\n room: shown === \"lane\" && !!spot,\n guides: guidesFor(p, shown, shift),\n shift,\n };\n return frame;\n }\n\n return {\n update,\n release(): LandingRelease {\n if (frame.region === \"lane\" && frame.lane && frame.spot) return { kind: \"spot\", lane: frame.lane, spot: frame.spot, home: !!options.home && options.home.spot === frame.spot && options.home.lane === frame.lane };\n if (frame.region === \"open\" && frame.landing) return { kind: \"float\", rect: frame.landing };\n return null;\n },\n setRegions(regions: LandingRegions, nextRegionsFor?: (spot: string) => LandingRegions | null): void {\n base = regions;\n if (nextRegionsFor) regionsFor = nextRegionsFor;\n cache.clear();\n const l = laneIn(base, laneId);\n if (laneId && !l) laneId = spotId = null;\n else if (l && spotId && !spotIn(l, spotId) && last) spotId = pick(l, alongOf(l, last.p))?.id ?? null;\n },\n hide(): void {\n laneId = spotId = null;\n approached = null;\n pathIn.clear();\n slide.clear();\n last = moved = null;\n lastStep = 0;\n },\n get frame(): LandingFrame {\n return frame;\n },\n };\n}\n","import type { DragFrame, DragTarget } from \"./intent\";\n\n/**\n * How a drag previews its drop, from least to most motion while dragging:\n *\n * - `\"indicator\"`: nothing moves; only the indicator (an outline or an\n * insertion marker) shows the target.\n * - `\"gap\"`: once the room is made, the others move aside and open the slot;\n * the item stays under the pointer.\n * - `\"snap\"`: the gap opens and the item itself glides into it (for a target\n * with a slot; one without keeps the indicator).\n * - `\"item\"`: the dragged item is the only preview: no indicator for any\n * target. It sits in a slotted target once the room is open and otherwise\n * stays on the pointer. Pair it with the intent's `earlyRelease: \"float\"`, so\n * a release lands what shows.\n *\n * Every mode follows the same intent: what shows, when, and what a release\n * lands on are the drag intent's, so a drop always lands where the preview\n * showed it.\n */\nexport type DragPreview = \"indicator\" | \"gap\" | \"snap\" | \"item\";\n\n/** The preview a drag uses unless the host picks another. */\nexport const DRAG_PREVIEW_DEFAULT: DragPreview = \"snap\";\n\n/**\n * Place guides: faint marks on the free places that take the held item, shown only while no landing shows. `\"off\"`:\n * none; `\"near\"`: the places of the edge the pointer approaches; `\"all\"`: every place, from the lift.\n */\nexport type PlaceGuides = \"off\" | \"near\" | \"all\";\n\n/**\n * A drop preview as a mode and its place guides, beside the string forms: `\"outline\"` is `\"indicator\"`'s plan,\n * `\"placeholder\"` is `\"gap\"`'s, and `\"snap\"` is `\"item\"`'s (the item the only preview). `placeGuides` defaults per mode\n * ({@link PLACE_GUIDES_DEFAULT}).\n */\nexport type DropPreviewMode =\n | { readonly mode: \"outline\"; readonly placeGuides?: PlaceGuides }\n | { readonly mode: \"placeholder\"; readonly placeGuides?: PlaceGuides }\n | { readonly mode: \"snap\"; readonly placeGuides?: PlaceGuides };\n\n/** Each mode's place guides when it names none: Snap and Placeholder near, Outline none. */\nexport const PLACE_GUIDES_DEFAULT: Readonly<Record<DropPreviewMode[\"mode\"], PlaceGuides>> = { outline: \"off\", placeholder: \"near\", snap: \"near\" };\n\n/** The string plan each mode draws with. */\nconst PLAN_OF: Readonly<Record<DropPreviewMode[\"mode\"], DragPreview>> = { outline: \"indicator\", placeholder: \"gap\", snap: \"item\" };\n\n/** What to draw for one frame of a drag. */\nexport interface PreviewPlan {\n /** Draw the indicator on the shown target. */\n readonly showIndicator: boolean;\n /** Lay the others out around the room (the gap is open). */\n readonly makeRoom: boolean;\n /** Draw the item in its slot instead of under the pointer. */\n readonly snapItem: boolean;\n /**\n * The place guides to draw this frame: the mode's `placeGuides` while no landing shows (no indicator, no room, no item\n * in its slot), `\"off\"` whenever one does, so the screen shows where the item can go or where it will land, never\n * both. Always `\"off\"` for the string forms. Optional, so a plan a host builds itself is still one: absent means\n * `\"off\"`.\n */\n readonly guides?: PlaceGuides;\n}\n\n/**\n * The plan for a frame of the drag intent under `preview`. `slotted` says\n * whether the shown target's drop has a slot the item can sit in (default: a\n * target that isn't `free`); only such a target snaps, and in `\"snap\"` it\n * previews with the item rather than the indicator.\n *\n * - `\"indicator\"`: the indicator, never room, never a snap.\n * - `\"gap\"`: the indicator, and room when the intent makes it.\n * - `\"snap\"`: room when the intent makes it, the item snapped into a slotted\n * target's room; the indicator only for a target without a slot.\n * - `\"item\"`: as `\"snap\"`, with no indicator at all.\n *\n * The object form ({@link DropPreviewMode}) draws with its mode's string plan and adds its place guides (`guides`).\n */\nexport function previewPlan<T extends DragTarget>(\n frame: Pick<DragFrame<T>, \"shown\" | \"room\">,\n preview: DragPreview | DropPreviewMode,\n slotted: boolean = !!frame.shown && !frame.shown.free,\n): PreviewPlan {\n if (typeof preview === \"object\") {\n const plan = stringPlan(frame, PLAN_OF[preview.mode], slotted);\n const asked = preview.placeGuides ?? PLACE_GUIDES_DEFAULT[preview.mode];\n const landing = plan.showIndicator || plan.makeRoom || plan.snapItem;\n return { ...plan, guides: landing ? \"off\" : asked };\n }\n return stringPlan(frame, preview, slotted);\n}\n\nfunction stringPlan<T extends DragTarget>(frame: Pick<DragFrame<T>, \"shown\" | \"room\">, preview: DragPreview, slotted: boolean): PreviewPlan {\n const shown = !!frame.shown;\n if (preview === \"indicator\") return { showIndicator: shown, makeRoom: false, snapItem: false, guides: \"off\" };\n if (preview === \"gap\") return { showIndicator: shown, makeRoom: frame.room, snapItem: false, guides: \"off\" };\n if (preview === \"item\") return { showIndicator: false, makeRoom: frame.room, snapItem: frame.room && shown && slotted, guides: \"off\" };\n // By design a slotted target draws nothing until the room opens (`roomAfter`); a release then still lands on it.\n return { showIndicator: shown && !slotted, makeRoom: frame.room, snapItem: frame.room && shown && slotted, guides: \"off\" };\n}\n","import { DOUBLE_CLICK, type DoubleClick } from \"../double-click\";\nimport type { Point } from \"../shapes\";\nimport { liftDecision, type DragTuning, type LiftDecision } from \"./intent\";\n\n/** How a press on a grip ended: a click, the second click of a double (`doubleActivate`, not a click), or a drag (`null`). */\nexport type GripRelease = \"click\" | \"doubleActivate\" | null;\n\n/** A press on a grip, start to end: whether it lifts, and what its release is. Pure: positions and times are the host's. */\nexport interface GripPress {\n /**\n * A press at `point`, `time` ms. `touch` for a finger (the touch lift rule). `clicks`, when the host has the\n * platform's count for this press (a `mousedown`'s `detail`, 1 or more), decides the double instead of the interval.\n */\n down(point: Point, time: number, options?: { readonly touch?: boolean; readonly clicks?: number }): void;\n /** The pointer moved: `liftDecision` for this press. Once `\"lift\"` it stays a drag; once `\"refuse\"` it never is. */\n move(point: Point, time: number): LiftDecision;\n /**\n * The press ended. `\"click\"`, or `\"doubleActivate\"` when it is the second click of a double (it is not a click\n * then); null when it lifted or was refused. A press that never moved past the lift distance never lifts, so an\n * unmoved double never starts a drag (a second press that moves past it is a drag like any other). A third click\n * after a double starts a new pair.\n */\n up(point: Point, time: number): GripRelease;\n /** Forget the press and the click before it (a cancelled press, a scroll). */\n cancel(): void;\n}\n\n/**\n * A grip's press, double-click included: a press that moves past the lift distance is a drag; one that doesn't is a\n * click, and a second such press within the double interval and distance is a double-activate (the host folds or\n * unfolds, say), never a second click and never a lift: an unmoved double never starts a drag.\n *\n * The first click of a double is delivered as `\"click\"` before the double is known (nothing waits for a second press),\n * so a host keeps a grip's click harmless (a use, a focus): the double-activate that follows must not have to undo it.\n */\nexport function createGripPress(options: { readonly tuning?: Partial<DragTuning>; readonly double?: Partial<DoubleClick> } = {}): GripPress {\n const tuning = options.tuning ?? {};\n // The package's one double click (`DOUBLE_CLICK`), unless the host tunes it.\n const dbl: DoubleClick = { ...DOUBLE_CLICK, ...options.double };\n let press: { at: Point; time: number; touch: boolean; double: boolean; state: LiftDecision } | null = null;\n // The last click (a press that ended as one): where and when it was pressed.\n let last: { at: Point; time: number } | null = null;\n return {\n down(point, time, o = {}) {\n const near = !!last && time - last.time <= dbl.ms && Math.hypot(point.x - last.at.x, point.y - last.at.y) <= dbl.px;\n const double = o.clicks !== undefined && o.clicks > 0 ? o.clicks === 2 : near;\n press = { at: { x: point.x, y: point.y }, time, touch: !!o.touch, double, state: \"wait\" };\n },\n move(point, time) {\n if (!press) return \"wait\";\n if (press.state !== \"wait\") return press.state;\n press.state = liftDecision({ touch: press.touch, distance: Math.hypot(point.x - press.at.x, point.y - press.at.y), elapsed: time - press.time }, tuning);\n return press.state;\n },\n up() {\n const p = press;\n press = null;\n if (!p || p.state !== \"wait\") {\n last = null;\n return null;\n }\n if (p.double) {\n last = null;\n return \"doubleActivate\";\n }\n last = { at: p.at, time: p.time };\n return \"click\";\n },\n cancel() {\n press = null;\n last = null;\n },\n };\n}\n"],"mappings":";;;;;AAoGO,IAAM,gBAA4B;AAAA,EACvC,MAAM;AAAA,EACN,WAAW;AAAA,EACX,WAAW;AAAA,EACX,aAAa;AAAA,EACb,UAAU;AAAA,EACV,OAAO;AAAA,EACP,OAAO;AAAA,EACP,MAAM;AAAA,EACN,cAAc;AAAA,EACd,WAAW;AAAA,EACX,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AAAA,EACX,gBAAgB;AAAA,EAChB,UAAU;AAAA,EACV,WAAW,EAAE,IAAI,MAAM,UAAU,SAAS,SAAS,MAAM;AAC3D;AAEA,IAAM,YAAiE,EAAE,OAAO,SAAS,KAAK,OAAO,SAAS,QAAQ,MAAM,OAAO;AAEnI,IAAM,OAAO,CAAC,MAA4B,QACxC,CAAC,CAAC,SAAS,QAAQ,QAAQ,CAAC,EAAE,KAAK,QAAQ,KAAK,QAAQ,CAAC,CAAC,KAAK,UAAU,GAAG,CAAC;AAuExE,IAAM,eAAe;AAGrB,IAAM,WAAW,CAAC,MAAwD,EAAE,WAAW,OAAO,eAAe,EAAE;AAGtH,IAAM,SAAS,CAAC,QAA0B,UACxC,CAAC,UAAW,MAAM,IAAI,OAAO,KAAK,MAAM,I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AA,MACT;AACA,UAAI,EAAE,QAAQ;AACZ,eAAO;AACP,eAAO;AAAA,MACT;AACA,aAAO,EAAE,IAAI,EAAE,IAAI,MAAM,EAAE,KAAK;AAChC,aAAO;AAAA,IACT;AAAA,IACA,SAAS;AACP,cAAQ;AACR,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":["held","distanceTo","held","l"]}
|
|
1
|
+
{"version":3,"sources":["../src/drag/intent.ts","../src/drag/landing.ts","../src/drag/preview.ts","../src/drag/grip.ts","../src/drag/guide-rects.ts"],"sourcesContent":["import type { Point, Rect } from \"../shapes\";\n\n/**\n * The drag intent model's tuning. Distances in px, speeds in px/ms, times in\n * ms; every value can be overridden per intent (see\n * {@link DragIntentOptions.tuning}).\n */\nexport interface DragTuning {\n /** A mouse press lifts once the pointer has moved this far. */\n readonly lift: number;\n /** A touch press lifts only after it has been held this long… */\n readonly touchHold: number;\n /** …and then moved this far (moving that far before the hold is over is not a drag). */\n readonly touchLift: number;\n /** The pointer's speed is measured over this window and smoothed. */\n readonly speedWindow: number;\n /** Aiming: the smoothed speed is below this… */\n readonly aimSpeed: number;\n /** …or the pointer has stayed within `still` px of one spot for `dwell` ms. */\n readonly still: number;\n readonly dwell: number;\n /** The current target holds while the pointer is within this band of its zone. */\n readonly band: number;\n /** A higher-priority target takes over at once when the pointer is this far inside it. */\n readonly breakthrough: number;\n /**\n * The band and the breakthrough scale with the zones: along each axis they are at most this share of the held\n * zone's extent and of the extent of the zone under the pointer (its `hit`), so a small zone (a 28 px row) can be\n * entered by a direct glide from its neighbor. Below a quarter, the pointer at a quarter of a zone is past them.\n */\n readonly bandShare: number;\n /** A gap between zones shorter than this keeps the current target (for a pointer that aims). */\n readonly gapGrace: number;\n /** Aiming, the shown target moves to another one only once that one has held this long. */\n readonly switchHold: number;\n /**\n * Room is made once the shown target, and the place in it, have held this long, so a pointer moving across targets\n * doesn't reflow the layout under it. A target with `opensRoom` holds this long before it shows, its room with it.\n */\n readonly roomAfter: number;\n /** The pointer has left the item's home once it is outside the home shrunk by this much on every side. */\n readonly homeInset: number;\n /**\n * Spring-loading: a target marked `arm: \"dwell\"` takes the drop only once the pointer has stayed in its zone this long\n * (ms); before that it is no target, so a fast pass, or a drop before it, lands on what lies beneath. 0 arms it at once.\n * Armed, its zone is its `armedHit` (the magnet: its band); moving out past that band's outer edge disarms it, and\n * re-entering needs a new full dwell. It arms only after the pointer has ENTERED its zone during the drag: the point\n * the drag starts at counts as not entered, so a drag that starts inside the zone (a panel's grip under the strip at\n * the window's edge) must leave it and come back before it can arm; entering from over home counts.\n */\n readonly railArmDwellMs: number;\n /**\n * The lift zone, a radius in px about the point the drag was lifted at ({@link DragIntentOptions.lift}, else the first\n * sample): no spring-loaded target arms by dwell inside it. Coming back to where you lifted and pausing is the\n * \"changed my mind\" gesture, so it commits nothing even where a strip lies over the grip (a flush drawer's grip at the\n * window's edge). 16 px is about a grip's size. Elsewhere, home under a strip included, arming works as before, and\n * the rail key forces the rail anywhere, the lift zone too.\n */\n readonly liftZone: number;\n /** The keys that win over geometry while held (see {@link DragModifiers}). */\n readonly modifiers: DragModifiers;\n}\n\n/**\n * A modifier key, by its `KeyboardEvent.key` name, or `\"Mod\"`: ⌘ (Meta) on macOS and Ctrl elsewhere. `\"Mod\"` counts\n * either key as held, so no platform detection is needed.\n */\nexport type ModifierKey = \"Shift\" | \"Alt\" | \"Control\" | \"Meta\" | \"Mod\";\n\n/** The modifier keys held on a sample (a pointer event's `shiftKey`, `altKey`, `ctrlKey`, `metaKey`). */\nexport interface DragKeys {\n readonly shift?: boolean;\n readonly alt?: boolean;\n readonly ctrl?: boolean;\n readonly meta?: boolean;\n}\n\n/**\n * Keys that win over geometry: while `floatKey` is held the drop floats (the `free` target) wherever the pointer is,\n * except over a refusal (the frame is refused) or outside the float's `bounds` (nothing);\n * while `railKey` is held it goes to the nearest target marked `arm` (a side's rail), without reaching it. `floatKey`\n * wins when both are held. `on: false` turns both off.\n */\nexport interface DragModifiers {\n readonly on: boolean;\n readonly floatKey: ModifierKey;\n readonly railKey: ModifierKey;\n}\n\n/**\n * The defaults: a mouse lifts after 5 px, a touch after a 180 ms hold and\n * 8 px; aiming is slower than 0.45 px/ms over 50 ms, or within 12 px for\n * 90 ms; a 10 px band and a 4 px breakthrough, each at most a fifth of the\n * zones' extents, and a 120 ms gap grace; a switch waits 150 ms (the shortest\n * an indicator may show); room after 160 ms. A spring-loaded target arms after\n * 200 ms of dwell (long enough that a pass at travelling speed never arms it,\n * short enough to feel like the platforms' spring-loading); Shift floats, ⌘/Ctrl\n * (`\"Mod\"`) goes to the nearest rail. Alt is left free: an app with a frozen\n * layout uses it to unfreeze temporarily, and a key should have one meaning.\n */\nexport const DRAG_DEFAULTS: DragTuning = {\n lift: 5,\n touchHold: 180,\n touchLift: 8,\n speedWindow: 50,\n aimSpeed: 0.45,\n still: 12,\n dwell: 90,\n band: 10,\n breakthrough: 4,\n bandShare: 0.2,\n gapGrace: 120,\n switchHold: 150,\n roomAfter: 160,\n homeInset: 6,\n railArmDwellMs: 200,\n liftZone: 16,\n modifiers: { on: true, floatKey: \"Shift\", railKey: \"Mod\" },\n};\n\nconst KEY_FIELD: Record<Exclude<ModifierKey, \"Mod\">, keyof DragKeys> = { Shift: \"shift\", Alt: \"alt\", Control: \"ctrl\", Meta: \"meta\" };\n/** Whether `key` is held in `keys` (`\"Mod\"`: ⌘ or Ctrl). */\nconst held = (keys: DragKeys | undefined, key: ModifierKey): boolean =>\n !!keys && (key === \"Mod\" ? !!(keys.meta || keys.ctrl) : !!keys[KEY_FIELD[key]]);\n\n/**\n * A drop target: plain data. `hit` is the zone the pointer can be in;\n * `priority` how precise it is (1 beats 2 beats 3; equal priorities go to the\n * smaller zone). `slot` is where the dragged item would land, `label` what to\n * call it; the model reads neither. A `free` target has no slot (the item\n * floats where it is dropped): no room is made for it. `hits`, when given, is\n * the whole zone as several rects (a zone that isn't one rect, `hit` the\n * largest of them): the pointer is in the zone when it is in any of them.\n *\n * `arm: \"dwell\"` makes it spring-loaded: it is no target until the pointer has\n * dwelt in its zone for `railArmDwellMs`; once armed its zone is `armedHit`\n * when given (a magnet: the zone grown), and leaving that disarms it.\n *\n * `refuse: true` makes it a refusal: a place that takes no drop (a host draws nothing over it, and at most says \"Can't\n * go here\" at the pointer). It takes part in\n * the pick under the pointer at {@link REFUSAL_RANK} (below every target of priority 1 or 2, whatever its own\n * `priority`, above priority 3), but it never becomes the current or the shown target, and a release over it lands\n * nowhere. Where the pick under the pointer is a refusal, no held target's band or gap grace keeps it: nothing shows,\n * and the frame's `refused` says which refusal it is.\n *\n * `bounds`, when given, is the drawn space the zone belongs to (a window's stage): the zone, its band and its gap grace\n * hold only points strictly inside it, so it is half-open toward the outside and a point on `bounds`' boundary or past\n * it is never in it. The window's boundary belongs only to the targets drawn against it: a refusal and a target over\n * the whole plane (the float) carry `bounds`, a gap or a slot doesn't. So a pointer a host clamps onto the window's\n * edge picks a gap whose hit reaches the edge, else nothing (a held target keeps its band), and never a refusal or the\n * float. The rule relies on the host clamping exactly onto the stage's edge (`x + width`, `y + height`): a host that\n * clamps to `width - 0.5` still picks inside the window, the float or a refusal there included.\n *\n * `opensRoom: true` marks a target whose indicator would lie over what its room moves (a side rail that pushes a column\n * aside). Showing it and making its room are then one decision: it shows only once it has held `roomAfter` ms, and the\n * frame that first shows it already has `room`. A sweep across it moves nothing, as for any target, and no frame draws\n * it over the column. Until it shows, a release still lands on it. An armed spring-loaded target has its room at once\n * too: its dwell was the decision. `roomHold` is how long this target holds before that decision, in ms, in place of\n * `roomAfter` (a rail or a new-column line against the window's edge, which a pointer rarely crosses on its way\n * elsewhere, can wait less). A\n * host that draws only a marker and doesn't use `previewPlan`'s room opens the room on\n * `frame.room && frame.shown?.opensRoom`.\n *\n * `roomHit`, with `opensRoom`, is where the target's room draws the item once it is open (its landing rect: an empty\n * rail or bar is entered over its drawn depth). While the target shows with its room open it holds in `hit ∪ roomHit`: wherever\n * the pointer is in `roomHit` and inside its `bounds` too. What lies there is drawn as the room, so a refusal or a\n * target of the same or a lower precision under it doesn't take over, and the frame isn't `refused` there. A more\n * precise target (a lower `priority`) still takes over once the pointer is past `breakthrough` into it, and a held key\n * still wins. Out of both the target is held as any other (its `hit` and band), so once it goes its zone is `hit` again.\n */\nexport interface DragTarget {\n readonly id: string;\n readonly priority: 1 | 2 | 3;\n readonly hit: Rect;\n readonly hits?: readonly Rect[];\n readonly slot?: Rect;\n readonly label?: string;\n readonly free?: boolean;\n readonly arm?: \"dwell\";\n readonly armedHit?: Rect;\n readonly refuse?: true;\n readonly bounds?: Rect;\n readonly opensRoom?: true;\n readonly roomHold?: number;\n readonly roomHit?: Rect;\n}\n\n/**\n * Where a refusal ranks in the pick ({@link targetAt}): an ordering rank, not a priority. Priorities stay the integers\n * 1, 2 and 3; a refusal's tier is `refuse: true`, and the pick orders it by this rank on the same scale: after every\n * target of priority 1 and 2 (a refusal and a real target where they meet or overlap: the target wins, so a gap keeps\n * its end), before priority 3 (the float: over drawn space that takes nothing, the refusal wins over floating).\n * Among refusals the smaller zone wins. `@n-uf/placement` exports the same value for its reference pick.\n */\nexport const REFUSAL_RANK = 2.5;\n\n/** A target's rank in the pick: its `priority`, a refusal's {@link REFUSAL_RANK}. Lower wins. */\nexport const pickRank = (t: Pick<DragTarget, \"priority\" | \"refuse\">): number => (t.refuse === true ? REFUSAL_RANK : t.priority);\n\n/** Whether `point` lies strictly inside `bounds` (none: everywhere). */\nconst within = (bounds: Rect | undefined, point: Point): boolean =>\n !bounds || (point.x > bounds.x && point.x < bounds.x + bounds.width && point.y > bounds.y && point.y < bounds.y + bounds.height);\n\n/** Whether `point` lies in `rect` grown by `margin` px on every side (shrunk, for a negative margin). */\nexport function inRect(rect: Rect, point: Point, margin = 0): boolean {\n return point.x >= rect.x - margin && point.x <= rect.x + rect.width + margin && point.y >= rect.y - margin && point.y <= rect.y + rect.height + margin;\n}\n\n/** How far `point` lies from `rect` (0 inside it). */\nconst distanceTo = (rect: Rect, point: Point): number =>\n Math.hypot(Math.max(rect.x - point.x, 0, point.x - (rect.x + rect.width)), Math.max(rect.y - point.y, 0, point.y - (rect.y + rect.height)));\n\n/** Whether `point` lies in a target's zone (`hits` when it has them, else `hit`), grown by `margin` px, and inside its `bounds`. */\nconst inZone = (t: DragTarget, point: Point, margin = 0): boolean => within(t.bounds, point) && (t.hits ? t.hits.some((r) => inRect(r, point, margin)) : inRect(t.hit, point, margin));\n\n/** A margin per axis: px grown (shrunk, when negative) left and right, and above and below. */\ninterface Margin {\n readonly x: number;\n readonly y: number;\n}\n/**\n * Whether `point` lies in a target's zone grown by `m.x` px left and right and `m.y` px above and below, and inside its\n * `bounds`: a band never reaches past a zone's bounds (the float's band holds nothing outside the window).\n */\nconst inZoneBy = (t: DragTarget, point: Point, m: Margin): boolean =>\n within(t.bounds, point) && (t.hits ?? [t.hit]).some((r) => point.x >= r.x - m.x && point.x <= r.x + r.width + m.x && point.y >= r.y - m.y && point.y <= r.y + r.height + m.y);\n/** `px`, but along each axis at most `share` of each zone's extent (its `hit`) along it. */\nconst scaled = (px: number, share: number, zones: readonly (DragTarget | null)[]): Margin => {\n let x = px;\n let y = px;\n for (const z of zones) {\n if (!z) continue;\n x = Math.min(x, share * z.hit.width);\n y = Math.min(y, share * z.hit.height);\n }\n return { x, y };\n};\nconst negate = (m: Margin): Margin => ({ x: -m.x, y: -m.y });\n\nconst area = (r: Rect): number => r.width * r.height;\n/** A target's zone's area: its `hits` together, else its `hit`. */\nconst zoneArea = (t: DragTarget): number => (t.hits ? t.hits.reduce((s, r) => s + area(r), 0) : area(t.hit));\n\n/**\n * The most precise target under `point`: the lowest rank ({@link pickRank}: the priority, a refusal's\n * {@link REFUSAL_RANK}), then the smallest zone; null when none is. A zone holds its edges (a closed rect), except\n * toward the outside of its `bounds`.\n */\nexport function targetAt<T extends DragTarget>(targets: readonly T[], point: Point): T | null {\n let best: T | null = null;\n for (const t of targets) {\n if (!inZone(t, point)) continue;\n if (!best || pickRank(t) < pickRank(best) || (pickRank(t) === pickRank(best) && zoneArea(t) < zoneArea(best))) best = t;\n }\n return best;\n}\n\n/** What a press does so far: not yet a drag (`wait`), a drag (`lift`), or never one (`refuse`: a touch that moved too soon). */\nexport type LiftDecision = \"wait\" | \"lift\" | \"refuse\";\n\n/**\n * The lift rule for a press that has moved `distance` px in `elapsed` ms. A\n * mouse (or pen) lifts at `lift` px. A touch lifts only after `touchHold` ms,\n * then at `touchLift` px; moving `touchLift` px before the hold is over\n * refuses the drag (the finger is scrolling or swiping).\n */\nexport function liftDecision(press: { readonly touch: boolean; readonly distance: number; readonly elapsed: number }, tuning: Partial<DragTuning> = {}): LiftDecision {\n const t = { ...DRAG_DEFAULTS, ...tuning };\n if (!press.touch) return press.distance >= t.lift ? \"lift\" : \"wait\";\n if (press.elapsed < t.touchHold) return press.distance >= t.touchLift ? \"refuse\" : \"wait\";\n return press.distance >= t.touchLift ? \"lift\" : \"wait\";\n}\n\n/** One update's answer. */\nexport interface DragFrame<T extends DragTarget> {\n /** The target the drop indicator shows, or null. */\n readonly shown: T | null;\n /**\n * The others make room for the shown target: it, and the place in it, have held `roomAfter` ms. For a target with\n * `opensRoom`, or an armed spring-loaded one, from the first frame that shows it.\n */\n readonly room: boolean;\n /**\n * The place the room is made for, or null. Within one target it stays on\n * the old place until a new one has held `roomAfter` ms (see\n * {@link DragIntentOptions.placeOf}).\n */\n readonly roomPlace: string | null;\n /** The pointer is aiming: slow, or nearly still for a moment. */\n readonly aiming: boolean;\n /**\n * The pointer is back inside `home` after it has been outside `home` itself. Never true at the press, nor while the\n * pointer only moves about inside `home`, even near its edge (where `state.leftHome` is already true: that flag is for\n * the indicator's gate and uses `homeInset`; this one does not). Over home no target is shown and a release does\n * nothing, so a host that wants to say \"a drop here returns it\" draws its own indicator for this frame (at the home\n * rect); the intent still shows no target.\n *\n * A docked item's home holds wherever it lies. The home of a floating item (`DragIntentOptions.floating`) is a free\n * placement, ranked like the float: it holds only where the pick there, home ignored, is no refusal and the point is\n * inside the window. Where it doesn't hold this is false and the pick is as anywhere else: over a refusal\n * `refused` says so, and a release lands nowhere.\n */\n readonly atHome: boolean;\n /**\n * A spring-loaded target (`arm: \"dwell\"`) the pointer is in and dwelling on, not armed yet (a host highlights it), or\n * null. Once it arms it is a target like any other and may show.\n */\n readonly arming: T | null;\n /**\n * A key held wins over geometry this frame: `\"float\"` (the float key) or `\"rail\"` (the rail key), else null. The\n * float key chooses the float over dock targets, not over a refusal or outside the window: there it is still\n * `\"float\"` (the key is held), but nothing shows, a release lands nowhere, and over a refusal `refused` says which.\n */\n readonly forced: \"float\" | \"rail\" | null;\n /**\n * The refusal (a target with `refuse: true`) the pointer is over, when it is the pick there: no target shows. A host\n * never draws the refused place; it may say \"Can't go here\" at the pointer. Null otherwise, and while a key forces a target; with the float key\n * held over a refusal it is that refusal (the key doesn't float over refused space).\n */\n readonly refused: T | null;\n /**\n * No target shows, and the pointer has been over a refusal since a target last showed (or since the lift). A refusal\n * hides the shown target at once, and the next one shows only once the pointer aims again, so a pointer that crosses\n * a refusal and is let go at speed over a target beyond it has no indicator drawn. Then this is true, and a release\n * still lands on what is under the pointer (`release`): a host that commits only what it has drawn commits that\n * release too. False whenever a target shows, over the refusal itself (`refused`), and after `hide`.\n *\n * Read it from the frame of an `update` at the release point, called before `release` (as `release` asks anyway), so\n * the last move counts. The field is required: a host or a test mock that builds a `DragFrame` itself must set it.\n */\n readonly refusedSinceShown: boolean;\n /**\n * What a release at this frame's point lands on, by the one check `release` makes (`earlyRelease` included), or null\n * (nowhere, or the item goes home). A host draws the landing from it, so what it draws and what a release lands on\n * never disagree. `createDragIntent` always sets it; it is optional only so a host or a test that builds a frame\n * itself needn't.\n */\n readonly landing?: T | null;\n}\n\n/** What a drag intent knows now. */\nexport interface DragIntentState<T extends DragTarget> {\n /** The pointer's smoothed speed, px/ms. */\n readonly speed: number;\n /** The target under the pointer as the hysteresis holds it, or null. */\n readonly current: T | null;\n /** The target the indicator shows, or null. */\n readonly shown: T | null;\n /** The pointer has left the item's home. */\n readonly leftHome: boolean;\n}\n\nexport interface DragIntentOptions<T extends DragTarget> {\n /** Where the item was lifted from: the indicator stays off until the pointer leaves it, and a release there does nothing. */\n readonly home: Rect;\n /** Where the press that lifted the item was (the grip); default the first sample's point. The lift zone is about it. */\n readonly lift?: Point;\n /**\n * The lift zone as a rect instead of a radius, in the same px as the samples: while a sample is inside it no\n * spring-loaded target arms by dwell, and the `liftZone` radius is not applied. A host passes the part of the grip\n * that a drop strip covers (grip ∩ strip), so a pause back there commits nothing while the rest of the strip, right\n * beside a wide grip, still arms. Absent: the `liftZone` radius about `lift`.\n */\n readonly liftRect?: Rect;\n /**\n * The held item floats, and `home` is its own box. A floating item's own place is a free placement: it ranks like the\n * float target, so home holds only where the pick there, home ignored, is no refusal and the point lies inside the\n * window (no target's `bounds` left with nothing picked). Over a refusal in its box the frame is refused and a\n * release lands nowhere; on or past the window's edge nothing is picked; elsewhere in its box home holds as before.\n * Absent (a docked item): home holds wherever it lies, as its own home target beats a refusal.\n */\n readonly floating?: boolean;\n /**\n * What a release does before the item has settled on a target (no room open for it yet). `\"target\"` (the default): it\n * lands on the shown target, else the target under the pointer, drawn or not, an `opensRoom` target that hasn't shown\n * included. `\"float\"`: what shows is what lands, for a host whose dragged item is the only preview (`previewPlan`'s\n * `\"item\"`): the item is still on the pointer, so it floats there (the `free` target; over a refusal or outside the\n * float's `bounds`, nowhere). `release` is its one reader.\n */\n readonly earlyRelease?: \"target\" | \"float\";\n /** Overrides of {@link DRAG_DEFAULTS}. */\n readonly tuning?: Partial<DragTuning>;\n /**\n * The place within a target the pointer is at (a tab index, a stack\n * position, a pane's edge), unique across targets; default: the target's id.\n * Moving between places of the shown target moves the indicator at once but\n * the room only once the new place has held `roomAfter` ms.\n *\n * - `previous` is the place this target had on the last sample (null if it\n * had none), so a place can hold near its boundary (hysteresis).\n * - A null place is no target: there is no drop at that point of the target.\n * It isn't picked or held, the indicator hides there at once (or shows a\n * target beneath that has a place), no room opens, and a release there\n * lands on a target beneath, else goes home.\n * - It is also asked about the current target while the pointer is just\n * outside its hit zone (within the band, or during the gap grace). Answer\n * the nearest place there: returning null outside the zone drops the band\n * and the grace, so the indicator hides a few px past the edge. Return null\n * only for a part of the target that takes no drop.\n * - It is called on every sample for each target under the pointer and for\n * the current one, so keep it cheap and free of side effects.\n */\n readonly placeOf?: (target: T, point: Point, previous: string | null) => string | null;\n}\n\n/** A drag's intent: feed it the pointer on every frame; it says what the indicator shows and what a release lands on. */\nexport interface DragIntent<T extends DragTarget> {\n /**\n * A pointer sample at `time` (ms), with the targets as they stand (they may\n * be rebuilt between calls: the model follows them by id). Call it once a\n * frame while the item is held, also when the pointer doesn't move: a\n * dwell is time passing. `keys`: the modifier keys held now (see {@link DragModifiers}).\n */\n update(point: Point, time: number, targets: readonly T[], keys?: DragKeys): DragFrame<T>;\n /**\n * What a release at `point` lands on: the shown target whenever one shows\n * (a drop lands where the indicator was), else the target under the\n * pointer, else null (the item goes home). A release over home is null: it\n * does nothing. Feed the release point to `update` first, so a last jump\n * of the pointer counts. With a modifier key held (`keys`), the target the key picks, even over home.\n */\n release(point: Point, targets: readonly T[], keys?: DragKeys): T | null;\n /**\n * Hide the indicator (the view is scrolling under the pointer, say). The\n * aim starts afresh: the next sample never counts as aiming, and a dwell\n * starts again.\n */\n hide(time: number): void;\n /** The item's home moved with the view (it scrolled) by (dx, dy). */\n moveHome(dx: number, dy: number): void;\n readonly state: DragIntentState<T>;\n readonly tuning: DragTuning;\n}\n\n/**\n * The drag intent model: when the drop indicator shows, which target it\n * shows, when the others make room, and what a release lands on. Pure: fed\n * pointer samples and plain-data targets, no DOM and no clock of its own.\n *\n * - The indicator shows only when the pointer has left the item's home, a\n * target is under it, and it is aiming (slow, or nearly still for a\n * moment). Time spent crossing a big target at speed doesn't count.\n * - The most precise target wins (priority, then the smaller zone).\n * - Hysteresis: the current target holds while the pointer is within `band`\n * px of its zone, unless a more precise one is clearly (`breakthrough` px)\n * under the pointer; both scale down for small zones (`bandShare` of the\n * held zone's and the entered zone's extents along each axis), so a small\n * zone is entered by a direct glide; for a pointer that aims, a short gap between zones\n * (`gapGrace` ms) keeps it too.\n * - Leaving the shown target: flying, the indicator hides at once; aiming, it\n * moves to the new target once that has held `switchHold` ms (so no\n * indicator shows for less than that), at once for a breakthrough. A target\n * kept only by the gap grace can keep the indicator, never show it.\n * - Room is made once the shown target has held `roomAfter` ms, never for a\n * free target, and closes at once when it changes. A target with `opensRoom`\n * holds that long before it shows and has its room in the same frame; an\n * armed spring-loaded target has its room as it shows. With its room open,\n * one with a `roomHit` holds wherever the pointer is in that room, over a\n * refusal or a target no more precise than it under the room included.\n * - Where `placeOf` gives a target no place (null), it is no target: it is\n * neither shown nor landed on there.\n * - Spring-loading: a target marked `arm: \"dwell\"` is no target until the\n * pointer has stayed in its zone `railArmDwellMs` (the frame's `arming` says\n * which one it dwells on); then it is armed: its zone is `armedHit` (the\n * magnet) and it shows at once. Leaving that zone disarms it.\n * - Keys win over geometry (`modifiers`): the float key shows the `free` target\n * wherever the pointer is over a dock target or open space inside the float's\n * `bounds`, the rail key the nearest target marked `arm`; a release with the\n * key held lands there. Over a refusal, or outside the float's `bounds`, the\n * float key picks nothing: nothing shows and a release lands nowhere.\n */\nexport function createDragIntent<T extends DragTarget>(options: DragIntentOptions<T>): DragIntent<T> {\n const tuning: DragTuning = { ...DRAG_DEFAULTS, ...options.tuning };\n const placeOf = options.placeOf ?? ((t: T) => t.id);\n // Each target's place on the last sample, by id: its `previous` on the next.\n let lastPlaces = new Map<string, string | null>();\n let home: Rect = { ...options.home };\n let samples: { x: number; y: number; t: number }[] = [];\n let cur: T | null = null;\n let curSince = 0;\n let lastInside = 0;\n let shown: T | null = null;\n let shownSince = 0;\n let place: string | null = null;\n let placeSince = 0;\n let roomPlace: string | null = null;\n let leftHome = false;\n // The pointer has been outside `home` itself (`leftHome` turns on already near its edge): `atHome`'s own memory.\n let wentOut = false;\n let speed = 0;\n let anchor: Point | null = null;\n let stillSince = 0;\n let restart = false;\n // The pointer has been over a refusal since a target last showed (the frame's `refusedSinceShown`).\n let crossedRefusal = false;\n // Spring-loading: the target armed (by id), and the one the pointer dwells on and since when.\n let armedId: string | null = null;\n let armingId: string | null = null;\n let armingSince = 0;\n // The spring-loaded targets (by id) the pointer has been outside of during this drag: only those can arm.\n const wasOutside = new Set<string>();\n // The point the drag was lifted at: no spring-loaded target arms by dwell within `liftZone` of it.\n let liftAt: Point | null = options.lift ? { ...options.lift } : null;\n const same =(a: T | null, b: T | null): boolean => (a === null || b === null ? a === b : a.id === b.id);\n // Targets may be rebuilt between calls: follow the ones held by id.\n const follow = (t: T | null, targets: readonly T[]): T | null => (t ? (targets.find((x) => x.id === t.id) ?? t) : null);\n /** An armed target as it acts: its zone is `armedHit` (the magnet) when it has one. */\n const asArmed = (x: T): T => {\n if (!x.armedHit) return x;\n const { hits: _pieces, ...rest } = x;\n return { ...rest, hit: x.armedHit } as T;\n };\n /** The targets as they act now: a spring-loaded one only once armed, in its armed zone. */\n const acting = (targets: readonly T[]): T[] => targets.filter((x) => x.arm !== \"dwell\" || x.id === armedId).map((x) => (x.id === armedId ? asArmed(x) : x));\n /**\n * The target a held key picks at `p`: the float key the `free` target, the rail key the nearest spring-loaded one.\n * The float key chooses the float over dock targets, not over refusals or outside the window: where the pick at `p`\n * (`has`: a target with a place there, or a refusal) is a refusal, it picks nothing and says which refusal; outside\n * the float's `bounds` (a pointer clamped onto the window's edge) it picks nothing. The rail key's drop lands on the\n * rail, not where the pointer is, so neither applies to it.\n */\n const forcedBy = (keys: DragKeys | undefined, p: Point, targets: readonly T[], has: (x: T) => boolean): { kind: \"float\" | \"rail\"; target: T | null; refused: T | null } | null => {\n const m = tuning.modifiers;\n if (!m.on || !keys) return null;\n if (held(keys, m.floatKey)) {\n const f = targets.find((x) => x.free);\n if (!f) return null;\n const under = targetAt(acting(targets).filter((x) => inZone(x, p) && has(x)), p);\n if (under?.refuse === true) return { kind: \"float\", target: null, refused: under };\n return within(f.bounds, p) ? { kind: \"float\", target: f, refused: null } : { kind: \"float\", target: null, refused: null };\n }\n if (!held(keys, m.railKey)) return null;\n let best: T | null = null;\n let bestD = Infinity;\n for (const x of targets) {\n if (x.arm !== \"dwell\") continue;\n const d = distanceTo(asArmed(x).hit, p);\n if (d < bestD) {\n best = x;\n bestD = d;\n }\n }\n return best ? { kind: \"rail\", target: asArmed(best), refused: null } : null;\n };\n\n /** What a release at `point` lands on, as things stand now: `release`'s answer, and every frame's `landing`. */\n const landAt = (point: Point, given: readonly T[], keys: DragKeys | undefined): T | null => {\n // A key held wins over geometry, home included; the float key over a refusal or outside the window lands nowhere.\n const forced = forcedBy(keys, point, given, (x) => x.refuse === true || placeOf(x, point, lastPlaces.get(x.id) ?? null) !== null);\n if (forced) {\n const ft = forced.target;\n return ft ? (given.find((x) => x.id === ft.id) ?? ft) : null;\n }\n // Over home a release does nothing, except onto an armed spring-loaded target whose zone overlaps home.\n if (inRect(home, point)) {\n const armed = armedId === null ? null : given.find((x) => x.id === armedId);\n return armed && inZone(asArmed(armed), point) && placeOf(armed, point, lastPlaces.get(armed.id) ?? null) !== null ? armed : null;\n }\n const targets = acting(given);\n // Drop = shown: a shown target is kept until it hides (flying out past its band hides it at once).\n const s = shown && !(shown.arm === \"dwell\" && shown.id !== armedId) ? follow(shown, given) : null;\n // The target under the pointer that has a place there (a null place is no drop); a refusal there lands nowhere.\n const under = targetAt(\n targets.filter((x) => inZone(x, point) && (x.refuse === true || placeOf(x, point, lastPlaces.get(x.id) ?? null) !== null)),\n point,\n );\n if (options.earlyRelease === \"float\") {\n // What shows is what lands: a target with a slot only once its room is open; before that the item is still on\n // the pointer, so it floats there. A target with no slot (the item's own place, a blocked one) needs no room.\n const needsNoRoom = (x: T): boolean => x.free === true || !x.slot;\n if (s && (needsNoRoom(s) || roomPlace !== null)) return s;\n if (under?.refuse) return null;\n if (under && !under.free && !under.slot) return given.find((x) => x.id === under.id) ?? under;\n const float = given.find((x) => x.free);\n return float && within(float.bounds, point) ? float : null;\n }\n if (s) return s;\n return under && !under.refuse ? (given.find((x) => x.id === under.id) ?? under) : null;\n };\n\n return {\n tuning,\n get state(): DragIntentState<T> {\n return { speed, current: cur, shown, leftHome };\n },\n update(point, time, given, keys) {\n const p = point;\n const t = time;\n samples.push({ x: p.x, y: p.y, t });\n while (samples.length > 2 && t - samples[0]!.t > tuning.speedWindow) samples.shift();\n const a = samples[0]!;\n speed = speed * 0.5 + (Math.hypot(p.x - a.x, p.y - a.y) / Math.max(1, t - a.t)) * 0.5;\n if (!anchor || Math.hypot(p.x - anchor.x, p.y - anchor.y) > tuning.still) {\n anchor = { x: p.x, y: p.y };\n stillSince = t;\n }\n if (!inRect(home, p, -tuning.homeInset)) leftHome = true;\n const atHome = inRect(home, p);\n if (!atHome) wentOut = true;\n // Each target's place at this point, worked out once per sample; a null place is no target.\n const places = new Map<string, string | null>();\n const placeAt = (x: T): string | null => {\n if (!places.has(x.id)) places.set(x.id, placeOf(x, p, lastPlaces.get(x.id) ?? null));\n return places.get(x.id)!;\n };\n const live = (x: T | null): x is T => x !== null && placeAt(x) !== null;\n // Spring-loading: the armed target holds while the pointer is in its armed zone; a target the pointer dwells in\n // arms once it has held `railArmDwellMs`. A key held wins over both.\n const forced = forcedBy(keys, p, given, (x) => x.refuse === true || live(x));\n if (armedId !== null) {\n const was = given.find((x) => x.id === armedId);\n if (!was || forced || !inZone(asArmed(was), p) || !live(was)) armedId = null;\n }\n // Spring-loading is not gated by `atHome`: a strip that overlaps the item's own place still arms by dwell.\n // A spring-loaded target arms only after the pointer has entered it: one it has been outside of during the drag.\n for (const x of given) if (x.arm === \"dwell\" && !inZone(x, p)) wasOutside.add(x.id);\n // Inside the lift zone nothing arms by dwell (\"changed my mind\"); the rail key still forces the rail.\n // With a `liftRect` the zone is that rect, the radius not applied.\n liftAt ??= { x: p.x, y: p.y };\n const inLiftZone = options.liftRect ? inRect(options.liftRect, p) : Math.hypot(p.x - liftAt.x, p.y - liftAt.y) <= tuning.liftZone;\n const dwelling = forced || inLiftZone ? null : targetAt(given.filter((x) => x.arm === \"dwell\" && x.id !== armedId && wasOutside.has(x.id) && inZone(x, p) && live(x)), p);\n let armedNow = false;\n if (!dwelling || armedId !== null) armingId = null;\n else {\n if (armingId !== dwelling.id) {\n armingId = dwelling.id;\n armingSince = t;\n }\n if (t - armingSince >= tuning.railArmDwellMs) {\n armedId = dwelling.id;\n armingId = null;\n armedNow = true;\n }\n }\n const arming = armingId === null ? null : (given.find((x) => x.id === armingId) ?? null);\n const targets = acting(given);\n // A docked item's home holds wherever it lies (its own home target beats a refusal). A floating item's own place\n // is a free placement, ranked like the float: its home holds only where the pick there, home ignored, is no\n // refusal and not nothing outside a target's `bounds` (past the window). Elsewhere the pick is as anywhere else.\n const underHome = atHome && options.floating ? targetAt(targets.filter((x) => inZone(x, p) && (x.refuse === true || live(x))), p) : null;\n const pastBounds = atHome && options.floating ? targets.some((x) => x.bounds !== undefined && !within(x.bounds, p)) : false;\n const homeHolds = atHome && (!options.floating || (underHome?.refuse !== true && !(underHome === null && pastBounds)));\n // Over home no target is picked, except a spring-loaded one that is armed (its zone overlaps home): home gates\n // geometry, not an armed dwell.\n const pickable = (x: T): boolean => !homeHolds || (x.arm === \"dwell\" && x.id === armedId);\n // A refusal takes part in the pick (it needs no place), but it is never a target: never held, never shown.\n const raw = targetAt(targets.filter((x) => pickable(x) && inZone(x, p) && (x.refuse === true || live(x))), p);\n // A spring-loaded target that isn't armed (any more) is no target: neither held nor shown.\n const disarmed = (x: T | null): boolean => x?.arm === \"dwell\" && x.id !== armedId;\n cur = disarmed(cur) ? null : follow(cur, targets);\n shown = disarmed(shown) ? null : follow(shown, targets);\n if (!live(cur)) cur = null;\n // A target shown with its room open holds in the room it opened (`roomHit`): what lies there is drawn as the room,\n // so a refusal under it is no refusal here.\n const roomHeld = cur && cur.opensRoom === true && cur.roomHit && roomPlace !== null && same(cur, shown) && pickable(cur) && within(cur.bounds, p) && inRect(cur.roomHit, p) ? cur : null;\n const refusedRaw = raw?.refuse === true && !roomHeld ? raw : null;\n // The band about a held zone, and the breakthrough into a zone, scaled with the zones (see `bandShare`).\n const bandOf = (held: T): Margin => scaled(tuning.band, tuning.bandShare, [held, raw && !same(raw, held) ? raw : null]);\n const pastBreakthrough = (x: T): boolean => inZoneBy(x, p, negate(scaled(tuning.breakthrough, tuning.bandShare, [x])));\n // Over a refusal nothing is held: no band and no gap grace keep the current target there.\n let next = refusedRaw ? null : raw;\n if (!refusedRaw && cur && pickable(cur) && (roomHeld !== null || inZoneBy(cur, p, bandOf(cur)))) {\n // Over a `free` target (the float everywhere) there is no edge to hold against: a more precise target takes over\n // once the pointer is in it, so a zone that ends at the window's edge is reached at its very first px. A refusal\n // here lies under the open room: it never takes over.\n const breaks = raw !== null && raw.refuse !== true && !same(raw, cur) && raw.priority < cur.priority && (cur.free === true || pastBreakthrough(raw));\n next = breaks ? raw : cur;\n }\n // The gap grace, like the band, never reaches past a zone's bounds: the float gets no grace outside the window.\n if (!refusedRaw && !next && cur && pickable(cur) && within(cur.bounds, p) && t - lastInside < tuning.gapGrace) next = cur;\n if (next && (inZone(next, p) || same(next, roomHeld))) lastInside = t;\n if (!same(next, cur)) curSince = t;\n cur = next;\n const aiming = !restart && (speed < tuning.aimSpeed || t - stillSince >= tuning.dwell);\n restart = false;\n const show = (s: T | null): void => {\n if (!same(s, shown)) shownSince = t;\n shown = s;\n };\n // Under the pointer (within its band, or in the room it holds), not just kept by the gap grace.\n const under = !!cur && (same(cur, roomHeld) || inZoneBy(cur, p, bandOf(cur)));\n // A target that opens its room as it shows shows only once it has held (`roomHold`, else `roomAfter`): one decision\n // for both, so a sweep moves nothing and the indicator never lies over what the room will move. An armed one has\n // had its dwell.\n const ready = (x: T): boolean => x.opensRoom !== true || x.arm === \"dwell\" || t - curSince >= (x.roomHold ?? tuning.roomAfter);\n // A shown target with no place here is no drop: the indicator hides at once (the switch hold is for targets).\n if (shown && !live(shown)) show(null);\n if (!shown) {\n if (cur && under && leftHome && aiming && ready(cur)) show(cur);\n } else if (same(cur, shown)) {\n // It stays while its target holds; but a pointer flying out past the band hides it at once.\n if (!aiming && !under) show(null);\n else shown = cur;\n } else if (!cur || !aiming) {\n show(null);\n } else if ((cur.priority < shown.priority && (shown.free === true || pastBreakthrough(cur))) || (under && t - curSince >= tuning.switchHold)) {\n // Not ready yet: the old indicator goes, and a release lands on the target under the pointer.\n show(ready(cur) ? cur : null);\n }\n // An armed target shows at once: the dwell was the aim. A key held wins over all of it.\n if (armedNow && cur?.id === armedId && under) show(cur);\n // A key that picks nothing here (the float key over a refusal or outside the window) shows nothing.\n if (forced) {\n if (!same(forced.target, cur)) curSince = t;\n cur = forced.target;\n show(forced.target);\n }\n // The place within the shown target, and the room: after the target and the place have both held; with the target\n // itself where showing it was already that decision (`opensRoom`, an armed target's dwell).\n const at = shown ? placeAt(shown) : null;\n if (at !== place) {\n place = at;\n placeSince = t;\n }\n if (!shown || shown.free) roomPlace = null;\n else if (shown.opensRoom === true || shown.arm === \"dwell\") roomPlace = place;\n else if (t - shownSince >= tuning.roomAfter && t - placeSince >= tuning.roomAfter) roomPlace = place;\n else if (shownSince === t) roomPlace = null;\n lastPlaces = places;\n // A refusal crossed since a target last showed: a release beyond it lands on what is under the pointer, drawn or not.\n // With a key held, the refusal is the one the key's pick met (the float key over a refusal), else none.\n const refused = forced ? forced.refused : refusedRaw;\n if (shown) crossedRefusal = false;\n else if (refused) crossedRefusal = true;\n return { shown, room: roomPlace !== null, roomPlace, aiming, atHome: !forced && wentOut && homeHolds, arming, forced: forced?.kind ?? null, refused, refusedSinceShown: !shown && !refused && crossedRefusal, landing: landAt(p, given, keys) };\n },\n release(point, given, keys) {\n return landAt(point, given, keys);\n },\n hide(time) {\n shown = null;\n cur = null;\n armedId = null;\n armingId = null;\n shownSince = time;\n place = null;\n roomPlace = null;\n lastPlaces = new Map();\n samples = [];\n anchor = null;\n restart = true;\n crossedRefusal = false;\n },\n moveHome(dx, dy) {\n home = { ...home, x: home.x + dx, y: home.y + dy };\n },\n };\n}\n","import type { Point, Rect } from \"../shapes\";\nimport type { DragKeys } from \"./intent\";\nimport type { PlaceGuides } from \"./preview\";\n\n/**\n * The landing model: where a docking drag's item lands, as state rather than a per-frame guess. A host gives it the\n * drag's regions (from `@n-uf/placement/scene`'s `lanes()`: plain data, the shapes below) and each pointer sample; it\n * says the region the pointer is in, the lane and spot held, where the item lands, whether the room is open, and the\n * place guides. Every change comes from where the pointer is and how it moved (margins, a path length, a step size):\n * the model has no waits of its own.\n *\n * - **The stage's edge** is the easiest place to dock: a pointer past the stage by up to `edge` px counts as on its\n * edge, so it lies deep inside a lane drawn against that edge; beyond, it is nowhere.\n * - **A lane holds** while the pointer is inside its rect grown by `exit`, whatever lies under it. Inside, over a spot's\n * stretch it is at that spot; over a refused stretch of the lane, refused (\"Can't go here\"). (Placement's `lanes()`\n * joins a refused stretch shorter than the item to its spots.)\n * - **Entering a lane** needs one of two gates: `path` px of slow pointer path along it inside it (steps of at most\n * `step`), or a still step (at most `still`) once `depth` px inside, the depth counted only from the lane's sides that\n * face into the stage (on the edge it is deep). A fly-through of a thin bar or rail at any angle meets neither, so its\n * room never opens. Inside a lane that touches the held one, past the held lane's exit margin, the held lane holds\n * until that lane's gate passes or the pointer has slid `path` px along it at any speed (across it at most a third as\n * far): lane to lane never passes through the float, and never opens a crossed lane's room. Over a refused place (a\n * lane's band lying over a column that takes nothing: an empty side rail's) a lane is entered on the first slow step\n * there (not on the lift), as there is nothing else to mean there; a fly-through still opens no room. A lane that owns\n * its rect (`owns`: a rail drop strip at the window's side) takes the pointer inside it from any lane it overlaps, a\n * held one too, once its own gate passes and only once the pointer came into it from outside since the lift. Within\n * `margins.lift` of the lift point (`options.lift`, else the first point; fixed for the drag) an owning lane takes the\n * pointer by no gate, so a pointer brought back there is in the item's own lane, not the strip. Elsewhere in the strip\n * a slow slide along it can take the pointer before it is back at the lift point.\n * - **Along a lane** the spot changes once the pointer is `spot` px past the boundary; where the change moves another\n * item (the two spots' `others` keys differ), on a step of at most `step`, or once the held landing trails the\n * pointer by more than `trail`: the item chases only as far as it must. A change that moves only the held item\n * follows the hand at any speed. With `regionsFor`, a reflowing change is kept only if, in the new spot's own regions\n * (its room open), the pointer still lies in that spot's stretch: the room shifting the boundary never bounces it.\n * - **Outside every lane:** a refused place, refused; open space (`\"open\"`: the content less what blocks it, the page),\n * the float at its landing; outside the stage (past `edge`), nowhere; else (docked content that takes nothing and\n * refuses nothing) refused.\n * - **Shift** turns a lane or open space into open space (the float), and hides the guides.\n * - **Guides** are the lane's `marks` (lines between items, a box per free stretch, in the layout as drawn), else its\n * spots' landings: the held lane's; else the approached lane's (the nearest within `reach`); over a refused place the\n * nearest lane's at any distance, so the lane behind a refused column shows its guides.\n * - Steps are measured between points that differ, normalized to 125 Hz, so the gates read the same at any input rate.\n * A repeated point keeps the last step; it is still only once the pointer has stayed put for `rest` ms.\n *\n * **The host's part:** call `update` whenever you like: per pointer sample, per animation frame, or both. Call it at\n * least once more after the pointer stops (every frame does), so it can become still, and again with the same point\n * when a key changes. Give `setRegions` the `regionsFor` that answers for the new state.\n */\n\n/** A place a drop in a lane lands: its stretch of the lane and its landing rect. Ids are stable across solves. */\nexport interface LandingSpot {\n readonly id: string;\n readonly along: readonly [number, number];\n readonly landing: Rect;\n /**\n * Where its drop draws every other item, as a key: a change between two spots with the same key moves only the held\n * item. Absent: every change to or from it counts as moving others.\n */\n readonly others?: string;\n}\n/**\n * A place guide's mark, in the layout as drawn: a line between two items that touch, a box over free room the item\n * lands in, a hatch over the part of a neighbor that gives way where the room is shorter than the item.\n */\nexport interface LandingMark {\n /** Stable while its neighbors stay; absent, the guide is keyed by its lane and place in the list. */\n readonly id?: string;\n readonly kind: \"line\" | \"box\" | \"hatch\";\n readonly rect: Rect;\n}\nexport interface LandingLane {\n readonly id: string;\n readonly rect: Rect;\n readonly axis: \"x\" | \"y\";\n readonly spots: readonly LandingSpot[];\n readonly refused: readonly { readonly along: readonly [number, number] }[];\n /** Its guides' marks; absent, its spots' landings are the guides. */\n readonly marks?: readonly LandingMark[];\n /**\n * Its rect is its own (a rail drop strip at the window's side): inside it, once its gate passes, it takes the pointer\n * from any lane it overlaps, a held one too. Absent: where lanes overlap, the deeper one wins.\n */\n readonly owns?: boolean;\n}\n/** A drag's regions (`lanes()` gives them). */\nexport interface LandingRegions {\n readonly lanes: readonly LandingLane[];\n readonly refused: readonly Rect[];\n readonly content: Rect;\n readonly blocked: readonly Rect[];\n readonly stage: Rect;\n /** The held item's size. */\n readonly item: { readonly width: number; readonly height: number };\n}\n\nexport interface LandingMargins {\n /** Past a held lane's rect before it lets go, px. */\n readonly exit: number;\n /** Past a spot boundary before the spot changes, px. */\n readonly spot: number;\n /** Past the stage that still counts as on its edge, px; beyond, nowhere. */\n readonly edge: number;\n /**\n * Around the lift point, px (16, as the drag intent's `liftZone`): an owning lane never takes the pointer there, so\n * away and back to where the item was lifted is home.\n */\n readonly lift?: number;\n}\nexport interface LandingGates {\n /** Pointer path inside a lane that enters it, px. */\n readonly path: number;\n /** Depth inside a lane where a still step enters it, px. */\n readonly depth: number;\n /** A still step, px per 8 ms. */\n readonly still: number;\n /**\n * The largest step that changes the spot along a lane where the change reflows the window, px per 8 ms; it also\n * bounds the steps the path gate counts (a fast crossing never enters).\n */\n readonly step: number;\n /** How far the held landing may trail the pointer before a fast reflowing change is taken anyway, px. */\n readonly trail: number;\n /**\n * The time a pointer has to stay put before it counts as still, ms, where its last step was already slow (at most\n * `step`) or it is on the stage's edge (a fling there is taken at once); repeated points before it aren't still.\n */\n readonly rest: number;\n /** The time a pointer that last moved fast has to stay put before it counts as still, ms: longer than sample gaps. */\n readonly pause: number;\n}\n/** The approach for near guides: the nearest lane within `reach`, kept until another is `nearer` closer or past `keep`. */\nexport interface LandingApproach {\n readonly reach: number;\n readonly keep: number;\n readonly nearer: number;\n}\n\nexport const LANDING_MARGINS: LandingMargins = { exit: 12, spot: 6, edge: 48, lift: 16 };\n/** A touch: wider margins, the finger's jitter. */\nexport const LANDING_TOUCH_MARGINS: LandingMargins = { exit: 16, spot: 8, edge: 48, lift: 16 };\nexport const LANDING_GATES: LandingGates = { path: 40, depth: 8, still: 1.5, step: 3, trail: 40, rest: 22, pause: 60 };\nexport const LANDING_APPROACH: LandingApproach = { reach: 80, keep: 96, nearer: 16 };\n\nexport interface LandingOptions {\n readonly regions: LandingRegions;\n /** The regions with `spot` held (its room open): the fixed-point check and the stretches while held. Cached per id. */\n readonly regionsFor?: (spot: string) => LandingRegions | null;\n /** The float's landing for a pointer over the document, or null where the item doesn't float. */\n readonly floatLanding?: (point: Point) => Rect | null;\n /** The item's own place at the lift: its lane and spot (the drag starts there, the room open). */\n readonly home?: { readonly lane: string; readonly spot: string };\n /** Where the item was lifted (the press), in the regions' space; default the first point `update` gets. */\n readonly lift?: Point;\n readonly margins?: Partial<LandingMargins>;\n readonly gates?: Partial<LandingGates>;\n readonly approach?: Partial<LandingApproach>;\n readonly placeGuides?: PlaceGuides;\n}\n\nexport type LandingRegion = \"lane\" | \"open\" | \"refused\" | \"nowhere\";\n\n/** A guide: a mark of a lane, where to draw it now (a spot's landing is a box). */\nexport interface LandingGuide {\n /** Stable while its neighbors stay: the mark's id, else `<lane>/<spot id>` for a spot's landing. Key a drawing by it. */\n readonly id: string;\n readonly lane: string;\n /** A line, a box, or a hatch over a neighbor that gives way (draw it over that item, in the guides' color). */\n readonly kind: \"line\" | \"box\" | \"hatch\";\n readonly rect: Rect;\n}\n\nexport interface LandingFrame {\n readonly region: LandingRegion;\n /** The lane held (also over its refused stretch), or null. */\n readonly lane: string | null;\n /** The spot held, or null. */\n readonly spot: string | null;\n /** Where a release now lands: the spot's landing, or the float's; null where it lands nowhere (the item goes home). */\n readonly landing: Rect | null;\n /** The room is open: a spot is held in a lane, no Shift. */\n readonly room: boolean;\n readonly guides: readonly LandingGuide[];\n /** Shift held: the region is open space wherever it was a lane or open space. */\n readonly shift: boolean;\n /**\n * The lane the pointer is inside but hasn't entered (its gate not passed yet: a fast pass, or the moment before a slow\n * step), else absent. A host shows no \"Can't go here\" while it is set, though a release now lands nowhere: the place\n * under the pointer is a lane's, not a refused one.\n */\n readonly pending?: string;\n}\n\n/** What a release lands: a spot (`home` when it is the item's own place), the float at `rect`, or nothing. */\nexport type LandingRelease = { readonly kind: \"spot\"; readonly lane: string; readonly spot: string; readonly home: boolean } | { readonly kind: \"float\"; readonly rect: Rect } | null;\n\nexport interface LandingModel {\n update(point: Point, time: number, keys?: DragKeys): LandingFrame;\n /** What a release lands, by the last frame: the same answer as its `landing`. */\n release(): LandingRelease;\n /**\n * The regions changed (a resize, a store change, a scroll): spots map by id; a lost one goes to its lane's nearest.\n * Pass the `regionsFor` that answers for the new state; without one, the old one stays (it must then read live state).\n */\n setRegions(regions: LandingRegions, regionsFor?: (spot: string) => LandingRegions | null): void;\n /** The view moved under the pointer: the gates start again, the lane is let go. */\n hide(): void;\n readonly frame: LandingFrame;\n}\n\nconst inside = (r: Rect, p: Point, grow = 0): boolean => p.x >= r.x - grow && p.x <= r.x + r.width + grow && p.y >= r.y - grow && p.y <= r.y + r.height + grow;\nconst strictlyIn = (r: Rect, p: Point): boolean => p.x >= r.x && p.x <= r.x + r.width && p.y >= r.y && p.y <= r.y + r.height;\n/**\n * How deep `p` lies inside `r` (0 on its edge or outside), counted only from the sides of `r` that face into `stage`: a\n * side on the stage's edge is open, as deep as the pointer can go.\n */\nfunction depthIn(r: Rect, p: Point, stage: Rect): number {\n if (!strictlyIn(r, p)) return 0;\n const on = (a: number, b: number): boolean => Math.abs(a - b) < 1;\n const sides = [\n on(r.x, stage.x) ? Infinity : p.x - r.x,\n on(r.x + r.width, stage.x + stage.width) ? Infinity : r.x + r.width - p.x,\n on(r.y, stage.y) ? Infinity : p.y - r.y,\n on(r.y + r.height, stage.y + stage.height) ? Infinity : r.y + r.height - p.y,\n ];\n return Math.max(0, Math.min(...sides));\n}\nconst distanceTo = (r: Rect, p: Point): number => Math.hypot(Math.max(r.x - p.x, 0, p.x - (r.x + r.width)), Math.max(r.y - p.y, 0, p.y - (r.y + r.height)));\nconst alongOf = (lane: LandingLane, p: Point): number => (lane.axis === \"x\" ? p.x : p.y);\nconst acrossOf = (lane: LandingLane, p: Point): number => (lane.axis === \"x\" ? p.y : p.x);\n/** Two rects meet: they overlap or touch (within 1 px), corners included. */\nconst touches = (a: Rect, b: Rect): boolean => a.x <= b.x + b.width + 1 && b.x <= a.x + a.width + 1 && a.y <= b.y + b.height + 1 && b.y <= a.y + a.height + 1;\n/** `p` onto `stage` when it lies past it by at most `reach`; else null (nowhere). */\nfunction ontoStage(stage: Rect, p: Point, reach: number): Point | null {\n if (!inside(stage, p, reach)) return null;\n return { x: Math.min(Math.max(p.x, stage.x), stage.x + stage.width), y: Math.min(Math.max(p.y, stage.y), stage.y + stage.height) };\n}\n\nexport function createLandingModel(options: LandingOptions): LandingModel {\n const margins = { ...LANDING_MARGINS, ...options.margins };\n const gates = { ...LANDING_GATES, ...options.gates };\n const approach = { ...LANDING_APPROACH, ...options.approach };\n const guidesLevel: PlaceGuides = options.placeGuides ?? \"off\";\n let base = options.regions;\n let regionsFor = options.regionsFor;\n const cache = new Map<string, LandingRegions | null>();\n /** The regions with `spot` held: the host's, cached for this lift until `setRegions`. */\n const heldRegions = (spot: string | null): LandingRegions => {\n if (!spot || !regionsFor) return base;\n if (!cache.has(spot)) cache.set(spot, regionsFor(spot));\n return cache.get(spot) ?? base;\n };\n\n let laneId: string | null = options.home?.lane ?? null;\n let spotId: string | null = options.home?.spot ?? null;\n let last: { p: Point; raw: Point; t: number } | null = null;\n /** The last point that differed from the one before, and the step then. */\n let moved: { raw: Point; t: number } | null = null;\n /** Where the item was lifted (`lift`, else the first point), fixed for the drag: back there, no owning lane takes it. */\n let liftAt: Point | null = options.lift ?? null;\n let lastStep = 0;\n /** Path inside each lane since the pointer last entered its rect. */\n const pathIn = new Map<string, number>();\n /** The path along and across each lane at any speed since the pointer entered it (a touching lane's takeover). */\n const slide = new Map<string, { along: number; across: number }>();\n /** The owning lanes the pointer has been outside since the lift: only those may take it (it came into them). */\n const cameIn = new Set<string>();\n let approached: string | null = null;\n let previous: LandingRegion = laneId ? \"lane\" : \"open\";\n let frame: LandingFrame = { region: previous, lane: laneId, spot: spotId, landing: null, room: !!spotId, guides: [], shift: false };\n\n const laneIn = (regions: LandingRegions, id: string | null): LandingLane | undefined => (id ? regions.lanes.find((l) => l.id === id) : undefined);\n const spotIn = (lane: LandingLane | undefined, id: string | null): LandingSpot | undefined => (lane && id ? lane.spots.find((s) => s.id === id) : undefined);\n\n /** The spot a point along `lane` picks: the spot whose stretch holds it, null over a refused stretch, else the nearest. */\n function pick(lane: LandingLane, a: number): LandingSpot | null {\n if (lane.refused.some((r) => a >= r.along[0] && a <= r.along[1])) return null;\n const hit = lane.spots.find((s) => a >= s.along[0] && a <= s.along[1]);\n if (hit) return hit;\n let best: LandingSpot | null = null;\n let dist = Infinity;\n for (const s of lane.spots) {\n const d = a < s.along[0] ? s.along[0] - a : a - s.along[1];\n if (d < dist) {\n best = s;\n dist = d;\n }\n }\n return best;\n }\n\n /** Along a held lane: the spot after hysteresis, the step gate and the fixed-point check. */\n function along(lane: LandingLane, p: Point, step: number): LandingSpot | null {\n const regions = heldRegions(spotId);\n const held = laneIn(regions, lane.id) ?? lane;\n const a = alongOf(held, p);\n const now = spotIn(held, spotId);\n const cand = pick(held, a);\n if (!cand) return null;\n if (!now || cand.id === now.id) return cand;\n // Past the boundary by the margin, the same everywhere (a wobble within it never flips the spot); where the change\n // moves another item, on a slow enough step. Else the last spot holds.\n const past = a < now.along[0] - margins.spot || a > now.along[1] + margins.spot;\n const reflows = now.others === undefined || now.others !== cand.others;\n if (!past) return now;\n // A fast reflowing change waits for a slow step, unless the held landing already trails the pointer by `trail`: the\n // item chases only as far as it must, so a fast hand across docked items never leaves it far behind.\n if (reflows && step > gates.step && distanceTo(now.landing, p) <= gates.trail) return now;\n // The fixed point: in the candidate's own regions (its room open), the pointer still picks it.\n if (regionsFor && reflows) {\n const theirs = heldRegions(cand.id);\n const lane2 = laneIn(theirs, lane.id);\n if (lane2 && pick(lane2, alongOf(lane2, p))?.id !== cand.id) return now;\n }\n return cand;\n }\n\n function guidesFor(p: Point, region: LandingRegion, shift: boolean): LandingGuide[] {\n if (guidesLevel === \"off\" || shift) return [];\n const regions = heldRegions(spotId);\n const all = (l: LandingLane): LandingGuide[] =>\n l.marks\n ? l.marks.map((m, i) => ({ id: m.id ?? `${l.id}#${i}`, lane: l.id, kind: m.kind, rect: m.rect }))\n : l.spots.map((s) => ({ id: `${l.id}/${s.id}`, lane: l.id, kind: \"box\" as const, rect: s.landing }));\n if (guidesLevel === \"all\") return regions.lanes.flatMap(all);\n if ((region === \"lane\" || region === \"refused\") && laneId) {\n approached = laneId;\n const l = laneIn(regions, laneId);\n return l ? all(l) : [];\n }\n let best: LandingLane | null = null;\n let bestD = Infinity;\n for (const l of regions.lanes) {\n const d = distanceTo(l.rect, p);\n if (d < bestD) {\n best = l;\n bestD = d;\n }\n }\n // Over a refused place: the nearest lane at any distance (the lane behind a refused column).\n if (region === \"refused\") {\n approached = best?.id ?? null;\n return best ? all(best) : [];\n }\n // The approached lane: the nearest within reach, kept until another is clearly nearer or it is past `keep`.\n const kept = laneIn(regions, approached);\n if (kept) {\n const d = distanceTo(kept.rect, p);\n if (d > approach.keep) approached = null;\n else if (best && best.id !== kept.id && bestD + approach.nearer < d) approached = bestD <= approach.reach ? best.id : null;\n } else approached = best && bestD <= approach.reach ? best.id : null;\n const l = laneIn(regions, approached);\n return l ? all(l) : [];\n }\n\n function update(raw: Point, t: number, keys?: DragKeys): LandingFrame {\n // Past the stage by up to `edge`: on its edge. Beyond: nowhere (kept as is).\n const p = ontoStage(heldRegions(spotId).stage, raw, margins.edge) ?? raw;\n // The step: the pointer as it moved (a fling past the edge isn't still) since the last point that differed,\n // normalized to 125 Hz (8 ms). A repeated point (a host updating per frame, or a gap between sparse samples) keeps\n // the last step until the pointer has stayed put for `rest` ms after a slow step or on the stage's edge, else for\n // `pause` ms; only then is it still. A hand moving fast with samples far apart is never still between them.\n let step = 0;\n if (moved && (raw.x !== moved.raw.x || raw.y !== moved.raw.y)) {\n step = (Math.hypot(raw.x - moved.raw.x, raw.y - moved.raw.y) * 8) / Math.max(1, t - moved.t);\n moved = { raw, t };\n lastStep = step;\n } else if (moved) {\n const stage = heldRegions(spotId).stage;\n const onEdge = p.x <= stage.x || p.y <= stage.y || p.x >= stage.x + stage.width || p.y >= stage.y + stage.height;\n const since = t - moved.t;\n step = since >= gates.pause || (since >= gates.rest && (lastStep <= gates.step || onEdge)) ? 0 : lastStep;\n } else {\n // The first point: how the pointer moves is unknown, never still (a lift over a lane's band doesn't enter it).\n moved = { raw, t };\n // (After `hide()` too, the lift point stays where the drag began.)\n liftAt ??= p;\n step = lastStep = Infinity;\n }\n const from = last?.p ?? null;\n // The pointer as it moved: a fling off the stage's edge moves across a lane there though its clamped point doesn't.\n const fromRaw = last?.raw ?? null;\n last = { p, raw, t };\n const shift = !!keys?.shift;\n const regions = heldRegions(spotId);\n // The path inside each lane: the part along the lane of slow steps from a point inside it to another (the step that\n // enters doesn't count, nor a fast one), so a crossing at `step` speed or faster never enters by path at any angle.\n // From a held lane, a touching lane counts the path along it and across it at any speed: a fast slide along it\n // (across it at most a third as far as along) is no crossing.\n const slow = step <= gates.step;\n for (const l of regions.lanes) {\n const was = from && strictlyIn(l.rect, from);\n const go = was ? Math.abs(alongOf(l, p) - alongOf(l, from)) : 0;\n const over = was && fromRaw ? Math.abs(acrossOf(l, raw) - acrossOf(l, fromRaw)) : 0;\n const inL = strictlyIn(l.rect, p);\n pathIn.set(l.id, inL ? (pathIn.get(l.id) ?? 0) + (slow ? go : 0) : 0);\n const s = slide.get(l.id);\n slide.set(l.id, inL ? { along: (s?.along ?? 0) + go, across: (s?.across ?? 0) + over } : { along: 0, across: 0 });\n if (l.owns && !inL) cameIn.add(l.id);\n }\n\n let region: LandingRegion;\n let pending: string | null = null;\n if (!inside(regions.stage, p)) {\n // Outside the stage: nowhere, and the lane is let go.\n region = \"nowhere\";\n laneId = spotId = null;\n } else {\n const held = laneIn(regions, laneId);\n const gate = (l: LandingLane): boolean => (pathIn.get(l.id) ?? 0) >= gates.path || (depthIn(l.rect, p, regions.stage) >= gates.depth && step <= gates.still);\n // Lane to lane: inside a lane touching the held one, past the held lane's exit margin (inside it the held lane holds,\n // P1), the held lane still holds until that lane's gate passes, then that lane takes it. Never the float between\n // them, never a fly-through's room.\n const touching = held ? regions.lanes.find((l) => l.id !== held.id && strictlyIn(l.rect, p) && touches(l.rect, held.rect) && !inside(held.rect, p, margins.exit)) : undefined;\n const sl = touching ? slide.get(touching.id) : undefined;\n const slid = !!sl && sl.along >= gates.path && sl.across * 3 <= sl.along;\n // A lane that owns its rect (a rail drop strip) takes the pointer inside it from any lane it overlaps, a held one\n // too, once its own gate passes (so a pass across it opens nothing), and only once the pointer came into it (it has\n // been outside it since the lift): a press in a column's outer edge, or a slow reorder along it, stays in the column.\n // Never within `lift` of where the item was lifted: away and back there is home, wherever a strip lies, while the\n // rest of the strip (all of it over a lone panel's own place) still takes it.\n const nearLift = !!liftAt && Math.hypot(p.x - liftAt.x, p.y - liftAt.y) <= (margins.lift ?? 16);\n const owner = nearLift ? undefined : regions.lanes.find((l) => l.owns && l.id !== held?.id && cameIn.has(l.id) && strictlyIn(l.rect, p) && gate(l));\n const next = owner ?? (touching && (gate(touching) || slid) ? touching : undefined);\n if (held && !next && (touching || inside(held.rect, p, margins.exit))) {\n const s = along(held, p, step);\n spotId = s?.id ?? spotId;\n region = s ? \"lane\" : \"refused\";\n if (!s) spotId = null;\n // Past its own rect, a held lane that refuses still holds (lane to lane never passes through the float), but\n // the pointer is in another lane it hasn't entered yet: that lane is pending, so a host shows no \"Can't go here\"\n // in a lane's first pixels when the pointer comes in over a refused stretch next to it.\n if (!s && !strictlyIn(held.rect, p)) {\n const others = regions.lanes.filter((l) => l.id !== held.id && strictlyIn(l.rect, p));\n if (others.length > 0) pending = others.reduce((a, b) => (depthIn(b.rect, p, regions.stage) > depthIn(a.rect, p, regions.stage) ? b : a)).id;\n }\n } else {\n laneId = spotId = null;\n // Entering: a touching lane at once, else the path gate or the still gate; at a tie, the lane the pointer is\n // deeper in. Over a refused place (a lane's band over a column that takes nothing, an empty side rail's) a lane is\n // entered at once, never on the lift: there is nothing else the pointer can mean there, and nothing to fly\n // through to.\n // (Over something that takes nothing reaching past the lane, a column's panel under an empty rail's band, and in\n // no other lane; a drawn bar's own rect and its items lie within it, so its gate holds.)\n // Within the lift zone an owning lane is no lane at all: by no gate does it take the pointer there.\n const lanesHere = regions.lanes.filter((l) => strictlyIn(l.rect, p) && !(l.owns && nearLift));\n const within = (b: Rect, l: LandingLane): boolean => b.x >= l.rect.x - 1 && b.y >= l.rect.y - 1 && b.x + b.width <= l.rect.x + l.rect.width + 1 && b.y + b.height <= l.rect.y + l.rect.height + 1;\n // On a slow step only (as a slow hand inside a bar enters it): a fly-through across such a place opens no room.\n const overRefused = (l: LandingLane): boolean =>\n Number.isFinite(step) && step <= gates.step && lanesHere.length === 1 && [...regions.blocked, ...regions.refused].some((b) => strictlyIn(b, p) && !within(b, l));\n let entered: LandingLane | null = next ?? null;\n if (!entered)\n for (const l of lanesHere) {\n const deep = depthIn(l.rect, p, regions.stage);\n if ((gate(l) || overRefused(l)) && (!entered || deep > depthIn(entered.rect, p, regions.stage))) entered = l;\n }\n // Inside a lane not entered yet: no refused place to say so of, whatever lies under it.\n if (!entered && lanesHere.length > 0) pending = lanesHere.reduce((a, b) => (depthIn(b.rect, p, regions.stage) > depthIn(a.rect, p, regions.stage) ? b : a)).id;\n if (entered) {\n laneId = entered.id;\n const s = pick(entered, alongOf(entered, p));\n spotId = s?.id ?? null;\n region = s ? \"lane\" : \"refused\";\n } else if (regions.refused.some((r) => inside(r, p))) region = \"refused\";\n else if (inside(regions.content, p) && !regions.blocked.some((b) => strictlyIn(b, p))) region = \"open\";\n // Inside a lane not yet entered: what it was (on the way in, the document's float).\n else if (regions.lanes.some((l) => strictlyIn(l.rect, p))) region = previous === \"lane\" ? \"open\" : previous;\n else region = \"refused\";\n }\n }\n previous = region;\n const shown: LandingRegion = shift && (region === \"lane\" || region === \"open\") ? \"open\" : region;\n const r2 = heldRegions(spotId);\n const spot = spotIn(laneIn(r2, laneId), spotId);\n const landing = shown === \"lane\" ? (spot?.landing ?? null) : shown === \"open\" ? (options.floatLanding?.(p) ?? null) : null;\n frame = {\n region: shown,\n lane: laneId,\n spot: shown === \"lane\" ? spotId : null,\n landing,\n room: shown === \"lane\" && !!spot,\n guides: guidesFor(p, shown, shift),\n shift,\n ...(pending && shown !== \"lane\" ? { pending } : {}),\n };\n return frame;\n }\n\n return {\n update,\n release(): LandingRelease {\n if (frame.region === \"lane\" && frame.lane && frame.spot) return { kind: \"spot\", lane: frame.lane, spot: frame.spot, home: !!options.home && options.home.spot === frame.spot && options.home.lane === frame.lane };\n if (frame.region === \"open\" && frame.landing) return { kind: \"float\", rect: frame.landing };\n return null;\n },\n setRegions(regions: LandingRegions, nextRegionsFor?: (spot: string) => LandingRegions | null): void {\n base = regions;\n if (nextRegionsFor) regionsFor = nextRegionsFor;\n cache.clear();\n const l = laneIn(base, laneId);\n if (laneId && !l) laneId = spotId = null;\n else if (l && spotId && !spotIn(l, spotId) && last) spotId = pick(l, alongOf(l, last.p))?.id ?? null;\n },\n hide(): void {\n laneId = spotId = null;\n approached = null;\n pathIn.clear();\n slide.clear();\n cameIn.clear();\n last = moved = null;\n lastStep = 0;\n },\n get frame(): LandingFrame {\n return frame;\n },\n };\n}\n","import type { DragFrame, DragTarget } from \"./intent\";\n\n/**\n * How a drag previews its drop, from least to most motion while dragging:\n *\n * - `\"indicator\"`: nothing moves; only the indicator (an outline or an\n * insertion marker) shows the target.\n * - `\"gap\"`: once the room is made, the others move aside and open the slot;\n * the item stays under the pointer.\n * - `\"snap\"`: the gap opens and the item itself glides into it (for a target\n * with a slot; one without keeps the indicator).\n * - `\"item\"`: the dragged item is the only preview: no indicator for any\n * target. It sits in a slotted target once the room is open and otherwise\n * stays on the pointer. Pair it with the intent's `earlyRelease: \"float\"`, so\n * a release lands what shows.\n *\n * Every mode follows the same intent: what shows, when, and what a release\n * lands on are the drag intent's, so a drop always lands where the preview\n * showed it.\n */\nexport type DragPreview = \"indicator\" | \"gap\" | \"snap\" | \"item\";\n\n/** The preview a drag uses unless the host picks another. */\nexport const DRAG_PREVIEW_DEFAULT: DragPreview = \"snap\";\n\n/**\n * Place guides: faint marks on the free places that take the held item, shown only while no landing shows. `\"off\"`:\n * none; `\"near\"`: the places of the edge the pointer approaches; `\"all\"`: every place, from the lift.\n */\nexport type PlaceGuides = \"off\" | \"near\" | \"all\";\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 (the page, a column); `\"edge\"`, a thin striped strip on the lane's window\n * side. The landing is the same either way. Placement's `lanes()` takes it as `emptyLanes`.\n */\nexport type EmptyLanes = \"real\" | \"edge\";\n\n/**\n * A drop preview as a mode and its place guides, beside the string forms: `\"outline\"` is `\"indicator\"`'s plan,\n * `\"placeholder\"` is `\"gap\"`'s, and `\"snap\"` is `\"item\"`'s (the item the only preview). `placeGuides` defaults per mode\n * ({@link PLACE_GUIDES_DEFAULT}); `emptyLanes` (how its guides draw an empty lane) defaults to `\"real\"`.\n */\nexport type DropPreviewMode =\n | { readonly mode: \"outline\"; readonly placeGuides?: PlaceGuides; readonly emptyLanes?: EmptyLanes }\n | { readonly mode: \"placeholder\"; readonly placeGuides?: PlaceGuides; readonly emptyLanes?: EmptyLanes }\n | { readonly mode: \"snap\"; readonly placeGuides?: PlaceGuides; readonly emptyLanes?: EmptyLanes };\n\n/** Each mode's place guides when it names none: Snap and Placeholder near, Outline none. */\nexport const PLACE_GUIDES_DEFAULT: Readonly<Record<DropPreviewMode[\"mode\"], PlaceGuides>> = { outline: \"off\", placeholder: \"near\", snap: \"near\" };\n\n/** The string plan each mode draws with. */\nconst PLAN_OF: Readonly<Record<DropPreviewMode[\"mode\"], DragPreview>> = { outline: \"indicator\", placeholder: \"gap\", snap: \"item\" };\n\n/** What to draw for one frame of a drag. */\nexport interface PreviewPlan {\n /** Draw the indicator on the shown target. */\n readonly showIndicator: boolean;\n /** Lay the others out around the room (the gap is open). */\n readonly makeRoom: boolean;\n /** Draw the item in its slot instead of under the pointer. */\n readonly snapItem: boolean;\n /**\n * The place guides to draw this frame: the mode's `placeGuides` while no landing shows (no indicator, no room, no item\n * in its slot), `\"off\"` whenever one does, so the screen shows where the item can go or where it will land, never\n * both. Always `\"off\"` for the string forms. Optional, so a plan a host builds itself is still one: absent means\n * `\"off\"`.\n */\n readonly guides?: PlaceGuides;\n /** How the guides draw an empty lane (the object form's `emptyLanes`, `\"real\"` when it names none); absent for the string forms. */\n readonly emptyLanes?: EmptyLanes;\n}\n\n/**\n * The plan for a frame of the drag intent under `preview`. `slotted` says\n * whether the shown target's drop has a slot the item can sit in (default: a\n * target that isn't `free`); only such a target snaps, and in `\"snap\"` it\n * previews with the item rather than the indicator.\n *\n * - `\"indicator\"`: the indicator, never room, never a snap.\n * - `\"gap\"`: the indicator, and room when the intent makes it.\n * - `\"snap\"`: room when the intent makes it, the item snapped into a slotted\n * target's room; the indicator only for a target without a slot.\n * - `\"item\"`: as `\"snap\"`, with no indicator at all.\n *\n * The object form ({@link DropPreviewMode}) draws with its mode's string plan and adds its place guides (`guides`).\n */\nexport function previewPlan<T extends DragTarget>(\n frame: Pick<DragFrame<T>, \"shown\" | \"room\">,\n preview: DragPreview | DropPreviewMode,\n slotted: boolean = !!frame.shown && !frame.shown.free,\n): PreviewPlan {\n if (typeof preview === \"object\") {\n const plan = stringPlan(frame, PLAN_OF[preview.mode], slotted);\n const asked = preview.placeGuides ?? PLACE_GUIDES_DEFAULT[preview.mode];\n const landing = plan.showIndicator || plan.makeRoom || plan.snapItem;\n return { ...plan, guides: landing ? \"off\" : asked, emptyLanes: preview.emptyLanes ?? \"real\" };\n }\n return stringPlan(frame, preview, slotted);\n}\n\nfunction stringPlan<T extends DragTarget>(frame: Pick<DragFrame<T>, \"shown\" | \"room\">, preview: DragPreview, slotted: boolean): PreviewPlan {\n const shown = !!frame.shown;\n if (preview === \"indicator\") return { showIndicator: shown, makeRoom: false, snapItem: false, guides: \"off\" };\n if (preview === \"gap\") return { showIndicator: shown, makeRoom: frame.room, snapItem: false, guides: \"off\" };\n if (preview === \"item\") return { showIndicator: false, makeRoom: frame.room, snapItem: frame.room && shown && slotted, guides: \"off\" };\n // By design a slotted target draws nothing until the room opens (`roomAfter`); a release then still lands on it.\n return { showIndicator: shown && !slotted, makeRoom: frame.room, snapItem: frame.room && shown && slotted, guides: \"off\" };\n}\n","import { DOUBLE_CLICK, type DoubleClick } from \"../double-click\";\nimport type { Point } from \"../shapes\";\nimport { liftDecision, type DragTuning, type LiftDecision } from \"./intent\";\n\n/** How a press on a grip ended: a click, the second click of a double (`doubleActivate`, not a click), or a drag (`null`). */\nexport type GripRelease = \"click\" | \"doubleActivate\" | null;\n\n/** A press on a grip, start to end: whether it lifts, and what its release is. Pure: positions and times are the host's. */\nexport interface GripPress {\n /**\n * A press at `point`, `time` ms. `touch` for a finger (the touch lift rule). `clicks`, when the host has the\n * platform's count for this press (a `mousedown`'s `detail`, 1 or more), decides the double instead of the interval.\n */\n down(point: Point, time: number, options?: { readonly touch?: boolean; readonly clicks?: number }): void;\n /** The pointer moved: `liftDecision` for this press. Once `\"lift\"` it stays a drag; once `\"refuse\"` it never is. */\n move(point: Point, time: number): LiftDecision;\n /**\n * The press ended. `\"click\"`, or `\"doubleActivate\"` when it is the second click of a double (it is not a click\n * then); null when it lifted or was refused. A press that never moved past the lift distance never lifts, so an\n * unmoved double never starts a drag (a second press that moves past it is a drag like any other). A third click\n * after a double starts a new pair.\n */\n up(point: Point, time: number): GripRelease;\n /** Forget the press and the click before it (a cancelled press, a scroll). */\n cancel(): void;\n}\n\n/**\n * A grip's press, double-click included: a press that moves past the lift distance is a drag; one that doesn't is a\n * click, and a second such press within the double interval and distance is a double-activate (the host folds or\n * unfolds, say), never a second click and never a lift: an unmoved double never starts a drag.\n *\n * The first click of a double is delivered as `\"click\"` before the double is known (nothing waits for a second press),\n * so a host keeps a grip's click harmless (a use, a focus): the double-activate that follows must not have to undo it.\n */\nexport function createGripPress(options: { readonly tuning?: Partial<DragTuning>; readonly double?: Partial<DoubleClick> } = {}): GripPress {\n const tuning = options.tuning ?? {};\n // The package's one double click (`DOUBLE_CLICK`), unless the host tunes it.\n const dbl: DoubleClick = { ...DOUBLE_CLICK, ...options.double };\n let press: { at: Point; time: number; touch: boolean; double: boolean; state: LiftDecision } | null = null;\n // The last click (a press that ended as one): where and when it was pressed.\n let last: { at: Point; time: number } | null = null;\n return {\n down(point, time, o = {}) {\n const near = !!last && time - last.time <= dbl.ms && Math.hypot(point.x - last.at.x, point.y - last.at.y) <= dbl.px;\n const double = o.clicks !== undefined && o.clicks > 0 ? o.clicks === 2 : near;\n press = { at: { x: point.x, y: point.y }, time, touch: !!o.touch, double, state: \"wait\" };\n },\n move(point, time) {\n if (!press) return \"wait\";\n if (press.state !== \"wait\") return press.state;\n press.state = liftDecision({ touch: press.touch, distance: Math.hypot(point.x - press.at.x, point.y - press.at.y), elapsed: time - press.time }, tuning);\n return press.state;\n },\n up() {\n const p = press;\n press = null;\n if (!p || p.state !== \"wait\") {\n last = null;\n return null;\n }\n if (p.double) {\n last = null;\n return \"doubleActivate\";\n }\n last = { at: p.at, time: p.time };\n return \"click\";\n },\n cancel() {\n press = null;\n last = null;\n },\n };\n}\n","import type { Rect } from \"../shapes\";\n\n/** A guide to place: any record with a `kind` and a `rect` (a landing model's `LandingGuide`, a lane's marks). */\nexport interface PlacedGuide {\n readonly kind: \"line\" | \"box\" | \"hatch\";\n readonly rect: Rect;\n}\n\nexport interface GuideRectsOptions {\n /** The area guides are drawn in: the window's inside (inside its border), px. */\n readonly inside: Rect;\n /** How far inside `inside` every guide stays, px (default 2). */\n readonly inset?: number;\n /** Rects a thin guide stays clear of (the content: a column's panels under an empty lane's thin edge). */\n readonly clear?: readonly Rect[];\n /** The least thickness a thin guide keeps, px (default 2); thinner, it is not drawn. */\n readonly minThickness?: number;\n}\n\nconst EPS = 1e-6;\n\n/**\n * Where to draw guides: every guide inside `inside` by `inset`. A box is clipped. A thin guide (a line, a striped\n * strip or end: its shorter side is its thickness) keeps its thickness and moves inside rather than being clipped, so\n * a line at a lane's far end is as thick as at its head. Then it is thinned, from the content side, to stay clear of\n * `clear`, so a thin strip at the window's side lies between the inset and the content, the same on both sides. A\n * guide with nothing left (or a thin one under `minThickness`) is left out. Pure; the guides come back as given with\n * their placed `rect`.\n */\nexport function guideRects<G extends PlacedGuide>(guides: readonly G[], options: GuideRectsOptions): G[] {\n const inset = Number.isFinite(options.inset) ? Math.max(0, options.inset!) : 2;\n const min = Number.isFinite(options.minThickness) ? Math.max(0, options.minThickness!) : 2;\n // A guide placed where it already was comes back as given (the same rect object), so a host can key on it.\n const same = (a: Rect, b: Rect): boolean => Math.abs(a.x - b.x) < EPS && Math.abs(a.y - b.y) < EPS && Math.abs(a.width - b.width) < EPS && Math.abs(a.height - b.height) < EPS;\n const place = (g: G, rect: Rect): G => (same(g.rect, rect) ? g : { ...g, rect });\n const x0 = options.inside.x + inset;\n const y0 = options.inside.y + inset;\n const x1 = options.inside.x + options.inside.width - inset;\n const y1 = options.inside.y + options.inside.height - inset;\n const clear = options.clear ?? [];\n const out: G[] = [];\n for (const g of guides) {\n const r = g.rect;\n if (g.kind === \"box\") {\n const a = Math.max(r.x, x0);\n const b = Math.max(r.y, y0);\n const c = Math.min(r.x + r.width, x1);\n const d = Math.min(r.y + r.height, y1);\n if (c - a > EPS && d - b > EPS) out.push(place(g, { x: a, y: b, width: c - a, height: d - b }));\n continue;\n }\n // A thin guide: thick along one axis (its shorter side), long along the other.\n const thinX = r.width <= r.height;\n // Along its thickness: moved inside whole; along its length: clipped.\n const t = thinX ? r.width : r.height;\n let lo = thinX ? r.x : r.y;\n const lim0 = thinX ? x0 : y0;\n const lim1 = thinX ? x1 : y1;\n if (lo + t > lim1) lo = lim1 - t;\n if (lo < lim0) lo = lim0;\n let hi = Math.min(lo + t, lim1);\n const s0 = Math.max(thinX ? r.y : r.x, thinX ? y0 : x0);\n const s1 = Math.min(thinX ? r.y + r.height : r.x + r.width, thinX ? y1 : x1);\n if (s1 - s0 <= EPS) continue;\n // Clear of what it must not cover: cut from the side the clear rect lies on.\n for (const c of clear) {\n const cs0 = thinX ? c.y : c.x;\n const cs1 = thinX ? c.y + c.height : c.x + c.width;\n if (cs1 <= s0 + EPS || cs0 >= s1 - EPS) continue;\n const c0 = thinX ? c.x : c.y;\n const c1 = thinX ? c.x + c.width : c.y + c.height;\n if (c1 <= lo + EPS || c0 >= hi - EPS) continue;\n // Keep the side away from the clear rect's middle.\n if ((c0 + c1) / 2 >= (lo + hi) / 2) hi = Math.min(hi, c0);\n else lo = Math.max(lo, c1);\n }\n if (hi - lo < Math.max(EPS, min)) continue;\n out.push(place(g, thinX ? { x: lo, y: s0, width: hi - lo, height: s1 - s0 } : { x: s0, y: lo, width: s1 - s0, height: hi - lo }));\n }\n return out;\n}\n"],"mappings":";;;;;AAoGO,IAAM,gBAA4B;AAAA,EACvC,MAAM;AAAA,EACN,WAAW;AAAA,EACX,WAAW;AAAA,EACX,aAAa;AAAA,EACb,UAAU;AAAA,EACV,OAAO;AAAA,EACP,OAAO;AAAA,EACP,MAAM;AAAA,EACN,cAAc;AAAA,EACd,WAAW;AAAA,EACX,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AAAA,EACX,gBAAgB;AAAA,EAChB,UAAU;AAAA,EACV,WAAW,EAAE,IAAI,MAAM,UAAU,SAAS,SAAS,MAAM;AAC3D;AAEA,IAAM,YAAiE,EAAE,OAAO,SAAS,KAAK,OAAO,SAAS,QAAQ,MAAM,OAAO;AAEnI,IAAM,OAAO,CAAC,MAA4B,QACxC,CAAC,CAAC,SAAS,QAAQ,QAAQ,CAAC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C9B,UAAM,KAAK,KAAK,IAAI,QAAQ,EAAE,IAAI,EAAE,GAAG,QAAQ,KAAK,EAAE;AACtD,UAAM,KAAK,KAAK,IAAI,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,QAAQ,KAAK,EAAE;AAC3E,QAAI,KAAK,MAAM,IAAK;AAEpB,eAAW,KAAK,OAAO;AACrB,YAAM,MAAM,QAAQ,EAAE,IAAI,EAAE;AAC5B,YAAM,MAAM,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE;AAC7C,UAAI,OAAO,KAAK,OAAO,OAAO,KAAK,IAAK;AACxC,YAAM,KAAK,QAAQ,EAAE,IAAI,EAAE;AAC3B,YAAM,KAAK,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;AAC3C,UAAI,MAAM,KAAK,OAAO,MAAM,KAAK,IAAK;AAEtC,WAAK,KAAK,MAAM,MAAM,KAAK,MAAM,EAAG,MAAK,KAAK,IAAI,IAAI,EAAE;AAAA,UACnD,MAAK,KAAK,IAAI,IAAI,EAAE;AAAA,IAC3B;AACA,QAAI,KAAK,KAAK,KAAK,IAAI,KAAK,GAAG,EAAG;AAClC,QAAI,KAAK,MAAM,GAAG,QAAQ,EAAE,GAAG,IAAI,GAAG,IAAI,OAAO,KAAK,IAAI,QAAQ,KAAK,GAAG,IAAI,EAAE,GAAG,IAAI,GAAG,IAAI,OAAO,KAAK,IAAI,QAAQ,KAAK,GAAG,CAAC,CAAC;AAAA,EAClI;AACA,SAAO;AACT;","names":["held","distanceTo","held","l","within"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@n-uf/motion",
|
|
3
|
-
"version": "26.11.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "26.11.49",
|
|
4
|
+
"description": "How things move: one frame loop with an injected clock, fine-grained signals, springs, tweens and the settle curve, a DOM-free gesture recognizer, the drag intent and the landing model, and layout motion. No DOM, no framework.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"animation",
|
|
7
7
|
"motion",
|