@falcon-ui/falcon-ui 1.0.0 → 1.1.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 (51) hide show
  1. package/README.md +1 -0
  2. package/THIRD_PARTY_NOTICES.md +51 -0
  3. package/cjs/components/index.cjs +1131 -4
  4. package/cjs/components/index.cjs.map +1 -1
  5. package/cjs/components/loading/index.cjs +1186 -0
  6. package/cjs/components/loading/index.cjs.map +1 -0
  7. package/cjs/components/loading/src/loading.cjs +72 -0
  8. package/cjs/components/loading/src/loading.cjs.map +1 -0
  9. package/cjs/index.cjs +1132 -4
  10. package/cjs/index.cjs.map +1 -1
  11. package/esm/components/index.mjs +1130 -6
  12. package/esm/components/index.mjs.map +1 -1
  13. package/esm/components/loading/index.mjs +1179 -0
  14. package/esm/components/loading/index.mjs.map +1 -0
  15. package/esm/components/loading/src/loading.mjs +66 -0
  16. package/esm/components/loading/src/loading.mjs.map +1 -0
  17. package/esm/index.mjs +1131 -6
  18. package/esm/index.mjs.map +1 -1
  19. package/global.d.ts +2 -0
  20. package/package.json +7 -1
  21. package/theme/index.css +1 -1
  22. package/theme/index.scss +1 -0
  23. package/theme/src/loading.scss +52 -0
  24. package/types/components/barcode/index.d.ts +1 -1
  25. package/types/components/barcode/src/barcode.vue.d.ts +1 -1
  26. package/types/components/index.d.ts +2 -0
  27. package/types/components/input/index.d.ts +1 -1
  28. package/types/components/input/src/input.vue.d.ts +1 -1
  29. package/types/components/input-number/index.d.ts +3 -3
  30. package/types/components/input-number/src/input-number.vue.d.ts +1 -1
  31. package/types/components/loading/index.d.ts +183 -0
  32. package/types/components/loading/src/FlLoading.vue.d.ts +109 -0
  33. package/types/components/loading/src/animations/composing.d.ts +2 -0
  34. package/types/components/loading/src/animations/earth.d.ts +12 -0
  35. package/types/components/loading/src/animations/listening.d.ts +2 -0
  36. package/types/components/loading/src/animations/searching.d.ts +2 -0
  37. package/types/components/loading/src/animations/shaping.d.ts +2 -0
  38. package/types/components/loading/src/animations/solving.d.ts +2 -0
  39. package/types/components/loading/src/animations/working.d.ts +2 -0
  40. package/types/components/loading/src/earth-points.d.ts +22 -0
  41. package/types/components/loading/src/loading-frame.d.ts +4 -0
  42. package/types/components/loading/src/loading-geometry.d.ts +66 -0
  43. package/types/components/loading/src/loading-presets.d.ts +6 -0
  44. package/types/components/loading/src/loading-profiles.d.ts +7 -0
  45. package/types/components/loading/src/loading-renderer.d.ts +4 -0
  46. package/types/components/loading/src/loading.d.ts +65 -0
  47. package/types/components/loading/src/use-fl-loading.d.ts +15 -0
  48. package/types/components/loading/src/use-loading-animation.d.ts +13 -0
  49. package/types/components/loading/src/use-loading-color.d.ts +6 -0
  50. package/umd/falcon-ui.umd.js +1137 -7
  51. package/umd/falcon-ui.umd.js.map +1 -1
@@ -0,0 +1,1179 @@
1
+ import { computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, h, normalizeClass, normalizeStyle, onActivated, onDeactivated, onMounted, onScopeDispose, openBlock, ref, renderSlot, toDisplayString, toValue, unref, vShow, watch, withDirectives } from "vue";
2
+ var defaultNamespace = "fl";
3
+ var statePrefix = "is-";
4
+ var buildBemName = (namespace, block, blockSuffix = "", element = "", modifier = "") => {
5
+ let className = `${namespace}-${block}`;
6
+ if (blockSuffix) className += `-${blockSuffix}`;
7
+ if (element) className += `__${element}`;
8
+ if (modifier) className += `--${modifier}`;
9
+ return className;
10
+ };
11
+ const useNamespace = (block, namespace = defaultNamespace) => {
12
+ const b = (blockSuffix = "") => buildBemName(namespace, block, blockSuffix);
13
+ const e = (element) => element ? buildBemName(namespace, block, "", element) : "";
14
+ const m = (modifier) => modifier ? buildBemName(namespace, block, "", "", modifier) : "";
15
+ const be = (blockSuffix, element) => {
16
+ if (!blockSuffix || !element) return "";
17
+ return buildBemName(namespace, block, blockSuffix, element);
18
+ };
19
+ const em = (element, modifier) => {
20
+ if (!element || !modifier) return "";
21
+ return buildBemName(namespace, block, "", element, modifier);
22
+ };
23
+ const bm = (blockSuffix, modifier) => {
24
+ if (!blockSuffix || !modifier) return "";
25
+ return buildBemName(namespace, block, blockSuffix, "", modifier);
26
+ };
27
+ const bem = (blockSuffix, element, modifier) => {
28
+ if (!blockSuffix && !element && !modifier) return b();
29
+ return buildBemName(namespace, block, blockSuffix, element, modifier);
30
+ };
31
+ const is = (name, state = true) => state ? `${statePrefix}${name}` : "";
32
+ return {
33
+ namespace,
34
+ b,
35
+ e,
36
+ m,
37
+ be,
38
+ em,
39
+ bm,
40
+ bem,
41
+ is
42
+ };
43
+ };
44
+ const withInstall = (component) => {
45
+ const installable = component;
46
+ installable.install = (app) => {
47
+ if (!component.name) return;
48
+ app.component(component.name, component);
49
+ };
50
+ return installable;
51
+ };
52
+ const flLoadingAnimations = [
53
+ "working",
54
+ "searching",
55
+ "solving",
56
+ "listening",
57
+ "composing",
58
+ "shaping",
59
+ "earth"
60
+ ];
61
+ const flLoadingSizes = [
62
+ 20,
63
+ 32,
64
+ 48,
65
+ 64,
66
+ 96
67
+ ];
68
+ const flLoadingProps = {
69
+ active: {
70
+ type: Boolean,
71
+ default: true
72
+ },
73
+ animation: {
74
+ type: String,
75
+ default: "searching",
76
+ validator: (v) => flLoadingAnimations.includes(v)
77
+ },
78
+ size: {
79
+ type: Number,
80
+ default: 64,
81
+ validator: (v) => flLoadingSizes.includes(v)
82
+ },
83
+ color: {
84
+ type: String,
85
+ default: ""
86
+ },
87
+ theme: {
88
+ type: String,
89
+ default: "auto"
90
+ },
91
+ speed: {
92
+ type: Number,
93
+ default: 1
94
+ },
95
+ paused: {
96
+ type: Boolean,
97
+ default: false
98
+ },
99
+ text: {
100
+ type: String,
101
+ default: ""
102
+ },
103
+ layout: {
104
+ type: String,
105
+ default: "inline"
106
+ },
107
+ ariaLabel: {
108
+ type: String,
109
+ default: "加载中"
110
+ }
111
+ };
112
+ const normalizeAnimation = (v) => flLoadingAnimations.includes(v) ? v : "searching";
113
+ const normalizeSize = (v) => flLoadingSizes.includes(v) ? v : 64;
114
+ const normalizeSpeed = (v) => Number.isFinite(v) ? Math.max(.25, Math.min(3, v)) : 1;
115
+ function useLoadingColor(host, options) {
116
+ const color = ref("#20252b");
117
+ let mounted = false;
118
+ let observer;
119
+ let media;
120
+ let probe;
121
+ let observedHost;
122
+ const resolve = () => {
123
+ if (!mounted) return;
124
+ const target = host() || document.documentElement;
125
+ if (target !== observedHost) {
126
+ observer?.disconnect();
127
+ probe?.remove();
128
+ probe = document.createElement("span");
129
+ probe.setAttribute("aria-hidden", "true");
130
+ probe.style.cssText = "position:absolute;visibility:hidden;pointer-events:none;width:0;height:0;overflow:hidden";
131
+ target.appendChild(probe);
132
+ for (let el = target; el; el = el.parentElement) observer?.observe(el, {
133
+ attributes: true,
134
+ attributeFilter: [
135
+ "class",
136
+ "style",
137
+ "data-theme"
138
+ ]
139
+ });
140
+ observedHost = target;
141
+ }
142
+ const { color: explicit, theme = "auto" } = options();
143
+ let dark = theme === "dark";
144
+ if (theme === "auto") {
145
+ dark = media?.matches ?? false;
146
+ for (let el = target; el; el = el.parentElement) {
147
+ const marker = el.dataset.theme;
148
+ if (marker === "dark" || marker === "light") {
149
+ dark = marker === "dark";
150
+ break;
151
+ }
152
+ if (el.classList.contains("dark") || el.classList.contains("light")) {
153
+ dark = el.classList.contains("dark");
154
+ break;
155
+ }
156
+ }
157
+ }
158
+ const variable = getComputedStyle(target).getPropertyValue("--fl-loading-color").trim();
159
+ const fallback = dark ? "#f0f3f7" : "#20252b";
160
+ if (probe) {
161
+ probe.style.color = fallback;
162
+ if (explicit || variable) probe.style.color = explicit || variable;
163
+ color.value = getComputedStyle(probe).color || fallback;
164
+ }
165
+ };
166
+ watch([
167
+ host,
168
+ () => options().color,
169
+ () => options().theme
170
+ ], resolve, { flush: "post" });
171
+ onMounted(() => {
172
+ mounted = true;
173
+ media = window.matchMedia?.("(prefers-color-scheme: dark)");
174
+ observer = typeof MutationObserver === "undefined" ? void 0 : new MutationObserver(resolve);
175
+ media?.addEventListener("change", resolve);
176
+ resolve();
177
+ });
178
+ onScopeDispose(() => {
179
+ mounted = false;
180
+ observer?.disconnect();
181
+ media?.removeEventListener("change", resolve);
182
+ probe?.remove();
183
+ });
184
+ return color;
185
+ }
186
+ var COUNT_PAIRS = [
187
+ ["latRings", "lonDensity"],
188
+ ["rings", "lonDensity"],
189
+ ["lanes", "segs"]
190
+ ];
191
+ var COUNT_KEYS = [
192
+ "orbitN",
193
+ "ghostN",
194
+ "nodeN",
195
+ "strandN",
196
+ "signals"
197
+ ];
198
+ var ICON_DENSITY_KEYS = ["iconD"];
199
+ var RADIUS_KEYS = [
200
+ "rBase",
201
+ "rDepth",
202
+ "rActive",
203
+ "rDot",
204
+ "ghostR",
205
+ "partR",
206
+ "partRDepth",
207
+ "nodeR",
208
+ "nodeRDepth"
209
+ ];
210
+ function scaleCounts(opts, scale) {
211
+ const out = { ...opts };
212
+ const done = /* @__PURE__ */ new Set();
213
+ const rt = Math.sqrt(scale);
214
+ for (const [a, b] of COUNT_PAIRS) {
215
+ const va = out[a];
216
+ const vb = out[b];
217
+ if (va != null && vb != null && !done.has(a) && !done.has(b)) {
218
+ out[a] = Math.max(2, Math.round(va * rt));
219
+ out[b] = Math.max(2, Math.round(vb * rt));
220
+ done.add(a);
221
+ done.add(b);
222
+ }
223
+ }
224
+ for (const k of COUNT_KEYS) {
225
+ const v = out[k];
226
+ if (v != null && v !== 0 && !done.has(k)) out[k] = Math.max(1, Math.round(v * scale));
227
+ }
228
+ for (const k of ICON_DENSITY_KEYS) {
229
+ const v = out[k];
230
+ if (v != null) out[k] = Math.max(.02, v * scale);
231
+ }
232
+ return out;
233
+ }
234
+ function scaleRadii(opts, scale) {
235
+ const out = { ...opts };
236
+ for (const k of RADIUS_KEYS) {
237
+ const v = out[k];
238
+ if (v != null) out[k] = v * scale;
239
+ }
240
+ out.rSizeMul = (out.rSizeMul ?? 1) * scale;
241
+ return out;
242
+ }
243
+ const BASE_PROFILES = {
244
+ globe: {
245
+ latRings: 17,
246
+ lonDensity: 44,
247
+ rBase: .6,
248
+ rDepth: 1.7,
249
+ rBoost: 1,
250
+ inkFar: .62,
251
+ inkSpan: .54,
252
+ rsPow: .6,
253
+ rMin: .3
254
+ },
255
+ orbits: {
256
+ orbitN: 12,
257
+ ghostN: 40,
258
+ ghostR: .9,
259
+ ghostA: .5,
260
+ particles: 3,
261
+ partR: 1.2,
262
+ partRDepth: 1.6,
263
+ rsPow: .6,
264
+ rMin: .3
265
+ },
266
+ rubik: {
267
+ latRings: 15,
268
+ lonDensity: 40,
269
+ moveCount: 14,
270
+ rBase: .6,
271
+ rDepth: 1.7,
272
+ rActive: .3,
273
+ inkFar: .62,
274
+ inkSpan: .54,
275
+ rsPow: .6,
276
+ rMin: .3
277
+ },
278
+ wave: {
279
+ rings: 15,
280
+ lonDensity: 40,
281
+ rBase: .6,
282
+ rDepth: 1.7,
283
+ rsPow: .6,
284
+ rMin: .3
285
+ },
286
+ web: {
287
+ nodeN: 30,
288
+ thr: .72,
289
+ signals: 5,
290
+ nodeR: 1.4,
291
+ nodeRDepth: 1.8,
292
+ lineW: .8,
293
+ rsPow: .6,
294
+ rMin: .3
295
+ },
296
+ braid: {
297
+ strandN: 52,
298
+ turns: 3,
299
+ ghostN: 150,
300
+ rBase: 1.2,
301
+ rDepth: 1.8,
302
+ rsPow: .6,
303
+ rMin: .3
304
+ },
305
+ ribbon: {
306
+ lanes: 5,
307
+ segs: 88,
308
+ ghostN: 150,
309
+ rBase: 1.1,
310
+ rDepth: 1.7,
311
+ rsPow: .6,
312
+ rMin: .3
313
+ },
314
+ ring: {
315
+ lanes: 5,
316
+ segs: 88,
317
+ ghostN: 0,
318
+ faceOn: 1,
319
+ rBase: 1.1,
320
+ rDepth: 1.7,
321
+ rsPow: .6,
322
+ rMin: .3
323
+ },
324
+ morph: {
325
+ rDot: .021,
326
+ iconD: 1,
327
+ rMin: .25
328
+ }
329
+ };
330
+ var presets = {
331
+ working: [
332
+ "orbits",
333
+ 1.885,
334
+ 1,
335
+ 1,
336
+ 3.9,
337
+ .238,
338
+ 2.4
339
+ ],
340
+ searching: [
341
+ "globe",
342
+ 2.015,
343
+ .42,
344
+ 1.15,
345
+ 2.665,
346
+ .105,
347
+ 1.75
348
+ ],
349
+ solving: [
350
+ "rubik",
351
+ 1.82,
352
+ .35,
353
+ 1.05,
354
+ 1.95,
355
+ .088,
356
+ 1.9
357
+ ],
358
+ listening: [
359
+ "wave",
360
+ 4.388,
361
+ .341,
362
+ 1,
363
+ 3.998,
364
+ .105,
365
+ 1.6
366
+ ],
367
+ composing: [
368
+ "ribbon",
369
+ 2.34,
370
+ .25,
371
+ .85,
372
+ 3.12,
373
+ .051,
374
+ 1.073
375
+ ],
376
+ shaping: [
377
+ "morph",
378
+ 2.405,
379
+ .702,
380
+ .395,
381
+ 2.08,
382
+ .53,
383
+ 1.011
384
+ ]
385
+ };
386
+ var cache$1 = /* @__PURE__ */ new Map();
387
+ function resolvePreset(animation, size) {
388
+ const key = `${animation}-${size}`;
389
+ const hit = cache$1.get(key);
390
+ if (hit) return hit;
391
+ if (animation === "earth") return {
392
+ speed: 1,
393
+ opts: {}
394
+ };
395
+ const [mode, bigSpeed, bigCount, bigRadius, smallSpeed, smallCount, smallRadius] = presets[animation];
396
+ const blend = Math.max(0, Math.min(1, (size - 20) / 44));
397
+ const count = smallCount + (bigCount - smallCount) * blend;
398
+ const radius = smallRadius + (bigRadius - smallRadius) * blend;
399
+ let opts = scaleRadii(scaleCounts(BASE_PROFILES[mode], count), radius);
400
+ if (animation === "searching") opts = {
401
+ ...opts,
402
+ scanMul: 4.08,
403
+ dimBase: .45
404
+ };
405
+ if (animation === "composing") opts = {
406
+ ...opts,
407
+ spin: 0,
408
+ bandMul: 3.9,
409
+ wobMul: 1
410
+ };
411
+ if (animation === "shaping") opts = {
412
+ ...opts,
413
+ spread: 1.45
414
+ };
415
+ const resolved = {
416
+ speed: smallSpeed + (bigSpeed - smallSpeed) * blend,
417
+ opts
418
+ };
419
+ cache$1.set(key, resolved);
420
+ return resolved;
421
+ }
422
+ function hashD(a, b) {
423
+ const h$1 = Math.sin(a * 12.9898 + b * 78.233) * 43758.5453;
424
+ return h$1 - Math.floor(h$1);
425
+ }
426
+ function fibDir(i, n) {
427
+ const golden = Math.PI * (3 - Math.sqrt(5));
428
+ const y = 1 - 2 * (i + .5) / n;
429
+ const rad = Math.sqrt(1 - y * y);
430
+ const a = i * golden;
431
+ return [
432
+ rad * Math.cos(a),
433
+ y,
434
+ rad * Math.sin(a)
435
+ ];
436
+ }
437
+ function angleDelta(a, b) {
438
+ return Math.atan2(Math.sin(a - b), Math.cos(a - b));
439
+ }
440
+ function makeProj(yaw, tilt, cx, cy, scale) {
441
+ const st = Math.sin(tilt);
442
+ const ct = Math.cos(tilt);
443
+ const sy = Math.sin(yaw);
444
+ const cyw = Math.cos(yaw);
445
+ return (x, y, z) => {
446
+ const x1 = x * cyw + z * sy;
447
+ const z1 = -x * sy + z * cyw;
448
+ const y1 = y * ct - z1 * st;
449
+ const z2 = y * st + z1 * ct;
450
+ return [
451
+ cx + x1 * scale,
452
+ cy - y1 * scale,
453
+ z2
454
+ ];
455
+ };
456
+ }
457
+ function finalizeFrame(dots, lines, rMin = .3) {
458
+ const visible = [];
459
+ for (const d of dots) {
460
+ if ((d.a ?? 1) < .02) continue;
461
+ d.r = Math.max(rMin, d.r);
462
+ visible.push(d);
463
+ }
464
+ visible.sort((a, b) => a.z - b.z);
465
+ return {
466
+ dots: visible,
467
+ lines: lines.filter((l) => (l.a ?? 1) >= .02)
468
+ };
469
+ }
470
+ function radiusScale(size, pow) {
471
+ return (size / 300) ** pow;
472
+ }
473
+ const frameGlobe = (size, t, o) => {
474
+ const spin = .5;
475
+ const cx = size / 2;
476
+ const cy = size / 2;
477
+ const radius = size / 2 * .82;
478
+ const tilt = .4 + .06 * Math.sin(t * .35);
479
+ const pt = makeProj(t * spin, tilt, cx, cy, radius);
480
+ const scan = t * (spin + (1.7 - spin) * (o.scanMul ?? 1));
481
+ const rs = radiusScale(size, o.rsPow ?? .6);
482
+ const dimBase = o.dimBase ?? 1;
483
+ const dots = [];
484
+ const latRings = o.latRings ?? 17;
485
+ const lonDensity = o.lonDensity ?? 44;
486
+ for (let li = 0; li <= latRings; li++) {
487
+ const lat = -Math.PI / 2 + li / latRings * Math.PI;
488
+ const cosLat = Math.cos(lat);
489
+ const sinLat = Math.sin(lat);
490
+ const lonCount = Math.max(1, Math.round(Math.abs(cosLat) * lonDensity));
491
+ for (let lj = 0; lj < lonCount; lj++) {
492
+ const lon = lj / lonCount * 2 * Math.PI;
493
+ const [px, py, z] = pt(cosLat * Math.cos(lon), sinLat, cosLat * Math.sin(lon));
494
+ const depth = (z + 1) / 2;
495
+ const d = angleDelta(lon + t * spin, scan);
496
+ const boost = Math.exp(-(d * d) / .18) * Math.max(0, z);
497
+ dots.push({
498
+ x: px,
499
+ y: py,
500
+ z,
501
+ r: ((o.rBase ?? .6) + (o.rDepth ?? 1.7) * depth + (o.rBoost ?? 1) * boost) * rs,
502
+ white: (o.inkFar ?? .62) - (o.inkSpan ?? .54) * depth,
503
+ a: dimBase + (1 - dimBase) * Math.min(1, boost)
504
+ });
505
+ }
506
+ }
507
+ return finalizeFrame(dots, [], o.rMin);
508
+ };
509
+ function solveCycle(time, count, slotDur, rest) {
510
+ const tc = time % (2 * count * slotDur + rest);
511
+ const amount = new Array(count).fill(0);
512
+ let active = -1;
513
+ if (tc < 2 * count * slotDur) {
514
+ const slot = Math.floor(tc / slotDur);
515
+ const p = (tc - slot * slotDur) / slotDur;
516
+ const ep = 1 - (1 - Math.min(1, p / .7)) ** 3;
517
+ if (slot < count) {
518
+ for (let i = 0; i < slot; i++) amount[i] = 1;
519
+ amount[slot] = ep;
520
+ active = slot;
521
+ } else {
522
+ const u = 2 * count - 1 - slot;
523
+ for (let i = 0; i < u; i++) amount[i] = 1;
524
+ amount[u] = 1 - ep;
525
+ active = u;
526
+ }
527
+ }
528
+ return {
529
+ amount,
530
+ active
531
+ };
532
+ }
533
+ function applyMoves(pt3, moves, sc) {
534
+ let [x, y, z] = pt3;
535
+ let inActive = false;
536
+ for (let i = 0; i < moves.length; i++) {
537
+ if (sc.amount[i] <= 0) continue;
538
+ const mv = moves[i];
539
+ const coord = mv.axis === 0 ? x : mv.axis === 1 ? y : z;
540
+ if (coord < mv.lo || coord >= mv.hi) continue;
541
+ if (i === sc.active) inActive = true;
542
+ const a = mv.ang * sc.amount[i];
543
+ const ca = Math.cos(a);
544
+ const sa = Math.sin(a);
545
+ if (mv.axis === 0) {
546
+ const y2 = y * ca - z * sa;
547
+ z = y * sa + z * ca;
548
+ y = y2;
549
+ } else if (mv.axis === 1) {
550
+ const x2 = x * ca + z * sa;
551
+ z = -x * sa + z * ca;
552
+ x = x2;
553
+ } else {
554
+ const x2 = x * ca - y * sa;
555
+ y = x * sa + y * ca;
556
+ x = x2;
557
+ }
558
+ }
559
+ return [
560
+ x,
561
+ y,
562
+ z,
563
+ inActive
564
+ ];
565
+ }
566
+ function makeMoves(count) {
567
+ const moves = [];
568
+ for (let i = 0; i < count; i++) {
569
+ const axis = Math.min(2, Math.floor(hashD(i, 2.3) * 3));
570
+ const lo = -1 + .5 * Math.min(3, Math.floor(hashD(i, 5.9) * 4));
571
+ const dir = hashD(i, 7.7) < .5 ? 1 : -1;
572
+ moves.push({
573
+ axis,
574
+ lo,
575
+ hi: lo + .5,
576
+ ang: dir * Math.PI / 2
577
+ });
578
+ }
579
+ return moves;
580
+ }
581
+ const frameRubik = (size, t, o) => {
582
+ const cx = size / 2;
583
+ const cy = size / 2;
584
+ const R = size / 2 * .82;
585
+ const pt = makeProj(t * .55, .35 + .1 * Math.sin(t * .9), cx, cy, R);
586
+ const rs = radiusScale(size, o.rsPow ?? .6);
587
+ const moveCount = o.moveCount ?? 14;
588
+ const moves = makeMoves(moveCount);
589
+ const sc = solveCycle(t, moveCount, .42, 1.2);
590
+ const dots = [];
591
+ const latRings = o.latRings ?? 15;
592
+ const lonDensity = o.lonDensity ?? 40;
593
+ for (let li = 0; li <= latRings; li++) {
594
+ const lat = -Math.PI / 2 + li / latRings * Math.PI;
595
+ const cosLat = Math.cos(lat);
596
+ const sinLat = Math.sin(lat);
597
+ const lonCount = Math.max(1, Math.round(Math.abs(cosLat) * lonDensity));
598
+ for (let lj = 0; lj < lonCount; lj++) {
599
+ const lon = lj / lonCount * 2 * Math.PI;
600
+ const [x, y, z, inActive] = applyMoves([
601
+ cosLat * Math.cos(lon),
602
+ sinLat,
603
+ cosLat * Math.sin(lon)
604
+ ], moves, sc);
605
+ const [px, py, zr] = pt(x, y, z);
606
+ const depth = (zr + 1) / 2;
607
+ dots.push({
608
+ x: px,
609
+ y: py,
610
+ z: zr,
611
+ r: ((o.rBase ?? .6) + (o.rDepth ?? 1.7) * depth + (inActive ? o.rActive ?? .3 : 0)) * rs,
612
+ white: (o.inkFar ?? .62) - (o.inkSpan ?? .54) * depth - (inActive ? .14 : 0)
613
+ });
614
+ }
615
+ }
616
+ return finalizeFrame(dots, [], o.rMin);
617
+ };
618
+ const frameWave = (size, t, o) => {
619
+ const cx = size / 2;
620
+ const cy = size / 2;
621
+ const R = size / 2 * .874;
622
+ const pt = makeProj(t * .18, .38, cx, cy, 1);
623
+ const rs = radiusScale(size, o.rsPow ?? .6);
624
+ const dots = [];
625
+ const rings = o.rings ?? 15;
626
+ const lonDensity = o.lonDensity ?? 40;
627
+ for (let ri = 0; ri <= rings; ri++) {
628
+ const lat = -Math.PI / 2 + ri / rings * Math.PI;
629
+ const cosLat = Math.cos(lat);
630
+ const sinLat = Math.sin(lat);
631
+ const w = .62 * Math.sin(t * 2.1 - ri * .52) + .38 * Math.sin(t * 1.27 + ri * .83);
632
+ const rr = R * (.88 + .105 * w);
633
+ const lonCount = Math.max(1, Math.round(Math.abs(cosLat) * lonDensity));
634
+ for (let lj = 0; lj < lonCount; lj++) {
635
+ const lon = lj / lonCount * 2 * Math.PI;
636
+ const [px, py, z] = pt(cosLat * Math.cos(lon) * rr, sinLat * rr, cosLat * Math.sin(lon) * rr);
637
+ const depth = (z / R + 1) / 2;
638
+ const crest = Math.max(0, w);
639
+ dots.push({
640
+ x: px,
641
+ y: py,
642
+ z,
643
+ r: ((o.rBase ?? .6) + (o.rDepth ?? 1.7) * depth) * (1 + .4 * crest) * rs,
644
+ white: .66 - .56 * depth - .1 * crest
645
+ });
646
+ }
647
+ }
648
+ return finalizeFrame(dots, [], o.rMin);
649
+ };
650
+ const frameOrbits = (size, t, o) => {
651
+ const cx = size / 2;
652
+ const cy = size / 2;
653
+ const R = size / 2 * .82;
654
+ const pt = makeProj(t * .12, .3, cx, cy, 1);
655
+ const rs = radiusScale(size, o.rsPow ?? .6);
656
+ const dots = [];
657
+ const orbitN = o.orbitN ?? 12;
658
+ const ghostN = o.ghostN ?? 40;
659
+ const particles = o.particles ?? 3;
660
+ for (let orb = 0; orb < orbitN; orb++) {
661
+ const h1 = hashD(orb, 1.7);
662
+ const h2 = hashD(orb, 5.2);
663
+ const h3 = hashD(orb, 8.9);
664
+ const ro = R * (.45 + .52 * h1);
665
+ const th = h1 * 2 * Math.PI;
666
+ const phi = Math.acos(2 * h2 - 1);
667
+ const nx = Math.sin(phi) * Math.cos(th);
668
+ const ny = Math.cos(phi);
669
+ const nz = Math.sin(phi) * Math.sin(th);
670
+ let ux = -ny;
671
+ let uy = nx;
672
+ const uz = 0;
673
+ const ul = Math.max(1e-6, Math.sqrt(ux * ux + uy * uy));
674
+ ux /= ul;
675
+ uy /= ul;
676
+ const vx = ny * uz - nz * uy;
677
+ const vy = nz * ux - nx * uz;
678
+ const vz = nx * uy - ny * ux;
679
+ const speed = (.25 + .55 * h3) * (h3 > .5 ? 1 : -1);
680
+ for (let k = 0; k < ghostN; k++) {
681
+ const a = k / ghostN * 2 * Math.PI;
682
+ const [px, py, z] = pt((ux * Math.cos(a) + vx * Math.sin(a)) * ro, (uy * Math.cos(a) + vy * Math.sin(a)) * ro, (uz * Math.cos(a) + vz * Math.sin(a)) * ro);
683
+ const depth = (z / ro + 1) / 2;
684
+ dots.push({
685
+ x: px,
686
+ y: py,
687
+ z,
688
+ r: (o.ghostR ?? .9) * rs,
689
+ white: .72,
690
+ a: (o.ghostA ?? .5) * (.4 + .6 * depth)
691
+ });
692
+ }
693
+ for (let m = 0; m < particles; m++) {
694
+ const a = t * speed + m / particles * 2 * Math.PI + h2 * 6;
695
+ const [px, py, z] = pt((ux * Math.cos(a) + vx * Math.sin(a)) * ro, (uy * Math.cos(a) + vy * Math.sin(a)) * ro, (uz * Math.cos(a) + vz * Math.sin(a)) * ro);
696
+ const depth = (z / ro + 1) / 2;
697
+ dots.push({
698
+ x: px,
699
+ y: py,
700
+ z,
701
+ r: ((o.partR ?? 1.2) + (o.partRDepth ?? 1.6) * depth) * rs,
702
+ white: .3 - .22 * depth
703
+ });
704
+ }
705
+ }
706
+ return finalizeFrame(dots, [], o.rMin);
707
+ };
708
+ const frameRibbon = (size, t, o) => {
709
+ const cx = size / 2;
710
+ const cy = size / 2;
711
+ const R = size / 2 * .78;
712
+ const spin = o.spin ?? 1;
713
+ const camTilt = .3;
714
+ const pt = makeProj(t * .1 * spin, camTilt, cx, cy, 1);
715
+ const rs = radiusScale(size, o.rsPow ?? .6);
716
+ const dots = [];
717
+ const ghostN = o.ghostN ?? 150;
718
+ for (let i = 0; i < ghostN; i++) {
719
+ const d = fibDir(i, ghostN);
720
+ const [px, py, z] = pt(d[0] * R, d[1] * R, d[2] * R);
721
+ const depth = (z / R + 1) / 2;
722
+ dots.push({
723
+ x: px,
724
+ y: py,
725
+ z,
726
+ r: .8 * rs,
727
+ white: .78,
728
+ a: .1 + .22 * depth
729
+ });
730
+ }
731
+ const ya = t * .24 * spin;
732
+ const ta = o.faceOn ? -camTilt : .55 + .3 * Math.sin(t * .18) * spin;
733
+ const ux = Math.cos(ya);
734
+ const uy = 0;
735
+ const uz = Math.sin(ya);
736
+ const vx = -uz * Math.sin(ta);
737
+ const vy = Math.cos(ta);
738
+ const vz = ux * Math.sin(ta);
739
+ const nx = uy * vz - uz * vy;
740
+ const ny = uz * vx - ux * vz;
741
+ const nz = ux * vy - uy * vx;
742
+ const wobAmp = .23 * (o.wobMul ?? 1);
743
+ const baseR = o.faceOn ? R / (1 + .85 * wobAmp) : R;
744
+ const baseLanes = o.lanes ?? 5;
745
+ const segs = o.segs ?? 88;
746
+ const lanes = Math.max(1, Math.round(baseLanes * (o.bandMul ?? 1)));
747
+ for (let w = 0; w < lanes; w++) {
748
+ const laneOff = (w - (lanes - 1) / 2) * .075;
749
+ const edge = Math.abs(w - (lanes - 1) / 2) / Math.max(1, (lanes - 1) / 2);
750
+ for (let k = 0; k < segs; k++) {
751
+ const a = k / segs * 2 * Math.PI;
752
+ const wob = (.16 * Math.sin(a * 3 - t * 1.7 + w * .22) + .07 * Math.sin(a * 5 + t * 1.1)) * (o.wobMul ?? 1);
753
+ const radial = o.faceOn ? 1 + wob : 1;
754
+ const off = o.faceOn ? laneOff : laneOff + wob;
755
+ const x = ux * Math.cos(a) + vx * Math.sin(a) + nx * off;
756
+ const y = uy * Math.cos(a) + vy * Math.sin(a) + ny * off;
757
+ const z = uz * Math.cos(a) + vz * Math.sin(a) + nz * off;
758
+ const l = Math.sqrt(x * x + y * y + z * z);
759
+ const rr = baseR * radial;
760
+ const [px, py, zr] = pt(x / l * rr, y / l * rr, z / l * rr);
761
+ const depth = (zr / R + 1) / 2;
762
+ dots.push({
763
+ x: px,
764
+ y: py,
765
+ z: zr,
766
+ r: ((o.rBase ?? 1.1) + (o.rDepth ?? 1.7) * depth) * (1 - .25 * edge) * rs,
767
+ white: .52 - .44 * depth + .18 * edge,
768
+ a: .4 + .6 * depth
769
+ });
770
+ }
771
+ }
772
+ return finalizeFrame(dots, [], o.rMin);
773
+ };
774
+ function smoothE(x) {
775
+ return x * x * (3 - 2 * x);
776
+ }
777
+ function polyPath(verts) {
778
+ const V = verts.length;
779
+ const L = [];
780
+ let total = 0;
781
+ for (let i = 0; i < V; i++) {
782
+ const a = verts[i];
783
+ const b = verts[(i + 1) % V];
784
+ const l = Math.hypot(b[0] - a[0], b[1] - a[1]);
785
+ L.push(l);
786
+ total += l;
787
+ }
788
+ return (f) => {
789
+ let target = f * total;
790
+ let i = 0;
791
+ while (target > L[i] && i < V - 1) {
792
+ target -= L[i];
793
+ i++;
794
+ }
795
+ const a = verts[i];
796
+ const b = verts[(i + 1) % V];
797
+ const ff = L[i] ? Math.min(1, target / L[i]) : 0;
798
+ return [a[0] + (b[0] - a[0]) * ff, a[1] + (b[1] - a[1]) * ff];
799
+ };
800
+ }
801
+ var CIRCLE = (f) => {
802
+ const a = -Math.PI / 2 + f * 2 * Math.PI;
803
+ return [Math.cos(a) * .24, Math.sin(a) * .24];
804
+ };
805
+ var CYCLE = [
806
+ CIRCLE,
807
+ polyPath([
808
+ [0, -.26],
809
+ [.24, .16],
810
+ [-.24, .16]
811
+ ]),
812
+ polyPath([
813
+ [0, -.2],
814
+ [.2, -.2],
815
+ [.2, .2],
816
+ [-.2, .2],
817
+ [-.2, -.2]
818
+ ])
819
+ ];
820
+ function morphN(d) {
821
+ return Math.max(6, Math.round(34 * d));
822
+ }
823
+ var HOLD = 1.4;
824
+ var MORPH = .9;
825
+ var SEG = HOLD + MORPH;
826
+ const frameMorph = (size, t, o) => {
827
+ const K = CYCLE.length;
828
+ const tc = t % (SEG * K);
829
+ const k = Math.floor(tc / SEG);
830
+ const local = tc - k * SEG;
831
+ const m = local > HOLD ? smoothE((local - HOLD) / MORPH) : 0;
832
+ const sprd = o.spread ?? 1;
833
+ const pA = CYCLE[k];
834
+ const pB = CYCLE[(k + 1) % K];
835
+ const M = 160;
836
+ const pts = [];
837
+ for (let i = 0; i < M; i++) {
838
+ const f = i / M;
839
+ const a = pA(f);
840
+ const b = pB(f);
841
+ pts.push([(a[0] + (b[0] - a[0]) * m) * sprd, (a[1] + (b[1] - a[1]) * m) * sprd]);
842
+ }
843
+ const L = [];
844
+ let total = 0;
845
+ for (let i = 0; i < M; i++) {
846
+ const a = pts[i];
847
+ const b = pts[(i + 1) % M];
848
+ const l = Math.hypot(b[0] - a[0], b[1] - a[1]);
849
+ L.push(l);
850
+ total += l;
851
+ }
852
+ const n = morphN(o.iconD ?? 1);
853
+ const re = (o.rDot ?? .021) * 1.35 * sprd;
854
+ const pulse = 1 + .02 * Math.sin(local * 3.1);
855
+ const dots = [];
856
+ const c2 = size / 2;
857
+ let seg = 0;
858
+ let acc = 0;
859
+ for (let k2 = 0; k2 < n; k2++) {
860
+ const target = k2 / n * total;
861
+ while (acc + L[seg] < target && seg < M - 1) {
862
+ acc += L[seg];
863
+ seg++;
864
+ }
865
+ const a = pts[seg];
866
+ const b = pts[(seg + 1) % M];
867
+ const f = L[seg] ? Math.min(1, (target - acc) / L[seg]) : 0;
868
+ const x = (a[0] + (b[0] - a[0]) * f) * pulse;
869
+ const y = (a[1] + (b[1] - a[1]) * f) * pulse;
870
+ dots.push({
871
+ x: c2 + x * size,
872
+ y: c2 + y * size,
873
+ z: 0,
874
+ r: Math.max(.35, re * size),
875
+ white: .1
876
+ });
877
+ }
878
+ return finalizeFrame(dots, [], o.rMin);
879
+ };
880
+ const earthPointData = {
881
+ "20": {
882
+ rings: 9,
883
+ flags: "01100000000000000000000000000000100010000100000011000110011000000000011111100000011001001100011000111010"
884
+ },
885
+ "32": {
886
+ rings: 17,
887
+ flags: "011001001111000000000000000000000100000000000000000000010000000000000000000000000110000010000000101000000000000111000001110000001110000000000001111000011100000000000000000000001110000011110000001000000000000000100000111111000000000000000000100000001111111010100000000000011000000110011111111000000011110000101001111100000011110001111111100011100001111111000000010000"
888
+ },
889
+ "48": {
890
+ rings: 29,
891
+ flags: "111011111111001011001111111100000000000000101111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000001000000000000001100000000000000000000000001100000000000000000001100000000001100000000000011111000000000000000000001110000000001110100000000001111100000000000000000000011111000000001111010000000000011100000000000000000000001111110000000011110000000000000001100000000000000000000011111111000000011111000000000000000010100000000000000000000111100000000001111100000000000100000000000000000000000000011100000000111111111000001000000000000000000000000000000100000000001111111111000001000100000000000000000000000101001000000001111111111100110110000000000000000000001110010000000001111111111001111111100000000000000000111110000000000111110111111111111000000000000000011111100000000100001111111111110010000000000011111100000000101101111111111100000000000111111010000011111111111111100000000011110100000100111111111110100011111010100010111111111111111010010001011111110001001100001000000110000000"
892
+ },
893
+ "64": {
894
+ rings: 37,
895
+ flags: "111011111111011110011111111100000001000111111111110000000000000000001101111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000011100000000000010000000000000001000111000000000000000000000000111100000000000011100000000000000011111110000000000000000000000000111100000000000011110100000000000011111110000000000000000000000000001111110000000000111100100000000000000111110000000000000000000000000001111111100000000001111110100000000000000011000000000000000000000000000001111111110000000000111110000000000000000000000001000000000000000000000000111111111000000000011111100000000000000000000100000000000000000000000000001111110000000000001111111000000000000101100000000000000000000000000000000001111100000000000011111111000000000011001000000000000000000000000000000000001100000000011111111111110000010000010000000000000000000000000000000011000000000000011111111111110000011000110000000000000000000000000000011000010000000000111111111111111000110011000000000000000000000000000011000100000000000111111111111110011111111110000000000000000000000011100000000000000011111111111111111111111100000000000000000000011111110000000000001110000111111111111110000000000000000000011111110000000000010000011101111111111000000000000000000011111111000000000010110010111111111111000000000000001111111101000000111111111111111111110000000000001111101110000011111111111111111110000000001111100100000010101111111111110010011111111010100000111111111111111101111010011000011111111111100001110110000001110000001011101000000000000000000"
896
+ },
897
+ "96": {
898
+ rings: 53,
899
+ flags: "111111111111001111011111111100111110011111111111110000110111000111111111111110000000000001000000111111111111111100000000000000000000000000110111111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000001100000000000000000000000000000000000000000000000001000000000000000000000000011100000000000000000000000000000000000000000000000000001000000000000000000000000011110000000000000000000000000000000000000000000000110000001000000000000000000000000000111100000000000000000011000000000000000000000010000111000000000000000000000000000000000001111100000000000000000111100000000000000000000011111111110000000000000000000000000000000000011111100000000000000001111100000000000000000000011111111110000000000000000000000000000000000000111111100000000000000001111110010000000000000000001111111111000000000000000000000000000000000000001111111100000000000000011111100100000000000000000000111111110000000000000000000000000000000000000001111111110000000000000011111111011000000000000000000001111101000000000000000000000000000000000000000111111111110000000000000001111111100000000000000000000000001101000000000000000000000000000000000000000011111111111100000000000000111111110000000000000000000000000000000100000000000000000000000000000000000000111111111111100000000000000111111100000000000000000000110000000111000000000000000000000000000000000000000111111111111000000000000000111111110000000000000000000101101000111000000000000000000000000000000000000000011111111100000000000000000111111111100000000000000000100110000000000000000000000000000000000000000000000000111111100000000000000000011111111111000000000000000110001000000000000000000000000000000000000000000000000111111000000000000001111111111111111100000000010000010000001000000000000000000000000000000000000000000000011100000000000000111111111111111111100000000000000000000000000000000000000000000000000000000000000011000000000000000000011111111111111111110000000110000011100000000000000000000000000000000000000000001110000000000000000000011111111111111110111000000110001111000000000000000000000000000000000000000001100100010000000000000001111111111111110111110000111101111000000000000000000000000000000000000000011100000000000000000000001111111111111111111100111111111111111000000000000000000000000000000000011100001000000000000000001111111111110111011111111111111111100000000000000000000000000000000111111110000000000000000000111111111111111111111111111111111000000000000000000000000000000111111111000000000000000000111100000011111111111111111111100100000000000000000000000001111111111100000000000000011000000011111011111111111111100100000000000000000000000011111111111000000000000000110100111111001111111111111101000000000000000000000001111111111110000000000000011101110010111111111111111111010000000000000000000111111111101010000000000111111111111111111111111111100000000000000000011111111111111000000000111111111111111111111111111100000000000000011111111011110000000000001111111111111111111110001000000000001111110001100000000000010111111111111111111000100000111111111100100010000000101111111111111111111010001111111111111001000100010111111111111111111110111111001010011000001111111111111111111000001111101110000000101111111100000000010011100000000110000000000011110010000000000000101100000000000000000000"
900
+ }
901
+ };
902
+ var cache = /* @__PURE__ */ new Map();
903
+ function getEarthPoints(size) {
904
+ const hit = cache.get(size);
905
+ if (hit) return hit;
906
+ const { rings, flags } = earthPointData[size];
907
+ const points = [];
908
+ let index = 0;
909
+ for (let row = 0; row < rings; row++) {
910
+ const lat = -Math.PI / 2 + (row + .5) / rings * Math.PI;
911
+ const count = Math.max(1, Math.round(2 * rings * Math.cos(lat)));
912
+ for (let col = 0; col < count; col++, index++) {
913
+ const lon = -Math.PI + col / count * 2 * Math.PI;
914
+ const land = flags[index] === "1";
915
+ if (!land && index % 3 !== 0) continue;
916
+ points.push({
917
+ x: Math.cos(lat) * Math.cos(lon),
918
+ y: Math.sin(lat),
919
+ z: Math.cos(lat) * Math.sin(lon),
920
+ lon,
921
+ land
922
+ });
923
+ }
924
+ }
925
+ cache.set(size, points);
926
+ return points;
927
+ }
928
+ function frameEarth(size, time) {
929
+ const project = makeProj(35 * Math.PI / 180 - Math.PI / 2 + time * .22, .18, size / 2, size / 2, size * .43);
930
+ const dots = [];
931
+ for (const p of getEarthPoints(size)) {
932
+ const [x, y, z] = project(p.x, p.y, p.z);
933
+ if (z <= 0) continue;
934
+ const scan = Math.exp(-Math.pow(angleDelta(p.lon, time * .9), 2) / .08);
935
+ const edge = Math.min(1, z / .14);
936
+ dots.push({
937
+ x,
938
+ y,
939
+ z,
940
+ r: (size <= 32 ? .48 : .52) * (size / 64) ** .25 * (1 + .2 * z + (p.land ? .22 * scan : 0)),
941
+ white: p.land ? .08 + .2 * (1 - z) : .65,
942
+ a: edge * (p.land ? .82 + scan * .18 : .2)
943
+ });
944
+ }
945
+ return finalizeFrame(dots, [], .3);
946
+ }
947
+ var frames = {
948
+ searching: frameGlobe,
949
+ solving: frameRubik,
950
+ listening: frameWave,
951
+ working: frameOrbits,
952
+ composing: frameRibbon,
953
+ shaping: frameMorph
954
+ };
955
+ function createLoadingFrame(animation, size, time) {
956
+ if (animation === "earth") return frameEarth(size, time);
957
+ const { speed, opts } = resolvePreset(animation, size);
958
+ const frame = frames[animation](size, time * speed, opts);
959
+ if (size === 20 && frame.dots.length > 120) {
960
+ const count = frame.dots.length;
961
+ frame.dots = Array.from({ length: 120 }, (_, i) => frame.dots[Math.floor(i * count / 120)]);
962
+ }
963
+ return frame;
964
+ }
965
+ function paintLoadingFrame(ctx, frame, color) {
966
+ ctx.fillStyle = color;
967
+ for (const dot of frame.dots) {
968
+ ctx.globalAlpha = Math.max(0, Math.min(1, (dot.a ?? 1) * (1 - dot.white)));
969
+ ctx.beginPath();
970
+ ctx.arc(dot.x, dot.y, dot.r, 0, Math.PI * 2);
971
+ ctx.fill();
972
+ }
973
+ ctx.globalAlpha = 1;
974
+ }
975
+ function useLoadingAnimation(canvas, options, color) {
976
+ const available = ref(true);
977
+ let ctx = null;
978
+ let raf;
979
+ let previous;
980
+ let elapsed = 0;
981
+ let enabled = true;
982
+ let inView = true;
983
+ let reduced = false;
984
+ let mounted = false;
985
+ let dpr = 1;
986
+ let observer;
987
+ let motion;
988
+ const stop = () => {
989
+ if (raf !== void 0) cancelAnimationFrame(raf);
990
+ raf = void 0;
991
+ previous = void 0;
992
+ };
993
+ const running = () => mounted && ctx && enabled && inView && options().active && !options().paused && !reduced && document.visibilityState !== "hidden";
994
+ const paint = () => {
995
+ if (!ctx || !canvas.value) return;
996
+ const size = normalizeSize(options().size);
997
+ const ratio = Math.min(2, Math.max(1, window.devicePixelRatio || 1));
998
+ if (canvas.value.width !== Math.round(size * ratio) || ratio !== dpr) {
999
+ canvas.value.width = Math.round(size * ratio);
1000
+ canvas.value.height = Math.round(size * ratio);
1001
+ }
1002
+ dpr = ratio;
1003
+ ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
1004
+ ctx.clearRect(0, 0, size, size);
1005
+ try {
1006
+ paintLoadingFrame(ctx, createLoadingFrame(normalizeAnimation(options().animation), size, reduced ? .6 : elapsed), color.value);
1007
+ } catch {
1008
+ available.value = false;
1009
+ ctx = null;
1010
+ stop();
1011
+ }
1012
+ };
1013
+ const tick = (now) => {
1014
+ raf = void 0;
1015
+ if (!running()) {
1016
+ previous = void 0;
1017
+ return;
1018
+ }
1019
+ if (previous !== void 0) elapsed += Math.min(100, now - previous) / 1e3 * normalizeSpeed(options().speed);
1020
+ previous = now;
1021
+ paint();
1022
+ if (running()) raf = requestAnimationFrame(tick);
1023
+ };
1024
+ const sync = () => {
1025
+ if (!mounted) return;
1026
+ if (!running()) stop();
1027
+ if (options().active && inView && enabled && document.visibilityState !== "hidden") paint();
1028
+ if (running() && raf === void 0) raf = requestAnimationFrame(tick);
1029
+ };
1030
+ const motionChange = () => {
1031
+ reduced = motion?.matches ?? false;
1032
+ sync();
1033
+ };
1034
+ watch(() => [
1035
+ options().active,
1036
+ options().paused,
1037
+ options().animation,
1038
+ options().size,
1039
+ options().speed,
1040
+ color.value
1041
+ ], sync, { flush: "post" });
1042
+ onMounted(() => {
1043
+ mounted = true;
1044
+ try {
1045
+ ctx = canvas.value?.getContext("2d") ?? null;
1046
+ } catch {
1047
+ ctx = null;
1048
+ }
1049
+ available.value = !!ctx;
1050
+ motion = window.matchMedia?.("(prefers-reduced-motion: reduce)");
1051
+ reduced = motion?.matches ?? false;
1052
+ motion?.addEventListener("change", motionChange);
1053
+ if (typeof IntersectionObserver !== "undefined" && canvas.value) {
1054
+ observer = new IntersectionObserver(([entry]) => {
1055
+ inView = entry.isIntersecting;
1056
+ sync();
1057
+ });
1058
+ observer.observe(canvas.value);
1059
+ }
1060
+ document.addEventListener("visibilitychange", sync);
1061
+ window.addEventListener("resize", sync);
1062
+ sync();
1063
+ });
1064
+ onActivated(() => {
1065
+ enabled = true;
1066
+ sync();
1067
+ });
1068
+ onDeactivated(() => {
1069
+ enabled = false;
1070
+ stop();
1071
+ });
1072
+ onScopeDispose(() => {
1073
+ mounted = false;
1074
+ stop();
1075
+ observer?.disconnect();
1076
+ motion?.removeEventListener("change", motionChange);
1077
+ if (typeof document !== "undefined") document.removeEventListener("visibilitychange", sync);
1078
+ if (typeof window !== "undefined") window.removeEventListener("resize", sync);
1079
+ ctx = null;
1080
+ });
1081
+ return { available };
1082
+ }
1083
+ var _hoisted_1 = [
1084
+ "role",
1085
+ "aria-live",
1086
+ "aria-hidden",
1087
+ "aria-label"
1088
+ ];
1089
+ var FlLoading_default = /* @__PURE__ */ defineComponent({
1090
+ name: "FlLoading",
1091
+ __name: "FlLoading",
1092
+ props: flLoadingProps,
1093
+ setup(__props) {
1094
+ const props = __props;
1095
+ const ns = useNamespace("loading");
1096
+ const root = ref();
1097
+ const canvas = ref();
1098
+ const resolvedSize = computed(() => normalizeSize(props.size));
1099
+ const resolvedColor = useLoadingColor(() => root.value, () => props);
1100
+ const { available } = useLoadingAnimation(canvas, () => props, resolvedColor);
1101
+ return (_ctx, _cache) => {
1102
+ return openBlock(), createElementBlock("span", {
1103
+ ref_key: "root",
1104
+ ref: root,
1105
+ class: normalizeClass([
1106
+ unref(ns).b(),
1107
+ unref(ns).m(_ctx.layout),
1108
+ unref(ns).is("inactive", !_ctx.active)
1109
+ ]),
1110
+ style: normalizeStyle({ "--fl-loading-size": `${resolvedSize.value}px` }),
1111
+ role: _ctx.active ? "status" : void 0,
1112
+ "aria-live": _ctx.active ? "polite" : "off",
1113
+ "aria-hidden": !_ctx.active || void 0,
1114
+ "aria-label": !_ctx.text && !_ctx.$slots.text ? _ctx.ariaLabel : void 0
1115
+ }, [createElementVNode("span", {
1116
+ class: normalizeClass(unref(ns).e("visual")),
1117
+ "aria-hidden": "true"
1118
+ }, [withDirectives(createElementVNode("canvas", {
1119
+ ref_key: "canvas",
1120
+ ref: canvas,
1121
+ class: normalizeClass(unref(ns).e("canvas")),
1122
+ style: normalizeStyle({
1123
+ width: `${resolvedSize.value}px`,
1124
+ height: `${resolvedSize.value}px`
1125
+ })
1126
+ }, null, 6), [[vShow, unref(available)]]), !unref(available) ? (openBlock(), createElementBlock("span", {
1127
+ key: 0,
1128
+ class: normalizeClass(unref(ns).e("fallback")),
1129
+ style: normalizeStyle({ color: unref(resolvedColor) })
1130
+ }, "●", 6)) : createCommentVNode("v-if", true)], 2), _ctx.text || _ctx.$slots.text ? (openBlock(), createElementBlock("span", {
1131
+ key: 0,
1132
+ class: normalizeClass(unref(ns).e("text"))
1133
+ }, [renderSlot(_ctx.$slots, "text", {}, () => [createTextVNode(toDisplayString(_ctx.text), 1)])], 2)) : createCommentVNode("v-if", true)], 14, _hoisted_1);
1134
+ };
1135
+ }
1136
+ });
1137
+ function useFlLoading(active, options = {}) {
1138
+ const ns = useNamespace("loading");
1139
+ const alive = ref(true);
1140
+ const generation = ref(0);
1141
+ const resolved = computed(() => toValue(options));
1142
+ const color = useLoadingColor(() => toValue(resolved.value.themeTarget), () => resolved.value);
1143
+ watch(() => toValue(active), () => generation.value++, { flush: "sync" });
1144
+ onScopeDispose(() => {
1145
+ alive.value = false;
1146
+ });
1147
+ const Content = defineComponent({
1148
+ name: "FlLoadingContent",
1149
+ props: { generation: {
1150
+ type: Number,
1151
+ required: true
1152
+ } },
1153
+ setup(props) {
1154
+ const ownGeneration = props.generation;
1155
+ return () => {
1156
+ const { background: _background, customClass: _customClass, themeTarget: _target, ...visual } = resolved.value;
1157
+ return h(FlLoading_default, {
1158
+ layout: "vertical",
1159
+ ...visual,
1160
+ color: color.value,
1161
+ active: alive.value && toValue(active) && ownGeneration === generation.value
1162
+ });
1163
+ };
1164
+ }
1165
+ });
1166
+ return computed(() => {
1167
+ if (!alive.value || !toValue(active)) return false;
1168
+ return {
1169
+ text: h(Content, { generation: generation.value }),
1170
+ customClass: [ns.b("adapter"), resolved.value.customClass].filter(Boolean).join(" "),
1171
+ background: resolved.value.background
1172
+ };
1173
+ });
1174
+ }
1175
+ const FlLoading = withInstall(FlLoading_default);
1176
+ var loading_default = FlLoading;
1177
+ export { FlLoading, loading_default as default, useFlLoading };
1178
+
1179
+ //# sourceMappingURL=index.mjs.map