asciify-engine 2.0.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var t={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"}},e={standard:" .:-=+*#%@",blocks:" ░▒▓█",minimal:" .:+",dense:" .'`^\",:;Il!i><~+_-?][}{1)(|/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$",binary:"01",dots:" ⠁⠃⠇⡇⣇⣧⣷⣿",letters:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",claudeCode:" ╔╗╚╝║═╠╣╦╩╬░▒▓█│─┌┐└┘├┤┬┴┼",box:" ▪◾◼■█",lines:" ˗‐–—―━",braille:" ⠁⠂⠃⠄⠅⠆⠇⠈⠉⠊⠋⠌⠍⠎⠏⠐⠑⠒⠓⠔⠕⠖⠗⠘⠙⠚⠛⠜⠝⠞⠟⠠⠡⠢⠣⠤⠥⠦⠧⠨⠩⠪⠫⠬⠭⠮⠯⠰⠱⠲⠳⠴⠵⠶⠷⠸⠹⠺⠻⠼⠽⠾⠿⡀⡁⡂⡃⡄⡅⡆⡇⣀⣁⣂⣃⣄⣅⣆⣇⣈⣉⣊⣋⣌⣍⣎⣏⣐⣑⣒⣓⣔⣕⣖⣗⣘⣙⣚⣛⣜⣝⣞⣟⣠⣡⣢⣣⣤⣥⣦⣧⣨⣩⣪⣫⣬⣭⣮⣯⣰⣱⣲⣳⣴⣵⣶⣷⣸⣹⣺⣻⣼⣽⣾⣿",katakana:" ヲァィゥェォャュョッアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン",circles:" .·:∘○◦°•∙",shadows:" ·∘◦○◎⊙●◉",geometric:" ·△▷◇◈◆▣■█",pipes:" ╶─┐└├┤┬┴┼╬▒▓█",waves:" ˜∼≈〰≋∿∾∭∫",shards:" ╱╲╳◤◥◣◢△▲◆◼█",smoke:" ·˙⁚⁖∶∷⋮⋰⋱∴∵",ascii:" .'`^\",:;~-_+<>i!lI?/\\|()[]{}1tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$",interface:" ·•-–—+=:;<>[]{}()⌘⌥⇧⌃↵↗↘◇◆◈□■",prompt:" .:;>_`/\\|{}[]()=+*#@$",data:" ·∙•◦○●◇◆◈▱▰▣█",humanist:" ·˙,:;∴∵∷∶⁚⋮⋯∼≈≋∞",mesh:" ·╶╴╷╵─│┌┐└┘├┤┬┴┼╬░▒▓█"},n={cosmic:[e.smoke,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.blocks],assistant:[e.interface,e.prompt,e.data],signal:[e.mesh,e.data,e.ascii],editorial:[e.humanist,e.waves,e.smoke]},o={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"},circles:{renderMode:"ascii",charset:e.circles,colorMode:"accent",accentColor:"#d4ff00"},shadows:{renderMode:"ascii",charset:e.shadows,colorMode:"accent",accentColor:"#50a0ff"},geometric:{renderMode:"ascii",charset:e.geometric,colorMode:"grayscale"},pipes:{renderMode:"ascii",charset:e.pipes,colorMode:"accent",accentColor:"#00ff88"},waves:{renderMode:"ascii",charset:e.waves,colorMode:"fullcolor"},shards:{renderMode:"ascii",charset:e.shards,colorMode:"grayscale"},smoke:{renderMode:"ascii",charset:e.smoke,colorMode:"accent",accentColor:"#c850ff"},ascii:{renderMode:"ascii",charset:e.ascii,colorMode:"grayscale"},interface:{renderMode:"ascii",charset:e.interface,colorMode:"accent",accentColor:"#f4f1ea"},prompt:{renderMode:"ascii",charset:e.prompt,colorMode:"matrix"},data:{renderMode:"ascii",charset:e.data,colorMode:"fullcolor"},humanist:{renderMode:"ascii",charset:e.humanist,colorMode:"accent",accentColor:"#d6ccc2"},mesh:{renderMode:"ascii",charset:e.mesh,colorMode:"accent",accentColor:"#8fd3ff"}},r={agentField:{...o.interface,charsetFrames:n.assistant,charsetFps:1.6,animationStyle:"breathe",animationSpeed:.75,ditherStrength:.12,hoverEffect:"glow",hoverStrength:.42,hoverRadius:.18,hoverColor:"#f4f1ea",normalize:!0},liquidSignal:{...o.data,charsetFrames:n.signal,charsetFps:2.4,animationStyle:"melt",animationSpeed:.65,ditherStrength:.45,hoverEffect:"repel",hoverStrength:.55,hoverRadius:.22,hoverColor:"#8fd3ff",normalize:!0},cursorGravity:{...o.mesh,charsetFrames:n.angular,charsetFps:1.2,animationStyle:"orbit",animationSpeed:.9,ditherStrength:.2,hoverEffect:"attract",hoverStrength:.82,hoverRadius:.24,hoverColor:"#ffffff",normalize:!0},editorialPulse:{...o.humanist,charsetFrames:n.editorial,charsetFps:.9,animationStyle:"ripple",animationSpeed:.55,ditherStrength:.18,hoverEffect:"spotlight",hoverStrength:.35,hoverRadius:.2,hoverColor:"#fff8ea",normalize:!0},terminalFlow:{...o.prompt,charsetFrames:n.terminal,charsetFps:3,animationStyle:"rain",animationSpeed:1.1,ditherStrength:.22,hoverEffect:"glitchText",hoverStrength:.65,hoverRadius:.16,hoverColor:"#d4ff00",hoverText:["BUILD","SHIP","RUN","ASK","MODEL"],normalize:!0}},a={fontSize:7,charSpacing:1,brightness:0,contrast:0,charset:e.standard,colorMode:"grayscale",accentColor:"#d4ff00",invert:!1,renderMode:"ascii",animationStyle:"none",animationSpeed:1,dotSizeRatio:.8,ditherStrength:0,charAspect:.55,normalize:!1,hoverStrength:0,hoverRadius:.2,hoverEffect:"spotlight",hoverColor:"#ffffff",hoverShape:"circle",hoverText:"ASCIIFY",artStyle:"classic",customText:"",chromaKey:null,chromaKeyTolerance:60,chromaKeyTrimPadding:.002,chromaKeyTrimLuminanceThreshold:0,chromaKeyTrimMode:"range"},i={none:{label:"Off",options:{hoverStrength:0,hoverEffect:"spotlight",hoverRadius:.2,hoverColor:"#ffffff"}},subtle:{label:"Subtle",options:{hoverStrength:.25,hoverEffect:"glow",hoverRadius:.12,hoverColor:"#ffffff"}},flashlight:{label:"Flashlight",options:{hoverStrength:.6,hoverEffect:"spotlight",hoverRadius:.15,hoverColor:"#fffbe6"}},magnifier:{label:"Magnifier",options:{hoverStrength:.7,hoverEffect:"magnify",hoverRadius:.12,hoverColor:"#ffffff"}},forceField:{label:"Force Field",options:{hoverStrength:.7,hoverEffect:"repel",hoverRadius:.15,hoverColor:"#a0e8ff"}},neon:{label:"Neon",options:{hoverStrength:.6,hoverEffect:"colorShift",hoverRadius:.15,hoverColor:"#d946ef"}},fire:{label:"Fire",options:{hoverStrength:.7,hoverEffect:"spotlight",hoverRadius:.15,hoverColor:"#ff6b2b"}},ice:{label:"Ice",options:{hoverStrength:.5,hoverEffect:"glow",hoverRadius:.15,hoverColor:"#60d5f7"}},gravity:{label:"Gravity",options:{hoverStrength:.7,hoverEffect:"attract",hoverRadius:.18,hoverColor:"#a5d6ff"}},shatter:{label:"Shatter",options:{hoverStrength:.8,hoverEffect:"shatter",hoverRadius:.14,hoverColor:"#ff6090"}},ghost:{label:"Fluid trail",options:{hoverStrength:.55,hoverEffect:"trail",hoverRadius:.2,hoverColor:"#b39ddb"}},glitchReveal:{label:"Glitch Reveal",options:{hoverStrength:.8,hoverEffect:"glitchText",hoverRadius:.18,hoverColor:"#a3e635"}}};function s(t,e){const n=document.createElement("canvas");n.width=t,n.height=e;const o=n.getContext("2d",{willReadFrequently:!0});return{canvas:n,ctx:o}}function c(t,e,n){let o=t+255*e;return o=259*(255*n+255)/(255*(259-255*n))*(o-128)+128,Math.max(0,Math.min(255,o))}function l(t,e,n,o,r,a){if((a?1-t/255:t/255)<.12)return" ";const i=[...e];return i[(o*r+n)%i.length]}var h=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];function f(t,e,n,o){if(o<=0)return t;const r=(h[n%4][e%4]/16-.5)*o*128;return Math.max(0,Math.min(255,t+r))}var d=new Array(256),m=new Array(256);for(let t=0;t<256;t++)d[t]=`rgb(${t},${t},${t})`,m[t]=`rgb(0,${t},0)`;function u(t,e,n,o,r,a=!1){switch(e){case"fullcolor":return`rgb(${t.r},${t.g},${t.b})`;case"matrix":return m[.299*t.r+.587*t.g+.114*t.b|0];case"accent":return`rgb(${n},${o},${r})`;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;return d[e]}}}var g=[0,0,0];function M(t,e,n,o,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]=n,g[1]=o,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 p(t){const e=t.match(/rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)(?:\s*[,/]\s*([\d.]+))?\s*\)/);return e?{r:+e[1],g:+e[2],b:+e[3],a:void 0!==e[4]?+e[4]:1}:null}function v(t){let e=t;for(;e&&e!==document.documentElement.parentElement;){const t=getComputedStyle(e).backgroundColor;if(t&&"transparent"!==t&&"rgba(0, 0, 0, 0)"!==t){const e=p(t);if(e&&e.a>.1)return e}e=e.parentElement}return null}function x(t){if(t){const e=v(t);if(e){return(.299*e.r+.587*e.g+.114*e.b)/255<.4}}if("undefined"!=typeof document){const t=document.documentElement,e=(t.getAttribute("data-theme")||"").toLowerCase();if("dark"===e)return!0;if("light"===e)return!1;if(t.classList.contains("dark"))return!0;if(document.body){const t=v(document.body);if(t){return(.299*t.r+.587*t.g+.114*t.b)/255<.4}}}return"undefined"!=typeof window&&window.matchMedia("(prefers-color-scheme: dark)").matches}function b(t){if("string"!=typeof t)return t;const e=document.createElement("canvas");e.width=1,e.height=1;const n=e.getContext("2d");n.fillStyle=t,n.fillRect(0,0,1,1);const o=n.getImageData(0,0,1,1).data;return{r:o[0],g:o[1],b:o[2]}}function w(t){return t*t*(3-2*t)}function y(t,e,n,o,r,a,i){if("none"===a)return 1;const s=r*i;switch(a){case"wave":return.3+.7*(.6*(.5*Math.sin(t/n*Math.PI*4+3*s)+.5)+.4*(.5*Math.sin(e/o*Math.PI*3+2*s)+.5));case"pulse":{const r=n/2,a=o/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/o*Math.PI*8-5*s+.3*t)+.5)*(.3*Math.sin(t/n*Math.PI*2+s)+.7);case"breathe":{const n=.3*Math.sin(2*s)+.7,o=.1*Math.sin(.1*(t+e)+s);return Math.max(.1,Math.min(1,n+o))}case"sparkle":{const n=43758.5453*Math.sin(127.1*t+311.7*e+43758.5453*Math.floor(8*s)),o=n-Math.floor(n);return o>.7?1:.15+.4*o}case"glitch":{const t=Math.floor(e/(.05*o)),n=43758.5453*Math.sin(43.23*t+17.89*Math.floor(6*s));if(n-Math.floor(n)>.85){const e=.5*Math.sin(30*s+t)+.5;return e<.3?0:e}return 1}case"spiral":{const r=n/2,a=o/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=n*o,a=e*n+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=n/2,a=o/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":return.55+.45*Math.sin(t/n*9+2*Math.sin(e/o*6-s)+1.5*s);case"ripple":{const r=n/2,a=o/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 n=e/o*Math.PI;return.05+(.5*Math.sin(n-1.8*s+.15*t)+.5)*(1-.6*(Math.max(0,e/o-.1)/.9))*.95}case"orbit":{const r=n/2,a=o/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 n=Math.floor(4*s),o=(t,e)=>{const o=43758.5453*Math.sin(127.1*t+311.7*e+43758.5453*n);return o-Math.floor(o)>.38?1:0},r=o(t,e),a=o(t-1,e)+o(t+1,e)+o(t,e-1)+o(t,e+1)+o(t-1,e-1)+o(t+1,e-1)+o(t-1,e+1)+o(t+1,e+1);return 1===(1===r?2===a||3===a?1:0:3===a?1:0)?1:.05}default:return 1}}var S={scale:1,offsetX:0,offsetY:0,glow:0,colorBlend:0,proximity:0};function $(t,e,n,o,r,a,i,s,c="spotlight",l=.5,h="circle",f=[],d=1){const m=(t-n)*Math.max(1,d),u=(e-o)*Math.max(1,1/d),g=.08+.35*l+.04*a;let M,p;if("box"===h){const t=Math.abs(m),e=Math.abs(u);M=Math.max(t,e),p=g}else M=Math.sqrt(m*m+u*u),p=g;if(M>=p&&("trail"!==c||0===f.length))return S.scale=1,S.offsetX=0,S.offsetY=0,S.glow=0,S.colorBlend=0,S.proximity=0,S;const v=w(Math.max(0,1-M/p))*r;let x=1,b=0,y=0,$=0,C=0;switch(c){case"spotlight":{x=1+v*a*1.8;const t=Math.atan2(u,m),e=v*v*a*.6;b=Math.cos(t)*e*i,y=Math.sin(t)*e*s,$=v*a*.4,C=v*v*a*.25;break}case"magnify":x=1+v*a*.85,$=v*a*.15;break;case"repel":{x=1;const t=Math.atan2(u,m),e=v*v*a*1.8;b=Math.cos(t)*e*i,y=Math.sin(t)*e*s;break}case"glow":$=v*a*.8,C=v*a*.4;break;case"colorShift":x=1,$=v*a*.12,C=v*a;break;case"attract":{const t=Math.atan2(u,m),e=v*v*a*1;b=(.45*-Math.cos(t)-1.6*Math.sin(t))*e*i,y=(.45*-Math.sin(t)+1.6*Math.cos(t))*e*s,$=v*a*.3;break}case"shatter":{const t=Math.atan2(u,m),e=.5*Math.sin(43.7*m+29.3*u),n=v*a*1.4*(.7+.3*e);b=Math.cos(t+e)*n*i,y=Math.sin(t+e)*n*s,x=Math.max(.1,1-v*a*.6),$=v*a*.25;break}case"trail":{let n=v,o=-u*v,r=m*v;for(const a of f){const i=(t-a.x)*Math.max(1,d),s=(e-a.y)*Math.max(1,1/d),c=Math.hypot(i,s)/g;if(c>=1)continue;const l=w(1-c)*a.intensity;n=Math.max(n,l),o+=(.35*a.vx-2*s)*l*.35,r+=(.35*a.vy+2*i)*l*.35}b=Math.tanh(2*o)*a*i*3,y=Math.tanh(2*r)*a*s*3,C=n*a*.65,$=n*a*.35,x=1+n*a*.08,S.proximity=n;break}case"glitchText":x=1,$=v*a*.5,C=v*a*.6}return S.scale=x,S.offsetX=b,S.offsetY=y,S.glow=$,S.colorBlend=C,"trail"!==c&&(S.proximity=v),S}function C(t,e,{continuous:n=!1,interactive:o=!1}={}){const r=t.parentElement??t;let a=null,i=0,s=!1,c=!0,l=!0,h=-1/0;const f=window.matchMedia("(prefers-reduced-motion: reduce)"),d=()=>{l=!0,s||!c||document.hidden||i||(i=requestAnimationFrame(m))},m=t=>{if(i=0,s||!c||document.hidden)return;const o=!f.matches&&(n||t-h<1500);(l||o)&&(e(t,f.matches?null:a),l=!1),o&&(i=requestAnimationFrame(m))},u=e=>{if("touch"===e.pointerType)return;const n=t.getBoundingClientRect();if(!n.width||!n.height)return;const o=(e.clientX-n.left)/n.width,r=(e.clientY-n.top)/n.height;a=o>=0&&o<=1&&r>=0&&r<=1?{x:o,y:r}:null,h=performance.now(),d()},g=()=>{a=null,h=performance.now(),d()},M=()=>{document.hidden&&i?(cancelAnimationFrame(i),i=0):d()},p="undefined"==typeof IntersectionObserver?null:new IntersectionObserver(([t])=>{c=t.isIntersecting,c?d():i&&(cancelAnimationFrame(i),i=0)});return p?.observe(t),o&&(r.addEventListener("pointermove",u),r.addEventListener("pointerleave",g)),document.addEventListener("visibilitychange",M),f.addEventListener("change",d),d(),{wake:d,stop:()=>{s=!0,cancelAnimationFrame(i),p?.disconnect(),r.removeEventListener("pointermove",u),r.removeEventListener("pointerleave",g),document.removeEventListener("visibilitychange",M),f.removeEventListener("change",d)}}}var E=null,T=null;function A(t,e){if(!E||!T){const n=s(t,e);E=n.canvas,T=n.ctx}return E.width!==t&&(E.width=t),E.height!==e&&(E.height=e),T}var F=new Map,I=new Map,R=new WeakMap;function k(t){const e=Intl.Segmenter;return e?Array.from(new e(void 0,{granularity:"grapheme"}).segment(t),({segment:t})=>t):[...t]}function L(t){let e=F.get(t);return e||(e=k(t),F.set(t,e)),e}function P(t){return k(t)}function z(t,e,n){const o=n?1-t/255:t/255,r=Math.floor(o*(e.length-1));return e[Math.max(0,Math.min(e.length-1,r))]??" "}function H(t,e,n,o){const r=`${t}\0${e?1:0}\0${n}\0${o}`;let a=I.get(r);if(!a){const i=L(t);a=new Array(256);for(let t=0;t<256;t++)a[t]=z(c(t,n,o),i,e);I.set(r,a)}return a}function W(){F.clear(),I.clear(),X=new WeakMap,Q=new WeakMap,G=new WeakMap,E=null,T=null}function q(t,e){return"auto"!==t?t:!x(e)}function B(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 n=t.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);return n?[n[1],n[2],n[3]].map(t=>parseInt(t).toString(16).padStart(2,"0")).join(""):null}function j(t){const e=t||"auto";if("auto"!==e)return B(e)??"ffffff";if("undefined"!=typeof document){const t=getComputedStyle(document.documentElement);for(const e of["--accent-color","--color-accent","--accent","--color-primary","--primary","--brand-color"]){const n=B(t.getPropertyValue(e).trim());if(n)return n}const e=B(getComputedStyle(document.body).accentColor??"");if(e)return e}return x("undefined"!=typeof document?document.body:null)?"faf9f7":"0d0d0d"}function O(t,e,n){return Math.max(e,Math.min(n,t))}function N(t,e,n){if(!t)return{x:0,y:0,width:e,height:n};const o=t.unit??"percent",r=!1!==t.preserveAspect,a=t=>void 0===t?void 0:"percent"===o?t*e:t,i=t=>void 0===t?void 0:"percent"===o?t*n:t,s=O(a(t.left)??0,0,e-1),c=O(a(t.right)??0,0,e-s-1),l=O(i(t.top)??0,0,n-1),h=O(i(t.bottom)??0,0,n-l-1),f=void 0!==t.left||void 0!==t.right||void 0!==t.top||void 0!==t.bottom,d=Math.max(1,e-s-c),m=Math.max(1,n-l-h),u=f?d:a(t.width),g=f?m:i(t.height);let M=u??e,p=g??n;if(r&&!f){const t=M/e,o=p/n,r=Math.min(t,o),a=void 0===u?o:void 0===g?t:r;M=e*a,p=n*a}M=O(M,1,f?d:e),p=O(p,1,f?m:n);const v=t.anchor??"center",x=a(t.x),b=i(t.y),w=f?s:0,y=f?l:0,S=f?d:e,$=f?m:n,C=v.endsWith("left")||"left"===v?0:v.endsWith("right")||"right"===v?S-M:(S-M)/2,E=v.startsWith("top")||"top"===v?0:v.startsWith("bottom")||"bottom"===v?$-p:($-p)/2;return{x:O(x??w+C,0,Math.max(0,e-M)),y:O(b??y+E,0,Math.max(0,n-p)),width:M,height:p}}function U(t,e,n,o){const r=t instanceof HTMLVideoElement?t.videoWidth:t.width,a=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(0===r||0===a)return{frame:[],cols:0,rows:0};const i=e.charAspect,s=e.fontSize*e.charSpacing,h=e.fontSize/i*e.charSpacing,d=n||r,m=o||a,u=Math.floor(d/s),g=Math.floor(m/h);if(u<=0||g<=0)return{frame:[],cols:0,rows:0};const M=N(e.sourceCrop,r,a),p=Math.max(1,Math.min(Math.floor(2048/u),Math.floor(M.width/u))),v=Math.max(1,Math.min(Math.floor(2048/g),Math.floor(M.height/g))),x=u*p,w=g*v,y=A(x,w),S=y.globalCompositeOperation;y.globalCompositeOperation="copy";try{y.drawImage(t,M.x,M.y,M.width,M.height,0,0,x,w)}finally{y.globalCompositeOperation=S}const $=y.getImageData(0,0,x,w).data,C=e.chromaKey,E=null!=C&&!1!==C,T=!0===C,F="blue-screen"===C;let I=null,R=0;!E||T||F||(I=b(C),R=(e.chromaKeyTolerance??60)**2);let k=0,P=255;if(e.normalize){let t=255,e=0;for(let n=0;n<$.length;n+=4){if(E){const t=$[n],e=$[n+1],o=$[n+2];let r=!1;if(T)r=e>1.4*t&&e>1.4*o&&e>80;else if(F)r=o>1.4*t&&o>1.4*e&&o>80;else if(null!==I){const n=t-I.r,a=e-I.g,i=o-I.b;r=n*n+a*a+i*i<=R}if(r)continue}const o=.299*$[n]+.587*$[n+1]+.114*$[n+2];o<t&&(t=o),o>e&&(e=o)}k=t,P=e>t?e-t:255}const W=[],B=q(e.invert),j=E&&e.charset.replace(/ /g,"")||e.charset,O=L(j),U=e.customText?null:H(j,B,e.brightness,e.contrast),V=p*v;for(let t=0;t<g;t++){const n=[];for(let o=0;o<u;o++){let r=0,a=0,i=0,s=0,h=0;for(let e=0;e<v;e++){const n=(t*v+e)*x;for(let t=0;t<p;t++){const e=4*(n+o*p+t),c=$[e],l=$[e+1],f=$[e+2],d=$[e+3];if(E){let t=!1;if(T)t=l>1.4*c&&l>1.4*f&&l>80;else if(F)t=f>1.4*c&&f>1.4*l&&f>80;else if(null!==I){const e=c-I.r,n=l-I.g,o=f-I.b;t=e*e+n*n+o*o<=R}if(t){h++;continue}}r+=c,a+=l,i+=f,s+=d}}if(E&&h>V/2){n.push({char:" ",r:0,g:0,b:0,a:0});continue}const d=V-h,m=d>0?r/d:0,g=d>0?a/d:0,M=d>0?i/d:0,b=d>0?s/d:0,w=.299*m+.587*g+.114*M,y=e.normalize?(w-k)/P*255:w,S=c(y,e.brightness,e.contrast),C=e.ditherStrength>0?f(S,o,t,e.ditherStrength):S,A=e.customText?l(C,e.customText,o,t,u,B):e.ditherStrength>0?z(C,O,B):U[Math.max(0,Math.min(255,0|y))];n.push({char:A,r:m,g:g,b:M,a:b,lum:C})}W.push(n)}return{frame:W,cols:u,rows:g}}function V(t,e,n,o){const r=t instanceof HTMLVideoElement?t.videoWidth:t.width,a=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(0===r||0===a)return{rows:[],cols:0,rowCount:0};const i=e.charAspect,s=e.fontSize*e.charSpacing,l=e.fontSize/i*e.charSpacing,h=n||r,d=o||a,m=Math.floor(h/s),u=Math.floor(d/l);if(m<=0||u<=0)return{rows:[],cols:0,rowCount:0};const g=m,M=u,p=A(g,M),v=N(e.sourceCrop,r,a),x=p.globalCompositeOperation;p.globalCompositeOperation="copy";try{p.drawImage(t,v.x,v.y,v.width,v.height,0,0,g,M)}finally{p.globalCompositeOperation=x}const w=p.getImageData(0,0,g,M).data,y=e.chromaKey,S=null!=y&&!1!==y,$=!0===y,C="blue-screen"===y;let E=null,T=0;!S||$||C||(E=b(y),T=(e.chromaKeyTolerance??60)**2);let F=0,I=255;if(e.normalize){let t=255,e=0;for(let n=0;n<w.length;n+=4){if(S){const t=w[n],e=w[n+1],o=w[n+2];let r=!1;if($)r=e>1.4*t&&e>1.4*o&&e>80;else if(C)r=o>1.4*t&&o>1.4*e&&o>80;else if(null!==E){const n=t-E.r,a=e-E.g,i=o-E.b;r=n*n+a*a+i*i<=T}if(r)continue}const o=.299*w[n]+.587*w[n+1]+.114*w[n+2];o<t&&(t=o),o>e&&(e=o)}F=t,I=e>t?e-t:255}const R=q(e.invert),k=S&&e.charset.replace(/ /g,"")||e.charset,P=L(k),W=e.customText?null:H(k,R,e.brightness,e.contrast),B=e.customText?L(e.customText):null,j="fullcolor"===e.colorMode?new Uint8ClampedArray(m*u*4):void 0,O=[];for(let t=0;t<u;t++){let n="";for(let o=0;o<m;o++){const r=4*(t*g+o),a=r,i=w[r],s=w[r+1],l=w[r+2],h=w[r+3];if(S){let t=!1;if($)t=s>1.4*i&&s>1.4*l&&s>80;else if(C)t=l>1.4*i&&l>1.4*s&&l>80;else if(null!==E){const e=i-E.r,n=s-E.g,o=l-E.b;t=e*e+n*n+o*o<=T}if(t){n+=" ",j&&(j[a]=0,j[a+1]=0,j[a+2]=0,j[a+3]=0);continue}}j&&(j[a]=i,j[a+1]=s,j[a+2]=l,j[a+3]=h);const d=.299*i+.587*s+.114*l,u=e.normalize?(d-F)/I*255:d,M=e.ditherStrength>0||B?c(u,e.brightness,e.contrast):u,p=e.ditherStrength>0?f(M,o,t,e.ditherStrength):M;if(B){n+=(R?1-p/255:p/255)<.12?" ":B[(t*m+o)%B.length]}else e.ditherStrength<=0?n+=W[Math.max(0,Math.min(255,0|u))]:n+=z(p,P,R)}O.push(n)}return{rows:O,cols:m,rowCount:u,colors:j}}function D(t,e,n,o,r){if(0===e.rows.length)return;const a=t.canvas,i=Boolean(n.chromaKey)||e.rows.some(t=>t.includes(" "));i||(R.delete(t),t.clearRect(0,0,o,r),t.fillStyle=x(a)?"#0a0a0a":"#faf9f7",t.fillRect(0,0,o,r));const s=j(n.accentColor),c=parseInt(s.substring(0,2),16),l=parseInt(s.substring(2,4),16),h=parseInt(s.substring(4,6),16),f=o/e.cols,d=r/e.rowCount,m=.9*Math.min(f/.55,d),u=e.colors;if("fullcolor"===n.colorMode&&u){R.delete(t),t.clearRect(0,0,o,r),t.font=`${m}px "JetBrains Mono", monospace`,t.textAlign="left",t.textBaseline="middle",t.globalAlpha=1;let n="";for(let o=0;o<e.rows.length;o++){const r=P(e.rows[o]);let a=0;for(;a<e.cols;){for(;a<e.cols&&" "===r[a];)a++;if(a>=e.cols)break;const i=a,s=4*(o*e.cols+a),c=240&u[s],l=240&u[s+1],h=240&u[s+2];for(a++;a<e.cols&&" "!==r[a];){const t=4*(o*e.cols+a);if((240&u[t])!==c||(240&u[t+1])!==l||(240&u[t+2])!==h)break;a++}const m=`rgb(${c},${l},${h})`;m!==n&&(t.fillStyle=m,n=m),t.fillText(r.slice(i,a).join(""),i*f+.5*f,o*d+.5*d)}}return void(t.globalAlpha=1)}t.font=`${m}px "JetBrains Mono", monospace`,t.textAlign="left",t.textBaseline="middle";const g="matrix"===n.colorMode?"rgb(0,255,0)":"grayscale"===n.colorMode?x(a)?"rgb(230,230,230)":"rgb(24,24,24)":`rgb(${c},${l},${h})`;t.fillStyle=g,t.globalAlpha=1;const M=R.get(t),p=i&&M&&M.cols===e.cols&&M.rowCount===e.rowCount&&M.canvasWidth===o&&M.canvasHeight===r&&M.fillStyle===g;p||t.clearRect(0,0,o,r);for(let n=0;n<e.rows.length;n++){const r=e.rows[n];p&&M.rows[n]===r||(p&&t.clearRect(0,n*d,o,d+1),0!==r.trim().length&&t.fillText(r,.5*f,n*d+.5*d))}R.set(t,{rows:e.rows.slice(),cols:e.cols,rowCount:e.rowCount,canvasWidth:o,canvasHeight:r,fillStyle:g}),t.globalAlpha=1}async function K(t,e,n,o,r=12,a=10,i,s=0){const c=Math.min(t.duration-s,a),l=Math.ceil(c*r),h=[];let f=0,d=0;for(let a=0;a<l;a++){const m=s+a/r;if(m>s+c)break;t.currentTime=m,await new Promise(e=>{const n=()=>{t.removeEventListener("seeked",n),e()};t.addEventListener("seeked",n)});const u=U(t,e,n,o);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 Y(t,e,n,o,r=12,a=10,i,s=0){const c=Math.min(t.duration-s,a),l=Math.ceil(c*r),h=[];let f=0,d=0;for(let a=0;a<l;a++){const m=s+a/r;if(m>s+c)break;t.currentTime=m,await new Promise(e=>{const n=()=>{t.removeEventListener("seeked",n),e()};t.addEventListener("seeked",n)});const u=V(t,e,n,o);h.push(u),f=u.cols,d=u.rowCount,i?.((a+1)/l)}return{frames:h,cols:f,rows:d,fps:r}}async function _(t,e,n,o,r){const{parseGIF:a,decompressFrames:i}=await import("gifuct-js"),s=a(t),c=i(s,!0);if(0===c.length)return{frames:[],cols:0,rows:0,fps:10};const l=c[0].dims.width,h=c[0].dims.height,f=s.lsd?.width||l,d=s.lsd?.height||h,m=document.createElement("canvas");m.width=f,m.height=d;const u=m.getContext("2d"),g=document.createElement("canvas");g.width=f,g.height=d;const M=g.getContext("2d"),p=document.createElement("canvas"),v=p.getContext("2d"),x=[];let b=0,w=0,y=0;for(const t of c)y+=t.delay||100;const S=y/c.length,$=Math.round(Math.min(30,Math.max(5,1e3/S))),C=Math.min(c.length,300);for(let t=0;t<C;t++){const a=c[t],{dims:i,patch:s,disposalType:l}=a;3===l&&(M.clearRect(0,0,f,d),M.drawImage(m,0,0)),p.width!==i.width&&(p.width=i.width),p.height!==i.height&&(p.height=i.height);const h=new ImageData(new Uint8ClampedArray(s.buffer),i.width,i.height);v.putImageData(h,0,0),u.drawImage(p,i.left||0,i.top||0);const y=U(m,e,n,o);x.push(y.frame),b=y.cols,w=y.rows,2===l?u.clearRect(i.left||0,i.top||0,i.width,i.height):3===l&&(u.clearRect(0,0,f,d),u.drawImage(g,0,0)),r?.((t+1)/C)}return{frames:x,cols:b,rows:w,fps:$}}async function J(t,e,n,o,r){const{parseGIF:a,decompressFrames:i}=await import("gifuct-js"),s=a(t),c=i(s,!0);if(0===c.length)return{frames:[],cols:0,rows:0,fps:10};const l=c[0].dims.width,h=c[0].dims.height,f=s.lsd?.width||l,d=s.lsd?.height||h,m=document.createElement("canvas");m.width=f,m.height=d;const u=m.getContext("2d"),g=document.createElement("canvas");g.width=f,g.height=d;const M=g.getContext("2d"),p=document.createElement("canvas"),v=p.getContext("2d"),x=[];let b=0,w=0,y=0;for(const t of c)y+=t.delay||100;const S=y/c.length,$=Math.round(Math.min(30,Math.max(5,1e3/S))),C=Math.min(c.length,300);for(let t=0;t<C;t++){const a=c[t],{dims:i,patch:s,disposalType:l}=a;3===l&&(M.clearRect(0,0,f,d),M.drawImage(m,0,0)),p.width!==i.width&&(p.width=i.width),p.height!==i.height&&(p.height=i.height);const h=new ImageData(new Uint8ClampedArray(s.buffer),i.width,i.height);v.putImageData(h,0,0),u.drawImage(p,i.left||0,i.top||0);const y=V(m,e,n,o);x.push(y),b=y.cols,w=y.rowCount,2===l?u.clearRect(i.left||0,i.top||0,i.width,i.height):3===l&&(u.clearRect(0,0,f,d),u.drawImage(g,0,0)),r?.((t+1)/C)}return{frames:x,cols:b,rows:w,fps:$}}var X=new WeakMap,G=new WeakMap,Q=new WeakMap;function Z(t,e,n,o,r,a=0,i){if(!e.length||!e[0].length||o<=0||r<=0)return;let s=null;if(n.hoverStrength>0){let e=X.get(t);e||(e={x:.5,y:.5,intensity:0,time:-1,emittedAt:-1,points:[]},X.set(t,e)),s=function(t,e,n){const o=t.time<0?1/60:Math.max(0,Math.min(.1,(n-t.time)/1e3));t.time=n;const r=t.intensity<.003,a=t.x,i=t.y;if(e){r&&(t.x=e.x,t.y=e.y);const n=1-Math.exp(-o/.055);t.x+=(e.x-t.x)*n,t.y+=(e.y-t.y)*n}t.intensity+=((e?.intensity??(e?1:0))-t.intensity)*(1-Math.exp(-o/(e?.09:.18)));const s=Math.exp(-o/.22);for(const e of t.points)e.intensity*=s;for(;t.points.length&&t.points[0].intensity<.01;)t.points.shift();return e&&!r&&n-t.emittedAt>=24&&Math.hypot(t.x-a,t.y-i)>5e-4&&(t.points.push({x:t.x,y:t.y,intensity:t.intensity,vx:Math.max(-1,Math.min(1,(t.x-a)/Math.max(o,.001))),vy:Math.max(-1,Math.min(1,(t.y-i)/Math.max(o,.001)))}),t.points.length>12&&t.points.shift(),t.emittedAt=n),!e&&t.intensity<.003&&!t.points.length?(t.intensity=0,null):{x:t.x,y:t.y,intensity:t.intensity,trail:t.points}}(e,i??null,performance.now())}else X.delete(t);if("none"!==n.animationStyle||n.charsetFrames?.length||n.hoverStrength<=0)return Q.delete(t),void tt(t,e,n,o,r,a,s);const c=G.get(t);if(c?.frame!==e)return G.set(t,{frame:e,since:performance.now()}),Q.delete(t),void tt(t,e,n,o,r,a,s);if(performance.now()-c.since<100)return void tt(t,e,n,o,r,a,s);const l=t.getTransform();if(l.b||l.c||l.a<=0||l.d<=0)return void tt(t,e,n,o,r,a,s);if(!s||(s.intensity??0)<.003)return void tt(t,e,n,o,r,a,null);const h=x(t.canvas),f={...n,accentColor:"#"+j(n.accentColor)},d=JSON.stringify([f,o,r,l.a,l.d,h,void 0!==document.fonts?document.fonts.status:"loaded"]);let m=Q.get(t);if(!m||m.frame!==e||m.key!==d){const n=m?.canvas??document.createElement("canvas");n.width=Math.ceil(o*l.a),n.height=Math.ceil(r*l.d);const a=n.getContext("2d");a.setTransform(l.a,0,0,l.d,0,0),tt(a,e,f,o,r,0,null,void 0,h),m={frame:e,key:d,canvas:n},Q.set(t,m)}if(t.clearRect(0,0,o,r),t.drawImage(m.canvas,0,0,o,r),!s||(s.intensity??0)<.003)return;const u=e.length,g=e[0].length,M=.08+.35*n.hoverRadius+.04*n.hoverStrength,p="trail"===n.hoverEffect?[s,...s.trail??[]]:[s];let v=1,b=1,w=0,y=0;for(const t of p)v=Math.min(v,t.x-M),w=Math.max(w,t.x+M),b=Math.min(b,t.y-M),y=Math.max(y,t.y+M);if("glitchText"===n.hoverEffect){const t=n.hoverText,e=Math.max(1,...(Array.isArray(t)?t:[t]).map(t=>t.length));v=Math.min(v,s.x-e/g),w=Math.max(w,s.x+e/g)}const S=Math.ceil(5+4*n.hoverStrength),$={x:Math.max(0,Math.floor(v*g)-S),y:Math.max(0,Math.floor(b*u)-S),right:Math.min(g,Math.ceil(w*g)+S),bottom:Math.min(u,Math.ceil(y*u)+S)};t.save(),t.beginPath(),t.rect($.x*o/g,$.y*r/u,($.right-$.x)*o/g,($.bottom-$.y)*r/u),t.clip(),tt(t,e,f,o,r,a,s,$,h),t.restore()}function tt(t,e,n,o,r,a=0,i,s,c){const l=e.length;if(0===l)return;const h=e[0].length;t.clearRect(0,0,o,r);let f=!1;const d=Math.max(1,l>>2),m=Math.max(1,h>>2);t:for(let t=0;t<l;t+=d){const n=e[t];for(let t=0;t<h;t+=m)if(n[t].a<200){f=!0;break t}}const g=t.canvas,p=c??x(g);f||(t.fillStyle=p?"#0a0a0a":"#faf9f7",t.fillRect(0,0,o,r));const v=o/h,b=r/l,w=i?.intensity??1,S=!!(i&&n.hoverStrength>0&&w>.005),C="#"+(B(n.hoverColor||"#ffffff")??"ffffff"),E=parseInt(C.slice(1,3),16),T=parseInt(C.slice(3,5),16),A=parseInt(C.slice(5,7),16),F=j(n.accentColor),I=parseInt(F.substring(0,2),16),R=parseInt(F.substring(2,4),16),k=parseInt(F.substring(4,6),16),P=n.hoverRadius;let H=0,W=h,O=0,N=l,U=0,V=0;if(S&&i){U=i.x,V=i.y;const t=.08+.35*P+.04*n.hoverStrength;H=Math.max(0,Math.floor((U-t)*h)-1),W=Math.min(h,Math.ceil((U+t)*h)+1),O=Math.max(0,Math.floor((V-t)*l)-1),N=Math.min(l,Math.ceil((V+t)*l)+1)}if(S&&"trail"===n.hoverEffect)for(const t of i?.trail??[]){const e=.08+.35*P+.04*n.hoverStrength;H=Math.min(H,Math.max(0,Math.floor((t.x-e)*h)-1)),W=Math.max(W,Math.min(h,Math.ceil((t.x+e)*h)+1)),O=Math.min(O,Math.max(0,Math.floor((t.y-e)*l)-1)),N=Math.max(N,Math.min(l,Math.ceil((t.y+e)*l)+1))}const D=n.animationStyle,K=n.animationSpeed,Y="none"===D,_=n.hoverStrength,J=n.hoverEffect,X=P,G=n.hoverShape||"circle",Q=q(n.invert,g),Z=n.colorMode,tt=2*Math.PI,et=1/h,nt=1/l;let ot="",rt=-1;if("dots"===n.renderMode){const c=.5*Math.min(v,b)*n.dotSizeRatio;for(let n=s?.y??0;n<(s?.bottom??l);n++){const f=e[n];for(let e=s?.x??0;e<(s?.right??h);e++){const s=f[e];if(s.a<10)continue;const d=.00392156863*(.299*s.r+.587*s.g+.114*s.b),m=Q?1-d:d;if(m<.02)continue;const g=Y?1:y(e,n,h,l,a,D,K);let p=1,x=0,C=0,F=0,L=0;if(S&&e>=H&&e<=W&&n>=O&&n<=N){const t=$(e*et,n*nt,U,V,w,_,v,b,J,X,G,i?.trail,o/r);p=t.scale,x=t.offsetX,C=t.offsetY,F=t.glow,L=t.colorBlend}const P=c*m*g*p;if(P<.3)continue;const z=e*v+.5*v+x,q=n*b+.5*b+C;let B;if(L>0){const t=M(s,Z,I,R,k,Q);B=`rgb(${Math.min(255,t[0]+(E-t[0])*L|0)},${Math.min(255,t[1]+(T-t[1])*L|0)},${Math.min(255,t[2]+(A-t[2])*L|0)})`}else B=u(s,Z,I,R,k,Q);const j=Math.min(1,.00392156863*s.a*g*(1+F));if(j!==rt&&(t.globalAlpha=j,rt=j),B!==ot&&(t.fillStyle=B,ot=B),P<=3){const e=2*P;t.fillRect(z-P,q-P,e,e)}else t.beginPath(),t.arc(z,q,P,0,tt),t.fill()}}}else{const c=.55,f=.9*Math.min(v/c,b);{const e=/\p{Extended_Pictographic}/u.test(n.customText||n.charset);t.font=e?`${f}px "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif`:`${f}px "JetBrains Mono", monospace`,t.textAlign="center",t.textBaseline="middle"}const d=n.charsetFrames,m=!!d?.length,g=m?d[Math.floor(Math.max(0,a)*(n.charsetFps??2))%d.length]:n.charset,p=t.getTransform();if(!S&&Y&&!m&&"accent"===Z&&!s&&n.hoverStrength<=0&&!/\p{Extended_Pictographic}/u.test(n.customText||n.charset)&&"letterSpacing"in t&&/^[\x20-\x7e]*$/.test(n.customText||n.charset)&&e.every(t=>t.every(t=>t.a<10||255===t.a&&1===t.char.length&&/^[\x20-\x7e]$/.test(t.char)))){const n=t.letterSpacing;t.letterSpacing="0px";const o=t.measureText("M").width;t.letterSpacing=v-o+"px",t.fillStyle=`rgb(${I},${R},${k})`,t.globalAlpha=1,t.textAlign="left";for(let n=0;n<l;n++){const r=e[n];let a="";for(let t=0;t<h;t++){const e=r[t];a+=e.a<10?" ":e.char}0!==a.trim().length&&t.fillText(a,.5*(v-o),n*b+.5*b)}return t.letterSpacing=n,t.textAlign="center",void(t.globalAlpha=1)}const x="glitchText"===J&&S,C="!@#$%^&*<>{}[]|/\\~`0123456789",F=C.length;let q="",B=0,j=0,tt=0,at=0,it=0,st=0;if(x){const t=n.hoverText??"ASCIIFY";if(j=Math.round(U*h),tt=Math.round(V*l),Array.isArray(t)){const e=t.filter(t=>t.length>0);0===e.length&&e.push("ASCIIFY");q=e[((7*Math.floor(j/Math.max(1,Math.ceil(h/5)))+13*Math.floor(tt/Math.max(1,Math.ceil(l/3))))%e.length+e.length)%e.length]}else q=t||"ASCIIFY";B=q.length,at=Math.max(3,Math.min(12,Math.round(l*P*.6)));const e=Math.floor(at/2);it=Math.max(0,tt-e),it+at>l&&(it=Math.max(0,l-at)),st=j-Math.floor(B/2)}for(let n=s?.y??0;n<(s?.bottom??l);n++){const c=e[n];for(let f=s?.x??0;f<(s?.right??h);f++){const s=c[f];if(s.a<10)continue;let d=m&&null!=s.lum?z(s.lum,L(g),Q):s.char;if(" "===d)continue;const P=Y?1:y(f,n,h,l,a,D,K);if(P<.05)continue;let ct=1,lt=0,ht=0,ft=0,dt=0;if(S&&!x&&f>=H&&f<=W&&n>=O&&n<=N){const t=$(f*et,n*nt,U,V,w,_,v,b,J,X,G,i?.trail,o/r);if(ct=t.scale,lt=t.offsetX,ht=t.offsetY,ft=t.glow,dt=t.colorBlend,"trail"===J&&t.proximity>0){const o=Math.max(0,Math.min(h-1,Math.round(f-t.offsetX/v))),r=e[Math.max(0,Math.min(l-1,Math.round(n-t.offsetY/b)))][o],a=r.lum??.299*r.r+.587*r.g+.114*r.b;d=z(Math.min(255,a+t.proximity*_*65),L(g),Q)}}if(x&&n>=it&&n<it+at){const t=f-st;if(t>=0&&t<B){const e=q[t],o=Math.abs(n-tt)/Math.max(1,.5*at),r=Math.abs(f-j)/Math.max(1,B),i=Math.max(o,r),s=Math.max(0,Math.min(1,1-.9*i)),c=43758.5453*Math.sin(127.1*f+311.7*n+43758.5453*Math.floor(12*a));d=Math.abs(c-Math.floor(c))<s?e:C[Math.abs(Math.floor(97*c))%F],ft=.3+.7*s,dt=.3+.65*s}}const mt=f*v+.5*v+lt,ut=n*b+.5*b+ht;let gt;if(dt>0){const t=M(s,Z,I,R,k,Q);gt=`rgb(${Math.min(255,t[0]+(E-t[0])*dt|0)},${Math.min(255,t[1]+(T-t[1])*dt|0)},${Math.min(255,t[2]+(A-t[2])*dt|0)})`}else gt=u(s,Z,I,R,k,Q);const Mt=Math.min(1,.00392156863*s.a*P*(1+ft));Mt!==rt&&(t.globalAlpha=Mt,rt=Mt),gt!==ot&&(t.fillStyle=gt,ot=gt),1!==ct?(t.translate(mt,ut),t.scale(ct,ct),t.fillText(d,0,0),t.setTransform(p)):t.fillText(d,mt,ut)}}}t.globalAlpha=1}function et(t){return Math.max(0,Math.min(1,t))}function nt(t){return"string"==typeof t?document.querySelector(t):t instanceof HTMLElement?t:null}function ot(t){return"ascii"===t.renderMode&&"none"===t.animationStyle&&t.hoverStrength<=0&&!t.charsetFrames?.length}function rt(t,e={}){const n=et(t),o=et(n*(void 0===e.speed?1:Math.max(.001,e.speed)));return et(e.ease?e.ease(o):o)}function at(t,e,n={}){if(!Number.isFinite(t.duration)||t.duration<=0)return;const o=n.from??0,r=n.to??t.duration,a=Math.max(o,Math.min(r,t.duration)),i=rt(e,n),s=o+(a-o)*i;t.currentTime=Math.min(Math.max(o,s),Math.max(o,a-.04)),n.onUpdate?.(i,t)}function it(t,e){return Math.abs(t.currentTime-e)<1/240?st(t):new Promise(n=>{const o=()=>{t.removeEventListener("seeked",o),n()};t.addEventListener("seeked",o,{once:!0});const r=t.fastSeek;r?r.call(t,e):t.currentTime=e})}function st(t){const e=t.requestVideoFrameCallback;return new Promise(e?n=>{let o=!1;const r=()=>{o||(o=!0,n())};e.call(t,r),window.setTimeout(r,32)}:t=>requestAnimationFrame(()=>t()))}function ct(t,e={}){const n=nt(e.trigger)??t;t.pause();const o=e.gsap,r=e.ScrollTrigger??o?.ScrollTrigger;if(o&&r?.create){o.registerPlugin?.(r);const a=r.create({trigger:n,start:e.start??"top bottom",end:e.end??"bottom top",scrub:e.scrub??!0,onUpdate:n=>at(t,n.progress,e)});return()=>a.kill?.()}return function(t,e,n){let o=0;const r=()=>{o=0;const r=e.getBoundingClientRect(),a=window.innerHeight||document.documentElement.clientHeight,i=r.height+a,s=i>0?et((a-r.top)/i):0;at(t,s,n)},a=()=>{o||(o=requestAnimationFrame(r))};return window.addEventListener("scroll",a,{passive:!0}),window.addEventListener("resize",a),a(),()=>{window.removeEventListener("scroll",a),window.removeEventListener("resize",a),o&&cancelAnimationFrame(o)}}(t,n,e)}function lt(t,e,n){const o=e.gsap,r=e.ScrollTrigger??o?.ScrollTrigger;if(o&&r?.create){o.registerPlugin?.(r);const a=r.create({trigger:t,start:e.start??"top bottom",end:e.end??"bottom top",scrub:e.scrub??!0,onUpdate:t=>n(t.progress)});return()=>a.kill?.()}return function(t,e){let n=0;const o=()=>{n=0;const o=t.getBoundingClientRect(),r=window.innerHeight||document.documentElement.clientHeight,a=o.height+r,i=a>0?et((r-o.top)/a):0;e(i)},r=()=>{n||(n=requestAnimationFrame(o))};return window.addEventListener("scroll",r,{passive:!0}),window.addEventListener("resize",r),r(),()=>{window.removeEventListener("scroll",r),window.removeEventListener("resize",r),n&&cancelAnimationFrame(n)}}(t,n)}function ht(t,e,n){if(!t||!e||!n.sourceCrop)return{w:t,h:e};const o=N(n.sourceCrop,t,e);return{w:Math.max(1,Math.round(o.width)),h:Math.max(1,Math.round(o.height))}}function ft(t,e,n,o){const r=o.chromaKey;if(null==r||!1===r)return!1;if(!0===r)return e>1.4*t&&e>1.4*n&&e>80;if("blue-screen"===r)return n>1.4*t&&n>1.4*e&&n>80;const a=b(r),i=(o.chromaKeyTolerance??60)**2,s=t-a.r,c=e-a.g,l=n-a.b;return s*s+c*c+l*l<=i}function dt(t,e,n){if(!e.chromaKey||!e.sourceCrop||"off"===e.chromaKeyTrimMode)return e;const o=t instanceof HTMLVideoElement?t.videoWidth:t.width,r=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(!o||!r)return e;const a=N(e.sourceCrop,o,r),i=Math.min(360,Math.max(1,Math.round(a.width))),c=Math.max(1,Math.round(i*(a.height/a.width))),{ctx:l}=s(i,c);l.drawImage(t,a.x,a.y,a.width,a.height,0,0,i,c);const h=l.getImageData(0,0,i,c).data,f=Math.max(0,Math.min(255,e.chromaKeyTrimLuminanceThreshold??0));let d=i,m=c,u=-1,g=-1;for(let t=0;t<c;t++)for(let n=0;n<i;n++){const o=4*(t*i+n),r=h[o+3],a=h[o],s=h[o+1],c=h[o+2];r<=8||.2126*a+.7152*s+.0722*c<=f||ft(a,s,c,e)||(n<d&&(d=n),t<m&&(m=t),n>u&&(u=n),t>g&&(g=t))}if(u<d||g<m)return e;const M=Math.max(0,Math.min(.25,e.chromaKeyTrimPadding??.002)),p=Math.round(i*M),v=Math.round(c*M);d=Math.max(0,d-p),m=Math.max(0,m-v),u=Math.min(i-1,u+p),g=Math.min(c-1,g+v);const x=function(t,e,n,o,r){const a=r&&Number.isFinite(r)&&r>0?r:null;if(!a)return t;const i=e.x,s=e.y,c=e.x+e.width,l=e.y+e.height,h=Math.max(i,t.left),f=Math.max(s,t.top),d=Math.min(c,n-t.right),m=Math.min(l,o-t.bottom),u=Math.max(1,d-h),g=Math.max(1,m-f),M=h+u/2,p=f+g/2;let v=u,x=g;v/x<a?v=x*a:x=v/a;v>e.width&&(v=e.width,x=Math.max(g,Math.min(e.height,v/a)));x>e.height&&(x=e.height,v=Math.max(u,Math.min(e.width,x*a)));let b=M-v/2,w=p-x/2;return b=Math.max(i,Math.min(c-v,b)),w=Math.max(s,Math.min(l-x,w)),{left:b,top:w,right:n-(b+v),bottom:o-(w+x)}}({left:a.x+d/i*a.width,top:a.y+m/c*a.height,right:o-(a.x+(u+1)/i*a.width),bottom:r-(a.y+(g+1)/c*a.height)},{x:a.x,y:a.y,width:a.width,height:a.height},o,r,n);return{...e,sourceCrop:{unit:"pixel",...x,preserveAspect:!1}}}function mt(t){const e=t.sourceCrop;return e&&"pixel"===e.unit?void 0===e.left||void 0===e.top||void 0===e.right||void 0===e.bottom?null:{left:e.left,top:e.top,right:e.right,bottom:e.bottom}:null}async function ut(t,e,n,o,r){if(!e.chromaKey||!e.sourceCrop||"range"!==e.chromaKeyTrimMode)return e;const a=t.currentTime,i=function(t,e,n,o){const r=!0===o?{}:o||{},a=Math.max(0,r.from??e),i=r.to??n??(Number.isFinite(t.duration)?t.duration:a),s=Math.max(a,i-.04),c=Math.max(0,s-a),l=c>.1?[a,a+.25*c,a+.5*c,a+.75*c,s]:[a];return Array.from(new Set(l.map(t=>Math.max(0,Number(t.toFixed(3))))))}(t,n,o,r);let s=null;for(const n of i){await it(t,n),await st(t);const o=mt(dt(t,e));o&&(s=s?{left:Math.min(s.left,o.left),top:Math.min(s.top,o.top),right:Math.min(s.right,o.right),bottom:Math.min(s.bottom,o.bottom)}:o)}return await it(t,a),await st(t),s?{...e,sourceCrop:{unit:"pixel",...s,preserveAspect:!0}}:e}function gt(t,e,n=2048){return Mt({sourceWidth:t,sourceHeight:e,maxRenderDimension:n})}function Mt({sourceWidth:t,sourceHeight:e,cssWidth:n=0,cssHeight:o=0,maxRenderDimension:r=2048}){const a=Math.max(1,t),i=Math.max(1,e),s=a/i,c=Math.max(1,r),l=Math.min(1,c/Math.max(a,i)),h=Math.max(a,i)*l,f=Math.max(0,n,o),d=Math.min(c,Math.max(h,f));return s>=1?{renderW:Math.round(d),renderH:Math.round(d/s)}:{renderW:Math.round(d*s),renderH:Math.round(d)}}function pt(t,e,n,o){if(void 0===t)return;if("number"==typeof t)return t;const r=t.trim();if(r.endsWith("%")){const t=Number.parseFloat(r)/100;return Number.isFinite(t)?e*t:void 0}if(r.endsWith("px")){const t=Number.parseFloat(r);return Number.isFinite(t)?t:void 0}if(r.endsWith("vw")){const t=Number.parseFloat(r)/100;return Number.isFinite(t)?n*t:void 0}if(r.endsWith("vh")){const t=Number.parseFloat(r)/100;return Number.isFinite(t)?o*t:void 0}}function vt(t,e,n,o,r,a=2048,i={}){const{width:s,height:c}=e.getBoundingClientRect();if(!s||!c)return{renderW:0,renderH:0,dpr:1};const l="undefined"!=typeof window?window.innerWidth:s,h="undefined"!=typeof window?window.innerHeight:c,f=pt(i.width,s,l,h)??s,d=pt(i.height,c,l,h)??c,m=function(t,e,n,o,r){const a=t=>{const n=pt(t,e,o,r);return n&&n>0?n:0},i=t=>{const e=pt(t,n,o,r);return e&&e>0?e:0};return void 0===t?{x:0,y:0}:"number"==typeof t||"string"==typeof t?{x:a(t),y:i(t)}:{x:a(t.x),y:i(t.y)}}(i.bleed,s,c,l,h),u=f+2*m.x,g=d+2*m.y,{cssW:M,cssH:p}=function(t,e,n,o="contain"){if("fill"===o)return{cssW:t,cssH:e};let r=t,a=r/n;const i="cover"===o,s=a>e;return(i&&!s||!i&&s)&&(a=e,r=a*n),"scale-down"===o&&(r=Math.min(r,t),a=Math.min(a,e)),{cssW:Math.round(r),cssH:Math.round(a)}}(u,g,n,i.objectFit??"contain"),v="undefined"!=typeof window&&window.devicePixelRatio||1;let x,b;o&&r?({renderW:x,renderH:b}=Mt({sourceWidth:o,sourceHeight:r,cssWidth:M,cssHeight:p,maxRenderDimension:a})):(x=M,b=p);const w=8e6,y=x*v*b*v>w?Math.sqrt(w/(x*b)):v;return t.width=Math.round(x*y),t.height=Math.round(b*y),t.style.width=`${M}px`,t.style.height=`${p}px`,{renderW:x,renderH:b,dpr:y}}async function xt(t,e,{fontSize:n,artStyle:r="classic",options:i={}}={}){let s;if("string"==typeof t){const e=new Image;e.crossOrigin="anonymous",await new Promise((n,o)=>{e.onload=()=>n(),e.onerror=()=>o(new Error(`Failed to load image: ${t}`)),e.src=t}),s=e}else t instanceof HTMLImageElement&&!t.complete?(await new Promise((e,n)=>{t.onload=()=>e(),t.onerror=()=>n(new Error("Image failed to load"))}),s=t):s=t;const c=o[r],l=n??i.fontSize??10,h={...a,...c,artStyle:r,...i,fontSize:l},f=e.getContext("2d");if(!f)throw new Error("Could not get 2d context from canvas");const{w:d,h:m}=function(t){return t instanceof HTMLVideoElement?{w:t.videoWidth,h:t.videoHeight}:t instanceof HTMLImageElement?{w:t.naturalWidth||t.width,h:t.naturalHeight||t.height}:{w:t.width,h:t.height}}(s),{renderW:u,renderH:g}=gt(d,m),M="undefined"!=typeof window&&window.devicePixelRatio||1,p=8e6,v=u*M*g*M>p?Math.sqrt(p/(u*g)):M;e.width===Math.round(u*v)&&e.height===Math.round(g*v)||(e.width=Math.round(u*v),e.height=Math.round(g*v));const{frame:x}=U(s,h,u,g),b=(t,e)=>{f.save(),f.setTransform(v,0,0,v,0,0),Z(f,x,h,u,g,t/1e3,e),f.restore()};b(0,null);return C(e,b,{continuous:"none"!==h.animationStyle||!!h.charsetFrames?.length,interactive:h.hoverStrength>0}).stop}async function bt(t,e,{fontSize:n,artStyle:r="classic",options:i={}}={}){const s="string"==typeof t?await fetch(t).then(t=>t.arrayBuffer()):t,c=n??i.fontSize??10;let l={...a,...o[r],artStyle:r,...i,fontSize:c};const h=e.getContext("2d");if(!h)throw new Error("Could not get 2d context from canvas");const{frames:f,fps:d}=await _(s,l,e.width,e.height);if(!f.length)throw new Error("asciifyGif: the GIF contains no renderable frames.");const m=performance.now();let u=-1;return C(e,(t,n)=>{const o=Math.floor((t-m)*d/1e3)%f.length;o===u&&!n&&l.hoverStrength<=0&&"none"===l.animationStyle&&!l.charsetFrames?.length||(Z(h,f[o],l,e.width,e.height,(t-m)/1e3,n),u=o)},{continuous:!0,interactive:l.hoverStrength>0}).stop}async function wt(t,e,{fontSize:n,artStyle:r="classic",options:i={},fitTo:s,objectFit:c,objectPosition:l,scale:h,width:f,height:d,bleed:m,preExtract:u=!1,fps:g,maxRenderDimension:M=2048,trim:p,scroll:v,maxCachedFrames:x=90,onReady:b,onFrame:w}={}){const y=p?.start??0,S=p?.end,$=n??i.fontSize??10;let E={...a,...o[r],artStyle:r,...i,fontSize:$};const T=e.getContext("2d");if(!T)throw new Error("asciifyVideo: could not get 2d context from canvas.");const A="string"==typeof s?document.querySelector(s):s instanceof HTMLElement?s:null,F={objectFit:c,objectPosition:l,scale:h,width:f,height:d,bleed:m},I=function(t,e){var n;if(!function(t){return void 0!==t.objectFit||void 0!==t.objectPosition||void 0!==t.scale||void 0!==t.width||void 0!==t.height||void 0!==t.bleed}(e))return()=>{};const o={width:t.style.width,height:t.style.height,objectFit:t.style.objectFit,objectPosition:t.style.objectPosition,maxWidth:t.style.maxWidth,maxHeight:t.style.maxHeight,transformOrigin:t.style.transformOrigin,scale:t.style.getPropertyValue("scale")};if(e.objectFit&&(t.style.objectFit=e.objectFit),e.objectPosition&&(t.style.objectPosition=e.objectPosition,t.style.transformOrigin=e.objectPosition),void 0===e.scale&&void 0===e.bleed||(t.style.maxWidth="none",t.style.maxHeight="none"),void 0!==e.scale){const o=Number.isFinite(e.scale)&&e.scale>0?e.scale:1;t.style.setProperty("scale",String(o)),(n=t.style).transformOrigin||(n.transformOrigin=e.objectPosition??"center center")}return()=>{t.style.width=o.width,t.style.height=o.height,t.style.objectFit=o.objectFit,t.style.objectPosition=o.objectPosition,t.style.maxWidth=o.maxWidth,t.style.maxHeight=o.maxHeight,t.style.transformOrigin=o.transformOrigin,o.scale?t.style.setProperty("scale",o.scale):t.style.removeProperty("scale")}}(e,F),R=t=>()=>{t(),I()};if(u){let n;"string"==typeof t?(n=document.createElement("video"),n.crossOrigin="anonymous",n.src=t,n.readyState<2&&await new Promise((e,o)=>{n.onloadeddata=()=>e(),n.onerror=()=>o(new Error(`asciifyVideo: failed to load "${t}"`))})):n=t,E=await ut(n,E,y,S,v);const o=ht(n.videoWidth,n.videoHeight,E);A&&vt(e,A,o.w/o.h,o.w,o.h,M,F);const{renderW:r,renderH:a}=gt(o.w,o.h,M),i="undefined"!=typeof window&&window.devicePixelRatio||1,s=8e6,c=r*i*a*i>s?Math.sqrt(s/(r*a)):i;e.width===Math.round(r*c)&&e.height===Math.round(a*c)||(e.width=Math.round(r*c),e.height=Math.round(a*c));const l=void 0!==S?S-y:10,h=g??(v?18:void 0);if(ot(E)){const{frames:t,fps:o}=await Y(n,E,r,a,h,l,void 0,y),i=e=>{const n=t[e];n&&(T.save(),T.setTransform(c,0,0,c,0,0),D(T,n,E,r,a),T.restore(),w?.())};if(v){let o=!1,r=-1;const a=!0===v?{}:v,s=lt(nt(a.trigger)??A??e,a,e=>{const s=rt(e,a),c=Math.max(0,Math.min(t.length-1,Math.round(s*(t.length-1))));c!==r&&(r=c,i(c),o||(o=!0,b?.(n)),a.onUpdate?.(s,n))});return i(0),o=!0,b?.(n),R(s)}let s,f=!1,d=0,m=performance.now(),u=!0;const g=1e3/o,M=e=>{f||(e-m>=g&&(i(d),d=(d+1)%t.length,m=e,u&&(u=!1,b?.(n))),s=requestAnimationFrame(M))};return s=requestAnimationFrame(M),R(()=>{f=!0,cancelAnimationFrame(s)})}const{frames:f,fps:d}=await K(n,E,r,a,h,l,void 0,y);if(!f.length)throw new Error("asciifyVideo: no frames were decoded.");let m=0;const u=performance.now(),p=C(e,(t,e)=>{v||(m=Math.floor((t-u)*d/1e3)%f.length),T.save(),T.setTransform(c,0,0,c,0,0),Z(T,f[m],E,r,a,(t-u)/1e3,e),T.restore(),w?.()},{continuous:!v||"none"!==E.animationStyle||!!E.charsetFrames?.length,interactive:E.hoverStrength>0});let x;if(v){const t=!0===v?{}:v;x=lt(nt(t.trigger)??A??e,t,e=>{m=Math.max(0,Math.min(f.length-1,Math.round(rt(e,t)*(f.length-1)))),p.wake(),t.onUpdate?.(e,n)})}return b?.(n),R(()=>{p.stop(),x?.()})}let k,L=!1;"string"==typeof t?(k=document.createElement("video"),k.crossOrigin="anonymous",k.src=t,k.muted=!0,k.loop=!0,k.playsInline=!0,k.setAttribute("playsinline",""),Object.assign(k.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(k),L=!0,await new Promise((e,n)=>{k.onloadedmetadata=()=>e(),k.onerror=()=>n(new Error(`asciifyVideo: failed to load "${t}"`))}),await k.play().catch(()=>{})):(k=t,k.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((t,e)=>{const n=()=>{k.removeEventListener("loadedmetadata",o),k.removeEventListener("error",r)},o=()=>{n(),t()},r=()=>{n(),e(new Error("asciifyVideo: provided video element failed to load metadata."))};k.addEventListener("loadedmetadata",o),k.addEventListener("error",r),k.load()}),k.paused&&await k.play().catch(()=>{})),y>0&&(k.currentTime=y,await new Promise(t=>{const e=()=>{k.removeEventListener("seeked",e),t()};k.addEventListener("seeked",e)}),await st(k));let P=null;(y>0||void 0!==S)&&(P=()=>{(void 0!==S&&k.currentTime>=S||y>0&&k.currentTime<y)&&(k.currentTime=y)},k.addEventListener("timeupdate",P)),E=await ut(k,E,y,S,v);let z=null;const H=ht(k.videoWidth,k.videoHeight,E);let{renderW:W,renderH:q}=gt(H.w,H.h,M);const B=t=>"frame"===E.chromaKeyTrimMode?dt(t,E,W/q):E;if(A){const t=H.w/H.h,n=H.w,o=H.h,r=vt(e,A,t,n,o,M,F);W=r.renderW,q=r.renderH;const a=e.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0),z=new ResizeObserver(()=>{const r=vt(e,A,t,n,o,M,F);W=r.renderW,q=r.renderH;const a=e.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0)}),z.observe(A)}else{const t="undefined"!=typeof window&&window.devicePixelRatio||1,n=8e6,o=W*t*q*t>n?Math.sqrt(n/(W*q)):t;e.width===Math.round(W*o)&&e.height===Math.round(q*o)||(e.width=Math.round(W*o),e.height=Math.round(q*o)),T.setTransform(o,0,0,o,0,0)}let j=!0,O=null;const N=v&&!u,_=g&&g>0?1e3/g:0;let J=0;const X=!N&&ot(E);if(N&&"ascii"===E.renderMode&&"none"===E.animationStyle&&E.hoverStrength<=0&&!E.charsetFrames?.length){const t=!0===v?{}:v,n=nt(t.trigger)??A??e,o=t.from??y,r=t.to??S??k.duration,a=Math.max(o,Math.min(r,k.duration)),i=Math.max(.001,a-o),s=Math.min(60,Math.max(12,g??30)),c=Math.max(2,Math.ceil(i*s)+1),l=new Array(c),h=[],f=Math.max(2,Math.min(c,Math.floor(x))),d=()=>{for(;h.length>f;){const t=h.findIndex(t=>t!==u&&Math.abs(t-u)>2),e=t>=0?t:0,n=h.splice(e,1)[0];void 0!==n&&(l[n]=void 0)}},m=t=>{const e=h.indexOf(t);e>=0&&h.splice(e,1),h.push(t),d()};let u=0,M=0,p=-1,$=0,C=!1,F=!1,I=!1;const H=new Set,j=document.createElement("video");j.muted=!0,j.playsInline=!0,j.preload="auto",j.crossOrigin=k.crossOrigin||"anonymous",j.src=k.currentSrc||k.src,Object.assign(j.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(j),j.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((t,e)=>{const n=()=>{j.removeEventListener("loadedmetadata",o),j.removeEventListener("error",r)},o=()=>{n(),t()},r=()=>{n(),e(new Error("asciifyVideo: cache video failed to load metadata."))};j.addEventListener("loadedmetadata",o),j.addEventListener("error",r),j.load()}),j.pause(),k.paused&&await k.play().catch(()=>{});const N=t=>o+i*t/Math.max(1,c-1),U=t=>Math.max(0,Math.min(c-1,Math.round(t*(c-1)))),K=B(k),Y=V(k,K,W,q);Y.rows.length>0&&(l[0]=Y,m(0),D(T,Y,K,W,q),I=!0,b?.(k),w?.());const X=t=>{if(l[t])return t;for(let e=1;e<c;e++){const n=t-e,o=t+e;if(n>=0&&l[n])return n;if(o<c&&l[o])return o}return-1},G=()=>{if(!l[u])return u;for(const t of H)if(!l[t])return t;for(let t=1;t<c;t++){const e=u-t,n=u+t;if(e>=0&&!l[e])return e;if(n<c&&!l[n])return n}return-1},Q=t=>{t<0||t>=c||l[t]||(H.add(t),Z())},Z=async()=>{if(C||F)return;const t=G();if(!(t<0)){H.delete(t),F=!0;try{if(await it(j,N(t)),!C){const e=B(j),n=V(j,e,W,q);n.rows.length>0&&(l[t]=n,m(t))}}finally{F=!1,C||requestAnimationFrame(()=>{Z()})}}},tt=()=>{if(C)return;const t=X(u);if(t>=0&&t!==p){const e=l[t];e&&(D(T,e,E,W,q),p=t,I||(I=!0,b?.(k)),w?.())}else if(t<0||p<0){const t=performance.now();if(_<=0||t-J>=_){const e=B(k),n=V(k,e,W,q);n.rows.length>0&&(D(T,n,e,W,q),J=t,I||(I=!0,b?.(k)),w?.())}}Q(u),$=requestAnimationFrame(tt)};return O=lt(n,t,e=>{const n=function(t,e,n={}){if(!Number.isFinite(t.duration)||t.duration<=0)return null;const o=n.from??0,r=n.to??t.duration,a=Math.max(o,Math.min(r,t.duration)),i=rt(e,n),s=o+(a-o)*i;return{progress:i,time:Math.min(Math.max(o,s),Math.max(o,a-.04))}}(k,e,{...t,from:o,to:a});M=n?.progress??et(e),u=U(M),Q(u),Q(u-1),Q(u+1),Q(u-2),Q(u+2),Q(u-3),Q(u+3),t.onUpdate?.(M,k)}),Q(0),Q(1),$=requestAnimationFrame(tt),R(()=>{C=!0,cancelAnimationFrame($),O?.(),z?.disconnect(),H.clear(),h.length=0,l.fill(void 0),j.pause(),j.src="",j.removeAttribute("src"),j.load(),j.isConnected&&j.remove(),P&&k.removeEventListener("timeupdate",P),L&&(k.pause(),k.src="",k.removeAttribute("src"),k.load(),k.isConnected&&k.remove())})}if(N){const t=!0===v?{}:v;O=ct(k,{...t,trigger:t.trigger??A??e,from:t.from??y,to:t.to??S})}let G=-1,Q=0,tt=-1,at=0;const ft="function"==typeof k.requestVideoFrameCallback,mt=()=>{at=k.requestVideoFrameCallback(()=>{Q++,mt()})};ft&&mt();let Mt=0,pt=0,xt=null;const bt=C(e,(t,n)=>{if(k.readyState<2||0===e.width||0===e.height)return;if(_>0&&t-J<_&&!n)return;if(y>0&&k.currentTime<y)return;if(void 0!==S&&k.currentTime>=S)return;const o=(ft?Q!==tt:k.currentTime!==G)||Mt!==W||pt!==q;if(o||!(E.hoverStrength<=0)||"none"!==E.animationStyle||E.charsetFrames?.length){if(X){const t=B(k),e=V(k,t,W,q);D(T,e,t,W,q)}else!o&&xt||(xt=U(k,B(k),W,q).frame),Z(T,xt,E,W,q,t/1e3,n);G=k.currentTime,tt=Q,Mt=W,pt=q,J=t,j&&(j=!1,b?.(k)),w?.()}},{continuous:!0,interactive:E.hoverStrength>0});return R(()=>{bt.stop(),at&&k.cancelVideoFrameCallback(at),O?.(),z?.disconnect(),P&&k.removeEventListener("timeupdate",P),L&&(k.pause(),k.src="",k.removeAttribute("src"),k.load(),k.isConnected&&k.remove())})}function yt(t,e,n){return wt(t,e,n)}function St(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 n=t.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i);return n?{r:+n[1],g:+n[2],b:+n[3]}:null}function $t(t){return t*t*t*(t*(6*t-15)+10)}function Ct(t,e,n){return t+(e-t)*n}function Et(t,e){let n=127*t+311*e;return n^=n>>13,(n*(n*n*15731+789221)+1376312589&2147483647)/2147483647}function Tt(t,e){const n=Math.floor(t),o=Math.floor(e),r=e-o,a=$t(t-n),i=$t(r),s=Et(n,o),c=Et(n+1,o),l=Et(n,o+1),h=Et(n+1,o+1);return Ct(Ct(s,c,a),Ct(l,h,a),i)}function At(t,e){return(.5*Tt(t,e)+.25*Tt(2.1*t,2.1*e)+.125*Tt(4.3*t,4.3*e))/.875}function Ft(t,e,n,o,r={x:.5,y:.5},a={}){const{fontSize:i=13,charAspect:s=.62,lineHeightRatio:c=1.4,chars:l=" .:-=+*#%@",baseColor:h=null,accentColor:f,accentThreshold:d=.52,mouseInfluence:m=.55,mouseFalloff:u=2.8,speed:g=1,vortex:M=!0,sparkles:p=!0,breathe:v=!0,lightMode:x=!1}=a,b=f??(x?"#6b8700":"#d4ff00"),w=i*s,y=i*c,S=Math.ceil(e/w),$=Math.ceil(n/y),C=r.x,E=r.y;let T=212,A=255,F=0;{const t=b.replace("#","");6===t.length&&(T=parseInt(t.slice(0,2),16),A=parseInt(t.slice(2,4),16),F=parseInt(t.slice(4,6),16))}t.clearRect(0,0,e,n),t.font=`${i}px "JetBrains Mono", monospace`,t.textBaseline="top";const I=o*g,R=v?.12*(.5*Math.sin(.22*I)+.5):0;for(let e=0;e<$;e++)for(let n=0;n<S;n++){const o=n/S,r=e/$,a=.045,i=.08*I,s=.06,c=.45*((.5*Math.sin(.08*n+.05*e+.6*I)+.5+(.5*Math.sin(.03*n-.07*e+.4*I)+.5)+(.5*Math.sin(.05*n+.03*e+.8*I)+.5))/3)+.35*(.5*At(n*a+i,e*a*1.4-.7*i)+.5)+.2*(.5*Math.sin((n+.65*e)*s+1.1*I)+.5)+R,f=o-C,g=r-E,v=Math.sqrt(f*f+g*g);let b=0;if(M&&v<.35){const t=Math.atan2(g,f),e=Math.sin(4*t+2.2*I-14*v),n=Math.max(0,1-v/.35);b=e*n*n*.22}const k=c*(1-m)+(Math.max(0,1-v*u)+.5*b)*m+.15*b,L=Math.min(1,Math.max(0,k));let P=L;if(p&&L>.72){const t=Math.floor(8*I),o=Et(7*n+3*t,11*e+t);o>.88&&(P=Math.min(1,L+4*(o-.88)))}const z=Math.floor(P*(l.length-1));if(" "===l[z])continue;const H=.015+.07*P;if(P>d){const e=Math.min(x?.9:.28,H*(x?14:2.8));t.fillStyle=`rgba(${T},${A},${F},${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[z],n*w,e*y)}}function It(t,e,n,o,r={}){const{fontSize:a=13,chars:i="0123456789ABCDEF@#$&*+=/<>",accentColor:s,color:c,speed:l=1,density:h=.55,tailLength:f=14,lightMode:d=!1}=r,m=s??(d?"#6b8700":"#d4ff00"),u=.62*a,g=1.4*a,M=Math.ceil(e/u),p=Math.ceil(n/g);t.clearRect(0,0,e,n),t.font=`${a}px monospace`,t.textBaseline="top";let v=255,x=255,b=255;if(d&&(v=55,x=55,b=55),c){const t=St(c);t&&(v=t.r,x=t.g,b=t.b)}let w=212,y=255,S=0;const $=St(m);$&&(w=$.r,y=$.g,S=$.b);const C=p+f;for(let e=0;e<M;e++){if(Et(17*e,3)>h)continue;const n=(.5+1.5*Et(31*e,7))*l,r=Et(13*e,11)*C,a=Math.floor((o*n*7+r)%C),s=e*u;for(let n=0;n<=f;n++){const r=a-(f-n);if(r<0||r>=p)continue;const c=r*g,l=Et(53*e+Math.floor(5*o+n),7*r),h=i[Math.floor(l*i.length)],m=n/f;if(n===f)t.fillStyle=`rgba(${w},${y},${S},${d?.7:.85})`;else{const e=d?.85*m:.15*m;t.fillStyle=`rgba(${v},${x},${b},${e})`}t.fillText(h,s,c)}}}function Rt(t,e,n,o,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" . · * + ° ★",accentColor:c,color:l,speed:h=1,count:f=180,lightMode:d=!1}=a,m=c??(d?"#6b8700":"#d4ff00");t.clearRect(0,0,e,n),t.textBaseline="middle",t.textAlign="center";const u=e*(.2+.6*r.x),g=n*(.2+.6*r.y),M=.65*Math.sqrt(e*e+n*n);let p=255,v=255,x=255;if(d&&(p=55,v=55,x=55),l){const t=St(l);t&&(p=t.r,v=t.g,x=t.b)}let b=212,w=255,y=0;const S=St(m);S&&(b=S.r,w=S.g,y=S.b);const $=s.replace(/ /g,"").split("");if(0!==$.length){for(let r=0;r<f;r++){const a=Et(17*r,3)*Math.PI*2,s=(o*(.15+.85*Et(31*r,7))*h*.22+Et(13*r,11))%1,c=u+Math.cos(a)*s*M,l=g+Math.sin(a)*s*M;if(c<-20||c>e+20||l<-20||l>n+20)continue;const f=Math.max(6,i*(.4+.9*s));t.font=`${f}px monospace`;const m=$[Math.min($.length-1,Math.floor(s*$.length))],S=s>.72,C=d?.85*s:.2*s;t.fillStyle=S?`rgba(${b},${w},${y},${Math.min(d?.92:.32,2.2*C)})`:`rgba(${p},${v},${x},${C})`,t.fillText(m,c,l)}t.textAlign="left"}}function kt(t,e,n,o,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=". · ○ ◎ ●",accentColor:c,color:l,rings:h=5,speed:f=1,sharpness:d=4,lightMode:m=!1}=a,u=c??(m?"#007a5e":"#00ffcc");t.clearRect(0,0,e,n),t.textBaseline="middle",t.textAlign="center";const g=e*r.x,M=n*r.y,p=1.6*Math.sqrt(g*g+M*M)+.2*Math.sqrt(e*e+n*n);let v=255,x=255,b=255;if(m&&(v=55,x=55,b=55),l){const t=St(l);t&&(v=t.r,x=t.g,b=t.b)}let w=0,y=255,S=204;const $=St(u);$&&(w=$.r,y=$.g,S=$.b);const C=s.replace(/ /g,"").split("");if(0===C.length)return;const E=Math.ceil(e/i),T=Math.ceil(n/i);for(let e=0;e<T;e++)for(let n=0;n<E;n++){const r=n*i+.5*i,a=e*i+.5*i,s=r-g,c=a-M,l=Math.sqrt(s*s+c*c)/p;let u=0;for(let t=0;t<h;t++){const e=(o*f*.38+t/h)%1,n=Math.abs(l-e),r=Math.max(0,1-n*p/(i*(12-d)));u+=Math.cos(r*Math.PI*.5)*r}if(u=Math.min(1,u),u<.02)continue;const $=u>.6;t.font=`${i}px monospace`;const E=Math.floor(u*(C.length-1)),T=C[Math.min(E,C.length-1)],A=m?.88*u:.22*u;t.fillStyle=$?`rgba(${w},${y},${S},${Math.min(m?.95:.4,.55*u)})`:`rgba(${v},${x},${b},${A})`,t.fillText(T,r,a)}t.textAlign="left"}function Lt(t,e,n,o,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" .·:;=+*#%@░▒▓",accentColor:c,color:l,octaves:h=4,speed:f=1,scale:d=1,accentThreshold:m=.78,mouseWarp:u=.3,lightMode:g=!1}=a,M=c??(g?"#6b8700":"#d4ff00"),p=.62*i,v=1.4*i,x=Math.ceil(e/p),b=Math.ceil(n/v);t.clearRect(0,0,e,n),t.font=`${i}px monospace`,t.textBaseline="top";let w=255,y=255,S=255;if(g&&(w=55,y=55,S=55),l){const t=St(l);t&&(w=t.r,y=t.g,S=t.b)}let $=212,C=255,E=0;const T=St(M);T&&($=T.r,C=T.g,E=T.b);const A=.035*d,F=o*f,I=Math.min(6,Math.max(1,h)),R=(t,e)=>{let n=0,o=.5,r=1,a=0;for(let i=0;i<I;i++)n+=Tt(t*r,e*r)*o,a+=o,o*=.5,r*=2.1;return n/a};for(let e=0;e<b;e++)for(let n=0;n<x;n++){const o=n*A+.06*F,a=e*A*1.3-.04*F,i=n/x-r.x,c=e/b-r.y,l=Math.sqrt(i*i+c*c),h=u>0?.12*Math.max(0,1-l/u):0,f=.5*R(o+h*Math.sin(1.3*F+8*c),a+h*Math.cos(.9*F+8*i))+.5;if(f<.12)continue;const d=s[Math.floor(f*(s.length-1))];if(" "===d)continue;const M=f>m,T=g?.82*f:.13*f;t.fillStyle=M?`rgba(${$},${C},${E},${g?.92:.28})`:`rgba(${w},${y},${S},${T})`,t.fillText(d,n*p,e*v)}}function Pt(t,e,n,o,r={x:.5,y:.5},a={}){const{fontSize:i=12,chars:s="·-=+|/",accentColor:c,color:l,bands:h=3,speed:f=1,bandWidth:d=.12,glitch:m=!0,lightMode:u=!1}=a,g=c??(u?"#6b8700":"#d4ff00"),M=.62*i,p=1.4*i,v=Math.ceil(e/M),x=Math.ceil(n/p);t.clearRect(0,0,e,n),t.font=`${i}px monospace`,t.textBaseline="top";let b=255,w=255,y=255;if(u&&(b=55,w=55,y=55),l){const t=St(l);t&&(b=t.r,w=t.g,y=t.b)}let S=212,$=255,C=0;const E=St(g);E&&(S=E.r,$=E.g,C=E.b);const T=o*f;for(let e=0;e<x;e++)for(let n=0;n<v;n++){const o=e/x,a=((o*h-.5*T)%1+1)%1,i=Math.max(0,1-a/d),c=.35*(.5*Et(3*n,7*e)+.5);let l=0;if(m){const t=n/v-r.x,a=o-r.y,i=Math.sqrt(t*t+a*a);if(i<.18){const t=Et(11*n+Math.floor(12*T),5*e);l=Math.max(0,1-i/.18)*(t>.5?t-.3:0)}}const f=Math.min(1,c+.8*i+.6*l);if(f<.04)continue;const g=s[Math.floor(f*(s.length-1))],E=i>.55,A=u?.82*f:.12*f;t.fillStyle=E?`rgba(${S},${$},${C},${u?.92:.28})`:`rgba(${b},${w},${y},${A})`,t.fillText(g,n*M,e*p)}}function zt(t,e,n,o,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" ·∙•:;+=≡≣#@",color:c,accentColor:l,speed:h=1,layers:f=5,softness:d=1.2,mouseRipple:m=.2,lightMode:u=!1}=a,g=l??(u?"#6b8700":"#d4ff00"),M=.62*i,p=1.4*i,v=Math.ceil(e/M),x=Math.ceil(n/p);t.clearRect(0,0,e,n),t.font=`${i}px monospace`,t.textBaseline="top";let b=255,w=255,y=255;if(u&&(b=55,w=55,y=55),c){const t=St(c);t&&(b=t.r,w=t.g,y=t.b)}let S=212,$=255,C=0;const E=St(g);E&&(S=E.r,$=E.g,C=E.b);const T=o*h,A=[];for(let t=0;t<f;t++){const e=Et(17*t,31*t+7),n=Et(23*t+5,11*t);A.push({fx:.8+2.2*e,fy:1.2+1.8*n,phase:e*Math.PI*4,dt:(.3+.5*Et(7*t,13*t+3))*(t%2==0?1:-1),amp:.55+.45*Et(29*t,3*t)})}for(let e=0;e<x;e++){const n=e/x;for(let o=0;o<v;o++){const a=o/v,i=a-r.x,c=n-r.y,l=Math.sqrt(i*i+c*c),h=m*Math.exp(-l*l/.06),g=a+i*h,x=n+c*h;let E=0,F=0;for(let t=0;t<f;t++){const{fx:e,fy:n,phase:o,dt:r,amp:a}=A[t];E+=Math.sin(g*e*Math.PI*2+T*r+o)*Math.cos(x*n*Math.PI*2+T*r*.7+1.3*o)*a,F+=a}const I=E/F,R=.5+.5*Math.tanh(I*d*2.2);if(R<.12)continue;const k=(R-.12)/.88,L=s[Math.min(s.length-1,Math.floor(k*s.length))],P=R>.82,z=u?.82*R:.14*R;t.fillStyle=P?`rgba(${S},${$},${C},${u?.92:.32})`:`rgba(${b},${w},${y},${z})`,t.fillText(L,o*M,e*p)}}}function Ht(t,e,n,o,r={}){const{fontSize:a=13,color:i,accentColor:s,speed:c=.4,layers:l=4,turbulence:h=.8,lightMode:f=!1}=r,d=s??(f?"#6b8700":"#d4ff00"),m=.62*a,u=1.4*a,g=Math.ceil(e/m),M=Math.ceil(n/u);t.clearRect(0,0,e,n),t.font=`${a}px monospace`,t.textBaseline="top";let p=255,v=255,x=255;if(f&&(p=55,v=55,x=55),i){const t=St(i);t&&(p=t.r,v=t.g,x=t.b)}let b=212,w=255,y=0;const S=St(d);S&&(b=S.r,w=S.g,y=S.b);const $=o*c,C=["─","─","╌","·","╌","─","─","╌","·"];for(let e=0;e<M;e++){const n=e/M;for(let o=0;o<g;o++){const r=o/g;let a=0,i=0;for(let t=0;t<l;t++){const e=Et(13*t,7*t+3),o=1.1+2.4*e,s=.9+2*Et(29*t,11*t+1),c=e*Math.PI*6,l=(.2+.5*Et(41*t,17*t))*(t%2==0?1:-1.3),f=Math.sin(r*o*Math.PI*2+$*l+c),d=Math.cos(n*s*Math.PI*2+$*l*.6+1.7*c),m=Math.sin(r*s*Math.PI*h+n*o*Math.PI*h+$*l*.4);a+=Math.atan2(d+.3*m,f),i+=.5*(f*d+1)}const s=a/l,c=Math.min(1,i/l);if(c<.1)continue;const d=(s+Math.PI)/(2*Math.PI),M=C[Math.floor(d*C.length)%C.length],S=c>.8,E=f?.8*c:.13*c;t.fillStyle=S?`rgba(${b},${w},${y},${f?.9:.26})`:`rgba(${p},${v},${x},${E})`,t.fillText(M,o*m,e*u)}}}function Wt(t,e,n,o,r={x:.5,y:.5},a={}){const{fontSize:i=13,chars:s=" ·:;=+*#%@",color:c,accentColor:l,speed:h=1,radius:f=.38,swirl:d=3,lightMode:m=!1}=a,u=l??(m?"#6b8700":"#d4ff00"),g=.62*i,M=1.4*i,p=Math.ceil(e/g),v=Math.ceil(n/M),x=e/n;t.clearRect(0,0,e,n),t.font=`${i}px monospace`,t.textBaseline="top";let b=255,w=255,y=255;if(m&&(b=55,w=55,y=55),c){const t=St(c);t&&(b=t.r,w=t.g,y=t.b)}let S=212,$=255,C=0;const E=St(u);E&&(S=E.r,$=E.g,C=E.b);const T=o*h;for(let e=0;e<v;e++){const n=e/v;for(let o=0;o<p;o++){const a=(o/p-r.x)*x,i=n-r.y,c=Math.sqrt(a*a+i*i)/f;if(c>1){const n=Et(3*o,7*e)*Math.max(0,1-3*(c-1));if(n<.62)continue;const r=n*(m?.28:.04);t.fillStyle=`rgba(${b},${w},${y},${r})`,t.fillText(s[1],o*g,e*M);continue}const l=Math.max(0,1-Math.abs(c-(.15+.12*Math.sin(1.1*T)))/.07),h=Math.pow(1-c,2.2),d=Math.min(1,h+.6*l);if(d<.06)continue;const u=Math.floor(d*(s.length-1)),v=s[Math.min(s.length-1,u)],E=l>.35||c<.08,A=m?.85*d:.18*d;t.fillStyle=E?`rgba(${S},${$},${C},${m?.95:.38})`:`rgba(${b},${w},${y},${A})`,t.fillText(v,o*g,e*M)}}}function qt(t,e,n,o,r={}){const{fontSize:a=14,chars:i=" ·∙•:-=+*#",color:s,accentColor:c,speed:l=.5,harmonics:h=3,lightMode:f=!1}=r,d=c??(f?"#6b8700":"#d4ff00"),m=.62*a,u=1.4*a,g=Math.ceil(e/m),M=Math.ceil(n/u);t.clearRect(0,0,e,n),t.font=`${a}px monospace`,t.textBaseline="top";let p=255,v=255,x=255;if(f&&(p=55,v=55,x=55),s){const t=St(s);t&&(p=t.r,v=t.g,x=t.b)}let b=212,w=255,y=0;const S=St(d);S&&(b=S.r,w=S.g,y=S.b);const $=o*l,C=Array.from({length:h},(t,e)=>1/(e+1)).reduce((t,e)=>t+e,0);for(let e=0;e<M;e++)for(let n=0;n<g;n++){let o=0;for(let t=0;t<h;t++){const r=.18+1.4*Et(n*(t+3)+7,e*(t+5)+11),a=Et(n*(t+7),e*(t+9)+3)*Math.PI*2,i=1/(t+1);o+=Math.sin($*r+a)*i}const r=.5*(o/C+1);if(r<.28)continue;const a=(r-.28)/.72,s=i[Math.min(i.length-1,Math.floor(a*i.length))],c=r>.88,l=f?.82*a:.13*a;t.fillStyle=c?`rgba(${b},${w},${y},${f?.92:.28})`:`rgba(${p},${v},${x},${l})`,t.fillText(s,n*m,e*u)}}function Bt(t,e,n,o,r={}){const{fontSize:a=13,chars:i=" .,:;i+xX#&@",color:s="#ff4500",hotColor:c="#ffe066",intensity:l=.85,wind:h=0,speed:f=1,lightMode:d=!1}=r,m=.62*a,u=1.4*a,g=Math.ceil(e/m),M=Math.ceil(n/u),p=g*M,v="__fire_heat__",x=t.canvas;let b=x[v];b&&b.length===p||(b=new Float32Array(p),x[v]=b);const w=.18*(.016*f),y=h*f*.8,S=M-1,$=o*f;for(let t=0;t<g;t++){const e=(.6*(.5*Math.sin(.31*t+4.1*$)+.5)+.4*(.5*Math.sin(.73*t-2.7*$)+.5))*l;b[S*g+t]=Math.min(1,e+.15*Math.random()*l),S>0&&(b[(S-1)*g+t]=Math.min(1,.85*e+.1*Math.random()*l))}const C=new Float32Array(p);for(let t=0;t<M-2;t++)for(let e=0;e<g;e++){const n=.4*b[(t+1)*g+e]+.25*b[(t+2)*g+Math.max(0,Math.min(g-1,e+Math.round(y)))]+.175*b[(t+1)*g+Math.max(0,e-1)]+.175*b[(t+1)*g+Math.min(g-1,e+1)];C[t*g+e]=Math.max(0,n-w-.02*Math.random()*f)}for(let t=0;t<g;t++)C[(M-1)*g+t]=b[(M-1)*g+t],M>1&&(C[(M-2)*g+t]=b[(M-2)*g+t]);x[v]=C;const E=St(s)??{r:255,g:69,b:0},T=St(c)??{r:255,g:224,b:102};t.clearRect(0,0,e,n),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";for(let e=0;e<M;e++)for(let n=0;n<g;n++){const o=C[e*g+n];if(o<.03)continue;const r=i[Math.min(i.length-1,Math.floor(o*i.length))];if(" "===r)continue;const a=Math.min(1,1.2*o),s=E.r+(T.r-E.r)*a|0,c=E.g+(T.g-E.g)*a|0,l=E.b+(T.b-E.b)*a|0,h=d?1-.3*o:Math.min(1,o+.15);t.globalAlpha=h,t.fillStyle=`rgb(${s},${c},${l})`,t.fillText(r,n*m,e*u)}t.globalAlpha=1}function jt(t,e,n,o,r={}){const{fontSize:a=13,baseChars:i="ATCG",bridgeChars:s="-=≡",color:c="#00e5ff",color2:l="#ff4081",bridgeColor:h="#88ffcc",speed:f=1,helixCount:d,lightMode:m=!1}=r,u=.62*a,g=1.4*a,M=Math.ceil(e/u),p=Math.ceil(n/g),v=d??Math.max(1,Math.floor(e/80)),x=M/v,b=St(c)??{r:0,g:229,b:255},w=St(l)??{r:255,g:64,b:129},y=St(h)??{r:136,g:255,b:204};t.clearRect(0,0,e,n),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const S=o*f,$=.35*x;for(let e=0;e<v;e++){const n=x*(e+.5);for(let o=0;o<p;o++){const r=o/p*Math.PI*6-1.8*S,a=n+Math.sin(r)*$,c=n+Math.sin(r+Math.PI)*$,l=Math.round(a),h=Math.round(c);if(l<0||l>=M)continue;const f=Et(31*e+7*o,3),d=i[Math.floor(f*i.length)],m=.5*(Math.sin(r)+1),v=.5*(Math.sin(r+Math.PI)+1);if(t.globalAlpha=.35+.65*m,t.fillStyle=`rgb(${b.r},${b.g},${b.b})`,t.fillText(d,l*u,o*g),h>=0&&h<M){const n=Et(53*e+11*o,7),r=i[Math.floor(n*i.length)];t.globalAlpha=.35+.65*v,t.fillStyle=`rgb(${w.r},${w.g},${w.b})`,t.fillText(r,h*u,o*g)}if(o%3===0){const n=Math.min(l,h),r=Math.max(l,h);if(r-n>1){const a=Et(17*o+43*e,5),i=s[Math.floor(a*s.length)],c=.25*(m+v)+.2;t.globalAlpha=c,t.fillStyle=`rgb(${y.r},${y.g},${y.b})`;for(let e=n+1;e<r;e++)t.fillText(i,e*u,o*g)}}}}t.globalAlpha=1}function Ot(t,e,n,o,r={}){const{fontSize:a=13,chars:i=" .,:;+*#@",color:s="#4caf50",skyColor:c="#1a237e",peakColor:l="#e0e0e0",speed:h=1,roughness:f=.55,heightScale:d=.55,stars:m=!0,lightMode:u=!1}=r,g=.62*a,M=1.4*a,p=Math.ceil(e/g),v=Math.ceil(n/M),x=St(s)??{r:76,g:175,b:80},b=St(c)??{r:26,g:35,b:126},w=St(l)??{r:224,g:224,b:224};t.clearRect(0,0,e,n),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const y=o*h*.4,S=new Array(p);for(let t=0;t<p;t++){const e=(.5*At((t/p+y)*f*3,.5)+.5)*d;S[t]=Math.floor(e*v)}for(let e=0;e<v;e++)for(let n=0;n<p;n++){const r=v-1-S[n],a=e===r;if(!(e>=r)){if(m){const r=Et(7*n+Math.floor(.3*y),13*e);if(r>.97){const a=.3*Math.sin(2*o+100*r)+.7;t.globalAlpha=.5*a,t.fillStyle=`rgb(${b.r+60},${b.g+60},${b.b+80})`,t.fillText("·",n*g,e*M)}}continue}const s=(e-r)/Math.max(1,S[n]),c=i[Math.min(i.length-1,Math.floor(s*i.length))];if(" "===c&&!a)continue;const l=a?1:Math.max(0,1-4*s),h=x.r+(w.r-x.r)*l|0,f=x.g+(w.g-x.g)*l|0,d=x.b+(w.b-x.b)*l|0;t.globalAlpha=.5+.5*s,t.fillStyle=`rgb(${h},${f},${d})`,t.fillText(a?i[i.length-1]:c,n*g,e*M)}t.globalAlpha=1}var Nt=1,Ut=2,Vt=4,Dt=8,Kt={3:"─",12:"│",9:"┌",10:"┐",5:"└",6:"┘",11:"┬",7:"┴",13:"├",14:"┤",15:"┼",[Nt]:"╶",[Ut]:"╴",[Vt]:"╵",[Dt]:"╷"};function Yt(t,e,n,o,r={}){const{fontSize:a=13,pulseColor:i="#ffffff",color:s="#00ff88",density:c=.38,speed:l=1,lightMode:h=!1}=r,f=.62*a,d=1.4*a,m=Math.ceil(e/f),u=Math.ceil(n/d),g=St(s)??{r:0,g:255,b:136},M=St(i)??{r:255,g:255,b:255},p=(t,e)=>{if(Et(17*t+1,7*e+2)>c)return 0;let n=0;return t+1<m&&Et(17*t+1,7*e+2)>.15&&(n|=1),t-1>=0&&Et(17*(t-1)+1,7*e+2)>.15&&(n|=2),e+1<u&&Et(17*t+1,7*(e+1)+2)>.15&&(n|=8),e-1>=0&&Et(17*t+1,7*(e-1)+2)>.15&&(n|=4),n};t.clearRect(0,0,e,n),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const v=o*l;for(let e=0;e<u;e++)for(let n=0;n<m;n++){const o=p(n,e);if(0===o)continue;const r=Kt[o]??"·",a=(8*v+40*Et(n,23*e))%m,i=(6*v+40*Et(17*e,11*n))%u,s=(1&o||2&o)&&Math.abs(n-a)<1.5,c=(4&o||8&o)&&Math.abs(e-i)<1.5,l=s||c,h=.25+.35*Et(3*n,5*e);l?(t.globalAlpha=.95,t.fillStyle=`rgb(${M.r},${M.g},${M.b})`):(t.globalAlpha=h,t.fillStyle=`rgb(${g.r},${g.g},${g.b})`),t.fillText(r,n*f,e*d)}t.globalAlpha=1}var _t=["wave","rain","stars","pulse","noise","grid","aurora","silk","void","morph","fire","dna","terrain","circuit"];function Jt(t,e={}){const{type:n="wave",opacity:o=.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:${o}`,"pointer-events:none",`z-index:${a}`].join(";"),r&&(f.className=r),l.prepend(f);const d=f.getContext("2d"),m=window.devicePixelRatio||1,u={x:.5,y:.5},g={x:.5,y:.5},M=()=>"light"===i||"dark"!==i&&(()=>{let t=l;for(;t&&t!==document.documentElement.parentElement;){const e=getComputedStyle(t).backgroundColor;if(e&&"transparent"!==e&&"rgba(0, 0, 0, 0)"!==e){const t=e.match(/rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)/);if(t)return(.299*+t[1]+.587*+t[2]+.114*+t[3])/255>=.4}t=t.parentElement}const e=document.documentElement,n=(e.getAttribute("data-theme")||"").toLowerCase();return"dark"!==n&&("light"===n||!e.classList.contains("dark")&&window.matchMedia("(prefers-color-scheme: light)").matches)})(),p=s?function(t){const e=t.match(/^#([0-9a-f]{3,8})$/i)?.[1];if(e){const t=e.length<=4?e.split("").map(t=>parseInt(t+t,16)):[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)];return{r:t[0],g:t[1],b:t[2]}}const n=t.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i);return n?{r:+n[1],g:+n[2],b:+n[3]}:null}(s):null,v=()=>({...c,lightMode:void 0!==c.lightMode?c.lightMode:M(),baseColor:p?`rgba(${p.r},${p.g},${p.b},{a})`:c.baseColor}),x={current:v()},b=()=>{x.current="rain"===n||"stars"===n||"pulse"===n||"noise"===n||"grid"===n||"aurora"===n||"silk"===n||"void"===n||"morph"===n?{...c,lightMode:void 0!==c.lightMode?c.lightMode:M(),color:s??c.color}:"fire"===n||"dna"===n?{...c,color:s??c.color}:"terrain"===n||"circuit"===n?{...c,color:s??c.color,lightMode:void 0!==c.lightMode?c.lightMode:M()}:v()};b();const w=window.matchMedia("(prefers-color-scheme: light)"),y=()=>{b()};let S=null;"auto"===i&&(w.addEventListener("change",y),S=new MutationObserver(y),S.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]}));const $=()=>{const t=l.getBoundingClientRect();f.width=t.width*m,f.height=t.height*m,d.setTransform(m,0,0,m,0,0)};$();const C=t=>{const e=l.getBoundingClientRect();u.x=(t.clientX-e.left)/e.width,u.y=(t.clientY-e.top)/e.height},E=new ResizeObserver($);E.observe(l),window.addEventListener("mousemove",C);let T=0,A=0;const F=()=>{g.x+=.07*(u.x-g.x),g.y+=.07*(u.y-g.y);const t=l.getBoundingClientRect();"rain"===n?It(d,t.width,t.height,T,x.current):"stars"===n?Rt(d,t.width,t.height,T,g,x.current):"pulse"===n?kt(d,t.width,t.height,T,g,x.current):"noise"===n?Lt(d,t.width,t.height,T,g,x.current):"grid"===n?Pt(d,t.width,t.height,T,g,x.current):"aurora"===n?zt(d,t.width,t.height,T,g,x.current):"silk"===n?Ht(d,t.width,t.height,T,x.current):"void"===n?Wt(d,t.width,t.height,T,g,x.current):"morph"===n?qt(d,t.width,t.height,T,x.current):"fire"===n?Bt(d,t.width,t.height,T,x.current):"dna"===n?jt(d,t.width,t.height,T,x.current):"terrain"===n?Ot(d,t.width,t.height,T,x.current):"circuit"===n?Yt(d,t.width,t.height,T,x.current):Ft(d,t.width,t.height,T,g,x.current),T+=.016,A=requestAnimationFrame(F)};return A=requestAnimationFrame(F),{destroy:()=>{cancelAnimationFrame(A),E.disconnect(),"auto"===i&&(w.removeEventListener("change",y),S?.disconnect()),window.removeEventListener("mousemove",C),f.remove(),l.style.position=h}}}var Xt=Jt;function Gt(t,e={},n,o){const r={...a,...e},{frame:i,cols:s}=U(t,r,n,o);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")}function Qt(t,e={},n,o){const r={...a,...e},{frame:i,cols:s}=U(t,r,n,o);if(!i.length||0===s)return"";const c=[];for(const t of i){let e="";for(const n of t)" "===n.char||n.a<10?e+=" ":e+=`[38;2;${n.r};${n.g};${n.b}m${n.char}`;c.push(e)}return c.join("\n")}function Zt(t,e,n,o="#505050",r=100){if(!t||e<=0||n<=0)return[];const a=St(o)??{r:80,g:80,b:80},i=t,s=i.length;return Array.from({length:n},(t,n)=>Array.from({length:e},(t,o)=>({char:i[(n*e+o)%s],r:a.r,g:a.g,b:a.b,a:r})))}var te=new WeakMap;function ee(t,e,n,o,r={},i){const{fontSize:s=10,lineHeight:c=1.6,color:l="#505050",opacity:h=100,hoverEffect:f="spotlight",hoverStrength:d=.85,hoverRadius:m=.18,hoverColor:u="#d4ff00"}=r,g=Math.max(1,Math.floor(e/s)),M=Math.max(1,Math.floor(n/(s*c))),p=JSON.stringify([o,g,M,l,h]);let v=te.get(t);v&&v.key===p||(v={key:p,frame:Zt(o,g,M,l,h)},te.set(t,v));Z(t,v.frame,{...a,fontSize:s,hoverEffect:f,hoverStrength:d,hoverRadius:m,hoverColor:u},e,n,0,i??null)}function ne(t,{format:e="png",quality:n=.92,scale:o=1}={}){return new Promise((r,a)=>{let i=t;if(1!==o){const e=document.createElement("canvas");e.width=Math.round(t.width*o),e.height=Math.round(t.height*o);const n=e.getContext("2d");if(!n)return void a(new Error("captureSnapshot: could not get 2d context"));n.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}`,n)})}async function oe(t,e={}){const{filename:n="asciify-snapshot",format:o="png",...r}=e,a=await ne(t,{format:o,...r}),i="jpeg"===o?"jpg":o,s=document.createElement("a");s.href=URL.createObjectURL(a),s.download=`${n}.${i}`,s.click(),setTimeout(()=>URL.revokeObjectURL(s.href),1e4)}async function re(t,{fontSize:e=10,style:n="classic",options:r={},liveOptions:i,mirror:s=!0,constraints:c={facingMode:"user"},dpr:l}={}){if(!navigator.mediaDevices?.getUserMedia)throw new Error("asciifyWebcam: getUserMedia is not supported in this browser.");const h=await navigator.mediaDevices.getUserMedia({video:c}),f=document.createElement("video");f.srcObject=h,f.muted=!0,f.playsInline=!0,await new Promise((t,e)=>{f.onloadedmetadata=()=>t(),f.onerror=()=>e(new Error("asciifyWebcam: video stream failed to load.")),f.play().catch(e)});const d={...a,...o[n],...r,fontSize:e},m=t.getContext("2d");if(!m)throw new Error("asciifyWebcam: could not get 2d context from canvas.");const u=l??("undefined"!=typeof window?window.devicePixelRatio:1)??1;1!==u&&m.scale(u,u);let g=null;const M=e=>{const n=t.getBoundingClientRect();g={x:(e.clientX-n.left)/n.width,y:(e.clientY-n.top)/n.height}},p=()=>{g=null};d.hoverStrength>0&&(t.addEventListener("mousemove",M),t.addEventListener("mouseleave",p));let v,x=!1;const b=performance.now(),w=e=>{if(!x){if(f.readyState>=f.HAVE_CURRENT_DATA){const n=t.width/u,o=t.height/u,r=(e-b)/1e3,a=i?{...d,...i()}:d;a.hoverStrength>0?(t.addEventListener("mousemove",M),t.addEventListener("mouseleave",p)):(t.removeEventListener("mousemove",M),t.removeEventListener("mouseleave",p));const{frame:c}=U(f,a,n,o),l=g&&s?{x:1-g.x,y:g.y}:g;s?(m.save(),m.scale(-1,1),m.translate(-n,0),Z(m,c,a,n,o,r,l),m.restore()):Z(m,c,a,n,o,r,l)}v=requestAnimationFrame(w)}};return v=requestAnimationFrame(w),()=>{x=!0,cancelAnimationFrame(v),t.removeEventListener("mousemove",M),t.removeEventListener("mouseleave",p),h.getTracks().forEach(t=>t.stop()),f.srcObject=null}}var ae={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]},ie=[127,65,65,65,65,65,127];function se(t){return ae[t]??ae[t.toUpperCase()]??ie}function ce(t,e={}){if(!t)return"";const{char:n="█",scale:o=1}=e,r=[...n][0]??"█",a=Math.max(1,Math.floor(o)),i=7*a,s=a,c=Array.from({length:i},()=>"");for(let e=0;e<t.length;e++){const n=se(t[e]);for(let t=0;t<7;t++){const e=n[t];let o="";for(let t=6;t>=0;t--)o+=(e>>t&1?r:" ").repeat(a);for(let e=0;e<a;e++)c[t*a+e]+=o}if(e<t.length-1)for(let t=0;t<i;t++)c[t]+=" ".repeat(s)}return c.join("\n")}function le(t,e,n={}){const{color:o="#d4ff00",bgColor:r,fontSize:a=10}=n,i=ce(e,n);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=o,l.font=`${a}px monospace`,l.textBaseline="top",s.forEach((t,e)=>l.fillText(t,0,e*a))}export{o as ART_STYLE_PRESETS,_t as BACKGROUND_TYPES,e as CHARSETS,n as CHARSET_SEQUENCES,a as DEFAULT_OPTIONS,i as HOVER_PRESETS,r as LIVING_STYLE_PRESETS,t as PALETTE_THEMES,Jt as asciiBackground,Gt as asciiText,Qt as asciiTextAnsi,xt as asciify,bt as asciifyGif,yt as asciifyLiveVideo,ce as asciifyText,wt as asciifyVideo,re as asciifyWebcam,Zt as buildTextFrame,ne as captureSnapshot,W as clearAsciifyCaches,Mt as computeCanvasRenderSize,ct as createVideoScrollScrub,_ as gifToAsciiFrames,J as gifToAsciiTextFrames,U as imageToAsciiFrame,V as imageToAsciiTextFrame,Xt as mountWaveBackground,zt as renderAuroraBackground,Yt as renderCircuitBackground,jt as renderDnaBackground,Bt as renderFireBackground,Z as renderFrameToCanvas,Pt as renderGridBackground,qt as renderMorphBackground,Lt as renderNoiseBackground,kt as renderPulseBackground,It as renderRainBackground,Ht as renderSilkBackground,Rt as renderStarsBackground,Ot as renderTerrainBackground,ee as renderTextBackground,D as renderTextFrameToCanvas,le as renderTextToCanvas,Wt as renderVoidBackground,Ft as renderWaveBackground,oe as snapshotAndDownload,K as videoToAsciiFrames,Y as videoToAsciiTextFrames};//# sourceMappingURL=index.js.map
1
+ var t={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"}},e={standard:" .:-=+*#%@",blocks:" ░▒▓█",minimal:" .:+",dense:" .'`^\",:;Il!i><~+_-?][}{1)(|/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$",binary:"01",dots:" ⠁⠃⠇⡇⣇⣧⣷⣿",letters:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",claudeCode:" ╔╗╚╝║═╠╣╦╩╬░▒▓█│─┌┐└┘├┤┬┴┼",box:" ▪◾◼■█",lines:" ˗‐–—―━",braille:" ⠁⠂⠃⠄⠅⠆⠇⠈⠉⠊⠋⠌⠍⠎⠏⠐⠑⠒⠓⠔⠕⠖⠗⠘⠙⠚⠛⠜⠝⠞⠟⠠⠡⠢⠣⠤⠥⠦⠧⠨⠩⠪⠫⠬⠭⠮⠯⠰⠱⠲⠳⠴⠵⠶⠷⠸⠹⠺⠻⠼⠽⠾⠿⡀⡁⡂⡃⡄⡅⡆⡇⣀⣁⣂⣃⣄⣅⣆⣇⣈⣉⣊⣋⣌⣍⣎⣏⣐⣑⣒⣓⣔⣕⣖⣗⣘⣙⣚⣛⣜⣝⣞⣟⣠⣡⣢⣣⣤⣥⣦⣧⣨⣩⣪⣫⣬⣭⣮⣯⣰⣱⣲⣳⣴⣵⣶⣷⣸⣹⣺⣻⣼⣽⣾⣿",katakana:" ヲァィゥェォャュョッアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン",circles:" .·:∘○◦°•∙",shadows:" ·∘◦○◎⊙●◉",geometric:" ·△▷◇◈◆▣■█",pipes:" ╶─┐└├┤┬┴┼╬▒▓█",waves:" ˜∼≈〰≋∿∾∭∫",shards:" ╱╲╳◤◥◣◢△▲◆◼█",smoke:" ·˙⁚⁖∶∷⋮⋰⋱∴∵",ascii:" .'`^\",:;~-_+<>i!lI?/\\|()[]{}1tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$",interface:" ·•-–—+=:;<>[]{}()⌘⌥⇧⌃↵↗↘◇◆◈□■",prompt:" .:;>_`/\\|{}[]()=+*#@$",data:" ·∙•◦○●◇◆◈▱▰▣█",humanist:" ·˙,:;∴∵∷∶⁚⋮⋯∼≈≋∞",mesh:" ·╶╴╷╵─│┌┐└┘├┤┬┴┼╬░▒▓█"},o={cosmic:[e.smoke,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.blocks],assistant:[e.interface,e.prompt,e.data],signal:[e.mesh,e.data,e.ascii],editorial:[e.humanist,e.waves,e.smoke]},n={classic:{renderMode:"ascii",charset:e.standard,colorMode:"grayscale"},particles:{renderMode:"dots",colorMode:"fullcolor",dotSizeRatio:.8},letters:{renderMode:"ascii",charset:e.letters,colorMode:"fullcolor"},claudeCode:{renderMode:"ascii",charset:e.claudeCode,colorMode:"accent",accentColor:"#f97316"},art:{renderMode:"ascii",charset:e.dense,colorMode:"fullcolor"},terminal:{renderMode:"ascii",charset:e.standard,colorMode:"matrix"},box:{renderMode:"ascii",charset:e.box,colorMode:"grayscale"},lines:{renderMode:"ascii",charset:e.lines,colorMode:"fullcolor"},braille:{renderMode:"ascii",charset:e.braille,colorMode:"fullcolor"},katakana:{renderMode:"ascii",charset:e.katakana,colorMode:"matrix"},circles:{renderMode:"ascii",charset:e.circles,colorMode:"accent",accentColor:"#d4ff00"},shadows:{renderMode:"ascii",charset:e.shadows,colorMode:"accent",accentColor:"#50a0ff"},geometric:{renderMode:"ascii",charset:e.geometric,colorMode:"grayscale"},pipes:{renderMode:"ascii",charset:e.pipes,colorMode:"accent",accentColor:"#00ff88"},waves:{renderMode:"ascii",charset:e.waves,colorMode:"fullcolor"},shards:{renderMode:"ascii",charset:e.shards,colorMode:"grayscale"},smoke:{renderMode:"ascii",charset:e.smoke,colorMode:"accent",accentColor:"#c850ff"},ascii:{renderMode:"ascii",charset:e.ascii,colorMode:"grayscale"},interface:{renderMode:"ascii",charset:e.interface,colorMode:"accent",accentColor:"#f4f1ea"},prompt:{renderMode:"ascii",charset:e.prompt,colorMode:"matrix"},data:{renderMode:"ascii",charset:e.data,colorMode:"fullcolor"},humanist:{renderMode:"ascii",charset:e.humanist,colorMode:"accent",accentColor:"#d6ccc2"},mesh:{renderMode:"ascii",charset:e.mesh,colorMode:"accent",accentColor:"#8fd3ff"}},r={agentField:{...n.interface,charsetFrames:o.assistant,charsetFps:1.6,animationStyle:"caustics",animationSpeed:.75,ditherStrength:.12,hoverEffect:"glow",hoverStrength:.42,hoverRadius:.18,hoverColor:"#f4f1ea",normalize:!0},liquidSignal:{...n.data,charsetFrames:o.signal,charsetFps:2.4,animationStyle:"current",animationSpeed:.65,ditherStrength:.45,hoverEffect:"repel",hoverStrength:.55,hoverRadius:.22,hoverColor:"#8fd3ff",normalize:!0},cursorGravity:{...n.mesh,charsetFrames:o.angular,charsetFps:1.2,animationStyle:"current",animationSpeed:.9,ditherStrength:.2,hoverEffect:"attract",hoverStrength:.82,hoverRadius:.24,hoverColor:"#ffffff",normalize:!0},editorialPulse:{...n.humanist,charsetFrames:o.editorial,charsetFps:.9,animationStyle:"caustics",animationSpeed:.55,ditherStrength:.18,hoverEffect:"spotlight",hoverStrength:.35,hoverRadius:.2,hoverColor:"#fff8ea",normalize:!0},terminalFlow:{...n.prompt,charsetFrames:o.terminal,charsetFps:3,animationStyle:"reform",animationSpeed:1.1,ditherStrength:.22,hoverEffect:"glitchText",hoverStrength:.65,hoverRadius:.16,hoverColor:"#d4ff00",hoverText:["BUILD","SHIP","RUN","ASK","MODEL"],normalize:!0}},a={fontSize:7,charSpacing:1,brightness:0,contrast:0,charset:e.standard,colorMode:"grayscale",accentColor:"#d4ff00",invert:!1,renderMode:"ascii",animationStyle:"none",animationSpeed:1,dotSizeRatio:.8,ditherStrength:0,charAspect:.55,normalize:!1,hoverStrength:0,hoverRadius:.2,hoverEffect:"spotlight",hoverColor:"#ffffff",hoverShape:"circle",hoverText:"ASCIIFY",artStyle:"classic",customText:"",chromaKey:null,chromaKeyTolerance:60,chromaKeyTrimPadding:.002,chromaKeyTrimLuminanceThreshold:0,chromaKeyTrimMode:"range"},i={none:{label:"Off",options:{hoverStrength:0,hoverEffect:"spotlight",hoverRadius:.2,hoverColor:"#ffffff"}},subtle:{label:"Subtle",options:{hoverStrength:.25,hoverEffect:"glow",hoverRadius:.12,hoverColor:"#ffffff"}},flashlight:{label:"Flashlight",options:{hoverStrength:.6,hoverEffect:"spotlight",hoverRadius:.15,hoverColor:"#fffbe6"}},magnifier:{label:"Magnifier",options:{hoverStrength:.7,hoverEffect:"magnify",hoverRadius:.12,hoverColor:"#ffffff"}},forceField:{label:"Force Field",options:{hoverStrength:.7,hoverEffect:"repel",hoverRadius:.15,hoverColor:"#a0e8ff"}},neon:{label:"Neon",options:{hoverStrength:.6,hoverEffect:"colorShift",hoverRadius:.15,hoverColor:"#d946ef"}},fire:{label:"Fire",options:{hoverStrength:.7,hoverEffect:"spotlight",hoverRadius:.15,hoverColor:"#ff6b2b"}},ice:{label:"Ice",options:{hoverStrength:.5,hoverEffect:"glow",hoverRadius:.15,hoverColor:"#60d5f7"}},gravity:{label:"Gravity",options:{hoverStrength:.7,hoverEffect:"attract",hoverRadius:.18,hoverColor:"#a5d6ff"}},shatter:{label:"Shatter",options:{hoverStrength:.8,hoverEffect:"shatter",hoverRadius:.14,hoverColor:"#ff6090"}},ghost:{label:"Fluid trail",options:{hoverStrength:.55,hoverEffect:"trail",hoverRadius:.2,hoverColor:"#b39ddb"}},glitchReveal:{label:"Glitch Reveal",options:{hoverStrength:.8,hoverEffect:"glitchText",hoverRadius:.18,hoverColor:"#a3e635"}}},s=[{value:"none",mode:"none",label:"Off",description:"Keep the image still. Hover stays available."},{value:"caustics",mode:"caustics",label:"Caustics",description:"Soft ribbons of light travel across a stationary character grid."},{value:"current",mode:"current",label:"Slow Current",description:"A gentle flow through the image, with steady edges."},{value:"reform",mode:"reform",label:"Reveal & Reform",description:"Disperse, gather, then hold the complete image."}];var c=(t,e,o)=>{const n=(t=>Math.max(0,Math.min(1,t)))((o-t)/(e-t));return n*n*(3-2*n)};function l(t,e,o,n,r){if(r[0]=r[1]=r[2]=0,r[3]=1,"none"===t)return r;const a=n*Math.PI/6,i=c(0,.12,Math.min(e,1-e,o,1-o));if("caustics"===t){const t=Math.sin(9*e+5*o+a)+Math.sin(8*o-3*e-a),n=Math.pow(Math.max(0,1-.72*Math.abs(t)),3);r[2]=(.22*n-.045)*i}else if("current"===t)r[0]=Math.sin(9*o+a)*Math.cos(7*e-a)*10*i,r[1]=Math.cos(8*e+a)*Math.sin(6*o-a)*7*i;else if("reform"===t){const t=(n%12+12)%12,s=((t,e)=>{const o=(.06711056*t+.00583715*e)%1*52.9829189;return o-Math.floor(o)})(Math.floor(160*e),Math.floor(100*o)),l=.65*e+.2*o+.15*s+.08*Math.sin(8*e-5*o),h=c(1.8+1.2*l,3.8+1.2*l,t)*(1-c(5+1.7*l,7.2+1.7*l,t));r[0]=Math.sin(9*o+a)*h*(1-h)*24*i,r[1]=-h*(1-h)*(8+12*s)*i,r[2]=.45*-h,r[3]=1-.9*h}return r}function h(t,e){const o=document.createElement("canvas");o.width=t,o.height=e;const n=o.getContext("2d",{willReadFrequently:!0});return{canvas:o,ctx:n}}function f(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 d(t,e,o,n,r,a){if((a?1-t/255:t/255)<.12)return" ";const i=[...e];return i[(n*r+o)%i.length]}var m=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];function u(t,e,o,n){if(n<=0)return t;const r=(m[o%4][e%4]/16-.5)*n*128;return Math.max(0,Math.min(255,t+r))}var g=new Array(256),M=new Array(256);for(let t=0;t<256;t++)g[t]=`rgb(${t},${t},${t})`,M[t]=`rgb(0,${t},0)`;function p(t,e,o,n,r,a=!1){switch(e){case"fullcolor":return`rgb(${t.r},${t.g},${t.b})`;case"matrix":return M[.299*t.r+.587*t.g+.114*t.b|0];case"accent":return`rgb(${o},${n},${r})`;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;return g[e]}}}var v=[0,0,0];function b(t,e,o,n,r,a=!1){switch(e){case"fullcolor":v[0]=t.r,v[1]=t.g,v[2]=t.b;break;case"matrix":{const e=.299*t.r+.587*t.g+.114*t.b|0;v[0]=0,v[1]=e,v[2]=0;break}case"accent":v[0]=o,v[1]=n,v[2]=r;break;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;v[0]=e,v[1]=e,v[2]=e;break}}return v}function x(t){const e=t.match(/rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)(?:\s*[,/]\s*([\d.]+))?\s*\)/);return e?{r:+e[1],g:+e[2],b:+e[3],a:void 0!==e[4]?+e[4]:1}:null}function w(t){let e=t;for(;e&&e!==document.documentElement.parentElement;){const t=getComputedStyle(e).backgroundColor;if(t&&"transparent"!==t&&"rgba(0, 0, 0, 0)"!==t){const e=x(t);if(e&&e.a>.1)return e}e=e.parentElement}return null}function y(t){if(t){const e=w(t);if(e){return(.299*e.r+.587*e.g+.114*e.b)/255<.4}}if("undefined"!=typeof document){const t=document.documentElement,e=(t.getAttribute("data-theme")||"").toLowerCase();if("dark"===e)return!0;if("light"===e)return!1;if(t.classList.contains("dark"))return!0;if(document.body){const t=w(document.body);if(t){return(.299*t.r+.587*t.g+.114*t.b)/255<.4}}}return"undefined"!=typeof window&&window.matchMedia("(prefers-color-scheme: dark)").matches}function S(t){if("string"!=typeof t)return t;const e=document.createElement("canvas");e.width=1,e.height=1;const o=e.getContext("2d");o.fillStyle=t,o.fillRect(0,0,1,1);const n=o.getImageData(0,0,1,1).data;return{r:n[0],g:n[1],b:n[2]}}function $(t){return t*t*(3-2*t)}var C={scale:1,offsetX:0,offsetY:0,glow:0,colorBlend:0,proximity:0};function E(t,e,o,n,r,a,i,s,c="spotlight",l=.5,h="circle",f=[],d=1){const m=(t-o)*Math.max(1,d),u=(e-n)*Math.max(1,1/d),g=.08+.35*l+.04*a;let M,p;if("box"===h){const t=Math.abs(m),e=Math.abs(u);M=Math.max(t,e),p=g}else M=Math.sqrt(m*m+u*u),p=g;if(M>=p&&("trail"!==c||0===f.length))return C.scale=1,C.offsetX=0,C.offsetY=0,C.glow=0,C.colorBlend=0,C.proximity=0,C;const v=$(Math.max(0,1-M/p))*r;let b=1,x=0,w=0,y=0,S=0;switch(c){case"spotlight":{b=1+v*a*1.8;const t=Math.atan2(u,m),e=v*v*a*.6;x=Math.cos(t)*e*i,w=Math.sin(t)*e*s,y=v*a*.4,S=v*v*a*.25;break}case"magnify":b=1+v*a*.85,y=v*a*.15;break;case"repel":{b=1;const t=Math.atan2(u,m),e=v*v*a*1.8;x=Math.cos(t)*e*i,w=Math.sin(t)*e*s;break}case"glow":y=v*a*.8,S=v*a*.4;break;case"colorShift":b=1,y=v*a*.12,S=v*a;break;case"attract":{const t=Math.atan2(u,m),e=v*v*a*1;x=(.45*-Math.cos(t)-1.6*Math.sin(t))*e*i,w=(.45*-Math.sin(t)+1.6*Math.cos(t))*e*s,y=v*a*.3;break}case"shatter":{const t=Math.atan2(u,m),e=.5*Math.sin(43.7*m+29.3*u),o=v*a*1.4*(.7+.3*e);x=Math.cos(t+e)*o*i,w=Math.sin(t+e)*o*s,b=Math.max(.1,1-v*a*.6),y=v*a*.25;break}case"trail":{let o=v,n=-u*v,r=m*v;for(const a of f){const i=(t-a.x)*Math.max(1,d),s=(e-a.y)*Math.max(1,1/d),c=Math.hypot(i,s)/g;if(c>=1)continue;const l=$(1-c)*a.intensity;o=Math.max(o,l),n+=(.35*a.vx-2*s)*l*.35,r+=(.35*a.vy+2*i)*l*.35}x=Math.tanh(2*n)*a*i*3,w=Math.tanh(2*r)*a*s*3,S=o*a*.65,y=o*a*.35,b=1+o*a*.08,C.proximity=o;break}case"glitchText":b=1,y=v*a*.5,S=v*a*.6}return C.scale=b,C.offsetX=x,C.offsetY=w,C.glow=y,C.colorBlend=S,"trail"!==c&&(C.proximity=v),C}function T(t,e,{continuous:o=!1,interactive:n=!1}={}){const r=t.parentElement??t;let a=null,i=0,s=!1,c=!0,l=!0,h=-1/0;const f=window.matchMedia("(prefers-reduced-motion: reduce)"),d=()=>{l=!0,s||!c||document.hidden||i||(i=requestAnimationFrame(m))},m=t=>{if(i=0,s||!c||document.hidden)return;const n=!f.matches&&(o||t-h<1500);(l||n)&&(e(t,f.matches?null:a),l=!1),n&&(i=requestAnimationFrame(m))},u=e=>{if("touch"===e.pointerType)return;const o=t.getBoundingClientRect();if(!o.width||!o.height)return;const n=(e.clientX-o.left)/o.width,r=(e.clientY-o.top)/o.height;a=n>=0&&n<=1&&r>=0&&r<=1?{x:n,y:r}:null,h=performance.now(),d()},g=()=>{a=null,h=performance.now(),d()},M=()=>{document.hidden&&i?(cancelAnimationFrame(i),i=0):d()},p="undefined"==typeof IntersectionObserver?null:new IntersectionObserver(([t])=>{c=t.isIntersecting,c?d():i&&(cancelAnimationFrame(i),i=0)});return p?.observe(t),n&&(r.addEventListener("pointermove",u),r.addEventListener("pointerleave",g)),document.addEventListener("visibilitychange",M),f.addEventListener("change",d),d(),{wake:d,stop:()=>{s=!0,cancelAnimationFrame(i),p?.disconnect(),r.removeEventListener("pointermove",u),r.removeEventListener("pointerleave",g),document.removeEventListener("visibilitychange",M),f.removeEventListener("change",d)}}}var A=null,F=null;function R(t,e){if(!A||!F){const o=h(t,e);A=o.canvas,F=o.ctx}return A.width!==t&&(A.width=t),A.height!==e&&(A.height=e),F}var I=new Map,k=new Map,L=new WeakMap;function P(t){const e=Intl.Segmenter;return e?Array.from(new e(void 0,{granularity:"grapheme"}).segment(t),({segment:t})=>t):[...t]}function z(t){let e=I.get(t);return e||(e=P(t),I.set(t,e)),e}function H(t){return P(t)}function W(t,e,o){const n=o?1-t/255:t/255,r=Math.floor(n*(e.length-1));return e[Math.max(0,Math.min(e.length-1,r))]??" "}function B(t,e,o,n){const r=`${t}\0${e?1:0}\0${o}\0${n}`;let a=k.get(r);if(!a){const i=z(t);a=new Array(256);for(let t=0;t<256;t++)a[t]=W(f(t,o,n),i,e);k.set(r,a)}return a}function j(){I.clear(),k.clear(),Q=new WeakMap,tt=new WeakMap,Z=new WeakMap,A=null,F=null}function q(t,e){return"auto"!==t?t:!y(e)}function O(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 N(t){const e=t||"auto";if("auto"!==e)return O(e)??"ffffff";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=O(t.getPropertyValue(e).trim());if(o)return o}const e=O(getComputedStyle(document.body).accentColor??"");if(e)return e}return y("undefined"!=typeof document?document.body:null)?"faf9f7":"0d0d0d"}function U(t,e,o){return Math.max(e,Math.min(o,t))}function D(t,e,o){if(!t)return{x:0,y:0,width:e,height:o};const n=t.unit??"percent",r=!1!==t.preserveAspect,a=t=>void 0===t?void 0:"percent"===n?t*e:t,i=t=>void 0===t?void 0:"percent"===n?t*o:t,s=U(a(t.left)??0,0,e-1),c=U(a(t.right)??0,0,e-s-1),l=U(i(t.top)??0,0,o-1),h=U(i(t.bottom)??0,0,o-l-1),f=void 0!==t.left||void 0!==t.right||void 0!==t.top||void 0!==t.bottom,d=Math.max(1,e-s-c),m=Math.max(1,o-l-h),u=f?d:a(t.width),g=f?m:i(t.height);let M=u??e,p=g??o;if(r&&!f){const t=M/e,n=p/o,r=Math.min(t,n),a=void 0===u?n:void 0===g?t:r;M=e*a,p=o*a}M=U(M,1,f?d:e),p=U(p,1,f?m:o);const v=t.anchor??"center",b=a(t.x),x=i(t.y),w=f?s:0,y=f?l:0,S=f?d:e,$=f?m:o,C=v.endsWith("left")||"left"===v?0:v.endsWith("right")||"right"===v?S-M:(S-M)/2,E=v.startsWith("top")||"top"===v?0:v.startsWith("bottom")||"bottom"===v?$-p:($-p)/2;return{x:U(b??w+C,0,Math.max(0,e-M)),y:U(x??y+E,0,Math.max(0,o-p)),width:M,height:p}}function V(t,e,o,n){const r=t instanceof HTMLVideoElement?t.videoWidth:t.width,a=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(0===r||0===a)return{frame:[],cols:0,rows:0};const i=e.charAspect,s=e.fontSize*e.charSpacing,c=e.fontSize/i*e.charSpacing,l=o||r,h=n||a,m=Math.floor(l/s),g=Math.floor(h/c);if(m<=0||g<=0)return{frame:[],cols:0,rows:0};const M=D(e.sourceCrop,r,a),p=Math.max(1,Math.min(Math.floor(2048/m),Math.floor(M.width/m))),v=Math.max(1,Math.min(Math.floor(2048/g),Math.floor(M.height/g))),b=m*p,x=g*v,w=R(b,x),y=w.globalCompositeOperation;w.globalCompositeOperation="copy";try{w.drawImage(t,M.x,M.y,M.width,M.height,0,0,b,x)}finally{w.globalCompositeOperation=y}const $=w.getImageData(0,0,b,x).data,C=e.chromaKey,E=null!=C&&!1!==C,T=!0===C,A="blue-screen"===C;let F=null,I=0;!E||T||A||(F=S(C),I=(e.chromaKeyTolerance??60)**2);let k=0,L=255;if(e.normalize){let t=255,e=0;for(let o=0;o<$.length;o+=4){if(E){const t=$[o],e=$[o+1],n=$[o+2];let r=!1;if(T)r=e>1.4*t&&e>1.4*n&&e>80;else if(A)r=n>1.4*t&&n>1.4*e&&n>80;else if(null!==F){const o=t-F.r,a=e-F.g,i=n-F.b;r=o*o+a*a+i*i<=I}if(r)continue}const n=.299*$[o]+.587*$[o+1]+.114*$[o+2];n<t&&(t=n),n>e&&(e=n)}k=t,L=e>t?e-t:255}const P=[],H=q(e.invert),j=E&&e.charset.replace(/ /g,"")||e.charset,O=z(j),N=e.customText?null:B(j,H,e.brightness,e.contrast),U=p*v;for(let t=0;t<g;t++){const o=[];for(let n=0;n<m;n++){let r=0,a=0,i=0,s=0,c=0;for(let e=0;e<v;e++){const o=(t*v+e)*b;for(let t=0;t<p;t++){const e=4*(o+n*p+t),l=$[e],h=$[e+1],f=$[e+2],d=$[e+3];if(E){let t=!1;if(T)t=h>1.4*l&&h>1.4*f&&h>80;else if(A)t=f>1.4*l&&f>1.4*h&&f>80;else if(null!==F){const e=l-F.r,o=h-F.g,n=f-F.b;t=e*e+o*o+n*n<=I}if(t){c++;continue}}r+=l,a+=h,i+=f,s+=d}}if(E&&c>U/2){o.push({char:" ",r:0,g:0,b:0,a:0});continue}const l=U-c,h=l>0?r/l:0,g=l>0?a/l:0,M=l>0?i/l:0,x=l>0?s/l:0,w=.299*h+.587*g+.114*M,y=e.normalize?(w-k)/L*255:w,S=f(y,e.brightness,e.contrast),C=e.ditherStrength>0?u(S,n,t,e.ditherStrength):S,R=e.customText?d(C,e.customText,n,t,m,H):e.ditherStrength>0?W(C,O,H):N[Math.max(0,Math.min(255,0|y))];o.push({char:R,r:h,g:g,b:M,a:x,lum:C})}P.push(o)}return{frame:P,cols:m,rows:g}}function K(t,e,o,n){const r=t instanceof HTMLVideoElement?t.videoWidth:t.width,a=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(0===r||0===a)return{rows:[],cols:0,rowCount:0};const i=e.charAspect,s=e.fontSize*e.charSpacing,c=e.fontSize/i*e.charSpacing,l=o||r,h=n||a,d=Math.floor(l/s),m=Math.floor(h/c);if(d<=0||m<=0)return{rows:[],cols:0,rowCount:0};const g=d,M=m,p=R(g,M),v=D(e.sourceCrop,r,a),b=p.globalCompositeOperation;p.globalCompositeOperation="copy";try{p.drawImage(t,v.x,v.y,v.width,v.height,0,0,g,M)}finally{p.globalCompositeOperation=b}const x=p.getImageData(0,0,g,M).data,w=e.chromaKey,y=null!=w&&!1!==w,$=!0===w,C="blue-screen"===w;let E=null,T=0;!y||$||C||(E=S(w),T=(e.chromaKeyTolerance??60)**2);let A=0,F=255;if(e.normalize){let t=255,e=0;for(let o=0;o<x.length;o+=4){if(y){const t=x[o],e=x[o+1],n=x[o+2];let r=!1;if($)r=e>1.4*t&&e>1.4*n&&e>80;else if(C)r=n>1.4*t&&n>1.4*e&&n>80;else if(null!==E){const o=t-E.r,a=e-E.g,i=n-E.b;r=o*o+a*a+i*i<=T}if(r)continue}const n=.299*x[o]+.587*x[o+1]+.114*x[o+2];n<t&&(t=n),n>e&&(e=n)}A=t,F=e>t?e-t:255}const I=q(e.invert),k=y&&e.charset.replace(/ /g,"")||e.charset,L=z(k),P=e.customText?null:B(k,I,e.brightness,e.contrast),H=e.customText?z(e.customText):null,j="fullcolor"===e.colorMode?new Uint8ClampedArray(d*m*4):void 0,O=[];for(let t=0;t<m;t++){let o="";for(let n=0;n<d;n++){const r=4*(t*g+n),a=r,i=x[r],s=x[r+1],c=x[r+2],l=x[r+3];if(y){let t=!1;if($)t=s>1.4*i&&s>1.4*c&&s>80;else if(C)t=c>1.4*i&&c>1.4*s&&c>80;else if(null!==E){const e=i-E.r,o=s-E.g,n=c-E.b;t=e*e+o*o+n*n<=T}if(t){o+=" ",j&&(j[a]=0,j[a+1]=0,j[a+2]=0,j[a+3]=0);continue}}j&&(j[a]=i,j[a+1]=s,j[a+2]=c,j[a+3]=l);const h=.299*i+.587*s+.114*c,m=e.normalize?(h-A)/F*255:h,M=e.ditherStrength>0||H?f(m,e.brightness,e.contrast):m,p=e.ditherStrength>0?u(M,n,t,e.ditherStrength):M;if(H){o+=(I?1-p/255:p/255)<.12?" ":H[(t*d+n)%H.length]}else e.ditherStrength<=0?o+=P[Math.max(0,Math.min(255,0|m))]:o+=W(p,L,I)}O.push(o)}return{rows:O,cols:d,rowCount:m,colors:j}}function Y(t,e,o,n,r){if(0===e.rows.length)return;const a=t.canvas,i=Boolean(o.chromaKey)||e.rows.some(t=>t.includes(" "));i||(L.delete(t),t.clearRect(0,0,n,r),t.fillStyle=y(a)?"#0a0a0a":"#faf9f7",t.fillRect(0,0,n,r));const s=N(o.accentColor),c=parseInt(s.substring(0,2),16),l=parseInt(s.substring(2,4),16),h=parseInt(s.substring(4,6),16),f=n/e.cols,d=r/e.rowCount,m=.9*Math.min(f/.55,d),u=e.colors;if("fullcolor"===o.colorMode&&u){L.delete(t),t.clearRect(0,0,n,r),t.font=`${m}px "JetBrains Mono", monospace`,t.textAlign="left",t.textBaseline="middle",t.globalAlpha=1;let o="";for(let n=0;n<e.rows.length;n++){const r=H(e.rows[n]);let a=0;for(;a<e.cols;){for(;a<e.cols&&" "===r[a];)a++;if(a>=e.cols)break;const i=a,s=4*(n*e.cols+a),c=240&u[s],l=240&u[s+1],h=240&u[s+2];for(a++;a<e.cols&&" "!==r[a];){const t=4*(n*e.cols+a);if((240&u[t])!==c||(240&u[t+1])!==l||(240&u[t+2])!==h)break;a++}const m=`rgb(${c},${l},${h})`;m!==o&&(t.fillStyle=m,o=m),t.fillText(r.slice(i,a).join(""),i*f+.5*f,n*d+.5*d)}}return void(t.globalAlpha=1)}t.font=`${m}px "JetBrains Mono", monospace`,t.textAlign="left",t.textBaseline="middle";const g="matrix"===o.colorMode?"rgb(0,255,0)":"grayscale"===o.colorMode?y(a)?"rgb(230,230,230)":"rgb(24,24,24)":`rgb(${c},${l},${h})`;t.fillStyle=g,t.globalAlpha=1;const M=L.get(t),p=i&&M&&M.cols===e.cols&&M.rowCount===e.rowCount&&M.canvasWidth===n&&M.canvasHeight===r&&M.fillStyle===g;p||t.clearRect(0,0,n,r);for(let o=0;o<e.rows.length;o++){const r=e.rows[o];p&&M.rows[o]===r||(p&&t.clearRect(0,o*d,n,d+1),0!==r.trim().length&&t.fillText(r,.5*f,o*d+.5*d))}L.set(t,{rows:e.rows.slice(),cols:e.cols,rowCount:e.rowCount,canvasWidth:n,canvasHeight:r,fillStyle:g}),t.globalAlpha=1}async function _(t,e,o,n,r=12,a=10,i,s=0){const c=Math.min(t.duration-s,a),l=Math.ceil(c*r),h=[];let f=0,d=0;for(let a=0;a<l;a++){const m=s+a/r;if(m>s+c)break;t.currentTime=m,await new Promise(e=>{const o=()=>{t.removeEventListener("seeked",o),e()};t.addEventListener("seeked",o)});const u=V(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 J(t,e,o,n,r=12,a=10,i,s=0){const c=Math.min(t.duration-s,a),l=Math.ceil(c*r),h=[];let f=0,d=0;for(let a=0;a<l;a++){const m=s+a/r;if(m>s+c)break;t.currentTime=m,await new Promise(e=>{const o=()=>{t.removeEventListener("seeked",o),e()};t.addEventListener("seeked",o)});const u=K(t,e,o,n);h.push(u),f=u.cols,d=u.rowCount,i?.((a+1)/l)}return{frames:h,cols:f,rows:d,fps:r}}async function X(t,e,o,n,r){const{parseGIF:a,decompressFrames:i}=await import("gifuct-js"),s=a(t),c=i(s,!0);if(0===c.length)return{frames:[],cols:0,rows:0,fps:10};const l=c[0].dims.width,h=c[0].dims.height,f=s.lsd?.width||l,d=s.lsd?.height||h,m=document.createElement("canvas");m.width=f,m.height=d;const u=m.getContext("2d"),g=document.createElement("canvas");g.width=f,g.height=d;const M=g.getContext("2d"),p=document.createElement("canvas"),v=p.getContext("2d"),b=[];let x=0,w=0,y=0;for(const t of c)y+=t.delay||100;const S=y/c.length,$=Math.round(Math.min(30,Math.max(5,1e3/S))),C=Math.min(c.length,300);for(let t=0;t<C;t++){const a=c[t],{dims:i,patch:s,disposalType:l}=a;3===l&&(M.clearRect(0,0,f,d),M.drawImage(m,0,0)),p.width!==i.width&&(p.width=i.width),p.height!==i.height&&(p.height=i.height);const h=new ImageData(new Uint8ClampedArray(s.buffer),i.width,i.height);v.putImageData(h,0,0),u.drawImage(p,i.left||0,i.top||0);const y=V(m,e,o,n);b.push(y.frame),x=y.cols,w=y.rows,2===l?u.clearRect(i.left||0,i.top||0,i.width,i.height):3===l&&(u.clearRect(0,0,f,d),u.drawImage(g,0,0)),r?.((t+1)/C)}return{frames:b,cols:x,rows:w,fps:$}}async function G(t,e,o,n,r){const{parseGIF:a,decompressFrames:i}=await import("gifuct-js"),s=a(t),c=i(s,!0);if(0===c.length)return{frames:[],cols:0,rows:0,fps:10};const l=c[0].dims.width,h=c[0].dims.height,f=s.lsd?.width||l,d=s.lsd?.height||h,m=document.createElement("canvas");m.width=f,m.height=d;const u=m.getContext("2d"),g=document.createElement("canvas");g.width=f,g.height=d;const M=g.getContext("2d"),p=document.createElement("canvas"),v=p.getContext("2d"),b=[];let x=0,w=0,y=0;for(const t of c)y+=t.delay||100;const S=y/c.length,$=Math.round(Math.min(30,Math.max(5,1e3/S))),C=Math.min(c.length,300);for(let t=0;t<C;t++){const a=c[t],{dims:i,patch:s,disposalType:l}=a;3===l&&(M.clearRect(0,0,f,d),M.drawImage(m,0,0)),p.width!==i.width&&(p.width=i.width),p.height!==i.height&&(p.height=i.height);const h=new ImageData(new Uint8ClampedArray(s.buffer),i.width,i.height);v.putImageData(h,0,0),u.drawImage(p,i.left||0,i.top||0);const y=K(m,e,o,n);b.push(y),x=y.cols,w=y.rowCount,2===l?u.clearRect(i.left||0,i.top||0,i.width,i.height):3===l&&(u.clearRect(0,0,f,d),u.drawImage(g,0,0)),r?.((t+1)/C)}return{frames:b,cols:x,rows:w,fps:$}}var Q=new WeakMap,Z=new WeakMap,tt=new WeakMap;function et(t,e,o,n,r,a=0,i){if(!e.length||!e[0].length||n<=0||r<=0)return;let s=null;if(o.hoverStrength>0){let e=Q.get(t);e||(e={x:.5,y:.5,intensity:0,time:-1,emittedAt:-1,points:[]},Q.set(t,e)),s=function(t,e,o){const n=t.time<0?1/60:Math.max(0,Math.min(.1,(o-t.time)/1e3));t.time=o;const r=t.intensity<.003,a=t.x,i=t.y;if(e){r&&(t.x=e.x,t.y=e.y);const o=1-Math.exp(-n/.055);t.x+=(e.x-t.x)*o,t.y+=(e.y-t.y)*o}t.intensity+=((e?.intensity??(e?1:0))-t.intensity)*(1-Math.exp(-n/(e?.09:.18)));const s=Math.exp(-n/.22);for(const e of t.points)e.intensity*=s;for(;t.points.length&&t.points[0].intensity<.01;)t.points.shift();return e&&!r&&o-t.emittedAt>=24&&Math.hypot(t.x-a,t.y-i)>5e-4&&(t.points.push({x:t.x,y:t.y,intensity:t.intensity,vx:Math.max(-1,Math.min(1,(t.x-a)/Math.max(n,.001))),vy:Math.max(-1,Math.min(1,(t.y-i)/Math.max(n,.001)))}),t.points.length>12&&t.points.shift(),t.emittedAt=o),!e&&t.intensity<.003&&!t.points.length?(t.intensity=0,null):{x:t.x,y:t.y,intensity:t.intensity,trail:t.points}}(e,i??null,performance.now())}else Q.delete(t);if("none"!==o.animationStyle||o.charsetFrames?.length||o.hoverStrength<=0)return tt.delete(t),void ot(t,e,o,n,r,a,s);const c=Z.get(t);if(c?.frame!==e)return Z.set(t,{frame:e,since:performance.now()}),tt.delete(t),void ot(t,e,o,n,r,a,s);if(performance.now()-c.since<100)return void ot(t,e,o,n,r,a,s);const l=t.getTransform();if(l.b||l.c||l.a<=0||l.d<=0)return void ot(t,e,o,n,r,a,s);if(!s||(s.intensity??0)<.003)return void ot(t,e,o,n,r,a,null);const h=y(t.canvas),f={...o,accentColor:"#"+N(o.accentColor)},d=JSON.stringify([f,n,r,l.a,l.d,h,void 0!==document.fonts?document.fonts.status:"loaded"]);let m=tt.get(t);if(!m||m.frame!==e||m.key!==d){const o=m?.canvas??document.createElement("canvas");o.width=Math.ceil(n*l.a),o.height=Math.ceil(r*l.d);const a=o.getContext("2d");a.setTransform(l.a,0,0,l.d,0,0),ot(a,e,f,n,r,0,null,void 0,h),m={frame:e,key:d,canvas:o},tt.set(t,m)}if(t.clearRect(0,0,n,r),t.drawImage(m.canvas,0,0,n,r),!s||(s.intensity??0)<.003)return;const u=e.length,g=e[0].length,M=.08+.35*o.hoverRadius+.04*o.hoverStrength,p="trail"===o.hoverEffect?[s,...s.trail??[]]:[s];let v=1,b=1,x=0,w=0;for(const t of p)v=Math.min(v,t.x-M),x=Math.max(x,t.x+M),b=Math.min(b,t.y-M),w=Math.max(w,t.y+M);if("glitchText"===o.hoverEffect){const t=o.hoverText,e=Math.max(1,...(Array.isArray(t)?t:[t]).map(t=>t.length));v=Math.min(v,s.x-e/g),x=Math.max(x,s.x+e/g)}const S=Math.ceil(5+4*o.hoverStrength),$={x:Math.max(0,Math.floor(v*g)-S),y:Math.max(0,Math.floor(b*u)-S),right:Math.min(g,Math.ceil(x*g)+S),bottom:Math.min(u,Math.ceil(w*u)+S)};t.save(),t.beginPath(),t.rect($.x*n/g,$.y*r/u,($.right-$.x)*n/g,($.bottom-$.y)*r/u),t.clip(),ot(t,e,f,n,r,a,s,$,h),t.restore()}function ot(t,e,o,n,r,a=0,i,c,h){const f=e.length;if(0===f)return;const d=e[0].length;t.clearRect(0,0,n,r);let m=!1;const u=Math.max(1,f>>2),g=Math.max(1,d>>2);t:for(let t=0;t<f;t+=u){const o=e[t];for(let t=0;t<d;t+=g)if(o[t].a<200){m=!0;break t}}const M=t.canvas,v=h??y(M);m||(t.fillStyle=v?"#0a0a0a":"#faf9f7",t.fillRect(0,0,n,r));const x=n/d,w=r/f,S=i?.intensity??1,$=!!(i&&o.hoverStrength>0&&S>.005),C="#"+(O(o.hoverColor||"#ffffff")??"ffffff"),T=parseInt(C.slice(1,3),16),A=parseInt(C.slice(3,5),16),F=parseInt(C.slice(5,7),16),R=N(o.accentColor),I=parseInt(R.substring(0,2),16),k=parseInt(R.substring(2,4),16),L=parseInt(R.substring(4,6),16),P=o.hoverRadius;let H=0,B=d,j=0,U=f,D=0,V=0;if($&&i){D=i.x,V=i.y;const t=.08+.35*P+.04*o.hoverStrength;H=Math.max(0,Math.floor((D-t)*d)-1),B=Math.min(d,Math.ceil((D+t)*d)+1),j=Math.max(0,Math.floor((V-t)*f)-1),U=Math.min(f,Math.ceil((V+t)*f)+1)}if($&&"trail"===o.hoverEffect)for(const t of i?.trail??[]){const e=.08+.35*P+.04*o.hoverStrength;H=Math.min(H,Math.max(0,Math.floor((t.x-e)*d)-1)),B=Math.max(B,Math.min(d,Math.ceil((t.x+e)*d)+1)),j=Math.min(j,Math.max(0,Math.floor((t.y-e)*f)-1)),U=Math.max(U,Math.min(f,Math.ceil((t.y+e)*f)+1))}const K=o.animationStyle,Y=o.animationSpeed,_=(J=K,s.find(t=>t.value===J||t.mode===J)?.mode??"none");var J;const X="none"===_,G=[0,0,0,1],Q=o.hoverStrength,Z=o.hoverEffect,tt=P,et=o.hoverShape||"circle",ot=q(o.invert,M),nt=o.colorMode,rt=2*Math.PI,at=1/d,it=1/f;let st="",ct=-1;if("dots"===o.renderMode){const s=.5*Math.min(x,w)*o.dotSizeRatio;for(let o=c?.y??0;o<(c?.bottom??f);o++){const h=e[o];for(let e=c?.x??0;e<(c?.right??d);e++){const c=h[e];if(c.a<10)continue;const m=.00392156863*(.299*c.r+.587*c.g+.114*c.b),u=ot?1-m:m;if(u<.02)continue;X||l(_,e/d,o/f,a*Y,G);const g=Math.max(0,Math.min(1,(1+G[2])*G[3]));let M=1,v=0,y=0,C=0,R=0;if($&&e>=H&&e<=B&&o>=j&&o<=U){const t=E(e*at,o*it,D,V,S,Q,x,w,Z,tt,et,i?.trail,n/r);M=t.scale,v=t.offsetX,y=t.offsetY,C=t.glow,R=t.colorBlend}const P=s*u*g*M;if(P<.3)continue;const z=e*x+.5*x+v+G[0],W=o*w+.5*w+y+G[1];let q;if(R>0){const t=b(c,nt,I,k,L,ot);q=`rgb(${Math.min(255,t[0]+(T-t[0])*R|0)},${Math.min(255,t[1]+(A-t[1])*R|0)},${Math.min(255,t[2]+(F-t[2])*R|0)})`}else q=p(c,nt,I,k,L,ot);const O=Math.min(1,.00392156863*c.a*g*(1+C));if(O!==ct&&(t.globalAlpha=O,ct=O),q!==st&&(t.fillStyle=q,st=q),P<=3){const e=2*P;t.fillRect(z-P,W-P,e,e)}else t.beginPath(),t.arc(z,W,P,0,rt),t.fill()}}}else{const s=.55,h=.9*Math.min(x/s,w);{const e=/\p{Extended_Pictographic}/u.test(o.customText||o.charset);t.font=e?`${h}px "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif`:`${h}px "JetBrains Mono", monospace`,t.textAlign="center",t.textBaseline="middle"}const m=o.charsetFrames,u=!!m?.length,g=u?m[Math.floor(Math.max(0,a)*(o.charsetFps??2))%m.length]:o.charset,M=t.getTransform();if(!$&&X&&!u&&"accent"===nt&&!c&&o.hoverStrength<=0&&!/\p{Extended_Pictographic}/u.test(o.customText||o.charset)&&"letterSpacing"in t&&/^[\x20-\x7e]*$/.test(o.customText||o.charset)&&e.every(t=>t.every(t=>t.a<10||255===t.a&&1===t.char.length&&/^[\x20-\x7e]$/.test(t.char)))){const o=t.letterSpacing;t.letterSpacing="0px";const n=t.measureText("M").width;t.letterSpacing=x-n+"px",t.fillStyle=`rgb(${I},${k},${L})`,t.globalAlpha=1,t.textAlign="left";for(let o=0;o<f;o++){const r=e[o];let a="";for(let t=0;t<d;t++){const e=r[t];a+=e.a<10?" ":e.char}0!==a.trim().length&&t.fillText(a,.5*(x-n),o*w+.5*w)}return t.letterSpacing=o,t.textAlign="center",void(t.globalAlpha=1)}const v="glitchText"===Z&&$,y="!@#$%^&*<>{}[]|/\\~`0123456789",C=y.length;let R="",q=0,O=0,N=0,K=0,J=0,rt=0;if(v){const t=o.hoverText??"ASCIIFY";if(O=Math.round(D*d),N=Math.round(V*f),Array.isArray(t)){const e=t.filter(t=>t.length>0);0===e.length&&e.push("ASCIIFY");R=e[((7*Math.floor(O/Math.max(1,Math.ceil(d/5)))+13*Math.floor(N/Math.max(1,Math.ceil(f/3))))%e.length+e.length)%e.length]}else R=t||"ASCIIFY";q=R.length,K=Math.max(3,Math.min(12,Math.round(f*P*.6)));const e=Math.floor(K/2);J=Math.max(0,N-e),J+K>f&&(J=Math.max(0,f-K)),rt=O-Math.floor(q/2)}for(let o=c?.y??0;o<(c?.bottom??f);o++){const s=e[o];for(let h=c?.x??0;h<(c?.right??d);h++){const c=s[h];if(c.a<10)continue;let m=u&&null!=c.lum?W(c.lum,z(g),ot):c.char;if(" "===m)continue;X||l(_,h/d,o/f,a*Y,G);const P=Math.max(0,Math.min(1,(1+G[2])*G[3]));if(P<.05)continue;let lt=1,ht=0,ft=0,dt=0,mt=0;if($&&!v&&h>=H&&h<=B&&o>=j&&o<=U){const t=E(h*at,o*it,D,V,S,Q,x,w,Z,tt,et,i?.trail,n/r);if(lt=t.scale,ht=t.offsetX,ft=t.offsetY,dt=t.glow,mt=t.colorBlend,"trail"===Z&&t.proximity>0){const n=Math.max(0,Math.min(d-1,Math.round(h-t.offsetX/x))),r=e[Math.max(0,Math.min(f-1,Math.round(o-t.offsetY/w)))][n],a=r.lum??.299*r.r+.587*r.g+.114*r.b;m=W(Math.min(255,a+t.proximity*Q*65),z(g),ot)}}if(v&&o>=J&&o<J+K){const t=h-rt;if(t>=0&&t<q){const e=R[t],n=Math.abs(o-N)/Math.max(1,.5*K),r=Math.abs(h-O)/Math.max(1,q),i=Math.max(n,r),s=Math.max(0,Math.min(1,1-.9*i)),c=43758.5453*Math.sin(127.1*h+311.7*o+43758.5453*Math.floor(12*a));m=Math.abs(c-Math.floor(c))<s?e:y[Math.abs(Math.floor(97*c))%C],dt=.3+.7*s,mt=.3+.65*s}}const ut=h*x+.5*x+ht+G[0],gt=o*w+.5*w+ft+G[1];let Mt;if(mt>0){const t=b(c,nt,I,k,L,ot);Mt=`rgb(${Math.min(255,t[0]+(T-t[0])*mt|0)},${Math.min(255,t[1]+(A-t[1])*mt|0)},${Math.min(255,t[2]+(F-t[2])*mt|0)})`}else Mt=p(c,nt,I,k,L,ot);const pt=Math.min(1,.00392156863*c.a*P*(1+dt));pt!==ct&&(t.globalAlpha=pt,ct=pt),Mt!==st&&(t.fillStyle=Mt,st=Mt),1!==lt?(t.translate(ut,gt),t.scale(lt,lt),t.fillText(m,0,0),t.setTransform(M)):t.fillText(m,ut,gt)}}}t.globalAlpha=1}function nt(t){return Math.max(0,Math.min(1,t))}function rt(t){return"string"==typeof t?document.querySelector(t):t instanceof HTMLElement?t:null}function at(t){return"ascii"===t.renderMode&&"none"===t.animationStyle&&t.hoverStrength<=0&&!t.charsetFrames?.length}function it(t,e={}){const o=nt(t),n=nt(o*(void 0===e.speed?1:Math.max(.001,e.speed)));return nt(e.ease?e.ease(n):n)}function st(t,e,o={}){if(!Number.isFinite(t.duration)||t.duration<=0)return;const n=o.from??0,r=o.to??t.duration,a=Math.max(n,Math.min(r,t.duration)),i=it(e,o),s=n+(a-n)*i;t.currentTime=Math.min(Math.max(n,s),Math.max(n,a-.04)),o.onUpdate?.(i,t)}function ct(t,e){return Math.abs(t.currentTime-e)<1/240?lt(t):new Promise(o=>{const n=()=>{t.removeEventListener("seeked",n),o()};t.addEventListener("seeked",n,{once:!0});const r=t.fastSeek;r?r.call(t,e):t.currentTime=e})}function lt(t){const e=t.requestVideoFrameCallback;return new Promise(e?o=>{let n=!1;const r=()=>{n||(n=!0,o())};e.call(t,r),window.setTimeout(r,32)}:t=>requestAnimationFrame(()=>t()))}function ht(t,e={}){const o=rt(e.trigger)??t;t.pause();const n=e.gsap,r=e.ScrollTrigger??n?.ScrollTrigger;if(n&&r?.create){n.registerPlugin?.(r);const a=r.create({trigger:o,start:e.start??"top bottom",end:e.end??"bottom top",scrub:e.scrub??!0,onUpdate:o=>st(t,o.progress,e)});return()=>a.kill?.()}return function(t,e,o){let n=0;const r=()=>{n=0;const r=e.getBoundingClientRect(),a=window.innerHeight||document.documentElement.clientHeight,i=r.height+a,s=i>0?nt((a-r.top)/i):0;st(t,s,o)},a=()=>{n||(n=requestAnimationFrame(r))};return window.addEventListener("scroll",a,{passive:!0}),window.addEventListener("resize",a),a(),()=>{window.removeEventListener("scroll",a),window.removeEventListener("resize",a),n&&cancelAnimationFrame(n)}}(t,o,e)}function ft(t,e,o){const n=e.gsap,r=e.ScrollTrigger??n?.ScrollTrigger;if(n&&r?.create){n.registerPlugin?.(r);const a=r.create({trigger:t,start:e.start??"top bottom",end:e.end??"bottom top",scrub:e.scrub??!0,onUpdate:t=>o(t.progress)});return()=>a.kill?.()}return function(t,e){let o=0;const n=()=>{o=0;const n=t.getBoundingClientRect(),r=window.innerHeight||document.documentElement.clientHeight,a=n.height+r,i=a>0?nt((r-n.top)/a):0;e(i)},r=()=>{o||(o=requestAnimationFrame(n))};return window.addEventListener("scroll",r,{passive:!0}),window.addEventListener("resize",r),r(),()=>{window.removeEventListener("scroll",r),window.removeEventListener("resize",r),o&&cancelAnimationFrame(o)}}(t,o)}function dt(t,e,o){if(!t||!e||!o.sourceCrop)return{w:t,h:e};const n=D(o.sourceCrop,t,e);return{w:Math.max(1,Math.round(n.width)),h:Math.max(1,Math.round(n.height))}}function mt(t,e,o,n){const r=n.chromaKey;if(null==r||!1===r)return!1;if(!0===r)return e>1.4*t&&e>1.4*o&&e>80;if("blue-screen"===r)return o>1.4*t&&o>1.4*e&&o>80;const a=S(r),i=(n.chromaKeyTolerance??60)**2,s=t-a.r,c=e-a.g,l=o-a.b;return s*s+c*c+l*l<=i}function ut(t,e,o){if(!e.chromaKey||!e.sourceCrop||"off"===e.chromaKeyTrimMode)return e;const n=t instanceof HTMLVideoElement?t.videoWidth:t.width,r=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(!n||!r)return e;const a=D(e.sourceCrop,n,r),i=Math.min(360,Math.max(1,Math.round(a.width))),s=Math.max(1,Math.round(i*(a.height/a.width))),{ctx:c}=h(i,s);c.drawImage(t,a.x,a.y,a.width,a.height,0,0,i,s);const l=c.getImageData(0,0,i,s).data,f=Math.max(0,Math.min(255,e.chromaKeyTrimLuminanceThreshold??0));let d=i,m=s,u=-1,g=-1;for(let t=0;t<s;t++)for(let o=0;o<i;o++){const n=4*(t*i+o),r=l[n+3],a=l[n],s=l[n+1],c=l[n+2];r<=8||.2126*a+.7152*s+.0722*c<=f||mt(a,s,c,e)||(o<d&&(d=o),t<m&&(m=t),o>u&&(u=o),t>g&&(g=t))}if(u<d||g<m)return e;const M=Math.max(0,Math.min(.25,e.chromaKeyTrimPadding??.002)),p=Math.round(i*M),v=Math.round(s*M);d=Math.max(0,d-p),m=Math.max(0,m-v),u=Math.min(i-1,u+p),g=Math.min(s-1,g+v);const b=function(t,e,o,n,r){const a=r&&Number.isFinite(r)&&r>0?r:null;if(!a)return t;const i=e.x,s=e.y,c=e.x+e.width,l=e.y+e.height,h=Math.max(i,t.left),f=Math.max(s,t.top),d=Math.min(c,o-t.right),m=Math.min(l,n-t.bottom),u=Math.max(1,d-h),g=Math.max(1,m-f),M=h+u/2,p=f+g/2;let v=u,b=g;v/b<a?v=b*a:b=v/a;v>e.width&&(v=e.width,b=Math.max(g,Math.min(e.height,v/a)));b>e.height&&(b=e.height,v=Math.max(u,Math.min(e.width,b*a)));let x=M-v/2,w=p-b/2;return x=Math.max(i,Math.min(c-v,x)),w=Math.max(s,Math.min(l-b,w)),{left:x,top:w,right:o-(x+v),bottom:n-(w+b)}}({left:a.x+d/i*a.width,top:a.y+m/s*a.height,right:n-(a.x+(u+1)/i*a.width),bottom:r-(a.y+(g+1)/s*a.height)},{x:a.x,y:a.y,width:a.width,height:a.height},n,r,o);return{...e,sourceCrop:{unit:"pixel",...b,preserveAspect:!1}}}function gt(t){const e=t.sourceCrop;return e&&"pixel"===e.unit?void 0===e.left||void 0===e.top||void 0===e.right||void 0===e.bottom?null:{left:e.left,top:e.top,right:e.right,bottom:e.bottom}:null}async function Mt(t,e,o,n,r){if(!e.chromaKey||!e.sourceCrop||"range"!==e.chromaKeyTrimMode)return e;const a=t.currentTime,i=function(t,e,o,n){const r=!0===n?{}:n||{},a=Math.max(0,r.from??e),i=r.to??o??(Number.isFinite(t.duration)?t.duration:a),s=Math.max(a,i-.04),c=Math.max(0,s-a),l=c>.1?[a,a+.25*c,a+.5*c,a+.75*c,s]:[a];return Array.from(new Set(l.map(t=>Math.max(0,Number(t.toFixed(3))))))}(t,o,n,r);let s=null;for(const o of i){await ct(t,o),await lt(t);const n=gt(ut(t,e));n&&(s=s?{left:Math.min(s.left,n.left),top:Math.min(s.top,n.top),right:Math.min(s.right,n.right),bottom:Math.min(s.bottom,n.bottom)}:n)}return await ct(t,a),await lt(t),s?{...e,sourceCrop:{unit:"pixel",...s,preserveAspect:!0}}:e}function pt(t,e,o=2048){return vt({sourceWidth:t,sourceHeight:e,maxRenderDimension:o})}function vt({sourceWidth:t,sourceHeight:e,cssWidth:o=0,cssHeight:n=0,maxRenderDimension:r=2048}){const a=Math.max(1,t),i=Math.max(1,e),s=a/i,c=Math.max(1,r),l=Math.min(1,c/Math.max(a,i)),h=Math.max(a,i)*l,f=Math.max(0,o,n),d=Math.min(c,Math.max(h,f));return s>=1?{renderW:Math.round(d),renderH:Math.round(d/s)}:{renderW:Math.round(d*s),renderH:Math.round(d)}}function bt(t,e,o,n){if(void 0===t)return;if("number"==typeof t)return t;const r=t.trim();if(r.endsWith("%")){const t=Number.parseFloat(r)/100;return Number.isFinite(t)?e*t:void 0}if(r.endsWith("px")){const t=Number.parseFloat(r);return Number.isFinite(t)?t:void 0}if(r.endsWith("vw")){const t=Number.parseFloat(r)/100;return Number.isFinite(t)?o*t:void 0}if(r.endsWith("vh")){const t=Number.parseFloat(r)/100;return Number.isFinite(t)?n*t:void 0}}function xt(t,e,o,n,r,a=2048,i={}){const{width:s,height:c}=e.getBoundingClientRect();if(!s||!c)return{renderW:0,renderH:0,dpr:1};const l="undefined"!=typeof window?window.innerWidth:s,h="undefined"!=typeof window?window.innerHeight:c,f=bt(i.width,s,l,h)??s,d=bt(i.height,c,l,h)??c,m=function(t,e,o,n,r){const a=t=>{const o=bt(t,e,n,r);return o&&o>0?o:0},i=t=>{const e=bt(t,o,n,r);return e&&e>0?e:0};return void 0===t?{x:0,y:0}:"number"==typeof t||"string"==typeof t?{x:a(t),y:i(t)}:{x:a(t.x),y:i(t.y)}}(i.bleed,s,c,l,h),u=f+2*m.x,g=d+2*m.y,{cssW:M,cssH:p}=function(t,e,o,n="contain"){if("fill"===n)return{cssW:t,cssH:e};let r=t,a=r/o;const i="cover"===n,s=a>e;return(i&&!s||!i&&s)&&(a=e,r=a*o),"scale-down"===n&&(r=Math.min(r,t),a=Math.min(a,e)),{cssW:Math.round(r),cssH:Math.round(a)}}(u,g,o,i.objectFit??"contain"),v="undefined"!=typeof window&&window.devicePixelRatio||1;let b,x;n&&r?({renderW:b,renderH:x}=vt({sourceWidth:n,sourceHeight:r,cssWidth:M,cssHeight:p,maxRenderDimension:a})):(b=M,x=p);const w=8e6,y=b*v*x*v>w?Math.sqrt(w/(b*x)):v;return t.width=Math.round(b*y),t.height=Math.round(x*y),t.style.width=`${M}px`,t.style.height=`${p}px`,{renderW:b,renderH:x,dpr:y}}async function wt(t,e,{fontSize:o,artStyle:r="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[r],l=o??i.fontSize??10,h={...a,...c,artStyle:r,...i,fontSize:l},f=e.getContext("2d");if(!f)throw new Error("Could not get 2d context from canvas");const{w:d,h:m}=function(t){return t instanceof HTMLVideoElement?{w:t.videoWidth,h:t.videoHeight}:t instanceof HTMLImageElement?{w:t.naturalWidth||t.width,h:t.naturalHeight||t.height}:{w:t.width,h:t.height}}(s),{renderW:u,renderH:g}=pt(d,m),M="undefined"!=typeof window&&window.devicePixelRatio||1,p=8e6,v=u*M*g*M>p?Math.sqrt(p/(u*g)):M;e.width===Math.round(u*v)&&e.height===Math.round(g*v)||(e.width=Math.round(u*v),e.height=Math.round(g*v));const{frame:b}=V(s,h,u,g),x=(t,e)=>{f.save(),f.setTransform(v,0,0,v,0,0),et(f,b,h,u,g,t/1e3,e),f.restore()};x(0,null);return T(e,x,{continuous:"none"!==h.animationStyle||!!h.charsetFrames?.length,interactive:h.hoverStrength>0}).stop}async function yt(t,e,{fontSize:o,artStyle:r="classic",options:i={}}={}){const s="string"==typeof t?await fetch(t).then(t=>t.arrayBuffer()):t,c=o??i.fontSize??10;let l={...a,...n[r],artStyle:r,...i,fontSize:c};const h=e.getContext("2d");if(!h)throw new Error("Could not get 2d context from canvas");const{frames:f,fps:d}=await X(s,l,e.width,e.height);if(!f.length)throw new Error("asciifyGif: the GIF contains no renderable frames.");const m=performance.now();let u=-1;return T(e,(t,o)=>{const n=Math.floor((t-m)*d/1e3)%f.length;n===u&&!o&&l.hoverStrength<=0&&"none"===l.animationStyle&&!l.charsetFrames?.length||(et(h,f[n],l,e.width,e.height,(t-m)/1e3,o),u=n)},{continuous:!0,interactive:l.hoverStrength>0}).stop}async function St(t,e,{fontSize:o,artStyle:r="classic",options:i={},fitTo:s,objectFit:c,objectPosition:l,scale:h,width:f,height:d,bleed:m,preExtract:u=!1,fps:g,maxRenderDimension:M=2048,trim:p,scroll:v,maxCachedFrames:b=90,onReady:x,onFrame:w}={}){const y=p?.start??0,S=p?.end,$=o??i.fontSize??10;let C={...a,...n[r],artStyle:r,...i,fontSize:$};const E=e.getContext("2d");if(!E)throw new Error("asciifyVideo: could not get 2d context from canvas.");const A="string"==typeof s?document.querySelector(s):s instanceof HTMLElement?s:null,F={objectFit:c,objectPosition:l,scale:h,width:f,height:d,bleed:m},R=function(t,e){var o;if(!function(t){return void 0!==t.objectFit||void 0!==t.objectPosition||void 0!==t.scale||void 0!==t.width||void 0!==t.height||void 0!==t.bleed}(e))return()=>{};const n={width:t.style.width,height:t.style.height,objectFit:t.style.objectFit,objectPosition:t.style.objectPosition,maxWidth:t.style.maxWidth,maxHeight:t.style.maxHeight,transformOrigin:t.style.transformOrigin,scale:t.style.getPropertyValue("scale")};if(e.objectFit&&(t.style.objectFit=e.objectFit),e.objectPosition&&(t.style.objectPosition=e.objectPosition,t.style.transformOrigin=e.objectPosition),void 0===e.scale&&void 0===e.bleed||(t.style.maxWidth="none",t.style.maxHeight="none"),void 0!==e.scale){const n=Number.isFinite(e.scale)&&e.scale>0?e.scale:1;t.style.setProperty("scale",String(n)),(o=t.style).transformOrigin||(o.transformOrigin=e.objectPosition??"center center")}return()=>{t.style.width=n.width,t.style.height=n.height,t.style.objectFit=n.objectFit,t.style.objectPosition=n.objectPosition,t.style.maxWidth=n.maxWidth,t.style.maxHeight=n.maxHeight,t.style.transformOrigin=n.transformOrigin,n.scale?t.style.setProperty("scale",n.scale):t.style.removeProperty("scale")}}(e,F),I=t=>()=>{t(),R()};if(u){let o;"string"==typeof t?(o=document.createElement("video"),o.crossOrigin="anonymous",o.src=t,o.readyState<2&&await new Promise((e,n)=>{o.onloadeddata=()=>e(),o.onerror=()=>n(new Error(`asciifyVideo: failed to load "${t}"`))})):o=t,C=await Mt(o,C,y,S,v);const n=dt(o.videoWidth,o.videoHeight,C);A&&xt(e,A,n.w/n.h,n.w,n.h,M,F);const{renderW:r,renderH:a}=pt(n.w,n.h,M),i="undefined"!=typeof window&&window.devicePixelRatio||1,s=8e6,c=r*i*a*i>s?Math.sqrt(s/(r*a)):i;e.width===Math.round(r*c)&&e.height===Math.round(a*c)||(e.width=Math.round(r*c),e.height=Math.round(a*c));const l=void 0!==S?S-y:10,h=g??(v?18:void 0);if(at(C)){const{frames:t,fps:n}=await J(o,C,r,a,h,l,void 0,y),i=e=>{const o=t[e];o&&(E.save(),E.setTransform(c,0,0,c,0,0),Y(E,o,C,r,a),E.restore(),w?.())};if(v){let n=!1,r=-1;const a=!0===v?{}:v,s=ft(rt(a.trigger)??A??e,a,e=>{const s=it(e,a),c=Math.max(0,Math.min(t.length-1,Math.round(s*(t.length-1))));c!==r&&(r=c,i(c),n||(n=!0,x?.(o)),a.onUpdate?.(s,o))});return i(0),n=!0,x?.(o),I(s)}let s,f=!1,d=0,m=performance.now(),u=!0;const g=1e3/n,M=e=>{f||(e-m>=g&&(i(d),d=(d+1)%t.length,m=e,u&&(u=!1,x?.(o))),s=requestAnimationFrame(M))};return s=requestAnimationFrame(M),I(()=>{f=!0,cancelAnimationFrame(s)})}const{frames:f,fps:d}=await _(o,C,r,a,h,l,void 0,y);if(!f.length)throw new Error("asciifyVideo: no frames were decoded.");let m=0;const u=performance.now(),p=T(e,(t,e)=>{v||(m=Math.floor((t-u)*d/1e3)%f.length),E.save(),E.setTransform(c,0,0,c,0,0),et(E,f[m],C,r,a,(t-u)/1e3,e),E.restore(),w?.()},{continuous:!v||"none"!==C.animationStyle||!!C.charsetFrames?.length,interactive:C.hoverStrength>0});let b;if(v){const t=!0===v?{}:v;b=ft(rt(t.trigger)??A??e,t,e=>{m=Math.max(0,Math.min(f.length-1,Math.round(it(e,t)*(f.length-1)))),p.wake(),t.onUpdate?.(e,o)})}return x?.(o),I(()=>{p.stop(),b?.()})}let k,L=!1;"string"==typeof t?(k=document.createElement("video"),k.crossOrigin="anonymous",k.src=t,k.muted=!0,k.loop=!0,k.playsInline=!0,k.setAttribute("playsinline",""),Object.assign(k.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(k),L=!0,await new Promise((e,o)=>{k.onloadedmetadata=()=>e(),k.onerror=()=>o(new Error(`asciifyVideo: failed to load "${t}"`))}),await k.play().catch(()=>{})):(k=t,k.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((t,e)=>{const o=()=>{k.removeEventListener("loadedmetadata",n),k.removeEventListener("error",r)},n=()=>{o(),t()},r=()=>{o(),e(new Error("asciifyVideo: provided video element failed to load metadata."))};k.addEventListener("loadedmetadata",n),k.addEventListener("error",r),k.load()}),k.paused&&await k.play().catch(()=>{})),y>0&&(k.currentTime=y,await new Promise(t=>{const e=()=>{k.removeEventListener("seeked",e),t()};k.addEventListener("seeked",e)}),await lt(k));let P=null;(y>0||void 0!==S)&&(P=()=>{(void 0!==S&&k.currentTime>=S||y>0&&k.currentTime<y)&&(k.currentTime=y)},k.addEventListener("timeupdate",P)),C=await Mt(k,C,y,S,v);let z=null;const H=dt(k.videoWidth,k.videoHeight,C);let{renderW:W,renderH:B}=pt(H.w,H.h,M);const j=t=>"frame"===C.chromaKeyTrimMode?ut(t,C,W/B):C;if(A){const t=H.w/H.h,o=H.w,n=H.h,r=xt(e,A,t,o,n,M,F);W=r.renderW,B=r.renderH;const a=e.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0),z=new ResizeObserver(()=>{const r=xt(e,A,t,o,n,M,F);W=r.renderW,B=r.renderH;const a=e.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0)}),z.observe(A)}else{const t="undefined"!=typeof window&&window.devicePixelRatio||1,o=8e6,n=W*t*B*t>o?Math.sqrt(o/(W*B)):t;e.width===Math.round(W*n)&&e.height===Math.round(B*n)||(e.width=Math.round(W*n),e.height=Math.round(B*n)),E.setTransform(n,0,0,n,0,0)}let q=!0,O=null;const N=v&&!u,U=g&&g>0?1e3/g:0;let D=0;const X=!N&&at(C);if(N&&"ascii"===C.renderMode&&"none"===C.animationStyle&&C.hoverStrength<=0&&!C.charsetFrames?.length){const t=!0===v?{}:v,o=rt(t.trigger)??A??e,n=t.from??y,r=t.to??S??k.duration,a=Math.max(n,Math.min(r,k.duration)),i=Math.max(.001,a-n),s=Math.min(60,Math.max(12,g??30)),c=Math.max(2,Math.ceil(i*s)+1),l=new Array(c),h=[],f=Math.max(2,Math.min(c,Math.floor(b))),d=()=>{for(;h.length>f;){const t=h.findIndex(t=>t!==u&&Math.abs(t-u)>2),e=t>=0?t:0,o=h.splice(e,1)[0];void 0!==o&&(l[o]=void 0)}},m=t=>{const e=h.indexOf(t);e>=0&&h.splice(e,1),h.push(t),d()};let u=0,M=0,p=-1,$=0,T=!1,F=!1,R=!1;const H=new Set,q=document.createElement("video");q.muted=!0,q.playsInline=!0,q.preload="auto",q.crossOrigin=k.crossOrigin||"anonymous",q.src=k.currentSrc||k.src,Object.assign(q.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(q),q.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((t,e)=>{const o=()=>{q.removeEventListener("loadedmetadata",n),q.removeEventListener("error",r)},n=()=>{o(),t()},r=()=>{o(),e(new Error("asciifyVideo: cache video failed to load metadata."))};q.addEventListener("loadedmetadata",n),q.addEventListener("error",r),q.load()}),q.pause(),k.paused&&await k.play().catch(()=>{});const N=t=>n+i*t/Math.max(1,c-1),V=t=>Math.max(0,Math.min(c-1,Math.round(t*(c-1)))),_=j(k),J=K(k,_,W,B);J.rows.length>0&&(l[0]=J,m(0),Y(E,J,_,W,B),R=!0,x?.(k),w?.());const X=t=>{if(l[t])return t;for(let e=1;e<c;e++){const o=t-e,n=t+e;if(o>=0&&l[o])return o;if(n<c&&l[n])return n}return-1},G=()=>{if(!l[u])return u;for(const t of H)if(!l[t])return t;for(let t=1;t<c;t++){const e=u-t,o=u+t;if(e>=0&&!l[e])return e;if(o<c&&!l[o])return o}return-1},Q=t=>{t<0||t>=c||l[t]||(H.add(t),Z())},Z=async()=>{if(T||F)return;const t=G();if(!(t<0)){H.delete(t),F=!0;try{if(await ct(q,N(t)),!T){const e=j(q),o=K(q,e,W,B);o.rows.length>0&&(l[t]=o,m(t))}}finally{F=!1,T||requestAnimationFrame(()=>{Z()})}}},tt=()=>{if(T)return;const t=X(u);if(t>=0&&t!==p){const e=l[t];e&&(Y(E,e,C,W,B),p=t,R||(R=!0,x?.(k)),w?.())}else if(t<0||p<0){const t=performance.now();if(U<=0||t-D>=U){const e=j(k),o=K(k,e,W,B);o.rows.length>0&&(Y(E,o,e,W,B),D=t,R||(R=!0,x?.(k)),w?.())}}Q(u),$=requestAnimationFrame(tt)};return O=ft(o,t,e=>{const o=function(t,e,o={}){if(!Number.isFinite(t.duration)||t.duration<=0)return null;const n=o.from??0,r=o.to??t.duration,a=Math.max(n,Math.min(r,t.duration)),i=it(e,o),s=n+(a-n)*i;return{progress:i,time:Math.min(Math.max(n,s),Math.max(n,a-.04))}}(k,e,{...t,from:n,to:a});M=o?.progress??nt(e),u=V(M),Q(u),Q(u-1),Q(u+1),Q(u-2),Q(u+2),Q(u-3),Q(u+3),t.onUpdate?.(M,k)}),Q(0),Q(1),$=requestAnimationFrame(tt),I(()=>{T=!0,cancelAnimationFrame($),O?.(),z?.disconnect(),H.clear(),h.length=0,l.fill(void 0),q.pause(),q.src="",q.removeAttribute("src"),q.load(),q.isConnected&&q.remove(),P&&k.removeEventListener("timeupdate",P),L&&(k.pause(),k.src="",k.removeAttribute("src"),k.load(),k.isConnected&&k.remove())})}if(N){const t=!0===v?{}:v;O=ht(k,{...t,trigger:t.trigger??A??e,from:t.from??y,to:t.to??S})}let G=-1,Q=0,Z=-1,tt=0;const ot="function"==typeof k.requestVideoFrameCallback,st=()=>{tt=k.requestVideoFrameCallback(()=>{Q++,st()})};ot&&st();let mt=0,gt=0,vt=null;const bt=T(e,(t,o)=>{if(k.readyState<2||0===e.width||0===e.height)return;if(U>0&&t-D<U&&!o)return;if(y>0&&k.currentTime<y)return;if(void 0!==S&&k.currentTime>=S)return;const n=(ot?Q!==Z:k.currentTime!==G)||mt!==W||gt!==B;if(n||!(C.hoverStrength<=0)||"none"!==C.animationStyle||C.charsetFrames?.length){if(X){const t=j(k),e=K(k,t,W,B);Y(E,e,t,W,B)}else!n&&vt||(vt=V(k,j(k),W,B).frame),et(E,vt,C,W,B,t/1e3,o);G=k.currentTime,Z=Q,mt=W,gt=B,D=t,q&&(q=!1,x?.(k)),w?.()}},{continuous:!0,interactive:C.hoverStrength>0});return I(()=>{bt.stop(),tt&&k.cancelVideoFrameCallback(tt),O?.(),z?.disconnect(),P&&k.removeEventListener("timeupdate",P),L&&(k.pause(),k.src="",k.removeAttribute("src"),k.load(),k.isConnected&&k.remove())})}function $t(t,e,o){return St(t,e,o)}function Ct(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 Et(t){return t*t*t*(t*(6*t-15)+10)}function Tt(t,e,o){return t+(e-t)*o}function At(t,e){let o=127*t+311*e;return o^=o>>13,(o*(o*o*15731+789221)+1376312589&2147483647)/2147483647}function Ft(t,e){const o=Math.floor(t),n=Math.floor(e),r=e-n,a=Et(t-o),i=Et(r),s=At(o,n),c=At(o+1,n),l=At(o,n+1),h=At(o+1,n+1);return Tt(Tt(s,c,a),Tt(l,h,a),i)}function Rt(t,e){return(.5*Ft(t,e)+.25*Ft(2.1*t,2.1*e)+.125*Ft(4.3*t,4.3*e))/.875}function It(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=13,charAspect:s=.62,lineHeightRatio:c=1.4,chars:l=" .:-=+*#%@",baseColor:h=null,accentColor:f,accentThreshold:d=.52,mouseInfluence:m=.55,mouseFalloff:u=2.8,speed:g=1,vortex:M=!0,sparkles:p=!0,breathe:v=!0,lightMode:b=!1}=a,x=f??(b?"#6b8700":"#d4ff00"),w=i*s,y=i*c,S=Math.ceil(e/w),$=Math.ceil(o/y),C=r.x,E=r.y;let T=212,A=255,F=0;{const t=x.replace("#","");6===t.length&&(T=parseInt(t.slice(0,2),16),A=parseInt(t.slice(2,4),16),F=parseInt(t.slice(4,6),16))}t.clearRect(0,0,e,o),t.font=`${i}px "JetBrains Mono", monospace`,t.textBaseline="top";const R=n*g,I=v?.12*(.5*Math.sin(.22*R)+.5):0;for(let e=0;e<$;e++)for(let o=0;o<S;o++){const n=o/S,r=e/$,a=.045,i=.08*R,s=.06,c=.45*((.5*Math.sin(.08*o+.05*e+.6*R)+.5+(.5*Math.sin(.03*o-.07*e+.4*R)+.5)+(.5*Math.sin(.05*o+.03*e+.8*R)+.5))/3)+.35*(.5*Rt(o*a+i,e*a*1.4-.7*i)+.5)+.2*(.5*Math.sin((o+.65*e)*s+1.1*R)+.5)+I,f=n-C,g=r-E,v=Math.sqrt(f*f+g*g);let x=0;if(M&&v<.35){const t=Math.atan2(g,f),e=Math.sin(4*t+2.2*R-14*v),o=Math.max(0,1-v/.35);x=e*o*o*.22}const k=c*(1-m)+(Math.max(0,1-v*u)+.5*x)*m+.15*x,L=Math.min(1,Math.max(0,k));let P=L;if(p&&L>.72){const t=Math.floor(8*R),n=At(7*o+3*t,11*e+t);n>.88&&(P=Math.min(1,L+4*(n-.88)))}const z=Math.floor(P*(l.length-1));if(" "===l[z])continue;const H=.015+.07*P;if(P>d){const e=Math.min(b?.9:.28,H*(b?14:2.8));t.fillStyle=`rgba(${T},${A},${F},${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[z],o*w,e*y)}}function kt(t,e,o,n,r={}){const{fontSize:a=13,chars:i="0123456789ABCDEF@#$&*+=/<>",accentColor:s,color:c,speed:l=1,density:h=.55,tailLength:f=14,lightMode:d=!1}=r,m=s??(d?"#6b8700":"#d4ff00"),u=.62*a,g=1.4*a,M=Math.ceil(e/u),p=Math.ceil(o/g);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let v=255,b=255,x=255;if(d&&(v=55,b=55,x=55),c){const t=Ct(c);t&&(v=t.r,b=t.g,x=t.b)}let w=212,y=255,S=0;const $=Ct(m);$&&(w=$.r,y=$.g,S=$.b);const C=p+f;for(let e=0;e<M;e++){if(At(17*e,3)>h)continue;const o=(.5+1.5*At(31*e,7))*l,r=At(13*e,11)*C,a=Math.floor((n*o*7+r)%C),s=e*u;for(let o=0;o<=f;o++){const r=a-(f-o);if(r<0||r>=p)continue;const c=r*g,l=At(53*e+Math.floor(5*n+o),7*r),h=i[Math.floor(l*i.length)],m=o/f;if(o===f)t.fillStyle=`rgba(${w},${y},${S},${d?.7:.85})`;else{const e=d?.85*m:.15*m;t.fillStyle=`rgba(${v},${b},${x},${e})`}t.fillText(h,s,c)}}}function Lt(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" . · * + ° ★",accentColor:c,color:l,speed:h=1,count:f=180,lightMode:d=!1}=a,m=c??(d?"#6b8700":"#d4ff00");t.clearRect(0,0,e,o),t.textBaseline="middle",t.textAlign="center";const u=e*(.2+.6*r.x),g=o*(.2+.6*r.y),M=.65*Math.sqrt(e*e+o*o);let p=255,v=255,b=255;if(d&&(p=55,v=55,b=55),l){const t=Ct(l);t&&(p=t.r,v=t.g,b=t.b)}let x=212,w=255,y=0;const S=Ct(m);S&&(x=S.r,w=S.g,y=S.b);const $=s.replace(/ /g,"").split("");if(0!==$.length){for(let r=0;r<f;r++){const a=At(17*r,3)*Math.PI*2,s=(n*(.15+.85*At(31*r,7))*h*.22+At(13*r,11))%1,c=u+Math.cos(a)*s*M,l=g+Math.sin(a)*s*M;if(c<-20||c>e+20||l<-20||l>o+20)continue;const f=Math.max(6,i*(.4+.9*s));t.font=`${f}px monospace`;const m=$[Math.min($.length-1,Math.floor(s*$.length))],S=s>.72,C=d?.85*s:.2*s;t.fillStyle=S?`rgba(${x},${w},${y},${Math.min(d?.92:.32,2.2*C)})`:`rgba(${p},${v},${b},${C})`,t.fillText(m,c,l)}t.textAlign="left"}}function Pt(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=". · ○ ◎ ●",accentColor:c,color:l,rings:h=5,speed:f=1,sharpness:d=4,lightMode:m=!1}=a,u=c??(m?"#007a5e":"#00ffcc");t.clearRect(0,0,e,o),t.textBaseline="middle",t.textAlign="center";const g=e*r.x,M=o*r.y,p=1.6*Math.sqrt(g*g+M*M)+.2*Math.sqrt(e*e+o*o);let v=255,b=255,x=255;if(m&&(v=55,b=55,x=55),l){const t=Ct(l);t&&(v=t.r,b=t.g,x=t.b)}let w=0,y=255,S=204;const $=Ct(u);$&&(w=$.r,y=$.g,S=$.b);const C=s.replace(/ /g,"").split("");if(0===C.length)return;const E=Math.ceil(e/i),T=Math.ceil(o/i);for(let e=0;e<T;e++)for(let o=0;o<E;o++){const r=o*i+.5*i,a=e*i+.5*i,s=r-g,c=a-M,l=Math.sqrt(s*s+c*c)/p;let u=0;for(let t=0;t<h;t++){const e=(n*f*.38+t/h)%1,o=Math.abs(l-e),r=Math.max(0,1-o*p/(i*(12-d)));u+=Math.cos(r*Math.PI*.5)*r}if(u=Math.min(1,u),u<.02)continue;const $=u>.6;t.font=`${i}px monospace`;const E=Math.floor(u*(C.length-1)),T=C[Math.min(E,C.length-1)],A=m?.88*u:.22*u;t.fillStyle=$?`rgba(${w},${y},${S},${Math.min(m?.95:.4,.55*u)})`:`rgba(${v},${b},${x},${A})`,t.fillText(T,r,a)}t.textAlign="left"}function zt(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" .·:;=+*#%@░▒▓",accentColor:c,color:l,octaves:h=4,speed:f=1,scale:d=1,accentThreshold:m=.78,mouseWarp:u=.3,lightMode:g=!1}=a,M=c??(g?"#6b8700":"#d4ff00"),p=.62*i,v=1.4*i,b=Math.ceil(e/p),x=Math.ceil(o/v);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let w=255,y=255,S=255;if(g&&(w=55,y=55,S=55),l){const t=Ct(l);t&&(w=t.r,y=t.g,S=t.b)}let $=212,C=255,E=0;const T=Ct(M);T&&($=T.r,C=T.g,E=T.b);const A=.035*d,F=n*f,R=Math.min(6,Math.max(1,h)),I=(t,e)=>{let o=0,n=.5,r=1,a=0;for(let i=0;i<R;i++)o+=Ft(t*r,e*r)*n,a+=n,n*=.5,r*=2.1;return o/a};for(let e=0;e<x;e++)for(let o=0;o<b;o++){const n=o*A+.06*F,a=e*A*1.3-.04*F,i=o/b-r.x,c=e/x-r.y,l=Math.sqrt(i*i+c*c),h=u>0?.12*Math.max(0,1-l/u):0,f=.5*I(n+h*Math.sin(1.3*F+8*c),a+h*Math.cos(.9*F+8*i))+.5;if(f<.12)continue;const d=s[Math.floor(f*(s.length-1))];if(" "===d)continue;const M=f>m,T=g?.82*f:.13*f;t.fillStyle=M?`rgba(${$},${C},${E},${g?.92:.28})`:`rgba(${w},${y},${S},${T})`,t.fillText(d,o*p,e*v)}}function Ht(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=12,chars:s="·-=+|/",accentColor:c,color:l,bands:h=3,speed:f=1,bandWidth:d=.12,glitch:m=!0,lightMode:u=!1}=a,g=c??(u?"#6b8700":"#d4ff00"),M=.62*i,p=1.4*i,v=Math.ceil(e/M),b=Math.ceil(o/p);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let x=255,w=255,y=255;if(u&&(x=55,w=55,y=55),l){const t=Ct(l);t&&(x=t.r,w=t.g,y=t.b)}let S=212,$=255,C=0;const E=Ct(g);E&&(S=E.r,$=E.g,C=E.b);const T=n*f;for(let e=0;e<b;e++)for(let o=0;o<v;o++){const n=e/b,a=((n*h-.5*T)%1+1)%1,i=Math.max(0,1-a/d),c=.35*(.5*At(3*o,7*e)+.5);let l=0;if(m){const t=o/v-r.x,a=n-r.y,i=Math.sqrt(t*t+a*a);if(i<.18){const t=At(11*o+Math.floor(12*T),5*e);l=Math.max(0,1-i/.18)*(t>.5?t-.3:0)}}const f=Math.min(1,c+.8*i+.6*l);if(f<.04)continue;const g=s[Math.floor(f*(s.length-1))],E=i>.55,A=u?.82*f:.12*f;t.fillStyle=E?`rgba(${S},${$},${C},${u?.92:.28})`:`rgba(${x},${w},${y},${A})`,t.fillText(g,o*M,e*p)}}function Wt(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" ·∙•:;+=≡≣#@",color:c,accentColor:l,speed:h=1,layers:f=5,softness:d=1.2,mouseRipple:m=.2,lightMode:u=!1}=a,g=l??(u?"#6b8700":"#d4ff00"),M=.62*i,p=1.4*i,v=Math.ceil(e/M),b=Math.ceil(o/p);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let x=255,w=255,y=255;if(u&&(x=55,w=55,y=55),c){const t=Ct(c);t&&(x=t.r,w=t.g,y=t.b)}let S=212,$=255,C=0;const E=Ct(g);E&&(S=E.r,$=E.g,C=E.b);const T=n*h,A=[];for(let t=0;t<f;t++){const e=At(17*t,31*t+7),o=At(23*t+5,11*t);A.push({fx:.8+2.2*e,fy:1.2+1.8*o,phase:e*Math.PI*4,dt:(.3+.5*At(7*t,13*t+3))*(t%2==0?1:-1),amp:.55+.45*At(29*t,3*t)})}for(let e=0;e<b;e++){const o=e/b;for(let n=0;n<v;n++){const a=n/v,i=a-r.x,c=o-r.y,l=Math.sqrt(i*i+c*c),h=m*Math.exp(-l*l/.06),g=a+i*h,b=o+c*h;let E=0,F=0;for(let t=0;t<f;t++){const{fx:e,fy:o,phase:n,dt:r,amp:a}=A[t];E+=Math.sin(g*e*Math.PI*2+T*r+n)*Math.cos(b*o*Math.PI*2+T*r*.7+1.3*n)*a,F+=a}const R=E/F,I=.5+.5*Math.tanh(R*d*2.2);if(I<.12)continue;const k=(I-.12)/.88,L=s[Math.min(s.length-1,Math.floor(k*s.length))],P=I>.82,z=u?.82*I:.14*I;t.fillStyle=P?`rgba(${S},${$},${C},${u?.92:.32})`:`rgba(${x},${w},${y},${z})`,t.fillText(L,n*M,e*p)}}}function Bt(t,e,o,n,r={}){const{fontSize:a=13,color:i,accentColor:s,speed:c=.4,layers:l=4,turbulence:h=.8,lightMode:f=!1}=r,d=s??(f?"#6b8700":"#d4ff00"),m=.62*a,u=1.4*a,g=Math.ceil(e/m),M=Math.ceil(o/u);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let p=255,v=255,b=255;if(f&&(p=55,v=55,b=55),i){const t=Ct(i);t&&(p=t.r,v=t.g,b=t.b)}let x=212,w=255,y=0;const S=Ct(d);S&&(x=S.r,w=S.g,y=S.b);const $=n*c,C=["─","─","╌","·","╌","─","─","╌","·"];for(let e=0;e<M;e++){const o=e/M;for(let n=0;n<g;n++){const r=n/g;let a=0,i=0;for(let t=0;t<l;t++){const e=At(13*t,7*t+3),n=1.1+2.4*e,s=.9+2*At(29*t,11*t+1),c=e*Math.PI*6,l=(.2+.5*At(41*t,17*t))*(t%2==0?1:-1.3),f=Math.sin(r*n*Math.PI*2+$*l+c),d=Math.cos(o*s*Math.PI*2+$*l*.6+1.7*c),m=Math.sin(r*s*Math.PI*h+o*n*Math.PI*h+$*l*.4);a+=Math.atan2(d+.3*m,f),i+=.5*(f*d+1)}const s=a/l,c=Math.min(1,i/l);if(c<.1)continue;const d=(s+Math.PI)/(2*Math.PI),M=C[Math.floor(d*C.length)%C.length],S=c>.8,E=f?.8*c:.13*c;t.fillStyle=S?`rgba(${x},${w},${y},${f?.9:.26})`:`rgba(${p},${v},${b},${E})`,t.fillText(M,n*m,e*u)}}}function jt(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=13,chars:s=" ·:;=+*#%@",color:c,accentColor:l,speed:h=1,radius:f=.38,swirl:d=3,lightMode:m=!1}=a,u=l??(m?"#6b8700":"#d4ff00"),g=.62*i,M=1.4*i,p=Math.ceil(e/g),v=Math.ceil(o/M),b=e/o;t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let x=255,w=255,y=255;if(m&&(x=55,w=55,y=55),c){const t=Ct(c);t&&(x=t.r,w=t.g,y=t.b)}let S=212,$=255,C=0;const E=Ct(u);E&&(S=E.r,$=E.g,C=E.b);const T=n*h;for(let e=0;e<v;e++){const o=e/v;for(let n=0;n<p;n++){const a=(n/p-r.x)*b,i=o-r.y,c=Math.sqrt(a*a+i*i)/f;if(c>1){const o=At(3*n,7*e)*Math.max(0,1-3*(c-1));if(o<.62)continue;const r=o*(m?.28:.04);t.fillStyle=`rgba(${x},${w},${y},${r})`,t.fillText(s[1],n*g,e*M);continue}const l=Math.max(0,1-Math.abs(c-(.15+.12*Math.sin(1.1*T)))/.07),h=Math.pow(1-c,2.2),d=Math.min(1,h+.6*l);if(d<.06)continue;const u=Math.floor(d*(s.length-1)),v=s[Math.min(s.length-1,u)],E=l>.35||c<.08,A=m?.85*d:.18*d;t.fillStyle=E?`rgba(${S},${$},${C},${m?.95:.38})`:`rgba(${x},${w},${y},${A})`,t.fillText(v,n*g,e*M)}}}function qt(t,e,o,n,r={}){const{fontSize:a=14,chars:i=" ·∙•:-=+*#",color:s,accentColor:c,speed:l=.5,harmonics:h=3,lightMode:f=!1}=r,d=c??(f?"#6b8700":"#d4ff00"),m=.62*a,u=1.4*a,g=Math.ceil(e/m),M=Math.ceil(o/u);t.clearRect(0,0,e,o),t.font=`${a}px monospace`,t.textBaseline="top";let p=255,v=255,b=255;if(f&&(p=55,v=55,b=55),s){const t=Ct(s);t&&(p=t.r,v=t.g,b=t.b)}let x=212,w=255,y=0;const S=Ct(d);S&&(x=S.r,w=S.g,y=S.b);const $=n*l,C=Array.from({length:h},(t,e)=>1/(e+1)).reduce((t,e)=>t+e,0);for(let e=0;e<M;e++)for(let o=0;o<g;o++){let n=0;for(let t=0;t<h;t++){const r=.18+1.4*At(o*(t+3)+7,e*(t+5)+11),a=At(o*(t+7),e*(t+9)+3)*Math.PI*2,i=1/(t+1);n+=Math.sin($*r+a)*i}const r=.5*(n/C+1);if(r<.28)continue;const a=(r-.28)/.72,s=i[Math.min(i.length-1,Math.floor(a*i.length))],c=r>.88,l=f?.82*a:.13*a;t.fillStyle=c?`rgba(${x},${w},${y},${f?.92:.28})`:`rgba(${p},${v},${b},${l})`,t.fillText(s,o*m,e*u)}}function Ot(t,e,o,n,r={}){const{fontSize:a=13,chars:i=" .,:;i+xX#&@",color:s="#ff4500",hotColor:c="#ffe066",intensity:l=.85,wind:h=0,speed:f=1,lightMode:d=!1}=r,m=.62*a,u=1.4*a,g=Math.ceil(e/m),M=Math.ceil(o/u),p=g*M,v="__fire_heat__",b=t.canvas;let x=b[v];x&&x.length===p||(x=new Float32Array(p),b[v]=x);const w=.18*(.016*f),y=h*f*.8,S=M-1,$=n*f;for(let t=0;t<g;t++){const e=(.6*(.5*Math.sin(.31*t+4.1*$)+.5)+.4*(.5*Math.sin(.73*t-2.7*$)+.5))*l;x[S*g+t]=Math.min(1,e+.15*Math.random()*l),S>0&&(x[(S-1)*g+t]=Math.min(1,.85*e+.1*Math.random()*l))}const C=new Float32Array(p);for(let t=0;t<M-2;t++)for(let e=0;e<g;e++){const o=.4*x[(t+1)*g+e]+.25*x[(t+2)*g+Math.max(0,Math.min(g-1,e+Math.round(y)))]+.175*x[(t+1)*g+Math.max(0,e-1)]+.175*x[(t+1)*g+Math.min(g-1,e+1)];C[t*g+e]=Math.max(0,o-w-.02*Math.random()*f)}for(let t=0;t<g;t++)C[(M-1)*g+t]=x[(M-1)*g+t],M>1&&(C[(M-2)*g+t]=x[(M-2)*g+t]);b[v]=C;const E=Ct(s)??{r:255,g:69,b:0},T=Ct(c)??{r:255,g:224,b:102};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";for(let e=0;e<M;e++)for(let o=0;o<g;o++){const n=C[e*g+o];if(n<.03)continue;const r=i[Math.min(i.length-1,Math.floor(n*i.length))];if(" "===r)continue;const a=Math.min(1,1.2*n),s=E.r+(T.r-E.r)*a|0,c=E.g+(T.g-E.g)*a|0,l=E.b+(T.b-E.b)*a|0,h=d?1-.3*n:Math.min(1,n+.15);t.globalAlpha=h,t.fillStyle=`rgb(${s},${c},${l})`,t.fillText(r,o*m,e*u)}t.globalAlpha=1}function Nt(t,e,o,n,r={}){const{fontSize:a=13,baseChars:i="ATCG",bridgeChars:s="-=≡",color:c="#00e5ff",color2:l="#ff4081",bridgeColor:h="#88ffcc",speed:f=1,helixCount:d,lightMode:m=!1}=r,u=.62*a,g=1.4*a,M=Math.ceil(e/u),p=Math.ceil(o/g),v=d??Math.max(1,Math.floor(e/80)),b=M/v,x=Ct(c)??{r:0,g:229,b:255},w=Ct(l)??{r:255,g:64,b:129},y=Ct(h)??{r:136,g:255,b:204};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const S=n*f,$=.35*b;for(let e=0;e<v;e++){const o=b*(e+.5);for(let n=0;n<p;n++){const r=n/p*Math.PI*6-1.8*S,a=o+Math.sin(r)*$,c=o+Math.sin(r+Math.PI)*$,l=Math.round(a),h=Math.round(c);if(l<0||l>=M)continue;const f=At(31*e+7*n,3),d=i[Math.floor(f*i.length)],m=.5*(Math.sin(r)+1),v=.5*(Math.sin(r+Math.PI)+1);if(t.globalAlpha=.35+.65*m,t.fillStyle=`rgb(${x.r},${x.g},${x.b})`,t.fillText(d,l*u,n*g),h>=0&&h<M){const o=At(53*e+11*n,7),r=i[Math.floor(o*i.length)];t.globalAlpha=.35+.65*v,t.fillStyle=`rgb(${w.r},${w.g},${w.b})`,t.fillText(r,h*u,n*g)}if(n%3===0){const o=Math.min(l,h),r=Math.max(l,h);if(r-o>1){const a=At(17*n+43*e,5),i=s[Math.floor(a*s.length)],c=.25*(m+v)+.2;t.globalAlpha=c,t.fillStyle=`rgb(${y.r},${y.g},${y.b})`;for(let e=o+1;e<r;e++)t.fillText(i,e*u,n*g)}}}}t.globalAlpha=1}function Ut(t,e,o,n,r={}){const{fontSize:a=13,chars:i=" .,:;+*#@",color:s="#4caf50",skyColor:c="#1a237e",peakColor:l="#e0e0e0",speed:h=1,roughness:f=.55,heightScale:d=.55,stars:m=!0,lightMode:u=!1}=r,g=.62*a,M=1.4*a,p=Math.ceil(e/g),v=Math.ceil(o/M),b=Ct(s)??{r:76,g:175,b:80},x=Ct(c)??{r:26,g:35,b:126},w=Ct(l)??{r:224,g:224,b:224};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const y=n*h*.4,S=new Array(p);for(let t=0;t<p;t++){const e=(.5*Rt((t/p+y)*f*3,.5)+.5)*d;S[t]=Math.floor(e*v)}for(let e=0;e<v;e++)for(let o=0;o<p;o++){const r=v-1-S[o],a=e===r;if(!(e>=r)){if(m){const r=At(7*o+Math.floor(.3*y),13*e);if(r>.97){const a=.3*Math.sin(2*n+100*r)+.7;t.globalAlpha=.5*a,t.fillStyle=`rgb(${x.r+60},${x.g+60},${x.b+80})`,t.fillText("·",o*g,e*M)}}continue}const s=(e-r)/Math.max(1,S[o]),c=i[Math.min(i.length-1,Math.floor(s*i.length))];if(" "===c&&!a)continue;const l=a?1:Math.max(0,1-4*s),h=b.r+(w.r-b.r)*l|0,f=b.g+(w.g-b.g)*l|0,d=b.b+(w.b-b.b)*l|0;t.globalAlpha=.5+.5*s,t.fillStyle=`rgb(${h},${f},${d})`,t.fillText(a?i[i.length-1]:c,o*g,e*M)}t.globalAlpha=1}var Dt=1,Vt=2,Kt=4,Yt=8,_t={3:"─",12:"│",9:"┌",10:"┐",5:"└",6:"┘",11:"┬",7:"┴",13:"├",14:"┤",15:"┼",[Dt]:"╶",[Vt]:"╴",[Kt]:"╵",[Yt]:"╷"};function Jt(t,e,o,n,r={}){const{fontSize:a=13,pulseColor:i="#ffffff",color:s="#00ff88",density:c=.38,speed:l=1,lightMode:h=!1}=r,f=.62*a,d=1.4*a,m=Math.ceil(e/f),u=Math.ceil(o/d),g=Ct(s)??{r:0,g:255,b:136},M=Ct(i)??{r:255,g:255,b:255},p=(t,e)=>{if(At(17*t+1,7*e+2)>c)return 0;let o=0;return t+1<m&&At(17*t+1,7*e+2)>.15&&(o|=1),t-1>=0&&At(17*(t-1)+1,7*e+2)>.15&&(o|=2),e+1<u&&At(17*t+1,7*(e+1)+2)>.15&&(o|=8),e-1>=0&&At(17*t+1,7*(e-1)+2)>.15&&(o|=4),o};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const v=n*l;for(let e=0;e<u;e++)for(let o=0;o<m;o++){const n=p(o,e);if(0===n)continue;const r=_t[n]??"·",a=(8*v+40*At(o,23*e))%m,i=(6*v+40*At(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*At(3*o,5*e);l?(t.globalAlpha=.95,t.fillStyle=`rgb(${M.r},${M.g},${M.b})`):(t.globalAlpha=h,t.fillStyle=`rgb(${g.r},${g.g},${g.b})`),t.fillText(r,o*f,e*d)}t.globalAlpha=1}var Xt=["wave","rain","stars","pulse","noise","grid","aurora","silk","void","morph","fire","dna","terrain","circuit"];function Gt(t,e={}){const{type:o="wave",opacity:n=.2,className:r,zIndex:a=0,colorScheme:i="auto",color:s,...c}=e,l="string"==typeof t?document.querySelector(t):t;if(!l)return console.warn("[asciify] asciiBackground: target not found",t),{destroy:()=>{}};const h=l.style.position;"static"===getComputedStyle(l).position&&(l.style.position="relative");const f=document.createElement("canvas");f.style.cssText=["position:absolute","inset:0","width:100%","height:100%",`opacity:${n}`,"pointer-events:none",`z-index:${a}`].join(";"),r&&(f.className=r),l.prepend(f);const d=f.getContext("2d"),m=window.devicePixelRatio||1,u={x:.5,y:.5},g={x:.5,y:.5},M=()=>"light"===i||"dark"!==i&&(()=>{let t=l;for(;t&&t!==document.documentElement.parentElement;){const e=getComputedStyle(t).backgroundColor;if(e&&"transparent"!==e&&"rgba(0, 0, 0, 0)"!==e){const t=e.match(/rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)/);if(t)return(.299*+t[1]+.587*+t[2]+.114*+t[3])/255>=.4}t=t.parentElement}const e=document.documentElement,o=(e.getAttribute("data-theme")||"").toLowerCase();return"dark"!==o&&("light"===o||!e.classList.contains("dark")&&window.matchMedia("(prefers-color-scheme: light)").matches)})(),p=s?function(t){const e=t.match(/^#([0-9a-f]{3,8})$/i)?.[1];if(e){const t=e.length<=4?e.split("").map(t=>parseInt(t+t,16)):[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)];return{r:t[0],g:t[1],b:t[2]}}const o=t.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i);return o?{r:+o[1],g:+o[2],b:+o[3]}:null}(s):null,v=()=>({...c,lightMode:void 0!==c.lightMode?c.lightMode:M(),baseColor:p?`rgba(${p.r},${p.g},${p.b},{a})`:c.baseColor}),b={current:v()},x=()=>{b.current="rain"===o||"stars"===o||"pulse"===o||"noise"===o||"grid"===o||"aurora"===o||"silk"===o||"void"===o||"morph"===o?{...c,lightMode:void 0!==c.lightMode?c.lightMode:M(),color:s??c.color}:"fire"===o||"dna"===o?{...c,color:s??c.color}:"terrain"===o||"circuit"===o?{...c,color:s??c.color,lightMode:void 0!==c.lightMode?c.lightMode:M()}:v()};x();const w=window.matchMedia("(prefers-color-scheme: light)"),y=()=>{x()};let S=null;"auto"===i&&(w.addEventListener("change",y),S=new MutationObserver(y),S.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]}));const $=()=>{const t=l.getBoundingClientRect();f.width=t.width*m,f.height=t.height*m,d.setTransform(m,0,0,m,0,0)};$();const C=t=>{const e=l.getBoundingClientRect();u.x=(t.clientX-e.left)/e.width,u.y=(t.clientY-e.top)/e.height},E=new ResizeObserver($);E.observe(l),window.addEventListener("mousemove",C);let T=0,A=0;const F=()=>{g.x+=.07*(u.x-g.x),g.y+=.07*(u.y-g.y);const t=l.getBoundingClientRect();"rain"===o?kt(d,t.width,t.height,T,b.current):"stars"===o?Lt(d,t.width,t.height,T,g,b.current):"pulse"===o?Pt(d,t.width,t.height,T,g,b.current):"noise"===o?zt(d,t.width,t.height,T,g,b.current):"grid"===o?Ht(d,t.width,t.height,T,g,b.current):"aurora"===o?Wt(d,t.width,t.height,T,g,b.current):"silk"===o?Bt(d,t.width,t.height,T,b.current):"void"===o?jt(d,t.width,t.height,T,g,b.current):"morph"===o?qt(d,t.width,t.height,T,b.current):"fire"===o?Ot(d,t.width,t.height,T,b.current):"dna"===o?Nt(d,t.width,t.height,T,b.current):"terrain"===o?Ut(d,t.width,t.height,T,b.current):"circuit"===o?Jt(d,t.width,t.height,T,b.current):It(d,t.width,t.height,T,g,b.current),T+=.016,A=requestAnimationFrame(F)};return A=requestAnimationFrame(F),{destroy:()=>{cancelAnimationFrame(A),E.disconnect(),"auto"===i&&(w.removeEventListener("change",y),S?.disconnect()),window.removeEventListener("mousemove",C),f.remove(),l.style.position=h}}}var Qt=Gt;function Zt(t,e={},o,n){const r={...a,...e},{frame:i,cols:s}=V(t,r,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")}function te(t,e={},o,n){const r={...a,...e},{frame:i,cols:s}=V(t,r,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")}function ee(t,e,o,n="#505050",r=100){if(!t||e<=0||o<=0)return[];const a=Ct(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})))}var oe=new WeakMap;function ne(t,e,o,n,r={},i){const{fontSize:s=10,lineHeight:c=1.6,color:l="#505050",opacity:h=100,hoverEffect:f="spotlight",hoverStrength:d=.85,hoverRadius:m=.18,hoverColor:u="#d4ff00"}=r,g=Math.max(1,Math.floor(e/s)),M=Math.max(1,Math.floor(o/(s*c))),p=JSON.stringify([n,g,M,l,h]);let v=oe.get(t);v&&v.key===p||(v={key:p,frame:ee(n,g,M,l,h)},oe.set(t,v));et(t,v.frame,{...a,fontSize:s,hoverEffect:f,hoverStrength:d,hoverRadius:m,hoverColor:u},e,o,0,i??null)}function re(t,{format:e="png",quality:o=.92,scale:n=1}={}){return new Promise((r,a)=>{let i=t;if(1!==n){const e=document.createElement("canvas");e.width=Math.round(t.width*n),e.height=Math.round(t.height*n);const o=e.getContext("2d");if(!o)return void a(new Error("captureSnapshot: could not get 2d context"));o.drawImage(t,0,0,e.width,e.height),i=e}i.toBlob(t=>t?r(t):a(new Error("captureSnapshot: toBlob returned null")),`image/${e}`,o)})}async function ae(t,e={}){const{filename:o="asciify-snapshot",format:n="png",...r}=e,a=await re(t,{format:n,...r}),i="jpeg"===n?"jpg":n,s=document.createElement("a");s.href=URL.createObjectURL(a),s.download=`${o}.${i}`,s.click(),setTimeout(()=>URL.revokeObjectURL(s.href),1e4)}async function ie(t,{fontSize:e=10,style:o="classic",options:r={},liveOptions:i,mirror:s=!0,constraints:c={facingMode:"user"},dpr:l}={}){if(!navigator.mediaDevices?.getUserMedia)throw new Error("asciifyWebcam: getUserMedia is not supported in this browser.");const h=await navigator.mediaDevices.getUserMedia({video:c}),f=document.createElement("video");f.srcObject=h,f.muted=!0,f.playsInline=!0,await new Promise((t,e)=>{f.onloadedmetadata=()=>t(),f.onerror=()=>e(new Error("asciifyWebcam: video stream failed to load.")),f.play().catch(e)});const d={...a,...n[o],...r,fontSize:e},m=t.getContext("2d");if(!m)throw new Error("asciifyWebcam: could not get 2d context from canvas.");const u=l??("undefined"!=typeof window?window.devicePixelRatio:1)??1;1!==u&&m.scale(u,u);let g=null;const M=e=>{const o=t.getBoundingClientRect();g={x:(e.clientX-o.left)/o.width,y:(e.clientY-o.top)/o.height}},p=()=>{g=null};d.hoverStrength>0&&(t.addEventListener("mousemove",M),t.addEventListener("mouseleave",p));let v,b=!1;const x=performance.now(),w=e=>{if(!b){if(f.readyState>=f.HAVE_CURRENT_DATA){const o=t.width/u,n=t.height/u,r=(e-x)/1e3,a=i?{...d,...i()}:d;a.hoverStrength>0?(t.addEventListener("mousemove",M),t.addEventListener("mouseleave",p)):(t.removeEventListener("mousemove",M),t.removeEventListener("mouseleave",p));const{frame:c}=V(f,a,o,n),l=g&&s?{x:1-g.x,y:g.y}:g;s?(m.save(),m.scale(-1,1),m.translate(-o,0),et(m,c,a,o,n,r,l),m.restore()):et(m,c,a,o,n,r,l)}v=requestAnimationFrame(w)}};return v=requestAnimationFrame(w),()=>{b=!0,cancelAnimationFrame(v),t.removeEventListener("mousemove",M),t.removeEventListener("mouseleave",p),h.getTracks().forEach(t=>t.stop()),f.srcObject=null}}var se={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]},ce=[127,65,65,65,65,65,127];function le(t){return se[t]??se[t.toUpperCase()]??ce}function he(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=le(t[e]);for(let t=0;t<7;t++){const e=o[t];let n="";for(let t=6;t>=0;t--)n+=(e>>t&1?r:" ").repeat(a);for(let e=0;e<a;e++)c[t*a+e]+=n}if(e<t.length-1)for(let t=0;t<i;t++)c[t]+=" ".repeat(s)}return c.join("\n")}function fe(t,e,o={}){const{color:n="#d4ff00",bgColor:r,fontSize:a=10}=o,i=he(e,o);if(!i)return;const s=i.split("\n"),c=Math.max(...s.map(t=>[...t].length));t.width=Math.ceil(c*a*.6),t.height=Math.ceil(s.length*a);const l=t.getContext("2d");r&&"transparent"!==r?(l.fillStyle=r,l.fillRect(0,0,t.width,t.height)):l.clearRect(0,0,t.width,t.height),l.fillStyle=n,l.font=`${a}px monospace`,l.textBaseline="top",s.forEach((t,e)=>l.fillText(t,0,e*a))}export{n as ART_STYLE_PRESETS,Xt as BACKGROUND_TYPES,e as CHARSETS,o as CHARSET_SEQUENCES,a as DEFAULT_OPTIONS,i as HOVER_PRESETS,r as LIVING_STYLE_PRESETS,t as PALETTE_THEMES,Gt as asciiBackground,Zt as asciiText,te as asciiTextAnsi,wt as asciify,yt as asciifyGif,$t as asciifyLiveVideo,he as asciifyText,St as asciifyVideo,ie as asciifyWebcam,ee as buildTextFrame,re as captureSnapshot,j as clearAsciifyCaches,vt as computeCanvasRenderSize,ht as createVideoScrollScrub,X as gifToAsciiFrames,G as gifToAsciiTextFrames,V as imageToAsciiFrame,K as imageToAsciiTextFrame,Qt as mountWaveBackground,Wt as renderAuroraBackground,Jt as renderCircuitBackground,Nt as renderDnaBackground,Ot as renderFireBackground,et as renderFrameToCanvas,Ht as renderGridBackground,qt as renderMorphBackground,zt as renderNoiseBackground,Pt as renderPulseBackground,kt as renderRainBackground,Bt as renderSilkBackground,Lt as renderStarsBackground,Ut as renderTerrainBackground,ne as renderTextBackground,Y as renderTextFrameToCanvas,fe as renderTextToCanvas,jt as renderVoidBackground,It as renderWaveBackground,ae as snapshotAndDownload,_ as videoToAsciiFrames,J as videoToAsciiTextFrames};//# sourceMappingURL=index.js.map