asciify-engine 3.0.0 → 4.1.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.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var t={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:" ·╶╴╷╵─│┌┐└┘├┤┬┴┼╬░▒▓█"},e={cosmic:[t.smoke,t.circles,t.shadows],rain:[t.katakana,t.braille,t.binary],terminal:[t.pipes,t.claudeCode,t.standard],crystal:[t.shards,t.geometric,t.blocks],fluid:[t.waves,t.smoke,t.circles],pulse:[t.dense,t.standard,t.blocks],dream:[t.braille,t.shadows,t.smoke],angular:[t.geometric,t.shards,t.blocks],assistant:[t.interface,t.prompt,t.data],signal:[t.mesh,t.data,t.ascii],editorial:[t.humanist,t.waves,t.smoke]},o={classic:{renderMode:"ascii",charset:t.standard,colorMode:"grayscale"},particles:{renderMode:"dots",colorMode:"fullcolor",dotSizeRatio:.8},letters:{renderMode:"ascii",charset:t.letters,colorMode:"fullcolor"},claudeCode:{renderMode:"ascii",charset:t.claudeCode,colorMode:"accent",accentColor:"#f97316"},art:{renderMode:"ascii",charset:t.dense,colorMode:"fullcolor"},terminal:{renderMode:"ascii",charset:t.standard,colorMode:"matrix"},box:{renderMode:"ascii",charset:t.box,colorMode:"grayscale"},lines:{renderMode:"ascii",charset:t.lines,colorMode:"fullcolor"},braille:{renderMode:"ascii",charset:t.braille,colorMode:"fullcolor"},katakana:{renderMode:"ascii",charset:t.katakana,colorMode:"matrix"},circles:{renderMode:"ascii",charset:t.circles,colorMode:"accent",accentColor:"#d4ff00"},shadows:{renderMode:"ascii",charset:t.shadows,colorMode:"accent",accentColor:"#50a0ff"},geometric:{renderMode:"ascii",charset:t.geometric,colorMode:"grayscale"},pipes:{renderMode:"ascii",charset:t.pipes,colorMode:"accent",accentColor:"#00ff88"},waves:{renderMode:"ascii",charset:t.waves,colorMode:"fullcolor"},shards:{renderMode:"ascii",charset:t.shards,colorMode:"grayscale"},smoke:{renderMode:"ascii",charset:t.smoke,colorMode:"accent",accentColor:"#c850ff"},ascii:{renderMode:"ascii",charset:t.ascii,colorMode:"grayscale"},interface:{renderMode:"ascii",charset:t.interface,colorMode:"accent",accentColor:"#f4f1ea"},prompt:{renderMode:"ascii",charset:t.prompt,colorMode:"matrix"},data:{renderMode:"ascii",charset:t.data,colorMode:"fullcolor"},humanist:{renderMode:"ascii",charset:t.humanist,colorMode:"accent",accentColor:"#d6ccc2"},mesh:{renderMode:"ascii",charset:t.mesh,colorMode:"accent",accentColor:"#8fd3ff"}},n={agentField:{...o.interface,charsetFrames:e.assistant,charsetFps:1.6,animationStyle:"caustics",animationSpeed:.75,ditherStrength:.12,hoverEffect:"glow",hoverStrength:.42,hoverRadius:.18,hoverColor:"#f4f1ea",normalize:!0},liquidSignal:{...o.data,charsetFrames:e.signal,charsetFps:2.4,animationStyle:"current",animationSpeed:.65,ditherStrength:.45,hoverEffect:"repel",hoverStrength:.55,hoverRadius:.22,hoverColor:"#8fd3ff",normalize:!0},cursorGravity:{...o.mesh,charsetFrames:e.angular,charsetFps:1.2,animationStyle:"current",animationSpeed:.9,ditherStrength:.2,hoverEffect:"attract",hoverStrength:.82,hoverRadius:.24,hoverColor:"#ffffff",normalize:!0},editorialPulse:{...o.humanist,charsetFrames:e.editorial,charsetFps:.9,animationStyle:"caustics",animationSpeed:.55,ditherStrength:.18,hoverEffect:"spotlight",hoverStrength:.35,hoverRadius:.2,hoverColor:"#fff8ea",normalize:!0},terminalFlow:{...o.prompt,charsetFrames:e.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}},r={fontSize:7,charSpacing:1,brightness:0,contrast:0,charset:t.standard,colorMode:"grayscale",accentColor:"#d4ff00",invert:!1,renderMode:"ascii",animationStyle:"none",animationSpeed:1,dotSizeRatio:.8,ditherStrength:0,charAspect:.55,normalize:!1,hoverStrength:0,hoverRadius:.2,hoverEffect:"spotlight",hoverColor:"#ffffff",hoverShape:"circle",hoverText:"ASCIIFY",artStyle:"classic",customText:"",chromaKey:null,chromaKeyTolerance:60,chromaKeyTrimPadding:.002,chromaKeyTrimLuminanceThreshold:0,chromaKeyTrimMode:"range"},a=[{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 i=(t,e,o)=>{const n=(t=>Math.max(0,Math.min(1,t)))((o-t)/(e-t));return n*n*(3-2*n)};function s(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,s=i(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)*s}else if("current"===t)r[0]=Math.sin(9*o+a)*Math.cos(7*e-a)*10*s,r[1]=Math.cos(8*e+a)*Math.sin(6*o-a)*7*s;else if("reform"===t){const t=(n%12+12)%12,c=((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*c+.08*Math.sin(8*e-5*o),h=i(1.8+1.2*l,3.8+1.2*l,t)*(1-i(5+1.7*l,7.2+1.7*l,t));r[0]=Math.sin(9*o+a)*h*(1-h)*24*s,r[1]=-h*(1-h)*(8+12*c)*s,r[2]=.45*-h,r[3]=1-.9*h}return r}function c(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 l(t,e,o){let n=t+255*e;return n=259*(255*o+255)/(255*(259-255*o))*(n-128)+128,Math.max(0,Math.min(255,n))}function h(t,e,o,n,r,a){if((a?1-t/255:t/255)<.12)return" ";const i=[...e];return i[(n*r+o)%i.length]}var d=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];function f(t,e,o,n){if(n<=0)return t;const r=(d[o%4][e%4]/16-.5)*n*128;return Math.max(0,Math.min(255,t+r))}var m=new Array(256),u=new Array(256);for(let t=0;t<256;t++)m[t]=`rgb(${t},${t},${t})`,u[t]=`rgb(0,${t},0)`;function g(t,e,o,n,r,a=!1){switch(e){case"fullcolor":return`rgb(${t.r},${t.g},${t.b})`;case"matrix":return u[.299*t.r+.587*t.g+.114*t.b|0];case"accent":return`rgb(${o},${n},${r})`;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;return m[e]}}}var M=[0,0,0];function p(t,e,o,n,r,a=!1){switch(e){case"fullcolor":M[0]=t.r,M[1]=t.g,M[2]=t.b;break;case"matrix":{const e=.299*t.r+.587*t.g+.114*t.b|0;M[0]=0,M[1]=e,M[2]=0;break}case"accent":M[0]=o,M[1]=n,M[2]=r;break;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;M[0]=e,M[1]=e,M[2]=e;break}}return M}function 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 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=x(t);if(e&&e.a>.1)return e}e=e.parentElement}return null}function b(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 w(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 y(t){return t*t*(3-2*t)}var S={scale:1,offsetX:0,offsetY:0,glow:0,colorBlend:0,proximity:0};function $(t,e,o,n,r,a,i,s,c="spotlight",l=.5,h="circle",d=[],f=1){const m=(t-o)*Math.max(1,f),u=(e-n)*Math.max(1,1/f),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===d.length))return S.scale=1,S.offsetX=0,S.offsetY=0,S.glow=0,S.colorBlend=0,S.proximity=0,S;const x=y(Math.max(0,1-M/p))*r;let v=1,b=0,w=0,$=0,E=0;switch(c){case"spotlight":{v=1+x*a*1.8;const t=Math.atan2(u,m),e=x*x*a*.6;b=Math.cos(t)*e*i,w=Math.sin(t)*e*s,$=x*a*.4,E=x*x*a*.25;break}case"magnify":v=1+x*a*.85,$=x*a*.15;break;case"repel":{v=1;const t=Math.atan2(u,m),e=x*x*a*1.8;b=Math.cos(t)*e*i,w=Math.sin(t)*e*s;break}case"glow":$=x*a*.8,E=x*a*.4;break;case"colorShift":v=1,$=x*a*.12,E=x*a;break;case"attract":{const t=Math.atan2(u,m),e=x*x*a*1;b=(.45*-Math.cos(t)-1.6*Math.sin(t))*e*i,w=(.45*-Math.sin(t)+1.6*Math.cos(t))*e*s,$=x*a*.3;break}case"shatter":{const t=Math.atan2(u,m),e=.5*Math.sin(43.7*m+29.3*u),o=x*a*1.4*(.7+.3*e);b=Math.cos(t+e)*o*i,w=Math.sin(t+e)*o*s,v=Math.max(.1,1-x*a*.6),$=x*a*.25;break}case"trail":{let o=x,n=-u*x,r=m*x;for(const a of d){const i=(t-a.x)*Math.max(1,f),s=(e-a.y)*Math.max(1,1/f),c=Math.hypot(i,s)/g;if(c>=1)continue;const l=y(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}b=Math.tanh(2*n)*a*i*3,w=Math.tanh(2*r)*a*s*3,E=o*a*.65,$=o*a*.35,v=1+o*a*.08,S.proximity=o;break}case"glitchText":v=1,$=x*a*.5,E=x*a*.6}return S.scale=v,S.offsetX=b,S.offsetY=w,S.glow=$,S.colorBlend=E,"trail"!==c&&(S.proximity=x),S}function E(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 d=window.matchMedia("(prefers-reduced-motion: reduce)"),f=()=>{l=!0,s||!c||document.hidden||i||(i=requestAnimationFrame(m))},m=t=>{if(i=0,s||!c||document.hidden)return;const n=!d.matches&&(o||t-h<1500);(l||n)&&(e(t,d.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(),f()},g=()=>{a=null,h=performance.now(),f()},M=()=>{document.hidden&&i?(cancelAnimationFrame(i),i=0):f()},p="undefined"==typeof IntersectionObserver?null:new IntersectionObserver(([t])=>{c=t.isIntersecting,c?f():i&&(cancelAnimationFrame(i),i=0)});return p?.observe(t),n&&(r.addEventListener("pointermove",u),r.addEventListener("pointerleave",g)),document.addEventListener("visibilitychange",M),d.addEventListener("change",f),f(),{wake:f,stop:()=>{s=!0,cancelAnimationFrame(i),p?.disconnect(),r.removeEventListener("pointermove",u),r.removeEventListener("pointerleave",g),document.removeEventListener("visibilitychange",M),d.removeEventListener("change",f)}}}var C=null,T=null;function A(t,e){if(!C||!T){const o=c(t,e);C=o.canvas,T=o.ctx}return C.width!==t&&(C.width=t),C.height!==e&&(C.height=e),T}var F=new Map,k=new Map,R=new WeakMap;function I(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=I(t),F.set(t,e)),e}function P(t){return I(t)}function B(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 z(t,e,o,n){const r=`${t}\0${e?1:0}\0${o}\0${n}`;let a=k.get(r);if(!a){const i=L(t);a=new Array(256);for(let t=0;t<256;t++)a[t]=B(l(t,o,n),i,e);k.set(r,a)}return a}function H(t,e){return"auto"!==t?t:!b(e)}function W(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 j(t){const e=t||"auto";if("auto"!==e)return W(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=W(t.getPropertyValue(e).trim());if(o)return o}const e=W(getComputedStyle(document.body).accentColor??"");if(e)return e}return b("undefined"!=typeof document?document.body:null)?"faf9f7":"0d0d0d"}function O(t,e,o){return Math.max(e,Math.min(o,t))}function q(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=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,o-1),h=O(i(t.bottom)??0,0,o-l-1),d=void 0!==t.left||void 0!==t.right||void 0!==t.top||void 0!==t.bottom,f=Math.max(1,e-s-c),m=Math.max(1,o-l-h),u=d?f:a(t.width),g=d?m:i(t.height);let M=u??e,p=g??o;if(r&&!d){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=O(M,1,d?f:e),p=O(p,1,d?m:o);const x=t.anchor??"center",v=a(t.x),b=i(t.y),w=d?s:0,y=d?l:0,S=d?f:e,$=d?m:o,E=x.endsWith("left")||"left"===x?0:x.endsWith("right")||"right"===x?S-M:(S-M)/2,C=x.startsWith("top")||"top"===x?0:x.startsWith("bottom")||"bottom"===x?$-p:($-p)/2;return{x:O(v??w+E,0,Math.max(0,e-M)),y:O(b??y+C,0,Math.max(0,o-p)),width:M,height:p}}function N(t,e,o,n){const r=t instanceof HTMLVideoElement?t.videoWidth:t.width,a=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(0===r||0===a)return{frame:[],cols:0,rows:0};const i=e.charAspect,s=e.fontSize*e.charSpacing,c=e.fontSize/i*e.charSpacing,d=o||r,m=n||a,u=Math.floor(d/s),g=Math.floor(m/c);if(u<=0||g<=0)return{frame:[],cols:0,rows:0};const M=q(e.sourceCrop,r,a),p=Math.max(1,Math.min(Math.floor(2048/u),Math.floor(M.width/u))),x=Math.max(1,Math.min(Math.floor(2048/g),Math.floor(M.height/g))),v=u*p,b=g*x,y=A(v,b),S=y.globalCompositeOperation;y.globalCompositeOperation="copy";try{y.drawImage(t,M.x,M.y,M.width,M.height,0,0,v,b)}finally{y.globalCompositeOperation=S}const $=y.getImageData(0,0,v,b).data,E=e.chromaKey,C=null!=E&&!1!==E,T=!0===E,F="blue-screen"===E;let k=null,R=0;!C||T||F||(k=w(E),R=(e.chromaKeyTolerance??60)**2);let I=0,P=255;if(e.normalize){let t=255,e=0;for(let o=0;o<$.length;o+=4){if(C){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(F)r=n>1.4*t&&n>1.4*e&&n>80;else if(null!==k){const o=t-k.r,a=e-k.g,i=n-k.b;r=o*o+a*a+i*i<=R}if(r)continue}const n=.299*$[o]+.587*$[o+1]+.114*$[o+2];n<t&&(t=n),n>e&&(e=n)}I=t,P=e>t?e-t:255}const W=[],j=H(e.invert),O=C&&e.charset.replace(/ /g,"")||e.charset,N=L(O),V=e.customText?null:z(O,j,e.brightness,e.contrast),D=p*x;for(let t=0;t<g;t++){const o=[];for(let n=0;n<u;n++){let r=0,a=0,i=0,s=0,c=0;for(let e=0;e<x;e++){const o=(t*x+e)*v;for(let t=0;t<p;t++){const e=4*(o+n*p+t),l=$[e],h=$[e+1],d=$[e+2],f=$[e+3];if(C){let t=!1;if(T)t=h>1.4*l&&h>1.4*d&&h>80;else if(F)t=d>1.4*l&&d>1.4*h&&d>80;else if(null!==k){const e=l-k.r,o=h-k.g,n=d-k.b;t=e*e+o*o+n*n<=R}if(t){c++;continue}}r+=l,a+=h,i+=d,s+=f}}if(C&&c>D/2){o.push({char:" ",r:0,g:0,b:0,a:0});continue}const d=D-c,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-I)/P*255:w,S=l(y,e.brightness,e.contrast),E=e.ditherStrength>0?f(S,n,t,e.ditherStrength):S,A=e.customText?h(E,e.customText,n,t,u,j):e.ditherStrength>0?B(E,N,j):V[Math.max(0,Math.min(255,0|y))];o.push({char:A,r:m,g:g,b:M,a:b,lum:E})}W.push(o)}return{frame:W,cols:u,rows:g}}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{rows:[],cols:0,rowCount:0};const i=e.charAspect,s=e.fontSize*e.charSpacing,c=e.fontSize/i*e.charSpacing,h=o||r,d=n||a,m=Math.floor(h/s),u=Math.floor(d/c);if(m<=0||u<=0)return{rows:[],cols:0,rowCount:0};const g=m,M=u,p=A(g,M),x=q(e.sourceCrop,r,a),v=p.globalCompositeOperation;p.globalCompositeOperation="copy";try{p.drawImage(t,x.x,x.y,x.width,x.height,0,0,g,M)}finally{p.globalCompositeOperation=v}const b=p.getImageData(0,0,g,M).data,y=e.chromaKey,S=null!=y&&!1!==y,$=!0===y,E="blue-screen"===y;let C=null,T=0;!S||$||E||(C=w(y),T=(e.chromaKeyTolerance??60)**2);let F=0,k=255;if(e.normalize){let t=255,e=0;for(let o=0;o<b.length;o+=4){if(S){const t=b[o],e=b[o+1],n=b[o+2];let r=!1;if($)r=e>1.4*t&&e>1.4*n&&e>80;else if(E)r=n>1.4*t&&n>1.4*e&&n>80;else if(null!==C){const o=t-C.r,a=e-C.g,i=n-C.b;r=o*o+a*a+i*i<=T}if(r)continue}const n=.299*b[o]+.587*b[o+1]+.114*b[o+2];n<t&&(t=n),n>e&&(e=n)}F=t,k=e>t?e-t:255}const R=H(e.invert),I=S&&e.charset.replace(/ /g,"")||e.charset,P=L(I),W=e.customText?null:z(I,R,e.brightness,e.contrast),j=e.customText?L(e.customText):null,O="fullcolor"===e.colorMode?new Uint8ClampedArray(m*u*4):void 0,N=[];for(let t=0;t<u;t++){let o="";for(let n=0;n<m;n++){const r=4*(t*g+n),a=r,i=b[r],s=b[r+1],c=b[r+2],h=b[r+3];if(S){let t=!1;if($)t=s>1.4*i&&s>1.4*c&&s>80;else if(E)t=c>1.4*i&&c>1.4*s&&c>80;else if(null!==C){const e=i-C.r,o=s-C.g,n=c-C.b;t=e*e+o*o+n*n<=T}if(t){o+=" ",O&&(O[a]=0,O[a+1]=0,O[a+2]=0,O[a+3]=0);continue}}O&&(O[a]=i,O[a+1]=s,O[a+2]=c,O[a+3]=h);const d=.299*i+.587*s+.114*c,u=e.normalize?(d-F)/k*255:d,M=e.ditherStrength>0||j?l(u,e.brightness,e.contrast):u,p=e.ditherStrength>0?f(M,n,t,e.ditherStrength):M;if(j){o+=(R?1-p/255:p/255)<.12?" ":j[(t*m+n)%j.length]}else e.ditherStrength<=0?o+=W[Math.max(0,Math.min(255,0|u))]:o+=B(p,P,R)}N.push(o)}return{rows:N,cols:m,rowCount:u,colors:O}}function D(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||(R.delete(t),t.clearRect(0,0,n,r),t.fillStyle=b(a)?"#0a0a0a":"#faf9f7",t.fillRect(0,0,n,r));const s=j(o.accentColor),c=parseInt(s.substring(0,2),16),l=parseInt(s.substring(2,4),16),h=parseInt(s.substring(4,6),16),d=n/e.cols,f=r/e.rowCount,m=.9*Math.min(d/.55,f),u=e.colors;if("fullcolor"===o.colorMode&&u){R.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=P(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*d+.5*d,n*f+.5*f)}}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?b(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===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*f,n,f+1),0!==r.trim().length&&t.fillText(r,.5*d,o*f+.5*f))}R.set(t,{rows:e.rows.slice(),cols:e.cols,rowCount:e.rowCount,canvasWidth:n,canvasHeight:r,fillStyle:g}),t.globalAlpha=1}async function U(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 d=0,f=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=N(t,e,o,n);h.push(u.frame),d=u.cols,f=u.rows,i?.((a+1)/l)}return{frames:h,cols:d,rows:f,fps:r}}async function K(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 d=0,f=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),d=u.cols,f=u.rowCount,i?.((a+1)/l)}return{frames:h,cols:d,rows:f,fps:r}}async function _(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,d=s.lsd?.width||l,f=s.lsd?.height||h,m=document.createElement("canvas");m.width=d,m.height=f;const u=m.getContext("2d"),g=document.createElement("canvas");g.width=d,g.height=f;const M=g.getContext("2d"),p=document.createElement("canvas"),x=p.getContext("2d"),v=[];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))),E=Math.min(c.length,300);for(let t=0;t<E;t++){const a=c[t],{dims:i,patch:s,disposalType:l}=a;3===l&&(M.clearRect(0,0,d,f),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);x.putImageData(h,0,0),u.drawImage(p,i.left||0,i.top||0);const y=N(m,e,o,n);v.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,d,f),u.drawImage(g,0,0)),r?.((t+1)/E)}return{frames:v,cols:b,rows:w,fps:$}}var Y=new WeakMap,G=new WeakMap,J=new WeakMap;function X(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=Y.get(t);e||(e={x:.5,y:.5,intensity:0,time:-1,emittedAt:-1,points:[]},Y.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 Y.delete(t);if("none"!==o.animationStyle||o.charsetFrames?.length||o.hoverStrength<=0)return J.delete(t),void Q(t,e,o,n,r,a,s);const c=G.get(t);if(c?.frame!==e)return G.set(t,{frame:e,since:performance.now()}),J.delete(t),void Q(t,e,o,n,r,a,s);if(performance.now()-c.since<100)return void Q(t,e,o,n,r,a,s);const l=t.getTransform();if(l.b||l.c||l.a<=0||l.d<=0)return void Q(t,e,o,n,r,a,s);if(!s||(s.intensity??0)<.003)return void Q(t,e,o,n,r,a,null);const h=b(t.canvas),d={...o,accentColor:"#"+j(o.accentColor)},f=JSON.stringify([d,n,r,l.a,l.d,h,void 0!==document.fonts?document.fonts.status:"loaded"]);let m=J.get(t);if(!m||m.frame!==e||m.key!==f){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),Q(a,e,d,n,r,0,null,void 0,h),m={frame:e,key:f,canvas:o},J.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 x=1,v=1,w=0,y=0;for(const t of p)x=Math.min(x,t.x-M),w=Math.max(w,t.x+M),v=Math.min(v,t.y-M),y=Math.max(y,t.y+M);if("glitchText"===o.hoverEffect){const t=o.hoverText,e=Math.max(1,...(Array.isArray(t)?t:[t]).map(t=>t.length));x=Math.min(x,s.x-e/g),w=Math.max(w,s.x+e/g)}const S=Math.ceil(5+4*o.hoverStrength),$={x:Math.max(0,Math.floor(x*g)-S),y:Math.max(0,Math.floor(v*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*n/g,$.y*r/u,($.right-$.x)*n/g,($.bottom-$.y)*r/u),t.clip(),Q(t,e,d,n,r,a,s,$,h),t.restore()}function Q(t,e,o,n,r,i=0,c,l,h){const d=e.length;if(0===d)return;const f=e[0].length;t.clearRect(0,0,n,r);let m=!1;const u=Math.max(1,d>>2),M=Math.max(1,f>>2);t:for(let t=0;t<d;t+=u){const o=e[t];for(let t=0;t<f;t+=M)if(o[t].a<200){m=!0;break t}}const x=t.canvas,v=h??b(x);m||(t.fillStyle=v?"#0a0a0a":"#faf9f7",t.fillRect(0,0,n,r));const w=n/f,y=r/d,S=c?.intensity??1,E=!!(c&&o.hoverStrength>0&&S>.005),C="#"+(W(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),k=j(o.accentColor),R=parseInt(k.substring(0,2),16),I=parseInt(k.substring(2,4),16),P=parseInt(k.substring(4,6),16),z=o.hoverRadius;let O=0,q=f,N=0,V=d,D=0,U=0;if(E&&c){D=c.x,U=c.y;const t=.08+.35*z+.04*o.hoverStrength;O=Math.max(0,Math.floor((D-t)*f)-1),q=Math.min(f,Math.ceil((D+t)*f)+1),N=Math.max(0,Math.floor((U-t)*d)-1),V=Math.min(d,Math.ceil((U+t)*d)+1)}if(E&&"trail"===o.hoverEffect)for(const t of c?.trail??[]){const e=.08+.35*z+.04*o.hoverStrength;O=Math.min(O,Math.max(0,Math.floor((t.x-e)*f)-1)),q=Math.max(q,Math.min(f,Math.ceil((t.x+e)*f)+1)),N=Math.min(N,Math.max(0,Math.floor((t.y-e)*d)-1)),V=Math.max(V,Math.min(d,Math.ceil((t.y+e)*d)+1))}const K=o.animationStyle,_=o.animationSpeed,Y=(G=K,a.find(t=>t.value===G||t.mode===G)?.mode??"none");var G;const J="none"===Y,X=[0,0,0,1],Q=o.hoverStrength,Z=o.hoverEffect,tt=z,et=o.hoverShape||"circle",ot=H(o.invert,x),nt=o.colorMode,rt=2*Math.PI,at=1/f,it=1/d;let st="",ct=-1;if("dots"===o.renderMode){const a=.5*Math.min(w,y)*o.dotSizeRatio;for(let o=l?.y??0;o<(l?.bottom??d);o++){const h=e[o];for(let e=l?.x??0;e<(l?.right??f);e++){const l=h[e];if(l.a<10)continue;const m=.00392156863*(.299*l.r+.587*l.g+.114*l.b),u=ot?1-m:m;if(u<.02)continue;J||s(Y,e/f,o/d,i*_,X);const M=Math.max(0,Math.min(1,(1+X[2])*X[3]));let x=1,v=0,b=0,C=0,k=0;if(E&&e>=O&&e<=q&&o>=N&&o<=V){const t=$(e*at,o*it,D,U,S,Q,w,y,Z,tt,et,c?.trail,n/r);x=t.scale,v=t.offsetX,b=t.offsetY,C=t.glow,k=t.colorBlend}const L=a*u*M*x;if(L<.3)continue;const B=e*w+.5*w+v+X[0],z=o*y+.5*y+b+X[1];let H;if(k>0){const t=p(l,nt,R,I,P,ot);H=`rgb(${Math.min(255,t[0]+(T-t[0])*k|0)},${Math.min(255,t[1]+(A-t[1])*k|0)},${Math.min(255,t[2]+(F-t[2])*k|0)})`}else H=g(l,nt,R,I,P,ot);const W=Math.min(1,.00392156863*l.a*M*(1+C));if(W!==ct&&(t.globalAlpha=W,ct=W),H!==st&&(t.fillStyle=H,st=H),L<=3){const e=2*L;t.fillRect(B-L,z-L,e,e)}else t.beginPath(),t.arc(B,z,L,0,rt),t.fill()}}}else{const a=.55,h=.9*Math.min(w/a,y);{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,M=u?m[Math.floor(Math.max(0,i)*(o.charsetFps??2))%m.length]:o.charset,x=t.getTransform();if(!E&&J&&!u&&"accent"===nt&&!l&&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=w-n+"px",t.fillStyle=`rgb(${R},${I},${P})`,t.globalAlpha=1,t.textAlign="left";for(let o=0;o<d;o++){const r=e[o];let a="";for(let t=0;t<f;t++){const e=r[t];a+=e.a<10?" ":e.char}0!==a.trim().length&&t.fillText(a,.5*(w-n),o*y+.5*y)}return t.letterSpacing=o,t.textAlign="center",void(t.globalAlpha=1)}const v="glitchText"===Z&&E,b="!@#$%^&*<>{}[]|/\\~`0123456789",C=b.length;let k="",H=0,W=0,j=0,K=0,G=0,rt=0;if(v){const t=o.hoverText??"ASCIIFY";if(W=Math.round(D*f),j=Math.round(U*d),Array.isArray(t)){const e=t.filter(t=>t.length>0);0===e.length&&e.push("ASCIIFY");k=e[((7*Math.floor(W/Math.max(1,Math.ceil(f/5)))+13*Math.floor(j/Math.max(1,Math.ceil(d/3))))%e.length+e.length)%e.length]}else k=t||"ASCIIFY";H=k.length,K=Math.max(3,Math.min(12,Math.round(d*z*.6)));const e=Math.floor(K/2);G=Math.max(0,j-e),G+K>d&&(G=Math.max(0,d-K)),rt=W-Math.floor(H/2)}for(let o=l?.y??0;o<(l?.bottom??d);o++){const a=e[o];for(let h=l?.x??0;h<(l?.right??f);h++){const l=a[h];if(l.a<10)continue;let m=u&&null!=l.lum?B(l.lum,L(M),ot):l.char;if(" "===m)continue;J||s(Y,h/f,o/d,i*_,X);const z=Math.max(0,Math.min(1,(1+X[2])*X[3]));if(z<.05)continue;let lt=1,ht=0,dt=0,ft=0,mt=0;if(E&&!v&&h>=O&&h<=q&&o>=N&&o<=V){const t=$(h*at,o*it,D,U,S,Q,w,y,Z,tt,et,c?.trail,n/r);if(lt=t.scale,ht=t.offsetX,dt=t.offsetY,ft=t.glow,mt=t.colorBlend,"trail"===Z&&t.proximity>0){const n=Math.max(0,Math.min(f-1,Math.round(h-t.offsetX/w))),r=e[Math.max(0,Math.min(d-1,Math.round(o-t.offsetY/y)))][n],a=r.lum??.299*r.r+.587*r.g+.114*r.b;m=B(Math.min(255,a+t.proximity*Q*65),L(M),ot)}}if(v&&o>=G&&o<G+K){const t=h-rt;if(t>=0&&t<H){const e=k[t],n=Math.abs(o-j)/Math.max(1,.5*K),r=Math.abs(h-W)/Math.max(1,H),a=Math.max(n,r),s=Math.max(0,Math.min(1,1-.9*a)),c=43758.5453*Math.sin(127.1*h+311.7*o+43758.5453*Math.floor(12*i));m=Math.abs(c-Math.floor(c))<s?e:b[Math.abs(Math.floor(97*c))%C],ft=.3+.7*s,mt=.3+.65*s}}const ut=h*w+.5*w+ht+X[0],gt=o*y+.5*y+dt+X[1];let Mt;if(mt>0){const t=p(l,nt,R,I,P,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=g(l,nt,R,I,P,ot);const pt=Math.min(1,.00392156863*l.a*z*(1+ft));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(x)):t.fillText(m,ut,gt)}}}t.globalAlpha=1}function Z(t){return Math.max(0,Math.min(1,t))}function tt(t){return"string"==typeof t?document.querySelector(t):t instanceof HTMLElement?t:null}function et(t){return"ascii"===t.renderMode&&"none"===t.animationStyle&&t.hoverStrength<=0&&!t.charsetFrames?.length}function ot(t,e={}){const o=Z(t),n=Z(o*(void 0===e.speed?1:Math.max(.001,e.speed)));return Z(e.ease?e.ease(n):n)}function nt(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=ot(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 rt(t,e){return Math.abs(t.currentTime-e)<1/240?at(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 at(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 it(t,e={}){const o=tt(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=>nt(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?Z((a-r.top)/i):0;nt(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 st(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?Z((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 ct(t,e,o){if(!t||!e||!o.sourceCrop)return{w:t,h:e};const n=q(o.sourceCrop,t,e);return{w:Math.max(1,Math.round(n.width)),h:Math.max(1,Math.round(n.height))}}function lt(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=w(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 ht(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=q(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:l}=c(i,s);l.drawImage(t,a.x,a.y,a.width,a.height,0,0,i,s);const h=l.getImageData(0,0,i,s).data,d=Math.max(0,Math.min(255,e.chromaKeyTrimLuminanceThreshold??0));let f=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=h[n+3],a=h[n],s=h[n+1],c=h[n+2];r<=8||.2126*a+.7152*s+.0722*c<=d||lt(a,s,c,e)||(o<f&&(f=o),t<m&&(m=t),o>u&&(u=o),t>g&&(g=t))}if(u<f||g<m)return e;const M=Math.max(0,Math.min(.25,e.chromaKeyTrimPadding??.002)),p=Math.round(i*M),x=Math.round(s*M);f=Math.max(0,f-p),m=Math.max(0,m-x),u=Math.min(i-1,u+p),g=Math.min(s-1,g+x);const v=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),d=Math.max(s,t.top),f=Math.min(c,o-t.right),m=Math.min(l,n-t.bottom),u=Math.max(1,f-h),g=Math.max(1,m-d),M=h+u/2,p=d+g/2;let x=u,v=g;x/v<a?x=v*a:v=x/a;x>e.width&&(x=e.width,v=Math.max(g,Math.min(e.height,x/a)));v>e.height&&(v=e.height,x=Math.max(u,Math.min(e.width,v*a)));let b=M-x/2,w=p-v/2;return b=Math.max(i,Math.min(c-x,b)),w=Math.max(s,Math.min(l-v,w)),{left:b,top:w,right:o-(b+x),bottom:n-(w+v)}}({left:a.x+f/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",...v,preserveAspect:!1}}}function dt(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 ft(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 rt(t,o),await at(t);const n=dt(ht(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 rt(t,a),await at(t),s?{...e,sourceCrop:{unit:"pixel",...s,preserveAspect:!0}}:e}function mt(t,e,o=2048){return ut({sourceWidth:t,sourceHeight:e,maxRenderDimension:o})}function ut({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,d=Math.max(0,o,n),f=Math.min(c,Math.max(h,d));return s>=1?{renderW:Math.round(f),renderH:Math.round(f/s)}:{renderW:Math.round(f*s),renderH:Math.round(f)}}function gt(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 Mt(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,d=gt(i.width,s,l,h)??s,f=gt(i.height,c,l,h)??c,m=function(t,e,o,n,r){const a=t=>{const o=gt(t,e,n,r);return o&&o>0?o:0},i=t=>{const e=gt(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=d+2*m.x,g=f+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"),x="undefined"!=typeof window&&window.devicePixelRatio||1;let v,b;n&&r?({renderW:v,renderH:b}=ut({sourceWidth:n,sourceHeight:r,cssWidth:M,cssHeight:p,maxRenderDimension:a})):(v=M,b=p);const w=8e6,y=v*x*b*x>w?Math.sqrt(w/(v*b)):x;return t.width=Math.round(v*y),t.height=Math.round(b*y),t.style.width=`${M}px`,t.style.height=`${p}px`,{renderW:v,renderH:b,dpr:y}}async function pt(t,e,{fontSize:n,artStyle:a="classic",options:i={},fitTo:s,objectFit:c,objectPosition:l,scale:h,width:d,height:f,bleed:m,preExtract:u=!1,fps:g,maxRenderDimension:M=2048,trim:p,scroll:x,maxCachedFrames:v=90,onReady:b,onFrame:w}={}){const y=p?.start??0,S=p?.end,$=n??i.fontSize??10;let C={...r,...o[a],artStyle:a,...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:d,height:f,bleed:m},k=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),R=t=>()=>{t(),k()};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 ft(o,C,y,S,x);const n=ct(o.videoWidth,o.videoHeight,C);A&&Mt(e,A,n.w/n.h,n.w,n.h,M,F);const{renderW:r,renderH:a}=mt(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??(x?18:void 0);if(et(C)){const{frames:t,fps:n}=await K(o,C,r,a,h,l,void 0,y),i=e=>{const o=t[e];o&&(T.save(),T.setTransform(c,0,0,c,0,0),D(T,o,C,r,a),T.restore(),w?.())};if(x){let n=!1,r=-1;const a=!0===x?{}:x,s=st(tt(a.trigger)??A??e,a,e=>{const s=ot(e,a),c=Math.max(0,Math.min(t.length-1,Math.round(s*(t.length-1))));c!==r&&(r=c,i(c),n||(n=!0,b?.(o)),a.onUpdate?.(s,o))});return i(0),n=!0,b?.(o),R(s)}let s,d=!1,f=0,m=performance.now(),u=!0;const g=1e3/n,M=e=>{d||(e-m>=g&&(i(f),f=(f+1)%t.length,m=e,u&&(u=!1,b?.(o))),s=requestAnimationFrame(M))};return s=requestAnimationFrame(M),R(()=>{d=!0,cancelAnimationFrame(s)})}const{frames:d,fps:f}=await U(o,C,r,a,h,l,void 0,y);if(!d.length)throw new Error("asciifyVideo: no frames were decoded.");let m=0;const u=performance.now(),p=E(e,(t,e)=>{x||(m=Math.floor((t-u)*f/1e3)%d.length),T.save(),T.setTransform(c,0,0,c,0,0),X(T,d[m],C,r,a,(t-u)/1e3,e),T.restore(),w?.()},{continuous:!x||"none"!==C.animationStyle||!!C.charsetFrames?.length,interactive:C.hoverStrength>0});let v;if(x){const t=!0===x?{}:x;v=st(tt(t.trigger)??A??e,t,e=>{m=Math.max(0,Math.min(d.length-1,Math.round(ot(e,t)*(d.length-1)))),p.wake(),t.onUpdate?.(e,o)})}return b?.(o),R(()=>{p.stop(),v?.()})}let I,L=!1;"string"==typeof t?(I=document.createElement("video"),I.crossOrigin="anonymous",I.src=t,I.muted=!0,I.loop=!0,I.playsInline=!0,I.setAttribute("playsinline",""),Object.assign(I.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(I),L=!0,await new Promise((e,o)=>{I.onloadedmetadata=()=>e(),I.onerror=()=>o(new Error(`asciifyVideo: failed to load "${t}"`))}),await I.play().catch(()=>{})):(I=t,I.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((t,e)=>{const o=()=>{I.removeEventListener("loadedmetadata",n),I.removeEventListener("error",r)},n=()=>{o(),t()},r=()=>{o(),e(new Error("asciifyVideo: provided video element failed to load metadata."))};I.addEventListener("loadedmetadata",n),I.addEventListener("error",r),I.load()}),I.paused&&await I.play().catch(()=>{})),y>0&&(I.currentTime=y,await new Promise(t=>{const e=()=>{I.removeEventListener("seeked",e),t()};I.addEventListener("seeked",e)}),await at(I));let P=null;(y>0||void 0!==S)&&(P=()=>{(void 0!==S&&I.currentTime>=S||y>0&&I.currentTime<y)&&(I.currentTime=y)},I.addEventListener("timeupdate",P)),C=await ft(I,C,y,S,x);let B=null;const z=ct(I.videoWidth,I.videoHeight,C);let{renderW:H,renderH:W}=mt(z.w,z.h,M);const j=t=>"frame"===C.chromaKeyTrimMode?ht(t,C,H/W):C;if(A){const t=z.w/z.h,o=z.w,n=z.h,r=Mt(e,A,t,o,n,M,F);H=r.renderW,W=r.renderH;const a=e.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0),B=new ResizeObserver(()=>{const r=Mt(e,A,t,o,n,M,F);H=r.renderW,W=r.renderH;const a=e.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0)}),B.observe(A)}else{const t="undefined"!=typeof window&&window.devicePixelRatio||1,o=8e6,n=H*t*W*t>o?Math.sqrt(o/(H*W)):t;e.width===Math.round(H*n)&&e.height===Math.round(W*n)||(e.width=Math.round(H*n),e.height=Math.round(W*n)),T.setTransform(n,0,0,n,0,0)}let O=!0,q=null;const _=x&&!u,Y=g&&g>0?1e3/g:0;let G=0;const J=!_&&et(C);if(_&&"ascii"===C.renderMode&&"none"===C.animationStyle&&C.hoverStrength<=0&&!C.charsetFrames?.length){const t=!0===x?{}:x,o=tt(t.trigger)??A??e,n=t.from??y,r=t.to??S??I.duration,a=Math.max(n,Math.min(r,I.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=[],d=Math.max(2,Math.min(c,Math.floor(v))),f=()=>{for(;h.length>d;){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),f()};let u=0,M=0,p=-1,$=0,E=!1,F=!1,k=!1;const z=new Set,O=document.createElement("video");O.muted=!0,O.playsInline=!0,O.preload="auto",O.crossOrigin=I.crossOrigin||"anonymous",O.src=I.currentSrc||I.src,Object.assign(O.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(O),O.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((t,e)=>{const o=()=>{O.removeEventListener("loadedmetadata",n),O.removeEventListener("error",r)},n=()=>{o(),t()},r=()=>{o(),e(new Error("asciifyVideo: cache video failed to load metadata."))};O.addEventListener("loadedmetadata",n),O.addEventListener("error",r),O.load()}),O.pause(),I.paused&&await I.play().catch(()=>{});const N=t=>n+i*t/Math.max(1,c-1),U=t=>Math.max(0,Math.min(c-1,Math.round(t*(c-1)))),K=j(I),_=V(I,K,H,W);_.rows.length>0&&(l[0]=_,m(0),D(T,_,K,H,W),k=!0,b?.(I),w?.());const J=t=>{if(l[t])return t;for(let e=1;e<c;e++){const o=t-e,n=t+e;if(o>=0&&l[o])return o;if(n<c&&l[n])return n}return-1},X=()=>{if(!l[u])return u;for(const t of z)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]||(z.add(t),et())},et=async()=>{if(E||F)return;const t=X();if(!(t<0)){z.delete(t),F=!0;try{if(await rt(O,N(t)),!E){const e=j(O),o=V(O,e,H,W);o.rows.length>0&&(l[t]=o,m(t))}}finally{F=!1,E||requestAnimationFrame(()=>{et()})}}},nt=()=>{if(E)return;const t=J(u);if(t>=0&&t!==p){const e=l[t];e&&(D(T,e,C,H,W),p=t,k||(k=!0,b?.(I)),w?.())}else if(t<0||p<0){const t=performance.now();if(Y<=0||t-G>=Y){const e=j(I),o=V(I,e,H,W);o.rows.length>0&&(D(T,o,e,H,W),G=t,k||(k=!0,b?.(I)),w?.())}}Q(u),$=requestAnimationFrame(nt)};return q=st(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=ot(e,o),s=n+(a-n)*i;return{progress:i,time:Math.min(Math.max(n,s),Math.max(n,a-.04))}}(I,e,{...t,from:n,to:a});M=o?.progress??Z(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,I)}),Q(0),Q(1),$=requestAnimationFrame(nt),R(()=>{E=!0,cancelAnimationFrame($),q?.(),B?.disconnect(),z.clear(),h.length=0,l.fill(void 0),O.pause(),O.src="",O.removeAttribute("src"),O.load(),O.isConnected&&O.remove(),P&&I.removeEventListener("timeupdate",P),L&&(I.pause(),I.src="",I.removeAttribute("src"),I.load(),I.isConnected&&I.remove())})}if(_){const t=!0===x?{}:x;q=it(I,{...t,trigger:t.trigger??A??e,from:t.from??y,to:t.to??S})}let Q=-1,nt=0,lt=-1,dt=0;const ut="function"==typeof I.requestVideoFrameCallback,gt=()=>{dt=I.requestVideoFrameCallback(()=>{nt++,gt()})};ut&&gt();let pt=0,xt=0,vt=null;const bt=E(e,(t,o)=>{if(I.readyState<2||0===e.width||0===e.height)return;if(Y>0&&t-G<Y&&!o)return;if(y>0&&I.currentTime<y)return;if(void 0!==S&&I.currentTime>=S)return;const n=(ut?nt!==lt:I.currentTime!==Q)||pt!==H||xt!==W;if(n||!(C.hoverStrength<=0)||"none"!==C.animationStyle||C.charsetFrames?.length){if(J){const t=j(I),e=V(I,t,H,W);D(T,e,t,H,W)}else!n&&vt||(vt=N(I,j(I),H,W).frame),X(T,vt,C,H,W,t/1e3,o);Q=I.currentTime,lt=nt,pt=H,xt=W,G=t,O&&(O=!1,b?.(I)),w?.()}},{continuous:!0,interactive:C.hoverStrength>0});return R(()=>{bt.stop(),dt&&I.cancelVideoFrameCallback(dt),q?.(),B?.disconnect(),P&&I.removeEventListener("timeupdate",P),L&&(I.pause(),I.src="",I.removeAttribute("src"),I.load(),I.isConnected&&I.remove())})}function xt(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 vt(t){return t*t*t*(t*(6*t-15)+10)}function bt(t,e,o){return t+(e-t)*o}function wt(t,e){let o=127*t+311*e;return o^=o>>13,(o*(o*o*15731+789221)+1376312589&2147483647)/2147483647}function yt(t,e){const o=Math.floor(t),n=Math.floor(e),r=e-n,a=vt(t-o),i=vt(r),s=wt(o,n),c=wt(o+1,n),l=wt(o,n+1),h=wt(o+1,n+1);return bt(bt(s,c,a),bt(l,h,a),i)}function St(t,e){return(.5*yt(t,e)+.25*yt(2.1*t,2.1*e)+.125*yt(4.3*t,4.3*e))/.875}function $t(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:d,accentThreshold:f=.52,mouseInfluence:m=.55,mouseFalloff:u=2.8,speed:g=1,vortex:M=!0,sparkles:p=!0,breathe:x=!0,lightMode:v=!1}=a,b=d??(v?"#6b8700":"#d4ff00"),w=i*s,y=i*c,S=Math.ceil(e/w),$=Math.ceil(o/y),E=r.x,C=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,o),t.font=`${i}px "JetBrains Mono", monospace`,t.textBaseline="top";const k=n*g,R=x?.12*(.5*Math.sin(.22*k)+.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*k,s=.06,c=.45*((.5*Math.sin(.08*o+.05*e+.6*k)+.5+(.5*Math.sin(.03*o-.07*e+.4*k)+.5)+(.5*Math.sin(.05*o+.03*e+.8*k)+.5))/3)+.35*(.5*St(o*a+i,e*a*1.4-.7*i)+.5)+.2*(.5*Math.sin((o+.65*e)*s+1.1*k)+.5)+R,d=n-E,g=r-C,x=Math.sqrt(d*d+g*g);let b=0;if(M&&x<.35){const t=Math.atan2(g,d),e=Math.sin(4*t+2.2*k-14*x),o=Math.max(0,1-x/.35);b=e*o*o*.22}const I=c*(1-m)+(Math.max(0,1-x*u)+.5*b)*m+.15*b,L=Math.min(1,Math.max(0,I));let P=L;if(p&&L>.72){const t=Math.floor(8*k),n=wt(7*o+3*t,11*e+t);n>.88&&(P=Math.min(1,L+4*(n-.88)))}const B=Math.floor(P*(l.length-1));if(" "===l[B])continue;const z=.015+.07*P;if(P>f){const e=Math.min(v?.9:.28,z*(v?14:2.8));t.fillStyle=`rgba(${T},${A},${F},${e})`}else t.fillStyle=h?h.replace("{a}",String(z)):v?`rgba(55,55,55,${7*z})`:`rgba(255,255,255,${z})`;t.fillText(l[B],o*w,e*y)}}function Et(t,e,o,n,r={}){const{fontSize:a=13,chars:i="0123456789ABCDEF@#$&*+=/<>",accentColor:s,color:c,speed:l=1,density:h=.55,tailLength:d=14,lightMode:f=!1}=r,m=s??(f?"#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 x=255,v=255,b=255;if(f&&(x=55,v=55,b=55),c){const t=xt(c);t&&(x=t.r,v=t.g,b=t.b)}let w=212,y=255,S=0;const $=xt(m);$&&(w=$.r,y=$.g,S=$.b);const E=p+d;for(let e=0;e<M;e++){if(wt(17*e,3)>h)continue;const o=(.5+1.5*wt(31*e,7))*l,r=wt(13*e,11)*E,a=Math.floor((n*o*7+r)%E),s=e*u;for(let o=0;o<=d;o++){const r=a-(d-o);if(r<0||r>=p)continue;const c=r*g,l=wt(53*e+Math.floor(5*n+o),7*r),h=i[Math.floor(l*i.length)],m=o/d;if(o===d)t.fillStyle=`rgba(${w},${y},${S},${f?.7:.85})`;else{const e=f?.85*m:.15*m;t.fillStyle=`rgba(${x},${v},${b},${e})`}t.fillText(h,s,c)}}}function Ct(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" . · * + ° ★",accentColor:c,color:l,speed:h=1,count:d=180,lightMode:f=!1}=a,m=c??(f?"#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,x=255,v=255;if(f&&(p=55,x=55,v=55),l){const t=xt(l);t&&(p=t.r,x=t.g,v=t.b)}let b=212,w=255,y=0;const S=xt(m);S&&(b=S.r,w=S.g,y=S.b);const $=s.replace(/ /g,"").split("");if(0!==$.length){for(let r=0;r<d;r++){const a=wt(17*r,3)*Math.PI*2,s=(n*(.15+.85*wt(31*r,7))*h*.22+wt(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 d=Math.max(6,i*(.4+.9*s));t.font=`${d}px monospace`;const m=$[Math.min($.length-1,Math.floor(s*$.length))],S=s>.72,E=f?.85*s:.2*s;t.fillStyle=S?`rgba(${b},${w},${y},${Math.min(f?.92:.32,2.2*E)})`:`rgba(${p},${x},${v},${E})`,t.fillText(m,c,l)}t.textAlign="left"}}function Tt(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=". · ○ ◎ ●",accentColor:c,color:l,rings:h=5,speed:d=1,sharpness:f=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 x=255,v=255,b=255;if(m&&(x=55,v=55,b=55),l){const t=xt(l);t&&(x=t.r,v=t.g,b=t.b)}let w=0,y=255,S=204;const $=xt(u);$&&(w=$.r,y=$.g,S=$.b);const E=s.replace(/ /g,"").split("");if(0===E.length)return;const C=Math.ceil(e/i),T=Math.ceil(o/i);for(let e=0;e<T;e++)for(let o=0;o<C;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*d*.38+t/h)%1,o=Math.abs(l-e),r=Math.max(0,1-o*p/(i*(12-f)));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 C=Math.floor(u*(E.length-1)),T=E[Math.min(C,E.length-1)],A=m?.88*u:.22*u;t.fillStyle=$?`rgba(${w},${y},${S},${Math.min(m?.95:.4,.55*u)})`:`rgba(${x},${v},${b},${A})`,t.fillText(T,r,a)}t.textAlign="left"}function At(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" .·:;=+*#%@░▒▓",accentColor:c,color:l,octaves:h=4,speed:d=1,scale:f=1,accentThreshold:m=.78,mouseWarp:u=.3,lightMode:g=!1}=a,M=c??(g?"#6b8700":"#d4ff00"),p=.62*i,x=1.4*i,v=Math.ceil(e/p),b=Math.ceil(o/x);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=xt(l);t&&(w=t.r,y=t.g,S=t.b)}let $=212,E=255,C=0;const T=xt(M);T&&($=T.r,E=T.g,C=T.b);const A=.035*f,F=n*d,k=Math.min(6,Math.max(1,h)),R=(t,e)=>{let o=0,n=.5,r=1,a=0;for(let i=0;i<k;i++)o+=yt(t*r,e*r)*n,a+=n,n*=.5,r*=2.1;return o/a};for(let e=0;e<b;e++)for(let o=0;o<v;o++){const n=o*A+.06*F,a=e*A*1.3-.04*F,i=o/v-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,d=.5*R(n+h*Math.sin(1.3*F+8*c),a+h*Math.cos(.9*F+8*i))+.5;if(d<.12)continue;const f=s[Math.floor(d*(s.length-1))];if(" "===f)continue;const M=d>m,T=g?.82*d:.13*d;t.fillStyle=M?`rgba(${$},${E},${C},${g?.92:.28})`:`rgba(${w},${y},${S},${T})`,t.fillText(f,o*p,e*x)}}function Ft(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=12,chars:s="·-=+|/",accentColor:c,color:l,bands:h=3,speed:d=1,bandWidth:f=.12,glitch:m=!0,lightMode:u=!1}=a,g=c??(u?"#6b8700":"#d4ff00"),M=.62*i,p=1.4*i,x=Math.ceil(e/M),v=Math.ceil(o/p);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let b=255,w=255,y=255;if(u&&(b=55,w=55,y=55),l){const t=xt(l);t&&(b=t.r,w=t.g,y=t.b)}let S=212,$=255,E=0;const C=xt(g);C&&(S=C.r,$=C.g,E=C.b);const T=n*d;for(let e=0;e<v;e++)for(let o=0;o<x;o++){const n=e/v,a=((n*h-.5*T)%1+1)%1,i=Math.max(0,1-a/f),c=.35*(.5*wt(3*o,7*e)+.5);let l=0;if(m){const t=o/x-r.x,a=n-r.y,i=Math.sqrt(t*t+a*a);if(i<.18){const t=wt(11*o+Math.floor(12*T),5*e);l=Math.max(0,1-i/.18)*(t>.5?t-.3:0)}}const d=Math.min(1,c+.8*i+.6*l);if(d<.04)continue;const g=s[Math.floor(d*(s.length-1))],C=i>.55,A=u?.82*d:.12*d;t.fillStyle=C?`rgba(${S},${$},${E},${u?.92:.28})`:`rgba(${b},${w},${y},${A})`,t.fillText(g,o*M,e*p)}}function kt(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=14,chars:s=" ·∙•:;+=≡≣#@",color:c,accentColor:l,speed:h=1,layers:d=5,softness:f=1.2,mouseRipple:m=.2,lightMode:u=!1}=a,g=l??(u?"#6b8700":"#d4ff00"),M=.62*i,p=1.4*i,x=Math.ceil(e/M),v=Math.ceil(o/p);t.clearRect(0,0,e,o),t.font=`${i}px monospace`,t.textBaseline="top";let b=255,w=255,y=255;if(u&&(b=55,w=55,y=55),c){const t=xt(c);t&&(b=t.r,w=t.g,y=t.b)}let S=212,$=255,E=0;const C=xt(g);C&&(S=C.r,$=C.g,E=C.b);const T=n*h,A=[];for(let t=0;t<d;t++){const e=wt(17*t,31*t+7),o=wt(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*wt(7*t,13*t+3))*(t%2==0?1:-1),amp:.55+.45*wt(29*t,3*t)})}for(let e=0;e<v;e++){const o=e/v;for(let n=0;n<x;n++){const a=n/x,i=a-r.x,c=o-r.y,l=Math.sqrt(i*i+c*c),h=m*Math.exp(-l*l/.06),g=a+i*h,v=o+c*h;let C=0,F=0;for(let t=0;t<d;t++){const{fx:e,fy:o,phase:n,dt:r,amp:a}=A[t];C+=Math.sin(g*e*Math.PI*2+T*r+n)*Math.cos(v*o*Math.PI*2+T*r*.7+1.3*n)*a,F+=a}const k=C/F,R=.5+.5*Math.tanh(k*f*2.2);if(R<.12)continue;const I=(R-.12)/.88,L=s[Math.min(s.length-1,Math.floor(I*s.length))],P=R>.82,B=u?.82*R:.14*R;t.fillStyle=P?`rgba(${S},${$},${E},${u?.92:.32})`:`rgba(${b},${w},${y},${B})`,t.fillText(L,n*M,e*p)}}}function Rt(t,e,o,n,r={}){const{fontSize:a=13,color:i,accentColor:s,speed:c=.4,layers:l=4,turbulence:h=.8,lightMode:d=!1}=r,f=s??(d?"#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,x=255,v=255;if(d&&(p=55,x=55,v=55),i){const t=xt(i);t&&(p=t.r,x=t.g,v=t.b)}let b=212,w=255,y=0;const S=xt(f);S&&(b=S.r,w=S.g,y=S.b);const $=n*c,E=["─","─","╌","·","╌","─","─","╌","·"];for(let e=0;e<M;e++){const o=e/M;for(let n=0;n<g;n++){const r=n/g;let a=0,i=0;for(let t=0;t<l;t++){const e=wt(13*t,7*t+3),n=1.1+2.4*e,s=.9+2*wt(29*t,11*t+1),c=e*Math.PI*6,l=(.2+.5*wt(41*t,17*t))*(t%2==0?1:-1.3),d=Math.sin(r*n*Math.PI*2+$*l+c),f=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(f+.3*m,d),i+=.5*(d*f+1)}const s=a/l,c=Math.min(1,i/l);if(c<.1)continue;const f=(s+Math.PI)/(2*Math.PI),M=E[Math.floor(f*E.length)%E.length],S=c>.8,C=d?.8*c:.13*c;t.fillStyle=S?`rgba(${b},${w},${y},${d?.9:.26})`:`rgba(${p},${x},${v},${C})`,t.fillText(M,n*m,e*u)}}}function It(t,e,o,n,r={x:.5,y:.5},a={}){const{fontSize:i=13,chars:s=" ·:;=+*#%@",color:c,accentColor:l,speed:h=1,radius:d=.38,swirl:f=3,lightMode:m=!1}=a,u=l??(m?"#6b8700":"#d4ff00"),g=.62*i,M=1.4*i,p=Math.ceil(e/g),x=Math.ceil(o/M),v=e/o;t.clearRect(0,0,e,o),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=xt(c);t&&(b=t.r,w=t.g,y=t.b)}let S=212,$=255,E=0;const C=xt(u);C&&(S=C.r,$=C.g,E=C.b);const T=n*h;for(let e=0;e<x;e++){const o=e/x;for(let n=0;n<p;n++){const a=(n/p-r.x)*v,i=o-r.y,c=Math.sqrt(a*a+i*i)/d;if(c>1){const o=wt(3*n,7*e)*Math.max(0,1-3*(c-1));if(o<.62)continue;const r=o*(m?.28:.04);t.fillStyle=`rgba(${b},${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),f=Math.min(1,h+.6*l);if(f<.06)continue;const u=Math.floor(f*(s.length-1)),x=s[Math.min(s.length-1,u)],C=l>.35||c<.08,A=m?.85*f:.18*f;t.fillStyle=C?`rgba(${S},${$},${E},${m?.95:.38})`:`rgba(${b},${w},${y},${A})`,t.fillText(x,n*g,e*M)}}}function Lt(t,e,o,n,r={}){const{fontSize:a=14,chars:i=" ·∙•:-=+*#",color:s,accentColor:c,speed:l=.5,harmonics:h=3,lightMode:d=!1}=r,f=c??(d?"#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,x=255,v=255;if(d&&(p=55,x=55,v=55),s){const t=xt(s);t&&(p=t.r,x=t.g,v=t.b)}let b=212,w=255,y=0;const S=xt(f);S&&(b=S.r,w=S.g,y=S.b);const $=n*l,E=Array.from({length:h},(t,e)=>1/(e+1)).reduce((t,e)=>t+e,0);for(let e=0;e<M;e++)for(let o=0;o<g;o++){let n=0;for(let t=0;t<h;t++){const r=.18+1.4*wt(o*(t+3)+7,e*(t+5)+11),a=wt(o*(t+7),e*(t+9)+3)*Math.PI*2,i=1/(t+1);n+=Math.sin($*r+a)*i}const r=.5*(n/E+1);if(r<.28)continue;const a=(r-.28)/.72,s=i[Math.min(i.length-1,Math.floor(a*i.length))],c=r>.88,l=d?.82*a:.13*a;t.fillStyle=c?`rgba(${b},${w},${y},${d?.92:.28})`:`rgba(${p},${x},${v},${l})`,t.fillText(s,o*m,e*u)}}function Pt(t,e,o,n,r={}){const{fontSize:a=13,chars:i=" .,:;i+xX#&@",color:s="#ff4500",hotColor:c="#ffe066",intensity:l=.85,wind:h=0,speed:d=1,lightMode:f=!1}=r,m=.62*a,u=1.4*a,g=Math.ceil(e/m),M=Math.ceil(o/u),p=g*M,x="__fire_heat__",v=t.canvas;let b=v[x];b&&b.length===p||(b=new Float32Array(p),v[x]=b);const w=.18*(.016*d),y=h*d*.8,S=M-1,$=n*d;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 E=new Float32Array(p);for(let t=0;t<M-2;t++)for(let e=0;e<g;e++){const o=.4*b[(t+1)*g+e]+.25*b[(t+2)*g+Math.max(0,Math.min(g-1,e+Math.round(y)))]+.175*b[(t+1)*g+Math.max(0,e-1)]+.175*b[(t+1)*g+Math.min(g-1,e+1)];E[t*g+e]=Math.max(0,o-w-.02*Math.random()*d)}for(let t=0;t<g;t++)E[(M-1)*g+t]=b[(M-1)*g+t],M>1&&(E[(M-2)*g+t]=b[(M-2)*g+t]);v[x]=E;const C=xt(s)??{r:255,g:69,b:0},T=xt(c)??{r:255,g:224,b:102};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";for(let e=0;e<M;e++)for(let o=0;o<g;o++){const n=E[e*g+o];if(n<.03)continue;const r=i[Math.min(i.length-1,Math.floor(n*i.length))];if(" "===r)continue;const a=Math.min(1,1.2*n),s=C.r+(T.r-C.r)*a|0,c=C.g+(T.g-C.g)*a|0,l=C.b+(T.b-C.b)*a|0,h=f?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 Bt(t,e,o,n,r={}){const{fontSize:a=13,baseChars:i="ATCG",bridgeChars:s="-=≡",color:c="#00e5ff",color2:l="#ff4081",bridgeColor:h="#88ffcc",speed:d=1,helixCount:f,lightMode:m=!1}=r,u=.62*a,g=1.4*a,M=Math.ceil(e/u),p=Math.ceil(o/g),x=f??Math.max(1,Math.floor(e/80)),v=M/x,b=xt(c)??{r:0,g:229,b:255},w=xt(l)??{r:255,g:64,b:129},y=xt(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*d,$=.35*v;for(let e=0;e<x;e++){const o=v*(e+.5);for(let n=0;n<p;n++){const r=n/p*Math.PI*6-1.8*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 d=wt(31*e+7*n,3),f=i[Math.floor(d*i.length)],m=.5*(Math.sin(r)+1),x=.5*(Math.sin(r+Math.PI)+1);if(t.globalAlpha=.35+.65*m,t.fillStyle=`rgb(${b.r},${b.g},${b.b})`,t.fillText(f,l*u,n*g),h>=0&&h<M){const o=wt(53*e+11*n,7),r=i[Math.floor(o*i.length)];t.globalAlpha=.35+.65*x,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=wt(17*n+43*e,5),i=s[Math.floor(a*s.length)],c=.25*(m+x)+.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 zt(t,e,o,n,r={}){const{fontSize:a=13,chars:i=" .,:;+*#@",color:s="#4caf50",skyColor:c="#1a237e",peakColor:l="#e0e0e0",speed:h=1,roughness:d=.55,heightScale:f=.55,stars:m=!0,lightMode:u=!1}=r,g=.62*a,M=1.4*a,p=Math.ceil(e/g),x=Math.ceil(o/M),v=xt(s)??{r:76,g:175,b:80},b=xt(c)??{r:26,g:35,b:126},w=xt(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*St((t/p+y)*d*3,.5)+.5)*f;S[t]=Math.floor(e*x)}for(let e=0;e<x;e++)for(let o=0;o<p;o++){const r=x-1-S[o],a=e===r;if(!(e>=r)){if(m){const r=wt(7*o+Math.floor(.3*y),13*e);if(r>.97){const a=.3*Math.sin(2*n+100*r)+.7;t.globalAlpha=.5*a,t.fillStyle=`rgb(${b.r+60},${b.g+60},${b.b+80})`,t.fillText("·",o*g,e*M)}}continue}const s=(e-r)/Math.max(1,S[o]),c=i[Math.min(i.length-1,Math.floor(s*i.length))];if(" "===c&&!a)continue;const l=a?1:Math.max(0,1-4*s),h=v.r+(w.r-v.r)*l|0,d=v.g+(w.g-v.g)*l|0,f=v.b+(w.b-v.b)*l|0;t.globalAlpha=.5+.5*s,t.fillStyle=`rgb(${h},${d},${f})`,t.fillText(a?i[i.length-1]:c,o*g,e*M)}t.globalAlpha=1}var Ht=1,Wt=2,jt=4,Ot=8,qt={3:"─",12:"│",9:"┌",10:"┐",5:"└",6:"┘",11:"┬",7:"┴",13:"├",14:"┤",15:"┼",[Ht]:"╶",[Wt]:"╴",[jt]:"╵",[Ot]:"╷"};function Nt(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,d=.62*a,f=1.4*a,m=Math.ceil(e/d),u=Math.ceil(o/f),g=xt(s)??{r:0,g:255,b:136},M=xt(i)??{r:255,g:255,b:255},p=(t,e)=>{if(wt(17*t+1,7*e+2)>c)return 0;let o=0;return t+1<m&&wt(17*t+1,7*e+2)>.15&&(o|=1),t-1>=0&&wt(17*(t-1)+1,7*e+2)>.15&&(o|=2),e+1<u&&wt(17*t+1,7*(e+1)+2)>.15&&(o|=8),e-1>=0&&wt(17*t+1,7*(e-1)+2)>.15&&(o|=4),o};t.clearRect(0,0,e,o),t.font=`${a}px "JetBrains Mono", monospace`,t.textBaseline="top";const x=n*l;for(let e=0;e<u;e++)for(let o=0;o<m;o++){const n=p(o,e);if(0===n)continue;const r=qt[n]??"·",a=(8*x+40*wt(o,23*e))%m,i=(6*x+40*wt(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*wt(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*d,e*f)}t.globalAlpha=1}function Vt(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 d=document.createElement("canvas");d.style.cssText=["position:absolute","inset:0","width:100%","height:100%",`opacity:${n}`,"pointer-events:none",`z-index:${a}`].join(";"),r&&(d.className=r),l.prepend(d);const f=d.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,x=()=>({...c,lightMode:void 0!==c.lightMode?c.lightMode:M(),baseColor:p?`rgba(${p.r},${p.g},${p.b},{a})`:c.baseColor}),v={current:x()},b=()=>{v.current="rain"===o||"stars"===o||"pulse"===o||"noise"===o||"grid"===o||"aurora"===o||"silk"===o||"void"===o||"morph"===o?{...c,lightMode:void 0!==c.lightMode?c.lightMode:M(),color:s??c.color}:"fire"===o||"dna"===o?{...c,color:s??c.color}:"terrain"===o||"circuit"===o?{...c,color:s??c.color,lightMode:void 0!==c.lightMode?c.lightMode:M()}:x()};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();d.width=t.width*m,d.height=t.height*m,f.setTransform(m,0,0,m,0,0)};$();const E=t=>{const e=l.getBoundingClientRect();u.x=(t.clientX-e.left)/e.width,u.y=(t.clientY-e.top)/e.height},C=new ResizeObserver($);C.observe(l),window.addEventListener("mousemove",E);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?Et(f,t.width,t.height,T,v.current):"stars"===o?Ct(f,t.width,t.height,T,g,v.current):"pulse"===o?Tt(f,t.width,t.height,T,g,v.current):"noise"===o?At(f,t.width,t.height,T,g,v.current):"grid"===o?Ft(f,t.width,t.height,T,g,v.current):"aurora"===o?kt(f,t.width,t.height,T,g,v.current):"silk"===o?Rt(f,t.width,t.height,T,v.current):"void"===o?It(f,t.width,t.height,T,g,v.current):"morph"===o?Lt(f,t.width,t.height,T,v.current):"fire"===o?Pt(f,t.width,t.height,T,v.current):"dna"===o?Bt(f,t.width,t.height,T,v.current):"terrain"===o?zt(f,t.width,t.height,T,v.current):"circuit"===o?Nt(f,t.width,t.height,T,v.current):$t(f,t.width,t.height,T,g,v.current),T+=.016,A=requestAnimationFrame(F)};return A=requestAnimationFrame(F),{destroy:()=>{cancelAnimationFrame(A),C.disconnect(),"auto"===i&&(w.removeEventListener("change",y),S?.disconnect()),window.removeEventListener("mousemove",E),d.remove(),l.style.position=h}}}var Dt=Vt;function Ut(t,e,o,n="#505050",r=100){if(!t||e<=0||o<=0)return[];const a=xt(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 Kt=new WeakMap;function _t(t,{format:e="png",quality:o=.92,scale:n=1}={}){return new Promise((r,a)=>{let i=t;if(1!==n){const e=document.createElement("canvas");e.width=Math.round(t.width*n),e.height=Math.round(t.height*n);const o=e.getContext("2d");if(!o)return void a(new Error("captureSnapshot: could not get 2d context"));o.drawImage(t,0,0,e.width,e.height),i=e}i.toBlob(t=>t?r(t):a(new Error("captureSnapshot: toBlob returned null")),`image/${e}`,o)})}var Yt={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]},Gt=[127,65,65,65,65,65,127];function Jt(t){return Yt[t]??Yt[t.toUpperCase()]??Gt}function Xt(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=Jt(t[e]);for(let t=0;t<7;t++){const e=o[t];let n="";for(let t=6;t>=0;t--)n+=(e>>t&1?r:" ").repeat(a);for(let e=0;e<a;e++)c[t*a+e]+=n}if(e<t.length-1)for(let t=0;t<i;t++)c[t]+=" ".repeat(s)}return c.join("\n")}exports.ART_STYLE_PRESETS=o,exports.BACKGROUND_TYPES=["wave","rain","stars","pulse","noise","grid","aurora","silk","void","morph","fire","dna","terrain","circuit"],exports.CHARSETS=t,exports.CHARSET_SEQUENCES=e,exports.DEFAULT_OPTIONS=r,exports.HOVER_PRESETS={none:{label:"Off",options:{hoverStrength:0,hoverEffect:"spotlight",hoverRadius:.2,hoverColor:"#ffffff"}},subtle:{label:"Subtle",options:{hoverStrength:.25,hoverEffect:"glow",hoverRadius:.12,hoverColor:"#ffffff"}},flashlight:{label:"Flashlight",options:{hoverStrength:.6,hoverEffect:"spotlight",hoverRadius:.15,hoverColor:"#fffbe6"}},magnifier:{label:"Magnifier",options:{hoverStrength:.7,hoverEffect:"magnify",hoverRadius:.12,hoverColor:"#ffffff"}},forceField:{label:"Force Field",options:{hoverStrength:.7,hoverEffect:"repel",hoverRadius:.15,hoverColor:"#a0e8ff"}},neon:{label:"Neon",options:{hoverStrength:.6,hoverEffect:"colorShift",hoverRadius:.15,hoverColor:"#d946ef"}},fire:{label:"Fire",options:{hoverStrength:.7,hoverEffect:"spotlight",hoverRadius:.15,hoverColor:"#ff6b2b"}},ice:{label:"Ice",options:{hoverStrength:.5,hoverEffect:"glow",hoverRadius:.15,hoverColor:"#60d5f7"}},gravity:{label:"Gravity",options:{hoverStrength:.7,hoverEffect:"attract",hoverRadius:.18,hoverColor:"#a5d6ff"}},shatter:{label:"Shatter",options:{hoverStrength:.8,hoverEffect:"shatter",hoverRadius:.14,hoverColor:"#ff6090"}},ghost:{label:"Fluid trail",options:{hoverStrength:.55,hoverEffect:"trail",hoverRadius:.2,hoverColor:"#b39ddb"}},glitchReveal:{label:"Glitch Reveal",options:{hoverStrength:.8,hoverEffect:"glitchText",hoverRadius:.18,hoverColor:"#a3e635"}}},exports.LIVING_STYLE_PRESETS=n,exports.PALETTE_THEMES={dracula:{name:"Dracula",accent:"#bd93f9",bg:"#282a36",fg:"#f8f8f2"},monokai:{name:"Monokai",accent:"#a6e22e",bg:"#272822",fg:"#f8f8f2"},nord:{name:"Nord",accent:"#88c0d0",bg:"#2e3440",fg:"#eceff4"},catppuccin:{name:"Catppuccin",accent:"#cba6f7",bg:"#1e1e2e",fg:"#cdd6f4"},solarized:{name:"Solarized",accent:"#268bd2",bg:"#002b36",fg:"#839496"},gruvbox:{name:"Gruvbox",accent:"#b8bb26",bg:"#282828",fg:"#ebdbb2"}},exports.asciiBackground=Vt,exports.asciiText=function(t,e={},o,n){const a={...r,...e},{frame:i,cols:s}=N(t,a,o,n);if(!i.length||0===s)return"";const c=[];for(const t of i)c.push(t.map(t=>t.char).join(""));return c.join("\n")},exports.asciiTextAnsi=function(t,e={},o,n){const a={...r,...e},{frame:i,cols:s}=N(t,a,o,n);if(!i.length||0===s)return"";const c=[];for(const t of i){let e="";for(const o of t)" "===o.char||o.a<10?e+=" ":e+=`[38;2;${o.r};${o.g};${o.b}m${o.char}`;c.push(e)}return c.join("\n")},exports.asciify=async function(t,e,{fontSize:n,artStyle:a="classic",options:i={}}={}){let s;if("string"==typeof t){const e=new Image;e.crossOrigin="anonymous",await new Promise((o,n)=>{e.onload=()=>o(),e.onerror=()=>n(new Error(`Failed to load image: ${t}`)),e.src=t}),s=e}else t instanceof HTMLImageElement&&!t.complete?(await new Promise((e,o)=>{t.onload=()=>e(),t.onerror=()=>o(new Error("Image failed to load"))}),s=t):s=t;const c=o[a],l=n??i.fontSize??10,h={...r,...c,artStyle:a,...i,fontSize:l},d=e.getContext("2d");if(!d)throw new Error("Could not get 2d context from canvas");const{w:f,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}=mt(f,m),M="undefined"!=typeof window&&window.devicePixelRatio||1,p=8e6,x=u*M*g*M>p?Math.sqrt(p/(u*g)):M;e.width===Math.round(u*x)&&e.height===Math.round(g*x)||(e.width=Math.round(u*x),e.height=Math.round(g*x));const{frame:v}=N(s,h,u,g),b=(t,e)=>{d.save(),d.setTransform(x,0,0,x,0,0),X(d,v,h,u,g,t/1e3,e),d.restore()};return b(0,null),E(e,b,{continuous:"none"!==h.animationStyle||!!h.charsetFrames?.length,interactive:h.hoverStrength>0}).stop},exports.asciifyGif=async function(t,e,{fontSize:n,artStyle:a="classic",options:i={}}={}){const s="string"==typeof t?await fetch(t).then(t=>t.arrayBuffer()):t,c=n??i.fontSize??10;let l={...r,...o[a],artStyle:a,...i,fontSize:c};const h=e.getContext("2d");if(!h)throw new Error("Could not get 2d context from canvas");const{frames:d,fps:f}=await _(s,l,e.width,e.height);if(!d.length)throw new Error("asciifyGif: the GIF contains no renderable frames.");const m=performance.now();let u=-1;return E(e,(t,o)=>{const n=Math.floor((t-m)*f/1e3)%d.length;n===u&&!o&&l.hoverStrength<=0&&"none"===l.animationStyle&&!l.charsetFrames?.length||(X(h,d[n],l,e.width,e.height,(t-m)/1e3,o),u=n)},{continuous:!0,interactive:l.hoverStrength>0}).stop},exports.asciifyLiveVideo=function(t,e,o){return pt(t,e,o)},exports.asciifyText=Xt,exports.asciifyVideo=pt,exports.asciifyWebcam=async function(t,{fontSize:e=10,style:n="classic",options:a={},liveOptions:i,mirror:s=!0,constraints:c={facingMode:"user"},dpr:l}={}){if(!navigator.mediaDevices?.getUserMedia)throw new Error("asciifyWebcam: getUserMedia is not supported in this browser.");const h=await navigator.mediaDevices.getUserMedia({video:c}),d=document.createElement("video");d.srcObject=h,d.muted=!0,d.playsInline=!0,await new Promise((t,e)=>{d.onloadedmetadata=()=>t(),d.onerror=()=>e(new Error("asciifyWebcam: video stream failed to load.")),d.play().catch(e)});const f={...r,...o[n],...a,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};f.hoverStrength>0&&(t.addEventListener("mousemove",M),t.addEventListener("mouseleave",p));let x,v=!1;const b=performance.now(),w=e=>{if(!v){if(d.readyState>=d.HAVE_CURRENT_DATA){const o=t.width/u,n=t.height/u,r=(e-b)/1e3,a=i?{...f,...i()}:f;a.hoverStrength>0?(t.addEventListener("mousemove",M),t.addEventListener("mouseleave",p)):(t.removeEventListener("mousemove",M),t.removeEventListener("mouseleave",p));const{frame:c}=N(d,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),X(m,c,a,o,n,r,l),m.restore()):X(m,c,a,o,n,r,l)}x=requestAnimationFrame(w)}};return x=requestAnimationFrame(w),()=>{v=!0,cancelAnimationFrame(x),t.removeEventListener("mousemove",M),t.removeEventListener("mouseleave",p),h.getTracks().forEach(t=>t.stop()),d.srcObject=null}},exports.buildTextFrame=Ut,exports.captureSnapshot=_t,exports.clearAsciifyCaches=function(){F.clear(),k.clear(),Y=new WeakMap,J=new WeakMap,G=new WeakMap,C=null,T=null},exports.computeCanvasRenderSize=ut,exports.createVideoScrollScrub=it,exports.gifToAsciiFrames=_,exports.gifToAsciiTextFrames=async function(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,d=s.lsd?.width||l,f=s.lsd?.height||h,m=document.createElement("canvas");m.width=d,m.height=f;const u=m.getContext("2d"),g=document.createElement("canvas");g.width=d,g.height=f;const M=g.getContext("2d"),p=document.createElement("canvas"),x=p.getContext("2d"),v=[];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))),E=Math.min(c.length,300);for(let t=0;t<E;t++){const a=c[t],{dims:i,patch:s,disposalType:l}=a;3===l&&(M.clearRect(0,0,d,f),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);x.putImageData(h,0,0),u.drawImage(p,i.left||0,i.top||0);const y=V(m,e,o,n);v.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,d,f),u.drawImage(g,0,0)),r?.((t+1)/E)}return{frames:v,cols:b,rows:w,fps:$}},exports.imageToAsciiFrame=N,exports.imageToAsciiTextFrame=V,exports.mountWaveBackground=Dt,exports.renderAuroraBackground=kt,exports.renderCircuitBackground=Nt,exports.renderDnaBackground=Bt,exports.renderFireBackground=Pt,exports.renderFrameToCanvas=X,exports.renderGridBackground=Ft,exports.renderMorphBackground=Lt,exports.renderNoiseBackground=At,exports.renderPulseBackground=Tt,exports.renderRainBackground=Et,exports.renderSilkBackground=Rt,exports.renderStarsBackground=Ct,exports.renderTerrainBackground=zt,exports.renderTextBackground=function(t,e,o,n,a={},i){const{fontSize:s=10,lineHeight:c=1.6,color:l="#505050",opacity:h=100,hoverEffect:d="spotlight",hoverStrength:f=.85,hoverRadius:m=.18,hoverColor:u="#d4ff00"}=a,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 x=Kt.get(t);x&&x.key===p||(x={key:p,frame:Ut(n,g,M,l,h)},Kt.set(t,x)),X(t,x.frame,{...r,fontSize:s,hoverEffect:d,hoverStrength:f,hoverRadius:m,hoverColor:u},e,o,0,i??null)},exports.renderTextFrameToCanvas=D,exports.renderTextToCanvas=function(t,e,o={}){const{color:n="#d4ff00",bgColor:r,fontSize:a=10}=o,i=Xt(e,o);if(!i)return;const s=i.split("\n"),c=Math.max(...s.map(t=>[...t].length));t.width=Math.ceil(c*a*.6),t.height=Math.ceil(s.length*a);const l=t.getContext("2d");r&&"transparent"!==r?(l.fillStyle=r,l.fillRect(0,0,t.width,t.height)):l.clearRect(0,0,t.width,t.height),l.fillStyle=n,l.font=`${a}px monospace`,l.textBaseline="top",s.forEach((t,e)=>l.fillText(t,0,e*a))},exports.renderVoidBackground=It,exports.renderWaveBackground=$t,exports.snapshotAndDownload=async function(t,e={}){const{filename:o="asciify-snapshot",format:n="png",...r}=e,a=await _t(t,{format:n,...r}),i="jpeg"===n?"jpg":n,s=document.createElement("a");s.href=URL.createObjectURL(a),s.download=`${o}.${i}`,s.click(),setTimeout(()=>URL.revokeObjectURL(s.href),1e4)},exports.videoToAsciiFrames=U,exports.videoToAsciiTextFrames=K;//# sourceMappingURL=index.cjs.map
1
+ "use strict";var t={standard:{label:"Classic ASCII",chars:" .:-=+*#%@"},asciify:{label:"Asciify",chars:" .:-=+ASCIIFY#@"},minimal:{label:"Minimal",chars:" .:+"},detailed:{label:"Detailed",chars:" .,:;i1tfLCG08@"},letters:{label:"Letters",chars:" .ilLCFTYASMW"},technical:{label:"Technical",chars:" .:;>_/[{}]=+*#@$"},blocks:{label:"Tonal blocks",chars:" ░▒▓█"},braille:{label:"Braille",chars:" ⠁⠃⠇⡇⣇⣧⣷⣿"}},e={fontSize:7,charSpacing:1,brightness:0,contrast:0,charset:t.standard.chars,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",fineDither:!1,customText:"",chromaKey:null,chromaKeyTolerance:60,chromaKeyTrimPadding:.002,chromaKeyTrimLuminanceThreshold:0,chromaKeyTrimMode:"range"},n=[{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 o=(t,e,n)=>{const o=(t=>Math.max(0,Math.min(1,t)))((n-t)/(e-t));return o*o*(3-2*o)};function r(t,e,n,r,i){if(i[0]=i[1]=i[2]=0,i[3]=1,"none"===t)return i;const a=r*Math.PI/6,s=o(0,.12,Math.min(e,1-e,n,1-n));if("caustics"===t){const t=Math.sin(9*e+5*n+a)+Math.sin(8*n-3*e-a),o=Math.pow(Math.max(0,1-.72*Math.abs(t)),3);i[2]=(.22*o-.045)*s}else if("current"===t)i[0]=Math.sin(9*n+a)*Math.cos(7*e-a)*10*s,i[1]=Math.cos(8*e+a)*Math.sin(6*n-a)*7*s;else if("reform"===t){const t=(r%12+12)%12,c=((t,e)=>{const n=(.06711056*t+.00583715*e)%1*52.9829189;return n-Math.floor(n)})(Math.floor(160*e),Math.floor(100*n)),l=.65*e+.2*n+.15*c+.08*Math.sin(8*e-5*n),h=o(1.8+1.2*l,3.8+1.2*l,t)*(1-o(5+1.7*l,7.2+1.7*l,t));i[0]=Math.sin(9*n+a)*h*(1-h)*24*s,i[1]=-h*(1-h)*(8+12*c)*s,i[2]=.45*-h,i[3]=1-.9*h}return i}function i(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 a(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 s(t,e,n,o,r,i){if((i?1-t/255:t/255)<.12)return" ";const a=[...e];return a[(o*r+n)%a.length]}var c=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];function l(t,e,n,o){if(o<=0)return t;const r=(c[n%4][e%4]/16-.5)*o*128;return Math.max(0,Math.min(255,t+r))}var h=new Array(256),d=new Array(256);for(let t=0;t<256;t++)h[t]=`rgb(${t},${t},${t})`,d[t]=`rgb(0,${t},0)`;function f(t,e,n,o,r,i=!1){switch(e){case"fullcolor":return`rgb(${t.r},${t.g},${t.b})`;case"matrix":return d[.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 h[e]}}}var m=[0,0,0];function u(t,e,n,o,r,i=!1){switch(e){case"fullcolor":m[0]=t.r,m[1]=t.g,m[2]=t.b;break;case"matrix":{const e=.299*t.r+.587*t.g+.114*t.b|0;m[0]=0,m[1]=e,m[2]=0;break}case"accent":m[0]=n,m[1]=o,m[2]=r;break;default:{const e=.299*t.r+.587*t.g+.114*t.b|0;m[0]=e,m[1]=e,m[2]=e;break}}return m}function g(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 p(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=g(t);if(e&&e.a>.1)return e}e=e.parentElement}return null}function M(t){if(t){const e=p(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=p(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 v(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)}var x={scale:1,offsetX:0,offsetY:0,glow:0,colorBlend:0,proximity:0};function y(t,e,n,o,r,i,a,s,c="spotlight",l=.5,h="circle",d=[],f=1){const m=(t-n)*Math.max(1,f),u=(e-o)*Math.max(1,1/f),g=.08+.35*l+.04*i;let p,M;if("box"===h){const t=Math.abs(m),e=Math.abs(u);p=Math.max(t,e),M=g}else p=Math.sqrt(m*m+u*u),M=g;if(p>=M&&("trail"!==c||0===d.length))return x.scale=1,x.offsetX=0,x.offsetY=0,x.glow=0,x.colorBlend=0,x.proximity=0,x;const v=w(Math.max(0,1-p/M))*r;let y=1,b=0,S=0,E=0,T=0;switch(c){case"spotlight":{y=1+v*i*1.8;const t=Math.atan2(u,m),e=v*v*i*.6;b=Math.cos(t)*e*a,S=Math.sin(t)*e*s,E=v*i*.4,T=v*v*i*.25;break}case"magnify":y=1+v*i*.85,E=v*i*.15;break;case"repel":{y=1;const t=Math.atan2(u,m),e=v*v*i*1.8;b=Math.cos(t)*e*a,S=Math.sin(t)*e*s;break}case"glow":E=v*i*.8,T=v*i*.4;break;case"colorShift":y=1,E=v*i*.12,T=v*i;break;case"attract":{const t=Math.atan2(u,m),e=v*v*i*1;b=(.45*-Math.cos(t)-1.6*Math.sin(t))*e*a,S=(.45*-Math.sin(t)+1.6*Math.cos(t))*e*s,E=v*i*.3;break}case"shatter":{const t=Math.atan2(u,m),e=.5*Math.sin(43.7*m+29.3*u),n=v*i*1.4*(.7+.3*e);b=Math.cos(t+e)*n*a,S=Math.sin(t+e)*n*s,y=Math.max(.1,1-v*i*.6),E=v*i*.25;break}case"trail":{let n=v,o=-u*v,r=m*v;for(const i of d){const a=(t-i.x)*Math.max(1,f),s=(e-i.y)*Math.max(1,1/f),c=Math.hypot(a,s)/g;if(c>=1)continue;const l=w(1-c)*i.intensity;n=Math.max(n,l),o+=(.35*i.vx-2*s)*l*.35,r+=(.35*i.vy+2*a)*l*.35}b=Math.tanh(2*o)*i*a*3,S=Math.tanh(2*r)*i*s*3,T=n*i*.65,E=n*i*.35,y=1+n*i*.08,x.proximity=n;break}case"glitchText":y=1,E=v*i*.5,T=v*i*.6}return x.scale=y,x.offsetX=b,x.offsetY=S,x.glow=E,x.colorBlend=T,"trail"!==c&&(x.proximity=v),x}function b(t,e,{continuous:n=!1,interactive:o=!1}={}){const r=t.parentElement??t;let i=null,a=0,s=!1,c=!0,l=!0,h=-1/0;const d=window.matchMedia("(prefers-reduced-motion: reduce)"),f=()=>{l=!0,s||!c||document.hidden||a||(a=requestAnimationFrame(m))},m=t=>{if(a=0,s||!c||document.hidden)return;const o=!d.matches&&(n||t-h<1500);(l||o)&&(e(t,d.matches?null:i),l=!1),o&&(a=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;i=o>=0&&o<=1&&r>=0&&r<=1?{x:o,y:r}:null,h=performance.now(),f()},g=()=>{i=null,h=performance.now(),f()},p=()=>{document.hidden&&a?(cancelAnimationFrame(a),a=0):f()},M="undefined"==typeof IntersectionObserver?null:new IntersectionObserver(([t])=>{c=t.isIntersecting,c?f():a&&(cancelAnimationFrame(a),a=0)});return M?.observe(t),o&&(r.addEventListener("pointermove",u),r.addEventListener("pointerleave",g)),document.addEventListener("visibilitychange",p),d.addEventListener("change",f),f(),{wake:f,stop:()=>{s=!0,cancelAnimationFrame(a),M?.disconnect(),r.removeEventListener("pointermove",u),r.removeEventListener("pointerleave",g),document.removeEventListener("visibilitychange",p),d.removeEventListener("change",f)}}}var S=null,E=null;function T(t,e){if(!S||!E){const n=i(t,e);S=n.canvas,E=n.ctx}return S.width!==t&&(S.width=t),S.height!==e&&(S.height=e),E}var C=new Map,A=new Map,F=new WeakMap;function L(t){const e=Intl.Segmenter;return e?Array.from(new e(void 0,{granularity:"grapheme"}).segment(t),({segment:t})=>t):[...t]}function R(t){let e=C.get(t);return e||(e=L(t),C.set(t,e)),e}function I(t){return L(t)}function k(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 i=A.get(r);if(!i){const s=R(t);i=new Array(256);for(let t=0;t<256;t++)i[t]=k(a(t,n,o),s,e);A.set(r,i)}return i}function W(t,e){return"auto"!==t?t:!M(e)}function $(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 P(t){const e=t||"auto";if("auto"!==e)return $(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=$(t.getPropertyValue(e).trim());if(n)return n}const e=$(getComputedStyle(document.body).accentColor??"");if(e)return e}return M("undefined"!=typeof document?document.body:null)?"faf9f7":"0d0d0d"}function j(t,e,n){return Math.max(e,Math.min(n,t))}function z(t,e,n){if(!t)return{x:0,y:0,width:e,height:n};const o=t.unit??"percent",r=!1!==t.preserveAspect,i=t=>void 0===t?void 0:"percent"===o?t*e:t,a=t=>void 0===t?void 0:"percent"===o?t*n:t,s=j(i(t.left)??0,0,e-1),c=j(i(t.right)??0,0,e-s-1),l=j(a(t.top)??0,0,n-1),h=j(a(t.bottom)??0,0,n-l-1),d=void 0!==t.left||void 0!==t.right||void 0!==t.top||void 0!==t.bottom,f=Math.max(1,e-s-c),m=Math.max(1,n-l-h),u=d?f:i(t.width),g=d?m:a(t.height);let p=u??e,M=g??n;if(r&&!d){const t=p/e,o=M/n,r=Math.min(t,o),i=void 0===u?o:void 0===g?t:r;p=e*i,M=n*i}p=j(p,1,d?f:e),M=j(M,1,d?m:n);const v=t.anchor??"center",w=i(t.x),x=a(t.y),y=d?s:0,b=d?l:0,S=d?f:e,E=d?m:n,T=v.endsWith("left")||"left"===v?0:v.endsWith("right")||"right"===v?S-p:(S-p)/2,C=v.startsWith("top")||"top"===v?0:v.startsWith("bottom")||"bottom"===v?E-M:(E-M)/2;return{x:j(w??y+T,0,Math.max(0,e-p)),y:j(x??b+C,0,Math.max(0,n-M)),width:p,height:M}}function O(t,e,n,o){const r=t instanceof HTMLVideoElement?t.videoWidth:t.width,i=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(0===r||0===i)return{frame:[],cols:0,rows:0};const c=e.charAspect,h=e.fontSize*e.charSpacing,d=e.fontSize/c*e.charSpacing,f=n||r,m=o||i,u=Math.floor(f/h),g=Math.floor(m/d);if(u<=0||g<=0)return{frame:[],cols:0,rows:0};const p=z(e.sourceCrop,r,i),M=Math.max(1,Math.min(Math.floor(2048/u),Math.floor(p.width/u))),w=Math.max(1,Math.min(Math.floor(2048/g),Math.floor(p.height/g))),x=u*M,y=g*w,b=T(x,y),S=b.globalCompositeOperation;b.globalCompositeOperation="copy";try{b.drawImage(t,p.x,p.y,p.width,p.height,0,0,x,y)}finally{b.globalCompositeOperation=S}const E=b.getImageData(0,0,x,y).data,C=e.chromaKey,A=null!=C&&!1!==C,F=!0===C,L="blue-screen"===C;let I=null,$=0;!A||F||L||(I=v(C),$=(e.chromaKeyTolerance??60)**2);let P=0,j=255;if(e.normalize){let t=255,e=0;for(let n=0;n<E.length;n+=4){if(A){const t=E[n],e=E[n+1],o=E[n+2];let r=!1;if(F)r=e>1.4*t&&e>1.4*o&&e>80;else if(L)r=o>1.4*t&&o>1.4*e&&o>80;else if(null!==I){const n=t-I.r,i=e-I.g,a=o-I.b;r=n*n+i*i+a*a<=$}if(r)continue}const o=.299*E[n]+.587*E[n+1]+.114*E[n+2];o<t&&(t=o),o>e&&(e=o)}P=t,j=e>t?e-t:255}const O=[],V=W(e.invert),q=A&&e.charset.replace(/ /g,"")||e.charset,D=R(q),B=e.customText?null:H(q,V,e.brightness,e.contrast),U=M*w;for(let t=0;t<g;t++){const n=[];for(let o=0;o<u;o++){let r=0,i=0,c=0,h=0,d=0;for(let e=0;e<w;e++){const n=(t*w+e)*x;for(let t=0;t<M;t++){const e=4*(n+o*M+t),a=E[e],s=E[e+1],l=E[e+2],f=E[e+3];if(A){let t=!1;if(F)t=s>1.4*a&&s>1.4*l&&s>80;else if(L)t=l>1.4*a&&l>1.4*s&&l>80;else if(null!==I){const e=a-I.r,n=s-I.g,o=l-I.b;t=e*e+n*n+o*o<=$}if(t){d++;continue}}r+=a,i+=s,c+=l,h+=f}}if(A&&d>U/2){n.push({char:" ",r:0,g:0,b:0,a:0});continue}const f=U-d,m=f>0?r/f:0,g=f>0?i/f:0,p=f>0?c/f:0,v=f>0?h/f:0,y=.299*m+.587*g+.114*p,b=e.normalize?(y-P)/j*255:y,S=a(b,e.brightness,e.contrast),T=e.ditherStrength>0?l(S,o,t,e.ditherStrength):S,C=e.customText?s(T,e.customText,o,t,u,V):e.ditherStrength>0?k(T,D,V):B[Math.max(0,Math.min(255,0|b))];n.push({char:C,r:m,g:g,b:p,a:v,lum:T})}O.push(n)}return{frame:O,cols:u,rows:g}}function V(t,e,n,o){const r=t instanceof HTMLVideoElement?t.videoWidth:t.width,i=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(0===r||0===i)return{rows:[],cols:0,rowCount:0};const s=e.charAspect,c=e.fontSize*e.charSpacing,h=e.fontSize/s*e.charSpacing,d=n||r,f=o||i,m=Math.floor(d/c),u=Math.floor(f/h);if(m<=0||u<=0)return{rows:[],cols:0,rowCount:0};const g=m,p=u,M=T(g,p),w=z(e.sourceCrop,r,i),x=M.globalCompositeOperation;M.globalCompositeOperation="copy";try{M.drawImage(t,w.x,w.y,w.width,w.height,0,0,g,p)}finally{M.globalCompositeOperation=x}const y=M.getImageData(0,0,g,p).data,b=e.chromaKey,S=null!=b&&!1!==b,E=!0===b,C="blue-screen"===b;let A=null,F=0;!S||E||C||(A=v(b),F=(e.chromaKeyTolerance??60)**2);let L=0,I=255;if(e.normalize){let t=255,e=0;for(let n=0;n<y.length;n+=4){if(S){const t=y[n],e=y[n+1],o=y[n+2];let r=!1;if(E)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!==A){const n=t-A.r,i=e-A.g,a=o-A.b;r=n*n+i*i+a*a<=F}if(r)continue}const o=.299*y[n]+.587*y[n+1]+.114*y[n+2];o<t&&(t=o),o>e&&(e=o)}L=t,I=e>t?e-t:255}const $=W(e.invert),P=S&&e.charset.replace(/ /g,"")||e.charset,j=R(P),O=e.customText?null:H(P,$,e.brightness,e.contrast),V=e.customText?R(e.customText):null,q="fullcolor"===e.colorMode?new Uint8ClampedArray(m*u*4):void 0,D=[];for(let t=0;t<u;t++){let n="";for(let o=0;o<m;o++){const r=4*(t*g+o),i=r,s=y[r],c=y[r+1],h=y[r+2],d=y[r+3];if(S){let t=!1;if(E)t=c>1.4*s&&c>1.4*h&&c>80;else if(C)t=h>1.4*s&&h>1.4*c&&h>80;else if(null!==A){const e=s-A.r,n=c-A.g,o=h-A.b;t=e*e+n*n+o*o<=F}if(t){n+=" ",q&&(q[i]=0,q[i+1]=0,q[i+2]=0,q[i+3]=0);continue}}q&&(q[i]=s,q[i+1]=c,q[i+2]=h,q[i+3]=d);const f=.299*s+.587*c+.114*h,u=e.normalize?(f-L)/I*255:f,p=e.ditherStrength>0||V?a(u,e.brightness,e.contrast):u,M=e.ditherStrength>0?l(p,o,t,e.ditherStrength):p;if(V){n+=($?1-M/255:M/255)<.12?" ":V[(t*m+o)%V.length]}else e.ditherStrength<=0?n+=O[Math.max(0,Math.min(255,0|u))]:n+=k(M,j,$)}D.push(n)}return{rows:D,cols:m,rowCount:u,colors:q}}function q(t,e,n,o,r){if(0===e.rows.length)return;const i=t.canvas,a=Boolean(n.chromaKey)||e.rows.some(t=>t.includes(" "));a||(F.delete(t),t.clearRect(0,0,o,r),t.fillStyle=M(i)?"#0a0a0a":"#faf9f7",t.fillRect(0,0,o,r));const s=P(n.accentColor),c=parseInt(s.substring(0,2),16),l=parseInt(s.substring(2,4),16),h=parseInt(s.substring(4,6),16),d=o/e.cols,f=r/e.rowCount,m=.9*Math.min(d/.55,f),u=e.colors;if("fullcolor"===n.colorMode&&u){F.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=I(e.rows[o]);let i=0;for(;i<e.cols;){for(;i<e.cols&&" "===r[i];)i++;if(i>=e.cols)break;const a=i,s=4*(o*e.cols+i),c=240&u[s],l=240&u[s+1],h=240&u[s+2];for(i++;i<e.cols&&" "!==r[i];){const t=4*(o*e.cols+i);if((240&u[t])!==c||(240&u[t+1])!==l||(240&u[t+2])!==h)break;i++}const m=`rgb(${c},${l},${h})`;m!==n&&(t.fillStyle=m,n=m),t.fillText(r.slice(a,i).join(""),a*d+.5*d,o*f+.5*f)}}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?M(i)?"rgb(230,230,230)":"rgb(24,24,24)":`rgb(${c},${l},${h})`;t.fillStyle=g,t.globalAlpha=1;const p=F.get(t),v=a&&p&&p.cols===e.cols&&p.rowCount===e.rowCount&&p.canvasWidth===o&&p.canvasHeight===r&&p.fillStyle===g;v||t.clearRect(0,0,o,r);for(let n=0;n<e.rows.length;n++){const r=e.rows[n];v&&p.rows[n]===r||(v&&t.clearRect(0,n*f,o,f+1),0!==r.trim().length&&t.fillText(r,.5*d,n*f+.5*f))}F.set(t,{rows:e.rows.slice(),cols:e.cols,rowCount:e.rowCount,canvasWidth:o,canvasHeight:r,fillStyle:g}),t.globalAlpha=1}async function D(t,e,n,o,r=12,i=10,a,s=0){const c=Math.min(t.duration-s,i),l=Math.ceil(c*r),h=[];let d=0,f=0;for(let i=0;i<l;i++){const m=s+i/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=O(t,e,n,o);h.push(u.frame),d=u.cols,f=u.rows,a?.((i+1)/l)}return{frames:h,cols:d,rows:f,fps:r}}async function B(t,e,n,o,r=12,i=10,a,s=0){const c=Math.min(t.duration-s,i),l=Math.ceil(c*r),h=[];let d=0,f=0;for(let i=0;i<l;i++){const m=s+i/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),d=u.cols,f=u.rowCount,a?.((i+1)/l)}return{frames:h,cols:d,rows:f,fps:r}}async function U(t,e,n,o,r){const{parseGIF:i,decompressFrames:a}=await import("gifuct-js"),s=i(t),c=a(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,d=s.lsd?.width||l,f=s.lsd?.height||h,m=document.createElement("canvas");m.width=d,m.height=f;const u=m.getContext("2d"),g=document.createElement("canvas");g.width=d,g.height=f;const p=g.getContext("2d"),M=document.createElement("canvas"),v=M.getContext("2d"),w=[];let x=0,y=0,b=0;for(const t of c)b+=t.delay||100;const S=b/c.length,E=Math.round(Math.min(30,Math.max(5,1e3/S))),T=Math.min(c.length,300);for(let t=0;t<T;t++){const i=c[t],{dims:a,patch:s,disposalType:l}=i;3===l&&(p.clearRect(0,0,d,f),p.drawImage(m,0,0)),M.width!==a.width&&(M.width=a.width),M.height!==a.height&&(M.height=a.height);const h=new ImageData(new Uint8ClampedArray(s.buffer),a.width,a.height);v.putImageData(h,0,0),u.drawImage(M,a.left||0,a.top||0);const b=O(m,e,n,o);w.push(b.frame),x=b.cols,y=b.rows,2===l?u.clearRect(a.left||0,a.top||0,a.width,a.height):3===l&&(u.clearRect(0,0,d,f),u.drawImage(g,0,0)),r?.((t+1)/T)}return{frames:w,cols:x,rows:y,fps:E}}var N=new WeakMap,K=new WeakMap,Y=new WeakMap;function _(t,e,n,o,r,i=0,a){if(!e.length||!e[0].length||o<=0||r<=0)return;let s=null;if(n.hoverStrength>0){let e=N.get(t);e||(e={x:.5,y:.5,intensity:0,time:-1,emittedAt:-1,points:[]},N.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,i=t.x,a=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-i,t.y-a)>5e-4&&(t.points.push({x:t.x,y:t.y,intensity:t.intensity,vx:Math.max(-1,Math.min(1,(t.x-i)/Math.max(o,.001))),vy:Math.max(-1,Math.min(1,(t.y-a)/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,a??null,performance.now())}else N.delete(t);if("none"!==n.animationStyle||n.charsetFrames?.length||n.hoverStrength<=0)return Y.delete(t),void G(t,e,n,o,r,i,s);const c=K.get(t);if(c?.frame!==e)return K.set(t,{frame:e,since:performance.now()}),Y.delete(t),void G(t,e,n,o,r,i,s);if(performance.now()-c.since<100)return void G(t,e,n,o,r,i,s);const l=t.getTransform();if(l.b||l.c||l.a<=0||l.d<=0)return void G(t,e,n,o,r,i,s);if(!s||(s.intensity??0)<.003)return void G(t,e,n,o,r,i,null);const h=M(t.canvas),d={...n,accentColor:"#"+P(n.accentColor)},f=JSON.stringify([d,o,r,l.a,l.d,h,void 0!==document.fonts?document.fonts.status:"loaded"]);let m=Y.get(t);if(!m||m.frame!==e||m.key!==f){const n=m?.canvas??document.createElement("canvas");n.width=Math.ceil(o*l.a),n.height=Math.ceil(r*l.d);const i=n.getContext("2d");i.setTransform(l.a,0,0,l.d,0,0),G(i,e,d,o,r,0,null,void 0,h),m={frame:e,key:f,canvas:n},Y.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,p=.08+.35*n.hoverRadius+.04*n.hoverStrength,v="trail"===n.hoverEffect?[s,...s.trail??[]]:[s];let w=1,x=1,y=0,b=0;for(const t of v)w=Math.min(w,t.x-p),y=Math.max(y,t.x+p),x=Math.min(x,t.y-p),b=Math.max(b,t.y+p);if("glitchText"===n.hoverEffect){const t=n.hoverText,e=Math.max(1,...(Array.isArray(t)?t:[t]).map(t=>t.length));w=Math.min(w,s.x-e/g),y=Math.max(y,s.x+e/g)}const S=Math.ceil(5+4*n.hoverStrength),E={x:Math.max(0,Math.floor(w*g)-S),y:Math.max(0,Math.floor(x*u)-S),right:Math.min(g,Math.ceil(y*g)+S),bottom:Math.min(u,Math.ceil(b*u)+S)};t.save(),t.beginPath(),t.rect(E.x*o/g,E.y*r/u,(E.right-E.x)*o/g,(E.bottom-E.y)*r/u),t.clip(),G(t,e,d,o,r,i,s,E,h),t.restore()}function G(t,e,o,i,a,s=0,c,l,h){const d=e.length;if(0===d)return;const m=e[0].length;t.clearRect(0,0,i,a);let g=!1;const p=Math.max(1,d>>2),v=Math.max(1,m>>2);t:for(let t=0;t<d;t+=p){const n=e[t];for(let t=0;t<m;t+=v)if(n[t].a<200){g=!0;break t}}const w=t.canvas,x=h??M(w);g||(t.fillStyle=x?"#0a0a0a":"#faf9f7",t.fillRect(0,0,i,a));const b=i/m,S=a/d,E=c?.intensity??1,T=!!(c&&o.hoverStrength>0&&E>.005),C="#"+($(o.hoverColor||"#ffffff")??"ffffff"),A=parseInt(C.slice(1,3),16),F=parseInt(C.slice(3,5),16),L=parseInt(C.slice(5,7),16),I=P(o.accentColor),H=parseInt(I.substring(0,2),16),j=parseInt(I.substring(2,4),16),z=parseInt(I.substring(4,6),16),O=o.hoverRadius;let V=0,q=m,D=0,B=d,U=0,N=0;if(T&&c){U=c.x,N=c.y;const t=.08+.35*O+.04*o.hoverStrength;V=Math.max(0,Math.floor((U-t)*m)-1),q=Math.min(m,Math.ceil((U+t)*m)+1),D=Math.max(0,Math.floor((N-t)*d)-1),B=Math.min(d,Math.ceil((N+t)*d)+1)}if(T&&"trail"===o.hoverEffect)for(const t of c?.trail??[]){const e=.08+.35*O+.04*o.hoverStrength;V=Math.min(V,Math.max(0,Math.floor((t.x-e)*m)-1)),q=Math.max(q,Math.min(m,Math.ceil((t.x+e)*m)+1)),D=Math.min(D,Math.max(0,Math.floor((t.y-e)*d)-1)),B=Math.max(B,Math.min(d,Math.ceil((t.y+e)*d)+1))}const K=o.animationStyle,Y=o.animationSpeed,_=(G=K,n.find(t=>t.value===G||t.mode===G)?.mode??"none");var G;const X="none"===_,J=[0,0,0,1],Q=o.hoverStrength,Z=o.hoverEffect,tt=O,et=o.hoverShape||"circle",nt=W(o.invert,w),ot=o.colorMode,rt=2*Math.PI,it=1/m,at=1/d;let st="",ct=-1;if("dots"===o.renderMode){const n=.5*Math.min(b,S)*o.dotSizeRatio;for(let o=l?.y??0;o<(l?.bottom??d);o++){const h=e[o];for(let e=l?.x??0;e<(l?.right??m);e++){const l=h[e];if(l.a<10)continue;const g=.00392156863*(.299*l.r+.587*l.g+.114*l.b),p=nt?1-g:g;if(p<.02)continue;X||r(_,e/m,o/d,s*Y,J);const M=Math.max(0,Math.min(1,(1+J[2])*J[3]));let v=1,w=0,x=0,C=0,R=0;if(T&&e>=V&&e<=q&&o>=D&&o<=B){const t=y(e*it,o*at,U,N,E,Q,b,S,Z,tt,et,c?.trail,i/a);v=t.scale,w=t.offsetX,x=t.offsetY,C=t.glow,R=t.colorBlend}const I=n*p*M*v;if(I<.3)continue;const k=e*b+.5*b+w+J[0],W=o*S+.5*S+x+J[1];let $;if(R>0){const t=u(l,ot,H,j,z,nt);$=`rgb(${Math.min(255,t[0]+(A-t[0])*R|0)},${Math.min(255,t[1]+(F-t[1])*R|0)},${Math.min(255,t[2]+(L-t[2])*R|0)})`}else $=f(l,ot,H,j,z,nt);const P=Math.min(1,.00392156863*l.a*M*(1+C));if(P!==ct&&(t.globalAlpha=P,ct=P),$!==st&&(t.fillStyle=$,st=$),I<=3){const e=2*I;t.fillRect(k-I,W-I,e,e)}else t.beginPath(),t.arc(k,W,I,0,rt),t.fill()}}}else{const n=.55,h=.9*Math.min(b/n,S);{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 g=o.charsetFrames,p=!!g?.length,M=p?g[Math.floor(Math.max(0,s)*(o.charsetFps??2))%g.length]:o.charset,v=t.getTransform();if(!T&&X&&!p&&"accent"===ot&&!l&&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 n=t.letterSpacing;t.letterSpacing="0px";const o=t.measureText("M").width;t.letterSpacing=b-o+"px",t.fillStyle=`rgb(${H},${j},${z})`,t.globalAlpha=1,t.textAlign="left";for(let n=0;n<d;n++){const r=e[n];let i="";for(let t=0;t<m;t++){const e=r[t];i+=e.a<10?" ":e.char}0!==i.trim().length&&t.fillText(i,.5*(b-o),n*S+.5*S)}return t.letterSpacing=n,t.textAlign="center",void(t.globalAlpha=1)}const w="glitchText"===Z&&T,x="!@#$%^&*<>{}[]|/\\~`0123456789",C=x.length;let I="",W=0,$=0,P=0,K=0,G=0,rt=0;if(w){const t=o.hoverText??"ASCIIFY";if($=Math.round(U*m),P=Math.round(N*d),Array.isArray(t)){const e=t.filter(t=>t.length>0);0===e.length&&e.push("ASCIIFY");I=e[((7*Math.floor($/Math.max(1,Math.ceil(m/5)))+13*Math.floor(P/Math.max(1,Math.ceil(d/3))))%e.length+e.length)%e.length]}else I=t||"ASCIIFY";W=I.length,K=Math.max(3,Math.min(12,Math.round(d*O*.6)));const e=Math.floor(K/2);G=Math.max(0,P-e),G+K>d&&(G=Math.max(0,d-K)),rt=$-Math.floor(W/2)}for(let n=l?.y??0;n<(l?.bottom??d);n++){const o=e[n];for(let h=l?.x??0;h<(l?.right??m);h++){const l=o[h];if(l.a<10)continue;let g=p&&null!=l.lum?k(l.lum,R(M),nt):l.char;if(" "===g)continue;X||r(_,h/m,n/d,s*Y,J);const O=Math.max(0,Math.min(1,(1+J[2])*J[3]));if(O<.05)continue;let lt=1,ht=0,dt=0,ft=0,mt=0;if(T&&!w&&h>=V&&h<=q&&n>=D&&n<=B){const t=y(h*it,n*at,U,N,E,Q,b,S,Z,tt,et,c?.trail,i/a);if(lt=t.scale,ht=t.offsetX,dt=t.offsetY,ft=t.glow,mt=t.colorBlend,"trail"===Z&&t.proximity>0){const o=Math.max(0,Math.min(m-1,Math.round(h-t.offsetX/b))),r=e[Math.max(0,Math.min(d-1,Math.round(n-t.offsetY/S)))][o],i=r.lum??.299*r.r+.587*r.g+.114*r.b;g=k(Math.min(255,i+t.proximity*Q*65),R(M),nt)}}if(w&&n>=G&&n<G+K){const t=h-rt;if(t>=0&&t<W){const e=I[t],o=Math.abs(n-P)/Math.max(1,.5*K),r=Math.abs(h-$)/Math.max(1,W),i=Math.max(o,r),a=Math.max(0,Math.min(1,1-.9*i)),c=43758.5453*Math.sin(127.1*h+311.7*n+43758.5453*Math.floor(12*s));g=Math.abs(c-Math.floor(c))<a?e:x[Math.abs(Math.floor(97*c))%C],ft=.3+.7*a,mt=.3+.65*a}}const ut=h*b+.5*b+ht+J[0],gt=n*S+.5*S+dt+J[1];let pt;if(mt>0){const t=u(l,ot,H,j,z,nt);pt=`rgb(${Math.min(255,t[0]+(A-t[0])*mt|0)},${Math.min(255,t[1]+(F-t[1])*mt|0)},${Math.min(255,t[2]+(L-t[2])*mt|0)})`}else pt=f(l,ot,H,j,z,nt);const Mt=Math.min(1,.00392156863*l.a*O*(1+ft));Mt!==ct&&(t.globalAlpha=Mt,ct=Mt),pt!==st&&(t.fillStyle=pt,st=pt),1!==lt?(t.translate(ut,gt),t.scale(lt,lt),t.fillText(g,0,0),t.setTransform(v)):t.fillText(g,ut,gt)}}}t.globalAlpha=1}function X(t="classic"){if("classic"!==t)throw new RangeError(`Art preset "${String(t)}" was removed in 4.1. Use a StudioStyle with asciify-engine/studio, or supply options.charset directly.`);return{artStyle:"classic"}}function J(t){return Math.max(0,Math.min(1,t))}function Q(t){return"string"==typeof t?document.querySelector(t):t instanceof HTMLElement?t:null}function Z(t){return"ascii"===t.renderMode&&"none"===t.animationStyle&&t.hoverStrength<=0&&!t.charsetFrames?.length}function tt(t,e={}){const n=J(t),o=J(n*(void 0===e.speed?1:Math.max(.001,e.speed)));return J(e.ease?e.ease(o):o)}function et(t,e,n={}){if(!Number.isFinite(t.duration)||t.duration<=0)return;const o=n.from??0,r=n.to??t.duration,i=Math.max(o,Math.min(r,t.duration)),a=tt(e,n),s=o+(i-o)*a;t.currentTime=Math.min(Math.max(o,s),Math.max(o,i-.04)),n.onUpdate?.(a,t)}function nt(t,e){return Math.abs(t.currentTime-e)<1/240?ot(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 ot(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 rt(t,e={}){const n=Q(e.trigger)??t;t.pause();const o=e.gsap,r=e.ScrollTrigger??o?.ScrollTrigger;if(o&&r?.create){o.registerPlugin?.(r);const i=r.create({trigger:n,start:e.start??"top bottom",end:e.end??"bottom top",scrub:e.scrub??!0,onUpdate:n=>et(t,n.progress,e)});return()=>i.kill?.()}return function(t,e,n){let o=0;const r=()=>{o=0;const r=e.getBoundingClientRect(),i=window.innerHeight||document.documentElement.clientHeight,a=r.height+i,s=a>0?J((i-r.top)/a):0;et(t,s,n)},i=()=>{o||(o=requestAnimationFrame(r))};return window.addEventListener("scroll",i,{passive:!0}),window.addEventListener("resize",i),i(),()=>{window.removeEventListener("scroll",i),window.removeEventListener("resize",i),o&&cancelAnimationFrame(o)}}(t,n,e)}function it(t,e,n){const o=e.gsap,r=e.ScrollTrigger??o?.ScrollTrigger;if(o&&r?.create){o.registerPlugin?.(r);const i=r.create({trigger:t,start:e.start??"top bottom",end:e.end??"bottom top",scrub:e.scrub??!0,onUpdate:t=>n(t.progress)});return()=>i.kill?.()}return function(t,e){let n=0;const o=()=>{n=0;const o=t.getBoundingClientRect(),r=window.innerHeight||document.documentElement.clientHeight,i=o.height+r,a=i>0?J((r-o.top)/i):0;e(a)},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 at(t,e,n){if(!t||!e||!n.sourceCrop)return{w:t,h:e};const o=z(n.sourceCrop,t,e);return{w:Math.max(1,Math.round(o.width)),h:Math.max(1,Math.round(o.height))}}function st(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 i=v(r),a=(o.chromaKeyTolerance??60)**2,s=t-i.r,c=e-i.g,l=n-i.b;return s*s+c*c+l*l<=a}function ct(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=z(e.sourceCrop,o,r),s=Math.min(360,Math.max(1,Math.round(a.width))),c=Math.max(1,Math.round(s*(a.height/a.width))),{ctx:l}=i(s,c);l.drawImage(t,a.x,a.y,a.width,a.height,0,0,s,c);const h=l.getImageData(0,0,s,c).data,d=Math.max(0,Math.min(255,e.chromaKeyTrimLuminanceThreshold??0));let f=s,m=c,u=-1,g=-1;for(let t=0;t<c;t++)for(let n=0;n<s;n++){const o=4*(t*s+n),r=h[o+3],i=h[o],a=h[o+1],c=h[o+2];r<=8||.2126*i+.7152*a+.0722*c<=d||st(i,a,c,e)||(n<f&&(f=n),t<m&&(m=t),n>u&&(u=n),t>g&&(g=t))}if(u<f||g<m)return e;const p=Math.max(0,Math.min(.25,e.chromaKeyTrimPadding??.002)),M=Math.round(s*p),v=Math.round(c*p);f=Math.max(0,f-M),m=Math.max(0,m-v),u=Math.min(s-1,u+M),g=Math.min(c-1,g+v);const w=function(t,e,n,o,r){const i=r&&Number.isFinite(r)&&r>0?r:null;if(!i)return t;const a=e.x,s=e.y,c=e.x+e.width,l=e.y+e.height,h=Math.max(a,t.left),d=Math.max(s,t.top),f=Math.min(c,n-t.right),m=Math.min(l,o-t.bottom),u=Math.max(1,f-h),g=Math.max(1,m-d),p=h+u/2,M=d+g/2;let v=u,w=g;v/w<i?v=w*i:w=v/i;v>e.width&&(v=e.width,w=Math.max(g,Math.min(e.height,v/i)));w>e.height&&(w=e.height,v=Math.max(u,Math.min(e.width,w*i)));let x=p-v/2,y=M-w/2;return x=Math.max(a,Math.min(c-v,x)),y=Math.max(s,Math.min(l-w,y)),{left:x,top:y,right:n-(x+v),bottom:o-(y+w)}}({left:a.x+f/s*a.width,top:a.y+m/c*a.height,right:o-(a.x+(u+1)/s*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",...w,preserveAspect:!1}}}function lt(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 ht(t,e,n,o,r){if(!e.chromaKey||!e.sourceCrop||"range"!==e.chromaKeyTrimMode)return e;const i=t.currentTime,a=function(t,e,n,o){const r=!0===o?{}:o||{},i=Math.max(0,r.from??e),a=r.to??n??(Number.isFinite(t.duration)?t.duration:i),s=Math.max(i,a-.04),c=Math.max(0,s-i),l=c>.1?[i,i+.25*c,i+.5*c,i+.75*c,s]:[i];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 a){await nt(t,n),await ot(t);const o=lt(ct(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 nt(t,i),await ot(t),s?{...e,sourceCrop:{unit:"pixel",...s,preserveAspect:!0}}:e}function dt(t,e,n=2048){return ft({sourceWidth:t,sourceHeight:e,maxRenderDimension:n})}function ft({sourceWidth:t,sourceHeight:e,cssWidth:n=0,cssHeight:o=0,maxRenderDimension:r=2048}){const i=Math.max(1,t),a=Math.max(1,e),s=i/a,c=Math.max(1,r),l=Math.min(1,c/Math.max(i,a)),h=Math.max(i,a)*l,d=Math.max(0,n,o),f=Math.min(c,Math.max(h,d));return s>=1?{renderW:Math.round(f),renderH:Math.round(f/s)}:{renderW:Math.round(f*s),renderH:Math.round(f)}}function mt(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 ut(t,e,n,o,r,i=2048,a={}){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,d=mt(a.width,s,l,h)??s,f=mt(a.height,c,l,h)??c,m=function(t,e,n,o,r){const i=t=>{const n=mt(t,e,o,r);return n&&n>0?n:0},a=t=>{const e=mt(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:i(t),y:a(t)}:{x:i(t.x),y:a(t.y)}}(a.bleed,s,c,l,h),u=d+2*m.x,g=f+2*m.y,{cssW:p,cssH:M}=function(t,e,n,o="contain"){if("fill"===o)return{cssW:t,cssH:e};let r=t,i=r/n;const a="cover"===o,s=i>e;return(a&&!s||!a&&s)&&(i=e,r=i*n),"scale-down"===o&&(r=Math.min(r,t),i=Math.min(i,e)),{cssW:Math.round(r),cssH:Math.round(i)}}(u,g,n,a.objectFit??"contain"),v="undefined"!=typeof window&&window.devicePixelRatio||1;let w,x;o&&r?({renderW:w,renderH:x}=ft({sourceWidth:o,sourceHeight:r,cssWidth:p,cssHeight:M,maxRenderDimension:i})):(w=p,x=M);const y=8e6,b=w*v*x*v>y?Math.sqrt(y/(w*x)):v;return t.width=Math.round(w*b),t.height=Math.round(x*b),t.style.width=`${p}px`,t.style.height=`${M}px`,{renderW:w,renderH:x,dpr:b}}async function gt(t,n,{fontSize:o,artStyle:r="classic",options:i={},fitTo:a,objectFit:s,objectPosition:c,scale:l,width:h,height:d,bleed:f,preExtract:m=!1,fps:u,maxRenderDimension:g=2048,trim:p,scroll:M,maxCachedFrames:v=90,onReady:w,onFrame:x}={}){const y=p?.start??0,S=p?.end,E=o??i.fontSize??10;let T={...e,...X(r),artStyle:r,...i,fontSize:E};const C=n.getContext("2d");if(!C)throw new Error("asciifyVideo: could not get 2d context from canvas.");const A="string"==typeof a?document.querySelector(a):a instanceof HTMLElement?a:null,F={objectFit:s,objectPosition:c,scale:l,width:h,height:d,bleed:f},L=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")}}(n,F),R=t=>()=>{t(),L()};if(m){let e;"string"==typeof t?(e=document.createElement("video"),e.crossOrigin="anonymous",e.src=t,e.readyState<2&&await new Promise((n,o)=>{e.onloadeddata=()=>n(),e.onerror=()=>o(new Error(`asciifyVideo: failed to load "${t}"`))})):e=t,T=await ht(e,T,y,S,M);const o=at(e.videoWidth,e.videoHeight,T);A&&ut(n,A,o.w/o.h,o.w,o.h,g,F);const{renderW:r,renderH:i}=dt(o.w,o.h,g),a="undefined"!=typeof window&&window.devicePixelRatio||1,s=8e6,c=r*a*i*a>s?Math.sqrt(s/(r*i)):a;n.width===Math.round(r*c)&&n.height===Math.round(i*c)||(n.width=Math.round(r*c),n.height=Math.round(i*c));const l=void 0!==S?S-y:10,h=u??(M?18:void 0);if(Z(T)){const{frames:t,fps:o}=await B(e,T,r,i,h,l,void 0,y),a=e=>{const n=t[e];n&&(C.save(),C.setTransform(c,0,0,c,0,0),q(C,n,T,r,i),C.restore(),x?.())};if(M){let o=!1,r=-1;const i=!0===M?{}:M,s=it(Q(i.trigger)??A??n,i,n=>{const s=tt(n,i),c=Math.max(0,Math.min(t.length-1,Math.round(s*(t.length-1))));c!==r&&(r=c,a(c),o||(o=!0,w?.(e)),i.onUpdate?.(s,e))});return a(0),o=!0,w?.(e),R(s)}let s,d=!1,f=0,m=performance.now(),u=!0;const g=1e3/o,p=n=>{d||(n-m>=g&&(a(f),f=(f+1)%t.length,m=n,u&&(u=!1,w?.(e))),s=requestAnimationFrame(p))};return s=requestAnimationFrame(p),R(()=>{d=!0,cancelAnimationFrame(s)})}const{frames:d,fps:f}=await D(e,T,r,i,h,l,void 0,y);if(!d.length)throw new Error("asciifyVideo: no frames were decoded.");let m=0;const p=performance.now(),v=b(n,(t,e)=>{M||(m=Math.floor((t-p)*f/1e3)%d.length),C.save(),C.setTransform(c,0,0,c,0,0),_(C,d[m],T,r,i,(t-p)/1e3,e),C.restore(),x?.()},{continuous:!M||"none"!==T.animationStyle||!!T.charsetFrames?.length,interactive:T.hoverStrength>0});let E;if(M){const t=!0===M?{}:M;E=it(Q(t.trigger)??A??n,t,n=>{m=Math.max(0,Math.min(d.length-1,Math.round(tt(n,t)*(d.length-1)))),v.wake(),t.onUpdate?.(n,e)})}return w?.(e),R(()=>{v.stop(),E?.()})}let I,k=!1;"string"==typeof t?(I=document.createElement("video"),I.crossOrigin="anonymous",I.src=t,I.muted=!0,I.loop=!0,I.playsInline=!0,I.setAttribute("playsinline",""),Object.assign(I.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(I),k=!0,await new Promise((e,n)=>{I.onloadedmetadata=()=>e(),I.onerror=()=>n(new Error(`asciifyVideo: failed to load "${t}"`))}),await I.play().catch(()=>{})):(I=t,I.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((t,e)=>{const n=()=>{I.removeEventListener("loadedmetadata",o),I.removeEventListener("error",r)},o=()=>{n(),t()},r=()=>{n(),e(new Error("asciifyVideo: provided video element failed to load metadata."))};I.addEventListener("loadedmetadata",o),I.addEventListener("error",r),I.load()}),I.paused&&await I.play().catch(()=>{})),y>0&&(I.currentTime=y,await new Promise(t=>{const e=()=>{I.removeEventListener("seeked",e),t()};I.addEventListener("seeked",e)}),await ot(I));let H=null;(y>0||void 0!==S)&&(H=()=>{(void 0!==S&&I.currentTime>=S||y>0&&I.currentTime<y)&&(I.currentTime=y)},I.addEventListener("timeupdate",H)),T=await ht(I,T,y,S,M);let W=null;const $=at(I.videoWidth,I.videoHeight,T);let{renderW:P,renderH:j}=dt($.w,$.h,g);const z=t=>"frame"===T.chromaKeyTrimMode?ct(t,T,P/j):T;if(A){const t=$.w/$.h,e=$.w,o=$.h,r=ut(n,A,t,e,o,g,F);P=r.renderW,j=r.renderH;const i=n.getContext("2d");i&&i.setTransform(r.dpr,0,0,r.dpr,0,0),W=new ResizeObserver(()=>{const r=ut(n,A,t,e,o,g,F);P=r.renderW,j=r.renderH;const i=n.getContext("2d");i&&i.setTransform(r.dpr,0,0,r.dpr,0,0)}),W.observe(A)}else{const t="undefined"!=typeof window&&window.devicePixelRatio||1,e=8e6,o=P*t*j*t>e?Math.sqrt(e/(P*j)):t;n.width===Math.round(P*o)&&n.height===Math.round(j*o)||(n.width=Math.round(P*o),n.height=Math.round(j*o)),C.setTransform(o,0,0,o,0,0)}let U=!0,N=null;const K=M&&!m,Y=u&&u>0?1e3/u:0;let G=0;const et=!K&&Z(T);if(K&&"ascii"===T.renderMode&&"none"===T.animationStyle&&T.hoverStrength<=0&&!T.charsetFrames?.length){const t=!0===M?{}:M,e=Q(t.trigger)??A??n,o=t.from??y,r=t.to??S??I.duration,i=Math.max(o,Math.min(r,I.duration)),a=Math.max(.001,i-o),s=Math.min(60,Math.max(12,u??30)),c=Math.max(2,Math.ceil(a*s)+1),l=new Array(c),h=[],d=Math.max(2,Math.min(c,Math.floor(v))),f=()=>{for(;h.length>d;){const t=h.findIndex(t=>t!==g&&Math.abs(t-g)>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),f()};let g=0,p=0,b=-1,E=0,F=!1,L=!1,$=!1;const O=new Set,D=document.createElement("video");D.muted=!0,D.playsInline=!0,D.preload="auto",D.crossOrigin=I.crossOrigin||"anonymous",D.src=I.currentSrc||I.src,Object.assign(D.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(D),D.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((t,e)=>{const n=()=>{D.removeEventListener("loadedmetadata",o),D.removeEventListener("error",r)},o=()=>{n(),t()},r=()=>{n(),e(new Error("asciifyVideo: cache video failed to load metadata."))};D.addEventListener("loadedmetadata",o),D.addEventListener("error",r),D.load()}),D.pause(),I.paused&&await I.play().catch(()=>{});const B=t=>o+a*t/Math.max(1,c-1),U=t=>Math.max(0,Math.min(c-1,Math.round(t*(c-1)))),K=z(I),_=V(I,K,P,j);_.rows.length>0&&(l[0]=_,m(0),q(C,_,K,P,j),$=!0,w?.(I),x?.());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},Z=()=>{if(!l[g])return g;for(const t of O)if(!l[t])return t;for(let t=1;t<c;t++){const e=g-t,n=g+t;if(e>=0&&!l[e])return e;if(n<c&&!l[n])return n}return-1},et=t=>{t<0||t>=c||l[t]||(O.add(t),ot())},ot=async()=>{if(F||L)return;const t=Z();if(!(t<0)){O.delete(t),L=!0;try{if(await nt(D,B(t)),!F){const e=z(D),n=V(D,e,P,j);n.rows.length>0&&(l[t]=n,m(t))}}finally{L=!1,F||requestAnimationFrame(()=>{ot()})}}},rt=()=>{if(F)return;const t=X(g);if(t>=0&&t!==b){const e=l[t];e&&(q(C,e,T,P,j),b=t,$||($=!0,w?.(I)),x?.())}else if(t<0||b<0){const t=performance.now();if(Y<=0||t-G>=Y){const e=z(I),n=V(I,e,P,j);n.rows.length>0&&(q(C,n,e,P,j),G=t,$||($=!0,w?.(I)),x?.())}}et(g),E=requestAnimationFrame(rt)};return N=it(e,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,i=Math.max(o,Math.min(r,t.duration)),a=tt(e,n),s=o+(i-o)*a;return{progress:a,time:Math.min(Math.max(o,s),Math.max(o,i-.04))}}(I,e,{...t,from:o,to:i});p=n?.progress??J(e),g=U(p),et(g),et(g-1),et(g+1),et(g-2),et(g+2),et(g-3),et(g+3),t.onUpdate?.(p,I)}),et(0),et(1),E=requestAnimationFrame(rt),R(()=>{F=!0,cancelAnimationFrame(E),N?.(),W?.disconnect(),O.clear(),h.length=0,l.fill(void 0),D.pause(),D.src="",D.removeAttribute("src"),D.load(),D.isConnected&&D.remove(),H&&I.removeEventListener("timeupdate",H),k&&(I.pause(),I.src="",I.removeAttribute("src"),I.load(),I.isConnected&&I.remove())})}if(K){const t=!0===M?{}:M;N=rt(I,{...t,trigger:t.trigger??A??n,from:t.from??y,to:t.to??S})}let st=-1,lt=0,ft=-1,mt=0;const gt="function"==typeof I.requestVideoFrameCallback,pt=()=>{mt=I.requestVideoFrameCallback(()=>{lt++,pt()})};gt&&pt();let Mt=0,vt=0,wt=null;const xt=b(n,(t,e)=>{if(I.readyState<2||0===n.width||0===n.height)return;if(Y>0&&t-G<Y&&!e)return;if(y>0&&I.currentTime<y)return;if(void 0!==S&&I.currentTime>=S)return;const o=(gt?lt!==ft:I.currentTime!==st)||Mt!==P||vt!==j;if(o||!(T.hoverStrength<=0)||"none"!==T.animationStyle||T.charsetFrames?.length){if(et){const t=z(I),e=V(I,t,P,j);q(C,e,t,P,j)}else!o&&wt||(wt=O(I,z(I),P,j).frame),_(C,wt,T,P,j,t/1e3,e);st=I.currentTime,ft=lt,Mt=P,vt=j,G=t,U&&(U=!1,w?.(I)),x?.()}},{continuous:!0,interactive:T.hoverStrength>0});return R(()=>{xt.stop(),mt&&I.cancelVideoFrameCallback(mt),N?.(),W?.disconnect(),H&&I.removeEventListener("timeupdate",H),k&&(I.pause(),I.src="",I.removeAttribute("src"),I.load(),I.isConnected&&I.remove())})}function pt(t,e,n,o="#505050",r=100){if(!t||e<=0||n<=0)return[];const i=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}(o)??{r:80,g:80,b:80},a=t,s=a.length;return Array.from({length:n},(t,n)=>Array.from({length:e},(t,o)=>({char:a[(n*e+o)%s],r:i.r,g:i.g,b:i.b,a:r})))}var Mt=new WeakMap;function vt(t,{format:e="png",quality:n=.92,scale:o=1}={}){return new Promise((r,i)=>{let a=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 i(new Error("captureSnapshot: could not get 2d context"));n.drawImage(t,0,0,e.width,e.height),a=e}a.toBlob(t=>t?r(t):i(new Error("captureSnapshot: toBlob returned null")),`image/${e}`,n)})}var wt={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]},xt=[127,65,65,65,65,65,127];function yt(t){return wt[t]??wt[t.toUpperCase()]??xt}function bt(t,e={}){if(!t)return"";const{char:n="█",scale:o=1}=e,r=[...n][0]??"█",i=Math.max(1,Math.floor(o)),a=7*i,s=i,c=Array.from({length:a},()=>"");for(let e=0;e<t.length;e++){const n=yt(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(i);for(let e=0;e<i;e++)c[t*i+e]+=o}if(e<t.length-1)for(let t=0;t<a;t++)c[t]+=" ".repeat(s)}return c.join("\n")}exports.CHARACTER_SETS=t,exports.DEFAULT_OPTIONS=e,exports.HOVER_PRESETS={none:{label:"Off",options:{hoverStrength:0,hoverEffect:"spotlight",hoverRadius:.2,hoverColor:"#ffffff"}},subtle:{label:"Subtle",options:{hoverStrength:.25,hoverEffect:"glow",hoverRadius:.12,hoverColor:"#ffffff"}},flashlight:{label:"Flashlight",options:{hoverStrength:.6,hoverEffect:"spotlight",hoverRadius:.15,hoverColor:"#fffbe6"}},magnifier:{label:"Magnifier",options:{hoverStrength:.7,hoverEffect:"magnify",hoverRadius:.12,hoverColor:"#ffffff"}},forceField:{label:"Force Field",options:{hoverStrength:.7,hoverEffect:"repel",hoverRadius:.15,hoverColor:"#a0e8ff"}},neon:{label:"Neon",options:{hoverStrength:.6,hoverEffect:"colorShift",hoverRadius:.15,hoverColor:"#d946ef"}},fire:{label:"Fire",options:{hoverStrength:.7,hoverEffect:"spotlight",hoverRadius:.15,hoverColor:"#ff6b2b"}},ice:{label:"Ice",options:{hoverStrength:.5,hoverEffect:"glow",hoverRadius:.15,hoverColor:"#60d5f7"}},gravity:{label:"Gravity",options:{hoverStrength:.7,hoverEffect:"attract",hoverRadius:.18,hoverColor:"#a5d6ff"}},shatter:{label:"Shatter",options:{hoverStrength:.8,hoverEffect:"shatter",hoverRadius:.14,hoverColor:"#ff6090"}},ghost:{label:"Fluid trail",options:{hoverStrength:.55,hoverEffect:"trail",hoverRadius:.2,hoverColor:"#b39ddb"}},glitchReveal:{label:"Glitch Reveal",options:{hoverStrength:.8,hoverEffect:"glitchText",hoverRadius:.18,hoverColor:"#a3e635"}}},exports.PALETTE_THEMES={dracula:{name:"Dracula",accent:"#bd93f9",bg:"#282a36",fg:"#f8f8f2"},monokai:{name:"Monokai",accent:"#a6e22e",bg:"#272822",fg:"#f8f8f2"},nord:{name:"Nord",accent:"#88c0d0",bg:"#2e3440",fg:"#eceff4"},catppuccin:{name:"Catppuccin",accent:"#cba6f7",bg:"#1e1e2e",fg:"#cdd6f4"},solarized:{name:"Solarized",accent:"#268bd2",bg:"#002b36",fg:"#839496"},gruvbox:{name:"Gruvbox",accent:"#b8bb26",bg:"#282828",fg:"#ebdbb2"}},exports.STUDIO_STYLES=["ascii","blocks","braille","dots","lines","cross","diagonal","diamond","mixed","pixel","mosaic","lego","voxel","disco","dither"],exports.asciiText=function(t,n={},o,r){const i={...e,...n},{frame:a,cols:s}=O(t,i,o,r);if(!a.length||0===s)return"";const c=[];for(const t of a)c.push(t.map(t=>t.char).join(""));return c.join("\n")},exports.asciiTextAnsi=function(t,n={},o,r){const i={...e,...n},{frame:a,cols:s}=O(t,i,o,r);if(!a.length||0===s)return"";const c=[];for(const t of a){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")},exports.asciify=async function(t,n,{fontSize:o,artStyle:r="classic",options:i={}}={}){let a;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}),a=e}else t instanceof HTMLImageElement&&!t.complete?(await new Promise((e,n)=>{t.onload=()=>e(),t.onerror=()=>n(new Error("Image failed to load"))}),a=t):a=t;const s=X(r),c=o??i.fontSize??10,l={...e,...s,artStyle:r,...i,fontSize:c},h=n.getContext("2d");if(!h)throw new Error("Could not get 2d context from canvas");const{w:d,h:f}=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}}(a),{renderW:m,renderH:u}=dt(d,f),g="undefined"!=typeof window&&window.devicePixelRatio||1,p=8e6,M=m*g*u*g>p?Math.sqrt(p/(m*u)):g;n.width===Math.round(m*M)&&n.height===Math.round(u*M)||(n.width=Math.round(m*M),n.height=Math.round(u*M));const{frame:v}=O(a,l,m,u),w=(t,e)=>{h.save(),h.setTransform(M,0,0,M,0,0),_(h,v,l,m,u,t/1e3,e),h.restore()};return w(0,null),b(n,w,{continuous:"none"!==l.animationStyle||!!l.charsetFrames?.length,interactive:l.hoverStrength>0}).stop},exports.asciifyGif=async function(t,n,{fontSize:o,artStyle:r="classic",options:i={}}={}){const a="string"==typeof t?await fetch(t).then(t=>t.arrayBuffer()):t,s=o??i.fontSize??10;let c={...e,...X(r),artStyle:r,...i,fontSize:s};const l=n.getContext("2d");if(!l)throw new Error("Could not get 2d context from canvas");const{frames:h,fps:d}=await U(a,c,n.width,n.height);if(!h.length)throw new Error("asciifyGif: the GIF contains no renderable frames.");const f=performance.now();let m=-1;return b(n,(t,e)=>{const o=Math.floor((t-f)*d/1e3)%h.length;o===m&&!e&&c.hoverStrength<=0&&"none"===c.animationStyle&&!c.charsetFrames?.length||(_(l,h[o],c,n.width,n.height,(t-f)/1e3,e),m=o)},{continuous:!0,interactive:c.hoverStrength>0}).stop},exports.asciifyLiveVideo=function(t,e,n){return gt(t,e,n)},exports.asciifyText=bt,exports.asciifyVideo=gt,exports.asciifyWebcam=async function(t,{fontSize:n=10,style:o="classic",options:r={},liveOptions:i,mirror:a=!0,constraints:s={facingMode:"user"},dpr:c}={}){if(!navigator.mediaDevices?.getUserMedia)throw new Error("asciifyWebcam: getUserMedia is not supported in this browser.");const l=X(o),h=await navigator.mediaDevices.getUserMedia({video:s}),d=document.createElement("video");d.srcObject=h,d.muted=!0,d.playsInline=!0,await new Promise((t,e)=>{d.onloadedmetadata=()=>t(),d.onerror=()=>e(new Error("asciifyWebcam: video stream failed to load.")),d.play().catch(e)});const f={...e,...l,...r,fontSize:n},m=t.getContext("2d");if(!m)throw new Error("asciifyWebcam: could not get 2d context from canvas.");const u=c??("undefined"!=typeof window?window.devicePixelRatio:1)??1;1!==u&&m.scale(u,u);let g=null;const p=e=>{const n=t.getBoundingClientRect();g={x:(e.clientX-n.left)/n.width,y:(e.clientY-n.top)/n.height}},M=()=>{g=null};f.hoverStrength>0&&(t.addEventListener("mousemove",p),t.addEventListener("mouseleave",M));let v,w=!1;const x=performance.now(),y=e=>{if(!w){if(d.readyState>=d.HAVE_CURRENT_DATA){const n=t.width/u,o=t.height/u,r=(e-x)/1e3,s=i?{...f,...i()}:f;s.hoverStrength>0?(t.addEventListener("mousemove",p),t.addEventListener("mouseleave",M)):(t.removeEventListener("mousemove",p),t.removeEventListener("mouseleave",M));const{frame:c}=O(d,s,n,o),l=g&&a?{x:1-g.x,y:g.y}:g;a?(m.save(),m.scale(-1,1),m.translate(-n,0),_(m,c,s,n,o,r,l),m.restore()):_(m,c,s,n,o,r,l)}v=requestAnimationFrame(y)}};return v=requestAnimationFrame(y),()=>{w=!0,cancelAnimationFrame(v),t.removeEventListener("mousemove",p),t.removeEventListener("mouseleave",M),h.getTracks().forEach(t=>t.stop()),d.srcObject=null}},exports.buildTextFrame=pt,exports.captureSnapshot=vt,exports.clearAsciifyCaches=function(){C.clear(),A.clear(),N=new WeakMap,Y=new WeakMap,K=new WeakMap,S=null,E=null},exports.computeCanvasRenderSize=ft,exports.createVideoScrollScrub=rt,exports.gifToAsciiFrames=U,exports.gifToAsciiTextFrames=async function(t,e,n,o,r){const{parseGIF:i,decompressFrames:a}=await import("gifuct-js"),s=i(t),c=a(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,d=s.lsd?.width||l,f=s.lsd?.height||h,m=document.createElement("canvas");m.width=d,m.height=f;const u=m.getContext("2d"),g=document.createElement("canvas");g.width=d,g.height=f;const p=g.getContext("2d"),M=document.createElement("canvas"),v=M.getContext("2d"),w=[];let x=0,y=0,b=0;for(const t of c)b+=t.delay||100;const S=b/c.length,E=Math.round(Math.min(30,Math.max(5,1e3/S))),T=Math.min(c.length,300);for(let t=0;t<T;t++){const i=c[t],{dims:a,patch:s,disposalType:l}=i;3===l&&(p.clearRect(0,0,d,f),p.drawImage(m,0,0)),M.width!==a.width&&(M.width=a.width),M.height!==a.height&&(M.height=a.height);const h=new ImageData(new Uint8ClampedArray(s.buffer),a.width,a.height);v.putImageData(h,0,0),u.drawImage(M,a.left||0,a.top||0);const b=V(m,e,n,o);w.push(b),x=b.cols,y=b.rowCount,2===l?u.clearRect(a.left||0,a.top||0,a.width,a.height):3===l&&(u.clearRect(0,0,d,f),u.drawImage(g,0,0)),r?.((t+1)/T)}return{frames:w,cols:x,rows:y,fps:E}},exports.imageToAsciiFrame=O,exports.imageToAsciiTextFrame=V,exports.renderFrameToCanvas=_,exports.renderTextBackground=function(t,n,o,r,i={},a){const{fontSize:s=10,lineHeight:c=1.6,color:l="#505050",opacity:h=100,hoverEffect:d="spotlight",hoverStrength:f=.85,hoverRadius:m=.18,hoverColor:u="#d4ff00"}=i,g=Math.max(1,Math.floor(n/s)),p=Math.max(1,Math.floor(o/(s*c))),M=JSON.stringify([r,g,p,l,h]);let v=Mt.get(t);v&&v.key===M||(v={key:M,frame:pt(r,g,p,l,h)},Mt.set(t,v)),_(t,v.frame,{...e,fontSize:s,hoverEffect:d,hoverStrength:f,hoverRadius:m,hoverColor:u},n,o,0,a??null)},exports.renderTextFrameToCanvas=q,exports.renderTextToCanvas=function(t,e,n={}){const{color:o="#d4ff00",bgColor:r,fontSize:i=10}=n,a=bt(e,n);if(!a)return;const s=a.split("\n"),c=Math.max(...s.map(t=>[...t].length));t.width=Math.ceil(c*i*.6),t.height=Math.ceil(s.length*i);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=`${i}px monospace`,l.textBaseline="top",s.forEach((t,e)=>l.fillText(t,0,e*i))},exports.snapshotAndDownload=async function(t,e={}){const{filename:n="asciify-snapshot",format:o="png",...r}=e,i=await vt(t,{format:o,...r}),a="jpeg"===o?"jpg":o,s=document.createElement("a");s.href=URL.createObjectURL(i),s.download=`${n}.${a}`,s.click(),setTimeout(()=>URL.revokeObjectURL(s.href),1e4)},exports.videoToAsciiFrames=D,exports.videoToAsciiTextFrames=B;//# sourceMappingURL=index.cjs.map
package/dist/index.d.cts CHANGED
@@ -1,3 +1,4 @@
1
- export { A as ART_STYLE_PRESETS, a as AnimationStyle, b as ArtStyle, c as AsciiCell, d as AsciiFrame, e as AsciiOptions, f as AsciiResult, C as CHARSETS, g as CHARSET_SEQUENCES, h as CharsetKey, i as CharsetSequenceKey, j as ColorMode, D as DEFAULT_OPTIONS, H as HOVER_PRESETS, k as HoverEffect, l as HoverPreset, m as HoverShape, L as LIVING_STYLE_PRESETS, n as LivingStylePresetKey, P as PALETTE_THEMES, o as PaletteTheme, R as RenderMode, S as SourceType } from './types-DQNGBw86.cjs';
1
+ export { c as AnimationStyle, b as ArtStyle, d as AsciiCell, A as AsciiFrame, a as AsciiOptions, e as AsciiResult, C as ColorMode, D as DEFAULT_OPTIONS, f as HOVER_PRESETS, H as HoverEffect, g as HoverPreset, h as HoverShape, P as PALETTE_THEMES, i as PaletteTheme, R as RenderMode, S as SourceType } from './types-BeXEm4UY.cjs';
2
2
  export { AsciiTextFrame, AsciifyLiveVideoOptions, AsciifySimpleOptions, AsciifyVideoOptions, BigTextOptions, CanvasBleed, CanvasObjectFit, CanvasRenderSizeInput, SnapshotOptions, TextBackgroundOptions, VideoScrollScrubOptions, WebcamOptions, asciiText, asciiTextAnsi, asciify, asciifyGif, asciifyLiveVideo, asciifyText, asciifyVideo, asciifyWebcam, buildTextFrame, captureSnapshot, clearAsciifyCaches, computeCanvasRenderSize, createVideoScrollScrub, gifToAsciiFrames, gifToAsciiTextFrames, imageToAsciiFrame, imageToAsciiTextFrame, renderFrameToCanvas, renderTextBackground, renderTextFrameToCanvas, renderTextToCanvas, snapshotAndDownload, videoToAsciiFrames, videoToAsciiTextFrames } from './core.cjs';
3
- export { AsciiBackgroundOptions, AuroraBackgroundOptions, BACKGROUND_TYPES, BackgroundType, CircuitBackgroundOptions, DnaBackgroundOptions, FireBackgroundOptions, GridBackgroundOptions, MorphBackgroundOptions, MountWaveOptions, NoiseBackgroundOptions, PulseBackgroundOptions, RainBackgroundOptions, SilkBackgroundOptions, StarsBackgroundOptions, TerrainBackgroundOptions, VoidBackgroundOptions, WaveBackgroundOptions, asciiBackground, mountWaveBackground, renderAuroraBackground, renderCircuitBackground, renderDnaBackground, renderFireBackground, renderGridBackground, renderMorphBackground, renderNoiseBackground, renderPulseBackground, renderRainBackground, renderSilkBackground, renderStarsBackground, renderTerrainBackground, renderVoidBackground, renderWaveBackground } from './backgrounds.cjs';
3
+ export { C as CHARACTER_SETS, f as STUDIO_STYLES, i as StudioStyle } from './model-aIWlIoDT.cjs';
4
+ import './ambient-motion-CqF5-eZ2.cjs';
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- export { A as ART_STYLE_PRESETS, a as AnimationStyle, b as ArtStyle, c as AsciiCell, d as AsciiFrame, e as AsciiOptions, f as AsciiResult, C as CHARSETS, g as CHARSET_SEQUENCES, h as CharsetKey, i as CharsetSequenceKey, j as ColorMode, D as DEFAULT_OPTIONS, H as HOVER_PRESETS, k as HoverEffect, l as HoverPreset, m as HoverShape, L as LIVING_STYLE_PRESETS, n as LivingStylePresetKey, P as PALETTE_THEMES, o as PaletteTheme, R as RenderMode, S as SourceType } from './types-DQNGBw86.js';
1
+ export { c as AnimationStyle, b as ArtStyle, d as AsciiCell, A as AsciiFrame, a as AsciiOptions, e as AsciiResult, C as ColorMode, D as DEFAULT_OPTIONS, f as HOVER_PRESETS, H as HoverEffect, g as HoverPreset, h as HoverShape, P as PALETTE_THEMES, i as PaletteTheme, R as RenderMode, S as SourceType } from './types-BeXEm4UY.js';
2
2
  export { AsciiTextFrame, AsciifyLiveVideoOptions, AsciifySimpleOptions, AsciifyVideoOptions, BigTextOptions, CanvasBleed, CanvasObjectFit, CanvasRenderSizeInput, SnapshotOptions, TextBackgroundOptions, VideoScrollScrubOptions, WebcamOptions, asciiText, asciiTextAnsi, asciify, asciifyGif, asciifyLiveVideo, asciifyText, asciifyVideo, asciifyWebcam, buildTextFrame, captureSnapshot, clearAsciifyCaches, computeCanvasRenderSize, createVideoScrollScrub, gifToAsciiFrames, gifToAsciiTextFrames, imageToAsciiFrame, imageToAsciiTextFrame, renderFrameToCanvas, renderTextBackground, renderTextFrameToCanvas, renderTextToCanvas, snapshotAndDownload, videoToAsciiFrames, videoToAsciiTextFrames } from './core.js';
3
- export { AsciiBackgroundOptions, AuroraBackgroundOptions, BACKGROUND_TYPES, BackgroundType, CircuitBackgroundOptions, DnaBackgroundOptions, FireBackgroundOptions, GridBackgroundOptions, MorphBackgroundOptions, MountWaveOptions, NoiseBackgroundOptions, PulseBackgroundOptions, RainBackgroundOptions, SilkBackgroundOptions, StarsBackgroundOptions, TerrainBackgroundOptions, VoidBackgroundOptions, WaveBackgroundOptions, asciiBackground, mountWaveBackground, renderAuroraBackground, renderCircuitBackground, renderDnaBackground, renderFireBackground, renderGridBackground, renderMorphBackground, renderNoiseBackground, renderPulseBackground, renderRainBackground, renderSilkBackground, renderStarsBackground, renderTerrainBackground, renderVoidBackground, renderWaveBackground } from './backgrounds.js';
3
+ export { C as CHARACTER_SETS, f as STUDIO_STYLES, i as StudioStyle } from './model-BJXd0Jl-.js';
4
+ import './ambient-motion-CqF5-eZ2.js';