asciify-engine 1.0.75 → 1.0.77

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 t=require("gifuct-js"),e={standard:" .:-=+*#%@",blocks:" ░▒▓█",minimal:" .:+",dense:" .'`^\",:;Il!i><~+_-?][}{1)(|/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$",binary:"01",dots:" ⠁⠃⠇⡇⣇⣧⣷⣿",letters:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",claudeCode:" ╔╗╚╝║═╠╣╦╩╬░▒▓█│─┌┐└┘├┤┬┴┼",box:" ▪◾◼■█",lines:" ˗‐–—―━",braille:" ⠁⠂⠃⠄⠅⠆⠇⠈⠉⠊⠋⠌⠍⠎⠏⠐⠑⠒⠓⠔⠕⠖⠗⠘⠙⠚⠛⠜⠝⠞⠟⠠⠡⠢⠣⠤⠥⠦⠧⠨⠩⠪⠫⠬⠭⠮⠯⠰⠱⠲⠳⠴⠵⠶⠷⠸⠹⠺⠻⠼⠽⠾⠿⡀⡁⡂⡃⡄⡅⡆⡇⣀⣁⣂⣃⣄⣅⣆⣇⣈⣉⣊⣋⣌⣍⣎⣏⣐⣑⣒⣓⣔⣕⣖⣗⣘⣙⣚⣛⣜⣝⣞⣟⣠⣡⣢⣣⣤⣥⣦⣧⣨⣩⣪⣫⣬⣭⣮⣯⣰⣱⣲⣳⣴⣵⣶⣷⣸⣹⣺⣻⣼⣽⣾⣿",katakana:" ヲァィゥェォャュョッアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン",musical:" ♩♪♫♬♭♮♯",emoji:" ⬛🟫🟥🟧🟨🟩🟦🟪⬜",circles:" .·:∘○◦°•∙",shadows:" ·∘◦○◎⊙●◉",starfield:" ˙·∘∗✦✧★◆●",geometric:" ·△▷◇◈◆▣■█",pipes:" ╶─┐└├┤┬┴┼╬▒▓█",waves:" ˜∼≈〰≋∿∾∭∫",shards:" ╱╲╳◤◥◣◢△▲◆◼█",smoke:" ·˙⁚⁖∶∷⋮⋰⋱∴∵"},o={cosmic:[e.starfield,e.circles,e.shadows],rain:[e.katakana,e.braille,e.binary],terminal:[e.pipes,e.claudeCode,e.standard],crystal:[e.shards,e.geometric,e.blocks],fluid:[e.waves,e.smoke,e.circles],pulse:[e.dense,e.standard,e.blocks],dream:[e.braille,e.shadows,e.smoke],angular:[e.geometric,e.shards,e.starfield]},n={classic:{renderMode:"ascii",charset:e.standard,colorMode:"grayscale"},particles:{renderMode:"dots",colorMode:"fullcolor",dotSizeRatio:.8},letters:{renderMode:"ascii",charset:e.letters,colorMode:"fullcolor"},claudeCode:{renderMode:"ascii",charset:e.claudeCode,colorMode:"accent",accentColor:"#f97316"},art:{renderMode:"ascii",charset:e.dense,colorMode:"fullcolor"},terminal:{renderMode:"ascii",charset:e.standard,colorMode:"matrix"},box:{renderMode:"ascii",charset:e.box,colorMode:"grayscale"},lines:{renderMode:"ascii",charset:e.lines,colorMode:"fullcolor"},braille:{renderMode:"ascii",charset:e.braille,colorMode:"fullcolor"},katakana:{renderMode:"ascii",charset:e.katakana,colorMode:"matrix"},musical:{renderMode:"ascii",charset:e.musical,colorMode:"accent",accentColor:"#e040fb"},emoji:{renderMode:"ascii",charset:e.emoji,colorMode:"fullcolor"},circles:{renderMode:"ascii",charset:e.circles,colorMode:"accent",accentColor:"#d4ff00"},shadows:{renderMode:"ascii",charset:e.shadows,colorMode:"accent",accentColor:"#50a0ff"},starfield:{renderMode:"ascii",charset:e.starfield,colorMode:"fullcolor"},geometric:{renderMode:"ascii",charset:e.geometric,colorMode:"grayscale"},pipes:{renderMode:"ascii",charset:e.pipes,colorMode:"accent",accentColor:"#00ff88"},waves:{renderMode:"ascii",charset:e.waves,colorMode:"fullcolor"},shards:{renderMode:"ascii",charset:e.shards,colorMode:"grayscale"},smoke:{renderMode:"ascii",charset:e.smoke,colorMode:"accent",accentColor:"#c850ff"}},r={fontSize:10,charSpacing:1,brightness:0,contrast:0,charset:e.standard,colorMode:"grayscale",accentColor:"#d4ff00",invert:!1,renderMode:"ascii",animationStyle:"none",animationSpeed:1,dotSizeRatio:.8,ditherStrength:0,charAspect:.55,normalize:!1,hoverStrength:0,hoverRadius:.2,hoverEffect:"spotlight",hoverColor:"#ffffff",hoverShape:"circle",hoverText:"ASCIIFY",artStyle:"classic",customText:"",chromaKey:null,chromaKeyTolerance:60};function a(t,e,o){let n=t+255*e;return n=259*(255*o+255)/(255*(259-255*o))*(n-128)+128,Math.max(0,Math.min(255,n))}function i(t,e,o){const n=o?1-t/255:t/255,r=[...e],a=Math.floor(n*(r.length-1));return r[Math.max(0,Math.min(r.length-1,a))]}function s(t,e,o,n,r,a){if((a?1-t/255:t/255)<.12)return" ";const i=[...e];return i[(n*r+o)%i.length]}var c=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];function l(t,e,o,n){if(n<=0)return t;const r=(c[o%4][e%4]/16-.5)*n*128;return Math.max(0,Math.min(255,t+r))}var h=new Array(256),f=new Array(256);for(let t=0;t<256;t++)h[t]=`rgb(${t},${t},${t})`,f[t]=`rgb(0,${t},0)`;function d(t,e,o,n,r,a=!1){switch(e){case"fullcolor":return`rgb(${t.r},${t.g},${t.b})`;case"matrix":return f[.299*t.r+.587*t.g+.114*t.b|0];case"accent":return`rgb(${o},${n},${r})`;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;return h[e]}}}var g=[0,0,0];function u(t,e,o,n,r,a=!1){switch(e){case"fullcolor":g[0]=t.r,g[1]=t.g,g[2]=t.b;break;case"matrix":{const e=.299*t.r+.587*t.g+.114*t.b|0;g[0]=0,g[1]=e,g[2]=0;break}case"accent":g[0]=o,g[1]=n,g[2]=r;break;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;g[0]=e,g[1]=e,g[2]=e;break}}return g}function m(t,e,o,n,r,a,i){if("none"===a)return 1;const s=r*i;switch(a){case"wave":return.3+.7*(.6*(.5*Math.sin(t/o*Math.PI*4+3*s)+.5)+.4*(.5*Math.sin(e/n*Math.PI*3+2*s)+.5));case"pulse":{const r=o/2,a=n/2,i=Math.sqrt((t-r)**2+(e-a)**2),c=Math.sqrt(r**2+a**2);return.2+.8*(.5*Math.sin(i/c*Math.PI*6-4*s)+.5)}case"rain":return.1+.9*(.5*Math.sin(e/n*Math.PI*8-5*s+.3*t)+.5)*(.3*Math.sin(t/o*Math.PI*2+s)+.7);case"breathe":{const o=.3*Math.sin(2*s)+.7,n=.1*Math.sin(.1*(t+e)+s);return Math.max(.1,Math.min(1,o+n))}case"sparkle":{const o=43758.5453*Math.sin(127.1*t+311.7*e+43758.5453*Math.floor(8*s)),n=o-Math.floor(o);return n>.7?1:.15+.4*n}case"glitch":{const t=Math.floor(e/(.05*n)),o=43758.5453*Math.sin(43.23*t+17.89*Math.floor(6*s));if(o-Math.floor(o)>.85){const e=.5*Math.sin(30*s+t)+.5;return e<.3?0:e}return 1}case"spiral":{const r=o/2,a=n/2,i=t-r,c=e-a,l=Math.atan2(c,i),h=Math.sqrt(i*i+c*c),f=Math.sqrt(r*r+a*a);return.15+.85*(.5*Math.sin(3*l+h/f*Math.PI*8-3*s)+.5)}case"typewriter":{const r=o*n,a=e*o+t-.5*s%1*r*1.3;if(a>0)return 0;const i=Math.max(0,1+a/(.15*r));return Math.min(1,i)}case"scatter":{const r=o/2,a=n/2,i=t-r,c=e-a,l=Math.sqrt(i*i+c*c)/Math.sqrt(r*r+a*a),h=.5*Math.sin(1.5*s)+.5;return l>h?Math.max(0,1-3*(l-h)):.7+.3*Math.sin(10*l-2*s)}case"waveField":default:return 1;case"ripple":{const r=o/2,a=n/2,i=t-r,c=e-a,l=Math.sqrt(i*i+c*c),h=Math.sqrt(r*r+a*a);return.1+.9*(.5*Math.sin(l/h*Math.PI*10-5*s)+.5)*(.4+.6*(1-Math.min(1,l/(1.1*h))))}case"melt":{const o=e/n*Math.PI;return.05+(.5*Math.sin(o-1.8*s+.15*t)+.5)*(1-.6*(Math.max(0,e/n-.1)/.9))*.95}case"orbit":{const r=o/2,a=n/2,i=t-r,c=e-a,l=Math.atan2(c,i),h=Math.sqrt(i*i+c*c)/Math.sqrt(r*r+a*a);return.1+.9*(.5*Math.sin(2*l+6*h-2.5*s)+.5)}case"cellular":{const o=Math.floor(4*s),n=(t,e)=>{const n=43758.5453*Math.sin(127.1*t+311.7*e+43758.5453*o);return n-Math.floor(n)>.38?1:0},r=n(t,e),a=n(t-1,e)+n(t+1,e)+n(t,e-1)+n(t,e+1)+n(t-1,e-1)+n(t+1,e-1)+n(t-1,e+1)+n(t+1,e+1);return 1===(1===r?2===a||3===a?1:0:3===a?1:0)?1:.05}}}var M={scale:1,offsetX:0,offsetY:0,glow:0,colorBlend:0,proximity:0};function p(t,e,o,n,r,a,i,s,c="spotlight",l=.5,h="circle"){const f=t-o,d=e-n,g=.08+.35*l+.04*a;let u,m;if("box"===h){const t=Math.abs(f),e=Math.abs(d);u=Math.max(t,e),m=g}else u=Math.sqrt(f*f+d*d),m=g;if(u>=m)return M.scale=1,M.offsetX=0,M.offsetY=0,M.glow=0,M.colorBlend=0,M.proximity=0,M;const p=function(t){return t*t*(3-2*t)}(1-u/m)*r;let b=1,x=0,v=0,w=0,y=0;switch(c){case"spotlight":{b=1+p*a*1.8;const t=Math.atan2(d,f),e=p*p*a*.6;x=Math.cos(t)*e*i,v=Math.sin(t)*e*s,w=p*a*.4,y=p*p*a*.25;break}case"magnify":b=1+p*a*2.5,w=p*a*.15;break;case"repel":{b=1+p*a*.3;const t=Math.atan2(d,f),e=p*p*a*1.2;x=Math.cos(t)*e*i,v=Math.sin(t)*e*s;break}case"glow":w=p*a*.8,y=p*a*.4;break;case"colorShift":b=1+p*a*.4,w=p*a*.2,y=p*a*.7;break;case"attract":{const t=Math.atan2(d,f),e=p*p*a*1;x=-Math.cos(t)*e*i,v=-Math.sin(t)*e*s,w=p*a*.3;break}case"shatter":{const t=Math.atan2(d,f),e=.5*Math.sin(43.7*f+29.3*d),o=p*a*1.4*(.7+.3*e);x=Math.cos(t+e)*o*i,v=Math.sin(t+e)*o*s,b=Math.max(.1,1-p*a*.6),w=p*a*.25;break}case"trail":y=p*a*.9,w=p*a*.6,b=1+p*a*.15;break;case"glitchText":b=1+p*a*.25,w=p*a*.7,y=p*a*.65}return M.scale=b,M.offsetX=x,M.offsetY=v,M.glow=w,M.colorBlend=y,M.proximity=p,M}function b(t){const e=t.match(/^#([0-9a-f]{3,8})$/i)?.[1];if(e){const t=e.length<=4?e.split("").map(t=>parseInt(t+t,16)):[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)];return{r:t[0],g:t[1],b:t[2]}}const o=t.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i);return o?{r:+o[1],g:+o[2],b:+o[3]}:null}function x(t){return t*t*t*(t*(6*t-15)+10)}function v(t,e,o){return t+(e-t)*o}function w(t,e){let o=127*t+311*e;return o^=o>>13,(o*(o*o*15731+789221)+1376312589&2147483647)/2147483647}function y(t,e){const o=Math.floor(t),n=Math.floor(e),r=e-n,a=x(t-o),i=x(r),s=w(o,n),c=w(o+1,n),l=w(o,n+1),h=w(o+1,n+1);return v(v(s,c,a),v(l,h,a),i)}function $(t,e){return(.5*y(t,e)+.25*y(2.1*t,2.1*e)+.125*y(4.3*t,4.3*e))/.875}function S(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=13,charAspect:s=.62,lineHeightRatio:c=1.4,chars:l=" .:-=+*#%@",baseColor:h=null,accentColor:f,accentThreshold:d=.52,mouseInfluence:g=.55,mouseFalloff:u=2.8,speed:m=1,vortex:M=!0,sparkles:p=!0,breathe:b=!0,lightMode:x=!1}=a,v=f??(x?"#6b8700":"#d4ff00"),y=i*s,S=i*c,C=Math.ceil(e/y),E=Math.ceil(o/S),T=r.x,A=r.y;let I=212,R=255,k=0;{const t=v.replace("#","");6===t.length&&(I=parseInt(t.slice(0,2),16),R=parseInt(t.slice(2,4),16),k=parseInt(t.slice(4,6),16))}t.clearRect(0,0,e,o),t.font=`${i}px "JetBrains Mono", monospace`,t.textBaseline="top";const B=n*m,F=b?.12*(.5*Math.sin(.22*B)+.5):0;for(let e=0;e<E;e++)for(let o=0;o<C;o++){const n=o/C,r=e/E,a=.045,i=.08*B,s=.06,c=.45*((.5*Math.sin(.08*o+.05*e+.6*B)+.5+(.5*Math.sin(.03*o-.07*e+.4*B)+.5)+(.5*Math.sin(.05*o+.03*e+.8*B)+.5))/3)+.35*(.5*$(o*a+i,e*a*1.4-.7*i)+.5)+.2*(.5*Math.sin((o+.65*e)*s+1.1*B)+.5)+F,f=n-T,m=r-A,b=Math.sqrt(f*f+m*m);let v=0;if(M&&b<.35){const t=Math.atan2(m,f),e=Math.sin(4*t+2.2*B-14*b),o=Math.max(0,1-b/.35);v=e*o*o*.22}const P=c*(1-g)+(Math.max(0,1-b*u)+.5*v)*g+.15*v,z=Math.min(1,Math.max(0,P));let q=z;if(p&&z>.72){const t=Math.floor(8*B),n=w(7*o+3*t,11*e+t);n>.88&&(q=Math.min(1,z+4*(n-.88)))}const L=Math.floor(q*(l.length-1));if(" "===l[L])continue;const H=.015+.07*q;if(q>d){const e=Math.min(x?.9:.28,H*(x?14:2.8));t.fillStyle=`rgba(${I},${R},${k},${e})`}else t.fillStyle=h?h.replace("{a}",String(H)):x?`rgba(55,55,55,${7*H})`:`rgba(255,255,255,${H})`;t.fillText(l[L],o*y,e*S)}}function C(t){return"auto"!==t?t:"undefined"!=typeof window&&!window.matchMedia("(prefers-color-scheme: dark)").matches}function E(t){const e=t.match(/^#([0-9a-fA-F]{3,6})$/);if(e){let t=e[1];if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return t}const o=t.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);return o?[o[1],o[2],o[3]].map(t=>parseInt(t).toString(16).padStart(2,"0")).join(""):null}function T(t){const e=t||"auto";if("auto"!==e)return e.replace("#","");if("undefined"!=typeof document){const t=getComputedStyle(document.documentElement);for(const e of["--accent-color","--color-accent","--accent","--color-primary","--primary","--brand-color"]){const o=E(t.getPropertyValue(e).trim());if(o)return o}const e=E(getComputedStyle(document.body).accentColor??"");if(e)return e}return"undefined"!=typeof window&&window.matchMedia("(prefers-color-scheme: dark)").matches?"faf9f7":"0d0d0d"}function A(t,e,o,n){const r=t instanceof HTMLVideoElement?t.videoWidth:t.width,c=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(0===r||0===c)return{frame:[],cols:0,rows:0};const h=e.charAspect,f=e.fontSize*e.charSpacing,d=e.fontSize/h*e.charSpacing,g=o||r,u=n||c,m=Math.floor(g/f),M=Math.floor(u/d);if(m<=0||M<=0)return{frame:[],cols:0,rows:0};const p=Math.max(1,Math.min(Math.floor(2048/m),Math.floor(r/m))),b=Math.max(1,Math.min(Math.floor(2048/M),Math.floor(c/M))),x=m*p,v=M*b,{ctx:w}=function(t,e){const o=document.createElement("canvas");o.width=t,o.height=e;const n=o.getContext("2d",{willReadFrequently:!0});return{canvas:o,ctx:n}}(x,v);w.drawImage(t,0,0,x,v);const y=w.getImageData(0,0,x,v).data,$=e.chromaKey,S=null!=$&&!1!==$,E=!0===$,T="blue-screen"===$;let A=null,I=0;!S||E||T||(A=function(t){if("string"!=typeof t)return t;const e=document.createElement("canvas");e.width=1,e.height=1;const o=e.getContext("2d");o.fillStyle=t,o.fillRect(0,0,1,1);const n=o.getImageData(0,0,1,1).data;return{r:n[0],g:n[1],b:n[2]}}($),I=(e.chromaKeyTolerance??60)**2);let R=0,k=255;if(e.normalize){let t=255,e=0;for(let o=0;o<y.length;o+=4){if(S){const t=y[o],e=y[o+1],n=y[o+2];let r=!1;if(E)r=e>1.4*t&&e>1.4*n&&e>80;else if(T)r=n>1.4*t&&n>1.4*e&&n>80;else if(null!==A){const o=t-A.r,a=e-A.g,i=n-A.b;r=o*o+a*a+i*i<=I}if(r)continue}const n=.299*y[o]+.587*y[o+1]+.114*y[o+2];n<t&&(t=n),n>e&&(e=n)}R=t,k=e>t?e-t:255}const B=[],F=C(e.invert),P=S&&e.charset.replace(/ /g,"")||e.charset,z=p*b;for(let t=0;t<M;t++){const o=[];for(let n=0;n<m;n++){let r=0,c=0,h=0,f=0,d=0;for(let e=0;e<b;e++){const o=(t*b+e)*x;for(let t=0;t<p;t++){const e=4*(o+n*p+t),a=y[e],i=y[e+1],s=y[e+2],l=y[e+3];if(S){let t=!1;if(E)t=i>1.4*a&&i>1.4*s&&i>80;else if(T)t=s>1.4*a&&s>1.4*i&&s>80;else if(null!==A){const e=a-A.r,o=i-A.g,n=s-A.b;t=e*e+o*o+n*n<=I}if(t){d++;continue}}r+=a,c+=i,h+=s,f+=l}}if(S&&d>z/2){o.push({char:" ",r:0,g:0,b:0,a:0});continue}const g=z-d,u=g>0?r/g:0,M=g>0?c/g:0,v=g>0?h/g:0,w=g>0?f/g:0,$=.299*u+.587*M+.114*v,C=l(a(e.normalize?($-R)/k*255:$,e.brightness,e.contrast),n,t,e.ditherStrength),B=e.customText?s(C,e.customText,n,t,m,F):i(C,P,F);o.push({char:B,r:u,g:M,b:v,a:w,lum:C})}B.push(o)}return{frame:B,cols:m,rows:M}}async function I(t,e,o,n,r=12,a=10,i,s=0){const c=Math.min(t.duration-s,a),l=Math.ceil(c*r),h=[];let f=0,d=0;for(let a=0;a<l;a++){const g=s+a/r;if(g>s+c)break;t.currentTime=g,await new Promise(e=>{const o=()=>{t.removeEventListener("seeked",o),e()};t.addEventListener("seeked",o)});const u=A(t,e,o,n);h.push(u.frame),f=u.cols,d=u.rows,i?.((a+1)/l)}return{frames:h,cols:f,rows:d,fps:r}}async function R(e,o,n,r,a){const i=t.parseGIF(e),s=t.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 g=d.getContext("2d"),u=document.createElement("canvas");u.width=h,u.height=f;const m=u.getContext("2d"),M=[];let p=0,b=0,x=0;for(const t of s)x+=t.delay||100;const v=x/s.length,w=Math.round(Math.min(30,Math.max(5,1e3/v))),y=Math.min(s.length,300);for(let t=0;t<y;t++){const e=s[t],{dims:i,patch:c,disposalType:l}=e;3===l&&(m.clearRect(0,0,h,f),m.drawImage(d,0,0));const x=new ImageData(new Uint8ClampedArray(c.buffer),i.width,i.height),v=document.createElement("canvas");v.width=i.width,v.height=i.height;v.getContext("2d").putImageData(x,0,0),g.drawImage(v,i.left||0,i.top||0);const w=A(d,o,n,r);M.push(w.frame),p=w.cols,b=w.rows,2===l?g.clearRect(i.left||0,i.top||0,i.width,i.height):3===l&&(g.clearRect(0,0,h,f),g.drawImage(u,0,0)),a?.((t+1)/y)}return{frames:M,cols:p,rows:b,fps:w}}function k(t,e,o,n,r,a=0,s){if("waveField"===o.animationStyle){return void S(t,n,r,a,s?{x:s.x,y:s.y}:{x:.5,y:.5},{accentColor:`#${o.accentColor?T(o.accentColor):"d4ff00"}`,accentThreshold:.52,mouseInfluence:o.hoverStrength>0?Math.min(1,.3+.5*o.hoverStrength):.55,mouseFalloff:2.8,speed:o.animationSpeed,vortex:o.hoverStrength>0,sparkles:!0,breathe:!0})}const c=e.length;if(0===c)return;const l=e[0].length;t.clearRect(0,0,n,r);let h=!1;const f=Math.max(1,c>>2),g=Math.max(1,l>>2);t:for(let t=0;t<c;t+=f){const o=e[t];for(let t=0;t<l;t+=g)if(o[t].a<200){h=!0;break t}}if(!h){const e="undefined"!=typeof window&&window.matchMedia("(prefers-color-scheme: dark)").matches;t.fillStyle=e?"#0a0a0a":"#faf9f7",t.fillRect(0,0,n,r)}const M=n/l,b=r/c,x=c*l,v=s?.intensity??1,w=!("none"!==o.animationStyle&&x>5e3)&&!!(s&&o.hoverStrength>0&&v>.005),y=o.hoverColor||"#ffffff",$=parseInt(y.slice(1,3),16)||255,E=parseInt(y.slice(3,5),16)||255,A=parseInt(y.slice(5,7),16)||255,I=T(o.accentColor),R=parseInt(I.substring(0,2),16)||255,k=parseInt(I.substring(2,4),16)||255,B=parseInt(I.substring(4,6),16)||255,F=x>3e4?.25:x>15e3?.4:x>5e3?.6:1,P=o.hoverRadius*F;let z=0,q=l,L=0,H=c,W=0,j=0;if(w&&s){W=s.x,j=s.y;const t=.08+.35*P+.04*o.hoverStrength;z=Math.max(0,Math.floor((W-t)*l)-1),q=Math.min(l,Math.ceil((W+t)*l)+1),L=Math.max(0,Math.floor((j-t)*c)-1),H=Math.min(c,Math.ceil((j+t)*c)+1)}const O=o.animationStyle,Y=o.animationSpeed,U="none"===O,D=o.hoverStrength,_=o.hoverEffect,V=P,N=o.hoverShape||"circle",X=C(o.invert),G=o.colorMode,J=2*Math.PI,K=1/l,Q=1/c;let Z="",tt=-1;if("dots"===o.renderMode){const n=.5*Math.min(M,b)*o.dotSizeRatio;for(let o=0;o<c;o++){const r=e[o];for(let e=0;e<l;e++){const i=r[e];if(i.a<10)continue;const s=.00392156863*(.299*i.r+.587*i.g+.114*i.b),h=X?1-s:s;if(h<.02)continue;const f=U?1:m(e,o,l,c,a,O,Y);let g=1,x=0,y=0,S=0,C=0;if(w&&e>=z&&e<=q&&o>=L&&o<=H){const t=p(e*K,o*Q,W,j,v,D,M,b,_,V,N);g=t.scale,x=t.offsetX,y=t.offsetY,S=t.glow,C=t.colorBlend}const T=n*h*f*g;if(T<.3)continue;const I=e*M+.5*M+x,F=o*b+.5*b+y;let P;if(C>0){const t=u(i,G,R,k,B,X);P=`rgb(${Math.min(255,t[0]+($-t[0])*C|0)},${Math.min(255,t[1]+(E-t[1])*C|0)},${Math.min(255,t[2]+(A-t[2])*C|0)})`}else P=d(i,G,R,k,B,X);const et=Math.min(1,.00392156863*i.a*f*(1+S));if(et!==tt&&(t.globalAlpha=et,tt=et),P!==Z&&(t.fillStyle=P,Z=P),T<=3){const e=2*T;t.fillRect(I-T,F-T,e,e)}else t.beginPath(),t.arc(I,F,T,0,J),t.fill()}}}else{const n=.55,r=.9*Math.min(M/n,b),s=r<6;if(!s){const e="emoji"===o.artStyle;t.font=e?`${r}px "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif`:`${r}px "JetBrains Mono", monospace`,t.textAlign="center",t.textBaseline="middle"}let h=null;const f=o.charsetFrames,g=!!f?.length,x=g?f[Math.floor(Math.max(0,a)*(o.charsetFps??2))%f.length]:o.charset;if(s){h={};const t=[...x],e=t.length;for(let o=0;o<e;o++)h[t[o]]=Math.max(.1,(o+.3)/e)}const y=s?null:t.getTransform(),S="glitchText"===_&&w,C="!@#$%^&*<>{}[]|/\\~`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",T=C.length;let I="",F=[],P=0,J=0;if(S){const t=o.hoverText??"ASCIIFY";if(P=Math.round(W*l),J=Math.round(j*c),Array.isArray(t)){I=t[((7*Math.floor(P/Math.max(1,Math.ceil(l/5)))+13*Math.floor(J/Math.max(1,Math.ceil(c/3))))%t.length+t.length)%t.length]||t[0]||"ASCIIFY"}else I=t||"ASCIIFY";F=I.split("\n")}for(let o=0;o<c;o++){const n=e[o];for(let e=0;e<l;e++){const r=n[e];if(r.a<10)continue;let f=g&&null!=r.lum?i(r.lum,x,X):r.char;if(" "===f)continue;const I=U?1:m(e,o,l,c,a,O,Y);if(I<.05)continue;let et=1,ot=0,nt=0,rt=0,at=0,it=0;if(w&&e>=z&&e<=q&&o>=L&&o<=H){const t=p(e*K,o*Q,W,j,v,D,M,b,_,V,N);et=t.scale,ot=t.offsetX,nt=t.offsetY,rt=t.glow,at=t.colorBlend,it=t.proximity}if(S&&it>0){const t=F[o-(J-Math.floor(F.length/2))];if(null!=t){const n=e-(P-Math.floor(t.length/2));if(n>=0&&n<t.length&&" "!==t[n]){const r=Math.max(0,(it-.15)/.55),i=43758.5453*Math.sin(127.1*e+311.7*o+43758.5453*Math.floor(10*a));f=i-Math.floor(i)<r?t[n]:C[Math.abs(Math.floor(97*i))%T],rt=Math.max(rt,.9*it),at=Math.max(at,.85*it)}else{const t=43758.5453*Math.sin(43.7*e+29.3*o+17.89*Math.floor(6*a));t-Math.floor(t)<.35*it&&(f=C[Math.abs(Math.floor(71*t))%T])}}else{const t=43758.5453*Math.sin(43.7*e+29.3*o+17.89*Math.floor(6*a));t-Math.floor(t)<.25*it&&(f=C[Math.abs(Math.floor(53*t))%T])}}const st=e*M+.5*M+ot,ct=o*b+.5*b+nt;let lt;if(at>0){const t=u(r,G,R,k,B,X);lt=`rgb(${Math.min(255,t[0]+($-t[0])*at|0)},${Math.min(255,t[1]+(E-t[1])*at|0)},${Math.min(255,t[2]+(A-t[2])*at|0)})`}else lt=d(r,G,R,k,B,X);if(s){const e=h[f]??.5,o=Math.min(1,.00392156863*r.a*I*(1+rt))*e;if(o<.02)continue;o!==tt&&(t.globalAlpha=o,tt=o),lt!==Z&&(t.fillStyle=lt,Z=lt);const n=M*et,a=b*et;t.fillRect(st-.5*n,ct-.5*a,n,a)}else{const e=Math.min(1,.00392156863*r.a*I*(1+rt));e!==tt&&(t.globalAlpha=e,tt=e),lt!==Z&&(t.fillStyle=lt,Z=lt),1!==et?(t.translate(st,ct),t.scale(et,et),t.fillText(f,0,0),t.setTransform(y)):t.fillText(f,st,ct)}}}}t.globalAlpha=1}function B(t,e){const o=Math.min(1,2048/Math.max(t,e));return{renderW:Math.round(t*o),renderH:Math.round(e*o)}}function F(t,e,o,n,r){const{width:a,height:i}=e.getBoundingClientRect();if(!a||!i)return{renderW:0,renderH:0,dpr:1};let s,c,l=a,h=l/o;h>i&&(h=i,l=h*o),l=Math.round(l),h=Math.round(h),n&&r?({renderW:s,renderH:c}=B(n,r)):(s=l,c=h);const f="undefined"!=typeof window&&window.devicePixelRatio||1,d=8e6,g=s*f*c*f>d?Math.sqrt(d/(s*c)):f;return t.width=Math.round(s*g),t.height=Math.round(c*g),t.style.width=l+"px",t.style.height=h+"px",{renderW:s,renderH:c,dpr:g}}async function P(t,e,{fontSize:o,artStyle:a="classic",options:i={},fitTo:s,preExtract:c=!1,trim:l,onReady:h,onFrame:f}={}){const d=l?.start??0,g=l?.end,u=o??i.fontSize??10,m={...r,...n[a],...i,fontSize:u},M=e.getContext("2d");if(!M)throw new Error("asciifyVideo: could not get 2d context from canvas.");const p="string"==typeof s?document.querySelector(s):s instanceof HTMLElement?s:null;if(c){let o;"string"==typeof t?(o=document.createElement("video"),o.crossOrigin="anonymous",o.src=t,o.readyState<2&&await new Promise((e,n)=>{o.onloadeddata=()=>e(),o.onerror=()=>n(new Error(`asciifyVideo: failed to load "${t}"`))})):o=t,p&&F(e,p,o.videoWidth/o.videoHeight,o.videoWidth,o.videoHeight);const{renderW:n,renderH:r}=B(o.videoWidth,o.videoHeight),a="undefined"!=typeof window&&window.devicePixelRatio||1,i=8e6,s=n*a*r*a>i?Math.sqrt(i/(n*r)):a;e.width<Math.round(n*s)&&(e.width=Math.round(n*s),e.height=Math.round(r*s));const c=void 0!==g?g-d:10,{frames:l,fps:u}=await I(o,m,n,r,void 0,c,void 0,d);let b,x=!1,v=0,w=performance.now(),y=!0;const $=1e3/u,S=t=>{x||(t-w>=$&&(M.save(),M.setTransform(s,0,0,s,0,0),k(M,l[v],m,n,r),M.restore(),v=(v+1)%l.length,w=t,y&&(y=!1,h?.(o)),f?.()),b=requestAnimationFrame(S))};return b=requestAnimationFrame(S),()=>{x=!0,cancelAnimationFrame(b)}}let b,x=!1;"string"==typeof t?(b=document.createElement("video"),b.src=t,b.muted=!0,b.loop=!0,b.playsInline=!0,b.setAttribute("playsinline",""),Object.assign(b.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(b),x=!0,await new Promise((e,o)=>{b.onloadedmetadata=()=>e(),b.onerror=()=>o(new Error(`asciifyVideo: failed to load "${t}"`))}),await b.play().catch(()=>{})):(b=t,b.paused&&await b.play().catch(()=>{})),d>0&&(b.currentTime=d,await new Promise(t=>{const e=()=>{b.removeEventListener("seeked",e),t()};b.addEventListener("seeked",e)}));let v=null;(d>0||void 0!==g)&&(v=()=>{(void 0!==g&&b.currentTime>=g||d>0&&b.currentTime<d)&&(b.currentTime=d)},b.addEventListener("timeupdate",v));let w=null;const{renderW:y,renderH:$}=B(b.videoWidth,b.videoHeight);if(p){const t=b.videoWidth/b.videoHeight,o=b.videoWidth,n=b.videoHeight,r=F(e,p,t,o,n),a=e.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0),w=new ResizeObserver(()=>{const r=F(e,p,t,o,n),a=e.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0)}),w.observe(p)}else{const t="undefined"!=typeof window&&window.devicePixelRatio||1,o=8e6,n=y*t*$*t>o?Math.sqrt(o/(y*$)):t;e.width<Math.round(y*n)&&(e.width=Math.round(y*n),e.height=Math.round($*n)),M.setTransform(n,0,0,n,0,0)}let S,C=!1,E=!0;const T=()=>{if(C)return;if(S=requestAnimationFrame(T),b.readyState<2||0===e.width||0===e.height)return;if(d>0&&b.currentTime<d)return;if(void 0!==g&&b.currentTime>=g)return;const{frame:t}=A(b,m,y,$);t.length>0&&(k(M,t,m,y,$,0,null),E&&(E=!1,h?.(b)),f?.())};return S=requestAnimationFrame(T),()=>{C=!0,cancelAnimationFrame(S),w?.disconnect(),v&&b.removeEventListener("timeupdate",v),x&&(b.pause(),b.src="",document.body.removeChild(b))}}function z(t,e,o,n,r={}){const{fontSize:a=13,chars:i="0123456789ABCDEF@#$&*+=/<>",accentColor:s,color:c,speed:l=1,density:h=.55,tailLength:f=14,lightMode:d=!1}=r,g=s??(d?"#6b8700":"#d4ff00"),u=.62*a,m=1.4*a,M=Math.ceil(e/u),p=Math.ceil(o/m);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let x=255,v=255,y=255;if(d&&(x=55,v=55,y=55),c){const t=b(c);t&&(x=t.r,v=t.g,y=t.b)}let $=212,S=255,C=0;const E=b(g);E&&($=E.r,S=E.g,C=E.b);const T=p+f;for(let e=0;e<M;e++){if(w(17*e,3)>h)continue;const o=(.5+1.5*w(31*e,7))*l,r=w(13*e,11)*T,a=Math.floor((n*o*7+r)%T),s=e*u;for(let o=0;o<=f;o++){const r=a-(f-o);if(r<0||r>=p)continue;const c=r*m,l=w(53*e+Math.floor(5*n+o),7*r),h=i[Math.floor(l*i.length)],g=o/f;if(o===f)t.fillStyle=`rgba(${$},${S},${C},${d?.7:.85})`;else{const e=d?.85*g:.15*g;t.fillStyle=`rgba(${x},${v},${y},${e})`}t.fillText(h,s,c)}}}function q(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" . · * + ° ★",accentColor:c,color:l,speed:h=1,count:f=180,lightMode:d=!1}=a,g=c??(d?"#6b8700":"#d4ff00");t.clearRect(0,0,e,o),t.textBaseline="middle",t.textAlign="center";const u=e*(.2+.6*r.x),m=o*(.2+.6*r.y),M=.65*Math.sqrt(e*e+o*o);let p=255,x=255,v=255;if(d&&(p=55,x=55,v=55),l){const t=b(l);t&&(p=t.r,x=t.g,v=t.b)}let y=212,$=255,S=0;const C=b(g);C&&(y=C.r,$=C.g,S=C.b);const E=s.replace(/ /g,"").split("");if(0!==E.length){for(let r=0;r<f;r++){const a=w(17*r,3)*Math.PI*2,s=(n*(.15+.85*w(31*r,7))*h*.22+w(13*r,11))%1,c=u+Math.cos(a)*s*M,l=m+Math.sin(a)*s*M;if(c<-20||c>e+20||l<-20||l>o+20)continue;const f=Math.max(6,i*(.4+.9*s));t.font=`${f}px monospace`;const g=E[Math.min(E.length-1,Math.floor(s*E.length))],b=s>.72,C=d?.85*s:.2*s;t.fillStyle=b?`rgba(${y},${$},${S},${Math.min(d?.92:.32,2.2*C)})`:`rgba(${p},${x},${v},${C})`,t.fillText(g,c,l)}t.textAlign="left"}}function L(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=". · ○ ◎ ●",accentColor:c,color:l,rings:h=5,speed:f=1,sharpness:d=4,lightMode:g=!1}=a,u=c??(g?"#007a5e":"#00ffcc");t.clearRect(0,0,e,o),t.textBaseline="middle",t.textAlign="center";const m=e*r.x,M=o*r.y,p=1.6*Math.sqrt(m*m+M*M)+.2*Math.sqrt(e*e+o*o);let x=255,v=255,w=255;if(g&&(x=55,v=55,w=55),l){const t=b(l);t&&(x=t.r,v=t.g,w=t.b)}let y=0,$=255,S=204;const C=b(u);C&&(y=C.r,$=C.g,S=C.b);const E=s.replace(/ /g,"").split("");if(0===E.length)return;const T=Math.ceil(e/i),A=Math.ceil(o/i);for(let e=0;e<A;e++)for(let o=0;o<T;o++){const r=o*i+.5*i,a=e*i+.5*i,s=r-m,c=a-M,l=Math.sqrt(s*s+c*c)/p;let u=0;for(let t=0;t<h;t++){const e=(n*f*.38+t/h)%1,o=Math.abs(l-e),r=Math.max(0,1-o*p/(i*(12-d)));u+=Math.cos(r*Math.PI*.5)*r}if(u=Math.min(1,u),u<.02)continue;const b=u>.6;t.font=`${i}px monospace`;const C=Math.floor(u*(E.length-1)),T=E[Math.min(C,E.length-1)],A=g?.88*u:.22*u;t.fillStyle=b?`rgba(${y},${$},${S},${Math.min(g?.95:.4,.55*u)})`:`rgba(${x},${v},${w},${A})`,t.fillText(T,r,a)}t.textAlign="left"}function H(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" .·:;=+*#%@░▒▓",accentColor:c,color:l,octaves:h=4,speed:f=1,scale:d=1,accentThreshold:g=.78,mouseWarp:u=.3,lightMode:m=!1}=a,M=c??(m?"#6b8700":"#d4ff00"),p=.62*i,x=1.4*i,v=Math.ceil(e/p),w=Math.ceil(o/x);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let $=255,S=255,C=255;if(m&&($=55,S=55,C=55),l){const t=b(l);t&&($=t.r,S=t.g,C=t.b)}let E=212,T=255,A=0;const I=b(M);I&&(E=I.r,T=I.g,A=I.b);const R=.035*d,k=n*f,B=Math.min(6,Math.max(1,h)),F=(t,e)=>{let o=0,n=.5,r=1,a=0;for(let i=0;i<B;i++)o+=y(t*r,e*r)*n,a+=n,n*=.5,r*=2.1;return o/a};for(let e=0;e<w;e++)for(let o=0;o<v;o++){const n=o*R+.06*k,a=e*R*1.3-.04*k,i=o/v-r.x,c=e/w-r.y,l=Math.sqrt(i*i+c*c),h=u>0?.12*Math.max(0,1-l/u):0,f=.5*F(n+h*Math.sin(1.3*k+8*c),a+h*Math.cos(.9*k+8*i))+.5;if(f<.12)continue;const d=s[Math.floor(f*(s.length-1))];if(" "===d)continue;const M=f>g,b=m?.82*f:.13*f;t.fillStyle=M?`rgba(${E},${T},${A},${m?.92:.28})`:`rgba(${$},${S},${C},${b})`,t.fillText(d,o*p,e*x)}}function W(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=12,chars:s="·-=+|/",accentColor:c,color:l,bands:h=3,speed:f=1,bandWidth:d=.12,glitch:g=!0,lightMode:u=!1}=a,m=c??(u?"#6b8700":"#d4ff00"),M=.62*i,p=1.4*i,x=Math.ceil(e/M),v=Math.ceil(o/p);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let y=255,$=255,S=255;if(u&&(y=55,$=55,S=55),l){const t=b(l);t&&(y=t.r,$=t.g,S=t.b)}let C=212,E=255,T=0;const A=b(m);A&&(C=A.r,E=A.g,T=A.b);const I=n*f;for(let e=0;e<v;e++)for(let o=0;o<x;o++){const n=e/v,a=((n*h-.5*I)%1+1)%1,i=Math.max(0,1-a/d),c=.35*(.5*w(3*o,7*e)+.5);let l=0;if(g){const t=o/x-r.x,a=n-r.y,i=Math.sqrt(t*t+a*a);if(i<.18){const t=w(11*o+Math.floor(12*I),5*e);l=Math.max(0,1-i/.18)*(t>.5?t-.3:0)}}const f=Math.min(1,c+.8*i+.6*l);if(f<.04)continue;const m=s[Math.floor(f*(s.length-1))],b=i>.55,A=u?.82*f:.12*f;t.fillStyle=b?`rgba(${C},${E},${T},${u?.92:.28})`:`rgba(${y},${$},${S},${A})`,t.fillText(m,o*M,e*p)}}function j(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" ·∙•:;+=≡≣#@",color:c,accentColor:l,speed:h=1,layers:f=5,softness:d=1.2,mouseRipple:g=.2,lightMode:u=!1}=a,m=l??(u?"#6b8700":"#d4ff00"),M=.62*i,p=1.4*i,x=Math.ceil(e/M),v=Math.ceil(o/p);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let y=255,$=255,S=255;if(u&&(y=55,$=55,S=55),c){const t=b(c);t&&(y=t.r,$=t.g,S=t.b)}let C=212,E=255,T=0;const A=b(m);A&&(C=A.r,E=A.g,T=A.b);const I=n*h,R=[];for(let t=0;t<f;t++){const e=w(17*t,31*t+7),o=w(23*t+5,11*t);R.push({fx:.8+2.2*e,fy:1.2+1.8*o,phase:e*Math.PI*4,dt:(.3+.5*w(7*t,13*t+3))*(t%2==0?1:-1),amp:.55+.45*w(29*t,3*t)})}for(let e=0;e<v;e++){const o=e/v;for(let n=0;n<x;n++){const a=n/x,i=a-r.x,c=o-r.y,l=Math.sqrt(i*i+c*c),h=g*Math.exp(-l*l/.06),m=a+i*h,b=o+c*h;let v=0,w=0;for(let t=0;t<f;t++){const{fx:e,fy:o,phase:n,dt:r,amp:a}=R[t];v+=Math.sin(m*e*Math.PI*2+I*r+n)*Math.cos(b*o*Math.PI*2+I*r*.7+1.3*n)*a,w+=a}const A=v/w,k=.5+.5*Math.tanh(A*d*2.2);if(k<.12)continue;const B=(k-.12)/.88,F=s[Math.min(s.length-1,Math.floor(B*s.length))],P=k>.82,z=u?.82*k:.14*k;t.fillStyle=P?`rgba(${C},${E},${T},${u?.92:.32})`:`rgba(${y},${$},${S},${z})`,t.fillText(F,n*M,e*p)}}}function O(t,e,o,n,r={}){const{fontSize:a=13,color:i,accentColor:s,speed:c=.4,layers:l=4,turbulence:h=.8,lightMode:f=!1}=r,d=s??(f?"#6b8700":"#d4ff00"),g=.62*a,u=1.4*a,m=Math.ceil(e/g),M=Math.ceil(o/u);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let p=255,x=255,v=255;if(f&&(p=55,x=55,v=55),i){const t=b(i);t&&(p=t.r,x=t.g,v=t.b)}let y=212,$=255,S=0;const C=b(d);C&&(y=C.r,$=C.g,S=C.b);const E=n*c,T=["─","─","╌","·","╌","─","─","╌","·"];for(let e=0;e<M;e++){const o=e/M;for(let n=0;n<m;n++){const r=n/m;let a=0,i=0;for(let t=0;t<l;t++){const e=w(13*t,7*t+3),n=1.1+2.4*e,s=.9+2*w(29*t,11*t+1),c=e*Math.PI*6,l=(.2+.5*w(41*t,17*t))*(t%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),g=Math.sin(r*s*Math.PI*h+o*n*Math.PI*h+E*l*.4);a+=Math.atan2(d+.3*g,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=T[Math.floor(d*T.length)%T.length],b=c>.8,C=f?.8*c:.13*c;t.fillStyle=b?`rgba(${y},${$},${S},${f?.9:.26})`:`rgba(${p},${x},${v},${C})`,t.fillText(M,n*g,e*u)}}}function Y(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=13,chars:s=" ·:;=+*#%@",color:c,accentColor:l,speed:h=1,radius:f=.38,swirl:d=3,lightMode:g=!1}=a,u=l??(g?"#6b8700":"#d4ff00"),m=.62*i,M=1.4*i,p=Math.ceil(e/m),x=Math.ceil(o/M),v=e/o;t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let y=255,$=255,S=255;if(g&&(y=55,$=55,S=55),c){const t=b(c);t&&(y=t.r,$=t.g,S=t.b)}let C=212,E=255,T=0;const A=b(u);A&&(C=A.r,E=A.g,T=A.b);const I=n*h;for(let e=0;e<x;e++){const o=e/x;for(let n=0;n<p;n++){const a=(n/p-r.x)*v,i=o-r.y,c=Math.sqrt(a*a+i*i)/f;if(c>1){const o=w(3*n,7*e)*Math.max(0,1-3*(c-1));if(o<.62)continue;const r=o*(g?.28:.04);t.fillStyle=`rgba(${y},${$},${S},${r})`,t.fillText(s[1],n*m,e*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)),b=s[Math.min(s.length-1,u)],x=l>.35||c<.08,A=g?.85*d:.18*d;t.fillStyle=x?`rgba(${C},${E},${T},${g?.95:.38})`:`rgba(${y},${$},${S},${A})`,t.fillText(b,n*m,e*M)}}}function U(t,e,o,n,r={}){const{fontSize:a=14,chars:i=" ·∙•:-=+*#",color:s,accentColor:c,speed:l=.5,harmonics:h=3,lightMode:f=!1}=r,d=c??(f?"#6b8700":"#d4ff00"),g=.62*a,u=1.4*a,m=Math.ceil(e/g),M=Math.ceil(o/u);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let p=255,x=255,v=255;if(f&&(p=55,x=55,v=55),s){const t=b(s);t&&(p=t.r,x=t.g,v=t.b)}let y=212,$=255,S=0;const C=b(d);C&&(y=C.r,$=C.g,S=C.b);const E=n*l,T=Array.from({length:h},(t,e)=>1/(e+1)).reduce((t,e)=>t+e,0);for(let e=0;e<M;e++)for(let o=0;o<m;o++){let n=0;for(let t=0;t<h;t++){const r=.18+1.4*w(o*(t+3)+7,e*(t+5)+11),a=w(o*(t+7),e*(t+9)+3)*Math.PI*2,i=1/(t+1);n+=Math.sin(E*r+a)*i}const r=.5*(n/T+1);if(r<.28)continue;const a=(r-.28)/.72,s=i[Math.min(i.length-1,Math.floor(a*i.length))],c=r>.88,l=f?.82*a:.13*a;t.fillStyle=c?`rgba(${y},${$},${S},${f?.92:.28})`:`rgba(${p},${x},${v},${l})`,t.fillText(s,o*g,e*u)}}function D(t,e,o,n,r={}){const{fontSize:a=13,chars:i=" .,:;i+xX#&@",color:s="#ff4500",hotColor:c="#ffe066",intensity:l=.85,wind:h=0,speed:f=1,lightMode:d=!1}=r,g=.62*a,u=1.4*a,m=Math.ceil(e/g),M=Math.ceil(o/u),p=m*M,x="__fire_heat__",v=t.canvas;let w=v[x];w&&w.length===p||(w=new Float32Array(p),v[x]=w);const y=.18*(.016*f),$=h*f*.8,S=M-1,C=n*f;for(let t=0;t<m;t++){const e=(.6*(.5*Math.sin(.31*t+4.1*C)+.5)+.4*(.5*Math.sin(.73*t-2.7*C)+.5))*l;w[S*m+t]=Math.min(1,e+.15*Math.random()*l),S>0&&(w[(S-1)*m+t]=Math.min(1,.85*e+.1*Math.random()*l))}const E=new Float32Array(p);for(let t=0;t<M-2;t++)for(let e=0;e<m;e++){const o=.4*w[(t+1)*m+e]+.25*w[(t+2)*m+Math.max(0,Math.min(m-1,e+Math.round($)))]+.175*w[(t+1)*m+Math.max(0,e-1)]+.175*w[(t+1)*m+Math.min(m-1,e+1)];E[t*m+e]=Math.max(0,o-y-.02*Math.random()*f)}for(let t=0;t<m;t++)E[(M-1)*m+t]=w[(M-1)*m+t],M>1&&(E[(M-2)*m+t]=w[(M-2)*m+t]);v[x]=E;const T=b(s)??{r:255,g:69,b:0},A=b(c)??{r:255,g:224,b:102};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";for(let e=0;e<M;e++)for(let o=0;o<m;o++){const n=E[e*m+o];if(n<.03)continue;const r=i[Math.min(i.length-1,Math.floor(n*i.length))];if(" "===r)continue;const a=Math.min(1,1.2*n),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);t.globalAlpha=h,t.fillStyle=`rgb(${s},${c},${l})`,t.fillText(r,o*g,e*u)}t.globalAlpha=1}function _(t,e,o,n,r={}){const{fontSize:a=13,baseChars:i="ATCG",bridgeChars:s="-=≡",color:c="#00e5ff",color2:l="#ff4081",bridgeColor:h="#88ffcc",speed:f=1,helixCount:d,lightMode:g=!1}=r,u=.62*a,m=1.4*a,M=Math.ceil(e/u),p=Math.ceil(o/m),x=d??Math.max(1,Math.floor(e/80)),v=M/x,y=b(c)??{r:0,g:229,b:255},$=b(l)??{r:255,g:64,b:129},S=b(h)??{r:136,g:255,b:204};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const C=n*f,E=.35*v;for(let e=0;e<x;e++){const o=v*(e+.5);for(let n=0;n<p;n++){const r=n/p*Math.PI*6-1.8*C,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=w(31*e+7*n,3),d=i[Math.floor(f*i.length)],g=.5*(Math.sin(r)+1),b=.5*(Math.sin(r+Math.PI)+1);if(t.globalAlpha=.35+.65*g,t.fillStyle=`rgb(${y.r},${y.g},${y.b})`,t.fillText(d,l*u,n*m),h>=0&&h<M){const o=w(53*e+11*n,7),r=i[Math.floor(o*i.length)];t.globalAlpha=.35+.65*b,t.fillStyle=`rgb(${$.r},${$.g},${$.b})`,t.fillText(r,h*u,n*m)}if(n%3===0){const o=Math.min(l,h),r=Math.max(l,h);if(r-o>1){const a=w(17*n+43*e,5),i=s[Math.floor(a*s.length)],c=.25*(g+b)+.2;t.globalAlpha=c,t.fillStyle=`rgb(${S.r},${S.g},${S.b})`;for(let e=o+1;e<r;e++)t.fillText(i,e*u,n*m)}}}}t.globalAlpha=1}function V(t,e,o,n,r={}){const{fontSize:a=13,chars:i=" .,:;+*#@",color:s="#4caf50",skyColor:c="#1a237e",peakColor:l="#e0e0e0",speed:h=1,roughness:f=.55,heightScale:d=.55,stars:g=!0,lightMode:u=!1}=r,m=.62*a,M=1.4*a,p=Math.ceil(e/m),x=Math.ceil(o/M),v=b(s)??{r:76,g:175,b:80},y=b(c)??{r:26,g:35,b:126},S=b(l)??{r:224,g:224,b:224};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const C=n*h*.4,E=new Array(p);for(let t=0;t<p;t++){const e=(.5*$((t/p+C)*f*3,.5)+.5)*d;E[t]=Math.floor(e*x)}for(let e=0;e<x;e++)for(let o=0;o<p;o++){const r=x-1-E[o],a=e===r;if(!(e>=r)){if(g){const r=w(7*o+Math.floor(.3*C),13*e);if(r>.97){const a=.3*Math.sin(2*n+100*r)+.7;t.globalAlpha=.5*a,t.fillStyle=`rgb(${y.r+60},${y.g+60},${y.b+80})`,t.fillText("·",o*m,e*M)}}continue}const s=(e-r)/Math.max(1,E[o]),c=i[Math.min(i.length-1,Math.floor(s*i.length))];if(" "===c&&!a)continue;const l=a?1:Math.max(0,1-4*s),h=v.r+(S.r-v.r)*l|0,f=v.g+(S.g-v.g)*l|0,d=v.b+(S.b-v.b)*l|0;t.globalAlpha=.5+.5*s,t.fillStyle=`rgb(${h},${f},${d})`,t.fillText(a?i[i.length-1]:c,o*m,e*M)}t.globalAlpha=1}var N=1,X=2,G=4,J=8,K={3:"─",12:"│",9:"┌",10:"┐",5:"└",6:"┘",11:"┬",7:"┴",13:"├",14:"┤",15:"┼",[N]:"╶",[X]:"╴",[G]:"╵",[J]:"╷"};function Q(t,e,o,n,r={}){const{fontSize:a=13,pulseColor:i="#ffffff",color:s="#00ff88",density:c=.38,speed:l=1,lightMode:h=!1}=r,f=.62*a,d=1.4*a,g=Math.ceil(e/f),u=Math.ceil(o/d),m=b(s)??{r:0,g:255,b:136},M=b(i)??{r:255,g:255,b:255},p=(t,e)=>{if(w(17*t+1,7*e+2)>c)return 0;let o=0;return t+1<g&&w(17*t+1,7*e+2)>.15&&(o|=1),t-1>=0&&w(17*(t-1)+1,7*e+2)>.15&&(o|=2),e+1<u&&w(17*t+1,7*(e+1)+2)>.15&&(o|=8),e-1>=0&&w(17*t+1,7*(e-1)+2)>.15&&(o|=4),o};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const x=n*l;for(let e=0;e<u;e++)for(let o=0;o<g;o++){const n=p(o,e);if(0===n)continue;const r=K[n]??"·",a=(8*x+40*w(o,23*e))%g,i=(6*x+40*w(17*e,11*o))%u,s=(1&n||2&n)&&Math.abs(o-a)<1.5,c=(4&n||8&n)&&Math.abs(e-i)<1.5,l=s||c,h=.25+.35*w(3*o,5*e);l?(t.globalAlpha=.95,t.fillStyle=`rgb(${M.r},${M.g},${M.b})`):(t.globalAlpha=h,t.fillStyle=`rgb(${m.r},${m.g},${m.b})`),t.fillText(r,o*f,e*d)}t.globalAlpha=1}function Z(t,e={}){const{type:o="wave",opacity:n=.2,className:r,zIndex:a=0,colorScheme:i="auto",color:s,...c}=e,l="string"==typeof t?document.querySelector(t):t;if(!l)return console.warn("[asciify] asciiBackground: target not found",t),{destroy:()=>{}};const h=l.style.position;"static"===getComputedStyle(l).position&&(l.style.position="relative");const f=document.createElement("canvas");f.style.cssText=["position:absolute","inset:0","width:100%","height:100%",`opacity:${n}`,"pointer-events:none",`z-index:${a}`].join(";"),r&&(f.className=r),l.prepend(f);const d=f.getContext("2d"),g=window.devicePixelRatio||1,u={x:.5,y:.5},m={x:.5,y:.5},M=window.matchMedia("(prefers-color-scheme: light)"),p=()=>"light"===i||"dark"!==i&&M.matches,b=s?function(t){const e=t.match(/^#([0-9a-f]{3,8})$/i)?.[1];if(e){const t=e.length<=4?e.split("").map(t=>parseInt(t+t,16)):[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)];return{r:t[0],g:t[1],b:t[2]}}const o=t.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i);return o?{r:+o[1],g:+o[2],b:+o[3]}:null}(s):null,x=()=>({...c,lightMode:void 0!==c.lightMode?c.lightMode:p(),baseColor:b?`rgba(${b.r},${b.g},${b.b},{a})`:c.baseColor}),v={current:x()},w=()=>{v.current="rain"===o||"stars"===o||"pulse"===o||"noise"===o||"grid"===o||"aurora"===o||"silk"===o||"void"===o||"morph"===o?{...c,lightMode:void 0!==c.lightMode?c.lightMode:p(),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:p()}:x()};w();const y=()=>{w()};"auto"===i&&M.addEventListener("change",y);const $=()=>{const t=l.getBoundingClientRect();f.width=t.width*g,f.height=t.height*g,d.setTransform(g,0,0,g,0,0)};$();const C=t=>{const e=l.getBoundingClientRect();u.x=(t.clientX-e.left)/e.width,u.y=(t.clientY-e.top)/e.height},E=new ResizeObserver($);E.observe(l),window.addEventListener("mousemove",C);let T=0,A=0;const I=()=>{m.x+=.07*(u.x-m.x),m.y+=.07*(u.y-m.y);const t=l.getBoundingClientRect();"rain"===o?z(d,t.width,t.height,T,v.current):"stars"===o?q(d,t.width,t.height,T,m,v.current):"pulse"===o?L(d,t.width,t.height,T,m,v.current):"noise"===o?H(d,t.width,t.height,T,m,v.current):"grid"===o?W(d,t.width,t.height,T,m,v.current):"aurora"===o?j(d,t.width,t.height,T,m,v.current):"silk"===o?O(d,t.width,t.height,T,v.current):"void"===o?Y(d,t.width,t.height,T,m,v.current):"morph"===o?U(d,t.width,t.height,T,v.current):"fire"===o?D(d,t.width,t.height,T,v.current):"dna"===o?_(d,t.width,t.height,T,v.current):"terrain"===o?V(d,t.width,t.height,T,v.current):"circuit"===o?Q(d,t.width,t.height,T,v.current):S(d,t.width,t.height,T,m,v.current),T+=.016,A=requestAnimationFrame(I)};return A=requestAnimationFrame(I),{destroy:()=>{cancelAnimationFrame(A),E.disconnect(),"auto"===i&&M.removeEventListener("change",y),window.removeEventListener("mousemove",C),f.remove(),l.style.position=h}}}var tt=Z;function et(t,e,o,n="#505050",r=100){if(!t||e<=0||o<=0)return[];const a=b(n)??{r:80,g:80,b:80},i=t,s=i.length;return Array.from({length:o},(t,o)=>Array.from({length:e},(t,n)=>({char:i[(o*e+n)%s],r:a.r,g:a.g,b:a.b,a:r})))}function ot(t,{format:e="png",quality:o=.92,scale:n=1}={}){return new Promise((r,a)=>{let i=t;if(1!==n){const e=document.createElement("canvas");e.width=Math.round(t.width*n),e.height=Math.round(t.height*n);const o=e.getContext("2d");if(!o)return void a(new Error("captureSnapshot: could not get 2d context"));o.drawImage(t,0,0,e.width,e.height),i=e}i.toBlob(t=>t?r(t):a(new Error("captureSnapshot: toBlob returned null")),`image/${e}`,o)})}exports.ART_STYLE_PRESETS=n,exports.BACKGROUND_TYPES=["wave","rain","stars","pulse","noise","grid","aurora","silk","void","morph","fire","dna","terrain","circuit"],exports.CHARSETS=e,exports.CHARSET_SEQUENCES=o,exports.DEFAULT_OPTIONS=r,exports.HOVER_PRESETS={none:{label:"Off",options:{hoverStrength:0,hoverEffect:"spotlight",hoverRadius:.2,hoverColor:"#ffffff"}},subtle:{label:"Subtle",options:{hoverStrength:.25,hoverEffect:"glow",hoverRadius:.12,hoverColor:"#ffffff"}},flashlight:{label:"Flashlight",options:{hoverStrength:.6,hoverEffect:"spotlight",hoverRadius:.15,hoverColor:"#fffbe6"}},magnifier:{label:"Magnifier",options:{hoverStrength:.7,hoverEffect:"magnify",hoverRadius:.12,hoverColor:"#ffffff"}},forceField:{label:"Force Field",options:{hoverStrength:.7,hoverEffect:"repel",hoverRadius:.15,hoverColor:"#a0e8ff"}},neon:{label:"Neon",options:{hoverStrength:.6,hoverEffect:"colorShift",hoverRadius:.15,hoverColor:"#d946ef"}},fire:{label:"Fire",options:{hoverStrength:.7,hoverEffect:"spotlight",hoverRadius:.15,hoverColor:"#ff6b2b"}},ice:{label:"Ice",options:{hoverStrength:.5,hoverEffect:"glow",hoverRadius:.15,hoverColor:"#60d5f7"}},gravity:{label:"Gravity",options:{hoverStrength:.7,hoverEffect:"attract",hoverRadius:.18,hoverColor:"#a5d6ff"}},shatter:{label:"Shatter",options:{hoverStrength:.8,hoverEffect:"shatter",hoverRadius:.14,hoverColor:"#ff6090"}},ghost:{label:"Ghost",options:{hoverStrength:.55,hoverEffect:"trail",hoverRadius:.2,hoverColor:"#b39ddb"}},glitchReveal:{label:"Glitch Reveal",options:{hoverStrength:.8,hoverEffect:"glitchText",hoverRadius:.18,hoverColor:"#a3e635"}}},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=Z,exports.asciiText=function(t,e={},o,n){const a={...r,...e},{frame:i,cols:s}=A(t,a,o,n);if(!i.length||0===s)return"";const c=[];for(const t of i)c.push(t.map(t=>t.char).join(""));return c.join("\n")},exports.asciiTextAnsi=function(t,e={},o,n){const a={...r,...e},{frame:i,cols:s}=A(t,a,o,n);if(!i.length||0===s)return"";const c=[];for(const t of i){let e="";for(const o of t)" "===o.char||o.a<10?e+=" ":e+=`[38;2;${o.r};${o.g};${o.b}m${o.char}`;c.push(e)}return c.join("\n")},exports.asciify=async function(t,e,{fontSize:o,artStyle:a="classic",options:i={}}={}){let s;if("string"==typeof t){const e=new Image;e.crossOrigin="anonymous",await new Promise((o,n)=>{e.onload=()=>o(),e.onerror=()=>n(new Error(`Failed to load image: ${t}`)),e.src=t}),s=e}else t instanceof HTMLImageElement&&!t.complete?(await new Promise((e,o)=>{t.onload=()=>e(),t.onerror=()=>o(new Error("Image failed to load"))}),s=t):s=t;const c=n[a],l=o??i.fontSize??10,h={...r,...c,...i,fontSize:l},f=e.getContext("2d");if(!f)throw new Error("Could not get 2d context from canvas");const{w:d,h:g}=function(t){return t instanceof HTMLVideoElement?{w:t.videoWidth,h:t.videoHeight}:t instanceof HTMLImageElement?{w:t.naturalWidth||t.width,h:t.naturalHeight||t.height}:{w:t.width,h:t.height}}(s),{renderW:u,renderH:m}=B(d,g),M="undefined"!=typeof window&&window.devicePixelRatio||1,p=8e6,b=u*M*m*M>p?Math.sqrt(p/(u*m)):M;(e.width<u||e.height<m)&&(e.width=Math.round(u*b),e.height=Math.round(m*b));const{frame:x}=A(s,h,u,m);if(h.hoverStrength>0){let t=null,o=!1,n=0;const r=o=>{const n=e.getBoundingClientRect();t={x:(o.clientX-n.left)/n.width,y:(o.clientY-n.top)/n.height}},a=()=>{t=null};e.addEventListener("mousemove",r),e.addEventListener("mouseleave",a);const i=e=>{o||(f.save(),f.setTransform(b,0,0,b,0,0),k(f,x,h,u,m,e/1e3,t),f.restore(),n=requestAnimationFrame(i))};return n=requestAnimationFrame(i),()=>{o=!0,cancelAnimationFrame(n),e.removeEventListener("mousemove",r),e.removeEventListener("mouseleave",a)}}f.save(),f.setTransform(b,0,0,b,0,0),k(f,x,h,u,m),f.restore()},exports.asciifyGif=async function(t,e,{fontSize:o,artStyle:a="classic",options:i={}}={}){const s="string"==typeof t?await fetch(t).then(t=>t.arrayBuffer()):t,c=o??i.fontSize??10,l={...r,...n[a],...i,fontSize:c},h=e.getContext("2d");if(!h)throw new Error("Could not get 2d context from canvas");const{frames:f,fps:d}=await R(s,l,e.width,e.height);let g,u=!1,m=0,M=performance.now();const p=1e3/d,b=t=>{u||(t-M>=p&&(k(h,f[m],l,e.width,e.height),m=(m+1)%f.length,M=t),g=requestAnimationFrame(b))};return g=requestAnimationFrame(b),()=>{u=!0,cancelAnimationFrame(g)}},exports.asciifyLiveVideo=function(t,e,o){return P(t,e,o)},exports.asciifyVideo=P,exports.asciifyWebcam=async function(t,{fontSize:e=10,style:o="classic",options:a={},liveOptions:i,mirror:s=!0,constraints:c={facingMode:"user"},dpr:l}={}){if(!navigator.mediaDevices?.getUserMedia)throw new Error("asciifyWebcam: getUserMedia is not supported in this browser.");const h=await navigator.mediaDevices.getUserMedia({video:c}),f=document.createElement("video");f.srcObject=h,f.muted=!0,f.playsInline=!0,await new Promise((t,e)=>{f.onloadedmetadata=()=>t(),f.onerror=()=>e(new Error("asciifyWebcam: video stream failed to load.")),f.play().catch(e)});const d={...r,...n[o],...a,fontSize:e},g=t.getContext("2d");if(!g)throw new Error("asciifyWebcam: could not get 2d context from canvas.");const u=l??("undefined"!=typeof window?window.devicePixelRatio:1)??1;1!==u&&g.scale(u,u);let m=null;const M={x:.5,y:.5,intensity:0},p=e=>{const o=t.getBoundingClientRect();m={x:(e.clientX-o.left)/o.width,y:(e.clientY-o.top)/o.height}},b=()=>{m=null};d.hoverStrength>0&&(t.addEventListener("mousemove",p),t.addEventListener("mouseleave",b));let x,v=!1;const w=performance.now(),y=e=>{if(!v){if(f.readyState>=f.HAVE_CURRENT_DATA){const o=t.width/u,n=t.height/u,r=(e-w)/1e3,a=i?{...d,...i()}:d;a.hoverStrength>0?(t.addEventListener("mousemove",p),t.addEventListener("mouseleave",b)):(t.removeEventListener("mousemove",p),t.removeEventListener("mouseleave",b));const{frame:c}=A(f,a,o,n);if(m){const t=m.x-M.x,e=m.y-M.y,o=Math.sqrt(t*t+e*e),n=Math.min(.25,.06+.8*o);M.x+=t*n,M.y+=e*n,M.intensity+=.12*(1-M.intensity)}else M.intensity*=.965,M.intensity<.003&&(M.intensity=0);const l=M.intensity>.003?{x:M.x,y:M.y,intensity:M.intensity}:null;s?(g.save(),g.scale(-1,1),g.translate(-o,0),k(g,c,a,o,n,r,l),g.restore()):k(g,c,a,o,n,r,l)}x=requestAnimationFrame(y)}};return x=requestAnimationFrame(y),()=>{v=!0,cancelAnimationFrame(x),t.removeEventListener("mousemove",p),t.removeEventListener("mouseleave",b),h.getTracks().forEach(t=>t.stop()),f.srcObject=null}},exports.buildTextFrame=et,exports.captureSnapshot=ot,exports.gifToAsciiFrames=R,exports.imageToAsciiFrame=A,exports.mountWaveBackground=tt,exports.renderAuroraBackground=j,exports.renderCircuitBackground=Q,exports.renderDnaBackground=_,exports.renderFireBackground=D,exports.renderFrameToCanvas=k,exports.renderGridBackground=W,exports.renderMorphBackground=U,exports.renderNoiseBackground=H,exports.renderPulseBackground=L,exports.renderRainBackground=z,exports.renderSilkBackground=O,exports.renderStarsBackground=q,exports.renderTerrainBackground=V,exports.renderTextBackground=function(t,e,o,n,a={},i){const{fontSize:s=10,lineHeight:c=1.6,color:l="#505050",opacity:h=100,hoverEffect:f="spotlight",hoverStrength:d=.85,hoverRadius:g=.18,hoverColor:u="#d4ff00"}=a;k(t,et(n,Math.max(1,Math.floor(e/s)),Math.max(1,Math.floor(o/(s*c))),l,h),{...r,hoverEffect:f,hoverStrength:d,hoverRadius:g,hoverColor:u},e,o,0,i??null)},exports.renderVoidBackground=Y,exports.renderWaveBackground=S,exports.snapshotAndDownload=async function(t,e={}){const{filename:o="asciify-snapshot",format:n="png",...r}=e,a=await ot(t,{format:n,...r}),i="jpeg"===n?"jpg":n,s=document.createElement("a");s.href=URL.createObjectURL(a),s.download=`${o}.${i}`,s.click(),setTimeout(()=>URL.revokeObjectURL(s.href),1e4)},exports.videoToAsciiFrames=I;//# sourceMappingURL=index.cjs.map
1
+ "use strict";var t=require("gifuct-js"),e={standard:" .:-=+*#%@",blocks:" ░▒▓█",minimal:" .:+",dense:" .'`^\",:;Il!i><~+_-?][}{1)(|/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$",binary:"01",dots:" ⠁⠃⠇⡇⣇⣧⣷⣿",letters:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",claudeCode:" ╔╗╚╝║═╠╣╦╩╬░▒▓█│─┌┐└┘├┤┬┴┼",box:" ▪◾◼■█",lines:" ˗‐–—―━",braille:" ⠁⠂⠃⠄⠅⠆⠇⠈⠉⠊⠋⠌⠍⠎⠏⠐⠑⠒⠓⠔⠕⠖⠗⠘⠙⠚⠛⠜⠝⠞⠟⠠⠡⠢⠣⠤⠥⠦⠧⠨⠩⠪⠫⠬⠭⠮⠯⠰⠱⠲⠳⠴⠵⠶⠷⠸⠹⠺⠻⠼⠽⠾⠿⡀⡁⡂⡃⡄⡅⡆⡇⣀⣁⣂⣃⣄⣅⣆⣇⣈⣉⣊⣋⣌⣍⣎⣏⣐⣑⣒⣓⣔⣕⣖⣗⣘⣙⣚⣛⣜⣝⣞⣟⣠⣡⣢⣣⣤⣥⣦⣧⣨⣩⣪⣫⣬⣭⣮⣯⣰⣱⣲⣳⣴⣵⣶⣷⣸⣹⣺⣻⣼⣽⣾⣿",katakana:" ヲァィゥェォャュョッアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン",musical:" ♩♪♫♬♭♮♯",emoji:" ⬛🟫🟥🟧🟨🟩🟦🟪⬜",circles:" .·:∘○◦°•∙",shadows:" ·∘◦○◎⊙●◉",starfield:" ˙·∘∗✦✧★◆●",geometric:" ·△▷◇◈◆▣■█",pipes:" ╶─┐└├┤┬┴┼╬▒▓█",waves:" ˜∼≈〰≋∿∾∭∫",shards:" ╱╲╳◤◥◣◢△▲◆◼█",smoke:" ·˙⁚⁖∶∷⋮⋰⋱∴∵"},o={cosmic:[e.starfield,e.circles,e.shadows],rain:[e.katakana,e.braille,e.binary],terminal:[e.pipes,e.claudeCode,e.standard],crystal:[e.shards,e.geometric,e.blocks],fluid:[e.waves,e.smoke,e.circles],pulse:[e.dense,e.standard,e.blocks],dream:[e.braille,e.shadows,e.smoke],angular:[e.geometric,e.shards,e.starfield]},n={classic:{renderMode:"ascii",charset:e.standard,colorMode:"grayscale"},particles:{renderMode:"dots",colorMode:"fullcolor",dotSizeRatio:.8},letters:{renderMode:"ascii",charset:e.letters,colorMode:"fullcolor"},claudeCode:{renderMode:"ascii",charset:e.claudeCode,colorMode:"accent",accentColor:"#f97316"},art:{renderMode:"ascii",charset:e.dense,colorMode:"fullcolor"},terminal:{renderMode:"ascii",charset:e.standard,colorMode:"matrix"},box:{renderMode:"ascii",charset:e.box,colorMode:"grayscale"},lines:{renderMode:"ascii",charset:e.lines,colorMode:"fullcolor"},braille:{renderMode:"ascii",charset:e.braille,colorMode:"fullcolor"},katakana:{renderMode:"ascii",charset:e.katakana,colorMode:"matrix"},musical:{renderMode:"ascii",charset:e.musical,colorMode:"accent",accentColor:"#e040fb"},emoji:{renderMode:"ascii",charset:e.emoji,colorMode:"fullcolor"},circles:{renderMode:"ascii",charset:e.circles,colorMode:"accent",accentColor:"#d4ff00"},shadows:{renderMode:"ascii",charset:e.shadows,colorMode:"accent",accentColor:"#50a0ff"},starfield:{renderMode:"ascii",charset:e.starfield,colorMode:"fullcolor"},geometric:{renderMode:"ascii",charset:e.geometric,colorMode:"grayscale"},pipes:{renderMode:"ascii",charset:e.pipes,colorMode:"accent",accentColor:"#00ff88"},waves:{renderMode:"ascii",charset:e.waves,colorMode:"fullcolor"},shards:{renderMode:"ascii",charset:e.shards,colorMode:"grayscale"},smoke:{renderMode:"ascii",charset:e.smoke,colorMode:"accent",accentColor:"#c850ff"}},r={fontSize:10,charSpacing:1,brightness:0,contrast:0,charset:e.standard,colorMode:"grayscale",accentColor:"#d4ff00",invert:!1,renderMode:"ascii",animationStyle:"none",animationSpeed:1,dotSizeRatio:.8,ditherStrength:0,charAspect:.55,normalize:!1,hoverStrength:0,hoverRadius:.2,hoverEffect:"spotlight",hoverColor:"#ffffff",hoverShape:"circle",hoverText:"ASCIIFY",artStyle:"classic",customText:"",chromaKey:null,chromaKeyTolerance:60};function a(t,e,o){let n=t+255*e;return n=259*(255*o+255)/(255*(259-255*o))*(n-128)+128,Math.max(0,Math.min(255,n))}function i(t,e,o){const n=o?1-t/255:t/255,r=[...e],a=Math.floor(n*(r.length-1));return r[Math.max(0,Math.min(r.length-1,a))]}function s(t,e,o,n,r,a){if((a?1-t/255:t/255)<.12)return" ";const i=[...e];return i[(n*r+o)%i.length]}var c=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];function l(t,e,o,n){if(n<=0)return t;const r=(c[o%4][e%4]/16-.5)*n*128;return Math.max(0,Math.min(255,t+r))}var h=new Array(256),f=new Array(256);for(let t=0;t<256;t++)h[t]=`rgb(${t},${t},${t})`,f[t]=`rgb(0,${t},0)`;function d(t,e,o,n,r,a=!1){switch(e){case"fullcolor":return`rgb(${t.r},${t.g},${t.b})`;case"matrix":return f[.299*t.r+.587*t.g+.114*t.b|0];case"accent":return`rgb(${o},${n},${r})`;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;return h[e]}}}var g=[0,0,0];function u(t,e,o,n,r,a=!1){switch(e){case"fullcolor":g[0]=t.r,g[1]=t.g,g[2]=t.b;break;case"matrix":{const e=.299*t.r+.587*t.g+.114*t.b|0;g[0]=0,g[1]=e,g[2]=0;break}case"accent":g[0]=o,g[1]=n,g[2]=r;break;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;g[0]=e,g[1]=e,g[2]=e;break}}return g}function m(t,e,o,n,r,a,i){if("none"===a)return 1;const s=r*i;switch(a){case"wave":return.3+.7*(.6*(.5*Math.sin(t/o*Math.PI*4+3*s)+.5)+.4*(.5*Math.sin(e/n*Math.PI*3+2*s)+.5));case"pulse":{const r=o/2,a=n/2,i=Math.sqrt((t-r)**2+(e-a)**2),c=Math.sqrt(r**2+a**2);return.2+.8*(.5*Math.sin(i/c*Math.PI*6-4*s)+.5)}case"rain":return.1+.9*(.5*Math.sin(e/n*Math.PI*8-5*s+.3*t)+.5)*(.3*Math.sin(t/o*Math.PI*2+s)+.7);case"breathe":{const o=.3*Math.sin(2*s)+.7,n=.1*Math.sin(.1*(t+e)+s);return Math.max(.1,Math.min(1,o+n))}case"sparkle":{const o=43758.5453*Math.sin(127.1*t+311.7*e+43758.5453*Math.floor(8*s)),n=o-Math.floor(o);return n>.7?1:.15+.4*n}case"glitch":{const t=Math.floor(e/(.05*n)),o=43758.5453*Math.sin(43.23*t+17.89*Math.floor(6*s));if(o-Math.floor(o)>.85){const e=.5*Math.sin(30*s+t)+.5;return e<.3?0:e}return 1}case"spiral":{const r=o/2,a=n/2,i=t-r,c=e-a,l=Math.atan2(c,i),h=Math.sqrt(i*i+c*c),f=Math.sqrt(r*r+a*a);return.15+.85*(.5*Math.sin(3*l+h/f*Math.PI*8-3*s)+.5)}case"typewriter":{const r=o*n,a=e*o+t-.5*s%1*r*1.3;if(a>0)return 0;const i=Math.max(0,1+a/(.15*r));return Math.min(1,i)}case"scatter":{const r=o/2,a=n/2,i=t-r,c=e-a,l=Math.sqrt(i*i+c*c)/Math.sqrt(r*r+a*a),h=.5*Math.sin(1.5*s)+.5;return l>h?Math.max(0,1-3*(l-h)):.7+.3*Math.sin(10*l-2*s)}case"waveField":default:return 1;case"ripple":{const r=o/2,a=n/2,i=t-r,c=e-a,l=Math.sqrt(i*i+c*c),h=Math.sqrt(r*r+a*a);return.1+.9*(.5*Math.sin(l/h*Math.PI*10-5*s)+.5)*(.4+.6*(1-Math.min(1,l/(1.1*h))))}case"melt":{const o=e/n*Math.PI;return.05+(.5*Math.sin(o-1.8*s+.15*t)+.5)*(1-.6*(Math.max(0,e/n-.1)/.9))*.95}case"orbit":{const r=o/2,a=n/2,i=t-r,c=e-a,l=Math.atan2(c,i),h=Math.sqrt(i*i+c*c)/Math.sqrt(r*r+a*a);return.1+.9*(.5*Math.sin(2*l+6*h-2.5*s)+.5)}case"cellular":{const o=Math.floor(4*s),n=(t,e)=>{const n=43758.5453*Math.sin(127.1*t+311.7*e+43758.5453*o);return n-Math.floor(n)>.38?1:0},r=n(t,e),a=n(t-1,e)+n(t+1,e)+n(t,e-1)+n(t,e+1)+n(t-1,e-1)+n(t+1,e-1)+n(t-1,e+1)+n(t+1,e+1);return 1===(1===r?2===a||3===a?1:0:3===a?1:0)?1:.05}}}var M={scale:1,offsetX:0,offsetY:0,glow:0,colorBlend:0,proximity:0};function p(t,e,o,n,r,a,i,s,c="spotlight",l=.5,h="circle"){const f=t-o,d=e-n,g=.08+.35*l+.04*a;let u,m;if("box"===h){const t=Math.abs(f),e=Math.abs(d);u=Math.max(t,e),m=g}else u=Math.sqrt(f*f+d*d),m=g;if(u>=m)return M.scale=1,M.offsetX=0,M.offsetY=0,M.glow=0,M.colorBlend=0,M.proximity=0,M;const p=function(t){return t*t*(3-2*t)}(1-u/m)*r;let x=1,b=0,v=0,w=0,y=0;switch(c){case"spotlight":{x=1+p*a*1.8;const t=Math.atan2(d,f),e=p*p*a*.6;b=Math.cos(t)*e*i,v=Math.sin(t)*e*s,w=p*a*.4,y=p*p*a*.25;break}case"magnify":x=1+p*a*2.5,w=p*a*.15;break;case"repel":{x=1+p*a*.3;const t=Math.atan2(d,f),e=p*p*a*1.2;b=Math.cos(t)*e*i,v=Math.sin(t)*e*s;break}case"glow":w=p*a*.8,y=p*a*.4;break;case"colorShift":x=1+p*a*.4,w=p*a*.2,y=p*a*.7;break;case"attract":{const t=Math.atan2(d,f),e=p*p*a*1;b=-Math.cos(t)*e*i,v=-Math.sin(t)*e*s,w=p*a*.3;break}case"shatter":{const t=Math.atan2(d,f),e=.5*Math.sin(43.7*f+29.3*d),o=p*a*1.4*(.7+.3*e);b=Math.cos(t+e)*o*i,v=Math.sin(t+e)*o*s,x=Math.max(.1,1-p*a*.6),w=p*a*.25;break}case"trail":y=p*a*.9,w=p*a*.6,x=1+p*a*.15;break;case"glitchText":x=1,w=p*a*.5,y=p*a*.6}return M.scale=x,M.offsetX=b,M.offsetY=v,M.glow=w,M.colorBlend=y,M.proximity=p,M}function x(t){const e=t.match(/^#([0-9a-f]{3,8})$/i)?.[1];if(e){const t=e.length<=4?e.split("").map(t=>parseInt(t+t,16)):[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)];return{r:t[0],g:t[1],b:t[2]}}const o=t.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i);return o?{r:+o[1],g:+o[2],b:+o[3]}:null}function b(t){return t*t*t*(t*(6*t-15)+10)}function v(t,e,o){return t+(e-t)*o}function w(t,e){let o=127*t+311*e;return o^=o>>13,(o*(o*o*15731+789221)+1376312589&2147483647)/2147483647}function y(t,e){const o=Math.floor(t),n=Math.floor(e),r=e-n,a=b(t-o),i=b(r),s=w(o,n),c=w(o+1,n),l=w(o,n+1),h=w(o+1,n+1);return v(v(s,c,a),v(l,h,a),i)}function $(t,e){return(.5*y(t,e)+.25*y(2.1*t,2.1*e)+.125*y(4.3*t,4.3*e))/.875}function S(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=13,charAspect:s=.62,lineHeightRatio:c=1.4,chars:l=" .:-=+*#%@",baseColor:h=null,accentColor:f,accentThreshold:d=.52,mouseInfluence:g=.55,mouseFalloff:u=2.8,speed:m=1,vortex:M=!0,sparkles:p=!0,breathe:x=!0,lightMode:b=!1}=a,v=f??(b?"#6b8700":"#d4ff00"),y=i*s,S=i*c,C=Math.ceil(e/y),E=Math.ceil(o/S),T=r.x,A=r.y;let R=212,I=255,k=0;{const t=v.replace("#","");6===t.length&&(R=parseInt(t.slice(0,2),16),I=parseInt(t.slice(2,4),16),k=parseInt(t.slice(4,6),16))}t.clearRect(0,0,e,o),t.font=`${i}px "JetBrains Mono", monospace`,t.textBaseline="top";const B=n*m,F=x?.12*(.5*Math.sin(.22*B)+.5):0;for(let e=0;e<E;e++)for(let o=0;o<C;o++){const n=o/C,r=e/E,a=.045,i=.08*B,s=.06,c=.45*((.5*Math.sin(.08*o+.05*e+.6*B)+.5+(.5*Math.sin(.03*o-.07*e+.4*B)+.5)+(.5*Math.sin(.05*o+.03*e+.8*B)+.5))/3)+.35*(.5*$(o*a+i,e*a*1.4-.7*i)+.5)+.2*(.5*Math.sin((o+.65*e)*s+1.1*B)+.5)+F,f=n-T,m=r-A,x=Math.sqrt(f*f+m*m);let v=0;if(M&&x<.35){const t=Math.atan2(m,f),e=Math.sin(4*t+2.2*B-14*x),o=Math.max(0,1-x/.35);v=e*o*o*.22}const P=c*(1-g)+(Math.max(0,1-x*u)+.5*v)*g+.15*v,z=Math.min(1,Math.max(0,P));let q=z;if(p&&z>.72){const t=Math.floor(8*B),n=w(7*o+3*t,11*e+t);n>.88&&(q=Math.min(1,z+4*(n-.88)))}const L=Math.floor(q*(l.length-1));if(" "===l[L])continue;const H=.015+.07*q;if(q>d){const e=Math.min(b?.9:.28,H*(b?14:2.8));t.fillStyle=`rgba(${R},${I},${k},${e})`}else t.fillStyle=h?h.replace("{a}",String(H)):b?`rgba(55,55,55,${7*H})`:`rgba(255,255,255,${H})`;t.fillText(l[L],o*y,e*S)}}function C(t){return"auto"!==t?t:"undefined"!=typeof window&&!window.matchMedia("(prefers-color-scheme: dark)").matches}function E(t){const e=t.match(/^#([0-9a-fA-F]{3,6})$/);if(e){let t=e[1];if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return t}const o=t.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);return o?[o[1],o[2],o[3]].map(t=>parseInt(t).toString(16).padStart(2,"0")).join(""):null}function T(t){const e=t||"auto";if("auto"!==e)return e.replace("#","");if("undefined"!=typeof document){const t=getComputedStyle(document.documentElement);for(const e of["--accent-color","--color-accent","--accent","--color-primary","--primary","--brand-color"]){const o=E(t.getPropertyValue(e).trim());if(o)return o}const e=E(getComputedStyle(document.body).accentColor??"");if(e)return e}return"undefined"!=typeof window&&window.matchMedia("(prefers-color-scheme: dark)").matches?"faf9f7":"0d0d0d"}function A(t,e,o,n){const r=t instanceof HTMLVideoElement?t.videoWidth:t.width,c=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(0===r||0===c)return{frame:[],cols:0,rows:0};const h=e.charAspect,f=e.fontSize*e.charSpacing,d=e.fontSize/h*e.charSpacing,g=o||r,u=n||c,m=Math.floor(g/f),M=Math.floor(u/d);if(m<=0||M<=0)return{frame:[],cols:0,rows:0};const p=Math.max(1,Math.min(Math.floor(2048/m),Math.floor(r/m))),x=Math.max(1,Math.min(Math.floor(2048/M),Math.floor(c/M))),b=m*p,v=M*x,{ctx:w}=function(t,e){const o=document.createElement("canvas");o.width=t,o.height=e;const n=o.getContext("2d",{willReadFrequently:!0});return{canvas:o,ctx:n}}(b,v);w.drawImage(t,0,0,b,v);const y=w.getImageData(0,0,b,v).data,$=e.chromaKey,S=null!=$&&!1!==$,E=!0===$,T="blue-screen"===$;let A=null,R=0;!S||E||T||(A=function(t){if("string"!=typeof t)return t;const e=document.createElement("canvas");e.width=1,e.height=1;const o=e.getContext("2d");o.fillStyle=t,o.fillRect(0,0,1,1);const n=o.getImageData(0,0,1,1).data;return{r:n[0],g:n[1],b:n[2]}}($),R=(e.chromaKeyTolerance??60)**2);let I=0,k=255;if(e.normalize){let t=255,e=0;for(let o=0;o<y.length;o+=4){if(S){const t=y[o],e=y[o+1],n=y[o+2];let r=!1;if(E)r=e>1.4*t&&e>1.4*n&&e>80;else if(T)r=n>1.4*t&&n>1.4*e&&n>80;else if(null!==A){const o=t-A.r,a=e-A.g,i=n-A.b;r=o*o+a*a+i*i<=R}if(r)continue}const n=.299*y[o]+.587*y[o+1]+.114*y[o+2];n<t&&(t=n),n>e&&(e=n)}I=t,k=e>t?e-t:255}const B=[],F=C(e.invert),P=S&&e.charset.replace(/ /g,"")||e.charset,z=p*x;for(let t=0;t<M;t++){const o=[];for(let n=0;n<m;n++){let r=0,c=0,h=0,f=0,d=0;for(let e=0;e<x;e++){const o=(t*x+e)*b;for(let t=0;t<p;t++){const e=4*(o+n*p+t),a=y[e],i=y[e+1],s=y[e+2],l=y[e+3];if(S){let t=!1;if(E)t=i>1.4*a&&i>1.4*s&&i>80;else if(T)t=s>1.4*a&&s>1.4*i&&s>80;else if(null!==A){const e=a-A.r,o=i-A.g,n=s-A.b;t=e*e+o*o+n*n<=R}if(t){d++;continue}}r+=a,c+=i,h+=s,f+=l}}if(S&&d>z/2){o.push({char:" ",r:0,g:0,b:0,a:0});continue}const g=z-d,u=g>0?r/g:0,M=g>0?c/g:0,v=g>0?h/g:0,w=g>0?f/g:0,$=.299*u+.587*M+.114*v,C=l(a(e.normalize?($-I)/k*255:$,e.brightness,e.contrast),n,t,e.ditherStrength),B=e.customText?s(C,e.customText,n,t,m,F):i(C,P,F);o.push({char:B,r:u,g:M,b:v,a:w,lum:C})}B.push(o)}return{frame:B,cols:m,rows:M}}async function R(t,e,o,n,r=12,a=10,i,s=0){const c=Math.min(t.duration-s,a),l=Math.ceil(c*r),h=[];let f=0,d=0;for(let a=0;a<l;a++){const g=s+a/r;if(g>s+c)break;t.currentTime=g,await new Promise(e=>{const o=()=>{t.removeEventListener("seeked",o),e()};t.addEventListener("seeked",o)});const u=A(t,e,o,n);h.push(u.frame),f=u.cols,d=u.rows,i?.((a+1)/l)}return{frames:h,cols:f,rows:d,fps:r}}async function I(e,o,n,r,a){const i=t.parseGIF(e),s=t.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 g=d.getContext("2d"),u=document.createElement("canvas");u.width=h,u.height=f;const m=u.getContext("2d"),M=[];let p=0,x=0,b=0;for(const t of s)b+=t.delay||100;const v=b/s.length,w=Math.round(Math.min(30,Math.max(5,1e3/v))),y=Math.min(s.length,300);for(let t=0;t<y;t++){const e=s[t],{dims:i,patch:c,disposalType:l}=e;3===l&&(m.clearRect(0,0,h,f),m.drawImage(d,0,0));const b=new ImageData(new Uint8ClampedArray(c.buffer),i.width,i.height),v=document.createElement("canvas");v.width=i.width,v.height=i.height;v.getContext("2d").putImageData(b,0,0),g.drawImage(v,i.left||0,i.top||0);const w=A(d,o,n,r);M.push(w.frame),p=w.cols,x=w.rows,2===l?g.clearRect(i.left||0,i.top||0,i.width,i.height):3===l&&(g.clearRect(0,0,h,f),g.drawImage(u,0,0)),a?.((t+1)/y)}return{frames:M,cols:p,rows:x,fps:w}}function k(t,e,o,n,r,a=0,s){if("waveField"===o.animationStyle){return void S(t,n,r,a,s?{x:s.x,y:s.y}:{x:.5,y:.5},{accentColor:`#${o.accentColor?T(o.accentColor):"d4ff00"}`,accentThreshold:.52,mouseInfluence:o.hoverStrength>0?Math.min(1,.3+.5*o.hoverStrength):.55,mouseFalloff:2.8,speed:o.animationSpeed,vortex:o.hoverStrength>0,sparkles:!0,breathe:!0})}const c=e.length;if(0===c)return;const l=e[0].length;t.clearRect(0,0,n,r);let h=!1;const f=Math.max(1,c>>2),g=Math.max(1,l>>2);t:for(let t=0;t<c;t+=f){const o=e[t];for(let t=0;t<l;t+=g)if(o[t].a<200){h=!0;break t}}if(!h){const e="undefined"!=typeof window&&window.matchMedia("(prefers-color-scheme: dark)").matches;t.fillStyle=e?"#0a0a0a":"#faf9f7",t.fillRect(0,0,n,r)}const M=n/l,x=r/c,b=c*l,v=s?.intensity??1,w=!("none"!==o.animationStyle&&b>5e3)&&!!(s&&o.hoverStrength>0&&v>.005),y=o.hoverColor||"#ffffff",$=parseInt(y.slice(1,3),16)||255,E=parseInt(y.slice(3,5),16)||255,A=parseInt(y.slice(5,7),16)||255,R=T(o.accentColor),I=parseInt(R.substring(0,2),16)||255,k=parseInt(R.substring(2,4),16)||255,B=parseInt(R.substring(4,6),16)||255,F=b>3e4?.25:b>15e3?.4:b>5e3?.6:1,P=o.hoverRadius*F;let z=0,q=l,L=0,H=c,W=0,j=0;if(w&&s){W=s.x,j=s.y;const t=.08+.35*P+.04*o.hoverStrength;z=Math.max(0,Math.floor((W-t)*l)-1),q=Math.min(l,Math.ceil((W+t)*l)+1),L=Math.max(0,Math.floor((j-t)*c)-1),H=Math.min(c,Math.ceil((j+t)*c)+1)}const O=o.animationStyle,U=o.animationSpeed,Y="none"===O,_=o.hoverStrength,D=o.hoverEffect,V=P,N=o.hoverShape||"circle",X=C(o.invert),G=o.colorMode,J=2*Math.PI,K=1/l,Q=1/c;let Z="",tt=-1;if("dots"===o.renderMode){const n=.5*Math.min(M,x)*o.dotSizeRatio;for(let o=0;o<c;o++){const r=e[o];for(let e=0;e<l;e++){const i=r[e];if(i.a<10)continue;const s=.00392156863*(.299*i.r+.587*i.g+.114*i.b),h=X?1-s:s;if(h<.02)continue;const f=Y?1:m(e,o,l,c,a,O,U);let g=1,b=0,y=0,S=0,C=0;if(w&&e>=z&&e<=q&&o>=L&&o<=H){const t=p(e*K,o*Q,W,j,v,_,M,x,D,V,N);g=t.scale,b=t.offsetX,y=t.offsetY,S=t.glow,C=t.colorBlend}const T=n*h*f*g;if(T<.3)continue;const R=e*M+.5*M+b,F=o*x+.5*x+y;let P;if(C>0){const t=u(i,G,I,k,B,X);P=`rgb(${Math.min(255,t[0]+($-t[0])*C|0)},${Math.min(255,t[1]+(E-t[1])*C|0)},${Math.min(255,t[2]+(A-t[2])*C|0)})`}else P=d(i,G,I,k,B,X);const et=Math.min(1,.00392156863*i.a*f*(1+S));if(et!==tt&&(t.globalAlpha=et,tt=et),P!==Z&&(t.fillStyle=P,Z=P),T<=3){const e=2*T;t.fillRect(R-T,F-T,e,e)}else t.beginPath(),t.arc(R,F,T,0,J),t.fill()}}}else{const n=.55,r=.9*Math.min(M/n,x),s=r<6;if(!s){const e="emoji"===o.artStyle;t.font=e?`${r}px "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif`:`${r}px "JetBrains Mono", monospace`,t.textAlign="center",t.textBaseline="middle"}let h=null;const f=o.charsetFrames,g=!!f?.length,b=g?f[Math.floor(Math.max(0,a)*(o.charsetFps??2))%f.length]:o.charset;if(s){h={};const t=[...b],e=t.length;for(let o=0;o<e;o++)h[t[o]]=Math.max(.1,(o+.3)/e)}const y=s?null:t.getTransform(),S="glitchText"===D&&w,C="!@#$%^&*<>{}[]|/\\~`0123456789",T=C.length;let R="",F=0,J=0,et=0,ot=0,nt=0,rt=0;if(S){const t=o.hoverText??"ASCIIFY";if(J=Math.round(W*l),et=Math.round(j*c),Array.isArray(t)){const e=t.filter(t=>t.length>0);0===e.length&&e.push("ASCIIFY");R=e[((7*Math.floor(J/Math.max(1,Math.ceil(l/5)))+13*Math.floor(et/Math.max(1,Math.ceil(c/3))))%e.length+e.length)%e.length]}else R=t||"ASCIIFY";F=R.length,ot=Math.max(3,Math.min(12,Math.round(c*P*.6)));const e=Math.floor(ot/2);nt=Math.max(0,et-e),nt+ot>c&&(nt=Math.max(0,c-ot)),rt=J-Math.floor(F/2)}for(let o=0;o<c;o++){const n=e[o];for(let e=0;e<l;e++){const r=n[e];if(r.a<10)continue;let f=g&&null!=r.lum?i(r.lum,b,X):r.char;if(" "===f)continue;const P=Y?1:m(e,o,l,c,a,O,U);if(P<.05)continue;let at=1,it=0,st=0,ct=0,lt=0;if(w&&!S&&e>=z&&e<=q&&o>=L&&o<=H){const t=p(e*K,o*Q,W,j,v,_,M,x,D,V,N);at=t.scale,it=t.offsetX,st=t.offsetY,ct=t.glow,lt=t.colorBlend}if(S&&o>=nt&&o<nt+ot){const t=e-rt;if(t>=0&&t<F){const n=R[t],r=Math.abs(o-et)/Math.max(1,.5*ot),i=Math.abs(e-J)/Math.max(1,F),s=Math.max(r,i),c=Math.max(0,Math.min(1,1-.9*s)),l=43758.5453*Math.sin(127.1*e+311.7*o+43758.5453*Math.floor(12*a));f=Math.abs(l-Math.floor(l))<c?n:C[Math.abs(Math.floor(97*l))%T],ct=.3+.7*c,lt=.3+.65*c}}const ht=e*M+.5*M+it,ft=o*x+.5*x+st;let dt;if(lt>0){const t=u(r,G,I,k,B,X);dt=`rgb(${Math.min(255,t[0]+($-t[0])*lt|0)},${Math.min(255,t[1]+(E-t[1])*lt|0)},${Math.min(255,t[2]+(A-t[2])*lt|0)})`}else dt=d(r,G,I,k,B,X);if(s){const e=h[f]??.5,o=Math.min(1,.00392156863*r.a*P*(1+ct))*e;if(o<.02)continue;o!==tt&&(t.globalAlpha=o,tt=o),dt!==Z&&(t.fillStyle=dt,Z=dt);const n=M*at,a=x*at;t.fillRect(ht-.5*n,ft-.5*a,n,a)}else{const e=Math.min(1,.00392156863*r.a*P*(1+ct));e!==tt&&(t.globalAlpha=e,tt=e),dt!==Z&&(t.fillStyle=dt,Z=dt),1!==at?(t.translate(ht,ft),t.scale(at,at),t.fillText(f,0,0),t.setTransform(y)):t.fillText(f,ht,ft)}}}}t.globalAlpha=1}function B(t,e){const o=Math.min(1,2048/Math.max(t,e));return{renderW:Math.round(t*o),renderH:Math.round(e*o)}}function F(t,e,o,n,r){const{width:a,height:i}=e.getBoundingClientRect();if(!a||!i)return{renderW:0,renderH:0,dpr:1};let s,c,l=a,h=l/o;h>i&&(h=i,l=h*o),l=Math.round(l),h=Math.round(h),n&&r?({renderW:s,renderH:c}=B(n,r)):(s=l,c=h);const f="undefined"!=typeof window&&window.devicePixelRatio||1,d=8e6,g=s*f*c*f>d?Math.sqrt(d/(s*c)):f;return t.width=Math.round(s*g),t.height=Math.round(c*g),t.style.width=l+"px",t.style.height=h+"px",{renderW:s,renderH:c,dpr:g}}async function P(t,e,{fontSize:o,artStyle:a="classic",options:i={},fitTo:s,preExtract:c=!1,trim:l,onReady:h,onFrame:f}={}){const d=l?.start??0,g=l?.end,u=o??i.fontSize??10,m={...r,...n[a],...i,fontSize:u},M=e.getContext("2d");if(!M)throw new Error("asciifyVideo: could not get 2d context from canvas.");const p="string"==typeof s?document.querySelector(s):s instanceof HTMLElement?s:null;if(c){let o;"string"==typeof t?(o=document.createElement("video"),o.crossOrigin="anonymous",o.src=t,o.readyState<2&&await new Promise((e,n)=>{o.onloadeddata=()=>e(),o.onerror=()=>n(new Error(`asciifyVideo: failed to load "${t}"`))})):o=t,p&&F(e,p,o.videoWidth/o.videoHeight,o.videoWidth,o.videoHeight);const{renderW:n,renderH:r}=B(o.videoWidth,o.videoHeight),a="undefined"!=typeof window&&window.devicePixelRatio||1,i=8e6,s=n*a*r*a>i?Math.sqrt(i/(n*r)):a;e.width<Math.round(n*s)&&(e.width=Math.round(n*s),e.height=Math.round(r*s));const c=void 0!==g?g-d:10,{frames:l,fps:u}=await R(o,m,n,r,void 0,c,void 0,d);let x,b=!1,v=0,w=performance.now(),y=!0;const $=1e3/u,S=t=>{b||(t-w>=$&&(M.save(),M.setTransform(s,0,0,s,0,0),k(M,l[v],m,n,r),M.restore(),v=(v+1)%l.length,w=t,y&&(y=!1,h?.(o)),f?.()),x=requestAnimationFrame(S))};return x=requestAnimationFrame(S),()=>{b=!0,cancelAnimationFrame(x)}}let x,b=!1;"string"==typeof t?(x=document.createElement("video"),x.src=t,x.muted=!0,x.loop=!0,x.playsInline=!0,x.setAttribute("playsinline",""),Object.assign(x.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(x),b=!0,await new Promise((e,o)=>{x.onloadedmetadata=()=>e(),x.onerror=()=>o(new Error(`asciifyVideo: failed to load "${t}"`))}),await x.play().catch(()=>{})):(x=t,x.paused&&await x.play().catch(()=>{})),d>0&&(x.currentTime=d,await new Promise(t=>{const e=()=>{x.removeEventListener("seeked",e),t()};x.addEventListener("seeked",e)}));let v=null;(d>0||void 0!==g)&&(v=()=>{(void 0!==g&&x.currentTime>=g||d>0&&x.currentTime<d)&&(x.currentTime=d)},x.addEventListener("timeupdate",v));let w=null;const{renderW:y,renderH:$}=B(x.videoWidth,x.videoHeight);if(p){const t=x.videoWidth/x.videoHeight,o=x.videoWidth,n=x.videoHeight,r=F(e,p,t,o,n),a=e.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0),w=new ResizeObserver(()=>{const r=F(e,p,t,o,n),a=e.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0)}),w.observe(p)}else{const t="undefined"!=typeof window&&window.devicePixelRatio||1,o=8e6,n=y*t*$*t>o?Math.sqrt(o/(y*$)):t;e.width<Math.round(y*n)&&(e.width=Math.round(y*n),e.height=Math.round($*n)),M.setTransform(n,0,0,n,0,0)}let S,C=!1,E=!0;const T=()=>{if(C)return;if(S=requestAnimationFrame(T),x.readyState<2||0===e.width||0===e.height)return;if(d>0&&x.currentTime<d)return;if(void 0!==g&&x.currentTime>=g)return;const{frame:t}=A(x,m,y,$);t.length>0&&(k(M,t,m,y,$,0,null),E&&(E=!1,h?.(x)),f?.())};return S=requestAnimationFrame(T),()=>{C=!0,cancelAnimationFrame(S),w?.disconnect(),v&&x.removeEventListener("timeupdate",v),b&&(x.pause(),x.src="",document.body.removeChild(x))}}function z(t,e,o,n,r={}){const{fontSize:a=13,chars:i="0123456789ABCDEF@#$&*+=/<>",accentColor:s,color:c,speed:l=1,density:h=.55,tailLength:f=14,lightMode:d=!1}=r,g=s??(d?"#6b8700":"#d4ff00"),u=.62*a,m=1.4*a,M=Math.ceil(e/u),p=Math.ceil(o/m);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let b=255,v=255,y=255;if(d&&(b=55,v=55,y=55),c){const t=x(c);t&&(b=t.r,v=t.g,y=t.b)}let $=212,S=255,C=0;const E=x(g);E&&($=E.r,S=E.g,C=E.b);const T=p+f;for(let e=0;e<M;e++){if(w(17*e,3)>h)continue;const o=(.5+1.5*w(31*e,7))*l,r=w(13*e,11)*T,a=Math.floor((n*o*7+r)%T),s=e*u;for(let o=0;o<=f;o++){const r=a-(f-o);if(r<0||r>=p)continue;const c=r*m,l=w(53*e+Math.floor(5*n+o),7*r),h=i[Math.floor(l*i.length)],g=o/f;if(o===f)t.fillStyle=`rgba(${$},${S},${C},${d?.7:.85})`;else{const e=d?.85*g:.15*g;t.fillStyle=`rgba(${b},${v},${y},${e})`}t.fillText(h,s,c)}}}function q(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" . · * + ° ★",accentColor:c,color:l,speed:h=1,count:f=180,lightMode:d=!1}=a,g=c??(d?"#6b8700":"#d4ff00");t.clearRect(0,0,e,o),t.textBaseline="middle",t.textAlign="center";const u=e*(.2+.6*r.x),m=o*(.2+.6*r.y),M=.65*Math.sqrt(e*e+o*o);let p=255,b=255,v=255;if(d&&(p=55,b=55,v=55),l){const t=x(l);t&&(p=t.r,b=t.g,v=t.b)}let y=212,$=255,S=0;const C=x(g);C&&(y=C.r,$=C.g,S=C.b);const E=s.replace(/ /g,"").split("");if(0!==E.length){for(let r=0;r<f;r++){const a=w(17*r,3)*Math.PI*2,s=(n*(.15+.85*w(31*r,7))*h*.22+w(13*r,11))%1,c=u+Math.cos(a)*s*M,l=m+Math.sin(a)*s*M;if(c<-20||c>e+20||l<-20||l>o+20)continue;const f=Math.max(6,i*(.4+.9*s));t.font=`${f}px monospace`;const g=E[Math.min(E.length-1,Math.floor(s*E.length))],x=s>.72,C=d?.85*s:.2*s;t.fillStyle=x?`rgba(${y},${$},${S},${Math.min(d?.92:.32,2.2*C)})`:`rgba(${p},${b},${v},${C})`,t.fillText(g,c,l)}t.textAlign="left"}}function L(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=". · ○ ◎ ●",accentColor:c,color:l,rings:h=5,speed:f=1,sharpness:d=4,lightMode:g=!1}=a,u=c??(g?"#007a5e":"#00ffcc");t.clearRect(0,0,e,o),t.textBaseline="middle",t.textAlign="center";const m=e*r.x,M=o*r.y,p=1.6*Math.sqrt(m*m+M*M)+.2*Math.sqrt(e*e+o*o);let b=255,v=255,w=255;if(g&&(b=55,v=55,w=55),l){const t=x(l);t&&(b=t.r,v=t.g,w=t.b)}let y=0,$=255,S=204;const C=x(u);C&&(y=C.r,$=C.g,S=C.b);const E=s.replace(/ /g,"").split("");if(0===E.length)return;const T=Math.ceil(e/i),A=Math.ceil(o/i);for(let e=0;e<A;e++)for(let o=0;o<T;o++){const r=o*i+.5*i,a=e*i+.5*i,s=r-m,c=a-M,l=Math.sqrt(s*s+c*c)/p;let u=0;for(let t=0;t<h;t++){const e=(n*f*.38+t/h)%1,o=Math.abs(l-e),r=Math.max(0,1-o*p/(i*(12-d)));u+=Math.cos(r*Math.PI*.5)*r}if(u=Math.min(1,u),u<.02)continue;const x=u>.6;t.font=`${i}px monospace`;const C=Math.floor(u*(E.length-1)),T=E[Math.min(C,E.length-1)],A=g?.88*u:.22*u;t.fillStyle=x?`rgba(${y},${$},${S},${Math.min(g?.95:.4,.55*u)})`:`rgba(${b},${v},${w},${A})`,t.fillText(T,r,a)}t.textAlign="left"}function H(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" .·:;=+*#%@░▒▓",accentColor:c,color:l,octaves:h=4,speed:f=1,scale:d=1,accentThreshold:g=.78,mouseWarp:u=.3,lightMode:m=!1}=a,M=c??(m?"#6b8700":"#d4ff00"),p=.62*i,b=1.4*i,v=Math.ceil(e/p),w=Math.ceil(o/b);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let $=255,S=255,C=255;if(m&&($=55,S=55,C=55),l){const t=x(l);t&&($=t.r,S=t.g,C=t.b)}let E=212,T=255,A=0;const R=x(M);R&&(E=R.r,T=R.g,A=R.b);const I=.035*d,k=n*f,B=Math.min(6,Math.max(1,h)),F=(t,e)=>{let o=0,n=.5,r=1,a=0;for(let i=0;i<B;i++)o+=y(t*r,e*r)*n,a+=n,n*=.5,r*=2.1;return o/a};for(let e=0;e<w;e++)for(let o=0;o<v;o++){const n=o*I+.06*k,a=e*I*1.3-.04*k,i=o/v-r.x,c=e/w-r.y,l=Math.sqrt(i*i+c*c),h=u>0?.12*Math.max(0,1-l/u):0,f=.5*F(n+h*Math.sin(1.3*k+8*c),a+h*Math.cos(.9*k+8*i))+.5;if(f<.12)continue;const d=s[Math.floor(f*(s.length-1))];if(" "===d)continue;const M=f>g,x=m?.82*f:.13*f;t.fillStyle=M?`rgba(${E},${T},${A},${m?.92:.28})`:`rgba(${$},${S},${C},${x})`,t.fillText(d,o*p,e*b)}}function W(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=12,chars:s="·-=+|/",accentColor:c,color:l,bands:h=3,speed:f=1,bandWidth:d=.12,glitch:g=!0,lightMode:u=!1}=a,m=c??(u?"#6b8700":"#d4ff00"),M=.62*i,p=1.4*i,b=Math.ceil(e/M),v=Math.ceil(o/p);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let y=255,$=255,S=255;if(u&&(y=55,$=55,S=55),l){const t=x(l);t&&(y=t.r,$=t.g,S=t.b)}let C=212,E=255,T=0;const A=x(m);A&&(C=A.r,E=A.g,T=A.b);const R=n*f;for(let e=0;e<v;e++)for(let o=0;o<b;o++){const n=e/v,a=((n*h-.5*R)%1+1)%1,i=Math.max(0,1-a/d),c=.35*(.5*w(3*o,7*e)+.5);let l=0;if(g){const t=o/b-r.x,a=n-r.y,i=Math.sqrt(t*t+a*a);if(i<.18){const t=w(11*o+Math.floor(12*R),5*e);l=Math.max(0,1-i/.18)*(t>.5?t-.3:0)}}const f=Math.min(1,c+.8*i+.6*l);if(f<.04)continue;const m=s[Math.floor(f*(s.length-1))],x=i>.55,A=u?.82*f:.12*f;t.fillStyle=x?`rgba(${C},${E},${T},${u?.92:.28})`:`rgba(${y},${$},${S},${A})`,t.fillText(m,o*M,e*p)}}function j(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" ·∙•:;+=≡≣#@",color:c,accentColor:l,speed:h=1,layers:f=5,softness:d=1.2,mouseRipple:g=.2,lightMode:u=!1}=a,m=l??(u?"#6b8700":"#d4ff00"),M=.62*i,p=1.4*i,b=Math.ceil(e/M),v=Math.ceil(o/p);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let y=255,$=255,S=255;if(u&&(y=55,$=55,S=55),c){const t=x(c);t&&(y=t.r,$=t.g,S=t.b)}let C=212,E=255,T=0;const A=x(m);A&&(C=A.r,E=A.g,T=A.b);const R=n*h,I=[];for(let t=0;t<f;t++){const e=w(17*t,31*t+7),o=w(23*t+5,11*t);I.push({fx:.8+2.2*e,fy:1.2+1.8*o,phase:e*Math.PI*4,dt:(.3+.5*w(7*t,13*t+3))*(t%2==0?1:-1),amp:.55+.45*w(29*t,3*t)})}for(let e=0;e<v;e++){const o=e/v;for(let n=0;n<b;n++){const a=n/b,i=a-r.x,c=o-r.y,l=Math.sqrt(i*i+c*c),h=g*Math.exp(-l*l/.06),m=a+i*h,x=o+c*h;let v=0,w=0;for(let t=0;t<f;t++){const{fx:e,fy:o,phase:n,dt:r,amp:a}=I[t];v+=Math.sin(m*e*Math.PI*2+R*r+n)*Math.cos(x*o*Math.PI*2+R*r*.7+1.3*n)*a,w+=a}const A=v/w,k=.5+.5*Math.tanh(A*d*2.2);if(k<.12)continue;const B=(k-.12)/.88,F=s[Math.min(s.length-1,Math.floor(B*s.length))],P=k>.82,z=u?.82*k:.14*k;t.fillStyle=P?`rgba(${C},${E},${T},${u?.92:.32})`:`rgba(${y},${$},${S},${z})`,t.fillText(F,n*M,e*p)}}}function O(t,e,o,n,r={}){const{fontSize:a=13,color:i,accentColor:s,speed:c=.4,layers:l=4,turbulence:h=.8,lightMode:f=!1}=r,d=s??(f?"#6b8700":"#d4ff00"),g=.62*a,u=1.4*a,m=Math.ceil(e/g),M=Math.ceil(o/u);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let p=255,b=255,v=255;if(f&&(p=55,b=55,v=55),i){const t=x(i);t&&(p=t.r,b=t.g,v=t.b)}let y=212,$=255,S=0;const C=x(d);C&&(y=C.r,$=C.g,S=C.b);const E=n*c,T=["─","─","╌","·","╌","─","─","╌","·"];for(let e=0;e<M;e++){const o=e/M;for(let n=0;n<m;n++){const r=n/m;let a=0,i=0;for(let t=0;t<l;t++){const e=w(13*t,7*t+3),n=1.1+2.4*e,s=.9+2*w(29*t,11*t+1),c=e*Math.PI*6,l=(.2+.5*w(41*t,17*t))*(t%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),g=Math.sin(r*s*Math.PI*h+o*n*Math.PI*h+E*l*.4);a+=Math.atan2(d+.3*g,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=T[Math.floor(d*T.length)%T.length],x=c>.8,C=f?.8*c:.13*c;t.fillStyle=x?`rgba(${y},${$},${S},${f?.9:.26})`:`rgba(${p},${b},${v},${C})`,t.fillText(M,n*g,e*u)}}}function U(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=13,chars:s=" ·:;=+*#%@",color:c,accentColor:l,speed:h=1,radius:f=.38,swirl:d=3,lightMode:g=!1}=a,u=l??(g?"#6b8700":"#d4ff00"),m=.62*i,M=1.4*i,p=Math.ceil(e/m),b=Math.ceil(o/M),v=e/o;t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let y=255,$=255,S=255;if(g&&(y=55,$=55,S=55),c){const t=x(c);t&&(y=t.r,$=t.g,S=t.b)}let C=212,E=255,T=0;const A=x(u);A&&(C=A.r,E=A.g,T=A.b);const R=n*h;for(let e=0;e<b;e++){const o=e/b;for(let n=0;n<p;n++){const a=(n/p-r.x)*v,i=o-r.y,c=Math.sqrt(a*a+i*i)/f;if(c>1){const o=w(3*n,7*e)*Math.max(0,1-3*(c-1));if(o<.62)continue;const r=o*(g?.28:.04);t.fillStyle=`rgba(${y},${$},${S},${r})`,t.fillText(s[1],n*m,e*M);continue}const l=Math.max(0,1-Math.abs(c-(.15+.12*Math.sin(1.1*R)))/.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)),x=s[Math.min(s.length-1,u)],b=l>.35||c<.08,A=g?.85*d:.18*d;t.fillStyle=b?`rgba(${C},${E},${T},${g?.95:.38})`:`rgba(${y},${$},${S},${A})`,t.fillText(x,n*m,e*M)}}}function Y(t,e,o,n,r={}){const{fontSize:a=14,chars:i=" ·∙•:-=+*#",color:s,accentColor:c,speed:l=.5,harmonics:h=3,lightMode:f=!1}=r,d=c??(f?"#6b8700":"#d4ff00"),g=.62*a,u=1.4*a,m=Math.ceil(e/g),M=Math.ceil(o/u);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let p=255,b=255,v=255;if(f&&(p=55,b=55,v=55),s){const t=x(s);t&&(p=t.r,b=t.g,v=t.b)}let y=212,$=255,S=0;const C=x(d);C&&(y=C.r,$=C.g,S=C.b);const E=n*l,T=Array.from({length:h},(t,e)=>1/(e+1)).reduce((t,e)=>t+e,0);for(let e=0;e<M;e++)for(let o=0;o<m;o++){let n=0;for(let t=0;t<h;t++){const r=.18+1.4*w(o*(t+3)+7,e*(t+5)+11),a=w(o*(t+7),e*(t+9)+3)*Math.PI*2,i=1/(t+1);n+=Math.sin(E*r+a)*i}const r=.5*(n/T+1);if(r<.28)continue;const a=(r-.28)/.72,s=i[Math.min(i.length-1,Math.floor(a*i.length))],c=r>.88,l=f?.82*a:.13*a;t.fillStyle=c?`rgba(${y},${$},${S},${f?.92:.28})`:`rgba(${p},${b},${v},${l})`,t.fillText(s,o*g,e*u)}}function _(t,e,o,n,r={}){const{fontSize:a=13,chars:i=" .,:;i+xX#&@",color:s="#ff4500",hotColor:c="#ffe066",intensity:l=.85,wind:h=0,speed:f=1,lightMode:d=!1}=r,g=.62*a,u=1.4*a,m=Math.ceil(e/g),M=Math.ceil(o/u),p=m*M,b="__fire_heat__",v=t.canvas;let w=v[b];w&&w.length===p||(w=new Float32Array(p),v[b]=w);const y=.18*(.016*f),$=h*f*.8,S=M-1,C=n*f;for(let t=0;t<m;t++){const e=(.6*(.5*Math.sin(.31*t+4.1*C)+.5)+.4*(.5*Math.sin(.73*t-2.7*C)+.5))*l;w[S*m+t]=Math.min(1,e+.15*Math.random()*l),S>0&&(w[(S-1)*m+t]=Math.min(1,.85*e+.1*Math.random()*l))}const E=new Float32Array(p);for(let t=0;t<M-2;t++)for(let e=0;e<m;e++){const o=.4*w[(t+1)*m+e]+.25*w[(t+2)*m+Math.max(0,Math.min(m-1,e+Math.round($)))]+.175*w[(t+1)*m+Math.max(0,e-1)]+.175*w[(t+1)*m+Math.min(m-1,e+1)];E[t*m+e]=Math.max(0,o-y-.02*Math.random()*f)}for(let t=0;t<m;t++)E[(M-1)*m+t]=w[(M-1)*m+t],M>1&&(E[(M-2)*m+t]=w[(M-2)*m+t]);v[b]=E;const T=x(s)??{r:255,g:69,b:0},A=x(c)??{r:255,g:224,b:102};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";for(let e=0;e<M;e++)for(let o=0;o<m;o++){const n=E[e*m+o];if(n<.03)continue;const r=i[Math.min(i.length-1,Math.floor(n*i.length))];if(" "===r)continue;const a=Math.min(1,1.2*n),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);t.globalAlpha=h,t.fillStyle=`rgb(${s},${c},${l})`,t.fillText(r,o*g,e*u)}t.globalAlpha=1}function D(t,e,o,n,r={}){const{fontSize:a=13,baseChars:i="ATCG",bridgeChars:s="-=≡",color:c="#00e5ff",color2:l="#ff4081",bridgeColor:h="#88ffcc",speed:f=1,helixCount:d,lightMode:g=!1}=r,u=.62*a,m=1.4*a,M=Math.ceil(e/u),p=Math.ceil(o/m),b=d??Math.max(1,Math.floor(e/80)),v=M/b,y=x(c)??{r:0,g:229,b:255},$=x(l)??{r:255,g:64,b:129},S=x(h)??{r:136,g:255,b:204};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const C=n*f,E=.35*v;for(let e=0;e<b;e++){const o=v*(e+.5);for(let n=0;n<p;n++){const r=n/p*Math.PI*6-1.8*C,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=w(31*e+7*n,3),d=i[Math.floor(f*i.length)],g=.5*(Math.sin(r)+1),x=.5*(Math.sin(r+Math.PI)+1);if(t.globalAlpha=.35+.65*g,t.fillStyle=`rgb(${y.r},${y.g},${y.b})`,t.fillText(d,l*u,n*m),h>=0&&h<M){const o=w(53*e+11*n,7),r=i[Math.floor(o*i.length)];t.globalAlpha=.35+.65*x,t.fillStyle=`rgb(${$.r},${$.g},${$.b})`,t.fillText(r,h*u,n*m)}if(n%3===0){const o=Math.min(l,h),r=Math.max(l,h);if(r-o>1){const a=w(17*n+43*e,5),i=s[Math.floor(a*s.length)],c=.25*(g+x)+.2;t.globalAlpha=c,t.fillStyle=`rgb(${S.r},${S.g},${S.b})`;for(let e=o+1;e<r;e++)t.fillText(i,e*u,n*m)}}}}t.globalAlpha=1}function V(t,e,o,n,r={}){const{fontSize:a=13,chars:i=" .,:;+*#@",color:s="#4caf50",skyColor:c="#1a237e",peakColor:l="#e0e0e0",speed:h=1,roughness:f=.55,heightScale:d=.55,stars:g=!0,lightMode:u=!1}=r,m=.62*a,M=1.4*a,p=Math.ceil(e/m),b=Math.ceil(o/M),v=x(s)??{r:76,g:175,b:80},y=x(c)??{r:26,g:35,b:126},S=x(l)??{r:224,g:224,b:224};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const C=n*h*.4,E=new Array(p);for(let t=0;t<p;t++){const e=(.5*$((t/p+C)*f*3,.5)+.5)*d;E[t]=Math.floor(e*b)}for(let e=0;e<b;e++)for(let o=0;o<p;o++){const r=b-1-E[o],a=e===r;if(!(e>=r)){if(g){const r=w(7*o+Math.floor(.3*C),13*e);if(r>.97){const a=.3*Math.sin(2*n+100*r)+.7;t.globalAlpha=.5*a,t.fillStyle=`rgb(${y.r+60},${y.g+60},${y.b+80})`,t.fillText("·",o*m,e*M)}}continue}const s=(e-r)/Math.max(1,E[o]),c=i[Math.min(i.length-1,Math.floor(s*i.length))];if(" "===c&&!a)continue;const l=a?1:Math.max(0,1-4*s),h=v.r+(S.r-v.r)*l|0,f=v.g+(S.g-v.g)*l|0,d=v.b+(S.b-v.b)*l|0;t.globalAlpha=.5+.5*s,t.fillStyle=`rgb(${h},${f},${d})`,t.fillText(a?i[i.length-1]:c,o*m,e*M)}t.globalAlpha=1}var N=1,X=2,G=4,J=8,K={3:"─",12:"│",9:"┌",10:"┐",5:"└",6:"┘",11:"┬",7:"┴",13:"├",14:"┤",15:"┼",[N]:"╶",[X]:"╴",[G]:"╵",[J]:"╷"};function Q(t,e,o,n,r={}){const{fontSize:a=13,pulseColor:i="#ffffff",color:s="#00ff88",density:c=.38,speed:l=1,lightMode:h=!1}=r,f=.62*a,d=1.4*a,g=Math.ceil(e/f),u=Math.ceil(o/d),m=x(s)??{r:0,g:255,b:136},M=x(i)??{r:255,g:255,b:255},p=(t,e)=>{if(w(17*t+1,7*e+2)>c)return 0;let o=0;return t+1<g&&w(17*t+1,7*e+2)>.15&&(o|=1),t-1>=0&&w(17*(t-1)+1,7*e+2)>.15&&(o|=2),e+1<u&&w(17*t+1,7*(e+1)+2)>.15&&(o|=8),e-1>=0&&w(17*t+1,7*(e-1)+2)>.15&&(o|=4),o};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const b=n*l;for(let e=0;e<u;e++)for(let o=0;o<g;o++){const n=p(o,e);if(0===n)continue;const r=K[n]??"·",a=(8*b+40*w(o,23*e))%g,i=(6*b+40*w(17*e,11*o))%u,s=(1&n||2&n)&&Math.abs(o-a)<1.5,c=(4&n||8&n)&&Math.abs(e-i)<1.5,l=s||c,h=.25+.35*w(3*o,5*e);l?(t.globalAlpha=.95,t.fillStyle=`rgb(${M.r},${M.g},${M.b})`):(t.globalAlpha=h,t.fillStyle=`rgb(${m.r},${m.g},${m.b})`),t.fillText(r,o*f,e*d)}t.globalAlpha=1}function Z(t,e={}){const{type:o="wave",opacity:n=.2,className:r,zIndex:a=0,colorScheme:i="auto",color:s,...c}=e,l="string"==typeof t?document.querySelector(t):t;if(!l)return console.warn("[asciify] asciiBackground: target not found",t),{destroy:()=>{}};const h=l.style.position;"static"===getComputedStyle(l).position&&(l.style.position="relative");const f=document.createElement("canvas");f.style.cssText=["position:absolute","inset:0","width:100%","height:100%",`opacity:${n}`,"pointer-events:none",`z-index:${a}`].join(";"),r&&(f.className=r),l.prepend(f);const d=f.getContext("2d"),g=window.devicePixelRatio||1,u={x:.5,y:.5},m={x:.5,y:.5},M=window.matchMedia("(prefers-color-scheme: light)"),p=()=>"light"===i||"dark"!==i&&M.matches,x=s?function(t){const e=t.match(/^#([0-9a-f]{3,8})$/i)?.[1];if(e){const t=e.length<=4?e.split("").map(t=>parseInt(t+t,16)):[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)];return{r:t[0],g:t[1],b:t[2]}}const o=t.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i);return o?{r:+o[1],g:+o[2],b:+o[3]}:null}(s):null,b=()=>({...c,lightMode:void 0!==c.lightMode?c.lightMode:p(),baseColor:x?`rgba(${x.r},${x.g},${x.b},{a})`:c.baseColor}),v={current:b()},w=()=>{v.current="rain"===o||"stars"===o||"pulse"===o||"noise"===o||"grid"===o||"aurora"===o||"silk"===o||"void"===o||"morph"===o?{...c,lightMode:void 0!==c.lightMode?c.lightMode:p(),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:p()}:b()};w();const y=()=>{w()};"auto"===i&&M.addEventListener("change",y);const $=()=>{const t=l.getBoundingClientRect();f.width=t.width*g,f.height=t.height*g,d.setTransform(g,0,0,g,0,0)};$();const C=t=>{const e=l.getBoundingClientRect();u.x=(t.clientX-e.left)/e.width,u.y=(t.clientY-e.top)/e.height},E=new ResizeObserver($);E.observe(l),window.addEventListener("mousemove",C);let T=0,A=0;const R=()=>{m.x+=.07*(u.x-m.x),m.y+=.07*(u.y-m.y);const t=l.getBoundingClientRect();"rain"===o?z(d,t.width,t.height,T,v.current):"stars"===o?q(d,t.width,t.height,T,m,v.current):"pulse"===o?L(d,t.width,t.height,T,m,v.current):"noise"===o?H(d,t.width,t.height,T,m,v.current):"grid"===o?W(d,t.width,t.height,T,m,v.current):"aurora"===o?j(d,t.width,t.height,T,m,v.current):"silk"===o?O(d,t.width,t.height,T,v.current):"void"===o?U(d,t.width,t.height,T,m,v.current):"morph"===o?Y(d,t.width,t.height,T,v.current):"fire"===o?_(d,t.width,t.height,T,v.current):"dna"===o?D(d,t.width,t.height,T,v.current):"terrain"===o?V(d,t.width,t.height,T,v.current):"circuit"===o?Q(d,t.width,t.height,T,v.current):S(d,t.width,t.height,T,m,v.current),T+=.016,A=requestAnimationFrame(R)};return A=requestAnimationFrame(R),{destroy:()=>{cancelAnimationFrame(A),E.disconnect(),"auto"===i&&M.removeEventListener("change",y),window.removeEventListener("mousemove",C),f.remove(),l.style.position=h}}}var tt=Z;function et(t,e,o,n="#505050",r=100){if(!t||e<=0||o<=0)return[];const a=x(n)??{r:80,g:80,b:80},i=t,s=i.length;return Array.from({length:o},(t,o)=>Array.from({length:e},(t,n)=>({char:i[(o*e+n)%s],r:a.r,g:a.g,b:a.b,a:r})))}function ot(t,{format:e="png",quality:o=.92,scale:n=1}={}){return new Promise((r,a)=>{let i=t;if(1!==n){const e=document.createElement("canvas");e.width=Math.round(t.width*n),e.height=Math.round(t.height*n);const o=e.getContext("2d");if(!o)return void a(new Error("captureSnapshot: could not get 2d context"));o.drawImage(t,0,0,e.width,e.height),i=e}i.toBlob(t=>t?r(t):a(new Error("captureSnapshot: toBlob returned null")),`image/${e}`,o)})}var nt={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]},rt=[127,65,65,65,65,65,127];function at(t){return nt[t]??nt[t.toUpperCase()]??rt}function it(t,e={}){if(!t)return"";const{char:o="█",scale:n=1}=e,r=[...o][0]??"█",a=Math.max(1,Math.floor(n)),i=7*a,s=a,c=Array.from({length:i},()=>"");for(let e=0;e<t.length;e++){const o=at(t[e]);for(let t=0;t<7;t++){const e=o[t];let n="";for(let t=6;t>=0;t--)n+=(e>>t&1?r:" ").repeat(a);for(let e=0;e<a;e++)c[t*a+e]+=n}if(e<t.length-1)for(let t=0;t<i;t++)c[t]+=" ".repeat(s)}return c.join("\n")}exports.ART_STYLE_PRESETS=n,exports.BACKGROUND_TYPES=["wave","rain","stars","pulse","noise","grid","aurora","silk","void","morph","fire","dna","terrain","circuit"],exports.CHARSETS=e,exports.CHARSET_SEQUENCES=o,exports.DEFAULT_OPTIONS=r,exports.HOVER_PRESETS={none:{label:"Off",options:{hoverStrength:0,hoverEffect:"spotlight",hoverRadius:.2,hoverColor:"#ffffff"}},subtle:{label:"Subtle",options:{hoverStrength:.25,hoverEffect:"glow",hoverRadius:.12,hoverColor:"#ffffff"}},flashlight:{label:"Flashlight",options:{hoverStrength:.6,hoverEffect:"spotlight",hoverRadius:.15,hoverColor:"#fffbe6"}},magnifier:{label:"Magnifier",options:{hoverStrength:.7,hoverEffect:"magnify",hoverRadius:.12,hoverColor:"#ffffff"}},forceField:{label:"Force Field",options:{hoverStrength:.7,hoverEffect:"repel",hoverRadius:.15,hoverColor:"#a0e8ff"}},neon:{label:"Neon",options:{hoverStrength:.6,hoverEffect:"colorShift",hoverRadius:.15,hoverColor:"#d946ef"}},fire:{label:"Fire",options:{hoverStrength:.7,hoverEffect:"spotlight",hoverRadius:.15,hoverColor:"#ff6b2b"}},ice:{label:"Ice",options:{hoverStrength:.5,hoverEffect:"glow",hoverRadius:.15,hoverColor:"#60d5f7"}},gravity:{label:"Gravity",options:{hoverStrength:.7,hoverEffect:"attract",hoverRadius:.18,hoverColor:"#a5d6ff"}},shatter:{label:"Shatter",options:{hoverStrength:.8,hoverEffect:"shatter",hoverRadius:.14,hoverColor:"#ff6090"}},ghost:{label:"Ghost",options:{hoverStrength:.55,hoverEffect:"trail",hoverRadius:.2,hoverColor:"#b39ddb"}},glitchReveal:{label:"Glitch Reveal",options:{hoverStrength:.8,hoverEffect:"glitchText",hoverRadius:.18,hoverColor:"#a3e635"}}},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=Z,exports.asciiText=function(t,e={},o,n){const a={...r,...e},{frame:i,cols:s}=A(t,a,o,n);if(!i.length||0===s)return"";const c=[];for(const t of i)c.push(t.map(t=>t.char).join(""));return c.join("\n")},exports.asciiTextAnsi=function(t,e={},o,n){const a={...r,...e},{frame:i,cols:s}=A(t,a,o,n);if(!i.length||0===s)return"";const c=[];for(const t of i){let e="";for(const o of t)" "===o.char||o.a<10?e+=" ":e+=`[38;2;${o.r};${o.g};${o.b}m${o.char}`;c.push(e)}return c.join("\n")},exports.asciify=async function(t,e,{fontSize:o,artStyle:a="classic",options:i={}}={}){let s;if("string"==typeof t){const e=new Image;e.crossOrigin="anonymous",await new Promise((o,n)=>{e.onload=()=>o(),e.onerror=()=>n(new Error(`Failed to load image: ${t}`)),e.src=t}),s=e}else t instanceof HTMLImageElement&&!t.complete?(await new Promise((e,o)=>{t.onload=()=>e(),t.onerror=()=>o(new Error("Image failed to load"))}),s=t):s=t;const c=n[a],l=o??i.fontSize??10,h={...r,...c,...i,fontSize:l},f=e.getContext("2d");if(!f)throw new Error("Could not get 2d context from canvas");const{w:d,h:g}=function(t){return t instanceof HTMLVideoElement?{w:t.videoWidth,h:t.videoHeight}:t instanceof HTMLImageElement?{w:t.naturalWidth||t.width,h:t.naturalHeight||t.height}:{w:t.width,h:t.height}}(s),{renderW:u,renderH:m}=B(d,g),M="undefined"!=typeof window&&window.devicePixelRatio||1,p=8e6,x=u*M*m*M>p?Math.sqrt(p/(u*m)):M;(e.width<u||e.height<m)&&(e.width=Math.round(u*x),e.height=Math.round(m*x));const{frame:b}=A(s,h,u,m);if(h.hoverStrength>0){let t=null,o=!1,n=0;const r=o=>{const n=e.getBoundingClientRect();t={x:(o.clientX-n.left)/n.width,y:(o.clientY-n.top)/n.height}},a=()=>{t=null};e.addEventListener("mousemove",r),e.addEventListener("mouseleave",a);const i=e=>{o||(f.save(),f.setTransform(x,0,0,x,0,0),k(f,b,h,u,m,e/1e3,t),f.restore(),n=requestAnimationFrame(i))};return n=requestAnimationFrame(i),()=>{o=!0,cancelAnimationFrame(n),e.removeEventListener("mousemove",r),e.removeEventListener("mouseleave",a)}}f.save(),f.setTransform(x,0,0,x,0,0),k(f,b,h,u,m),f.restore()},exports.asciifyGif=async function(t,e,{fontSize:o,artStyle:a="classic",options:i={}}={}){const s="string"==typeof t?await fetch(t).then(t=>t.arrayBuffer()):t,c=o??i.fontSize??10,l={...r,...n[a],...i,fontSize:c},h=e.getContext("2d");if(!h)throw new Error("Could not get 2d context from canvas");const{frames:f,fps:d}=await I(s,l,e.width,e.height);let g,u=!1,m=0,M=performance.now();const p=1e3/d,x=t=>{u||(t-M>=p&&(k(h,f[m],l,e.width,e.height),m=(m+1)%f.length,M=t),g=requestAnimationFrame(x))};return g=requestAnimationFrame(x),()=>{u=!0,cancelAnimationFrame(g)}},exports.asciifyLiveVideo=function(t,e,o){return P(t,e,o)},exports.asciifyText=it,exports.asciifyVideo=P,exports.asciifyWebcam=async function(t,{fontSize:e=10,style:o="classic",options:a={},liveOptions:i,mirror:s=!0,constraints:c={facingMode:"user"},dpr:l}={}){if(!navigator.mediaDevices?.getUserMedia)throw new Error("asciifyWebcam: getUserMedia is not supported in this browser.");const h=await navigator.mediaDevices.getUserMedia({video:c}),f=document.createElement("video");f.srcObject=h,f.muted=!0,f.playsInline=!0,await new Promise((t,e)=>{f.onloadedmetadata=()=>t(),f.onerror=()=>e(new Error("asciifyWebcam: video stream failed to load.")),f.play().catch(e)});const d={...r,...n[o],...a,fontSize:e},g=t.getContext("2d");if(!g)throw new Error("asciifyWebcam: could not get 2d context from canvas.");const u=l??("undefined"!=typeof window?window.devicePixelRatio:1)??1;1!==u&&g.scale(u,u);let m=null;const M={x:.5,y:.5,intensity:0},p=e=>{const o=t.getBoundingClientRect();m={x:(e.clientX-o.left)/o.width,y:(e.clientY-o.top)/o.height}},x=()=>{m=null};d.hoverStrength>0&&(t.addEventListener("mousemove",p),t.addEventListener("mouseleave",x));let b,v=!1;const w=performance.now(),y=e=>{if(!v){if(f.readyState>=f.HAVE_CURRENT_DATA){const o=t.width/u,n=t.height/u,r=(e-w)/1e3,a=i?{...d,...i()}:d;a.hoverStrength>0?(t.addEventListener("mousemove",p),t.addEventListener("mouseleave",x)):(t.removeEventListener("mousemove",p),t.removeEventListener("mouseleave",x));const{frame:c}=A(f,a,o,n);if(m){const t=m.x-M.x,e=m.y-M.y,o=Math.sqrt(t*t+e*e),n=Math.min(.25,.06+.8*o);M.x+=t*n,M.y+=e*n,M.intensity+=.12*(1-M.intensity)}else M.intensity*=.965,M.intensity<.003&&(M.intensity=0);const l=M.intensity>.003?{x:M.x,y:M.y,intensity:M.intensity}:null;s?(g.save(),g.scale(-1,1),g.translate(-o,0),k(g,c,a,o,n,r,l),g.restore()):k(g,c,a,o,n,r,l)}b=requestAnimationFrame(y)}};return b=requestAnimationFrame(y),()=>{v=!0,cancelAnimationFrame(b),t.removeEventListener("mousemove",p),t.removeEventListener("mouseleave",x),h.getTracks().forEach(t=>t.stop()),f.srcObject=null}},exports.buildTextFrame=et,exports.captureSnapshot=ot,exports.gifToAsciiFrames=I,exports.imageToAsciiFrame=A,exports.mountWaveBackground=tt,exports.renderAuroraBackground=j,exports.renderCircuitBackground=Q,exports.renderDnaBackground=D,exports.renderFireBackground=_,exports.renderFrameToCanvas=k,exports.renderGridBackground=W,exports.renderMorphBackground=Y,exports.renderNoiseBackground=H,exports.renderPulseBackground=L,exports.renderRainBackground=z,exports.renderSilkBackground=O,exports.renderStarsBackground=q,exports.renderTerrainBackground=V,exports.renderTextBackground=function(t,e,o,n,a={},i){const{fontSize:s=10,lineHeight:c=1.6,color:l="#505050",opacity:h=100,hoverEffect:f="spotlight",hoverStrength:d=.85,hoverRadius:g=.18,hoverColor:u="#d4ff00"}=a;k(t,et(n,Math.max(1,Math.floor(e/s)),Math.max(1,Math.floor(o/(s*c))),l,h),{...r,hoverEffect:f,hoverStrength:d,hoverRadius:g,hoverColor:u},e,o,0,i??null)},exports.renderTextToCanvas=function(t,e,o={}){const{color:n="#d4ff00",bgColor:r,fontSize:a=10}=o,i=it(e,o);if(!i)return;const s=i.split("\n"),c=Math.max(...s.map(t=>[...t].length));t.width=Math.ceil(c*a*.6),t.height=Math.ceil(s.length*a);const l=t.getContext("2d");r&&"transparent"!==r?(l.fillStyle=r,l.fillRect(0,0,t.width,t.height)):l.clearRect(0,0,t.width,t.height),l.fillStyle=n,l.font=`${a}px monospace`,l.textBaseline="top",s.forEach((t,e)=>l.fillText(t,0,e*a))},exports.renderVoidBackground=U,exports.renderWaveBackground=S,exports.snapshotAndDownload=async function(t,e={}){const{filename:o="asciify-snapshot",format:n="png",...r}=e,a=await ot(t,{format:n,...r}),i="jpeg"===n?"jpg":n,s=document.createElement("a");s.href=URL.createObjectURL(a),s.download=`${o}.${i}`,s.click(),setTimeout(()=>URL.revokeObjectURL(s.href),1e4)},exports.videoToAsciiFrames=R;//# sourceMappingURL=index.cjs.map