@n-uf/motion 26.11.36 → 26.11.38

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 CHANGED
@@ -3,6 +3,37 @@
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.38
7
+
8
+ - `./drag`, **`frame.refusedSinceShown`** (additive for reading; a host or test mock that builds a `DragFrame` itself
9
+ must now set it, since the field is required). A refusal hides the shown target at once, and the next one shows
10
+ only once the pointer aims again, so a pointer that crosses a refusal and is let go at speed beyond it has no
11
+ indicator drawn, while `release` lands on what is under it. The new frame field is true then: no target shows, and
12
+ the pointer has been over a refusal since a target last showed. A host that commits only what it has drawn commits
13
+ such a release too (`frame.shown || frame.refusedSinceShown`), with no memory of its own: read both from the frame of
14
+ an `update` at the release point, called before `release`. What shows, and when, is unchanged: no indicator flashes
15
+ as a fast pointer leaves a refusal.
16
+
17
+ - `./drag`, **a real target always beats a refusal** (pick change). `targetAt` ranks a refusal (`refuse: true`) at the
18
+ new `REFUSAL_RANK`, 2.5, whatever its own `priority`. It is an ordering rank, not a priority: priorities stay the
19
+ integers 1, 2 and 3, and `refuse: true` is a refusal's tier, ordered after every target of priority 1 and 2 and
20
+ before priority 3 (the float). Where a refusal and a real target meet or overlap, the target wins, so a gap that
21
+ shares an edge with a smaller refusal keeps its end; over a refusal alone it still wins over the float, and the band
22
+ rule is unchanged. `pickRank(t)` gives a target's rank. A pick with no refusal in it is unchanged.
23
+
24
+ - `./drag`, **a zone's bounds** (additive). `DragTarget.bounds` (a rect, the window's stage) makes a zone, its band
25
+ and its gap grace half-open toward the outside: they hold only points strictly inside `bounds`, so a float shown
26
+ inside the window hides on the first frame the pointer reaches the edge. The window's boundary belongs only
27
+ to the targets drawn against it: a refusal and the whole-plane float carry `bounds`, a gap or a slot doesn't. So a
28
+ pointer a host clamps onto the window's edge picks a gap whose hit reaches the edge, else nothing (a held gap keeps
29
+ its band), and never a refusal or the float: a release past the window over open space commits nothing. This relies
30
+ on the host clamping exactly onto the stage's edge (`x + width`, `y + height`): one that clamps to `width - 0.5`
31
+ still picks inside the window. A target without `bounds` is unchanged.
32
+
33
+ ## 26.11.37
34
+
35
+ - No change in `@n-uf/motion`. Released together with `@n-uf/placement` 26.11.37 (`Edge.hidden` in `./scene`).
36
+
6
37
  ## 26.11.36
7
38
 
8
39
  - No change in `@n-uf/motion`. Released together with `@n-uf/placement` 26.11.36 (`./tiling` fixes, bars that give way by
package/README.md CHANGED
@@ -335,9 +335,9 @@ 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 }` (`arming`: the spring-loaded target the pointer dwells on, not armed yet; `forced`: `"float"` or `"rail"` when a modifier key won; `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`. 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`. |
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; `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`. 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
- | `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. This is the one pick rule: `@n-uf/placement/scene/cases` takes it as its hosts' `pick`. |
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). |
342
342
  | `createGripPress({ tuning?, double? })`, `GripRelease`, `DOUBLE_CLICK` | A press on a grip, start to end: `down(point, time, { touch?, clicks? })`, `move(point, time)` (the lift rule), `up(point, time)` → `"click"`, `"doubleActivate"` or null (it lifted). Two presses within `DOUBLE_CLICK` (500 ms and 5 px, the package's one double click, which the recognizer's `clickCount` uses too; browsers don't expose the system setting, so this is the common desktop default; `double` tunes it, and `clicks`, a `mousedown`'s `detail`, overrides it) give a click, then a double-activate: never a second click, never a lift. A press past the lift distance is a drag, also as the second press. |
343
343
  | `previewPlan(frame, preview, slotted?)`, `DragPreview`, `DRAG_PREVIEW_DEFAULT` | What to draw for a frame under one of three drop preview modes: `{ showIndicator, makeRoom, snapItem }`. `"indicator"`: only the indicator, nothing moves. `"gap"` (make room): the others make room once the intent does; the item stays under the pointer. `"snap"` (the default): room opens and the item glides into a slotted target's room, with no indicator (a target without a slot keeps it). |
package/dist/drag.d.ts CHANGED
@@ -107,9 +107,18 @@ declare const DRAG_DEFAULTS: DragTuning;
107
107
  * when given (a magnet: the zone grown), and leaving that disarms it.
108
108
  *
109
109
  * `refuse: true` makes it a refusal: a place that takes no drop (a host says "No room here" there). It takes part in
110
- * the pick under the pointer, but it never becomes the current or the shown target, and a release over it lands
110
+ * the pick under the pointer at {@link REFUSAL_RANK} (below every target of priority 1 or 2, whatever its own
111
+ * `priority`, above priority 3), but it never becomes the current or the shown target, and a release over it lands
111
112
  * nowhere. Where the pick under the pointer is a refusal, no held target's band or gap grace keeps it: nothing shows,
112
113
  * and the frame's `refused` says which refusal it is.
114
+ *
115
+ * `bounds`, when given, is the drawn space the zone belongs to (a window's stage): the zone, its band and its gap grace
116
+ * hold only points strictly inside it, so it is half-open toward the outside and a point on `bounds`' boundary or past
117
+ * it is never in it. The window's boundary belongs only to the targets drawn against it: a refusal and a target over
118
+ * the whole plane (the float) carry `bounds`, a gap or a slot doesn't. So a pointer a host clamps onto the window's
119
+ * edge picks a gap whose hit reaches the edge, else nothing (a held target keeps its band), and never a refusal or the
120
+ * float. The rule relies on the host clamping exactly onto the stage's edge (`x + width`, `y + height`): a host that
121
+ * clamps to `width - 0.5` still picks inside the window, the float or a refusal there included.
113
122
  */
114
123
  interface DragTarget {
115
124
  readonly id: string;
@@ -122,10 +131,25 @@ interface DragTarget {
122
131
  readonly arm?: "dwell";
123
132
  readonly armedHit?: Rect;
124
133
  readonly refuse?: true;
134
+ readonly bounds?: Rect;
125
135
  }
136
+ /**
137
+ * Where a refusal ranks in the pick ({@link targetAt}): an ordering rank, not a priority. Priorities stay the integers
138
+ * 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
139
+ * target of priority 1 and 2 (a refusal and a real target where they meet or overlap: the target wins, so a gap keeps
140
+ * its end), before priority 3 (the float: over drawn space that takes nothing, "No room here" wins over floating).
141
+ * Among refusals the smaller zone wins. `@n-uf/placement` exports the same value for its reference pick.
142
+ */
143
+ declare const REFUSAL_RANK = 2.5;
144
+ /** A target's rank in the pick: its `priority`, a refusal's {@link REFUSAL_RANK}. Lower wins. */
145
+ declare const pickRank: (t: Pick<DragTarget, "priority" | "refuse">) => number;
126
146
  /** Whether `point` lies in `rect` grown by `margin` px on every side (shrunk, for a negative margin). */
127
147
  declare function inRect(rect: Rect, point: Point, margin?: number): boolean;
128
- /** The most precise target under `point`: the lowest priority number, then the smallest zone; null when none is. */
148
+ /**
149
+ * The most precise target under `point`: the lowest rank ({@link pickRank}: the priority, a refusal's
150
+ * {@link REFUSAL_RANK}), then the smallest zone; null when none is. A zone holds its edges (a closed rect), except
151
+ * toward the outside of its `bounds`.
152
+ */
129
153
  declare function targetAt<T extends DragTarget>(targets: readonly T[], point: Point): T | null;
130
154
  /** What a press does so far: not yet a drag (`wait`), a drag (`lift`), or never one (`refuse`: a touch that moved too soon). */
131
155
  type LiftDecision = "wait" | "lift" | "refuse";
@@ -174,6 +198,17 @@ interface DragFrame<T extends DragTarget> {
174
198
  * host says so at the pointer ("No room here"). Null otherwise, and while a key forces a target.
175
199
  */
176
200
  readonly refused: T | null;
201
+ /**
202
+ * No target shows, and the pointer has been over a refusal since a target last showed (or since the lift). A refusal
203
+ * hides the shown target at once, and the next one shows only once the pointer aims again, so a pointer that crosses
204
+ * a refusal and is let go at speed over a target beyond it has no indicator drawn. Then this is true, and a release
205
+ * still lands on what is under the pointer (`release`): a host that commits only what it has drawn commits that
206
+ * release too. False whenever a target shows, over the refusal itself (`refused`), and after `hide`.
207
+ *
208
+ * Read it from the frame of an `update` at the release point, called before `release` (as `release` asks anyway), so
209
+ * the last move counts. The field is required: a host or a test mock that builds a `DragFrame` itself must set it.
210
+ */
211
+ readonly refusedSinceShown: boolean;
177
212
  }
178
213
  /** What a drag intent knows now. */
179
214
  interface DragIntentState<T extends DragTarget> {
@@ -359,4 +394,4 @@ declare function createGripPress(options?: {
359
394
  readonly double?: Partial<DoubleClick>;
360
395
  }): GripPress;
361
396
 
362
- export { DRAG_DEFAULTS, DRAG_PREVIEW_DEFAULT, DoubleClick, type DragFrame, type DragIntent, type DragIntentOptions, type DragIntentState, type DragKeys, type DragModifiers, type DragPreview, type DragTarget, type DragTuning, type GripPress, type GripRelease, type LiftDecision, type ModifierKey, type PreviewPlan, createDragIntent, createGripPress, inRect, liftDecision, previewPlan, targetAt };
397
+ export { DRAG_DEFAULTS, DRAG_PREVIEW_DEFAULT, DoubleClick, type DragFrame, type DragIntent, type DragIntentOptions, type DragIntentState, type DragKeys, type DragModifiers, type DragPreview, type DragTarget, type DragTuning, type GripPress, type GripRelease, type LiftDecision, type ModifierKey, type PreviewPlan, REFUSAL_RANK, createDragIntent, createGripPress, inRect, liftDecision, pickRank, previewPlan, targetAt };
package/dist/drag.js CHANGED
@@ -24,12 +24,15 @@ var DRAG_DEFAULTS = {
24
24
  };
25
25
  var KEY_FIELD = { Shift: "shift", Alt: "alt", Control: "ctrl", Meta: "meta" };
26
26
  var held = (keys, key) => !!keys && (key === "Mod" ? !!(keys.meta || keys.ctrl) : !!keys[KEY_FIELD[key]]);
27
+ var REFUSAL_RANK = 2.5;
28
+ var pickRank = (t) => t.refuse === true ? REFUSAL_RANK : t.priority;
29
+ var within = (bounds, point) => !bounds || point.x > bounds.x && point.x < bounds.x + bounds.width && point.y > bounds.y && point.y < bounds.y + bounds.height;
27
30
  function inRect(rect, point, margin = 0) {
28
31
  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;
29
32
  }
30
33
  var distanceTo = (rect, point) => 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)));
31
- var inZone = (t, point, margin = 0) => t.hits ? t.hits.some((r) => inRect(r, point, margin)) : inRect(t.hit, point, margin);
32
- var inZoneBy = (t, point, m) => (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);
34
+ var inZone = (t, point, margin = 0) => within(t.bounds, point) && (t.hits ? t.hits.some((r) => inRect(r, point, margin)) : inRect(t.hit, point, margin));
35
+ var inZoneBy = (t, point, m) => 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);
33
36
  var scaled = (px, share, zones) => {
34
37
  let x = px;
35
38
  let y = px;
@@ -47,7 +50,7 @@ function targetAt(targets, point) {
47
50
  let best = null;
48
51
  for (const t of targets) {
49
52
  if (!inZone(t, point)) continue;
50
- if (!best || t.priority < best.priority || t.priority === best.priority && zoneArea(t) < zoneArea(best)) best = t;
53
+ if (!best || pickRank(t) < pickRank(best) || pickRank(t) === pickRank(best) && zoneArea(t) < zoneArea(best)) best = t;
51
54
  }
52
55
  return best;
53
56
  }
@@ -77,6 +80,7 @@ function createDragIntent(options) {
77
80
  let anchor = null;
78
81
  let stillSince = 0;
79
82
  let restart = false;
83
+ let crossedRefusal = false;
80
84
  let armedId = null;
81
85
  let armingId = null;
82
86
  let armingSince = 0;
@@ -173,7 +177,7 @@ function createDragIntent(options) {
173
177
  const breaks = raw !== null && !same(raw, cur) && raw.priority < cur.priority && (cur.free === true || pastBreakthrough(raw));
174
178
  next = breaks ? raw : cur;
175
179
  }
176
- if (!refusedRaw && !next && cur && pickable(cur) && t - lastInside < tuning.gapGrace) next = cur;
180
+ if (!refusedRaw && !next && cur && pickable(cur) && within(cur.bounds, p) && t - lastInside < tuning.gapGrace) next = cur;
177
181
  if (next && inZone(next, p)) lastInside = t;
178
182
  if (!same(next, cur)) curSince = t;
179
183
  cur = next;
@@ -210,7 +214,10 @@ function createDragIntent(options) {
210
214
  else if (t - shownSince >= tuning.roomAfter && t - placeSince >= tuning.roomAfter) roomPlace = place;
211
215
  else if (shownSince === t) roomPlace = null;
212
216
  lastPlaces = places;
213
- return { shown, room: roomPlace !== null, roomPlace, aiming, atHome: !forced && wentOut && atHome, arming, forced: forced?.kind ?? null, refused: forced ? null : refusedRaw };
217
+ if (shown) crossedRefusal = false;
218
+ else if (refusedRaw && !forced) crossedRefusal = true;
219
+ const refused = forced ? null : refusedRaw;
220
+ return { shown, room: roomPlace !== null, roomPlace, aiming, atHome: !forced && wentOut && atHome, arming, forced: forced?.kind ?? null, refused, refusedSinceShown: !shown && !refused && crossedRefusal };
214
221
  },
215
222
  release(point, given, keys) {
216
223
  const forced = forcedBy(keys, point, given, () => true);
@@ -240,6 +247,7 @@ function createDragIntent(options) {
240
247
  samples = [];
241
248
  anchor = null;
242
249
  restart = true;
250
+ crossedRefusal = false;
243
251
  },
244
252
  moveHome(dx, dy) {
245
253
  home = { ...home, x: home.x + dx, y: home.y + dy };
@@ -298,10 +306,12 @@ export {
298
306
  DOUBLE_CLICK,
299
307
  DRAG_DEFAULTS,
300
308
  DRAG_PREVIEW_DEFAULT,
309
+ REFUSAL_RANK,
301
310
  createDragIntent,
302
311
  createGripPress,
303
312
  inRect,
304
313
  liftDecision,
314
+ pickRank,
305
315
  previewPlan,
306
316
  targetAt
307
317
  };
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 * 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, 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 */\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}\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. */\nconst inZone = (t: DragTarget, point: Point, margin = 0): boolean => (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/** Whether `point` lies in a target's zone grown by `m.x` px left and right and `m.y` px above and below. */\nconst inZoneBy = (t: DragTarget, point: Point, m: Margin): boolean =>\n (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/** The most precise target under `point`: the lowest priority number, then the smallest zone; null when none is. */\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 || t.priority < best.priority || (t.priority === best.priority && 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 /** A key held wins over geometry this frame: `\"float\"` (the float key) or `\"rail\"` (the rail key), else null. */\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.\n */\n readonly refused: T | null;\n}\n\n/** What a drag intent knows now. */\nexport interface DragIntentState<T extends DragTarget> {\n /** The pointer's smoothed speed, px/ms. */\n readonly speed: number;\n /** The target under the pointer as the hysteresis holds it, or null. */\n readonly current: T | null;\n /** The target the indicator shows, or null. */\n readonly shown: T | null;\n /** The pointer has left the item's home. */\n readonly leftHome: boolean;\n}\n\nexport interface DragIntentOptions<T extends DragTarget> {\n /** Where the item was lifted from: the indicator stays off until the pointer leaves it, and a release there does nothing. */\n readonly home: Rect;\n /** Where the press that lifted the item was (the grip); default the first sample's point. The lift zone is about it. */\n readonly lift?: Point;\n /**\n * The lift zone as a rect instead of a radius, in the same px as the samples: while a sample is inside it no\n * spring-loaded target arms by dwell, and the `liftZone` radius is not applied. A host passes the part of the grip\n * that a drop strip covers (grip ∩ strip), so a pause back there commits nothing while the rest of the strip, right\n * beside a wide grip, still arms. Absent: the `liftZone` radius about `lift`.\n */\n readonly liftRect?: Rect;\n /** 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, the rail key the nearest target marked `arm`; a\n * release with the key held lands there.\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 // 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 /** The target a held key picks at `p`: the float key the `free` target, the rail key the nearest spring-loaded one. */\n const forcedBy = (keys: DragKeys | undefined, p: Point, targets: readonly T[], ok: (x: T) => boolean): { kind: \"float\" | \"rail\"; target: T } | 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 && ok(x));\n return f ? { kind: \"float\", target: f } : 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\" || !ok(x)) 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) } : 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, () => true);\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 if (!refusedRaw && !next && cur && pickable(cur) && 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 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 return { shown, room: roomPlace !== null, roomPlace, aiming, atHome: !forced && wentOut && atHome, arming, forced: forced?.kind ?? null, refused: forced ? null : refusedRaw };\n },\n release(point, given, keys) {\n // A key held wins over geometry, home included.\n const forced = forcedBy(keys, point, given, () => true);\n if (forced) return given.find((x) => x.id === forced.target.id) ?? forced.target;\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 },\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":";;;;;AAgGO,IAAM,gBAA4B;AAAA,EACvC,MAAM;AAAA,EACN,WAAW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,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 * 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 /** A key held wins over geometry this frame: `\"float\"` (the float key) or `\"rail\"` (the rail key), else null. */\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.\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, the rail key the nearest target marked `arm`; a\n * release with the key held lands there.\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 /** The target a held key picks at `p`: the float key the `free` target, the rail key the nearest spring-loaded one. */\n const forcedBy = (keys: DragKeys | undefined, p: Point, targets: readonly T[], ok: (x: T) => boolean): { kind: \"float\" | \"rail\"; target: T } | 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 && ok(x));\n return f ? { kind: \"float\", target: f } : 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\" || !ok(x)) 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) } : 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, () => true);\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 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 if (shown) crossedRefusal = false;\n else if (refusedRaw && !forced) crossedRefusal = true;\n const refused = forced ? null : refusedRaw;\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.\n const forced = forcedBy(keys, point, given, () => true);\n if (forced) return given.find((x) => x.id === forced.target.id) ?? forced.target;\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":";;;;;AAgGO,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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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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@n-uf/motion",
3
- "version": "26.11.36",
3
+ "version": "26.11.38",
4
4
  "description": "One frame loop with an injected clock, fine-grained signals, springs and tweens, and a DOM-free gesture recogniser. No DOM, no framework.",
5
5
  "keywords": [
6
6
  "animation",