asciify-engine 1.0.118 → 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.
@@ -0,0 +1,401 @@
1
+ interface WaveBackgroundOptions {
2
+ /** Font size in CSS pixels (default: 13) */
3
+ fontSize?: number;
4
+ /** Character aspect ratio width/height (default: 0.62) */
5
+ charAspect?: number;
6
+ /** Line height multiplier (default: 1.4) */
7
+ lineHeightRatio?: number;
8
+ /** Character set from dark→bright (default: ' .:-=+*#%@') */
9
+ chars?: string;
10
+ /** Base colour — use '{a}' as alpha placeholder */
11
+ baseColor?: string;
12
+ /** Accent colour applied near the cursor and on wave peaks (default: '#d4ff00') */
13
+ accentColor?: string;
14
+ /** Accent threshold: normalised intensity above which accent kicks in (default: 0.52) */
15
+ accentThreshold?: number;
16
+ /** How strongly the mouse influences local intensity (default: 0.55) */
17
+ mouseInfluence?: number;
18
+ /** Radial falloff for mouse influence (default: 2.8) */
19
+ mouseFalloff?: number;
20
+ /** Base wave animation speed (default: 1) */
21
+ speed?: number;
22
+ /** Enable vortex swirl effect around cursor (default: true) */
23
+ vortex?: boolean;
24
+ /** Enable sparkle / pop flicker (default: true) */
25
+ sparkles?: boolean;
26
+ /** Enable a slow global breathe pulse (default: true) */
27
+ breathe?: boolean;
28
+ /** Light mode: swap fill colours to dark-on-light (default: false) */
29
+ lightMode?: boolean;
30
+ }
31
+ declare function renderWaveBackground(ctx: CanvasRenderingContext2D, width: number, height: number, time: number, mousePos?: {
32
+ x: number;
33
+ y: number;
34
+ }, options?: WaveBackgroundOptions): void;
35
+
36
+ interface RainBackgroundOptions {
37
+ fontSize?: number;
38
+ /** Characters drawn in columns */
39
+ chars?: string;
40
+ /** Head / accent colour (default: '#d4ff00') */
41
+ accentColor?: string;
42
+ /** Custom character colour */
43
+ color?: string;
44
+ /** Global speed multiplier (default: 1) */
45
+ speed?: number;
46
+ /** Fraction of columns active at once 0-1 (default: 0.55) */
47
+ density?: number;
48
+ /** Number of cells in the fading tail (default: 14) */
49
+ tailLength?: number;
50
+ /** Light mode (default: false) */
51
+ lightMode?: boolean;
52
+ }
53
+ declare function renderRainBackground(ctx: CanvasRenderingContext2D, width: number, height: number, time: number, options?: RainBackgroundOptions): void;
54
+
55
+ interface StarsBackgroundOptions {
56
+ fontSize?: number;
57
+ /** Characters used as stars */
58
+ chars?: string;
59
+ /** Accent/trail colour for fast near-edge stars (default: '#d4ff00') */
60
+ accentColor?: string;
61
+ /** Custom base colour */
62
+ color?: string;
63
+ /** Global speed multiplier (default: 1) */
64
+ speed?: number;
65
+ /** Number of star particles (default: 180) */
66
+ count?: number;
67
+ /** Light mode (default: false) */
68
+ lightMode?: boolean;
69
+ }
70
+ declare function renderStarsBackground(ctx: CanvasRenderingContext2D, width: number, height: number, time: number, mousePos?: {
71
+ x: number;
72
+ y: number;
73
+ }, options?: StarsBackgroundOptions): void;
74
+
75
+ interface PulseBackgroundOptions {
76
+ fontSize?: number;
77
+ /** Characters to tile (default: '. · ○ ◎ ●') */
78
+ chars?: string;
79
+ /** Ring peak colour (default: '#00ffcc') */
80
+ accentColor?: string;
81
+ /** Custom base colour */
82
+ color?: string;
83
+ /** Number of simultaneous rings (default: 5) */
84
+ rings?: number;
85
+ /** Animation speed (default: 1) */
86
+ speed?: number;
87
+ /** Ring edge sharpness 1–10 (default: 4) */
88
+ sharpness?: number;
89
+ /** Light mode (default: false) */
90
+ lightMode?: boolean;
91
+ }
92
+ declare function renderPulseBackground(ctx: CanvasRenderingContext2D, width: number, height: number, time: number, mousePos?: {
93
+ x: number;
94
+ y: number;
95
+ }, options?: PulseBackgroundOptions): void;
96
+
97
+ interface NoiseBackgroundOptions {
98
+ /** Font size in CSS pixels (default: 14). */
99
+ fontSize?: number;
100
+ /** Character ramp dark → bright (default: ' .·:;=+*#%@░▒▓'). */
101
+ chars?: string;
102
+ /** Accent colour on intensity peaks (default: '#d4ff00'). */
103
+ accentColor?: string;
104
+ /** Custom base character colour (any CSS colour string). */
105
+ color?: string;
106
+ /** Number of noise octaves for FBM detail (default: 4, max: 6). */
107
+ octaves?: number;
108
+ /** Drift / scroll speed (default: 1). */
109
+ speed?: number;
110
+ /** Noise scale — lower = larger blobs (default: 1). */
111
+ scale?: number;
112
+ /** Accent threshold 0-1 (default: 0.78). */
113
+ accentThreshold?: number;
114
+ /** Mouse warp radius 0-1 (default: 0.3). */
115
+ mouseWarp?: number;
116
+ /** Light mode (default: false). */
117
+ lightMode?: boolean;
118
+ }
119
+ declare function renderNoiseBackground(ctx: CanvasRenderingContext2D, width: number, height: number, time: number, mousePos?: {
120
+ x: number;
121
+ y: number;
122
+ }, options?: NoiseBackgroundOptions): void;
123
+
124
+ interface GridBackgroundOptions {
125
+ /** Font size in CSS pixels (default: 12). */
126
+ fontSize?: number;
127
+ /** Character set (default: '·-=+|/'). */
128
+ chars?: string;
129
+ /** Accent / scan-band colour (default: '#d4ff00'). */
130
+ accentColor?: string;
131
+ /** Custom base character colour (any CSS colour string). */
132
+ color?: string;
133
+ /** Number of scan bands visible at once (default: 3). */
134
+ bands?: number;
135
+ /** Band travel speed (default: 1). */
136
+ speed?: number;
137
+ /** Band width as fraction of canvas height (default: 0.12). */
138
+ bandWidth?: number;
139
+ /** Enable cursor disruption glitch zone (default: true). */
140
+ glitch?: boolean;
141
+ /** Light mode (default: false). */
142
+ lightMode?: boolean;
143
+ }
144
+ declare function renderGridBackground(ctx: CanvasRenderingContext2D, width: number, height: number, time: number, mousePos?: {
145
+ x: number;
146
+ y: number;
147
+ }, options?: GridBackgroundOptions): void;
148
+
149
+ interface AuroraBackgroundOptions {
150
+ /** Character grid density. Default 14. */
151
+ fontSize?: number;
152
+ /** Character ramp from sparse to dense. */
153
+ chars?: string;
154
+ /** Base character color. Default theme-aware white/black. */
155
+ color?: string;
156
+ /** Accent color for intensity peaks. Default '#d4ff00'. */
157
+ accentColor?: string;
158
+ /** Animation speed multiplier. Default 1. */
159
+ speed?: number;
160
+ /** Number of wave layers stacked. More = richer interference. Default 5. */
161
+ layers?: number;
162
+ /** Wave spread/softness — higher = broader, more diffuse bands. Default 1.2. */
163
+ softness?: number;
164
+ /** Mouse distortion radius (0–1). Elegant ripple that follows the cursor. Default 0.2. */
165
+ mouseRipple?: number;
166
+ /** Force light mode (dark chars on light bg). Default false. */
167
+ lightMode?: boolean;
168
+ }
169
+ declare function renderAuroraBackground(ctx: CanvasRenderingContext2D, width: number, height: number, time: number, mousePos?: {
170
+ x: number;
171
+ y: number;
172
+ }, options?: AuroraBackgroundOptions): void;
173
+
174
+ interface SilkBackgroundOptions {
175
+ /** Character grid density. Default 13. */
176
+ fontSize?: number;
177
+ /** Base character color. Default theme-aware white/black. */
178
+ color?: string;
179
+ /** Accent color for intensity peaks. Default '#d4ff00'. */
180
+ accentColor?: string;
181
+ /** Animation speed multiplier. Default 0.4 (intentionally slow). */
182
+ speed?: number;
183
+ /** Number of flow-field layers. More = richer ribbons. Default 4. */
184
+ layers?: number;
185
+ /** Flow turbulence (0–2). Higher = more folded, tangled ribbons. Default 0.8. */
186
+ turbulence?: number;
187
+ /** Force light mode. Default false. */
188
+ lightMode?: boolean;
189
+ }
190
+ declare function renderSilkBackground(ctx: CanvasRenderingContext2D, width: number, height: number, time: number, options?: SilkBackgroundOptions): void;
191
+
192
+ interface VoidBackgroundOptions {
193
+ /** Character grid density. Default 13. */
194
+ fontSize?: number;
195
+ /** Character ramp. Default space-to-dense. */
196
+ chars?: string;
197
+ /** Base character color. Default theme-aware. */
198
+ color?: string;
199
+ /** Accent color for the inner singularity ring. Default '#d4ff00'. */
200
+ accentColor?: string;
201
+ /** Animation speed multiplier. Default 1. */
202
+ speed?: number;
203
+ /** Gravity well radius (fraction of canvas width). Default 0.38. */
204
+ radius?: number;
205
+ /** Spiral tightness — higher = more rotation per unit distance. Default 3. */
206
+ swirl?: number;
207
+ /** Force light mode. Default false. */
208
+ lightMode?: boolean;
209
+ }
210
+ declare function renderVoidBackground(ctx: CanvasRenderingContext2D, width: number, height: number, time: number, mousePos?: {
211
+ x: number;
212
+ y: number;
213
+ }, options?: VoidBackgroundOptions): void;
214
+
215
+ interface MorphBackgroundOptions {
216
+ /** Character grid density. Default 14. */
217
+ fontSize?: number;
218
+ /** Character ramp. Default clean gradient. */
219
+ chars?: string;
220
+ /** Base character color. Default theme-aware. */
221
+ color?: string;
222
+ /** Accent color for intensity peaks. Default '#d4ff00'. */
223
+ accentColor?: string;
224
+ /** Animation speed multiplier. Default 0.5 (intentionally slow). */
225
+ speed?: number;
226
+ /** How many frequency harmonics per cell. More = richer shimmer. Default 3. */
227
+ harmonics?: number;
228
+ /** Force light mode. Default false. */
229
+ lightMode?: boolean;
230
+ }
231
+ declare function renderMorphBackground(ctx: CanvasRenderingContext2D, width: number, height: number, time: number, options?: MorphBackgroundOptions): void;
232
+
233
+ interface FireBackgroundOptions {
234
+ /** Font size in CSS pixels (default: 13) */
235
+ fontSize?: number;
236
+ /** Characters mapped from cool→hot (default: ' .,:;i+xX#&@') */
237
+ chars?: string;
238
+ /** Base flame colour (default: '#ff4500') */
239
+ color?: string;
240
+ /** Secondary hot-tip colour (default: '#ffe066') */
241
+ hotColor?: string;
242
+ /** Flame intensity 0–1 (default: 0.85) */
243
+ intensity?: number;
244
+ /** Horizontal wind force -1..1 (default: 0) */
245
+ wind?: number;
246
+ /** Global speed multiplier (default: 1) */
247
+ speed?: number;
248
+ /** Light mode: invert text colours (default: false) */
249
+ lightMode?: boolean;
250
+ }
251
+ declare function renderFireBackground(ctx: CanvasRenderingContext2D, width: number, height: number, time: number, options?: FireBackgroundOptions): void;
252
+
253
+ interface DnaBackgroundOptions {
254
+ /** Font size in CSS pixels (default: 13) */
255
+ fontSize?: number;
256
+ /** Characters for strand nodes (default: 'ATCG') */
257
+ baseChars?: string;
258
+ /** Characters for the connectors between strands (default: '-=≡') */
259
+ bridgeChars?: string;
260
+ /** Primary strand colour (default: '#00e5ff') */
261
+ color?: string;
262
+ /** Secondary strand colour (default: '#ff4081') */
263
+ color2?: string;
264
+ /** Bridge / connector colour (default: '#88ffcc') */
265
+ bridgeColor?: string;
266
+ /** Speed multiplier (default: 1) */
267
+ speed?: number;
268
+ /** Number of helix columns (default: auto, ~1 per 80px) */
269
+ helixCount?: number;
270
+ /** Light mode (default: false) */
271
+ lightMode?: boolean;
272
+ }
273
+ declare function renderDnaBackground(ctx: CanvasRenderingContext2D, width: number, height: number, time: number, options?: DnaBackgroundOptions): void;
274
+
275
+ interface TerrainBackgroundOptions {
276
+ /** Font size in CSS pixels (default: 13) */
277
+ fontSize?: number;
278
+ /** Characters for terrain density (default: ' .,:;+*#@') */
279
+ chars?: string;
280
+ /** Foreground ground colour (default: '#4caf50') */
281
+ color?: string;
282
+ /** Sky / star colour (default: '#1a237e') */
283
+ skyColor?: string;
284
+ /** Peak / snow-cap colour (default: '#e0e0e0') */
285
+ peakColor?: string;
286
+ /** Horizontal scroll speed (default: 1) */
287
+ speed?: number;
288
+ /** Terrain roughness 0.1–1 (default: 0.55) */
289
+ roughness?: number;
290
+ /** Mountain height fraction 0–1 (default: 0.55) */
291
+ heightScale?: number;
292
+ /** Show faint background stars (default: true) */
293
+ stars?: boolean;
294
+ /** Light mode (default: false) */
295
+ lightMode?: boolean;
296
+ }
297
+ declare function renderTerrainBackground(ctx: CanvasRenderingContext2D, width: number, height: number, time: number, options?: TerrainBackgroundOptions): void;
298
+
299
+ interface CircuitBackgroundOptions {
300
+ /** Font size in CSS pixels (default: 13) */
301
+ fontSize?: number;
302
+ /** Trace characters (default: '─│┌┐└┘├┤┬┴┼') */
303
+ chars?: string;
304
+ /** Trace colour (default: '#00ff88') */
305
+ color?: string;
306
+ /** Signal pulse colour (default: '#ffffff') */
307
+ pulseColor?: string;
308
+ /** Fraction of cells that have a trace (default: 0.38) */
309
+ density?: number;
310
+ /** Signal pulse speed (default: 1) */
311
+ speed?: number;
312
+ /** Light mode (default: false) */
313
+ lightMode?: boolean;
314
+ }
315
+ declare function renderCircuitBackground(ctx: CanvasRenderingContext2D, width: number, height: number, time: number, options?: CircuitBackgroundOptions): void;
316
+
317
+ /**
318
+ * ASCII Background — public entry point for the backgrounds sub-system.
319
+ *
320
+ * Exports:
321
+ * - All 10 render functions
322
+ * - All 10 option interfaces
323
+ * - `AsciiBackgroundOptions` — combined union type + mount options
324
+ * - `asciiBackground()` — the drop-in mount helper
325
+ * - `mountWaveBackground` / `MountWaveOptions` — deprecated aliases
326
+ */
327
+
328
+ /**
329
+ * Combined options for `asciiBackground()`. Extends all 10 background option
330
+ * interfaces so every background's options can be passed through one object.
331
+ */
332
+ interface AsciiBackgroundOptions extends WaveBackgroundOptions, RainBackgroundOptions, StarsBackgroundOptions, PulseBackgroundOptions, NoiseBackgroundOptions, GridBackgroundOptions, AuroraBackgroundOptions, SilkBackgroundOptions, VoidBackgroundOptions, MorphBackgroundOptions, FireBackgroundOptions, DnaBackgroundOptions, TerrainBackgroundOptions, CircuitBackgroundOptions {
333
+ /**
334
+ * Which background to render (default: 'wave').
335
+ * - 'wave' — interactive ASCII field with vortex, sparkles, breathe
336
+ * - 'rain' — digital column rain (Matrix-style falling characters)
337
+ * - 'stars' — 3D star-warp / hyperspace chars fly toward the viewer
338
+ * - 'pulse' — concentric ASCII ripples radiating from the mouse
339
+ * - 'noise' — slow-drifting organic fractal noise field
340
+ * - 'grid' — CRT-style horizontal scan bands with cursor glitch zone
341
+ * - 'aurora' — premium slow-drifting light bands
342
+ * - 'silk' — smooth directional flow-field ribbons
343
+ * - 'void' — gravitational singularity follows the cursor
344
+ * - 'morph' — per-cell multi-frequency shimmer
345
+ * - 'fire' — upward cellular-automata flame simulation
346
+ * - 'dna' — double-helix strand scrolling with base-pair chars
347
+ * - 'terrain' — scrolling ASCII side-scroll heightmap landscape
348
+ * - 'circuit' — procedural PCB traces with traveling signal pulses
349
+ */
350
+ type?: 'wave' | 'rain' | 'stars' | 'pulse' | 'noise' | 'grid' | 'aurora' | 'silk' | 'void' | 'morph' | 'fire' | 'dna' | 'terrain' | 'circuit';
351
+ /** CSS opacity applied to the canvas element (default: 0.2) */
352
+ opacity?: number;
353
+ /** Extra CSS class names added to the injected canvas */
354
+ className?: string;
355
+ /** z-index of the canvas (default: 0) */
356
+ zIndex?: number;
357
+ /**
358
+ * Colour scheme handling (default: 'auto').
359
+ * - 'auto' — follows system prefers-color-scheme and updates live
360
+ * - 'dark' — always render bright chars on dark background
361
+ * - 'light' — always render dark chars on light background
362
+ */
363
+ colorScheme?: 'auto' | 'light' | 'dark';
364
+ /**
365
+ * Custom character colour. Accepts any CSS colour string: hex, rgb(), hsl().
366
+ * Overrides the default white/black for ASCII chars.
367
+ * @example '#6b8700'
368
+ */
369
+ color?: string;
370
+ }
371
+ /**
372
+ * All supported background type identifiers — single source of truth for
373
+ * counts, type-safe option values, and documentation.
374
+ */
375
+ declare const BACKGROUND_TYPES: readonly ["wave", "rain", "stars", "pulse", "noise", "grid", "aurora", "silk", "void", "morph", "fire", "dna", "terrain", "circuit"];
376
+ type BackgroundType = typeof BACKGROUND_TYPES[number];
377
+ /**
378
+ * Drop-in helper that mounts an interactive ASCII background onto any element.
379
+ * Injects a canvas, wires DPR resize, mouse tracking, and the RAF loop.
380
+ * Auto-detects light/dark mode and stays in sync if the system theme changes.
381
+ *
382
+ * Returns a `destroy()` function to clean everything up.
383
+ *
384
+ * @example
385
+ * ```ts
386
+ * // 1 line:
387
+ * const { destroy } = asciiBackground('#hero', { opacity: 0.2 });
388
+ *
389
+ * // React — return destroy as cleanup:
390
+ * useEffect(() => asciiBackground(ref.current).destroy, []);
391
+ * ```
392
+ */
393
+ declare function asciiBackground(target: string | HTMLElement | null, options?: AsciiBackgroundOptions): {
394
+ destroy: () => void;
395
+ };
396
+ /** @deprecated Use `asciiBackground` instead. */
397
+ declare const mountWaveBackground: typeof asciiBackground;
398
+ /** @deprecated Use `AsciiBackgroundOptions` instead. */
399
+ type MountWaveOptions = AsciiBackgroundOptions;
400
+
401
+ export { type AsciiBackgroundOptions, type AuroraBackgroundOptions, BACKGROUND_TYPES, type BackgroundType, type CircuitBackgroundOptions, type DnaBackgroundOptions, type FireBackgroundOptions, type GridBackgroundOptions, type MorphBackgroundOptions, type MountWaveOptions, type NoiseBackgroundOptions, type PulseBackgroundOptions, type RainBackgroundOptions, type SilkBackgroundOptions, type StarsBackgroundOptions, type TerrainBackgroundOptions, type VoidBackgroundOptions, type WaveBackgroundOptions, asciiBackground, mountWaveBackground, renderAuroraBackground, renderCircuitBackground, renderDnaBackground, renderFireBackground, renderGridBackground, renderMorphBackground, renderNoiseBackground, renderPulseBackground, renderRainBackground, renderSilkBackground, renderStarsBackground, renderTerrainBackground, renderVoidBackground, renderWaveBackground };
@@ -0,0 +1 @@
1
+ function t(t){const e=t.match(/^#([0-9a-f]{3,8})$/i)?.[1];if(e){const t=e.length<=4?e.split("").map(t=>parseInt(t+t,16)):[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)];return{r:t[0],g:t[1],b:t[2]}}const o=t.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i);return o?{r:+o[1],g:+o[2],b:+o[3]}:null}function e(t){return t*t*t*(t*(6*t-15)+10)}function o(t,e,o){return t+(e-t)*o}function n(t,e){let o=127*t+311*e;return o^=o>>13,(o*(o*o*15731+789221)+1376312589&2147483647)/2147483647}function l(t,l){const a=Math.floor(t),i=Math.floor(l),r=l-i,c=e(t-a),s=e(r),h=n(a,i),f=n(a+1,i),g=n(a,i+1),M=n(a+1,i+1);return o(o(h,f,c),o(g,M,c),s)}function a(t,e){return(.5*l(t,e)+.25*l(2.1*t,2.1*e)+.125*l(4.3*t,4.3*e))/.875}function i(t,e,o,l,i={x:.5,y:.5},r={}){const{fontSize:c=13,charAspect:s=.62,lineHeightRatio:h=1.4,chars:f=" .:-=+*#%@",baseColor:g=null,accentColor:M,accentThreshold:d=.52,mouseInfluence:u=.55,mouseFalloff:p=2.8,speed:$=1,vortex:b=!0,sparkles:m=!0,breathe:x=!0,lightMode:y=!1}=r,S=M??(y?"#6b8700":"#d4ff00"),w=c*s,v=c*h,C=Math.ceil(e/w),I=Math.ceil(o/v),A=i.x,B=i.y;let T=212,R=255,z=0;{const t=S.replace("#","");6===t.length&&(T=parseInt(t.slice(0,2),16),R=parseInt(t.slice(2,4),16),z=parseInt(t.slice(4,6),16))}t.clearRect(0,0,e,o),t.font=`${c}px "JetBrains Mono", monospace`,t.textBaseline="top";const P=l*$,q=x?.12*(.5*Math.sin(.22*P)+.5):0;for(let e=0;e<I;e++)for(let o=0;o<C;o++){const l=o/C,i=e/I,r=.045,c=.08*P,s=.06,h=.45*((.5*Math.sin(.08*o+.05*e+.6*P)+.5+(.5*Math.sin(.03*o-.07*e+.4*P)+.5)+(.5*Math.sin(.05*o+.03*e+.8*P)+.5))/3)+.35*(.5*a(o*r+c,e*r*1.4-.7*c)+.5)+.2*(.5*Math.sin((o+.65*e)*s+1.1*P)+.5)+q,M=l-A,$=i-B,x=Math.sqrt(M*M+$*$);let S=0;if(b&&x<.35){const t=Math.atan2($,M),e=Math.sin(4*t+2.2*P-14*x),o=Math.max(0,1-x/.35);S=e*o*o*.22}const k=h*(1-u)+(Math.max(0,1-x*p)+.5*S)*u+.15*S,E=Math.min(1,Math.max(0,k));let F=E;if(m&&E>.72){const t=Math.floor(8*P),l=n(7*o+3*t,11*e+t);l>.88&&(F=Math.min(1,E+4*(l-.88)))}const L=Math.floor(F*(f.length-1));if(" "===f[L])continue;const J=.015+.07*F;if(F>d){const e=Math.min(y?.9:.28,J*(y?14:2.8));t.fillStyle=`rgba(${T},${R},${z},${e})`}else t.fillStyle=g?g.replace("{a}",String(J)):y?`rgba(55,55,55,${7*J})`:`rgba(255,255,255,${J})`;t.fillText(f[L],o*w,e*v)}}function r(e,o,l,a,i={}){const{fontSize:r=13,chars:c="0123456789ABCDEF@#$&*+=/<>",accentColor:s,color:h,speed:f=1,density:g=.55,tailLength:M=14,lightMode:d=!1}=i,u=s??(d?"#6b8700":"#d4ff00"),p=.62*r,$=1.4*r,b=Math.ceil(o/p),m=Math.ceil(l/$);e.clearRect(0,0,o,l),e.font=`${r}px monospace`,e.textBaseline="top";let x=255,y=255,S=255;if(d&&(x=55,y=55,S=55),h){const e=t(h);e&&(x=e.r,y=e.g,S=e.b)}let w=212,v=255,C=0;const I=t(u);I&&(w=I.r,v=I.g,C=I.b);const A=m+M;for(let t=0;t<b;t++){if(n(17*t,3)>g)continue;const o=(.5+1.5*n(31*t,7))*f,l=n(13*t,11)*A,i=Math.floor((a*o*7+l)%A),r=t*p;for(let o=0;o<=M;o++){const l=i-(M-o);if(l<0||l>=m)continue;const s=l*$,h=n(53*t+Math.floor(5*a+o),7*l),f=c[Math.floor(h*c.length)],g=o/M;if(o===M)e.fillStyle=`rgba(${w},${v},${C},${d?.7:.85})`;else{const t=d?.85*g:.15*g;e.fillStyle=`rgba(${x},${y},${S},${t})`}e.fillText(f,r,s)}}}function c(e,o,l,a,i={x:.5,y:.5},r={}){const{fontSize:c=14,chars:s=" . · * + ° ★",accentColor:h,color:f,speed:g=1,count:M=180,lightMode:d=!1}=r,u=h??(d?"#6b8700":"#d4ff00");e.clearRect(0,0,o,l),e.textBaseline="middle",e.textAlign="center";const p=o*(.2+.6*i.x),$=l*(.2+.6*i.y),b=.65*Math.sqrt(o*o+l*l);let m=255,x=255,y=255;if(d&&(m=55,x=55,y=55),f){const e=t(f);e&&(m=e.r,x=e.g,y=e.b)}let S=212,w=255,v=0;const C=t(u);C&&(S=C.r,w=C.g,v=C.b);const I=s.replace(/ /g,"").split("");if(0!==I.length){for(let t=0;t<M;t++){const i=n(17*t,3)*Math.PI*2,r=(a*(.15+.85*n(31*t,7))*g*.22+n(13*t,11))%1,s=p+Math.cos(i)*r*b,h=$+Math.sin(i)*r*b;if(s<-20||s>o+20||h<-20||h>l+20)continue;const f=Math.max(6,c*(.4+.9*r));e.font=`${f}px monospace`;const M=I[Math.min(I.length-1,Math.floor(r*I.length))],u=r>.72,C=d?.85*r:.2*r;e.fillStyle=u?`rgba(${S},${w},${v},${Math.min(d?.92:.32,2.2*C)})`:`rgba(${m},${x},${y},${C})`,e.fillText(M,s,h)}e.textAlign="left"}}function s(e,o,n,l,a={x:.5,y:.5},i={}){const{fontSize:r=14,chars:c=". · ○ ◎ ●",accentColor:s,color:h,rings:f=5,speed:g=1,sharpness:M=4,lightMode:d=!1}=i,u=s??(d?"#007a5e":"#00ffcc");e.clearRect(0,0,o,n),e.textBaseline="middle",e.textAlign="center";const p=o*a.x,$=n*a.y,b=1.6*Math.sqrt(p*p+$*$)+.2*Math.sqrt(o*o+n*n);let m=255,x=255,y=255;if(d&&(m=55,x=55,y=55),h){const e=t(h);e&&(m=e.r,x=e.g,y=e.b)}let S=0,w=255,v=204;const C=t(u);C&&(S=C.r,w=C.g,v=C.b);const I=c.replace(/ /g,"").split("");if(0===I.length)return;const A=Math.ceil(o/r),B=Math.ceil(n/r);for(let t=0;t<B;t++)for(let o=0;o<A;o++){const n=o*r+.5*r,a=t*r+.5*r,i=n-p,c=a-$,s=Math.sqrt(i*i+c*c)/b;let h=0;for(let t=0;t<f;t++){const e=(l*g*.38+t/f)%1,o=Math.abs(s-e),n=Math.max(0,1-o*b/(r*(12-M)));h+=Math.cos(n*Math.PI*.5)*n}if(h=Math.min(1,h),h<.02)continue;const u=h>.6;e.font=`${r}px monospace`;const C=Math.floor(h*(I.length-1)),A=I[Math.min(C,I.length-1)],B=d?.88*h:.22*h;e.fillStyle=u?`rgba(${S},${w},${v},${Math.min(d?.95:.4,.55*h)})`:`rgba(${m},${x},${y},${B})`,e.fillText(A,n,a)}e.textAlign="left"}function h(e,o,n,a,i={x:.5,y:.5},r={}){const{fontSize:c=14,chars:s=" .·:;=+*#%@░▒▓",accentColor:h,color:f,octaves:g=4,speed:M=1,scale:d=1,accentThreshold:u=.78,mouseWarp:p=.3,lightMode:$=!1}=r,b=h??($?"#6b8700":"#d4ff00"),m=.62*c,x=1.4*c,y=Math.ceil(o/m),S=Math.ceil(n/x);e.clearRect(0,0,o,n),e.font=`${c}px monospace`,e.textBaseline="top";let w=255,v=255,C=255;if($&&(w=55,v=55,C=55),f){const e=t(f);e&&(w=e.r,v=e.g,C=e.b)}let I=212,A=255,B=0;const T=t(b);T&&(I=T.r,A=T.g,B=T.b);const R=.035*d,z=a*M,P=Math.min(6,Math.max(1,g)),q=(t,e)=>{let o=0,n=.5,a=1,i=0;for(let r=0;r<P;r++)o+=l(t*a,e*a)*n,i+=n,n*=.5,a*=2.1;return o/i};for(let t=0;t<S;t++)for(let o=0;o<y;o++){const n=o*R+.06*z,l=t*R*1.3-.04*z,a=o/y-i.x,r=t/S-i.y,c=Math.sqrt(a*a+r*r),h=p>0?.12*Math.max(0,1-c/p):0,f=.5*q(n+h*Math.sin(1.3*z+8*r),l+h*Math.cos(.9*z+8*a))+.5;if(f<.12)continue;const g=s[Math.floor(f*(s.length-1))];if(" "===g)continue;const M=f>u,d=$?.82*f:.13*f;e.fillStyle=M?`rgba(${I},${A},${B},${$?.92:.28})`:`rgba(${w},${v},${C},${d})`,e.fillText(g,o*m,t*x)}}function f(e,o,l,a,i={x:.5,y:.5},r={}){const{fontSize:c=12,chars:s="·-=+|/",accentColor:h,color:f,bands:g=3,speed:M=1,bandWidth:d=.12,glitch:u=!0,lightMode:p=!1}=r,$=h??(p?"#6b8700":"#d4ff00"),b=.62*c,m=1.4*c,x=Math.ceil(o/b),y=Math.ceil(l/m);e.clearRect(0,0,o,l),e.font=`${c}px monospace`,e.textBaseline="top";let S=255,w=255,v=255;if(p&&(S=55,w=55,v=55),f){const e=t(f);e&&(S=e.r,w=e.g,v=e.b)}let C=212,I=255,A=0;const B=t($);B&&(C=B.r,I=B.g,A=B.b);const T=a*M;for(let t=0;t<y;t++)for(let o=0;o<x;o++){const l=t/y,a=((l*g-.5*T)%1+1)%1,r=Math.max(0,1-a/d),c=.35*(.5*n(3*o,7*t)+.5);let h=0;if(u){const e=o/x-i.x,a=l-i.y,r=Math.sqrt(e*e+a*a);if(r<.18){const e=n(11*o+Math.floor(12*T),5*t);h=Math.max(0,1-r/.18)*(e>.5?e-.3:0)}}const f=Math.min(1,c+.8*r+.6*h);if(f<.04)continue;const M=s[Math.floor(f*(s.length-1))],$=r>.55,B=p?.82*f:.12*f;e.fillStyle=$?`rgba(${C},${I},${A},${p?.92:.28})`:`rgba(${S},${w},${v},${B})`,e.fillText(M,o*b,t*m)}}function g(e,o,l,a,i={x:.5,y:.5},r={}){const{fontSize:c=14,chars:s=" ·∙•:;+=≡≣#@",color:h,accentColor:f,speed:g=1,layers:M=5,softness:d=1.2,mouseRipple:u=.2,lightMode:p=!1}=r,$=f??(p?"#6b8700":"#d4ff00"),b=.62*c,m=1.4*c,x=Math.ceil(o/b),y=Math.ceil(l/m);e.clearRect(0,0,o,l),e.font=`${c}px monospace`,e.textBaseline="top";let S=255,w=255,v=255;if(p&&(S=55,w=55,v=55),h){const e=t(h);e&&(S=e.r,w=e.g,v=e.b)}let C=212,I=255,A=0;const B=t($);B&&(C=B.r,I=B.g,A=B.b);const T=a*g,R=[];for(let t=0;t<M;t++){const e=n(17*t,31*t+7),o=n(23*t+5,11*t);R.push({fx:.8+2.2*e,fy:1.2+1.8*o,phase:e*Math.PI*4,dt:(.3+.5*n(7*t,13*t+3))*(t%2==0?1:-1),amp:.55+.45*n(29*t,3*t)})}for(let t=0;t<y;t++){const o=t/y;for(let n=0;n<x;n++){const l=n/x,a=l-i.x,r=o-i.y,c=Math.sqrt(a*a+r*r),h=u*Math.exp(-c*c/.06),f=l+a*h,g=o+r*h;let $=0,y=0;for(let t=0;t<M;t++){const{fx:e,fy:o,phase:n,dt:l,amp:a}=R[t];$+=Math.sin(f*e*Math.PI*2+T*l+n)*Math.cos(g*o*Math.PI*2+T*l*.7+1.3*n)*a,y+=a}const B=$/y,z=.5+.5*Math.tanh(B*d*2.2);if(z<.12)continue;const P=(z-.12)/.88,q=s[Math.min(s.length-1,Math.floor(P*s.length))],k=z>.82,E=p?.82*z:.14*z;e.fillStyle=k?`rgba(${C},${I},${A},${p?.92:.32})`:`rgba(${S},${w},${v},${E})`,e.fillText(q,n*b,t*m)}}}function M(e,o,l,a,i={}){const{fontSize:r=13,color:c,accentColor:s,speed:h=.4,layers:f=4,turbulence:g=.8,lightMode:M=!1}=i,d=s??(M?"#6b8700":"#d4ff00"),u=.62*r,p=1.4*r,$=Math.ceil(o/u),b=Math.ceil(l/p);e.clearRect(0,0,o,l),e.font=`${r}px monospace`,e.textBaseline="top";let m=255,x=255,y=255;if(M&&(m=55,x=55,y=55),c){const e=t(c);e&&(m=e.r,x=e.g,y=e.b)}let S=212,w=255,v=0;const C=t(d);C&&(S=C.r,w=C.g,v=C.b);const I=a*h,A=["─","─","╌","·","╌","─","─","╌","·"];for(let t=0;t<b;t++){const o=t/b;for(let l=0;l<$;l++){const a=l/$;let i=0,r=0;for(let t=0;t<f;t++){const e=n(13*t,7*t+3),l=1.1+2.4*e,c=.9+2*n(29*t,11*t+1),s=e*Math.PI*6,h=(.2+.5*n(41*t,17*t))*(t%2==0?1:-1.3),f=Math.sin(a*l*Math.PI*2+I*h+s),M=Math.cos(o*c*Math.PI*2+I*h*.6+1.7*s),d=Math.sin(a*c*Math.PI*g+o*l*Math.PI*g+I*h*.4);i+=Math.atan2(M+.3*d,f),r+=.5*(f*M+1)}const c=i/f,s=Math.min(1,r/f);if(s<.1)continue;const h=(c+Math.PI)/(2*Math.PI),d=A[Math.floor(h*A.length)%A.length],b=s>.8,C=M?.8*s:.13*s;e.fillStyle=b?`rgba(${S},${w},${v},${M?.9:.26})`:`rgba(${m},${x},${y},${C})`,e.fillText(d,l*u,t*p)}}}function d(e,o,l,a,i={x:.5,y:.5},r={}){const{fontSize:c=13,chars:s=" ·:;=+*#%@",color:h,accentColor:f,speed:g=1,radius:M=.38,swirl:d=3,lightMode:u=!1}=r,p=f??(u?"#6b8700":"#d4ff00"),$=.62*c,b=1.4*c,m=Math.ceil(o/$),x=Math.ceil(l/b),y=o/l;e.clearRect(0,0,o,l),e.font=`${c}px monospace`,e.textBaseline="top";let S=255,w=255,v=255;if(u&&(S=55,w=55,v=55),h){const e=t(h);e&&(S=e.r,w=e.g,v=e.b)}let C=212,I=255,A=0;const B=t(p);B&&(C=B.r,I=B.g,A=B.b);const T=a*g;for(let t=0;t<x;t++){const o=t/x;for(let l=0;l<m;l++){const a=(l/m-i.x)*y,r=o-i.y,c=Math.sqrt(a*a+r*r)/M;if(c>1){const o=n(3*l,7*t)*Math.max(0,1-3*(c-1));if(o<.62)continue;const a=o*(u?.28:.04);e.fillStyle=`rgba(${S},${w},${v},${a})`,e.fillText(s[1],l*$,t*b);continue}const h=Math.max(0,1-Math.abs(c-(.15+.12*Math.sin(1.1*T)))/.07),f=Math.pow(1-c,2.2),g=Math.min(1,f+.6*h);if(g<.06)continue;const d=Math.floor(g*(s.length-1)),p=s[Math.min(s.length-1,d)],x=h>.35||c<.08,B=u?.85*g:.18*g;e.fillStyle=x?`rgba(${C},${I},${A},${u?.95:.38})`:`rgba(${S},${w},${v},${B})`,e.fillText(p,l*$,t*b)}}}function u(e,o,l,a,i={}){const{fontSize:r=14,chars:c=" ·∙•:-=+*#",color:s,accentColor:h,speed:f=.5,harmonics:g=3,lightMode:M=!1}=i,d=h??(M?"#6b8700":"#d4ff00"),u=.62*r,p=1.4*r,$=Math.ceil(o/u),b=Math.ceil(l/p);e.clearRect(0,0,o,l),e.font=`${r}px monospace`,e.textBaseline="top";let m=255,x=255,y=255;if(M&&(m=55,x=55,y=55),s){const e=t(s);e&&(m=e.r,x=e.g,y=e.b)}let S=212,w=255,v=0;const C=t(d);C&&(S=C.r,w=C.g,v=C.b);const I=a*f,A=Array.from({length:g},(t,e)=>1/(e+1)).reduce((t,e)=>t+e,0);for(let t=0;t<b;t++)for(let o=0;o<$;o++){let l=0;for(let e=0;e<g;e++){const a=.18+1.4*n(o*(e+3)+7,t*(e+5)+11),i=n(o*(e+7),t*(e+9)+3)*Math.PI*2,r=1/(e+1);l+=Math.sin(I*a+i)*r}const a=.5*(l/A+1);if(a<.28)continue;const i=(a-.28)/.72,r=c[Math.min(c.length-1,Math.floor(i*c.length))],s=a>.88,h=M?.82*i:.13*i;e.fillStyle=s?`rgba(${S},${w},${v},${M?.92:.28})`:`rgba(${m},${x},${y},${h})`,e.fillText(r,o*u,t*p)}}function p(e,o,n,l,a={}){const{fontSize:i=13,chars:r=" .,:;i+xX#&@",color:c="#ff4500",hotColor:s="#ffe066",intensity:h=.85,wind:f=0,speed:g=1,lightMode:M=!1}=a,d=.62*i,u=1.4*i,p=Math.ceil(o/d),$=Math.ceil(n/u),b=p*$,m="__fire_heat__",x=e.canvas;let y=x[m];y&&y.length===b||(y=new Float32Array(b),x[m]=y);const S=.18*(.016*g),w=f*g*.8,v=$-1,C=l*g;for(let t=0;t<p;t++){const e=(.6*(.5*Math.sin(.31*t+4.1*C)+.5)+.4*(.5*Math.sin(.73*t-2.7*C)+.5))*h;y[v*p+t]=Math.min(1,e+.15*Math.random()*h),v>0&&(y[(v-1)*p+t]=Math.min(1,.85*e+.1*Math.random()*h))}const I=new Float32Array(b);for(let t=0;t<$-2;t++)for(let e=0;e<p;e++){const o=.4*y[(t+1)*p+e]+.25*y[(t+2)*p+Math.max(0,Math.min(p-1,e+Math.round(w)))]+.175*y[(t+1)*p+Math.max(0,e-1)]+.175*y[(t+1)*p+Math.min(p-1,e+1)];I[t*p+e]=Math.max(0,o-S-.02*Math.random()*g)}for(let t=0;t<p;t++)I[($-1)*p+t]=y[($-1)*p+t],$>1&&(I[($-2)*p+t]=y[($-2)*p+t]);x[m]=I;const A=t(c)??{r:255,g:69,b:0},B=t(s)??{r:255,g:224,b:102};e.clearRect(0,0,o,n),e.font=`${i}px "JetBrains Mono", monospace`,e.textBaseline="top";for(let t=0;t<$;t++)for(let o=0;o<p;o++){const n=I[t*p+o];if(n<.03)continue;const l=r[Math.min(r.length-1,Math.floor(n*r.length))];if(" "===l)continue;const a=Math.min(1,1.2*n),i=A.r+(B.r-A.r)*a|0,c=A.g+(B.g-A.g)*a|0,s=A.b+(B.b-A.b)*a|0,h=M?1-.3*n:Math.min(1,n+.15);e.globalAlpha=h,e.fillStyle=`rgb(${i},${c},${s})`,e.fillText(l,o*d,t*u)}e.globalAlpha=1}function $(e,o,l,a,i={}){const{fontSize:r=13,baseChars:c="ATCG",bridgeChars:s="-=≡",color:h="#00e5ff",color2:f="#ff4081",bridgeColor:g="#88ffcc",speed:M=1,helixCount:d,lightMode:u=!1}=i,p=.62*r,$=1.4*r,b=Math.ceil(o/p),m=Math.ceil(l/$),x=d??Math.max(1,Math.floor(o/80)),y=b/x,S=t(h)??{r:0,g:229,b:255},w=t(f)??{r:255,g:64,b:129},v=t(g)??{r:136,g:255,b:204};e.clearRect(0,0,o,l),e.font=`${r}px "JetBrains Mono", monospace`,e.textBaseline="top";const C=a*M,I=.35*y;for(let t=0;t<x;t++){const o=y*(t+.5);for(let l=0;l<m;l++){const a=l/m*Math.PI*6-1.8*C,i=o+Math.sin(a)*I,r=o+Math.sin(a+Math.PI)*I,h=Math.round(i),f=Math.round(r);if(h<0||h>=b)continue;const g=n(31*t+7*l,3),M=c[Math.floor(g*c.length)],d=.5*(Math.sin(a)+1),u=.5*(Math.sin(a+Math.PI)+1);if(e.globalAlpha=.35+.65*d,e.fillStyle=`rgb(${S.r},${S.g},${S.b})`,e.fillText(M,h*p,l*$),f>=0&&f<b){const o=n(53*t+11*l,7),a=c[Math.floor(o*c.length)];e.globalAlpha=.35+.65*u,e.fillStyle=`rgb(${w.r},${w.g},${w.b})`,e.fillText(a,f*p,l*$)}if(l%3===0){const o=Math.min(h,f),a=Math.max(h,f);if(a-o>1){const i=n(17*l+43*t,5),r=s[Math.floor(i*s.length)],c=.25*(d+u)+.2;e.globalAlpha=c,e.fillStyle=`rgb(${v.r},${v.g},${v.b})`;for(let t=o+1;t<a;t++)e.fillText(r,t*p,l*$)}}}}e.globalAlpha=1}function b(e,o,l,i,r={}){const{fontSize:c=13,chars:s=" .,:;+*#@",color:h="#4caf50",skyColor:f="#1a237e",peakColor:g="#e0e0e0",speed:M=1,roughness:d=.55,heightScale:u=.55,stars:p=!0,lightMode:$=!1}=r,b=.62*c,m=1.4*c,x=Math.ceil(o/b),y=Math.ceil(l/m),S=t(h)??{r:76,g:175,b:80},w=t(f)??{r:26,g:35,b:126},v=t(g)??{r:224,g:224,b:224};e.clearRect(0,0,o,l),e.font=`${c}px "JetBrains Mono", monospace`,e.textBaseline="top";const C=i*M*.4,I=new Array(x);for(let t=0;t<x;t++){const e=(.5*a((t/x+C)*d*3,.5)+.5)*u;I[t]=Math.floor(e*y)}for(let t=0;t<y;t++)for(let o=0;o<x;o++){const l=y-1-I[o],a=t===l;if(!(t>=l)){if(p){const l=n(7*o+Math.floor(.3*C),13*t);if(l>.97){const n=.3*Math.sin(2*i+100*l)+.7;e.globalAlpha=.5*n,e.fillStyle=`rgb(${w.r+60},${w.g+60},${w.b+80})`,e.fillText("·",o*b,t*m)}}continue}const r=(t-l)/Math.max(1,I[o]),c=s[Math.min(s.length-1,Math.floor(r*s.length))];if(" "===c&&!a)continue;const h=a?1:Math.max(0,1-4*r),f=S.r+(v.r-S.r)*h|0,g=S.g+(v.g-S.g)*h|0,M=S.b+(v.b-S.b)*h|0;e.globalAlpha=.5+.5*r,e.fillStyle=`rgb(${f},${g},${M})`,e.fillText(a?s[s.length-1]:c,o*b,t*m)}e.globalAlpha=1}var m=1,x=2,y=4,S=8,w={3:"─",12:"│",9:"┌",10:"┐",5:"└",6:"┘",11:"┬",7:"┴",13:"├",14:"┤",15:"┼",[m]:"╶",[x]:"╴",[y]:"╵",[S]:"╷"};function v(e,o,l,a,i={}){const{fontSize:r=13,pulseColor:c="#ffffff",color:s="#00ff88",density:h=.38,speed:f=1,lightMode:g=!1}=i,M=.62*r,d=1.4*r,u=Math.ceil(o/M),p=Math.ceil(l/d),$=t(s)??{r:0,g:255,b:136},b=t(c)??{r:255,g:255,b:255},m=(t,e)=>{if(n(17*t+1,7*e+2)>h)return 0;let o=0;return t+1<u&&n(17*t+1,7*e+2)>.15&&(o|=1),t-1>=0&&n(17*(t-1)+1,7*e+2)>.15&&(o|=2),e+1<p&&n(17*t+1,7*(e+1)+2)>.15&&(o|=8),e-1>=0&&n(17*t+1,7*(e-1)+2)>.15&&(o|=4),o};e.clearRect(0,0,o,l),e.font=`${r}px "JetBrains Mono", monospace`,e.textBaseline="top";const x=a*f;for(let t=0;t<p;t++)for(let o=0;o<u;o++){const l=m(o,t);if(0===l)continue;const a=w[l]??"·",i=(8*x+40*n(o,23*t))%u,r=(6*x+40*n(17*t,11*o))%p,c=(1&l||2&l)&&Math.abs(o-i)<1.5,s=(4&l||8&l)&&Math.abs(t-r)<1.5,h=c||s,f=.25+.35*n(3*o,5*t);h?(e.globalAlpha=.95,e.fillStyle=`rgb(${b.r},${b.g},${b.b})`):(e.globalAlpha=f,e.fillStyle=`rgb(${$.r},${$.g},${$.b})`),e.fillText(a,o*M,t*d)}e.globalAlpha=1}var C=["wave","rain","stars","pulse","noise","grid","aurora","silk","void","morph","fire","dna","terrain","circuit"];function I(t,e={}){const{type:o="wave",opacity:n=.2,className:l,zIndex:a=0,colorScheme:m="auto",color:x,...y}=e,S="string"==typeof t?document.querySelector(t):t;if(!S)return console.warn("[asciify] asciiBackground: target not found",t),{destroy:()=>{}};const w=S.style.position;"static"===getComputedStyle(S).position&&(S.style.position="relative");const C=document.createElement("canvas");C.style.cssText=["position:absolute","inset:0","width:100%","height:100%",`opacity:${n}`,"pointer-events:none",`z-index:${a}`].join(";"),l&&(C.className=l),S.prepend(C);const I=C.getContext("2d"),A=window.devicePixelRatio||1,B={x:.5,y:.5},T={x:.5,y:.5},R=()=>"light"===m||"dark"!==m&&(()=>{let t=S;for(;t&&t!==document.documentElement.parentElement;){const e=getComputedStyle(t).backgroundColor;if(e&&"transparent"!==e&&"rgba(0, 0, 0, 0)"!==e){const t=e.match(/rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)/);if(t)return(.299*+t[1]+.587*+t[2]+.114*+t[3])/255>=.4}t=t.parentElement}const e=document.documentElement,o=(e.getAttribute("data-theme")||"").toLowerCase();return"dark"!==o&&("light"===o||!e.classList.contains("dark")&&window.matchMedia("(prefers-color-scheme: light)").matches)})(),z=x?function(t){const e=t.match(/^#([0-9a-f]{3,8})$/i)?.[1];if(e){const t=e.length<=4?e.split("").map(t=>parseInt(t+t,16)):[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)];return{r:t[0],g:t[1],b:t[2]}}const o=t.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i);return o?{r:+o[1],g:+o[2],b:+o[3]}:null}(x):null,P=()=>({...y,lightMode:void 0!==y.lightMode?y.lightMode:R(),baseColor:z?`rgba(${z.r},${z.g},${z.b},{a})`:y.baseColor}),q={current:P()},k=()=>{q.current="rain"===o||"stars"===o||"pulse"===o||"noise"===o||"grid"===o||"aurora"===o||"silk"===o||"void"===o||"morph"===o?{...y,lightMode:void 0!==y.lightMode?y.lightMode:R(),color:x??y.color}:"fire"===o||"dna"===o?{...y,color:x??y.color}:"terrain"===o||"circuit"===o?{...y,color:x??y.color,lightMode:void 0!==y.lightMode?y.lightMode:R()}:P()};k();const E=window.matchMedia("(prefers-color-scheme: light)"),F=()=>{k()};let L=null;"auto"===m&&(E.addEventListener("change",F),L=new MutationObserver(F),L.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]}));const J=()=>{const t=S.getBoundingClientRect();C.width=t.width*A,C.height=t.height*A,I.setTransform(A,0,0,A,0,0)};J();const _=t=>{const e=S.getBoundingClientRect();B.x=(t.clientX-e.left)/e.width,B.y=(t.clientY-e.top)/e.height},N=new ResizeObserver(J);N.observe(S),window.addEventListener("mousemove",_);let O=0,W=0;const X=()=>{T.x+=.07*(B.x-T.x),T.y+=.07*(B.y-T.y);const t=S.getBoundingClientRect();"rain"===o?r(I,t.width,t.height,O,q.current):"stars"===o?c(I,t.width,t.height,O,T,q.current):"pulse"===o?s(I,t.width,t.height,O,T,q.current):"noise"===o?h(I,t.width,t.height,O,T,q.current):"grid"===o?f(I,t.width,t.height,O,T,q.current):"aurora"===o?g(I,t.width,t.height,O,T,q.current):"silk"===o?M(I,t.width,t.height,O,q.current):"void"===o?d(I,t.width,t.height,O,T,q.current):"morph"===o?u(I,t.width,t.height,O,q.current):"fire"===o?p(I,t.width,t.height,O,q.current):"dna"===o?$(I,t.width,t.height,O,q.current):"terrain"===o?b(I,t.width,t.height,O,q.current):"circuit"===o?v(I,t.width,t.height,O,q.current):i(I,t.width,t.height,O,T,q.current),O+=.016,W=requestAnimationFrame(X)};return W=requestAnimationFrame(X),{destroy:()=>{cancelAnimationFrame(W),N.disconnect(),"auto"===m&&(E.removeEventListener("change",F),L?.disconnect()),window.removeEventListener("mousemove",_),C.remove(),S.style.position=w}}}var A=I;export{C as BACKGROUND_TYPES,I as asciiBackground,A as mountWaveBackground,g as renderAuroraBackground,v as renderCircuitBackground,$ as renderDnaBackground,p as renderFireBackground,f as renderGridBackground,u as renderMorphBackground,h as renderNoiseBackground,s as renderPulseBackground,r as renderRainBackground,M as renderSilkBackground,c as renderStarsBackground,b as renderTerrainBackground,d as renderVoidBackground,i as renderWaveBackground};//# sourceMappingURL=backgrounds.js.map
package/dist/core.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";var e={standard:" .:-=+*#%@",blocks:" ░▒▓█",minimal:" .:+",dense:" .'`^\",:;Il!i><~+_-?][}{1)(|/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$",binary:"01",dots:" ⠁⠃⠇⡇⣇⣧⣷⣿",letters:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",claudeCode:" ╔╗╚╝║═╠╣╦╩╬░▒▓█│─┌┐└┘├┤┬┴┼",box:" ▪◾◼■█",lines:" ˗‐–—―━",braille:" ⠁⠂⠃⠄⠅⠆⠇⠈⠉⠊⠋⠌⠍⠎⠏⠐⠑⠒⠓⠔⠕⠖⠗⠘⠙⠚⠛⠜⠝⠞⠟⠠⠡⠢⠣⠤⠥⠦⠧⠨⠩⠪⠫⠬⠭⠮⠯⠰⠱⠲⠳⠴⠵⠶⠷⠸⠹⠺⠻⠼⠽⠾⠿⡀⡁⡂⡃⡄⡅⡆⡇⣀⣁⣂⣃⣄⣅⣆⣇⣈⣉⣊⣋⣌⣍⣎⣏⣐⣑⣒⣓⣔⣕⣖⣗⣘⣙⣚⣛⣜⣝⣞⣟⣠⣡⣢⣣⣤⣥⣦⣧⣨⣩⣪⣫⣬⣭⣮⣯⣰⣱⣲⣳⣴⣵⣶⣷⣸⣹⣺⣻⣼⣽⣾⣿",katakana:" ヲァィゥェォャュョッアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン",musical:" ♩♪♫♬♭♮♯",emoji:" ⬛🟫🟥🟧🟨🟩🟦🟪⬜",circles:" .·:∘○◦°•∙",shadows:" ·∘◦○◎⊙●◉",starfield:" ˙·∘∗✦✧★◆●",geometric:" ·△▷◇◈◆▣■█",pipes:" ╶─┐└├┤┬┴┼╬▒▓█",waves:" ˜∼≈〰≋∿∾∭∫",shards:" ╱╲╳◤◥◣◢△▲◆◼█",smoke:" ·˙⁚⁖∶∷⋮⋰⋱∴∵",ascii:" .'`^\",:;~-_+<>i!lI?/\\|()[]{}1tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$",interface:" ·•-–—+=:;<>[]{}()⌘⌥⇧⌃↵↗↘◇◆◈□■",prompt:" .:;>_`/\\|{}[]()=+*#@$",data:" ·∙•◦○●◇◆◈▱▰▣█",humanist:" ·˙,:;∴∵∷∶⁚⋮⋯∼≈≋∞",mesh:" ·╶╴╷╵─│┌┐└┘├┤┬┴┼╬░▒▓█"},t={cosmic:[e.starfield,e.circles,e.shadows],rain:[e.katakana,e.braille,e.binary],terminal:[e.pipes,e.claudeCode,e.standard],crystal:[e.shards,e.geometric,e.blocks],fluid:[e.waves,e.smoke,e.circles],pulse:[e.dense,e.standard,e.blocks],dream:[e.braille,e.shadows,e.smoke],angular:[e.geometric,e.shards,e.starfield],assistant:[e.interface,e.prompt,e.data],signal:[e.mesh,e.data,e.ascii],editorial:[e.humanist,e.waves,e.smoke]},n={classic:{renderMode:"ascii",charset:e.standard,colorMode:"grayscale"},particles:{renderMode:"dots",colorMode:"fullcolor",dotSizeRatio:.8},letters:{renderMode:"ascii",charset:e.letters,colorMode:"fullcolor"},claudeCode:{renderMode:"ascii",charset:e.claudeCode,colorMode:"accent",accentColor:"#f97316"},art:{renderMode:"ascii",charset:e.dense,colorMode:"fullcolor"},terminal:{renderMode:"ascii",charset:e.standard,colorMode:"matrix"},box:{renderMode:"ascii",charset:e.box,colorMode:"grayscale"},lines:{renderMode:"ascii",charset:e.lines,colorMode:"fullcolor"},braille:{renderMode:"ascii",charset:e.braille,colorMode:"fullcolor"},katakana:{renderMode:"ascii",charset:e.katakana,colorMode:"matrix"},musical:{renderMode:"ascii",charset:e.musical,colorMode:"accent",accentColor:"#e040fb"},emoji:{renderMode:"ascii",charset:e.emoji,colorMode:"fullcolor"},circles:{renderMode:"ascii",charset:e.circles,colorMode:"accent",accentColor:"#d4ff00"},shadows:{renderMode:"ascii",charset:e.shadows,colorMode:"accent",accentColor:"#50a0ff"},starfield:{renderMode:"ascii",charset:e.starfield,colorMode:"fullcolor"},geometric:{renderMode:"ascii",charset:e.geometric,colorMode:"grayscale"},pipes:{renderMode:"ascii",charset:e.pipes,colorMode:"accent",accentColor:"#00ff88"},waves:{renderMode:"ascii",charset:e.waves,colorMode:"fullcolor"},shards:{renderMode:"ascii",charset:e.shards,colorMode:"grayscale"},smoke:{renderMode:"ascii",charset:e.smoke,colorMode:"accent",accentColor:"#c850ff"},ascii:{renderMode:"ascii",charset:e.ascii,colorMode:"grayscale"},interface:{renderMode:"ascii",charset:e.interface,colorMode:"accent",accentColor:"#f4f1ea"},prompt:{renderMode:"ascii",charset:e.prompt,colorMode:"matrix"},data:{renderMode:"ascii",charset:e.data,colorMode:"fullcolor"},humanist:{renderMode:"ascii",charset:e.humanist,colorMode:"accent",accentColor:"#d6ccc2"},mesh:{renderMode:"ascii",charset:e.mesh,colorMode:"accent",accentColor:"#8fd3ff"}},o={agentField:{...n.interface,charsetFrames:t.assistant,charsetFps:1.6,animationStyle:"breathe",animationSpeed:.75,ditherStrength:.12,hoverEffect:"glow",hoverStrength:.42,hoverRadius:.18,hoverColor:"#f4f1ea",normalize:!0},liquidSignal:{...n.data,charsetFrames:t.signal,charsetFps:2.4,animationStyle:"melt",animationSpeed:.65,ditherStrength:.45,hoverEffect:"repel",hoverStrength:.55,hoverRadius:.22,hoverColor:"#8fd3ff",normalize:!0},cursorGravity:{...n.mesh,charsetFrames:t.angular,charsetFps:1.2,animationStyle:"orbit",animationSpeed:.9,ditherStrength:.2,hoverEffect:"attract",hoverStrength:.82,hoverRadius:.24,hoverColor:"#ffffff",normalize:!0},editorialPulse:{...n.humanist,charsetFrames:t.editorial,charsetFps:.9,animationStyle:"ripple",animationSpeed:.55,ditherStrength:.18,hoverEffect:"spotlight",hoverStrength:.35,hoverRadius:.2,hoverColor:"#fff8ea",normalize:!0},terminalFlow:{...n.prompt,charsetFrames:t.terminal,charsetFps:3,animationStyle:"rain",animationSpeed:1.1,ditherStrength:.22,hoverEffect:"glitchText",hoverStrength:.65,hoverRadius:.16,hoverColor:"#d4ff00",hoverText:["BUILD","SHIP","RUN","ASK","MODEL"],normalize:!0}},r={fontSize:7,charSpacing:1,brightness:0,contrast:0,charset:e.standard,colorMode:"grayscale",accentColor:"#d4ff00",invert:!1,renderMode:"ascii",animationStyle:"none",animationSpeed:1,dotSizeRatio:.8,ditherStrength:0,charAspect:.55,normalize:!1,hoverStrength:0,hoverRadius:.2,hoverEffect:"spotlight",hoverColor:"#ffffff",hoverShape:"circle",hoverText:"ASCIIFY",artStyle:"classic",customText:"",chromaKey:null,chromaKeyTolerance:60,chromaKeyTrimPadding:.002,chromaKeyTrimLuminanceThreshold:0,chromaKeyTrimMode:"range"};function a(e,t){const n=document.createElement("canvas");n.width=e,n.height=t;const o=n.getContext("2d",{willReadFrequently:!0});return{canvas:n,ctx:o}}function i(e,t,n){let o=e+255*t;return o=259*(255*n+255)/(255*(259-255*n))*(o-128)+128,Math.max(0,Math.min(255,o))}function s(e,t,n,o,r,a){if((a?1-e/255:e/255)<.12)return" ";const i=[...t];return i[(o*r+n)%i.length]}var c=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];function l(e,t,n,o){if(o<=0)return e;const r=(c[n%4][t%4]/16-.5)*o*128;return Math.max(0,Math.min(255,e+r))}var h=new Array(256),d=new Array(256);for(let e=0;e<256;e++)h[e]=`rgb(${e},${e},${e})`,d[e]=`rgb(0,${e},0)`;function f(e,t,n,o,r,a=!1){switch(t){case"fullcolor":return`rgb(${e.r},${e.g},${e.b})`;case"matrix":return d[.299*e.r+.587*e.g+.114*e.b|0];case"accent":return`rgb(${n},${o},${r})`;default:{const t=.299*e.r+.587*e.g+.114*e.b|0;return h[t]}}}var m=[0,0,0];function u(e,t,n,o,r,a=!1){switch(t){case"fullcolor":m[0]=e.r,m[1]=e.g,m[2]=e.b;break;case"matrix":{const t=.299*e.r+.587*e.g+.114*e.b|0;m[0]=0,m[1]=t,m[2]=0;break}case"accent":m[0]=n,m[1]=o,m[2]=r;break;default:{const t=.299*e.r+.587*e.g+.114*e.b|0;m[0]=t,m[1]=t,m[2]=t;break}}return m}function g(e){const t=e.match(/rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)(?:\s*[,/]\s*([\d.]+))?\s*\)/);return t?{r:+t[1],g:+t[2],b:+t[3],a:void 0!==t[4]?+t[4]:1}:null}function M(e){let t=e;for(;t&&t!==document.documentElement.parentElement;){const e=getComputedStyle(t).backgroundColor;if(e&&"transparent"!==e&&"rgba(0, 0, 0, 0)"!==e){const t=g(e);if(t&&t.a>.1)return t}t=t.parentElement}return null}function p(e){if(e){const t=M(e);if(t){return(.299*t.r+.587*t.g+.114*t.b)/255<.4}}if("undefined"!=typeof document){const e=document.documentElement,t=(e.getAttribute("data-theme")||"").toLowerCase();if("dark"===t)return!0;if("light"===t)return!1;if(e.classList.contains("dark"))return!0;if(document.body){const e=M(document.body);if(e){return(.299*e.r+.587*e.g+.114*e.b)/255<.4}}}return"undefined"!=typeof window&&window.matchMedia("(prefers-color-scheme: dark)").matches}function v(e){if("string"!=typeof e)return e;const t=document.createElement("canvas");t.width=1,t.height=1;const n=t.getContext("2d");n.fillStyle=e,n.fillRect(0,0,1,1);const o=n.getImageData(0,0,1,1).data;return{r:o[0],g:o[1],b:o[2]}}function w(e){return e*e*(3-2*e)}function x(e,t,n,o,r,a,i){if("none"===a)return 1;const s=r*i;switch(a){case"wave":return.3+.7*(.6*(.5*Math.sin(e/n*Math.PI*4+3*s)+.5)+.4*(.5*Math.sin(t/o*Math.PI*3+2*s)+.5));case"pulse":{const r=n/2,a=o/2,i=Math.sqrt((e-r)**2+(t-a)**2),c=Math.sqrt(r**2+a**2);return.2+.8*(.5*Math.sin(i/c*Math.PI*6-4*s)+.5)}case"rain":return.1+.9*(.5*Math.sin(t/o*Math.PI*8-5*s+.3*e)+.5)*(.3*Math.sin(e/n*Math.PI*2+s)+.7);case"breathe":{const n=.3*Math.sin(2*s)+.7,o=.1*Math.sin(.1*(e+t)+s);return Math.max(.1,Math.min(1,n+o))}case"sparkle":{const n=43758.5453*Math.sin(127.1*e+311.7*t+43758.5453*Math.floor(8*s)),o=n-Math.floor(n);return o>.7?1:.15+.4*o}case"glitch":{const e=Math.floor(t/(.05*o)),n=43758.5453*Math.sin(43.23*e+17.89*Math.floor(6*s));if(n-Math.floor(n)>.85){const t=.5*Math.sin(30*s+e)+.5;return t<.3?0:t}return 1}case"spiral":{const r=n/2,a=o/2,i=e-r,c=t-a,l=Math.atan2(c,i),h=Math.sqrt(i*i+c*c),d=Math.sqrt(r*r+a*a);return.15+.85*(.5*Math.sin(3*l+h/d*Math.PI*8-3*s)+.5)}case"typewriter":{const r=n*o,a=t*n+e-.5*s%1*r*1.3;if(a>0)return 0;const i=Math.max(0,1+a/(.15*r));return Math.min(1,i)}case"scatter":{const r=n/2,a=o/2,i=e-r,c=t-a,l=Math.sqrt(i*i+c*c)/Math.sqrt(r*r+a*a),h=.5*Math.sin(1.5*s)+.5;return l>h?Math.max(0,1-3*(l-h)):.7+.3*Math.sin(10*l-2*s)}case"waveField":return.55+.45*Math.sin(e/n*9+2*Math.sin(t/o*6-s)+1.5*s);case"ripple":{const r=n/2,a=o/2,i=e-r,c=t-a,l=Math.sqrt(i*i+c*c),h=Math.sqrt(r*r+a*a);return.1+.9*(.5*Math.sin(l/h*Math.PI*10-5*s)+.5)*(.4+.6*(1-Math.min(1,l/(1.1*h))))}case"melt":{const n=t/o*Math.PI;return.05+(.5*Math.sin(n-1.8*s+.15*e)+.5)*(1-.6*(Math.max(0,t/o-.1)/.9))*.95}case"orbit":{const r=n/2,a=o/2,i=e-r,c=t-a,l=Math.atan2(c,i),h=Math.sqrt(i*i+c*c)/Math.sqrt(r*r+a*a);return.1+.9*(.5*Math.sin(2*l+6*h-2.5*s)+.5)}case"cellular":{const n=Math.floor(4*s),o=(e,t)=>{const o=43758.5453*Math.sin(127.1*e+311.7*t+43758.5453*n);return o-Math.floor(o)>.38?1:0},r=o(e,t),a=o(e-1,t)+o(e+1,t)+o(e,t-1)+o(e,t+1)+o(e-1,t-1)+o(e+1,t-1)+o(e-1,t+1)+o(e+1,t+1);return 1===(1===r?2===a||3===a?1:0:3===a?1:0)?1:.05}default:return 1}}var y={scale:1,offsetX:0,offsetY:0,glow:0,colorBlend:0,proximity:0};function b(e,t,n,o,r,a,i,s,c="spotlight",l=.5,h="circle",d=[],f=1){const m=(e-n)*Math.max(1,f),u=(t-o)*Math.max(1,1/f),g=.08+.35*l+.04*a;let M,p;if("box"===h){const e=Math.abs(m),t=Math.abs(u);M=Math.max(e,t),p=g}else M=Math.sqrt(m*m+u*u),p=g;if(M>=p&&("trail"!==c||0===d.length))return y.scale=1,y.offsetX=0,y.offsetY=0,y.glow=0,y.colorBlend=0,y.proximity=0,y;const v=w(Math.max(0,1-M/p))*r;let x=1,b=0,S=0,E=0,C=0;switch(c){case"spotlight":{x=1+v*a*1.8;const e=Math.atan2(u,m),t=v*v*a*.6;b=Math.cos(e)*t*i,S=Math.sin(e)*t*s,E=v*a*.4,C=v*v*a*.25;break}case"magnify":x=1+v*a*.85,E=v*a*.15;break;case"repel":{x=1;const e=Math.atan2(u,m),t=v*v*a*1.8;b=Math.cos(e)*t*i,S=Math.sin(e)*t*s;break}case"glow":E=v*a*.8,C=v*a*.4;break;case"colorShift":x=1,E=v*a*.12,C=v*a;break;case"attract":{const e=Math.atan2(u,m),t=v*v*a*1;b=(.45*-Math.cos(e)-1.6*Math.sin(e))*t*i,S=(.45*-Math.sin(e)+1.6*Math.cos(e))*t*s,E=v*a*.3;break}case"shatter":{const e=Math.atan2(u,m),t=.5*Math.sin(43.7*m+29.3*u),n=v*a*1.4*(.7+.3*t);b=Math.cos(e+t)*n*i,S=Math.sin(e+t)*n*s,x=Math.max(.1,1-v*a*.6),E=v*a*.25;break}case"trail":{let n=v,o=-u*v,r=m*v;for(const a of d){const i=(e-a.x)*Math.max(1,f),s=(t-a.y)*Math.max(1,1/f),c=Math.hypot(i,s)/g;if(c>=1)continue;const l=w(1-c)*a.intensity;n=Math.max(n,l),o+=(.35*a.vx-2*s)*l*.35,r+=(.35*a.vy+2*i)*l*.35}b=Math.tanh(2*o)*a*i*3,S=Math.tanh(2*r)*a*s*3,C=n*a*.65,E=n*a*.35,x=1+n*a*.08,y.proximity=n;break}case"glitchText":x=1,E=v*a*.5,C=v*a*.6}return y.scale=x,y.offsetX=b,y.offsetY=S,y.glow=E,y.colorBlend=C,"trail"!==c&&(y.proximity=v),y}function S(e,t,{continuous:n=!1,interactive:o=!1}={}){const r=e.parentElement??e;let a=null,i=0,s=!1,c=!0,l=!0,h=-1/0;const d=window.matchMedia("(prefers-reduced-motion: reduce)"),f=()=>{l=!0,s||!c||document.hidden||i||(i=requestAnimationFrame(m))},m=e=>{if(i=0,s||!c||document.hidden)return;const o=!d.matches&&(n||e-h<1500);(l||o)&&(t(e,d.matches?null:a),l=!1),o&&(i=requestAnimationFrame(m))},u=t=>{if("touch"===t.pointerType)return;const n=e.getBoundingClientRect();if(!n.width||!n.height)return;const o=(t.clientX-n.left)/n.width,r=(t.clientY-n.top)/n.height;a=o>=0&&o<=1&&r>=0&&r<=1?{x:o,y:r}:null,h=performance.now(),f()},g=()=>{a=null,h=performance.now(),f()},M=()=>{document.hidden&&i?(cancelAnimationFrame(i),i=0):f()},p="undefined"==typeof IntersectionObserver?null:new IntersectionObserver(([e])=>{c=e.isIntersecting,c?f():i&&(cancelAnimationFrame(i),i=0)});return p?.observe(e),o&&(r.addEventListener("pointermove",u),r.addEventListener("pointerleave",g)),document.addEventListener("visibilitychange",M),d.addEventListener("change",f),f(),{wake:f,stop:()=>{s=!0,cancelAnimationFrame(i),p?.disconnect(),r.removeEventListener("pointermove",u),r.removeEventListener("pointerleave",g),document.removeEventListener("visibilitychange",M),d.removeEventListener("change",f)}}}var E=null,C=null;function T(e,t){if(!E||!C){const n=a(e,t);E=n.canvas,C=n.ctx}return E.width!==e&&(E.width=e),E.height!==t&&(E.height=t),C}var F=new Map,A=new Map,R=new WeakMap;function k(e){const t=Intl.Segmenter;return t?Array.from(new t(void 0,{granularity:"grapheme"}).segment(e),({segment:e})=>e):[...e]}function I(e){let t=F.get(e);return t||(t=k(e),F.set(e,t)),t}function L(e){return k(e)}function H(e,t,n){const o=n?1-e/255:e/255,r=Math.floor(o*(t.length-1));return t[Math.max(0,Math.min(t.length-1,r))]??" "}function P(e,t,n,o){const r=`${e}\0${t?1:0}\0${n}\0${o}`;let a=A.get(r);if(!a){const s=I(e);a=new Array(256);for(let e=0;e<256;e++)a[e]=H(i(e,n,o),s,t);A.set(r,a)}return a}function W(e,t){return"auto"!==e?e:!p(t)}function $(e){const t=e.match(/^#([0-9a-fA-F]{3,6})$/);if(t){let e=t[1];if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return e}const n=e.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);return n?[n[1],n[2],n[3]].map(e=>parseInt(e).toString(16).padStart(2,"0")).join(""):null}function j(e){const t=e||"auto";if("auto"!==t)return $(t)??"ffffff";if("undefined"!=typeof document){const e=getComputedStyle(document.documentElement);for(const t of["--accent-color","--color-accent","--accent","--color-primary","--primary","--brand-color"]){const n=$(e.getPropertyValue(t).trim());if(n)return n}const t=$(getComputedStyle(document.body).accentColor??"");if(t)return t}return p("undefined"!=typeof document?document.body:null)?"faf9f7":"0d0d0d"}function z(e,t,n){return Math.max(t,Math.min(n,e))}function O(e,t,n){if(!e)return{x:0,y:0,width:t,height:n};const o=e.unit??"percent",r=!1!==e.preserveAspect,a=e=>void 0===e?void 0:"percent"===o?e*t:e,i=e=>void 0===e?void 0:"percent"===o?e*n:e,s=z(a(e.left)??0,0,t-1),c=z(a(e.right)??0,0,t-s-1),l=z(i(e.top)??0,0,n-1),h=z(i(e.bottom)??0,0,n-l-1),d=void 0!==e.left||void 0!==e.right||void 0!==e.top||void 0!==e.bottom,f=Math.max(1,t-s-c),m=Math.max(1,n-l-h),u=d?f:a(e.width),g=d?m:i(e.height);let M=u??t,p=g??n;if(r&&!d){const e=M/t,o=p/n,r=Math.min(e,o),a=void 0===u?o:void 0===g?e:r;M=t*a,p=n*a}M=z(M,1,d?f:t),p=z(p,1,d?m:n);const v=e.anchor??"center",w=a(e.x),x=i(e.y),y=d?s:0,b=d?l:0,S=d?f:t,E=d?m:n,C=v.endsWith("left")||"left"===v?0:v.endsWith("right")||"right"===v?S-M:(S-M)/2,T=v.startsWith("top")||"top"===v?0:v.startsWith("bottom")||"bottom"===v?E-p:(E-p)/2;return{x:z(w??y+C,0,Math.max(0,t-M)),y:z(x??b+T,0,Math.max(0,n-p)),width:M,height:p}}function q(e,t,n,o){const r=e instanceof HTMLVideoElement?e.videoWidth:e.width,a=e instanceof HTMLVideoElement?e.videoHeight:e.height;if(0===r||0===a)return{frame:[],cols:0,rows:0};const c=t.charAspect,h=t.fontSize*t.charSpacing,d=t.fontSize/c*t.charSpacing,f=n||r,m=o||a,u=Math.floor(f/h),g=Math.floor(m/d);if(u<=0||g<=0)return{frame:[],cols:0,rows:0};const M=O(t.sourceCrop,r,a),p=Math.max(1,Math.min(Math.floor(2048/u),Math.floor(M.width/u))),w=Math.max(1,Math.min(Math.floor(2048/g),Math.floor(M.height/g))),x=u*p,y=g*w,b=T(x,y),S=b.globalCompositeOperation;b.globalCompositeOperation="copy";try{b.drawImage(e,M.x,M.y,M.width,M.height,0,0,x,y)}finally{b.globalCompositeOperation=S}const E=b.getImageData(0,0,x,y).data,C=t.chromaKey,F=null!=C&&!1!==C,A=!0===C,R="blue-screen"===C;let k=null,L=0;!F||A||R||(k=v(C),L=(t.chromaKeyTolerance??60)**2);let $=0,j=255;if(t.normalize){let e=255,t=0;for(let n=0;n<E.length;n+=4){if(F){const e=E[n],t=E[n+1],o=E[n+2];let r=!1;if(A)r=t>1.4*e&&t>1.4*o&&t>80;else if(R)r=o>1.4*e&&o>1.4*t&&o>80;else if(null!==k){const n=e-k.r,a=t-k.g,i=o-k.b;r=n*n+a*a+i*i<=L}if(r)continue}const o=.299*E[n]+.587*E[n+1]+.114*E[n+2];o<e&&(e=o),o>t&&(t=o)}$=e,j=t>e?t-e:255}const z=[],q=W(t.invert),V=F&&t.charset.replace(/ /g,"")||t.charset,B=I(V),U=t.customText?null:P(V,q,t.brightness,t.contrast),N=p*w;for(let e=0;e<g;e++){const n=[];for(let o=0;o<u;o++){let r=0,a=0,c=0,h=0,d=0;for(let t=0;t<w;t++){const n=(e*w+t)*x;for(let e=0;e<p;e++){const t=4*(n+o*p+e),i=E[t],s=E[t+1],l=E[t+2],f=E[t+3];if(F){let e=!1;if(A)e=s>1.4*i&&s>1.4*l&&s>80;else if(R)e=l>1.4*i&&l>1.4*s&&l>80;else if(null!==k){const t=i-k.r,n=s-k.g,o=l-k.b;e=t*t+n*n+o*o<=L}if(e){d++;continue}}r+=i,a+=s,c+=l,h+=f}}if(F&&d>N/2){n.push({char:" ",r:0,g:0,b:0,a:0});continue}const f=N-d,m=f>0?r/f:0,g=f>0?a/f:0,M=f>0?c/f:0,v=f>0?h/f:0,y=.299*m+.587*g+.114*M,b=t.normalize?(y-$)/j*255:y,S=i(b,t.brightness,t.contrast),C=t.ditherStrength>0?l(S,o,e,t.ditherStrength):S,T=t.customText?s(C,t.customText,o,e,u,q):t.ditherStrength>0?H(C,B,q):U[Math.max(0,Math.min(255,0|b))];n.push({char:T,r:m,g:g,b:M,a:v,lum:C})}z.push(n)}return{frame:z,cols:u,rows:g}}function V(e,t,n,o){const r=e instanceof HTMLVideoElement?e.videoWidth:e.width,a=e instanceof HTMLVideoElement?e.videoHeight:e.height;if(0===r||0===a)return{rows:[],cols:0,rowCount:0};const s=t.charAspect,c=t.fontSize*t.charSpacing,h=t.fontSize/s*t.charSpacing,d=n||r,f=o||a,m=Math.floor(d/c),u=Math.floor(f/h);if(m<=0||u<=0)return{rows:[],cols:0,rowCount:0};const g=m,M=u,p=T(g,M),w=O(t.sourceCrop,r,a),x=p.globalCompositeOperation;p.globalCompositeOperation="copy";try{p.drawImage(e,w.x,w.y,w.width,w.height,0,0,g,M)}finally{p.globalCompositeOperation=x}const y=p.getImageData(0,0,g,M).data,b=t.chromaKey,S=null!=b&&!1!==b,E=!0===b,C="blue-screen"===b;let F=null,A=0;!S||E||C||(F=v(b),A=(t.chromaKeyTolerance??60)**2);let R=0,k=255;if(t.normalize){let e=255,t=0;for(let n=0;n<y.length;n+=4){if(S){const e=y[n],t=y[n+1],o=y[n+2];let r=!1;if(E)r=t>1.4*e&&t>1.4*o&&t>80;else if(C)r=o>1.4*e&&o>1.4*t&&o>80;else if(null!==F){const n=e-F.r,a=t-F.g,i=o-F.b;r=n*n+a*a+i*i<=A}if(r)continue}const o=.299*y[n]+.587*y[n+1]+.114*y[n+2];o<e&&(e=o),o>t&&(t=o)}R=e,k=t>e?t-e:255}const L=W(t.invert),$=S&&t.charset.replace(/ /g,"")||t.charset,j=I($),z=t.customText?null:P($,L,t.brightness,t.contrast),q=t.customText?I(t.customText):null,V="fullcolor"===t.colorMode?new Uint8ClampedArray(m*u*4):void 0,B=[];for(let e=0;e<u;e++){let n="";for(let o=0;o<m;o++){const r=4*(e*g+o),a=r,s=y[r],c=y[r+1],h=y[r+2],d=y[r+3];if(S){let e=!1;if(E)e=c>1.4*s&&c>1.4*h&&c>80;else if(C)e=h>1.4*s&&h>1.4*c&&h>80;else if(null!==F){const t=s-F.r,n=c-F.g,o=h-F.b;e=t*t+n*n+o*o<=A}if(e){n+=" ",V&&(V[a]=0,V[a+1]=0,V[a+2]=0,V[a+3]=0);continue}}V&&(V[a]=s,V[a+1]=c,V[a+2]=h,V[a+3]=d);const f=.299*s+.587*c+.114*h,u=t.normalize?(f-R)/k*255:f,M=t.ditherStrength>0||q?i(u,t.brightness,t.contrast):u,p=t.ditherStrength>0?l(M,o,e,t.ditherStrength):M;if(q){n+=(L?1-p/255:p/255)<.12?" ":q[(e*m+o)%q.length]}else t.ditherStrength<=0?n+=z[Math.max(0,Math.min(255,0|u))]:n+=H(p,j,L)}B.push(n)}return{rows:B,cols:m,rowCount:u,colors:V}}function B(e,t,n,o,r){if(0===t.rows.length)return;const a=e.canvas,i=Boolean(n.chromaKey)||t.rows.some(e=>e.includes(" "));i||(R.delete(e),e.clearRect(0,0,o,r),e.fillStyle=p(a)?"#0a0a0a":"#faf9f7",e.fillRect(0,0,o,r));const s=j(n.accentColor),c=parseInt(s.substring(0,2),16),l=parseInt(s.substring(2,4),16),h=parseInt(s.substring(4,6),16),d=o/t.cols,f=r/t.rowCount,m=.9*Math.min(d/.55,f),u=t.colors;if("fullcolor"===n.colorMode&&u){R.delete(e),e.clearRect(0,0,o,r),e.font=`${m}px "JetBrains Mono", monospace`,e.textAlign="left",e.textBaseline="middle",e.globalAlpha=1;let n="";for(let o=0;o<t.rows.length;o++){const r=L(t.rows[o]);let a=0;for(;a<t.cols;){for(;a<t.cols&&" "===r[a];)a++;if(a>=t.cols)break;const i=a,s=4*(o*t.cols+a),c=240&u[s],l=240&u[s+1],h=240&u[s+2];for(a++;a<t.cols&&" "!==r[a];){const e=4*(o*t.cols+a);if((240&u[e])!==c||(240&u[e+1])!==l||(240&u[e+2])!==h)break;a++}const m=`rgb(${c},${l},${h})`;m!==n&&(e.fillStyle=m,n=m),e.fillText(r.slice(i,a).join(""),i*d+.5*d,o*f+.5*f)}}return void(e.globalAlpha=1)}e.font=`${m}px "JetBrains Mono", monospace`,e.textAlign="left",e.textBaseline="middle";const g="matrix"===n.colorMode?"rgb(0,255,0)":"grayscale"===n.colorMode?p(a)?"rgb(230,230,230)":"rgb(24,24,24)":`rgb(${c},${l},${h})`;e.fillStyle=g,e.globalAlpha=1;const M=R.get(e),v=i&&M&&M.cols===t.cols&&M.rowCount===t.rowCount&&M.canvasWidth===o&&M.canvasHeight===r&&M.fillStyle===g;v||e.clearRect(0,0,o,r);for(let n=0;n<t.rows.length;n++){const r=t.rows[n];v&&M.rows[n]===r||(v&&e.clearRect(0,n*f,o,f+1),0!==r.trim().length&&e.fillText(r,.5*d,n*f+.5*f))}R.set(e,{rows:t.rows.slice(),cols:t.cols,rowCount:t.rowCount,canvasWidth:o,canvasHeight:r,fillStyle:g}),e.globalAlpha=1}async function U(e,t,n,o,r=12,a=10,i,s=0){const c=Math.min(e.duration-s,a),l=Math.ceil(c*r),h=[];let d=0,f=0;for(let a=0;a<l;a++){const m=s+a/r;if(m>s+c)break;e.currentTime=m,await new Promise(t=>{const n=()=>{e.removeEventListener("seeked",n),t()};e.addEventListener("seeked",n)});const u=q(e,t,n,o);h.push(u.frame),d=u.cols,f=u.rows,i?.((a+1)/l)}return{frames:h,cols:d,rows:f,fps:r}}async function N(e,t,n,o,r=12,a=10,i,s=0){const c=Math.min(e.duration-s,a),l=Math.ceil(c*r),h=[];let d=0,f=0;for(let a=0;a<l;a++){const m=s+a/r;if(m>s+c)break;e.currentTime=m,await new Promise(t=>{const n=()=>{e.removeEventListener("seeked",n),t()};e.addEventListener("seeked",n)});const u=V(e,t,n,o);h.push(u),d=u.cols,f=u.rowCount,i?.((a+1)/l)}return{frames:h,cols:d,rows:f,fps:r}}async function D(e,t,n,o,r){const{parseGIF:a,decompressFrames:i}=await import("gifuct-js"),s=a(e),c=i(s,!0);if(0===c.length)return{frames:[],cols:0,rows:0,fps:10};const l=c[0].dims.width,h=c[0].dims.height,d=s.lsd?.width||l,f=s.lsd?.height||h,m=document.createElement("canvas");m.width=d,m.height=f;const u=m.getContext("2d"),g=document.createElement("canvas");g.width=d,g.height=f;const M=g.getContext("2d"),p=document.createElement("canvas"),v=p.getContext("2d"),w=[];let x=0,y=0,b=0;for(const e of c)b+=e.delay||100;const S=b/c.length,E=Math.round(Math.min(30,Math.max(5,1e3/S))),C=Math.min(c.length,300);for(let e=0;e<C;e++){const a=c[e],{dims:i,patch:s,disposalType:l}=a;3===l&&(M.clearRect(0,0,d,f),M.drawImage(m,0,0)),p.width!==i.width&&(p.width=i.width),p.height!==i.height&&(p.height=i.height);const h=new ImageData(new Uint8ClampedArray(s.buffer),i.width,i.height);v.putImageData(h,0,0),u.drawImage(p,i.left||0,i.top||0);const b=q(m,t,n,o);w.push(b.frame),x=b.cols,y=b.rows,2===l?u.clearRect(i.left||0,i.top||0,i.width,i.height):3===l&&(u.clearRect(0,0,d,f),u.drawImage(g,0,0)),r?.((e+1)/C)}return{frames:w,cols:x,rows:y,fps:E}}var K=new WeakMap,Y=new WeakMap,_=new WeakMap;function G(e,t,n,o,r,a=0,i){if(!t.length||!t[0].length||o<=0||r<=0)return;let s=null;if(n.hoverStrength>0){let t=K.get(e);t||(t={x:.5,y:.5,intensity:0,time:-1,emittedAt:-1,points:[]},K.set(e,t)),s=function(e,t,n){const o=e.time<0?1/60:Math.max(0,Math.min(.1,(n-e.time)/1e3));e.time=n;const r=e.intensity<.003,a=e.x,i=e.y;if(t){r&&(e.x=t.x,e.y=t.y);const n=1-Math.exp(-o/.055);e.x+=(t.x-e.x)*n,e.y+=(t.y-e.y)*n}e.intensity+=((t?.intensity??(t?1:0))-e.intensity)*(1-Math.exp(-o/(t?.09:.18)));const s=Math.exp(-o/.22);for(const t of e.points)t.intensity*=s;for(;e.points.length&&e.points[0].intensity<.01;)e.points.shift();return t&&!r&&n-e.emittedAt>=24&&Math.hypot(e.x-a,e.y-i)>5e-4&&(e.points.push({x:e.x,y:e.y,intensity:e.intensity,vx:Math.max(-1,Math.min(1,(e.x-a)/Math.max(o,.001))),vy:Math.max(-1,Math.min(1,(e.y-i)/Math.max(o,.001)))}),e.points.length>12&&e.points.shift(),e.emittedAt=n),!t&&e.intensity<.003&&!e.points.length?(e.intensity=0,null):{x:e.x,y:e.y,intensity:e.intensity,trail:e.points}}(t,i??null,performance.now())}else K.delete(e);if("none"!==n.animationStyle||n.charsetFrames?.length||n.hoverStrength<=0)return _.delete(e),void X(e,t,n,o,r,a,s);const c=Y.get(e);if(c?.frame!==t)return Y.set(e,{frame:t,since:performance.now()}),_.delete(e),void X(e,t,n,o,r,a,s);if(performance.now()-c.since<100)return void X(e,t,n,o,r,a,s);const l=e.getTransform();if(l.b||l.c||l.a<=0||l.d<=0)return void X(e,t,n,o,r,a,s);if(!s||(s.intensity??0)<.003)return void X(e,t,n,o,r,a,null);const h=p(e.canvas),d={...n,accentColor:"#"+j(n.accentColor)},f=JSON.stringify([d,o,r,l.a,l.d,h,void 0!==document.fonts?document.fonts.status:"loaded"]);let m=_.get(e);if(!m||m.frame!==t||m.key!==f){const n=m?.canvas??document.createElement("canvas");n.width=Math.ceil(o*l.a),n.height=Math.ceil(r*l.d);const a=n.getContext("2d");a.setTransform(l.a,0,0,l.d,0,0),X(a,t,d,o,r,0,null,void 0,h),m={frame:t,key:f,canvas:n},_.set(e,m)}if(e.clearRect(0,0,o,r),e.drawImage(m.canvas,0,0,o,r),!s||(s.intensity??0)<.003)return;const u=t.length,g=t[0].length,M=.08+.35*n.hoverRadius+.04*n.hoverStrength,v="trail"===n.hoverEffect?[s,...s.trail??[]]:[s];let w=1,x=1,y=0,b=0;for(const e of v)w=Math.min(w,e.x-M),y=Math.max(y,e.x+M),x=Math.min(x,e.y-M),b=Math.max(b,e.y+M);if("glitchText"===n.hoverEffect){const e=n.hoverText,t=Math.max(1,...(Array.isArray(e)?e:[e]).map(e=>e.length));w=Math.min(w,s.x-t/g),y=Math.max(y,s.x+t/g)}const S=Math.ceil(5+4*n.hoverStrength),E={x:Math.max(0,Math.floor(w*g)-S),y:Math.max(0,Math.floor(x*u)-S),right:Math.min(g,Math.ceil(y*g)+S),bottom:Math.min(u,Math.ceil(b*u)+S)};e.save(),e.beginPath(),e.rect(E.x*o/g,E.y*r/u,(E.right-E.x)*o/g,(E.bottom-E.y)*r/u),e.clip(),X(e,t,d,o,r,a,s,E,h),e.restore()}function X(e,t,n,o,r,a=0,i,s,c){const l=t.length;if(0===l)return;const h=t[0].length;e.clearRect(0,0,o,r);let d=!1;const m=Math.max(1,l>>2),g=Math.max(1,h>>2);e:for(let e=0;e<l;e+=m){const n=t[e];for(let e=0;e<h;e+=g)if(n[e].a<200){d=!0;break e}}const M=e.canvas,v=c??p(M);d||(e.fillStyle=v?"#0a0a0a":"#faf9f7",e.fillRect(0,0,o,r));const w=o/h,y=r/l,S=i?.intensity??1,E=!!(i&&n.hoverStrength>0&&S>.005),C="#"+($(n.hoverColor||"#ffffff")??"ffffff"),T=parseInt(C.slice(1,3),16),F=parseInt(C.slice(3,5),16),A=parseInt(C.slice(5,7),16),R=j(n.accentColor),k=parseInt(R.substring(0,2),16),L=parseInt(R.substring(2,4),16),P=parseInt(R.substring(4,6),16),z=n.hoverRadius;let O=0,q=h,V=0,B=l,U=0,N=0;if(E&&i){U=i.x,N=i.y;const e=.08+.35*z+.04*n.hoverStrength;O=Math.max(0,Math.floor((U-e)*h)-1),q=Math.min(h,Math.ceil((U+e)*h)+1),V=Math.max(0,Math.floor((N-e)*l)-1),B=Math.min(l,Math.ceil((N+e)*l)+1)}if(E&&"trail"===n.hoverEffect)for(const e of i?.trail??[]){const t=.08+.35*z+.04*n.hoverStrength;O=Math.min(O,Math.max(0,Math.floor((e.x-t)*h)-1)),q=Math.max(q,Math.min(h,Math.ceil((e.x+t)*h)+1)),V=Math.min(V,Math.max(0,Math.floor((e.y-t)*l)-1)),B=Math.max(B,Math.min(l,Math.ceil((e.y+t)*l)+1))}const D=n.animationStyle,K=n.animationSpeed,Y="none"===D,_=n.hoverStrength,G=n.hoverEffect,X=z,J=n.hoverShape||"circle",Q=W(n.invert,M),Z=n.colorMode,ee=2*Math.PI,te=1/h,ne=1/l;let oe="",re=-1;if("dots"===n.renderMode){const c=.5*Math.min(w,y)*n.dotSizeRatio;for(let n=s?.y??0;n<(s?.bottom??l);n++){const d=t[n];for(let t=s?.x??0;t<(s?.right??h);t++){const s=d[t];if(s.a<10)continue;const m=.00392156863*(.299*s.r+.587*s.g+.114*s.b),g=Q?1-m:m;if(g<.02)continue;const M=Y?1:x(t,n,h,l,a,D,K);let p=1,v=0,C=0,R=0,I=0;if(E&&t>=O&&t<=q&&n>=V&&n<=B){const e=b(t*te,n*ne,U,N,S,_,w,y,G,X,J,i?.trail,o/r);p=e.scale,v=e.offsetX,C=e.offsetY,R=e.glow,I=e.colorBlend}const H=c*g*M*p;if(H<.3)continue;const W=t*w+.5*w+v,$=n*y+.5*y+C;let j;if(I>0){const e=u(s,Z,k,L,P,Q);j=`rgb(${Math.min(255,e[0]+(T-e[0])*I|0)},${Math.min(255,e[1]+(F-e[1])*I|0)},${Math.min(255,e[2]+(A-e[2])*I|0)})`}else j=f(s,Z,k,L,P,Q);const z=Math.min(1,.00392156863*s.a*M*(1+R));if(z!==re&&(e.globalAlpha=z,re=z),j!==oe&&(e.fillStyle=j,oe=j),H<=3){const t=2*H;e.fillRect(W-H,$-H,t,t)}else e.beginPath(),e.arc(W,$,H,0,ee),e.fill()}}}else{const c=.55,d=.9*Math.min(w/c,y);{const t="emoji"===n.artStyle;e.font=t?`${d}px "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif`:`${d}px "JetBrains Mono", monospace`,e.textAlign="center",e.textBaseline="middle"}const m=n.charsetFrames,g=!!m?.length,M=g?m[Math.floor(Math.max(0,a)*(n.charsetFps??2))%m.length]:n.charset,p=e.getTransform();if(!E&&Y&&!g&&"accent"===Z&&!s&&n.hoverStrength<=0&&"emoji"!==n.artStyle&&"letterSpacing"in e&&/^[\x20-\x7e]*$/.test(n.customText||n.charset)&&t.every(e=>e.every(e=>e.a<10||255===e.a&&1===e.char.length&&/^[\x20-\x7e]$/.test(e.char)))){const n=e.letterSpacing;e.letterSpacing="0px";const o=e.measureText("M").width;e.letterSpacing=w-o+"px",e.fillStyle=`rgb(${k},${L},${P})`,e.globalAlpha=1,e.textAlign="left";for(let n=0;n<l;n++){const r=t[n];let a="";for(let e=0;e<h;e++){const t=r[e];a+=t.a<10?" ":t.char}0!==a.trim().length&&e.fillText(a,.5*(w-o),n*y+.5*y)}return e.letterSpacing=n,e.textAlign="center",void(e.globalAlpha=1)}const v="glitchText"===G&&E,C="!@#$%^&*<>{}[]|/\\~`0123456789",R=C.length;let W="",$=0,j=0,ee=0,ae=0,ie=0,se=0;if(v){const e=n.hoverText??"ASCIIFY";if(j=Math.round(U*h),ee=Math.round(N*l),Array.isArray(e)){const t=e.filter(e=>e.length>0);0===t.length&&t.push("ASCIIFY");W=t[((7*Math.floor(j/Math.max(1,Math.ceil(h/5)))+13*Math.floor(ee/Math.max(1,Math.ceil(l/3))))%t.length+t.length)%t.length]}else W=e||"ASCIIFY";$=W.length,ae=Math.max(3,Math.min(12,Math.round(l*z*.6)));const t=Math.floor(ae/2);ie=Math.max(0,ee-t),ie+ae>l&&(ie=Math.max(0,l-ae)),se=j-Math.floor($/2)}for(let n=s?.y??0;n<(s?.bottom??l);n++){const c=t[n];for(let d=s?.x??0;d<(s?.right??h);d++){const s=c[d];if(s.a<10)continue;let m=g&&null!=s.lum?H(s.lum,I(M),Q):s.char;if(" "===m)continue;const z=Y?1:x(d,n,h,l,a,D,K);if(z<.05)continue;let ce=1,le=0,he=0,de=0,fe=0;if(E&&!v&&d>=O&&d<=q&&n>=V&&n<=B){const e=b(d*te,n*ne,U,N,S,_,w,y,G,X,J,i?.trail,o/r);if(ce=e.scale,le=e.offsetX,he=e.offsetY,de=e.glow,fe=e.colorBlend,"trail"===G&&e.proximity>0){const o=Math.max(0,Math.min(h-1,Math.round(d-e.offsetX/w))),r=t[Math.max(0,Math.min(l-1,Math.round(n-e.offsetY/y)))][o],a=r.lum??.299*r.r+.587*r.g+.114*r.b;m=H(Math.min(255,a+e.proximity*_*65),I(M),Q)}}if(v&&n>=ie&&n<ie+ae){const e=d-se;if(e>=0&&e<$){const t=W[e],o=Math.abs(n-ee)/Math.max(1,.5*ae),r=Math.abs(d-j)/Math.max(1,$),i=Math.max(o,r),s=Math.max(0,Math.min(1,1-.9*i)),c=43758.5453*Math.sin(127.1*d+311.7*n+43758.5453*Math.floor(12*a));m=Math.abs(c-Math.floor(c))<s?t:C[Math.abs(Math.floor(97*c))%R],de=.3+.7*s,fe=.3+.65*s}}const me=d*w+.5*w+le,ue=n*y+.5*y+he;let ge;if(fe>0){const e=u(s,Z,k,L,P,Q);ge=`rgb(${Math.min(255,e[0]+(T-e[0])*fe|0)},${Math.min(255,e[1]+(F-e[1])*fe|0)},${Math.min(255,e[2]+(A-e[2])*fe|0)})`}else ge=f(s,Z,k,L,P,Q);const Me=Math.min(1,.00392156863*s.a*z*(1+de));Me!==re&&(e.globalAlpha=Me,re=Me),ge!==oe&&(e.fillStyle=ge,oe=ge),1!==ce?(e.translate(me,ue),e.scale(ce,ce),e.fillText(m,0,0),e.setTransform(p)):e.fillText(m,me,ue)}}}e.globalAlpha=1}function J(e){return Math.max(0,Math.min(1,e))}function Q(e){return"string"==typeof e?document.querySelector(e):e instanceof HTMLElement?e:null}function Z(e){return"ascii"===e.renderMode&&"none"===e.animationStyle&&e.hoverStrength<=0&&!e.charsetFrames?.length}function ee(e,t={}){const n=J(e),o=J(n*(void 0===t.speed?1:Math.max(.001,t.speed)));return J(t.ease?t.ease(o):o)}function te(e,t,n={}){if(!Number.isFinite(e.duration)||e.duration<=0)return;const o=n.from??0,r=n.to??e.duration,a=Math.max(o,Math.min(r,e.duration)),i=ee(t,n),s=o+(a-o)*i;e.currentTime=Math.min(Math.max(o,s),Math.max(o,a-.04)),n.onUpdate?.(i,e)}function ne(e,t){return Math.abs(e.currentTime-t)<1/240?oe(e):new Promise(n=>{const o=()=>{e.removeEventListener("seeked",o),n()};e.addEventListener("seeked",o,{once:!0});const r=e.fastSeek;r?r.call(e,t):e.currentTime=t})}function oe(e){const t=e.requestVideoFrameCallback;return new Promise(t?n=>{let o=!1;const r=()=>{o||(o=!0,n())};t.call(e,r),window.setTimeout(r,32)}:e=>requestAnimationFrame(()=>e()))}function re(e,t={}){const n=Q(t.trigger)??e;e.pause();const o=t.gsap,r=t.ScrollTrigger??o?.ScrollTrigger;if(o&&r?.create){o.registerPlugin?.(r);const a=r.create({trigger:n,start:t.start??"top bottom",end:t.end??"bottom top",scrub:t.scrub??!0,onUpdate:n=>te(e,n.progress,t)});return()=>a.kill?.()}return function(e,t,n){let o=0;const r=()=>{o=0;const r=t.getBoundingClientRect(),a=window.innerHeight||document.documentElement.clientHeight,i=r.height+a,s=i>0?J((a-r.top)/i):0;te(e,s,n)},a=()=>{o||(o=requestAnimationFrame(r))};return window.addEventListener("scroll",a,{passive:!0}),window.addEventListener("resize",a),a(),()=>{window.removeEventListener("scroll",a),window.removeEventListener("resize",a),o&&cancelAnimationFrame(o)}}(e,n,t)}function ae(e,t,n){const o=t.gsap,r=t.ScrollTrigger??o?.ScrollTrigger;if(o&&r?.create){o.registerPlugin?.(r);const a=r.create({trigger:e,start:t.start??"top bottom",end:t.end??"bottom top",scrub:t.scrub??!0,onUpdate:e=>n(e.progress)});return()=>a.kill?.()}return function(e,t){let n=0;const o=()=>{n=0;const o=e.getBoundingClientRect(),r=window.innerHeight||document.documentElement.clientHeight,a=o.height+r,i=a>0?J((r-o.top)/a):0;t(i)},r=()=>{n||(n=requestAnimationFrame(o))};return window.addEventListener("scroll",r,{passive:!0}),window.addEventListener("resize",r),r(),()=>{window.removeEventListener("scroll",r),window.removeEventListener("resize",r),n&&cancelAnimationFrame(n)}}(e,n)}function ie(e,t,n){if(!e||!t||!n.sourceCrop)return{w:e,h:t};const o=O(n.sourceCrop,e,t);return{w:Math.max(1,Math.round(o.width)),h:Math.max(1,Math.round(o.height))}}function se(e,t,n,o){const r=o.chromaKey;if(null==r||!1===r)return!1;if(!0===r)return t>1.4*e&&t>1.4*n&&t>80;if("blue-screen"===r)return n>1.4*e&&n>1.4*t&&n>80;const a=v(r),i=(o.chromaKeyTolerance??60)**2,s=e-a.r,c=t-a.g,l=n-a.b;return s*s+c*c+l*l<=i}function ce(e,t,n){if(!t.chromaKey||!t.sourceCrop||"off"===t.chromaKeyTrimMode)return t;const o=e instanceof HTMLVideoElement?e.videoWidth:e.width,r=e instanceof HTMLVideoElement?e.videoHeight:e.height;if(!o||!r)return t;const i=O(t.sourceCrop,o,r),s=Math.min(360,Math.max(1,Math.round(i.width))),c=Math.max(1,Math.round(s*(i.height/i.width))),{ctx:l}=a(s,c);l.drawImage(e,i.x,i.y,i.width,i.height,0,0,s,c);const h=l.getImageData(0,0,s,c).data,d=Math.max(0,Math.min(255,t.chromaKeyTrimLuminanceThreshold??0));let f=s,m=c,u=-1,g=-1;for(let e=0;e<c;e++)for(let n=0;n<s;n++){const o=4*(e*s+n),r=h[o+3],a=h[o],i=h[o+1],c=h[o+2];r<=8||.2126*a+.7152*i+.0722*c<=d||se(a,i,c,t)||(n<f&&(f=n),e<m&&(m=e),n>u&&(u=n),e>g&&(g=e))}if(u<f||g<m)return t;const M=Math.max(0,Math.min(.25,t.chromaKeyTrimPadding??.002)),p=Math.round(s*M),v=Math.round(c*M);f=Math.max(0,f-p),m=Math.max(0,m-v),u=Math.min(s-1,u+p),g=Math.min(c-1,g+v);const w=function(e,t,n,o,r){const a=r&&Number.isFinite(r)&&r>0?r:null;if(!a)return e;const i=t.x,s=t.y,c=t.x+t.width,l=t.y+t.height,h=Math.max(i,e.left),d=Math.max(s,e.top),f=Math.min(c,n-e.right),m=Math.min(l,o-e.bottom),u=Math.max(1,f-h),g=Math.max(1,m-d),M=h+u/2,p=d+g/2;let v=u,w=g;v/w<a?v=w*a:w=v/a;v>t.width&&(v=t.width,w=Math.max(g,Math.min(t.height,v/a)));w>t.height&&(w=t.height,v=Math.max(u,Math.min(t.width,w*a)));let x=M-v/2,y=p-w/2;return x=Math.max(i,Math.min(c-v,x)),y=Math.max(s,Math.min(l-w,y)),{left:x,top:y,right:n-(x+v),bottom:o-(y+w)}}({left:i.x+f/s*i.width,top:i.y+m/c*i.height,right:o-(i.x+(u+1)/s*i.width),bottom:r-(i.y+(g+1)/c*i.height)},{x:i.x,y:i.y,width:i.width,height:i.height},o,r,n);return{...t,sourceCrop:{unit:"pixel",...w,preserveAspect:!1}}}function le(e){const t=e.sourceCrop;return t&&"pixel"===t.unit?void 0===t.left||void 0===t.top||void 0===t.right||void 0===t.bottom?null:{left:t.left,top:t.top,right:t.right,bottom:t.bottom}:null}async function he(e,t,n,o,r){if(!t.chromaKey||!t.sourceCrop||"range"!==t.chromaKeyTrimMode)return t;const a=e.currentTime,i=function(e,t,n,o){const r=!0===o?{}:o||{},a=Math.max(0,r.from??t),i=r.to??n??(Number.isFinite(e.duration)?e.duration:a),s=Math.max(a,i-.04),c=Math.max(0,s-a),l=c>.1?[a,a+.25*c,a+.5*c,a+.75*c,s]:[a];return Array.from(new Set(l.map(e=>Math.max(0,Number(e.toFixed(3))))))}(e,n,o,r);let s=null;for(const n of i){await ne(e,n),await oe(e);const o=le(ce(e,t));o&&(s=s?{left:Math.min(s.left,o.left),top:Math.min(s.top,o.top),right:Math.min(s.right,o.right),bottom:Math.min(s.bottom,o.bottom)}:o)}return await ne(e,a),await oe(e),s?{...t,sourceCrop:{unit:"pixel",...s,preserveAspect:!0}}:t}function de(e,t,n=2048){return fe({sourceWidth:e,sourceHeight:t,maxRenderDimension:n})}function fe({sourceWidth:e,sourceHeight:t,cssWidth:n=0,cssHeight:o=0,maxRenderDimension:r=2048}){const a=Math.max(1,e),i=Math.max(1,t),s=a/i,c=Math.max(1,r),l=Math.min(1,c/Math.max(a,i)),h=Math.max(a,i)*l,d=Math.max(0,n,o),f=Math.min(c,Math.max(h,d));return s>=1?{renderW:Math.round(f),renderH:Math.round(f/s)}:{renderW:Math.round(f*s),renderH:Math.round(f)}}function me(e,t,n,o){if(void 0===e)return;if("number"==typeof e)return e;const r=e.trim();if(r.endsWith("%")){const e=Number.parseFloat(r)/100;return Number.isFinite(e)?t*e:void 0}if(r.endsWith("px")){const e=Number.parseFloat(r);return Number.isFinite(e)?e:void 0}if(r.endsWith("vw")){const e=Number.parseFloat(r)/100;return Number.isFinite(e)?n*e:void 0}if(r.endsWith("vh")){const e=Number.parseFloat(r)/100;return Number.isFinite(e)?o*e:void 0}}function ue(e,t,n,o,r,a=2048,i={}){const{width:s,height:c}=t.getBoundingClientRect();if(!s||!c)return{renderW:0,renderH:0,dpr:1};const l="undefined"!=typeof window?window.innerWidth:s,h="undefined"!=typeof window?window.innerHeight:c,d=me(i.width,s,l,h)??s,f=me(i.height,c,l,h)??c,m=function(e,t,n,o,r){const a=e=>{const n=me(e,t,o,r);return n&&n>0?n:0},i=e=>{const t=me(e,n,o,r);return t&&t>0?t:0};return void 0===e?{x:0,y:0}:"number"==typeof e||"string"==typeof e?{x:a(e),y:i(e)}:{x:a(e.x),y:i(e.y)}}(i.bleed,s,c,l,h),u=d+2*m.x,g=f+2*m.y,{cssW:M,cssH:p}=function(e,t,n,o="contain"){if("fill"===o)return{cssW:e,cssH:t};let r=e,a=r/n;const i="cover"===o,s=a>t;return(i&&!s||!i&&s)&&(a=t,r=a*n),"scale-down"===o&&(r=Math.min(r,e),a=Math.min(a,t)),{cssW:Math.round(r),cssH:Math.round(a)}}(u,g,n,i.objectFit??"contain"),v="undefined"!=typeof window&&window.devicePixelRatio||1;let w,x;o&&r?({renderW:w,renderH:x}=fe({sourceWidth:o,sourceHeight:r,cssWidth:M,cssHeight:p,maxRenderDimension:a})):(w=M,x=p);const y=8e6,b=w*v*x*v>y?Math.sqrt(y/(w*x)):v;return e.width=Math.round(w*b),e.height=Math.round(x*b),e.style.width=`${M}px`,e.style.height=`${p}px`,{renderW:w,renderH:x,dpr:b}}async function ge(e,t,{fontSize:o,artStyle:a="classic",options:i={},fitTo:s,objectFit:c,objectPosition:l,scale:h,width:d,height:f,bleed:m,preExtract:u=!1,fps:g,maxRenderDimension:M=2048,trim:p,scroll:v,maxCachedFrames:w=90,onReady:x,onFrame:y}={}){const b=p?.start??0,E=p?.end,C=o??i.fontSize??10;let T={...r,...n[a],artStyle:a,...i,fontSize:C};const F=t.getContext("2d");if(!F)throw new Error("asciifyVideo: could not get 2d context from canvas.");const A="string"==typeof s?document.querySelector(s):s instanceof HTMLElement?s:null,R={objectFit:c,objectPosition:l,scale:h,width:d,height:f,bleed:m},k=function(e,t){var n;if(!function(e){return void 0!==e.objectFit||void 0!==e.objectPosition||void 0!==e.scale||void 0!==e.width||void 0!==e.height||void 0!==e.bleed}(t))return()=>{};const o={width:e.style.width,height:e.style.height,objectFit:e.style.objectFit,objectPosition:e.style.objectPosition,maxWidth:e.style.maxWidth,maxHeight:e.style.maxHeight,transformOrigin:e.style.transformOrigin,scale:e.style.getPropertyValue("scale")};if(t.objectFit&&(e.style.objectFit=t.objectFit),t.objectPosition&&(e.style.objectPosition=t.objectPosition,e.style.transformOrigin=t.objectPosition),void 0===t.scale&&void 0===t.bleed||(e.style.maxWidth="none",e.style.maxHeight="none"),void 0!==t.scale){const o=Number.isFinite(t.scale)&&t.scale>0?t.scale:1;e.style.setProperty("scale",String(o)),(n=e.style).transformOrigin||(n.transformOrigin=t.objectPosition??"center center")}return()=>{e.style.width=o.width,e.style.height=o.height,e.style.objectFit=o.objectFit,e.style.objectPosition=o.objectPosition,e.style.maxWidth=o.maxWidth,e.style.maxHeight=o.maxHeight,e.style.transformOrigin=o.transformOrigin,o.scale?e.style.setProperty("scale",o.scale):e.style.removeProperty("scale")}}(t,R),I=e=>()=>{e(),k()};if(u){let n;"string"==typeof e?(n=document.createElement("video"),n.crossOrigin="anonymous",n.src=e,n.readyState<2&&await new Promise((t,o)=>{n.onloadeddata=()=>t(),n.onerror=()=>o(new Error(`asciifyVideo: failed to load "${e}"`))})):n=e,T=await he(n,T,b,E,v);const o=ie(n.videoWidth,n.videoHeight,T);A&&ue(t,A,o.w/o.h,o.w,o.h,M,R);const{renderW:r,renderH:a}=de(o.w,o.h,M),i="undefined"!=typeof window&&window.devicePixelRatio||1,s=8e6,c=r*i*a*i>s?Math.sqrt(s/(r*a)):i;t.width===Math.round(r*c)&&t.height===Math.round(a*c)||(t.width=Math.round(r*c),t.height=Math.round(a*c));const l=void 0!==E?E-b:10,h=g??(v?18:void 0);if(Z(T)){const{frames:e,fps:o}=await N(n,T,r,a,h,l,void 0,b),i=t=>{const n=e[t];n&&(F.save(),F.setTransform(c,0,0,c,0,0),B(F,n,T,r,a),F.restore(),y?.())};if(v){let o=!1,r=-1;const a=!0===v?{}:v,s=ae(Q(a.trigger)??A??t,a,t=>{const s=ee(t,a),c=Math.max(0,Math.min(e.length-1,Math.round(s*(e.length-1))));c!==r&&(r=c,i(c),o||(o=!0,x?.(n)),a.onUpdate?.(s,n))});return i(0),o=!0,x?.(n),I(s)}let s,d=!1,f=0,m=performance.now(),u=!0;const g=1e3/o,M=t=>{d||(t-m>=g&&(i(f),f=(f+1)%e.length,m=t,u&&(u=!1,x?.(n))),s=requestAnimationFrame(M))};return s=requestAnimationFrame(M),I(()=>{d=!0,cancelAnimationFrame(s)})}const{frames:d,fps:f}=await U(n,T,r,a,h,l,void 0,b);if(!d.length)throw new Error("asciifyVideo: no frames were decoded.");let m=0;const u=performance.now(),p=S(t,(e,t)=>{v||(m=Math.floor((e-u)*f/1e3)%d.length),F.save(),F.setTransform(c,0,0,c,0,0),G(F,d[m],T,r,a,(e-u)/1e3,t),F.restore(),y?.()},{continuous:!v||"none"!==T.animationStyle||!!T.charsetFrames?.length,interactive:T.hoverStrength>0});let w;if(v){const e=!0===v?{}:v;w=ae(Q(e.trigger)??A??t,e,t=>{m=Math.max(0,Math.min(d.length-1,Math.round(ee(t,e)*(d.length-1)))),p.wake(),e.onUpdate?.(t,n)})}return x?.(n),I(()=>{p.stop(),w?.()})}let L,H=!1;"string"==typeof e?(L=document.createElement("video"),L.crossOrigin="anonymous",L.src=e,L.muted=!0,L.loop=!0,L.playsInline=!0,L.setAttribute("playsinline",""),Object.assign(L.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(L),H=!0,await new Promise((t,n)=>{L.onloadedmetadata=()=>t(),L.onerror=()=>n(new Error(`asciifyVideo: failed to load "${e}"`))}),await L.play().catch(()=>{})):(L=e,L.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((e,t)=>{const n=()=>{L.removeEventListener("loadedmetadata",o),L.removeEventListener("error",r)},o=()=>{n(),e()},r=()=>{n(),t(new Error("asciifyVideo: provided video element failed to load metadata."))};L.addEventListener("loadedmetadata",o),L.addEventListener("error",r),L.load()}),L.paused&&await L.play().catch(()=>{})),b>0&&(L.currentTime=b,await new Promise(e=>{const t=()=>{L.removeEventListener("seeked",t),e()};L.addEventListener("seeked",t)}),await oe(L));let P=null;(b>0||void 0!==E)&&(P=()=>{(void 0!==E&&L.currentTime>=E||b>0&&L.currentTime<b)&&(L.currentTime=b)},L.addEventListener("timeupdate",P)),T=await he(L,T,b,E,v);let W=null;const $=ie(L.videoWidth,L.videoHeight,T);let{renderW:j,renderH:z}=de($.w,$.h,M);const O=e=>"frame"===T.chromaKeyTrimMode?ce(e,T,j/z):T;if(A){const e=$.w/$.h,n=$.w,o=$.h,r=ue(t,A,e,n,o,M,R);j=r.renderW,z=r.renderH;const a=t.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0),W=new ResizeObserver(()=>{const r=ue(t,A,e,n,o,M,R);j=r.renderW,z=r.renderH;const a=t.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0)}),W.observe(A)}else{const e="undefined"!=typeof window&&window.devicePixelRatio||1,n=8e6,o=j*e*z*e>n?Math.sqrt(n/(j*z)):e;t.width===Math.round(j*o)&&t.height===Math.round(z*o)||(t.width=Math.round(j*o),t.height=Math.round(z*o)),F.setTransform(o,0,0,o,0,0)}let D=!0,K=null;const Y=v&&!u,_=g&&g>0?1e3/g:0;let X=0;const te=!Y&&Z(T);if(Y&&"ascii"===T.renderMode&&"none"===T.animationStyle&&T.hoverStrength<=0&&!T.charsetFrames?.length){const e=!0===v?{}:v,n=Q(e.trigger)??A??t,o=e.from??b,r=e.to??E??L.duration,a=Math.max(o,Math.min(r,L.duration)),i=Math.max(.001,a-o),s=Math.min(60,Math.max(12,g??30)),c=Math.max(2,Math.ceil(i*s)+1),l=new Array(c),h=[],d=Math.max(2,Math.min(c,Math.floor(w))),f=()=>{for(;h.length>d;){const e=h.findIndex(e=>e!==u&&Math.abs(e-u)>2),t=e>=0?e:0,n=h.splice(t,1)[0];void 0!==n&&(l[n]=void 0)}},m=e=>{const t=h.indexOf(e);t>=0&&h.splice(t,1),h.push(e),f()};let u=0,M=0,p=-1,S=0,C=!1,R=!1,k=!1;const $=new Set,q=document.createElement("video");q.muted=!0,q.playsInline=!0,q.preload="auto",q.crossOrigin=L.crossOrigin||"anonymous",q.src=L.currentSrc||L.src,Object.assign(q.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(q),q.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((e,t)=>{const n=()=>{q.removeEventListener("loadedmetadata",o),q.removeEventListener("error",r)},o=()=>{n(),e()},r=()=>{n(),t(new Error("asciifyVideo: cache video failed to load metadata."))};q.addEventListener("loadedmetadata",o),q.addEventListener("error",r),q.load()}),q.pause(),L.paused&&await L.play().catch(()=>{});const U=e=>o+i*e/Math.max(1,c-1),N=e=>Math.max(0,Math.min(c-1,Math.round(e*(c-1)))),D=O(L),Y=V(L,D,j,z);Y.rows.length>0&&(l[0]=Y,m(0),B(F,Y,D,j,z),k=!0,x?.(L),y?.());const G=e=>{if(l[e])return e;for(let t=1;t<c;t++){const n=e-t,o=e+t;if(n>=0&&l[n])return n;if(o<c&&l[o])return o}return-1},Z=()=>{if(!l[u])return u;for(const e of $)if(!l[e])return e;for(let e=1;e<c;e++){const t=u-e,n=u+e;if(t>=0&&!l[t])return t;if(n<c&&!l[n])return n}return-1},te=e=>{e<0||e>=c||l[e]||($.add(e),oe())},oe=async()=>{if(C||R)return;const e=Z();if(!(e<0)){$.delete(e),R=!0;try{if(await ne(q,U(e)),!C){const t=O(q),n=V(q,t,j,z);n.rows.length>0&&(l[e]=n,m(e))}}finally{R=!1,C||requestAnimationFrame(()=>{oe()})}}},re=()=>{if(C)return;const e=G(u);if(e>=0&&e!==p){const t=l[e];t&&(B(F,t,T,j,z),p=e,k||(k=!0,x?.(L)),y?.())}else if(e<0||p<0){const e=performance.now();if(_<=0||e-X>=_){const t=O(L),n=V(L,t,j,z);n.rows.length>0&&(B(F,n,t,j,z),X=e,k||(k=!0,x?.(L)),y?.())}}te(u),S=requestAnimationFrame(re)};return K=ae(n,e,t=>{const n=function(e,t,n={}){if(!Number.isFinite(e.duration)||e.duration<=0)return null;const o=n.from??0,r=n.to??e.duration,a=Math.max(o,Math.min(r,e.duration)),i=ee(t,n),s=o+(a-o)*i;return{progress:i,time:Math.min(Math.max(o,s),Math.max(o,a-.04))}}(L,t,{...e,from:o,to:a});M=n?.progress??J(t),u=N(M),te(u),te(u-1),te(u+1),te(u-2),te(u+2),te(u-3),te(u+3),e.onUpdate?.(M,L)}),te(0),te(1),S=requestAnimationFrame(re),I(()=>{C=!0,cancelAnimationFrame(S),K?.(),W?.disconnect(),$.clear(),h.length=0,l.fill(void 0),q.pause(),q.src="",q.removeAttribute("src"),q.load(),q.isConnected&&q.remove(),P&&L.removeEventListener("timeupdate",P),H&&(L.pause(),L.src="",L.removeAttribute("src"),L.load(),L.isConnected&&L.remove())})}if(Y){const e=!0===v?{}:v;K=re(L,{...e,trigger:e.trigger??A??t,from:e.from??b,to:e.to??E})}let se=-1,le=0,fe=-1,me=0;const ge="function"==typeof L.requestVideoFrameCallback,Me=()=>{me=L.requestVideoFrameCallback(()=>{le++,Me()})};ge&&Me();let pe=0,ve=0,we=null;const xe=S(t,(e,n)=>{if(L.readyState<2||0===t.width||0===t.height)return;if(_>0&&e-X<_&&!n)return;if(b>0&&L.currentTime<b)return;if(void 0!==E&&L.currentTime>=E)return;const o=(ge?le!==fe:L.currentTime!==se)||pe!==j||ve!==z;if(o||!(T.hoverStrength<=0)||"none"!==T.animationStyle||T.charsetFrames?.length){if(te){const e=O(L),t=V(L,e,j,z);B(F,t,e,j,z)}else!o&&we||(we=q(L,O(L),j,z).frame),G(F,we,T,j,z,e/1e3,n);se=L.currentTime,fe=le,pe=j,ve=z,X=e,D&&(D=!1,x?.(L)),y?.()}},{continuous:!0,interactive:T.hoverStrength>0});return I(()=>{xe.stop(),me&&L.cancelVideoFrameCallback(me),K?.(),W?.disconnect(),P&&L.removeEventListener("timeupdate",P),H&&(L.pause(),L.src="",L.removeAttribute("src"),L.load(),L.isConnected&&L.remove())})}function Me(e,t,n,o="#505050",r=100){if(!e||t<=0||n<=0)return[];const a=function(e){const t=e.match(/^#([0-9a-f]{3,8})$/i)?.[1];if(t){const e=t.length<=4?t.split("").map(e=>parseInt(e+e,16)):[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)];return{r:e[0],g:e[1],b:e[2]}}const n=e.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i);return n?{r:+n[1],g:+n[2],b:+n[3]}:null}(o)??{r:80,g:80,b:80},i=e,s=i.length;return Array.from({length:n},(e,n)=>Array.from({length:t},(e,o)=>({char:i[(n*t+o)%s],r:a.r,g:a.g,b:a.b,a:r})))}var pe=new WeakMap;function ve(e,{format:t="png",quality:n=.92,scale:o=1}={}){return new Promise((r,a)=>{let i=e;if(1!==o){const t=document.createElement("canvas");t.width=Math.round(e.width*o),t.height=Math.round(e.height*o);const n=t.getContext("2d");if(!n)return void a(new Error("captureSnapshot: could not get 2d context"));n.drawImage(e,0,0,t.width,t.height),i=t}i.toBlob(e=>e?r(e):a(new Error("captureSnapshot: toBlob returned null")),`image/${t}`,n)})}var we={A:[28,54,99,127,99,99,99],B:[126,99,99,126,99,99,126],C:[62,99,96,96,96,99,62],D:[124,102,99,99,99,102,124],E:[127,96,96,124,96,96,127],F:[127,96,96,124,96,96,96],G:[62,99,96,111,99,99,62],H:[99,99,99,127,99,99,99],I:[127,8,8,8,8,8,127],J:[63,6,6,6,102,102,60],K:[99,102,108,120,108,102,99],L:[96,96,96,96,96,96,127],M:[99,119,107,107,99,99,99],N:[99,115,107,103,99,99,99],O:[62,99,99,99,99,99,62],P:[126,99,99,126,96,96,96],Q:[62,99,99,99,107,102,61],R:[126,99,99,126,108,102,99],S:[62,99,96,62,3,99,62],T:[127,8,8,8,8,8,8],U:[99,99,99,99,99,99,62],V:[99,99,99,99,54,28,8],W:[99,99,99,107,107,54,20],X:[99,54,28,8,28,54,99],Y:[99,99,54,28,8,8,8],Z:[127,3,6,12,24,48,127],a:[0,0,60,3,62,99,61],b:[96,96,124,99,99,99,124],c:[0,0,62,96,96,96,62],d:[3,3,31,99,99,99,31],e:[0,0,62,99,127,96,62],f:[30,48,48,126,48,48,48],g:[0,0,63,99,63,3,62],h:[96,96,124,99,99,99,99],i:[8,0,24,8,8,8,28],j:[4,0,12,4,4,36,24],k:[96,96,102,108,120,108,102],l:[24,8,8,8,8,8,28],m:[0,0,92,107,107,99,99],n:[0,0,94,99,99,99,99],o:[0,0,62,99,99,99,62],p:[0,0,126,99,126,96,96],q:[0,0,63,99,63,3,3],r:[0,0,94,99,96,96,96],s:[0,0,62,96,62,3,124],t:[48,48,126,48,48,48,30],u:[0,0,99,99,99,103,59],v:[0,0,99,99,54,28,8],w:[0,0,99,99,107,54,20],x:[0,0,99,54,28,54,99],y:[0,0,99,99,63,3,62],z:[0,0,127,6,12,24,127],0:[62,99,103,107,115,99,62],1:[8,24,56,8,8,8,62],2:[62,99,3,6,24,48,127],3:[62,99,3,30,3,99,62],4:[6,14,22,38,127,6,6],5:[127,96,126,3,3,99,62],6:[62,99,96,126,99,99,62],7:[127,3,6,12,24,24,24],8:[62,99,99,62,99,99,62],9:[62,99,99,63,3,99,62]," ":[0,0,0,0,0,0,0],"!":[24,24,24,24,24,0,24],"?":[62,99,3,14,8,0,8],".":[0,0,0,0,0,24,24],",":[0,0,0,0,0,24,48],";":[0,24,24,0,24,24,48],":":[0,24,24,0,24,24,0],"-":[0,0,0,62,0,0,0],_:[0,0,0,0,0,0,127],"'":[24,24,32,0,0,0,0],'"':[54,54,36,0,0,0,0],"`":[24,8,0,0,0,0,0],")":[24,12,6,6,6,12,24],"(":[12,24,48,48,48,24,12],"[":[60,48,48,48,48,48,60],"]":[30,6,6,6,6,6,30],"{":[14,24,24,48,24,24,14],"}":[56,12,12,6,12,12,56],"/":[3,6,12,24,48,96,0],"\\":[96,48,24,12,6,3,0],"|":[8,8,8,8,8,8,8],"+":[0,8,8,62,8,8,0],"=":[0,0,62,0,62,0,0],"*":[0,42,28,127,28,42,0],"#":[36,36,127,36,127,36,36],"@":[62,99,111,107,111,96,62],"&":[24,36,24,60,74,68,58],"%":[99,38,4,8,16,50,99],$:[8,62,72,62,9,62,8],"^":[8,20,34,0,0,0,0],"~":[0,0,50,76,0,0,0],"<":[6,12,24,48,24,12,6],">":[48,24,12,6,12,24,48]},xe=[127,65,65,65,65,65,127];function ye(e){return we[e]??we[e.toUpperCase()]??xe}function be(e,t={}){if(!e)return"";const{char:n="█",scale:o=1}=t,r=[...n][0]??"█",a=Math.max(1,Math.floor(o)),i=7*a,s=a,c=Array.from({length:i},()=>"");for(let t=0;t<e.length;t++){const n=ye(e[t]);for(let e=0;e<7;e++){const t=n[e];let o="";for(let e=6;e>=0;e--)o+=(t>>e&1?r:" ").repeat(a);for(let t=0;t<a;t++)c[e*a+t]+=o}if(t<e.length-1)for(let e=0;e<i;e++)c[e]+=" ".repeat(s)}return c.join("\n")}exports.ART_STYLE_PRESETS=n,exports.CHARSETS=e,exports.CHARSET_SEQUENCES=t,exports.DEFAULT_OPTIONS=r,exports.HOVER_PRESETS={none:{label:"Off",options:{hoverStrength:0,hoverEffect:"spotlight",hoverRadius:.2,hoverColor:"#ffffff"}},subtle:{label:"Subtle",options:{hoverStrength:.25,hoverEffect:"glow",hoverRadius:.12,hoverColor:"#ffffff"}},flashlight:{label:"Flashlight",options:{hoverStrength:.6,hoverEffect:"spotlight",hoverRadius:.15,hoverColor:"#fffbe6"}},magnifier:{label:"Magnifier",options:{hoverStrength:.7,hoverEffect:"magnify",hoverRadius:.12,hoverColor:"#ffffff"}},forceField:{label:"Force Field",options:{hoverStrength:.7,hoverEffect:"repel",hoverRadius:.15,hoverColor:"#a0e8ff"}},neon:{label:"Neon",options:{hoverStrength:.6,hoverEffect:"colorShift",hoverRadius:.15,hoverColor:"#d946ef"}},fire:{label:"Fire",options:{hoverStrength:.7,hoverEffect:"spotlight",hoverRadius:.15,hoverColor:"#ff6b2b"}},ice:{label:"Ice",options:{hoverStrength:.5,hoverEffect:"glow",hoverRadius:.15,hoverColor:"#60d5f7"}},gravity:{label:"Gravity",options:{hoverStrength:.7,hoverEffect:"attract",hoverRadius:.18,hoverColor:"#a5d6ff"}},shatter:{label:"Shatter",options:{hoverStrength:.8,hoverEffect:"shatter",hoverRadius:.14,hoverColor:"#ff6090"}},ghost:{label:"Fluid trail",options:{hoverStrength:.55,hoverEffect:"trail",hoverRadius:.2,hoverColor:"#b39ddb"}},glitchReveal:{label:"Glitch Reveal",options:{hoverStrength:.8,hoverEffect:"glitchText",hoverRadius:.18,hoverColor:"#a3e635"}}},exports.LIVING_STYLE_PRESETS=o,exports.PALETTE_THEMES={dracula:{name:"Dracula",accent:"#bd93f9",bg:"#282a36",fg:"#f8f8f2"},monokai:{name:"Monokai",accent:"#a6e22e",bg:"#272822",fg:"#f8f8f2"},nord:{name:"Nord",accent:"#88c0d0",bg:"#2e3440",fg:"#eceff4"},catppuccin:{name:"Catppuccin",accent:"#cba6f7",bg:"#1e1e2e",fg:"#cdd6f4"},solarized:{name:"Solarized",accent:"#268bd2",bg:"#002b36",fg:"#839496"},gruvbox:{name:"Gruvbox",accent:"#b8bb26",bg:"#282828",fg:"#ebdbb2"}},exports.asciiText=function(e,t={},n,o){const a={...r,...t},{frame:i,cols:s}=q(e,a,n,o);if(!i.length||0===s)return"";const c=[];for(const e of i)c.push(e.map(e=>e.char).join(""));return c.join("\n")},exports.asciiTextAnsi=function(e,t={},n,o){const a={...r,...t},{frame:i,cols:s}=q(e,a,n,o);if(!i.length||0===s)return"";const c=[];for(const e of i){let t="";for(const n of e)" "===n.char||n.a<10?t+=" ":t+=`[38;2;${n.r};${n.g};${n.b}m${n.char}`;c.push(t)}return c.join("\n")},exports.asciify=async function(e,t,{fontSize:o,artStyle:a="classic",options:i={}}={}){let s;if("string"==typeof e){const t=new Image;t.crossOrigin="anonymous",await new Promise((n,o)=>{t.onload=()=>n(),t.onerror=()=>o(new Error(`Failed to load image: ${e}`)),t.src=e}),s=t}else e instanceof HTMLImageElement&&!e.complete?(await new Promise((t,n)=>{e.onload=()=>t(),e.onerror=()=>n(new Error("Image failed to load"))}),s=e):s=e;const c=n[a],l=o??i.fontSize??10,h={...r,...c,artStyle:a,...i,fontSize:l},d=t.getContext("2d");if(!d)throw new Error("Could not get 2d context from canvas");const{w:f,h:m}=function(e){return e instanceof HTMLVideoElement?{w:e.videoWidth,h:e.videoHeight}:e instanceof HTMLImageElement?{w:e.naturalWidth||e.width,h:e.naturalHeight||e.height}:{w:e.width,h:e.height}}(s),{renderW:u,renderH:g}=de(f,m),M="undefined"!=typeof window&&window.devicePixelRatio||1,p=8e6,v=u*M*g*M>p?Math.sqrt(p/(u*g)):M;t.width===Math.round(u*v)&&t.height===Math.round(g*v)||(t.width=Math.round(u*v),t.height=Math.round(g*v));const{frame:w}=q(s,h,u,g),x=(e,t)=>{d.save(),d.setTransform(v,0,0,v,0,0),G(d,w,h,u,g,e/1e3,t),d.restore()};return x(0,null),S(t,x,{continuous:"none"!==h.animationStyle||!!h.charsetFrames?.length,interactive:h.hoverStrength>0}).stop},exports.asciifyGif=async function(e,t,{fontSize:o,artStyle:a="classic",options:i={}}={}){const s="string"==typeof e?await fetch(e).then(e=>e.arrayBuffer()):e,c=o??i.fontSize??10;let l={...r,...n[a],artStyle:a,...i,fontSize:c};const h=t.getContext("2d");if(!h)throw new Error("Could not get 2d context from canvas");const{frames:d,fps:f}=await D(s,l,t.width,t.height);if(!d.length)throw new Error("asciifyGif: the GIF contains no renderable frames.");const m=performance.now();let u=-1;return S(t,(e,n)=>{const o=Math.floor((e-m)*f/1e3)%d.length;o===u&&!n&&l.hoverStrength<=0&&"none"===l.animationStyle&&!l.charsetFrames?.length||(G(h,d[o],l,t.width,t.height,(e-m)/1e3,n),u=o)},{continuous:!0,interactive:l.hoverStrength>0}).stop},exports.asciifyLiveVideo=function(e,t,n){return ge(e,t,n)},exports.asciifyText=be,exports.asciifyVideo=ge,exports.asciifyWebcam=async function(e,{fontSize:t=10,style:o="classic",options:a={},liveOptions:i,mirror:s=!0,constraints:c={facingMode:"user"},dpr:l}={}){if(!navigator.mediaDevices?.getUserMedia)throw new Error("asciifyWebcam: getUserMedia is not supported in this browser.");const h=await navigator.mediaDevices.getUserMedia({video:c}),d=document.createElement("video");d.srcObject=h,d.muted=!0,d.playsInline=!0,await new Promise((e,t)=>{d.onloadedmetadata=()=>e(),d.onerror=()=>t(new Error("asciifyWebcam: video stream failed to load.")),d.play().catch(t)});const f={...r,...n[o],...a,fontSize:t},m=e.getContext("2d");if(!m)throw new Error("asciifyWebcam: could not get 2d context from canvas.");const u=l??("undefined"!=typeof window?window.devicePixelRatio:1)??1;1!==u&&m.scale(u,u);let g=null;const M=t=>{const n=e.getBoundingClientRect();g={x:(t.clientX-n.left)/n.width,y:(t.clientY-n.top)/n.height}},p=()=>{g=null};f.hoverStrength>0&&(e.addEventListener("mousemove",M),e.addEventListener("mouseleave",p));let v,w=!1;const x=performance.now(),y=t=>{if(!w){if(d.readyState>=d.HAVE_CURRENT_DATA){const n=e.width/u,o=e.height/u,r=(t-x)/1e3,a=i?{...f,...i()}:f;a.hoverStrength>0?(e.addEventListener("mousemove",M),e.addEventListener("mouseleave",p)):(e.removeEventListener("mousemove",M),e.removeEventListener("mouseleave",p));const{frame:c}=q(d,a,n,o),l=g&&s?{x:1-g.x,y:g.y}:g;s?(m.save(),m.scale(-1,1),m.translate(-n,0),G(m,c,a,n,o,r,l),m.restore()):G(m,c,a,n,o,r,l)}v=requestAnimationFrame(y)}};return v=requestAnimationFrame(y),()=>{w=!0,cancelAnimationFrame(v),e.removeEventListener("mousemove",M),e.removeEventListener("mouseleave",p),h.getTracks().forEach(e=>e.stop()),d.srcObject=null}},exports.buildTextFrame=Me,exports.captureSnapshot=ve,exports.clearAsciifyCaches=function(){F.clear(),A.clear(),K=new WeakMap,_=new WeakMap,Y=new WeakMap,E=null,C=null},exports.computeCanvasRenderSize=fe,exports.createVideoScrollScrub=re,exports.gifToAsciiFrames=D,exports.gifToAsciiTextFrames=async function(e,t,n,o,r){const{parseGIF:a,decompressFrames:i}=await import("gifuct-js"),s=a(e),c=i(s,!0);if(0===c.length)return{frames:[],cols:0,rows:0,fps:10};const l=c[0].dims.width,h=c[0].dims.height,d=s.lsd?.width||l,f=s.lsd?.height||h,m=document.createElement("canvas");m.width=d,m.height=f;const u=m.getContext("2d"),g=document.createElement("canvas");g.width=d,g.height=f;const M=g.getContext("2d"),p=document.createElement("canvas"),v=p.getContext("2d"),w=[];let x=0,y=0,b=0;for(const e of c)b+=e.delay||100;const S=b/c.length,E=Math.round(Math.min(30,Math.max(5,1e3/S))),C=Math.min(c.length,300);for(let e=0;e<C;e++){const a=c[e],{dims:i,patch:s,disposalType:l}=a;3===l&&(M.clearRect(0,0,d,f),M.drawImage(m,0,0)),p.width!==i.width&&(p.width=i.width),p.height!==i.height&&(p.height=i.height);const h=new ImageData(new Uint8ClampedArray(s.buffer),i.width,i.height);v.putImageData(h,0,0),u.drawImage(p,i.left||0,i.top||0);const b=V(m,t,n,o);w.push(b),x=b.cols,y=b.rowCount,2===l?u.clearRect(i.left||0,i.top||0,i.width,i.height):3===l&&(u.clearRect(0,0,d,f),u.drawImage(g,0,0)),r?.((e+1)/C)}return{frames:w,cols:x,rows:y,fps:E}},exports.imageToAsciiFrame=q,exports.imageToAsciiTextFrame=V,exports.renderFrameToCanvas=G,exports.renderTextBackground=function(e,t,n,o,a={},i){const{fontSize:s=10,lineHeight:c=1.6,color:l="#505050",opacity:h=100,hoverEffect:d="spotlight",hoverStrength:f=.85,hoverRadius:m=.18,hoverColor:u="#d4ff00"}=a,g=Math.max(1,Math.floor(t/s)),M=Math.max(1,Math.floor(n/(s*c))),p=JSON.stringify([o,g,M,l,h]);let v=pe.get(e);v&&v.key===p||(v={key:p,frame:Me(o,g,M,l,h)},pe.set(e,v)),G(e,v.frame,{...r,fontSize:s,hoverEffect:d,hoverStrength:f,hoverRadius:m,hoverColor:u},t,n,0,i??null)},exports.renderTextFrameToCanvas=B,exports.renderTextToCanvas=function(e,t,n={}){const{color:o="#d4ff00",bgColor:r,fontSize:a=10}=n,i=be(t,n);if(!i)return;const s=i.split("\n"),c=Math.max(...s.map(e=>[...e].length));e.width=Math.ceil(c*a*.6),e.height=Math.ceil(s.length*a);const l=e.getContext("2d");r&&"transparent"!==r?(l.fillStyle=r,l.fillRect(0,0,e.width,e.height)):l.clearRect(0,0,e.width,e.height),l.fillStyle=o,l.font=`${a}px monospace`,l.textBaseline="top",s.forEach((e,t)=>l.fillText(e,0,t*a))},exports.snapshotAndDownload=async function(e,t={}){const{filename:n="asciify-snapshot",format:o="png",...r}=t,a=await ve(e,{format:o,...r}),i="jpeg"===o?"jpg":o,s=document.createElement("a");s.href=URL.createObjectURL(a),s.download=`${n}.${i}`,s.click(),setTimeout(()=>URL.revokeObjectURL(s.href),1e4)},exports.videoToAsciiFrames=U,exports.videoToAsciiTextFrames=N;//# sourceMappingURL=core.cjs.map