asciify-engine 1.0.80 → 1.0.82

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.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:" ·˙⁚⁖∶∷⋮⋰⋱∴∵"},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]},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"}},i={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 s(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 l(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 h(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 f=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];function d(t,e,o,n){if(n<=0)return t;const r=(f[o%4][e%4]/16-.5)*n*128;return Math.max(0,Math.min(255,t+r))}var u=new Array(256),g=new Array(256);for(let t=0;t<256;t++)u[t]=`rgb(${t},${t},${t})`,g[t]=`rgb(0,${t},0)`;function m(t,e,o,n,r,a=!1){switch(e){case"fullcolor":return`rgb(${t.r},${t.g},${t.b})`;case"matrix":return g[.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 u[e]}}}var M=[0,0,0];function p(t,e,o,n,r,a=!1){switch(e){case"fullcolor":M[0]=t.r,M[1]=t.g,M[2]=t.b;break;case"matrix":{const e=.299*t.r+.587*t.g+.114*t.b|0;M[0]=0,M[1]=e,M[2]=0;break}case"accent":M[0]=o,M[1]=n,M[2]=r;break;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;M[0]=e,M[1]=e,M[2]=e;break}}return M}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 v(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 x(t){if(t){const e=v(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=v(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 y(t,e,o,n,r,a,i){if("none"===a)return 1;const c=r*i;switch(a){case"wave":return.3+.7*(.6*(.5*Math.sin(t/o*Math.PI*4+3*c)+.5)+.4*(.5*Math.sin(e/n*Math.PI*3+2*c)+.5));case"pulse":{const r=o/2,a=n/2,i=Math.sqrt((t-r)**2+(e-a)**2),s=Math.sqrt(r**2+a**2);return.2+.8*(.5*Math.sin(i/s*Math.PI*6-4*c)+.5)}case"rain":return.1+.9*(.5*Math.sin(e/n*Math.PI*8-5*c+.3*t)+.5)*(.3*Math.sin(t/o*Math.PI*2+c)+.7);case"breathe":{const o=.3*Math.sin(2*c)+.7,n=.1*Math.sin(.1*(t+e)+c);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*c)),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*c));if(o-Math.floor(o)>.85){const e=.5*Math.sin(30*c+t)+.5;return e<.3?0:e}return 1}case"spiral":{const r=o/2,a=n/2,i=t-r,s=e-a,l=Math.atan2(s,i),h=Math.sqrt(i*i+s*s),f=Math.sqrt(r*r+a*a);return.15+.85*(.5*Math.sin(3*l+h/f*Math.PI*8-3*c)+.5)}case"typewriter":{const r=o*n,a=e*o+t-.5*c%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,s=e-a,l=Math.sqrt(i*i+s*s)/Math.sqrt(r*r+a*a),h=.5*Math.sin(1.5*c)+.5;return l>h?Math.max(0,1-3*(l-h)):.7+.3*Math.sin(10*l-2*c)}case"waveField":default:return 1;case"ripple":{const r=o/2,a=n/2,i=t-r,s=e-a,l=Math.sqrt(i*i+s*s),h=Math.sqrt(r*r+a*a);return.1+.9*(.5*Math.sin(l/h*Math.PI*10-5*c)+.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*c+.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,s=e-a,l=Math.atan2(s,i),h=Math.sqrt(i*i+s*s)/Math.sqrt(r*r+a*a);return.1+.9*(.5*Math.sin(2*l+6*h-2.5*c)+.5)}case"cellular":{const o=Math.floor(4*c),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 w={scale:1,offsetX:0,offsetY:0,glow:0,colorBlend:0,proximity:0};function $(t,e,o,n,r,a,i,c,s="spotlight",l=.5,h="circle"){const f=t-o,d=e-n,u=.08+.35*l+.04*a;let g,m;if("box"===h){const t=Math.abs(f),e=Math.abs(d);g=Math.max(t,e),m=u}else g=Math.sqrt(f*f+d*d),m=u;if(g>=m)return w.scale=1,w.offsetX=0,w.offsetY=0,w.glow=0,w.colorBlend=0,w.proximity=0,w;const M=function(t){return t*t*(3-2*t)}(1-g/m)*r;let p=1,b=0,v=0,x=0,y=0;switch(s){case"spotlight":{p=1+M*a*1.8;const t=Math.atan2(d,f),e=M*M*a*.6;b=Math.cos(t)*e*i,v=Math.sin(t)*e*c,x=M*a*.4,y=M*M*a*.25;break}case"magnify":p=1+M*a*2.5,x=M*a*.15;break;case"repel":{p=1+M*a*.3;const t=Math.atan2(d,f),e=M*M*a*1.2;b=Math.cos(t)*e*i,v=Math.sin(t)*e*c;break}case"glow":x=M*a*.8,y=M*a*.4;break;case"colorShift":p=1+M*a*.4,x=M*a*.2,y=M*a*.7;break;case"attract":{const t=Math.atan2(d,f),e=M*M*a*1;b=-Math.cos(t)*e*i,v=-Math.sin(t)*e*c,x=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);b=Math.cos(t+e)*o*i,v=Math.sin(t+e)*o*c,p=Math.max(.1,1-M*a*.6),x=M*a*.25;break}case"trail":y=M*a*.9,x=M*a*.6,p=1+M*a*.15;break;case"glitchText":p=1,x=M*a*.5,y=M*a*.6}return w.scale=p,w.offsetX=b,w.offsetY=v,w.glow=x,w.colorBlend=y,w.proximity=M,w}function S(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 C(t){return t*t*t*(t*(6*t-15)+10)}function E(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=C(t-o),i=C(r),c=I(o,n),s=I(o+1,n),l=I(o,n+1),h=I(o+1,n+1);return E(E(c,s,a),E(l,h,a),i)}function A(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 T(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=13,charAspect:c=.62,lineHeightRatio:s=1.4,chars:l=" .:-=+*#%@",baseColor:h=null,accentColor:f,accentThreshold:d=.52,mouseInfluence:u=.55,mouseFalloff:g=2.8,speed:m=1,vortex:M=!0,sparkles:p=!0,breathe:b=!0,lightMode:v=!1}=a,x=f??(v?"#6b8700":"#d4ff00"),y=i*c,w=i*s,$=Math.ceil(e/y),S=Math.ceil(o/w),C=r.x,E=r.y;let R=212,T=255,k=0;{const t=x.replace("#","");6===t.length&&(R=parseInt(t.slice(0,2),16),T=parseInt(t.slice(2,4),16),k=parseInt(t.slice(4,6),16))}t.clearRect(0,0,e,o),t.font=`${i}px "JetBrains Mono", monospace`,t.textBaseline="top";const z=n*m,q=b?.12*(.5*Math.sin(.22*z)+.5):0;for(let e=0;e<S;e++)for(let o=0;o<$;o++){const n=o/$,r=e/S,a=.045,i=.08*z,c=.06,s=.45*((.5*Math.sin(.08*o+.05*e+.6*z)+.5+(.5*Math.sin(.03*o-.07*e+.4*z)+.5)+(.5*Math.sin(.05*o+.03*e+.8*z)+.5))/3)+.35*(.5*A(o*a+i,e*a*1.4-.7*i)+.5)+.2*(.5*Math.sin((o+.65*e)*c+1.1*z)+.5)+q,f=n-C,m=r-E,b=Math.sqrt(f*f+m*m);let x=0;if(M&&b<.35){const t=Math.atan2(m,f),e=Math.sin(4*t+2.2*z-14*b),o=Math.max(0,1-b/.35);x=e*o*o*.22}const F=s*(1-u)+(Math.max(0,1-b*g)+.5*x)*u+.15*x,P=Math.min(1,Math.max(0,F));let B=P;if(p&&P>.72){const t=Math.floor(8*z),n=I(7*o+3*t,11*e+t);n>.88&&(B=Math.min(1,P+4*(n-.88)))}const L=Math.floor(B*(l.length-1));if(" "===l[L])continue;const H=.015+.07*B;if(B>d){const e=Math.min(v?.9:.28,H*(v?14:2.8));t.fillStyle=`rgba(${R},${T},${k},${e})`}else t.fillStyle=h?h.replace("{a}",String(H)):v?`rgba(55,55,55,${7*H})`:`rgba(255,255,255,${H})`;t.fillText(l[L],o*y,e*w)}}function k(t,e){return"auto"!==t?t:!x(e)}function z(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=z(t.getPropertyValue(e).trim());if(o)return o}const e=z(getComputedStyle(document.body).accentColor??"");if(e)return e}return x("undefined"!=typeof document?document.body:null)?"faf9f7":"0d0d0d"}function F(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,c=e.fontSize*e.charSpacing,f=e.fontSize/i*e.charSpacing,u=o||r,g=n||a,m=Math.floor(u/c),M=Math.floor(g/f);if(m<=0||M<=0)return{frame:[],cols:0,rows:0};const p=Math.max(1,Math.min(Math.floor(2048/m),Math.floor(r/m))),b=Math.max(1,Math.min(Math.floor(2048/M),Math.floor(a/M))),v=m*p,x=M*b,{ctx:y}=function(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}}(v,x);y.drawImage(t,0,0,v,x);const w=y.getImageData(0,0,v,x).data,$=e.chromaKey,S=null!=$&&!1!==$,C=!0===$,E="blue-screen"===$;let I=null,R=0;!S||C||E||(I=function(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]}}($),R=(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(S){const t=w[o],e=w[o+1],n=w[o+2];let r=!1;if(C)r=e>1.4*t&&e>1.4*n&&e>80;else if(E)r=n>1.4*t&&n>1.4*e&&n>80;else if(null!==I){const o=t-I.r,a=e-I.g,i=n-I.b;r=o*o+a*a+i*i<=R}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 z=[],q=k(e.invert),F=S&&e.charset.replace(/ /g,"")||e.charset,P=p*b;for(let t=0;t<M;t++){const o=[];for(let n=0;n<m;n++){let r=0,a=0,i=0,c=0,f=0;for(let e=0;e<b;e++){const o=(t*b+e)*v;for(let t=0;t<p;t++){const e=4*(o+n*p+t),s=w[e],l=w[e+1],h=w[e+2],d=w[e+3];if(S){let t=!1;if(C)t=l>1.4*s&&l>1.4*h&&l>80;else if(E)t=h>1.4*s&&h>1.4*l&&h>80;else if(null!==I){const e=s-I.r,o=l-I.g,n=h-I.b;t=e*e+o*o+n*n<=R}if(t){f++;continue}}r+=s,a+=l,i+=h,c+=d}}if(S&&f>P/2){o.push({char:" ",r:0,g:0,b:0,a:0});continue}const u=P-f,g=u>0?r/u:0,M=u>0?a/u:0,x=u>0?i/u:0,y=u>0?c/u:0,$=.299*g+.587*M+.114*x,k=d(s(e.normalize?($-A)/T*255:$,e.brightness,e.contrast),n,t,e.ditherStrength),z=e.customText?h(k,e.customText,n,t,m,q):l(k,F,q);o.push({char:z,r:g,g:M,b:x,a:y,lum:k})}z.push(o)}return{frame:z,cols:m,rows:M}}async function P(t,e,o,n,r=12,a=10,i,c=0){const s=Math.min(t.duration-c,a),l=Math.ceil(s*r),h=[];let f=0,d=0;for(let a=0;a<l;a++){const u=c+a/r;if(u>c+s)break;t.currentTime=u,await new Promise(e=>{const o=()=>{t.removeEventListener("seeked",o),e()};t.addEventListener("seeked",o)});const g=F(t,e,o,n);h.push(g.frame),f=g.cols,d=g.rows,i?.((a+1)/l)}return{frames:h,cols:f,rows:d,fps:r}}async function B(o,n,r,a,i){const c=t(o),s=e(c,!0);if(0===s.length)return{frames:[],cols:0,rows:0,fps:10};const l=s[0].dims.width,h=s[0].dims.height,f=c.lsd?.width||l,d=c.lsd?.height||h,u=document.createElement("canvas");u.width=f,u.height=d;const g=u.getContext("2d"),m=document.createElement("canvas");m.width=f,m.height=d;const M=m.getContext("2d"),p=[];let b=0,v=0,x=0;for(const t of s)x+=t.delay||100;const y=x/s.length,w=Math.round(Math.min(30,Math.max(5,1e3/y))),$=Math.min(s.length,300);for(let t=0;t<$;t++){const e=s[t],{dims:o,patch:c,disposalType:l}=e;3===l&&(M.clearRect(0,0,f,d),M.drawImage(u,0,0));const h=new ImageData(new Uint8ClampedArray(c.buffer),o.width,o.height),x=document.createElement("canvas");x.width=o.width,x.height=o.height;x.getContext("2d").putImageData(h,0,0),g.drawImage(x,o.left||0,o.top||0);const y=F(u,n,r,a);p.push(y.frame),b=y.cols,v=y.rows,2===l?g.clearRect(o.left||0,o.top||0,o.width,o.height):3===l&&(g.clearRect(0,0,f,d),g.drawImage(m,0,0)),i?.((t+1)/$)}return{frames:p,cols:b,rows:v,fps:w}}function L(t,e,o,n,r,a=0,i){if("waveField"===o.animationStyle){return void T(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 c=e.length;if(0===c)return;const s=e[0].length;t.clearRect(0,0,n,r);let h=!1;const f=Math.max(1,c>>2),d=Math.max(1,s>>2);t:for(let t=0;t<c;t+=f){const o=e[t];for(let t=0;t<s;t+=d)if(o[t].a<200){h=!0;break t}}const u=t.canvas,g=x(u);h||(t.fillStyle=g?"#0a0a0a":"#faf9f7",t.fillRect(0,0,n,r));const M=n/s,b=r/c,v=c*s,w=i?.intensity??1,S=!("none"!==o.animationStyle&&v>5e3)&&!!(i&&o.hoverStrength>0&&w>.005),C=o.hoverColor||"#ffffff",E=parseInt(C.slice(1,3),16)||255,I=parseInt(C.slice(3,5),16)||255,R=parseInt(C.slice(5,7),16)||255,A=q(o.accentColor),z=parseInt(A.substring(0,2),16)||255,F=parseInt(A.substring(2,4),16)||255,P=parseInt(A.substring(4,6),16)||255,B=v>3e4?.25:v>15e3?.4:v>5e3?.6:1,L=o.hoverRadius*B;let H=0,j=s,W=0,O=c,Y=0,U=0;if(S&&i){Y=i.x,U=i.y;const t=.08+.35*L+.04*o.hoverStrength;H=Math.max(0,Math.floor((Y-t)*s)-1),j=Math.min(s,Math.ceil((Y+t)*s)+1),W=Math.max(0,Math.floor((U-t)*c)-1),O=Math.min(c,Math.ceil((U+t)*c)+1)}const X=o.animationStyle,D=o.animationSpeed,V="none"===X,J=o.hoverStrength,_=o.hoverEffect,N=L,G=o.hoverShape||"circle",K=k(o.invert,u),Q=o.colorMode,Z=2*Math.PI,tt=1/s,et=1/c;let ot="",nt=-1;if("dots"===o.renderMode){const n=.5*Math.min(M,b)*o.dotSizeRatio;for(let o=0;o<c;o++){const r=e[o];for(let e=0;e<s;e++){const i=r[e];if(i.a<10)continue;const l=.00392156863*(.299*i.r+.587*i.g+.114*i.b),h=K?1-l:l;if(h<.02)continue;const f=V?1:y(e,o,s,c,a,X,D);let d=1,u=0,g=0,v=0,x=0;if(S&&e>=H&&e<=j&&o>=W&&o<=O){const t=$(e*tt,o*et,Y,U,w,J,M,b,_,N,G);d=t.scale,u=t.offsetX,g=t.offsetY,v=t.glow,x=t.colorBlend}const C=n*h*f*d;if(C<.3)continue;const A=e*M+.5*M+u,T=o*b+.5*b+g;let k;if(x>0){const t=p(i,Q,z,F,P,K);k=`rgb(${Math.min(255,t[0]+(E-t[0])*x|0)},${Math.min(255,t[1]+(I-t[1])*x|0)},${Math.min(255,t[2]+(R-t[2])*x|0)})`}else k=m(i,Q,z,F,P,K);const q=Math.min(1,.00392156863*i.a*f*(1+v));if(q!==nt&&(t.globalAlpha=q,nt=q),k!==ot&&(t.fillStyle=k,ot=k),C<=3){const e=2*C;t.fillRect(A-C,T-C,e,e)}else t.beginPath(),t.arc(A,T,C,0,Z),t.fill()}}}else{const n=.55,r=.9*Math.min(M/n,b),i=r<6;if(!i){const e="emoji"===o.artStyle;t.font=e?`${r}px "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif`:`${r}px "JetBrains Mono", monospace`,t.textAlign="center",t.textBaseline="middle"}let h=null;const f=o.charsetFrames,d=!!f?.length,u=d?f[Math.floor(Math.max(0,a)*(o.charsetFps??2))%f.length]:o.charset;if(i){h={};const t=[...u],e=t.length;for(let o=0;o<e;o++)h[t[o]]=Math.max(.1,(o+.3)/e)}const g=i?null:t.getTransform(),v="glitchText"===_&&S,x="!@#$%^&*<>{}[]|/\\~`0123456789",C=x.length;let A="",T=0,k=0,q=0,B=0,Z=0,rt=0;if(v){const t=o.hoverText??"ASCIIFY";if(k=Math.round(Y*s),q=Math.round(U*c),Array.isArray(t)){const e=t.filter(t=>t.length>0);0===e.length&&e.push("ASCIIFY");A=e[((7*Math.floor(k/Math.max(1,Math.ceil(s/5)))+13*Math.floor(q/Math.max(1,Math.ceil(c/3))))%e.length+e.length)%e.length]}else A=t||"ASCIIFY";T=A.length,B=Math.max(3,Math.min(12,Math.round(c*L*.6)));const e=Math.floor(B/2);Z=Math.max(0,q-e),Z+B>c&&(Z=Math.max(0,c-B)),rt=k-Math.floor(T/2)}for(let o=0;o<c;o++){const n=e[o];for(let e=0;e<s;e++){const r=n[e];if(r.a<10)continue;let f=d&&null!=r.lum?l(r.lum,u,K):r.char;if(" "===f)continue;const L=V?1:y(e,o,s,c,a,X,D);if(L<.05)continue;let at=1,it=0,ct=0,st=0,lt=0;if(S&&!v&&e>=H&&e<=j&&o>=W&&o<=O){const t=$(e*tt,o*et,Y,U,w,J,M,b,_,N,G);at=t.scale,it=t.offsetX,ct=t.offsetY,st=t.glow,lt=t.colorBlend}if(v&&o>=Z&&o<Z+B){const t=e-rt;if(t>=0&&t<T){const n=A[t],r=Math.abs(o-q)/Math.max(1,.5*B),i=Math.abs(e-k)/Math.max(1,T),c=Math.max(r,i),s=Math.max(0,Math.min(1,1-.9*c)),l=43758.5453*Math.sin(127.1*e+311.7*o+43758.5453*Math.floor(12*a));f=Math.abs(l-Math.floor(l))<s?n:x[Math.abs(Math.floor(97*l))%C],st=.3+.7*s,lt=.3+.65*s}}const ht=e*M+.5*M+it,ft=o*b+.5*b+ct;let dt;if(lt>0){const t=p(r,Q,z,F,P,K);dt=`rgb(${Math.min(255,t[0]+(E-t[0])*lt|0)},${Math.min(255,t[1]+(I-t[1])*lt|0)},${Math.min(255,t[2]+(R-t[2])*lt|0)})`}else dt=m(r,Q,z,F,P,K);if(i){const e=h[f]??.5,o=Math.min(1,.00392156863*r.a*L*(1+st))*e;if(o<.02)continue;o!==nt&&(t.globalAlpha=o,nt=o),dt!==ot&&(t.fillStyle=dt,ot=dt);const n=M*at,a=b*at;t.fillRect(ht-.5*n,ft-.5*a,n,a)}else{const e=Math.min(1,.00392156863*r.a*L*(1+st));e!==nt&&(t.globalAlpha=e,nt=e),dt!==ot&&(t.fillStyle=dt,ot=dt),1!==at?(t.translate(ht,ft),t.scale(at,at),t.fillText(f,0,0),t.setTransform(g)):t.fillText(f,ht,ft)}}}}t.globalAlpha=1}function H(t,e){const o=Math.min(1,2048/Math.max(t,e));return{renderW:Math.round(t*o),renderH:Math.round(e*o)}}function j(t,e,o,n,r){const{width:a,height:i}=e.getBoundingClientRect();if(!a||!i)return{renderW:0,renderH:0,dpr:1};let c,s,l=a,h=l/o;h>i&&(h=i,l=h*o),l=Math.round(l),h=Math.round(h),n&&r?({renderW:c,renderH:s}=H(n,r)):(c=l,s=h);const f="undefined"!=typeof window&&window.devicePixelRatio||1,d=8e6,u=c*f*s*f>d?Math.sqrt(d/(c*s)):f;return t.width=Math.round(c*u),t.height=Math.round(s*u),t.style.width=l+"px",t.style.height=h+"px",{renderW:c,renderH:s,dpr:u}}async function W(t,e,{fontSize:o,artStyle:n="classic",options:r={}}={}){let c;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}),c=e}else t instanceof HTMLImageElement&&!t.complete?(await new Promise((e,o)=>{t.onload=()=>e(),t.onerror=()=>o(new Error("Image failed to load"))}),c=t):c=t;const s=a[n],l=o??r.fontSize??10,h={...i,...s,...r,fontSize:l},f=e.getContext("2d");if(!f)throw new Error("Could not get 2d context from canvas");const{w:d,h:u}=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}}(c),{renderW:g,renderH:m}=H(d,u),M="undefined"!=typeof window&&window.devicePixelRatio||1,p=8e6,b=g*M*m*M>p?Math.sqrt(p/(g*m)):M;(e.width<g||e.height<m)&&(e.width=Math.round(g*b),e.height=Math.round(m*b));const{frame:v}=F(c,h,g,m);if(h.hoverStrength>0){let t=null,o=!1,n=0;const r=o=>{const n=e.getBoundingClientRect();t={x:(o.clientX-n.left)/n.width,y:(o.clientY-n.top)/n.height}},a=()=>{t=null};e.addEventListener("mousemove",r),e.addEventListener("mouseleave",a);const i=e=>{o||(f.save(),f.setTransform(b,0,0,b,0,0),L(f,v,h,g,m,e/1e3,t),f.restore(),n=requestAnimationFrame(i))};return n=requestAnimationFrame(i),()=>{o=!0,cancelAnimationFrame(n),e.removeEventListener("mousemove",r),e.removeEventListener("mouseleave",a)}}f.save(),f.setTransform(b,0,0,b,0,0),L(f,v,h,g,m),f.restore()}async function O(t,e,{fontSize:o,artStyle:n="classic",options:r={}}={}){const c="string"==typeof t?await fetch(t).then(t=>t.arrayBuffer()):t,s=o??r.fontSize??10,l={...i,...a[n],...r,fontSize:s},h=e.getContext("2d");if(!h)throw new Error("Could not get 2d context from canvas");const{frames:f,fps:d}=await B(c,l,e.width,e.height);let u,g=!1,m=0,M=performance.now();const p=1e3/d,b=t=>{g||(t-M>=p&&(L(h,f[m],l,e.width,e.height),m=(m+1)%f.length,M=t),u=requestAnimationFrame(b))};return u=requestAnimationFrame(b),()=>{g=!0,cancelAnimationFrame(u)}}async function Y(t,e,{fontSize:o,artStyle:n="classic",options:r={},fitTo:c,preExtract:s=!1,trim:l,onReady:h,onFrame:f}={}){const d=l?.start??0,u=l?.end,g=o??r.fontSize??10,m={...i,...a[n],...r,fontSize:g},M=e.getContext("2d");if(!M)throw new Error("asciifyVideo: could not get 2d context from canvas.");const p="string"==typeof c?document.querySelector(c):c instanceof HTMLElement?c:null;if(s){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,p&&j(e,p,o.videoWidth/o.videoHeight,o.videoWidth,o.videoHeight);const{renderW:n,renderH:r}=H(o.videoWidth,o.videoHeight),a="undefined"!=typeof window&&window.devicePixelRatio||1,i=8e6,c=n*a*r*a>i?Math.sqrt(i/(n*r)):a;e.width<Math.round(n*c)&&(e.width=Math.round(n*c),e.height=Math.round(r*c));const s=void 0!==u?u-d:10,{frames:l,fps:g}=await P(o,m,n,r,void 0,s,void 0,d);let b,v=!1,x=0,y=performance.now(),w=!0;const $=1e3/g,S=t=>{v||(t-y>=$&&(M.save(),M.setTransform(c,0,0,c,0,0),L(M,l[x],m,n,r),M.restore(),x=(x+1)%l.length,y=t,w&&(w=!1,h?.(o)),f?.()),b=requestAnimationFrame(S))};return b=requestAnimationFrame(S),()=>{v=!0,cancelAnimationFrame(b)}}let b,v=!1;"string"==typeof t?(b=document.createElement("video"),b.src=t,b.muted=!0,b.loop=!0,b.playsInline=!0,b.setAttribute("playsinline",""),Object.assign(b.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(b),v=!0,await new Promise((e,o)=>{b.onloadedmetadata=()=>e(),b.onerror=()=>o(new Error(`asciifyVideo: failed to load "${t}"`))}),await b.play().catch(()=>{})):(b=t,b.paused&&await b.play().catch(()=>{})),d>0&&(b.currentTime=d,await new Promise(t=>{const e=()=>{b.removeEventListener("seeked",e),t()};b.addEventListener("seeked",e)}));let x=null;(d>0||void 0!==u)&&(x=()=>{(void 0!==u&&b.currentTime>=u||d>0&&b.currentTime<d)&&(b.currentTime=d)},b.addEventListener("timeupdate",x));let y=null;const{renderW:w,renderH:$}=H(b.videoWidth,b.videoHeight);if(p){const t=b.videoWidth/b.videoHeight,o=b.videoWidth,n=b.videoHeight,r=j(e,p,t,o,n),a=e.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0),y=new ResizeObserver(()=>{const r=j(e,p,t,o,n),a=e.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0)}),y.observe(p)}else{const t="undefined"!=typeof window&&window.devicePixelRatio||1,o=8e6,n=w*t*$*t>o?Math.sqrt(o/(w*$)):t;e.width<Math.round(w*n)&&(e.width=Math.round(w*n),e.height=Math.round($*n)),M.setTransform(n,0,0,n,0,0)}let S,C=!1,E=!0;const I=()=>{if(C)return;if(S=requestAnimationFrame(I),b.readyState<2||0===e.width||0===e.height)return;if(d>0&&b.currentTime<d)return;if(void 0!==u&&b.currentTime>=u)return;const{frame:t}=F(b,m,w,$);t.length>0&&(L(M,t,m,w,$,0,null),E&&(E=!1,h?.(b)),f?.())};return S=requestAnimationFrame(I),()=>{C=!0,cancelAnimationFrame(S),y?.disconnect(),x&&b.removeEventListener("timeupdate",x),v&&(b.pause(),b.src="",document.body.removeChild(b))}}function U(t,e,o){return Y(t,e,o)}function X(t,e,o,n,r={}){const{fontSize:a=13,chars:i="0123456789ABCDEF@#$&*+=/<>",accentColor:c,color:s,speed:l=1,density:h=.55,tailLength:f=14,lightMode:d=!1}=r,u=c??(d?"#6b8700":"#d4ff00"),g=.62*a,m=1.4*a,M=Math.ceil(e/g),p=Math.ceil(o/m);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let b=255,v=255,x=255;if(d&&(b=55,v=55,x=55),s){const t=S(s);t&&(b=t.r,v=t.g,x=t.b)}let y=212,w=255,$=0;const C=S(u);C&&(y=C.r,w=C.g,$=C.b);const E=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)*E,a=Math.floor((n*o*7+r)%E),c=e*g;for(let o=0;o<=f;o++){const r=a-(f-o);if(r<0||r>=p)continue;const s=r*m,l=I(53*e+Math.floor(5*n+o),7*r),h=i[Math.floor(l*i.length)],u=o/f;if(o===f)t.fillStyle=`rgba(${y},${w},${$},${d?.7:.85})`;else{const e=d?.85*u:.15*u;t.fillStyle=`rgba(${b},${v},${x},${e})`}t.fillText(h,c,s)}}}function D(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:c=" . · * + ° ★",accentColor:s,color:l,speed:h=1,count:f=180,lightMode:d=!1}=a,u=s??(d?"#6b8700":"#d4ff00");t.clearRect(0,0,e,o),t.textBaseline="middle",t.textAlign="center";const g=e*(.2+.6*r.x),m=o*(.2+.6*r.y),M=.65*Math.sqrt(e*e+o*o);let p=255,b=255,v=255;if(d&&(p=55,b=55,v=55),l){const t=S(l);t&&(p=t.r,b=t.g,v=t.b)}let x=212,y=255,w=0;const $=S(u);$&&(x=$.r,y=$.g,w=$.b);const C=c.replace(/ /g,"").split("");if(0!==C.length){for(let r=0;r<f;r++){const a=I(17*r,3)*Math.PI*2,c=(n*(.15+.85*I(31*r,7))*h*.22+I(13*r,11))%1,s=g+Math.cos(a)*c*M,l=m+Math.sin(a)*c*M;if(s<-20||s>e+20||l<-20||l>o+20)continue;const f=Math.max(6,i*(.4+.9*c));t.font=`${f}px monospace`;const u=C[Math.min(C.length-1,Math.floor(c*C.length))],$=c>.72,S=d?.85*c:.2*c;t.fillStyle=$?`rgba(${x},${y},${w},${Math.min(d?.92:.32,2.2*S)})`:`rgba(${p},${b},${v},${S})`,t.fillText(u,s,l)}t.textAlign="left"}}function V(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:c=". · ○ ◎ ●",accentColor:s,color:l,rings:h=5,speed:f=1,sharpness:d=4,lightMode:u=!1}=a,g=s??(u?"#007a5e":"#00ffcc");t.clearRect(0,0,e,o),t.textBaseline="middle",t.textAlign="center";const m=e*r.x,M=o*r.y,p=1.6*Math.sqrt(m*m+M*M)+.2*Math.sqrt(e*e+o*o);let b=255,v=255,x=255;if(u&&(b=55,v=55,x=55),l){const t=S(l);t&&(b=t.r,v=t.g,x=t.b)}let y=0,w=255,$=204;const C=S(g);C&&(y=C.r,w=C.g,$=C.b);const E=c.replace(/ /g,"").split("");if(0===E.length)return;const I=Math.ceil(e/i),R=Math.ceil(o/i);for(let e=0;e<R;e++)for(let o=0;o<I;o++){const r=o*i+.5*i,a=e*i+.5*i,c=r-m,s=a-M,l=Math.sqrt(c*c+s*s)/p;let g=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)));g+=Math.cos(r*Math.PI*.5)*r}if(g=Math.min(1,g),g<.02)continue;const S=g>.6;t.font=`${i}px monospace`;const C=Math.floor(g*(E.length-1)),I=E[Math.min(C,E.length-1)],R=u?.88*g:.22*g;t.fillStyle=S?`rgba(${y},${w},${$},${Math.min(u?.95:.4,.55*g)})`:`rgba(${b},${v},${x},${R})`,t.fillText(I,r,a)}t.textAlign="left"}function J(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:c=" .·:;=+*#%@░▒▓",accentColor:s,color:l,octaves:h=4,speed:f=1,scale:d=1,accentThreshold:u=.78,mouseWarp:g=.3,lightMode:m=!1}=a,M=s??(m?"#6b8700":"#d4ff00"),p=.62*i,b=1.4*i,v=Math.ceil(e/p),x=Math.ceil(o/b);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let y=255,w=255,$=255;if(m&&(y=55,w=55,$=55),l){const t=S(l);t&&(y=t.r,w=t.g,$=t.b)}let C=212,E=255,I=0;const A=S(M);A&&(C=A.r,E=A.g,I=A.b);const T=.035*d,k=n*f,z=Math.min(6,Math.max(1,h)),q=(t,e)=>{let o=0,n=.5,r=1,a=0;for(let i=0;i<z;i++)o+=R(t*r,e*r)*n,a+=n,n*=.5,r*=2.1;return o/a};for(let e=0;e<x;e++)for(let o=0;o<v;o++){const n=o*T+.06*k,a=e*T*1.3-.04*k,i=o/v-r.x,s=e/x-r.y,l=Math.sqrt(i*i+s*s),h=g>0?.12*Math.max(0,1-l/g):0,f=.5*q(n+h*Math.sin(1.3*k+8*s),a+h*Math.cos(.9*k+8*i))+.5;if(f<.12)continue;const d=c[Math.floor(f*(c.length-1))];if(" "===d)continue;const M=f>u,S=m?.82*f:.13*f;t.fillStyle=M?`rgba(${C},${E},${I},${m?.92:.28})`:`rgba(${y},${w},${$},${S})`,t.fillText(d,o*p,e*b)}}function _(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=12,chars:c="·-=+|/",accentColor:s,color:l,bands:h=3,speed:f=1,bandWidth:d=.12,glitch:u=!0,lightMode:g=!1}=a,m=s??(g?"#6b8700":"#d4ff00"),M=.62*i,p=1.4*i,b=Math.ceil(e/M),v=Math.ceil(o/p);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let x=255,y=255,w=255;if(g&&(x=55,y=55,w=55),l){const t=S(l);t&&(x=t.r,y=t.g,w=t.b)}let $=212,C=255,E=0;const R=S(m);R&&($=R.r,C=R.g,E=R.b);const A=n*f;for(let e=0;e<v;e++)for(let o=0;o<b;o++){const n=e/v,a=((n*h-.5*A)%1+1)%1,i=Math.max(0,1-a/d),s=.35*(.5*I(3*o,7*e)+.5);let l=0;if(u){const t=o/b-r.x,a=n-r.y,i=Math.sqrt(t*t+a*a);if(i<.18){const t=I(11*o+Math.floor(12*A),5*e);l=Math.max(0,1-i/.18)*(t>.5?t-.3:0)}}const f=Math.min(1,s+.8*i+.6*l);if(f<.04)continue;const m=c[Math.floor(f*(c.length-1))],S=i>.55,R=g?.82*f:.12*f;t.fillStyle=S?`rgba(${$},${C},${E},${g?.92:.28})`:`rgba(${x},${y},${w},${R})`,t.fillText(m,o*M,e*p)}}function N(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:c=" ·∙•:;+=≡≣#@",color:s,accentColor:l,speed:h=1,layers:f=5,softness:d=1.2,mouseRipple:u=.2,lightMode:g=!1}=a,m=l??(g?"#6b8700":"#d4ff00"),M=.62*i,p=1.4*i,b=Math.ceil(e/M),v=Math.ceil(o/p);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let x=255,y=255,w=255;if(g&&(x=55,y=55,w=55),s){const t=S(s);t&&(x=t.r,y=t.g,w=t.b)}let $=212,C=255,E=0;const R=S(m);R&&($=R.r,C=R.g,E=R.b);const A=n*h,T=[];for(let t=0;t<f;t++){const e=I(17*t,31*t+7),o=I(23*t+5,11*t);T.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<v;e++){const o=e/v;for(let n=0;n<b;n++){const a=n/b,i=a-r.x,s=o-r.y,l=Math.sqrt(i*i+s*s),h=u*Math.exp(-l*l/.06),m=a+i*h,v=o+s*h;let S=0,I=0;for(let t=0;t<f;t++){const{fx:e,fy:o,phase:n,dt:r,amp:a}=T[t];S+=Math.sin(m*e*Math.PI*2+A*r+n)*Math.cos(v*o*Math.PI*2+A*r*.7+1.3*n)*a,I+=a}const R=S/I,k=.5+.5*Math.tanh(R*d*2.2);if(k<.12)continue;const z=(k-.12)/.88,q=c[Math.min(c.length-1,Math.floor(z*c.length))],F=k>.82,P=g?.82*k:.14*k;t.fillStyle=F?`rgba(${$},${C},${E},${g?.92:.32})`:`rgba(${x},${y},${w},${P})`,t.fillText(q,n*M,e*p)}}}function G(t,e,o,n,r={}){const{fontSize:a=13,color:i,accentColor:c,speed:s=.4,layers:l=4,turbulence:h=.8,lightMode:f=!1}=r,d=c??(f?"#6b8700":"#d4ff00"),u=.62*a,g=1.4*a,m=Math.ceil(e/u),M=Math.ceil(o/g);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let p=255,b=255,v=255;if(f&&(p=55,b=55,v=55),i){const t=S(i);t&&(p=t.r,b=t.g,v=t.b)}let x=212,y=255,w=0;const $=S(d);$&&(x=$.r,y=$.g,w=$.b);const C=n*s,E=["─","─","╌","·","╌","─","─","╌","·"];for(let e=0;e<M;e++){const o=e/M;for(let n=0;n<m;n++){const r=n/m;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,c=.9+2*I(29*t,11*t+1),s=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+C*l+s),d=Math.cos(o*c*Math.PI*2+C*l*.6+1.7*s),u=Math.sin(r*c*Math.PI*h+o*n*Math.PI*h+C*l*.4);a+=Math.atan2(d+.3*u,f),i+=.5*(f*d+1)}const c=a/l,s=Math.min(1,i/l);if(s<.1)continue;const d=(c+Math.PI)/(2*Math.PI),M=E[Math.floor(d*E.length)%E.length],$=s>.8,S=f?.8*s:.13*s;t.fillStyle=$?`rgba(${x},${y},${w},${f?.9:.26})`:`rgba(${p},${b},${v},${S})`,t.fillText(M,n*u,e*g)}}}function K(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=13,chars:c=" ·:;=+*#%@",color:s,accentColor:l,speed:h=1,radius:f=.38,swirl:d=3,lightMode:u=!1}=a,g=l??(u?"#6b8700":"#d4ff00"),m=.62*i,M=1.4*i,p=Math.ceil(e/m),b=Math.ceil(o/M),v=e/o;t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let x=255,y=255,w=255;if(u&&(x=55,y=55,w=55),s){const t=S(s);t&&(x=t.r,y=t.g,w=t.b)}let $=212,C=255,E=0;const R=S(g);R&&($=R.r,C=R.g,E=R.b);const A=n*h;for(let e=0;e<b;e++){const o=e/b;for(let n=0;n<p;n++){const a=(n/p-r.x)*v,i=o-r.y,s=Math.sqrt(a*a+i*i)/f;if(s>1){const o=I(3*n,7*e)*Math.max(0,1-3*(s-1));if(o<.62)continue;const r=o*(u?.28:.04);t.fillStyle=`rgba(${x},${y},${w},${r})`,t.fillText(c[1],n*m,e*M);continue}const l=Math.max(0,1-Math.abs(s-(.15+.12*Math.sin(1.1*A)))/.07),h=Math.pow(1-s,2.2),d=Math.min(1,h+.6*l);if(d<.06)continue;const g=Math.floor(d*(c.length-1)),b=c[Math.min(c.length-1,g)],S=l>.35||s<.08,R=u?.85*d:.18*d;t.fillStyle=S?`rgba(${$},${C},${E},${u?.95:.38})`:`rgba(${x},${y},${w},${R})`,t.fillText(b,n*m,e*M)}}}function Q(t,e,o,n,r={}){const{fontSize:a=14,chars:i=" ·∙•:-=+*#",color:c,accentColor:s,speed:l=.5,harmonics:h=3,lightMode:f=!1}=r,d=s??(f?"#6b8700":"#d4ff00"),u=.62*a,g=1.4*a,m=Math.ceil(e/u),M=Math.ceil(o/g);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let p=255,b=255,v=255;if(f&&(p=55,b=55,v=55),c){const t=S(c);t&&(p=t.r,b=t.g,v=t.b)}let x=212,y=255,w=0;const $=S(d);$&&(x=$.r,y=$.g,w=$.b);const C=n*l,E=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<m;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(C*r+a)*i}const r=.5*(n/E+1);if(r<.28)continue;const a=(r-.28)/.72,c=i[Math.min(i.length-1,Math.floor(a*i.length))],s=r>.88,l=f?.82*a:.13*a;t.fillStyle=s?`rgba(${x},${y},${w},${f?.92:.28})`:`rgba(${p},${b},${v},${l})`,t.fillText(c,o*u,e*g)}}function Z(t,e,o,n,r={}){const{fontSize:a=13,chars:i=" .,:;i+xX#&@",color:c="#ff4500",hotColor:s="#ffe066",intensity:l=.85,wind:h=0,speed:f=1,lightMode:d=!1}=r,u=.62*a,g=1.4*a,m=Math.ceil(e/u),M=Math.ceil(o/g),p=m*M,b="__fire_heat__",v=t.canvas;let x=v[b];x&&x.length===p||(x=new Float32Array(p),v[b]=x);const y=.18*(.016*f),w=h*f*.8,$=M-1,C=n*f;for(let t=0;t<m;t++){const e=(.6*(.5*Math.sin(.31*t+4.1*C)+.5)+.4*(.5*Math.sin(.73*t-2.7*C)+.5))*l;x[$*m+t]=Math.min(1,e+.15*Math.random()*l),$>0&&(x[($-1)*m+t]=Math.min(1,.85*e+.1*Math.random()*l))}const E=new Float32Array(p);for(let t=0;t<M-2;t++)for(let e=0;e<m;e++){const o=.4*x[(t+1)*m+e]+.25*x[(t+2)*m+Math.max(0,Math.min(m-1,e+Math.round(w)))]+.175*x[(t+1)*m+Math.max(0,e-1)]+.175*x[(t+1)*m+Math.min(m-1,e+1)];E[t*m+e]=Math.max(0,o-y-.02*Math.random()*f)}for(let t=0;t<m;t++)E[(M-1)*m+t]=x[(M-1)*m+t],M>1&&(E[(M-2)*m+t]=x[(M-2)*m+t]);v[b]=E;const I=S(c)??{r:255,g:69,b:0},R=S(s)??{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<m;o++){const n=E[e*m+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),c=I.r+(R.r-I.r)*a|0,s=I.g+(R.g-I.g)*a|0,l=I.b+(R.b-I.b)*a|0,h=d?1-.3*n:Math.min(1,n+.15);t.globalAlpha=h,t.fillStyle=`rgb(${c},${s},${l})`,t.fillText(r,o*u,e*g)}t.globalAlpha=1}function tt(t,e,o,n,r={}){const{fontSize:a=13,baseChars:i="ATCG",bridgeChars:c="-=≡",color:s="#00e5ff",color2:l="#ff4081",bridgeColor:h="#88ffcc",speed:f=1,helixCount:d,lightMode:u=!1}=r,g=.62*a,m=1.4*a,M=Math.ceil(e/g),p=Math.ceil(o/m),b=d??Math.max(1,Math.floor(e/80)),v=M/b,x=S(s)??{r:0,g:229,b:255},y=S(l)??{r:255,g:64,b:129},w=S(h)??{r:136,g:255,b:204};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const $=n*f,C=.35*v;for(let e=0;e<b;e++){const o=v*(e+.5);for(let n=0;n<p;n++){const r=n/p*Math.PI*6-1.8*$,a=o+Math.sin(r)*C,s=o+Math.sin(r+Math.PI)*C,l=Math.round(a),h=Math.round(s);if(l<0||l>=M)continue;const f=I(31*e+7*n,3),d=i[Math.floor(f*i.length)],u=.5*(Math.sin(r)+1),b=.5*(Math.sin(r+Math.PI)+1);if(t.globalAlpha=.35+.65*u,t.fillStyle=`rgb(${x.r},${x.g},${x.b})`,t.fillText(d,l*g,n*m),h>=0&&h<M){const o=I(53*e+11*n,7),r=i[Math.floor(o*i.length)];t.globalAlpha=.35+.65*b,t.fillStyle=`rgb(${y.r},${y.g},${y.b})`,t.fillText(r,h*g,n*m)}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=c[Math.floor(a*c.length)],s=.25*(u+b)+.2;t.globalAlpha=s,t.fillStyle=`rgb(${w.r},${w.g},${w.b})`;for(let e=o+1;e<r;e++)t.fillText(i,e*g,n*m)}}}}t.globalAlpha=1}function et(t,e,o,n,r={}){const{fontSize:a=13,chars:i=" .,:;+*#@",color:c="#4caf50",skyColor:s="#1a237e",peakColor:l="#e0e0e0",speed:h=1,roughness:f=.55,heightScale:d=.55,stars:u=!0,lightMode:g=!1}=r,m=.62*a,M=1.4*a,p=Math.ceil(e/m),b=Math.ceil(o/M),v=S(c)??{r:76,g:175,b:80},x=S(s)??{r:26,g:35,b:126},y=S(l)??{r:224,g:224,b:224};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const w=n*h*.4,$=new Array(p);for(let t=0;t<p;t++){const e=(.5*A((t/p+w)*f*3,.5)+.5)*d;$[t]=Math.floor(e*b)}for(let e=0;e<b;e++)for(let o=0;o<p;o++){const r=b-1-$[o],a=e===r;if(!(e>=r)){if(u){const r=I(7*o+Math.floor(.3*w),13*e);if(r>.97){const a=.3*Math.sin(2*n+100*r)+.7;t.globalAlpha=.5*a,t.fillStyle=`rgb(${x.r+60},${x.g+60},${x.b+80})`,t.fillText("·",o*m,e*M)}}continue}const c=(e-r)/Math.max(1,$[o]),s=i[Math.min(i.length-1,Math.floor(c*i.length))];if(" "===s&&!a)continue;const l=a?1:Math.max(0,1-4*c),h=v.r+(y.r-v.r)*l|0,f=v.g+(y.g-v.g)*l|0,d=v.b+(y.b-v.b)*l|0;t.globalAlpha=.5+.5*c,t.fillStyle=`rgb(${h},${f},${d})`,t.fillText(a?i[i.length-1]:s,o*m,e*M)}t.globalAlpha=1}var ot=1,nt=2,rt=4,at=8,it={3:"─",12:"│",9:"┌",10:"┐",5:"└",6:"┘",11:"┬",7:"┴",13:"├",14:"┤",15:"┼",[ot]:"╶",[nt]:"╴",[rt]:"╵",[at]:"╷"};function ct(t,e,o,n,r={}){const{fontSize:a=13,pulseColor:i="#ffffff",color:c="#00ff88",density:s=.38,speed:l=1,lightMode:h=!1}=r,f=.62*a,d=1.4*a,u=Math.ceil(e/f),g=Math.ceil(o/d),m=S(c)??{r:0,g:255,b:136},M=S(i)??{r:255,g:255,b:255},p=(t,e)=>{if(I(17*t+1,7*e+2)>s)return 0;let o=0;return t+1<u&&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<g&&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 b=n*l;for(let e=0;e<g;e++)for(let o=0;o<u;o++){const n=p(o,e);if(0===n)continue;const r=it[n]??"·",a=(8*b+40*I(o,23*e))%u,i=(6*b+40*I(17*e,11*o))%g,c=(1&n||2&n)&&Math.abs(o-a)<1.5,s=(4&n||8&n)&&Math.abs(e-i)<1.5,l=c||s,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(${m.r},${m.g},${m.b})`),t.fillText(r,o*f,e*d)}t.globalAlpha=1}var st=["wave","rain","stars","pulse","noise","grid","aurora","silk","void","morph","fire","dna","terrain","circuit"];function lt(t,e={}){const{type:o="wave",opacity:n=.2,className:r,zIndex:a=0,colorScheme:i="auto",color:c,...s}=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"),u=window.devicePixelRatio||1,g={x:.5,y:.5},m={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=c?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}(c):null,b=()=>({...s,lightMode:void 0!==s.lightMode?s.lightMode:M(),baseColor:p?`rgba(${p.r},${p.g},${p.b},{a})`:s.baseColor}),v={current:b()},x=()=>{v.current="rain"===o||"stars"===o||"pulse"===o||"noise"===o||"grid"===o||"aurora"===o||"silk"===o||"void"===o||"morph"===o?{...s,lightMode:void 0!==s.lightMode?s.lightMode:M(),color:c??s.color}:"fire"===o||"dna"===o?{...s,color:c??s.color}:"terrain"===o||"circuit"===o?{...s,color:c??s.color,lightMode:void 0!==s.lightMode?s.lightMode:M()}:b()};x();const y=window.matchMedia("(prefers-color-scheme: light)"),w=()=>{x()};let $=null;"auto"===i&&(y.addEventListener("change",w),$=new MutationObserver(w),$.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]}));const S=()=>{const t=l.getBoundingClientRect();f.width=t.width*u,f.height=t.height*u,d.setTransform(u,0,0,u,0,0)};S();const C=t=>{const e=l.getBoundingClientRect();g.x=(t.clientX-e.left)/e.width,g.y=(t.clientY-e.top)/e.height},E=new ResizeObserver(S);E.observe(l),window.addEventListener("mousemove",C);let I=0,R=0;const A=()=>{m.x+=.07*(g.x-m.x),m.y+=.07*(g.y-m.y);const t=l.getBoundingClientRect();"rain"===o?X(d,t.width,t.height,I,v.current):"stars"===o?D(d,t.width,t.height,I,m,v.current):"pulse"===o?V(d,t.width,t.height,I,m,v.current):"noise"===o?J(d,t.width,t.height,I,m,v.current):"grid"===o?_(d,t.width,t.height,I,m,v.current):"aurora"===o?N(d,t.width,t.height,I,m,v.current):"silk"===o?G(d,t.width,t.height,I,v.current):"void"===o?K(d,t.width,t.height,I,m,v.current):"morph"===o?Q(d,t.width,t.height,I,v.current):"fire"===o?Z(d,t.width,t.height,I,v.current):"dna"===o?tt(d,t.width,t.height,I,v.current):"terrain"===o?et(d,t.width,t.height,I,v.current):"circuit"===o?ct(d,t.width,t.height,I,v.current):T(d,t.width,t.height,I,m,v.current),I+=.016,R=requestAnimationFrame(A)};return R=requestAnimationFrame(A),{destroy:()=>{cancelAnimationFrame(R),E.disconnect(),"auto"===i&&(y.removeEventListener("change",w),$?.disconnect()),window.removeEventListener("mousemove",C),f.remove(),l.style.position=h}}}var ht=lt;function ft(t,e={},o,n){const r={...i,...e},{frame:a,cols:c}=F(t,r,o,n);if(!a.length||0===c)return"";const s=[];for(const t of a)s.push(t.map(t=>t.char).join(""));return s.join("\n")}function dt(t,e={},o,n){const r={...i,...e},{frame:a,cols:c}=F(t,r,o,n);if(!a.length||0===c)return"";const s=[];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}`;s.push(e)}return s.join("\n")}function ut(t,e,o,n="#505050",r=100){if(!t||e<=0||o<=0)return[];const a=S(n)??{r:80,g:80,b:80},i=t,c=i.length;return Array.from({length:o},(t,o)=>Array.from({length:e},(t,n)=>({char:i[(o*e+n)%c],r:a.r,g:a.g,b:a.b,a:r})))}function gt(t,e,o,n,r={},a){const{fontSize:c=10,lineHeight:s=1.6,color:l="#505050",opacity:h=100,hoverEffect:f="spotlight",hoverStrength:d=.85,hoverRadius:u=.18,hoverColor:g="#d4ff00"}=r;L(t,ut(n,Math.max(1,Math.floor(e/c)),Math.max(1,Math.floor(o/(c*s))),l,h),{...i,hoverEffect:f,hoverStrength:d,hoverRadius:u,hoverColor:g},e,o,0,a??null)}function mt(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 Mt(t,e={}){const{filename:o="asciify-snapshot",format:n="png",...r}=e,a=await mt(t,{format:n,...r}),i="jpeg"===n?"jpg":n,c=document.createElement("a");c.href=URL.createObjectURL(a),c.download=`${o}.${i}`,c.click(),setTimeout(()=>URL.revokeObjectURL(c.href),1e4)}async function pt(t,{fontSize:e=10,style:o="classic",options:n={},liveOptions:r,mirror:c=!0,constraints:s={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:s}),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={...i,...a[o],...n,fontSize:e},u=t.getContext("2d");if(!u)throw new Error("asciifyWebcam: could not get 2d context from canvas.");const g=l??("undefined"!=typeof window?window.devicePixelRatio:1)??1;1!==g&&u.scale(g,g);let m=null;const M={x:.5,y:.5,intensity:0},p=e=>{const o=t.getBoundingClientRect();m={x:(e.clientX-o.left)/o.width,y:(e.clientY-o.top)/o.height}},b=()=>{m=null};d.hoverStrength>0&&(t.addEventListener("mousemove",p),t.addEventListener("mouseleave",b));let v,x=!1;const y=performance.now(),w=e=>{if(!x){if(f.readyState>=f.HAVE_CURRENT_DATA){const o=t.width/g,n=t.height/g,a=(e-y)/1e3,i=r?{...d,...r()}:d;i.hoverStrength>0?(t.addEventListener("mousemove",p),t.addEventListener("mouseleave",b)):(t.removeEventListener("mousemove",p),t.removeEventListener("mouseleave",b));const{frame:s}=F(f,i,o,n);if(m){const t=m.x-M.x,e=m.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;c?(u.save(),u.scale(-1,1),u.translate(-o,0),L(u,s,i,o,n,a,l),u.restore()):L(u,s,i,o,n,a,l)}v=requestAnimationFrame(w)}};return v=requestAnimationFrame(w),()=>{x=!0,cancelAnimationFrame(v),t.removeEventListener("mousemove",p),t.removeEventListener("mouseleave",b),h.getTracks().forEach(t=>t.stop()),f.srcObject=null}}var bt={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]},vt=[127,65,65,65,65,65,127];function xt(t){return bt[t]??bt[t.toUpperCase()]??vt}function yt(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,c=a,s=Array.from({length:i},()=>"");for(let e=0;e<t.length;e++){const o=xt(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++)s[t*a+e]+=n}if(e<t.length-1)for(let t=0;t<i;t++)s[t]+=" ".repeat(c)}return s.join("\n")}function wt(t,e,o={}){const{color:n="#d4ff00",bgColor:r,fontSize:a=10}=o,i=yt(e,o);if(!i)return;const c=i.split("\n"),s=Math.max(...c.map(t=>[...t].length));t.width=Math.ceil(s*a*.6),t.height=Math.ceil(c.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",c.forEach((t,e)=>l.fillText(t,0,e*a))}export{a as ART_STYLE_PRESETS,st as BACKGROUND_TYPES,n as CHARSETS,r as CHARSET_SEQUENCES,i as DEFAULT_OPTIONS,c as HOVER_PRESETS,o as PALETTE_THEMES,lt as asciiBackground,ft as asciiText,dt as asciiTextAnsi,W as asciify,O as asciifyGif,U as asciifyLiveVideo,yt as asciifyText,Y as asciifyVideo,pt as asciifyWebcam,ut as buildTextFrame,mt as captureSnapshot,B as gifToAsciiFrames,F as imageToAsciiFrame,ht as mountWaveBackground,N as renderAuroraBackground,ct as renderCircuitBackground,tt as renderDnaBackground,Z as renderFireBackground,L as renderFrameToCanvas,_ as renderGridBackground,Q as renderMorphBackground,J as renderNoiseBackground,V as renderPulseBackground,X as renderRainBackground,G as renderSilkBackground,D as renderStarsBackground,et as renderTerrainBackground,gt as renderTextBackground,wt as renderTextToCanvas,K as renderVoidBackground,T as renderWaveBackground,Mt as snapshotAndDownload,P as videoToAsciiFrames};//# 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,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 h(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 f(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 d=[[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=(d[o%4][e%4]/16-.5)*n*128;return Math.max(0,Math.min(255,t+r))}var m=new Array(256),g=new Array(256);for(let t=0;t<256;t++)m[t]=`rgb(${t},${t},${t})`,g[t]=`rgb(0,${t},0)`;function M(t,e,o,n,r,a=!1){switch(e){case"fullcolor":return`rgb(${t.r},${t.g},${t.b})`;case"matrix":return g[.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 m[e]}}}var p=[0,0,0];function b(t,e,o,n,r,a=!1){switch(e){case"fullcolor":p[0]=t.r,p[1]=t.g,p[2]=t.b;break;case"matrix":{const e=.299*t.r+.587*t.g+.114*t.b|0;p[0]=0,p[1]=e,p[2]=0;break}case"accent":p[0]=o,p[1]=n,p[2]=r;break;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;p[0]=e,p[1]=e,p[2]=e;break}}return p}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 w(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 x(t){if(t){const e=w(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=w(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 y(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 $={scale:1,offsetX:0,offsetY:0,glow:0,colorBlend:0,proximity:0};function S(t,e,o,n,r,a,i,s,c="spotlight",l=.5,h="circle"){const f=t-o,d=e-n,u=.08+.35*l+.04*a;let m,g;if("box"===h){const t=Math.abs(f),e=Math.abs(d);m=Math.max(t,e),g=u}else m=Math.sqrt(f*f+d*d),g=u;if(m>=g)return $.scale=1,$.offsetX=0,$.offsetY=0,$.glow=0,$.colorBlend=0,$.proximity=0,$;const M=function(t){return t*t*(3-2*t)}(1-m/g)*r;let p=1,b=0,v=0,w=0,x=0;switch(c){case"spotlight":{p=1+M*a*1.8;const t=Math.atan2(d,f),e=M*M*a*.6;b=Math.cos(t)*e*i,v=Math.sin(t)*e*s,w=M*a*.4,x=M*M*a*.25;break}case"magnify":p=1+M*a*2.5,w=M*a*.15;break;case"repel":{p=1+M*a*.3;const t=Math.atan2(d,f),e=M*M*a*1.2;b=Math.cos(t)*e*i,v=Math.sin(t)*e*s;break}case"glow":w=M*a*.8,x=M*a*.4;break;case"colorShift":p=1+M*a*.4,w=M*a*.2,x=M*a*.7;break;case"attract":{const t=Math.atan2(d,f),e=M*M*a*1;b=-Math.cos(t)*e*i,v=-Math.sin(t)*e*s,w=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);b=Math.cos(t+e)*o*i,v=Math.sin(t+e)*o*s,p=Math.max(.1,1-M*a*.6),w=M*a*.25;break}case"trail":x=M*a*.9,w=M*a*.6,p=1+M*a*.15;break;case"glitchText":p=1,w=M*a*.5,x=M*a*.6}return $.scale=p,$.offsetX=b,$.offsetY=v,$.glow=w,$.colorBlend=x,$.proximity=M,$}function C(t){const e=t.match(/^#([0-9a-f]{3,8})$/i)?.[1];if(e){const t=e.length<=4?e.split("").map(t=>parseInt(t+t,16)):[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)];return{r:t[0],g:t[1],b:t[2]}}const o=t.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i);return o?{r:+o[1],g:+o[2],b:+o[3]}:null}function E(t){return t*t*t*(t*(6*t-15)+10)}function R(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 T(t,e){const o=Math.floor(t),n=Math.floor(e),r=e-n,a=E(t-o),i=E(r),s=I(o,n),c=I(o+1,n),l=I(o,n+1),h=I(o+1,n+1);return R(R(s,c,a),R(l,h,a),i)}function A(t,e){return(.5*T(t,e)+.25*T(2.1*t,2.1*e)+.125*T(4.3*t,4.3*e))/.875}function k(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:u=.55,mouseFalloff:m=2.8,speed:g=1,vortex:M=!0,sparkles:p=!0,breathe:b=!0,lightMode:v=!1}=a,w=f??(v?"#6b8700":"#d4ff00"),x=i*s,y=i*c,$=Math.ceil(e/x),S=Math.ceil(o/y),C=r.x,E=r.y;let R=212,T=255,k=0;{const t=w.replace("#","");6===t.length&&(R=parseInt(t.slice(0,2),16),T=parseInt(t.slice(2,4),16),k=parseInt(t.slice(4,6),16))}t.clearRect(0,0,e,o),t.font=`${i}px "JetBrains Mono", monospace`,t.textBaseline="top";const F=n*g,z=b?.12*(.5*Math.sin(.22*F)+.5):0;for(let e=0;e<S;e++)for(let o=0;o<$;o++){const n=o/$,r=e/S,a=.045,i=.08*F,s=.06,c=.45*((.5*Math.sin(.08*o+.05*e+.6*F)+.5+(.5*Math.sin(.03*o-.07*e+.4*F)+.5)+(.5*Math.sin(.05*o+.03*e+.8*F)+.5))/3)+.35*(.5*A(o*a+i,e*a*1.4-.7*i)+.5)+.2*(.5*Math.sin((o+.65*e)*s+1.1*F)+.5)+z,f=n-C,g=r-E,b=Math.sqrt(f*f+g*g);let w=0;if(M&&b<.35){const t=Math.atan2(g,f),e=Math.sin(4*t+2.2*F-14*b),o=Math.max(0,1-b/.35);w=e*o*o*.22}const L=c*(1-u)+(Math.max(0,1-b*m)+.5*w)*u+.15*w,q=Math.min(1,Math.max(0,L));let P=q;if(p&&q>.72){const t=Math.floor(8*F),n=I(7*o+3*t,11*e+t);n>.88&&(P=Math.min(1,q+4*(n-.88)))}const B=Math.floor(P*(l.length-1));if(" "===l[B])continue;const H=.015+.07*P;if(P>d){const e=Math.min(v?.9:.28,H*(v?14:2.8));t.fillStyle=`rgba(${R},${T},${k},${e})`}else t.fillStyle=h?h.replace("{a}",String(H)):v?`rgba(55,55,55,${7*H})`:`rgba(255,255,255,${H})`;t.fillText(l[B],o*x,e*y)}}function F(t,e){return"auto"!==t?t:!x(e)}function z(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 L(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=z(t.getPropertyValue(e).trim());if(o)return o}const e=z(getComputedStyle(document.body).accentColor??"");if(e)return e}return x("undefined"!=typeof document?document.body:null)?"faf9f7":"0d0d0d"}function q(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,d=o||r,m=n||a,g=Math.floor(d/s),M=Math.floor(m/c);if(g<=0||M<=0)return{frame:[],cols:0,rows:0};const p=Math.max(1,Math.min(Math.floor(2048/g),Math.floor(r/g))),b=Math.max(1,Math.min(Math.floor(2048/M),Math.floor(a/M))),v=g*p,w=M*b,{ctx:x}=function(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}}(v,w);x.drawImage(t,0,0,v,w);const y=x.getImageData(0,0,v,w).data,$=e.chromaKey,S=null!=$&&!1!==$,C=!0===$,E="blue-screen"===$;let R=null,I=0;!S||C||E||(R=function(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]}}($),I=(e.chromaKeyTolerance??60)**2);let T=0,A=255;if(e.normalize){let t=255,e=0;for(let o=0;o<y.length;o+=4){if(S){const t=y[o],e=y[o+1],n=y[o+2];let r=!1;if(C)r=e>1.4*t&&e>1.4*n&&e>80;else if(E)r=n>1.4*t&&n>1.4*e&&n>80;else if(null!==R){const o=t-R.r,a=e-R.g,i=n-R.b;r=o*o+a*a+i*i<=I}if(r)continue}const n=.299*y[o]+.587*y[o+1]+.114*y[o+2];n<t&&(t=n),n>e&&(e=n)}T=t,A=e>t?e-t:255}const k=[],z=F(e.invert),L=S&&e.charset.replace(/ /g,"")||e.charset,q=p*b;for(let t=0;t<M;t++){const o=[];for(let n=0;n<g;n++){let r=0,a=0,i=0,s=0,c=0;for(let e=0;e<b;e++){const o=(t*b+e)*v;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(S){let t=!1;if(C)t=h>1.4*l&&h>1.4*f&&h>80;else if(E)t=f>1.4*l&&f>1.4*h&&f>80;else if(null!==R){const e=l-R.r,o=h-R.g,n=f-R.b;t=e*e+o*o+n*n<=I}if(t){c++;continue}}r+=l,a+=h,i+=f,s+=d}}if(S&&c>q/2){o.push({char:" ",r:0,g:0,b:0,a:0});continue}const d=q-c,m=d>0?r/d:0,M=d>0?a/d:0,w=d>0?i/d:0,x=d>0?s/d:0,$=.299*m+.587*M+.114*w,k=u(l(e.normalize?($-T)/A*255:$,e.brightness,e.contrast),n,t,e.ditherStrength),F=e.customText?f(k,e.customText,n,t,g,z):h(k,L,z);o.push({char:F,r:m,g:M,b:w,a:x,lum:k})}k.push(o)}return{frame:k,cols:g,rows:M}}async function P(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 u=s+a/r;if(u>s+c)break;t.currentTime=u,await new Promise(e=>{const o=()=>{t.removeEventListener("seeked",o),e()};t.addEventListener("seeked",o)});const m=q(t,e,o,n);h.push(m.frame),f=m.cols,d=m.rows,i?.((a+1)/l)}return{frames:h,cols:f,rows:d,fps:r}}async function B(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,u=document.createElement("canvas");u.width=f,u.height=d;const m=u.getContext("2d"),g=document.createElement("canvas");g.width=f,g.height=d;const M=g.getContext("2d"),p=[];let b=0,v=0,w=0;for(const t of c)w+=t.delay||100;const x=w/c.length,y=Math.round(Math.min(30,Math.max(5,1e3/x))),$=Math.min(c.length,300);for(let t=0;t<$;t++){const e=c[t],{dims:o,patch:s,disposalType:l}=e;3===l&&(M.clearRect(0,0,f,d),M.drawImage(u,0,0));const h=new ImageData(new Uint8ClampedArray(s.buffer),o.width,o.height),w=document.createElement("canvas");w.width=o.width,w.height=o.height;w.getContext("2d").putImageData(h,0,0),m.drawImage(w,o.left||0,o.top||0);const x=q(u,n,r,a);p.push(x.frame),b=x.cols,v=x.rows,2===l?m.clearRect(o.left||0,o.top||0,o.width,o.height):3===l&&(m.clearRect(0,0,f,d),m.drawImage(g,0,0)),i?.((t+1)/$)}return{frames:p,cols:b,rows:v,fps:y}}function H(t,e,o,n,r,a=0,i){if("waveField"===o.animationStyle){return void k(t,n,r,a,i?{x:i.x,y:i.y}:{x:.5,y:.5},{accentColor:`#${o.accentColor?L(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 l=!1;const f=Math.max(1,s>>2),d=Math.max(1,c>>2);t:for(let t=0;t<s;t+=f){const o=e[t];for(let t=0;t<c;t+=d)if(o[t].a<200){l=!0;break t}}const u=t.canvas,m=x(u);l||(t.fillStyle=m?"#0a0a0a":"#faf9f7",t.fillRect(0,0,n,r));const g=n/c,p=r/s,v=s*c,w=i?.intensity??1,$=!("none"!==o.animationStyle&&v>5e3)&&!!(i&&o.hoverStrength>0&&w>.005),C=o.hoverColor||"#ffffff",E=parseInt(C.slice(1,3),16)||255,R=parseInt(C.slice(3,5),16)||255,I=parseInt(C.slice(5,7),16)||255,T=L(o.accentColor),A=parseInt(T.substring(0,2),16)||255,z=parseInt(T.substring(2,4),16)||255,q=parseInt(T.substring(4,6),16)||255,P=v>3e4?.25:v>15e3?.4:v>5e3?.6:1,B=o.hoverRadius*P;let H=0,j=c,W=0,U=s,O=0,Y=0;if($&&i){O=i.x,Y=i.y;const t=.08+.35*B+.04*o.hoverStrength;H=Math.max(0,Math.floor((O-t)*c)-1),j=Math.min(c,Math.ceil((O+t)*c)+1),W=Math.max(0,Math.floor((Y-t)*s)-1),U=Math.min(s,Math.ceil((Y+t)*s)+1)}const D=o.animationStyle,X=o.animationSpeed,_="none"===D,J=o.hoverStrength,N=o.hoverEffect,V=B,G=o.hoverShape||"circle",K=F(o.invert,u),Q=o.colorMode,Z=2*Math.PI,tt=1/c,et=1/s;let ot="",nt=-1;if("dots"===o.renderMode){const n=.5*Math.min(g,p)*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=K?1-l:l;if(h<.02)continue;const f=_?1:y(e,o,c,s,a,D,X);let d=1,u=0,m=0,v=0,x=0;if($&&e>=H&&e<=j&&o>=W&&o<=U){const t=S(e*tt,o*et,O,Y,w,J,g,p,N,V,G);d=t.scale,u=t.offsetX,m=t.offsetY,v=t.glow,x=t.colorBlend}const C=n*h*f*d;if(C<.3)continue;const T=e*g+.5*g+u,k=o*p+.5*p+m;let F;if(x>0){const t=b(i,Q,A,z,q,K);F=`rgb(${Math.min(255,t[0]+(E-t[0])*x|0)},${Math.min(255,t[1]+(R-t[1])*x|0)},${Math.min(255,t[2]+(I-t[2])*x|0)})`}else F=M(i,Q,A,z,q,K);const L=Math.min(1,.00392156863*i.a*f*(1+v));if(L!==nt&&(t.globalAlpha=L,nt=L),F!==ot&&(t.fillStyle=F,ot=F),C<=3){const e=2*C;t.fillRect(T-C,k-C,e,e)}else t.beginPath(),t.arc(T,k,C,0,Z),t.fill()}}}else{const n=.55,r=.9*Math.min(g/n,p),i=r<6;if(!i){const e="emoji"===o.artStyle;t.font=e?`${r}px "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif`:`${r}px "JetBrains Mono", monospace`,t.textAlign="center",t.textBaseline="middle"}let l=null;const f=o.charsetFrames,d=!!f?.length,u=d?f[Math.floor(Math.max(0,a)*(o.charsetFps??2))%f.length]:o.charset;if(i){l={};const t=[...u],e=t.length;for(let o=0;o<e;o++)l[t[o]]=Math.max(.1,(o+.3)/e)}const m=i?null:t.getTransform(),v="glitchText"===N&&$,x="!@#$%^&*<>{}[]|/\\~`0123456789",C=x.length;let T="",k=0,F=0,L=0,P=0,Z=0,rt=0;if(v){const t=o.hoverText??"ASCIIFY";if(F=Math.round(O*c),L=Math.round(Y*s),Array.isArray(t)){const e=t.filter(t=>t.length>0);0===e.length&&e.push("ASCIIFY");T=e[((7*Math.floor(F/Math.max(1,Math.ceil(c/5)))+13*Math.floor(L/Math.max(1,Math.ceil(s/3))))%e.length+e.length)%e.length]}else T=t||"ASCIIFY";k=T.length,P=Math.max(3,Math.min(12,Math.round(s*B*.6)));const e=Math.floor(P/2);Z=Math.max(0,L-e),Z+P>s&&(Z=Math.max(0,s-P)),rt=F-Math.floor(k/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 f=d&&null!=r.lum?h(r.lum,u,K):r.char;if(" "===f)continue;const B=_?1:y(e,o,c,s,a,D,X);if(B<.05)continue;let at=1,it=0,st=0,ct=0,lt=0;if($&&!v&&e>=H&&e<=j&&o>=W&&o<=U){const t=S(e*tt,o*et,O,Y,w,J,g,p,N,V,G);at=t.scale,it=t.offsetX,st=t.offsetY,ct=t.glow,lt=t.colorBlend}if(v&&o>=Z&&o<Z+P){const t=e-rt;if(t>=0&&t<k){const n=T[t],r=Math.abs(o-L)/Math.max(1,.5*P),i=Math.abs(e-F)/Math.max(1,k),s=Math.max(r,i),c=Math.max(0,Math.min(1,1-.9*s)),l=43758.5453*Math.sin(127.1*e+311.7*o+43758.5453*Math.floor(12*a));f=Math.abs(l-Math.floor(l))<c?n:x[Math.abs(Math.floor(97*l))%C],ct=.3+.7*c,lt=.3+.65*c}}const ht=e*g+.5*g+it,ft=o*p+.5*p+st;let dt;if(lt>0){const t=b(r,Q,A,z,q,K);dt=`rgb(${Math.min(255,t[0]+(E-t[0])*lt|0)},${Math.min(255,t[1]+(R-t[1])*lt|0)},${Math.min(255,t[2]+(I-t[2])*lt|0)})`}else dt=M(r,Q,A,z,q,K);if(i){const e=l[f]??.5,o=Math.min(1,.00392156863*r.a*B*(1+ct))*e;if(o<.02)continue;o!==nt&&(t.globalAlpha=o,nt=o),dt!==ot&&(t.fillStyle=dt,ot=dt);const n=g*at,a=p*at;t.fillRect(ht-.5*n,ft-.5*a,n,a)}else{const e=Math.min(1,.00392156863*r.a*B*(1+ct));e!==nt&&(t.globalAlpha=e,nt=e),dt!==ot&&(t.fillStyle=dt,ot=dt),1!==at?(t.translate(ht,ft),t.scale(at,at),t.fillText(f,0,0),t.setTransform(m)):t.fillText(f,ht,ft)}}}}t.globalAlpha=1}function j(t){return Math.max(0,Math.min(1,t))}function W(t){return"string"==typeof t?document.querySelector(t):t instanceof HTMLElement?t:null}function U(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=j(o.ease?o.ease(j(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 O(t,e={}){const o=W(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=>U(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?j((a-r.top)/i):0;U(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 Y(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?j((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 D(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 X(t,e,o,n,r,a=2048){const{width:i,height:s}=e.getBoundingClientRect();if(!i||!s)return{renderW:0,renderH:0,dpr:1};let c,l,h=i,f=h/o;f>s&&(f=s,h=f*o),h=Math.round(h),f=Math.round(f),n&&r?({renderW:c,renderH:l}=D(n,r,a)):(c=h,l=f);const d="undefined"!=typeof window&&window.devicePixelRatio||1,u=8e6,m=c*d*l*d>u?Math.sqrt(u/(c*l)):d;return t.width=Math.round(c*m),t.height=Math.round(l*m),t.style.width=h+"px",t.style.height=f+"px",{renderW:c,renderH:l,dpr:m}}async function _(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:u}=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:m,renderH:g}=D(d,u),M="undefined"!=typeof window&&window.devicePixelRatio||1,p=8e6,b=m*M*g*M>p?Math.sqrt(p/(m*g)):M;(e.width<m||e.height<g)&&(e.width=Math.round(m*b),e.height=Math.round(g*b));const{frame:v}=q(i,h,m,g);if(h.hoverStrength>0){let t=null,o=!1,n=0;const r=o=>{const n=e.getBoundingClientRect();t={x:(o.clientX-n.left)/n.width,y:(o.clientY-n.top)/n.height}},a=()=>{t=null};e.addEventListener("mousemove",r),e.addEventListener("mouseleave",a);const i=e=>{o||(f.save(),f.setTransform(b,0,0,b,0,0),H(f,v,h,m,g,e/1e3,t),f.restore(),n=requestAnimationFrame(i))};return n=requestAnimationFrame(i),()=>{o=!0,cancelAnimationFrame(n),e.removeEventListener("mousemove",r),e.removeEventListener("mouseleave",a)}}f.save(),f.setTransform(b,0,0,b,0,0),H(f,v,h,m,g),f.restore()}async function J(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");const{frames:f,fps:d}=await B(i,l,e.width,e.height);let u,m=!1,g=0,M=performance.now();const p=1e3/d,b=t=>{m||(t-M>=p&&(H(h,f[g],l,e.width,e.height),g=(g+1)%f.length,M=t),u=requestAnimationFrame(b))};return u=requestAnimationFrame(b),()=>{m=!0,cancelAnimationFrame(u)}}async function N(t,e,{fontSize:o,artStyle:n="classic",options:r={},fitTo:i,preExtract:c=!1,fps:l,maxRenderDimension:h=2048,trim:f,scroll:d,onReady:u,onFrame:m}={}){const g=f?.start??0,M=f?.end,p=o??r.fontSize??10,b={...s,...a[n],...r,fontSize:p},v=e.getContext("2d");if(!v)throw new Error("asciifyVideo: could not get 2d context from canvas.");const w="string"==typeof i?document.querySelector(i):i instanceof HTMLElement?i:null;if(c){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,w&&X(e,w,o.videoWidth/o.videoHeight,o.videoWidth,o.videoHeight,h);const{renderW:n,renderH:r}=D(o.videoWidth,o.videoHeight,h),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!==M?M-g:10,f=l??(d?18:void 0),{frames:p,fps:x}=await P(o,b,n,r,f,c,void 0,g),y=t=>{const e=p[t];e&&(v.save(),v.setTransform(s,0,0,s,0,0),H(v,e,b,n,r),v.restore(),m?.())};if(d){let t=!1,n=-1;const r=!0===d?{}:d,a=Y(W(r.trigger)??w??e,r,e=>{const a=j(r.ease?r.ease(j(e)):e),i=Math.max(0,Math.min(p.length-1,Math.round(a*(p.length-1))));i!==n&&(n=i,y(i),t||(t=!0,u?.(o)),r.onUpdate?.(a,o))});return y(0),t=!0,u?.(o),a}let $,S=!1,C=0,E=performance.now(),R=!0;const I=1e3/x,T=t=>{S||(t-E>=I&&(y(C),C=(C+1)%p.length,E=t,R&&(R=!1,u?.(o))),$=requestAnimationFrame(T))};return $=requestAnimationFrame(T),()=>{S=!0,cancelAnimationFrame($)}}let x,y=!1;"string"==typeof t?(x=document.createElement("video"),x.src=t,x.muted=!0,x.loop=!0,x.playsInline=!0,x.setAttribute("playsinline",""),Object.assign(x.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(x),y=!0,await new Promise((e,o)=>{x.onloadedmetadata=()=>e(),x.onerror=()=>o(new Error(`asciifyVideo: failed to load "${t}"`))}),await x.play().catch(()=>{})):(x=t,x.paused&&await x.play().catch(()=>{})),g>0&&(x.currentTime=g,await new Promise(t=>{const e=()=>{x.removeEventListener("seeked",e),t()};x.addEventListener("seeked",e)}));let $=null;(g>0||void 0!==M)&&($=()=>{(void 0!==M&&x.currentTime>=M||g>0&&x.currentTime<g)&&(x.currentTime=g)},x.addEventListener("timeupdate",$));let S=null;const{renderW:C,renderH:E}=D(x.videoWidth,x.videoHeight,h);if(w){const t=x.videoWidth/x.videoHeight,o=x.videoWidth,n=x.videoHeight,r=X(e,w,t,o,n,h),a=e.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0),S=new ResizeObserver(()=>{const r=X(e,w,t,o,n,h),a=e.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0)}),S.observe(w)}else{const t="undefined"!=typeof window&&window.devicePixelRatio||1,o=8e6,n=C*t*E*t>o?Math.sqrt(o/(C*E)):t;e.width<Math.round(C*n)&&(e.width=Math.round(C*n),e.height=Math.round(E*n)),v.setTransform(n,0,0,n,0,0)}let R,I=!1,T=!0,A=null;const k=d&&!c,F=l&&l>0?1e3/l:0;let z=0,L=-1;if(k){const t=!0===d?{}:d;A=O(x,{...t,trigger:t.trigger??w??e,from:t.from??g,to:t.to??M})}const B=t=>{if(I)return;if(R=requestAnimationFrame(B),x.readyState<2||0===e.width||0===e.height)return;if(F>0&&t-z<F)return;if(g>0&&x.currentTime<g)return;if(void 0!==M&&x.currentTime>=M)return;if(k&&Math.abs(x.currentTime-L)<1/240)return;const{frame:o}=q(x,b,C,E);o.length>0&&(H(v,o,b,C,E,0,null),z=t,L=x.currentTime,T&&(T=!1,u?.(x)),m?.())};return R=requestAnimationFrame(B),()=>{I=!0,cancelAnimationFrame(R),A?.(),S?.disconnect(),$&&x.removeEventListener("timeupdate",$),y&&(x.pause(),x.src="",document.body.removeChild(x))}}function V(t,e,o){return N(t,e,o)}function G(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,u=s??(d?"#6b8700":"#d4ff00"),m=.62*a,g=1.4*a,M=Math.ceil(e/m),p=Math.ceil(o/g);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let b=255,v=255,w=255;if(d&&(b=55,v=55,w=55),c){const t=C(c);t&&(b=t.r,v=t.g,w=t.b)}let x=212,y=255,$=0;const S=C(u);S&&(x=S.r,y=S.g,$=S.b);const E=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)*E,a=Math.floor((n*o*7+r)%E),s=e*m;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)],u=o/f;if(o===f)t.fillStyle=`rgba(${x},${y},${$},${d?.7:.85})`;else{const e=d?.85*u:.15*u;t.fillStyle=`rgba(${b},${v},${w},${e})`}t.fillText(h,s,c)}}}function K(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,u=c??(d?"#6b8700":"#d4ff00");t.clearRect(0,0,e,o),t.textBaseline="middle",t.textAlign="center";const m=e*(.2+.6*r.x),g=o*(.2+.6*r.y),M=.65*Math.sqrt(e*e+o*o);let p=255,b=255,v=255;if(d&&(p=55,b=55,v=55),l){const t=C(l);t&&(p=t.r,b=t.g,v=t.b)}let w=212,x=255,y=0;const $=C(u);$&&(w=$.r,x=$.g,y=$.b);const S=s.replace(/ /g,"").split("");if(0!==S.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=m+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 u=S[Math.min(S.length-1,Math.floor(s*S.length))],$=s>.72,C=d?.85*s:.2*s;t.fillStyle=$?`rgba(${w},${x},${y},${Math.min(d?.92:.32,2.2*C)})`:`rgba(${p},${b},${v},${C})`,t.fillText(u,c,l)}t.textAlign="left"}}function Q(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:u=!1}=a,m=c??(u?"#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 b=255,v=255,w=255;if(u&&(b=55,v=55,w=55),l){const t=C(l);t&&(b=t.r,v=t.g,w=t.b)}let x=0,y=255,$=204;const S=C(m);S&&(x=S.r,y=S.g,$=S.b);const E=s.replace(/ /g,"").split("");if(0===E.length)return;const R=Math.ceil(e/i),I=Math.ceil(o/i);for(let e=0;e<I;e++)for(let o=0;o<R;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 m=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)));m+=Math.cos(r*Math.PI*.5)*r}if(m=Math.min(1,m),m<.02)continue;const S=m>.6;t.font=`${i}px monospace`;const C=Math.floor(m*(E.length-1)),R=E[Math.min(C,E.length-1)],I=u?.88*m:.22*m;t.fillStyle=S?`rgba(${x},${y},${$},${Math.min(u?.95:.4,.55*m)})`:`rgba(${b},${v},${w},${I})`,t.fillText(R,r,a)}t.textAlign="left"}function Z(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:u=.78,mouseWarp:m=.3,lightMode:g=!1}=a,M=c??(g?"#6b8700":"#d4ff00"),p=.62*i,b=1.4*i,v=Math.ceil(e/p),w=Math.ceil(o/b);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let x=255,y=255,$=255;if(g&&(x=55,y=55,$=55),l){const t=C(l);t&&(x=t.r,y=t.g,$=t.b)}let S=212,E=255,R=0;const I=C(M);I&&(S=I.r,E=I.g,R=I.b);const A=.035*d,k=n*f,F=Math.min(6,Math.max(1,h)),z=(t,e)=>{let o=0,n=.5,r=1,a=0;for(let i=0;i<F;i++)o+=T(t*r,e*r)*n,a+=n,n*=.5,r*=2.1;return o/a};for(let e=0;e<w;e++)for(let o=0;o<v;o++){const n=o*A+.06*k,a=e*A*1.3-.04*k,i=o/v-r.x,c=e/w-r.y,l=Math.sqrt(i*i+c*c),h=m>0?.12*Math.max(0,1-l/m):0,f=.5*z(n+h*Math.sin(1.3*k+8*c),a+h*Math.cos(.9*k+8*i))+.5;if(f<.12)continue;const d=s[Math.floor(f*(s.length-1))];if(" "===d)continue;const M=f>u,C=g?.82*f:.13*f;t.fillStyle=M?`rgba(${S},${E},${R},${g?.92:.28})`:`rgba(${x},${y},${$},${C})`,t.fillText(d,o*p,e*b)}}function tt(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:u=!0,lightMode:m=!1}=a,g=c??(m?"#6b8700":"#d4ff00"),M=.62*i,p=1.4*i,b=Math.ceil(e/M),v=Math.ceil(o/p);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let w=255,x=255,y=255;if(m&&(w=55,x=55,y=55),l){const t=C(l);t&&(w=t.r,x=t.g,y=t.b)}let $=212,S=255,E=0;const R=C(g);R&&($=R.r,S=R.g,E=R.b);const T=n*f;for(let e=0;e<v;e++)for(let o=0;o<b;o++){const n=e/v,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(u){const t=o/b-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))],C=i>.55,R=m?.82*f:.12*f;t.fillStyle=C?`rgba(${$},${S},${E},${m?.92:.28})`:`rgba(${w},${x},${y},${R})`,t.fillText(g,o*M,e*p)}}function et(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:u=.2,lightMode:m=!1}=a,g=l??(m?"#6b8700":"#d4ff00"),M=.62*i,p=1.4*i,b=Math.ceil(e/M),v=Math.ceil(o/p);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let w=255,x=255,y=255;if(m&&(w=55,x=55,y=55),c){const t=C(c);t&&(w=t.r,x=t.g,y=t.b)}let $=212,S=255,E=0;const R=C(g);R&&($=R.r,S=R.g,E=R.b);const T=n*h,A=[];for(let t=0;t<f;t++){const e=I(17*t,31*t+7),o=I(23*t+5,11*t);A.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<v;e++){const o=e/v;for(let n=0;n<b;n++){const a=n/b,i=a-r.x,c=o-r.y,l=Math.sqrt(i*i+c*c),h=u*Math.exp(-l*l/.06),g=a+i*h,v=o+c*h;let C=0,R=0;for(let t=0;t<f;t++){const{fx:e,fy:o,phase:n,dt:r,amp:a}=A[t];C+=Math.sin(g*e*Math.PI*2+T*r+n)*Math.cos(v*o*Math.PI*2+T*r*.7+1.3*n)*a,R+=a}const I=C/R,k=.5+.5*Math.tanh(I*d*2.2);if(k<.12)continue;const F=(k-.12)/.88,z=s[Math.min(s.length-1,Math.floor(F*s.length))],L=k>.82,q=m?.82*k:.14*k;t.fillStyle=L?`rgba(${$},${S},${E},${m?.92:.32})`:`rgba(${w},${x},${y},${q})`,t.fillText(z,n*M,e*p)}}}function ot(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"),u=.62*a,m=1.4*a,g=Math.ceil(e/u),M=Math.ceil(o/m);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let p=255,b=255,v=255;if(f&&(p=55,b=55,v=55),i){const t=C(i);t&&(p=t.r,b=t.g,v=t.b)}let w=212,x=255,y=0;const $=C(d);$&&(w=$.r,x=$.g,y=$.b);const S=n*c,E=["─","─","╌","·","╌","─","─","╌","·"];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+S*l+c),d=Math.cos(o*s*Math.PI*2+S*l*.6+1.7*c),u=Math.sin(r*s*Math.PI*h+o*n*Math.PI*h+S*l*.4);a+=Math.atan2(d+.3*u,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=E[Math.floor(d*E.length)%E.length],$=c>.8,C=f?.8*c:.13*c;t.fillStyle=$?`rgba(${w},${x},${y},${f?.9:.26})`:`rgba(${p},${b},${v},${C})`,t.fillText(M,n*u,e*m)}}}function nt(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:u=!1}=a,m=l??(u?"#6b8700":"#d4ff00"),g=.62*i,M=1.4*i,p=Math.ceil(e/g),b=Math.ceil(o/M),v=e/o;t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let w=255,x=255,y=255;if(u&&(w=55,x=55,y=55),c){const t=C(c);t&&(w=t.r,x=t.g,y=t.b)}let $=212,S=255,E=0;const R=C(m);R&&($=R.r,S=R.g,E=R.b);const T=n*h;for(let e=0;e<b;e++){const o=e/b;for(let n=0;n<p;n++){const a=(n/p-r.x)*v,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*(u?.28:.04);t.fillStyle=`rgba(${w},${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 m=Math.floor(d*(s.length-1)),b=s[Math.min(s.length-1,m)],C=l>.35||c<.08,R=u?.85*d:.18*d;t.fillStyle=C?`rgba(${$},${S},${E},${u?.95:.38})`:`rgba(${w},${x},${y},${R})`,t.fillText(b,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"),u=.62*a,m=1.4*a,g=Math.ceil(e/u),M=Math.ceil(o/m);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let p=255,b=255,v=255;if(f&&(p=55,b=55,v=55),s){const t=C(s);t&&(p=t.r,b=t.g,v=t.b)}let w=212,x=255,y=0;const $=C(d);$&&(w=$.r,x=$.g,y=$.b);const S=n*l,E=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(S*r+a)*i}const r=.5*(n/E+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(${w},${x},${y},${f?.92:.28})`:`rgba(${p},${b},${v},${l})`,t.fillText(s,o*u,e*m)}}function at(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,u=.62*a,m=1.4*a,g=Math.ceil(e/u),M=Math.ceil(o/m),p=g*M,b="__fire_heat__",v=t.canvas;let w=v[b];w&&w.length===p||(w=new Float32Array(p),v[b]=w);const x=.18*(.016*f),y=h*f*.8,$=M-1,S=n*f;for(let t=0;t<g;t++){const e=(.6*(.5*Math.sin(.31*t+4.1*S)+.5)+.4*(.5*Math.sin(.73*t-2.7*S)+.5))*l;w[$*g+t]=Math.min(1,e+.15*Math.random()*l),$>0&&(w[($-1)*g+t]=Math.min(1,.85*e+.1*Math.random()*l))}const E=new Float32Array(p);for(let t=0;t<M-2;t++)for(let e=0;e<g;e++){const o=.4*w[(t+1)*g+e]+.25*w[(t+2)*g+Math.max(0,Math.min(g-1,e+Math.round(y)))]+.175*w[(t+1)*g+Math.max(0,e-1)]+.175*w[(t+1)*g+Math.min(g-1,e+1)];E[t*g+e]=Math.max(0,o-x-.02*Math.random()*f)}for(let t=0;t<g;t++)E[(M-1)*g+t]=w[(M-1)*g+t],M>1&&(E[(M-2)*g+t]=w[(M-2)*g+t]);v[b]=E;const R=C(s)??{r:255,g:69,b:0},I=C(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=E[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=R.r+(I.r-R.r)*a|0,c=R.g+(I.g-R.g)*a|0,l=R.b+(I.b-R.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*u,e*m)}t.globalAlpha=1}function it(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:u=!1}=r,m=.62*a,g=1.4*a,M=Math.ceil(e/m),p=Math.ceil(o/g),b=d??Math.max(1,Math.floor(e/80)),v=M/b,w=C(c)??{r:0,g:229,b:255},x=C(l)??{r:255,g:64,b:129},y=C(h)??{r:136,g:255,b:204};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const $=n*f,S=.35*v;for(let e=0;e<b;e++){const o=v*(e+.5);for(let n=0;n<p;n++){const r=n/p*Math.PI*6-1.8*$,a=o+Math.sin(r)*S,c=o+Math.sin(r+Math.PI)*S,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)],u=.5*(Math.sin(r)+1),b=.5*(Math.sin(r+Math.PI)+1);if(t.globalAlpha=.35+.65*u,t.fillStyle=`rgb(${w.r},${w.g},${w.b})`,t.fillText(d,l*m,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*b,t.fillStyle=`rgb(${x.r},${x.g},${x.b})`,t.fillText(r,h*m,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*(u+b)+.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*m,n*g)}}}}t.globalAlpha=1}function st(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:u=!0,lightMode:m=!1}=r,g=.62*a,M=1.4*a,p=Math.ceil(e/g),b=Math.ceil(o/M),v=C(s)??{r:76,g:175,b:80},w=C(c)??{r:26,g:35,b:126},x=C(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,$=new Array(p);for(let t=0;t<p;t++){const e=(.5*A((t/p+y)*f*3,.5)+.5)*d;$[t]=Math.floor(e*b)}for(let e=0;e<b;e++)for(let o=0;o<p;o++){const r=b-1-$[o],a=e===r;if(!(e>=r)){if(u){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(${w.r+60},${w.g+60},${w.b+80})`,t.fillText("·",o*g,e*M)}}continue}const s=(e-r)/Math.max(1,$[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=v.r+(x.r-v.r)*l|0,f=v.g+(x.g-v.g)*l|0,d=v.b+(x.b-v.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 ct=1,lt=2,ht=4,ft=8,dt={3:"─",12:"│",9:"┌",10:"┐",5:"└",6:"┘",11:"┬",7:"┴",13:"├",14:"┤",15:"┼",[ct]:"╶",[lt]:"╴",[ht]:"╵",[ft]:"╷"};function ut(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,u=Math.ceil(e/f),m=Math.ceil(o/d),g=C(s)??{r:0,g:255,b:136},M=C(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<u&&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<m&&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 b=n*l;for(let e=0;e<m;e++)for(let o=0;o<u;o++){const n=p(o,e);if(0===n)continue;const r=dt[n]??"·",a=(8*b+40*I(o,23*e))%u,i=(6*b+40*I(17*e,11*o))%m,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 mt=["wave","rain","stars","pulse","noise","grid","aurora","silk","void","morph","fire","dna","terrain","circuit"];function gt(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"),u=window.devicePixelRatio||1,m={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,b=()=>({...c,lightMode:void 0!==c.lightMode?c.lightMode:M(),baseColor:p?`rgba(${p.r},${p.g},${p.b},{a})`:c.baseColor}),v={current:b()},w=()=>{v.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()}:b()};w();const x=window.matchMedia("(prefers-color-scheme: light)"),y=()=>{w()};let $=null;"auto"===i&&(x.addEventListener("change",y),$=new MutationObserver(y),$.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]}));const S=()=>{const t=l.getBoundingClientRect();f.width=t.width*u,f.height=t.height*u,d.setTransform(u,0,0,u,0,0)};S();const C=t=>{const e=l.getBoundingClientRect();m.x=(t.clientX-e.left)/e.width,m.y=(t.clientY-e.top)/e.height},E=new ResizeObserver(S);E.observe(l),window.addEventListener("mousemove",C);let R=0,I=0;const T=()=>{g.x+=.07*(m.x-g.x),g.y+=.07*(m.y-g.y);const t=l.getBoundingClientRect();"rain"===o?G(d,t.width,t.height,R,v.current):"stars"===o?K(d,t.width,t.height,R,g,v.current):"pulse"===o?Q(d,t.width,t.height,R,g,v.current):"noise"===o?Z(d,t.width,t.height,R,g,v.current):"grid"===o?tt(d,t.width,t.height,R,g,v.current):"aurora"===o?et(d,t.width,t.height,R,g,v.current):"silk"===o?ot(d,t.width,t.height,R,v.current):"void"===o?nt(d,t.width,t.height,R,g,v.current):"morph"===o?rt(d,t.width,t.height,R,v.current):"fire"===o?at(d,t.width,t.height,R,v.current):"dna"===o?it(d,t.width,t.height,R,v.current):"terrain"===o?st(d,t.width,t.height,R,v.current):"circuit"===o?ut(d,t.width,t.height,R,v.current):k(d,t.width,t.height,R,g,v.current),R+=.016,I=requestAnimationFrame(T)};return I=requestAnimationFrame(T),{destroy:()=>{cancelAnimationFrame(I),E.disconnect(),"auto"===i&&(x.removeEventListener("change",y),$?.disconnect()),window.removeEventListener("mousemove",C),f.remove(),l.style.position=h}}}var Mt=gt;function pt(t,e={},o,n){const r={...s,...e},{frame:a,cols:i}=q(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 bt(t,e={},o,n){const r={...s,...e},{frame:a,cols:i}=q(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 vt(t,e,o,n="#505050",r=100){if(!t||e<=0||o<=0)return[];const a=C(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 wt(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:u=.18,hoverColor:m="#d4ff00"}=r;H(t,vt(n,Math.max(1,Math.floor(e/i)),Math.max(1,Math.floor(o/(i*c))),l,h),{...s,hoverEffect:f,hoverStrength:d,hoverRadius:u,hoverColor:m},e,o,0,a??null)}function xt(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 yt(t,e={}){const{filename:o="asciify-snapshot",format:n="png",...r}=e,a=await xt(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 $t(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},u=t.getContext("2d");if(!u)throw new Error("asciifyWebcam: could not get 2d context from canvas.");const m=l??("undefined"!=typeof window?window.devicePixelRatio:1)??1;1!==m&&u.scale(m,m);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}},b=()=>{g=null};d.hoverStrength>0&&(t.addEventListener("mousemove",p),t.addEventListener("mouseleave",b));let v,w=!1;const x=performance.now(),y=e=>{if(!w){if(f.readyState>=f.HAVE_CURRENT_DATA){const o=t.width/m,n=t.height/m,a=(e-x)/1e3,s=r?{...d,...r()}:d;s.hoverStrength>0?(t.addEventListener("mousemove",p),t.addEventListener("mouseleave",b)):(t.removeEventListener("mousemove",p),t.removeEventListener("mouseleave",b));const{frame:c}=q(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?(u.save(),u.scale(-1,1),u.translate(-o,0),H(u,c,s,o,n,a,l),u.restore()):H(u,c,s,o,n,a,l)}v=requestAnimationFrame(y)}};return v=requestAnimationFrame(y),()=>{w=!0,cancelAnimationFrame(v),t.removeEventListener("mousemove",p),t.removeEventListener("mouseleave",b),h.getTracks().forEach(t=>t.stop()),f.srcObject=null}}var St={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]},Ct=[127,65,65,65,65,65,127];function Et(t){return St[t]??St[t.toUpperCase()]??Ct}function Rt(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=Et(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 It(t,e,o={}){const{color:n="#d4ff00",bgColor:r,fontSize:a=10}=o,i=Rt(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,mt 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,gt as asciiBackground,pt as asciiText,bt as asciiTextAnsi,_ as asciify,J as asciifyGif,V as asciifyLiveVideo,Rt as asciifyText,N as asciifyVideo,$t as asciifyWebcam,vt as buildTextFrame,xt as captureSnapshot,O as createVideoScrollScrub,B as gifToAsciiFrames,q as imageToAsciiFrame,Mt as mountWaveBackground,et as renderAuroraBackground,ut as renderCircuitBackground,it as renderDnaBackground,at as renderFireBackground,H as renderFrameToCanvas,tt as renderGridBackground,rt as renderMorphBackground,Z as renderNoiseBackground,Q as renderPulseBackground,G as renderRainBackground,ot as renderSilkBackground,K as renderStarsBackground,st as renderTerrainBackground,wt as renderTextBackground,It as renderTextToCanvas,nt as renderVoidBackground,k as renderWaveBackground,yt as snapshotAndDownload,P as videoToAsciiFrames};//# sourceMappingURL=index.js.map