asciify-engine 1.0.90 → 1.0.91

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.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("gifuct-js"),t={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:" ·╶╴╷╵─│┌┐└┘├┤┬┴┼╬░▒▓█"},o={cosmic:[t.starfield,t.circles,t.shadows],rain:[t.katakana,t.braille,t.binary],terminal:[t.pipes,t.claudeCode,t.standard],crystal:[t.shards,t.geometric,t.blocks],fluid:[t.waves,t.smoke,t.circles],pulse:[t.dense,t.standard,t.blocks],dream:[t.braille,t.shadows,t.smoke],angular:[t.geometric,t.shards,t.starfield],assistant:[t.interface,t.prompt,t.data],signal:[t.mesh,t.data,t.ascii],editorial:[t.humanist,t.waves,t.smoke]},n={classic:{renderMode:"ascii",charset:t.standard,colorMode:"grayscale"},particles:{renderMode:"dots",colorMode:"fullcolor",dotSizeRatio:.8},letters:{renderMode:"ascii",charset:t.letters,colorMode:"fullcolor"},claudeCode:{renderMode:"ascii",charset:t.claudeCode,colorMode:"accent",accentColor:"#f97316"},art:{renderMode:"ascii",charset:t.dense,colorMode:"fullcolor"},terminal:{renderMode:"ascii",charset:t.standard,colorMode:"matrix"},box:{renderMode:"ascii",charset:t.box,colorMode:"grayscale"},lines:{renderMode:"ascii",charset:t.lines,colorMode:"fullcolor"},braille:{renderMode:"ascii",charset:t.braille,colorMode:"fullcolor"},katakana:{renderMode:"ascii",charset:t.katakana,colorMode:"matrix"},musical:{renderMode:"ascii",charset:t.musical,colorMode:"accent",accentColor:"#e040fb"},emoji:{renderMode:"ascii",charset:t.emoji,colorMode:"fullcolor"},circles:{renderMode:"ascii",charset:t.circles,colorMode:"accent",accentColor:"#d4ff00"},shadows:{renderMode:"ascii",charset:t.shadows,colorMode:"accent",accentColor:"#50a0ff"},starfield:{renderMode:"ascii",charset:t.starfield,colorMode:"fullcolor"},geometric:{renderMode:"ascii",charset:t.geometric,colorMode:"grayscale"},pipes:{renderMode:"ascii",charset:t.pipes,colorMode:"accent",accentColor:"#00ff88"},waves:{renderMode:"ascii",charset:t.waves,colorMode:"fullcolor"},shards:{renderMode:"ascii",charset:t.shards,colorMode:"grayscale"},smoke:{renderMode:"ascii",charset:t.smoke,colorMode:"accent",accentColor:"#c850ff"},ascii:{renderMode:"ascii",charset:t.ascii,colorMode:"grayscale"},interface:{renderMode:"ascii",charset:t.interface,colorMode:"accent",accentColor:"#f4f1ea"},prompt:{renderMode:"ascii",charset:t.prompt,colorMode:"matrix"},data:{renderMode:"ascii",charset:t.data,colorMode:"fullcolor"},humanist:{renderMode:"ascii",charset:t.humanist,colorMode:"accent",accentColor:"#d6ccc2"},mesh:{renderMode:"ascii",charset:t.mesh,colorMode:"accent",accentColor:"#8fd3ff"}},r={agentField:{...n.interface,charsetFrames:o.assistant,charsetFps:1.6,animationStyle:"breathe",animationSpeed:.75,ditherStrength:.12,hoverEffect:"glow",hoverStrength:.42,hoverRadius:.18,hoverColor:"#f4f1ea",normalize:!0},liquidSignal:{...n.data,charsetFrames:o.signal,charsetFps:2.4,animationStyle:"melt",animationSpeed:.65,ditherStrength:.45,hoverEffect:"repel",hoverStrength:.55,hoverRadius:.22,hoverColor:"#8fd3ff",normalize:!0},cursorGravity:{...n.mesh,charsetFrames:o.angular,charsetFps:1.2,animationStyle:"orbit",animationSpeed:.9,ditherStrength:.2,hoverEffect:"attract",hoverStrength:.82,hoverRadius:.24,hoverColor:"#ffffff",normalize:!0},editorialPulse:{...n.humanist,charsetFrames:o.editorial,charsetFps:.9,animationStyle:"ripple",animationSpeed:.55,ditherStrength:.18,hoverEffect:"spotlight",hoverStrength:.35,hoverRadius:.2,hoverColor:"#fff8ea",normalize:!0},terminalFlow:{...n.prompt,charsetFrames:o.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}},a={fontSize:10,charSpacing:1,brightness:0,contrast:0,charset:t.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};function i(e,t){const o=document.createElement("canvas");o.width=e,o.height=t;const n=o.getContext("2d",{willReadFrequently:!0});return{canvas:o,ctx:n}}function s(e,t,o){let n=e+255*t;return n=259*(255*o+255)/(255*(259-255*o))*(n-128)+128,Math.max(0,Math.min(255,n))}function c(e,t,o){const n=o?1-e/255:e/255,r=[...t],a=Math.floor(n*(r.length-1));return r[Math.max(0,Math.min(r.length-1,a))]}function l(e,t,o,n,r,a){if((a?1-e/255:e/255)<.12)return" ";const i=[...t];return i[(n*r+o)%i.length]}var h=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];function f(e,t,o,n){if(n<=0)return e;const r=(h[o%4][t%4]/16-.5)*n*128;return Math.max(0,Math.min(255,e+r))}var d=new Array(256),m=new Array(256);for(let e=0;e<256;e++)d[e]=`rgb(${e},${e},${e})`,m[e]=`rgb(0,${e},0)`;function u(e,t,o,n,r,a=!1){switch(t){case"fullcolor":return`rgb(${e.r},${e.g},${e.b})`;case"matrix":return m[.299*e.r+.587*e.g+.114*e.b|0];case"accent":return`rgb(${o},${n},${r})`;default:{const t=.299*e.r+.587*e.g+.114*e.b|0;return d[t]}}}var g=[0,0,0];function M(e,t,o,n,r,a=!1){switch(t){case"fullcolor":g[0]=e.r,g[1]=e.g,g[2]=e.b;break;case"matrix":{const t=.299*e.r+.587*e.g+.114*e.b|0;g[0]=0,g[1]=t,g[2]=0;break}case"accent":g[0]=o,g[1]=n,g[2]=r;break;default:{const t=.299*e.r+.587*e.g+.114*e.b|0;g[0]=t,g[1]=t,g[2]=t;break}}return g}function p(e){const t=e.match(/rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)(?:\s*[,/]\s*([\d.]+))?\s*\)/);return t?{r:+t[1],g:+t[2],b:+t[3],a:void 0!==t[4]?+t[4]:1}:null}function v(e){let t=e;for(;t&&t!==document.documentElement.parentElement;){const e=getComputedStyle(t).backgroundColor;if(e&&"transparent"!==e&&"rgba(0, 0, 0, 0)"!==e){const t=p(e);if(t&&t.a>.1)return t}t=t.parentElement}return null}function x(e){if(e){const t=v(e);if(t){return(.299*t.r+.587*t.g+.114*t.b)/255<.4}}if("undefined"!=typeof document){const e=document.documentElement,t=(e.getAttribute("data-theme")||"").toLowerCase();if("dark"===t)return!0;if("light"===t)return!1;if(e.classList.contains("dark"))return!0;if(document.body){const e=v(document.body);if(e){return(.299*e.r+.587*e.g+.114*e.b)/255<.4}}}return"undefined"!=typeof window&&window.matchMedia("(prefers-color-scheme: dark)").matches}function b(e){if("string"!=typeof e)return e;const t=document.createElement("canvas");t.width=1,t.height=1;const o=t.getContext("2d");o.fillStyle=e,o.fillRect(0,0,1,1);const n=o.getImageData(0,0,1,1).data;return{r:n[0],g:n[1],b:n[2]}}function w(e,t,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(e/o*Math.PI*4+3*s)+.5)+.4*(.5*Math.sin(t/n*Math.PI*3+2*s)+.5));case"pulse":{const r=o/2,a=n/2,i=Math.sqrt((e-r)**2+(t-a)**2),c=Math.sqrt(r**2+a**2);return.2+.8*(.5*Math.sin(i/c*Math.PI*6-4*s)+.5)}case"rain":return.1+.9*(.5*Math.sin(t/n*Math.PI*8-5*s+.3*e)+.5)*(.3*Math.sin(e/o*Math.PI*2+s)+.7);case"breathe":{const o=.3*Math.sin(2*s)+.7,n=.1*Math.sin(.1*(e+t)+s);return Math.max(.1,Math.min(1,o+n))}case"sparkle":{const o=43758.5453*Math.sin(127.1*e+311.7*t+43758.5453*Math.floor(8*s)),n=o-Math.floor(o);return n>.7?1:.15+.4*n}case"glitch":{const e=Math.floor(t/(.05*n)),o=43758.5453*Math.sin(43.23*e+17.89*Math.floor(6*s));if(o-Math.floor(o)>.85){const t=.5*Math.sin(30*s+e)+.5;return t<.3?0:t}return 1}case"spiral":{const r=o/2,a=n/2,i=e-r,c=t-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=t*o+e-.5*s%1*r*1.3;if(a>0)return 0;const i=Math.max(0,1+a/(.15*r));return Math.min(1,i)}case"scatter":{const r=o/2,a=n/2,i=e-r,c=t-a,l=Math.sqrt(i*i+c*c)/Math.sqrt(r*r+a*a),h=.5*Math.sin(1.5*s)+.5;return l>h?Math.max(0,1-3*(l-h)):.7+.3*Math.sin(10*l-2*s)}case"waveField":default:return 1;case"ripple":{const r=o/2,a=n/2,i=e-r,c=t-a,l=Math.sqrt(i*i+c*c),h=Math.sqrt(r*r+a*a);return.1+.9*(.5*Math.sin(l/h*Math.PI*10-5*s)+.5)*(.4+.6*(1-Math.min(1,l/(1.1*h))))}case"melt":{const o=t/n*Math.PI;return.05+(.5*Math.sin(o-1.8*s+.15*e)+.5)*(1-.6*(Math.max(0,t/n-.1)/.9))*.95}case"orbit":{const r=o/2,a=n/2,i=e-r,c=t-a,l=Math.atan2(c,i),h=Math.sqrt(i*i+c*c)/Math.sqrt(r*r+a*a);return.1+.9*(.5*Math.sin(2*l+6*h-2.5*s)+.5)}case"cellular":{const o=Math.floor(4*s),n=(e,t)=>{const n=43758.5453*Math.sin(127.1*e+311.7*t+43758.5453*o);return n-Math.floor(n)>.38?1:0},r=n(e,t),a=n(e-1,t)+n(e+1,t)+n(e,t-1)+n(e,t+1)+n(e-1,t-1)+n(e+1,t-1)+n(e-1,t+1)+n(e+1,t+1);return 1===(1===r?2===a||3===a?1:0:3===a?1:0)?1:.05}}}var y={scale:1,offsetX:0,offsetY:0,glow:0,colorBlend:0,proximity:0};function S(e,t,o,n,r,a,i,s,c="spotlight",l=.5,h="circle"){const f=e-o,d=t-n,m=.08+.35*l+.04*a;let u,g;if("box"===h){const e=Math.abs(f),t=Math.abs(d);u=Math.max(e,t),g=m}else u=Math.sqrt(f*f+d*d),g=m;if(u>=g)return y.scale=1,y.offsetX=0,y.offsetY=0,y.glow=0,y.colorBlend=0,y.proximity=0,y;const M=function(e){return e*e*(3-2*e)}(1-u/g)*r;let p=1,v=0,x=0,b=0,w=0;switch(c){case"spotlight":{p=1+M*a*1.8;const e=Math.atan2(d,f),t=M*M*a*.6;v=Math.cos(e)*t*i,x=Math.sin(e)*t*s,b=M*a*.4,w=M*M*a*.25;break}case"magnify":p=1+M*a*2.5,b=M*a*.15;break;case"repel":{p=1+M*a*.3;const e=Math.atan2(d,f),t=M*M*a*1.2;v=Math.cos(e)*t*i,x=Math.sin(e)*t*s;break}case"glow":b=M*a*.8,w=M*a*.4;break;case"colorShift":p=1+M*a*.4,b=M*a*.2,w=M*a*.7;break;case"attract":{const e=Math.atan2(d,f),t=M*M*a*1;v=-Math.cos(e)*t*i,x=-Math.sin(e)*t*s,b=M*a*.3;break}case"shatter":{const e=Math.atan2(d,f),t=.5*Math.sin(43.7*f+29.3*d),o=M*a*1.4*(.7+.3*t);v=Math.cos(e+t)*o*i,x=Math.sin(e+t)*o*s,p=Math.max(.1,1-M*a*.6),b=M*a*.25;break}case"trail":w=M*a*.9,b=M*a*.6,p=1+M*a*.15;break;case"glitchText":p=1,b=M*a*.5,w=M*a*.6}return y.scale=p,y.offsetX=v,y.offsetY=x,y.glow=b,y.colorBlend=w,y.proximity=M,y}function $(e){const t=e.match(/^#([0-9a-f]{3,8})$/i)?.[1];if(t){const e=t.length<=4?t.split("").map(e=>parseInt(e+e,16)):[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)];return{r:e[0],g:e[1],b:e[2]}}const o=e.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i);return o?{r:+o[1],g:+o[2],b:+o[3]}:null}function E(e){return e*e*e*(e*(6*e-15)+10)}function C(e,t,o){return e+(t-e)*o}function T(e,t){let o=127*e+311*t;return o^=o>>13,(o*(o*o*15731+789221)+1376312589&2147483647)/2147483647}function A(e,t){const o=Math.floor(e),n=Math.floor(t),r=t-n,a=E(e-o),i=E(r),s=T(o,n),c=T(o+1,n),l=T(o,n+1),h=T(o+1,n+1);return C(C(s,c,a),C(l,h,a),i)}function I(e,t){return(.5*A(e,t)+.25*A(2.1*e,2.1*t)+.125*A(4.3*e,4.3*t))/.875}function R(e,t,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=13,charAspect:s=.62,lineHeightRatio:c=1.4,chars:l=" .:-=+*#%@",baseColor:h=null,accentColor:f,accentThreshold:d=.52,mouseInfluence:m=.55,mouseFalloff:u=2.8,speed:g=1,vortex:M=!0,sparkles:p=!0,breathe:v=!0,lightMode:x=!1}=a,b=f??(x?"#6b8700":"#d4ff00"),w=i*s,y=i*c,S=Math.ceil(t/w),$=Math.ceil(o/y),E=r.x,C=r.y;let A=212,R=255,F=0;{const e=b.replace("#","");6===e.length&&(A=parseInt(e.slice(0,2),16),R=parseInt(e.slice(2,4),16),F=parseInt(e.slice(4,6),16))}e.clearRect(0,0,t,o),e.font=`${i}px "JetBrains Mono", monospace`,e.textBaseline="top";const k=n*g,L=v?.12*(.5*Math.sin(.22*k)+.5):0;for(let t=0;t<$;t++)for(let o=0;o<S;o++){const n=o/S,r=t/$,a=.045,i=.08*k,s=.06,c=.45*((.5*Math.sin(.08*o+.05*t+.6*k)+.5+(.5*Math.sin(.03*o-.07*t+.4*k)+.5)+(.5*Math.sin(.05*o+.03*t+.8*k)+.5))/3)+.35*(.5*I(o*a+i,t*a*1.4-.7*i)+.5)+.2*(.5*Math.sin((o+.65*t)*s+1.1*k)+.5)+L,f=n-E,g=r-C,v=Math.sqrt(f*f+g*g);let b=0;if(M&&v<.35){const e=Math.atan2(g,f),t=Math.sin(4*e+2.2*k-14*v),o=Math.max(0,1-v/.35);b=t*o*o*.22}const B=c*(1-m)+(Math.max(0,1-v*u)+.5*b)*m+.15*b,z=Math.min(1,Math.max(0,B));let q=z;if(p&&z>.72){const e=Math.floor(8*k),n=T(7*o+3*e,11*t+e);n>.88&&(q=Math.min(1,z+4*(n-.88)))}const P=Math.floor(q*(l.length-1));if(" "===l[P])continue;const H=.015+.07*q;if(q>d){const t=Math.min(x?.9:.28,H*(x?14:2.8));e.fillStyle=`rgba(${A},${R},${F},${t})`}else e.fillStyle=h?h.replace("{a}",String(H)):x?`rgba(55,55,55,${7*H})`:`rgba(255,255,255,${H})`;e.fillText(l[P],o*w,t*y)}}var F=new WeakMap,k=new WeakMap,L=null,B=null;function z(e,t){if(!L||!B){const o=i(e,t);L=o.canvas,B=o.ctx}return L.width!==e&&(L.width=e),L.height!==t&&(L.height=t),B}var q=new Map,P=new Map,H=new Map;function W(e){let t=q.get(e);return t||(t=[...e],q.set(e,t)),t}function j(e,t,o){const n=o?1-e/255:e/255,r=Math.floor(n*(t.length-1));return t[Math.max(0,Math.min(t.length-1,r))]??" "}function D(e,t,o,n){const r=`${e}\0${t?1:0}\0${o}\0${n}`;let a=P.get(r);if(!a){const i=W(e);a=new Array(256);for(let e=0;e<256;e++)a[e]=j(s(e,o,n),i,t);P.set(r,a)}return a}function U(e,t){return"auto"!==e?e:!x(t)}function O(e){const t=e.match(/^#([0-9a-fA-F]{3,6})$/);if(t){let e=t[1];if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return e}const o=e.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);return o?[o[1],o[2],o[3]].map(e=>parseInt(e).toString(16).padStart(2,"0")).join(""):null}function V(e){const t=e||"auto";if("auto"!==t)return t.replace("#","");if("undefined"!=typeof document){const e=getComputedStyle(document.documentElement);for(const t of["--accent-color","--color-accent","--accent","--color-primary","--primary","--brand-color"]){const o=O(e.getPropertyValue(t).trim());if(o)return o}const t=O(getComputedStyle(document.body).accentColor??"");if(t)return t}return x("undefined"!=typeof document?document.body:null)?"faf9f7":"0d0d0d"}function _(e,t,o,n){const r=e instanceof HTMLVideoElement?e.videoWidth:e.width,a=e instanceof HTMLVideoElement?e.videoHeight:e.height;if(0===r||0===a)return{frame:[],cols:0,rows:0};const i=t.charAspect,c=t.fontSize*t.charSpacing,h=t.fontSize/i*t.charSpacing,d=o||r,m=n||a,u=Math.floor(d/c),g=Math.floor(m/h);if(u<=0||g<=0)return{frame:[],cols:0,rows:0};const M=Math.max(1,Math.min(Math.floor(2048/u),Math.floor(r/u))),p=Math.max(1,Math.min(Math.floor(2048/g),Math.floor(a/g))),v=u*M,x=g*p,w=z(v,x);w.drawImage(e,0,0,v,x);const y=w.getImageData(0,0,v,x).data,S=t.chromaKey,$=null!=S&&!1!==S,E=!0===S,C="blue-screen"===S;let T=null,A=0;!$||E||C||(T=b(S),A=(t.chromaKeyTolerance??60)**2);let I=0,R=255;if(t.normalize){let e=255,t=0;for(let o=0;o<y.length;o+=4){if($){const e=y[o],t=y[o+1],n=y[o+2];let r=!1;if(E)r=t>1.4*e&&t>1.4*n&&t>80;else if(C)r=n>1.4*e&&n>1.4*t&&n>80;else if(null!==T){const o=e-T.r,a=t-T.g,i=n-T.b;r=o*o+a*a+i*i<=A}if(r)continue}const n=.299*y[o]+.587*y[o+1]+.114*y[o+2];n<e&&(e=n),n>t&&(t=n)}I=e,R=t>e?t-e:255}const F=[],k=U(t.invert),L=$&&t.charset.replace(/ /g,"")||t.charset,B=W(L),q=t.customText?null:D(L,k,t.brightness,t.contrast),P=M*p;for(let e=0;e<g;e++){const o=[];for(let n=0;n<u;n++){let r=0,a=0,i=0,c=0,h=0;for(let t=0;t<p;t++){const o=(e*p+t)*v;for(let e=0;e<M;e++){const t=4*(o+n*M+e),s=y[t],l=y[t+1],f=y[t+2],d=y[t+3];if($){let e=!1;if(E)e=l>1.4*s&&l>1.4*f&&l>80;else if(C)e=f>1.4*s&&f>1.4*l&&f>80;else if(null!==T){const t=s-T.r,o=l-T.g,n=f-T.b;e=t*t+o*o+n*n<=A}if(e){h++;continue}}r+=s,a+=l,i+=f,c+=d}}if($&&h>P/2){o.push({char:" ",r:0,g:0,b:0,a:0});continue}const d=P-h,m=d>0?r/d:0,g=d>0?a/d:0,x=d>0?i/d:0,b=d>0?c/d:0,w=.299*m+.587*g+.114*x,S=t.normalize?(w-I)/R*255:w,F=s(S,t.brightness,t.contrast),L=t.ditherStrength>0?f(F,n,e,t.ditherStrength):F,z=t.customText?l(L,t.customText,n,e,u,k):t.ditherStrength>0?j(L,B,k):q[Math.max(0,Math.min(255,0|S))];o.push({char:z,r:m,g:g,b:x,a:b,lum:L})}F.push(o)}return{frame:F,cols:u,rows:g}}function Y(e,t,o,n){const r=e instanceof HTMLVideoElement?e.videoWidth:e.width,a=e instanceof HTMLVideoElement?e.videoHeight:e.height;if(0===r||0===a)return{rows:[],cols:0,rowCount:0};const i=t.charAspect,c=t.fontSize*t.charSpacing,l=t.fontSize/i*t.charSpacing,h=o||r,d=n||a,m=Math.floor(h/c),u=Math.floor(d/l);if(m<=0||u<=0)return{rows:[],cols:0,rowCount:0};const g=m,M=u,p=z(g,M);p.drawImage(e,0,0,g,M);const v=p.getImageData(0,0,g,M).data,x=t.chromaKey,w=null!=x&&!1!==x,y=!0===x,S="blue-screen"===x;let $=null,E=0;!w||y||S||($=b(x),E=(t.chromaKeyTolerance??60)**2);let C=0,T=255;if(t.normalize){let e=255,t=0;for(let o=0;o<v.length;o+=4){if(w){const e=v[o],t=v[o+1],n=v[o+2];let r=!1;if(y)r=t>1.4*e&&t>1.4*n&&t>80;else if(S)r=n>1.4*e&&n>1.4*t&&n>80;else if(null!==$){const o=e-$.r,a=t-$.g,i=n-$.b;r=o*o+a*a+i*i<=E}if(r)continue}const n=.299*v[o]+.587*v[o+1]+.114*v[o+2];n<e&&(e=n),n>t&&(t=n)}C=e,T=t>e?t-e:255}const A=U(t.invert),I=w&&t.charset.replace(/ /g,"")||t.charset,R=W(I),F=t.customText?null:D(I,A,t.brightness,t.contrast),k=t.customText?W(t.customText):null,L=[];for(let e=0;e<u;e++){let o="";for(let n=0;n<m;n++){const r=4*(e*g+n),a=v[r],i=v[r+1],c=v[r+2];if(w){let e=!1;if(y)e=i>1.4*a&&i>1.4*c&&i>80;else if(S)e=c>1.4*a&&c>1.4*i&&c>80;else if(null!==$){const t=a-$.r,o=i-$.g,n=c-$.b;e=t*t+o*o+n*n<=E}if(e){o+=" ";continue}}const l=.299*a+.587*i+.114*c,h=t.normalize?(l-C)/T*255:l,d=t.ditherStrength>0||k?s(h,t.brightness,t.contrast):h,u=t.ditherStrength>0?f(d,n,e,t.ditherStrength):d;if(k){o+=(A?1-u/255:u/255)<.12?" ":k[(e*m+n)%k.length]}else t.ditherStrength<=0?o+=F[Math.max(0,Math.min(255,0|h))]:o+=j(u,R,A)}L.push(o)}return{rows:L,cols:m,rowCount:u}}function N(e,t,o,n,r){if(0===t.rows.length)return;e.clearRect(0,0,n,r);const a=e.canvas;o.chromaKey||t.rows.some(e=>e.includes(" "))||(e.fillStyle=x(a)?"#0a0a0a":"#faf9f7",e.fillRect(0,0,n,r));const i=V(o.accentColor),s=parseInt(i.substring(0,2),16)||255,c=parseInt(i.substring(2,4),16)||255,l=parseInt(i.substring(4,6),16)||255,h=n/t.cols,f=r/t.rowCount,d=.9*Math.min(h/.55,f);e.font=`${d}px "JetBrains Mono", monospace`,e.textAlign="left",e.textBaseline="middle",e.fillStyle="matrix"===o.colorMode?"rgb(0,255,0)":"grayscale"===o.colorMode?x(a)?"rgb(230,230,230)":"rgb(24,24,24)":`rgb(${s},${c},${l})`,e.globalAlpha=1;for(let o=0;o<t.rows.length;o++){const n=t.rows[o];0!==n.trim().length&&e.fillText(n,.5*h,o*f+.5*f)}e.globalAlpha=1}async function G(e,t,o,n,r=12,a=10,i,s=0){const c=Math.min(e.duration-s,a),l=Math.ceil(c*r),h=[];let f=0,d=0;for(let a=0;a<l;a++){const m=s+a/r;if(m>s+c)break;e.currentTime=m,await new Promise(t=>{const o=()=>{e.removeEventListener("seeked",o),t()};e.addEventListener("seeked",o)});const u=_(e,t,o,n);h.push(u.frame),f=u.cols,d=u.rows,i?.((a+1)/l)}return{frames:h,cols:f,rows:d,fps:r}}async function X(e,t,o,n,r=12,a=10,i,s=0){const c=Math.min(e.duration-s,a),l=Math.ceil(c*r),h=[];let f=0,d=0;for(let a=0;a<l;a++){const m=s+a/r;if(m>s+c)break;e.currentTime=m,await new Promise(t=>{const o=()=>{e.removeEventListener("seeked",o),t()};e.addEventListener("seeked",o)});const u=Y(e,t,o,n);h.push(u),f=u.cols,d=u.rowCount,i?.((a+1)/l)}return{frames:h,cols:f,rows:d,fps:r}}async function J(t,o,n,r,a){const i=e.parseGIF(t),s=e.decompressFrames(i,!0);if(0===s.length)return{frames:[],cols:0,rows:0,fps:10};const c=s[0].dims.width,l=s[0].dims.height,h=i.lsd?.width||c,f=i.lsd?.height||l,d=document.createElement("canvas");d.width=h,d.height=f;const m=d.getContext("2d"),u=document.createElement("canvas");u.width=h,u.height=f;const g=u.getContext("2d"),M=document.createElement("canvas"),p=M.getContext("2d"),v=[];let x=0,b=0,w=0;for(const e of s)w+=e.delay||100;const y=w/s.length,S=Math.round(Math.min(30,Math.max(5,1e3/y))),$=Math.min(s.length,300);for(let e=0;e<$;e++){const t=s[e],{dims:i,patch:c,disposalType:l}=t;3===l&&(g.clearRect(0,0,h,f),g.drawImage(d,0,0)),M.width!==i.width&&(M.width=i.width),M.height!==i.height&&(M.height=i.height);const w=new ImageData(new Uint8ClampedArray(c.buffer),i.width,i.height);p.putImageData(w,0,0),m.drawImage(M,i.left||0,i.top||0);const y=_(d,o,n,r);v.push(y.frame),x=y.cols,b=y.rows,2===l?m.clearRect(i.left||0,i.top||0,i.width,i.height):3===l&&(m.clearRect(0,0,h,f),m.drawImage(u,0,0)),a?.((e+1)/$)}return{frames:v,cols:x,rows:b,fps:S}}async function K(t,o,n,r,a){const i=e.parseGIF(t),s=e.decompressFrames(i,!0);if(0===s.length)return{frames:[],cols:0,rows:0,fps:10};const c=s[0].dims.width,l=s[0].dims.height,h=i.lsd?.width||c,f=i.lsd?.height||l,d=document.createElement("canvas");d.width=h,d.height=f;const m=d.getContext("2d"),u=document.createElement("canvas");u.width=h,u.height=f;const g=u.getContext("2d"),M=document.createElement("canvas"),p=M.getContext("2d"),v=[];let x=0,b=0,w=0;for(const e of s)w+=e.delay||100;const y=w/s.length,S=Math.round(Math.min(30,Math.max(5,1e3/y))),$=Math.min(s.length,300);for(let e=0;e<$;e++){const t=s[e],{dims:i,patch:c,disposalType:l}=t;3===l&&(g.clearRect(0,0,h,f),g.drawImage(d,0,0)),M.width!==i.width&&(M.width=i.width),M.height!==i.height&&(M.height=i.height);const w=new ImageData(new Uint8ClampedArray(c.buffer),i.width,i.height);p.putImageData(w,0,0),m.drawImage(M,i.left||0,i.top||0);const y=Y(d,o,n,r);v.push(y),x=y.cols,b=y.rowCount,2===l?m.clearRect(i.left||0,i.top||0,i.width,i.height):3===l&&(m.clearRect(0,0,h,f),m.drawImage(u,0,0)),a?.((e+1)/$)}return{frames:v,cols:x,rows:b,fps:S}}function Q(e,t,o,n,r,a=0,s){if("waveField"===o.animationStyle){return void R(e,n,r,a,s?{x:s.x,y:s.y}:{x:.5,y:.5},{accentColor:`#${o.accentColor?V(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 l=t.length;if(0===l)return;const h=t[0].length;e.clearRect(0,0,n,r);let f=!1;const d=Math.max(1,l>>2),m=Math.max(1,h>>2);e:for(let e=0;e<l;e+=d){const o=t[e];for(let e=0;e<h;e+=m)if(o[e].a<200){f=!0;break e}}const g=e.canvas,p=x(g);f||(e.fillStyle=p?"#0a0a0a":"#faf9f7",e.fillRect(0,0,n,r));const v=n/h,b=r/l,y=l*h,$=s?.intensity??1,E=!("none"!==o.animationStyle&&y>5e3)&&!!(s&&o.hoverStrength>0&&$>.005),C=o.hoverColor||"#ffffff",T=parseInt(C.slice(1,3),16)||255,A=parseInt(C.slice(3,5),16)||255,I=parseInt(C.slice(5,7),16)||255,L=V(o.accentColor),B=parseInt(L.substring(0,2),16)||255,z=parseInt(L.substring(2,4),16)||255,q=parseInt(L.substring(4,6),16)||255,P=y>3e4?.25:y>15e3?.4:y>5e3?.6:1,j=o.hoverRadius*P;let D=0,O=h,_=0,Y=l,N=0,G=0;if(E&&s){N=s.x,G=s.y;const e=.08+.35*j+.04*o.hoverStrength;D=Math.max(0,Math.floor((N-e)*h)-1),O=Math.min(h,Math.ceil((N+e)*h)+1),_=Math.max(0,Math.floor((G-e)*l)-1),Y=Math.min(l,Math.ceil((G+e)*l)+1)}const X=o.animationStyle,J=o.animationSpeed,K="none"===X,Q=o.hoverStrength,Z=o.hoverEffect,ee=j,te=o.hoverShape||"circle",oe=U(o.invert,g),ne=o.colorMode,re=2*Math.PI,ae=1/h,ie=1/l;let se="",ce=-1;if("dots"===o.renderMode){const n=.5*Math.min(v,b)*o.dotSizeRatio;for(let o=0;o<l;o++){const r=t[o];for(let t=0;t<h;t++){const i=r[t];if(i.a<10)continue;const s=.00392156863*(.299*i.r+.587*i.g+.114*i.b),c=oe?1-s:s;if(c<.02)continue;const f=K?1:w(t,o,h,l,a,X,J);let d=1,m=0,g=0,p=0,x=0;if(E&&t>=D&&t<=O&&o>=_&&o<=Y){const e=S(t*ae,o*ie,N,G,$,Q,v,b,Z,ee,te);d=e.scale,m=e.offsetX,g=e.offsetY,p=e.glow,x=e.colorBlend}const y=n*c*f*d;if(y<.3)continue;const C=t*v+.5*v+m,R=o*b+.5*b+g;let F;if(x>0){const e=M(i,ne,B,z,q,oe);F=`rgb(${Math.min(255,e[0]+(T-e[0])*x|0)},${Math.min(255,e[1]+(A-e[1])*x|0)},${Math.min(255,e[2]+(I-e[2])*x|0)})`}else F=u(i,ne,B,z,q,oe);const k=Math.min(1,.00392156863*i.a*f*(1+p));if(k!==ce&&(e.globalAlpha=k,ce=k),F!==se&&(e.fillStyle=F,se=F),y<=3){const t=2*y;e.fillRect(C-y,R-y,t,t)}else e.beginPath(),e.arc(C,R,y,0,re),e.fill()}}}else{const s=.55,f=.9*Math.min(v/s,b),d=f<6;if(!d){const t="emoji"===o.artStyle;e.font=t?`${f}px "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif`:`${f}px "JetBrains Mono", monospace`,e.textAlign="center",e.textBaseline="middle"}const m=o.charsetFrames,g=!!m?.length,p=g?m[Math.floor(Math.max(0,a)*(o.charsetFps??2))%m.length]:o.charset;if(d){const{canvas:o,ctx:a}=function(e,t,o){let n=F.get(e);n||(n=i(t,o).canvas,F.set(e,n)),n.width!==t&&(n.width=t),n.height!==o&&(n.height=o);const r=n.getContext("2d",{willReadFrequently:!1});if(!r)throw new Error("renderFrameToCanvas: could not create raster context.");return{canvas:n,ctx:r}}(e,h,l);let s=k.get(a);s&&s.width===h&&s.height===l||(s={width:h,height:l,imageData:a.createImageData(h,l)},k.set(a,s));const f=s.imageData,d=f.data;d.fill(0);const m=function(e){let t=H.get(e);if(!t){const o=W(e),n=Math.max(1,o.length);t=new Map;for(let e=0;e<o.length;e++)t.has(o[e])||t.set(o[e],Math.max(.08,(e+.5)/n));H.set(e,t)}return t}(p);for(let e=0;e<l;e++){const o=t[e];for(let t=0;t<h;t++){const n=o[t],r=4*(e*h+t);if(n.a<10)continue;const a=g&&null!=n.lum?c(n.lum,p,oe):n.char;if(" "===a)continue;let i,s,l,f=m.get(a)??.5,u=0,x=0;if(E&&t>=D&&t<=O&&e>=_&&e<=Y){const o=S(t*ae,e*ie,N,G,$,Q,v,b,Z,ee,te);f*=o.scale,u=o.glow,x=o.colorBlend}if(x>0){const e=M(n,ne,B,z,q,oe);i=Math.min(255,e[0]+(T-e[0])*x|0),s=Math.min(255,e[1]+(A-e[1])*x|0),l=Math.min(255,e[2]+(I-e[2])*x|0)}else{const e=M(n,ne,B,z,q,oe);i=e[0],s=e[1],l=e[2]}const w=Math.min(255,Math.max(0,n.a*f*(1+u)));d[r]=i,d[r+1]=s,d[r+2]=l,d[r+3]=w}}return a.putImageData(f,0,0),e.imageSmoothingEnabled=!1,e.drawImage(o,0,0,n,r),e.imageSmoothingEnabled=!0,void(e.globalAlpha=1)}const x=d?null:e.getTransform();if(!d&&!E&&K&&!g&&"accent"===ne){e.fillStyle=`rgb(${B},${z},${q})`,e.globalAlpha=1,e.textAlign="left";for(let o=0;o<l;o++){const n=t[o];let r="";for(let e=0;e<h;e++){const t=n[e];r+=t.a<10?" ":t.char}0!==r.trim().length&&e.fillText(r,.5*v,o*b+.5*b)}return void(e.globalAlpha=1)}const y="glitchText"===Z&&E,C="!@#$%^&*<>{}[]|/\\~`0123456789",R=C.length;let L="",P=0,U=0,V=0,re=0,le=0,he=0;if(y){const e=o.hoverText??"ASCIIFY";if(U=Math.round(N*h),V=Math.round(G*l),Array.isArray(e)){const t=e.filter(e=>e.length>0);0===t.length&&t.push("ASCIIFY");L=t[((7*Math.floor(U/Math.max(1,Math.ceil(h/5)))+13*Math.floor(V/Math.max(1,Math.ceil(l/3))))%t.length+t.length)%t.length]}else L=e||"ASCIIFY";P=L.length,re=Math.max(3,Math.min(12,Math.round(l*j*.6)));const t=Math.floor(re/2);le=Math.max(0,V-t),le+re>l&&(le=Math.max(0,l-re)),he=U-Math.floor(P/2)}for(let o=0;o<l;o++){const n=t[o];for(let t=0;t<h;t++){const r=n[t];if(r.a<10)continue;let i=g&&null!=r.lum?c(r.lum,p,oe):r.char;if(" "===i)continue;const s=K?1:w(t,o,h,l,a,X,J);if(s<.05)continue;let f=1,d=0,m=0,F=0,k=0;if(E&&!y&&t>=D&&t<=O&&o>=_&&o<=Y){const e=S(t*ae,o*ie,N,G,$,Q,v,b,Z,ee,te);f=e.scale,d=e.offsetX,m=e.offsetY,F=e.glow,k=e.colorBlend}if(y&&o>=le&&o<le+re){const e=t-he;if(e>=0&&e<P){const n=L[e],r=Math.abs(o-V)/Math.max(1,.5*re),s=Math.abs(t-U)/Math.max(1,P),c=Math.max(r,s),l=Math.max(0,Math.min(1,1-.9*c)),h=43758.5453*Math.sin(127.1*t+311.7*o+43758.5453*Math.floor(12*a));i=Math.abs(h-Math.floor(h))<l?n:C[Math.abs(Math.floor(97*h))%R],F=.3+.7*l,k=.3+.65*l}}const H=t*v+.5*v+d,W=o*b+.5*b+m;let j;if(k>0){const e=M(r,ne,B,z,q,oe);j=`rgb(${Math.min(255,e[0]+(T-e[0])*k|0)},${Math.min(255,e[1]+(A-e[1])*k|0)},${Math.min(255,e[2]+(I-e[2])*k|0)})`}else j=u(r,ne,B,z,q,oe);const fe=Math.min(1,.00392156863*r.a*s*(1+F));fe!==ce&&(e.globalAlpha=fe,ce=fe),j!==se&&(e.fillStyle=j,se=j),1!==f?(e.translate(H,W),e.scale(f,f),e.fillText(i,0,0),e.setTransform(x)):e.fillText(i,H,W)}}}e.globalAlpha=1}function Z(e){return Math.max(0,Math.min(1,e))}function ee(e){return"string"==typeof e?document.querySelector(e):e instanceof HTMLElement?e:null}function te(e){return"ascii"===e.renderMode&&"fullcolor"!==e.colorMode&&"none"===e.animationStyle&&e.hoverStrength<=0&&!e.charsetFrames?.length}function oe(e,t,o={}){if(!Number.isFinite(e.duration)||e.duration<=0)return;const n=o.from??0,r=o.to??e.duration,a=Math.max(n,Math.min(r,e.duration)),i=Z(o.ease?o.ease(Z(t)):t),s=n+(a-n)*i;e.currentTime=Math.min(Math.max(n,s),Math.max(n,a-.04)),o.onUpdate?.(i,e)}function ne(e){const t=e.requestVideoFrameCallback;return new Promise(t?o=>{let n=!1;const r=()=>{n||(n=!0,o())};t.call(e,r),window.setTimeout(r,80)}:e=>requestAnimationFrame(()=>e()))}function re(e,t={}){const o=ee(t.trigger)??e;e.pause();const n=t.gsap,r=t.ScrollTrigger??n?.ScrollTrigger;if(n&&r?.create){n.registerPlugin?.(r);const a=r.create({trigger:o,start:t.start??"top bottom",end:t.end??"bottom top",scrub:t.scrub??!0,onUpdate:o=>oe(e,o.progress,t)});return()=>a.kill?.()}return function(e,t,o){let n=0;const r=()=>{n=0;const r=t.getBoundingClientRect(),a=window.innerHeight||document.documentElement.clientHeight,i=r.height+a,s=i>0?Z((a-r.top)/i):0;oe(e,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)}}(e,o,t)}function ae(e,t,o){const n=t.gsap,r=t.ScrollTrigger??n?.ScrollTrigger;if(n&&r?.create){n.registerPlugin?.(r);const a=r.create({trigger:e,start:t.start??"top bottom",end:t.end??"bottom top",scrub:t.scrub??!0,onUpdate:e=>o(e.progress)});return()=>a.kill?.()}return function(e,t){let o=0;const n=()=>{o=0;const n=e.getBoundingClientRect(),r=window.innerHeight||document.documentElement.clientHeight,a=n.height+r,i=a>0?Z((r-n.top)/a):0;t(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)}}(e,o)}function ie(e,t,o=2048){const n=o,r=Math.min(1,n/Math.max(e,t));return{renderW:Math.round(e*r),renderH:Math.round(t*r)}}function se(e,t,o,n,r,a=2048){const{width:i,height:s}=t.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}=ie(n,r,a)):(c=h,l=f);const d="undefined"!=typeof window&&window.devicePixelRatio||1,m=8e6,u=c*d*l*d>m?Math.sqrt(m/(c*l)):d;return e.width=Math.round(c*u),e.height=Math.round(l*u),e.style.width=h+"px",e.style.height=f+"px",{renderW:c,renderH:l,dpr:u}}async function ce(e,t,{fontSize:o,artStyle:r="classic",options:i={},fitTo:s,preExtract:c=!1,fps:l,maxRenderDimension:h=2048,trim:f,scroll:d,onReady:m,onFrame:u}={}){const g=f?.start??0,M=f?.end,p=o??i.fontSize??10,v={...a,...n[r],...i,fontSize:p},x=t.getContext("2d");if(!x)throw new Error("asciifyVideo: could not get 2d context from canvas.");const b="string"==typeof s?document.querySelector(s):s instanceof HTMLElement?s:null;if(c){let o;"string"==typeof e?(o=document.createElement("video"),o.crossOrigin="anonymous",o.src=e,o.readyState<2&&await new Promise((t,n)=>{o.onloadeddata=()=>t(),o.onerror=()=>n(new Error(`asciifyVideo: failed to load "${e}"`))})):o=e,b&&se(t,b,o.videoWidth/o.videoHeight,o.videoWidth,o.videoHeight,h);const{renderW:n,renderH:r}=ie(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;t.width<Math.round(n*s)&&(t.width=Math.round(n*s),t.height=Math.round(r*s));const c=void 0!==M?M-g:10,f=l??(d?18:void 0);if(te(v)){const{frames:e,fps:a}=await X(o,v,n,r,f,c,void 0,g),i=t=>{const o=e[t];o&&(x.save(),x.setTransform(s,0,0,s,0,0),N(x,o,v,n,r),x.restore(),u?.())};if(d){let n=!1,r=-1;const a=!0===d?{}:d,s=ae(ee(a.trigger)??b??t,a,t=>{const s=Z(a.ease?a.ease(Z(t)):t),c=Math.max(0,Math.min(e.length-1,Math.round(s*(e.length-1))));c!==r&&(r=c,i(c),n||(n=!0,m?.(o)),a.onUpdate?.(s,o))});return i(0),n=!0,m?.(o),s}let l,h=!1,M=0,p=performance.now(),w=!0;const y=1e3/a,S=t=>{h||(t-p>=y&&(i(M),M=(M+1)%e.length,p=t,w&&(w=!1,m?.(o))),l=requestAnimationFrame(S))};return l=requestAnimationFrame(S),()=>{h=!0,cancelAnimationFrame(l)}}const{frames:p,fps:w}=await G(o,v,n,r,f,c,void 0,g),y=e=>{const t=p[e];t&&(x.save(),x.setTransform(s,0,0,s,0,0),Q(x,t,v,n,r),x.restore(),u?.())};if(d){let e=!1,n=-1;const r=!0===d?{}:d,a=ae(ee(r.trigger)??b??t,r,t=>{const a=Z(r.ease?r.ease(Z(t)):t),i=Math.max(0,Math.min(p.length-1,Math.round(a*(p.length-1))));i!==n&&(n=i,y(i),e||(e=!0,m?.(o)),r.onUpdate?.(a,o))});return y(0),e=!0,m?.(o),a}let S,$=!1,E=0,C=performance.now(),T=!0;const A=1e3/w,I=e=>{$||(e-C>=A&&(y(E),E=(E+1)%p.length,C=e,T&&(T=!1,m?.(o))),S=requestAnimationFrame(I))};return S=requestAnimationFrame(I),()=>{$=!0,cancelAnimationFrame(S)}}let w,y=!1;"string"==typeof e?(w=document.createElement("video"),w.src=e,w.muted=!0,w.loop=!0,w.playsInline=!0,w.setAttribute("playsinline",""),Object.assign(w.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(w),y=!0,await new Promise((t,o)=>{w.onloadedmetadata=()=>t(),w.onerror=()=>o(new Error(`asciifyVideo: failed to load "${e}"`))}),await w.play().catch(()=>{})):(w=e,w.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((e,t)=>{const o=()=>{w.removeEventListener("loadedmetadata",n),w.removeEventListener("error",r)},n=()=>{o(),e()},r=()=>{o(),t(new Error("asciifyVideo: provided video element failed to load metadata."))};w.addEventListener("loadedmetadata",n),w.addEventListener("error",r),w.load()}),w.paused&&await w.play().catch(()=>{})),g>0&&(w.currentTime=g,await new Promise(e=>{const t=()=>{w.removeEventListener("seeked",t),e()};w.addEventListener("seeked",t)}),await ne(w));let S=null;(g>0||void 0!==M)&&(S=()=>{(void 0!==M&&w.currentTime>=M||g>0&&w.currentTime<g)&&(w.currentTime=g)},w.addEventListener("timeupdate",S));let $=null;const{renderW:E,renderH:C}=ie(w.videoWidth,w.videoHeight,h);if(b){const e=w.videoWidth/w.videoHeight,o=w.videoWidth,n=w.videoHeight,r=se(t,b,e,o,n,h),a=t.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0),$=new ResizeObserver(()=>{const r=se(t,b,e,o,n,h),a=t.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0)}),$.observe(b)}else{const e="undefined"!=typeof window&&window.devicePixelRatio||1,o=8e6,n=E*e*C*e>o?Math.sqrt(o/(E*C)):e;t.width<Math.round(E*n)&&(t.width=Math.round(E*n),t.height=Math.round(C*n)),x.setTransform(n,0,0,n,0,0)}let T,A=!1,I=!0,R=null;const F=d&&!c,k=l&&l>0?1e3/l:0;let L=0,B=-1;const z=!F&&te(v);if(F&&"ascii"===v.renderMode&&("accent"===v.colorMode||"matrix"===v.colorMode)&&"none"===v.animationStyle&&v.hoverStrength<=0&&!v.charsetFrames?.length){const e=!0===d?{}:d,o=ee(e.trigger)??b??t,n=e.from??g,r=e.to??M??w.duration,a=Math.max(n,Math.min(r,w.duration)),i=Math.max(.001,a-n),s=Math.min(60,Math.max(12,l??30)),c=Math.max(2,Math.ceil(i*s)+1),h=new Array(c);let f=0,p=0,T=-1,A=0,I=!1,F=!1,B=!1;const z=new Set,q=document.createElement("video");q.muted=!0,q.playsInline=!0,q.preload="auto",q.crossOrigin=w.crossOrigin||"anonymous",q.src=w.currentSrc||w.src,Object.assign(q.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(q),q.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((e,t)=>{const o=()=>{q.removeEventListener("loadedmetadata",n),q.removeEventListener("error",r)},n=()=>{o(),e()},r=()=>{o(),t(new Error("asciifyVideo: cache video failed to load metadata."))};q.addEventListener("loadedmetadata",n),q.addEventListener("error",r),q.load()}),q.pause(),w.paused&&await w.play().catch(()=>{});const P=e=>n+i*e/Math.max(1,c-1),H=e=>Math.max(0,Math.min(c-1,Math.round(e*(c-1)))),W=Y(w,v,E,C);W.rows.length>0&&(h[0]=W,N(x,W,v,E,C),B=!0,m?.(w),u?.());const j=e=>{if(h[e])return e;for(let t=1;t<c;t++){const o=e-t,n=e+t;if(o>=0&&h[o])return o;if(n<c&&h[n])return n}return-1},D=()=>{if(!h[f])return f;for(const e of z)if(!h[e])return e;for(let e=1;e<c;e++){const t=f-e,o=f+e;if(t>=0&&!h[t])return t;if(o<c&&!h[o])return o}return-1},U=e=>{e<0||e>=c||h[e]||(z.add(e),O())},O=async()=>{if(I||F)return;const e=D();if(!(e<0)){z.delete(e),F=!0;try{if(await function(e,t){return Math.abs(e.currentTime-t)<1/240?ne(e):new Promise(o=>{const n=()=>{e.removeEventListener("seeked",n),o()};e.addEventListener("seeked",n,{once:!0}),e.currentTime=t})}(q,P(e)),await ne(q),!I){const t=Y(q,v,E,C);t.rows.length>0&&(h[e]=t)}}finally{F=!1,I||requestAnimationFrame(()=>{O()})}}},V=()=>{if(I)return;const e=j(f);if(e>=0&&e!==T){const t=h[e];t&&(N(x,t,v,E,C),T=e,B||(B=!0,m?.(w)),u?.())}else if(e<0||T<0){const e=performance.now();if(k<=0||e-L>=k){const t=Y(w,v,E,C);t.rows.length>0&&(N(x,t,v,E,C),L=e,B||(B=!0,m?.(w)),u?.())}}U(f),A=requestAnimationFrame(V)};return R=ae(o,e,t=>{const o=function(e,t,o={}){if(!Number.isFinite(e.duration)||e.duration<=0)return null;const n=o.from??0,r=o.to??e.duration,a=Math.max(n,Math.min(r,e.duration)),i=Z(o.ease?o.ease(Z(t)):t),s=n+(a-n)*i;return{progress:i,time:Math.min(Math.max(n,s),Math.max(n,a-.04))}}(w,t,{...e,from:n,to:a});p=o?.progress??Z(t),f=H(p),U(f),U(f-1),U(f+1),e.onUpdate?.(p,w)}),U(0),U(1),A=requestAnimationFrame(V),()=>{I=!0,cancelAnimationFrame(A),R?.(),$?.disconnect(),q.pause(),q.src="",document.body.removeChild(q),S&&w.removeEventListener("timeupdate",S),y&&(w.pause(),w.src="",document.body.removeChild(w))}}if(F){const e=!0===d?{}:d;R=re(w,{...e,trigger:e.trigger??b??t,from:e.from??g,to:e.to??M})}const q=e=>{if(A)return;if(T=requestAnimationFrame(q),w.readyState<2||0===t.width||0===t.height)return;if(k>0&&e-L<k)return;if(g>0&&w.currentTime<g)return;if(void 0!==M&&w.currentTime>=M)return;if(F&&Math.abs(w.currentTime-B)<1/240)return;if(z){const t=Y(w,v,E,C);return void(t.rows.length>0&&(N(x,t,v,E,C),L=e,B=w.currentTime,I&&(I=!1,m?.(w)),u?.()))}const{frame:o}=_(w,v,E,C);o.length>0&&(Q(x,o,v,E,C,0,null),L=e,B=w.currentTime,I&&(I=!1,m?.(w)),u?.())};return T=requestAnimationFrame(q),()=>{A=!0,cancelAnimationFrame(T),R?.(),$?.disconnect(),S&&w.removeEventListener("timeupdate",S),y&&(w.pause(),w.src="",document.body.removeChild(w))}}function le(e,t,o,n,r={}){const{fontSize:a=13,chars:i="0123456789ABCDEF@#$&*+=/<>",accentColor:s,color:c,speed:l=1,density:h=.55,tailLength:f=14,lightMode:d=!1}=r,m=s??(d?"#6b8700":"#d4ff00"),u=.62*a,g=1.4*a,M=Math.ceil(t/u),p=Math.ceil(o/g);e.clearRect(0,0,t,o),e.font=`${a}px monospace`,e.textBaseline="top";let v=255,x=255,b=255;if(d&&(v=55,x=55,b=55),c){const e=$(c);e&&(v=e.r,x=e.g,b=e.b)}let w=212,y=255,S=0;const E=$(m);E&&(w=E.r,y=E.g,S=E.b);const C=p+f;for(let t=0;t<M;t++){if(T(17*t,3)>h)continue;const o=(.5+1.5*T(31*t,7))*l,r=T(13*t,11)*C,a=Math.floor((n*o*7+r)%C),s=t*u;for(let o=0;o<=f;o++){const r=a-(f-o);if(r<0||r>=p)continue;const c=r*g,l=T(53*t+Math.floor(5*n+o),7*r),h=i[Math.floor(l*i.length)],m=o/f;if(o===f)e.fillStyle=`rgba(${w},${y},${S},${d?.7:.85})`;else{const t=d?.85*m:.15*m;e.fillStyle=`rgba(${v},${x},${b},${t})`}e.fillText(h,s,c)}}}function he(e,t,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" . · * + ° ★",accentColor:c,color:l,speed:h=1,count:f=180,lightMode:d=!1}=a,m=c??(d?"#6b8700":"#d4ff00");e.clearRect(0,0,t,o),e.textBaseline="middle",e.textAlign="center";const u=t*(.2+.6*r.x),g=o*(.2+.6*r.y),M=.65*Math.sqrt(t*t+o*o);let p=255,v=255,x=255;if(d&&(p=55,v=55,x=55),l){const e=$(l);e&&(p=e.r,v=e.g,x=e.b)}let b=212,w=255,y=0;const S=$(m);S&&(b=S.r,w=S.g,y=S.b);const E=s.replace(/ /g,"").split("");if(0!==E.length){for(let r=0;r<f;r++){const a=T(17*r,3)*Math.PI*2,s=(n*(.15+.85*T(31*r,7))*h*.22+T(13*r,11))%1,c=u+Math.cos(a)*s*M,l=g+Math.sin(a)*s*M;if(c<-20||c>t+20||l<-20||l>o+20)continue;const f=Math.max(6,i*(.4+.9*s));e.font=`${f}px monospace`;const m=E[Math.min(E.length-1,Math.floor(s*E.length))],S=s>.72,$=d?.85*s:.2*s;e.fillStyle=S?`rgba(${b},${w},${y},${Math.min(d?.92:.32,2.2*$)})`:`rgba(${p},${v},${x},${$})`,e.fillText(m,c,l)}e.textAlign="left"}}function fe(e,t,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=". · ○ ◎ ●",accentColor:c,color:l,rings:h=5,speed:f=1,sharpness:d=4,lightMode:m=!1}=a,u=c??(m?"#007a5e":"#00ffcc");e.clearRect(0,0,t,o),e.textBaseline="middle",e.textAlign="center";const g=t*r.x,M=o*r.y,p=1.6*Math.sqrt(g*g+M*M)+.2*Math.sqrt(t*t+o*o);let v=255,x=255,b=255;if(m&&(v=55,x=55,b=55),l){const e=$(l);e&&(v=e.r,x=e.g,b=e.b)}let w=0,y=255,S=204;const E=$(u);E&&(w=E.r,y=E.g,S=E.b);const C=s.replace(/ /g,"").split("");if(0===C.length)return;const T=Math.ceil(t/i),A=Math.ceil(o/i);for(let t=0;t<A;t++)for(let o=0;o<T;o++){const r=o*i+.5*i,a=t*i+.5*i,s=r-g,c=a-M,l=Math.sqrt(s*s+c*c)/p;let u=0;for(let e=0;e<h;e++){const t=(n*f*.38+e/h)%1,o=Math.abs(l-t),r=Math.max(0,1-o*p/(i*(12-d)));u+=Math.cos(r*Math.PI*.5)*r}if(u=Math.min(1,u),u<.02)continue;const $=u>.6;e.font=`${i}px monospace`;const E=Math.floor(u*(C.length-1)),T=C[Math.min(E,C.length-1)],A=m?.88*u:.22*u;e.fillStyle=$?`rgba(${w},${y},${S},${Math.min(m?.95:.4,.55*u)})`:`rgba(${v},${x},${b},${A})`,e.fillText(T,r,a)}e.textAlign="left"}function de(e,t,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" .·:;=+*#%@░▒▓",accentColor:c,color:l,octaves:h=4,speed:f=1,scale:d=1,accentThreshold:m=.78,mouseWarp:u=.3,lightMode:g=!1}=a,M=c??(g?"#6b8700":"#d4ff00"),p=.62*i,v=1.4*i,x=Math.ceil(t/p),b=Math.ceil(o/v);e.clearRect(0,0,t,o),e.font=`${i}px monospace`,e.textBaseline="top";let w=255,y=255,S=255;if(g&&(w=55,y=55,S=55),l){const e=$(l);e&&(w=e.r,y=e.g,S=e.b)}let E=212,C=255,T=0;const I=$(M);I&&(E=I.r,C=I.g,T=I.b);const R=.035*d,F=n*f,k=Math.min(6,Math.max(1,h)),L=(e,t)=>{let o=0,n=.5,r=1,a=0;for(let i=0;i<k;i++)o+=A(e*r,t*r)*n,a+=n,n*=.5,r*=2.1;return o/a};for(let t=0;t<b;t++)for(let o=0;o<x;o++){const n=o*R+.06*F,a=t*R*1.3-.04*F,i=o/x-r.x,c=t/b-r.y,l=Math.sqrt(i*i+c*c),h=u>0?.12*Math.max(0,1-l/u):0,f=.5*L(n+h*Math.sin(1.3*F+8*c),a+h*Math.cos(.9*F+8*i))+.5;if(f<.12)continue;const d=s[Math.floor(f*(s.length-1))];if(" "===d)continue;const M=f>m,$=g?.82*f:.13*f;e.fillStyle=M?`rgba(${E},${C},${T},${g?.92:.28})`:`rgba(${w},${y},${S},${$})`,e.fillText(d,o*p,t*v)}}function me(e,t,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=12,chars:s="·-=+|/",accentColor:c,color:l,bands:h=3,speed:f=1,bandWidth:d=.12,glitch:m=!0,lightMode:u=!1}=a,g=c??(u?"#6b8700":"#d4ff00"),M=.62*i,p=1.4*i,v=Math.ceil(t/M),x=Math.ceil(o/p);e.clearRect(0,0,t,o),e.font=`${i}px monospace`,e.textBaseline="top";let b=255,w=255,y=255;if(u&&(b=55,w=55,y=55),l){const e=$(l);e&&(b=e.r,w=e.g,y=e.b)}let S=212,E=255,C=0;const A=$(g);A&&(S=A.r,E=A.g,C=A.b);const I=n*f;for(let t=0;t<x;t++)for(let o=0;o<v;o++){const n=t/x,a=((n*h-.5*I)%1+1)%1,i=Math.max(0,1-a/d),c=.35*(.5*T(3*o,7*t)+.5);let l=0;if(m){const e=o/v-r.x,a=n-r.y,i=Math.sqrt(e*e+a*a);if(i<.18){const e=T(11*o+Math.floor(12*I),5*t);l=Math.max(0,1-i/.18)*(e>.5?e-.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))],$=i>.55,A=u?.82*f:.12*f;e.fillStyle=$?`rgba(${S},${E},${C},${u?.92:.28})`:`rgba(${b},${w},${y},${A})`,e.fillText(g,o*M,t*p)}}function ue(e,t,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" ·∙•:;+=≡≣#@",color:c,accentColor:l,speed:h=1,layers:f=5,softness:d=1.2,mouseRipple:m=.2,lightMode:u=!1}=a,g=l??(u?"#6b8700":"#d4ff00"),M=.62*i,p=1.4*i,v=Math.ceil(t/M),x=Math.ceil(o/p);e.clearRect(0,0,t,o),e.font=`${i}px monospace`,e.textBaseline="top";let b=255,w=255,y=255;if(u&&(b=55,w=55,y=55),c){const e=$(c);e&&(b=e.r,w=e.g,y=e.b)}let S=212,E=255,C=0;const A=$(g);A&&(S=A.r,E=A.g,C=A.b);const I=n*h,R=[];for(let e=0;e<f;e++){const t=T(17*e,31*e+7),o=T(23*e+5,11*e);R.push({fx:.8+2.2*t,fy:1.2+1.8*o,phase:t*Math.PI*4,dt:(.3+.5*T(7*e,13*e+3))*(e%2==0?1:-1),amp:.55+.45*T(29*e,3*e)})}for(let t=0;t<x;t++){const o=t/x;for(let n=0;n<v;n++){const a=n/v,i=a-r.x,c=o-r.y,l=Math.sqrt(i*i+c*c),h=m*Math.exp(-l*l/.06),g=a+i*h,x=o+c*h;let $=0,T=0;for(let e=0;e<f;e++){const{fx:t,fy:o,phase:n,dt:r,amp:a}=R[e];$+=Math.sin(g*t*Math.PI*2+I*r+n)*Math.cos(x*o*Math.PI*2+I*r*.7+1.3*n)*a,T+=a}const A=$/T,F=.5+.5*Math.tanh(A*d*2.2);if(F<.12)continue;const k=(F-.12)/.88,L=s[Math.min(s.length-1,Math.floor(k*s.length))],B=F>.82,z=u?.82*F:.14*F;e.fillStyle=B?`rgba(${S},${E},${C},${u?.92:.32})`:`rgba(${b},${w},${y},${z})`,e.fillText(L,n*M,t*p)}}}function ge(e,t,o,n,r={}){const{fontSize:a=13,color:i,accentColor:s,speed:c=.4,layers:l=4,turbulence:h=.8,lightMode:f=!1}=r,d=s??(f?"#6b8700":"#d4ff00"),m=.62*a,u=1.4*a,g=Math.ceil(t/m),M=Math.ceil(o/u);e.clearRect(0,0,t,o),e.font=`${a}px monospace`,e.textBaseline="top";let p=255,v=255,x=255;if(f&&(p=55,v=55,x=55),i){const e=$(i);e&&(p=e.r,v=e.g,x=e.b)}let b=212,w=255,y=0;const S=$(d);S&&(b=S.r,w=S.g,y=S.b);const E=n*c,C=["─","─","╌","·","╌","─","─","╌","·"];for(let t=0;t<M;t++){const o=t/M;for(let n=0;n<g;n++){const r=n/g;let a=0,i=0;for(let e=0;e<l;e++){const t=T(13*e,7*e+3),n=1.1+2.4*t,s=.9+2*T(29*e,11*e+1),c=t*Math.PI*6,l=(.2+.5*T(41*e,17*e))*(e%2==0?1:-1.3),f=Math.sin(r*n*Math.PI*2+E*l+c),d=Math.cos(o*s*Math.PI*2+E*l*.6+1.7*c),m=Math.sin(r*s*Math.PI*h+o*n*Math.PI*h+E*l*.4);a+=Math.atan2(d+.3*m,f),i+=.5*(f*d+1)}const s=a/l,c=Math.min(1,i/l);if(c<.1)continue;const d=(s+Math.PI)/(2*Math.PI),M=C[Math.floor(d*C.length)%C.length],S=c>.8,$=f?.8*c:.13*c;e.fillStyle=S?`rgba(${b},${w},${y},${f?.9:.26})`:`rgba(${p},${v},${x},${$})`,e.fillText(M,n*m,t*u)}}}function Me(e,t,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=13,chars:s=" ·:;=+*#%@",color:c,accentColor:l,speed:h=1,radius:f=.38,swirl:d=3,lightMode:m=!1}=a,u=l??(m?"#6b8700":"#d4ff00"),g=.62*i,M=1.4*i,p=Math.ceil(t/g),v=Math.ceil(o/M),x=t/o;e.clearRect(0,0,t,o),e.font=`${i}px monospace`,e.textBaseline="top";let b=255,w=255,y=255;if(m&&(b=55,w=55,y=55),c){const e=$(c);e&&(b=e.r,w=e.g,y=e.b)}let S=212,E=255,C=0;const A=$(u);A&&(S=A.r,E=A.g,C=A.b);const I=n*h;for(let t=0;t<v;t++){const o=t/v;for(let n=0;n<p;n++){const a=(n/p-r.x)*x,i=o-r.y,c=Math.sqrt(a*a+i*i)/f;if(c>1){const o=T(3*n,7*t)*Math.max(0,1-3*(c-1));if(o<.62)continue;const r=o*(m?.28:.04);e.fillStyle=`rgba(${b},${w},${y},${r})`,e.fillText(s[1],n*g,t*M);continue}const l=Math.max(0,1-Math.abs(c-(.15+.12*Math.sin(1.1*I)))/.07),h=Math.pow(1-c,2.2),d=Math.min(1,h+.6*l);if(d<.06)continue;const u=Math.floor(d*(s.length-1)),v=s[Math.min(s.length-1,u)],$=l>.35||c<.08,A=m?.85*d:.18*d;e.fillStyle=$?`rgba(${S},${E},${C},${m?.95:.38})`:`rgba(${b},${w},${y},${A})`,e.fillText(v,n*g,t*M)}}}function pe(e,t,o,n,r={}){const{fontSize:a=14,chars:i=" ·∙•:-=+*#",color:s,accentColor:c,speed:l=.5,harmonics:h=3,lightMode:f=!1}=r,d=c??(f?"#6b8700":"#d4ff00"),m=.62*a,u=1.4*a,g=Math.ceil(t/m),M=Math.ceil(o/u);e.clearRect(0,0,t,o),e.font=`${a}px monospace`,e.textBaseline="top";let p=255,v=255,x=255;if(f&&(p=55,v=55,x=55),s){const e=$(s);e&&(p=e.r,v=e.g,x=e.b)}let b=212,w=255,y=0;const S=$(d);S&&(b=S.r,w=S.g,y=S.b);const E=n*l,C=Array.from({length:h},(e,t)=>1/(t+1)).reduce((e,t)=>e+t,0);for(let t=0;t<M;t++)for(let o=0;o<g;o++){let n=0;for(let e=0;e<h;e++){const r=.18+1.4*T(o*(e+3)+7,t*(e+5)+11),a=T(o*(e+7),t*(e+9)+3)*Math.PI*2,i=1/(e+1);n+=Math.sin(E*r+a)*i}const r=.5*(n/C+1);if(r<.28)continue;const a=(r-.28)/.72,s=i[Math.min(i.length-1,Math.floor(a*i.length))],c=r>.88,l=f?.82*a:.13*a;e.fillStyle=c?`rgba(${b},${w},${y},${f?.92:.28})`:`rgba(${p},${v},${x},${l})`,e.fillText(s,o*m,t*u)}}function ve(e,t,o,n,r={}){const{fontSize:a=13,chars:i=" .,:;i+xX#&@",color:s="#ff4500",hotColor:c="#ffe066",intensity:l=.85,wind:h=0,speed:f=1,lightMode:d=!1}=r,m=.62*a,u=1.4*a,g=Math.ceil(t/m),M=Math.ceil(o/u),p=g*M,v="__fire_heat__",x=e.canvas;let b=x[v];b&&b.length===p||(b=new Float32Array(p),x[v]=b);const w=.18*(.016*f),y=h*f*.8,S=M-1,E=n*f;for(let e=0;e<g;e++){const t=(.6*(.5*Math.sin(.31*e+4.1*E)+.5)+.4*(.5*Math.sin(.73*e-2.7*E)+.5))*l;b[S*g+e]=Math.min(1,t+.15*Math.random()*l),S>0&&(b[(S-1)*g+e]=Math.min(1,.85*t+.1*Math.random()*l))}const C=new Float32Array(p);for(let e=0;e<M-2;e++)for(let t=0;t<g;t++){const o=.4*b[(e+1)*g+t]+.25*b[(e+2)*g+Math.max(0,Math.min(g-1,t+Math.round(y)))]+.175*b[(e+1)*g+Math.max(0,t-1)]+.175*b[(e+1)*g+Math.min(g-1,t+1)];C[e*g+t]=Math.max(0,o-w-.02*Math.random()*f)}for(let e=0;e<g;e++)C[(M-1)*g+e]=b[(M-1)*g+e],M>1&&(C[(M-2)*g+e]=b[(M-2)*g+e]);x[v]=C;const T=$(s)??{r:255,g:69,b:0},A=$(c)??{r:255,g:224,b:102};e.clearRect(0,0,t,o),e.font=`${a}px "JetBrains Mono", monospace`,e.textBaseline="top";for(let t=0;t<M;t++)for(let o=0;o<g;o++){const n=C[t*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=T.r+(A.r-T.r)*a|0,c=T.g+(A.g-T.g)*a|0,l=T.b+(A.b-T.b)*a|0,h=d?1-.3*n:Math.min(1,n+.15);e.globalAlpha=h,e.fillStyle=`rgb(${s},${c},${l})`,e.fillText(r,o*m,t*u)}e.globalAlpha=1}function xe(e,t,o,n,r={}){const{fontSize:a=13,baseChars:i="ATCG",bridgeChars:s="-=≡",color:c="#00e5ff",color2:l="#ff4081",bridgeColor:h="#88ffcc",speed:f=1,helixCount:d,lightMode:m=!1}=r,u=.62*a,g=1.4*a,M=Math.ceil(t/u),p=Math.ceil(o/g),v=d??Math.max(1,Math.floor(t/80)),x=M/v,b=$(c)??{r:0,g:229,b:255},w=$(l)??{r:255,g:64,b:129},y=$(h)??{r:136,g:255,b:204};e.clearRect(0,0,t,o),e.font=`${a}px "JetBrains Mono", monospace`,e.textBaseline="top";const S=n*f,E=.35*x;for(let t=0;t<v;t++){const o=x*(t+.5);for(let n=0;n<p;n++){const r=n/p*Math.PI*6-1.8*S,a=o+Math.sin(r)*E,c=o+Math.sin(r+Math.PI)*E,l=Math.round(a),h=Math.round(c);if(l<0||l>=M)continue;const f=T(31*t+7*n,3),d=i[Math.floor(f*i.length)],m=.5*(Math.sin(r)+1),v=.5*(Math.sin(r+Math.PI)+1);if(e.globalAlpha=.35+.65*m,e.fillStyle=`rgb(${b.r},${b.g},${b.b})`,e.fillText(d,l*u,n*g),h>=0&&h<M){const o=T(53*t+11*n,7),r=i[Math.floor(o*i.length)];e.globalAlpha=.35+.65*v,e.fillStyle=`rgb(${w.r},${w.g},${w.b})`,e.fillText(r,h*u,n*g)}if(n%3===0){const o=Math.min(l,h),r=Math.max(l,h);if(r-o>1){const a=T(17*n+43*t,5),i=s[Math.floor(a*s.length)],c=.25*(m+v)+.2;e.globalAlpha=c,e.fillStyle=`rgb(${y.r},${y.g},${y.b})`;for(let t=o+1;t<r;t++)e.fillText(i,t*u,n*g)}}}}e.globalAlpha=1}function be(e,t,o,n,r={}){const{fontSize:a=13,chars:i=" .,:;+*#@",color:s="#4caf50",skyColor:c="#1a237e",peakColor:l="#e0e0e0",speed:h=1,roughness:f=.55,heightScale:d=.55,stars:m=!0,lightMode:u=!1}=r,g=.62*a,M=1.4*a,p=Math.ceil(t/g),v=Math.ceil(o/M),x=$(s)??{r:76,g:175,b:80},b=$(c)??{r:26,g:35,b:126},w=$(l)??{r:224,g:224,b:224};e.clearRect(0,0,t,o),e.font=`${a}px "JetBrains Mono", monospace`,e.textBaseline="top";const y=n*h*.4,S=new Array(p);for(let e=0;e<p;e++){const t=(.5*I((e/p+y)*f*3,.5)+.5)*d;S[e]=Math.floor(t*v)}for(let t=0;t<v;t++)for(let o=0;o<p;o++){const r=v-1-S[o],a=t===r;if(!(t>=r)){if(m){const r=T(7*o+Math.floor(.3*y),13*t);if(r>.97){const a=.3*Math.sin(2*n+100*r)+.7;e.globalAlpha=.5*a,e.fillStyle=`rgb(${b.r+60},${b.g+60},${b.b+80})`,e.fillText("·",o*g,t*M)}}continue}const s=(t-r)/Math.max(1,S[o]),c=i[Math.min(i.length-1,Math.floor(s*i.length))];if(" "===c&&!a)continue;const l=a?1:Math.max(0,1-4*s),h=x.r+(w.r-x.r)*l|0,f=x.g+(w.g-x.g)*l|0,d=x.b+(w.b-x.b)*l|0;e.globalAlpha=.5+.5*s,e.fillStyle=`rgb(${h},${f},${d})`,e.fillText(a?i[i.length-1]:c,o*g,t*M)}e.globalAlpha=1}var we=1,ye=2,Se=4,$e=8,Ee={3:"─",12:"│",9:"┌",10:"┐",5:"└",6:"┘",11:"┬",7:"┴",13:"├",14:"┤",15:"┼",[we]:"╶",[ye]:"╴",[Se]:"╵",[$e]:"╷"};function Ce(e,t,o,n,r={}){const{fontSize:a=13,pulseColor:i="#ffffff",color:s="#00ff88",density:c=.38,speed:l=1,lightMode:h=!1}=r,f=.62*a,d=1.4*a,m=Math.ceil(t/f),u=Math.ceil(o/d),g=$(s)??{r:0,g:255,b:136},M=$(i)??{r:255,g:255,b:255},p=(e,t)=>{if(T(17*e+1,7*t+2)>c)return 0;let o=0;return e+1<m&&T(17*e+1,7*t+2)>.15&&(o|=1),e-1>=0&&T(17*(e-1)+1,7*t+2)>.15&&(o|=2),t+1<u&&T(17*e+1,7*(t+1)+2)>.15&&(o|=8),t-1>=0&&T(17*e+1,7*(t-1)+2)>.15&&(o|=4),o};e.clearRect(0,0,t,o),e.font=`${a}px "JetBrains Mono", monospace`,e.textBaseline="top";const v=n*l;for(let t=0;t<u;t++)for(let o=0;o<m;o++){const n=p(o,t);if(0===n)continue;const r=Ee[n]??"·",a=(8*v+40*T(o,23*t))%m,i=(6*v+40*T(17*t,11*o))%u,s=(1&n||2&n)&&Math.abs(o-a)<1.5,c=(4&n||8&n)&&Math.abs(t-i)<1.5,l=s||c,h=.25+.35*T(3*o,5*t);l?(e.globalAlpha=.95,e.fillStyle=`rgb(${M.r},${M.g},${M.b})`):(e.globalAlpha=h,e.fillStyle=`rgb(${g.r},${g.g},${g.b})`),e.fillText(r,o*f,t*d)}e.globalAlpha=1}function Te(e,t={}){const{type:o="wave",opacity:n=.2,className:r,zIndex:a=0,colorScheme:i="auto",color:s,...c}=t,l="string"==typeof e?document.querySelector(e):e;if(!l)return console.warn("[asciify] asciiBackground: target not found",e),{destroy:()=>{}};const h=l.style.position;"static"===getComputedStyle(l).position&&(l.style.position="relative");const f=document.createElement("canvas");f.style.cssText=["position:absolute","inset:0","width:100%","height:100%",`opacity:${n}`,"pointer-events:none",`z-index:${a}`].join(";"),r&&(f.className=r),l.prepend(f);const d=f.getContext("2d"),m=window.devicePixelRatio||1,u={x:.5,y:.5},g={x:.5,y:.5},M=()=>"light"===i||"dark"!==i&&(()=>{let e=l;for(;e&&e!==document.documentElement.parentElement;){const t=getComputedStyle(e).backgroundColor;if(t&&"transparent"!==t&&"rgba(0, 0, 0, 0)"!==t){const e=t.match(/rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)/);if(e)return(.299*+e[1]+.587*+e[2]+.114*+e[3])/255>=.4}e=e.parentElement}const t=document.documentElement,o=(t.getAttribute("data-theme")||"").toLowerCase();return"dark"!==o&&("light"===o||!t.classList.contains("dark")&&window.matchMedia("(prefers-color-scheme: light)").matches)})(),p=s?function(e){const t=e.match(/^#([0-9a-f]{3,8})$/i)?.[1];if(t){const e=t.length<=4?t.split("").map(e=>parseInt(e+e,16)):[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)];return{r:e[0],g:e[1],b:e[2]}}const o=e.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i);return o?{r:+o[1],g:+o[2],b:+o[3]}:null}(s):null,v=()=>({...c,lightMode:void 0!==c.lightMode?c.lightMode:M(),baseColor:p?`rgba(${p.r},${p.g},${p.b},{a})`:c.baseColor}),x={current:v()},b=()=>{x.current="rain"===o||"stars"===o||"pulse"===o||"noise"===o||"grid"===o||"aurora"===o||"silk"===o||"void"===o||"morph"===o?{...c,lightMode:void 0!==c.lightMode?c.lightMode:M(),color:s??c.color}:"fire"===o||"dna"===o?{...c,color:s??c.color}:"terrain"===o||"circuit"===o?{...c,color:s??c.color,lightMode:void 0!==c.lightMode?c.lightMode:M()}:v()};b();const w=window.matchMedia("(prefers-color-scheme: light)"),y=()=>{b()};let S=null;"auto"===i&&(w.addEventListener("change",y),S=new MutationObserver(y),S.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]}));const $=()=>{const e=l.getBoundingClientRect();f.width=e.width*m,f.height=e.height*m,d.setTransform(m,0,0,m,0,0)};$();const E=e=>{const t=l.getBoundingClientRect();u.x=(e.clientX-t.left)/t.width,u.y=(e.clientY-t.top)/t.height},C=new ResizeObserver($);C.observe(l),window.addEventListener("mousemove",E);let T=0,A=0;const I=()=>{g.x+=.07*(u.x-g.x),g.y+=.07*(u.y-g.y);const e=l.getBoundingClientRect();"rain"===o?le(d,e.width,e.height,T,x.current):"stars"===o?he(d,e.width,e.height,T,g,x.current):"pulse"===o?fe(d,e.width,e.height,T,g,x.current):"noise"===o?de(d,e.width,e.height,T,g,x.current):"grid"===o?me(d,e.width,e.height,T,g,x.current):"aurora"===o?ue(d,e.width,e.height,T,g,x.current):"silk"===o?ge(d,e.width,e.height,T,x.current):"void"===o?Me(d,e.width,e.height,T,g,x.current):"morph"===o?pe(d,e.width,e.height,T,x.current):"fire"===o?ve(d,e.width,e.height,T,x.current):"dna"===o?xe(d,e.width,e.height,T,x.current):"terrain"===o?be(d,e.width,e.height,T,x.current):"circuit"===o?Ce(d,e.width,e.height,T,x.current):R(d,e.width,e.height,T,g,x.current),T+=.016,A=requestAnimationFrame(I)};return A=requestAnimationFrame(I),{destroy:()=>{cancelAnimationFrame(A),C.disconnect(),"auto"===i&&(w.removeEventListener("change",y),S?.disconnect()),window.removeEventListener("mousemove",E),f.remove(),l.style.position=h}}}var Ae=Te;function Ie(e,t,o,n="#505050",r=100){if(!e||t<=0||o<=0)return[];const a=$(n)??{r:80,g:80,b:80},i=e,s=i.length;return Array.from({length:o},(e,o)=>Array.from({length:t},(e,n)=>({char:i[(o*t+n)%s],r:a.r,g:a.g,b:a.b,a:r})))}function Re(e,{format:t="png",quality:o=.92,scale:n=1}={}){return new Promise((r,a)=>{let i=e;if(1!==n){const t=document.createElement("canvas");t.width=Math.round(e.width*n),t.height=Math.round(e.height*n);const o=t.getContext("2d");if(!o)return void a(new Error("captureSnapshot: could not get 2d context"));o.drawImage(e,0,0,t.width,t.height),i=t}i.toBlob(e=>e?r(e):a(new Error("captureSnapshot: toBlob returned null")),`image/${t}`,o)})}var Fe={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]},ke=[127,65,65,65,65,65,127];function Le(e){return Fe[e]??Fe[e.toUpperCase()]??ke}function Be(e,t={}){if(!e)return"";const{char:o="█",scale:n=1}=t,r=[...o][0]??"█",a=Math.max(1,Math.floor(n)),i=7*a,s=a,c=Array.from({length:i},()=>"");for(let t=0;t<e.length;t++){const o=Le(e[t]);for(let e=0;e<7;e++){const t=o[e];let n="";for(let e=6;e>=0;e--)n+=(t>>e&1?r:" ").repeat(a);for(let t=0;t<a;t++)c[e*a+t]+=n}if(t<e.length-1)for(let e=0;e<i;e++)c[e]+=" ".repeat(s)}return c.join("\n")}exports.ART_STYLE_PRESETS=n,exports.BACKGROUND_TYPES=["wave","rain","stars","pulse","noise","grid","aurora","silk","void","morph","fire","dna","terrain","circuit"],exports.CHARSETS=t,exports.CHARSET_SEQUENCES=o,exports.DEFAULT_OPTIONS=a,exports.HOVER_PRESETS={none:{label:"Off",options:{hoverStrength:0,hoverEffect:"spotlight",hoverRadius:.2,hoverColor:"#ffffff"}},subtle:{label:"Subtle",options:{hoverStrength:.25,hoverEffect:"glow",hoverRadius:.12,hoverColor:"#ffffff"}},flashlight:{label:"Flashlight",options:{hoverStrength:.6,hoverEffect:"spotlight",hoverRadius:.15,hoverColor:"#fffbe6"}},magnifier:{label:"Magnifier",options:{hoverStrength:.7,hoverEffect:"magnify",hoverRadius:.12,hoverColor:"#ffffff"}},forceField:{label:"Force Field",options:{hoverStrength:.7,hoverEffect:"repel",hoverRadius:.15,hoverColor:"#a0e8ff"}},neon:{label:"Neon",options:{hoverStrength:.6,hoverEffect:"colorShift",hoverRadius:.15,hoverColor:"#d946ef"}},fire:{label:"Fire",options:{hoverStrength:.7,hoverEffect:"spotlight",hoverRadius:.15,hoverColor:"#ff6b2b"}},ice:{label:"Ice",options:{hoverStrength:.5,hoverEffect:"glow",hoverRadius:.15,hoverColor:"#60d5f7"}},gravity:{label:"Gravity",options:{hoverStrength:.7,hoverEffect:"attract",hoverRadius:.18,hoverColor:"#a5d6ff"}},shatter:{label:"Shatter",options:{hoverStrength:.8,hoverEffect:"shatter",hoverRadius:.14,hoverColor:"#ff6090"}},ghost:{label:"Ghost",options:{hoverStrength:.55,hoverEffect:"trail",hoverRadius:.2,hoverColor:"#b39ddb"}},glitchReveal:{label:"Glitch Reveal",options:{hoverStrength:.8,hoverEffect:"glitchText",hoverRadius:.18,hoverColor:"#a3e635"}}},exports.LIVING_STYLE_PRESETS=r,exports.PALETTE_THEMES={dracula:{name:"Dracula",accent:"#bd93f9",bg:"#282a36",fg:"#f8f8f2"},monokai:{name:"Monokai",accent:"#a6e22e",bg:"#272822",fg:"#f8f8f2"},nord:{name:"Nord",accent:"#88c0d0",bg:"#2e3440",fg:"#eceff4"},catppuccin:{name:"Catppuccin",accent:"#cba6f7",bg:"#1e1e2e",fg:"#cdd6f4"},solarized:{name:"Solarized",accent:"#268bd2",bg:"#002b36",fg:"#839496"},gruvbox:{name:"Gruvbox",accent:"#b8bb26",bg:"#282828",fg:"#ebdbb2"}},exports.asciiBackground=Te,exports.asciiText=function(e,t={},o,n){const r={...a,...t},{frame:i,cols:s}=_(e,r,o,n);if(!i.length||0===s)return"";const c=[];for(const e of i)c.push(e.map(e=>e.char).join(""));return c.join("\n")},exports.asciiTextAnsi=function(e,t={},o,n){const r={...a,...t},{frame:i,cols:s}=_(e,r,o,n);if(!i.length||0===s)return"";const c=[];for(const e of i){let t="";for(const o of e)" "===o.char||o.a<10?t+=" ":t+=`[38;2;${o.r};${o.g};${o.b}m${o.char}`;c.push(t)}return c.join("\n")},exports.asciify=async function(e,t,{fontSize:o,artStyle:r="classic",options:i={}}={}){let s;if("string"==typeof e){const t=new Image;t.crossOrigin="anonymous",await new Promise((o,n)=>{t.onload=()=>o(),t.onerror=()=>n(new Error(`Failed to load image: ${e}`)),t.src=e}),s=t}else e instanceof HTMLImageElement&&!e.complete?(await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error("Image failed to load"))}),s=e):s=e;const c=n[r],l=o??i.fontSize??10,h={...a,...c,...i,fontSize:l},f=t.getContext("2d");if(!f)throw new Error("Could not get 2d context from canvas");const{w:d,h:m}=function(e){return e instanceof HTMLVideoElement?{w:e.videoWidth,h:e.videoHeight}:e instanceof HTMLImageElement?{w:e.naturalWidth||e.width,h:e.naturalHeight||e.height}:{w:e.width,h:e.height}}(s),{renderW:u,renderH:g}=ie(d,m),M="undefined"!=typeof window&&window.devicePixelRatio||1,p=8e6,v=u*M*g*M>p?Math.sqrt(p/(u*g)):M;if((t.width<u||t.height<g)&&(t.width=Math.round(u*v),t.height=Math.round(g*v)),h.hoverStrength>0){const{frame:e}=_(s,h,u,g);let o=null,n=!1,r=0;const a=e=>{const n=t.getBoundingClientRect();o={x:(e.clientX-n.left)/n.width,y:(e.clientY-n.top)/n.height}},i=()=>{o=null};t.addEventListener("mousemove",a),t.addEventListener("mouseleave",i);const c=t=>{n||(f.save(),f.setTransform(v,0,0,v,0,0),Q(f,e,h,u,g,t/1e3,o),f.restore(),r=requestAnimationFrame(c))};return r=requestAnimationFrame(c),()=>{n=!0,cancelAnimationFrame(r),t.removeEventListener("mousemove",a),t.removeEventListener("mouseleave",i)}}if(f.save(),f.setTransform(v,0,0,v,0,0),te(h)){const e=Y(s,h,u,g);N(f,e,h,u,g)}else{const{frame:e}=_(s,h,u,g);Q(f,e,h,u,g)}f.restore()},exports.asciifyGif=async function(e,t,{fontSize:o,artStyle:r="classic",options:i={}}={}){const s="string"==typeof e?await fetch(e).then(e=>e.arrayBuffer()):e,c=o??i.fontSize??10,l={...a,...n[r],...i,fontSize:c},h=t.getContext("2d");if(!h)throw new Error("Could not get 2d context from canvas");if(te(l)){const{frames:e,fps:o}=await K(s,l,t.width,t.height);let n,r=!1,a=0,i=performance.now();const c=1e3/o,f=o=>{r||(o-i>=c&&(N(h,e[a],l,t.width,t.height),a=(a+1)%e.length,i=o),n=requestAnimationFrame(f))};return n=requestAnimationFrame(f),()=>{r=!0,cancelAnimationFrame(n)}}const{frames:f,fps:d}=await J(s,l,t.width,t.height);let m,u=!1,g=0,M=performance.now();const p=1e3/d,v=e=>{u||(e-M>=p&&(Q(h,f[g],l,t.width,t.height),g=(g+1)%f.length,M=e),m=requestAnimationFrame(v))};return m=requestAnimationFrame(v),()=>{u=!0,cancelAnimationFrame(m)}},exports.asciifyLiveVideo=function(e,t,o){return ce(e,t,o)},exports.asciifyText=Be,exports.asciifyVideo=ce,exports.asciifyWebcam=async function(e,{fontSize:t=10,style:o="classic",options:r={},liveOptions:i,mirror:s=!0,constraints:c={facingMode:"user"},dpr:l}={}){if(!navigator.mediaDevices?.getUserMedia)throw new Error("asciifyWebcam: getUserMedia is not supported in this browser.");const h=await navigator.mediaDevices.getUserMedia({video:c}),f=document.createElement("video");f.srcObject=h,f.muted=!0,f.playsInline=!0,await new Promise((e,t)=>{f.onloadedmetadata=()=>e(),f.onerror=()=>t(new Error("asciifyWebcam: video stream failed to load.")),f.play().catch(t)});const d={...a,...n[o],...r,fontSize:t},m=e.getContext("2d");if(!m)throw new Error("asciifyWebcam: could not get 2d context from canvas.");const u=l??("undefined"!=typeof window?window.devicePixelRatio:1)??1;1!==u&&m.scale(u,u);let g=null;const M={x:.5,y:.5,intensity:0},p=t=>{const o=e.getBoundingClientRect();g={x:(t.clientX-o.left)/o.width,y:(t.clientY-o.top)/o.height}},v=()=>{g=null};d.hoverStrength>0&&(e.addEventListener("mousemove",p),e.addEventListener("mouseleave",v));let x,b=!1;const w=performance.now(),y=t=>{if(!b){if(f.readyState>=f.HAVE_CURRENT_DATA){const o=e.width/u,n=e.height/u,r=(t-w)/1e3,a=i?{...d,...i()}:d;a.hoverStrength>0?(e.addEventListener("mousemove",p),e.addEventListener("mouseleave",v)):(e.removeEventListener("mousemove",p),e.removeEventListener("mouseleave",v));const{frame:c}=_(f,a,o,n);if(g){const e=g.x-M.x,t=g.y-M.y,o=Math.sqrt(e*e+t*t),n=Math.min(.25,.06+.8*o);M.x+=e*n,M.y+=t*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;s?(m.save(),m.scale(-1,1),m.translate(-o,0),Q(m,c,a,o,n,r,l),m.restore()):Q(m,c,a,o,n,r,l)}x=requestAnimationFrame(y)}};return x=requestAnimationFrame(y),()=>{b=!0,cancelAnimationFrame(x),e.removeEventListener("mousemove",p),e.removeEventListener("mouseleave",v),h.getTracks().forEach(e=>e.stop()),f.srcObject=null}},exports.buildTextFrame=Ie,exports.captureSnapshot=Re,exports.clearAsciifyCaches=function(){q.clear(),P.clear(),H.clear(),L=null,B=null},exports.createVideoScrollScrub=re,exports.gifToAsciiFrames=J,exports.gifToAsciiTextFrames=K,exports.imageToAsciiFrame=_,exports.imageToAsciiTextFrame=Y,exports.mountWaveBackground=Ae,exports.renderAuroraBackground=ue,exports.renderCircuitBackground=Ce,exports.renderDnaBackground=xe,exports.renderFireBackground=ve,exports.renderFrameToCanvas=Q,exports.renderGridBackground=me,exports.renderMorphBackground=pe,exports.renderNoiseBackground=de,exports.renderPulseBackground=fe,exports.renderRainBackground=le,exports.renderSilkBackground=ge,exports.renderStarsBackground=he,exports.renderTerrainBackground=be,exports.renderTextBackground=function(e,t,o,n,r={},i){const{fontSize:s=10,lineHeight:c=1.6,color:l="#505050",opacity:h=100,hoverEffect:f="spotlight",hoverStrength:d=.85,hoverRadius:m=.18,hoverColor:u="#d4ff00"}=r;Q(e,Ie(n,Math.max(1,Math.floor(t/s)),Math.max(1,Math.floor(o/(s*c))),l,h),{...a,hoverEffect:f,hoverStrength:d,hoverRadius:m,hoverColor:u},t,o,0,i??null)},exports.renderTextFrameToCanvas=N,exports.renderTextToCanvas=function(e,t,o={}){const{color:n="#d4ff00",bgColor:r,fontSize:a=10}=o,i=Be(t,o);if(!i)return;const s=i.split("\n"),c=Math.max(...s.map(e=>[...e].length));e.width=Math.ceil(c*a*.6),e.height=Math.ceil(s.length*a);const l=e.getContext("2d");r&&"transparent"!==r?(l.fillStyle=r,l.fillRect(0,0,e.width,e.height)):l.clearRect(0,0,e.width,e.height),l.fillStyle=n,l.font=`${a}px monospace`,l.textBaseline="top",s.forEach((e,t)=>l.fillText(e,0,t*a))},exports.renderVoidBackground=Me,exports.renderWaveBackground=R,exports.snapshotAndDownload=async function(e,t={}){const{filename:o="asciify-snapshot",format:n="png",...r}=t,a=await Re(e,{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)},exports.videoToAsciiFrames=G,exports.videoToAsciiTextFrames=X;//# sourceMappingURL=index.cjs.map
1
+ "use strict";var e=require("gifuct-js"),t={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:" ·╶╴╷╵─│┌┐└┘├┤┬┴┼╬░▒▓█"},o={cosmic:[t.starfield,t.circles,t.shadows],rain:[t.katakana,t.braille,t.binary],terminal:[t.pipes,t.claudeCode,t.standard],crystal:[t.shards,t.geometric,t.blocks],fluid:[t.waves,t.smoke,t.circles],pulse:[t.dense,t.standard,t.blocks],dream:[t.braille,t.shadows,t.smoke],angular:[t.geometric,t.shards,t.starfield],assistant:[t.interface,t.prompt,t.data],signal:[t.mesh,t.data,t.ascii],editorial:[t.humanist,t.waves,t.smoke]},n={classic:{renderMode:"ascii",charset:t.standard,colorMode:"grayscale"},particles:{renderMode:"dots",colorMode:"fullcolor",dotSizeRatio:.8},letters:{renderMode:"ascii",charset:t.letters,colorMode:"fullcolor"},claudeCode:{renderMode:"ascii",charset:t.claudeCode,colorMode:"accent",accentColor:"#f97316"},art:{renderMode:"ascii",charset:t.dense,colorMode:"fullcolor"},terminal:{renderMode:"ascii",charset:t.standard,colorMode:"matrix"},box:{renderMode:"ascii",charset:t.box,colorMode:"grayscale"},lines:{renderMode:"ascii",charset:t.lines,colorMode:"fullcolor"},braille:{renderMode:"ascii",charset:t.braille,colorMode:"fullcolor"},katakana:{renderMode:"ascii",charset:t.katakana,colorMode:"matrix"},musical:{renderMode:"ascii",charset:t.musical,colorMode:"accent",accentColor:"#e040fb"},emoji:{renderMode:"ascii",charset:t.emoji,colorMode:"fullcolor"},circles:{renderMode:"ascii",charset:t.circles,colorMode:"accent",accentColor:"#d4ff00"},shadows:{renderMode:"ascii",charset:t.shadows,colorMode:"accent",accentColor:"#50a0ff"},starfield:{renderMode:"ascii",charset:t.starfield,colorMode:"fullcolor"},geometric:{renderMode:"ascii",charset:t.geometric,colorMode:"grayscale"},pipes:{renderMode:"ascii",charset:t.pipes,colorMode:"accent",accentColor:"#00ff88"},waves:{renderMode:"ascii",charset:t.waves,colorMode:"fullcolor"},shards:{renderMode:"ascii",charset:t.shards,colorMode:"grayscale"},smoke:{renderMode:"ascii",charset:t.smoke,colorMode:"accent",accentColor:"#c850ff"},ascii:{renderMode:"ascii",charset:t.ascii,colorMode:"grayscale"},interface:{renderMode:"ascii",charset:t.interface,colorMode:"accent",accentColor:"#f4f1ea"},prompt:{renderMode:"ascii",charset:t.prompt,colorMode:"matrix"},data:{renderMode:"ascii",charset:t.data,colorMode:"fullcolor"},humanist:{renderMode:"ascii",charset:t.humanist,colorMode:"accent",accentColor:"#d6ccc2"},mesh:{renderMode:"ascii",charset:t.mesh,colorMode:"accent",accentColor:"#8fd3ff"}},r={agentField:{...n.interface,charsetFrames:o.assistant,charsetFps:1.6,animationStyle:"breathe",animationSpeed:.75,ditherStrength:.12,hoverEffect:"glow",hoverStrength:.42,hoverRadius:.18,hoverColor:"#f4f1ea",normalize:!0},liquidSignal:{...n.data,charsetFrames:o.signal,charsetFps:2.4,animationStyle:"melt",animationSpeed:.65,ditherStrength:.45,hoverEffect:"repel",hoverStrength:.55,hoverRadius:.22,hoverColor:"#8fd3ff",normalize:!0},cursorGravity:{...n.mesh,charsetFrames:o.angular,charsetFps:1.2,animationStyle:"orbit",animationSpeed:.9,ditherStrength:.2,hoverEffect:"attract",hoverStrength:.82,hoverRadius:.24,hoverColor:"#ffffff",normalize:!0},editorialPulse:{...n.humanist,charsetFrames:o.editorial,charsetFps:.9,animationStyle:"ripple",animationSpeed:.55,ditherStrength:.18,hoverEffect:"spotlight",hoverStrength:.35,hoverRadius:.2,hoverColor:"#fff8ea",normalize:!0},terminalFlow:{...n.prompt,charsetFrames:o.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}},a={fontSize:10,charSpacing:1,brightness:0,contrast:0,charset:t.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};function i(e,t){const o=document.createElement("canvas");o.width=e,o.height=t;const n=o.getContext("2d",{willReadFrequently:!0});return{canvas:o,ctx:n}}function s(e,t,o){let n=e+255*t;return n=259*(255*o+255)/(255*(259-255*o))*(n-128)+128,Math.max(0,Math.min(255,n))}function c(e,t,o){const n=o?1-e/255:e/255,r=[...t],a=Math.floor(n*(r.length-1));return r[Math.max(0,Math.min(r.length-1,a))]}function l(e,t,o,n,r,a){if((a?1-e/255:e/255)<.12)return" ";const i=[...t];return i[(n*r+o)%i.length]}var h=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];function f(e,t,o,n){if(n<=0)return e;const r=(h[o%4][t%4]/16-.5)*n*128;return Math.max(0,Math.min(255,e+r))}var d=new Array(256),m=new Array(256);for(let e=0;e<256;e++)d[e]=`rgb(${e},${e},${e})`,m[e]=`rgb(0,${e},0)`;function u(e,t,o,n,r,a=!1){switch(t){case"fullcolor":return`rgb(${e.r},${e.g},${e.b})`;case"matrix":return m[.299*e.r+.587*e.g+.114*e.b|0];case"accent":return`rgb(${o},${n},${r})`;default:{const t=.299*e.r+.587*e.g+.114*e.b|0;return d[t]}}}var g=[0,0,0];function M(e,t,o,n,r,a=!1){switch(t){case"fullcolor":g[0]=e.r,g[1]=e.g,g[2]=e.b;break;case"matrix":{const t=.299*e.r+.587*e.g+.114*e.b|0;g[0]=0,g[1]=t,g[2]=0;break}case"accent":g[0]=o,g[1]=n,g[2]=r;break;default:{const t=.299*e.r+.587*e.g+.114*e.b|0;g[0]=t,g[1]=t,g[2]=t;break}}return g}function p(e){const t=e.match(/rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)(?:\s*[,/]\s*([\d.]+))?\s*\)/);return t?{r:+t[1],g:+t[2],b:+t[3],a:void 0!==t[4]?+t[4]:1}:null}function v(e){let t=e;for(;t&&t!==document.documentElement.parentElement;){const e=getComputedStyle(t).backgroundColor;if(e&&"transparent"!==e&&"rgba(0, 0, 0, 0)"!==e){const t=p(e);if(t&&t.a>.1)return t}t=t.parentElement}return null}function w(e){if(e){const t=v(e);if(t){return(.299*t.r+.587*t.g+.114*t.b)/255<.4}}if("undefined"!=typeof document){const e=document.documentElement,t=(e.getAttribute("data-theme")||"").toLowerCase();if("dark"===t)return!0;if("light"===t)return!1;if(e.classList.contains("dark"))return!0;if(document.body){const e=v(document.body);if(e){return(.299*e.r+.587*e.g+.114*e.b)/255<.4}}}return"undefined"!=typeof window&&window.matchMedia("(prefers-color-scheme: dark)").matches}function x(e){if("string"!=typeof e)return e;const t=document.createElement("canvas");t.width=1,t.height=1;const o=t.getContext("2d");o.fillStyle=e,o.fillRect(0,0,1,1);const n=o.getImageData(0,0,1,1).data;return{r:n[0],g:n[1],b:n[2]}}function b(e,t,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(e/o*Math.PI*4+3*s)+.5)+.4*(.5*Math.sin(t/n*Math.PI*3+2*s)+.5));case"pulse":{const r=o/2,a=n/2,i=Math.sqrt((e-r)**2+(t-a)**2),c=Math.sqrt(r**2+a**2);return.2+.8*(.5*Math.sin(i/c*Math.PI*6-4*s)+.5)}case"rain":return.1+.9*(.5*Math.sin(t/n*Math.PI*8-5*s+.3*e)+.5)*(.3*Math.sin(e/o*Math.PI*2+s)+.7);case"breathe":{const o=.3*Math.sin(2*s)+.7,n=.1*Math.sin(.1*(e+t)+s);return Math.max(.1,Math.min(1,o+n))}case"sparkle":{const o=43758.5453*Math.sin(127.1*e+311.7*t+43758.5453*Math.floor(8*s)),n=o-Math.floor(o);return n>.7?1:.15+.4*n}case"glitch":{const e=Math.floor(t/(.05*n)),o=43758.5453*Math.sin(43.23*e+17.89*Math.floor(6*s));if(o-Math.floor(o)>.85){const t=.5*Math.sin(30*s+e)+.5;return t<.3?0:t}return 1}case"spiral":{const r=o/2,a=n/2,i=e-r,c=t-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=t*o+e-.5*s%1*r*1.3;if(a>0)return 0;const i=Math.max(0,1+a/(.15*r));return Math.min(1,i)}case"scatter":{const r=o/2,a=n/2,i=e-r,c=t-a,l=Math.sqrt(i*i+c*c)/Math.sqrt(r*r+a*a),h=.5*Math.sin(1.5*s)+.5;return l>h?Math.max(0,1-3*(l-h)):.7+.3*Math.sin(10*l-2*s)}case"waveField":default:return 1;case"ripple":{const r=o/2,a=n/2,i=e-r,c=t-a,l=Math.sqrt(i*i+c*c),h=Math.sqrt(r*r+a*a);return.1+.9*(.5*Math.sin(l/h*Math.PI*10-5*s)+.5)*(.4+.6*(1-Math.min(1,l/(1.1*h))))}case"melt":{const o=t/n*Math.PI;return.05+(.5*Math.sin(o-1.8*s+.15*e)+.5)*(1-.6*(Math.max(0,t/n-.1)/.9))*.95}case"orbit":{const r=o/2,a=n/2,i=e-r,c=t-a,l=Math.atan2(c,i),h=Math.sqrt(i*i+c*c)/Math.sqrt(r*r+a*a);return.1+.9*(.5*Math.sin(2*l+6*h-2.5*s)+.5)}case"cellular":{const o=Math.floor(4*s),n=(e,t)=>{const n=43758.5453*Math.sin(127.1*e+311.7*t+43758.5453*o);return n-Math.floor(n)>.38?1:0},r=n(e,t),a=n(e-1,t)+n(e+1,t)+n(e,t-1)+n(e,t+1)+n(e-1,t-1)+n(e+1,t-1)+n(e-1,t+1)+n(e+1,t+1);return 1===(1===r?2===a||3===a?1:0:3===a?1:0)?1:.05}}}var y={scale:1,offsetX:0,offsetY:0,glow:0,colorBlend:0,proximity:0};function S(e,t,o,n,r,a,i,s,c="spotlight",l=.5,h="circle"){const f=e-o,d=t-n,m=.08+.35*l+.04*a;let u,g;if("box"===h){const e=Math.abs(f),t=Math.abs(d);u=Math.max(e,t),g=m}else u=Math.sqrt(f*f+d*d),g=m;if(u>=g)return y.scale=1,y.offsetX=0,y.offsetY=0,y.glow=0,y.colorBlend=0,y.proximity=0,y;const M=function(e){return e*e*(3-2*e)}(1-u/g)*r;let p=1,v=0,w=0,x=0,b=0;switch(c){case"spotlight":{p=1+M*a*1.8;const e=Math.atan2(d,f),t=M*M*a*.6;v=Math.cos(e)*t*i,w=Math.sin(e)*t*s,x=M*a*.4,b=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 e=Math.atan2(d,f),t=M*M*a*1.2;v=Math.cos(e)*t*i,w=Math.sin(e)*t*s;break}case"glow":x=M*a*.8,b=M*a*.4;break;case"colorShift":p=1+M*a*.4,x=M*a*.2,b=M*a*.7;break;case"attract":{const e=Math.atan2(d,f),t=M*M*a*1;v=-Math.cos(e)*t*i,w=-Math.sin(e)*t*s,x=M*a*.3;break}case"shatter":{const e=Math.atan2(d,f),t=.5*Math.sin(43.7*f+29.3*d),o=M*a*1.4*(.7+.3*t);v=Math.cos(e+t)*o*i,w=Math.sin(e+t)*o*s,p=Math.max(.1,1-M*a*.6),x=M*a*.25;break}case"trail":b=M*a*.9,x=M*a*.6,p=1+M*a*.15;break;case"glitchText":p=1,x=M*a*.5,b=M*a*.6}return y.scale=p,y.offsetX=v,y.offsetY=w,y.glow=x,y.colorBlend=b,y.proximity=M,y}function $(e){const t=e.match(/^#([0-9a-f]{3,8})$/i)?.[1];if(t){const e=t.length<=4?t.split("").map(e=>parseInt(e+e,16)):[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)];return{r:e[0],g:e[1],b:e[2]}}const o=e.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i);return o?{r:+o[1],g:+o[2],b:+o[3]}:null}function E(e){return e*e*e*(e*(6*e-15)+10)}function C(e,t,o){return e+(t-e)*o}function T(e,t){let o=127*e+311*t;return o^=o>>13,(o*(o*o*15731+789221)+1376312589&2147483647)/2147483647}function A(e,t){const o=Math.floor(e),n=Math.floor(t),r=t-n,a=E(e-o),i=E(r),s=T(o,n),c=T(o+1,n),l=T(o,n+1),h=T(o+1,n+1);return C(C(s,c,a),C(l,h,a),i)}function I(e,t){return(.5*A(e,t)+.25*A(2.1*e,2.1*t)+.125*A(4.3*e,4.3*t))/.875}function R(e,t,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=13,charAspect:s=.62,lineHeightRatio:c=1.4,chars:l=" .:-=+*#%@",baseColor:h=null,accentColor:f,accentThreshold:d=.52,mouseInfluence:m=.55,mouseFalloff:u=2.8,speed:g=1,vortex:M=!0,sparkles:p=!0,breathe:v=!0,lightMode:w=!1}=a,x=f??(w?"#6b8700":"#d4ff00"),b=i*s,y=i*c,S=Math.ceil(t/b),$=Math.ceil(o/y),E=r.x,C=r.y;let A=212,R=255,F=0;{const e=x.replace("#","");6===e.length&&(A=parseInt(e.slice(0,2),16),R=parseInt(e.slice(2,4),16),F=parseInt(e.slice(4,6),16))}e.clearRect(0,0,t,o),e.font=`${i}px "JetBrains Mono", monospace`,e.textBaseline="top";const k=n*g,L=v?.12*(.5*Math.sin(.22*k)+.5):0;for(let t=0;t<$;t++)for(let o=0;o<S;o++){const n=o/S,r=t/$,a=.045,i=.08*k,s=.06,c=.45*((.5*Math.sin(.08*o+.05*t+.6*k)+.5+(.5*Math.sin(.03*o-.07*t+.4*k)+.5)+(.5*Math.sin(.05*o+.03*t+.8*k)+.5))/3)+.35*(.5*I(o*a+i,t*a*1.4-.7*i)+.5)+.2*(.5*Math.sin((o+.65*t)*s+1.1*k)+.5)+L,f=n-E,g=r-C,v=Math.sqrt(f*f+g*g);let x=0;if(M&&v<.35){const e=Math.atan2(g,f),t=Math.sin(4*e+2.2*k-14*v),o=Math.max(0,1-v/.35);x=t*o*o*.22}const B=c*(1-m)+(Math.max(0,1-v*u)+.5*x)*m+.15*x,z=Math.min(1,Math.max(0,B));let q=z;if(p&&z>.72){const e=Math.floor(8*k),n=T(7*o+3*e,11*t+e);n>.88&&(q=Math.min(1,z+4*(n-.88)))}const P=Math.floor(q*(l.length-1));if(" "===l[P])continue;const H=.015+.07*q;if(q>d){const t=Math.min(w?.9:.28,H*(w?14:2.8));e.fillStyle=`rgba(${A},${R},${F},${t})`}else e.fillStyle=h?h.replace("{a}",String(H)):w?`rgba(55,55,55,${7*H})`:`rgba(255,255,255,${H})`;e.fillText(l[P],o*b,t*y)}}var F=new WeakMap,k=new WeakMap,L=null,B=null;function z(e,t){if(!L||!B){const o=i(e,t);L=o.canvas,B=o.ctx}return L.width!==e&&(L.width=e),L.height!==t&&(L.height=t),B}var q=new Map,P=new Map,H=new Map,W=new WeakMap,D=new WeakMap;function U(e){let t=q.get(e);return t||(t=[...e],q.set(e,t)),t}function j(e,t,o){const n=o?1-e/255:e/255,r=Math.floor(n*(t.length-1));return t[Math.max(0,Math.min(t.length-1,r))]??" "}function O(e,t,o,n){const r=`${e}\0${t?1:0}\0${o}\0${n}`;let a=P.get(r);if(!a){const i=U(e);a=new Array(256);for(let e=0;e<256;e++)a[e]=j(s(e,o,n),i,t);P.set(r,a)}return a}function V(e){let t=H.get(e);if(!t){const o=U(e),n=Math.max(1,o.length);t=new Map;for(let e=0;e<o.length;e++)t.has(o[e])||t.set(o[e],Math.max(.08,(e+.5)/n));H.set(e,t)}return t}function _(e,t){return"auto"!==e?e:!w(t)}function Y(e){const t=e.match(/^#([0-9a-fA-F]{3,6})$/);if(t){let e=t[1];if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return e}const o=e.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);return o?[o[1],o[2],o[3]].map(e=>parseInt(e).toString(16).padStart(2,"0")).join(""):null}function N(e){const t=e||"auto";if("auto"!==t)return t.replace("#","");if("undefined"!=typeof document){const e=getComputedStyle(document.documentElement);for(const t of["--accent-color","--color-accent","--accent","--color-primary","--primary","--brand-color"]){const o=Y(e.getPropertyValue(t).trim());if(o)return o}const t=Y(getComputedStyle(document.body).accentColor??"");if(t)return t}return w("undefined"!=typeof document?document.body:null)?"faf9f7":"0d0d0d"}function G(e,t,o,n){const r=e instanceof HTMLVideoElement?e.videoWidth:e.width,a=e instanceof HTMLVideoElement?e.videoHeight:e.height;if(0===r||0===a)return{frame:[],cols:0,rows:0};const i=t.charAspect,c=t.fontSize*t.charSpacing,h=t.fontSize/i*t.charSpacing,d=o||r,m=n||a,u=Math.floor(d/c),g=Math.floor(m/h);if(u<=0||g<=0)return{frame:[],cols:0,rows:0};const M=Math.max(1,Math.min(Math.floor(2048/u),Math.floor(r/u))),p=Math.max(1,Math.min(Math.floor(2048/g),Math.floor(a/g))),v=u*M,w=g*p,b=z(v,w);b.drawImage(e,0,0,v,w);const y=b.getImageData(0,0,v,w).data,S=t.chromaKey,$=null!=S&&!1!==S,E=!0===S,C="blue-screen"===S;let T=null,A=0;!$||E||C||(T=x(S),A=(t.chromaKeyTolerance??60)**2);let I=0,R=255;if(t.normalize){let e=255,t=0;for(let o=0;o<y.length;o+=4){if($){const e=y[o],t=y[o+1],n=y[o+2];let r=!1;if(E)r=t>1.4*e&&t>1.4*n&&t>80;else if(C)r=n>1.4*e&&n>1.4*t&&n>80;else if(null!==T){const o=e-T.r,a=t-T.g,i=n-T.b;r=o*o+a*a+i*i<=A}if(r)continue}const n=.299*y[o]+.587*y[o+1]+.114*y[o+2];n<e&&(e=n),n>t&&(t=n)}I=e,R=t>e?t-e:255}const F=[],k=_(t.invert),L=$&&t.charset.replace(/ /g,"")||t.charset,B=U(L),q=t.customText?null:O(L,k,t.brightness,t.contrast),P=M*p;for(let e=0;e<g;e++){const o=[];for(let n=0;n<u;n++){let r=0,a=0,i=0,c=0,h=0;for(let t=0;t<p;t++){const o=(e*p+t)*v;for(let e=0;e<M;e++){const t=4*(o+n*M+e),s=y[t],l=y[t+1],f=y[t+2],d=y[t+3];if($){let e=!1;if(E)e=l>1.4*s&&l>1.4*f&&l>80;else if(C)e=f>1.4*s&&f>1.4*l&&f>80;else if(null!==T){const t=s-T.r,o=l-T.g,n=f-T.b;e=t*t+o*o+n*n<=A}if(e){h++;continue}}r+=s,a+=l,i+=f,c+=d}}if($&&h>P/2){o.push({char:" ",r:0,g:0,b:0,a:0});continue}const d=P-h,m=d>0?r/d:0,g=d>0?a/d:0,w=d>0?i/d:0,x=d>0?c/d:0,b=.299*m+.587*g+.114*w,S=t.normalize?(b-I)/R*255:b,F=s(S,t.brightness,t.contrast),L=t.ditherStrength>0?f(F,n,e,t.ditherStrength):F,z=t.customText?l(L,t.customText,n,e,u,k):t.ditherStrength>0?j(L,B,k):q[Math.max(0,Math.min(255,0|S))];o.push({char:z,r:m,g:g,b:w,a:x,lum:L})}F.push(o)}return{frame:F,cols:u,rows:g}}function X(e,t,o,n){const r=e instanceof HTMLVideoElement?e.videoWidth:e.width,a=e instanceof HTMLVideoElement?e.videoHeight:e.height;if(0===r||0===a)return{rows:[],cols:0,rowCount:0};const i=t.charAspect,c=t.fontSize*t.charSpacing,l=t.fontSize/i*t.charSpacing,h=o||r,d=n||a,m=Math.floor(h/c),u=Math.floor(d/l);if(m<=0||u<=0)return{rows:[],cols:0,rowCount:0};const g=m,M=u,p=z(g,M);p.drawImage(e,0,0,g,M);const v=p.getImageData(0,0,g,M).data,w=t.chromaKey,b=null!=w&&!1!==w,y=!0===w,S="blue-screen"===w;let $=null,E=0;!b||y||S||($=x(w),E=(t.chromaKeyTolerance??60)**2);let C=0,T=255;if(t.normalize){let e=255,t=0;for(let o=0;o<v.length;o+=4){if(b){const e=v[o],t=v[o+1],n=v[o+2];let r=!1;if(y)r=t>1.4*e&&t>1.4*n&&t>80;else if(S)r=n>1.4*e&&n>1.4*t&&n>80;else if(null!==$){const o=e-$.r,a=t-$.g,i=n-$.b;r=o*o+a*a+i*i<=E}if(r)continue}const n=.299*v[o]+.587*v[o+1]+.114*v[o+2];n<e&&(e=n),n>t&&(t=n)}C=e,T=t>e?t-e:255}const A=_(t.invert),I=b&&t.charset.replace(/ /g,"")||t.charset,R=U(I),F=t.customText?null:O(I,A,t.brightness,t.contrast),k=t.customText?U(t.customText):null,L="fullcolor"===t.colorMode?new Uint8ClampedArray(m*u*4):void 0,B=[];for(let e=0;e<u;e++){let o="";for(let n=0;n<m;n++){const r=4*(e*g+n),a=r,i=v[r],c=v[r+1],l=v[r+2],h=v[r+3];if(b){let e=!1;if(y)e=c>1.4*i&&c>1.4*l&&c>80;else if(S)e=l>1.4*i&&l>1.4*c&&l>80;else if(null!==$){const t=i-$.r,o=c-$.g,n=l-$.b;e=t*t+o*o+n*n<=E}if(e){o+=" ",L&&(L[a]=0,L[a+1]=0,L[a+2]=0,L[a+3]=0);continue}}L&&(L[a]=i,L[a+1]=c,L[a+2]=l,L[a+3]=h);const d=.299*i+.587*c+.114*l,u=t.normalize?(d-C)/T*255:d,M=t.ditherStrength>0||k?s(u,t.brightness,t.contrast):u,p=t.ditherStrength>0?f(M,n,e,t.ditherStrength):M;if(k){o+=(A?1-p/255:p/255)<.12?" ":k[(e*m+n)%k.length]}else t.ditherStrength<=0?o+=F[Math.max(0,Math.min(255,0|u))]:o+=j(p,R,A)}B.push(o)}return{rows:B,cols:m,rowCount:u,colors:L}}function J(e,t,o,n,r){if(0===t.rows.length)return;e.clearRect(0,0,n,r);const a=e.canvas;o.chromaKey||t.rows.some(e=>e.includes(" "))||(e.fillStyle=w(a)?"#0a0a0a":"#faf9f7",e.fillRect(0,0,n,r));const s=N(o.accentColor),c=parseInt(s.substring(0,2),16)||255,l=parseInt(s.substring(2,4),16)||255,h=parseInt(s.substring(4,6),16)||255,f=n/t.cols,d=r/t.rowCount,m=.9*Math.min(f/.55,d),u=t.colors;if("fullcolor"===o.colorMode&&u){if(m<6){const{canvas:a,ctx:s}=function(e,t,o){let n=W.get(e);n||(n=i(t,o).canvas,W.set(e,n)),n.width!==t&&(n.width=t),n.height!==o&&(n.height=o);const r=n.getContext("2d",{willReadFrequently:!1});if(!r)throw new Error("renderTextFrameToCanvas: could not create raster context.");return{canvas:n,ctx:r}}(e,t.cols,t.rowCount);let c=D.get(s);c&&c.width===t.cols&&c.height===t.rowCount||(c={width:t.cols,height:t.rowCount,imageData:s.createImageData(t.cols,t.rowCount)},D.set(s,c));const l=c.imageData,h=l.data;h.fill(0);const f=V(o.charset);for(let e=0;e<t.rowCount;e++){const o=t.rows[e];for(let n=0;n<t.cols;n++){const r=o[n];if(" "===r)continue;const a=4*(e*t.cols+n),i=u[a+3];if(i<10)continue;const s=f.get(r)??.5;h[a]=u[a],h[a+1]=u[a+1],h[a+2]=u[a+2],h[a+3]=0|Math.min(255,i*s)}}return s.putImageData(l,0,0),e.imageSmoothingEnabled=!1,e.drawImage(a,0,0,n,r),e.imageSmoothingEnabled=!0,void(e.globalAlpha=1)}e.font=`${m}px "JetBrains Mono", monospace`,e.textAlign="left",e.textBaseline="middle",e.globalAlpha=1;let a="";for(let o=0;o<t.rows.length;o++){const n=t.rows[o];let r=0;for(;r<t.cols;){for(;r<t.cols&&" "===n[r];)r++;if(r>=t.cols)break;const i=r,s=4*(o*t.cols+r),c=240&u[s],l=240&u[s+1],h=240&u[s+2];for(r++;r<t.cols&&" "!==n[r];){const e=4*(o*t.cols+r);if((240&u[e])!==c||(240&u[e+1])!==l||(240&u[e+2])!==h)break;r++}const m=`rgb(${c},${l},${h})`;m!==a&&(e.fillStyle=m,a=m),e.fillText(n.slice(i,r),i*f+.5*f,o*d+.5*d)}}return void(e.globalAlpha=1)}e.font=`${m}px "JetBrains Mono", monospace`,e.textAlign="left",e.textBaseline="middle",e.fillStyle="matrix"===o.colorMode?"rgb(0,255,0)":"grayscale"===o.colorMode?w(a)?"rgb(230,230,230)":"rgb(24,24,24)":`rgb(${c},${l},${h})`,e.globalAlpha=1;for(let o=0;o<t.rows.length;o++){const n=t.rows[o];0!==n.trim().length&&e.fillText(n,.5*f,o*d+.5*d)}e.globalAlpha=1}async function K(e,t,o,n,r=12,a=10,i,s=0){const c=Math.min(e.duration-s,a),l=Math.ceil(c*r),h=[];let f=0,d=0;for(let a=0;a<l;a++){const m=s+a/r;if(m>s+c)break;e.currentTime=m,await new Promise(t=>{const o=()=>{e.removeEventListener("seeked",o),t()};e.addEventListener("seeked",o)});const u=G(e,t,o,n);h.push(u.frame),f=u.cols,d=u.rows,i?.((a+1)/l)}return{frames:h,cols:f,rows:d,fps:r}}async function Q(e,t,o,n,r=12,a=10,i,s=0){const c=Math.min(e.duration-s,a),l=Math.ceil(c*r),h=[];let f=0,d=0;for(let a=0;a<l;a++){const m=s+a/r;if(m>s+c)break;e.currentTime=m,await new Promise(t=>{const o=()=>{e.removeEventListener("seeked",o),t()};e.addEventListener("seeked",o)});const u=X(e,t,o,n);h.push(u),f=u.cols,d=u.rowCount,i?.((a+1)/l)}return{frames:h,cols:f,rows:d,fps:r}}async function Z(t,o,n,r,a){const i=e.parseGIF(t),s=e.decompressFrames(i,!0);if(0===s.length)return{frames:[],cols:0,rows:0,fps:10};const c=s[0].dims.width,l=s[0].dims.height,h=i.lsd?.width||c,f=i.lsd?.height||l,d=document.createElement("canvas");d.width=h,d.height=f;const m=d.getContext("2d"),u=document.createElement("canvas");u.width=h,u.height=f;const g=u.getContext("2d"),M=document.createElement("canvas"),p=M.getContext("2d"),v=[];let w=0,x=0,b=0;for(const e of s)b+=e.delay||100;const y=b/s.length,S=Math.round(Math.min(30,Math.max(5,1e3/y))),$=Math.min(s.length,300);for(let e=0;e<$;e++){const t=s[e],{dims:i,patch:c,disposalType:l}=t;3===l&&(g.clearRect(0,0,h,f),g.drawImage(d,0,0)),M.width!==i.width&&(M.width=i.width),M.height!==i.height&&(M.height=i.height);const b=new ImageData(new Uint8ClampedArray(c.buffer),i.width,i.height);p.putImageData(b,0,0),m.drawImage(M,i.left||0,i.top||0);const y=G(d,o,n,r);v.push(y.frame),w=y.cols,x=y.rows,2===l?m.clearRect(i.left||0,i.top||0,i.width,i.height):3===l&&(m.clearRect(0,0,h,f),m.drawImage(u,0,0)),a?.((e+1)/$)}return{frames:v,cols:w,rows:x,fps:S}}async function ee(t,o,n,r,a){const i=e.parseGIF(t),s=e.decompressFrames(i,!0);if(0===s.length)return{frames:[],cols:0,rows:0,fps:10};const c=s[0].dims.width,l=s[0].dims.height,h=i.lsd?.width||c,f=i.lsd?.height||l,d=document.createElement("canvas");d.width=h,d.height=f;const m=d.getContext("2d"),u=document.createElement("canvas");u.width=h,u.height=f;const g=u.getContext("2d"),M=document.createElement("canvas"),p=M.getContext("2d"),v=[];let w=0,x=0,b=0;for(const e of s)b+=e.delay||100;const y=b/s.length,S=Math.round(Math.min(30,Math.max(5,1e3/y))),$=Math.min(s.length,300);for(let e=0;e<$;e++){const t=s[e],{dims:i,patch:c,disposalType:l}=t;3===l&&(g.clearRect(0,0,h,f),g.drawImage(d,0,0)),M.width!==i.width&&(M.width=i.width),M.height!==i.height&&(M.height=i.height);const b=new ImageData(new Uint8ClampedArray(c.buffer),i.width,i.height);p.putImageData(b,0,0),m.drawImage(M,i.left||0,i.top||0);const y=X(d,o,n,r);v.push(y),w=y.cols,x=y.rowCount,2===l?m.clearRect(i.left||0,i.top||0,i.width,i.height):3===l&&(m.clearRect(0,0,h,f),m.drawImage(u,0,0)),a?.((e+1)/$)}return{frames:v,cols:w,rows:x,fps:S}}function te(e,t,o,n,r,a=0,s){if("waveField"===o.animationStyle){return void R(e,n,r,a,s?{x:s.x,y:s.y}:{x:.5,y:.5},{accentColor:`#${o.accentColor?N(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 l=t.length;if(0===l)return;const h=t[0].length;e.clearRect(0,0,n,r);let f=!1;const d=Math.max(1,l>>2),m=Math.max(1,h>>2);e:for(let e=0;e<l;e+=d){const o=t[e];for(let e=0;e<h;e+=m)if(o[e].a<200){f=!0;break e}}const g=e.canvas,p=w(g);f||(e.fillStyle=p?"#0a0a0a":"#faf9f7",e.fillRect(0,0,n,r));const v=n/h,x=r/l,y=l*h,$=s?.intensity??1,E=!("none"!==o.animationStyle&&y>5e3)&&!!(s&&o.hoverStrength>0&&$>.005),C=o.hoverColor||"#ffffff",T=parseInt(C.slice(1,3),16)||255,A=parseInt(C.slice(3,5),16)||255,I=parseInt(C.slice(5,7),16)||255,L=N(o.accentColor),B=parseInt(L.substring(0,2),16)||255,z=parseInt(L.substring(2,4),16)||255,q=parseInt(L.substring(4,6),16)||255,P=y>3e4?.25:y>15e3?.4:y>5e3?.6:1,H=o.hoverRadius*P;let W=0,D=h,U=0,j=l,O=0,Y=0;if(E&&s){O=s.x,Y=s.y;const e=.08+.35*H+.04*o.hoverStrength;W=Math.max(0,Math.floor((O-e)*h)-1),D=Math.min(h,Math.ceil((O+e)*h)+1),U=Math.max(0,Math.floor((Y-e)*l)-1),j=Math.min(l,Math.ceil((Y+e)*l)+1)}const G=o.animationStyle,X=o.animationSpeed,J="none"===G,K=o.hoverStrength,Q=o.hoverEffect,Z=H,ee=o.hoverShape||"circle",te=_(o.invert,g),oe=o.colorMode,ne=2*Math.PI,re=1/h,ae=1/l;let ie="",se=-1;if("dots"===o.renderMode){const n=.5*Math.min(v,x)*o.dotSizeRatio;for(let o=0;o<l;o++){const r=t[o];for(let t=0;t<h;t++){const i=r[t];if(i.a<10)continue;const s=.00392156863*(.299*i.r+.587*i.g+.114*i.b),c=te?1-s:s;if(c<.02)continue;const f=J?1:b(t,o,h,l,a,G,X);let d=1,m=0,g=0,p=0,w=0;if(E&&t>=W&&t<=D&&o>=U&&o<=j){const e=S(t*re,o*ae,O,Y,$,K,v,x,Q,Z,ee);d=e.scale,m=e.offsetX,g=e.offsetY,p=e.glow,w=e.colorBlend}const y=n*c*f*d;if(y<.3)continue;const C=t*v+.5*v+m,R=o*x+.5*x+g;let F;if(w>0){const e=M(i,oe,B,z,q,te);F=`rgb(${Math.min(255,e[0]+(T-e[0])*w|0)},${Math.min(255,e[1]+(A-e[1])*w|0)},${Math.min(255,e[2]+(I-e[2])*w|0)})`}else F=u(i,oe,B,z,q,te);const k=Math.min(1,.00392156863*i.a*f*(1+p));if(k!==se&&(e.globalAlpha=k,se=k),F!==ie&&(e.fillStyle=F,ie=F),y<=3){const t=2*y;e.fillRect(C-y,R-y,t,t)}else e.beginPath(),e.arc(C,R,y,0,ne),e.fill()}}}else{const s=.55,f=.9*Math.min(v/s,x),d=f<6;if(!d){const t="emoji"===o.artStyle;e.font=t?`${f}px "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif`:`${f}px "JetBrains Mono", monospace`,e.textAlign="center",e.textBaseline="middle"}const m=o.charsetFrames,g=!!m?.length,p=g?m[Math.floor(Math.max(0,a)*(o.charsetFps??2))%m.length]:o.charset;if(d){const{canvas:o,ctx:a}=function(e,t,o){let n=F.get(e);n||(n=i(t,o).canvas,F.set(e,n)),n.width!==t&&(n.width=t),n.height!==o&&(n.height=o);const r=n.getContext("2d",{willReadFrequently:!1});if(!r)throw new Error("renderFrameToCanvas: could not create raster context.");return{canvas:n,ctx:r}}(e,h,l);let s=k.get(a);s&&s.width===h&&s.height===l||(s={width:h,height:l,imageData:a.createImageData(h,l)},k.set(a,s));const f=s.imageData,d=f.data;d.fill(0);const m=V(p);for(let e=0;e<l;e++){const o=t[e];for(let t=0;t<h;t++){const n=o[t],r=4*(e*h+t);if(n.a<10)continue;const a=g&&null!=n.lum?c(n.lum,p,te):n.char;if(" "===a)continue;let i,s,l,f=m.get(a)??.5,u=0,w=0;if(E&&t>=W&&t<=D&&e>=U&&e<=j){const o=S(t*re,e*ae,O,Y,$,K,v,x,Q,Z,ee);f*=o.scale,u=o.glow,w=o.colorBlend}if(w>0){const e=M(n,oe,B,z,q,te);i=Math.min(255,e[0]+(T-e[0])*w|0),s=Math.min(255,e[1]+(A-e[1])*w|0),l=Math.min(255,e[2]+(I-e[2])*w|0)}else{const e=M(n,oe,B,z,q,te);i=e[0],s=e[1],l=e[2]}const b=Math.min(255,Math.max(0,n.a*f*(1+u)));d[r]=i,d[r+1]=s,d[r+2]=l,d[r+3]=b}}return a.putImageData(f,0,0),e.imageSmoothingEnabled=!1,e.drawImage(o,0,0,n,r),e.imageSmoothingEnabled=!0,void(e.globalAlpha=1)}const w=d?null:e.getTransform();if(!d&&!E&&J&&!g&&"accent"===oe){e.fillStyle=`rgb(${B},${z},${q})`,e.globalAlpha=1,e.textAlign="left";for(let o=0;o<l;o++){const n=t[o];let r="";for(let e=0;e<h;e++){const t=n[e];r+=t.a<10?" ":t.char}0!==r.trim().length&&e.fillText(r,.5*v,o*x+.5*x)}return void(e.globalAlpha=1)}const y="glitchText"===Q&&E,C="!@#$%^&*<>{}[]|/\\~`0123456789",R=C.length;let L="",P=0,_=0,N=0,ne=0,ce=0,le=0;if(y){const e=o.hoverText??"ASCIIFY";if(_=Math.round(O*h),N=Math.round(Y*l),Array.isArray(e)){const t=e.filter(e=>e.length>0);0===t.length&&t.push("ASCIIFY");L=t[((7*Math.floor(_/Math.max(1,Math.ceil(h/5)))+13*Math.floor(N/Math.max(1,Math.ceil(l/3))))%t.length+t.length)%t.length]}else L=e||"ASCIIFY";P=L.length,ne=Math.max(3,Math.min(12,Math.round(l*H*.6)));const t=Math.floor(ne/2);ce=Math.max(0,N-t),ce+ne>l&&(ce=Math.max(0,l-ne)),le=_-Math.floor(P/2)}for(let o=0;o<l;o++){const n=t[o];for(let t=0;t<h;t++){const r=n[t];if(r.a<10)continue;let i=g&&null!=r.lum?c(r.lum,p,te):r.char;if(" "===i)continue;const s=J?1:b(t,o,h,l,a,G,X);if(s<.05)continue;let f=1,d=0,m=0,F=0,k=0;if(E&&!y&&t>=W&&t<=D&&o>=U&&o<=j){const e=S(t*re,o*ae,O,Y,$,K,v,x,Q,Z,ee);f=e.scale,d=e.offsetX,m=e.offsetY,F=e.glow,k=e.colorBlend}if(y&&o>=ce&&o<ce+ne){const e=t-le;if(e>=0&&e<P){const n=L[e],r=Math.abs(o-N)/Math.max(1,.5*ne),s=Math.abs(t-_)/Math.max(1,P),c=Math.max(r,s),l=Math.max(0,Math.min(1,1-.9*c)),h=43758.5453*Math.sin(127.1*t+311.7*o+43758.5453*Math.floor(12*a));i=Math.abs(h-Math.floor(h))<l?n:C[Math.abs(Math.floor(97*h))%R],F=.3+.7*l,k=.3+.65*l}}const H=t*v+.5*v+d,V=o*x+.5*x+m;let he;if(k>0){const e=M(r,oe,B,z,q,te);he=`rgb(${Math.min(255,e[0]+(T-e[0])*k|0)},${Math.min(255,e[1]+(A-e[1])*k|0)},${Math.min(255,e[2]+(I-e[2])*k|0)})`}else he=u(r,oe,B,z,q,te);const fe=Math.min(1,.00392156863*r.a*s*(1+F));fe!==se&&(e.globalAlpha=fe,se=fe),he!==ie&&(e.fillStyle=he,ie=he),1!==f?(e.translate(H,V),e.scale(f,f),e.fillText(i,0,0),e.setTransform(w)):e.fillText(i,H,V)}}}e.globalAlpha=1}function oe(e){return Math.max(0,Math.min(1,e))}function ne(e){return"string"==typeof e?document.querySelector(e):e instanceof HTMLElement?e:null}function re(e){return"ascii"===e.renderMode&&"none"===e.animationStyle&&e.hoverStrength<=0&&!e.charsetFrames?.length}function ae(e,t,o={}){if(!Number.isFinite(e.duration)||e.duration<=0)return;const n=o.from??0,r=o.to??e.duration,a=Math.max(n,Math.min(r,e.duration)),i=oe(o.ease?o.ease(oe(t)):t),s=n+(a-n)*i;e.currentTime=Math.min(Math.max(n,s),Math.max(n,a-.04)),o.onUpdate?.(i,e)}function ie(e){const t=e.requestVideoFrameCallback;return new Promise(t?o=>{let n=!1;const r=()=>{n||(n=!0,o())};t.call(e,r),window.setTimeout(r,80)}:e=>requestAnimationFrame(()=>e()))}function se(e,t={}){const o=ne(t.trigger)??e;e.pause();const n=t.gsap,r=t.ScrollTrigger??n?.ScrollTrigger;if(n&&r?.create){n.registerPlugin?.(r);const a=r.create({trigger:o,start:t.start??"top bottom",end:t.end??"bottom top",scrub:t.scrub??!0,onUpdate:o=>ae(e,o.progress,t)});return()=>a.kill?.()}return function(e,t,o){let n=0;const r=()=>{n=0;const r=t.getBoundingClientRect(),a=window.innerHeight||document.documentElement.clientHeight,i=r.height+a,s=i>0?oe((a-r.top)/i):0;ae(e,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)}}(e,o,t)}function ce(e,t,o){const n=t.gsap,r=t.ScrollTrigger??n?.ScrollTrigger;if(n&&r?.create){n.registerPlugin?.(r);const a=r.create({trigger:e,start:t.start??"top bottom",end:t.end??"bottom top",scrub:t.scrub??!0,onUpdate:e=>o(e.progress)});return()=>a.kill?.()}return function(e,t){let o=0;const n=()=>{o=0;const n=e.getBoundingClientRect(),r=window.innerHeight||document.documentElement.clientHeight,a=n.height+r,i=a>0?oe((r-n.top)/a):0;t(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)}}(e,o)}function le(e,t,o=2048){const n=o,r=Math.min(1,n/Math.max(e,t));return{renderW:Math.round(e*r),renderH:Math.round(t*r)}}function he(e,t,o,n,r,a=2048){const{width:i,height:s}=t.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}=le(n,r,a)):(c=h,l=f);const d="undefined"!=typeof window&&window.devicePixelRatio||1,m=8e6,u=c*d*l*d>m?Math.sqrt(m/(c*l)):d;return e.width=Math.round(c*u),e.height=Math.round(l*u),e.style.width=h+"px",e.style.height=f+"px",{renderW:c,renderH:l,dpr:u}}async function fe(e,t,{fontSize:o,artStyle:r="classic",options:i={},fitTo:s,preExtract:c=!1,fps:l,maxRenderDimension:h=2048,trim:f,scroll:d,onReady:m,onFrame:u}={}){const g=f?.start??0,M=f?.end,p=o??i.fontSize??10,v={...a,...n[r],...i,fontSize:p},w=t.getContext("2d");if(!w)throw new Error("asciifyVideo: could not get 2d context from canvas.");const x="string"==typeof s?document.querySelector(s):s instanceof HTMLElement?s:null;if(c){let o;"string"==typeof e?(o=document.createElement("video"),o.crossOrigin="anonymous",o.src=e,o.readyState<2&&await new Promise((t,n)=>{o.onloadeddata=()=>t(),o.onerror=()=>n(new Error(`asciifyVideo: failed to load "${e}"`))})):o=e,x&&he(t,x,o.videoWidth/o.videoHeight,o.videoWidth,o.videoHeight,h);const{renderW:n,renderH:r}=le(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;t.width<Math.round(n*s)&&(t.width=Math.round(n*s),t.height=Math.round(r*s));const c=void 0!==M?M-g:10,f=l??(d?18:void 0);if(re(v)){const{frames:e,fps:a}=await Q(o,v,n,r,f,c,void 0,g),i=t=>{const o=e[t];o&&(w.save(),w.setTransform(s,0,0,s,0,0),J(w,o,v,n,r),w.restore(),u?.())};if(d){let n=!1,r=-1;const a=!0===d?{}:d,s=ce(ne(a.trigger)??x??t,a,t=>{const s=oe(a.ease?a.ease(oe(t)):t),c=Math.max(0,Math.min(e.length-1,Math.round(s*(e.length-1))));c!==r&&(r=c,i(c),n||(n=!0,m?.(o)),a.onUpdate?.(s,o))});return i(0),n=!0,m?.(o),s}let l,h=!1,M=0,p=performance.now(),b=!0;const y=1e3/a,S=t=>{h||(t-p>=y&&(i(M),M=(M+1)%e.length,p=t,b&&(b=!1,m?.(o))),l=requestAnimationFrame(S))};return l=requestAnimationFrame(S),()=>{h=!0,cancelAnimationFrame(l)}}const{frames:p,fps:b}=await K(o,v,n,r,f,c,void 0,g),y=e=>{const t=p[e];t&&(w.save(),w.setTransform(s,0,0,s,0,0),te(w,t,v,n,r),w.restore(),u?.())};if(d){let e=!1,n=-1;const r=!0===d?{}:d,a=ce(ne(r.trigger)??x??t,r,t=>{const a=oe(r.ease?r.ease(oe(t)):t),i=Math.max(0,Math.min(p.length-1,Math.round(a*(p.length-1))));i!==n&&(n=i,y(i),e||(e=!0,m?.(o)),r.onUpdate?.(a,o))});return y(0),e=!0,m?.(o),a}let S,$=!1,E=0,C=performance.now(),T=!0;const A=1e3/b,I=e=>{$||(e-C>=A&&(y(E),E=(E+1)%p.length,C=e,T&&(T=!1,m?.(o))),S=requestAnimationFrame(I))};return S=requestAnimationFrame(I),()=>{$=!0,cancelAnimationFrame(S)}}let b,y=!1;"string"==typeof e?(b=document.createElement("video"),b.src=e,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),y=!0,await new Promise((t,o)=>{b.onloadedmetadata=()=>t(),b.onerror=()=>o(new Error(`asciifyVideo: failed to load "${e}"`))}),await b.play().catch(()=>{})):(b=e,b.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((e,t)=>{const o=()=>{b.removeEventListener("loadedmetadata",n),b.removeEventListener("error",r)},n=()=>{o(),e()},r=()=>{o(),t(new Error("asciifyVideo: provided video element failed to load metadata."))};b.addEventListener("loadedmetadata",n),b.addEventListener("error",r),b.load()}),b.paused&&await b.play().catch(()=>{})),g>0&&(b.currentTime=g,await new Promise(e=>{const t=()=>{b.removeEventListener("seeked",t),e()};b.addEventListener("seeked",t)}),await ie(b));let S=null;(g>0||void 0!==M)&&(S=()=>{(void 0!==M&&b.currentTime>=M||g>0&&b.currentTime<g)&&(b.currentTime=g)},b.addEventListener("timeupdate",S));let $=null;const{renderW:E,renderH:C}=le(b.videoWidth,b.videoHeight,h);if(x){const e=b.videoWidth/b.videoHeight,o=b.videoWidth,n=b.videoHeight,r=he(t,x,e,o,n,h),a=t.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0),$=new ResizeObserver(()=>{const r=he(t,x,e,o,n,h),a=t.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0)}),$.observe(x)}else{const e="undefined"!=typeof window&&window.devicePixelRatio||1,o=8e6,n=E*e*C*e>o?Math.sqrt(o/(E*C)):e;t.width<Math.round(E*n)&&(t.width=Math.round(E*n),t.height=Math.round(C*n)),w.setTransform(n,0,0,n,0,0)}let T,A=!1,I=!0,R=null;const F=d&&!c,k=l&&l>0?1e3/l:0;let L=0,B=-1;const z=!F&&re(v);if(F&&"ascii"===v.renderMode&&"none"===v.animationStyle&&v.hoverStrength<=0&&!v.charsetFrames?.length){const e=!0===d?{}:d,o=ne(e.trigger)??x??t,n=e.from??g,r=e.to??M??b.duration,a=Math.max(n,Math.min(r,b.duration)),i=Math.max(.001,a-n),s=Math.min(60,Math.max(12,l??30)),c=Math.max(2,Math.ceil(i*s)+1),h=new Array(c);let f=0,p=0,T=-1,A=0,I=!1,F=!1,B=!1;const z=new Set,q=document.createElement("video");q.muted=!0,q.playsInline=!0,q.preload="auto",q.crossOrigin=b.crossOrigin||"anonymous",q.src=b.currentSrc||b.src,Object.assign(q.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(q),q.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((e,t)=>{const o=()=>{q.removeEventListener("loadedmetadata",n),q.removeEventListener("error",r)},n=()=>{o(),e()},r=()=>{o(),t(new Error("asciifyVideo: cache video failed to load metadata."))};q.addEventListener("loadedmetadata",n),q.addEventListener("error",r),q.load()}),q.pause(),b.paused&&await b.play().catch(()=>{});const P=e=>n+i*e/Math.max(1,c-1),H=e=>Math.max(0,Math.min(c-1,Math.round(e*(c-1)))),W=X(b,v,E,C);W.rows.length>0&&(h[0]=W,J(w,W,v,E,C),B=!0,m?.(b),u?.());const D=e=>{if(h[e])return e;for(let t=1;t<c;t++){const o=e-t,n=e+t;if(o>=0&&h[o])return o;if(n<c&&h[n])return n}return-1},U=()=>{if(!h[f])return f;for(const e of z)if(!h[e])return e;for(let e=1;e<c;e++){const t=f-e,o=f+e;if(t>=0&&!h[t])return t;if(o<c&&!h[o])return o}return-1},j=e=>{e<0||e>=c||h[e]||(z.add(e),O())},O=async()=>{if(I||F)return;const e=U();if(!(e<0)){z.delete(e),F=!0;try{if(await function(e,t){return Math.abs(e.currentTime-t)<1/240?ie(e):new Promise(o=>{const n=()=>{e.removeEventListener("seeked",n),o()};e.addEventListener("seeked",n,{once:!0}),e.currentTime=t})}(q,P(e)),await ie(q),!I){const t=X(q,v,E,C);t.rows.length>0&&(h[e]=t)}}finally{F=!1,I||requestAnimationFrame(()=>{O()})}}},V=()=>{if(I)return;const e=D(f);if(e>=0&&e!==T){const t=h[e];t&&(J(w,t,v,E,C),T=e,B||(B=!0,m?.(b)),u?.())}else if(e<0||T<0){const e=performance.now();if(k<=0||e-L>=k){const t=X(b,v,E,C);t.rows.length>0&&(J(w,t,v,E,C),L=e,B||(B=!0,m?.(b)),u?.())}}j(f),A=requestAnimationFrame(V)};return R=ce(o,e,t=>{const o=function(e,t,o={}){if(!Number.isFinite(e.duration)||e.duration<=0)return null;const n=o.from??0,r=o.to??e.duration,a=Math.max(n,Math.min(r,e.duration)),i=oe(o.ease?o.ease(oe(t)):t),s=n+(a-n)*i;return{progress:i,time:Math.min(Math.max(n,s),Math.max(n,a-.04))}}(b,t,{...e,from:n,to:a});p=o?.progress??oe(t),f=H(p),j(f),j(f-1),j(f+1),e.onUpdate?.(p,b)}),j(0),j(1),A=requestAnimationFrame(V),()=>{I=!0,cancelAnimationFrame(A),R?.(),$?.disconnect(),q.pause(),q.src="",document.body.removeChild(q),S&&b.removeEventListener("timeupdate",S),y&&(b.pause(),b.src="",document.body.removeChild(b))}}if(F){const e=!0===d?{}:d;R=se(b,{...e,trigger:e.trigger??x??t,from:e.from??g,to:e.to??M})}const q=e=>{if(A)return;if(T=requestAnimationFrame(q),b.readyState<2||0===t.width||0===t.height)return;if(k>0&&e-L<k)return;if(g>0&&b.currentTime<g)return;if(void 0!==M&&b.currentTime>=M)return;if(F&&Math.abs(b.currentTime-B)<1/240)return;if(z){const t=X(b,v,E,C);return void(t.rows.length>0&&(J(w,t,v,E,C),L=e,B=b.currentTime,I&&(I=!1,m?.(b)),u?.()))}const{frame:o}=G(b,v,E,C);o.length>0&&(te(w,o,v,E,C,0,null),L=e,B=b.currentTime,I&&(I=!1,m?.(b)),u?.())};return T=requestAnimationFrame(q),()=>{A=!0,cancelAnimationFrame(T),R?.(),$?.disconnect(),S&&b.removeEventListener("timeupdate",S),y&&(b.pause(),b.src="",document.body.removeChild(b))}}function de(e,t,o,n,r={}){const{fontSize:a=13,chars:i="0123456789ABCDEF@#$&*+=/<>",accentColor:s,color:c,speed:l=1,density:h=.55,tailLength:f=14,lightMode:d=!1}=r,m=s??(d?"#6b8700":"#d4ff00"),u=.62*a,g=1.4*a,M=Math.ceil(t/u),p=Math.ceil(o/g);e.clearRect(0,0,t,o),e.font=`${a}px monospace`,e.textBaseline="top";let v=255,w=255,x=255;if(d&&(v=55,w=55,x=55),c){const e=$(c);e&&(v=e.r,w=e.g,x=e.b)}let b=212,y=255,S=0;const E=$(m);E&&(b=E.r,y=E.g,S=E.b);const C=p+f;for(let t=0;t<M;t++){if(T(17*t,3)>h)continue;const o=(.5+1.5*T(31*t,7))*l,r=T(13*t,11)*C,a=Math.floor((n*o*7+r)%C),s=t*u;for(let o=0;o<=f;o++){const r=a-(f-o);if(r<0||r>=p)continue;const c=r*g,l=T(53*t+Math.floor(5*n+o),7*r),h=i[Math.floor(l*i.length)],m=o/f;if(o===f)e.fillStyle=`rgba(${b},${y},${S},${d?.7:.85})`;else{const t=d?.85*m:.15*m;e.fillStyle=`rgba(${v},${w},${x},${t})`}e.fillText(h,s,c)}}}function me(e,t,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" . · * + ° ★",accentColor:c,color:l,speed:h=1,count:f=180,lightMode:d=!1}=a,m=c??(d?"#6b8700":"#d4ff00");e.clearRect(0,0,t,o),e.textBaseline="middle",e.textAlign="center";const u=t*(.2+.6*r.x),g=o*(.2+.6*r.y),M=.65*Math.sqrt(t*t+o*o);let p=255,v=255,w=255;if(d&&(p=55,v=55,w=55),l){const e=$(l);e&&(p=e.r,v=e.g,w=e.b)}let x=212,b=255,y=0;const S=$(m);S&&(x=S.r,b=S.g,y=S.b);const E=s.replace(/ /g,"").split("");if(0!==E.length){for(let r=0;r<f;r++){const a=T(17*r,3)*Math.PI*2,s=(n*(.15+.85*T(31*r,7))*h*.22+T(13*r,11))%1,c=u+Math.cos(a)*s*M,l=g+Math.sin(a)*s*M;if(c<-20||c>t+20||l<-20||l>o+20)continue;const f=Math.max(6,i*(.4+.9*s));e.font=`${f}px monospace`;const m=E[Math.min(E.length-1,Math.floor(s*E.length))],S=s>.72,$=d?.85*s:.2*s;e.fillStyle=S?`rgba(${x},${b},${y},${Math.min(d?.92:.32,2.2*$)})`:`rgba(${p},${v},${w},${$})`,e.fillText(m,c,l)}e.textAlign="left"}}function ue(e,t,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=". · ○ ◎ ●",accentColor:c,color:l,rings:h=5,speed:f=1,sharpness:d=4,lightMode:m=!1}=a,u=c??(m?"#007a5e":"#00ffcc");e.clearRect(0,0,t,o),e.textBaseline="middle",e.textAlign="center";const g=t*r.x,M=o*r.y,p=1.6*Math.sqrt(g*g+M*M)+.2*Math.sqrt(t*t+o*o);let v=255,w=255,x=255;if(m&&(v=55,w=55,x=55),l){const e=$(l);e&&(v=e.r,w=e.g,x=e.b)}let b=0,y=255,S=204;const E=$(u);E&&(b=E.r,y=E.g,S=E.b);const C=s.replace(/ /g,"").split("");if(0===C.length)return;const T=Math.ceil(t/i),A=Math.ceil(o/i);for(let t=0;t<A;t++)for(let o=0;o<T;o++){const r=o*i+.5*i,a=t*i+.5*i,s=r-g,c=a-M,l=Math.sqrt(s*s+c*c)/p;let u=0;for(let e=0;e<h;e++){const t=(n*f*.38+e/h)%1,o=Math.abs(l-t),r=Math.max(0,1-o*p/(i*(12-d)));u+=Math.cos(r*Math.PI*.5)*r}if(u=Math.min(1,u),u<.02)continue;const $=u>.6;e.font=`${i}px monospace`;const E=Math.floor(u*(C.length-1)),T=C[Math.min(E,C.length-1)],A=m?.88*u:.22*u;e.fillStyle=$?`rgba(${b},${y},${S},${Math.min(m?.95:.4,.55*u)})`:`rgba(${v},${w},${x},${A})`,e.fillText(T,r,a)}e.textAlign="left"}function ge(e,t,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" .·:;=+*#%@░▒▓",accentColor:c,color:l,octaves:h=4,speed:f=1,scale:d=1,accentThreshold:m=.78,mouseWarp:u=.3,lightMode:g=!1}=a,M=c??(g?"#6b8700":"#d4ff00"),p=.62*i,v=1.4*i,w=Math.ceil(t/p),x=Math.ceil(o/v);e.clearRect(0,0,t,o),e.font=`${i}px monospace`,e.textBaseline="top";let b=255,y=255,S=255;if(g&&(b=55,y=55,S=55),l){const e=$(l);e&&(b=e.r,y=e.g,S=e.b)}let E=212,C=255,T=0;const I=$(M);I&&(E=I.r,C=I.g,T=I.b);const R=.035*d,F=n*f,k=Math.min(6,Math.max(1,h)),L=(e,t)=>{let o=0,n=.5,r=1,a=0;for(let i=0;i<k;i++)o+=A(e*r,t*r)*n,a+=n,n*=.5,r*=2.1;return o/a};for(let t=0;t<x;t++)for(let o=0;o<w;o++){const n=o*R+.06*F,a=t*R*1.3-.04*F,i=o/w-r.x,c=t/x-r.y,l=Math.sqrt(i*i+c*c),h=u>0?.12*Math.max(0,1-l/u):0,f=.5*L(n+h*Math.sin(1.3*F+8*c),a+h*Math.cos(.9*F+8*i))+.5;if(f<.12)continue;const d=s[Math.floor(f*(s.length-1))];if(" "===d)continue;const M=f>m,$=g?.82*f:.13*f;e.fillStyle=M?`rgba(${E},${C},${T},${g?.92:.28})`:`rgba(${b},${y},${S},${$})`,e.fillText(d,o*p,t*v)}}function Me(e,t,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=12,chars:s="·-=+|/",accentColor:c,color:l,bands:h=3,speed:f=1,bandWidth:d=.12,glitch:m=!0,lightMode:u=!1}=a,g=c??(u?"#6b8700":"#d4ff00"),M=.62*i,p=1.4*i,v=Math.ceil(t/M),w=Math.ceil(o/p);e.clearRect(0,0,t,o),e.font=`${i}px monospace`,e.textBaseline="top";let x=255,b=255,y=255;if(u&&(x=55,b=55,y=55),l){const e=$(l);e&&(x=e.r,b=e.g,y=e.b)}let S=212,E=255,C=0;const A=$(g);A&&(S=A.r,E=A.g,C=A.b);const I=n*f;for(let t=0;t<w;t++)for(let o=0;o<v;o++){const n=t/w,a=((n*h-.5*I)%1+1)%1,i=Math.max(0,1-a/d),c=.35*(.5*T(3*o,7*t)+.5);let l=0;if(m){const e=o/v-r.x,a=n-r.y,i=Math.sqrt(e*e+a*a);if(i<.18){const e=T(11*o+Math.floor(12*I),5*t);l=Math.max(0,1-i/.18)*(e>.5?e-.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))],$=i>.55,A=u?.82*f:.12*f;e.fillStyle=$?`rgba(${S},${E},${C},${u?.92:.28})`:`rgba(${x},${b},${y},${A})`,e.fillText(g,o*M,t*p)}}function pe(e,t,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" ·∙•:;+=≡≣#@",color:c,accentColor:l,speed:h=1,layers:f=5,softness:d=1.2,mouseRipple:m=.2,lightMode:u=!1}=a,g=l??(u?"#6b8700":"#d4ff00"),M=.62*i,p=1.4*i,v=Math.ceil(t/M),w=Math.ceil(o/p);e.clearRect(0,0,t,o),e.font=`${i}px monospace`,e.textBaseline="top";let x=255,b=255,y=255;if(u&&(x=55,b=55,y=55),c){const e=$(c);e&&(x=e.r,b=e.g,y=e.b)}let S=212,E=255,C=0;const A=$(g);A&&(S=A.r,E=A.g,C=A.b);const I=n*h,R=[];for(let e=0;e<f;e++){const t=T(17*e,31*e+7),o=T(23*e+5,11*e);R.push({fx:.8+2.2*t,fy:1.2+1.8*o,phase:t*Math.PI*4,dt:(.3+.5*T(7*e,13*e+3))*(e%2==0?1:-1),amp:.55+.45*T(29*e,3*e)})}for(let t=0;t<w;t++){const o=t/w;for(let n=0;n<v;n++){const a=n/v,i=a-r.x,c=o-r.y,l=Math.sqrt(i*i+c*c),h=m*Math.exp(-l*l/.06),g=a+i*h,w=o+c*h;let $=0,T=0;for(let e=0;e<f;e++){const{fx:t,fy:o,phase:n,dt:r,amp:a}=R[e];$+=Math.sin(g*t*Math.PI*2+I*r+n)*Math.cos(w*o*Math.PI*2+I*r*.7+1.3*n)*a,T+=a}const A=$/T,F=.5+.5*Math.tanh(A*d*2.2);if(F<.12)continue;const k=(F-.12)/.88,L=s[Math.min(s.length-1,Math.floor(k*s.length))],B=F>.82,z=u?.82*F:.14*F;e.fillStyle=B?`rgba(${S},${E},${C},${u?.92:.32})`:`rgba(${x},${b},${y},${z})`,e.fillText(L,n*M,t*p)}}}function ve(e,t,o,n,r={}){const{fontSize:a=13,color:i,accentColor:s,speed:c=.4,layers:l=4,turbulence:h=.8,lightMode:f=!1}=r,d=s??(f?"#6b8700":"#d4ff00"),m=.62*a,u=1.4*a,g=Math.ceil(t/m),M=Math.ceil(o/u);e.clearRect(0,0,t,o),e.font=`${a}px monospace`,e.textBaseline="top";let p=255,v=255,w=255;if(f&&(p=55,v=55,w=55),i){const e=$(i);e&&(p=e.r,v=e.g,w=e.b)}let x=212,b=255,y=0;const S=$(d);S&&(x=S.r,b=S.g,y=S.b);const E=n*c,C=["─","─","╌","·","╌","─","─","╌","·"];for(let t=0;t<M;t++){const o=t/M;for(let n=0;n<g;n++){const r=n/g;let a=0,i=0;for(let e=0;e<l;e++){const t=T(13*e,7*e+3),n=1.1+2.4*t,s=.9+2*T(29*e,11*e+1),c=t*Math.PI*6,l=(.2+.5*T(41*e,17*e))*(e%2==0?1:-1.3),f=Math.sin(r*n*Math.PI*2+E*l+c),d=Math.cos(o*s*Math.PI*2+E*l*.6+1.7*c),m=Math.sin(r*s*Math.PI*h+o*n*Math.PI*h+E*l*.4);a+=Math.atan2(d+.3*m,f),i+=.5*(f*d+1)}const s=a/l,c=Math.min(1,i/l);if(c<.1)continue;const d=(s+Math.PI)/(2*Math.PI),M=C[Math.floor(d*C.length)%C.length],S=c>.8,$=f?.8*c:.13*c;e.fillStyle=S?`rgba(${x},${b},${y},${f?.9:.26})`:`rgba(${p},${v},${w},${$})`,e.fillText(M,n*m,t*u)}}}function we(e,t,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=13,chars:s=" ·:;=+*#%@",color:c,accentColor:l,speed:h=1,radius:f=.38,swirl:d=3,lightMode:m=!1}=a,u=l??(m?"#6b8700":"#d4ff00"),g=.62*i,M=1.4*i,p=Math.ceil(t/g),v=Math.ceil(o/M),w=t/o;e.clearRect(0,0,t,o),e.font=`${i}px monospace`,e.textBaseline="top";let x=255,b=255,y=255;if(m&&(x=55,b=55,y=55),c){const e=$(c);e&&(x=e.r,b=e.g,y=e.b)}let S=212,E=255,C=0;const A=$(u);A&&(S=A.r,E=A.g,C=A.b);const I=n*h;for(let t=0;t<v;t++){const o=t/v;for(let n=0;n<p;n++){const a=(n/p-r.x)*w,i=o-r.y,c=Math.sqrt(a*a+i*i)/f;if(c>1){const o=T(3*n,7*t)*Math.max(0,1-3*(c-1));if(o<.62)continue;const r=o*(m?.28:.04);e.fillStyle=`rgba(${x},${b},${y},${r})`,e.fillText(s[1],n*g,t*M);continue}const l=Math.max(0,1-Math.abs(c-(.15+.12*Math.sin(1.1*I)))/.07),h=Math.pow(1-c,2.2),d=Math.min(1,h+.6*l);if(d<.06)continue;const u=Math.floor(d*(s.length-1)),v=s[Math.min(s.length-1,u)],$=l>.35||c<.08,A=m?.85*d:.18*d;e.fillStyle=$?`rgba(${S},${E},${C},${m?.95:.38})`:`rgba(${x},${b},${y},${A})`,e.fillText(v,n*g,t*M)}}}function xe(e,t,o,n,r={}){const{fontSize:a=14,chars:i=" ·∙•:-=+*#",color:s,accentColor:c,speed:l=.5,harmonics:h=3,lightMode:f=!1}=r,d=c??(f?"#6b8700":"#d4ff00"),m=.62*a,u=1.4*a,g=Math.ceil(t/m),M=Math.ceil(o/u);e.clearRect(0,0,t,o),e.font=`${a}px monospace`,e.textBaseline="top";let p=255,v=255,w=255;if(f&&(p=55,v=55,w=55),s){const e=$(s);e&&(p=e.r,v=e.g,w=e.b)}let x=212,b=255,y=0;const S=$(d);S&&(x=S.r,b=S.g,y=S.b);const E=n*l,C=Array.from({length:h},(e,t)=>1/(t+1)).reduce((e,t)=>e+t,0);for(let t=0;t<M;t++)for(let o=0;o<g;o++){let n=0;for(let e=0;e<h;e++){const r=.18+1.4*T(o*(e+3)+7,t*(e+5)+11),a=T(o*(e+7),t*(e+9)+3)*Math.PI*2,i=1/(e+1);n+=Math.sin(E*r+a)*i}const r=.5*(n/C+1);if(r<.28)continue;const a=(r-.28)/.72,s=i[Math.min(i.length-1,Math.floor(a*i.length))],c=r>.88,l=f?.82*a:.13*a;e.fillStyle=c?`rgba(${x},${b},${y},${f?.92:.28})`:`rgba(${p},${v},${w},${l})`,e.fillText(s,o*m,t*u)}}function be(e,t,o,n,r={}){const{fontSize:a=13,chars:i=" .,:;i+xX#&@",color:s="#ff4500",hotColor:c="#ffe066",intensity:l=.85,wind:h=0,speed:f=1,lightMode:d=!1}=r,m=.62*a,u=1.4*a,g=Math.ceil(t/m),M=Math.ceil(o/u),p=g*M,v="__fire_heat__",w=e.canvas;let x=w[v];x&&x.length===p||(x=new Float32Array(p),w[v]=x);const b=.18*(.016*f),y=h*f*.8,S=M-1,E=n*f;for(let e=0;e<g;e++){const t=(.6*(.5*Math.sin(.31*e+4.1*E)+.5)+.4*(.5*Math.sin(.73*e-2.7*E)+.5))*l;x[S*g+e]=Math.min(1,t+.15*Math.random()*l),S>0&&(x[(S-1)*g+e]=Math.min(1,.85*t+.1*Math.random()*l))}const C=new Float32Array(p);for(let e=0;e<M-2;e++)for(let t=0;t<g;t++){const o=.4*x[(e+1)*g+t]+.25*x[(e+2)*g+Math.max(0,Math.min(g-1,t+Math.round(y)))]+.175*x[(e+1)*g+Math.max(0,t-1)]+.175*x[(e+1)*g+Math.min(g-1,t+1)];C[e*g+t]=Math.max(0,o-b-.02*Math.random()*f)}for(let e=0;e<g;e++)C[(M-1)*g+e]=x[(M-1)*g+e],M>1&&(C[(M-2)*g+e]=x[(M-2)*g+e]);w[v]=C;const T=$(s)??{r:255,g:69,b:0},A=$(c)??{r:255,g:224,b:102};e.clearRect(0,0,t,o),e.font=`${a}px "JetBrains Mono", monospace`,e.textBaseline="top";for(let t=0;t<M;t++)for(let o=0;o<g;o++){const n=C[t*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=T.r+(A.r-T.r)*a|0,c=T.g+(A.g-T.g)*a|0,l=T.b+(A.b-T.b)*a|0,h=d?1-.3*n:Math.min(1,n+.15);e.globalAlpha=h,e.fillStyle=`rgb(${s},${c},${l})`,e.fillText(r,o*m,t*u)}e.globalAlpha=1}function ye(e,t,o,n,r={}){const{fontSize:a=13,baseChars:i="ATCG",bridgeChars:s="-=≡",color:c="#00e5ff",color2:l="#ff4081",bridgeColor:h="#88ffcc",speed:f=1,helixCount:d,lightMode:m=!1}=r,u=.62*a,g=1.4*a,M=Math.ceil(t/u),p=Math.ceil(o/g),v=d??Math.max(1,Math.floor(t/80)),w=M/v,x=$(c)??{r:0,g:229,b:255},b=$(l)??{r:255,g:64,b:129},y=$(h)??{r:136,g:255,b:204};e.clearRect(0,0,t,o),e.font=`${a}px "JetBrains Mono", monospace`,e.textBaseline="top";const S=n*f,E=.35*w;for(let t=0;t<v;t++){const o=w*(t+.5);for(let n=0;n<p;n++){const r=n/p*Math.PI*6-1.8*S,a=o+Math.sin(r)*E,c=o+Math.sin(r+Math.PI)*E,l=Math.round(a),h=Math.round(c);if(l<0||l>=M)continue;const f=T(31*t+7*n,3),d=i[Math.floor(f*i.length)],m=.5*(Math.sin(r)+1),v=.5*(Math.sin(r+Math.PI)+1);if(e.globalAlpha=.35+.65*m,e.fillStyle=`rgb(${x.r},${x.g},${x.b})`,e.fillText(d,l*u,n*g),h>=0&&h<M){const o=T(53*t+11*n,7),r=i[Math.floor(o*i.length)];e.globalAlpha=.35+.65*v,e.fillStyle=`rgb(${b.r},${b.g},${b.b})`,e.fillText(r,h*u,n*g)}if(n%3===0){const o=Math.min(l,h),r=Math.max(l,h);if(r-o>1){const a=T(17*n+43*t,5),i=s[Math.floor(a*s.length)],c=.25*(m+v)+.2;e.globalAlpha=c,e.fillStyle=`rgb(${y.r},${y.g},${y.b})`;for(let t=o+1;t<r;t++)e.fillText(i,t*u,n*g)}}}}e.globalAlpha=1}function Se(e,t,o,n,r={}){const{fontSize:a=13,chars:i=" .,:;+*#@",color:s="#4caf50",skyColor:c="#1a237e",peakColor:l="#e0e0e0",speed:h=1,roughness:f=.55,heightScale:d=.55,stars:m=!0,lightMode:u=!1}=r,g=.62*a,M=1.4*a,p=Math.ceil(t/g),v=Math.ceil(o/M),w=$(s)??{r:76,g:175,b:80},x=$(c)??{r:26,g:35,b:126},b=$(l)??{r:224,g:224,b:224};e.clearRect(0,0,t,o),e.font=`${a}px "JetBrains Mono", monospace`,e.textBaseline="top";const y=n*h*.4,S=new Array(p);for(let e=0;e<p;e++){const t=(.5*I((e/p+y)*f*3,.5)+.5)*d;S[e]=Math.floor(t*v)}for(let t=0;t<v;t++)for(let o=0;o<p;o++){const r=v-1-S[o],a=t===r;if(!(t>=r)){if(m){const r=T(7*o+Math.floor(.3*y),13*t);if(r>.97){const a=.3*Math.sin(2*n+100*r)+.7;e.globalAlpha=.5*a,e.fillStyle=`rgb(${x.r+60},${x.g+60},${x.b+80})`,e.fillText("·",o*g,t*M)}}continue}const s=(t-r)/Math.max(1,S[o]),c=i[Math.min(i.length-1,Math.floor(s*i.length))];if(" "===c&&!a)continue;const l=a?1:Math.max(0,1-4*s),h=w.r+(b.r-w.r)*l|0,f=w.g+(b.g-w.g)*l|0,d=w.b+(b.b-w.b)*l|0;e.globalAlpha=.5+.5*s,e.fillStyle=`rgb(${h},${f},${d})`,e.fillText(a?i[i.length-1]:c,o*g,t*M)}e.globalAlpha=1}var $e=1,Ee=2,Ce=4,Te=8,Ae={3:"─",12:"│",9:"┌",10:"┐",5:"└",6:"┘",11:"┬",7:"┴",13:"├",14:"┤",15:"┼",[$e]:"╶",[Ee]:"╴",[Ce]:"╵",[Te]:"╷"};function Ie(e,t,o,n,r={}){const{fontSize:a=13,pulseColor:i="#ffffff",color:s="#00ff88",density:c=.38,speed:l=1,lightMode:h=!1}=r,f=.62*a,d=1.4*a,m=Math.ceil(t/f),u=Math.ceil(o/d),g=$(s)??{r:0,g:255,b:136},M=$(i)??{r:255,g:255,b:255},p=(e,t)=>{if(T(17*e+1,7*t+2)>c)return 0;let o=0;return e+1<m&&T(17*e+1,7*t+2)>.15&&(o|=1),e-1>=0&&T(17*(e-1)+1,7*t+2)>.15&&(o|=2),t+1<u&&T(17*e+1,7*(t+1)+2)>.15&&(o|=8),t-1>=0&&T(17*e+1,7*(t-1)+2)>.15&&(o|=4),o};e.clearRect(0,0,t,o),e.font=`${a}px "JetBrains Mono", monospace`,e.textBaseline="top";const v=n*l;for(let t=0;t<u;t++)for(let o=0;o<m;o++){const n=p(o,t);if(0===n)continue;const r=Ae[n]??"·",a=(8*v+40*T(o,23*t))%m,i=(6*v+40*T(17*t,11*o))%u,s=(1&n||2&n)&&Math.abs(o-a)<1.5,c=(4&n||8&n)&&Math.abs(t-i)<1.5,l=s||c,h=.25+.35*T(3*o,5*t);l?(e.globalAlpha=.95,e.fillStyle=`rgb(${M.r},${M.g},${M.b})`):(e.globalAlpha=h,e.fillStyle=`rgb(${g.r},${g.g},${g.b})`),e.fillText(r,o*f,t*d)}e.globalAlpha=1}function Re(e,t={}){const{type:o="wave",opacity:n=.2,className:r,zIndex:a=0,colorScheme:i="auto",color:s,...c}=t,l="string"==typeof e?document.querySelector(e):e;if(!l)return console.warn("[asciify] asciiBackground: target not found",e),{destroy:()=>{}};const h=l.style.position;"static"===getComputedStyle(l).position&&(l.style.position="relative");const f=document.createElement("canvas");f.style.cssText=["position:absolute","inset:0","width:100%","height:100%",`opacity:${n}`,"pointer-events:none",`z-index:${a}`].join(";"),r&&(f.className=r),l.prepend(f);const d=f.getContext("2d"),m=window.devicePixelRatio||1,u={x:.5,y:.5},g={x:.5,y:.5},M=()=>"light"===i||"dark"!==i&&(()=>{let e=l;for(;e&&e!==document.documentElement.parentElement;){const t=getComputedStyle(e).backgroundColor;if(t&&"transparent"!==t&&"rgba(0, 0, 0, 0)"!==t){const e=t.match(/rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)/);if(e)return(.299*+e[1]+.587*+e[2]+.114*+e[3])/255>=.4}e=e.parentElement}const t=document.documentElement,o=(t.getAttribute("data-theme")||"").toLowerCase();return"dark"!==o&&("light"===o||!t.classList.contains("dark")&&window.matchMedia("(prefers-color-scheme: light)").matches)})(),p=s?function(e){const t=e.match(/^#([0-9a-f]{3,8})$/i)?.[1];if(t){const e=t.length<=4?t.split("").map(e=>parseInt(e+e,16)):[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)];return{r:e[0],g:e[1],b:e[2]}}const o=e.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i);return o?{r:+o[1],g:+o[2],b:+o[3]}:null}(s):null,v=()=>({...c,lightMode:void 0!==c.lightMode?c.lightMode:M(),baseColor:p?`rgba(${p.r},${p.g},${p.b},{a})`:c.baseColor}),w={current:v()},x=()=>{w.current="rain"===o||"stars"===o||"pulse"===o||"noise"===o||"grid"===o||"aurora"===o||"silk"===o||"void"===o||"morph"===o?{...c,lightMode:void 0!==c.lightMode?c.lightMode:M(),color:s??c.color}:"fire"===o||"dna"===o?{...c,color:s??c.color}:"terrain"===o||"circuit"===o?{...c,color:s??c.color,lightMode:void 0!==c.lightMode?c.lightMode:M()}:v()};x();const b=window.matchMedia("(prefers-color-scheme: light)"),y=()=>{x()};let S=null;"auto"===i&&(b.addEventListener("change",y),S=new MutationObserver(y),S.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]}));const $=()=>{const e=l.getBoundingClientRect();f.width=e.width*m,f.height=e.height*m,d.setTransform(m,0,0,m,0,0)};$();const E=e=>{const t=l.getBoundingClientRect();u.x=(e.clientX-t.left)/t.width,u.y=(e.clientY-t.top)/t.height},C=new ResizeObserver($);C.observe(l),window.addEventListener("mousemove",E);let T=0,A=0;const I=()=>{g.x+=.07*(u.x-g.x),g.y+=.07*(u.y-g.y);const e=l.getBoundingClientRect();"rain"===o?de(d,e.width,e.height,T,w.current):"stars"===o?me(d,e.width,e.height,T,g,w.current):"pulse"===o?ue(d,e.width,e.height,T,g,w.current):"noise"===o?ge(d,e.width,e.height,T,g,w.current):"grid"===o?Me(d,e.width,e.height,T,g,w.current):"aurora"===o?pe(d,e.width,e.height,T,g,w.current):"silk"===o?ve(d,e.width,e.height,T,w.current):"void"===o?we(d,e.width,e.height,T,g,w.current):"morph"===o?xe(d,e.width,e.height,T,w.current):"fire"===o?be(d,e.width,e.height,T,w.current):"dna"===o?ye(d,e.width,e.height,T,w.current):"terrain"===o?Se(d,e.width,e.height,T,w.current):"circuit"===o?Ie(d,e.width,e.height,T,w.current):R(d,e.width,e.height,T,g,w.current),T+=.016,A=requestAnimationFrame(I)};return A=requestAnimationFrame(I),{destroy:()=>{cancelAnimationFrame(A),C.disconnect(),"auto"===i&&(b.removeEventListener("change",y),S?.disconnect()),window.removeEventListener("mousemove",E),f.remove(),l.style.position=h}}}var Fe=Re;function ke(e,t,o,n="#505050",r=100){if(!e||t<=0||o<=0)return[];const a=$(n)??{r:80,g:80,b:80},i=e,s=i.length;return Array.from({length:o},(e,o)=>Array.from({length:t},(e,n)=>({char:i[(o*t+n)%s],r:a.r,g:a.g,b:a.b,a:r})))}function Le(e,{format:t="png",quality:o=.92,scale:n=1}={}){return new Promise((r,a)=>{let i=e;if(1!==n){const t=document.createElement("canvas");t.width=Math.round(e.width*n),t.height=Math.round(e.height*n);const o=t.getContext("2d");if(!o)return void a(new Error("captureSnapshot: could not get 2d context"));o.drawImage(e,0,0,t.width,t.height),i=t}i.toBlob(e=>e?r(e):a(new Error("captureSnapshot: toBlob returned null")),`image/${t}`,o)})}var Be={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]},ze=[127,65,65,65,65,65,127];function qe(e){return Be[e]??Be[e.toUpperCase()]??ze}function Pe(e,t={}){if(!e)return"";const{char:o="█",scale:n=1}=t,r=[...o][0]??"█",a=Math.max(1,Math.floor(n)),i=7*a,s=a,c=Array.from({length:i},()=>"");for(let t=0;t<e.length;t++){const o=qe(e[t]);for(let e=0;e<7;e++){const t=o[e];let n="";for(let e=6;e>=0;e--)n+=(t>>e&1?r:" ").repeat(a);for(let t=0;t<a;t++)c[e*a+t]+=n}if(t<e.length-1)for(let e=0;e<i;e++)c[e]+=" ".repeat(s)}return c.join("\n")}exports.ART_STYLE_PRESETS=n,exports.BACKGROUND_TYPES=["wave","rain","stars","pulse","noise","grid","aurora","silk","void","morph","fire","dna","terrain","circuit"],exports.CHARSETS=t,exports.CHARSET_SEQUENCES=o,exports.DEFAULT_OPTIONS=a,exports.HOVER_PRESETS={none:{label:"Off",options:{hoverStrength:0,hoverEffect:"spotlight",hoverRadius:.2,hoverColor:"#ffffff"}},subtle:{label:"Subtle",options:{hoverStrength:.25,hoverEffect:"glow",hoverRadius:.12,hoverColor:"#ffffff"}},flashlight:{label:"Flashlight",options:{hoverStrength:.6,hoverEffect:"spotlight",hoverRadius:.15,hoverColor:"#fffbe6"}},magnifier:{label:"Magnifier",options:{hoverStrength:.7,hoverEffect:"magnify",hoverRadius:.12,hoverColor:"#ffffff"}},forceField:{label:"Force Field",options:{hoverStrength:.7,hoverEffect:"repel",hoverRadius:.15,hoverColor:"#a0e8ff"}},neon:{label:"Neon",options:{hoverStrength:.6,hoverEffect:"colorShift",hoverRadius:.15,hoverColor:"#d946ef"}},fire:{label:"Fire",options:{hoverStrength:.7,hoverEffect:"spotlight",hoverRadius:.15,hoverColor:"#ff6b2b"}},ice:{label:"Ice",options:{hoverStrength:.5,hoverEffect:"glow",hoverRadius:.15,hoverColor:"#60d5f7"}},gravity:{label:"Gravity",options:{hoverStrength:.7,hoverEffect:"attract",hoverRadius:.18,hoverColor:"#a5d6ff"}},shatter:{label:"Shatter",options:{hoverStrength:.8,hoverEffect:"shatter",hoverRadius:.14,hoverColor:"#ff6090"}},ghost:{label:"Ghost",options:{hoverStrength:.55,hoverEffect:"trail",hoverRadius:.2,hoverColor:"#b39ddb"}},glitchReveal:{label:"Glitch Reveal",options:{hoverStrength:.8,hoverEffect:"glitchText",hoverRadius:.18,hoverColor:"#a3e635"}}},exports.LIVING_STYLE_PRESETS=r,exports.PALETTE_THEMES={dracula:{name:"Dracula",accent:"#bd93f9",bg:"#282a36",fg:"#f8f8f2"},monokai:{name:"Monokai",accent:"#a6e22e",bg:"#272822",fg:"#f8f8f2"},nord:{name:"Nord",accent:"#88c0d0",bg:"#2e3440",fg:"#eceff4"},catppuccin:{name:"Catppuccin",accent:"#cba6f7",bg:"#1e1e2e",fg:"#cdd6f4"},solarized:{name:"Solarized",accent:"#268bd2",bg:"#002b36",fg:"#839496"},gruvbox:{name:"Gruvbox",accent:"#b8bb26",bg:"#282828",fg:"#ebdbb2"}},exports.asciiBackground=Re,exports.asciiText=function(e,t={},o,n){const r={...a,...t},{frame:i,cols:s}=G(e,r,o,n);if(!i.length||0===s)return"";const c=[];for(const e of i)c.push(e.map(e=>e.char).join(""));return c.join("\n")},exports.asciiTextAnsi=function(e,t={},o,n){const r={...a,...t},{frame:i,cols:s}=G(e,r,o,n);if(!i.length||0===s)return"";const c=[];for(const e of i){let t="";for(const o of e)" "===o.char||o.a<10?t+=" ":t+=`[38;2;${o.r};${o.g};${o.b}m${o.char}`;c.push(t)}return c.join("\n")},exports.asciify=async function(e,t,{fontSize:o,artStyle:r="classic",options:i={}}={}){let s;if("string"==typeof e){const t=new Image;t.crossOrigin="anonymous",await new Promise((o,n)=>{t.onload=()=>o(),t.onerror=()=>n(new Error(`Failed to load image: ${e}`)),t.src=e}),s=t}else e instanceof HTMLImageElement&&!e.complete?(await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error("Image failed to load"))}),s=e):s=e;const c=n[r],l=o??i.fontSize??10,h={...a,...c,...i,fontSize:l},f=t.getContext("2d");if(!f)throw new Error("Could not get 2d context from canvas");const{w:d,h:m}=function(e){return e instanceof HTMLVideoElement?{w:e.videoWidth,h:e.videoHeight}:e instanceof HTMLImageElement?{w:e.naturalWidth||e.width,h:e.naturalHeight||e.height}:{w:e.width,h:e.height}}(s),{renderW:u,renderH:g}=le(d,m),M="undefined"!=typeof window&&window.devicePixelRatio||1,p=8e6,v=u*M*g*M>p?Math.sqrt(p/(u*g)):M;if((t.width<u||t.height<g)&&(t.width=Math.round(u*v),t.height=Math.round(g*v)),h.hoverStrength>0){const{frame:e}=G(s,h,u,g);let o=null,n=!1,r=0;const a=e=>{const n=t.getBoundingClientRect();o={x:(e.clientX-n.left)/n.width,y:(e.clientY-n.top)/n.height}},i=()=>{o=null};t.addEventListener("mousemove",a),t.addEventListener("mouseleave",i);const c=t=>{n||(f.save(),f.setTransform(v,0,0,v,0,0),te(f,e,h,u,g,t/1e3,o),f.restore(),r=requestAnimationFrame(c))};return r=requestAnimationFrame(c),()=>{n=!0,cancelAnimationFrame(r),t.removeEventListener("mousemove",a),t.removeEventListener("mouseleave",i)}}if(f.save(),f.setTransform(v,0,0,v,0,0),re(h)){const e=X(s,h,u,g);J(f,e,h,u,g)}else{const{frame:e}=G(s,h,u,g);te(f,e,h,u,g)}f.restore()},exports.asciifyGif=async function(e,t,{fontSize:o,artStyle:r="classic",options:i={}}={}){const s="string"==typeof e?await fetch(e).then(e=>e.arrayBuffer()):e,c=o??i.fontSize??10,l={...a,...n[r],...i,fontSize:c},h=t.getContext("2d");if(!h)throw new Error("Could not get 2d context from canvas");if(re(l)){const{frames:e,fps:o}=await ee(s,l,t.width,t.height);let n,r=!1,a=0,i=performance.now();const c=1e3/o,f=o=>{r||(o-i>=c&&(J(h,e[a],l,t.width,t.height),a=(a+1)%e.length,i=o),n=requestAnimationFrame(f))};return n=requestAnimationFrame(f),()=>{r=!0,cancelAnimationFrame(n)}}const{frames:f,fps:d}=await Z(s,l,t.width,t.height);let m,u=!1,g=0,M=performance.now();const p=1e3/d,v=e=>{u||(e-M>=p&&(te(h,f[g],l,t.width,t.height),g=(g+1)%f.length,M=e),m=requestAnimationFrame(v))};return m=requestAnimationFrame(v),()=>{u=!0,cancelAnimationFrame(m)}},exports.asciifyLiveVideo=function(e,t,o){return fe(e,t,o)},exports.asciifyText=Pe,exports.asciifyVideo=fe,exports.asciifyWebcam=async function(e,{fontSize:t=10,style:o="classic",options:r={},liveOptions:i,mirror:s=!0,constraints:c={facingMode:"user"},dpr:l}={}){if(!navigator.mediaDevices?.getUserMedia)throw new Error("asciifyWebcam: getUserMedia is not supported in this browser.");const h=await navigator.mediaDevices.getUserMedia({video:c}),f=document.createElement("video");f.srcObject=h,f.muted=!0,f.playsInline=!0,await new Promise((e,t)=>{f.onloadedmetadata=()=>e(),f.onerror=()=>t(new Error("asciifyWebcam: video stream failed to load.")),f.play().catch(t)});const d={...a,...n[o],...r,fontSize:t},m=e.getContext("2d");if(!m)throw new Error("asciifyWebcam: could not get 2d context from canvas.");const u=l??("undefined"!=typeof window?window.devicePixelRatio:1)??1;1!==u&&m.scale(u,u);let g=null;const M={x:.5,y:.5,intensity:0},p=t=>{const o=e.getBoundingClientRect();g={x:(t.clientX-o.left)/o.width,y:(t.clientY-o.top)/o.height}},v=()=>{g=null};d.hoverStrength>0&&(e.addEventListener("mousemove",p),e.addEventListener("mouseleave",v));let w,x=!1;const b=performance.now(),y=t=>{if(!x){if(f.readyState>=f.HAVE_CURRENT_DATA){const o=e.width/u,n=e.height/u,r=(t-b)/1e3,a=i?{...d,...i()}:d;a.hoverStrength>0?(e.addEventListener("mousemove",p),e.addEventListener("mouseleave",v)):(e.removeEventListener("mousemove",p),e.removeEventListener("mouseleave",v));const{frame:c}=G(f,a,o,n);if(g){const e=g.x-M.x,t=g.y-M.y,o=Math.sqrt(e*e+t*t),n=Math.min(.25,.06+.8*o);M.x+=e*n,M.y+=t*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;s?(m.save(),m.scale(-1,1),m.translate(-o,0),te(m,c,a,o,n,r,l),m.restore()):te(m,c,a,o,n,r,l)}w=requestAnimationFrame(y)}};return w=requestAnimationFrame(y),()=>{x=!0,cancelAnimationFrame(w),e.removeEventListener("mousemove",p),e.removeEventListener("mouseleave",v),h.getTracks().forEach(e=>e.stop()),f.srcObject=null}},exports.buildTextFrame=ke,exports.captureSnapshot=Le,exports.clearAsciifyCaches=function(){q.clear(),P.clear(),H.clear(),L=null,B=null},exports.createVideoScrollScrub=se,exports.gifToAsciiFrames=Z,exports.gifToAsciiTextFrames=ee,exports.imageToAsciiFrame=G,exports.imageToAsciiTextFrame=X,exports.mountWaveBackground=Fe,exports.renderAuroraBackground=pe,exports.renderCircuitBackground=Ie,exports.renderDnaBackground=ye,exports.renderFireBackground=be,exports.renderFrameToCanvas=te,exports.renderGridBackground=Me,exports.renderMorphBackground=xe,exports.renderNoiseBackground=ge,exports.renderPulseBackground=ue,exports.renderRainBackground=de,exports.renderSilkBackground=ve,exports.renderStarsBackground=me,exports.renderTerrainBackground=Se,exports.renderTextBackground=function(e,t,o,n,r={},i){const{fontSize:s=10,lineHeight:c=1.6,color:l="#505050",opacity:h=100,hoverEffect:f="spotlight",hoverStrength:d=.85,hoverRadius:m=.18,hoverColor:u="#d4ff00"}=r;te(e,ke(n,Math.max(1,Math.floor(t/s)),Math.max(1,Math.floor(o/(s*c))),l,h),{...a,hoverEffect:f,hoverStrength:d,hoverRadius:m,hoverColor:u},t,o,0,i??null)},exports.renderTextFrameToCanvas=J,exports.renderTextToCanvas=function(e,t,o={}){const{color:n="#d4ff00",bgColor:r,fontSize:a=10}=o,i=Pe(t,o);if(!i)return;const s=i.split("\n"),c=Math.max(...s.map(e=>[...e].length));e.width=Math.ceil(c*a*.6),e.height=Math.ceil(s.length*a);const l=e.getContext("2d");r&&"transparent"!==r?(l.fillStyle=r,l.fillRect(0,0,e.width,e.height)):l.clearRect(0,0,e.width,e.height),l.fillStyle=n,l.font=`${a}px monospace`,l.textBaseline="top",s.forEach((e,t)=>l.fillText(e,0,t*a))},exports.renderVoidBackground=we,exports.renderWaveBackground=R,exports.snapshotAndDownload=async function(e,t={}){const{filename:o="asciify-snapshot",format:n="png",...r}=t,a=await Le(e,{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)},exports.videoToAsciiFrames=K,exports.videoToAsciiTextFrames=Q;//# sourceMappingURL=index.cjs.map