use-scroll-animate 2.5.0 → 2.7.0

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 (79) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +2 -0
  3. package/README_ja.md +2 -0
  4. package/README_zh.md +2 -0
  5. package/dist/chunks/{base-CJ7XfidP.cjs → base-BR6fYLBA.cjs} +25 -2
  6. package/dist/chunks/base-BR6fYLBA.cjs.map +1 -0
  7. package/dist/chunks/{base-CuvCgqLy.js → base-D6zLiNGH.js} +21 -3
  8. package/dist/chunks/base-D6zLiNGH.js.map +1 -0
  9. package/dist/chunks/{spring-BKUU7-Xm.js → spring-C2Megtcf.js} +3 -3
  10. package/dist/chunks/spring-C2Megtcf.js.map +1 -0
  11. package/dist/chunks/{spring-CGO9Jd9b.cjs → spring-DyHe1Hfa.cjs} +3 -3
  12. package/dist/chunks/spring-DyHe1Hfa.cjs.map +1 -0
  13. package/dist/components/background.cjs +1 -1
  14. package/dist/components/background.d.cts +8 -0
  15. package/dist/components/background.d.ts +8 -0
  16. package/dist/components/background.js +2 -2
  17. package/dist/components/cards.cjs +2 -2
  18. package/dist/components/cards.d.cts +8 -0
  19. package/dist/components/cards.d.ts +8 -0
  20. package/dist/components/cards.js +3 -3
  21. package/dist/components/click.cjs +2 -2
  22. package/dist/components/click.d.cts +8 -0
  23. package/dist/components/click.d.ts +8 -0
  24. package/dist/components/click.js +3 -3
  25. package/dist/components/feedback.cjs +2 -2
  26. package/dist/components/feedback.css +1 -1
  27. package/dist/components/feedback.d.cts +8 -0
  28. package/dist/components/feedback.d.ts +8 -0
  29. package/dist/components/feedback.js +3 -3
  30. package/dist/components/interaction.cjs +2 -2
  31. package/dist/components/interaction.css +1 -1
  32. package/dist/components/interaction.d.cts +8 -0
  33. package/dist/components/interaction.d.ts +8 -0
  34. package/dist/components/interaction.js +3 -3
  35. package/dist/components/page.cjs +801 -0
  36. package/dist/components/page.cjs.map +1 -0
  37. package/dist/components/page.css +11 -0
  38. package/dist/components/page.d.cts +275 -0
  39. package/dist/components/page.d.ts +275 -0
  40. package/dist/components/page.js +776 -0
  41. package/dist/components/page.js.map +1 -0
  42. package/dist/components/physics.cjs +2 -2
  43. package/dist/components/physics.d.cts +8 -0
  44. package/dist/components/physics.d.ts +8 -0
  45. package/dist/components/physics.js +4 -4
  46. package/dist/components/reveal.cjs +1 -1
  47. package/dist/components/reveal.d.cts +8 -0
  48. package/dist/components/reveal.d.ts +8 -0
  49. package/dist/components/reveal.js +2 -2
  50. package/dist/components/text.cjs +1 -1
  51. package/dist/components/text.d.cts +8 -0
  52. package/dist/components/text.d.ts +8 -0
  53. package/dist/components/text.js +2 -2
  54. package/dist/components/transitions.cjs +1 -1
  55. package/dist/components/transitions.d.cts +8 -0
  56. package/dist/components/transitions.d.ts +8 -0
  57. package/dist/components/transitions.js +2 -2
  58. package/dist/components/ui.cjs +1082 -0
  59. package/dist/components/ui.cjs.map +1 -0
  60. package/dist/components/ui.css +14 -0
  61. package/dist/components/ui.d.cts +259 -0
  62. package/dist/components/ui.d.ts +259 -0
  63. package/dist/components/ui.js +1064 -0
  64. package/dist/components/ui.js.map +1 -0
  65. package/dist/components.cjs +51 -4
  66. package/dist/components.cjs.map +1 -1
  67. package/dist/components.css +23 -2
  68. package/dist/components.d.cts +452 -2
  69. package/dist/components.d.ts +452 -2
  70. package/dist/components.js +14 -3
  71. package/dist/components.js.map +1 -1
  72. package/dist/components.umd.js +2 -2
  73. package/dist/components.umd.js.map +1 -1
  74. package/docs/components.md +37 -0
  75. package/package.json +24 -2
  76. package/dist/chunks/base-CJ7XfidP.cjs.map +0 -1
  77. package/dist/chunks/base-CuvCgqLy.js.map +0 -1
  78. package/dist/chunks/spring-BKUU7-Xm.js.map +0 -1
  79. package/dist/chunks/spring-CGO9Jd9b.cjs.map +0 -1
@@ -0,0 +1,801 @@
1
+ 'use strict';
2
+
3
+ var base = require('../chunks/base-BR6fYLBA.cjs');
4
+ var spring = require('../chunks/spring-DyHe1Hfa.cjs');
5
+
6
+ var css$8 = "usa-cursor{--usa-cursor-color:var(--usa-accent,#7c5cff);--usa-cursor-size:28px;position:fixed;inset:0;pointer-events:none;z-index:2147483600;opacity:0;transition:opacity 0.2s ease;contain:strict}usa-cursor[data-active]{opacity:1}usa-cursor .usa-cursor-ring{position:absolute;left:0;top:0;width:var(--usa-cursor-size);height:var(--usa-cursor-size);margin:calc(var(--usa-cursor-size) / -2) 0 0 calc(var(--usa-cursor-size) / -2);border:1.5px solid var(--usa-cursor-color);border-radius:999px;box-sizing:border-box;transition:width 0.25s cubic-bezier(0.34,1.56,0.64,1),height 0.25s cubic-bezier(0.34,1.56,0.64,1),margin 0.25s ease,border-radius 0.25s ease,background-color 0.2s ease;will-change:transform}usa-cursor[mode=\"trail\"] .usa-cursor-ring{border:0;background:var(--usa-cursor-color);width:calc(var(--usa-cursor-size) * (0.45 - var(--i) * 0.04));height:calc(var(--usa-cursor-size) * (0.45 - var(--i) * 0.04));margin:calc(var(--usa-cursor-size) * (0.45 - var(--i) * 0.04) / -2) 0 0 calc(var(--usa-cursor-size) * (0.45 - var(--i) * 0.04) / -2);opacity:calc(1 - var(--i) * 0.11)}usa-cursor[data-hover] .usa-cursor-ring:first-child{width:calc(var(--usa-cursor-size) * 1.6);height:calc(var(--usa-cursor-size) * 1.6);margin:calc(var(--usa-cursor-size) * -0.8) 0 0 calc(var(--usa-cursor-size) * -0.8);background:color-mix(in srgb,var(--usa-cursor-color) 15%,transparent)}usa-cursor[data-snapped] .usa-cursor-ring{border-radius:12px;background:color-mix(in srgb,var(--usa-cursor-color) 12%,transparent);translate:-50% -50%;margin:0}usa-cursor[data-down] .usa-cursor-ring:first-child{scale:0.8}usa-cursor .usa-cursor-dot{position:absolute;left:-3px;top:-3px;width:6px;height:6px;border-radius:50%;background:var(--usa-cursor-color)}usa-cursor[data-snapped] .usa-cursor-dot{opacity:0}usa-cursor .usa-cursor-glow{position:absolute;left:-200px;top:-200px;width:400px;height:400px;border-radius:50%;background:radial-gradient(circle,color-mix(in srgb,var(--usa-cursor-color) 35%,transparent),transparent 65%);mix-blend-mode:screen}.usa-cursor-none,.usa-cursor-none *{cursor:none !important}@media (pointer:coarse),(prefers-reduced-motion:reduce){usa-cursor{display:none}.usa-cursor-none,.usa-cursor-none *{cursor:auto !important}}";
7
+
8
+ const CURSOR_MODES = ['dot', 'trail', 'magnetic', 'glow'];
9
+ function defineCursor(tag = 'usa-cursor') {
10
+ return base.defineElement(tag, (Base) => class UsaCursor extends Base {
11
+ constructor() {
12
+ super(...arguments);
13
+ this._frame = 0;
14
+ }
15
+ static get observedAttributes() {
16
+ return ['mode', 'size', 'color', 'hide-native'];
17
+ }
18
+ get active() {
19
+ return this.hasAttribute('data-active');
20
+ }
21
+ mount() {
22
+ this.setAttribute('aria-hidden', 'true');
23
+ const fine = typeof matchMedia !== 'function' || matchMedia('(pointer: fine)').matches || matchMedia('(hover: hover)').matches;
24
+ if (this.reduced || !fine)
25
+ return;
26
+ const mode = this.str('mode', 'dot');
27
+ const n = mode === 'trail' ? 8 : 1;
28
+ this.innerHTML = Array.from({ length: n }, (_, i) => `<span class="usa-cursor-${mode === 'glow' ? 'glow' : 'ring'}" style="--i:${i}"></span>`).join('') + (mode === 'glow' ? '' : '<span class="usa-cursor-dot"></span>');
29
+ if (this.str('color'))
30
+ this.style.setProperty('--usa-cursor-color', this.str('color'));
31
+ this.style.setProperty('--usa-cursor-size', `${this.num('size', 28)}px`);
32
+ if (this.flag('hide-native'))
33
+ document.documentElement.classList.add('usa-cursor-none');
34
+ this.onCleanup(() => document.documentElement.classList.remove('usa-cursor-none'));
35
+ const parts = Array.from(this.querySelectorAll('.usa-cursor-ring, .usa-cursor-glow'));
36
+ const dot = this.querySelector('.usa-cursor-dot');
37
+ const pts = parts.map(() => ({ x: -100, y: -100 }));
38
+ let mx = -100;
39
+ let my = -100;
40
+ let snap = null;
41
+ const sel = this.str('targets', 'a, button, [role="button"], [data-cursor], input, select, textarea, label');
42
+ const loop = () => {
43
+ this._frame = 0;
44
+ let tx = mx;
45
+ let ty = my;
46
+ pts.forEach((p, i) => {
47
+ const k = mode === 'trail' ? 0.35 - i * 0.03 : mode === 'glow' ? 0.12 : 0.22;
48
+ const goalX = snap && i === 0 ? snap.left + snap.width / 2 : tx;
49
+ const goalY = snap && i === 0 ? snap.top + snap.height / 2 : ty;
50
+ p.x += (goalX - p.x) * k;
51
+ p.y += (goalY - p.y) * k;
52
+ parts[i].style.transform = `translate3d(${p.x.toFixed(1)}px, ${p.y.toFixed(1)}px, 0)`;
53
+ tx = p.x;
54
+ ty = p.y;
55
+ });
56
+ if (snap && parts[0]) {
57
+ parts[0].style.width = `${snap.width + 12}px`;
58
+ parts[0].style.height = `${snap.height + 12}px`;
59
+ }
60
+ else if (parts[0]) {
61
+ parts[0].style.width = parts[0].style.height = '';
62
+ }
63
+ if (dot)
64
+ dot.style.transform = `translate3d(${mx}px, ${my}px, 0)`;
65
+ const moving = pts.some((p, i) => Math.abs(p.x - (i === 0 && snap ? snap.left + snap.width / 2 : mx)) > 0.3);
66
+ if (moving)
67
+ this._frame = base.raf(loop);
68
+ };
69
+ const kick = () => {
70
+ if (!this._frame)
71
+ this._frame = base.raf(loop);
72
+ };
73
+ this.listen(document, 'pointermove', (e) => {
74
+ if (e.pointerType === 'touch')
75
+ return;
76
+ mx = e.clientX;
77
+ my = e.clientY;
78
+ this.setAttribute('data-active', '');
79
+ if (mode === 'magnetic') {
80
+ const t = e.target?.closest?.(sel);
81
+ snap = t ? t.getBoundingClientRect() : null;
82
+ this.toggleAttribute('data-snapped', !!t);
83
+ }
84
+ else {
85
+ this.toggleAttribute('data-hover', !!e.target?.closest?.(sel));
86
+ }
87
+ kick();
88
+ }, { passive: true });
89
+ this.listen(document, 'pointerdown', () => this.setAttribute('data-down', ''));
90
+ this.listen(document, 'pointerup', () => this.removeAttribute('data-down'));
91
+ this.listen(document.documentElement, 'pointerleave', () => this.removeAttribute('data-active'));
92
+ }
93
+ unmount() {
94
+ base.caf(this._frame);
95
+ this._frame = 0;
96
+ this.removeAttribute('data-active');
97
+ }
98
+ }, { id: 'cursor', text: css$8 });
99
+ }
100
+
101
+ function smoothScroll(options = {}) {
102
+ if (typeof window === 'undefined' || base.prefersReducedMotion())
103
+ return () => undefined;
104
+ const el = options.target || null;
105
+ const lerp = Math.min(1, Math.max(0.02, options.lerp ?? 0.12));
106
+ const mult = options.wheelMultiplier ?? 1;
107
+ const get = () => (el ? el.scrollTop : window.scrollY);
108
+ const max = () => (el ? el.scrollHeight - el.clientHeight : document.documentElement.scrollHeight - window.innerHeight);
109
+ const set = (y) => (el ? (el.scrollTop = y) : window.scrollTo(0, y));
110
+ let target = get();
111
+ let current = target;
112
+ let id = 0;
113
+ const loop = () => {
114
+ current += (target - current) * lerp;
115
+ if (Math.abs(target - current) < 0.5)
116
+ current = target;
117
+ set(current);
118
+ id = current === target ? 0 : base.raf(loop);
119
+ };
120
+ const onWheel = (e) => {
121
+ if (e.ctrlKey || e.defaultPrevented)
122
+ return;
123
+ if (!id)
124
+ target = current = get();
125
+ e.preventDefault();
126
+ const dy = e.deltaMode === 1 ? e.deltaY * 16 : e.deltaMode === 2 ? e.deltaY * (window.innerHeight || 800) : e.deltaY;
127
+ target = Math.max(0, Math.min(max(), target + dy * mult));
128
+ if (!id)
129
+ id = base.raf(loop);
130
+ };
131
+ const onScroll = () => {
132
+ if (!id)
133
+ target = current = get();
134
+ };
135
+ const host = el || window;
136
+ host.addEventListener('wheel', onWheel, { passive: false });
137
+ host.addEventListener('scroll', onScroll, { passive: true });
138
+ return () => {
139
+ host.removeEventListener('wheel', onWheel);
140
+ host.removeEventListener('scroll', onScroll);
141
+ if (id)
142
+ base.caf(id);
143
+ id = 0;
144
+ };
145
+ }
146
+ /**
147
+ * Scroll to a y position, element or selector with spring timing (or
148
+ * instantly under reduced motion). Resolves when done.
149
+ */
150
+ function scrollToTarget(to, options = {}) {
151
+ if (typeof window === 'undefined')
152
+ return Promise.resolve();
153
+ const el = options.target || null;
154
+ const start = el ? el.scrollTop : window.scrollY;
155
+ let y = typeof to === 'number' ? to : 0;
156
+ if (typeof to !== 'number') {
157
+ const node = typeof to === 'string' ? document.querySelector(to) : to;
158
+ if (!node)
159
+ return Promise.resolve();
160
+ const top = node.getBoundingClientRect().top;
161
+ y = start + top - (el ? el.getBoundingClientRect().top : 0);
162
+ }
163
+ y = Math.max(0, y - (options.offset ?? 0));
164
+ const set = (v) => (el ? (el.scrollTop = v) : window.scrollTo(0, v));
165
+ if (base.prefersReducedMotion()) {
166
+ set(y);
167
+ return Promise.resolve();
168
+ }
169
+ const { values, duration } = spring.springSamples(options.preset || 'slow');
170
+ const t0 = base.now();
171
+ return new Promise((resolve) => {
172
+ const step = () => {
173
+ const p = Math.min(1, (base.now() - t0) / Math.max(1, duration));
174
+ const v = values[Math.min(values.length - 1, Math.round(p * (values.length - 1)))];
175
+ set(start + (y - start) * v);
176
+ if (p < 1)
177
+ base.raf(step);
178
+ else
179
+ resolve();
180
+ };
181
+ base.raf(step);
182
+ });
183
+ }
184
+
185
+ var css$7 = "usa-fullpage{position:relative;display:block;height:100vh;height:100dvh;overflow-y:auto;scroll-snap-type:y mandatory;overscroll-behavior:contain;outline:none}usa-fullpage[axis=\"x\"]{display:flex;overflow-x:auto;overflow-y:hidden;scroll-snap-type:x mandatory}usa-fullpage .usa-fullpage-section{box-sizing:border-box;min-height:100%;scroll-snap-align:start;scroll-snap-stop:always}usa-fullpage[axis=\"x\"] .usa-fullpage-section{flex:0 0 100%}usa-fullpage .usa-fullpage-dots{position:sticky;float:right;top:50%;margin-right:16px;transform:translateY(-50%);display:grid;gap:10px;z-index:5}usa-fullpage .usa-fullpage-dots button{width:10px;height:10px;padding:0;border-radius:50%;border:0;cursor:pointer;background:color-mix(in srgb,currentColor 35%,transparent);transition:transform 0.3s cubic-bezier(0.34,1.56,0.64,1),background-color 0.2s ease}usa-fullpage .usa-fullpage-dots button[aria-current]{background:var(--usa-accent,#7c5cff);transform:scale(1.5)}";
186
+
187
+ function defineFullpage(tag = 'usa-fullpage') {
188
+ return base.defineElement(tag, (Base) => class UsaFullpage extends Base {
189
+ constructor() {
190
+ super(...arguments);
191
+ this._i = 0;
192
+ }
193
+ get index() {
194
+ return this._i;
195
+ }
196
+ sections() {
197
+ return Array.from(this.children).filter((c) => !c.classList.contains('usa-fullpage-dots'));
198
+ }
199
+ mount() {
200
+ if (!this.hasAttribute('tabindex'))
201
+ this.tabIndex = 0;
202
+ const secs = this.sections();
203
+ secs.forEach((s, i) => {
204
+ s.classList.add('usa-fullpage-section');
205
+ s.setAttribute('data-index', String(i));
206
+ });
207
+ let nav = null;
208
+ if (this.flag('dots')) {
209
+ nav = document.createElement('nav');
210
+ nav.className = 'usa-fullpage-dots';
211
+ nav.setAttribute('aria-label', 'Sections');
212
+ secs.forEach((s, i) => {
213
+ const b = document.createElement('button');
214
+ b.type = 'button';
215
+ b.setAttribute('aria-label', s.getAttribute('aria-label') || s.querySelector('h1,h2,h3')?.textContent?.trim() || `Section ${i + 1}`);
216
+ b.addEventListener('click', () => this.go(i));
217
+ nav.append(b);
218
+ });
219
+ this.append(nav);
220
+ this.onCleanup(() => nav?.remove());
221
+ }
222
+ this.mark(0);
223
+ if (typeof IntersectionObserver !== 'undefined') {
224
+ const io = new IntersectionObserver((entries) => {
225
+ for (const e of entries)
226
+ if (e.isIntersecting && e.intersectionRatio >= 0.6)
227
+ this.mark(Number(e.target.dataset.index));
228
+ }, { root: this, threshold: [0.6] });
229
+ secs.forEach((s) => io.observe(s));
230
+ this.onCleanup(() => io.disconnect());
231
+ }
232
+ this.listen(this, 'keydown', (e) => {
233
+ const n = this.sections().length;
234
+ const map = { PageDown: this._i + 1, ArrowDown: this._i + 1, ' ': this._i + 1, PageUp: this._i - 1, ArrowUp: this._i - 1, Home: 0, End: n - 1 };
235
+ if (this.str('axis') === 'x')
236
+ Object.assign(map, { ArrowRight: this._i + 1, ArrowLeft: this._i - 1 });
237
+ if (!(e.key in map) || e.target.closest?.('input, textarea, select'))
238
+ return;
239
+ e.preventDefault();
240
+ this.go(map[e.key]);
241
+ });
242
+ }
243
+ mark(i) {
244
+ if (i === this._i && this.hasAttribute('data-ready'))
245
+ return;
246
+ this.setAttribute('data-ready', '');
247
+ this._i = i;
248
+ this.sections().forEach((s, j) => s.toggleAttribute('data-current', j === i));
249
+ this.querySelectorAll('.usa-fullpage-dots button').forEach((b, j) => (j === i ? b.setAttribute('aria-current', 'true') : b.removeAttribute('aria-current')));
250
+ this.emit('section', { index: i });
251
+ }
252
+ go(i) {
253
+ const secs = this.sections();
254
+ const t = secs[Math.max(0, Math.min(secs.length - 1, i))];
255
+ if (!t)
256
+ return;
257
+ if (this.str('axis') === 'x')
258
+ this.scrollTo({ left: t.offsetLeft, behavior: this.reduced ? 'auto' : 'smooth' });
259
+ else
260
+ scrollToTarget(t.offsetTop, { target: this, preset: 'stiff' });
261
+ this.mark(secs.indexOf(t));
262
+ }
263
+ next() {
264
+ this.go(this._i + 1);
265
+ }
266
+ prev() {
267
+ this.go(this._i - 1);
268
+ }
269
+ }, { id: 'fullpage', text: css$7 });
270
+ }
271
+
272
+ var css$6 = "usa-loading-bar{--usa-loading:0;--usa-loading-h:3px;--usa-loading-color:var(--usa-accent,#7c5cff);position:fixed;left:0;right:0;top:0;height:var(--usa-loading-h);z-index:2147483500;pointer-events:none;opacity:0;transition:opacity 0.3s ease}usa-loading-bar[position=\"bottom\"]{top:auto;bottom:0}usa-loading-bar[data-active]{opacity:1}usa-loading-bar .usa-loading-bar-fill{position:absolute;inset:0;transform-origin:0 50%;transform:scaleX(var(--usa-loading));background:var(--usa-loading-color);box-shadow:0 0 10px var(--usa-loading-color);transition:transform 0.2s ease-out}@media (prefers-reduced-motion:reduce){usa-loading-bar .usa-loading-bar-fill{transition:none}}";
273
+
274
+ function defineLoadingBar(tag = 'usa-loading-bar') {
275
+ return base.defineElement(tag, (Base) => class UsaLoadingBar extends Base {
276
+ constructor() {
277
+ super(...arguments);
278
+ this._p = 0;
279
+ }
280
+ get progress() {
281
+ return this._p;
282
+ }
283
+ mount() {
284
+ if (!this.querySelector('.usa-loading-bar-fill'))
285
+ this.innerHTML = '<span class="usa-loading-bar-fill"></span>';
286
+ this.setAttribute('role', 'progressbar');
287
+ this.setAttribute('aria-label', this.str('label', 'Loading'));
288
+ this.setAttribute('aria-valuemin', '0');
289
+ this.setAttribute('aria-valuemax', '100');
290
+ if (this.str('color'))
291
+ this.style.setProperty('--usa-loading-color', this.str('color'));
292
+ this.style.setProperty('--usa-loading-h', `${this.num('height', 3)}px`);
293
+ this.paint();
294
+ }
295
+ unmount() {
296
+ clearInterval(this._t);
297
+ clearTimeout(this._h);
298
+ }
299
+ paint() {
300
+ this.style.setProperty('--usa-loading', this._p.toFixed(4));
301
+ this.setAttribute('aria-valuenow', String(Math.round(this._p * 100)));
302
+ }
303
+ start() {
304
+ clearTimeout(this._h);
305
+ clearInterval(this._t);
306
+ this.setAttribute('data-active', '');
307
+ this.setAttribute('aria-busy', 'true');
308
+ this._p = Math.max(this._p, 0.08);
309
+ this.paint();
310
+ this._t = setInterval(() => {
311
+ this._p += (0.9 - this._p) * (this.reduced ? 0.5 : 0.08);
312
+ this.paint();
313
+ }, 200);
314
+ }
315
+ set(p) {
316
+ this.setAttribute('data-active', '');
317
+ this._p = Math.max(0, Math.min(1, p));
318
+ this.paint();
319
+ }
320
+ done() {
321
+ clearInterval(this._t);
322
+ this._p = 1;
323
+ this.paint();
324
+ this.removeAttribute('aria-busy');
325
+ this._h = setTimeout(() => {
326
+ this.removeAttribute('data-active');
327
+ this._h = setTimeout(() => {
328
+ this._p = 0;
329
+ this.paint();
330
+ }, 300);
331
+ }, 250);
332
+ }
333
+ }, { id: 'loading-bar', text: css$6 });
334
+ }
335
+ function bar() {
336
+ if (typeof document === 'undefined')
337
+ return null;
338
+ let el = document.querySelector('usa-loading-bar');
339
+ if (!el) {
340
+ defineLoadingBar();
341
+ el = document.createElement('usa-loading-bar');
342
+ document.body.appendChild(el);
343
+ }
344
+ return typeof el.start === 'function' ? el : null;
345
+ }
346
+ /** Drive the page's `<usa-loading-bar>` (created on first use). */
347
+ const loadingBar = {
348
+ start: () => bar()?.start(),
349
+ set: (p) => bar()?.set(p),
350
+ done: () => bar()?.done(),
351
+ /** Run `task` with the bar shown; resolves with its result. */
352
+ async track(task) {
353
+ bar()?.start();
354
+ try {
355
+ return await (typeof task === 'function' ? task() : task);
356
+ }
357
+ finally {
358
+ bar()?.done();
359
+ }
360
+ },
361
+ };
362
+
363
+ var css$5 = "usa-back-to-top{--usa-btt:0;position:fixed;right:max(20px,env(safe-area-inset-right));bottom:max(20px,env(safe-area-inset-bottom));z-index:850;opacity:0;transform:translateY(16px) scale(0.8);pointer-events:none;transition:opacity 0.25s ease,transform 0.4s cubic-bezier(0.34,1.56,0.64,1)}usa-back-to-top[position=\"bottom-left\"]{right:auto;left:max(20px,env(safe-area-inset-left))}usa-back-to-top[data-visible]{opacity:1;transform:none;pointer-events:auto}usa-back-to-top button{width:48px;height:48px;padding:0;border:0;border-radius:50%;cursor:pointer;display:grid;place-items:center;color:var(--usa-accent,#7c5cff);background:var(--usa-surface,#1b1e27);box-shadow:var(--usa-shadow,0 8px 24px -10px rgb(0 0 0 / 0.5))}usa-back-to-top svg{width:44px;height:44px;fill:none;stroke:currentColor;stroke-width:2.4;stroke-linecap:round;stroke-linejoin:round}usa-back-to-top circle{stroke-dasharray:100;stroke-dashoffset:calc(100 - var(--usa-btt) * 100);transform:rotate(-90deg);transform-origin:50% 50%;opacity:0.85}usa-back-to-top button:focus-visible{outline:2px solid var(--usa-accent,#7c5cff);outline-offset:3px}@media (prefers-reduced-motion:reduce){usa-back-to-top{transition:opacity 0.2s ease;transform:none}}";
364
+
365
+ function defineBackToTop(tag = 'usa-back-to-top') {
366
+ return base.defineElement(tag, (Base) => class UsaBackToTop extends Base {
367
+ constructor() {
368
+ super(...arguments);
369
+ this._frame = 0;
370
+ }
371
+ get visible() {
372
+ return this.hasAttribute('data-visible');
373
+ }
374
+ mount() {
375
+ if (!this.querySelector('button')) {
376
+ this.innerHTML = `<button type="button" aria-label="${this.str('label', 'Back to top')}"><svg viewBox="0 0 36 36" aria-hidden="true"><circle cx="18" cy="18" r="16" pathLength="100"/><path d="M12 20l6-6 6 6"/></svg></button>`;
377
+ }
378
+ const btn = this.querySelector('button');
379
+ const update = () => {
380
+ this._frame = 0;
381
+ const y = window.scrollY || document.documentElement.scrollTop || 0;
382
+ const max = Math.max(1, (document.documentElement.scrollHeight || 0) - (window.innerHeight || 0));
383
+ this.toggleAttribute('data-visible', y > this.num('offset', 300));
384
+ this.style.setProperty('--usa-btt', Math.min(1, y / max).toFixed(4));
385
+ };
386
+ this.listen(window, 'scroll', () => {
387
+ if (!this._frame)
388
+ this._frame = base.raf(update);
389
+ }, { passive: true });
390
+ this.listen(btn, 'click', async () => {
391
+ await scrollToTarget(0, { preset: 'slow' });
392
+ const f = document.querySelector(this.str('focus-target', '#main')) || document.body;
393
+ if (!f.hasAttribute('tabindex') && f !== document.body)
394
+ f.tabIndex = -1;
395
+ f.focus?.({ preventScroll: true });
396
+ });
397
+ update();
398
+ }
399
+ unmount() {
400
+ base.caf(this._frame);
401
+ this._frame = 0;
402
+ }
403
+ }, { id: 'back-to-top', text: css$5 });
404
+ }
405
+
406
+ var css$4 = "usa-ambient{--usa-ambient-opacity:0.6;--usa-ambient-p:0;position:fixed;inset:0;z-index:-1;pointer-events:none;opacity:var(--usa-ambient-opacity);contain:strict}usa-ambient[layer=\"front\"]{z-index:2147483000}usa-ambient canvas{display:block}usa-ambient[effect=\"noise\"]{opacity:calc(var(--usa-ambient-opacity) * 0.25);background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E\");animation:usa-ambient-grain 0.6s steps(4) infinite;mix-blend-mode:overlay}@keyframes usa-ambient-grain{25%{background-position:-40px 20px}50%{background-position:30px -50px}75%{background-position:-20px -30px}}usa-ambient[effect=\"gradient\"]{background:linear-gradient(135deg,hsl(calc(250 + var(--usa-ambient-p) * 140) 85% 60%),hsl(calc(190 + var(--usa-ambient-p) * 160) 85% 55%) 50%,hsl(calc(320 + var(--usa-ambient-p) * 90) 85% 62%))}@media (prefers-reduced-motion:reduce){usa-ambient[effect=\"noise\"]{animation:none}}";
407
+
408
+ const AMBIENT_EFFECTS = ['particles', 'snow', 'stars', 'noise', 'gradient'];
409
+ function defineAmbient(tag = 'usa-ambient') {
410
+ return base.defineElement(tag, (Base) => class UsaAmbient extends Base {
411
+ constructor() {
412
+ super(...arguments);
413
+ this._frame = 0;
414
+ }
415
+ static get observedAttributes() {
416
+ return ['effect', 'density', 'color'];
417
+ }
418
+ mount() {
419
+ this.setAttribute('aria-hidden', 'true');
420
+ const effect = this.str('effect', 'particles');
421
+ this.style.setProperty('--usa-ambient-opacity', String(this.num('opacity', 0.6)));
422
+ this.replaceChildren();
423
+ if (effect === 'noise')
424
+ return;
425
+ if (effect === 'gradient') {
426
+ const upd = () => {
427
+ this._frame = 0;
428
+ const max = Math.max(1, document.documentElement.scrollHeight - window.innerHeight);
429
+ this.style.setProperty('--usa-ambient-p', ((window.scrollY || 0) / max).toFixed(4));
430
+ };
431
+ if (!this.reduced)
432
+ this.listen(window, 'scroll', () => !this._frame && (this._frame = base.raf(upd)), { passive: true });
433
+ upd();
434
+ return;
435
+ }
436
+ const canvas = document.createElement('canvas');
437
+ this.append(canvas);
438
+ const ctx = canvas.getContext?.('2d');
439
+ if (!ctx)
440
+ return;
441
+ const dpr = Math.min(2, window.devicePixelRatio || 1);
442
+ let W = 0;
443
+ let H = 0;
444
+ const color = this.str('color', effect === 'snow' ? '#ffffff' : effect === 'stars' ? '#ffffff' : '#a78bfa');
445
+ const speed = this.num('speed', 1);
446
+ const resize = () => {
447
+ W = window.innerWidth || 800;
448
+ H = window.innerHeight || 600;
449
+ canvas.width = W * dpr;
450
+ canvas.height = H * dpr;
451
+ canvas.style.width = `${W}px`;
452
+ canvas.style.height = `${H}px`;
453
+ ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
454
+ };
455
+ resize();
456
+ const base$1 = effect === 'stars' ? 140 : effect === 'snow' ? 90 : 60;
457
+ const n = Math.round(base$1 * Math.max(0.2, Math.min(3, this.num('density', 1))) * Math.min(1.5, (W * H) / (1280 * 800)));
458
+ const dots = Array.from({ length: n }, () => ({
459
+ x: Math.random() * W,
460
+ y: Math.random() * H,
461
+ r: effect === 'stars' ? Math.random() * 1.3 + 0.2 : effect === 'snow' ? Math.random() * 2.6 + 0.8 : Math.random() * 2 + 0.6,
462
+ vx: (Math.random() - 0.5) * 0.25,
463
+ vy: effect === 'snow' ? Math.random() * 0.8 + 0.4 : (Math.random() - 0.5) * 0.25,
464
+ t: Math.random() * Math.PI * 2,
465
+ }));
466
+ ctx.fillStyle = color;
467
+ const draw = (move) => {
468
+ ctx.clearRect(0, 0, W, H);
469
+ for (const d of dots) {
470
+ if (move) {
471
+ d.t += 0.02 * speed;
472
+ d.x += (d.vx + (effect === 'snow' ? Math.sin(d.t) * 0.3 : 0)) * speed;
473
+ d.y += d.vy * speed;
474
+ if (d.y > H + 5)
475
+ d.y = -5;
476
+ if (d.y < -5)
477
+ d.y = H + 5;
478
+ if (d.x > W + 5)
479
+ d.x = -5;
480
+ if (d.x < -5)
481
+ d.x = W + 5;
482
+ }
483
+ ctx.globalAlpha = effect === 'stars' ? 0.35 + 0.65 * Math.abs(Math.sin(d.t)) : 0.85;
484
+ ctx.beginPath();
485
+ ctx.arc(d.x, d.y, d.r, 0, Math.PI * 2);
486
+ ctx.fill();
487
+ }
488
+ };
489
+ this.listen(window, 'resize', () => {
490
+ resize();
491
+ ctx.fillStyle = color;
492
+ draw(false);
493
+ });
494
+ if (this.reduced) {
495
+ draw(false);
496
+ return;
497
+ }
498
+ const loop = () => {
499
+ if (!document.hidden)
500
+ draw(true);
501
+ this._frame = base.raf(loop);
502
+ };
503
+ this._frame = base.raf(loop);
504
+ }
505
+ unmount() {
506
+ base.caf(this._frame);
507
+ this._frame = 0;
508
+ }
509
+ }, { id: 'ambient', text: css$4 });
510
+ }
511
+
512
+ var css$3 = "usa-splash{position:fixed;inset:0;z-index:2147483400;display:grid;place-items:center;background:var(--usa-splash-bg,var(--usa-surface,#0b0d12));color:var(--usa-text,#fff)}usa-splash[hidden]{display:none}";
513
+
514
+ function defineSplash(tag = 'usa-splash') {
515
+ return base.defineElement(tag, (Base) => class UsaSplash extends Base {
516
+ constructor() {
517
+ super(...arguments);
518
+ this._t0 = 0;
519
+ this._gone = false;
520
+ }
521
+ mount() {
522
+ this._t0 = Date.now();
523
+ this.setAttribute('role', 'status');
524
+ this.setAttribute('aria-label', this.str('label', 'Loading'));
525
+ document.body?.setAttribute('aria-busy', 'true');
526
+ if (this.flag('manual'))
527
+ return;
528
+ if (document.readyState === 'complete')
529
+ this.done();
530
+ else
531
+ this.listen(window, 'load', () => this.done(), { once: true });
532
+ }
533
+ async done() {
534
+ if (this._gone)
535
+ return;
536
+ this._gone = true;
537
+ const wait = Math.max(0, this.num('min', 600) - (Date.now() - this._t0));
538
+ if (wait)
539
+ await new Promise((r) => setTimeout(r, wait));
540
+ const exit = this.reduced ? 'fade' : this.str('exit', 'fade');
541
+ const frames = {
542
+ fade: [{ opacity: 1 }, { opacity: 0 }],
543
+ scale: [{ opacity: 1, transform: 'scale(1)' }, { opacity: 0, transform: 'scale(1.15)' }],
544
+ 'slide-up': [{ transform: 'translateY(0)' }, { transform: 'translateY(-100%)' }],
545
+ circle: [{ clipPath: 'circle(150% at 50% 50%)' }, { clipPath: 'circle(0% at 50% 50%)' }],
546
+ };
547
+ const a = this.motion(this, frames[exit] || frames.fade, { duration: this.reduced ? 200 : 550, easing: 'cubic-bezier(0.65, 0, 0.35, 1)', fill: 'forwards' });
548
+ await a?.finished.catch(() => undefined);
549
+ document.body?.removeAttribute('aria-busy');
550
+ this.hidden = true;
551
+ this.emit('done');
552
+ }
553
+ }, { id: 'splash', text: css$3 });
554
+ }
555
+
556
+ var css$2 = "usa-auto-skeleton{display:block;--usa-skel-base:color-mix(in srgb,currentColor 10%,transparent);--usa-skel-shine:color-mix(in srgb,currentColor 18%,transparent)}usa-auto-skeleton[loading] :is(h1,h2,h3,h4,h5,h6,p,li,span,a,button,label,img,svg,video,input,select,textarea,td,th,figcaption,blockquote,[data-skeleton]):not([data-no-skeleton]):not(:has(:is(h1,h2,h3,h4,h5,h6,p,li,img,button,input))){color:transparent !important;border-color:transparent !important;box-shadow:none !important;user-select:none;pointer-events:none;background:linear-gradient(90deg,var(--usa-skel-base) 25%,var(--usa-skel-shine) 50%,var(--usa-skel-base) 75%) 0 0 / 300% 100% !important;border-radius:6px;animation:usa-skel-shimmer 1.4s ease-in-out infinite}usa-auto-skeleton[loading] :is(img,svg,video){opacity:0}usa-auto-skeleton[loading] :is(img,svg,video):not([data-no-skeleton]){opacity:1;object-position:-9999px}@keyframes usa-skel-shimmer{from{background-position:100% 0}to{background-position:0 0}}@media (prefers-reduced-motion:reduce){usa-auto-skeleton[loading] *{animation:none !important}}";
557
+
558
+ function defineAutoSkeleton(tag = 'usa-auto-skeleton') {
559
+ return base.defineElement(tag, (Base) => class UsaAutoSkeleton extends Base {
560
+ static get observedAttributes() {
561
+ return ['loading'];
562
+ }
563
+ get loading() {
564
+ return this.flag('loading');
565
+ }
566
+ set loading(v) {
567
+ this.setFlag('loading', v);
568
+ }
569
+ mount() {
570
+ this.sync(false);
571
+ }
572
+ changed() {
573
+ this.sync(true);
574
+ }
575
+ sync(animate) {
576
+ if (this.loading)
577
+ this.setAttribute('aria-busy', 'true');
578
+ else {
579
+ this.removeAttribute('aria-busy');
580
+ if (animate && !this.reduced)
581
+ this.motion(this, [{ opacity: 0.4 }, { opacity: 1 }], { duration: 300, easing: 'ease-out' });
582
+ }
583
+ }
584
+ }, { id: 'auto-skeleton', text: css$2 });
585
+ }
586
+
587
+ var css$1 = "usa-motion-switch{--usa-motion-i:2;position:relative;display:inline-grid;grid-auto-flow:column;grid-auto-columns:1fr;padding:3px;border-radius:999px;background:color-mix(in srgb,currentColor 9%,transparent);isolation:isolate}usa-motion-switch button{position:relative;z-index:1;padding:6px 12px;border:0;background:none;color:inherit;font:inherit;font-size:0.85em;border-radius:999px;cursor:pointer}usa-motion-switch button[aria-checked=\"true\"]{color:var(--usa-accent-text,#fff)}usa-motion-switch button:focus-visible{outline:2px solid var(--usa-accent,#7c5cff);outline-offset:1px}usa-motion-switch .usa-motion-thumb{position:absolute;z-index:0;top:3px;bottom:3px;left:3px;width:calc((100% - 6px) / 4);border-radius:999px;background:var(--usa-accent,#7c5cff);transform:translateX(calc(var(--usa-motion-i) * 100%));transition:transform 0.4s cubic-bezier(0.34,1.4,0.64,1)}@media (prefers-reduced-motion:reduce){usa-motion-switch .usa-motion-thumb{transition:none}}";
588
+
589
+ const LEVELS = ['off', 'low', 'normal', 'high'];
590
+ const KEY = 'usa:motion';
591
+ /**
592
+ * Set the global motion intensity for every `<usa-*>` component:
593
+ * `'off'` (like reduced motion), `'low'`, `'normal'` (default), `'high'`.
594
+ * Sets `--usa-motion` and `data-usa-motion` on `<html>`; with `persist`
595
+ * the choice is remembered (localStorage) and restored by `restoreMotionIntensity()`.
596
+ */
597
+ function setMotionIntensity(level, persist = false) {
598
+ if (!LEVELS.includes(level))
599
+ return;
600
+ base.configureComponents({ motionIntensity: level });
601
+ if (persist) {
602
+ try {
603
+ localStorage.setItem(KEY, level);
604
+ }
605
+ catch {
606
+ /* private mode */
607
+ }
608
+ }
609
+ if (typeof document !== 'undefined')
610
+ document.dispatchEvent(new CustomEvent('usa:motion', { detail: { level } }));
611
+ }
612
+ /** Re-apply a persisted intensity (call early on page load). Returns it. */
613
+ function restoreMotionIntensity() {
614
+ try {
615
+ const v = localStorage.getItem(KEY);
616
+ if (v && LEVELS.includes(v))
617
+ setMotionIntensity(v);
618
+ }
619
+ catch {
620
+ /* ignore */
621
+ }
622
+ return base.getMotionIntensity();
623
+ }
624
+ function defineMotionSwitch(tag = 'usa-motion-switch') {
625
+ return base.defineElement(tag, (Base) => class UsaMotionSwitch extends Base {
626
+ get value() {
627
+ return base.getMotionIntensity();
628
+ }
629
+ set value(v) {
630
+ setMotionIntensity(v, true);
631
+ this.sync();
632
+ }
633
+ mount() {
634
+ restoreMotionIntensity();
635
+ const labels = this.str('labels', 'Off,Low,Normal,High').split(',');
636
+ this.setAttribute('role', 'radiogroup');
637
+ this.setAttribute('aria-label', this.str('label', 'Motion'));
638
+ this.innerHTML = LEVELS.map((l, i) => `<button type="button" role="radio" data-level="${l}">${labels[i] || l}</button><span hidden></span>`.replace('<span hidden></span>', '')).join('') + '<span class="usa-motion-thumb" aria-hidden="true"></span>';
639
+ this.listen(this, 'click', (e) => {
640
+ const b = e.target.closest?.('[data-level]');
641
+ if (b)
642
+ this.pick(b.dataset.level);
643
+ });
644
+ this.listen(this, 'keydown', (e) => {
645
+ const i = LEVELS.indexOf(this.value);
646
+ const n = e.key === 'ArrowRight' || e.key === 'ArrowDown' ? i + 1 : e.key === 'ArrowLeft' || e.key === 'ArrowUp' ? i - 1 : null;
647
+ if (n === null)
648
+ return;
649
+ e.preventDefault();
650
+ this.pick(LEVELS[(n + LEVELS.length) % LEVELS.length]);
651
+ this.querySelector('[aria-checked="true"]')?.focus();
652
+ });
653
+ this.listen(document, 'usa:motion', () => this.sync());
654
+ this.sync();
655
+ }
656
+ pick(l) {
657
+ this.value = l;
658
+ this.emit('change', { level: l });
659
+ }
660
+ sync() {
661
+ const v = this.value;
662
+ const i = LEVELS.indexOf(v);
663
+ this.style.setProperty('--usa-motion-i', String(i));
664
+ this.querySelectorAll('[data-level]').forEach((b) => {
665
+ const on = b.dataset.level === v;
666
+ b.setAttribute('aria-checked', String(on));
667
+ b.tabIndex = on ? 0 : -1;
668
+ });
669
+ }
670
+ }, { id: 'motion-switch', text: css$1 });
671
+ }
672
+
673
+ var css = "::view-transition-group(root){animation-duration:var(--usa-pt-duration,600ms)}html[data-usa-pt] ::view-transition-old(root),html[data-usa-pt] ::view-transition-new(root){animation-duration:var(--usa-pt-duration,600ms);animation-timing-function:cubic-bezier(0.22,1,0.36,1);mix-blend-mode:normal}html[data-usa-pt=\"slide\"] ::view-transition-old(root),html[data-usa-pt=\"slide-left\"] ::view-transition-old(root){animation-name:usa-pt-out-left}html[data-usa-pt=\"slide\"] ::view-transition-new(root),html[data-usa-pt=\"slide-left\"] ::view-transition-new(root){animation-name:usa-pt-in-right}html[data-usa-pt=\"slide-right\"] ::view-transition-old(root){animation-name:usa-pt-out-right}html[data-usa-pt=\"slide-right\"] ::view-transition-new(root){animation-name:usa-pt-in-left}html[data-usa-pt=\"slide-up\"] ::view-transition-old(root){animation-name:usa-pt-out-up}html[data-usa-pt=\"slide-up\"] ::view-transition-new(root){animation-name:usa-pt-in-up}html[data-usa-pt=\"zoom\"] ::view-transition-old(root){animation-name:usa-pt-zoom-out}html[data-usa-pt=\"zoom\"] ::view-transition-new(root){animation-name:usa-pt-zoom-in}html[data-usa-pt=\"circle\"] ::view-transition-old(root){animation:none}html[data-usa-pt=\"circle\"] ::view-transition-new(root){animation-name:usa-pt-circle}html[data-usa-pt=\"blinds\"] ::view-transition-old(root){animation:none}html[data-usa-pt=\"blinds\"] ::view-transition-new(root){animation-name:usa-pt-blinds;-webkit-mask-image:repeating-linear-gradient(to bottom,#000 0 var(--usa-blind),transparent var(--usa-blind) 10vh);mask-image:repeating-linear-gradient(to bottom,#000 0 var(--usa-blind),transparent var(--usa-blind) 10vh)}html[data-usa-pt=\"pixel\"] ::view-transition-old(root){animation-name:usa-pt-pixel-out;animation-timing-function:steps(10,end)}html[data-usa-pt=\"pixel\"] ::view-transition-new(root){animation-name:usa-pt-pixel-in;animation-timing-function:steps(10,end)}@property --usa-blind{syntax:\"<length-percentage>\";inherits:false;initial-value:0vh}@keyframes usa-pt-out-left{to{transform:translateX(-30%);opacity:0}}@keyframes usa-pt-in-right{from{transform:translateX(30%);opacity:0}}@keyframes usa-pt-out-right{to{transform:translateX(30%);opacity:0}}@keyframes usa-pt-in-left{from{transform:translateX(-30%);opacity:0}}@keyframes usa-pt-out-up{to{transform:translateY(-12%);opacity:0}}@keyframes usa-pt-in-up{from{transform:translateY(12%);opacity:0}}@keyframes usa-pt-zoom-out{to{transform:scale(0.92);opacity:0}}@keyframes usa-pt-zoom-in{from{transform:scale(1.08);opacity:0}}@keyframes usa-pt-circle{from{clip-path:circle(0 at var(--usa-pt-x,50%) var(--usa-pt-y,50%))}to{clip-path:circle(var(--usa-pt-r,150vmax) at var(--usa-pt-x,50%) var(--usa-pt-y,50%))}}@keyframes usa-pt-blinds{from{--usa-blind:0vh}to{--usa-blind:10vh}}@keyframes usa-pt-pixel-out{to{opacity:0;filter:blur(6px) contrast(1.4)}}@keyframes usa-pt-pixel-in{from{opacity:0;filter:blur(6px) contrast(1.4)}}@media (prefers-reduced-motion:reduce){::view-transition-group(*),::view-transition-old(*),::view-transition-new(*){animation:none !important}}";
674
+
675
+ /**
676
+ * Page & app-wide transitions (v2.7), built on the View Transitions API
677
+ * (Chromium: Chrome, Edge, Electron, WebView2) with graceful fallbacks.
678
+ *
679
+ * - `pageTransition(update, { effect })` — SPA route changes: `fade`,
680
+ * `slide` (`slide-left` / `slide-right` / `slide-up`), `circle` (reveal
681
+ * from `x`, `y`), `blinds`, `pixel` (stepped dissolve), `zoom`.
682
+ * - `enableMpaTransitions(effect)` — the same effects for multi-page sites
683
+ * (`@view-transition { navigation: auto }`); call it on every page.
684
+ * - `themeTransition(apply, { x, y })` — a circle-reveal theme switch.
685
+ *
686
+ * Without View Transitions (Firefox, older Safari) or under reduced motion
687
+ * the update runs immediately (`fade` falls back to a short cross-fade of
688
+ * `fallback` when given).
689
+ */
690
+ const PAGE_EFFECTS = ['fade', 'slide', 'slide-left', 'slide-right', 'slide-up', 'circle', 'blinds', 'pixel', 'zoom'];
691
+ let lastPointer = null;
692
+ function trackPointer() {
693
+ if (typeof document === 'undefined' || trackPointer.done)
694
+ return;
695
+ trackPointer.done = true;
696
+ document.addEventListener('pointerdown', (e) => (lastPointer = [e.clientX, e.clientY]), { capture: true, passive: true });
697
+ }
698
+ /** `true` when `document.startViewTransition` exists. */
699
+ const supportsViewTransitions = () => typeof document !== 'undefined' && typeof document.startViewTransition === 'function';
700
+ function setVars(o) {
701
+ const d = document.documentElement;
702
+ const W = window.innerWidth || 1024;
703
+ const H = window.innerHeight || 768;
704
+ const [x, y] = o.x !== undefined && o.y !== undefined ? [o.x, o.y] : lastPointer || [W / 2, H / 2];
705
+ const r = Math.hypot(Math.max(x, W - x), Math.max(y, H - y));
706
+ d.style.setProperty('--usa-pt-x', `${x}px`);
707
+ d.style.setProperty('--usa-pt-y', `${y}px`);
708
+ d.style.setProperty('--usa-pt-r', `${Math.ceil(r)}px`);
709
+ d.style.setProperty('--usa-pt-duration', `${o.duration ?? 600}ms`);
710
+ }
711
+ /** Run `update` (sync or async) as an animated page transition. Resolves when it is done. */
712
+ async function pageTransition(update, options = {}) {
713
+ if (typeof document === 'undefined') {
714
+ await update();
715
+ return;
716
+ }
717
+ base.adoptStyles('page-transitions', css);
718
+ trackPointer();
719
+ const effect = options.effect || 'fade';
720
+ if (base.prefersReducedMotion() || !supportsViewTransitions()) {
721
+ await update();
722
+ const f = options.fallback;
723
+ if (f && typeof f.animate === 'function' && !base.prefersReducedMotion())
724
+ await f.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 200 }).finished.catch(() => undefined);
725
+ return;
726
+ }
727
+ const d = document.documentElement;
728
+ setVars(options);
729
+ d.setAttribute('data-usa-pt', effect);
730
+ try {
731
+ const vt = document.startViewTransition(() => update());
732
+ await vt.finished;
733
+ }
734
+ finally {
735
+ d.removeAttribute('data-usa-pt');
736
+ }
737
+ }
738
+ /** Opt a multi-page site into cross-document view transitions with `effect`. */
739
+ function enableMpaTransitions(effect = 'fade', duration = 450) {
740
+ if (typeof document === 'undefined')
741
+ return;
742
+ base.adoptStyles('page-transitions', css);
743
+ base.adoptStyles('mpa-transitions', base.prefersReducedMotion() ? '' : '@view-transition{navigation:auto}');
744
+ const d = document.documentElement;
745
+ d.setAttribute('data-usa-pt', effect);
746
+ setVars({ duration });
747
+ }
748
+ /**
749
+ * Switch theme with a circle reveal from (`x`, `y`) (default: last pointer).
750
+ * `apply` flips your theme (e.g. toggles a class / `data-theme`).
751
+ */
752
+ function themeTransition(apply, options = {}) {
753
+ return pageTransition(apply, { ...options, effect: 'circle', duration: options.duration ?? 650 });
754
+ }
755
+
756
+ /**
757
+ * use-scroll-animate/components/page — page & app-wide effects (v2.7).
758
+ * Page transitions (`pageTransition()`, `enableMpaTransitions()`,
759
+ * `themeTransition()`), `<usa-cursor>`, `smoothScroll()` / `scrollToTarget()`,
760
+ * `<usa-fullpage>`, `<usa-loading-bar>` + `loadingBar`, `<usa-back-to-top>`,
761
+ * `<usa-ambient>`, `<usa-splash>`, `<usa-auto-skeleton>` and the global motion
762
+ * intensity (`setMotionIntensity()`, `<usa-motion-switch>`).
763
+ */
764
+ /** Register every component of this category under its default tag. */
765
+ function definePageComponents() {
766
+ defineCursor();
767
+ defineFullpage();
768
+ defineLoadingBar();
769
+ defineBackToTop();
770
+ defineAmbient();
771
+ defineSplash();
772
+ defineAutoSkeleton();
773
+ defineMotionSwitch();
774
+ }
775
+
776
+ exports.MOTION_SCALE = base.MOTION_SCALE;
777
+ exports.configureComponents = base.configureComponents;
778
+ exports.getMotionIntensity = base.getMotionIntensity;
779
+ exports.prefersReducedMotion = base.prefersReducedMotion;
780
+ exports.AMBIENT_EFFECTS = AMBIENT_EFFECTS;
781
+ exports.CURSOR_MODES = CURSOR_MODES;
782
+ exports.PAGE_EFFECTS = PAGE_EFFECTS;
783
+ exports.defineAmbient = defineAmbient;
784
+ exports.defineAutoSkeleton = defineAutoSkeleton;
785
+ exports.defineBackToTop = defineBackToTop;
786
+ exports.defineCursor = defineCursor;
787
+ exports.defineFullpage = defineFullpage;
788
+ exports.defineLoadingBar = defineLoadingBar;
789
+ exports.defineMotionSwitch = defineMotionSwitch;
790
+ exports.definePageComponents = definePageComponents;
791
+ exports.defineSplash = defineSplash;
792
+ exports.enableMpaTransitions = enableMpaTransitions;
793
+ exports.loadingBar = loadingBar;
794
+ exports.pageTransition = pageTransition;
795
+ exports.restoreMotionIntensity = restoreMotionIntensity;
796
+ exports.scrollToTarget = scrollToTarget;
797
+ exports.setMotionIntensity = setMotionIntensity;
798
+ exports.smoothScroll = smoothScroll;
799
+ exports.supportsViewTransitions = supportsViewTransitions;
800
+ exports.themeTransition = themeTransition;
801
+ //# sourceMappingURL=page.cjs.map