partycles 0.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 (73) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +295 -0
  3. package/dist/animations/animations/bubbles.d.ts +8 -0
  4. package/dist/animations/animations/bubbles.d.ts.map +1 -0
  5. package/dist/animations/animations/confetti.d.ts +8 -0
  6. package/dist/animations/animations/confetti.d.ts.map +1 -0
  7. package/dist/animations/animations/fireworks.d.ts +8 -0
  8. package/dist/animations/animations/fireworks.d.ts.map +1 -0
  9. package/dist/animations/animations/hearts.d.ts +8 -0
  10. package/dist/animations/animations/hearts.d.ts.map +1 -0
  11. package/dist/animations/animations/index.d.ts +13 -0
  12. package/dist/animations/animations/index.d.ts.map +1 -0
  13. package/dist/animations/animations/sparkles.d.ts +8 -0
  14. package/dist/animations/animations/sparkles.d.ts.map +1 -0
  15. package/dist/animations/animations/stars.d.ts +8 -0
  16. package/dist/animations/animations/stars.d.ts.map +1 -0
  17. package/dist/animations/bubbles.d.ts +8 -0
  18. package/dist/animations/bubbles.d.ts.map +1 -0
  19. package/dist/animations/bubbles.esm.js +46 -0
  20. package/dist/animations/bubbles.esm.js.map +1 -0
  21. package/dist/animations/bubbles.js +49 -0
  22. package/dist/animations/bubbles.js.map +1 -0
  23. package/dist/animations/confetti.d.ts +8 -0
  24. package/dist/animations/confetti.d.ts.map +1 -0
  25. package/dist/animations/confetti.esm.js +50 -0
  26. package/dist/animations/confetti.esm.js.map +1 -0
  27. package/dist/animations/confetti.js +53 -0
  28. package/dist/animations/confetti.js.map +1 -0
  29. package/dist/animations/fireworks.d.ts +8 -0
  30. package/dist/animations/fireworks.d.ts.map +1 -0
  31. package/dist/animations/fireworks.esm.js +56 -0
  32. package/dist/animations/fireworks.esm.js.map +1 -0
  33. package/dist/animations/fireworks.js +59 -0
  34. package/dist/animations/fireworks.js.map +1 -0
  35. package/dist/animations/hearts.d.ts +8 -0
  36. package/dist/animations/hearts.d.ts.map +1 -0
  37. package/dist/animations/hearts.esm.js +44 -0
  38. package/dist/animations/hearts.esm.js.map +1 -0
  39. package/dist/animations/hearts.js +47 -0
  40. package/dist/animations/hearts.js.map +1 -0
  41. package/dist/animations/index.d.ts +3 -0
  42. package/dist/animations/index.d.ts.map +1 -0
  43. package/dist/animations/sparkles.d.ts +8 -0
  44. package/dist/animations/sparkles.d.ts.map +1 -0
  45. package/dist/animations/sparkles.esm.js +40 -0
  46. package/dist/animations/sparkles.esm.js.map +1 -0
  47. package/dist/animations/sparkles.js +43 -0
  48. package/dist/animations/sparkles.js.map +1 -0
  49. package/dist/animations/stars.d.ts +8 -0
  50. package/dist/animations/stars.d.ts.map +1 -0
  51. package/dist/animations/stars.esm.js +40 -0
  52. package/dist/animations/stars.esm.js.map +1 -0
  53. package/dist/animations/stars.js +43 -0
  54. package/dist/animations/stars.js.map +1 -0
  55. package/dist/animations/types.d.ts +33 -0
  56. package/dist/animations/types.d.ts.map +1 -0
  57. package/dist/animations/useReward.d.ts +8 -0
  58. package/dist/animations/useReward.d.ts.map +1 -0
  59. package/dist/animations/utils.d.ts +7 -0
  60. package/dist/animations/utils.d.ts.map +1 -0
  61. package/dist/index.d.ts +3 -0
  62. package/dist/index.d.ts.map +1 -0
  63. package/dist/index.esm.js +374 -0
  64. package/dist/index.esm.js.map +1 -0
  65. package/dist/index.js +376 -0
  66. package/dist/index.js.map +1 -0
  67. package/dist/types.d.ts +33 -0
  68. package/dist/types.d.ts.map +1 -0
  69. package/dist/useReward.d.ts +8 -0
  70. package/dist/useReward.d.ts.map +1 -0
  71. package/dist/utils.d.ts +7 -0
  72. package/dist/utils.d.ts.map +1 -0
  73. package/package.json +76 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Jonathan Leane
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,295 @@
1
+ # Partycles 🎉
2
+
3
+ A lightweight, performant React library for adding delightful animation effects to your applications. Perfect for celebrating user achievements, form submissions, or any moment worth highlighting.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/partycles.svg)](https://www.npmjs.com/package/partycles)
6
+ [![Bundle Size](https://img.shields.io/bundlephobia/minzip/partycles)](https://bundlephobia.com/package/partycles)
7
+ [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
9
+
10
+ ## ✨ Features
11
+
12
+ - 🎯 **Simple API** - Just one hook to rule them all
13
+ - 🎨 **6 Beautiful Animations** - Confetti, sparkles, hearts, stars, fireworks, and bubbles
14
+ - 📦 **Tiny Bundle** - Less than 5KB gzipped with tree-shaking support
15
+ - 🚀 **Performant** - Optimized animations using requestAnimationFrame
16
+ - 🎮 **Full Control** - Customize colors, particle count, physics, and more
17
+ - 📱 **Responsive** - Works seamlessly on all devices
18
+ - 🔧 **TypeScript Support** - Fully typed for excellent DX
19
+ - ⚡ **React 18 Ready** - Built with the latest React features
20
+
21
+ ## 📦 Installation
22
+
23
+ ```bash
24
+ npm install partycles
25
+ # or
26
+ yarn add partycles
27
+ # or
28
+ pnpm add partycles
29
+ ```
30
+
31
+ ## 🚀 Quick Start
32
+
33
+ ```tsx
34
+ import { useReward } from 'partycles';
35
+
36
+ function App() {
37
+ const { reward, isAnimating } = useReward('rewardId', 'confetti');
38
+
39
+ return (
40
+ <button id="rewardId" onClick={reward} disabled={isAnimating}>
41
+ Click me for a surprise! 🎉
42
+ </button>
43
+ );
44
+ }
45
+ ```
46
+
47
+ ## 📖 API Reference
48
+
49
+ ### `useReward(elementId, animationType, config?)`
50
+
51
+ The main hook for creating reward animations.
52
+
53
+ #### Parameters
54
+
55
+ - `elementId` (string): The ID of the element to animate from
56
+ - `animationType` (string): One of: `'confetti'`, `'sparkles'`, `'hearts'`, `'stars'`, `'fireworks'`, `'bubbles'`
57
+ - `config` (optional): Animation configuration object
58
+
59
+ #### Returns
60
+
61
+ - `reward` (function): Triggers the animation
62
+ - `isAnimating` (boolean): Whether the animation is currently running
63
+
64
+ ### Configuration Options
65
+
66
+ ```typescript
67
+ interface AnimationConfig {
68
+ particleCount?: number; // Number of particles (default: varies by animation)
69
+ spread?: number; // Spread angle in degrees (default: 50)
70
+ startVelocity?: number; // Initial velocity (default: 45)
71
+ decay?: number; // Velocity decay rate (default: 0.9)
72
+ lifetime?: number; // Particle lifetime (default: 100)
73
+ colors?: string[]; // Array of colors
74
+ elementSize?: number; // Size of particles in pixels
75
+ duration?: number; // Total animation duration
76
+ physics?: {
77
+ gravity?: number; // Gravity force (default: 0.5)
78
+ wind?: number; // Horizontal wind force (default: 0)
79
+ friction?: number; // Air friction (default: 0.99)
80
+ };
81
+ }
82
+ ```
83
+
84
+ ## 🎨 Animation Types
85
+
86
+ ### Confetti 🎊
87
+ Classic celebration effect with colorful paper pieces.
88
+
89
+ ```tsx
90
+ const { reward } = useReward('buttonId', 'confetti', {
91
+ particleCount: 30,
92
+ spread: 60,
93
+ colors: ['#ff0000', '#00ff00', '#0000ff']
94
+ });
95
+ ```
96
+
97
+ ### Sparkles ✨
98
+ Twinkling star effect perfect for magical moments.
99
+
100
+ ```tsx
101
+ const { reward } = useReward('buttonId', 'sparkles', {
102
+ particleCount: 20,
103
+ elementSize: 15
104
+ });
105
+ ```
106
+
107
+ ### Hearts 💕
108
+ Floating hearts for likes, favorites, or love actions.
109
+
110
+ ```tsx
111
+ const { reward } = useReward('buttonId', 'hearts', {
112
+ particleCount: 15,
113
+ colors: ['#ff1744', '#e91e63', '#ff4569']
114
+ });
115
+ ```
116
+
117
+ ### Stars ⭐
118
+ Shooting stars effect for achievements and ratings.
119
+
120
+ ```tsx
121
+ const { reward } = useReward('buttonId', 'stars', {
122
+ particleCount: 25,
123
+ physics: { gravity: 0.3 }
124
+ });
125
+ ```
126
+
127
+ ### Fireworks 🎆
128
+ Explosive celebration for major milestones.
129
+
130
+ ```tsx
131
+ const { reward } = useReward('buttonId', 'fireworks', {
132
+ particleCount: 40,
133
+ spread: 180
134
+ });
135
+ ```
136
+
137
+ ### Bubbles 🫧
138
+ Gentle floating bubbles for calm, playful effects.
139
+
140
+ ```tsx
141
+ const { reward } = useReward('buttonId', 'bubbles', {
142
+ particleCount: 20,
143
+ physics: { gravity: -0.1 }
144
+ });
145
+ ```
146
+
147
+ ## 💡 Examples
148
+
149
+ ### Form Submission Success
150
+ ```tsx
151
+ function ContactForm() {
152
+ const { reward } = useReward('submit-btn', 'confetti');
153
+
154
+ const handleSubmit = async (e) => {
155
+ e.preventDefault();
156
+ const success = await submitForm();
157
+ if (success) {
158
+ reward();
159
+ }
160
+ };
161
+
162
+ return (
163
+ <form onSubmit={handleSubmit}>
164
+ {/* form fields */}
165
+ <button id="submit-btn" type="submit">
166
+ Send Message
167
+ </button>
168
+ </form>
169
+ );
170
+ }
171
+ ```
172
+
173
+ ### Like Button with Hearts
174
+ ```tsx
175
+ function LikeButton() {
176
+ const [liked, setLiked] = useState(false);
177
+ const { reward } = useReward('like-btn', 'hearts', {
178
+ particleCount: 10,
179
+ elementSize: 20
180
+ });
181
+
182
+ const handleLike = () => {
183
+ setLiked(!liked);
184
+ if (!liked) {
185
+ reward();
186
+ }
187
+ };
188
+
189
+ return (
190
+ <button id="like-btn" onClick={handleLike}>
191
+ {liked ? '❤️' : '🤍'} Like
192
+ </button>
193
+ );
194
+ }
195
+ ```
196
+
197
+ ### Achievement Unlocked
198
+ ```tsx
199
+ function Achievement({ unlocked, name }) {
200
+ const { reward } = useReward('achievement', 'fireworks', {
201
+ particleCount: 50,
202
+ spread: 120
203
+ });
204
+
205
+ useEffect(() => {
206
+ if (unlocked) {
207
+ reward();
208
+ }
209
+ }, [unlocked, reward]);
210
+
211
+ return (
212
+ <div id="achievement" className="achievement-badge">
213
+ 🏆 {name}
214
+ </div>
215
+ );
216
+ }
217
+ ```
218
+
219
+ ## 🎯 Best Practices
220
+
221
+ 1. **Unique IDs**: Ensure each animated element has a unique ID
222
+ 2. **Performance**: Avoid triggering multiple animations simultaneously
223
+ 3. **Accessibility**: Provide alternative feedback for users who prefer reduced motion
224
+ 4. **Mobile**: Test animations on mobile devices and adjust particle counts if needed
225
+
226
+ ```tsx
227
+ // Respect user preferences
228
+ const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
229
+
230
+ const { reward } = useReward('buttonId', 'confetti', {
231
+ particleCount: prefersReducedMotion ? 0 : 30
232
+ });
233
+ ```
234
+
235
+ ## 🔧 Advanced Usage
236
+
237
+ ### Custom Physics
238
+ ```tsx
239
+ const { reward } = useReward('buttonId', 'confetti', {
240
+ physics: {
241
+ gravity: 0.2, // Lower gravity = floatier particles
242
+ wind: 0.1, // Positive = blow right, negative = blow left
243
+ friction: 0.95 // Higher = more air resistance
244
+ }
245
+ });
246
+ ```
247
+
248
+ ### Dynamic Configuration
249
+ ```tsx
250
+ function DynamicReward() {
251
+ const [intensity, setIntensity] = useState(1);
252
+
253
+ const { reward } = useReward('buttonId', 'confetti', {
254
+ particleCount: 30 * intensity,
255
+ spread: 50 + (20 * intensity),
256
+ startVelocity: 45 * intensity
257
+ });
258
+
259
+ return (
260
+ <>
261
+ <input
262
+ type="range"
263
+ min="0.5"
264
+ max="2"
265
+ step="0.1"
266
+ value={intensity}
267
+ onChange={(e) => setIntensity(parseFloat(e.target.value))}
268
+ />
269
+ <button id="buttonId" onClick={reward}>
270
+ Celebrate!
271
+ </button>
272
+ </>
273
+ );
274
+ }
275
+ ```
276
+
277
+ ## 🤝 Contributing
278
+
279
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
280
+
281
+ 1. Fork the repository
282
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
283
+ 3. Commit your changes (`git commit -m 'Add amazing feature'`)
284
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
285
+ 5. Open a Pull Request
286
+
287
+ ## 📄 License
288
+
289
+ MIT © [Your Name]
290
+
291
+ ---
292
+
293
+ <p align="center">
294
+ Made with ❤️ by developers, for developers
295
+ </p>
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { AnimationConfig, Particle } from '../types';
3
+ export declare const createBubbleParticles: (origin: {
4
+ x: number;
5
+ y: number;
6
+ }, config: AnimationConfig) => Particle[];
7
+ export declare const renderBubbleParticle: (particle: Particle) => React.ReactNode;
8
+ //# sourceMappingURL=bubbles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bubbles.d.ts","sourceRoot":"","sources":["../../src/animations/bubbles.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAKrD,eAAO,MAAM,qBAAqB,GAChC,QAAQ;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EAChC,QAAQ,eAAe,KACtB,QAAQ,EA2BV,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,UAAU,QAAQ,KAAG,KAAK,CAAC,SAkB/D,CAAC"}
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { AnimationConfig, Particle } from '../types';
3
+ export declare const createConfettiParticles: (origin: {
4
+ x: number;
5
+ y: number;
6
+ }, config: AnimationConfig) => Particle[];
7
+ export declare const renderConfettiParticle: (particle: Particle) => React.ReactNode;
8
+ //# sourceMappingURL=confetti.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confetti.d.ts","sourceRoot":"","sources":["../../src/animations/confetti.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAKrD,eAAO,MAAM,uBAAuB,GAClC,QAAQ;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EAChC,QAAQ,eAAe,KACtB,QAAQ,EA8BV,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,UAAU,QAAQ,KAAG,KAAK,CAAC,SAajE,CAAC"}
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { AnimationConfig, Particle } from '../types';
3
+ export declare const createFireworkParticles: (origin: {
4
+ x: number;
5
+ y: number;
6
+ }, config: AnimationConfig) => Particle[];
7
+ export declare const renderFireworkParticle: (particle: Particle) => React.ReactNode;
8
+ //# sourceMappingURL=fireworks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fireworks.d.ts","sourceRoot":"","sources":["../../src/animations/fireworks.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAKrD,eAAO,MAAM,uBAAuB,GAClC,QAAQ;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EAChC,QAAQ,eAAe,KACtB,QAAQ,EA8BV,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,UAAU,QAAQ,KAAG,KAAK,CAAC,SAmBjE,CAAC"}
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { AnimationConfig, Particle } from '../types';
3
+ export declare const createHeartParticles: (origin: {
4
+ x: number;
5
+ y: number;
6
+ }, config: AnimationConfig) => Particle[];
7
+ export declare const renderHeartParticle: (particle: Particle) => React.ReactNode;
8
+ //# sourceMappingURL=hearts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hearts.d.ts","sourceRoot":"","sources":["../../src/animations/hearts.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAKrD,eAAO,MAAM,oBAAoB,GAC/B,QAAQ;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EAChC,QAAQ,eAAe,KACtB,QAAQ,EA8BV,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,UAAU,QAAQ,KAAG,KAAK,CAAC,SAe9D,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { AnimationType, AnimationConfig, Particle } from '../types';
2
+ export type ParticleCreator = (origin: {
3
+ x: number;
4
+ y: number;
5
+ }, config: AnimationConfig) => Particle[];
6
+ export type ParticleRenderer = (particle: Particle) => React.ReactNode;
7
+ interface AnimationHandler {
8
+ createParticles: ParticleCreator;
9
+ renderParticle: ParticleRenderer;
10
+ }
11
+ export declare const animations: Record<AnimationType, AnimationHandler>;
12
+ export {};
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/animations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAQpE,MAAM,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,MAAM,EAAE,eAAe,KAAK,QAAQ,EAAE,CAAC;AACxG,MAAM,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,QAAQ,KAAK,KAAK,CAAC,SAAS,CAAC;AAEvE,UAAU,gBAAgB;IACxB,eAAe,EAAE,eAAe,CAAC;IACjC,cAAc,EAAE,gBAAgB,CAAC;CAClC;AAED,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAyB9D,CAAC"}
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { AnimationConfig, Particle } from '../types';
3
+ export declare const createSparkleParticles: (origin: {
4
+ x: number;
5
+ y: number;
6
+ }, config: AnimationConfig) => Particle[];
7
+ export declare const renderSparkleParticle: (particle: Particle) => React.ReactNode;
8
+ //# sourceMappingURL=sparkles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sparkles.d.ts","sourceRoot":"","sources":["../../src/animations/sparkles.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGrD,eAAO,MAAM,sBAAsB,GACjC,QAAQ;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EAChC,QAAQ,eAAe,KACtB,QAAQ,EA4BV,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,UAAU,QAAQ,KAAG,KAAK,CAAC,SAoBhE,CAAC"}
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { AnimationConfig, Particle } from '../types';
3
+ export declare const createStarParticles: (origin: {
4
+ x: number;
5
+ y: number;
6
+ }, config: AnimationConfig) => Particle[];
7
+ export declare const renderStarParticle: (particle: Particle) => React.ReactNode;
8
+ //# sourceMappingURL=stars.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stars.d.ts","sourceRoot":"","sources":["../../src/animations/stars.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAKrD,eAAO,MAAM,mBAAmB,GAC9B,QAAQ;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EAChC,QAAQ,eAAe,KACtB,QAAQ,EA6BV,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,UAAU,QAAQ,KAAG,KAAK,CAAC,SAe7D,CAAC"}
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { AnimationConfig, Particle } from '../types';
3
+ export declare const createBubbleParticles: (origin: {
4
+ x: number;
5
+ y: number;
6
+ }, config: AnimationConfig) => Particle[];
7
+ export declare const renderBubbleParticle: (particle: Particle) => React.ReactNode;
8
+ //# sourceMappingURL=bubbles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bubbles.d.ts","sourceRoot":"","sources":["../../src/animations/bubbles.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAKrD,eAAO,MAAM,qBAAqB,GAChC,QAAQ;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EAChC,QAAQ,eAAe,KACtB,QAAQ,EA2BV,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,UAAU,QAAQ,KAAG,KAAK,CAAC,SAkB/D,CAAC"}
@@ -0,0 +1,46 @@
1
+ import React from 'react';
2
+
3
+ const randomInRange = (min, max) => {
4
+ return Math.random() * (max - min) + min;
5
+ };
6
+ const generateId = () => {
7
+ return Math.random().toString(36).substring(2, 9);
8
+ };
9
+
10
+ const bubbleColors = ['rgba(66, 165, 245, 0.4)', 'rgba(41, 182, 246, 0.4)', 'rgba(38, 198, 218, 0.4)', 'rgba(129, 212, 250, 0.4)'];
11
+ const createBubbleParticles = (origin, config) => {
12
+ const { particleCount = 30, spread = 80, startVelocity = 30, colors = bubbleColors, elementSize = 40 } = config;
13
+ const particles = [];
14
+ for (let i = 0; i < particleCount; i++) {
15
+ particles.push({
16
+ id: generateId(),
17
+ x: origin.x + randomInRange(-spread, spread),
18
+ y: origin.y,
19
+ vx: randomInRange(-3, 3),
20
+ vy: -randomInRange(startVelocity * 0.7, startVelocity * 1.2),
21
+ life: config.lifetime || 160,
22
+ opacity: 0.7,
23
+ size: randomInRange(elementSize * 0.4, elementSize * 1.2),
24
+ rotation: 0,
25
+ color: colors[Math.floor(Math.random() * colors.length)] || colors[0],
26
+ });
27
+ }
28
+ return particles;
29
+ };
30
+ const renderBubbleParticle = (particle) => {
31
+ return (React.createElement("div", { key: particle.id, style: {
32
+ width: `${particle.size}px`,
33
+ height: `${particle.size}px`,
34
+ backgroundColor: particle.color,
35
+ borderRadius: '50%',
36
+ border: '2px solid rgba(255, 255, 255, 0.6)',
37
+ backgroundImage: 'radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.8), transparent)',
38
+ boxShadow: `
39
+ inset 0 0 ${particle.size * 0.3}px rgba(255, 255, 255, 0.4),
40
+ 0 0 ${particle.size * 0.5}px ${particle.color}
41
+ `,
42
+ } }));
43
+ };
44
+
45
+ export { createBubbleParticles, renderBubbleParticle };
46
+ //# sourceMappingURL=bubbles.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bubbles.esm.js","sources":["../../src/utils.ts","../../src/animations/bubbles.tsx"],"sourcesContent":["import { Particle } from './types';\n\nexport const randomInRange = (min: number, max: number): number => {\n return Math.random() * (max - min) + min;\n};\n\nexport const degreesToRadians = (degrees: number): number => {\n return (degrees * Math.PI) / 180;\n};\n\nexport const generateId = (): string => {\n return Math.random().toString(36).substring(2, 9);\n};\n\nexport const getRandomColor = (colors: string[]): string => {\n return colors[Math.floor(Math.random() * colors.length)] || colors[0];\n};\n\nexport const createParticleStyle = (\n particle: Particle,\n containerRect: DOMRect\n): React.CSSProperties => {\n return {\n position: 'absolute',\n left: `${particle.x - containerRect.left}px`,\n top: `${particle.y - containerRect.top}px`,\n transform: `rotate(${particle.rotation}deg)`,\n opacity: particle.opacity,\n pointerEvents: 'none',\n transition: 'none',\n willChange: 'transform, opacity',\n };\n};","import React from 'react';\nimport { AnimationConfig, Particle } from '../types';\nimport { randomInRange, generateId } from '../utils';\n\nconst bubbleColors = ['rgba(66, 165, 245, 0.4)', 'rgba(41, 182, 246, 0.4)', 'rgba(38, 198, 218, 0.4)', 'rgba(129, 212, 250, 0.4)'];\n\nexport const createBubbleParticles = (\n origin: { x: number; y: number },\n config: AnimationConfig\n): Particle[] => {\n const {\n particleCount = 30,\n spread = 80,\n startVelocity = 30,\n colors = bubbleColors,\n elementSize = 40\n } = config;\n\n const particles: Particle[] = [];\n\n for (let i = 0; i < particleCount; i++) {\n particles.push({\n id: generateId(),\n x: origin.x + randomInRange(-spread, spread),\n y: origin.y,\n vx: randomInRange(-3, 3),\n vy: -randomInRange(startVelocity * 0.7, startVelocity * 1.2),\n life: config.lifetime || 160,\n opacity: 0.7,\n size: randomInRange(elementSize * 0.4, elementSize * 1.2),\n rotation: 0,\n color: colors[Math.floor(Math.random() * colors.length)] || colors[0],\n });\n }\n\n return particles;\n};\n\nexport const renderBubbleParticle = (particle: Particle): React.ReactNode => {\n return (\n <div\n key={particle.id}\n style={{\n width: `${particle.size}px`,\n height: `${particle.size}px`,\n backgroundColor: particle.color,\n borderRadius: '50%',\n border: '2px solid rgba(255, 255, 255, 0.6)',\n backgroundImage: 'radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.8), transparent)',\n boxShadow: `\n inset 0 0 ${particle.size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Z,IAAI,EAAE,aAAa,CAAC,WAAW,GAAG,GAAG,EAAE,WAAW,GAAG,GAAG,CAAC;AACzD,YAAA,QAAQ,EAAE,CAAC;YACX,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC;AACtE,SAAA,CAAC;;AAGJ,IAAA,OAAO,SAAS;AAClB;AAEa,MAAA,oBAAoB,GAAG,CAAC,QAAkB,KAAqB;IAC1E,QACE,6BACE,GAAG,EAAE,QAAQ,CAAC,EAAE,EAChB,KAAK,EAAE;AACL,YAAA,KAAK,EAAE,CAAA,EAAG,QAAQ,CAAC,IAAI,CAAI,EAAA,CAAA;AAC3B,YAAA,MAAM,EAAE,CAAA,EAAG,QAAQ,CAAC,IAAI,CAAI,EAAA,CAAA;YAC5B,eAAe,EAAE,QAAQ,CAAC,KAAK;AAC/B,YAAA,YAAY,EAAE,KAAK;AACnB,YAAA,MAAM,EAAE,oCAAoC;AAC5C,YAAA,eAAe,EAAE,2EAA2E;AAC5F,YAAA,SAAS,EAAE;sBACG,QAAQ,CAAC,IAAI,GAAG,GAAG,CAAA;AACzB,cAAA,EAAA,QAAQ,CAAC,IAAI,GAAG,GAAG,CAAM,GAAA,EAAA,QAAQ,CAAC,KAAK;AAC9C,QAAA,CAAA;AACF,SAAA,EAAA,CACD;AAEN;;;;"}
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ const randomInRange = (min, max) => {
6
+ return Math.random() * (max - min) + min;
7
+ };
8
+ const generateId = () => {
9
+ return Math.random().toString(36).substring(2, 9);
10
+ };
11
+
12
+ const bubbleColors = ['rgba(66, 165, 245, 0.4)', 'rgba(41, 182, 246, 0.4)', 'rgba(38, 198, 218, 0.4)', 'rgba(129, 212, 250, 0.4)'];
13
+ const createBubbleParticles = (origin, config) => {
14
+ const { particleCount = 30, spread = 80, startVelocity = 30, colors = bubbleColors, elementSize = 40 } = config;
15
+ const particles = [];
16
+ for (let i = 0; i < particleCount; i++) {
17
+ particles.push({
18
+ id: generateId(),
19
+ x: origin.x + randomInRange(-spread, spread),
20
+ y: origin.y,
21
+ vx: randomInRange(-3, 3),
22
+ vy: -randomInRange(startVelocity * 0.7, startVelocity * 1.2),
23
+ life: config.lifetime || 160,
24
+ opacity: 0.7,
25
+ size: randomInRange(elementSize * 0.4, elementSize * 1.2),
26
+ rotation: 0,
27
+ color: colors[Math.floor(Math.random() * colors.length)] || colors[0],
28
+ });
29
+ }
30
+ return particles;
31
+ };
32
+ const renderBubbleParticle = (particle) => {
33
+ return (React.createElement("div", { key: particle.id, style: {
34
+ width: `${particle.size}px`,
35
+ height: `${particle.size}px`,
36
+ backgroundColor: particle.color,
37
+ borderRadius: '50%',
38
+ border: '2px solid rgba(255, 255, 255, 0.6)',
39
+ backgroundImage: 'radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.8), transparent)',
40
+ boxShadow: `
41
+ inset 0 0 ${particle.size * 0.3}px rgba(255, 255, 255, 0.4),
42
+ 0 0 ${particle.size * 0.5}px ${particle.color}
43
+ `,
44
+ } }));
45
+ };
46
+
47
+ exports.createBubbleParticles = createBubbleParticles;
48
+ exports.renderBubbleParticle = renderBubbleParticle;
49
+ //# sourceMappingURL=bubbles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bubbles.js","sources":["../../src/utils.ts","../../src/animations/bubbles.tsx"],"sourcesContent":["import { Particle } from './types';\n\nexport const randomInRange = (min: number, max: number): number => {\n return Math.random() * (max - min) + min;\n};\n\nexport const degreesToRadians = (degrees: number): number => {\n return (degrees * Math.PI) / 180;\n};\n\nexport const generateId = (): string => {\n return Math.random().toString(36).substring(2, 9);\n};\n\nexport const getRandomColor = (colors: string[]): string => {\n return colors[Math.floor(Math.random() * colors.length)] || colors[0];\n};\n\nexport const createParticleStyle = (\n particle: Particle,\n containerRect: DOMRect\n): React.CSSProperties => {\n return {\n position: 'absolute',\n left: `${particle.x - containerRect.left}px`,\n top: `${particle.y - containerRect.top}px`,\n transform: `rotate(${particle.rotation}deg)`,\n opacity: particle.opacity,\n pointerEvents: 'none',\n transition: 'none',\n willChange: 'transform, opacity',\n };\n};","import React from 'react';\nimport { AnimationConfig, Particle } from '../types';\nimport { randomInRange, generateId } from '../utils';\n\nconst bubbleColors = ['rgba(66, 165, 245, 0.4)', 'rgba(41, 182, 246, 0.4)', 'rgba(38, 198, 218, 0.4)', 'rgba(129, 212, 250, 0.4)'];\n\nexport const createBubbleParticles = (\n origin: { x: number; y: number },\n config: AnimationConfig\n): Particle[] => {\n const {\n particleCount = 30,\n spread = 80,\n startVelocity = 30,\n colors = bubbleColors,\n elementSize = 40\n } = config;\n\n const particles: Particle[] = [];\n\n for (let i = 0; i < particleCount; i++) {\n particles.push({\n id: generateId(),\n x: origin.x + randomInRange(-spread, spread),\n y: origin.y,\n vx: randomInRange(-3, 3),\n vy: -randomInRange(startVelocity * 0.7, startVelocity * 1.2),\n life: config.lifetime || 160,\n opacity: 0.7,\n size: randomInRange(elementSize * 0.4, elementSize * 1.2),\n rotation: 0,\n color: colors[Math.floor(Math.random() * colors.length)] || colors[0],\n });\n }\n\n return particles;\n};\n\nexport const renderBubbleParticle = (particle: Particle): React.ReactNode => {\n return (\n <div\n key={particle.id}\n style={{\n width: `${particle.size}px`,\n height: `${particle.size}px`,\n backgroundColor: particle.color,\n borderRadius: '50%',\n border: '2px solid rgba(255, 255, 255, 0.6)',\n backgroundImage: 'radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.8), transparent)',\n boxShadow: `\n inset 0 0 ${particle.size * 0.3}px rgba(255, 255, 255, 0.4),\n 0 0 ${particle.size * 0.5}px ${particle.color}\n `,\n }}\n />\n );\n};"],"names":[],"mappings":";;;;AAEO,MAAM,aAAa,GAAG,CAAC,GAAW,EAAE,GAAW,KAAY;AAChE,IAAA,OAAO,IAAI,CAAC,MAAM,EAA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AM,CAAC,MAAM,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC;AACtE,SAAA,CAAC;;AAGJ,IAAA,OAAO,SAAS;AAClB;AAEa,MAAA,oBAAoB,GAAG,CAAC,QAAkB,KAAqB;IAC1E,QACE,6BACE,GAAG,EAAE,QAAQ,CAAC,EAAE,EAChB,KAAK,EAAE;AACL,YAAA,KAAK,EAAE,CAAA,EAAG,QAAQ,CAAC,IAAI,CAAI,EAAA,CAAA;AAC3B,YAAA,MAAM,EAAE,CAAA,EAAG,QAAQ,CAAC,IAAI,CAAI,EAAA,CAAA;YAC5B,eAAe,EAAE,QAAQ,CAAC,KAAK;AAC/B,YAAA,YAAY,EAAE,KAAK;AACnB,YAAA,MAAM,EAAE,oCAAoC;AAC5C,YAAA,eAAe,EAAE,2EAA2E;AAC5F,YAAA,SAAS,EAAE;sBACG,QAAQ,CAAC,IAAI,GAAG,GAAG,CAAA;AACzB,cAAA,EAAA,QAAQ,CAAC,IAAI,GAAG,GAAG,CAAM,GAAA,EAAA,QAAQ,CAAC,KAAK;AAC9C,QAAA,CAAA;AACF,SAAA,EAAA,CACD;AAEN;;;;;"}
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { AnimationConfig, Particle } from '../types';
3
+ export declare const createConfettiParticles: (origin: {
4
+ x: number;
5
+ y: number;
6
+ }, config: AnimationConfig) => Particle[];
7
+ export declare const renderConfettiParticle: (particle: Particle) => React.ReactNode;
8
+ //# sourceMappingURL=confetti.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confetti.d.ts","sourceRoot":"","sources":["../../src/animations/confetti.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAKrD,eAAO,MAAM,uBAAuB,GAClC,QAAQ;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EAChC,QAAQ,eAAe,KACtB,QAAQ,EA8BV,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,UAAU,QAAQ,KAAG,KAAK,CAAC,SAajE,CAAC"}
@@ -0,0 +1,50 @@
1
+ import React from 'react';
2
+
3
+ const randomInRange = (min, max) => {
4
+ return Math.random() * (max - min) + min;
5
+ };
6
+ const degreesToRadians = (degrees) => {
7
+ return (degrees * Math.PI) / 180;
8
+ };
9
+ const generateId = () => {
10
+ return Math.random().toString(36).substring(2, 9);
11
+ };
12
+ const getRandomColor = (colors) => {
13
+ return colors[Math.floor(Math.random() * colors.length)] || colors[0];
14
+ };
15
+
16
+ const defaultColors = ['#f44336', '#e91e63', '#9c27b0', '#673ab7', '#3f51b5', '#2196f3', '#03a9f4', '#00bcd4', '#009688', '#4caf50', '#8bc34a', '#cddc39', '#ffeb3b', '#ffc107', '#ff9800', '#ff5722'];
17
+ const createConfettiParticles = (origin, config) => {
18
+ const { particleCount = 50, startVelocity = 55, colors = defaultColors, elementSize = 20 } = config;
19
+ const particles = [];
20
+ for (let i = 0; i < particleCount; i++) {
21
+ const angle = randomInRange(0, 360);
22
+ const velocity = randomInRange(startVelocity * 0.5, startVelocity);
23
+ const color = getRandomColor(colors);
24
+ particles.push({
25
+ id: generateId(),
26
+ x: origin.x,
27
+ y: origin.y,
28
+ vx: Math.cos(degreesToRadians(angle)) * velocity,
29
+ vy: Math.sin(degreesToRadians(angle)) * velocity - 30,
30
+ life: config.lifetime || 150,
31
+ opacity: 1,
32
+ size: randomInRange(elementSize * 0.7, elementSize * 1.5),
33
+ rotation: randomInRange(0, 360),
34
+ color,
35
+ });
36
+ }
37
+ return particles;
38
+ };
39
+ const renderConfettiParticle = (particle) => {
40
+ return (React.createElement("div", { key: particle.id, style: {
41
+ width: `${particle.size}px`,
42
+ height: `${particle.size * 0.6}px`,
43
+ backgroundColor: particle.color,
44
+ borderRadius: '3px',
45
+ boxShadow: '0 2px 4px rgba(0,0,0,0.2)',
46
+ } }));
47
+ };
48
+
49
+ export { createConfettiParticles, renderConfettiParticle };
50
+ //# sourceMappingURL=confetti.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confetti.esm.js","sources":["../../src/utils.ts","../../src/animations/confetti.tsx"],"sourcesContent":["import { Particle } from './types';\n\nexport const randomInRange = (min: number, max: number): number => {\n return Math.random() * (max - min) + min;\n};\n\nexport const degreesToRadians = (degrees: number): number => {\n return (degrees * Math.PI) / 180;\n};\n\nexport const generateId = (): string => {\n return Math.random().toString(36).substring(2, 9);\n};\n\nexport const getRandomColor = (colors: string[]): string => {\n return colors[Math.floor(Math.random() * colors.length)] || colors[0];\n};\n\nexport const createParticleStyle = (\n particle: Particle,\n containerRect: DOMRect\n): React.CSSProperties => {\n return {\n position: 'absolute',\n left: `${particle.x - containerRect.left}px`,\n top: `${particle.y - containerRect.top}px`,\n transform: `rotate(${particle.rotation}deg)`,\n opacity: particle.opacity,\n pointerEvents: 'none',\n transition: 'none',\n willChange: 'transform, opacity',\n };\n};","import React from 'react';\nimport { AnimationConfig, Particle } from '../types';\nimport { randomInRange, degreesToRadians, generateId, getRandomColor } from '../utils';\n\nconst defaultColors = ['#f44336', '#e91e63', '#9c27b0', '#673ab7', '#3f51b5', '#2196f3', '#03a9f4', '#00bcd4', '#009688', '#4caf50', '#8bc34a', '#cddc39', '#ffeb3b', '#ffc107', '#ff9800', '#ff5722'];\n\nexport const createConfettiParticles = (\n origin: { x: number; y: number },\n config: AnimationConfig\n): Particle[] => {\n const {\n particleCount = 50,\n startVelocity = 55,\n colors = defaultColors,\n elementSize = 20\n } = config;\n\n const particles: Particle[] = [];\n\n for (let i = 0; i < particleCount; i++) {\n const angle = randomInRange(0, 360);\n const velocity = randomInRange(startVelocity * 0.5, startVelocity);\n const color = getRandomColor(colors);\n\n particles.push({\n id: generateId(),\n x: origin.x,\n y: origin.y,\n vx: Math.cos(degreesToRadians(angle)) * velocity,\n vy: Math.sin(degreesToRadians(angle)) * velocity - 30,\n life: config.lifetime || 150,\n opacity: 1,\n size: randomInRange(elementSize * 0.7, elementSize * 1.5),\n rotation: randomInRange(0, 360),\n color,\n });\n }\n\n return particles;\n};\n\nexport const renderConfettiParticle = (particle: Particle): React.ReactNode => {\n return (\n <div\n key={particle.id}\n style={{\n width: `${particle.size}px`,\n height: `${particle.size * 0.6}px`,\n backgroundColor: particle.color,\n borderRadius: '3px',\n boxShadow: '0 2px 4px rgba(0,0,0,0.2)',\n }}\n />\n );\n};"],"names":[],"mappings":";;AAEO,MAAM,aAAa,GAAG,CAAC,GAAW,EAAE,GAAW,KAAY;AAChE,IAAA,OAAO,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG;AAC1C,CAAC;AAEM,MAAM,gBAAgB,GAAG,CAAC,OAAe,KAAY;IAC1D,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,IAAI,GAAG;AAClC,CAAC;AAEM,MAAM,UAAU,GAAG,MAAa;AACrC,IAAA,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;AACnD,CAAC;AAEM,MAAM,cAAc,GAAG,CAAC,MAAgB,KAAY;IACzD,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC;AACvE,CAAC;;ACZD,MAAM,aAAa,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;MAEzL,uBAAuB,GAAG,CACrC,MAAgC,EAChC,MAAuB,KACT;AACd,IAAA,MAAM,EACJ,aAAa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