@n-uf/motion 26.11.40 → 26.11.41
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 +11 -0
- package/README.md +1 -1
- package/dist/drag.d.ts +13 -0
- package/dist/drag.js +5 -2
- package/dist/drag.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
Versions are calendar versions, `YY.M.R` (year, month of the release, counter
|
|
4
4
|
within the month), the same scheme as `@n-uf/hypr-tiling`.
|
|
5
5
|
|
|
6
|
+
## 26.11.41
|
|
7
|
+
|
|
8
|
+
- `./drag`, fixed: **a floating item's own place loses to a refusal and ends at the window's edge.** Home gated every
|
|
9
|
+
pick, refusals included, so a float whose box lay over a refused place, lifted and let go there, was over home (no
|
|
10
|
+
`refused`, a host moved it where it was let go). New `DragIntentOptions.floating`: the held item floats and `home` is
|
|
11
|
+
its box, a free placement ranked like the float target. Its home then holds only where the pick there, home ignored,
|
|
12
|
+
is no refusal and inside the window: over a refusal the frame is refused, `atHome` is false and a release lands
|
|
13
|
+
nowhere; on or past the window's edge (the float holds only inside its `bounds`) nothing is picked. Elsewhere in its
|
|
14
|
+
box home holds as before (a host moves the float where it is let go). Without the option (a docked item) home is
|
|
15
|
+
unchanged: its own home target beats a refusal. Hosts that lift a float pass `floating: true`.
|
|
16
|
+
|
|
6
17
|
## 26.11.40
|
|
7
18
|
|
|
8
19
|
- No change in `@n-uf/motion`. Released together with `@n-uf/placement` 26.11.40 (a drop names a zone only where the
|
package/README.md
CHANGED
|
@@ -335,7 +335,7 @@ targets, and draws what it says. It is only there, not in the root.
|
|
|
335
335
|
|
|
336
336
|
| | |
|
|
337
337
|
|---|---|
|
|
338
|
-
| `createDragIntent({ home, lift?, tuning?, placeOf? })` | `update(point, time, targets, keys?)` once a frame while an item is dragged, returning `{ shown, room, roomPlace, aiming, atHome, arming, forced, refused, refusedSinceShown }` (`refusedSinceShown`: no target shows and the pointer has crossed a refusal since one last did, so a host that commits only drawn targets commits `release` too, as a quick drag across a refusal let go beyond it has no indicator drawn: read it from an `update` at the release point, called before `release`; the field is required, so a host or mock that builds a frame itself sets it; `arming`: the spring-loaded target the pointer dwells on, not armed yet; `forced`: `"float"` or `"rail"` when a modifier key won (the float key wins over dock targets only: over a refusal, or outside the float's `bounds`, it shows nothing and a release lands nowhere, `refused` naming the refusal); `refused`: the refusal under the pointer, a target marked `refuse: true` that the pick lands on, which no held target's band or grace covers, so nothing shows there and a release lands nowhere: pass a host's refusals in with the targets and say "No room here" from it; `atHome`: the pointer is back inside `home` after it has been outside `home` itself; never true at the press or while it moves about inside `home
|
|
338
|
+
| `createDragIntent({ home, lift?, liftRect?, floating?, tuning?, placeOf? })` | `update(point, time, targets, keys?)` once a frame while an item is dragged, returning `{ shown, room, roomPlace, aiming, atHome, arming, forced, refused, refusedSinceShown }` (`refusedSinceShown`: no target shows and the pointer has crossed a refusal since one last did, so a host that commits only drawn targets commits `release` too, as a quick drag across a refusal let go beyond it has no indicator drawn: read it from an `update` at the release point, called before `release`; the field is required, so a host or mock that builds a frame itself sets it; `arming`: the spring-loaded target the pointer dwells on, not armed yet; `forced`: `"float"` or `"rail"` when a modifier key won (the float key wins over dock targets only: over a refusal, or outside the float's `bounds`, it shows nothing and a release lands nowhere, `refused` naming the refusal); `refused`: the refusal under the pointer, a target marked `refuse: true` that the pick lands on, which no held target's band or grace covers, so nothing shows there and a release lands nowhere: pass a host's refusals in with the targets and say "No room here" from it; `atHome`: the pointer is back inside `home` after it has been outside `home` itself; never true at the press or while it moves about inside `home`; with `floating` (the held item floats, `home` its box: a free placement, ranked like the float) home holds only where the pick there, home ignored, is no refusal and inside the window, so over a refusal in its box the frame is refused and a release lands nowhere, and on or past the window's edge nothing is picked; a docked item's home holds wherever it lies. A host sets it at lift from the placement layout, `floating: layout.items[id]?.floating === true`: the option is the intent's, read from `@n-uf/placement`'s layout item flag of the same name, not that flag itself. Over home no target is shown and a release does nothing, so a host that wants to say "a drop here returns it" draws its own indicator at the home rect for that frame); `release(point, targets, keys?)`, the target a release lands on or null (home); `hide(time)` while the view scrolls under the pointer; `moveHome(dx, dy)`; `state`; `tuning`. |
|
|
339
339
|
| `DRAG_DEFAULTS` | Lift at 5 px (a touch: a 180 ms hold, then 8 px); aiming below 0.45 px/ms over 50 ms, or within 12 px for 90 ms; a 10 px hysteresis margin (`band`) and a 4 px breakthrough, each at most a fifth of the hit areas' extents (`bandShare` 0.2), a 120 ms grace across the gap between two hit areas (`gapGrace`); a switch waits 150 ms (the switch delay); room after 160 ms; a spring-loaded target arms after a 200 ms dwell (`railArmDwellMs`: a pass at travelling speed never arms it, and platforms spring-load after a similar rest), never within 16 px of the lift point (`liftZone`: the "changed my mind" spot); Shift floats and ⌘/Ctrl (`"Mod"`, either key) goes to the nearest rail (`modifiers`; Alt is left free, so an app can keep it for unfreezing a frozen layout). Each is overridable per intent. |
|
|
340
340
|
| `targetAt(targets, point)`, `inRect(rect, point, margin?)` | The most precise target under a point (priority 1, 2, 3, then the smaller hit area; a rect holds its edges exactly); a point in a rect grown or shrunk by a margin. A `DragTarget` whose hit area isn't one rect gives `hits`, every piece of it (`hit` is then the largest): the pointer is in the hit area when it is in any piece, and the hit area's size, for the smaller-hit-area rule and the drag intent's bands, is the pieces' together. A refusal ranks at `REFUSAL_RANK` (2.5, an ordering rank, not a priority: priorities stay 1, 2 and 3, and `refuse: true` is a refusal's tier; it orders after every target of priority 1 and 2, so a real target wins wherever the two meet or overlap, before the float's 3); `pickRank(t)` gives a target's rank. A zone with `bounds` (a refusal's and the float's: the window's stage) holds only points strictly inside it, its band and gap grace too, so a pointer clamped exactly onto the window's edge (`x + width`; a host that clamps to `width - 0.5` still picks inside) is never in it. This is the one pick rule: `@n-uf/placement/scene/cases` takes it as its hosts' `pick`. |
|
|
341
341
|
| `liftDecision({ touch, distance, elapsed }, tuning?)` | `"wait"`, `"lift"` or `"refuse"`: when a press becomes a drag (`"refuse"` is a touch that moved before the hold: scroll wins). |
|
package/dist/drag.d.ts
CHANGED
|
@@ -185,6 +185,11 @@ interface DragFrame<T extends DragTarget> {
|
|
|
185
185
|
* the indicator's gate and uses `homeInset`; this one does not). Over home no target is shown and a release does
|
|
186
186
|
* nothing, so a host that wants to say "a drop here returns it" draws its own indicator for this frame (at the home
|
|
187
187
|
* rect); the intent still shows no target.
|
|
188
|
+
*
|
|
189
|
+
* A docked item's home holds wherever it lies. The home of a floating item (`DragIntentOptions.floating`) is a free
|
|
190
|
+
* placement, ranked like the float: it holds only where the pick there, home ignored, is no refusal and the point is
|
|
191
|
+
* inside the window. Where it doesn't hold this is false and the pick is as anywhere else: over a refusal
|
|
192
|
+
* `refused` says so, and a release lands nowhere.
|
|
188
193
|
*/
|
|
189
194
|
readonly atHome: boolean;
|
|
190
195
|
/**
|
|
@@ -239,6 +244,14 @@ interface DragIntentOptions<T extends DragTarget> {
|
|
|
239
244
|
* beside a wide grip, still arms. Absent: the `liftZone` radius about `lift`.
|
|
240
245
|
*/
|
|
241
246
|
readonly liftRect?: Rect;
|
|
247
|
+
/**
|
|
248
|
+
* The held item floats, and `home` is its own box. A floating item's own place is a free placement: it ranks like the
|
|
249
|
+
* float target, so home holds only where the pick there, home ignored, is no refusal and the point lies inside the
|
|
250
|
+
* window (no target's `bounds` left with nothing picked). Over a refusal in its box the frame is refused and a
|
|
251
|
+
* release lands nowhere; on or past the window's edge nothing is picked; elsewhere in its box home holds as before.
|
|
252
|
+
* Absent (a docked item): home holds wherever it lies, as its own home target beats a refusal.
|
|
253
|
+
*/
|
|
254
|
+
readonly floating?: boolean;
|
|
242
255
|
/** Overrides of {@link DRAG_DEFAULTS}. */
|
|
243
256
|
readonly tuning?: Partial<DragTuning>;
|
|
244
257
|
/**
|
package/dist/drag.js
CHANGED
|
@@ -166,7 +166,10 @@ function createDragIntent(options) {
|
|
|
166
166
|
}
|
|
167
167
|
const arming = armingId === null ? null : given.find((x) => x.id === armingId) ?? null;
|
|
168
168
|
const targets = acting(given);
|
|
169
|
-
const
|
|
169
|
+
const underHome = atHome && options.floating ? targetAt(targets.filter((x) => inZone(x, p) && (x.refuse === true || live(x))), p) : null;
|
|
170
|
+
const pastBounds = atHome && options.floating ? targets.some((x) => x.bounds !== void 0 && !within(x.bounds, p)) : false;
|
|
171
|
+
const homeHolds = atHome && (!options.floating || underHome?.refuse !== true && !(underHome === null && pastBounds));
|
|
172
|
+
const pickable = (x) => !homeHolds || x.arm === "dwell" && x.id === armedId;
|
|
170
173
|
const raw = targetAt(targets.filter((x) => pickable(x) && inZone(x, p) && (x.refuse === true || live(x))), p);
|
|
171
174
|
const refusedRaw = raw?.refuse === true ? raw : null;
|
|
172
175
|
const disarmed = (x) => x?.arm === "dwell" && x.id !== armedId;
|
|
@@ -220,7 +223,7 @@ function createDragIntent(options) {
|
|
|
220
223
|
const refused = forced ? forced.refused : refusedRaw;
|
|
221
224
|
if (shown) crossedRefusal = false;
|
|
222
225
|
else if (refused) crossedRefusal = true;
|
|
223
|
-
return { shown, room: roomPlace !== null, roomPlace, aiming, atHome: !forced && wentOut &&
|
|
226
|
+
return { shown, room: roomPlace !== null, roomPlace, aiming, atHome: !forced && wentOut && homeHolds, arming, forced: forced?.kind ?? null, refused, refusedSinceShown: !shown && !refused && crossedRefusal };
|
|
224
227
|
},
|
|
225
228
|
release(point, given, keys) {
|
|
226
229
|
const forced = forcedBy(keys, point, given, (x) => x.refuse === true || placeOf(x, point, lastPlaces.get(x.id) ?? null) !== null);
|
package/dist/drag.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/drag/intent.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 /** Room is made once the shown target, and the place in it, have held this long. */\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 says \"No room here\" there). 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 */\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}\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, \"No room here\" 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 /** The others make room for the shown target: it, and the place in it, have held `roomAfter` ms. */\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 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, and a\n * host says so at the pointer (\"No room here\"). 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\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 /** 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.\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 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 // 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 => !atHome || (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 const refusedRaw = raw?.refuse === true ? raw : null;\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 // 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) && 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.\n const breaks = raw !== null && !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)) 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), not just kept by the gap grace.\n const under = !!cur && inZoneBy(cur, p, bandOf(cur));\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) 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 show(cur);\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.\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 (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 && atHome, arming, forced: forced?.kind ?? null, refused, refusedSinceShown: !shown && !refused && crossedRefusal };\n },\n release(point, given, keys) {\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 if (s) return s;\n // Else 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 return under && !under.refuse ? (given.find((x) => x.id === under.id) ?? under) : null;\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 { 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 *\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\";\n\n/** The preview a drag uses unless the host picks another. */\nexport const DRAG_PREVIEW_DEFAULT: DragPreview = \"snap\";\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\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 */\nexport function previewPlan<T extends DragTarget>(\n frame: Pick<DragFrame<T>, \"shown\" | \"room\">,\n preview: DragPreview,\n slotted: boolean = !!frame.shown && !frame.shown.free,\n): PreviewPlan {\n const shown = !!frame.shown;\n if (preview === \"indicator\") return { showIndicator: shown, makeRoom: false, snapItem: false };\n if (preview === \"gap\") return { showIndicator: shown, makeRoom: frame.room, snapItem: false };\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 };\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":";;;;;AAiGO,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;AAkDxE,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,IAA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c,GAAG,QAAQ,OAAO;AAC9D,MAAI,QAAkG;AAEtG,MAAI,OAA2C;AAC/C,SAAO;AAAA,IACL,KAAK,OAAO,MAAM,IAAI,CAAC,GAAG;AACxB,YAAM,OAAO,CAAC,CAAC,QAAQ,OAAO,KAAK,QAAQ,IAAI,MAAM,KAAK,MAAM,MAAM,IAAI,KAAK,GAAG,GAAG,MAAM,IAAI,KAAK,GAAG,CAAC,KAAK,IAAI;AACjH,YAAM,SAAS,EAAE,WAAW,UAAa,EAAE,SAAS,IAAI,EAAE,WAAW,IAAI;AACzE,cAAQ,EAAE,IAAI,EAAE,GAAG,MAAM,GAAG,GAAG,MAAM,EAAE,GAAG,MAAM,OAAO,CAAC,CAAC,EAAE,OAAO,QAAQ,OAAO,OAAO;AAAA,IAC1F;AAAA,IACA,KAAK,OAAO,MAAM;AAChB,UAAI,CAAC,MAAO,QAAO;AACnB,UAAI,MAAM,UAAU,OAAQ,QAAO,MAAM;AACzC,YAAM,QAAQ,aAAa,EAAE,OAAO,MAAM,OAAO,UAAU,KAAK,MAAM,MAAM,IAAI,MAAM,GAAG,GAAG,MAAM,IAAI,MAAM,GAAG,CAAC,GAAG,SAAS,OAAO,MAAM,KAAK,GAAG,MAAM;AACvJ,aAAO,MAAM;AAAA,IACf;AAAA,IACA,KAAK;AACH,YAAM,IAAI;AACV,cAAQ;AACR,UAAI,CAAC,KAAK,EAAE,UAAU,QAAQ;AAC5B,eAAO;AACP,eAAO;AAAA,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"]}
|
|
1
|
+
{"version":3,"sources":["../src/drag/intent.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 /** Room is made once the shown target, and the place in it, have held this long. */\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 says \"No room here\" there). 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 */\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}\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, \"No room here\" 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 /** The others make room for the shown target: it, and the place in it, have held `roomAfter` ms. */\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, and a\n * host says so at the pointer (\"No room here\"). 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\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 /** 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.\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 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 const refusedRaw = raw?.refuse === true ? raw : null;\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 // 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) && 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.\n const breaks = raw !== null && !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)) 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), not just kept by the gap grace.\n const under = !!cur && inZoneBy(cur, p, bandOf(cur));\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) 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 show(cur);\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.\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 (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 };\n },\n release(point, given, keys) {\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 if (s) return s;\n // Else 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 return under && !under.refuse ? (given.find((x) => x.id === under.id) ?? under) : null;\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 { 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 *\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\";\n\n/** The preview a drag uses unless the host picks another. */\nexport const DRAG_PREVIEW_DEFAULT: DragPreview = \"snap\";\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\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 */\nexport function previewPlan<T extends DragTarget>(\n frame: Pick<DragFrame<T>, \"shown\" | \"room\">,\n preview: DragPreview,\n slotted: boolean = !!frame.shown && !frame.shown.free,\n): PreviewPlan {\n const shown = !!frame.shown;\n if (preview === \"indicator\") return { showIndicator: shown, makeRoom: false, snapItem: false };\n if (preview === \"gap\") return { showIndicator: shown, makeRoom: frame.room, snapItem: false };\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 };\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":";;;;;AAiGO,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;AAkDxE,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,IAAI,OAAO,IAAI,OAAO,SAAS,MAAM,IAAI,OAAO,KAAK,MAAM,IAAI,OAAO,IAAI,OAAO;AAGpH,SAAS,OAAO,MAAY,OAAc,SAAS,GAAY;AACpE,SAAO,MAAM,KAAK,KAAK,IAAI,UAAU,MAAM,KAAK,KAAK,IAAI,KAAK,QAAQ,UAAU,MAAM,KAAK,KAAK,IAAI,UAAU,MAAM,KAAK,KAAK,IAAI,KAAK,SAAS;AAClJ;AAGA,IAAM,aAAa,CAAC,MAAY,UAC9B,KAAK,MAAM,KAAK,I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