asciify-engine 1.0.101 → 1.0.103

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.
package/dist/index.d.cts CHANGED
@@ -24,7 +24,12 @@ interface SourceCrop {
24
24
  bottom?: number;
25
25
  /** CSS-like crop inset from the left edge. Percent values use 0–1. */
26
26
  left?: number;
27
- /** Keep the source aspect ratio when deriving a crop from insets or a single dimension. Default: `true` */
27
+ /**
28
+ * Keep the source aspect ratio when deriving a crop from a single `width` or
29
+ * `height`. CSS-like side insets (`top`, `right`, `bottom`, `left`) already
30
+ * define an exact source view box, and `asciifyVideo` sizes from that crop
31
+ * aspect so the output does not stretch. Default: `true`.
32
+ */
28
33
  preserveAspect?: boolean;
29
34
  /** Bias auto-centered crops toward an edge or corner. Default: `'center'` */
30
35
  anchor?: SourceCropAnchor;
@@ -667,6 +672,12 @@ interface VideoScrollScrubOptions {
667
672
  end?: string;
668
673
  /** GSAP scrub value. Default: `true`. Native fallback always scrubs. */
669
674
  scrub?: boolean | number;
675
+ /**
676
+ * Multiply scroll progress before mapping it to video time.
677
+ * `2` reaches the end of the clip in half the scroll distance, `0.5` makes it
678
+ * take twice as much scroll. Default: `1`.
679
+ */
680
+ speed?: number;
670
681
  /** Video time to map from. Defaults to trim start or `0`. */
671
682
  from?: number;
672
683
  /** Video time to map to. Defaults to trim end or video duration. */
@@ -692,7 +703,8 @@ interface AsciifyVideoOptions extends AsciifySimpleOptions {
692
703
  /**
693
704
  * CSS object-fit behavior for the visible canvas when `fitTo` or explicit
694
705
  * `width`/`height` is used. This controls visual framing only; ASCII sampling
695
- * resolution and `sourceCrop` remain unchanged.
706
+ * resolution remains independent. When `options.sourceCrop` is present, the
707
+ * engine sizes from the resolved crop aspect to avoid stretch.
696
708
  *
697
709
  * Use `'cover'` for full-bleed heroes and `'contain'` for previews.
698
710
  * Default: `'contain'`.
@@ -784,6 +796,13 @@ interface AsciifyVideoOptions extends AsciifySimpleOptions {
784
796
  * Receives the backing video element.
785
797
  */
786
798
  onReady?: (video: HTMLVideoElement) => void;
799
+ /**
800
+ * Maximum number of decoded text frames kept in memory for live scroll scrub.
801
+ * The cache is nearest-frame and bounded; lower values reduce memory for long
802
+ * clips while preserving smooth scrubbing around the current scroll position.
803
+ * Default: `90`.
804
+ */
805
+ maxCachedFrames?: number;
787
806
  /** Called after every rendered frame. */
788
807
  onFrame?: () => void;
789
808
  }
@@ -850,7 +869,7 @@ declare function asciifyGif(source: string | ArrayBuffer, canvas: HTMLCanvasElem
850
869
  * // Pre-extract frames (old behavior):
851
870
  * const stop = await asciifyVideo('/clip.mp4', canvas, { preExtract: true });
852
871
  */
853
- declare function asciifyVideo(source: HTMLVideoElement | string, canvas: HTMLCanvasElement, { fontSize, artStyle, options, fitTo, objectFit, objectPosition, scale, width, height, preExtract, fps, maxRenderDimension, trim, scroll, onReady, onFrame, }?: AsciifyVideoOptions): Promise<() => void>;
872
+ declare function asciifyVideo(source: HTMLVideoElement | string, canvas: HTMLCanvasElement, { fontSize, artStyle, options, fitTo, objectFit, objectPosition, scale, width, height, preExtract, fps, maxRenderDimension, trim, scroll, maxCachedFrames, onReady, onFrame, }?: AsciifyVideoOptions): Promise<() => void>;
854
873
  /**
855
874
  * @deprecated Use {@link asciifyVideo} instead — it now defaults to live streaming
856
875
  * and accepts the same options including `fitTo` and `preExtract`.
package/dist/index.d.ts CHANGED
@@ -24,7 +24,12 @@ interface SourceCrop {
24
24
  bottom?: number;
25
25
  /** CSS-like crop inset from the left edge. Percent values use 0–1. */
26
26
  left?: number;
27
- /** Keep the source aspect ratio when deriving a crop from insets or a single dimension. Default: `true` */
27
+ /**
28
+ * Keep the source aspect ratio when deriving a crop from a single `width` or
29
+ * `height`. CSS-like side insets (`top`, `right`, `bottom`, `left`) already
30
+ * define an exact source view box, and `asciifyVideo` sizes from that crop
31
+ * aspect so the output does not stretch. Default: `true`.
32
+ */
28
33
  preserveAspect?: boolean;
29
34
  /** Bias auto-centered crops toward an edge or corner. Default: `'center'` */
30
35
  anchor?: SourceCropAnchor;
@@ -667,6 +672,12 @@ interface VideoScrollScrubOptions {
667
672
  end?: string;
668
673
  /** GSAP scrub value. Default: `true`. Native fallback always scrubs. */
669
674
  scrub?: boolean | number;
675
+ /**
676
+ * Multiply scroll progress before mapping it to video time.
677
+ * `2` reaches the end of the clip in half the scroll distance, `0.5` makes it
678
+ * take twice as much scroll. Default: `1`.
679
+ */
680
+ speed?: number;
670
681
  /** Video time to map from. Defaults to trim start or `0`. */
671
682
  from?: number;
672
683
  /** Video time to map to. Defaults to trim end or video duration. */
@@ -692,7 +703,8 @@ interface AsciifyVideoOptions extends AsciifySimpleOptions {
692
703
  /**
693
704
  * CSS object-fit behavior for the visible canvas when `fitTo` or explicit
694
705
  * `width`/`height` is used. This controls visual framing only; ASCII sampling
695
- * resolution and `sourceCrop` remain unchanged.
706
+ * resolution remains independent. When `options.sourceCrop` is present, the
707
+ * engine sizes from the resolved crop aspect to avoid stretch.
696
708
  *
697
709
  * Use `'cover'` for full-bleed heroes and `'contain'` for previews.
698
710
  * Default: `'contain'`.
@@ -784,6 +796,13 @@ interface AsciifyVideoOptions extends AsciifySimpleOptions {
784
796
  * Receives the backing video element.
785
797
  */
786
798
  onReady?: (video: HTMLVideoElement) => void;
799
+ /**
800
+ * Maximum number of decoded text frames kept in memory for live scroll scrub.
801
+ * The cache is nearest-frame and bounded; lower values reduce memory for long
802
+ * clips while preserving smooth scrubbing around the current scroll position.
803
+ * Default: `90`.
804
+ */
805
+ maxCachedFrames?: number;
787
806
  /** Called after every rendered frame. */
788
807
  onFrame?: () => void;
789
808
  }
@@ -850,7 +869,7 @@ declare function asciifyGif(source: string | ArrayBuffer, canvas: HTMLCanvasElem
850
869
  * // Pre-extract frames (old behavior):
851
870
  * const stop = await asciifyVideo('/clip.mp4', canvas, { preExtract: true });
852
871
  */
853
- declare function asciifyVideo(source: HTMLVideoElement | string, canvas: HTMLCanvasElement, { fontSize, artStyle, options, fitTo, objectFit, objectPosition, scale, width, height, preExtract, fps, maxRenderDimension, trim, scroll, onReady, onFrame, }?: AsciifyVideoOptions): Promise<() => void>;
872
+ declare function asciifyVideo(source: HTMLVideoElement | string, canvas: HTMLCanvasElement, { fontSize, artStyle, options, fitTo, objectFit, objectPosition, scale, width, height, preExtract, fps, maxRenderDimension, trim, scroll, maxCachedFrames, onReady, onFrame, }?: AsciifyVideoOptions): Promise<() => void>;
854
873
  /**
855
874
  * @deprecated Use {@link asciifyVideo} instead — it now defaults to live streaming
856
875
  * and accepts the same options including `fitTo` and `preExtract`.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{parseGIF as t,decompressFrames as e}from"gifuct-js";var o={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"}},n={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:" ·╶╴╷╵─│┌┐└┘├┤┬┴┼╬░▒▓█"},r={cosmic:[n.starfield,n.circles,n.shadows],rain:[n.katakana,n.braille,n.binary],terminal:[n.pipes,n.claudeCode,n.standard],crystal:[n.shards,n.geometric,n.blocks],fluid:[n.waves,n.smoke,n.circles],pulse:[n.dense,n.standard,n.blocks],dream:[n.braille,n.shadows,n.smoke],angular:[n.geometric,n.shards,n.starfield],assistant:[n.interface,n.prompt,n.data],signal:[n.mesh,n.data,n.ascii],editorial:[n.humanist,n.waves,n.smoke]},a={classic:{renderMode:"ascii",charset:n.standard,colorMode:"grayscale"},particles:{renderMode:"dots",colorMode:"fullcolor",dotSizeRatio:.8},letters:{renderMode:"ascii",charset:n.letters,colorMode:"fullcolor"},claudeCode:{renderMode:"ascii",charset:n.claudeCode,colorMode:"accent",accentColor:"#f97316"},art:{renderMode:"ascii",charset:n.dense,colorMode:"fullcolor"},terminal:{renderMode:"ascii",charset:n.standard,colorMode:"matrix"},box:{renderMode:"ascii",charset:n.box,colorMode:"grayscale"},lines:{renderMode:"ascii",charset:n.lines,colorMode:"fullcolor"},braille:{renderMode:"ascii",charset:n.braille,colorMode:"fullcolor"},katakana:{renderMode:"ascii",charset:n.katakana,colorMode:"matrix"},musical:{renderMode:"ascii",charset:n.musical,colorMode:"accent",accentColor:"#e040fb"},emoji:{renderMode:"ascii",charset:n.emoji,colorMode:"fullcolor"},circles:{renderMode:"ascii",charset:n.circles,colorMode:"accent",accentColor:"#d4ff00"},shadows:{renderMode:"ascii",charset:n.shadows,colorMode:"accent",accentColor:"#50a0ff"},starfield:{renderMode:"ascii",charset:n.starfield,colorMode:"fullcolor"},geometric:{renderMode:"ascii",charset:n.geometric,colorMode:"grayscale"},pipes:{renderMode:"ascii",charset:n.pipes,colorMode:"accent",accentColor:"#00ff88"},waves:{renderMode:"ascii",charset:n.waves,colorMode:"fullcolor"},shards:{renderMode:"ascii",charset:n.shards,colorMode:"grayscale"},smoke:{renderMode:"ascii",charset:n.smoke,colorMode:"accent",accentColor:"#c850ff"},ascii:{renderMode:"ascii",charset:n.ascii,colorMode:"grayscale"},interface:{renderMode:"ascii",charset:n.interface,colorMode:"accent",accentColor:"#f4f1ea"},prompt:{renderMode:"ascii",charset:n.prompt,colorMode:"matrix"},data:{renderMode:"ascii",charset:n.data,colorMode:"fullcolor"},humanist:{renderMode:"ascii",charset:n.humanist,colorMode:"accent",accentColor:"#d6ccc2"},mesh:{renderMode:"ascii",charset:n.mesh,colorMode:"accent",accentColor:"#8fd3ff"}},i={agentField:{...a.interface,charsetFrames:r.assistant,charsetFps:1.6,animationStyle:"breathe",animationSpeed:.75,ditherStrength:.12,hoverEffect:"glow",hoverStrength:.42,hoverRadius:.18,hoverColor:"#f4f1ea",normalize:!0},liquidSignal:{...a.data,charsetFrames:r.signal,charsetFps:2.4,animationStyle:"melt",animationSpeed:.65,ditherStrength:.45,hoverEffect:"repel",hoverStrength:.55,hoverRadius:.22,hoverColor:"#8fd3ff",normalize:!0},cursorGravity:{...a.mesh,charsetFrames:r.angular,charsetFps:1.2,animationStyle:"orbit",animationSpeed:.9,ditherStrength:.2,hoverEffect:"attract",hoverStrength:.82,hoverRadius:.24,hoverColor:"#ffffff",normalize:!0},editorialPulse:{...a.humanist,charsetFrames:r.editorial,charsetFps:.9,animationStyle:"ripple",animationSpeed:.55,ditherStrength:.18,hoverEffect:"spotlight",hoverStrength:.35,hoverRadius:.2,hoverColor:"#fff8ea",normalize:!0},terminalFlow:{...a.prompt,charsetFrames:r.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}},s={fontSize:10,charSpacing:1,brightness:0,contrast:0,charset:n.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},c={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:"Ghost",options:{hoverStrength:.55,hoverEffect:"trail",hoverRadius:.2,hoverColor:"#b39ddb"}},glitchReveal:{label:"Glitch Reveal",options:{hoverStrength:.8,hoverEffect:"glitchText",hoverRadius:.18,hoverColor:"#a3e635"}}};function l(t,e){const o=document.createElement("canvas");o.width=t,o.height=e;const n=o.getContext("2d",{willReadFrequently:!0});return{canvas:o,ctx:n}}function h(t,e,o){let n=t+255*e;return n=259*(255*o+255)/(255*(259-255*o))*(n-128)+128,Math.max(0,Math.min(255,n))}function f(t,e,o){const n=o?1-t/255:t/255,r=[...e],a=Math.floor(n*(r.length-1));return r[Math.max(0,Math.min(r.length-1,a))]}function d(t,e,o,n,r,a){if((a?1-t/255:t/255)<.12)return" ";const i=[...e];return i[(n*r+o)%i.length]}var m=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];function u(t,e,o,n){if(n<=0)return t;const r=(m[o%4][e%4]/16-.5)*n*128;return Math.max(0,Math.min(255,t+r))}var g=new Array(256),M=new Array(256);for(let t=0;t<256;t++)g[t]=`rgb(${t},${t},${t})`,M[t]=`rgb(0,${t},0)`;function p(t,e,o,n,r,a=!1){switch(e){case"fullcolor":return`rgb(${t.r},${t.g},${t.b})`;case"matrix":return M[.299*t.r+.587*t.g+.114*t.b|0];case"accent":return`rgb(${o},${n},${r})`;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;return g[e]}}}var v=[0,0,0];function w(t,e,o,n,r,a=!1){switch(e){case"fullcolor":v[0]=t.r,v[1]=t.g,v[2]=t.b;break;case"matrix":{const e=.299*t.r+.587*t.g+.114*t.b|0;v[0]=0,v[1]=e,v[2]=0;break}case"accent":v[0]=o,v[1]=n,v[2]=r;break;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;v[0]=e,v[1]=e,v[2]=e;break}}return v}function b(t){const e=t.match(/rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)(?:\s*[,/]\s*([\d.]+))?\s*\)/);return e?{r:+e[1],g:+e[2],b:+e[3],a:void 0!==e[4]?+e[4]:1}:null}function x(t){let e=t;for(;e&&e!==document.documentElement.parentElement;){const t=getComputedStyle(e).backgroundColor;if(t&&"transparent"!==t&&"rgba(0, 0, 0, 0)"!==t){const e=b(t);if(e&&e.a>.1)return e}e=e.parentElement}return null}function y(t){if(t){const e=x(t);if(e){return(.299*e.r+.587*e.g+.114*e.b)/255<.4}}if("undefined"!=typeof document){const t=document.documentElement,e=(t.getAttribute("data-theme")||"").toLowerCase();if("dark"===e)return!0;if("light"===e)return!1;if(t.classList.contains("dark"))return!0;if(document.body){const t=x(document.body);if(t){return(.299*t.r+.587*t.g+.114*t.b)/255<.4}}}return"undefined"!=typeof window&&window.matchMedia("(prefers-color-scheme: dark)").matches}function S(t){if("string"!=typeof t)return t;const e=document.createElement("canvas");e.width=1,e.height=1;const o=e.getContext("2d");o.fillStyle=t,o.fillRect(0,0,1,1);const n=o.getImageData(0,0,1,1).data;return{r:n[0],g:n[1],b:n[2]}}function $(t,e,o,n,r,a,i){if("none"===a)return 1;const s=r*i;switch(a){case"wave":return.3+.7*(.6*(.5*Math.sin(t/o*Math.PI*4+3*s)+.5)+.4*(.5*Math.sin(e/n*Math.PI*3+2*s)+.5));case"pulse":{const r=o/2,a=n/2,i=Math.sqrt((t-r)**2+(e-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(e/n*Math.PI*8-5*s+.3*t)+.5)*(.3*Math.sin(t/o*Math.PI*2+s)+.7);case"breathe":{const o=.3*Math.sin(2*s)+.7,n=.1*Math.sin(.1*(t+e)+s);return Math.max(.1,Math.min(1,o+n))}case"sparkle":{const o=43758.5453*Math.sin(127.1*t+311.7*e+43758.5453*Math.floor(8*s)),n=o-Math.floor(o);return n>.7?1:.15+.4*n}case"glitch":{const t=Math.floor(e/(.05*n)),o=43758.5453*Math.sin(43.23*t+17.89*Math.floor(6*s));if(o-Math.floor(o)>.85){const e=.5*Math.sin(30*s+t)+.5;return e<.3?0:e}return 1}case"spiral":{const r=o/2,a=n/2,i=t-r,c=e-a,l=Math.atan2(c,i),h=Math.sqrt(i*i+c*c),f=Math.sqrt(r*r+a*a);return.15+.85*(.5*Math.sin(3*l+h/f*Math.PI*8-3*s)+.5)}case"typewriter":{const r=o*n,a=e*o+t-.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=o/2,a=n/2,i=t-r,c=e-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":default:return 1;case"ripple":{const r=o/2,a=n/2,i=t-r,c=e-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 o=e/n*Math.PI;return.05+(.5*Math.sin(o-1.8*s+.15*t)+.5)*(1-.6*(Math.max(0,e/n-.1)/.9))*.95}case"orbit":{const r=o/2,a=n/2,i=t-r,c=e-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 o=Math.floor(4*s),n=(t,e)=>{const n=43758.5453*Math.sin(127.1*t+311.7*e+43758.5453*o);return n-Math.floor(n)>.38?1:0},r=n(t,e),a=n(t-1,e)+n(t+1,e)+n(t,e-1)+n(t,e+1)+n(t-1,e-1)+n(t+1,e-1)+n(t-1,e+1)+n(t+1,e+1);return 1===(1===r?2===a||3===a?1:0:3===a?1:0)?1:.05}}}var C={scale:1,offsetX:0,offsetY:0,glow:0,colorBlend:0,proximity:0};function E(t,e,o,n,r,a,i,s,c="spotlight",l=.5,h="circle"){const f=t-o,d=e-n,m=.08+.35*l+.04*a;let u,g;if("box"===h){const t=Math.abs(f),e=Math.abs(d);u=Math.max(t,e),g=m}else u=Math.sqrt(f*f+d*d),g=m;if(u>=g)return C.scale=1,C.offsetX=0,C.offsetY=0,C.glow=0,C.colorBlend=0,C.proximity=0,C;const M=function(t){return t*t*(3-2*t)}(1-u/g)*r;let p=1,v=0,w=0,b=0,x=0;switch(c){case"spotlight":{p=1+M*a*1.8;const t=Math.atan2(d,f),e=M*M*a*.6;v=Math.cos(t)*e*i,w=Math.sin(t)*e*s,b=M*a*.4,x=M*M*a*.25;break}case"magnify":p=1+M*a*2.5,b=M*a*.15;break;case"repel":{p=1+M*a*.3;const t=Math.atan2(d,f),e=M*M*a*1.2;v=Math.cos(t)*e*i,w=Math.sin(t)*e*s;break}case"glow":b=M*a*.8,x=M*a*.4;break;case"colorShift":p=1+M*a*.4,b=M*a*.2,x=M*a*.7;break;case"attract":{const t=Math.atan2(d,f),e=M*M*a*1;v=-Math.cos(t)*e*i,w=-Math.sin(t)*e*s,b=M*a*.3;break}case"shatter":{const t=Math.atan2(d,f),e=.5*Math.sin(43.7*f+29.3*d),o=M*a*1.4*(.7+.3*e);v=Math.cos(t+e)*o*i,w=Math.sin(t+e)*o*s,p=Math.max(.1,1-M*a*.6),b=M*a*.25;break}case"trail":x=M*a*.9,b=M*a*.6,p=1+M*a*.15;break;case"glitchText":p=1,b=M*a*.5,x=M*a*.6}return C.scale=p,C.offsetX=v,C.offsetY=w,C.glow=b,C.colorBlend=x,C.proximity=M,C}function A(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 T(t){return t*t*t*(t*(6*t-15)+10)}function F(t,e,o){return t+(e-t)*o}function I(t,e){let o=127*t+311*e;return o^=o>>13,(o*(o*o*15731+789221)+1376312589&2147483647)/2147483647}function R(t,e){const o=Math.floor(t),n=Math.floor(e),r=e-n,a=T(t-o),i=T(r),s=I(o,n),c=I(o+1,n),l=I(o,n+1),h=I(o+1,n+1);return F(F(s,c,a),F(l,h,a),i)}function k(t,e){return(.5*R(t,e)+.25*R(2.1*t,2.1*e)+.125*R(4.3*t,4.3*e))/.875}function L(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=13,charAspect:s=.62,lineHeightRatio:c=1.4,chars:l=" .:-=+*#%@",baseColor:h=null,accentColor:f,accentThreshold:d=.52,mouseInfluence:m=.55,mouseFalloff:u=2.8,speed:g=1,vortex:M=!0,sparkles:p=!0,breathe:v=!0,lightMode:w=!1}=a,b=f??(w?"#6b8700":"#d4ff00"),x=i*s,y=i*c,S=Math.ceil(e/x),$=Math.ceil(o/y),C=r.x,E=r.y;let A=212,T=255,F=0;{const t=b.replace("#","");6===t.length&&(A=parseInt(t.slice(0,2),16),T=parseInt(t.slice(2,4),16),F=parseInt(t.slice(4,6),16))}t.clearRect(0,0,e,o),t.font=`${i}px "JetBrains Mono", monospace`,t.textBaseline="top";const R=n*g,L=v?.12*(.5*Math.sin(.22*R)+.5):0;for(let e=0;e<$;e++)for(let o=0;o<S;o++){const n=o/S,r=e/$,a=.045,i=.08*R,s=.06,c=.45*((.5*Math.sin(.08*o+.05*e+.6*R)+.5+(.5*Math.sin(.03*o-.07*e+.4*R)+.5)+(.5*Math.sin(.05*o+.03*e+.8*R)+.5))/3)+.35*(.5*k(o*a+i,e*a*1.4-.7*i)+.5)+.2*(.5*Math.sin((o+.65*e)*s+1.1*R)+.5)+L,f=n-C,g=r-E,v=Math.sqrt(f*f+g*g);let b=0;if(M&&v<.35){const t=Math.atan2(g,f),e=Math.sin(4*t+2.2*R-14*v),o=Math.max(0,1-v/.35);b=e*o*o*.22}const P=c*(1-m)+(Math.max(0,1-v*u)+.5*b)*m+.15*b,z=Math.min(1,Math.max(0,P));let q=z;if(p&&z>.72){const t=Math.floor(8*R),n=I(7*o+3*t,11*e+t);n>.88&&(q=Math.min(1,z+4*(n-.88)))}const B=Math.floor(q*(l.length-1));if(" "===l[B])continue;const H=.015+.07*q;if(q>d){const e=Math.min(w?.9:.28,H*(w?14:2.8));t.fillStyle=`rgba(${A},${T},${F},${e})`}else t.fillStyle=h?h.replace("{a}",String(H)):w?`rgba(55,55,55,${7*H})`:`rgba(255,255,255,${H})`;t.fillText(l[B],o*x,e*y)}}var P=new WeakMap,z=new WeakMap,q=null,B=null;function H(t,e){if(!q||!B){const o=l(t,e);q=o.canvas,B=o.ctx}return q.width!==t&&(q.width=t),q.height!==e&&(q.height=e),B}var j=new Map,W=new Map,D=new Map,O=new WeakMap,U=new WeakMap,N=new WeakMap;function V(t){let e=j.get(t);return e||(e=[...t],j.set(t,e)),e}function Y(t,e,o){const n=o?1-t/255:t/255,r=Math.floor(n*(e.length-1));return e[Math.max(0,Math.min(e.length-1,r))]??" "}function X(t,e,o,n){const r=`${t}\0${e?1:0}\0${o}\0${n}`;let a=W.get(r);if(!a){const i=V(t);a=new Array(256);for(let t=0;t<256;t++)a[t]=Y(h(t,o,n),i,e);W.set(r,a)}return a}function _(t){let e=D.get(t);if(!e){const o=V(t),n=Math.max(1,o.length);e=new Map;for(let t=0;t<o.length;t++)e.has(o[t])||e.set(o[t],Math.max(.08,(t+.5)/n));D.set(t,e)}return e}function J(){j.clear(),W.clear(),D.clear(),q=null,B=null}function K(t,e){return"auto"!==t?t:!y(e)}function G(t){const e=t.match(/^#([0-9a-fA-F]{3,6})$/);if(e){let t=e[1];if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return t}const o=t.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);return o?[o[1],o[2],o[3]].map(t=>parseInt(t).toString(16).padStart(2,"0")).join(""):null}function Q(t){const e=t||"auto";if("auto"!==e)return e.replace("#","");if("undefined"!=typeof document){const t=getComputedStyle(document.documentElement);for(const e of["--accent-color","--color-accent","--accent","--color-primary","--primary","--brand-color"]){const o=G(t.getPropertyValue(e).trim());if(o)return o}const e=G(getComputedStyle(document.body).accentColor??"");if(e)return e}return y("undefined"!=typeof document?document.body:null)?"faf9f7":"0d0d0d"}function Z(t,e,o){return Math.max(e,Math.min(o,t))}function tt(t,e,o){if(!t)return{x:0,y:0,width:e,height:o};const n=t.unit??"percent",r=!1!==t.preserveAspect,a=t=>void 0===t?void 0:"percent"===n?t*e:t,i=t=>void 0===t?void 0:"percent"===n?t*o:t,s=Z(a(t.left)??0,0,e-1),c=Z(a(t.right)??0,0,e-s-1),l=Z(i(t.top)??0,0,o-1),h=Z(i(t.bottom)??0,0,o-l-1),f=void 0!==t.left||void 0!==t.right||void 0!==t.top||void 0!==t.bottom,d=Math.max(1,e-s-c),m=Math.max(1,o-l-h),u=f?d:a(t.width),g=f?m:i(t.height);let M=u??e,p=g??o;if(r){const t=M/e,n=p/o,r=Math.min(t,n),a=void 0===u?n:void 0===g?t:r;M=e*a,p=o*a}M=Z(M,1,f?d:e),p=Z(p,1,f?m:o);const v=t.anchor??"center",w=a(t.x),b=i(t.y),x=f?s:0,y=f?l:0,S=f?d:e,$=f?m:o,C=v.endsWith("left")||"left"===v?0:v.endsWith("right")||"right"===v?S-M:(S-M)/2,E=v.startsWith("top")||"top"===v?0:v.startsWith("bottom")||"bottom"===v?$-p:($-p)/2;return{x:Z(w??x+C,0,Math.max(0,e-M)),y:Z(b??y+E,0,Math.max(0,o-p)),width:M,height:p}}function et(t,e,o,n){const r=t instanceof HTMLVideoElement?t.videoWidth:t.width,a=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(0===r||0===a)return{frame:[],cols:0,rows:0};const i=e.charAspect,s=e.fontSize*e.charSpacing,c=e.fontSize/i*e.charSpacing,l=o||r,f=n||a,m=Math.floor(l/s),g=Math.floor(f/c);if(m<=0||g<=0)return{frame:[],cols:0,rows:0};const M=tt(e.sourceCrop,r,a),p=Math.max(1,Math.min(Math.floor(2048/m),Math.floor(M.width/m))),v=Math.max(1,Math.min(Math.floor(2048/g),Math.floor(M.height/g))),w=m*p,b=g*v,x=H(w,b);x.drawImage(t,M.x,M.y,M.width,M.height,0,0,w,b);const y=x.getImageData(0,0,w,b).data,$=e.chromaKey,C=null!=$&&!1!==$,E=!0===$,A="blue-screen"===$;let T=null,F=0;!C||E||A||(T=S($),F=(e.chromaKeyTolerance??60)**2);let I=0,R=255;if(e.normalize){let t=255,e=0;for(let o=0;o<y.length;o+=4){if(C){const t=y[o],e=y[o+1],n=y[o+2];let r=!1;if(E)r=e>1.4*t&&e>1.4*n&&e>80;else if(A)r=n>1.4*t&&n>1.4*e&&n>80;else if(null!==T){const o=t-T.r,a=e-T.g,i=n-T.b;r=o*o+a*a+i*i<=F}if(r)continue}const n=.299*y[o]+.587*y[o+1]+.114*y[o+2];n<t&&(t=n),n>e&&(e=n)}I=t,R=e>t?e-t:255}const k=[],L=K(e.invert),P=C&&e.charset.replace(/ /g,"")||e.charset,z=V(P),q=e.customText?null:X(P,L,e.brightness,e.contrast),B=p*v;for(let t=0;t<g;t++){const o=[];for(let n=0;n<m;n++){let r=0,a=0,i=0,s=0,c=0;for(let e=0;e<v;e++){const o=(t*v+e)*w;for(let t=0;t<p;t++){const e=4*(o+n*p+t),l=y[e],h=y[e+1],f=y[e+2],d=y[e+3];if(C){let t=!1;if(E)t=h>1.4*l&&h>1.4*f&&h>80;else if(A)t=f>1.4*l&&f>1.4*h&&f>80;else if(null!==T){const e=l-T.r,o=h-T.g,n=f-T.b;t=e*e+o*o+n*n<=F}if(t){c++;continue}}r+=l,a+=h,i+=f,s+=d}}if(C&&c>B/2){o.push({char:" ",r:0,g:0,b:0,a:0});continue}const l=B-c,f=l>0?r/l:0,g=l>0?a/l:0,M=l>0?i/l:0,b=l>0?s/l:0,x=.299*f+.587*g+.114*M,S=e.normalize?(x-I)/R*255:x,$=h(S,e.brightness,e.contrast),k=e.ditherStrength>0?u($,n,t,e.ditherStrength):$,P=e.customText?d(k,e.customText,n,t,m,L):e.ditherStrength>0?Y(k,z,L):q[Math.max(0,Math.min(255,0|S))];o.push({char:P,r:f,g:g,b:M,a:b,lum:k})}k.push(o)}return{frame:k,cols:m,rows:g}}function ot(t,e,o,n){const r=t instanceof HTMLVideoElement?t.videoWidth:t.width,a=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(0===r||0===a)return{rows:[],cols:0,rowCount:0};const i=e.charAspect,s=e.fontSize*e.charSpacing,c=e.fontSize/i*e.charSpacing,l=o||r,f=n||a,d=Math.floor(l/s),m=Math.floor(f/c);if(d<=0||m<=0)return{rows:[],cols:0,rowCount:0};const g=d,M=m,p=H(g,M),v=tt(e.sourceCrop,r,a);p.drawImage(t,v.x,v.y,v.width,v.height,0,0,g,M);const w=p.getImageData(0,0,g,M).data,b=e.chromaKey,x=null!=b&&!1!==b,y=!0===b,$="blue-screen"===b;let C=null,E=0;!x||y||$||(C=S(b),E=(e.chromaKeyTolerance??60)**2);let A=0,T=255;if(e.normalize){let t=255,e=0;for(let o=0;o<w.length;o+=4){if(x){const t=w[o],e=w[o+1],n=w[o+2];let r=!1;if(y)r=e>1.4*t&&e>1.4*n&&e>80;else if($)r=n>1.4*t&&n>1.4*e&&n>80;else if(null!==C){const o=t-C.r,a=e-C.g,i=n-C.b;r=o*o+a*a+i*i<=E}if(r)continue}const n=.299*w[o]+.587*w[o+1]+.114*w[o+2];n<t&&(t=n),n>e&&(e=n)}A=t,T=e>t?e-t:255}const F=K(e.invert),I=x&&e.charset.replace(/ /g,"")||e.charset,R=V(I),k=e.customText?null:X(I,F,e.brightness,e.contrast),L=e.customText?V(e.customText):null,P="fullcolor"===e.colorMode?new Uint8ClampedArray(d*m*4):void 0,z=[];for(let t=0;t<m;t++){let o="";for(let n=0;n<d;n++){const r=4*(t*g+n),a=r,i=w[r],s=w[r+1],c=w[r+2],l=w[r+3];if(x){let t=!1;if(y)t=s>1.4*i&&s>1.4*c&&s>80;else if($)t=c>1.4*i&&c>1.4*s&&c>80;else if(null!==C){const e=i-C.r,o=s-C.g,n=c-C.b;t=e*e+o*o+n*n<=E}if(t){o+=" ",P&&(P[a]=0,P[a+1]=0,P[a+2]=0,P[a+3]=0);continue}}P&&(P[a]=i,P[a+1]=s,P[a+2]=c,P[a+3]=l);const f=.299*i+.587*s+.114*c,m=e.normalize?(f-A)/T*255:f,M=e.ditherStrength>0||L?h(m,e.brightness,e.contrast):m,p=e.ditherStrength>0?u(M,n,t,e.ditherStrength):M;if(L){o+=(F?1-p/255:p/255)<.12?" ":L[(t*d+n)%L.length]}else e.ditherStrength<=0?o+=k[Math.max(0,Math.min(255,0|m))]:o+=Y(p,R,F)}z.push(o)}return{rows:z,cols:d,rowCount:m,colors:P}}function nt(t,e,o,n,r){if(0===e.rows.length)return;const a=t.canvas,i=Boolean(o.chromaKey)||e.rows.some(t=>t.includes(" "));i||(N.delete(t),t.clearRect(0,0,n,r),t.fillStyle=y(a)?"#0a0a0a":"#faf9f7",t.fillRect(0,0,n,r));const s=Q(o.accentColor),c=parseInt(s.substring(0,2),16)||255,h=parseInt(s.substring(2,4),16)||255,f=parseInt(s.substring(4,6),16)||255,d=n/e.cols,m=r/e.rowCount,u=.9*Math.min(d/.55,m),g=e.colors;if("fullcolor"===o.colorMode&&g){if(N.delete(t),t.clearRect(0,0,n,r),u<6){const{canvas:a,ctx:i}=function(t,e,o){let n=O.get(t);n||(n=l(e,o).canvas,O.set(t,n)),n.width!==e&&(n.width=e),n.height!==o&&(n.height=o);const r=n.getContext("2d",{willReadFrequently:!1});if(!r)throw new Error("renderTextFrameToCanvas: could not create raster context.");return{canvas:n,ctx:r}}(t,e.cols,e.rowCount);let s=U.get(i);s&&s.width===e.cols&&s.height===e.rowCount||(s={width:e.cols,height:e.rowCount,imageData:i.createImageData(e.cols,e.rowCount)},U.set(i,s));const c=s.imageData,h=c.data;h.fill(0);const f=_(o.charset);for(let t=0;t<e.rowCount;t++){const o=e.rows[t];for(let n=0;n<e.cols;n++){const r=o[n];if(" "===r)continue;const a=4*(t*e.cols+n),i=g[a+3];if(i<10)continue;const s=f.get(r)??.5;h[a]=g[a],h[a+1]=g[a+1],h[a+2]=g[a+2],h[a+3]=0|Math.min(255,i*s)}}return i.putImageData(c,0,0),t.imageSmoothingEnabled=!1,t.drawImage(a,0,0,n,r),t.imageSmoothingEnabled=!0,void(t.globalAlpha=1)}t.font=`${u}px "JetBrains Mono", monospace`,t.textAlign="left",t.textBaseline="middle",t.globalAlpha=1;let a="";for(let o=0;o<e.rows.length;o++){const n=e.rows[o];let r=0;for(;r<e.cols;){for(;r<e.cols&&" "===n[r];)r++;if(r>=e.cols)break;const i=r,s=4*(o*e.cols+r),c=240&g[s],l=240&g[s+1],h=240&g[s+2];for(r++;r<e.cols&&" "!==n[r];){const t=4*(o*e.cols+r);if((240&g[t])!==c||(240&g[t+1])!==l||(240&g[t+2])!==h)break;r++}const f=`rgb(${c},${l},${h})`;f!==a&&(t.fillStyle=f,a=f),t.fillText(n.slice(i,r),i*d+.5*d,o*m+.5*m)}}return void(t.globalAlpha=1)}t.font=`${u}px "JetBrains Mono", monospace`,t.textAlign="left",t.textBaseline="middle";const M="matrix"===o.colorMode?"rgb(0,255,0)":"grayscale"===o.colorMode?y(a)?"rgb(230,230,230)":"rgb(24,24,24)":`rgb(${c},${h},${f})`;t.fillStyle=M,t.globalAlpha=1;const p=N.get(t),v=i&&p&&p.cols===e.cols&&p.rowCount===e.rowCount&&p.canvasWidth===n&&p.canvasHeight===r&&p.fillStyle===M;v||t.clearRect(0,0,n,r);for(let o=0;o<e.rows.length;o++){const r=e.rows[o];v&&p.rows[o]===r||(v&&t.clearRect(0,o*m,n,m+1),0!==r.trim().length&&t.fillText(r,.5*d,o*m+.5*m))}N.set(t,{rows:e.rows.slice(),cols:e.cols,rowCount:e.rowCount,canvasWidth:n,canvasHeight:r,fillStyle:M}),t.globalAlpha=1}async function rt(t,e,o,n,r=12,a=10,i,s=0){const c=Math.min(t.duration-s,a),l=Math.ceil(c*r),h=[];let f=0,d=0;for(let a=0;a<l;a++){const m=s+a/r;if(m>s+c)break;t.currentTime=m,await new Promise(e=>{const o=()=>{t.removeEventListener("seeked",o),e()};t.addEventListener("seeked",o)});const u=et(t,e,o,n);h.push(u.frame),f=u.cols,d=u.rows,i?.((a+1)/l)}return{frames:h,cols:f,rows:d,fps:r}}async function at(t,e,o,n,r=12,a=10,i,s=0){const c=Math.min(t.duration-s,a),l=Math.ceil(c*r),h=[];let f=0,d=0;for(let a=0;a<l;a++){const m=s+a/r;if(m>s+c)break;t.currentTime=m,await new Promise(e=>{const o=()=>{t.removeEventListener("seeked",o),e()};t.addEventListener("seeked",o)});const u=ot(t,e,o,n);h.push(u),f=u.cols,d=u.rowCount,i?.((a+1)/l)}return{frames:h,cols:f,rows:d,fps:r}}async function it(o,n,r,a,i){const s=t(o),c=e(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,f=s.lsd?.width||l,d=s.lsd?.height||h,m=document.createElement("canvas");m.width=f,m.height=d;const u=m.getContext("2d"),g=document.createElement("canvas");g.width=f,g.height=d;const M=g.getContext("2d"),p=document.createElement("canvas"),v=p.getContext("2d"),w=[];let b=0,x=0,y=0;for(const t of c)y+=t.delay||100;const S=y/c.length,$=Math.round(Math.min(30,Math.max(5,1e3/S))),C=Math.min(c.length,300);for(let t=0;t<C;t++){const e=c[t],{dims:o,patch:s,disposalType:l}=e;3===l&&(M.clearRect(0,0,f,d),M.drawImage(m,0,0)),p.width!==o.width&&(p.width=o.width),p.height!==o.height&&(p.height=o.height);const h=new ImageData(new Uint8ClampedArray(s.buffer),o.width,o.height);v.putImageData(h,0,0),u.drawImage(p,o.left||0,o.top||0);const y=et(m,n,r,a);w.push(y.frame),b=y.cols,x=y.rows,2===l?u.clearRect(o.left||0,o.top||0,o.width,o.height):3===l&&(u.clearRect(0,0,f,d),u.drawImage(g,0,0)),i?.((t+1)/C)}return{frames:w,cols:b,rows:x,fps:$}}async function st(o,n,r,a,i){const s=t(o),c=e(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,f=s.lsd?.width||l,d=s.lsd?.height||h,m=document.createElement("canvas");m.width=f,m.height=d;const u=m.getContext("2d"),g=document.createElement("canvas");g.width=f,g.height=d;const M=g.getContext("2d"),p=document.createElement("canvas"),v=p.getContext("2d"),w=[];let b=0,x=0,y=0;for(const t of c)y+=t.delay||100;const S=y/c.length,$=Math.round(Math.min(30,Math.max(5,1e3/S))),C=Math.min(c.length,300);for(let t=0;t<C;t++){const e=c[t],{dims:o,patch:s,disposalType:l}=e;3===l&&(M.clearRect(0,0,f,d),M.drawImage(m,0,0)),p.width!==o.width&&(p.width=o.width),p.height!==o.height&&(p.height=o.height);const h=new ImageData(new Uint8ClampedArray(s.buffer),o.width,o.height);v.putImageData(h,0,0),u.drawImage(p,o.left||0,o.top||0);const y=ot(m,n,r,a);w.push(y),b=y.cols,x=y.rowCount,2===l?u.clearRect(o.left||0,o.top||0,o.width,o.height):3===l&&(u.clearRect(0,0,f,d),u.drawImage(g,0,0)),i?.((t+1)/C)}return{frames:w,cols:b,rows:x,fps:$}}function ct(t,e,o,n,r,a=0,i){if("waveField"===o.animationStyle){return void L(t,n,r,a,i?{x:i.x,y:i.y}:{x:.5,y:.5},{accentColor:`#${o.accentColor?Q(o.accentColor):"d4ff00"}`,accentThreshold:.52,mouseInfluence:o.hoverStrength>0?Math.min(1,.3+.5*o.hoverStrength):.55,mouseFalloff:2.8,speed:o.animationSpeed,vortex:o.hoverStrength>0,sparkles:!0,breathe:!0})}const s=e.length;if(0===s)return;const c=e[0].length;t.clearRect(0,0,n,r);let h=!1;const d=Math.max(1,s>>2),m=Math.max(1,c>>2);t:for(let t=0;t<s;t+=d){const o=e[t];for(let t=0;t<c;t+=m)if(o[t].a<200){h=!0;break t}}const u=t.canvas,g=y(u);h||(t.fillStyle=g?"#0a0a0a":"#faf9f7",t.fillRect(0,0,n,r));const M=n/c,v=r/s,b=s*c,x=i?.intensity??1,S=!("none"!==o.animationStyle&&b>5e3)&&!!(i&&o.hoverStrength>0&&x>.005),C=o.hoverColor||"#ffffff",A=parseInt(C.slice(1,3),16)||255,T=parseInt(C.slice(3,5),16)||255,F=parseInt(C.slice(5,7),16)||255,I=Q(o.accentColor),R=parseInt(I.substring(0,2),16)||255,k=parseInt(I.substring(2,4),16)||255,q=parseInt(I.substring(4,6),16)||255,B=b>3e4?.25:b>15e3?.4:b>5e3?.6:1,H=o.hoverRadius*B;let j=0,W=c,D=0,O=s,U=0,N=0;if(S&&i){U=i.x,N=i.y;const t=.08+.35*H+.04*o.hoverStrength;j=Math.max(0,Math.floor((U-t)*c)-1),W=Math.min(c,Math.ceil((U+t)*c)+1),D=Math.max(0,Math.floor((N-t)*s)-1),O=Math.min(s,Math.ceil((N+t)*s)+1)}const V=o.animationStyle,Y=o.animationSpeed,X="none"===V,J=o.hoverStrength,G=o.hoverEffect,Z=H,tt=o.hoverShape||"circle",et=K(o.invert,u),ot=o.colorMode,nt=2*Math.PI,rt=1/c,at=1/s;let it="",st=-1;if("dots"===o.renderMode){const n=.5*Math.min(M,v)*o.dotSizeRatio;for(let o=0;o<s;o++){const r=e[o];for(let e=0;e<c;e++){const i=r[e];if(i.a<10)continue;const l=.00392156863*(.299*i.r+.587*i.g+.114*i.b),h=et?1-l:l;if(h<.02)continue;const f=X?1:$(e,o,c,s,a,V,Y);let d=1,m=0,u=0,g=0,b=0;if(S&&e>=j&&e<=W&&o>=D&&o<=O){const t=E(e*rt,o*at,U,N,x,J,M,v,G,Z,tt);d=t.scale,m=t.offsetX,u=t.offsetY,g=t.glow,b=t.colorBlend}const y=n*h*f*d;if(y<.3)continue;const C=e*M+.5*M+m,I=o*v+.5*v+u;let L;if(b>0){const t=w(i,ot,R,k,q,et);L=`rgb(${Math.min(255,t[0]+(A-t[0])*b|0)},${Math.min(255,t[1]+(T-t[1])*b|0)},${Math.min(255,t[2]+(F-t[2])*b|0)})`}else L=p(i,ot,R,k,q,et);const P=Math.min(1,.00392156863*i.a*f*(1+g));if(P!==st&&(t.globalAlpha=P,st=P),L!==it&&(t.fillStyle=L,it=L),y<=3){const e=2*y;t.fillRect(C-y,I-y,e,e)}else t.beginPath(),t.arc(C,I,y,0,nt),t.fill()}}}else{const i=.55,h=.9*Math.min(M/i,v),d=h<6;if(!d){const e="emoji"===o.artStyle;t.font=e?`${h}px "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif`:`${h}px "JetBrains Mono", monospace`,t.textAlign="center",t.textBaseline="middle"}const m=o.charsetFrames,u=!!m?.length,g=u?m[Math.floor(Math.max(0,a)*(o.charsetFps??2))%m.length]:o.charset;if(d){const{canvas:o,ctx:a}=function(t,e,o){let n=P.get(t);n||(n=l(e,o).canvas,P.set(t,n)),n.width!==e&&(n.width=e),n.height!==o&&(n.height=o);const r=n.getContext("2d",{willReadFrequently:!1});if(!r)throw new Error("renderFrameToCanvas: could not create raster context.");return{canvas:n,ctx:r}}(t,c,s);let i=z.get(a);i&&i.width===c&&i.height===s||(i={width:c,height:s,imageData:a.createImageData(c,s)},z.set(a,i));const h=i.imageData,d=h.data;d.fill(0);const m=_(g);for(let t=0;t<s;t++){const o=e[t];for(let e=0;e<c;e++){const n=o[e],r=4*(t*c+e);if(n.a<10)continue;const a=u&&null!=n.lum?f(n.lum,g,et):n.char;if(" "===a)continue;let i,s,l,h=m.get(a)??.5,p=0,b=0;if(S&&e>=j&&e<=W&&t>=D&&t<=O){const o=E(e*rt,t*at,U,N,x,J,M,v,G,Z,tt);h*=o.scale,p=o.glow,b=o.colorBlend}if(b>0){const t=w(n,ot,R,k,q,et);i=Math.min(255,t[0]+(A-t[0])*b|0),s=Math.min(255,t[1]+(T-t[1])*b|0),l=Math.min(255,t[2]+(F-t[2])*b|0)}else{const t=w(n,ot,R,k,q,et);i=t[0],s=t[1],l=t[2]}const y=Math.min(255,Math.max(0,n.a*h*(1+p)));d[r]=i,d[r+1]=s,d[r+2]=l,d[r+3]=y}}return a.putImageData(h,0,0),t.imageSmoothingEnabled=!1,t.drawImage(o,0,0,n,r),t.imageSmoothingEnabled=!0,void(t.globalAlpha=1)}const b=d?null:t.getTransform();if(!d&&!S&&X&&!u&&"accent"===ot){t.fillStyle=`rgb(${R},${k},${q})`,t.globalAlpha=1,t.textAlign="left";for(let o=0;o<s;o++){const n=e[o];let r="";for(let t=0;t<c;t++){const e=n[t];r+=e.a<10?" ":e.char}0!==r.trim().length&&t.fillText(r,.5*M,o*v+.5*v)}return void(t.globalAlpha=1)}const y="glitchText"===G&&S,C="!@#$%^&*<>{}[]|/\\~`0123456789",I=C.length;let L="",B=0,K=0,Q=0,nt=0,ct=0,lt=0;if(y){const t=o.hoverText??"ASCIIFY";if(K=Math.round(U*c),Q=Math.round(N*s),Array.isArray(t)){const e=t.filter(t=>t.length>0);0===e.length&&e.push("ASCIIFY");L=e[((7*Math.floor(K/Math.max(1,Math.ceil(c/5)))+13*Math.floor(Q/Math.max(1,Math.ceil(s/3))))%e.length+e.length)%e.length]}else L=t||"ASCIIFY";B=L.length,nt=Math.max(3,Math.min(12,Math.round(s*H*.6)));const e=Math.floor(nt/2);ct=Math.max(0,Q-e),ct+nt>s&&(ct=Math.max(0,s-nt)),lt=K-Math.floor(B/2)}for(let o=0;o<s;o++){const n=e[o];for(let e=0;e<c;e++){const r=n[e];if(r.a<10)continue;let i=u&&null!=r.lum?f(r.lum,g,et):r.char;if(" "===i)continue;const l=X?1:$(e,o,c,s,a,V,Y);if(l<.05)continue;let h=1,d=0,m=0,P=0,z=0;if(S&&!y&&e>=j&&e<=W&&o>=D&&o<=O){const t=E(e*rt,o*at,U,N,x,J,M,v,G,Z,tt);h=t.scale,d=t.offsetX,m=t.offsetY,P=t.glow,z=t.colorBlend}if(y&&o>=ct&&o<ct+nt){const t=e-lt;if(t>=0&&t<B){const n=L[t],r=Math.abs(o-Q)/Math.max(1,.5*nt),s=Math.abs(e-K)/Math.max(1,B),c=Math.max(r,s),l=Math.max(0,Math.min(1,1-.9*c)),h=43758.5453*Math.sin(127.1*e+311.7*o+43758.5453*Math.floor(12*a));i=Math.abs(h-Math.floor(h))<l?n:C[Math.abs(Math.floor(97*h))%I],P=.3+.7*l,z=.3+.65*l}}const H=e*M+.5*M+d,_=o*v+.5*v+m;let ht;if(z>0){const t=w(r,ot,R,k,q,et);ht=`rgb(${Math.min(255,t[0]+(A-t[0])*z|0)},${Math.min(255,t[1]+(T-t[1])*z|0)},${Math.min(255,t[2]+(F-t[2])*z|0)})`}else ht=p(r,ot,R,k,q,et);const ft=Math.min(1,.00392156863*r.a*l*(1+P));ft!==st&&(t.globalAlpha=ft,st=ft),ht!==it&&(t.fillStyle=ht,it=ht),1!==h?(t.translate(H,_),t.scale(h,h),t.fillText(i,0,0),t.setTransform(b)):t.fillText(i,H,_)}}}t.globalAlpha=1}function lt(t){return Math.max(0,Math.min(1,t))}function ht(t){return"string"==typeof t?document.querySelector(t):t instanceof HTMLElement?t:null}function ft(t){return"ascii"===t.renderMode&&"none"===t.animationStyle&&t.hoverStrength<=0&&!t.charsetFrames?.length}function dt(t,e,o={}){if(!Number.isFinite(t.duration)||t.duration<=0)return;const n=o.from??0,r=o.to??t.duration,a=Math.max(n,Math.min(r,t.duration)),i=lt(o.ease?o.ease(lt(e)):e),s=n+(a-n)*i;t.currentTime=Math.min(Math.max(n,s),Math.max(n,a-.04)),o.onUpdate?.(i,t)}function mt(t){const e=t.requestVideoFrameCallback;return new Promise(e?o=>{let n=!1;const r=()=>{n||(n=!0,o())};e.call(t,r),window.setTimeout(r,32)}:t=>requestAnimationFrame(()=>t()))}function ut(t,e={}){const o=ht(e.trigger)??t;t.pause();const n=e.gsap,r=e.ScrollTrigger??n?.ScrollTrigger;if(n&&r?.create){n.registerPlugin?.(r);const a=r.create({trigger:o,start:e.start??"top bottom",end:e.end??"bottom top",scrub:e.scrub??!0,onUpdate:o=>dt(t,o.progress,e)});return()=>a.kill?.()}return function(t,e,o){let n=0;const r=()=>{n=0;const r=e.getBoundingClientRect(),a=window.innerHeight||document.documentElement.clientHeight,i=r.height+a,s=i>0?lt((a-r.top)/i):0;dt(t,s,o)},a=()=>{n||(n=requestAnimationFrame(r))};return window.addEventListener("scroll",a,{passive:!0}),window.addEventListener("resize",a),a(),()=>{window.removeEventListener("scroll",a),window.removeEventListener("resize",a),n&&cancelAnimationFrame(n)}}(t,o,e)}function gt(t,e,o){const n=e.gsap,r=e.ScrollTrigger??n?.ScrollTrigger;if(n&&r?.create){n.registerPlugin?.(r);const a=r.create({trigger:t,start:e.start??"top bottom",end:e.end??"bottom top",scrub:e.scrub??!0,onUpdate:t=>o(t.progress)});return()=>a.kill?.()}return function(t,e){let o=0;const n=()=>{o=0;const n=t.getBoundingClientRect(),r=window.innerHeight||document.documentElement.clientHeight,a=n.height+r,i=a>0?lt((r-n.top)/a):0;e(i)},r=()=>{o||(o=requestAnimationFrame(n))};return window.addEventListener("scroll",r,{passive:!0}),window.addEventListener("resize",r),r(),()=>{window.removeEventListener("scroll",r),window.removeEventListener("resize",r),o&&cancelAnimationFrame(o)}}(t,o)}function Mt(t,e,o=2048){const n=o,r=Math.min(1,n/Math.max(t,e));return{renderW:Math.round(t*r),renderH:Math.round(e*r)}}function pt(t,e,o){if(void 0===t)return;if("number"==typeof t)return t;const n=t.trim();if(n.endsWith("%")){const t=Number.parseFloat(n)/100;return Number.isFinite(t)?e*t:void 0}if(n.endsWith("px")){const t=Number.parseFloat(n);return Number.isFinite(t)?t:void 0}if(n.endsWith("vw")){const t=Number.parseFloat(n)/100;return Number.isFinite(t)?o*t:void 0}}function vt(t,e,o,n,r,a=2048,i={}){const{width:s,height:c}=e.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,f=pt(i.width,s,l)??s,d=pt(i.height,c,h)??c,{cssW:m,cssH:u}=function(t,e,o,n="contain"){if("fill"===n)return{cssW:t,cssH:e};let r=t,a=r/o;const i="cover"===n,s=a>e;return(i&&!s||!i&&s)&&(a=e,r=a*o),"scale-down"===n&&(r=Math.min(r,t),a=Math.min(a,e)),{cssW:Math.round(r),cssH:Math.round(a)}}(f,d,o,i.objectFit??"contain");let g,M;n&&r?({renderW:g,renderH:M}=Mt(n,r,a)):(g=m,M=u);const p="undefined"!=typeof window&&window.devicePixelRatio||1,v=8e6,w=g*p*M*p>v?Math.sqrt(v/(g*M)):p;return t.width=Math.round(g*w),t.height=Math.round(M*w),t.style.width=`${m}px`,t.style.height=`${u}px`,{renderW:g,renderH:M,dpr:w}}async function wt(t,e,{fontSize:o,artStyle:n="classic",options:r={}}={}){let i;if("string"==typeof t){const e=new Image;e.crossOrigin="anonymous",await new Promise((o,n)=>{e.onload=()=>o(),e.onerror=()=>n(new Error(`Failed to load image: ${t}`)),e.src=t}),i=e}else t instanceof HTMLImageElement&&!t.complete?(await new Promise((e,o)=>{t.onload=()=>e(),t.onerror=()=>o(new Error("Image failed to load"))}),i=t):i=t;const c=a[n],l=o??r.fontSize??10,h={...s,...c,...r,fontSize:l},f=e.getContext("2d");if(!f)throw new Error("Could not get 2d context from canvas");const{w:d,h:m}=function(t){return t instanceof HTMLVideoElement?{w:t.videoWidth,h:t.videoHeight}:t instanceof HTMLImageElement?{w:t.naturalWidth||t.width,h:t.naturalHeight||t.height}:{w:t.width,h:t.height}}(i),{renderW:u,renderH:g}=Mt(d,m),M="undefined"!=typeof window&&window.devicePixelRatio||1,p=8e6,v=u*M*g*M>p?Math.sqrt(p/(u*g)):M;if((e.width<u||e.height<g)&&(e.width=Math.round(u*v),e.height=Math.round(g*v)),h.hoverStrength>0){const{frame:t}=et(i,h,u,g);let o=null,n=!1,r=0;const a=t=>{const n=e.getBoundingClientRect();o={x:(t.clientX-n.left)/n.width,y:(t.clientY-n.top)/n.height}},s=()=>{o=null};e.addEventListener("mousemove",a),e.addEventListener("mouseleave",s);const c=e=>{n||(f.save(),f.setTransform(v,0,0,v,0,0),ct(f,t,h,u,g,e/1e3,o),f.restore(),r=requestAnimationFrame(c))};return r=requestAnimationFrame(c),()=>{n=!0,cancelAnimationFrame(r),e.removeEventListener("mousemove",a),e.removeEventListener("mouseleave",s)}}if(f.save(),f.setTransform(v,0,0,v,0,0),ft(h)){const t=ot(i,h,u,g);nt(f,t,h,u,g)}else{const{frame:t}=et(i,h,u,g);ct(f,t,h,u,g)}f.restore()}async function bt(t,e,{fontSize:o,artStyle:n="classic",options:r={}}={}){const i="string"==typeof t?await fetch(t).then(t=>t.arrayBuffer()):t,c=o??r.fontSize??10,l={...s,...a[n],...r,fontSize:c},h=e.getContext("2d");if(!h)throw new Error("Could not get 2d context from canvas");if(ft(l)){const{frames:t,fps:o}=await st(i,l,e.width,e.height);let n,r=!1,a=0,s=performance.now();const c=1e3/o,f=o=>{r||(o-s>=c&&(nt(h,t[a],l,e.width,e.height),a=(a+1)%t.length,s=o),n=requestAnimationFrame(f))};return n=requestAnimationFrame(f),()=>{r=!0,cancelAnimationFrame(n)}}const{frames:f,fps:d}=await it(i,l,e.width,e.height);let m,u=!1,g=0,M=performance.now();const p=1e3/d,v=t=>{u||(t-M>=p&&(ct(h,f[g],l,e.width,e.height),g=(g+1)%f.length,M=t),m=requestAnimationFrame(v))};return m=requestAnimationFrame(v),()=>{u=!0,cancelAnimationFrame(m)}}async function xt(t,e,{fontSize:o,artStyle:n="classic",options:r={},fitTo:i,objectFit:c,objectPosition:l,scale:h,width:f,height:d,preExtract:m=!1,fps:u,maxRenderDimension:g=2048,trim:M,scroll:p,onReady:v,onFrame:w}={}){const b=M?.start??0,x=M?.end,y=o??r.fontSize??10,S={...s,...a[n],...r,fontSize:y},$=e.getContext("2d");if(!$)throw new Error("asciifyVideo: could not get 2d context from canvas.");const C="string"==typeof i?document.querySelector(i):i instanceof HTMLElement?i:null,E={objectFit:c,objectPosition:l,scale:h,width:f,height:d},A=function(t,e){var o;if(!function(t){return void 0!==t.objectFit||void 0!==t.objectPosition||void 0!==t.scale||void 0!==t.width||void 0!==t.height}(e))return()=>{};const n={width:t.style.width,height:t.style.height,objectFit:t.style.objectFit,objectPosition:t.style.objectPosition,maxWidth:t.style.maxWidth,maxHeight:t.style.maxHeight,transformOrigin:t.style.transformOrigin,scale:t.style.getPropertyValue("scale")};if(e.objectFit&&(t.style.objectFit=e.objectFit),e.objectPosition&&(t.style.objectPosition=e.objectPosition,t.style.transformOrigin=e.objectPosition),void 0!==e.scale){const n=Number.isFinite(e.scale)&&e.scale>0?e.scale:1;t.style.setProperty("scale",String(n)),t.style.maxWidth="none",t.style.maxHeight="none",(o=t.style).transformOrigin||(o.transformOrigin=e.objectPosition??"center center")}return()=>{t.style.width=n.width,t.style.height=n.height,t.style.objectFit=n.objectFit,t.style.objectPosition=n.objectPosition,t.style.maxWidth=n.maxWidth,t.style.maxHeight=n.maxHeight,t.style.transformOrigin=n.transformOrigin,n.scale?t.style.setProperty("scale",n.scale):t.style.removeProperty("scale")}}(e,E),T=t=>()=>{t(),A()};if(m){let o;"string"==typeof t?(o=document.createElement("video"),o.crossOrigin="anonymous",o.src=t,o.readyState<2&&await new Promise((e,n)=>{o.onloadeddata=()=>e(),o.onerror=()=>n(new Error(`asciifyVideo: failed to load "${t}"`))})):o=t,C&&vt(e,C,o.videoWidth/o.videoHeight,o.videoWidth,o.videoHeight,g,E);const{renderW:n,renderH:r}=Mt(o.videoWidth,o.videoHeight,g),a="undefined"!=typeof window&&window.devicePixelRatio||1,i=8e6,s=n*a*r*a>i?Math.sqrt(i/(n*r)):a;e.width<Math.round(n*s)&&(e.width=Math.round(n*s),e.height=Math.round(r*s));const c=void 0!==x?x-b:10,l=u??(p?18:void 0);if(ft(S)){const{frames:t,fps:a}=await at(o,S,n,r,l,c,void 0,b),i=e=>{const o=t[e];o&&($.save(),$.setTransform(s,0,0,s,0,0),nt($,o,S,n,r),$.restore(),w?.())};if(p){let n=!1,r=-1;const a=!0===p?{}:p,s=gt(ht(a.trigger)??C??e,a,e=>{const s=lt(a.ease?a.ease(lt(e)):e),c=Math.max(0,Math.min(t.length-1,Math.round(s*(t.length-1))));c!==r&&(r=c,i(c),n||(n=!0,v?.(o)),a.onUpdate?.(s,o))});return i(0),n=!0,v?.(o),T(s)}let h,f=!1,d=0,m=performance.now(),u=!0;const g=1e3/a,M=e=>{f||(e-m>=g&&(i(d),d=(d+1)%t.length,m=e,u&&(u=!1,v?.(o))),h=requestAnimationFrame(M))};return h=requestAnimationFrame(M),T(()=>{f=!0,cancelAnimationFrame(h)})}const{frames:h,fps:f}=await rt(o,S,n,r,l,c,void 0,b),d=t=>{const e=h[t];e&&($.save(),$.setTransform(s,0,0,s,0,0),ct($,e,S,n,r),$.restore(),w?.())};if(p){let t=!1,n=-1;const r=!0===p?{}:p,a=gt(ht(r.trigger)??C??e,r,e=>{const a=lt(r.ease?r.ease(lt(e)):e),i=Math.max(0,Math.min(h.length-1,Math.round(a*(h.length-1))));i!==n&&(n=i,d(i),t||(t=!0,v?.(o)),r.onUpdate?.(a,o))});return d(0),t=!0,v?.(o),T(a)}let m,M=!1,y=0,A=performance.now(),F=!0;const I=1e3/f,R=t=>{M||(t-A>=I&&(d(y),y=(y+1)%h.length,A=t,F&&(F=!1,v?.(o))),m=requestAnimationFrame(R))};return m=requestAnimationFrame(R),T(()=>{M=!0,cancelAnimationFrame(m)})}let F,I=!1;"string"==typeof t?(F=document.createElement("video"),F.src=t,F.muted=!0,F.loop=!0,F.playsInline=!0,F.setAttribute("playsinline",""),Object.assign(F.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(F),I=!0,await new Promise((e,o)=>{F.onloadedmetadata=()=>e(),F.onerror=()=>o(new Error(`asciifyVideo: failed to load "${t}"`))}),await F.play().catch(()=>{})):(F=t,F.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((t,e)=>{const o=()=>{F.removeEventListener("loadedmetadata",n),F.removeEventListener("error",r)},n=()=>{o(),t()},r=()=>{o(),e(new Error("asciifyVideo: provided video element failed to load metadata."))};F.addEventListener("loadedmetadata",n),F.addEventListener("error",r),F.load()}),F.paused&&await F.play().catch(()=>{})),b>0&&(F.currentTime=b,await new Promise(t=>{const e=()=>{F.removeEventListener("seeked",e),t()};F.addEventListener("seeked",e)}),await mt(F));let R=null;(b>0||void 0!==x)&&(R=()=>{(void 0!==x&&F.currentTime>=x||b>0&&F.currentTime<b)&&(F.currentTime=b)},F.addEventListener("timeupdate",R));let k=null;const{renderW:L,renderH:P}=Mt(F.videoWidth,F.videoHeight,g);if(C){const t=F.videoWidth/F.videoHeight,o=F.videoWidth,n=F.videoHeight,r=vt(e,C,t,o,n,g,E),a=e.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0),k=new ResizeObserver(()=>{const r=vt(e,C,t,o,n,g,E),a=e.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0)}),k.observe(C)}else{const t="undefined"!=typeof window&&window.devicePixelRatio||1,o=8e6,n=L*t*P*t>o?Math.sqrt(o/(L*P)):t;e.width<Math.round(L*n)&&(e.width=Math.round(L*n),e.height=Math.round(P*n)),$.setTransform(n,0,0,n,0,0)}let z,q=!1,B=!0,H=null;const j=p&&!m,W=u&&u>0?1e3/u:0;let D=0,O=-1;const U=!j&&ft(S);if(j&&"ascii"===S.renderMode&&"none"===S.animationStyle&&S.hoverStrength<=0&&!S.charsetFrames?.length){const t=!0===p?{}:p,o=ht(t.trigger)??C??e,n=t.from??b,r=t.to??x??F.duration,a=Math.max(n,Math.min(r,F.duration)),i=Math.max(.001,a-n),s=Math.min(60,Math.max(12,u??30)),c=Math.max(2,Math.ceil(i*s)+1),l=new Array(c);let h=0,f=0,d=-1,m=0,g=!1,M=!1,y=!1;const E=new Set,A=document.createElement("video");A.muted=!0,A.playsInline=!0,A.preload="auto",A.crossOrigin=F.crossOrigin||"anonymous",A.src=F.currentSrc||F.src,Object.assign(A.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(A),A.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((t,e)=>{const o=()=>{A.removeEventListener("loadedmetadata",n),A.removeEventListener("error",r)},n=()=>{o(),t()},r=()=>{o(),e(new Error("asciifyVideo: cache video failed to load metadata."))};A.addEventListener("loadedmetadata",n),A.addEventListener("error",r),A.load()}),A.pause(),F.paused&&await F.play().catch(()=>{});const z=t=>n+i*t/Math.max(1,c-1),q=t=>Math.max(0,Math.min(c-1,Math.round(t*(c-1)))),B=ot(F,S,L,P);B.rows.length>0&&(l[0]=B,nt($,B,S,L,P),y=!0,v?.(F),w?.());const j=t=>{if(l[t])return t;for(let e=1;e<c;e++){const o=t-e,n=t+e;if(o>=0&&l[o])return o;if(n<c&&l[n])return n}return-1},O=()=>{if(!l[h])return h;for(const t of E)if(!l[t])return t;for(let t=1;t<c;t++){const e=h-t,o=h+t;if(e>=0&&!l[e])return e;if(o<c&&!l[o])return o}return-1},U=t=>{t<0||t>=c||l[t]||(E.add(t),N())},N=async()=>{if(g||M)return;const t=O();if(!(t<0)){E.delete(t),M=!0;try{if(await function(t,e){return Math.abs(t.currentTime-e)<1/240?mt(t):new Promise(o=>{const n=()=>{t.removeEventListener("seeked",n),o()};t.addEventListener("seeked",n,{once:!0});const r=t.fastSeek;r?r.call(t,e):t.currentTime=e})}(A,z(t)),!g){const e=ot(A,S,L,P);e.rows.length>0&&(l[t]=e)}}finally{M=!1,g||requestAnimationFrame(()=>{N()})}}},V=()=>{if(g)return;const t=j(h);if(t>=0&&t!==d){const e=l[t];e&&(nt($,e,S,L,P),d=t,y||(y=!0,v?.(F)),w?.())}else if(t<0||d<0){const t=performance.now();if(W<=0||t-D>=W){const e=ot(F,S,L,P);e.rows.length>0&&(nt($,e,S,L,P),D=t,y||(y=!0,v?.(F)),w?.())}}U(h),m=requestAnimationFrame(V)};return H=gt(o,t,e=>{const o=function(t,e,o={}){if(!Number.isFinite(t.duration)||t.duration<=0)return null;const n=o.from??0,r=o.to??t.duration,a=Math.max(n,Math.min(r,t.duration)),i=lt(o.ease?o.ease(lt(e)):e),s=n+(a-n)*i;return{progress:i,time:Math.min(Math.max(n,s),Math.max(n,a-.04))}}(F,e,{...t,from:n,to:a});f=o?.progress??lt(e),h=q(f),U(h),U(h-1),U(h+1),U(h-2),U(h+2),U(h-3),U(h+3),t.onUpdate?.(f,F)}),U(0),U(1),m=requestAnimationFrame(V),T(()=>{g=!0,cancelAnimationFrame(m),H?.(),k?.disconnect(),A.pause(),A.src="",document.body.removeChild(A),R&&F.removeEventListener("timeupdate",R),I&&(F.pause(),F.src="",document.body.removeChild(F))})}if(j){const t=!0===p?{}:p;H=ut(F,{...t,trigger:t.trigger??C??e,from:t.from??b,to:t.to??x})}const N=t=>{if(q)return;if(z=requestAnimationFrame(N),F.readyState<2||0===e.width||0===e.height)return;if(W>0&&t-D<W)return;if(b>0&&F.currentTime<b)return;if(void 0!==x&&F.currentTime>=x)return;if(j&&Math.abs(F.currentTime-O)<1/240)return;if(U){const e=ot(F,S,L,P);return void(e.rows.length>0&&(nt($,e,S,L,P),D=t,O=F.currentTime,B&&(B=!1,v?.(F)),w?.()))}const{frame:o}=et(F,S,L,P);o.length>0&&(ct($,o,S,L,P,0,null),D=t,O=F.currentTime,B&&(B=!1,v?.(F)),w?.())};return z=requestAnimationFrame(N),T(()=>{q=!0,cancelAnimationFrame(z),H?.(),k?.disconnect(),R&&F.removeEventListener("timeupdate",R),I&&(F.pause(),F.src="",document.body.removeChild(F))})}function yt(t,e,o){return xt(t,e,o)}function St(t,e,o,n,r={}){const{fontSize:a=13,chars:i="0123456789ABCDEF@#$&*+=/<>",accentColor:s,color:c,speed:l=1,density:h=.55,tailLength:f=14,lightMode:d=!1}=r,m=s??(d?"#6b8700":"#d4ff00"),u=.62*a,g=1.4*a,M=Math.ceil(e/u),p=Math.ceil(o/g);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let v=255,w=255,b=255;if(d&&(v=55,w=55,b=55),c){const t=A(c);t&&(v=t.r,w=t.g,b=t.b)}let x=212,y=255,S=0;const $=A(m);$&&(x=$.r,y=$.g,S=$.b);const C=p+f;for(let e=0;e<M;e++){if(I(17*e,3)>h)continue;const o=(.5+1.5*I(31*e,7))*l,r=I(13*e,11)*C,a=Math.floor((n*o*7+r)%C),s=e*u;for(let o=0;o<=f;o++){const r=a-(f-o);if(r<0||r>=p)continue;const c=r*g,l=I(53*e+Math.floor(5*n+o),7*r),h=i[Math.floor(l*i.length)],m=o/f;if(o===f)t.fillStyle=`rgba(${x},${y},${S},${d?.7:.85})`;else{const e=d?.85*m:.15*m;t.fillStyle=`rgba(${v},${w},${b},${e})`}t.fillText(h,s,c)}}}function $t(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" . · * + ° ★",accentColor:c,color:l,speed:h=1,count:f=180,lightMode:d=!1}=a,m=c??(d?"#6b8700":"#d4ff00");t.clearRect(0,0,e,o),t.textBaseline="middle",t.textAlign="center";const u=e*(.2+.6*r.x),g=o*(.2+.6*r.y),M=.65*Math.sqrt(e*e+o*o);let p=255,v=255,w=255;if(d&&(p=55,v=55,w=55),l){const t=A(l);t&&(p=t.r,v=t.g,w=t.b)}let b=212,x=255,y=0;const S=A(m);S&&(b=S.r,x=S.g,y=S.b);const $=s.replace(/ /g,"").split("");if(0!==$.length){for(let r=0;r<f;r++){const a=I(17*r,3)*Math.PI*2,s=(n*(.15+.85*I(31*r,7))*h*.22+I(13*r,11))%1,c=u+Math.cos(a)*s*M,l=g+Math.sin(a)*s*M;if(c<-20||c>e+20||l<-20||l>o+20)continue;const f=Math.max(6,i*(.4+.9*s));t.font=`${f}px monospace`;const m=$[Math.min($.length-1,Math.floor(s*$.length))],S=s>.72,C=d?.85*s:.2*s;t.fillStyle=S?`rgba(${b},${x},${y},${Math.min(d?.92:.32,2.2*C)})`:`rgba(${p},${v},${w},${C})`,t.fillText(m,c,l)}t.textAlign="left"}}function Ct(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=". · ○ ◎ ●",accentColor:c,color:l,rings:h=5,speed:f=1,sharpness:d=4,lightMode:m=!1}=a,u=c??(m?"#007a5e":"#00ffcc");t.clearRect(0,0,e,o),t.textBaseline="middle",t.textAlign="center";const g=e*r.x,M=o*r.y,p=1.6*Math.sqrt(g*g+M*M)+.2*Math.sqrt(e*e+o*o);let v=255,w=255,b=255;if(m&&(v=55,w=55,b=55),l){const t=A(l);t&&(v=t.r,w=t.g,b=t.b)}let x=0,y=255,S=204;const $=A(u);$&&(x=$.r,y=$.g,S=$.b);const C=s.replace(/ /g,"").split("");if(0===C.length)return;const E=Math.ceil(e/i),T=Math.ceil(o/i);for(let e=0;e<T;e++)for(let o=0;o<E;o++){const r=o*i+.5*i,a=e*i+.5*i,s=r-g,c=a-M,l=Math.sqrt(s*s+c*c)/p;let u=0;for(let t=0;t<h;t++){const e=(n*f*.38+t/h)%1,o=Math.abs(l-e),r=Math.max(0,1-o*p/(i*(12-d)));u+=Math.cos(r*Math.PI*.5)*r}if(u=Math.min(1,u),u<.02)continue;const $=u>.6;t.font=`${i}px monospace`;const E=Math.floor(u*(C.length-1)),A=C[Math.min(E,C.length-1)],T=m?.88*u:.22*u;t.fillStyle=$?`rgba(${x},${y},${S},${Math.min(m?.95:.4,.55*u)})`:`rgba(${v},${w},${b},${T})`,t.fillText(A,r,a)}t.textAlign="left"}function Et(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" .·:;=+*#%@░▒▓",accentColor:c,color:l,octaves:h=4,speed:f=1,scale:d=1,accentThreshold:m=.78,mouseWarp:u=.3,lightMode:g=!1}=a,M=c??(g?"#6b8700":"#d4ff00"),p=.62*i,v=1.4*i,w=Math.ceil(e/p),b=Math.ceil(o/v);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let x=255,y=255,S=255;if(g&&(x=55,y=55,S=55),l){const t=A(l);t&&(x=t.r,y=t.g,S=t.b)}let $=212,C=255,E=0;const T=A(M);T&&($=T.r,C=T.g,E=T.b);const F=.035*d,I=n*f,k=Math.min(6,Math.max(1,h)),L=(t,e)=>{let o=0,n=.5,r=1,a=0;for(let i=0;i<k;i++)o+=R(t*r,e*r)*n,a+=n,n*=.5,r*=2.1;return o/a};for(let e=0;e<b;e++)for(let o=0;o<w;o++){const n=o*F+.06*I,a=e*F*1.3-.04*I,i=o/w-r.x,c=e/b-r.y,l=Math.sqrt(i*i+c*c),h=u>0?.12*Math.max(0,1-l/u):0,f=.5*L(n+h*Math.sin(1.3*I+8*c),a+h*Math.cos(.9*I+8*i))+.5;if(f<.12)continue;const d=s[Math.floor(f*(s.length-1))];if(" "===d)continue;const M=f>m,A=g?.82*f:.13*f;t.fillStyle=M?`rgba(${$},${C},${E},${g?.92:.28})`:`rgba(${x},${y},${S},${A})`,t.fillText(d,o*p,e*v)}}function At(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=12,chars:s="·-=+|/",accentColor:c,color:l,bands:h=3,speed:f=1,bandWidth:d=.12,glitch:m=!0,lightMode:u=!1}=a,g=c??(u?"#6b8700":"#d4ff00"),M=.62*i,p=1.4*i,v=Math.ceil(e/M),w=Math.ceil(o/p);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let b=255,x=255,y=255;if(u&&(b=55,x=55,y=55),l){const t=A(l);t&&(b=t.r,x=t.g,y=t.b)}let S=212,$=255,C=0;const E=A(g);E&&(S=E.r,$=E.g,C=E.b);const T=n*f;for(let e=0;e<w;e++)for(let o=0;o<v;o++){const n=e/w,a=((n*h-.5*T)%1+1)%1,i=Math.max(0,1-a/d),c=.35*(.5*I(3*o,7*e)+.5);let l=0;if(m){const t=o/v-r.x,a=n-r.y,i=Math.sqrt(t*t+a*a);if(i<.18){const t=I(11*o+Math.floor(12*T),5*e);l=Math.max(0,1-i/.18)*(t>.5?t-.3:0)}}const f=Math.min(1,c+.8*i+.6*l);if(f<.04)continue;const g=s[Math.floor(f*(s.length-1))],E=i>.55,A=u?.82*f:.12*f;t.fillStyle=E?`rgba(${S},${$},${C},${u?.92:.28})`:`rgba(${b},${x},${y},${A})`,t.fillText(g,o*M,e*p)}}function Tt(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" ·∙•:;+=≡≣#@",color:c,accentColor:l,speed:h=1,layers:f=5,softness:d=1.2,mouseRipple:m=.2,lightMode:u=!1}=a,g=l??(u?"#6b8700":"#d4ff00"),M=.62*i,p=1.4*i,v=Math.ceil(e/M),w=Math.ceil(o/p);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let b=255,x=255,y=255;if(u&&(b=55,x=55,y=55),c){const t=A(c);t&&(b=t.r,x=t.g,y=t.b)}let S=212,$=255,C=0;const E=A(g);E&&(S=E.r,$=E.g,C=E.b);const T=n*h,F=[];for(let t=0;t<f;t++){const e=I(17*t,31*t+7),o=I(23*t+5,11*t);F.push({fx:.8+2.2*e,fy:1.2+1.8*o,phase:e*Math.PI*4,dt:(.3+.5*I(7*t,13*t+3))*(t%2==0?1:-1),amp:.55+.45*I(29*t,3*t)})}for(let e=0;e<w;e++){const o=e/w;for(let n=0;n<v;n++){const a=n/v,i=a-r.x,c=o-r.y,l=Math.sqrt(i*i+c*c),h=m*Math.exp(-l*l/.06),g=a+i*h,w=o+c*h;let E=0,A=0;for(let t=0;t<f;t++){const{fx:e,fy:o,phase:n,dt:r,amp:a}=F[t];E+=Math.sin(g*e*Math.PI*2+T*r+n)*Math.cos(w*o*Math.PI*2+T*r*.7+1.3*n)*a,A+=a}const I=E/A,R=.5+.5*Math.tanh(I*d*2.2);if(R<.12)continue;const k=(R-.12)/.88,L=s[Math.min(s.length-1,Math.floor(k*s.length))],P=R>.82,z=u?.82*R:.14*R;t.fillStyle=P?`rgba(${S},${$},${C},${u?.92:.32})`:`rgba(${b},${x},${y},${z})`,t.fillText(L,n*M,e*p)}}}function Ft(t,e,o,n,r={}){const{fontSize:a=13,color:i,accentColor:s,speed:c=.4,layers:l=4,turbulence:h=.8,lightMode:f=!1}=r,d=s??(f?"#6b8700":"#d4ff00"),m=.62*a,u=1.4*a,g=Math.ceil(e/m),M=Math.ceil(o/u);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let p=255,v=255,w=255;if(f&&(p=55,v=55,w=55),i){const t=A(i);t&&(p=t.r,v=t.g,w=t.b)}let b=212,x=255,y=0;const S=A(d);S&&(b=S.r,x=S.g,y=S.b);const $=n*c,C=["─","─","╌","·","╌","─","─","╌","·"];for(let e=0;e<M;e++){const o=e/M;for(let n=0;n<g;n++){const r=n/g;let a=0,i=0;for(let t=0;t<l;t++){const e=I(13*t,7*t+3),n=1.1+2.4*e,s=.9+2*I(29*t,11*t+1),c=e*Math.PI*6,l=(.2+.5*I(41*t,17*t))*(t%2==0?1:-1.3),f=Math.sin(r*n*Math.PI*2+$*l+c),d=Math.cos(o*s*Math.PI*2+$*l*.6+1.7*c),m=Math.sin(r*s*Math.PI*h+o*n*Math.PI*h+$*l*.4);a+=Math.atan2(d+.3*m,f),i+=.5*(f*d+1)}const s=a/l,c=Math.min(1,i/l);if(c<.1)continue;const d=(s+Math.PI)/(2*Math.PI),M=C[Math.floor(d*C.length)%C.length],S=c>.8,E=f?.8*c:.13*c;t.fillStyle=S?`rgba(${b},${x},${y},${f?.9:.26})`:`rgba(${p},${v},${w},${E})`,t.fillText(M,n*m,e*u)}}}function It(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=13,chars:s=" ·:;=+*#%@",color:c,accentColor:l,speed:h=1,radius:f=.38,swirl:d=3,lightMode:m=!1}=a,u=l??(m?"#6b8700":"#d4ff00"),g=.62*i,M=1.4*i,p=Math.ceil(e/g),v=Math.ceil(o/M),w=e/o;t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let b=255,x=255,y=255;if(m&&(b=55,x=55,y=55),c){const t=A(c);t&&(b=t.r,x=t.g,y=t.b)}let S=212,$=255,C=0;const E=A(u);E&&(S=E.r,$=E.g,C=E.b);const T=n*h;for(let e=0;e<v;e++){const o=e/v;for(let n=0;n<p;n++){const a=(n/p-r.x)*w,i=o-r.y,c=Math.sqrt(a*a+i*i)/f;if(c>1){const o=I(3*n,7*e)*Math.max(0,1-3*(c-1));if(o<.62)continue;const r=o*(m?.28:.04);t.fillStyle=`rgba(${b},${x},${y},${r})`,t.fillText(s[1],n*g,e*M);continue}const l=Math.max(0,1-Math.abs(c-(.15+.12*Math.sin(1.1*T)))/.07),h=Math.pow(1-c,2.2),d=Math.min(1,h+.6*l);if(d<.06)continue;const u=Math.floor(d*(s.length-1)),v=s[Math.min(s.length-1,u)],E=l>.35||c<.08,A=m?.85*d:.18*d;t.fillStyle=E?`rgba(${S},${$},${C},${m?.95:.38})`:`rgba(${b},${x},${y},${A})`,t.fillText(v,n*g,e*M)}}}function Rt(t,e,o,n,r={}){const{fontSize:a=14,chars:i=" ·∙•:-=+*#",color:s,accentColor:c,speed:l=.5,harmonics:h=3,lightMode:f=!1}=r,d=c??(f?"#6b8700":"#d4ff00"),m=.62*a,u=1.4*a,g=Math.ceil(e/m),M=Math.ceil(o/u);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let p=255,v=255,w=255;if(f&&(p=55,v=55,w=55),s){const t=A(s);t&&(p=t.r,v=t.g,w=t.b)}let b=212,x=255,y=0;const S=A(d);S&&(b=S.r,x=S.g,y=S.b);const $=n*l,C=Array.from({length:h},(t,e)=>1/(e+1)).reduce((t,e)=>t+e,0);for(let e=0;e<M;e++)for(let o=0;o<g;o++){let n=0;for(let t=0;t<h;t++){const r=.18+1.4*I(o*(t+3)+7,e*(t+5)+11),a=I(o*(t+7),e*(t+9)+3)*Math.PI*2,i=1/(t+1);n+=Math.sin($*r+a)*i}const r=.5*(n/C+1);if(r<.28)continue;const a=(r-.28)/.72,s=i[Math.min(i.length-1,Math.floor(a*i.length))],c=r>.88,l=f?.82*a:.13*a;t.fillStyle=c?`rgba(${b},${x},${y},${f?.92:.28})`:`rgba(${p},${v},${w},${l})`,t.fillText(s,o*m,e*u)}}function kt(t,e,o,n,r={}){const{fontSize:a=13,chars:i=" .,:;i+xX#&@",color:s="#ff4500",hotColor:c="#ffe066",intensity:l=.85,wind:h=0,speed:f=1,lightMode:d=!1}=r,m=.62*a,u=1.4*a,g=Math.ceil(e/m),M=Math.ceil(o/u),p=g*M,v="__fire_heat__",w=t.canvas;let b=w[v];b&&b.length===p||(b=new Float32Array(p),w[v]=b);const x=.18*(.016*f),y=h*f*.8,S=M-1,$=n*f;for(let t=0;t<g;t++){const e=(.6*(.5*Math.sin(.31*t+4.1*$)+.5)+.4*(.5*Math.sin(.73*t-2.7*$)+.5))*l;b[S*g+t]=Math.min(1,e+.15*Math.random()*l),S>0&&(b[(S-1)*g+t]=Math.min(1,.85*e+.1*Math.random()*l))}const C=new Float32Array(p);for(let t=0;t<M-2;t++)for(let e=0;e<g;e++){const o=.4*b[(t+1)*g+e]+.25*b[(t+2)*g+Math.max(0,Math.min(g-1,e+Math.round(y)))]+.175*b[(t+1)*g+Math.max(0,e-1)]+.175*b[(t+1)*g+Math.min(g-1,e+1)];C[t*g+e]=Math.max(0,o-x-.02*Math.random()*f)}for(let t=0;t<g;t++)C[(M-1)*g+t]=b[(M-1)*g+t],M>1&&(C[(M-2)*g+t]=b[(M-2)*g+t]);w[v]=C;const E=A(s)??{r:255,g:69,b:0},T=A(c)??{r:255,g:224,b:102};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";for(let e=0;e<M;e++)for(let o=0;o<g;o++){const n=C[e*g+o];if(n<.03)continue;const r=i[Math.min(i.length-1,Math.floor(n*i.length))];if(" "===r)continue;const a=Math.min(1,1.2*n),s=E.r+(T.r-E.r)*a|0,c=E.g+(T.g-E.g)*a|0,l=E.b+(T.b-E.b)*a|0,h=d?1-.3*n:Math.min(1,n+.15);t.globalAlpha=h,t.fillStyle=`rgb(${s},${c},${l})`,t.fillText(r,o*m,e*u)}t.globalAlpha=1}function Lt(t,e,o,n,r={}){const{fontSize:a=13,baseChars:i="ATCG",bridgeChars:s="-=≡",color:c="#00e5ff",color2:l="#ff4081",bridgeColor:h="#88ffcc",speed:f=1,helixCount:d,lightMode:m=!1}=r,u=.62*a,g=1.4*a,M=Math.ceil(e/u),p=Math.ceil(o/g),v=d??Math.max(1,Math.floor(e/80)),w=M/v,b=A(c)??{r:0,g:229,b:255},x=A(l)??{r:255,g:64,b:129},y=A(h)??{r:136,g:255,b:204};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const S=n*f,$=.35*w;for(let e=0;e<v;e++){const o=w*(e+.5);for(let n=0;n<p;n++){const r=n/p*Math.PI*6-1.8*S,a=o+Math.sin(r)*$,c=o+Math.sin(r+Math.PI)*$,l=Math.round(a),h=Math.round(c);if(l<0||l>=M)continue;const f=I(31*e+7*n,3),d=i[Math.floor(f*i.length)],m=.5*(Math.sin(r)+1),v=.5*(Math.sin(r+Math.PI)+1);if(t.globalAlpha=.35+.65*m,t.fillStyle=`rgb(${b.r},${b.g},${b.b})`,t.fillText(d,l*u,n*g),h>=0&&h<M){const o=I(53*e+11*n,7),r=i[Math.floor(o*i.length)];t.globalAlpha=.35+.65*v,t.fillStyle=`rgb(${x.r},${x.g},${x.b})`,t.fillText(r,h*u,n*g)}if(n%3===0){const o=Math.min(l,h),r=Math.max(l,h);if(r-o>1){const a=I(17*n+43*e,5),i=s[Math.floor(a*s.length)],c=.25*(m+v)+.2;t.globalAlpha=c,t.fillStyle=`rgb(${y.r},${y.g},${y.b})`;for(let e=o+1;e<r;e++)t.fillText(i,e*u,n*g)}}}}t.globalAlpha=1}function Pt(t,e,o,n,r={}){const{fontSize:a=13,chars:i=" .,:;+*#@",color:s="#4caf50",skyColor:c="#1a237e",peakColor:l="#e0e0e0",speed:h=1,roughness:f=.55,heightScale:d=.55,stars:m=!0,lightMode:u=!1}=r,g=.62*a,M=1.4*a,p=Math.ceil(e/g),v=Math.ceil(o/M),w=A(s)??{r:76,g:175,b:80},b=A(c)??{r:26,g:35,b:126},x=A(l)??{r:224,g:224,b:224};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const y=n*h*.4,S=new Array(p);for(let t=0;t<p;t++){const e=(.5*k((t/p+y)*f*3,.5)+.5)*d;S[t]=Math.floor(e*v)}for(let e=0;e<v;e++)for(let o=0;o<p;o++){const r=v-1-S[o],a=e===r;if(!(e>=r)){if(m){const r=I(7*o+Math.floor(.3*y),13*e);if(r>.97){const a=.3*Math.sin(2*n+100*r)+.7;t.globalAlpha=.5*a,t.fillStyle=`rgb(${b.r+60},${b.g+60},${b.b+80})`,t.fillText("·",o*g,e*M)}}continue}const s=(e-r)/Math.max(1,S[o]),c=i[Math.min(i.length-1,Math.floor(s*i.length))];if(" "===c&&!a)continue;const l=a?1:Math.max(0,1-4*s),h=w.r+(x.r-w.r)*l|0,f=w.g+(x.g-w.g)*l|0,d=w.b+(x.b-w.b)*l|0;t.globalAlpha=.5+.5*s,t.fillStyle=`rgb(${h},${f},${d})`,t.fillText(a?i[i.length-1]:c,o*g,e*M)}t.globalAlpha=1}var zt=1,qt=2,Bt=4,Ht=8,jt={3:"─",12:"│",9:"┌",10:"┐",5:"└",6:"┘",11:"┬",7:"┴",13:"├",14:"┤",15:"┼",[zt]:"╶",[qt]:"╴",[Bt]:"╵",[Ht]:"╷"};function Wt(t,e,o,n,r={}){const{fontSize:a=13,pulseColor:i="#ffffff",color:s="#00ff88",density:c=.38,speed:l=1,lightMode:h=!1}=r,f=.62*a,d=1.4*a,m=Math.ceil(e/f),u=Math.ceil(o/d),g=A(s)??{r:0,g:255,b:136},M=A(i)??{r:255,g:255,b:255},p=(t,e)=>{if(I(17*t+1,7*e+2)>c)return 0;let o=0;return t+1<m&&I(17*t+1,7*e+2)>.15&&(o|=1),t-1>=0&&I(17*(t-1)+1,7*e+2)>.15&&(o|=2),e+1<u&&I(17*t+1,7*(e+1)+2)>.15&&(o|=8),e-1>=0&&I(17*t+1,7*(e-1)+2)>.15&&(o|=4),o};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const v=n*l;for(let e=0;e<u;e++)for(let o=0;o<m;o++){const n=p(o,e);if(0===n)continue;const r=jt[n]??"·",a=(8*v+40*I(o,23*e))%m,i=(6*v+40*I(17*e,11*o))%u,s=(1&n||2&n)&&Math.abs(o-a)<1.5,c=(4&n||8&n)&&Math.abs(e-i)<1.5,l=s||c,h=.25+.35*I(3*o,5*e);l?(t.globalAlpha=.95,t.fillStyle=`rgb(${M.r},${M.g},${M.b})`):(t.globalAlpha=h,t.fillStyle=`rgb(${g.r},${g.g},${g.b})`),t.fillText(r,o*f,e*d)}t.globalAlpha=1}var Dt=["wave","rain","stars","pulse","noise","grid","aurora","silk","void","morph","fire","dna","terrain","circuit"];function Ot(t,e={}){const{type:o="wave",opacity:n=.2,className:r,zIndex:a=0,colorScheme:i="auto",color:s,...c}=e,l="string"==typeof t?document.querySelector(t):t;if(!l)return console.warn("[asciify] asciiBackground: target not found",t),{destroy:()=>{}};const h=l.style.position;"static"===getComputedStyle(l).position&&(l.style.position="relative");const f=document.createElement("canvas");f.style.cssText=["position:absolute","inset:0","width:100%","height:100%",`opacity:${n}`,"pointer-events:none",`z-index:${a}`].join(";"),r&&(f.className=r),l.prepend(f);const d=f.getContext("2d"),m=window.devicePixelRatio||1,u={x:.5,y:.5},g={x:.5,y:.5},M=()=>"light"===i||"dark"!==i&&(()=>{let t=l;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)})(),p=s?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}(s):null,v=()=>({...c,lightMode:void 0!==c.lightMode?c.lightMode:M(),baseColor:p?`rgba(${p.r},${p.g},${p.b},{a})`:c.baseColor}),w={current:v()},b=()=>{w.current="rain"===o||"stars"===o||"pulse"===o||"noise"===o||"grid"===o||"aurora"===o||"silk"===o||"void"===o||"morph"===o?{...c,lightMode:void 0!==c.lightMode?c.lightMode:M(),color:s??c.color}:"fire"===o||"dna"===o?{...c,color:s??c.color}:"terrain"===o||"circuit"===o?{...c,color:s??c.color,lightMode:void 0!==c.lightMode?c.lightMode:M()}:v()};b();const x=window.matchMedia("(prefers-color-scheme: light)"),y=()=>{b()};let S=null;"auto"===i&&(x.addEventListener("change",y),S=new MutationObserver(y),S.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]}));const $=()=>{const t=l.getBoundingClientRect();f.width=t.width*m,f.height=t.height*m,d.setTransform(m,0,0,m,0,0)};$();const C=t=>{const e=l.getBoundingClientRect();u.x=(t.clientX-e.left)/e.width,u.y=(t.clientY-e.top)/e.height},E=new ResizeObserver($);E.observe(l),window.addEventListener("mousemove",C);let A=0,T=0;const F=()=>{g.x+=.07*(u.x-g.x),g.y+=.07*(u.y-g.y);const t=l.getBoundingClientRect();"rain"===o?St(d,t.width,t.height,A,w.current):"stars"===o?$t(d,t.width,t.height,A,g,w.current):"pulse"===o?Ct(d,t.width,t.height,A,g,w.current):"noise"===o?Et(d,t.width,t.height,A,g,w.current):"grid"===o?At(d,t.width,t.height,A,g,w.current):"aurora"===o?Tt(d,t.width,t.height,A,g,w.current):"silk"===o?Ft(d,t.width,t.height,A,w.current):"void"===o?It(d,t.width,t.height,A,g,w.current):"morph"===o?Rt(d,t.width,t.height,A,w.current):"fire"===o?kt(d,t.width,t.height,A,w.current):"dna"===o?Lt(d,t.width,t.height,A,w.current):"terrain"===o?Pt(d,t.width,t.height,A,w.current):"circuit"===o?Wt(d,t.width,t.height,A,w.current):L(d,t.width,t.height,A,g,w.current),A+=.016,T=requestAnimationFrame(F)};return T=requestAnimationFrame(F),{destroy:()=>{cancelAnimationFrame(T),E.disconnect(),"auto"===i&&(x.removeEventListener("change",y),S?.disconnect()),window.removeEventListener("mousemove",C),f.remove(),l.style.position=h}}}var Ut=Ot;function Nt(t,e={},o,n){const r={...s,...e},{frame:a,cols:i}=et(t,r,o,n);if(!a.length||0===i)return"";const c=[];for(const t of a)c.push(t.map(t=>t.char).join(""));return c.join("\n")}function Vt(t,e={},o,n){const r={...s,...e},{frame:a,cols:i}=et(t,r,o,n);if(!a.length||0===i)return"";const c=[];for(const t of a){let e="";for(const o of t)" "===o.char||o.a<10?e+=" ":e+=`[38;2;${o.r};${o.g};${o.b}m${o.char}`;c.push(e)}return c.join("\n")}function Yt(t,e,o,n="#505050",r=100){if(!t||e<=0||o<=0)return[];const a=A(n)??{r:80,g:80,b:80},i=t,s=i.length;return Array.from({length:o},(t,o)=>Array.from({length:e},(t,n)=>({char:i[(o*e+n)%s],r:a.r,g:a.g,b:a.b,a:r})))}function Xt(t,e,o,n,r={},a){const{fontSize:i=10,lineHeight:c=1.6,color:l="#505050",opacity:h=100,hoverEffect:f="spotlight",hoverStrength:d=.85,hoverRadius:m=.18,hoverColor:u="#d4ff00"}=r;ct(t,Yt(n,Math.max(1,Math.floor(e/i)),Math.max(1,Math.floor(o/(i*c))),l,h),{...s,hoverEffect:f,hoverStrength:d,hoverRadius:m,hoverColor:u},e,o,0,a??null)}function _t(t,{format:e="png",quality:o=.92,scale:n=1}={}){return new Promise((r,a)=>{let i=t;if(1!==n){const e=document.createElement("canvas");e.width=Math.round(t.width*n),e.height=Math.round(t.height*n);const o=e.getContext("2d");if(!o)return void a(new Error("captureSnapshot: could not get 2d context"));o.drawImage(t,0,0,e.width,e.height),i=e}i.toBlob(t=>t?r(t):a(new Error("captureSnapshot: toBlob returned null")),`image/${e}`,o)})}async function Jt(t,e={}){const{filename:o="asciify-snapshot",format:n="png",...r}=e,a=await _t(t,{format:n,...r}),i="jpeg"===n?"jpg":n,s=document.createElement("a");s.href=URL.createObjectURL(a),s.download=`${o}.${i}`,s.click(),setTimeout(()=>URL.revokeObjectURL(s.href),1e4)}async function Kt(t,{fontSize:e=10,style:o="classic",options:n={},liveOptions:r,mirror:i=!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}),f=document.createElement("video");f.srcObject=h,f.muted=!0,f.playsInline=!0,await new Promise((t,e)=>{f.onloadedmetadata=()=>t(),f.onerror=()=>e(new Error("asciifyWebcam: video stream failed to load.")),f.play().catch(e)});const d={...s,...a[o],...n,fontSize:e},m=t.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={x:.5,y:.5,intensity:0},p=e=>{const o=t.getBoundingClientRect();g={x:(e.clientX-o.left)/o.width,y:(e.clientY-o.top)/o.height}},v=()=>{g=null};d.hoverStrength>0&&(t.addEventListener("mousemove",p),t.addEventListener("mouseleave",v));let w,b=!1;const x=performance.now(),y=e=>{if(!b){if(f.readyState>=f.HAVE_CURRENT_DATA){const o=t.width/u,n=t.height/u,a=(e-x)/1e3,s=r?{...d,...r()}:d;s.hoverStrength>0?(t.addEventListener("mousemove",p),t.addEventListener("mouseleave",v)):(t.removeEventListener("mousemove",p),t.removeEventListener("mouseleave",v));const{frame:c}=et(f,s,o,n);if(g){const t=g.x-M.x,e=g.y-M.y,o=Math.sqrt(t*t+e*e),n=Math.min(.25,.06+.8*o);M.x+=t*n,M.y+=e*n,M.intensity+=.12*(1-M.intensity)}else M.intensity*=.965,M.intensity<.003&&(M.intensity=0);const l=M.intensity>.003?{x:M.x,y:M.y,intensity:M.intensity}:null;i?(m.save(),m.scale(-1,1),m.translate(-o,0),ct(m,c,s,o,n,a,l),m.restore()):ct(m,c,s,o,n,a,l)}w=requestAnimationFrame(y)}};return w=requestAnimationFrame(y),()=>{b=!0,cancelAnimationFrame(w),t.removeEventListener("mousemove",p),t.removeEventListener("mouseleave",v),h.getTracks().forEach(t=>t.stop()),f.srcObject=null}}var Gt={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]},Qt=[127,65,65,65,65,65,127];function Zt(t){return Gt[t]??Gt[t.toUpperCase()]??Qt}function te(t,e={}){if(!t)return"";const{char:o="█",scale:n=1}=e,r=[...o][0]??"█",a=Math.max(1,Math.floor(n)),i=7*a,s=a,c=Array.from({length:i},()=>"");for(let e=0;e<t.length;e++){const o=Zt(t[e]);for(let t=0;t<7;t++){const e=o[t];let n="";for(let t=6;t>=0;t--)n+=(e>>t&1?r:" ").repeat(a);for(let e=0;e<a;e++)c[t*a+e]+=n}if(e<t.length-1)for(let t=0;t<i;t++)c[t]+=" ".repeat(s)}return c.join("\n")}function ee(t,e,o={}){const{color:n="#d4ff00",bgColor:r,fontSize:a=10}=o,i=te(e,o);if(!i)return;const s=i.split("\n"),c=Math.max(...s.map(t=>[...t].length));t.width=Math.ceil(c*a*.6),t.height=Math.ceil(s.length*a);const l=t.getContext("2d");r&&"transparent"!==r?(l.fillStyle=r,l.fillRect(0,0,t.width,t.height)):l.clearRect(0,0,t.width,t.height),l.fillStyle=n,l.font=`${a}px monospace`,l.textBaseline="top",s.forEach((t,e)=>l.fillText(t,0,e*a))}export{a as ART_STYLE_PRESETS,Dt as BACKGROUND_TYPES,n as CHARSETS,r as CHARSET_SEQUENCES,s as DEFAULT_OPTIONS,c as HOVER_PRESETS,i as LIVING_STYLE_PRESETS,o as PALETTE_THEMES,Ot as asciiBackground,Nt as asciiText,Vt as asciiTextAnsi,wt as asciify,bt as asciifyGif,yt as asciifyLiveVideo,te as asciifyText,xt as asciifyVideo,Kt as asciifyWebcam,Yt as buildTextFrame,_t as captureSnapshot,J as clearAsciifyCaches,ut as createVideoScrollScrub,it as gifToAsciiFrames,st as gifToAsciiTextFrames,et as imageToAsciiFrame,ot as imageToAsciiTextFrame,Ut as mountWaveBackground,Tt as renderAuroraBackground,Wt as renderCircuitBackground,Lt as renderDnaBackground,kt as renderFireBackground,ct as renderFrameToCanvas,At as renderGridBackground,Rt as renderMorphBackground,Et as renderNoiseBackground,Ct as renderPulseBackground,St as renderRainBackground,Ft as renderSilkBackground,$t as renderStarsBackground,Pt as renderTerrainBackground,Xt as renderTextBackground,nt as renderTextFrameToCanvas,ee as renderTextToCanvas,It as renderVoidBackground,L as renderWaveBackground,Jt as snapshotAndDownload,rt as videoToAsciiFrames,at as videoToAsciiTextFrames};//# sourceMappingURL=index.js.map
1
+ import{parseGIF as t,decompressFrames as e}from"gifuct-js";var o={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"}},n={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:" ·╶╴╷╵─│┌┐└┘├┤┬┴┼╬░▒▓█"},r={cosmic:[n.starfield,n.circles,n.shadows],rain:[n.katakana,n.braille,n.binary],terminal:[n.pipes,n.claudeCode,n.standard],crystal:[n.shards,n.geometric,n.blocks],fluid:[n.waves,n.smoke,n.circles],pulse:[n.dense,n.standard,n.blocks],dream:[n.braille,n.shadows,n.smoke],angular:[n.geometric,n.shards,n.starfield],assistant:[n.interface,n.prompt,n.data],signal:[n.mesh,n.data,n.ascii],editorial:[n.humanist,n.waves,n.smoke]},a={classic:{renderMode:"ascii",charset:n.standard,colorMode:"grayscale"},particles:{renderMode:"dots",colorMode:"fullcolor",dotSizeRatio:.8},letters:{renderMode:"ascii",charset:n.letters,colorMode:"fullcolor"},claudeCode:{renderMode:"ascii",charset:n.claudeCode,colorMode:"accent",accentColor:"#f97316"},art:{renderMode:"ascii",charset:n.dense,colorMode:"fullcolor"},terminal:{renderMode:"ascii",charset:n.standard,colorMode:"matrix"},box:{renderMode:"ascii",charset:n.box,colorMode:"grayscale"},lines:{renderMode:"ascii",charset:n.lines,colorMode:"fullcolor"},braille:{renderMode:"ascii",charset:n.braille,colorMode:"fullcolor"},katakana:{renderMode:"ascii",charset:n.katakana,colorMode:"matrix"},musical:{renderMode:"ascii",charset:n.musical,colorMode:"accent",accentColor:"#e040fb"},emoji:{renderMode:"ascii",charset:n.emoji,colorMode:"fullcolor"},circles:{renderMode:"ascii",charset:n.circles,colorMode:"accent",accentColor:"#d4ff00"},shadows:{renderMode:"ascii",charset:n.shadows,colorMode:"accent",accentColor:"#50a0ff"},starfield:{renderMode:"ascii",charset:n.starfield,colorMode:"fullcolor"},geometric:{renderMode:"ascii",charset:n.geometric,colorMode:"grayscale"},pipes:{renderMode:"ascii",charset:n.pipes,colorMode:"accent",accentColor:"#00ff88"},waves:{renderMode:"ascii",charset:n.waves,colorMode:"fullcolor"},shards:{renderMode:"ascii",charset:n.shards,colorMode:"grayscale"},smoke:{renderMode:"ascii",charset:n.smoke,colorMode:"accent",accentColor:"#c850ff"},ascii:{renderMode:"ascii",charset:n.ascii,colorMode:"grayscale"},interface:{renderMode:"ascii",charset:n.interface,colorMode:"accent",accentColor:"#f4f1ea"},prompt:{renderMode:"ascii",charset:n.prompt,colorMode:"matrix"},data:{renderMode:"ascii",charset:n.data,colorMode:"fullcolor"},humanist:{renderMode:"ascii",charset:n.humanist,colorMode:"accent",accentColor:"#d6ccc2"},mesh:{renderMode:"ascii",charset:n.mesh,colorMode:"accent",accentColor:"#8fd3ff"}},i={agentField:{...a.interface,charsetFrames:r.assistant,charsetFps:1.6,animationStyle:"breathe",animationSpeed:.75,ditherStrength:.12,hoverEffect:"glow",hoverStrength:.42,hoverRadius:.18,hoverColor:"#f4f1ea",normalize:!0},liquidSignal:{...a.data,charsetFrames:r.signal,charsetFps:2.4,animationStyle:"melt",animationSpeed:.65,ditherStrength:.45,hoverEffect:"repel",hoverStrength:.55,hoverRadius:.22,hoverColor:"#8fd3ff",normalize:!0},cursorGravity:{...a.mesh,charsetFrames:r.angular,charsetFps:1.2,animationStyle:"orbit",animationSpeed:.9,ditherStrength:.2,hoverEffect:"attract",hoverStrength:.82,hoverRadius:.24,hoverColor:"#ffffff",normalize:!0},editorialPulse:{...a.humanist,charsetFrames:r.editorial,charsetFps:.9,animationStyle:"ripple",animationSpeed:.55,ditherStrength:.18,hoverEffect:"spotlight",hoverStrength:.35,hoverRadius:.2,hoverColor:"#fff8ea",normalize:!0},terminalFlow:{...a.prompt,charsetFrames:r.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}},s={fontSize:10,charSpacing:1,brightness:0,contrast:0,charset:n.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},c={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:"Ghost",options:{hoverStrength:.55,hoverEffect:"trail",hoverRadius:.2,hoverColor:"#b39ddb"}},glitchReveal:{label:"Glitch Reveal",options:{hoverStrength:.8,hoverEffect:"glitchText",hoverRadius:.18,hoverColor:"#a3e635"}}};function l(t,e){const o=document.createElement("canvas");o.width=t,o.height=e;const n=o.getContext("2d",{willReadFrequently:!0});return{canvas:o,ctx:n}}function h(t,e,o){let n=t+255*e;return n=259*(255*o+255)/(255*(259-255*o))*(n-128)+128,Math.max(0,Math.min(255,n))}function f(t,e,o){const n=o?1-t/255:t/255,r=[...e],a=Math.floor(n*(r.length-1));return r[Math.max(0,Math.min(r.length-1,a))]}function d(t,e,o,n,r,a){if((a?1-t/255:t/255)<.12)return" ";const i=[...e];return i[(n*r+o)%i.length]}var m=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];function u(t,e,o,n){if(n<=0)return t;const r=(m[o%4][e%4]/16-.5)*n*128;return Math.max(0,Math.min(255,t+r))}var g=new Array(256),M=new Array(256);for(let t=0;t<256;t++)g[t]=`rgb(${t},${t},${t})`,M[t]=`rgb(0,${t},0)`;function p(t,e,o,n,r,a=!1){switch(e){case"fullcolor":return`rgb(${t.r},${t.g},${t.b})`;case"matrix":return M[.299*t.r+.587*t.g+.114*t.b|0];case"accent":return`rgb(${o},${n},${r})`;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;return g[e]}}}var w=[0,0,0];function b(t,e,o,n,r,a=!1){switch(e){case"fullcolor":w[0]=t.r,w[1]=t.g,w[2]=t.b;break;case"matrix":{const e=.299*t.r+.587*t.g+.114*t.b|0;w[0]=0,w[1]=e,w[2]=0;break}case"accent":w[0]=o,w[1]=n,w[2]=r;break;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;w[0]=e,w[1]=e,w[2]=e;break}}return w}function v(t){const e=t.match(/rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)(?:\s*[,/]\s*([\d.]+))?\s*\)/);return e?{r:+e[1],g:+e[2],b:+e[3],a:void 0!==e[4]?+e[4]:1}:null}function x(t){let e=t;for(;e&&e!==document.documentElement.parentElement;){const t=getComputedStyle(e).backgroundColor;if(t&&"transparent"!==t&&"rgba(0, 0, 0, 0)"!==t){const e=v(t);if(e&&e.a>.1)return e}e=e.parentElement}return null}function y(t){if(t){const e=x(t);if(e){return(.299*e.r+.587*e.g+.114*e.b)/255<.4}}if("undefined"!=typeof document){const t=document.documentElement,e=(t.getAttribute("data-theme")||"").toLowerCase();if("dark"===e)return!0;if("light"===e)return!1;if(t.classList.contains("dark"))return!0;if(document.body){const t=x(document.body);if(t){return(.299*t.r+.587*t.g+.114*t.b)/255<.4}}}return"undefined"!=typeof window&&window.matchMedia("(prefers-color-scheme: dark)").matches}function S(t){if("string"!=typeof t)return t;const e=document.createElement("canvas");e.width=1,e.height=1;const o=e.getContext("2d");o.fillStyle=t,o.fillRect(0,0,1,1);const n=o.getImageData(0,0,1,1).data;return{r:n[0],g:n[1],b:n[2]}}function $(t,e,o,n,r,a,i){if("none"===a)return 1;const s=r*i;switch(a){case"wave":return.3+.7*(.6*(.5*Math.sin(t/o*Math.PI*4+3*s)+.5)+.4*(.5*Math.sin(e/n*Math.PI*3+2*s)+.5));case"pulse":{const r=o/2,a=n/2,i=Math.sqrt((t-r)**2+(e-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(e/n*Math.PI*8-5*s+.3*t)+.5)*(.3*Math.sin(t/o*Math.PI*2+s)+.7);case"breathe":{const o=.3*Math.sin(2*s)+.7,n=.1*Math.sin(.1*(t+e)+s);return Math.max(.1,Math.min(1,o+n))}case"sparkle":{const o=43758.5453*Math.sin(127.1*t+311.7*e+43758.5453*Math.floor(8*s)),n=o-Math.floor(o);return n>.7?1:.15+.4*n}case"glitch":{const t=Math.floor(e/(.05*n)),o=43758.5453*Math.sin(43.23*t+17.89*Math.floor(6*s));if(o-Math.floor(o)>.85){const e=.5*Math.sin(30*s+t)+.5;return e<.3?0:e}return 1}case"spiral":{const r=o/2,a=n/2,i=t-r,c=e-a,l=Math.atan2(c,i),h=Math.sqrt(i*i+c*c),f=Math.sqrt(r*r+a*a);return.15+.85*(.5*Math.sin(3*l+h/f*Math.PI*8-3*s)+.5)}case"typewriter":{const r=o*n,a=e*o+t-.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=o/2,a=n/2,i=t-r,c=e-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":default:return 1;case"ripple":{const r=o/2,a=n/2,i=t-r,c=e-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 o=e/n*Math.PI;return.05+(.5*Math.sin(o-1.8*s+.15*t)+.5)*(1-.6*(Math.max(0,e/n-.1)/.9))*.95}case"orbit":{const r=o/2,a=n/2,i=t-r,c=e-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 o=Math.floor(4*s),n=(t,e)=>{const n=43758.5453*Math.sin(127.1*t+311.7*e+43758.5453*o);return n-Math.floor(n)>.38?1:0},r=n(t,e),a=n(t-1,e)+n(t+1,e)+n(t,e-1)+n(t,e+1)+n(t-1,e-1)+n(t+1,e-1)+n(t-1,e+1)+n(t+1,e+1);return 1===(1===r?2===a||3===a?1:0:3===a?1:0)?1:.05}}}var C={scale:1,offsetX:0,offsetY:0,glow:0,colorBlend:0,proximity:0};function E(t,e,o,n,r,a,i,s,c="spotlight",l=.5,h="circle"){const f=t-o,d=e-n,m=.08+.35*l+.04*a;let u,g;if("box"===h){const t=Math.abs(f),e=Math.abs(d);u=Math.max(t,e),g=m}else u=Math.sqrt(f*f+d*d),g=m;if(u>=g)return C.scale=1,C.offsetX=0,C.offsetY=0,C.glow=0,C.colorBlend=0,C.proximity=0,C;const M=function(t){return t*t*(3-2*t)}(1-u/g)*r;let p=1,w=0,b=0,v=0,x=0;switch(c){case"spotlight":{p=1+M*a*1.8;const t=Math.atan2(d,f),e=M*M*a*.6;w=Math.cos(t)*e*i,b=Math.sin(t)*e*s,v=M*a*.4,x=M*M*a*.25;break}case"magnify":p=1+M*a*2.5,v=M*a*.15;break;case"repel":{p=1+M*a*.3;const t=Math.atan2(d,f),e=M*M*a*1.2;w=Math.cos(t)*e*i,b=Math.sin(t)*e*s;break}case"glow":v=M*a*.8,x=M*a*.4;break;case"colorShift":p=1+M*a*.4,v=M*a*.2,x=M*a*.7;break;case"attract":{const t=Math.atan2(d,f),e=M*M*a*1;w=-Math.cos(t)*e*i,b=-Math.sin(t)*e*s,v=M*a*.3;break}case"shatter":{const t=Math.atan2(d,f),e=.5*Math.sin(43.7*f+29.3*d),o=M*a*1.4*(.7+.3*e);w=Math.cos(t+e)*o*i,b=Math.sin(t+e)*o*s,p=Math.max(.1,1-M*a*.6),v=M*a*.25;break}case"trail":x=M*a*.9,v=M*a*.6,p=1+M*a*.15;break;case"glitchText":p=1,v=M*a*.5,x=M*a*.6}return C.scale=p,C.offsetX=w,C.offsetY=b,C.glow=v,C.colorBlend=x,C.proximity=M,C}function A(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 T(t){return t*t*t*(t*(6*t-15)+10)}function F(t,e,o){return t+(e-t)*o}function I(t,e){let o=127*t+311*e;return o^=o>>13,(o*(o*o*15731+789221)+1376312589&2147483647)/2147483647}function R(t,e){const o=Math.floor(t),n=Math.floor(e),r=e-n,a=T(t-o),i=T(r),s=I(o,n),c=I(o+1,n),l=I(o,n+1),h=I(o+1,n+1);return F(F(s,c,a),F(l,h,a),i)}function k(t,e){return(.5*R(t,e)+.25*R(2.1*t,2.1*e)+.125*R(4.3*t,4.3*e))/.875}function L(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=13,charAspect:s=.62,lineHeightRatio:c=1.4,chars:l=" .:-=+*#%@",baseColor:h=null,accentColor:f,accentThreshold:d=.52,mouseInfluence:m=.55,mouseFalloff:u=2.8,speed:g=1,vortex:M=!0,sparkles:p=!0,breathe:w=!0,lightMode:b=!1}=a,v=f??(b?"#6b8700":"#d4ff00"),x=i*s,y=i*c,S=Math.ceil(e/x),$=Math.ceil(o/y),C=r.x,E=r.y;let A=212,T=255,F=0;{const t=v.replace("#","");6===t.length&&(A=parseInt(t.slice(0,2),16),T=parseInt(t.slice(2,4),16),F=parseInt(t.slice(4,6),16))}t.clearRect(0,0,e,o),t.font=`${i}px "JetBrains Mono", monospace`,t.textBaseline="top";const R=n*g,L=w?.12*(.5*Math.sin(.22*R)+.5):0;for(let e=0;e<$;e++)for(let o=0;o<S;o++){const n=o/S,r=e/$,a=.045,i=.08*R,s=.06,c=.45*((.5*Math.sin(.08*o+.05*e+.6*R)+.5+(.5*Math.sin(.03*o-.07*e+.4*R)+.5)+(.5*Math.sin(.05*o+.03*e+.8*R)+.5))/3)+.35*(.5*k(o*a+i,e*a*1.4-.7*i)+.5)+.2*(.5*Math.sin((o+.65*e)*s+1.1*R)+.5)+L,f=n-C,g=r-E,w=Math.sqrt(f*f+g*g);let v=0;if(M&&w<.35){const t=Math.atan2(g,f),e=Math.sin(4*t+2.2*R-14*w),o=Math.max(0,1-w/.35);v=e*o*o*.22}const P=c*(1-m)+(Math.max(0,1-w*u)+.5*v)*m+.15*v,z=Math.min(1,Math.max(0,P));let q=z;if(p&&z>.72){const t=Math.floor(8*R),n=I(7*o+3*t,11*e+t);n>.88&&(q=Math.min(1,z+4*(n-.88)))}const B=Math.floor(q*(l.length-1));if(" "===l[B])continue;const j=.015+.07*q;if(q>d){const e=Math.min(b?.9:.28,j*(b?14:2.8));t.fillStyle=`rgba(${A},${T},${F},${e})`}else t.fillStyle=h?h.replace("{a}",String(j)):b?`rgba(55,55,55,${7*j})`:`rgba(255,255,255,${j})`;t.fillText(l[B],o*x,e*y)}}var P=new WeakMap,z=new WeakMap,q=null,B=null;function j(t,e){if(!q||!B){const o=l(t,e);q=o.canvas,B=o.ctx}return q.width!==t&&(q.width=t),q.height!==e&&(q.height=e),B}var H=new Map,W=new Map,O=new Map,D=new WeakMap,U=new WeakMap,N=new WeakMap;function V(t){let e=H.get(t);return e||(e=[...t],H.set(t,e)),e}function Y(t,e,o){const n=o?1-t/255:t/255,r=Math.floor(n*(e.length-1));return e[Math.max(0,Math.min(e.length-1,r))]??" "}function X(t,e,o,n){const r=`${t}\0${e?1:0}\0${o}\0${n}`;let a=W.get(r);if(!a){const i=V(t);a=new Array(256);for(let t=0;t<256;t++)a[t]=Y(h(t,o,n),i,e);W.set(r,a)}return a}function _(t){let e=O.get(t);if(!e){const o=V(t),n=Math.max(1,o.length);e=new Map;for(let t=0;t<o.length;t++)e.has(o[t])||e.set(o[t],Math.max(.08,(t+.5)/n));O.set(t,e)}return e}function J(){H.clear(),W.clear(),O.clear(),q=null,B=null}function K(t,e){return"auto"!==t?t:!y(e)}function G(t){const e=t.match(/^#([0-9a-fA-F]{3,6})$/);if(e){let t=e[1];if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return t}const o=t.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);return o?[o[1],o[2],o[3]].map(t=>parseInt(t).toString(16).padStart(2,"0")).join(""):null}function Q(t){const e=t||"auto";if("auto"!==e)return e.replace("#","");if("undefined"!=typeof document){const t=getComputedStyle(document.documentElement);for(const e of["--accent-color","--color-accent","--accent","--color-primary","--primary","--brand-color"]){const o=G(t.getPropertyValue(e).trim());if(o)return o}const e=G(getComputedStyle(document.body).accentColor??"");if(e)return e}return y("undefined"!=typeof document?document.body:null)?"faf9f7":"0d0d0d"}function Z(t,e,o){return Math.max(e,Math.min(o,t))}function tt(t,e,o){if(!t)return{x:0,y:0,width:e,height:o};const n=t.unit??"percent",r=!1!==t.preserveAspect,a=t=>void 0===t?void 0:"percent"===n?t*e:t,i=t=>void 0===t?void 0:"percent"===n?t*o:t,s=Z(a(t.left)??0,0,e-1),c=Z(a(t.right)??0,0,e-s-1),l=Z(i(t.top)??0,0,o-1),h=Z(i(t.bottom)??0,0,o-l-1),f=void 0!==t.left||void 0!==t.right||void 0!==t.top||void 0!==t.bottom,d=Math.max(1,e-s-c),m=Math.max(1,o-l-h),u=f?d:a(t.width),g=f?m:i(t.height);let M=u??e,p=g??o;if(r&&!f){const t=M/e,n=p/o,r=Math.min(t,n),a=void 0===u?n:void 0===g?t:r;M=e*a,p=o*a}M=Z(M,1,f?d:e),p=Z(p,1,f?m:o);const w=t.anchor??"center",b=a(t.x),v=i(t.y),x=f?s:0,y=f?l:0,S=f?d:e,$=f?m:o,C=w.endsWith("left")||"left"===w?0:w.endsWith("right")||"right"===w?S-M:(S-M)/2,E=w.startsWith("top")||"top"===w?0:w.startsWith("bottom")||"bottom"===w?$-p:($-p)/2;return{x:Z(b??x+C,0,Math.max(0,e-M)),y:Z(v??y+E,0,Math.max(0,o-p)),width:M,height:p}}function et(t,e,o,n){const r=t instanceof HTMLVideoElement?t.videoWidth:t.width,a=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(0===r||0===a)return{frame:[],cols:0,rows:0};const i=e.charAspect,s=e.fontSize*e.charSpacing,c=e.fontSize/i*e.charSpacing,l=o||r,f=n||a,m=Math.floor(l/s),g=Math.floor(f/c);if(m<=0||g<=0)return{frame:[],cols:0,rows:0};const M=tt(e.sourceCrop,r,a),p=Math.max(1,Math.min(Math.floor(2048/m),Math.floor(M.width/m))),w=Math.max(1,Math.min(Math.floor(2048/g),Math.floor(M.height/g))),b=m*p,v=g*w,x=j(b,v);x.drawImage(t,M.x,M.y,M.width,M.height,0,0,b,v);const y=x.getImageData(0,0,b,v).data,$=e.chromaKey,C=null!=$&&!1!==$,E=!0===$,A="blue-screen"===$;let T=null,F=0;!C||E||A||(T=S($),F=(e.chromaKeyTolerance??60)**2);let I=0,R=255;if(e.normalize){let t=255,e=0;for(let o=0;o<y.length;o+=4){if(C){const t=y[o],e=y[o+1],n=y[o+2];let r=!1;if(E)r=e>1.4*t&&e>1.4*n&&e>80;else if(A)r=n>1.4*t&&n>1.4*e&&n>80;else if(null!==T){const o=t-T.r,a=e-T.g,i=n-T.b;r=o*o+a*a+i*i<=F}if(r)continue}const n=.299*y[o]+.587*y[o+1]+.114*y[o+2];n<t&&(t=n),n>e&&(e=n)}I=t,R=e>t?e-t:255}const k=[],L=K(e.invert),P=C&&e.charset.replace(/ /g,"")||e.charset,z=V(P),q=e.customText?null:X(P,L,e.brightness,e.contrast),B=p*w;for(let t=0;t<g;t++){const o=[];for(let n=0;n<m;n++){let r=0,a=0,i=0,s=0,c=0;for(let e=0;e<w;e++){const o=(t*w+e)*b;for(let t=0;t<p;t++){const e=4*(o+n*p+t),l=y[e],h=y[e+1],f=y[e+2],d=y[e+3];if(C){let t=!1;if(E)t=h>1.4*l&&h>1.4*f&&h>80;else if(A)t=f>1.4*l&&f>1.4*h&&f>80;else if(null!==T){const e=l-T.r,o=h-T.g,n=f-T.b;t=e*e+o*o+n*n<=F}if(t){c++;continue}}r+=l,a+=h,i+=f,s+=d}}if(C&&c>B/2){o.push({char:" ",r:0,g:0,b:0,a:0});continue}const l=B-c,f=l>0?r/l:0,g=l>0?a/l:0,M=l>0?i/l:0,v=l>0?s/l:0,x=.299*f+.587*g+.114*M,S=e.normalize?(x-I)/R*255:x,$=h(S,e.brightness,e.contrast),k=e.ditherStrength>0?u($,n,t,e.ditherStrength):$,P=e.customText?d(k,e.customText,n,t,m,L):e.ditherStrength>0?Y(k,z,L):q[Math.max(0,Math.min(255,0|S))];o.push({char:P,r:f,g:g,b:M,a:v,lum:k})}k.push(o)}return{frame:k,cols:m,rows:g}}function ot(t,e,o,n){const r=t instanceof HTMLVideoElement?t.videoWidth:t.width,a=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(0===r||0===a)return{rows:[],cols:0,rowCount:0};const i=e.charAspect,s=e.fontSize*e.charSpacing,c=e.fontSize/i*e.charSpacing,l=o||r,f=n||a,d=Math.floor(l/s),m=Math.floor(f/c);if(d<=0||m<=0)return{rows:[],cols:0,rowCount:0};const g=d,M=m,p=j(g,M),w=tt(e.sourceCrop,r,a);p.drawImage(t,w.x,w.y,w.width,w.height,0,0,g,M);const b=p.getImageData(0,0,g,M).data,v=e.chromaKey,x=null!=v&&!1!==v,y=!0===v,$="blue-screen"===v;let C=null,E=0;!x||y||$||(C=S(v),E=(e.chromaKeyTolerance??60)**2);let A=0,T=255;if(e.normalize){let t=255,e=0;for(let o=0;o<b.length;o+=4){if(x){const t=b[o],e=b[o+1],n=b[o+2];let r=!1;if(y)r=e>1.4*t&&e>1.4*n&&e>80;else if($)r=n>1.4*t&&n>1.4*e&&n>80;else if(null!==C){const o=t-C.r,a=e-C.g,i=n-C.b;r=o*o+a*a+i*i<=E}if(r)continue}const n=.299*b[o]+.587*b[o+1]+.114*b[o+2];n<t&&(t=n),n>e&&(e=n)}A=t,T=e>t?e-t:255}const F=K(e.invert),I=x&&e.charset.replace(/ /g,"")||e.charset,R=V(I),k=e.customText?null:X(I,F,e.brightness,e.contrast),L=e.customText?V(e.customText):null,P="fullcolor"===e.colorMode?new Uint8ClampedArray(d*m*4):void 0,z=[];for(let t=0;t<m;t++){let o="";for(let n=0;n<d;n++){const r=4*(t*g+n),a=r,i=b[r],s=b[r+1],c=b[r+2],l=b[r+3];if(x){let t=!1;if(y)t=s>1.4*i&&s>1.4*c&&s>80;else if($)t=c>1.4*i&&c>1.4*s&&c>80;else if(null!==C){const e=i-C.r,o=s-C.g,n=c-C.b;t=e*e+o*o+n*n<=E}if(t){o+=" ",P&&(P[a]=0,P[a+1]=0,P[a+2]=0,P[a+3]=0);continue}}P&&(P[a]=i,P[a+1]=s,P[a+2]=c,P[a+3]=l);const f=.299*i+.587*s+.114*c,m=e.normalize?(f-A)/T*255:f,M=e.ditherStrength>0||L?h(m,e.brightness,e.contrast):m,p=e.ditherStrength>0?u(M,n,t,e.ditherStrength):M;if(L){o+=(F?1-p/255:p/255)<.12?" ":L[(t*d+n)%L.length]}else e.ditherStrength<=0?o+=k[Math.max(0,Math.min(255,0|m))]:o+=Y(p,R,F)}z.push(o)}return{rows:z,cols:d,rowCount:m,colors:P}}function nt(t,e,o,n,r){if(0===e.rows.length)return;const a=t.canvas,i=Boolean(o.chromaKey)||e.rows.some(t=>t.includes(" "));i||(N.delete(t),t.clearRect(0,0,n,r),t.fillStyle=y(a)?"#0a0a0a":"#faf9f7",t.fillRect(0,0,n,r));const s=Q(o.accentColor),c=parseInt(s.substring(0,2),16)||255,h=parseInt(s.substring(2,4),16)||255,f=parseInt(s.substring(4,6),16)||255,d=n/e.cols,m=r/e.rowCount,u=.9*Math.min(d/.55,m),g=e.colors;if("fullcolor"===o.colorMode&&g){if(N.delete(t),t.clearRect(0,0,n,r),u<6){const{canvas:a,ctx:i}=function(t,e,o){let n=D.get(t);n||(n=l(e,o).canvas,D.set(t,n)),n.width!==e&&(n.width=e),n.height!==o&&(n.height=o);const r=n.getContext("2d",{willReadFrequently:!1});if(!r)throw new Error("renderTextFrameToCanvas: could not create raster context.");return{canvas:n,ctx:r}}(t,e.cols,e.rowCount);let s=U.get(i);s&&s.width===e.cols&&s.height===e.rowCount||(s={width:e.cols,height:e.rowCount,imageData:i.createImageData(e.cols,e.rowCount)},U.set(i,s));const c=s.imageData,h=c.data;h.fill(0);const f=_(o.charset);for(let t=0;t<e.rowCount;t++){const o=e.rows[t];for(let n=0;n<e.cols;n++){const r=o[n];if(" "===r)continue;const a=4*(t*e.cols+n),i=g[a+3];if(i<10)continue;const s=f.get(r)??.5;h[a]=g[a],h[a+1]=g[a+1],h[a+2]=g[a+2],h[a+3]=0|Math.min(255,i*s)}}return i.putImageData(c,0,0),t.imageSmoothingEnabled=!1,t.drawImage(a,0,0,n,r),t.imageSmoothingEnabled=!0,void(t.globalAlpha=1)}t.font=`${u}px "JetBrains Mono", monospace`,t.textAlign="left",t.textBaseline="middle",t.globalAlpha=1;let a="";for(let o=0;o<e.rows.length;o++){const n=e.rows[o];let r=0;for(;r<e.cols;){for(;r<e.cols&&" "===n[r];)r++;if(r>=e.cols)break;const i=r,s=4*(o*e.cols+r),c=240&g[s],l=240&g[s+1],h=240&g[s+2];for(r++;r<e.cols&&" "!==n[r];){const t=4*(o*e.cols+r);if((240&g[t])!==c||(240&g[t+1])!==l||(240&g[t+2])!==h)break;r++}const f=`rgb(${c},${l},${h})`;f!==a&&(t.fillStyle=f,a=f),t.fillText(n.slice(i,r),i*d+.5*d,o*m+.5*m)}}return void(t.globalAlpha=1)}t.font=`${u}px "JetBrains Mono", monospace`,t.textAlign="left",t.textBaseline="middle";const M="matrix"===o.colorMode?"rgb(0,255,0)":"grayscale"===o.colorMode?y(a)?"rgb(230,230,230)":"rgb(24,24,24)":`rgb(${c},${h},${f})`;t.fillStyle=M,t.globalAlpha=1;const p=N.get(t),w=i&&p&&p.cols===e.cols&&p.rowCount===e.rowCount&&p.canvasWidth===n&&p.canvasHeight===r&&p.fillStyle===M;w||t.clearRect(0,0,n,r);for(let o=0;o<e.rows.length;o++){const r=e.rows[o];w&&p.rows[o]===r||(w&&t.clearRect(0,o*m,n,m+1),0!==r.trim().length&&t.fillText(r,.5*d,o*m+.5*m))}N.set(t,{rows:e.rows.slice(),cols:e.cols,rowCount:e.rowCount,canvasWidth:n,canvasHeight:r,fillStyle:M}),t.globalAlpha=1}async function rt(t,e,o,n,r=12,a=10,i,s=0){const c=Math.min(t.duration-s,a),l=Math.ceil(c*r),h=[];let f=0,d=0;for(let a=0;a<l;a++){const m=s+a/r;if(m>s+c)break;t.currentTime=m,await new Promise(e=>{const o=()=>{t.removeEventListener("seeked",o),e()};t.addEventListener("seeked",o)});const u=et(t,e,o,n);h.push(u.frame),f=u.cols,d=u.rows,i?.((a+1)/l)}return{frames:h,cols:f,rows:d,fps:r}}async function at(t,e,o,n,r=12,a=10,i,s=0){const c=Math.min(t.duration-s,a),l=Math.ceil(c*r),h=[];let f=0,d=0;for(let a=0;a<l;a++){const m=s+a/r;if(m>s+c)break;t.currentTime=m,await new Promise(e=>{const o=()=>{t.removeEventListener("seeked",o),e()};t.addEventListener("seeked",o)});const u=ot(t,e,o,n);h.push(u),f=u.cols,d=u.rowCount,i?.((a+1)/l)}return{frames:h,cols:f,rows:d,fps:r}}async function it(o,n,r,a,i){const s=t(o),c=e(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,f=s.lsd?.width||l,d=s.lsd?.height||h,m=document.createElement("canvas");m.width=f,m.height=d;const u=m.getContext("2d"),g=document.createElement("canvas");g.width=f,g.height=d;const M=g.getContext("2d"),p=document.createElement("canvas"),w=p.getContext("2d"),b=[];let v=0,x=0,y=0;for(const t of c)y+=t.delay||100;const S=y/c.length,$=Math.round(Math.min(30,Math.max(5,1e3/S))),C=Math.min(c.length,300);for(let t=0;t<C;t++){const e=c[t],{dims:o,patch:s,disposalType:l}=e;3===l&&(M.clearRect(0,0,f,d),M.drawImage(m,0,0)),p.width!==o.width&&(p.width=o.width),p.height!==o.height&&(p.height=o.height);const h=new ImageData(new Uint8ClampedArray(s.buffer),o.width,o.height);w.putImageData(h,0,0),u.drawImage(p,o.left||0,o.top||0);const y=et(m,n,r,a);b.push(y.frame),v=y.cols,x=y.rows,2===l?u.clearRect(o.left||0,o.top||0,o.width,o.height):3===l&&(u.clearRect(0,0,f,d),u.drawImage(g,0,0)),i?.((t+1)/C)}return{frames:b,cols:v,rows:x,fps:$}}async function st(o,n,r,a,i){const s=t(o),c=e(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,f=s.lsd?.width||l,d=s.lsd?.height||h,m=document.createElement("canvas");m.width=f,m.height=d;const u=m.getContext("2d"),g=document.createElement("canvas");g.width=f,g.height=d;const M=g.getContext("2d"),p=document.createElement("canvas"),w=p.getContext("2d"),b=[];let v=0,x=0,y=0;for(const t of c)y+=t.delay||100;const S=y/c.length,$=Math.round(Math.min(30,Math.max(5,1e3/S))),C=Math.min(c.length,300);for(let t=0;t<C;t++){const e=c[t],{dims:o,patch:s,disposalType:l}=e;3===l&&(M.clearRect(0,0,f,d),M.drawImage(m,0,0)),p.width!==o.width&&(p.width=o.width),p.height!==o.height&&(p.height=o.height);const h=new ImageData(new Uint8ClampedArray(s.buffer),o.width,o.height);w.putImageData(h,0,0),u.drawImage(p,o.left||0,o.top||0);const y=ot(m,n,r,a);b.push(y),v=y.cols,x=y.rowCount,2===l?u.clearRect(o.left||0,o.top||0,o.width,o.height):3===l&&(u.clearRect(0,0,f,d),u.drawImage(g,0,0)),i?.((t+1)/C)}return{frames:b,cols:v,rows:x,fps:$}}function ct(t,e,o,n,r,a=0,i){if("waveField"===o.animationStyle){return void L(t,n,r,a,i?{x:i.x,y:i.y}:{x:.5,y:.5},{accentColor:`#${o.accentColor?Q(o.accentColor):"d4ff00"}`,accentThreshold:.52,mouseInfluence:o.hoverStrength>0?Math.min(1,.3+.5*o.hoverStrength):.55,mouseFalloff:2.8,speed:o.animationSpeed,vortex:o.hoverStrength>0,sparkles:!0,breathe:!0})}const s=e.length;if(0===s)return;const c=e[0].length;t.clearRect(0,0,n,r);let h=!1;const d=Math.max(1,s>>2),m=Math.max(1,c>>2);t:for(let t=0;t<s;t+=d){const o=e[t];for(let t=0;t<c;t+=m)if(o[t].a<200){h=!0;break t}}const u=t.canvas,g=y(u);h||(t.fillStyle=g?"#0a0a0a":"#faf9f7",t.fillRect(0,0,n,r));const M=n/c,w=r/s,v=s*c,x=i?.intensity??1,S=!("none"!==o.animationStyle&&v>5e3)&&!!(i&&o.hoverStrength>0&&x>.005),C=o.hoverColor||"#ffffff",A=parseInt(C.slice(1,3),16)||255,T=parseInt(C.slice(3,5),16)||255,F=parseInt(C.slice(5,7),16)||255,I=Q(o.accentColor),R=parseInt(I.substring(0,2),16)||255,k=parseInt(I.substring(2,4),16)||255,q=parseInt(I.substring(4,6),16)||255,B=v>3e4?.25:v>15e3?.4:v>5e3?.6:1,j=o.hoverRadius*B;let H=0,W=c,O=0,D=s,U=0,N=0;if(S&&i){U=i.x,N=i.y;const t=.08+.35*j+.04*o.hoverStrength;H=Math.max(0,Math.floor((U-t)*c)-1),W=Math.min(c,Math.ceil((U+t)*c)+1),O=Math.max(0,Math.floor((N-t)*s)-1),D=Math.min(s,Math.ceil((N+t)*s)+1)}const V=o.animationStyle,Y=o.animationSpeed,X="none"===V,J=o.hoverStrength,G=o.hoverEffect,Z=j,tt=o.hoverShape||"circle",et=K(o.invert,u),ot=o.colorMode,nt=2*Math.PI,rt=1/c,at=1/s;let it="",st=-1;if("dots"===o.renderMode){const n=.5*Math.min(M,w)*o.dotSizeRatio;for(let o=0;o<s;o++){const r=e[o];for(let e=0;e<c;e++){const i=r[e];if(i.a<10)continue;const l=.00392156863*(.299*i.r+.587*i.g+.114*i.b),h=et?1-l:l;if(h<.02)continue;const f=X?1:$(e,o,c,s,a,V,Y);let d=1,m=0,u=0,g=0,v=0;if(S&&e>=H&&e<=W&&o>=O&&o<=D){const t=E(e*rt,o*at,U,N,x,J,M,w,G,Z,tt);d=t.scale,m=t.offsetX,u=t.offsetY,g=t.glow,v=t.colorBlend}const y=n*h*f*d;if(y<.3)continue;const C=e*M+.5*M+m,I=o*w+.5*w+u;let L;if(v>0){const t=b(i,ot,R,k,q,et);L=`rgb(${Math.min(255,t[0]+(A-t[0])*v|0)},${Math.min(255,t[1]+(T-t[1])*v|0)},${Math.min(255,t[2]+(F-t[2])*v|0)})`}else L=p(i,ot,R,k,q,et);const P=Math.min(1,.00392156863*i.a*f*(1+g));if(P!==st&&(t.globalAlpha=P,st=P),L!==it&&(t.fillStyle=L,it=L),y<=3){const e=2*y;t.fillRect(C-y,I-y,e,e)}else t.beginPath(),t.arc(C,I,y,0,nt),t.fill()}}}else{const i=.55,h=.9*Math.min(M/i,w),d=h<6;if(!d){const e="emoji"===o.artStyle;t.font=e?`${h}px "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif`:`${h}px "JetBrains Mono", monospace`,t.textAlign="center",t.textBaseline="middle"}const m=o.charsetFrames,u=!!m?.length,g=u?m[Math.floor(Math.max(0,a)*(o.charsetFps??2))%m.length]:o.charset;if(d){const{canvas:o,ctx:a}=function(t,e,o){let n=P.get(t);n||(n=l(e,o).canvas,P.set(t,n)),n.width!==e&&(n.width=e),n.height!==o&&(n.height=o);const r=n.getContext("2d",{willReadFrequently:!1});if(!r)throw new Error("renderFrameToCanvas: could not create raster context.");return{canvas:n,ctx:r}}(t,c,s);let i=z.get(a);i&&i.width===c&&i.height===s||(i={width:c,height:s,imageData:a.createImageData(c,s)},z.set(a,i));const h=i.imageData,d=h.data;d.fill(0);const m=_(g);for(let t=0;t<s;t++){const o=e[t];for(let e=0;e<c;e++){const n=o[e],r=4*(t*c+e);if(n.a<10)continue;const a=u&&null!=n.lum?f(n.lum,g,et):n.char;if(" "===a)continue;let i,s,l,h=m.get(a)??.5,p=0,v=0;if(S&&e>=H&&e<=W&&t>=O&&t<=D){const o=E(e*rt,t*at,U,N,x,J,M,w,G,Z,tt);h*=o.scale,p=o.glow,v=o.colorBlend}if(v>0){const t=b(n,ot,R,k,q,et);i=Math.min(255,t[0]+(A-t[0])*v|0),s=Math.min(255,t[1]+(T-t[1])*v|0),l=Math.min(255,t[2]+(F-t[2])*v|0)}else{const t=b(n,ot,R,k,q,et);i=t[0],s=t[1],l=t[2]}const y=Math.min(255,Math.max(0,n.a*h*(1+p)));d[r]=i,d[r+1]=s,d[r+2]=l,d[r+3]=y}}return a.putImageData(h,0,0),t.imageSmoothingEnabled=!1,t.drawImage(o,0,0,n,r),t.imageSmoothingEnabled=!0,void(t.globalAlpha=1)}const v=d?null:t.getTransform();if(!d&&!S&&X&&!u&&"accent"===ot){t.fillStyle=`rgb(${R},${k},${q})`,t.globalAlpha=1,t.textAlign="left";for(let o=0;o<s;o++){const n=e[o];let r="";for(let t=0;t<c;t++){const e=n[t];r+=e.a<10?" ":e.char}0!==r.trim().length&&t.fillText(r,.5*M,o*w+.5*w)}return void(t.globalAlpha=1)}const y="glitchText"===G&&S,C="!@#$%^&*<>{}[]|/\\~`0123456789",I=C.length;let L="",B=0,K=0,Q=0,nt=0,ct=0,lt=0;if(y){const t=o.hoverText??"ASCIIFY";if(K=Math.round(U*c),Q=Math.round(N*s),Array.isArray(t)){const e=t.filter(t=>t.length>0);0===e.length&&e.push("ASCIIFY");L=e[((7*Math.floor(K/Math.max(1,Math.ceil(c/5)))+13*Math.floor(Q/Math.max(1,Math.ceil(s/3))))%e.length+e.length)%e.length]}else L=t||"ASCIIFY";B=L.length,nt=Math.max(3,Math.min(12,Math.round(s*j*.6)));const e=Math.floor(nt/2);ct=Math.max(0,Q-e),ct+nt>s&&(ct=Math.max(0,s-nt)),lt=K-Math.floor(B/2)}for(let o=0;o<s;o++){const n=e[o];for(let e=0;e<c;e++){const r=n[e];if(r.a<10)continue;let i=u&&null!=r.lum?f(r.lum,g,et):r.char;if(" "===i)continue;const l=X?1:$(e,o,c,s,a,V,Y);if(l<.05)continue;let h=1,d=0,m=0,P=0,z=0;if(S&&!y&&e>=H&&e<=W&&o>=O&&o<=D){const t=E(e*rt,o*at,U,N,x,J,M,w,G,Z,tt);h=t.scale,d=t.offsetX,m=t.offsetY,P=t.glow,z=t.colorBlend}if(y&&o>=ct&&o<ct+nt){const t=e-lt;if(t>=0&&t<B){const n=L[t],r=Math.abs(o-Q)/Math.max(1,.5*nt),s=Math.abs(e-K)/Math.max(1,B),c=Math.max(r,s),l=Math.max(0,Math.min(1,1-.9*c)),h=43758.5453*Math.sin(127.1*e+311.7*o+43758.5453*Math.floor(12*a));i=Math.abs(h-Math.floor(h))<l?n:C[Math.abs(Math.floor(97*h))%I],P=.3+.7*l,z=.3+.65*l}}const j=e*M+.5*M+d,_=o*w+.5*w+m;let ht;if(z>0){const t=b(r,ot,R,k,q,et);ht=`rgb(${Math.min(255,t[0]+(A-t[0])*z|0)},${Math.min(255,t[1]+(T-t[1])*z|0)},${Math.min(255,t[2]+(F-t[2])*z|0)})`}else ht=p(r,ot,R,k,q,et);const ft=Math.min(1,.00392156863*r.a*l*(1+P));ft!==st&&(t.globalAlpha=ft,st=ft),ht!==it&&(t.fillStyle=ht,it=ht),1!==h?(t.translate(j,_),t.scale(h,h),t.fillText(i,0,0),t.setTransform(v)):t.fillText(i,j,_)}}}t.globalAlpha=1}function lt(t){return Math.max(0,Math.min(1,t))}function ht(t){return"string"==typeof t?document.querySelector(t):t instanceof HTMLElement?t:null}function ft(t){return"ascii"===t.renderMode&&"none"===t.animationStyle&&t.hoverStrength<=0&&!t.charsetFrames?.length}function dt(t,e={}){const o=lt(t),n=lt(o*(void 0===e.speed?1:Math.max(.001,e.speed)));return lt(e.ease?e.ease(n):n)}function mt(t,e,o={}){if(!Number.isFinite(t.duration)||t.duration<=0)return;const n=o.from??0,r=o.to??t.duration,a=Math.max(n,Math.min(r,t.duration)),i=dt(e,o),s=n+(a-n)*i;t.currentTime=Math.min(Math.max(n,s),Math.max(n,a-.04)),o.onUpdate?.(i,t)}function ut(t){const e=t.requestVideoFrameCallback;return new Promise(e?o=>{let n=!1;const r=()=>{n||(n=!0,o())};e.call(t,r),window.setTimeout(r,32)}:t=>requestAnimationFrame(()=>t()))}function gt(t,e={}){const o=ht(e.trigger)??t;t.pause();const n=e.gsap,r=e.ScrollTrigger??n?.ScrollTrigger;if(n&&r?.create){n.registerPlugin?.(r);const a=r.create({trigger:o,start:e.start??"top bottom",end:e.end??"bottom top",scrub:e.scrub??!0,onUpdate:o=>mt(t,o.progress,e)});return()=>a.kill?.()}return function(t,e,o){let n=0;const r=()=>{n=0;const r=e.getBoundingClientRect(),a=window.innerHeight||document.documentElement.clientHeight,i=r.height+a,s=i>0?lt((a-r.top)/i):0;mt(t,s,o)},a=()=>{n||(n=requestAnimationFrame(r))};return window.addEventListener("scroll",a,{passive:!0}),window.addEventListener("resize",a),a(),()=>{window.removeEventListener("scroll",a),window.removeEventListener("resize",a),n&&cancelAnimationFrame(n)}}(t,o,e)}function Mt(t,e,o){const n=e.gsap,r=e.ScrollTrigger??n?.ScrollTrigger;if(n&&r?.create){n.registerPlugin?.(r);const a=r.create({trigger:t,start:e.start??"top bottom",end:e.end??"bottom top",scrub:e.scrub??!0,onUpdate:t=>o(t.progress)});return()=>a.kill?.()}return function(t,e){let o=0;const n=()=>{o=0;const n=t.getBoundingClientRect(),r=window.innerHeight||document.documentElement.clientHeight,a=n.height+r,i=a>0?lt((r-n.top)/a):0;e(i)},r=()=>{o||(o=requestAnimationFrame(n))};return window.addEventListener("scroll",r,{passive:!0}),window.addEventListener("resize",r),r(),()=>{window.removeEventListener("scroll",r),window.removeEventListener("resize",r),o&&cancelAnimationFrame(o)}}(t,o)}function pt(t,e,o){if(!t||!e||!o.sourceCrop)return{w:t,h:e};const n=tt(o.sourceCrop,t,e);return{w:Math.max(1,Math.round(n.width)),h:Math.max(1,Math.round(n.height))}}function wt(t,e,o=2048){const n=o,r=Math.min(1,n/Math.max(t,e));return{renderW:Math.round(t*r),renderH:Math.round(e*r)}}function bt(t,e,o){if(void 0===t)return;if("number"==typeof t)return t;const n=t.trim();if(n.endsWith("%")){const t=Number.parseFloat(n)/100;return Number.isFinite(t)?e*t:void 0}if(n.endsWith("px")){const t=Number.parseFloat(n);return Number.isFinite(t)?t:void 0}if(n.endsWith("vw")){const t=Number.parseFloat(n)/100;return Number.isFinite(t)?o*t:void 0}}function vt(t,e,o,n,r,a=2048,i={}){const{width:s,height:c}=e.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,f=bt(i.width,s,l)??s,d=bt(i.height,c,h)??c,{cssW:m,cssH:u}=function(t,e,o,n="contain"){if("fill"===n)return{cssW:t,cssH:e};let r=t,a=r/o;const i="cover"===n,s=a>e;return(i&&!s||!i&&s)&&(a=e,r=a*o),"scale-down"===n&&(r=Math.min(r,t),a=Math.min(a,e)),{cssW:Math.round(r),cssH:Math.round(a)}}(f,d,o,i.objectFit??"contain");let g,M;n&&r?({renderW:g,renderH:M}=wt(n,r,a)):(g=m,M=u);const p="undefined"!=typeof window&&window.devicePixelRatio||1,w=8e6,b=g*p*M*p>w?Math.sqrt(w/(g*M)):p;return t.width=Math.round(g*b),t.height=Math.round(M*b),t.style.width=`${m}px`,t.style.height=`${u}px`,{renderW:g,renderH:M,dpr:b}}async function xt(t,e,{fontSize:o,artStyle:n="classic",options:r={}}={}){let i;if("string"==typeof t){const e=new Image;e.crossOrigin="anonymous",await new Promise((o,n)=>{e.onload=()=>o(),e.onerror=()=>n(new Error(`Failed to load image: ${t}`)),e.src=t}),i=e}else t instanceof HTMLImageElement&&!t.complete?(await new Promise((e,o)=>{t.onload=()=>e(),t.onerror=()=>o(new Error("Image failed to load"))}),i=t):i=t;const c=a[n],l=o??r.fontSize??10,h={...s,...c,...r,fontSize:l},f=e.getContext("2d");if(!f)throw new Error("Could not get 2d context from canvas");const{w:d,h:m}=function(t){return t instanceof HTMLVideoElement?{w:t.videoWidth,h:t.videoHeight}:t instanceof HTMLImageElement?{w:t.naturalWidth||t.width,h:t.naturalHeight||t.height}:{w:t.width,h:t.height}}(i),{renderW:u,renderH:g}=wt(d,m),M="undefined"!=typeof window&&window.devicePixelRatio||1,p=8e6,w=u*M*g*M>p?Math.sqrt(p/(u*g)):M;if((e.width<u||e.height<g)&&(e.width=Math.round(u*w),e.height=Math.round(g*w)),h.hoverStrength>0){const{frame:t}=et(i,h,u,g);let o=null,n=!1,r=0;const a=t=>{const n=e.getBoundingClientRect();o={x:(t.clientX-n.left)/n.width,y:(t.clientY-n.top)/n.height}},s=()=>{o=null};e.addEventListener("mousemove",a),e.addEventListener("mouseleave",s);const c=e=>{n||(f.save(),f.setTransform(w,0,0,w,0,0),ct(f,t,h,u,g,e/1e3,o),f.restore(),r=requestAnimationFrame(c))};return r=requestAnimationFrame(c),()=>{n=!0,cancelAnimationFrame(r),e.removeEventListener("mousemove",a),e.removeEventListener("mouseleave",s)}}if(f.save(),f.setTransform(w,0,0,w,0,0),ft(h)){const t=ot(i,h,u,g);nt(f,t,h,u,g)}else{const{frame:t}=et(i,h,u,g);ct(f,t,h,u,g)}f.restore()}async function yt(t,e,{fontSize:o,artStyle:n="classic",options:r={}}={}){const i="string"==typeof t?await fetch(t).then(t=>t.arrayBuffer()):t,c=o??r.fontSize??10,l={...s,...a[n],...r,fontSize:c},h=e.getContext("2d");if(!h)throw new Error("Could not get 2d context from canvas");if(ft(l)){const{frames:t,fps:o}=await st(i,l,e.width,e.height);let n,r=!1,a=0,s=performance.now();const c=1e3/o,f=o=>{r||(o-s>=c&&(nt(h,t[a],l,e.width,e.height),a=(a+1)%t.length,s=o),n=requestAnimationFrame(f))};return n=requestAnimationFrame(f),()=>{r=!0,cancelAnimationFrame(n)}}const{frames:f,fps:d}=await it(i,l,e.width,e.height);let m,u=!1,g=0,M=performance.now();const p=1e3/d,w=t=>{u||(t-M>=p&&(ct(h,f[g],l,e.width,e.height),g=(g+1)%f.length,M=t),m=requestAnimationFrame(w))};return m=requestAnimationFrame(w),()=>{u=!0,cancelAnimationFrame(m)}}async function St(t,e,{fontSize:o,artStyle:n="classic",options:r={},fitTo:i,objectFit:c,objectPosition:l,scale:h,width:f,height:d,preExtract:m=!1,fps:u,maxRenderDimension:g=2048,trim:M,scroll:p,maxCachedFrames:w=90,onReady:b,onFrame:v}={}){const x=M?.start??0,y=M?.end,S=o??r.fontSize??10,$={...s,...a[n],...r,fontSize:S},C=e.getContext("2d");if(!C)throw new Error("asciifyVideo: could not get 2d context from canvas.");const E="string"==typeof i?document.querySelector(i):i instanceof HTMLElement?i:null,A={objectFit:c,objectPosition:l,scale:h,width:f,height:d},T=function(t,e){var o;if(!function(t){return void 0!==t.objectFit||void 0!==t.objectPosition||void 0!==t.scale||void 0!==t.width||void 0!==t.height}(e))return()=>{};const n={width:t.style.width,height:t.style.height,objectFit:t.style.objectFit,objectPosition:t.style.objectPosition,maxWidth:t.style.maxWidth,maxHeight:t.style.maxHeight,transformOrigin:t.style.transformOrigin,scale:t.style.getPropertyValue("scale")};if(e.objectFit&&(t.style.objectFit=e.objectFit),e.objectPosition&&(t.style.objectPosition=e.objectPosition,t.style.transformOrigin=e.objectPosition),void 0!==e.scale){const n=Number.isFinite(e.scale)&&e.scale>0?e.scale:1;t.style.setProperty("scale",String(n)),t.style.maxWidth="none",t.style.maxHeight="none",(o=t.style).transformOrigin||(o.transformOrigin=e.objectPosition??"center center")}return()=>{t.style.width=n.width,t.style.height=n.height,t.style.objectFit=n.objectFit,t.style.objectPosition=n.objectPosition,t.style.maxWidth=n.maxWidth,t.style.maxHeight=n.maxHeight,t.style.transformOrigin=n.transformOrigin,n.scale?t.style.setProperty("scale",n.scale):t.style.removeProperty("scale")}}(e,A),F=t=>()=>{t(),T()};if(m){let o;"string"==typeof t?(o=document.createElement("video"),o.crossOrigin="anonymous",o.src=t,o.readyState<2&&await new Promise((e,n)=>{o.onloadeddata=()=>e(),o.onerror=()=>n(new Error(`asciifyVideo: failed to load "${t}"`))})):o=t;const n=pt(o.videoWidth,o.videoHeight,$);E&&vt(e,E,n.w/n.h,n.w,n.h,g,A);const{renderW:r,renderH:a}=wt(n.w,n.h,g),i="undefined"!=typeof window&&window.devicePixelRatio||1,s=8e6,c=r*i*a*i>s?Math.sqrt(s/(r*a)):i;e.width<Math.round(r*c)&&(e.width=Math.round(r*c),e.height=Math.round(a*c));const l=void 0!==y?y-x:10,h=u??(p?18:void 0);if(ft($)){const{frames:t,fps:n}=await at(o,$,r,a,h,l,void 0,x),i=e=>{const o=t[e];o&&(C.save(),C.setTransform(c,0,0,c,0,0),nt(C,o,$,r,a),C.restore(),v?.())};if(p){let n=!1,r=-1;const a=!0===p?{}:p,s=Mt(ht(a.trigger)??E??e,a,e=>{const s=dt(e,a),c=Math.max(0,Math.min(t.length-1,Math.round(s*(t.length-1))));c!==r&&(r=c,i(c),n||(n=!0,b?.(o)),a.onUpdate?.(s,o))});return i(0),n=!0,b?.(o),F(s)}let s,f=!1,d=0,m=performance.now(),u=!0;const g=1e3/n,M=e=>{f||(e-m>=g&&(i(d),d=(d+1)%t.length,m=e,u&&(u=!1,b?.(o))),s=requestAnimationFrame(M))};return s=requestAnimationFrame(M),F(()=>{f=!0,cancelAnimationFrame(s)})}const{frames:f,fps:d}=await rt(o,$,r,a,h,l,void 0,x),m=t=>{const e=f[t];e&&(C.save(),C.setTransform(c,0,0,c,0,0),ct(C,e,$,r,a),C.restore(),v?.())};if(p){let t=!1,n=-1;const r=!0===p?{}:p,a=Mt(ht(r.trigger)??E??e,r,e=>{const a=dt(e,r),i=Math.max(0,Math.min(f.length-1,Math.round(a*(f.length-1))));i!==n&&(n=i,m(i),t||(t=!0,b?.(o)),r.onUpdate?.(a,o))});return m(0),t=!0,b?.(o),F(a)}let M,w=!1,S=0,T=performance.now(),I=!0;const R=1e3/d,k=t=>{w||(t-T>=R&&(m(S),S=(S+1)%f.length,T=t,I&&(I=!1,b?.(o))),M=requestAnimationFrame(k))};return M=requestAnimationFrame(k),F(()=>{w=!0,cancelAnimationFrame(M)})}let I,R=!1;"string"==typeof t?(I=document.createElement("video"),I.src=t,I.muted=!0,I.loop=!0,I.playsInline=!0,I.setAttribute("playsinline",""),Object.assign(I.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(I),R=!0,await new Promise((e,o)=>{I.onloadedmetadata=()=>e(),I.onerror=()=>o(new Error(`asciifyVideo: failed to load "${t}"`))}),await I.play().catch(()=>{})):(I=t,I.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((t,e)=>{const o=()=>{I.removeEventListener("loadedmetadata",n),I.removeEventListener("error",r)},n=()=>{o(),t()},r=()=>{o(),e(new Error("asciifyVideo: provided video element failed to load metadata."))};I.addEventListener("loadedmetadata",n),I.addEventListener("error",r),I.load()}),I.paused&&await I.play().catch(()=>{})),x>0&&(I.currentTime=x,await new Promise(t=>{const e=()=>{I.removeEventListener("seeked",e),t()};I.addEventListener("seeked",e)}),await ut(I));let k=null;(x>0||void 0!==y)&&(k=()=>{(void 0!==y&&I.currentTime>=y||x>0&&I.currentTime<x)&&(I.currentTime=x)},I.addEventListener("timeupdate",k));let L=null;const P=pt(I.videoWidth,I.videoHeight,$),{renderW:z,renderH:q}=wt(P.w,P.h,g);if(E){const t=P.w/P.h,o=P.w,n=P.h,r=vt(e,E,t,o,n,g,A),a=e.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0),L=new ResizeObserver(()=>{const r=vt(e,E,t,o,n,g,A),a=e.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0)}),L.observe(E)}else{const t="undefined"!=typeof window&&window.devicePixelRatio||1,o=8e6,n=z*t*q*t>o?Math.sqrt(o/(z*q)):t;e.width<Math.round(z*n)&&(e.width=Math.round(z*n),e.height=Math.round(q*n)),C.setTransform(n,0,0,n,0,0)}let B,j=!1,H=!0,W=null;const O=p&&!m,D=u&&u>0?1e3/u:0;let U=0,N=-1;const V=!O&&ft($);if(O&&"ascii"===$.renderMode&&"none"===$.animationStyle&&$.hoverStrength<=0&&!$.charsetFrames?.length){const t=!0===p?{}:p,o=ht(t.trigger)??E??e,n=t.from??x,r=t.to??y??I.duration,a=Math.max(n,Math.min(r,I.duration)),i=Math.max(.001,a-n),s=Math.min(60,Math.max(12,u??30)),c=Math.max(2,Math.ceil(i*s)+1),l=new Array(c),h=[],f=Math.max(2,Math.min(c,Math.floor(w))),d=t=>{const e=h.indexOf(t);for(e>=0&&h.splice(e,1),h.push(t);h.length>f;){const t=h.shift();void 0!==t&&t!==m&&Math.abs(t-m)>2&&(l[t]=void 0)}};let m=0,g=0,M=-1,S=0,A=!1,T=!1,P=!1;const B=new Set,j=document.createElement("video");j.muted=!0,j.playsInline=!0,j.preload="auto",j.crossOrigin=I.crossOrigin||"anonymous",j.src=I.currentSrc||I.src,Object.assign(j.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(j),j.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((t,e)=>{const o=()=>{j.removeEventListener("loadedmetadata",n),j.removeEventListener("error",r)},n=()=>{o(),t()},r=()=>{o(),e(new Error("asciifyVideo: cache video failed to load metadata."))};j.addEventListener("loadedmetadata",n),j.addEventListener("error",r),j.load()}),j.pause(),I.paused&&await I.play().catch(()=>{});const H=t=>n+i*t/Math.max(1,c-1),O=t=>Math.max(0,Math.min(c-1,Math.round(t*(c-1)))),N=ot(I,$,z,q);N.rows.length>0&&(l[0]=N,d(0),nt(C,N,$,z,q),P=!0,b?.(I),v?.());const V=t=>{if(l[t])return t;for(let e=1;e<c;e++){const o=t-e,n=t+e;if(o>=0&&l[o])return o;if(n<c&&l[n])return n}return-1},Y=()=>{if(!l[m])return m;for(const t of B)if(!l[t])return t;for(let t=1;t<c;t++){const e=m-t,o=m+t;if(e>=0&&!l[e])return e;if(o<c&&!l[o])return o}return-1},X=t=>{t<0||t>=c||l[t]||(B.add(t),_())},_=async()=>{if(A||T)return;const t=Y();if(!(t<0)){B.delete(t),T=!0;try{if(await function(t,e){return Math.abs(t.currentTime-e)<1/240?ut(t):new Promise(o=>{const n=()=>{t.removeEventListener("seeked",n),o()};t.addEventListener("seeked",n,{once:!0});const r=t.fastSeek;r?r.call(t,e):t.currentTime=e})}(j,H(t)),!A){const e=ot(j,$,z,q);e.rows.length>0&&(l[t]=e,d(t))}}finally{T=!1,A||requestAnimationFrame(()=>{_()})}}},J=()=>{if(A)return;const t=V(m);if(t>=0&&t!==M){const e=l[t];e&&(nt(C,e,$,z,q),M=t,P||(P=!0,b?.(I)),v?.())}else if(t<0||M<0){const t=performance.now();if(D<=0||t-U>=D){const e=ot(I,$,z,q);e.rows.length>0&&(nt(C,e,$,z,q),U=t,P||(P=!0,b?.(I)),v?.())}}X(m),S=requestAnimationFrame(J)};return W=Mt(o,t,e=>{const o=function(t,e,o={}){if(!Number.isFinite(t.duration)||t.duration<=0)return null;const n=o.from??0,r=o.to??t.duration,a=Math.max(n,Math.min(r,t.duration)),i=dt(e,o),s=n+(a-n)*i;return{progress:i,time:Math.min(Math.max(n,s),Math.max(n,a-.04))}}(I,e,{...t,from:n,to:a});g=o?.progress??lt(e),m=O(g),X(m),X(m-1),X(m+1),X(m-2),X(m+2),X(m-3),X(m+3),t.onUpdate?.(g,I)}),X(0),X(1),S=requestAnimationFrame(J),F(()=>{A=!0,cancelAnimationFrame(S),W?.(),L?.disconnect(),j.pause(),j.src="",document.body.removeChild(j),k&&I.removeEventListener("timeupdate",k),R&&(I.pause(),I.src="",document.body.removeChild(I))})}if(O){const t=!0===p?{}:p;W=gt(I,{...t,trigger:t.trigger??E??e,from:t.from??x,to:t.to??y})}const Y=t=>{if(j)return;if(B=requestAnimationFrame(Y),I.readyState<2||0===e.width||0===e.height)return;if(D>0&&t-U<D)return;if(x>0&&I.currentTime<x)return;if(void 0!==y&&I.currentTime>=y)return;if(O&&Math.abs(I.currentTime-N)<1/240)return;if(V){const e=ot(I,$,z,q);return void(e.rows.length>0&&(nt(C,e,$,z,q),U=t,N=I.currentTime,H&&(H=!1,b?.(I)),v?.()))}const{frame:o}=et(I,$,z,q);o.length>0&&(ct(C,o,$,z,q,0,null),U=t,N=I.currentTime,H&&(H=!1,b?.(I)),v?.())};return B=requestAnimationFrame(Y),F(()=>{j=!0,cancelAnimationFrame(B),W?.(),L?.disconnect(),k&&I.removeEventListener("timeupdate",k),R&&(I.pause(),I.src="",document.body.removeChild(I))})}function $t(t,e,o){return St(t,e,o)}function Ct(t,e,o,n,r={}){const{fontSize:a=13,chars:i="0123456789ABCDEF@#$&*+=/<>",accentColor:s,color:c,speed:l=1,density:h=.55,tailLength:f=14,lightMode:d=!1}=r,m=s??(d?"#6b8700":"#d4ff00"),u=.62*a,g=1.4*a,M=Math.ceil(e/u),p=Math.ceil(o/g);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let w=255,b=255,v=255;if(d&&(w=55,b=55,v=55),c){const t=A(c);t&&(w=t.r,b=t.g,v=t.b)}let x=212,y=255,S=0;const $=A(m);$&&(x=$.r,y=$.g,S=$.b);const C=p+f;for(let e=0;e<M;e++){if(I(17*e,3)>h)continue;const o=(.5+1.5*I(31*e,7))*l,r=I(13*e,11)*C,a=Math.floor((n*o*7+r)%C),s=e*u;for(let o=0;o<=f;o++){const r=a-(f-o);if(r<0||r>=p)continue;const c=r*g,l=I(53*e+Math.floor(5*n+o),7*r),h=i[Math.floor(l*i.length)],m=o/f;if(o===f)t.fillStyle=`rgba(${x},${y},${S},${d?.7:.85})`;else{const e=d?.85*m:.15*m;t.fillStyle=`rgba(${w},${b},${v},${e})`}t.fillText(h,s,c)}}}function Et(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" . · * + ° ★",accentColor:c,color:l,speed:h=1,count:f=180,lightMode:d=!1}=a,m=c??(d?"#6b8700":"#d4ff00");t.clearRect(0,0,e,o),t.textBaseline="middle",t.textAlign="center";const u=e*(.2+.6*r.x),g=o*(.2+.6*r.y),M=.65*Math.sqrt(e*e+o*o);let p=255,w=255,b=255;if(d&&(p=55,w=55,b=55),l){const t=A(l);t&&(p=t.r,w=t.g,b=t.b)}let v=212,x=255,y=0;const S=A(m);S&&(v=S.r,x=S.g,y=S.b);const $=s.replace(/ /g,"").split("");if(0!==$.length){for(let r=0;r<f;r++){const a=I(17*r,3)*Math.PI*2,s=(n*(.15+.85*I(31*r,7))*h*.22+I(13*r,11))%1,c=u+Math.cos(a)*s*M,l=g+Math.sin(a)*s*M;if(c<-20||c>e+20||l<-20||l>o+20)continue;const f=Math.max(6,i*(.4+.9*s));t.font=`${f}px monospace`;const m=$[Math.min($.length-1,Math.floor(s*$.length))],S=s>.72,C=d?.85*s:.2*s;t.fillStyle=S?`rgba(${v},${x},${y},${Math.min(d?.92:.32,2.2*C)})`:`rgba(${p},${w},${b},${C})`,t.fillText(m,c,l)}t.textAlign="left"}}function At(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=". · ○ ◎ ●",accentColor:c,color:l,rings:h=5,speed:f=1,sharpness:d=4,lightMode:m=!1}=a,u=c??(m?"#007a5e":"#00ffcc");t.clearRect(0,0,e,o),t.textBaseline="middle",t.textAlign="center";const g=e*r.x,M=o*r.y,p=1.6*Math.sqrt(g*g+M*M)+.2*Math.sqrt(e*e+o*o);let w=255,b=255,v=255;if(m&&(w=55,b=55,v=55),l){const t=A(l);t&&(w=t.r,b=t.g,v=t.b)}let x=0,y=255,S=204;const $=A(u);$&&(x=$.r,y=$.g,S=$.b);const C=s.replace(/ /g,"").split("");if(0===C.length)return;const E=Math.ceil(e/i),T=Math.ceil(o/i);for(let e=0;e<T;e++)for(let o=0;o<E;o++){const r=o*i+.5*i,a=e*i+.5*i,s=r-g,c=a-M,l=Math.sqrt(s*s+c*c)/p;let u=0;for(let t=0;t<h;t++){const e=(n*f*.38+t/h)%1,o=Math.abs(l-e),r=Math.max(0,1-o*p/(i*(12-d)));u+=Math.cos(r*Math.PI*.5)*r}if(u=Math.min(1,u),u<.02)continue;const $=u>.6;t.font=`${i}px monospace`;const E=Math.floor(u*(C.length-1)),A=C[Math.min(E,C.length-1)],T=m?.88*u:.22*u;t.fillStyle=$?`rgba(${x},${y},${S},${Math.min(m?.95:.4,.55*u)})`:`rgba(${w},${b},${v},${T})`,t.fillText(A,r,a)}t.textAlign="left"}function Tt(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" .·:;=+*#%@░▒▓",accentColor:c,color:l,octaves:h=4,speed:f=1,scale:d=1,accentThreshold:m=.78,mouseWarp:u=.3,lightMode:g=!1}=a,M=c??(g?"#6b8700":"#d4ff00"),p=.62*i,w=1.4*i,b=Math.ceil(e/p),v=Math.ceil(o/w);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let x=255,y=255,S=255;if(g&&(x=55,y=55,S=55),l){const t=A(l);t&&(x=t.r,y=t.g,S=t.b)}let $=212,C=255,E=0;const T=A(M);T&&($=T.r,C=T.g,E=T.b);const F=.035*d,I=n*f,k=Math.min(6,Math.max(1,h)),L=(t,e)=>{let o=0,n=.5,r=1,a=0;for(let i=0;i<k;i++)o+=R(t*r,e*r)*n,a+=n,n*=.5,r*=2.1;return o/a};for(let e=0;e<v;e++)for(let o=0;o<b;o++){const n=o*F+.06*I,a=e*F*1.3-.04*I,i=o/b-r.x,c=e/v-r.y,l=Math.sqrt(i*i+c*c),h=u>0?.12*Math.max(0,1-l/u):0,f=.5*L(n+h*Math.sin(1.3*I+8*c),a+h*Math.cos(.9*I+8*i))+.5;if(f<.12)continue;const d=s[Math.floor(f*(s.length-1))];if(" "===d)continue;const M=f>m,A=g?.82*f:.13*f;t.fillStyle=M?`rgba(${$},${C},${E},${g?.92:.28})`:`rgba(${x},${y},${S},${A})`,t.fillText(d,o*p,e*w)}}function Ft(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=12,chars:s="·-=+|/",accentColor:c,color:l,bands:h=3,speed:f=1,bandWidth:d=.12,glitch:m=!0,lightMode:u=!1}=a,g=c??(u?"#6b8700":"#d4ff00"),M=.62*i,p=1.4*i,w=Math.ceil(e/M),b=Math.ceil(o/p);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let v=255,x=255,y=255;if(u&&(v=55,x=55,y=55),l){const t=A(l);t&&(v=t.r,x=t.g,y=t.b)}let S=212,$=255,C=0;const E=A(g);E&&(S=E.r,$=E.g,C=E.b);const T=n*f;for(let e=0;e<b;e++)for(let o=0;o<w;o++){const n=e/b,a=((n*h-.5*T)%1+1)%1,i=Math.max(0,1-a/d),c=.35*(.5*I(3*o,7*e)+.5);let l=0;if(m){const t=o/w-r.x,a=n-r.y,i=Math.sqrt(t*t+a*a);if(i<.18){const t=I(11*o+Math.floor(12*T),5*e);l=Math.max(0,1-i/.18)*(t>.5?t-.3:0)}}const f=Math.min(1,c+.8*i+.6*l);if(f<.04)continue;const g=s[Math.floor(f*(s.length-1))],E=i>.55,A=u?.82*f:.12*f;t.fillStyle=E?`rgba(${S},${$},${C},${u?.92:.28})`:`rgba(${v},${x},${y},${A})`,t.fillText(g,o*M,e*p)}}function It(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" ·∙•:;+=≡≣#@",color:c,accentColor:l,speed:h=1,layers:f=5,softness:d=1.2,mouseRipple:m=.2,lightMode:u=!1}=a,g=l??(u?"#6b8700":"#d4ff00"),M=.62*i,p=1.4*i,w=Math.ceil(e/M),b=Math.ceil(o/p);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let v=255,x=255,y=255;if(u&&(v=55,x=55,y=55),c){const t=A(c);t&&(v=t.r,x=t.g,y=t.b)}let S=212,$=255,C=0;const E=A(g);E&&(S=E.r,$=E.g,C=E.b);const T=n*h,F=[];for(let t=0;t<f;t++){const e=I(17*t,31*t+7),o=I(23*t+5,11*t);F.push({fx:.8+2.2*e,fy:1.2+1.8*o,phase:e*Math.PI*4,dt:(.3+.5*I(7*t,13*t+3))*(t%2==0?1:-1),amp:.55+.45*I(29*t,3*t)})}for(let e=0;e<b;e++){const o=e/b;for(let n=0;n<w;n++){const a=n/w,i=a-r.x,c=o-r.y,l=Math.sqrt(i*i+c*c),h=m*Math.exp(-l*l/.06),g=a+i*h,b=o+c*h;let E=0,A=0;for(let t=0;t<f;t++){const{fx:e,fy:o,phase:n,dt:r,amp:a}=F[t];E+=Math.sin(g*e*Math.PI*2+T*r+n)*Math.cos(b*o*Math.PI*2+T*r*.7+1.3*n)*a,A+=a}const I=E/A,R=.5+.5*Math.tanh(I*d*2.2);if(R<.12)continue;const k=(R-.12)/.88,L=s[Math.min(s.length-1,Math.floor(k*s.length))],P=R>.82,z=u?.82*R:.14*R;t.fillStyle=P?`rgba(${S},${$},${C},${u?.92:.32})`:`rgba(${v},${x},${y},${z})`,t.fillText(L,n*M,e*p)}}}function Rt(t,e,o,n,r={}){const{fontSize:a=13,color:i,accentColor:s,speed:c=.4,layers:l=4,turbulence:h=.8,lightMode:f=!1}=r,d=s??(f?"#6b8700":"#d4ff00"),m=.62*a,u=1.4*a,g=Math.ceil(e/m),M=Math.ceil(o/u);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let p=255,w=255,b=255;if(f&&(p=55,w=55,b=55),i){const t=A(i);t&&(p=t.r,w=t.g,b=t.b)}let v=212,x=255,y=0;const S=A(d);S&&(v=S.r,x=S.g,y=S.b);const $=n*c,C=["─","─","╌","·","╌","─","─","╌","·"];for(let e=0;e<M;e++){const o=e/M;for(let n=0;n<g;n++){const r=n/g;let a=0,i=0;for(let t=0;t<l;t++){const e=I(13*t,7*t+3),n=1.1+2.4*e,s=.9+2*I(29*t,11*t+1),c=e*Math.PI*6,l=(.2+.5*I(41*t,17*t))*(t%2==0?1:-1.3),f=Math.sin(r*n*Math.PI*2+$*l+c),d=Math.cos(o*s*Math.PI*2+$*l*.6+1.7*c),m=Math.sin(r*s*Math.PI*h+o*n*Math.PI*h+$*l*.4);a+=Math.atan2(d+.3*m,f),i+=.5*(f*d+1)}const s=a/l,c=Math.min(1,i/l);if(c<.1)continue;const d=(s+Math.PI)/(2*Math.PI),M=C[Math.floor(d*C.length)%C.length],S=c>.8,E=f?.8*c:.13*c;t.fillStyle=S?`rgba(${v},${x},${y},${f?.9:.26})`:`rgba(${p},${w},${b},${E})`,t.fillText(M,n*m,e*u)}}}function kt(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=13,chars:s=" ·:;=+*#%@",color:c,accentColor:l,speed:h=1,radius:f=.38,swirl:d=3,lightMode:m=!1}=a,u=l??(m?"#6b8700":"#d4ff00"),g=.62*i,M=1.4*i,p=Math.ceil(e/g),w=Math.ceil(o/M),b=e/o;t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let v=255,x=255,y=255;if(m&&(v=55,x=55,y=55),c){const t=A(c);t&&(v=t.r,x=t.g,y=t.b)}let S=212,$=255,C=0;const E=A(u);E&&(S=E.r,$=E.g,C=E.b);const T=n*h;for(let e=0;e<w;e++){const o=e/w;for(let n=0;n<p;n++){const a=(n/p-r.x)*b,i=o-r.y,c=Math.sqrt(a*a+i*i)/f;if(c>1){const o=I(3*n,7*e)*Math.max(0,1-3*(c-1));if(o<.62)continue;const r=o*(m?.28:.04);t.fillStyle=`rgba(${v},${x},${y},${r})`,t.fillText(s[1],n*g,e*M);continue}const l=Math.max(0,1-Math.abs(c-(.15+.12*Math.sin(1.1*T)))/.07),h=Math.pow(1-c,2.2),d=Math.min(1,h+.6*l);if(d<.06)continue;const u=Math.floor(d*(s.length-1)),w=s[Math.min(s.length-1,u)],E=l>.35||c<.08,A=m?.85*d:.18*d;t.fillStyle=E?`rgba(${S},${$},${C},${m?.95:.38})`:`rgba(${v},${x},${y},${A})`,t.fillText(w,n*g,e*M)}}}function Lt(t,e,o,n,r={}){const{fontSize:a=14,chars:i=" ·∙•:-=+*#",color:s,accentColor:c,speed:l=.5,harmonics:h=3,lightMode:f=!1}=r,d=c??(f?"#6b8700":"#d4ff00"),m=.62*a,u=1.4*a,g=Math.ceil(e/m),M=Math.ceil(o/u);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let p=255,w=255,b=255;if(f&&(p=55,w=55,b=55),s){const t=A(s);t&&(p=t.r,w=t.g,b=t.b)}let v=212,x=255,y=0;const S=A(d);S&&(v=S.r,x=S.g,y=S.b);const $=n*l,C=Array.from({length:h},(t,e)=>1/(e+1)).reduce((t,e)=>t+e,0);for(let e=0;e<M;e++)for(let o=0;o<g;o++){let n=0;for(let t=0;t<h;t++){const r=.18+1.4*I(o*(t+3)+7,e*(t+5)+11),a=I(o*(t+7),e*(t+9)+3)*Math.PI*2,i=1/(t+1);n+=Math.sin($*r+a)*i}const r=.5*(n/C+1);if(r<.28)continue;const a=(r-.28)/.72,s=i[Math.min(i.length-1,Math.floor(a*i.length))],c=r>.88,l=f?.82*a:.13*a;t.fillStyle=c?`rgba(${v},${x},${y},${f?.92:.28})`:`rgba(${p},${w},${b},${l})`,t.fillText(s,o*m,e*u)}}function Pt(t,e,o,n,r={}){const{fontSize:a=13,chars:i=" .,:;i+xX#&@",color:s="#ff4500",hotColor:c="#ffe066",intensity:l=.85,wind:h=0,speed:f=1,lightMode:d=!1}=r,m=.62*a,u=1.4*a,g=Math.ceil(e/m),M=Math.ceil(o/u),p=g*M,w="__fire_heat__",b=t.canvas;let v=b[w];v&&v.length===p||(v=new Float32Array(p),b[w]=v);const x=.18*(.016*f),y=h*f*.8,S=M-1,$=n*f;for(let t=0;t<g;t++){const e=(.6*(.5*Math.sin(.31*t+4.1*$)+.5)+.4*(.5*Math.sin(.73*t-2.7*$)+.5))*l;v[S*g+t]=Math.min(1,e+.15*Math.random()*l),S>0&&(v[(S-1)*g+t]=Math.min(1,.85*e+.1*Math.random()*l))}const C=new Float32Array(p);for(let t=0;t<M-2;t++)for(let e=0;e<g;e++){const o=.4*v[(t+1)*g+e]+.25*v[(t+2)*g+Math.max(0,Math.min(g-1,e+Math.round(y)))]+.175*v[(t+1)*g+Math.max(0,e-1)]+.175*v[(t+1)*g+Math.min(g-1,e+1)];C[t*g+e]=Math.max(0,o-x-.02*Math.random()*f)}for(let t=0;t<g;t++)C[(M-1)*g+t]=v[(M-1)*g+t],M>1&&(C[(M-2)*g+t]=v[(M-2)*g+t]);b[w]=C;const E=A(s)??{r:255,g:69,b:0},T=A(c)??{r:255,g:224,b:102};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";for(let e=0;e<M;e++)for(let o=0;o<g;o++){const n=C[e*g+o];if(n<.03)continue;const r=i[Math.min(i.length-1,Math.floor(n*i.length))];if(" "===r)continue;const a=Math.min(1,1.2*n),s=E.r+(T.r-E.r)*a|0,c=E.g+(T.g-E.g)*a|0,l=E.b+(T.b-E.b)*a|0,h=d?1-.3*n:Math.min(1,n+.15);t.globalAlpha=h,t.fillStyle=`rgb(${s},${c},${l})`,t.fillText(r,o*m,e*u)}t.globalAlpha=1}function zt(t,e,o,n,r={}){const{fontSize:a=13,baseChars:i="ATCG",bridgeChars:s="-=≡",color:c="#00e5ff",color2:l="#ff4081",bridgeColor:h="#88ffcc",speed:f=1,helixCount:d,lightMode:m=!1}=r,u=.62*a,g=1.4*a,M=Math.ceil(e/u),p=Math.ceil(o/g),w=d??Math.max(1,Math.floor(e/80)),b=M/w,v=A(c)??{r:0,g:229,b:255},x=A(l)??{r:255,g:64,b:129},y=A(h)??{r:136,g:255,b:204};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const S=n*f,$=.35*b;for(let e=0;e<w;e++){const o=b*(e+.5);for(let n=0;n<p;n++){const r=n/p*Math.PI*6-1.8*S,a=o+Math.sin(r)*$,c=o+Math.sin(r+Math.PI)*$,l=Math.round(a),h=Math.round(c);if(l<0||l>=M)continue;const f=I(31*e+7*n,3),d=i[Math.floor(f*i.length)],m=.5*(Math.sin(r)+1),w=.5*(Math.sin(r+Math.PI)+1);if(t.globalAlpha=.35+.65*m,t.fillStyle=`rgb(${v.r},${v.g},${v.b})`,t.fillText(d,l*u,n*g),h>=0&&h<M){const o=I(53*e+11*n,7),r=i[Math.floor(o*i.length)];t.globalAlpha=.35+.65*w,t.fillStyle=`rgb(${x.r},${x.g},${x.b})`,t.fillText(r,h*u,n*g)}if(n%3===0){const o=Math.min(l,h),r=Math.max(l,h);if(r-o>1){const a=I(17*n+43*e,5),i=s[Math.floor(a*s.length)],c=.25*(m+w)+.2;t.globalAlpha=c,t.fillStyle=`rgb(${y.r},${y.g},${y.b})`;for(let e=o+1;e<r;e++)t.fillText(i,e*u,n*g)}}}}t.globalAlpha=1}function qt(t,e,o,n,r={}){const{fontSize:a=13,chars:i=" .,:;+*#@",color:s="#4caf50",skyColor:c="#1a237e",peakColor:l="#e0e0e0",speed:h=1,roughness:f=.55,heightScale:d=.55,stars:m=!0,lightMode:u=!1}=r,g=.62*a,M=1.4*a,p=Math.ceil(e/g),w=Math.ceil(o/M),b=A(s)??{r:76,g:175,b:80},v=A(c)??{r:26,g:35,b:126},x=A(l)??{r:224,g:224,b:224};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const y=n*h*.4,S=new Array(p);for(let t=0;t<p;t++){const e=(.5*k((t/p+y)*f*3,.5)+.5)*d;S[t]=Math.floor(e*w)}for(let e=0;e<w;e++)for(let o=0;o<p;o++){const r=w-1-S[o],a=e===r;if(!(e>=r)){if(m){const r=I(7*o+Math.floor(.3*y),13*e);if(r>.97){const a=.3*Math.sin(2*n+100*r)+.7;t.globalAlpha=.5*a,t.fillStyle=`rgb(${v.r+60},${v.g+60},${v.b+80})`,t.fillText("·",o*g,e*M)}}continue}const s=(e-r)/Math.max(1,S[o]),c=i[Math.min(i.length-1,Math.floor(s*i.length))];if(" "===c&&!a)continue;const l=a?1:Math.max(0,1-4*s),h=b.r+(x.r-b.r)*l|0,f=b.g+(x.g-b.g)*l|0,d=b.b+(x.b-b.b)*l|0;t.globalAlpha=.5+.5*s,t.fillStyle=`rgb(${h},${f},${d})`,t.fillText(a?i[i.length-1]:c,o*g,e*M)}t.globalAlpha=1}var Bt=1,jt=2,Ht=4,Wt=8,Ot={3:"─",12:"│",9:"┌",10:"┐",5:"└",6:"┘",11:"┬",7:"┴",13:"├",14:"┤",15:"┼",[Bt]:"╶",[jt]:"╴",[Ht]:"╵",[Wt]:"╷"};function Dt(t,e,o,n,r={}){const{fontSize:a=13,pulseColor:i="#ffffff",color:s="#00ff88",density:c=.38,speed:l=1,lightMode:h=!1}=r,f=.62*a,d=1.4*a,m=Math.ceil(e/f),u=Math.ceil(o/d),g=A(s)??{r:0,g:255,b:136},M=A(i)??{r:255,g:255,b:255},p=(t,e)=>{if(I(17*t+1,7*e+2)>c)return 0;let o=0;return t+1<m&&I(17*t+1,7*e+2)>.15&&(o|=1),t-1>=0&&I(17*(t-1)+1,7*e+2)>.15&&(o|=2),e+1<u&&I(17*t+1,7*(e+1)+2)>.15&&(o|=8),e-1>=0&&I(17*t+1,7*(e-1)+2)>.15&&(o|=4),o};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const w=n*l;for(let e=0;e<u;e++)for(let o=0;o<m;o++){const n=p(o,e);if(0===n)continue;const r=Ot[n]??"·",a=(8*w+40*I(o,23*e))%m,i=(6*w+40*I(17*e,11*o))%u,s=(1&n||2&n)&&Math.abs(o-a)<1.5,c=(4&n||8&n)&&Math.abs(e-i)<1.5,l=s||c,h=.25+.35*I(3*o,5*e);l?(t.globalAlpha=.95,t.fillStyle=`rgb(${M.r},${M.g},${M.b})`):(t.globalAlpha=h,t.fillStyle=`rgb(${g.r},${g.g},${g.b})`),t.fillText(r,o*f,e*d)}t.globalAlpha=1}var Ut=["wave","rain","stars","pulse","noise","grid","aurora","silk","void","morph","fire","dna","terrain","circuit"];function Nt(t,e={}){const{type:o="wave",opacity:n=.2,className:r,zIndex:a=0,colorScheme:i="auto",color:s,...c}=e,l="string"==typeof t?document.querySelector(t):t;if(!l)return console.warn("[asciify] asciiBackground: target not found",t),{destroy:()=>{}};const h=l.style.position;"static"===getComputedStyle(l).position&&(l.style.position="relative");const f=document.createElement("canvas");f.style.cssText=["position:absolute","inset:0","width:100%","height:100%",`opacity:${n}`,"pointer-events:none",`z-index:${a}`].join(";"),r&&(f.className=r),l.prepend(f);const d=f.getContext("2d"),m=window.devicePixelRatio||1,u={x:.5,y:.5},g={x:.5,y:.5},M=()=>"light"===i||"dark"!==i&&(()=>{let t=l;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)})(),p=s?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}(s):null,w=()=>({...c,lightMode:void 0!==c.lightMode?c.lightMode:M(),baseColor:p?`rgba(${p.r},${p.g},${p.b},{a})`:c.baseColor}),b={current:w()},v=()=>{b.current="rain"===o||"stars"===o||"pulse"===o||"noise"===o||"grid"===o||"aurora"===o||"silk"===o||"void"===o||"morph"===o?{...c,lightMode:void 0!==c.lightMode?c.lightMode:M(),color:s??c.color}:"fire"===o||"dna"===o?{...c,color:s??c.color}:"terrain"===o||"circuit"===o?{...c,color:s??c.color,lightMode:void 0!==c.lightMode?c.lightMode:M()}:w()};v();const x=window.matchMedia("(prefers-color-scheme: light)"),y=()=>{v()};let S=null;"auto"===i&&(x.addEventListener("change",y),S=new MutationObserver(y),S.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]}));const $=()=>{const t=l.getBoundingClientRect();f.width=t.width*m,f.height=t.height*m,d.setTransform(m,0,0,m,0,0)};$();const C=t=>{const e=l.getBoundingClientRect();u.x=(t.clientX-e.left)/e.width,u.y=(t.clientY-e.top)/e.height},E=new ResizeObserver($);E.observe(l),window.addEventListener("mousemove",C);let A=0,T=0;const F=()=>{g.x+=.07*(u.x-g.x),g.y+=.07*(u.y-g.y);const t=l.getBoundingClientRect();"rain"===o?Ct(d,t.width,t.height,A,b.current):"stars"===o?Et(d,t.width,t.height,A,g,b.current):"pulse"===o?At(d,t.width,t.height,A,g,b.current):"noise"===o?Tt(d,t.width,t.height,A,g,b.current):"grid"===o?Ft(d,t.width,t.height,A,g,b.current):"aurora"===o?It(d,t.width,t.height,A,g,b.current):"silk"===o?Rt(d,t.width,t.height,A,b.current):"void"===o?kt(d,t.width,t.height,A,g,b.current):"morph"===o?Lt(d,t.width,t.height,A,b.current):"fire"===o?Pt(d,t.width,t.height,A,b.current):"dna"===o?zt(d,t.width,t.height,A,b.current):"terrain"===o?qt(d,t.width,t.height,A,b.current):"circuit"===o?Dt(d,t.width,t.height,A,b.current):L(d,t.width,t.height,A,g,b.current),A+=.016,T=requestAnimationFrame(F)};return T=requestAnimationFrame(F),{destroy:()=>{cancelAnimationFrame(T),E.disconnect(),"auto"===i&&(x.removeEventListener("change",y),S?.disconnect()),window.removeEventListener("mousemove",C),f.remove(),l.style.position=h}}}var Vt=Nt;function Yt(t,e={},o,n){const r={...s,...e},{frame:a,cols:i}=et(t,r,o,n);if(!a.length||0===i)return"";const c=[];for(const t of a)c.push(t.map(t=>t.char).join(""));return c.join("\n")}function Xt(t,e={},o,n){const r={...s,...e},{frame:a,cols:i}=et(t,r,o,n);if(!a.length||0===i)return"";const c=[];for(const t of a){let e="";for(const o of t)" "===o.char||o.a<10?e+=" ":e+=`[38;2;${o.r};${o.g};${o.b}m${o.char}`;c.push(e)}return c.join("\n")}function _t(t,e,o,n="#505050",r=100){if(!t||e<=0||o<=0)return[];const a=A(n)??{r:80,g:80,b:80},i=t,s=i.length;return Array.from({length:o},(t,o)=>Array.from({length:e},(t,n)=>({char:i[(o*e+n)%s],r:a.r,g:a.g,b:a.b,a:r})))}function Jt(t,e,o,n,r={},a){const{fontSize:i=10,lineHeight:c=1.6,color:l="#505050",opacity:h=100,hoverEffect:f="spotlight",hoverStrength:d=.85,hoverRadius:m=.18,hoverColor:u="#d4ff00"}=r;ct(t,_t(n,Math.max(1,Math.floor(e/i)),Math.max(1,Math.floor(o/(i*c))),l,h),{...s,hoverEffect:f,hoverStrength:d,hoverRadius:m,hoverColor:u},e,o,0,a??null)}function Kt(t,{format:e="png",quality:o=.92,scale:n=1}={}){return new Promise((r,a)=>{let i=t;if(1!==n){const e=document.createElement("canvas");e.width=Math.round(t.width*n),e.height=Math.round(t.height*n);const o=e.getContext("2d");if(!o)return void a(new Error("captureSnapshot: could not get 2d context"));o.drawImage(t,0,0,e.width,e.height),i=e}i.toBlob(t=>t?r(t):a(new Error("captureSnapshot: toBlob returned null")),`image/${e}`,o)})}async function Gt(t,e={}){const{filename:o="asciify-snapshot",format:n="png",...r}=e,a=await Kt(t,{format:n,...r}),i="jpeg"===n?"jpg":n,s=document.createElement("a");s.href=URL.createObjectURL(a),s.download=`${o}.${i}`,s.click(),setTimeout(()=>URL.revokeObjectURL(s.href),1e4)}async function Qt(t,{fontSize:e=10,style:o="classic",options:n={},liveOptions:r,mirror:i=!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}),f=document.createElement("video");f.srcObject=h,f.muted=!0,f.playsInline=!0,await new Promise((t,e)=>{f.onloadedmetadata=()=>t(),f.onerror=()=>e(new Error("asciifyWebcam: video stream failed to load.")),f.play().catch(e)});const d={...s,...a[o],...n,fontSize:e},m=t.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={x:.5,y:.5,intensity:0},p=e=>{const o=t.getBoundingClientRect();g={x:(e.clientX-o.left)/o.width,y:(e.clientY-o.top)/o.height}},w=()=>{g=null};d.hoverStrength>0&&(t.addEventListener("mousemove",p),t.addEventListener("mouseleave",w));let b,v=!1;const x=performance.now(),y=e=>{if(!v){if(f.readyState>=f.HAVE_CURRENT_DATA){const o=t.width/u,n=t.height/u,a=(e-x)/1e3,s=r?{...d,...r()}:d;s.hoverStrength>0?(t.addEventListener("mousemove",p),t.addEventListener("mouseleave",w)):(t.removeEventListener("mousemove",p),t.removeEventListener("mouseleave",w));const{frame:c}=et(f,s,o,n);if(g){const t=g.x-M.x,e=g.y-M.y,o=Math.sqrt(t*t+e*e),n=Math.min(.25,.06+.8*o);M.x+=t*n,M.y+=e*n,M.intensity+=.12*(1-M.intensity)}else M.intensity*=.965,M.intensity<.003&&(M.intensity=0);const l=M.intensity>.003?{x:M.x,y:M.y,intensity:M.intensity}:null;i?(m.save(),m.scale(-1,1),m.translate(-o,0),ct(m,c,s,o,n,a,l),m.restore()):ct(m,c,s,o,n,a,l)}b=requestAnimationFrame(y)}};return b=requestAnimationFrame(y),()=>{v=!0,cancelAnimationFrame(b),t.removeEventListener("mousemove",p),t.removeEventListener("mouseleave",w),h.getTracks().forEach(t=>t.stop()),f.srcObject=null}}var Zt={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]},te=[127,65,65,65,65,65,127];function ee(t){return Zt[t]??Zt[t.toUpperCase()]??te}function oe(t,e={}){if(!t)return"";const{char:o="█",scale:n=1}=e,r=[...o][0]??"█",a=Math.max(1,Math.floor(n)),i=7*a,s=a,c=Array.from({length:i},()=>"");for(let e=0;e<t.length;e++){const o=ee(t[e]);for(let t=0;t<7;t++){const e=o[t];let n="";for(let t=6;t>=0;t--)n+=(e>>t&1?r:" ").repeat(a);for(let e=0;e<a;e++)c[t*a+e]+=n}if(e<t.length-1)for(let t=0;t<i;t++)c[t]+=" ".repeat(s)}return c.join("\n")}function ne(t,e,o={}){const{color:n="#d4ff00",bgColor:r,fontSize:a=10}=o,i=oe(e,o);if(!i)return;const s=i.split("\n"),c=Math.max(...s.map(t=>[...t].length));t.width=Math.ceil(c*a*.6),t.height=Math.ceil(s.length*a);const l=t.getContext("2d");r&&"transparent"!==r?(l.fillStyle=r,l.fillRect(0,0,t.width,t.height)):l.clearRect(0,0,t.width,t.height),l.fillStyle=n,l.font=`${a}px monospace`,l.textBaseline="top",s.forEach((t,e)=>l.fillText(t,0,e*a))}export{a as ART_STYLE_PRESETS,Ut as BACKGROUND_TYPES,n as CHARSETS,r as CHARSET_SEQUENCES,s as DEFAULT_OPTIONS,c as HOVER_PRESETS,i as LIVING_STYLE_PRESETS,o as PALETTE_THEMES,Nt as asciiBackground,Yt as asciiText,Xt as asciiTextAnsi,xt as asciify,yt as asciifyGif,$t as asciifyLiveVideo,oe as asciifyText,St as asciifyVideo,Qt as asciifyWebcam,_t as buildTextFrame,Kt as captureSnapshot,J as clearAsciifyCaches,gt as createVideoScrollScrub,it as gifToAsciiFrames,st as gifToAsciiTextFrames,et as imageToAsciiFrame,ot as imageToAsciiTextFrame,Vt as mountWaveBackground,It as renderAuroraBackground,Dt as renderCircuitBackground,zt as renderDnaBackground,Pt as renderFireBackground,ct as renderFrameToCanvas,Ft as renderGridBackground,Lt as renderMorphBackground,Tt as renderNoiseBackground,At as renderPulseBackground,Ct as renderRainBackground,Rt as renderSilkBackground,Et as renderStarsBackground,qt as renderTerrainBackground,Jt as renderTextBackground,nt as renderTextFrameToCanvas,ne as renderTextToCanvas,kt as renderVoidBackground,L as renderWaveBackground,Gt as snapshotAndDownload,rt as videoToAsciiFrames,at as videoToAsciiTextFrames};//# sourceMappingURL=index.js.map