@activecollab/components 2.0.468 → 2.0.470

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.
Files changed (34) hide show
  1. package/dist/cjs/components/StackedCard/StackedCard.js.map +1 -1
  2. package/dist/cjs/components/StackedCard/Styles.js.map +1 -1
  3. package/dist/cjs/components/StackedCard/resizePolicy.js +141 -60
  4. package/dist/cjs/components/StackedCard/resizePolicy.js.map +1 -1
  5. package/dist/cjs/components/StackedCard/resizePolicy.test.js +362 -15
  6. package/dist/cjs/components/StackedCard/resizePolicy.test.js.map +1 -1
  7. package/dist/cjs/components/StackedCard/useStackedCardResize.js +35 -14
  8. package/dist/cjs/components/StackedCard/useStackedCardResize.js.map +1 -1
  9. package/dist/cjs/presentation/shared/SourceCodeSection.js +88 -82
  10. package/dist/cjs/presentation/shared/SourceCodeSection.js.map +1 -1
  11. package/dist/esm/components/StackedCard/StackedCard.d.ts +5 -5
  12. package/dist/esm/components/StackedCard/StackedCard.d.ts.map +1 -1
  13. package/dist/esm/components/StackedCard/StackedCard.js.map +1 -1
  14. package/dist/esm/components/StackedCard/Styles.d.ts +2 -2
  15. package/dist/esm/components/StackedCard/Styles.d.ts.map +1 -1
  16. package/dist/esm/components/StackedCard/Styles.js.map +1 -1
  17. package/dist/esm/components/StackedCard/resizePolicy.d.ts +85 -40
  18. package/dist/esm/components/StackedCard/resizePolicy.d.ts.map +1 -1
  19. package/dist/esm/components/StackedCard/resizePolicy.js +139 -60
  20. package/dist/esm/components/StackedCard/resizePolicy.js.map +1 -1
  21. package/dist/esm/components/StackedCard/resizePolicy.test.js +359 -16
  22. package/dist/esm/components/StackedCard/resizePolicy.test.js.map +1 -1
  23. package/dist/esm/components/StackedCard/useStackedCardResize.d.ts +25 -13
  24. package/dist/esm/components/StackedCard/useStackedCardResize.d.ts.map +1 -1
  25. package/dist/esm/components/StackedCard/useStackedCardResize.js +35 -14
  26. package/dist/esm/components/StackedCard/useStackedCardResize.js.map +1 -1
  27. package/dist/esm/presentation/shared/SourceCodeSection.d.ts.map +1 -1
  28. package/dist/esm/presentation/shared/SourceCodeSection.js +88 -82
  29. package/dist/esm/presentation/shared/SourceCodeSection.js.map +1 -1
  30. package/dist/index.js +179 -74
  31. package/dist/index.js.map +1 -1
  32. package/dist/index.min.js +1 -1
  33. package/dist/index.min.js.map +1 -1
  34. package/package.json +1 -1
@@ -1,14 +1,16 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  /**
3
- * StackedCard resize policy — pure math.
3
+ * Resize policy — pure math, shared by every resizable element.
4
4
  *
5
- * The card reports intent; the HOST applies a resize policy (spec §7). This
6
- * module is that policy, packaged as pure functions so the SAME code path
7
- * serves the pointer drag and the keyboard resize. Nothing here touches the
8
- * DOM, React or the card's content: it takes a start size, a delta and a
9
- * policy, and returns a clamped size. `useStackedCardResize` wires events to
10
- * it; the card's intrinsic content minimum is measured by the host and passed
11
- * in as `contentMin`, so this module knows nothing about heroes or footers.
5
+ * The element reports intent; the HOST applies a resize policy (StackedCard
6
+ * spec §7). This module is that policy, packaged as pure functions so the SAME
7
+ * code path serves the pointer drag and the keyboard resize, a card's single
8
+ * bottom-right grip and a shape's eight handles. Nothing here touches the DOM,
9
+ * React or the element's content: it takes a start box, a delta, a policy and
10
+ * the handle being dragged, and returns a clamped box — size AND position.
11
+ * `useStackedCardResize` wires events to it; an element's intrinsic content
12
+ * minimum is measured by the host and passed in as `contentMin`, so this module
13
+ * knows nothing about heroes or footers.
12
14
  *
13
15
  * The policy has four parts:
14
16
  * - bounds — optional min/max per axis; unset means unbounded.
@@ -17,12 +19,34 @@ import _extends from "@babel/runtime/helpers/esm/extends";
17
19
  * distorts at a bound.
18
20
  * - step — optional grid snap; proportion wins over the grid.
19
21
  * - content min — the effective min is max(policyMin, contentMin) per axis,
20
- * so a card can never be crushed below what its content needs.
22
+ * so an element can never be crushed below what its content
23
+ * needs.
24
+ *
25
+ * The anchor is the handle being dragged. The edge or corner OPPOSITE to it
26
+ * never moves — not while the pointer travels, and not when a bound stops the
27
+ * resize — which is what makes a resize feel like a resize rather than a nudge.
28
+ * A `left` handle moves the position by exactly the amount the width grew; a
29
+ * `right` handle leaves it alone. An edge handle touches one axis only.
21
30
  */
22
31
 
23
- /** The card's intrinsic minimum, measured from its real content. */
32
+ /** A resized element: its size and where its top-left corner now sits. */
24
33
 
25
- /** The size captured at the start of a gesture (pointer down or a key press). */
34
+ /** The element's intrinsic minimum, measured from its real content. */
35
+
36
+ /**
37
+ * The handle being dragged, named after the edge or corner it sits on. The
38
+ * opposite edge or corner is held in place.
39
+ */
40
+
41
+ export const RESIZE_ANCHORS = ["top-left", "top", "top-right", "right", "bottom-right", "bottom", "bottom-left", "left"];
42
+
43
+ /** A card's single grip: the top-left corner stays put. */
44
+ export const DEFAULT_RESIZE_ANCHOR = "bottom-right";
45
+
46
+ /**
47
+ * The box captured at the start of a gesture (pointer down or a key press).
48
+ * A host that only tracks a size leaves the position at the origin.
49
+ */
26
50
 
27
51
  /**
28
52
  * `width` locks the vertical axis: an auto-height card takes a width and lets
@@ -42,11 +66,16 @@ export const RESIZE_KEYS = ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "
42
66
  export const isResizeKey = key => RESIZE_KEYS.includes(key);
43
67
  export const clamp = (v, lo, hi) => Math.min(hi != null ? hi : Number.POSITIVE_INFINITY, Math.max(lo, v));
44
68
  export const snap = (v, step) => step && step > 0 ? Math.round(v / step) * step : v;
45
- export const makeStart = (size, contentMin) => ({
46
- w: size.w,
47
- h: size.h,
48
- contentMin
49
- });
69
+ export const makeStart = (box, contentMin) => {
70
+ var _box$x, _box$y;
71
+ return {
72
+ w: box.w,
73
+ h: box.h,
74
+ x: (_box$x = box.x) != null ? _box$x : 0,
75
+ y: (_box$y = box.y) != null ? _box$y : 0,
76
+ contentMin
77
+ };
78
+ };
50
79
 
51
80
  /**
52
81
  * The effective bounds a size is clamped to: the policy min floored by the
@@ -69,18 +98,44 @@ export const effectiveBounds = (policy, contentMin) => {
69
98
  * an axis nobody gave a minimum must not collapse to nothing.
70
99
  */
71
100
  const hasFloor = (policyMin, contentMin) => policyMin !== undefined || contentMin > 0;
101
+ /**
102
+ * Which way each axis grows for a handle: +1 when the handle is on the far
103
+ * edge (right/bottom), −1 when it is on the near edge (left/top), 0 when the
104
+ * handle does not touch that axis at all.
105
+ */
106
+ export const anchorSigns = anchor => ({
107
+ sx: anchor.includes("left") ? -1 : anchor.includes("right") ? 1 : 0,
108
+ sy: anchor.includes("top") ? -1 : anchor.includes("bottom") ? 1 : 0
109
+ });
72
110
 
73
111
  /**
74
- * Apply a delta to the start size under the policy — the single path for both
75
- * inputs.
112
+ * Snap the MOVING edge of one axis to the grid and return the length that
113
+ * leaves the anchored edge exactly where it was. A far-edge handle snaps
114
+ * `origin + length`; a near-edge handle snaps `origin + startLength − length`.
115
+ * With no step this is the identity.
116
+ */
117
+ const snapMovingEdge = (origin, startLength, length, sign, step) => {
118
+ if (!step || sign === 0) return length;
119
+ return sign > 0 ? snap(origin + length, step) - origin : origin + startLength - snap(origin + startLength - length, step);
120
+ };
121
+
122
+ /** The position that keeps the anchored edge of one axis in place. */
123
+ const anchoredOrigin = (origin, startLength, length, sign) => sign < 0 ? origin + startLength - length : origin;
124
+
125
+ /**
126
+ * Apply a delta to the start box under the policy — the single path for both
127
+ * inputs and for every handle.
76
128
  *
77
129
  * `constrain` is the transient Shift-to-constrain lock: a free-form policy
78
130
  * behaves proportionally for that one gesture; a proportional policy is already
79
131
  * locked and ignores it. `axis: "width"` drops the gesture's vertical component;
80
132
  * the height then holds still in free-form mode, and still follows the ratio in
81
- * proportional mode (that is what proportional means).
133
+ * proportional mode (that is what proportional means). `anchor` is the handle
134
+ * being dragged: the opposite edge or corner is held, so the returned position
135
+ * moves only when a near-edge handle (left/top) grew or shrank the box.
82
136
  */
83
137
  export const applyResize = function (start, delta, policy, opts) {
138
+ var _opts$anchor;
84
139
  if (opts === void 0) {
85
140
  opts = {};
86
141
  }
@@ -90,8 +145,12 @@ export const applyResize = function (start, delta, policy, opts) {
90
145
  wMax = _effectiveBounds.wMax,
91
146
  hMax = _effectiveBounds.hMax;
92
147
  const widthOnly = opts.axis === "width";
93
- const dx = delta.dx;
94
- const dy = widthOnly ? 0 : delta.dy;
148
+ const _anchorSigns = anchorSigns((_opts$anchor = opts.anchor) != null ? _opts$anchor : DEFAULT_RESIZE_ANCHOR),
149
+ sx = _anchorSigns.sx,
150
+ anchorSy = _anchorSigns.sy;
151
+ const sy = widthOnly ? 0 : anchorSy;
152
+ const dx = sx * delta.dx;
153
+ const dy = sy * delta.dy;
95
154
 
96
155
  // A ratio needs two non-zero sides to be a ratio at all; a width-only card
97
156
  // parks a placeholder height, so fall back to free-form rather than dividing
@@ -101,69 +160,95 @@ export const applyResize = function (start, delta, policy, opts) {
101
160
  let h;
102
161
  if (proportional) {
103
162
  // one scale drives both axes; the corner's dominant direction wins, so a
104
- // vertical drag is as effective as a horizontal one
105
- const sW = (start.w + dx) / start.w;
106
- const sH = (start.h + dy) / start.h;
107
- let scale = Math.abs(sW - 1) >= Math.abs(sH - 1) ? sW : sH;
108
-
109
- // step: proportion wins over the grid. Snap through the SCALE (driven off
110
- // the width edge) so both axes move together and the ratio survives; the
111
- // grid yields whenever honouring it would cost the ratio.
163
+ // vertical drag is as effective as a horizontal one. An edge handle has
164
+ // only its own axis to drive with.
165
+ const sW = sx === 0 ? 1 : (start.w + dx) / start.w;
166
+ const sH = sy === 0 ? 1 : (start.h + dy) / start.h;
167
+ const drivenByWidth = sx !== 0 && (sy === 0 || Math.abs(sW - 1) >= Math.abs(sH - 1));
168
+ let scale = drivenByWidth ? sW : sH;
169
+
170
+ // step: proportion wins over the grid. Snap through the SCALE, driven off
171
+ // the moving edge of the driving axis, so both axes move together and the
172
+ // ratio survives; the grid yields whenever honouring it would cost the
173
+ // ratio.
112
174
  if (policy.step) {
113
- scale = snap(start.w * scale, policy.step) / start.w;
175
+ scale = drivenByWidth ? snapMovingEdge(start.x, start.w, start.w * scale, sx, policy.step) / start.w : snapMovingEdge(start.y, start.h, start.h * scale, sy, policy.step) / start.h;
114
176
  }
115
177
 
116
178
  // Then clamp the scale so both axes stay in bounds (the binding constraint):
117
179
  // the ratio can never break at a bound — whichever edge is limiting stops
118
- // both. The clamp comes last on purpose: a bound is a hard stop, so the card
119
- // sits exactly on it rather than at the nearest grid line inside it.
180
+ // both. The clamp comes last on purpose: a bound is a hard stop, so the
181
+ // element sits exactly on it rather than at the nearest grid line inside it.
120
182
  const scaleMin = Math.max(wMin / start.w, hMin / start.h);
121
183
  const scaleMax = Math.min(wMax / start.w, hMax / start.h);
122
184
  scale = clamp(scale, scaleMin, Math.max(scaleMin, scaleMax));
123
185
  w = start.w * scale;
124
186
  h = start.h * scale;
125
187
  } else {
126
- w = clamp(snap(start.w + dx, policy.step), wMin, wMax);
127
- h = widthOnly ? start.h : clamp(snap(start.h + dy, policy.step), hMin, hMax);
188
+ // An axis the handle does not touch holds its start value exactly — it is
189
+ // neither snapped nor clamped, because nothing about it changed.
190
+ w = sx === 0 ? start.w : clamp(snapMovingEdge(start.x, start.w, start.w + dx, sx, policy.step), wMin, wMax);
191
+ h = sy === 0 ? start.h : clamp(snapMovingEdge(start.y, start.h, start.h + dy, sy, policy.step), hMin, hMax);
128
192
  }
193
+
194
+ // Round the size first and derive the position from the rounded size, so
195
+ // the anchored edge lands on exactly the coordinate it started at.
196
+ w = Math.round(w);
197
+ h = Math.round(h);
129
198
  return {
130
- w: Math.round(w),
131
- h: Math.round(h)
199
+ w,
200
+ h,
201
+ x: anchoredOrigin(start.x, start.w, w, sx),
202
+ y: anchoredOrigin(start.y, start.h, h, sy)
132
203
  };
133
204
  };
134
205
 
135
206
  /**
136
- * Translate a resize key into the next size, reusing `applyResize` so the
137
- * keyboard clamps exactly like the pointer. Arrows nudge by the step (Shift ×4);
138
- * Home/End jump to the min/max of the allowed range, leaving any axis without
139
- * that bound where it is. Returns null for a key the handle does not own, and
140
- * for a vertical key on a width-only card.
207
+ * Translate a resize key into the next box, reusing `applyResize` so the
208
+ * keyboard clamps exactly like the pointer. Arrows move the HANDLE by the step
209
+ * (Shift ×4) — so on a left handle ArrowLeft grows the element and ArrowRight
210
+ * shrinks it — and Home/End jump the handle to the min/max of the allowed
211
+ * range, leaving any axis without that bound where it is. Returns null for a
212
+ * key the handle does not own: a key on an axis the handle does not touch, or a
213
+ * vertical key on a width-only card.
141
214
  */
142
- export const keyboardResize = function (key, size, policy, contentMin, opts) {
215
+ export const keyboardResize = function (key, box, policy, contentMin, opts) {
216
+ var _opts$anchor2;
143
217
  if (opts === void 0) {
144
218
  opts = {};
145
219
  }
146
220
  const widthOnly = opts.axis === "width";
147
- if (widthOnly && (key === "ArrowUp" || key === "ArrowDown")) return null;
221
+ const anchor = (_opts$anchor2 = opts.anchor) != null ? _opts$anchor2 : DEFAULT_RESIZE_ANCHOR;
222
+ const _anchorSigns2 = anchorSigns(anchor),
223
+ sx = _anchorSigns2.sx,
224
+ anchorSy = _anchorSigns2.sy;
225
+ const sy = widthOnly ? 0 : anchorSy;
226
+ const horizontalKey = key === "ArrowLeft" || key === "ArrowRight";
227
+ const verticalKey = key === "ArrowUp" || key === "ArrowDown";
228
+ if (horizontalKey && sx === 0 || verticalKey && sy === 0) return null;
148
229
  const base = policy.step && policy.step > 0 ? policy.step : DEFAULT_KEYBOARD_STEP;
149
230
  const step = base * (opts.shiftKey ? SHIFT_STEP_MULTIPLIER : 1);
150
- const start = makeStart(size, contentMin);
231
+ const start = makeStart(box, contentMin);
151
232
  const b = effectiveBounds(policy, contentMin);
152
- const apply = delta => applyResize(start, delta, policy, {
153
- axis: opts.axis
154
- });
233
+ const resizeOpts = {
234
+ axis: opts.axis,
235
+ anchor
236
+ };
237
+ const apply = delta => applyResize(start, delta, policy, resizeOpts);
155
238
 
156
239
  /**
157
240
  * Home and End are absolute jumps to a bound, not nudges, so they ignore the
158
241
  * grid: landing 4px off the minimum because that is where the nearest grid
159
242
  * line fell would mean the keyboard could never reach the bound the pointer
160
- * stops at.
243
+ * stops at. The jump is expressed as handle travel, so a near-edge handle
244
+ * moves the opposite way to reach the same size.
161
245
  */
162
- const jump = delta => applyResize(start, delta, _extends({}, policy, {
246
+ const jump = (growW, growH) => applyResize(start, {
247
+ dx: sx * growW,
248
+ dy: sy * growH
249
+ }, _extends({}, policy, {
163
250
  step: 0
164
- }), {
165
- axis: opts.axis
166
- });
251
+ }), resizeOpts);
167
252
  switch (key) {
168
253
  case "ArrowRight":
169
254
  return apply({
@@ -187,16 +272,10 @@ export const keyboardResize = function (key, size, policy, contentMin, opts) {
187
272
  });
188
273
  case "Home":
189
274
  // jump to the min corner; an axis with no floor of its own stays put
190
- return jump({
191
- dx: hasFloor(policy.minW, contentMin.w) ? b.wMin - size.w : 0,
192
- dy: !widthOnly && hasFloor(policy.minH, contentMin.h) ? b.hMin - size.h : 0
193
- });
275
+ return jump(sx !== 0 && hasFloor(policy.minW, contentMin.w) ? b.wMin - box.w : 0, sy !== 0 && hasFloor(policy.minH, contentMin.h) ? b.hMin - box.h : 0);
194
276
  case "End":
195
277
  // jump to the max corner; an unbounded axis simply doesn't move
196
- return jump({
197
- dx: Number.isFinite(b.wMax) ? b.wMax - size.w : 0,
198
- dy: !widthOnly && Number.isFinite(b.hMax) ? b.hMax - size.h : 0
199
- });
278
+ return jump(sx !== 0 && Number.isFinite(b.wMax) ? b.wMax - box.w : 0, sy !== 0 && Number.isFinite(b.hMax) ? b.hMax - box.h : 0);
200
279
  default:
201
280
  return null;
202
281
  }
@@ -1 +1 @@
1
- {"version":3,"file":"resizePolicy.js","names":["DEFAULT_KEYBOARD_STEP","SHIFT_STEP_MULTIPLIER","RESIZE_KEYS","isResizeKey","key","includes","clamp","v","lo","hi","Math","min","Number","POSITIVE_INFINITY","max","snap","step","round","makeStart","size","contentMin","w","h","effectiveBounds","policy","_policy$minW","_policy$minH","_policy$maxW","_policy$maxH","wMin","minW","hMin","minH","wMax","maxW","hMax","maxH","hasFloor","policyMin","undefined","applyResize","start","delta","opts","_effectiveBounds","widthOnly","axis","dx","dy","proportional","constrain","sW","sH","scale","abs","scaleMin","scaleMax","keyboardResize","base","shiftKey","b","apply","jump","_extends","isFinite","measurePercent","_effectiveBounds2"],"sources":["../../../../src/components/StackedCard/resizePolicy.ts"],"sourcesContent":["/**\n * StackedCard resize policy — pure math.\n *\n * The card reports intent; the HOST applies a resize policy (spec §7). This\n * module is that policy, packaged as pure functions so the SAME code path\n * serves the pointer drag and the keyboard resize. Nothing here touches the\n * DOM, React or the card's content: it takes a start size, a delta and a\n * policy, and returns a clamped size. `useStackedCardResize` wires events to\n * it; the card's intrinsic content minimum is measured by the host and passed\n * in as `contentMin`, so this module knows nothing about heroes or footers.\n *\n * The policy has four parts:\n * - bounds — optional min/max per axis; unset means unbounded.\n * - proportional — lock the aspect ratio captured at the start of the gesture;\n * the scale is clamped by the BINDING axis so the ratio never\n * distorts at a bound.\n * - step — optional grid snap; proportion wins over the grid.\n * - content min — the effective min is max(policyMin, contentMin) per axis,\n * so a card can never be crushed below what its content needs.\n */\n\nexport interface StackedCardSize {\n w: number;\n h: number;\n}\n\n/** The card's intrinsic minimum, measured from its real content. */\nexport interface StackedCardContentMin {\n w: number;\n h: number;\n}\n\nexport interface StackedCardResizePolicy {\n minW?: number;\n maxW?: number;\n minH?: number;\n maxH?: number;\n /** Lock the aspect ratio for the whole gesture. */\n proportional: boolean;\n /** Grid snap increment in px; omitted / 0 means continuous. */\n step?: number;\n}\n\n/** The size captured at the start of a gesture (pointer down or a key press). */\nexport interface StackedCardResizeStart {\n w: number;\n h: number;\n contentMin: StackedCardContentMin;\n}\n\nexport interface StackedCardResizeDelta {\n dx: number;\n dy: number;\n}\n\nexport interface StackedCardResizeBounds {\n wMin: number;\n wMax: number;\n hMin: number;\n hMax: number;\n}\n\n/**\n * `width` locks the vertical axis: an auto-height card takes a width and lets\n * its rows set the height, so the gesture's vertical component is ignored.\n */\nexport type StackedCardResizeAxis = \"both\" | \"width\";\n\n/** Which input drove a resize event. Hosts log undo entries per source. */\nexport type StackedCardResizeSource = \"pointer\" | \"keyboard\";\n\n/** Keyboard resize nudges by the policy step, or this when no step is set. */\nexport const DEFAULT_KEYBOARD_STEP = 8;\n\n/** Shift + arrow resizes by a larger increment (the familiar coarse nudge). */\nexport const SHIFT_STEP_MULTIPLIER = 4;\n\n/** Keys the separator handles; everything else falls through to the browser. */\nexport const RESIZE_KEYS: ReadonlyArray<string> = [\n \"ArrowLeft\",\n \"ArrowRight\",\n \"ArrowUp\",\n \"ArrowDown\",\n \"Home\",\n \"End\",\n];\n\nexport const isResizeKey = (key: string): boolean => RESIZE_KEYS.includes(key);\n\nexport const clamp = (v: number, lo: number, hi?: number): number =>\n Math.min(hi ?? Number.POSITIVE_INFINITY, Math.max(lo, v));\n\nexport const snap = (v: number, step?: number): number =>\n step && step > 0 ? Math.round(v / step) * step : v;\n\nexport const makeStart = (\n size: StackedCardSize,\n contentMin: StackedCardContentMin\n): StackedCardResizeStart => ({\n w: size.w,\n h: size.h,\n contentMin,\n});\n\n/**\n * The effective bounds a size is clamped to: the policy min floored by the\n * content min, and the policy max (unbounded when unset). Independent of any\n * live gesture, so a host can also use it for the aria value and Home/End.\n */\nexport const effectiveBounds = (\n policy: StackedCardResizePolicy,\n contentMin: StackedCardContentMin\n): StackedCardResizeBounds => ({\n wMin: Math.max(policy.minW ?? 0, contentMin.w),\n hMin: Math.max(policy.minH ?? 0, contentMin.h),\n wMax: policy.maxW ?? Number.POSITIVE_INFINITY,\n hMax: policy.maxH ?? Number.POSITIVE_INFINITY,\n});\n\n/**\n * Whether an axis has a floor anyone asked for. `effectiveBounds` reports 0 for\n * an unset minimum — correct as a clamp, but not something Home should jump to:\n * an axis nobody gave a minimum must not collapse to nothing.\n */\nconst hasFloor = (policyMin: number | undefined, contentMin: number): boolean =>\n policyMin !== undefined || contentMin > 0;\n\n/**\n * Apply a delta to the start size under the policy — the single path for both\n * inputs.\n *\n * `constrain` is the transient Shift-to-constrain lock: a free-form policy\n * behaves proportionally for that one gesture; a proportional policy is already\n * locked and ignores it. `axis: \"width\"` drops the gesture's vertical component;\n * the height then holds still in free-form mode, and still follows the ratio in\n * proportional mode (that is what proportional means).\n */\nexport const applyResize = (\n start: StackedCardResizeStart,\n delta: StackedCardResizeDelta,\n policy: StackedCardResizePolicy,\n opts: { constrain?: boolean; axis?: StackedCardResizeAxis } = {}\n): StackedCardSize => {\n const { wMin, hMin, wMax, hMax } = effectiveBounds(policy, start.contentMin);\n const widthOnly = opts.axis === \"width\";\n const dx = delta.dx;\n const dy = widthOnly ? 0 : delta.dy;\n\n // A ratio needs two non-zero sides to be a ratio at all; a width-only card\n // parks a placeholder height, so fall back to free-form rather than dividing\n // by zero.\n const proportional =\n (policy.proportional || opts.constrain === true) &&\n start.w > 0 &&\n start.h > 0;\n\n let w: number;\n let h: number;\n\n if (proportional) {\n // one scale drives both axes; the corner's dominant direction wins, so a\n // vertical drag is as effective as a horizontal one\n const sW = (start.w + dx) / start.w;\n const sH = (start.h + dy) / start.h;\n let scale = Math.abs(sW - 1) >= Math.abs(sH - 1) ? sW : sH;\n\n // step: proportion wins over the grid. Snap through the SCALE (driven off\n // the width edge) so both axes move together and the ratio survives; the\n // grid yields whenever honouring it would cost the ratio.\n if (policy.step) {\n scale = snap(start.w * scale, policy.step) / start.w;\n }\n\n // Then clamp the scale so both axes stay in bounds (the binding constraint):\n // the ratio can never break at a bound — whichever edge is limiting stops\n // both. The clamp comes last on purpose: a bound is a hard stop, so the card\n // sits exactly on it rather than at the nearest grid line inside it.\n const scaleMin = Math.max(wMin / start.w, hMin / start.h);\n const scaleMax = Math.min(wMax / start.w, hMax / start.h);\n scale = clamp(scale, scaleMin, Math.max(scaleMin, scaleMax));\n\n w = start.w * scale;\n h = start.h * scale;\n } else {\n w = clamp(snap(start.w + dx, policy.step), wMin, wMax);\n h = widthOnly\n ? start.h\n : clamp(snap(start.h + dy, policy.step), hMin, hMax);\n }\n\n return { w: Math.round(w), h: Math.round(h) };\n};\n\n/**\n * Translate a resize key into the next size, reusing `applyResize` so the\n * keyboard clamps exactly like the pointer. Arrows nudge by the step (Shift ×4);\n * Home/End jump to the min/max of the allowed range, leaving any axis without\n * that bound where it is. Returns null for a key the handle does not own, and\n * for a vertical key on a width-only card.\n */\nexport const keyboardResize = (\n key: string,\n size: StackedCardSize,\n policy: StackedCardResizePolicy,\n contentMin: StackedCardContentMin,\n opts: { shiftKey?: boolean; axis?: StackedCardResizeAxis } = {}\n): StackedCardSize | null => {\n const widthOnly = opts.axis === \"width\";\n if (widthOnly && (key === \"ArrowUp\" || key === \"ArrowDown\")) return null;\n\n const base =\n policy.step && policy.step > 0 ? policy.step : DEFAULT_KEYBOARD_STEP;\n const step = base * (opts.shiftKey ? SHIFT_STEP_MULTIPLIER : 1);\n const start = makeStart(size, contentMin);\n const b = effectiveBounds(policy, contentMin);\n const apply = (delta: StackedCardResizeDelta): StackedCardSize =>\n applyResize(start, delta, policy, { axis: opts.axis });\n\n /**\n * Home and End are absolute jumps to a bound, not nudges, so they ignore the\n * grid: landing 4px off the minimum because that is where the nearest grid\n * line fell would mean the keyboard could never reach the bound the pointer\n * stops at.\n */\n const jump = (delta: StackedCardResizeDelta): StackedCardSize =>\n applyResize(start, delta, { ...policy, step: 0 }, { axis: opts.axis });\n\n switch (key) {\n case \"ArrowRight\":\n return apply({ dx: step, dy: 0 });\n case \"ArrowLeft\":\n return apply({ dx: -step, dy: 0 });\n case \"ArrowDown\":\n return apply({ dx: 0, dy: step });\n case \"ArrowUp\":\n return apply({ dx: 0, dy: -step });\n case \"Home\":\n // jump to the min corner; an axis with no floor of its own stays put\n return jump({\n dx: hasFloor(policy.minW, contentMin.w) ? b.wMin - size.w : 0,\n dy:\n !widthOnly && hasFloor(policy.minH, contentMin.h)\n ? b.hMin - size.h\n : 0,\n });\n case \"End\":\n // jump to the max corner; an unbounded axis simply doesn't move\n return jump({\n dx: Number.isFinite(b.wMax) ? b.wMax - size.w : 0,\n dy: !widthOnly && Number.isFinite(b.hMax) ? b.hMax - size.h : 0,\n });\n default:\n return null;\n }\n};\n\n/**\n * The handle's `aria-valuenow`: the current size as a percent (0–100) of its\n * allowed range. The corner resizes both axes, but the value must be a single\n * number, so it reports the WIDTH axis — the one axis the fixed-box and the\n * width-only cards share. Returns 0 when the range isn't finite (no max bound).\n */\nexport const measurePercent = (\n size: StackedCardSize,\n policy: StackedCardResizePolicy,\n contentMin: StackedCardContentMin\n): number => {\n const { wMin, wMax } = effectiveBounds(policy, contentMin);\n if (!Number.isFinite(wMax) || wMax <= wMin) return 0;\n return Math.round(clamp(((size.w - wMin) / (wMax - wMin)) * 100, 0, 100));\n};\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;;AAiBA;;AAmBA;AACA;AACA;AACA;;AAGA;;AAGA;AACA,OAAO,MAAMA,qBAAqB,GAAG,CAAC;;AAEtC;AACA,OAAO,MAAMC,qBAAqB,GAAG,CAAC;;AAEtC;AACA,OAAO,MAAMC,WAAkC,GAAG,CAChD,WAAW,EACX,YAAY,EACZ,SAAS,EACT,WAAW,EACX,MAAM,EACN,KAAK,CACN;AAED,OAAO,MAAMC,WAAW,GAAIC,GAAW,IAAcF,WAAW,CAACG,QAAQ,CAACD,GAAG,CAAC;AAE9E,OAAO,MAAME,KAAK,GAAGA,CAACC,CAAS,EAAEC,EAAU,EAAEC,EAAW,KACtDC,IAAI,CAACC,GAAG,CAACF,EAAE,WAAFA,EAAE,GAAIG,MAAM,CAACC,iBAAiB,EAAEH,IAAI,CAACI,GAAG,CAACN,EAAE,EAAED,CAAC,CAAC,CAAC;AAE3D,OAAO,MAAMQ,IAAI,GAAGA,CAACR,CAAS,EAAES,IAAa,KAC3CA,IAAI,IAAIA,IAAI,GAAG,CAAC,GAAGN,IAAI,CAACO,KAAK,CAACV,CAAC,GAAGS,IAAI,CAAC,GAAGA,IAAI,GAAG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,KAAK,CAAE,CAACa,IAAI,CAACE,CAAC,GAAGQ,IAAI,KAAKI,IAAI,GAAGJ,IAAI,CAAC,GAAI,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;AAC3E,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"resizePolicy.js","names":["RESIZE_ANCHORS","DEFAULT_RESIZE_ANCHOR","DEFAULT_KEYBOARD_STEP","SHIFT_STEP_MULTIPLIER","RESIZE_KEYS","isResizeKey","key","includes","clamp","v","lo","hi","Math","min","Number","POSITIVE_INFINITY","max","snap","step","round","makeStart","box","contentMin","_box$x","_box$y","w","h","x","y","effectiveBounds","policy","_policy$minW","_policy$minH","_policy$maxW","_policy$maxH","wMin","minW","hMin","minH","wMax","maxW","hMax","maxH","hasFloor","policyMin","undefined","anchorSigns","anchor","sx","sy","snapMovingEdge","origin","startLength","length","sign","anchoredOrigin","applyResize","start","delta","opts","_opts$anchor","_effectiveBounds","widthOnly","axis","_anchorSigns","anchorSy","dx","dy","proportional","constrain","sW","sH","drivenByWidth","abs","scale","scaleMin","scaleMax","keyboardResize","_opts$anchor2","_anchorSigns2","horizontalKey","verticalKey","base","shiftKey","b","resizeOpts","apply","jump","growW","growH","_extends","isFinite","measurePercent","size","_effectiveBounds2"],"sources":["../../../../src/components/StackedCard/resizePolicy.ts"],"sourcesContent":["/**\n * Resize policy — pure math, shared by every resizable element.\n *\n * The element reports intent; the HOST applies a resize policy (StackedCard\n * spec §7). This module is that policy, packaged as pure functions so the SAME\n * code path serves the pointer drag and the keyboard resize, a card's single\n * bottom-right grip and a shape's eight handles. Nothing here touches the DOM,\n * React or the element's content: it takes a start box, a delta, a policy and\n * the handle being dragged, and returns a clamped box — size AND position.\n * `useStackedCardResize` wires events to it; an element's intrinsic content\n * minimum is measured by the host and passed in as `contentMin`, so this module\n * knows nothing about heroes or footers.\n *\n * The policy has four parts:\n * - bounds — optional min/max per axis; unset means unbounded.\n * - proportional — lock the aspect ratio captured at the start of the gesture;\n * the scale is clamped by the BINDING axis so the ratio never\n * distorts at a bound.\n * - step — optional grid snap; proportion wins over the grid.\n * - content min — the effective min is max(policyMin, contentMin) per axis,\n * so an element can never be crushed below what its content\n * needs.\n *\n * The anchor is the handle being dragged. The edge or corner OPPOSITE to it\n * never moves — not while the pointer travels, and not when a bound stops the\n * resize — which is what makes a resize feel like a resize rather than a nudge.\n * A `left` handle moves the position by exactly the amount the width grew; a\n * `right` handle leaves it alone. An edge handle touches one axis only.\n */\n\nexport interface ResizeSize {\n w: number;\n h: number;\n}\n\nexport interface ResizePosition {\n x: number;\n y: number;\n}\n\n/** A resized element: its size and where its top-left corner now sits. */\nexport interface ResizeBox extends ResizeSize, ResizePosition {}\n\n/** The element's intrinsic minimum, measured from its real content. */\nexport interface ResizeContentMin {\n w: number;\n h: number;\n}\n\nexport interface ResizePolicy {\n minW?: number;\n maxW?: number;\n minH?: number;\n maxH?: number;\n /** Lock the aspect ratio for the whole gesture. */\n proportional: boolean;\n /** Grid snap increment in px; omitted / 0 means continuous. */\n step?: number;\n}\n\n/**\n * The handle being dragged, named after the edge or corner it sits on. The\n * opposite edge or corner is held in place.\n */\nexport type ResizeAnchor =\n | \"top-left\"\n | \"top\"\n | \"top-right\"\n | \"right\"\n | \"bottom-right\"\n | \"bottom\"\n | \"bottom-left\"\n | \"left\";\n\nexport const RESIZE_ANCHORS: ReadonlyArray<ResizeAnchor> = [\n \"top-left\",\n \"top\",\n \"top-right\",\n \"right\",\n \"bottom-right\",\n \"bottom\",\n \"bottom-left\",\n \"left\",\n];\n\n/** A card's single grip: the top-left corner stays put. */\nexport const DEFAULT_RESIZE_ANCHOR: ResizeAnchor = \"bottom-right\";\n\n/**\n * The box captured at the start of a gesture (pointer down or a key press).\n * A host that only tracks a size leaves the position at the origin.\n */\nexport interface ResizeStart extends ResizeBox {\n contentMin: ResizeContentMin;\n}\n\nexport interface ResizeDelta {\n dx: number;\n dy: number;\n}\n\nexport interface ResizeBounds {\n wMin: number;\n wMax: number;\n hMin: number;\n hMax: number;\n}\n\n/**\n * `width` locks the vertical axis: an auto-height card takes a width and lets\n * its rows set the height, so the gesture's vertical component is ignored.\n */\nexport type ResizeAxis = \"both\" | \"width\";\n\n/** Which input drove a resize event. Hosts log undo entries per source. */\nexport type ResizeSource = \"pointer\" | \"keyboard\";\n\nexport interface ResizeOptions {\n /** Shift-to-constrain: one gesture behaves proportionally. */\n constrain?: boolean;\n axis?: ResizeAxis;\n /** The handle being dragged. Defaults to a card's bottom-right grip. */\n anchor?: ResizeAnchor;\n}\n\n/** Keyboard resize nudges by the policy step, or this when no step is set. */\nexport const DEFAULT_KEYBOARD_STEP = 8;\n\n/** Shift + arrow resizes by a larger increment (the familiar coarse nudge). */\nexport const SHIFT_STEP_MULTIPLIER = 4;\n\n/** Keys the separator handles; everything else falls through to the browser. */\nexport const RESIZE_KEYS: ReadonlyArray<string> = [\n \"ArrowLeft\",\n \"ArrowRight\",\n \"ArrowUp\",\n \"ArrowDown\",\n \"Home\",\n \"End\",\n];\n\nexport const isResizeKey = (key: string): boolean => RESIZE_KEYS.includes(key);\n\nexport const clamp = (v: number, lo: number, hi?: number): number =>\n Math.min(hi ?? Number.POSITIVE_INFINITY, Math.max(lo, v));\n\nexport const snap = (v: number, step?: number): number =>\n step && step > 0 ? Math.round(v / step) * step : v;\n\nexport const makeStart = (\n box: ResizeSize & Partial<ResizePosition>,\n contentMin: ResizeContentMin\n): ResizeStart => ({\n w: box.w,\n h: box.h,\n x: box.x ?? 0,\n y: box.y ?? 0,\n contentMin,\n});\n\n/**\n * The effective bounds a size is clamped to: the policy min floored by the\n * content min, and the policy max (unbounded when unset). Independent of any\n * live gesture, so a host can also use it for the aria value and Home/End.\n */\nexport const effectiveBounds = (\n policy: ResizePolicy,\n contentMin: ResizeContentMin\n): ResizeBounds => ({\n wMin: Math.max(policy.minW ?? 0, contentMin.w),\n hMin: Math.max(policy.minH ?? 0, contentMin.h),\n wMax: policy.maxW ?? Number.POSITIVE_INFINITY,\n hMax: policy.maxH ?? Number.POSITIVE_INFINITY,\n});\n\n/**\n * Whether an axis has a floor anyone asked for. `effectiveBounds` reports 0 for\n * an unset minimum — correct as a clamp, but not something Home should jump to:\n * an axis nobody gave a minimum must not collapse to nothing.\n */\nconst hasFloor = (policyMin: number | undefined, contentMin: number): boolean =>\n policyMin !== undefined || contentMin > 0;\n\ntype AxisSign = -1 | 0 | 1;\n\n/**\n * Which way each axis grows for a handle: +1 when the handle is on the far\n * edge (right/bottom), −1 when it is on the near edge (left/top), 0 when the\n * handle does not touch that axis at all.\n */\nexport const anchorSigns = (\n anchor: ResizeAnchor\n): { sx: AxisSign; sy: AxisSign } => ({\n sx: anchor.includes(\"left\") ? -1 : anchor.includes(\"right\") ? 1 : 0,\n sy: anchor.includes(\"top\") ? -1 : anchor.includes(\"bottom\") ? 1 : 0,\n});\n\n/**\n * Snap the MOVING edge of one axis to the grid and return the length that\n * leaves the anchored edge exactly where it was. A far-edge handle snaps\n * `origin + length`; a near-edge handle snaps `origin + startLength − length`.\n * With no step this is the identity.\n */\nconst snapMovingEdge = (\n origin: number,\n startLength: number,\n length: number,\n sign: AxisSign,\n step?: number\n): number => {\n if (!step || sign === 0) return length;\n return sign > 0\n ? snap(origin + length, step) - origin\n : origin + startLength - snap(origin + startLength - length, step);\n};\n\n/** The position that keeps the anchored edge of one axis in place. */\nconst anchoredOrigin = (\n origin: number,\n startLength: number,\n length: number,\n sign: AxisSign\n): number => (sign < 0 ? origin + startLength - length : origin);\n\n/**\n * Apply a delta to the start box under the policy — the single path for both\n * inputs and for every handle.\n *\n * `constrain` is the transient Shift-to-constrain lock: a free-form policy\n * behaves proportionally for that one gesture; a proportional policy is already\n * locked and ignores it. `axis: \"width\"` drops the gesture's vertical component;\n * the height then holds still in free-form mode, and still follows the ratio in\n * proportional mode (that is what proportional means). `anchor` is the handle\n * being dragged: the opposite edge or corner is held, so the returned position\n * moves only when a near-edge handle (left/top) grew or shrank the box.\n */\nexport const applyResize = (\n start: ResizeStart,\n delta: ResizeDelta,\n policy: ResizePolicy,\n opts: ResizeOptions = {}\n): ResizeBox => {\n const { wMin, hMin, wMax, hMax } = effectiveBounds(policy, start.contentMin);\n const widthOnly = opts.axis === \"width\";\n const { sx, sy: anchorSy } = anchorSigns(\n opts.anchor ?? DEFAULT_RESIZE_ANCHOR\n );\n const sy: AxisSign = widthOnly ? 0 : anchorSy;\n const dx = sx * delta.dx;\n const dy = sy * delta.dy;\n\n // A ratio needs two non-zero sides to be a ratio at all; a width-only card\n // parks a placeholder height, so fall back to free-form rather than dividing\n // by zero.\n const proportional =\n (policy.proportional || opts.constrain === true) &&\n start.w > 0 &&\n start.h > 0;\n\n let w: number;\n let h: number;\n\n if (proportional) {\n // one scale drives both axes; the corner's dominant direction wins, so a\n // vertical drag is as effective as a horizontal one. An edge handle has\n // only its own axis to drive with.\n const sW = sx === 0 ? 1 : (start.w + dx) / start.w;\n const sH = sy === 0 ? 1 : (start.h + dy) / start.h;\n const drivenByWidth =\n sx !== 0 && (sy === 0 || Math.abs(sW - 1) >= Math.abs(sH - 1));\n let scale = drivenByWidth ? sW : sH;\n\n // step: proportion wins over the grid. Snap through the SCALE, driven off\n // the moving edge of the driving axis, so both axes move together and the\n // ratio survives; the grid yields whenever honouring it would cost the\n // ratio.\n if (policy.step) {\n scale = drivenByWidth\n ? snapMovingEdge(start.x, start.w, start.w * scale, sx, policy.step) /\n start.w\n : snapMovingEdge(start.y, start.h, start.h * scale, sy, policy.step) /\n start.h;\n }\n\n // Then clamp the scale so both axes stay in bounds (the binding constraint):\n // the ratio can never break at a bound — whichever edge is limiting stops\n // both. The clamp comes last on purpose: a bound is a hard stop, so the\n // element sits exactly on it rather than at the nearest grid line inside it.\n const scaleMin = Math.max(wMin / start.w, hMin / start.h);\n const scaleMax = Math.min(wMax / start.w, hMax / start.h);\n scale = clamp(scale, scaleMin, Math.max(scaleMin, scaleMax));\n\n w = start.w * scale;\n h = start.h * scale;\n } else {\n // An axis the handle does not touch holds its start value exactly — it is\n // neither snapped nor clamped, because nothing about it changed.\n w =\n sx === 0\n ? start.w\n : clamp(\n snapMovingEdge(start.x, start.w, start.w + dx, sx, policy.step),\n wMin,\n wMax\n );\n h =\n sy === 0\n ? start.h\n : clamp(\n snapMovingEdge(start.y, start.h, start.h + dy, sy, policy.step),\n hMin,\n hMax\n );\n }\n\n // Round the size first and derive the position from the rounded size, so\n // the anchored edge lands on exactly the coordinate it started at.\n w = Math.round(w);\n h = Math.round(h);\n\n return {\n w,\n h,\n x: anchoredOrigin(start.x, start.w, w, sx),\n y: anchoredOrigin(start.y, start.h, h, sy),\n };\n};\n\n/**\n * Translate a resize key into the next box, reusing `applyResize` so the\n * keyboard clamps exactly like the pointer. Arrows move the HANDLE by the step\n * (Shift ×4) — so on a left handle ArrowLeft grows the element and ArrowRight\n * shrinks it — and Home/End jump the handle to the min/max of the allowed\n * range, leaving any axis without that bound where it is. Returns null for a\n * key the handle does not own: a key on an axis the handle does not touch, or a\n * vertical key on a width-only card.\n */\nexport const keyboardResize = (\n key: string,\n box: ResizeSize & Partial<ResizePosition>,\n policy: ResizePolicy,\n contentMin: ResizeContentMin,\n opts: { shiftKey?: boolean; axis?: ResizeAxis; anchor?: ResizeAnchor } = {}\n): ResizeBox | null => {\n const widthOnly = opts.axis === \"width\";\n const anchor = opts.anchor ?? DEFAULT_RESIZE_ANCHOR;\n const { sx, sy: anchorSy } = anchorSigns(anchor);\n const sy: AxisSign = widthOnly ? 0 : anchorSy;\n const horizontalKey = key === \"ArrowLeft\" || key === \"ArrowRight\";\n const verticalKey = key === \"ArrowUp\" || key === \"ArrowDown\";\n if ((horizontalKey && sx === 0) || (verticalKey && sy === 0)) return null;\n\n const base =\n policy.step && policy.step > 0 ? policy.step : DEFAULT_KEYBOARD_STEP;\n const step = base * (opts.shiftKey ? SHIFT_STEP_MULTIPLIER : 1);\n const start = makeStart(box, contentMin);\n const b = effectiveBounds(policy, contentMin);\n const resizeOpts: ResizeOptions = { axis: opts.axis, anchor };\n const apply = (delta: ResizeDelta): ResizeBox =>\n applyResize(start, delta, policy, resizeOpts);\n\n /**\n * Home and End are absolute jumps to a bound, not nudges, so they ignore the\n * grid: landing 4px off the minimum because that is where the nearest grid\n * line fell would mean the keyboard could never reach the bound the pointer\n * stops at. The jump is expressed as handle travel, so a near-edge handle\n * moves the opposite way to reach the same size.\n */\n const jump = (growW: number, growH: number): ResizeBox =>\n applyResize(\n start,\n { dx: sx * growW, dy: sy * growH },\n { ...policy, step: 0 },\n resizeOpts\n );\n\n switch (key) {\n case \"ArrowRight\":\n return apply({ dx: step, dy: 0 });\n case \"ArrowLeft\":\n return apply({ dx: -step, dy: 0 });\n case \"ArrowDown\":\n return apply({ dx: 0, dy: step });\n case \"ArrowUp\":\n return apply({ dx: 0, dy: -step });\n case \"Home\":\n // jump to the min corner; an axis with no floor of its own stays put\n return jump(\n sx !== 0 && hasFloor(policy.minW, contentMin.w) ? b.wMin - box.w : 0,\n sy !== 0 && hasFloor(policy.minH, contentMin.h) ? b.hMin - box.h : 0\n );\n case \"End\":\n // jump to the max corner; an unbounded axis simply doesn't move\n return jump(\n sx !== 0 && Number.isFinite(b.wMax) ? b.wMax - box.w : 0,\n sy !== 0 && Number.isFinite(b.hMax) ? b.hMax - box.h : 0\n );\n default:\n return null;\n }\n};\n\n/**\n * The handle's `aria-valuenow`: the current size as a percent (0–100) of its\n * allowed range. The corner resizes both axes, but the value must be a single\n * number, so it reports the WIDTH axis — the one axis the fixed-box and the\n * width-only cards share. Returns 0 when the range isn't finite (no max bound).\n */\nexport const measurePercent = (\n size: ResizeSize,\n policy: ResizePolicy,\n contentMin: ResizeContentMin\n): number => {\n const { wMin, wMax } = effectiveBounds(policy, contentMin);\n if (!Number.isFinite(wMax) || wMax <= wMin) return 0;\n return Math.round(clamp(((size.w - wMin) / (wMax - wMin)) * 100, 0, 100));\n};\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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