asciify-engine 1.3.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -487,6 +487,32 @@ MIT © [asciify.org](https://asciify.org)
487
487
  > ☕ [Buy me a coffee](https://www.buymeacoffee.com/asciify) — if this saved you time, I'd appreciate it!
488
488
 
489
489
 
490
- ## Unreleased hero finish
490
+ ## Hero finish
491
491
 
492
492
  Version 1.3.0 adds text-shaped charcoal cutouts (`textMask`), peripheral scanline/fringe control (`edgeEffect`), fixed accent ink, and velocity-driven Trail source flow. These additions ship in **npm 1.3.0**. Upgrade older applications before using them. See the [complete API, layering example, lifecycle, and fallback limits](skills/asciify-engine/references/hero-finish.md).
493
+
494
+ ## Studio composition tools
495
+
496
+ The `asciify-engine/studio` entry adds a reusable composition pipeline: alternate render styles, palette dithering, crop and masks, source/blurred/gradient backdrops, combined optical effects, saved looks, text fonts, and PNG/JPG/GIF/MP4/WebM export. Existing ASCII defaults and `/core` and `/hover` imports stay unchanged. Fonts and video encoders load on demand.
497
+
498
+ ```ts
499
+ import { mountStudio } from 'asciify-engine/studio';
500
+
501
+ const studio = await mountStudio(canvas, '/your-video.mp4', {
502
+ settings: {
503
+ style: 'ascii',
504
+ backdrop: { mode: 'blurred', opacity: 0.4 },
505
+ },
506
+ });
507
+ studio.update({ hover: { effect: 'water', radius: 0.35 } });
508
+ // On unmount:
509
+ studio.destroy();
510
+ ```
511
+
512
+ See the [Studio API guide](skills/asciify-engine/references/studio-workspace.md) for complete settings, import/export, media ownership, browser requirements, and performance budgets.
513
+
514
+ ## Version 2.0 migration
515
+
516
+ Emoji, Musical and Starfield preset keys have been removed from `CHARSETS`, `ArtStyle` and `ART_STYLE_PRESETS`. Use `classic` with an application-owned `charset` to retain a custom alphabet, or choose structural presets such as braille/circles/geometric. General Unicode support remains. Cosmic and angular character sequences now use structural marks. Existing core rendering and hover APIs remain modular.
517
+
518
+ `STUDIO_CHARACTER_SETS` from `asciify-engine/studio` provides named ramps with `{ label, chars }`; assign `chars` to Studio `charset` with `style: 'ascii'`. The website's new default workspace is [/editor](https://asciify.org/editor); earlier workflows remain in [/editor/classic](https://asciify.org/editor/classic).
package/THIRD_PARTY.md ADDED
@@ -0,0 +1,14 @@
1
+ # Third-party components
2
+
3
+ Asciify's own code is MIT licensed. Dependencies keep their own licenses.
4
+
5
+ | Component | Version used for this release | License | Source |
6
+ | --- | --- | --- | --- |
7
+ | gifuct-js | 2.1.2 | MIT | https://github.com/matt-way/gifuct-js |
8
+ | gifenc | 1.0.3 | MIT | https://github.com/mattdesl/gifenc |
9
+ | FIGlet.js | 1.11.4 | MIT | https://github.com/patorjk/figlet.js |
10
+ | Mediabunny | 1.56.0 | MPL-2.0 | https://github.com/Vanilagy/mediabunny/tree/533c857a313b15f98af24ad916eeda27204c38ce |
11
+
12
+ Mediabunny is loaded on demand for Studio video encoding. Its source is unmodified; the corresponding source release is available at https://registry.npmjs.org/mediabunny/-/mediabunny-1.56.0.tgz. The MPL-2.0 text is included in `licenses/Mediabunny-MPL-2.0.txt`. Encoding uses browser-provided WebCodecs implementations.
13
+
14
+ Font data loads individually from FIGlet.js and retains its embedded font authorship notices. The package includes only code for selecting fonts; it does not relicense the font authors' work.
package/dist/core.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var e={standard:" .:-=+*#%@",blocks:" ░▒▓█",minimal:" .:+",dense:" .'`^\",:;Il!i><~+_-?][}{1)(|/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$",binary:"01",dots:" ⠁⠃⠇⡇⣇⣧⣷⣿",letters:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",claudeCode:" ╔╗╚╝║═╠╣╦╩╬░▒▓█│─┌┐└┘├┤┬┴┼",box:" ▪◾◼■█",lines:" ˗‐–—―━",braille:" ⠁⠂⠃⠄⠅⠆⠇⠈⠉⠊⠋⠌⠍⠎⠏⠐⠑⠒⠓⠔⠕⠖⠗⠘⠙⠚⠛⠜⠝⠞⠟⠠⠡⠢⠣⠤⠥⠦⠧⠨⠩⠪⠫⠬⠭⠮⠯⠰⠱⠲⠳⠴⠵⠶⠷⠸⠹⠺⠻⠼⠽⠾⠿⡀⡁⡂⡃⡄⡅⡆⡇⣀⣁⣂⣃⣄⣅⣆⣇⣈⣉⣊⣋⣌⣍⣎⣏⣐⣑⣒⣓⣔⣕⣖⣗⣘⣙⣚⣛⣜⣝⣞⣟⣠⣡⣢⣣⣤⣥⣦⣧⣨⣩⣪⣫⣬⣭⣮⣯⣰⣱⣲⣳⣴⣵⣶⣷⣸⣹⣺⣻⣼⣽⣾⣿",katakana:" ヲァィゥェォャュョッアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン",musical:" ♩♪♫♬♭♮♯",emoji:" ⬛🟫🟥🟧🟨🟩🟦🟪⬜",circles:" .·:∘○◦°•∙",shadows:" ·∘◦○◎⊙●◉",starfield:" ˙·∘∗✦✧★◆●",geometric:" ·△▷◇◈◆▣■█",pipes:" ╶─┐└├┤┬┴┼╬▒▓█",waves:" ˜∼≈〰≋∿∾∭∫",shards:" ╱╲╳◤◥◣◢△▲◆◼█",smoke:" ·˙⁚⁖∶∷⋮⋰⋱∴∵",ascii:" .'`^\",:;~-_+<>i!lI?/\\|()[]{}1tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$",interface:" ·•-–—+=:;<>[]{}()⌘⌥⇧⌃↵↗↘◇◆◈□■",prompt:" .:;>_`/\\|{}[]()=+*#@$",data:" ·∙•◦○●◇◆◈▱▰▣█",humanist:" ·˙,:;∴∵∷∶⁚⋮⋯∼≈≋∞",mesh:" ·╶╴╷╵─│┌┐└┘├┤┬┴┼╬░▒▓█"},t={cosmic:[e.starfield,e.circles,e.shadows],rain:[e.katakana,e.braille,e.binary],terminal:[e.pipes,e.claudeCode,e.standard],crystal:[e.shards,e.geometric,e.blocks],fluid:[e.waves,e.smoke,e.circles],pulse:[e.dense,e.standard,e.blocks],dream:[e.braille,e.shadows,e.smoke],angular:[e.geometric,e.shards,e.starfield],assistant:[e.interface,e.prompt,e.data],signal:[e.mesh,e.data,e.ascii],editorial:[e.humanist,e.waves,e.smoke]},n={classic:{renderMode:"ascii",charset:e.standard,colorMode:"grayscale"},particles:{renderMode:"dots",colorMode:"fullcolor",dotSizeRatio:.8},letters:{renderMode:"ascii",charset:e.letters,colorMode:"fullcolor"},claudeCode:{renderMode:"ascii",charset:e.claudeCode,colorMode:"accent",accentColor:"#f97316"},art:{renderMode:"ascii",charset:e.dense,colorMode:"fullcolor"},terminal:{renderMode:"ascii",charset:e.standard,colorMode:"matrix"},box:{renderMode:"ascii",charset:e.box,colorMode:"grayscale"},lines:{renderMode:"ascii",charset:e.lines,colorMode:"fullcolor"},braille:{renderMode:"ascii",charset:e.braille,colorMode:"fullcolor"},katakana:{renderMode:"ascii",charset:e.katakana,colorMode:"matrix"},musical:{renderMode:"ascii",charset:e.musical,colorMode:"accent",accentColor:"#e040fb"},emoji:{renderMode:"ascii",charset:e.emoji,colorMode:"fullcolor"},circles:{renderMode:"ascii",charset:e.circles,colorMode:"accent",accentColor:"#d4ff00"},shadows:{renderMode:"ascii",charset:e.shadows,colorMode:"accent",accentColor:"#50a0ff"},starfield:{renderMode:"ascii",charset:e.starfield,colorMode:"fullcolor"},geometric:{renderMode:"ascii",charset:e.geometric,colorMode:"grayscale"},pipes:{renderMode:"ascii",charset:e.pipes,colorMode:"accent",accentColor:"#00ff88"},waves:{renderMode:"ascii",charset:e.waves,colorMode:"fullcolor"},shards:{renderMode:"ascii",charset:e.shards,colorMode:"grayscale"},smoke:{renderMode:"ascii",charset:e.smoke,colorMode:"accent",accentColor:"#c850ff"},ascii:{renderMode:"ascii",charset:e.ascii,colorMode:"grayscale"},interface:{renderMode:"ascii",charset:e.interface,colorMode:"accent",accentColor:"#f4f1ea"},prompt:{renderMode:"ascii",charset:e.prompt,colorMode:"matrix"},data:{renderMode:"ascii",charset:e.data,colorMode:"fullcolor"},humanist:{renderMode:"ascii",charset:e.humanist,colorMode:"accent",accentColor:"#d6ccc2"},mesh:{renderMode:"ascii",charset:e.mesh,colorMode:"accent",accentColor:"#8fd3ff"}},o={agentField:{...n.interface,charsetFrames:t.assistant,charsetFps:1.6,animationStyle:"breathe",animationSpeed:.75,ditherStrength:.12,hoverEffect:"glow",hoverStrength:.42,hoverRadius:.18,hoverColor:"#f4f1ea",normalize:!0},liquidSignal:{...n.data,charsetFrames:t.signal,charsetFps:2.4,animationStyle:"melt",animationSpeed:.65,ditherStrength:.45,hoverEffect:"repel",hoverStrength:.55,hoverRadius:.22,hoverColor:"#8fd3ff",normalize:!0},cursorGravity:{...n.mesh,charsetFrames:t.angular,charsetFps:1.2,animationStyle:"orbit",animationSpeed:.9,ditherStrength:.2,hoverEffect:"attract",hoverStrength:.82,hoverRadius:.24,hoverColor:"#ffffff",normalize:!0},editorialPulse:{...n.humanist,charsetFrames:t.editorial,charsetFps:.9,animationStyle:"ripple",animationSpeed:.55,ditherStrength:.18,hoverEffect:"spotlight",hoverStrength:.35,hoverRadius:.2,hoverColor:"#fff8ea",normalize:!0},terminalFlow:{...n.prompt,charsetFrames:t.terminal,charsetFps:3,animationStyle:"rain",animationSpeed:1.1,ditherStrength:.22,hoverEffect:"glitchText",hoverStrength:.65,hoverRadius:.16,hoverColor:"#d4ff00",hoverText:["BUILD","SHIP","RUN","ASK","MODEL"],normalize:!0}},r={fontSize:7,charSpacing:1,brightness:0,contrast:0,charset:e.standard,colorMode:"grayscale",accentColor:"#d4ff00",invert:!1,renderMode:"ascii",animationStyle:"none",animationSpeed:1,dotSizeRatio:.8,ditherStrength:0,charAspect:.55,normalize:!1,hoverStrength:0,hoverRadius:.2,hoverEffect:"spotlight",hoverColor:"#ffffff",hoverShape:"circle",hoverText:"ASCIIFY",artStyle:"classic",customText:"",chromaKey:null,chromaKeyTolerance:60,chromaKeyTrimPadding:.002,chromaKeyTrimLuminanceThreshold:0,chromaKeyTrimMode:"range"};function a(e,t){const n=document.createElement("canvas");n.width=e,n.height=t;const o=n.getContext("2d",{willReadFrequently:!0});return{canvas:n,ctx:o}}function i(e,t,n){let o=e+255*t;return o=259*(255*n+255)/(255*(259-255*n))*(o-128)+128,Math.max(0,Math.min(255,o))}function s(e,t,n,o,r,a){if((a?1-e/255:e/255)<.12)return" ";const i=[...t];return i[(o*r+n)%i.length]}var c=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];function l(e,t,n,o){if(o<=0)return e;const r=(c[n%4][t%4]/16-.5)*o*128;return Math.max(0,Math.min(255,e+r))}var h=new Array(256),d=new Array(256);for(let e=0;e<256;e++)h[e]=`rgb(${e},${e},${e})`,d[e]=`rgb(0,${e},0)`;function f(e,t,n,o,r,a=!1){switch(t){case"fullcolor":return`rgb(${e.r},${e.g},${e.b})`;case"matrix":return d[.299*e.r+.587*e.g+.114*e.b|0];case"accent":return`rgb(${n},${o},${r})`;default:{const t=.299*e.r+.587*e.g+.114*e.b|0;return h[t]}}}var m=[0,0,0];function u(e,t,n,o,r,a=!1){switch(t){case"fullcolor":m[0]=e.r,m[1]=e.g,m[2]=e.b;break;case"matrix":{const t=.299*e.r+.587*e.g+.114*e.b|0;m[0]=0,m[1]=t,m[2]=0;break}case"accent":m[0]=n,m[1]=o,m[2]=r;break;default:{const t=.299*e.r+.587*e.g+.114*e.b|0;m[0]=t,m[1]=t,m[2]=t;break}}return m}function g(e){const t=e.match(/rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)(?:\s*[,/]\s*([\d.]+))?\s*\)/);return t?{r:+t[1],g:+t[2],b:+t[3],a:void 0!==t[4]?+t[4]:1}:null}function M(e){let t=e;for(;t&&t!==document.documentElement.parentElement;){const e=getComputedStyle(t).backgroundColor;if(e&&"transparent"!==e&&"rgba(0, 0, 0, 0)"!==e){const t=g(e);if(t&&t.a>.1)return t}t=t.parentElement}return null}function p(e){if(e){const t=M(e);if(t){return(.299*t.r+.587*t.g+.114*t.b)/255<.4}}if("undefined"!=typeof document){const e=document.documentElement,t=(e.getAttribute("data-theme")||"").toLowerCase();if("dark"===t)return!0;if("light"===t)return!1;if(e.classList.contains("dark"))return!0;if(document.body){const e=M(document.body);if(e){return(.299*e.r+.587*e.g+.114*e.b)/255<.4}}}return"undefined"!=typeof window&&window.matchMedia("(prefers-color-scheme: dark)").matches}function v(e){if("string"!=typeof e)return e;const t=document.createElement("canvas");t.width=1,t.height=1;const n=t.getContext("2d");n.fillStyle=e,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(e){return e*e*(3-2*e)}function x(e,t,n,o,r,a,i){if("none"===a)return 1;const s=r*i;switch(a){case"wave":return.3+.7*(.6*(.5*Math.sin(e/n*Math.PI*4+3*s)+.5)+.4*(.5*Math.sin(t/o*Math.PI*3+2*s)+.5));case"pulse":{const r=n/2,a=o/2,i=Math.sqrt((e-r)**2+(t-a)**2),c=Math.sqrt(r**2+a**2);return.2+.8*(.5*Math.sin(i/c*Math.PI*6-4*s)+.5)}case"rain":return.1+.9*(.5*Math.sin(t/o*Math.PI*8-5*s+.3*e)+.5)*(.3*Math.sin(e/n*Math.PI*2+s)+.7);case"breathe":{const n=.3*Math.sin(2*s)+.7,o=.1*Math.sin(.1*(e+t)+s);return Math.max(.1,Math.min(1,n+o))}case"sparkle":{const n=43758.5453*Math.sin(127.1*e+311.7*t+43758.5453*Math.floor(8*s)),o=n-Math.floor(n);return o>.7?1:.15+.4*o}case"glitch":{const e=Math.floor(t/(.05*o)),n=43758.5453*Math.sin(43.23*e+17.89*Math.floor(6*s));if(n-Math.floor(n)>.85){const t=.5*Math.sin(30*s+e)+.5;return t<.3?0:t}return 1}case"spiral":{const r=n/2,a=o/2,i=e-r,c=t-a,l=Math.atan2(c,i),h=Math.sqrt(i*i+c*c),d=Math.sqrt(r*r+a*a);return.15+.85*(.5*Math.sin(3*l+h/d*Math.PI*8-3*s)+.5)}case"typewriter":{const r=n*o,a=t*n+e-.5*s%1*r*1.3;if(a>0)return 0;const i=Math.max(0,1+a/(.15*r));return Math.min(1,i)}case"scatter":{const r=n/2,a=o/2,i=e-r,c=t-a,l=Math.sqrt(i*i+c*c)/Math.sqrt(r*r+a*a),h=.5*Math.sin(1.5*s)+.5;return l>h?Math.max(0,1-3*(l-h)):.7+.3*Math.sin(10*l-2*s)}case"waveField":return.55+.45*Math.sin(e/n*9+2*Math.sin(t/o*6-s)+1.5*s);case"ripple":{const r=n/2,a=o/2,i=e-r,c=t-a,l=Math.sqrt(i*i+c*c),h=Math.sqrt(r*r+a*a);return.1+.9*(.5*Math.sin(l/h*Math.PI*10-5*s)+.5)*(.4+.6*(1-Math.min(1,l/(1.1*h))))}case"melt":{const n=t/o*Math.PI;return.05+(.5*Math.sin(n-1.8*s+.15*e)+.5)*(1-.6*(Math.max(0,t/o-.1)/.9))*.95}case"orbit":{const r=n/2,a=o/2,i=e-r,c=t-a,l=Math.atan2(c,i),h=Math.sqrt(i*i+c*c)/Math.sqrt(r*r+a*a);return.1+.9*(.5*Math.sin(2*l+6*h-2.5*s)+.5)}case"cellular":{const n=Math.floor(4*s),o=(e,t)=>{const o=43758.5453*Math.sin(127.1*e+311.7*t+43758.5453*n);return o-Math.floor(o)>.38?1:0},r=o(e,t),a=o(e-1,t)+o(e+1,t)+o(e,t-1)+o(e,t+1)+o(e-1,t-1)+o(e+1,t-1)+o(e-1,t+1)+o(e+1,t+1);return 1===(1===r?2===a||3===a?1:0:3===a?1:0)?1:.05}default:return 1}}var y={scale:1,offsetX:0,offsetY:0,glow:0,colorBlend:0,proximity:0};function b(e,t,n,o,r,a,i,s,c="spotlight",l=.5,h="circle",d=[],f=1){const m=(e-n)*Math.max(1,f),u=(t-o)*Math.max(1,1/f),g=.08+.35*l+.04*a;let M,p;if("box"===h){const e=Math.abs(m),t=Math.abs(u);M=Math.max(e,t),p=g}else M=Math.sqrt(m*m+u*u),p=g;if(M>=p&&("trail"!==c||0===d.length))return y.scale=1,y.offsetX=0,y.offsetY=0,y.glow=0,y.colorBlend=0,y.proximity=0,y;const v=w(Math.max(0,1-M/p))*r;let x=1,b=0,S=0,E=0,C=0;switch(c){case"spotlight":{x=1+v*a*1.8;const e=Math.atan2(u,m),t=v*v*a*.6;b=Math.cos(e)*t*i,S=Math.sin(e)*t*s,E=v*a*.4,C=v*v*a*.25;break}case"magnify":x=1+v*a*.85,E=v*a*.15;break;case"repel":{x=1;const e=Math.atan2(u,m),t=v*v*a*1.8;b=Math.cos(e)*t*i,S=Math.sin(e)*t*s;break}case"glow":E=v*a*.8,C=v*a*.4;break;case"colorShift":x=1,E=v*a*.12,C=v*a;break;case"attract":{const e=Math.atan2(u,m),t=v*v*a*1;b=(.45*-Math.cos(e)-1.6*Math.sin(e))*t*i,S=(.45*-Math.sin(e)+1.6*Math.cos(e))*t*s,E=v*a*.3;break}case"shatter":{const e=Math.atan2(u,m),t=.5*Math.sin(43.7*m+29.3*u),n=v*a*1.4*(.7+.3*t);b=Math.cos(e+t)*n*i,S=Math.sin(e+t)*n*s,x=Math.max(.1,1-v*a*.6),E=v*a*.25;break}case"trail":{let n=v,o=-u*v,r=m*v;for(const a of d){const i=(e-a.x)*Math.max(1,f),s=(t-a.y)*Math.max(1,1/f),c=Math.hypot(i,s)/g;if(c>=1)continue;const l=w(1-c)*a.intensity;n=Math.max(n,l),o+=(.35*a.vx-2*s)*l*.35,r+=(.35*a.vy+2*i)*l*.35}b=Math.tanh(2*o)*a*i*3,S=Math.tanh(2*r)*a*s*3,C=n*a*.65,E=n*a*.35,x=1+n*a*.08,y.proximity=n;break}case"glitchText":x=1,E=v*a*.5,C=v*a*.6}return y.scale=x,y.offsetX=b,y.offsetY=S,y.glow=E,y.colorBlend=C,"trail"!==c&&(y.proximity=v),y}function S(e,t,{continuous:n=!1,interactive:o=!1}={}){const r=e.parentElement??e;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=e=>{if(i=0,s||!c||document.hidden)return;const o=!d.matches&&(n||e-h<1500);(l||o)&&(t(e,d.matches?null:a),l=!1),o&&(i=requestAnimationFrame(m))},u=t=>{if("touch"===t.pointerType)return;const n=e.getBoundingClientRect();if(!n.width||!n.height)return;const o=(t.clientX-n.left)/n.width,r=(t.clientY-n.top)/n.height;a=o>=0&&o<=1&&r>=0&&r<=1?{x:o,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(([e])=>{c=e.isIntersecting,c?f():i&&(cancelAnimationFrame(i),i=0)});return p?.observe(e),o&&(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 E=null,C=null;function T(e,t){if(!E||!C){const n=a(e,t);E=n.canvas,C=n.ctx}return E.width!==e&&(E.width=e),E.height!==t&&(E.height=t),C}var F=new Map,A=new Map,R=new WeakMap;function k(e){const t=Intl.Segmenter;return t?Array.from(new t(void 0,{granularity:"grapheme"}).segment(e),({segment:e})=>e):[...e]}function I(e){let t=F.get(e);return t||(t=k(e),F.set(e,t)),t}function L(e){return k(e)}function H(e,t,n){const o=n?1-e/255:e/255,r=Math.floor(o*(t.length-1));return t[Math.max(0,Math.min(t.length-1,r))]??" "}function P(e,t,n,o){const r=`${e}\0${t?1:0}\0${n}\0${o}`;let a=A.get(r);if(!a){const s=I(e);a=new Array(256);for(let e=0;e<256;e++)a[e]=H(i(e,n,o),s,t);A.set(r,a)}return a}function W(e,t){return"auto"!==e?e:!p(t)}function $(e){const t=e.match(/^#([0-9a-fA-F]{3,6})$/);if(t){let e=t[1];if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return e}const n=e.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);return n?[n[1],n[2],n[3]].map(e=>parseInt(e).toString(16).padStart(2,"0")).join(""):null}function j(e){const t=e||"auto";if("auto"!==t)return $(t)??"ffffff";if("undefined"!=typeof document){const e=getComputedStyle(document.documentElement);for(const t of["--accent-color","--color-accent","--accent","--color-primary","--primary","--brand-color"]){const n=$(e.getPropertyValue(t).trim());if(n)return n}const t=$(getComputedStyle(document.body).accentColor??"");if(t)return t}return p("undefined"!=typeof document?document.body:null)?"faf9f7":"0d0d0d"}function z(e,t,n){return Math.max(t,Math.min(n,e))}function O(e,t,n){if(!e)return{x:0,y:0,width:t,height:n};const o=e.unit??"percent",r=!1!==e.preserveAspect,a=e=>void 0===e?void 0:"percent"===o?e*t:e,i=e=>void 0===e?void 0:"percent"===o?e*n:e,s=z(a(e.left)??0,0,t-1),c=z(a(e.right)??0,0,t-s-1),l=z(i(e.top)??0,0,n-1),h=z(i(e.bottom)??0,0,n-l-1),d=void 0!==e.left||void 0!==e.right||void 0!==e.top||void 0!==e.bottom,f=Math.max(1,t-s-c),m=Math.max(1,n-l-h),u=d?f:a(e.width),g=d?m:i(e.height);let M=u??t,p=g??n;if(r&&!d){const e=M/t,o=p/n,r=Math.min(e,o),a=void 0===u?o:void 0===g?e:r;M=t*a,p=n*a}M=z(M,1,d?f:t),p=z(p,1,d?m:n);const v=e.anchor??"center",w=a(e.x),x=i(e.y),y=d?s:0,b=d?l:0,S=d?f:t,E=d?m:n,C=v.endsWith("left")||"left"===v?0:v.endsWith("right")||"right"===v?S-M:(S-M)/2,T=v.startsWith("top")||"top"===v?0:v.startsWith("bottom")||"bottom"===v?E-p:(E-p)/2;return{x:z(w??y+C,0,Math.max(0,t-M)),y:z(x??b+T,0,Math.max(0,n-p)),width:M,height:p}}function q(e,t,n,o){const r=e instanceof HTMLVideoElement?e.videoWidth:e.width,a=e instanceof HTMLVideoElement?e.videoHeight:e.height;if(0===r||0===a)return{frame:[],cols:0,rows:0};const c=t.charAspect,h=t.fontSize*t.charSpacing,d=t.fontSize/c*t.charSpacing,f=n||r,m=o||a,u=Math.floor(f/h),g=Math.floor(m/d);if(u<=0||g<=0)return{frame:[],cols:0,rows:0};const M=O(t.sourceCrop,r,a),p=Math.max(1,Math.min(Math.floor(2048/u),Math.floor(M.width/u))),w=Math.max(1,Math.min(Math.floor(2048/g),Math.floor(M.height/g))),x=u*p,y=g*w,b=T(x,y),S=b.globalCompositeOperation;b.globalCompositeOperation="copy";try{b.drawImage(e,M.x,M.y,M.width,M.height,0,0,x,y)}finally{b.globalCompositeOperation=S}const E=b.getImageData(0,0,x,y).data,C=t.chromaKey,F=null!=C&&!1!==C,A=!0===C,R="blue-screen"===C;let k=null,L=0;!F||A||R||(k=v(C),L=(t.chromaKeyTolerance??60)**2);let $=0,j=255;if(t.normalize){let e=255,t=0;for(let n=0;n<E.length;n+=4){if(F){const e=E[n],t=E[n+1],o=E[n+2];let r=!1;if(A)r=t>1.4*e&&t>1.4*o&&t>80;else if(R)r=o>1.4*e&&o>1.4*t&&o>80;else if(null!==k){const n=e-k.r,a=t-k.g,i=o-k.b;r=n*n+a*a+i*i<=L}if(r)continue}const o=.299*E[n]+.587*E[n+1]+.114*E[n+2];o<e&&(e=o),o>t&&(t=o)}$=e,j=t>e?t-e:255}const z=[],q=W(t.invert),V=F&&t.charset.replace(/ /g,"")||t.charset,B=I(V),U=t.customText?null:P(V,q,t.brightness,t.contrast),N=p*w;for(let e=0;e<g;e++){const n=[];for(let o=0;o<u;o++){let r=0,a=0,c=0,h=0,d=0;for(let t=0;t<w;t++){const n=(e*w+t)*x;for(let e=0;e<p;e++){const t=4*(n+o*p+e),i=E[t],s=E[t+1],l=E[t+2],f=E[t+3];if(F){let e=!1;if(A)e=s>1.4*i&&s>1.4*l&&s>80;else if(R)e=l>1.4*i&&l>1.4*s&&l>80;else if(null!==k){const t=i-k.r,n=s-k.g,o=l-k.b;e=t*t+n*n+o*o<=L}if(e){d++;continue}}r+=i,a+=s,c+=l,h+=f}}if(F&&d>N/2){n.push({char:" ",r:0,g:0,b:0,a:0});continue}const f=N-d,m=f>0?r/f:0,g=f>0?a/f:0,M=f>0?c/f:0,v=f>0?h/f:0,y=.299*m+.587*g+.114*M,b=t.normalize?(y-$)/j*255:y,S=i(b,t.brightness,t.contrast),C=t.ditherStrength>0?l(S,o,e,t.ditherStrength):S,T=t.customText?s(C,t.customText,o,e,u,q):t.ditherStrength>0?H(C,B,q):U[Math.max(0,Math.min(255,0|b))];n.push({char:T,r:m,g:g,b:M,a:v,lum:C})}z.push(n)}return{frame:z,cols:u,rows:g}}function V(e,t,n,o){const r=e instanceof HTMLVideoElement?e.videoWidth:e.width,a=e instanceof HTMLVideoElement?e.videoHeight:e.height;if(0===r||0===a)return{rows:[],cols:0,rowCount:0};const s=t.charAspect,c=t.fontSize*t.charSpacing,h=t.fontSize/s*t.charSpacing,d=n||r,f=o||a,m=Math.floor(d/c),u=Math.floor(f/h);if(m<=0||u<=0)return{rows:[],cols:0,rowCount:0};const g=m,M=u,p=T(g,M),w=O(t.sourceCrop,r,a),x=p.globalCompositeOperation;p.globalCompositeOperation="copy";try{p.drawImage(e,w.x,w.y,w.width,w.height,0,0,g,M)}finally{p.globalCompositeOperation=x}const y=p.getImageData(0,0,g,M).data,b=t.chromaKey,S=null!=b&&!1!==b,E=!0===b,C="blue-screen"===b;let F=null,A=0;!S||E||C||(F=v(b),A=(t.chromaKeyTolerance??60)**2);let R=0,k=255;if(t.normalize){let e=255,t=0;for(let n=0;n<y.length;n+=4){if(S){const e=y[n],t=y[n+1],o=y[n+2];let r=!1;if(E)r=t>1.4*e&&t>1.4*o&&t>80;else if(C)r=o>1.4*e&&o>1.4*t&&o>80;else if(null!==F){const n=e-F.r,a=t-F.g,i=o-F.b;r=n*n+a*a+i*i<=A}if(r)continue}const o=.299*y[n]+.587*y[n+1]+.114*y[n+2];o<e&&(e=o),o>t&&(t=o)}R=e,k=t>e?t-e:255}const L=W(t.invert),$=S&&t.charset.replace(/ /g,"")||t.charset,j=I($),z=t.customText?null:P($,L,t.brightness,t.contrast),q=t.customText?I(t.customText):null,V="fullcolor"===t.colorMode?new Uint8ClampedArray(m*u*4):void 0,B=[];for(let e=0;e<u;e++){let n="";for(let o=0;o<m;o++){const r=4*(e*g+o),a=r,s=y[r],c=y[r+1],h=y[r+2],d=y[r+3];if(S){let e=!1;if(E)e=c>1.4*s&&c>1.4*h&&c>80;else if(C)e=h>1.4*s&&h>1.4*c&&h>80;else if(null!==F){const t=s-F.r,n=c-F.g,o=h-F.b;e=t*t+n*n+o*o<=A}if(e){n+=" ",V&&(V[a]=0,V[a+1]=0,V[a+2]=0,V[a+3]=0);continue}}V&&(V[a]=s,V[a+1]=c,V[a+2]=h,V[a+3]=d);const f=.299*s+.587*c+.114*h,u=t.normalize?(f-R)/k*255:f,M=t.ditherStrength>0||q?i(u,t.brightness,t.contrast):u,p=t.ditherStrength>0?l(M,o,e,t.ditherStrength):M;if(q){n+=(L?1-p/255:p/255)<.12?" ":q[(e*m+o)%q.length]}else t.ditherStrength<=0?n+=z[Math.max(0,Math.min(255,0|u))]:n+=H(p,j,L)}B.push(n)}return{rows:B,cols:m,rowCount:u,colors:V}}function B(e,t,n,o,r){if(0===t.rows.length)return;const a=e.canvas,i=Boolean(n.chromaKey)||t.rows.some(e=>e.includes(" "));i||(R.delete(e),e.clearRect(0,0,o,r),e.fillStyle=p(a)?"#0a0a0a":"#faf9f7",e.fillRect(0,0,o,r));const s=j(n.accentColor),c=parseInt(s.substring(0,2),16),l=parseInt(s.substring(2,4),16),h=parseInt(s.substring(4,6),16),d=o/t.cols,f=r/t.rowCount,m=.9*Math.min(d/.55,f),u=t.colors;if("fullcolor"===n.colorMode&&u){R.delete(e),e.clearRect(0,0,o,r),e.font=`${m}px "JetBrains Mono", monospace`,e.textAlign="left",e.textBaseline="middle",e.globalAlpha=1;let n="";for(let o=0;o<t.rows.length;o++){const r=L(t.rows[o]);let a=0;for(;a<t.cols;){for(;a<t.cols&&" "===r[a];)a++;if(a>=t.cols)break;const i=a,s=4*(o*t.cols+a),c=240&u[s],l=240&u[s+1],h=240&u[s+2];for(a++;a<t.cols&&" "!==r[a];){const e=4*(o*t.cols+a);if((240&u[e])!==c||(240&u[e+1])!==l||(240&u[e+2])!==h)break;a++}const m=`rgb(${c},${l},${h})`;m!==n&&(e.fillStyle=m,n=m),e.fillText(r.slice(i,a).join(""),i*d+.5*d,o*f+.5*f)}}return void(e.globalAlpha=1)}e.font=`${m}px "JetBrains Mono", monospace`,e.textAlign="left",e.textBaseline="middle";const g="matrix"===n.colorMode?"rgb(0,255,0)":"grayscale"===n.colorMode?p(a)?"rgb(230,230,230)":"rgb(24,24,24)":`rgb(${c},${l},${h})`;e.fillStyle=g,e.globalAlpha=1;const M=R.get(e),v=i&&M&&M.cols===t.cols&&M.rowCount===t.rowCount&&M.canvasWidth===o&&M.canvasHeight===r&&M.fillStyle===g;v||e.clearRect(0,0,o,r);for(let n=0;n<t.rows.length;n++){const r=t.rows[n];v&&M.rows[n]===r||(v&&e.clearRect(0,n*f,o,f+1),0!==r.trim().length&&e.fillText(r,.5*d,n*f+.5*f))}R.set(e,{rows:t.rows.slice(),cols:t.cols,rowCount:t.rowCount,canvasWidth:o,canvasHeight:r,fillStyle:g}),e.globalAlpha=1}async function U(e,t,n,o,r=12,a=10,i,s=0){const c=Math.min(e.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;e.currentTime=m,await new Promise(t=>{const n=()=>{e.removeEventListener("seeked",n),t()};e.addEventListener("seeked",n)});const u=q(e,t,n,o);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 N(e,t,n,o,r=12,a=10,i,s=0){const c=Math.min(e.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;e.currentTime=m,await new Promise(t=>{const n=()=>{e.removeEventListener("seeked",n),t()};e.addEventListener("seeked",n)});const u=V(e,t,n,o);h.push(u),d=u.cols,f=u.rowCount,i?.((a+1)/l)}return{frames:h,cols:d,rows:f,fps:r}}async function D(e,t,n,o,r){const{parseGIF:a,decompressFrames:i}=await import("gifuct-js"),s=a(e),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"),v=p.getContext("2d"),w=[];let x=0,y=0,b=0;for(const e of c)b+=e.delay||100;const S=b/c.length,E=Math.round(Math.min(30,Math.max(5,1e3/S))),C=Math.min(c.length,300);for(let e=0;e<C;e++){const a=c[e],{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);v.putImageData(h,0,0),u.drawImage(p,i.left||0,i.top||0);const b=q(m,t,n,o);w.push(b.frame),x=b.cols,y=b.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?.((e+1)/C)}return{frames:w,cols:x,rows:y,fps:E}}var K=new WeakMap,Y=new WeakMap,_=new WeakMap;function G(e,t,n,o,r,a=0,i){if(!t.length||!t[0].length||o<=0||r<=0)return;let s=null;if(n.hoverStrength>0){let t=K.get(e);t||(t={x:.5,y:.5,intensity:0,time:-1,emittedAt:-1,points:[]},K.set(e,t)),s=function(e,t,n){const o=e.time<0?1/60:Math.max(0,Math.min(.1,(n-e.time)/1e3));e.time=n;const r=e.intensity<.003,a=e.x,i=e.y;if(t){r&&(e.x=t.x,e.y=t.y);const n=1-Math.exp(-o/.055);e.x+=(t.x-e.x)*n,e.y+=(t.y-e.y)*n}e.intensity+=((t?.intensity??(t?1:0))-e.intensity)*(1-Math.exp(-o/(t?.09:.18)));const s=Math.exp(-o/.22);for(const t of e.points)t.intensity*=s;for(;e.points.length&&e.points[0].intensity<.01;)e.points.shift();return t&&!r&&n-e.emittedAt>=24&&Math.hypot(e.x-a,e.y-i)>5e-4&&(e.points.push({x:e.x,y:e.y,intensity:e.intensity,vx:Math.max(-1,Math.min(1,(e.x-a)/Math.max(o,.001))),vy:Math.max(-1,Math.min(1,(e.y-i)/Math.max(o,.001)))}),e.points.length>12&&e.points.shift(),e.emittedAt=n),!t&&e.intensity<.003&&!e.points.length?(e.intensity=0,null):{x:e.x,y:e.y,intensity:e.intensity,trail:e.points}}(t,i??null,performance.now())}else K.delete(e);if("none"!==n.animationStyle||n.charsetFrames?.length||n.hoverStrength<=0)return _.delete(e),void X(e,t,n,o,r,a,s);const c=Y.get(e);if(c?.frame!==t)return Y.set(e,{frame:t,since:performance.now()}),_.delete(e),void X(e,t,n,o,r,a,s);if(performance.now()-c.since<100)return void X(e,t,n,o,r,a,s);const l=e.getTransform();if(l.b||l.c||l.a<=0||l.d<=0)return void X(e,t,n,o,r,a,s);if(!s||(s.intensity??0)<.003)return void X(e,t,n,o,r,a,null);const h=p(e.canvas),d={...n,accentColor:"#"+j(n.accentColor)},f=JSON.stringify([d,o,r,l.a,l.d,h,void 0!==document.fonts?document.fonts.status:"loaded"]);let m=_.get(e);if(!m||m.frame!==t||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 a=n.getContext("2d");a.setTransform(l.a,0,0,l.d,0,0),X(a,t,d,o,r,0,null,void 0,h),m={frame:t,key:f,canvas:n},_.set(e,m)}if(e.clearRect(0,0,o,r),e.drawImage(m.canvas,0,0,o,r),!s||(s.intensity??0)<.003)return;const u=t.length,g=t[0].length,M=.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 e of v)w=Math.min(w,e.x-M),y=Math.max(y,e.x+M),x=Math.min(x,e.y-M),b=Math.max(b,e.y+M);if("glitchText"===n.hoverEffect){const e=n.hoverText,t=Math.max(1,...(Array.isArray(e)?e:[e]).map(e=>e.length));w=Math.min(w,s.x-t/g),y=Math.max(y,s.x+t/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)};e.save(),e.beginPath(),e.rect(E.x*o/g,E.y*r/u,(E.right-E.x)*o/g,(E.bottom-E.y)*r/u),e.clip(),X(e,t,d,o,r,a,s,E,h),e.restore()}function X(e,t,n,o,r,a=0,i,s,c){const l=t.length;if(0===l)return;const h=t[0].length;e.clearRect(0,0,o,r);let d=!1;const m=Math.max(1,l>>2),g=Math.max(1,h>>2);e:for(let e=0;e<l;e+=m){const n=t[e];for(let e=0;e<h;e+=g)if(n[e].a<200){d=!0;break e}}const M=e.canvas,v=c??p(M);d||(e.fillStyle=v?"#0a0a0a":"#faf9f7",e.fillRect(0,0,o,r));const w=o/h,y=r/l,S=i?.intensity??1,E=!!(i&&n.hoverStrength>0&&S>.005),C="#"+($(n.hoverColor||"#ffffff")??"ffffff"),T=parseInt(C.slice(1,3),16),F=parseInt(C.slice(3,5),16),A=parseInt(C.slice(5,7),16),R=j(n.accentColor),k=parseInt(R.substring(0,2),16),L=parseInt(R.substring(2,4),16),P=parseInt(R.substring(4,6),16),z=n.hoverRadius;let O=0,q=h,V=0,B=l,U=0,N=0;if(E&&i){U=i.x,N=i.y;const e=.08+.35*z+.04*n.hoverStrength;O=Math.max(0,Math.floor((U-e)*h)-1),q=Math.min(h,Math.ceil((U+e)*h)+1),V=Math.max(0,Math.floor((N-e)*l)-1),B=Math.min(l,Math.ceil((N+e)*l)+1)}if(E&&"trail"===n.hoverEffect)for(const e of i?.trail??[]){const t=.08+.35*z+.04*n.hoverStrength;O=Math.min(O,Math.max(0,Math.floor((e.x-t)*h)-1)),q=Math.max(q,Math.min(h,Math.ceil((e.x+t)*h)+1)),V=Math.min(V,Math.max(0,Math.floor((e.y-t)*l)-1)),B=Math.max(B,Math.min(l,Math.ceil((e.y+t)*l)+1))}const D=n.animationStyle,K=n.animationSpeed,Y="none"===D,_=n.hoverStrength,G=n.hoverEffect,X=z,J=n.hoverShape||"circle",Q=W(n.invert,M),Z=n.colorMode,ee=2*Math.PI,te=1/h,ne=1/l;let oe="",re=-1;if("dots"===n.renderMode){const c=.5*Math.min(w,y)*n.dotSizeRatio;for(let n=s?.y??0;n<(s?.bottom??l);n++){const d=t[n];for(let t=s?.x??0;t<(s?.right??h);t++){const s=d[t];if(s.a<10)continue;const m=.00392156863*(.299*s.r+.587*s.g+.114*s.b),g=Q?1-m:m;if(g<.02)continue;const M=Y?1:x(t,n,h,l,a,D,K);let p=1,v=0,C=0,R=0,I=0;if(E&&t>=O&&t<=q&&n>=V&&n<=B){const e=b(t*te,n*ne,U,N,S,_,w,y,G,X,J,i?.trail,o/r);p=e.scale,v=e.offsetX,C=e.offsetY,R=e.glow,I=e.colorBlend}const H=c*g*M*p;if(H<.3)continue;const W=t*w+.5*w+v,$=n*y+.5*y+C;let j;if(I>0){const e=u(s,Z,k,L,P,Q);j=`rgb(${Math.min(255,e[0]+(T-e[0])*I|0)},${Math.min(255,e[1]+(F-e[1])*I|0)},${Math.min(255,e[2]+(A-e[2])*I|0)})`}else j=f(s,Z,k,L,P,Q);const z=Math.min(1,.00392156863*s.a*M*(1+R));if(z!==re&&(e.globalAlpha=z,re=z),j!==oe&&(e.fillStyle=j,oe=j),H<=3){const t=2*H;e.fillRect(W-H,$-H,t,t)}else e.beginPath(),e.arc(W,$,H,0,ee),e.fill()}}}else{const c=.55,d=.9*Math.min(w/c,y);{const t="emoji"===n.artStyle;e.font=t?`${d}px "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif`:`${d}px "JetBrains Mono", monospace`,e.textAlign="center",e.textBaseline="middle"}const m=n.charsetFrames,g=!!m?.length,M=g?m[Math.floor(Math.max(0,a)*(n.charsetFps??2))%m.length]:n.charset,p=e.getTransform();if(!E&&Y&&!g&&"accent"===Z&&!s&&n.hoverStrength<=0&&"emoji"!==n.artStyle&&"letterSpacing"in e&&/^[\x20-\x7e]*$/.test(n.customText||n.charset)&&t.every(e=>e.every(e=>e.a<10||255===e.a&&1===e.char.length&&/^[\x20-\x7e]$/.test(e.char)))){const n=e.letterSpacing;e.letterSpacing="0px";const o=e.measureText("M").width;e.letterSpacing=w-o+"px",e.fillStyle=`rgb(${k},${L},${P})`,e.globalAlpha=1,e.textAlign="left";for(let n=0;n<l;n++){const r=t[n];let a="";for(let e=0;e<h;e++){const t=r[e];a+=t.a<10?" ":t.char}0!==a.trim().length&&e.fillText(a,.5*(w-o),n*y+.5*y)}return e.letterSpacing=n,e.textAlign="center",void(e.globalAlpha=1)}const v="glitchText"===G&&E,C="!@#$%^&*<>{}[]|/\\~`0123456789",R=C.length;let W="",$=0,j=0,ee=0,ae=0,ie=0,se=0;if(v){const e=n.hoverText??"ASCIIFY";if(j=Math.round(U*h),ee=Math.round(N*l),Array.isArray(e)){const t=e.filter(e=>e.length>0);0===t.length&&t.push("ASCIIFY");W=t[((7*Math.floor(j/Math.max(1,Math.ceil(h/5)))+13*Math.floor(ee/Math.max(1,Math.ceil(l/3))))%t.length+t.length)%t.length]}else W=e||"ASCIIFY";$=W.length,ae=Math.max(3,Math.min(12,Math.round(l*z*.6)));const t=Math.floor(ae/2);ie=Math.max(0,ee-t),ie+ae>l&&(ie=Math.max(0,l-ae)),se=j-Math.floor($/2)}for(let n=s?.y??0;n<(s?.bottom??l);n++){const c=t[n];for(let d=s?.x??0;d<(s?.right??h);d++){const s=c[d];if(s.a<10)continue;let m=g&&null!=s.lum?H(s.lum,I(M),Q):s.char;if(" "===m)continue;const z=Y?1:x(d,n,h,l,a,D,K);if(z<.05)continue;let ce=1,le=0,he=0,de=0,fe=0;if(E&&!v&&d>=O&&d<=q&&n>=V&&n<=B){const e=b(d*te,n*ne,U,N,S,_,w,y,G,X,J,i?.trail,o/r);if(ce=e.scale,le=e.offsetX,he=e.offsetY,de=e.glow,fe=e.colorBlend,"trail"===G&&e.proximity>0){const o=Math.max(0,Math.min(h-1,Math.round(d-e.offsetX/w))),r=t[Math.max(0,Math.min(l-1,Math.round(n-e.offsetY/y)))][o],a=r.lum??.299*r.r+.587*r.g+.114*r.b;m=H(Math.min(255,a+e.proximity*_*65),I(M),Q)}}if(v&&n>=ie&&n<ie+ae){const e=d-se;if(e>=0&&e<$){const t=W[e],o=Math.abs(n-ee)/Math.max(1,.5*ae),r=Math.abs(d-j)/Math.max(1,$),i=Math.max(o,r),s=Math.max(0,Math.min(1,1-.9*i)),c=43758.5453*Math.sin(127.1*d+311.7*n+43758.5453*Math.floor(12*a));m=Math.abs(c-Math.floor(c))<s?t:C[Math.abs(Math.floor(97*c))%R],de=.3+.7*s,fe=.3+.65*s}}const me=d*w+.5*w+le,ue=n*y+.5*y+he;let ge;if(fe>0){const e=u(s,Z,k,L,P,Q);ge=`rgb(${Math.min(255,e[0]+(T-e[0])*fe|0)},${Math.min(255,e[1]+(F-e[1])*fe|0)},${Math.min(255,e[2]+(A-e[2])*fe|0)})`}else ge=f(s,Z,k,L,P,Q);const Me=Math.min(1,.00392156863*s.a*z*(1+de));Me!==re&&(e.globalAlpha=Me,re=Me),ge!==oe&&(e.fillStyle=ge,oe=ge),1!==ce?(e.translate(me,ue),e.scale(ce,ce),e.fillText(m,0,0),e.setTransform(p)):e.fillText(m,me,ue)}}}e.globalAlpha=1}function J(e){return Math.max(0,Math.min(1,e))}function Q(e){return"string"==typeof e?document.querySelector(e):e instanceof HTMLElement?e:null}function Z(e){return"ascii"===e.renderMode&&"none"===e.animationStyle&&e.hoverStrength<=0&&!e.charsetFrames?.length}function ee(e,t={}){const n=J(e),o=J(n*(void 0===t.speed?1:Math.max(.001,t.speed)));return J(t.ease?t.ease(o):o)}function te(e,t,n={}){if(!Number.isFinite(e.duration)||e.duration<=0)return;const o=n.from??0,r=n.to??e.duration,a=Math.max(o,Math.min(r,e.duration)),i=ee(t,n),s=o+(a-o)*i;e.currentTime=Math.min(Math.max(o,s),Math.max(o,a-.04)),n.onUpdate?.(i,e)}function ne(e,t){return Math.abs(e.currentTime-t)<1/240?oe(e):new Promise(n=>{const o=()=>{e.removeEventListener("seeked",o),n()};e.addEventListener("seeked",o,{once:!0});const r=e.fastSeek;r?r.call(e,t):e.currentTime=t})}function oe(e){const t=e.requestVideoFrameCallback;return new Promise(t?n=>{let o=!1;const r=()=>{o||(o=!0,n())};t.call(e,r),window.setTimeout(r,32)}:e=>requestAnimationFrame(()=>e()))}function re(e,t={}){const n=Q(t.trigger)??e;e.pause();const o=t.gsap,r=t.ScrollTrigger??o?.ScrollTrigger;if(o&&r?.create){o.registerPlugin?.(r);const a=r.create({trigger:n,start:t.start??"top bottom",end:t.end??"bottom top",scrub:t.scrub??!0,onUpdate:n=>te(e,n.progress,t)});return()=>a.kill?.()}return function(e,t,n){let o=0;const r=()=>{o=0;const r=t.getBoundingClientRect(),a=window.innerHeight||document.documentElement.clientHeight,i=r.height+a,s=i>0?J((a-r.top)/i):0;te(e,s,n)},a=()=>{o||(o=requestAnimationFrame(r))};return window.addEventListener("scroll",a,{passive:!0}),window.addEventListener("resize",a),a(),()=>{window.removeEventListener("scroll",a),window.removeEventListener("resize",a),o&&cancelAnimationFrame(o)}}(e,n,t)}function ae(e,t,n){const o=t.gsap,r=t.ScrollTrigger??o?.ScrollTrigger;if(o&&r?.create){o.registerPlugin?.(r);const a=r.create({trigger:e,start:t.start??"top bottom",end:t.end??"bottom top",scrub:t.scrub??!0,onUpdate:e=>n(e.progress)});return()=>a.kill?.()}return function(e,t){let n=0;const o=()=>{n=0;const o=e.getBoundingClientRect(),r=window.innerHeight||document.documentElement.clientHeight,a=o.height+r,i=a>0?J((r-o.top)/a):0;t(i)},r=()=>{n||(n=requestAnimationFrame(o))};return window.addEventListener("scroll",r,{passive:!0}),window.addEventListener("resize",r),r(),()=>{window.removeEventListener("scroll",r),window.removeEventListener("resize",r),n&&cancelAnimationFrame(n)}}(e,n)}function ie(e,t,n){if(!e||!t||!n.sourceCrop)return{w:e,h:t};const o=O(n.sourceCrop,e,t);return{w:Math.max(1,Math.round(o.width)),h:Math.max(1,Math.round(o.height))}}function se(e,t,n,o){const r=o.chromaKey;if(null==r||!1===r)return!1;if(!0===r)return t>1.4*e&&t>1.4*n&&t>80;if("blue-screen"===r)return n>1.4*e&&n>1.4*t&&n>80;const a=v(r),i=(o.chromaKeyTolerance??60)**2,s=e-a.r,c=t-a.g,l=n-a.b;return s*s+c*c+l*l<=i}function ce(e,t,n){if(!t.chromaKey||!t.sourceCrop||"off"===t.chromaKeyTrimMode)return t;const o=e instanceof HTMLVideoElement?e.videoWidth:e.width,r=e instanceof HTMLVideoElement?e.videoHeight:e.height;if(!o||!r)return t;const i=O(t.sourceCrop,o,r),s=Math.min(360,Math.max(1,Math.round(i.width))),c=Math.max(1,Math.round(s*(i.height/i.width))),{ctx:l}=a(s,c);l.drawImage(e,i.x,i.y,i.width,i.height,0,0,s,c);const h=l.getImageData(0,0,s,c).data,d=Math.max(0,Math.min(255,t.chromaKeyTrimLuminanceThreshold??0));let f=s,m=c,u=-1,g=-1;for(let e=0;e<c;e++)for(let n=0;n<s;n++){const o=4*(e*s+n),r=h[o+3],a=h[o],i=h[o+1],c=h[o+2];r<=8||.2126*a+.7152*i+.0722*c<=d||se(a,i,c,t)||(n<f&&(f=n),e<m&&(m=e),n>u&&(u=n),e>g&&(g=e))}if(u<f||g<m)return t;const M=Math.max(0,Math.min(.25,t.chromaKeyTrimPadding??.002)),p=Math.round(s*M),v=Math.round(c*M);f=Math.max(0,f-p),m=Math.max(0,m-v),u=Math.min(s-1,u+p),g=Math.min(c-1,g+v);const w=function(e,t,n,o,r){const a=r&&Number.isFinite(r)&&r>0?r:null;if(!a)return e;const i=t.x,s=t.y,c=t.x+t.width,l=t.y+t.height,h=Math.max(i,e.left),d=Math.max(s,e.top),f=Math.min(c,n-e.right),m=Math.min(l,o-e.bottom),u=Math.max(1,f-h),g=Math.max(1,m-d),M=h+u/2,p=d+g/2;let v=u,w=g;v/w<a?v=w*a:w=v/a;v>t.width&&(v=t.width,w=Math.max(g,Math.min(t.height,v/a)));w>t.height&&(w=t.height,v=Math.max(u,Math.min(t.width,w*a)));let x=M-v/2,y=p-w/2;return x=Math.max(i,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:i.x+f/s*i.width,top:i.y+m/c*i.height,right:o-(i.x+(u+1)/s*i.width),bottom:r-(i.y+(g+1)/c*i.height)},{x:i.x,y:i.y,width:i.width,height:i.height},o,r,n);return{...t,sourceCrop:{unit:"pixel",...w,preserveAspect:!1}}}function le(e){const t=e.sourceCrop;return t&&"pixel"===t.unit?void 0===t.left||void 0===t.top||void 0===t.right||void 0===t.bottom?null:{left:t.left,top:t.top,right:t.right,bottom:t.bottom}:null}async function he(e,t,n,o,r){if(!t.chromaKey||!t.sourceCrop||"range"!==t.chromaKeyTrimMode)return t;const a=e.currentTime,i=function(e,t,n,o){const r=!0===o?{}:o||{},a=Math.max(0,r.from??t),i=r.to??n??(Number.isFinite(e.duration)?e.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(e=>Math.max(0,Number(e.toFixed(3))))))}(e,n,o,r);let s=null;for(const n of i){await ne(e,n),await oe(e);const o=le(ce(e,t));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 ne(e,a),await oe(e),s?{...t,sourceCrop:{unit:"pixel",...s,preserveAspect:!0}}:t}function de(e,t,n=2048){return fe({sourceWidth:e,sourceHeight:t,maxRenderDimension:n})}function fe({sourceWidth:e,sourceHeight:t,cssWidth:n=0,cssHeight:o=0,maxRenderDimension:r=2048}){const a=Math.max(1,e),i=Math.max(1,t),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,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 me(e,t,n,o){if(void 0===e)return;if("number"==typeof e)return e;const r=e.trim();if(r.endsWith("%")){const e=Number.parseFloat(r)/100;return Number.isFinite(e)?t*e:void 0}if(r.endsWith("px")){const e=Number.parseFloat(r);return Number.isFinite(e)?e:void 0}if(r.endsWith("vw")){const e=Number.parseFloat(r)/100;return Number.isFinite(e)?n*e:void 0}if(r.endsWith("vh")){const e=Number.parseFloat(r)/100;return Number.isFinite(e)?o*e:void 0}}function ue(e,t,n,o,r,a=2048,i={}){const{width:s,height:c}=t.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=me(i.width,s,l,h)??s,f=me(i.height,c,l,h)??c,m=function(e,t,n,o,r){const a=e=>{const n=me(e,t,o,r);return n&&n>0?n:0},i=e=>{const t=me(e,n,o,r);return t&&t>0?t:0};return void 0===e?{x:0,y:0}:"number"==typeof e||"string"==typeof e?{x:a(e),y:i(e)}:{x:a(e.x),y:i(e.y)}}(i.bleed,s,c,l,h),u=d+2*m.x,g=f+2*m.y,{cssW:M,cssH:p}=function(e,t,n,o="contain"){if("fill"===o)return{cssW:e,cssH:t};let r=e,a=r/n;const i="cover"===o,s=a>t;return(i&&!s||!i&&s)&&(a=t,r=a*n),"scale-down"===o&&(r=Math.min(r,e),a=Math.min(a,t)),{cssW:Math.round(r),cssH:Math.round(a)}}(u,g,n,i.objectFit??"contain"),v="undefined"!=typeof window&&window.devicePixelRatio||1;let w,x;o&&r?({renderW:w,renderH:x}=fe({sourceWidth:o,sourceHeight:r,cssWidth:M,cssHeight:p,maxRenderDimension:a})):(w=M,x=p);const y=8e6,b=w*v*x*v>y?Math.sqrt(y/(w*x)):v;return e.width=Math.round(w*b),e.height=Math.round(x*b),e.style.width=`${M}px`,e.style.height=`${p}px`,{renderW:w,renderH:x,dpr:b}}async function ge(e,t,{fontSize:o,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:v,maxCachedFrames:w=90,onReady:x,onFrame:y}={}){const b=p?.start??0,E=p?.end,C=o??i.fontSize??10;let T={...r,...n[a],artStyle:a,...i,fontSize:C};const F=t.getContext("2d");if(!F)throw new Error("asciifyVideo: could not get 2d context from canvas.");const A="string"==typeof s?document.querySelector(s):s instanceof HTMLElement?s:null,R={objectFit:c,objectPosition:l,scale:h,width:d,height:f,bleed:m},k=function(e,t){var n;if(!function(e){return void 0!==e.objectFit||void 0!==e.objectPosition||void 0!==e.scale||void 0!==e.width||void 0!==e.height||void 0!==e.bleed}(t))return()=>{};const o={width:e.style.width,height:e.style.height,objectFit:e.style.objectFit,objectPosition:e.style.objectPosition,maxWidth:e.style.maxWidth,maxHeight:e.style.maxHeight,transformOrigin:e.style.transformOrigin,scale:e.style.getPropertyValue("scale")};if(t.objectFit&&(e.style.objectFit=t.objectFit),t.objectPosition&&(e.style.objectPosition=t.objectPosition,e.style.transformOrigin=t.objectPosition),void 0===t.scale&&void 0===t.bleed||(e.style.maxWidth="none",e.style.maxHeight="none"),void 0!==t.scale){const o=Number.isFinite(t.scale)&&t.scale>0?t.scale:1;e.style.setProperty("scale",String(o)),(n=e.style).transformOrigin||(n.transformOrigin=t.objectPosition??"center center")}return()=>{e.style.width=o.width,e.style.height=o.height,e.style.objectFit=o.objectFit,e.style.objectPosition=o.objectPosition,e.style.maxWidth=o.maxWidth,e.style.maxHeight=o.maxHeight,e.style.transformOrigin=o.transformOrigin,o.scale?e.style.setProperty("scale",o.scale):e.style.removeProperty("scale")}}(t,R),I=e=>()=>{e(),k()};if(u){let n;"string"==typeof e?(n=document.createElement("video"),n.crossOrigin="anonymous",n.src=e,n.readyState<2&&await new Promise((t,o)=>{n.onloadeddata=()=>t(),n.onerror=()=>o(new Error(`asciifyVideo: failed to load "${e}"`))})):n=e,T=await he(n,T,b,E,v);const o=ie(n.videoWidth,n.videoHeight,T);A&&ue(t,A,o.w/o.h,o.w,o.h,M,R);const{renderW:r,renderH:a}=de(o.w,o.h,M),i="undefined"!=typeof window&&window.devicePixelRatio||1,s=8e6,c=r*i*a*i>s?Math.sqrt(s/(r*a)):i;t.width===Math.round(r*c)&&t.height===Math.round(a*c)||(t.width=Math.round(r*c),t.height=Math.round(a*c));const l=void 0!==E?E-b:10,h=g??(v?18:void 0);if(Z(T)){const{frames:e,fps:o}=await N(n,T,r,a,h,l,void 0,b),i=t=>{const n=e[t];n&&(F.save(),F.setTransform(c,0,0,c,0,0),B(F,n,T,r,a),F.restore(),y?.())};if(v){let o=!1,r=-1;const a=!0===v?{}:v,s=ae(Q(a.trigger)??A??t,a,t=>{const s=ee(t,a),c=Math.max(0,Math.min(e.length-1,Math.round(s*(e.length-1))));c!==r&&(r=c,i(c),o||(o=!0,x?.(n)),a.onUpdate?.(s,n))});return i(0),o=!0,x?.(n),I(s)}let s,d=!1,f=0,m=performance.now(),u=!0;const g=1e3/o,M=t=>{d||(t-m>=g&&(i(f),f=(f+1)%e.length,m=t,u&&(u=!1,x?.(n))),s=requestAnimationFrame(M))};return s=requestAnimationFrame(M),I(()=>{d=!0,cancelAnimationFrame(s)})}const{frames:d,fps:f}=await U(n,T,r,a,h,l,void 0,b);if(!d.length)throw new Error("asciifyVideo: no frames were decoded.");let m=0;const u=performance.now(),p=S(t,(e,t)=>{v||(m=Math.floor((e-u)*f/1e3)%d.length),F.save(),F.setTransform(c,0,0,c,0,0),G(F,d[m],T,r,a,(e-u)/1e3,t),F.restore(),y?.()},{continuous:!v||"none"!==T.animationStyle||!!T.charsetFrames?.length,interactive:T.hoverStrength>0});let w;if(v){const e=!0===v?{}:v;w=ae(Q(e.trigger)??A??t,e,t=>{m=Math.max(0,Math.min(d.length-1,Math.round(ee(t,e)*(d.length-1)))),p.wake(),e.onUpdate?.(t,n)})}return x?.(n),I(()=>{p.stop(),w?.()})}let L,H=!1;"string"==typeof e?(L=document.createElement("video"),L.crossOrigin="anonymous",L.src=e,L.muted=!0,L.loop=!0,L.playsInline=!0,L.setAttribute("playsinline",""),Object.assign(L.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(L),H=!0,await new Promise((t,n)=>{L.onloadedmetadata=()=>t(),L.onerror=()=>n(new Error(`asciifyVideo: failed to load "${e}"`))}),await L.play().catch(()=>{})):(L=e,L.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((e,t)=>{const n=()=>{L.removeEventListener("loadedmetadata",o),L.removeEventListener("error",r)},o=()=>{n(),e()},r=()=>{n(),t(new Error("asciifyVideo: provided video element failed to load metadata."))};L.addEventListener("loadedmetadata",o),L.addEventListener("error",r),L.load()}),L.paused&&await L.play().catch(()=>{})),b>0&&(L.currentTime=b,await new Promise(e=>{const t=()=>{L.removeEventListener("seeked",t),e()};L.addEventListener("seeked",t)}),await oe(L));let P=null;(b>0||void 0!==E)&&(P=()=>{(void 0!==E&&L.currentTime>=E||b>0&&L.currentTime<b)&&(L.currentTime=b)},L.addEventListener("timeupdate",P)),T=await he(L,T,b,E,v);let W=null;const $=ie(L.videoWidth,L.videoHeight,T);let{renderW:j,renderH:z}=de($.w,$.h,M);const O=e=>"frame"===T.chromaKeyTrimMode?ce(e,T,j/z):T;if(A){const e=$.w/$.h,n=$.w,o=$.h,r=ue(t,A,e,n,o,M,R);j=r.renderW,z=r.renderH;const a=t.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0),W=new ResizeObserver(()=>{const r=ue(t,A,e,n,o,M,R);j=r.renderW,z=r.renderH;const a=t.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0)}),W.observe(A)}else{const e="undefined"!=typeof window&&window.devicePixelRatio||1,n=8e6,o=j*e*z*e>n?Math.sqrt(n/(j*z)):e;t.width===Math.round(j*o)&&t.height===Math.round(z*o)||(t.width=Math.round(j*o),t.height=Math.round(z*o)),F.setTransform(o,0,0,o,0,0)}let D=!0,K=null;const Y=v&&!u,_=g&&g>0?1e3/g:0;let X=0;const te=!Y&&Z(T);if(Y&&"ascii"===T.renderMode&&"none"===T.animationStyle&&T.hoverStrength<=0&&!T.charsetFrames?.length){const e=!0===v?{}:v,n=Q(e.trigger)??A??t,o=e.from??b,r=e.to??E??L.duration,a=Math.max(o,Math.min(r,L.duration)),i=Math.max(.001,a-o),s=Math.min(60,Math.max(12,g??30)),c=Math.max(2,Math.ceil(i*s)+1),l=new Array(c),h=[],d=Math.max(2,Math.min(c,Math.floor(w))),f=()=>{for(;h.length>d;){const e=h.findIndex(e=>e!==u&&Math.abs(e-u)>2),t=e>=0?e:0,n=h.splice(t,1)[0];void 0!==n&&(l[n]=void 0)}},m=e=>{const t=h.indexOf(e);t>=0&&h.splice(t,1),h.push(e),f()};let u=0,M=0,p=-1,S=0,C=!1,R=!1,k=!1;const $=new Set,q=document.createElement("video");q.muted=!0,q.playsInline=!0,q.preload="auto",q.crossOrigin=L.crossOrigin||"anonymous",q.src=L.currentSrc||L.src,Object.assign(q.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(q),q.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((e,t)=>{const n=()=>{q.removeEventListener("loadedmetadata",o),q.removeEventListener("error",r)},o=()=>{n(),e()},r=()=>{n(),t(new Error("asciifyVideo: cache video failed to load metadata."))};q.addEventListener("loadedmetadata",o),q.addEventListener("error",r),q.load()}),q.pause(),L.paused&&await L.play().catch(()=>{});const U=e=>o+i*e/Math.max(1,c-1),N=e=>Math.max(0,Math.min(c-1,Math.round(e*(c-1)))),D=O(L),Y=V(L,D,j,z);Y.rows.length>0&&(l[0]=Y,m(0),B(F,Y,D,j,z),k=!0,x?.(L),y?.());const G=e=>{if(l[e])return e;for(let t=1;t<c;t++){const n=e-t,o=e+t;if(n>=0&&l[n])return n;if(o<c&&l[o])return o}return-1},Z=()=>{if(!l[u])return u;for(const e of $)if(!l[e])return e;for(let e=1;e<c;e++){const t=u-e,n=u+e;if(t>=0&&!l[t])return t;if(n<c&&!l[n])return n}return-1},te=e=>{e<0||e>=c||l[e]||($.add(e),oe())},oe=async()=>{if(C||R)return;const e=Z();if(!(e<0)){$.delete(e),R=!0;try{if(await ne(q,U(e)),!C){const t=O(q),n=V(q,t,j,z);n.rows.length>0&&(l[e]=n,m(e))}}finally{R=!1,C||requestAnimationFrame(()=>{oe()})}}},re=()=>{if(C)return;const e=G(u);if(e>=0&&e!==p){const t=l[e];t&&(B(F,t,T,j,z),p=e,k||(k=!0,x?.(L)),y?.())}else if(e<0||p<0){const e=performance.now();if(_<=0||e-X>=_){const t=O(L),n=V(L,t,j,z);n.rows.length>0&&(B(F,n,t,j,z),X=e,k||(k=!0,x?.(L)),y?.())}}te(u),S=requestAnimationFrame(re)};return K=ae(n,e,t=>{const n=function(e,t,n={}){if(!Number.isFinite(e.duration)||e.duration<=0)return null;const o=n.from??0,r=n.to??e.duration,a=Math.max(o,Math.min(r,e.duration)),i=ee(t,n),s=o+(a-o)*i;return{progress:i,time:Math.min(Math.max(o,s),Math.max(o,a-.04))}}(L,t,{...e,from:o,to:a});M=n?.progress??J(t),u=N(M),te(u),te(u-1),te(u+1),te(u-2),te(u+2),te(u-3),te(u+3),e.onUpdate?.(M,L)}),te(0),te(1),S=requestAnimationFrame(re),I(()=>{C=!0,cancelAnimationFrame(S),K?.(),W?.disconnect(),$.clear(),h.length=0,l.fill(void 0),q.pause(),q.src="",q.removeAttribute("src"),q.load(),q.isConnected&&q.remove(),P&&L.removeEventListener("timeupdate",P),H&&(L.pause(),L.src="",L.removeAttribute("src"),L.load(),L.isConnected&&L.remove())})}if(Y){const e=!0===v?{}:v;K=re(L,{...e,trigger:e.trigger??A??t,from:e.from??b,to:e.to??E})}let se=-1,le=0,fe=-1,me=0;const ge="function"==typeof L.requestVideoFrameCallback,Me=()=>{me=L.requestVideoFrameCallback(()=>{le++,Me()})};ge&&Me();let pe=0,ve=0,we=null;const xe=S(t,(e,n)=>{if(L.readyState<2||0===t.width||0===t.height)return;if(_>0&&e-X<_&&!n)return;if(b>0&&L.currentTime<b)return;if(void 0!==E&&L.currentTime>=E)return;const o=(ge?le!==fe:L.currentTime!==se)||pe!==j||ve!==z;if(o||!(T.hoverStrength<=0)||"none"!==T.animationStyle||T.charsetFrames?.length){if(te){const e=O(L),t=V(L,e,j,z);B(F,t,e,j,z)}else!o&&we||(we=q(L,O(L),j,z).frame),G(F,we,T,j,z,e/1e3,n);se=L.currentTime,fe=le,pe=j,ve=z,X=e,D&&(D=!1,x?.(L)),y?.()}},{continuous:!0,interactive:T.hoverStrength>0});return I(()=>{xe.stop(),me&&L.cancelVideoFrameCallback(me),K?.(),W?.disconnect(),P&&L.removeEventListener("timeupdate",P),H&&(L.pause(),L.src="",L.removeAttribute("src"),L.load(),L.isConnected&&L.remove())})}function Me(e,t,n,o="#505050",r=100){if(!e||t<=0||n<=0)return[];const a=function(e){const t=e.match(/^#([0-9a-f]{3,8})$/i)?.[1];if(t){const e=t.length<=4?t.split("").map(e=>parseInt(e+e,16)):[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)];return{r:e[0],g:e[1],b:e[2]}}const n=e.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},i=e,s=i.length;return Array.from({length:n},(e,n)=>Array.from({length:t},(e,o)=>({char:i[(n*t+o)%s],r:a.r,g:a.g,b:a.b,a:r})))}var pe=new WeakMap;function ve(e,{format:t="png",quality:n=.92,scale:o=1}={}){return new Promise((r,a)=>{let i=e;if(1!==o){const t=document.createElement("canvas");t.width=Math.round(e.width*o),t.height=Math.round(e.height*o);const n=t.getContext("2d");if(!n)return void a(new Error("captureSnapshot: could not get 2d context"));n.drawImage(e,0,0,t.width,t.height),i=t}i.toBlob(e=>e?r(e):a(new Error("captureSnapshot: toBlob returned null")),`image/${t}`,n)})}var we={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]},xe=[127,65,65,65,65,65,127];function ye(e){return we[e]??we[e.toUpperCase()]??xe}function be(e,t={}){if(!e)return"";const{char:n="█",scale:o=1}=t,r=[...n][0]??"█",a=Math.max(1,Math.floor(o)),i=7*a,s=a,c=Array.from({length:i},()=>"");for(let t=0;t<e.length;t++){const n=ye(e[t]);for(let e=0;e<7;e++){const t=n[e];let o="";for(let e=6;e>=0;e--)o+=(t>>e&1?r:" ").repeat(a);for(let t=0;t<a;t++)c[e*a+t]+=o}if(t<e.length-1)for(let e=0;e<i;e++)c[e]+=" ".repeat(s)}return c.join("\n")}exports.ART_STYLE_PRESETS=n,exports.CHARSETS=e,exports.CHARSET_SEQUENCES=t,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=o,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.asciiText=function(e,t={},n,o){const a={...r,...t},{frame:i,cols:s}=q(e,a,n,o);if(!i.length||0===s)return"";const c=[];for(const e of i)c.push(e.map(e=>e.char).join(""));return c.join("\n")},exports.asciiTextAnsi=function(e,t={},n,o){const a={...r,...t},{frame:i,cols:s}=q(e,a,n,o);if(!i.length||0===s)return"";const c=[];for(const e of i){let t="";for(const n of e)" "===n.char||n.a<10?t+=" ":t+=`[38;2;${n.r};${n.g};${n.b}m${n.char}`;c.push(t)}return c.join("\n")},exports.asciify=async function(e,t,{fontSize:o,artStyle:a="classic",options:i={}}={}){let s;if("string"==typeof e){const t=new Image;t.crossOrigin="anonymous",await new Promise((n,o)=>{t.onload=()=>n(),t.onerror=()=>o(new Error(`Failed to load image: ${e}`)),t.src=e}),s=t}else e instanceof HTMLImageElement&&!e.complete?(await new Promise((t,n)=>{e.onload=()=>t(),e.onerror=()=>n(new Error("Image failed to load"))}),s=e):s=e;const c=n[a],l=o??i.fontSize??10,h={...r,...c,artStyle:a,...i,fontSize:l},d=t.getContext("2d");if(!d)throw new Error("Could not get 2d context from canvas");const{w:f,h:m}=function(e){return e instanceof HTMLVideoElement?{w:e.videoWidth,h:e.videoHeight}:e instanceof HTMLImageElement?{w:e.naturalWidth||e.width,h:e.naturalHeight||e.height}:{w:e.width,h:e.height}}(s),{renderW:u,renderH:g}=de(f,m),M="undefined"!=typeof window&&window.devicePixelRatio||1,p=8e6,v=u*M*g*M>p?Math.sqrt(p/(u*g)):M;t.width===Math.round(u*v)&&t.height===Math.round(g*v)||(t.width=Math.round(u*v),t.height=Math.round(g*v));const{frame:w}=q(s,h,u,g),x=(e,t)=>{d.save(),d.setTransform(v,0,0,v,0,0),G(d,w,h,u,g,e/1e3,t),d.restore()};return x(0,null),S(t,x,{continuous:"none"!==h.animationStyle||!!h.charsetFrames?.length,interactive:h.hoverStrength>0}).stop},exports.asciifyGif=async function(e,t,{fontSize:o,artStyle:a="classic",options:i={}}={}){const s="string"==typeof e?await fetch(e).then(e=>e.arrayBuffer()):e,c=o??i.fontSize??10;let l={...r,...n[a],artStyle:a,...i,fontSize:c};const h=t.getContext("2d");if(!h)throw new Error("Could not get 2d context from canvas");const{frames:d,fps:f}=await D(s,l,t.width,t.height);if(!d.length)throw new Error("asciifyGif: the GIF contains no renderable frames.");const m=performance.now();let u=-1;return S(t,(e,n)=>{const o=Math.floor((e-m)*f/1e3)%d.length;o===u&&!n&&l.hoverStrength<=0&&"none"===l.animationStyle&&!l.charsetFrames?.length||(G(h,d[o],l,t.width,t.height,(e-m)/1e3,n),u=o)},{continuous:!0,interactive:l.hoverStrength>0}).stop},exports.asciifyLiveVideo=function(e,t,n){return ge(e,t,n)},exports.asciifyText=be,exports.asciifyVideo=ge,exports.asciifyWebcam=async function(e,{fontSize:t=10,style:o="classic",options:a={},liveOptions:i,mirror:s=!0,constraints:c={facingMode:"user"},dpr:l}={}){if(!navigator.mediaDevices?.getUserMedia)throw new Error("asciifyWebcam: getUserMedia is not supported in this browser.");const h=await navigator.mediaDevices.getUserMedia({video:c}),d=document.createElement("video");d.srcObject=h,d.muted=!0,d.playsInline=!0,await new Promise((e,t)=>{d.onloadedmetadata=()=>e(),d.onerror=()=>t(new Error("asciifyWebcam: video stream failed to load.")),d.play().catch(t)});const f={...r,...n[o],...a,fontSize:t},m=e.getContext("2d");if(!m)throw new Error("asciifyWebcam: could not get 2d context from canvas.");const u=l??("undefined"!=typeof window?window.devicePixelRatio:1)??1;1!==u&&m.scale(u,u);let g=null;const M=t=>{const n=e.getBoundingClientRect();g={x:(t.clientX-n.left)/n.width,y:(t.clientY-n.top)/n.height}},p=()=>{g=null};f.hoverStrength>0&&(e.addEventListener("mousemove",M),e.addEventListener("mouseleave",p));let v,w=!1;const x=performance.now(),y=t=>{if(!w){if(d.readyState>=d.HAVE_CURRENT_DATA){const n=e.width/u,o=e.height/u,r=(t-x)/1e3,a=i?{...f,...i()}:f;a.hoverStrength>0?(e.addEventListener("mousemove",M),e.addEventListener("mouseleave",p)):(e.removeEventListener("mousemove",M),e.removeEventListener("mouseleave",p));const{frame:c}=q(d,a,n,o),l=g&&s?{x:1-g.x,y:g.y}:g;s?(m.save(),m.scale(-1,1),m.translate(-n,0),G(m,c,a,n,o,r,l),m.restore()):G(m,c,a,n,o,r,l)}v=requestAnimationFrame(y)}};return v=requestAnimationFrame(y),()=>{w=!0,cancelAnimationFrame(v),e.removeEventListener("mousemove",M),e.removeEventListener("mouseleave",p),h.getTracks().forEach(e=>e.stop()),d.srcObject=null}},exports.buildTextFrame=Me,exports.captureSnapshot=ve,exports.clearAsciifyCaches=function(){F.clear(),A.clear(),K=new WeakMap,_=new WeakMap,Y=new WeakMap,E=null,C=null},exports.computeCanvasRenderSize=fe,exports.createVideoScrollScrub=re,exports.gifToAsciiFrames=D,exports.gifToAsciiTextFrames=async function(e,t,n,o,r){const{parseGIF:a,decompressFrames:i}=await import("gifuct-js"),s=a(e),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"),v=p.getContext("2d"),w=[];let x=0,y=0,b=0;for(const e of c)b+=e.delay||100;const S=b/c.length,E=Math.round(Math.min(30,Math.max(5,1e3/S))),C=Math.min(c.length,300);for(let e=0;e<C;e++){const a=c[e],{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);v.putImageData(h,0,0),u.drawImage(p,i.left||0,i.top||0);const b=V(m,t,n,o);w.push(b),x=b.cols,y=b.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?.((e+1)/C)}return{frames:w,cols:x,rows:y,fps:E}},exports.imageToAsciiFrame=q,exports.imageToAsciiTextFrame=V,exports.renderFrameToCanvas=G,exports.renderTextBackground=function(e,t,n,o,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(t/s)),M=Math.max(1,Math.floor(n/(s*c))),p=JSON.stringify([o,g,M,l,h]);let v=pe.get(e);v&&v.key===p||(v={key:p,frame:Me(o,g,M,l,h)},pe.set(e,v)),G(e,v.frame,{...r,fontSize:s,hoverEffect:d,hoverStrength:f,hoverRadius:m,hoverColor:u},t,n,0,i??null)},exports.renderTextFrameToCanvas=B,exports.renderTextToCanvas=function(e,t,n={}){const{color:o="#d4ff00",bgColor:r,fontSize:a=10}=n,i=be(t,n);if(!i)return;const s=i.split("\n"),c=Math.max(...s.map(e=>[...e].length));e.width=Math.ceil(c*a*.6),e.height=Math.ceil(s.length*a);const l=e.getContext("2d");r&&"transparent"!==r?(l.fillStyle=r,l.fillRect(0,0,e.width,e.height)):l.clearRect(0,0,e.width,e.height),l.fillStyle=o,l.font=`${a}px monospace`,l.textBaseline="top",s.forEach((e,t)=>l.fillText(e,0,t*a))},exports.snapshotAndDownload=async function(e,t={}){const{filename:n="asciify-snapshot",format:o="png",...r}=t,a=await ve(e,{format:o,...r}),i="jpeg"===o?"jpg":o,s=document.createElement("a");s.href=URL.createObjectURL(a),s.download=`${n}.${i}`,s.click(),setTimeout(()=>URL.revokeObjectURL(s.href),1e4)},exports.videoToAsciiFrames=U,exports.videoToAsciiTextFrames=N;//# sourceMappingURL=core.cjs.map
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]},n={classic:{renderMode:"ascii",charset:t.standard,colorMode:"grayscale"},particles:{renderMode:"dots",colorMode:"fullcolor",dotSizeRatio:.8},letters:{renderMode:"ascii",charset:t.letters,colorMode:"fullcolor"},claudeCode:{renderMode:"ascii",charset:t.claudeCode,colorMode:"accent",accentColor:"#f97316"},art:{renderMode:"ascii",charset:t.dense,colorMode:"fullcolor"},terminal:{renderMode:"ascii",charset:t.standard,colorMode:"matrix"},box:{renderMode:"ascii",charset:t.box,colorMode:"grayscale"},lines:{renderMode:"ascii",charset:t.lines,colorMode:"fullcolor"},braille:{renderMode:"ascii",charset:t.braille,colorMode:"fullcolor"},katakana:{renderMode:"ascii",charset:t.katakana,colorMode:"matrix"},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"}},o={agentField:{...n.interface,charsetFrames:e.assistant,charsetFps:1.6,animationStyle:"breathe",animationSpeed:.75,ditherStrength:.12,hoverEffect:"glow",hoverStrength:.42,hoverRadius:.18,hoverColor:"#f4f1ea",normalize:!0},liquidSignal:{...n.data,charsetFrames:e.signal,charsetFps:2.4,animationStyle:"melt",animationSpeed:.65,ditherStrength:.45,hoverEffect:"repel",hoverStrength:.55,hoverRadius:.22,hoverColor:"#8fd3ff",normalize:!0},cursorGravity:{...n.mesh,charsetFrames:e.angular,charsetFps:1.2,animationStyle:"orbit",animationSpeed:.9,ditherStrength:.2,hoverEffect:"attract",hoverStrength:.82,hoverRadius:.24,hoverColor:"#ffffff",normalize:!0},editorialPulse:{...n.humanist,charsetFrames:e.editorial,charsetFps:.9,animationStyle:"ripple",animationSpeed:.55,ditherStrength:.18,hoverEffect:"spotlight",hoverStrength:.35,hoverRadius:.2,hoverColor:"#fff8ea",normalize:!0},terminalFlow:{...n.prompt,charsetFrames:e.terminal,charsetFps:3,animationStyle:"rain",animationSpeed:1.1,ditherStrength:.22,hoverEffect:"glitchText",hoverStrength:.65,hoverRadius:.16,hoverColor:"#d4ff00",hoverText:["BUILD","SHIP","RUN","ASK","MODEL"],normalize:!0}},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"};function a(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 i(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,a){if((a?1-t/255:t/255)<.12)return" ";const i=[...e];return i[(o*r+n)%i.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,a=!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,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]=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)}function x(t,e,n,o,r,a,i){if("none"===a)return 1;const s=r*i;switch(a){case"wave":return.3+.7*(.6*(.5*Math.sin(t/n*Math.PI*4+3*s)+.5)+.4*(.5*Math.sin(e/o*Math.PI*3+2*s)+.5));case"pulse":{const r=n/2,a=o/2,i=Math.sqrt((t-r)**2+(e-a)**2),c=Math.sqrt(r**2+a**2);return.2+.8*(.5*Math.sin(i/c*Math.PI*6-4*s)+.5)}case"rain":return.1+.9*(.5*Math.sin(e/o*Math.PI*8-5*s+.3*t)+.5)*(.3*Math.sin(t/n*Math.PI*2+s)+.7);case"breathe":{const n=.3*Math.sin(2*s)+.7,o=.1*Math.sin(.1*(t+e)+s);return Math.max(.1,Math.min(1,n+o))}case"sparkle":{const n=43758.5453*Math.sin(127.1*t+311.7*e+43758.5453*Math.floor(8*s)),o=n-Math.floor(n);return o>.7?1:.15+.4*o}case"glitch":{const t=Math.floor(e/(.05*o)),n=43758.5453*Math.sin(43.23*t+17.89*Math.floor(6*s));if(n-Math.floor(n)>.85){const e=.5*Math.sin(30*s+t)+.5;return e<.3?0:e}return 1}case"spiral":{const r=n/2,a=o/2,i=t-r,c=e-a,l=Math.atan2(c,i),h=Math.sqrt(i*i+c*c),d=Math.sqrt(r*r+a*a);return.15+.85*(.5*Math.sin(3*l+h/d*Math.PI*8-3*s)+.5)}case"typewriter":{const r=n*o,a=e*n+t-.5*s%1*r*1.3;if(a>0)return 0;const i=Math.max(0,1+a/(.15*r));return Math.min(1,i)}case"scatter":{const r=n/2,a=o/2,i=t-r,c=e-a,l=Math.sqrt(i*i+c*c)/Math.sqrt(r*r+a*a),h=.5*Math.sin(1.5*s)+.5;return l>h?Math.max(0,1-3*(l-h)):.7+.3*Math.sin(10*l-2*s)}case"waveField":return.55+.45*Math.sin(t/n*9+2*Math.sin(e/o*6-s)+1.5*s);case"ripple":{const r=n/2,a=o/2,i=t-r,c=e-a,l=Math.sqrt(i*i+c*c),h=Math.sqrt(r*r+a*a);return.1+.9*(.5*Math.sin(l/h*Math.PI*10-5*s)+.5)*(.4+.6*(1-Math.min(1,l/(1.1*h))))}case"melt":{const n=e/o*Math.PI;return.05+(.5*Math.sin(n-1.8*s+.15*t)+.5)*(1-.6*(Math.max(0,e/o-.1)/.9))*.95}case"orbit":{const r=n/2,a=o/2,i=t-r,c=e-a,l=Math.atan2(c,i),h=Math.sqrt(i*i+c*c)/Math.sqrt(r*r+a*a);return.1+.9*(.5*Math.sin(2*l+6*h-2.5*s)+.5)}case"cellular":{const n=Math.floor(4*s),o=(t,e)=>{const o=43758.5453*Math.sin(127.1*t+311.7*e+43758.5453*n);return o-Math.floor(o)>.38?1:0},r=o(t,e),a=o(t-1,e)+o(t+1,e)+o(t,e-1)+o(t,e+1)+o(t-1,e-1)+o(t+1,e-1)+o(t-1,e+1)+o(t+1,e+1);return 1===(1===r?2===a||3===a?1:0:3===a?1:0)?1:.05}default:return 1}}var y={scale:1,offsetX:0,offsetY:0,glow:0,colorBlend:0,proximity:0};function b(t,e,n,o,r,a,i,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*a;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 y.scale=1,y.offsetX=0,y.offsetY=0,y.glow=0,y.colorBlend=0,y.proximity=0,y;const v=w(Math.max(0,1-p/M))*r;let x=1,b=0,S=0,E=0,C=0;switch(c){case"spotlight":{x=1+v*a*1.8;const t=Math.atan2(u,m),e=v*v*a*.6;b=Math.cos(t)*e*i,S=Math.sin(t)*e*s,E=v*a*.4,C=v*v*a*.25;break}case"magnify":x=1+v*a*.85,E=v*a*.15;break;case"repel":{x=1;const t=Math.atan2(u,m),e=v*v*a*1.8;b=Math.cos(t)*e*i,S=Math.sin(t)*e*s;break}case"glow":E=v*a*.8,C=v*a*.4;break;case"colorShift":x=1,E=v*a*.12,C=v*a;break;case"attract":{const t=Math.atan2(u,m),e=v*v*a*1;b=(.45*-Math.cos(t)-1.6*Math.sin(t))*e*i,S=(.45*-Math.sin(t)+1.6*Math.cos(t))*e*s,E=v*a*.3;break}case"shatter":{const t=Math.atan2(u,m),e=.5*Math.sin(43.7*m+29.3*u),n=v*a*1.4*(.7+.3*e);b=Math.cos(t+e)*n*i,S=Math.sin(t+e)*n*s,x=Math.max(.1,1-v*a*.6),E=v*a*.25;break}case"trail":{let n=v,o=-u*v,r=m*v;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=w(1-c)*a.intensity;n=Math.max(n,l),o+=(.35*a.vx-2*s)*l*.35,r+=(.35*a.vy+2*i)*l*.35}b=Math.tanh(2*o)*a*i*3,S=Math.tanh(2*r)*a*s*3,C=n*a*.65,E=n*a*.35,x=1+n*a*.08,y.proximity=n;break}case"glitchText":x=1,E=v*a*.5,C=v*a*.6}return y.scale=x,y.offsetX=b,y.offsetY=S,y.glow=E,y.colorBlend=C,"trail"!==c&&(y.proximity=v),y}function S(t,e,{continuous:n=!1,interactive:o=!1}={}){const r=t.parentElement??t;let a=null,i=0,s=!1,c=!0,l=!0,h=-1/0;const 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 o=!d.matches&&(n||t-h<1500);(l||o)&&(e(t,d.matches?null:a),l=!1),o&&(i=requestAnimationFrame(m))},u=e=>{if("touch"===e.pointerType)return;const n=t.getBoundingClientRect();if(!n.width||!n.height)return;const o=(e.clientX-n.left)/n.width,r=(e.clientY-n.top)/n.height;a=o>=0&&o<=1&&r>=0&&r<=1?{x:o,y:r}:null,h=performance.now(),f()},g=()=>{a=null,h=performance.now(),f()},p=()=>{document.hidden&&i?(cancelAnimationFrame(i),i=0):f()},M="undefined"==typeof IntersectionObserver?null:new IntersectionObserver(([t])=>{c=t.isIntersecting,c?f():i&&(cancelAnimationFrame(i),i=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(i),M?.disconnect(),r.removeEventListener("pointermove",u),r.removeEventListener("pointerleave",g),document.removeEventListener("visibilitychange",p),d.removeEventListener("change",f)}}}var E=null,C=null;function T(t,e){if(!E||!C){const n=a(t,e);E=n.canvas,C=n.ctx}return E.width!==t&&(E.width=t),E.height!==e&&(E.height=e),C}var F=new Map,A=new Map,k=new WeakMap;function R(t){const e=Intl.Segmenter;return e?Array.from(new e(void 0,{granularity:"grapheme"}).segment(t),({segment:t})=>t):[...t]}function I(t){let e=F.get(t);return e||(e=R(t),F.set(t,e)),e}function L(t){return R(t)}function H(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 P(t,e,n,o){const r=`${t}\0${e?1:0}\0${n}\0${o}`;let a=A.get(r);if(!a){const s=I(t);a=new Array(256);for(let t=0;t<256;t++)a[t]=H(i(t,n,o),s,e);A.set(r,a)}return a}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 j(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 z(t,e,n){return Math.max(e,Math.min(n,t))}function O(t,e,n){if(!t)return{x:0,y:0,width:e,height:n};const o=t.unit??"percent",r=!1!==t.preserveAspect,a=t=>void 0===t?void 0:"percent"===o?t*e:t,i=t=>void 0===t?void 0:"percent"===o?t*n:t,s=z(a(t.left)??0,0,e-1),c=z(a(t.right)??0,0,e-s-1),l=z(i(t.top)??0,0,n-1),h=z(i(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:a(t.width),g=d?m:i(t.height);let p=u??e,M=g??n;if(r&&!d){const t=p/e,o=M/n,r=Math.min(t,o),a=void 0===u?o:void 0===g?t:r;p=e*a,M=n*a}p=z(p,1,d?f:e),M=z(M,1,d?m:n);const v=t.anchor??"center",w=a(t.x),x=i(t.y),y=d?s:0,b=d?l:0,S=d?f:e,E=d?m:n,C=v.endsWith("left")||"left"===v?0:v.endsWith("right")||"right"===v?S-p:(S-p)/2,T=v.startsWith("top")||"top"===v?0:v.startsWith("bottom")||"bottom"===v?E-M:(E-M)/2;return{x:z(w??y+C,0,Math.max(0,e-p)),y:z(x??b+T,0,Math.max(0,n-M)),width:p,height:M}}function q(t,e,n,o){const r=t instanceof HTMLVideoElement?t.videoWidth:t.width,a=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(0===r||0===a)return{frame:[],cols:0,rows:0};const c=e.charAspect,h=e.fontSize*e.charSpacing,d=e.fontSize/c*e.charSpacing,f=n||r,m=o||a,u=Math.floor(f/h),g=Math.floor(m/d);if(u<=0||g<=0)return{frame:[],cols:0,rows:0};const p=O(e.sourceCrop,r,a),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,F=null!=C&&!1!==C,A=!0===C,k="blue-screen"===C;let R=null,L=0;!F||A||k||(R=v(C),L=(e.chromaKeyTolerance??60)**2);let $=0,j=255;if(e.normalize){let t=255,e=0;for(let n=0;n<E.length;n+=4){if(F){const t=E[n],e=E[n+1],o=E[n+2];let r=!1;if(A)r=e>1.4*t&&e>1.4*o&&e>80;else if(k)r=o>1.4*t&&o>1.4*e&&o>80;else if(null!==R){const n=t-R.r,a=e-R.g,i=o-R.b;r=n*n+a*a+i*i<=L}if(r)continue}const o=.299*E[n]+.587*E[n+1]+.114*E[n+2];o<t&&(t=o),o>e&&(e=o)}$=t,j=e>t?e-t:255}const z=[],q=W(e.invert),V=F&&e.charset.replace(/ /g,"")||e.charset,B=I(V),U=e.customText?null:P(V,q,e.brightness,e.contrast),N=M*w;for(let t=0;t<g;t++){const n=[];for(let o=0;o<u;o++){let r=0,a=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),i=E[e],s=E[e+1],l=E[e+2],f=E[e+3];if(F){let t=!1;if(A)t=s>1.4*i&&s>1.4*l&&s>80;else if(k)t=l>1.4*i&&l>1.4*s&&l>80;else if(null!==R){const e=i-R.r,n=s-R.g,o=l-R.b;t=e*e+n*n+o*o<=L}if(t){d++;continue}}r+=i,a+=s,c+=l,h+=f}}if(F&&d>N/2){n.push({char:" ",r:0,g:0,b:0,a:0});continue}const f=N-d,m=f>0?r/f:0,g=f>0?a/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-$)/j*255:y,S=i(b,e.brightness,e.contrast),C=e.ditherStrength>0?l(S,o,t,e.ditherStrength):S,T=e.customText?s(C,e.customText,o,t,u,q):e.ditherStrength>0?H(C,B,q):U[Math.max(0,Math.min(255,0|b))];n.push({char:T,r:m,g:g,b:p,a:v,lum:C})}z.push(n)}return{frame:z,cols:u,rows:g}}function V(t,e,n,o){const r=t instanceof HTMLVideoElement?t.videoWidth:t.width,a=t instanceof HTMLVideoElement?t.videoHeight:t.height;if(0===r||0===a)return{rows:[],cols:0,rowCount:0};const s=e.charAspect,c=e.fontSize*e.charSpacing,h=e.fontSize/s*e.charSpacing,d=n||r,f=o||a,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=O(e.sourceCrop,r,a),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 F=null,A=0;!S||E||C||(F=v(b),A=(e.chromaKeyTolerance??60)**2);let k=0,R=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!==F){const n=t-F.r,a=e-F.g,i=o-F.b;r=n*n+a*a+i*i<=A}if(r)continue}const o=.299*y[n]+.587*y[n+1]+.114*y[n+2];o<t&&(t=o),o>e&&(e=o)}k=t,R=e>t?e-t:255}const L=W(e.invert),$=S&&e.charset.replace(/ /g,"")||e.charset,j=I($),z=e.customText?null:P($,L,e.brightness,e.contrast),q=e.customText?I(e.customText):null,V="fullcolor"===e.colorMode?new Uint8ClampedArray(m*u*4):void 0,B=[];for(let t=0;t<u;t++){let n="";for(let o=0;o<m;o++){const r=4*(t*g+o),a=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!==F){const e=s-F.r,n=c-F.g,o=h-F.b;t=e*e+n*n+o*o<=A}if(t){n+=" ",V&&(V[a]=0,V[a+1]=0,V[a+2]=0,V[a+3]=0);continue}}V&&(V[a]=s,V[a+1]=c,V[a+2]=h,V[a+3]=d);const f=.299*s+.587*c+.114*h,u=e.normalize?(f-k)/R*255:f,p=e.ditherStrength>0||q?i(u,e.brightness,e.contrast):u,M=e.ditherStrength>0?l(p,o,t,e.ditherStrength):p;if(q){n+=(L?1-M/255:M/255)<.12?" ":q[(t*m+o)%q.length]}else e.ditherStrength<=0?n+=z[Math.max(0,Math.min(255,0|u))]:n+=H(M,j,L)}B.push(n)}return{rows:B,cols:m,rowCount:u,colors:V}}function B(t,e,n,o,r){if(0===e.rows.length)return;const a=t.canvas,i=Boolean(n.chromaKey)||e.rows.some(t=>t.includes(" "));i||(k.delete(t),t.clearRect(0,0,o,r),t.fillStyle=M(a)?"#0a0a0a":"#faf9f7",t.fillRect(0,0,o,r));const s=j(n.accentColor),c=parseInt(s.substring(0,2),16),l=parseInt(s.substring(2,4),16),h=parseInt(s.substring(4,6),16),d=o/e.cols,f=r/e.rowCount,m=.9*Math.min(d/.55,f),u=e.colors;if("fullcolor"===n.colorMode&&u){k.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=L(e.rows[o]);let a=0;for(;a<e.cols;){for(;a<e.cols&&" "===r[a];)a++;if(a>=e.cols)break;const i=a,s=4*(o*e.cols+a),c=240&u[s],l=240&u[s+1],h=240&u[s+2];for(a++;a<e.cols&&" "!==r[a];){const t=4*(o*e.cols+a);if((240&u[t])!==c||(240&u[t+1])!==l||(240&u[t+2])!==h)break;a++}const m=`rgb(${c},${l},${h})`;m!==n&&(t.fillStyle=m,n=m),t.fillText(r.slice(i,a).join(""),i*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(a)?"rgb(230,230,230)":"rgb(24,24,24)":`rgb(${c},${l},${h})`;t.fillStyle=g,t.globalAlpha=1;const p=k.get(t),v=i&&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))}k.set(t,{rows:e.rows.slice(),cols:e.cols,rowCount:e.rowCount,canvasWidth:o,canvasHeight:r,fillStyle:g}),t.globalAlpha=1}async function U(t,e,n,o,r=12,a=10,i,s=0){const c=Math.min(t.duration-s,a),l=Math.ceil(c*r),h=[];let 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 n=()=>{t.removeEventListener("seeked",n),e()};t.addEventListener("seeked",n)});const u=q(t,e,n,o);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 N(t,e,n,o,r=12,a=10,i,s=0){const c=Math.min(t.duration-s,a),l=Math.ceil(c*r),h=[];let 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 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,i?.((a+1)/l)}return{frames:h,cols:d,rows:f,fps:r}}async function D(t,e,n,o,r){const{parseGIF:a,decompressFrames:i}=await import("gifuct-js"),s=a(t),c=i(s,!0);if(0===c.length)return{frames:[],cols:0,rows:0,fps:10};const l=c[0].dims.width,h=c[0].dims.height,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))),C=Math.min(c.length,300);for(let t=0;t<C;t++){const a=c[t],{dims:i,patch:s,disposalType:l}=a;3===l&&(p.clearRect(0,0,d,f),p.drawImage(m,0,0)),M.width!==i.width&&(M.width=i.width),M.height!==i.height&&(M.height=i.height);const h=new ImageData(new Uint8ClampedArray(s.buffer),i.width,i.height);v.putImageData(h,0,0),u.drawImage(M,i.left||0,i.top||0);const b=q(m,e,n,o);w.push(b.frame),x=b.cols,y=b.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)/C)}return{frames:w,cols:x,rows:y,fps:E}}var K=new WeakMap,Y=new WeakMap,_=new WeakMap;function G(t,e,n,o,r,a=0,i){if(!e.length||!e[0].length||o<=0||r<=0)return;let s=null;if(n.hoverStrength>0){let e=K.get(t);e||(e={x:.5,y:.5,intensity:0,time:-1,emittedAt:-1,points:[]},K.set(t,e)),s=function(t,e,n){const o=t.time<0?1/60:Math.max(0,Math.min(.1,(n-t.time)/1e3));t.time=n;const r=t.intensity<.003,a=t.x,i=t.y;if(e){r&&(t.x=e.x,t.y=e.y);const n=1-Math.exp(-o/.055);t.x+=(e.x-t.x)*n,t.y+=(e.y-t.y)*n}t.intensity+=((e?.intensity??(e?1:0))-t.intensity)*(1-Math.exp(-o/(e?.09:.18)));const s=Math.exp(-o/.22);for(const e of t.points)e.intensity*=s;for(;t.points.length&&t.points[0].intensity<.01;)t.points.shift();return e&&!r&&n-t.emittedAt>=24&&Math.hypot(t.x-a,t.y-i)>5e-4&&(t.points.push({x:t.x,y:t.y,intensity:t.intensity,vx:Math.max(-1,Math.min(1,(t.x-a)/Math.max(o,.001))),vy:Math.max(-1,Math.min(1,(t.y-i)/Math.max(o,.001)))}),t.points.length>12&&t.points.shift(),t.emittedAt=n),!e&&t.intensity<.003&&!t.points.length?(t.intensity=0,null):{x:t.x,y:t.y,intensity:t.intensity,trail:t.points}}(e,i??null,performance.now())}else K.delete(t);if("none"!==n.animationStyle||n.charsetFrames?.length||n.hoverStrength<=0)return _.delete(t),void X(t,e,n,o,r,a,s);const c=Y.get(t);if(c?.frame!==e)return Y.set(t,{frame:e,since:performance.now()}),_.delete(t),void X(t,e,n,o,r,a,s);if(performance.now()-c.since<100)return void X(t,e,n,o,r,a,s);const l=t.getTransform();if(l.b||l.c||l.a<=0||l.d<=0)return void X(t,e,n,o,r,a,s);if(!s||(s.intensity??0)<.003)return void X(t,e,n,o,r,a,null);const h=M(t.canvas),d={...n,accentColor:"#"+j(n.accentColor)},f=JSON.stringify([d,o,r,l.a,l.d,h,void 0!==document.fonts?document.fonts.status:"loaded"]);let m=_.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 a=n.getContext("2d");a.setTransform(l.a,0,0,l.d,0,0),X(a,e,d,o,r,0,null,void 0,h),m={frame:e,key:f,canvas:n},_.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(),X(t,e,d,o,r,a,s,E,h),t.restore()}function X(t,e,n,o,r,a=0,i,s,c){const l=e.length;if(0===l)return;const h=e[0].length;t.clearRect(0,0,o,r);let d=!1;const m=Math.max(1,l>>2),g=Math.max(1,h>>2);t:for(let t=0;t<l;t+=m){const n=e[t];for(let t=0;t<h;t+=g)if(n[t].a<200){d=!0;break t}}const p=t.canvas,v=c??M(p);d||(t.fillStyle=v?"#0a0a0a":"#faf9f7",t.fillRect(0,0,o,r));const w=o/h,y=r/l,S=i?.intensity??1,E=!!(i&&n.hoverStrength>0&&S>.005),C="#"+($(n.hoverColor||"#ffffff")??"ffffff"),T=parseInt(C.slice(1,3),16),F=parseInt(C.slice(3,5),16),A=parseInt(C.slice(5,7),16),k=j(n.accentColor),R=parseInt(k.substring(0,2),16),L=parseInt(k.substring(2,4),16),P=parseInt(k.substring(4,6),16),z=n.hoverRadius;let O=0,q=h,V=0,B=l,U=0,N=0;if(E&&i){U=i.x,N=i.y;const t=.08+.35*z+.04*n.hoverStrength;O=Math.max(0,Math.floor((U-t)*h)-1),q=Math.min(h,Math.ceil((U+t)*h)+1),V=Math.max(0,Math.floor((N-t)*l)-1),B=Math.min(l,Math.ceil((N+t)*l)+1)}if(E&&"trail"===n.hoverEffect)for(const t of i?.trail??[]){const e=.08+.35*z+.04*n.hoverStrength;O=Math.min(O,Math.max(0,Math.floor((t.x-e)*h)-1)),q=Math.max(q,Math.min(h,Math.ceil((t.x+e)*h)+1)),V=Math.min(V,Math.max(0,Math.floor((t.y-e)*l)-1)),B=Math.max(B,Math.min(l,Math.ceil((t.y+e)*l)+1))}const D=n.animationStyle,K=n.animationSpeed,Y="none"===D,_=n.hoverStrength,G=n.hoverEffect,X=z,J=n.hoverShape||"circle",Q=W(n.invert,p),Z=n.colorMode,tt=2*Math.PI,et=1/h,nt=1/l;let ot="",rt=-1;if("dots"===n.renderMode){const c=.5*Math.min(w,y)*n.dotSizeRatio;for(let n=s?.y??0;n<(s?.bottom??l);n++){const d=e[n];for(let e=s?.x??0;e<(s?.right??h);e++){const s=d[e];if(s.a<10)continue;const m=.00392156863*(.299*s.r+.587*s.g+.114*s.b),g=Q?1-m:m;if(g<.02)continue;const p=Y?1:x(e,n,h,l,a,D,K);let M=1,v=0,C=0,k=0,I=0;if(E&&e>=O&&e<=q&&n>=V&&n<=B){const t=b(e*et,n*nt,U,N,S,_,w,y,G,X,J,i?.trail,o/r);M=t.scale,v=t.offsetX,C=t.offsetY,k=t.glow,I=t.colorBlend}const H=c*g*p*M;if(H<.3)continue;const W=e*w+.5*w+v,$=n*y+.5*y+C;let j;if(I>0){const t=u(s,Z,R,L,P,Q);j=`rgb(${Math.min(255,t[0]+(T-t[0])*I|0)},${Math.min(255,t[1]+(F-t[1])*I|0)},${Math.min(255,t[2]+(A-t[2])*I|0)})`}else j=f(s,Z,R,L,P,Q);const z=Math.min(1,.00392156863*s.a*p*(1+k));if(z!==rt&&(t.globalAlpha=z,rt=z),j!==ot&&(t.fillStyle=j,ot=j),H<=3){const e=2*H;t.fillRect(W-H,$-H,e,e)}else t.beginPath(),t.arc(W,$,H,0,tt),t.fill()}}}else{const c=.55,d=.9*Math.min(w/c,y);{const e=/\p{Extended_Pictographic}/u.test(n.customText||n.charset);t.font=e?`${d}px "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif`:`${d}px "JetBrains Mono", monospace`,t.textAlign="center",t.textBaseline="middle"}const m=n.charsetFrames,g=!!m?.length,p=g?m[Math.floor(Math.max(0,a)*(n.charsetFps??2))%m.length]:n.charset,M=t.getTransform();if(!E&&Y&&!g&&"accent"===Z&&!s&&n.hoverStrength<=0&&!/\p{Extended_Pictographic}/u.test(n.customText||n.charset)&&"letterSpacing"in t&&/^[\x20-\x7e]*$/.test(n.customText||n.charset)&&e.every(t=>t.every(t=>t.a<10||255===t.a&&1===t.char.length&&/^[\x20-\x7e]$/.test(t.char)))){const n=t.letterSpacing;t.letterSpacing="0px";const o=t.measureText("M").width;t.letterSpacing=w-o+"px",t.fillStyle=`rgb(${R},${L},${P})`,t.globalAlpha=1,t.textAlign="left";for(let n=0;n<l;n++){const r=e[n];let a="";for(let t=0;t<h;t++){const e=r[t];a+=e.a<10?" ":e.char}0!==a.trim().length&&t.fillText(a,.5*(w-o),n*y+.5*y)}return t.letterSpacing=n,t.textAlign="center",void(t.globalAlpha=1)}const v="glitchText"===G&&E,C="!@#$%^&*<>{}[]|/\\~`0123456789",k=C.length;let W="",$=0,j=0,tt=0,at=0,it=0,st=0;if(v){const t=n.hoverText??"ASCIIFY";if(j=Math.round(U*h),tt=Math.round(N*l),Array.isArray(t)){const e=t.filter(t=>t.length>0);0===e.length&&e.push("ASCIIFY");W=e[((7*Math.floor(j/Math.max(1,Math.ceil(h/5)))+13*Math.floor(tt/Math.max(1,Math.ceil(l/3))))%e.length+e.length)%e.length]}else W=t||"ASCIIFY";$=W.length,at=Math.max(3,Math.min(12,Math.round(l*z*.6)));const e=Math.floor(at/2);it=Math.max(0,tt-e),it+at>l&&(it=Math.max(0,l-at)),st=j-Math.floor($/2)}for(let n=s?.y??0;n<(s?.bottom??l);n++){const c=e[n];for(let d=s?.x??0;d<(s?.right??h);d++){const s=c[d];if(s.a<10)continue;let m=g&&null!=s.lum?H(s.lum,I(p),Q):s.char;if(" "===m)continue;const z=Y?1:x(d,n,h,l,a,D,K);if(z<.05)continue;let ct=1,lt=0,ht=0,dt=0,ft=0;if(E&&!v&&d>=O&&d<=q&&n>=V&&n<=B){const t=b(d*et,n*nt,U,N,S,_,w,y,G,X,J,i?.trail,o/r);if(ct=t.scale,lt=t.offsetX,ht=t.offsetY,dt=t.glow,ft=t.colorBlend,"trail"===G&&t.proximity>0){const o=Math.max(0,Math.min(h-1,Math.round(d-t.offsetX/w))),r=e[Math.max(0,Math.min(l-1,Math.round(n-t.offsetY/y)))][o],a=r.lum??.299*r.r+.587*r.g+.114*r.b;m=H(Math.min(255,a+t.proximity*_*65),I(p),Q)}}if(v&&n>=it&&n<it+at){const t=d-st;if(t>=0&&t<$){const e=W[t],o=Math.abs(n-tt)/Math.max(1,.5*at),r=Math.abs(d-j)/Math.max(1,$),i=Math.max(o,r),s=Math.max(0,Math.min(1,1-.9*i)),c=43758.5453*Math.sin(127.1*d+311.7*n+43758.5453*Math.floor(12*a));m=Math.abs(c-Math.floor(c))<s?e:C[Math.abs(Math.floor(97*c))%k],dt=.3+.7*s,ft=.3+.65*s}}const mt=d*w+.5*w+lt,ut=n*y+.5*y+ht;let gt;if(ft>0){const t=u(s,Z,R,L,P,Q);gt=`rgb(${Math.min(255,t[0]+(T-t[0])*ft|0)},${Math.min(255,t[1]+(F-t[1])*ft|0)},${Math.min(255,t[2]+(A-t[2])*ft|0)})`}else gt=f(s,Z,R,L,P,Q);const pt=Math.min(1,.00392156863*s.a*z*(1+dt));pt!==rt&&(t.globalAlpha=pt,rt=pt),gt!==ot&&(t.fillStyle=gt,ot=gt),1!==ct?(t.translate(mt,ut),t.scale(ct,ct),t.fillText(m,0,0),t.setTransform(M)):t.fillText(m,mt,ut)}}}t.globalAlpha=1}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,a=Math.max(o,Math.min(r,t.duration)),i=tt(e,n),s=o+(a-o)*i;t.currentTime=Math.min(Math.max(o,s),Math.max(o,a-.04)),n.onUpdate?.(i,t)}function 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 a=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()=>a.kill?.()}return function(t,e,n){let o=0;const r=()=>{o=0;const r=e.getBoundingClientRect(),a=window.innerHeight||document.documentElement.clientHeight,i=r.height+a,s=i>0?J((a-r.top)/i):0;et(t,s,n)},a=()=>{o||(o=requestAnimationFrame(r))};return window.addEventListener("scroll",a,{passive:!0}),window.addEventListener("resize",a),a(),()=>{window.removeEventListener("scroll",a),window.removeEventListener("resize",a),o&&cancelAnimationFrame(o)}}(t,n,e)}function at(t,e,n){const o=e.gsap,r=e.ScrollTrigger??o?.ScrollTrigger;if(o&&r?.create){o.registerPlugin?.(r);const a=r.create({trigger:t,start:e.start??"top bottom",end:e.end??"bottom top",scrub:e.scrub??!0,onUpdate:t=>n(t.progress)});return()=>a.kill?.()}return function(t,e){let n=0;const o=()=>{n=0;const o=t.getBoundingClientRect(),r=window.innerHeight||document.documentElement.clientHeight,a=o.height+r,i=a>0?J((r-o.top)/a):0;e(i)},r=()=>{n||(n=requestAnimationFrame(o))};return window.addEventListener("scroll",r,{passive:!0}),window.addEventListener("resize",r),r(),()=>{window.removeEventListener("scroll",r),window.removeEventListener("resize",r),n&&cancelAnimationFrame(n)}}(t,n)}function it(t,e,n){if(!t||!e||!n.sourceCrop)return{w:t,h:e};const o=O(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 a=v(r),i=(o.chromaKeyTolerance??60)**2,s=t-a.r,c=e-a.g,l=n-a.b;return s*s+c*c+l*l<=i}function 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 i=O(e.sourceCrop,o,r),s=Math.min(360,Math.max(1,Math.round(i.width))),c=Math.max(1,Math.round(s*(i.height/i.width))),{ctx:l}=a(s,c);l.drawImage(t,i.x,i.y,i.width,i.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],a=h[o],i=h[o+1],c=h[o+2];r<=8||.2126*a+.7152*i+.0722*c<=d||st(a,i,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 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,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<a?v=w*a:w=v/a;v>e.width&&(v=e.width,w=Math.max(g,Math.min(e.height,v/a)));w>e.height&&(w=e.height,v=Math.max(u,Math.min(e.width,w*a)));let x=p-v/2,y=M-w/2;return x=Math.max(i,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:i.x+f/s*i.width,top:i.y+m/c*i.height,right:o-(i.x+(u+1)/s*i.width),bottom:r-(i.y+(g+1)/c*i.height)},{x:i.x,y:i.y,width:i.width,height:i.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 a=t.currentTime,i=function(t,e,n,o){const r=!0===o?{}:o||{},a=Math.max(0,r.from??e),i=r.to??n??(Number.isFinite(t.duration)?t.duration:a),s=Math.max(a,i-.04),c=Math.max(0,s-a),l=c>.1?[a,a+.25*c,a+.5*c,a+.75*c,s]:[a];return Array.from(new Set(l.map(t=>Math.max(0,Number(t.toFixed(3))))))}(t,n,o,r);let s=null;for(const n of i){await 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,a),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 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,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,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=mt(i.width,s,l,h)??s,f=mt(i.height,c,l,h)??c,m=function(t,e,n,o,r){const a=t=>{const n=mt(t,e,o,r);return n&&n>0?n:0},i=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: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:p,cssH:M}=function(t,e,n,o="contain"){if("fill"===o)return{cssW:t,cssH:e};let r=t,a=r/n;const i="cover"===o,s=a>e;return(i&&!s||!i&&s)&&(a=e,r=a*n),"scale-down"===o&&(r=Math.min(r,t),a=Math.min(a,e)),{cssW:Math.round(r),cssH:Math.round(a)}}(u,g,n,i.objectFit??"contain"),v="undefined"!=typeof window&&window.devicePixelRatio||1;let w,x;o&&r?({renderW:w,renderH:x}=ft({sourceWidth:o,sourceHeight:r,cssWidth:p,cssHeight:M,maxRenderDimension:a})):(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,e,{fontSize:o,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:p=2048,trim:M,scroll:v,maxCachedFrames:w=90,onReady:x,onFrame:y}={}){const b=M?.start??0,E=M?.end,C=o??i.fontSize??10;let T={...r,...n[a],artStyle:a,...i,fontSize:C};const F=e.getContext("2d");if(!F)throw new Error("asciifyVideo: could not get 2d context from canvas.");const A="string"==typeof s?document.querySelector(s):s instanceof HTMLElement?s:null,k={objectFit:c,objectPosition:l,scale:h,width:d,height:f,bleed:m},R=function(t,e){var n;if(!function(t){return void 0!==t.objectFit||void 0!==t.objectPosition||void 0!==t.scale||void 0!==t.width||void 0!==t.height||void 0!==t.bleed}(e))return()=>{};const o={width:t.style.width,height:t.style.height,objectFit:t.style.objectFit,objectPosition:t.style.objectPosition,maxWidth:t.style.maxWidth,maxHeight:t.style.maxHeight,transformOrigin:t.style.transformOrigin,scale:t.style.getPropertyValue("scale")};if(e.objectFit&&(t.style.objectFit=e.objectFit),e.objectPosition&&(t.style.objectPosition=e.objectPosition,t.style.transformOrigin=e.objectPosition),void 0===e.scale&&void 0===e.bleed||(t.style.maxWidth="none",t.style.maxHeight="none"),void 0!==e.scale){const o=Number.isFinite(e.scale)&&e.scale>0?e.scale:1;t.style.setProperty("scale",String(o)),(n=t.style).transformOrigin||(n.transformOrigin=e.objectPosition??"center center")}return()=>{t.style.width=o.width,t.style.height=o.height,t.style.objectFit=o.objectFit,t.style.objectPosition=o.objectPosition,t.style.maxWidth=o.maxWidth,t.style.maxHeight=o.maxHeight,t.style.transformOrigin=o.transformOrigin,o.scale?t.style.setProperty("scale",o.scale):t.style.removeProperty("scale")}}(e,k),I=t=>()=>{t(),R()};if(u){let n;"string"==typeof t?(n=document.createElement("video"),n.crossOrigin="anonymous",n.src=t,n.readyState<2&&await new Promise((e,o)=>{n.onloadeddata=()=>e(),n.onerror=()=>o(new Error(`asciifyVideo: failed to load "${t}"`))})):n=t,T=await ht(n,T,b,E,v);const o=it(n.videoWidth,n.videoHeight,T);A&&ut(e,A,o.w/o.h,o.w,o.h,p,k);const{renderW:r,renderH:a}=dt(o.w,o.h,p),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!==E?E-b:10,h=g??(v?18:void 0);if(Z(T)){const{frames:t,fps:o}=await N(n,T,r,a,h,l,void 0,b),i=e=>{const n=t[e];n&&(F.save(),F.setTransform(c,0,0,c,0,0),B(F,n,T,r,a),F.restore(),y?.())};if(v){let o=!1,r=-1;const a=!0===v?{}:v,s=at(Q(a.trigger)??A??e,a,e=>{const s=tt(e,a),c=Math.max(0,Math.min(t.length-1,Math.round(s*(t.length-1))));c!==r&&(r=c,i(c),o||(o=!0,x?.(n)),a.onUpdate?.(s,n))});return i(0),o=!0,x?.(n),I(s)}let s,d=!1,f=0,m=performance.now(),u=!0;const g=1e3/o,p=e=>{d||(e-m>=g&&(i(f),f=(f+1)%t.length,m=e,u&&(u=!1,x?.(n))),s=requestAnimationFrame(p))};return s=requestAnimationFrame(p),I(()=>{d=!0,cancelAnimationFrame(s)})}const{frames:d,fps:f}=await U(n,T,r,a,h,l,void 0,b);if(!d.length)throw new Error("asciifyVideo: no frames were decoded.");let m=0;const u=performance.now(),M=S(e,(t,e)=>{v||(m=Math.floor((t-u)*f/1e3)%d.length),F.save(),F.setTransform(c,0,0,c,0,0),G(F,d[m],T,r,a,(t-u)/1e3,e),F.restore(),y?.()},{continuous:!v||"none"!==T.animationStyle||!!T.charsetFrames?.length,interactive:T.hoverStrength>0});let w;if(v){const t=!0===v?{}:v;w=at(Q(t.trigger)??A??e,t,e=>{m=Math.max(0,Math.min(d.length-1,Math.round(tt(e,t)*(d.length-1)))),M.wake(),t.onUpdate?.(e,n)})}return x?.(n),I(()=>{M.stop(),w?.()})}let L,H=!1;"string"==typeof t?(L=document.createElement("video"),L.crossOrigin="anonymous",L.src=t,L.muted=!0,L.loop=!0,L.playsInline=!0,L.setAttribute("playsinline",""),Object.assign(L.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(L),H=!0,await new Promise((e,n)=>{L.onloadedmetadata=()=>e(),L.onerror=()=>n(new Error(`asciifyVideo: failed to load "${t}"`))}),await L.play().catch(()=>{})):(L=t,L.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((t,e)=>{const n=()=>{L.removeEventListener("loadedmetadata",o),L.removeEventListener("error",r)},o=()=>{n(),t()},r=()=>{n(),e(new Error("asciifyVideo: provided video element failed to load metadata."))};L.addEventListener("loadedmetadata",o),L.addEventListener("error",r),L.load()}),L.paused&&await L.play().catch(()=>{})),b>0&&(L.currentTime=b,await new Promise(t=>{const e=()=>{L.removeEventListener("seeked",e),t()};L.addEventListener("seeked",e)}),await ot(L));let P=null;(b>0||void 0!==E)&&(P=()=>{(void 0!==E&&L.currentTime>=E||b>0&&L.currentTime<b)&&(L.currentTime=b)},L.addEventListener("timeupdate",P)),T=await ht(L,T,b,E,v);let W=null;const $=it(L.videoWidth,L.videoHeight,T);let{renderW:j,renderH:z}=dt($.w,$.h,p);const O=t=>"frame"===T.chromaKeyTrimMode?ct(t,T,j/z):T;if(A){const t=$.w/$.h,n=$.w,o=$.h,r=ut(e,A,t,n,o,p,k);j=r.renderW,z=r.renderH;const a=e.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0),W=new ResizeObserver(()=>{const r=ut(e,A,t,n,o,p,k);j=r.renderW,z=r.renderH;const a=e.getContext("2d");a&&a.setTransform(r.dpr,0,0,r.dpr,0,0)}),W.observe(A)}else{const t="undefined"!=typeof window&&window.devicePixelRatio||1,n=8e6,o=j*t*z*t>n?Math.sqrt(n/(j*z)):t;e.width===Math.round(j*o)&&e.height===Math.round(z*o)||(e.width=Math.round(j*o),e.height=Math.round(z*o)),F.setTransform(o,0,0,o,0,0)}let D=!0,K=null;const Y=v&&!u,_=g&&g>0?1e3/g:0;let X=0;const et=!Y&&Z(T);if(Y&&"ascii"===T.renderMode&&"none"===T.animationStyle&&T.hoverStrength<=0&&!T.charsetFrames?.length){const t=!0===v?{}:v,n=Q(t.trigger)??A??e,o=t.from??b,r=t.to??E??L.duration,a=Math.max(o,Math.min(r,L.duration)),i=Math.max(.001,a-o),s=Math.min(60,Math.max(12,g??30)),c=Math.max(2,Math.ceil(i*s)+1),l=new Array(c),h=[],d=Math.max(2,Math.min(c,Math.floor(w))),f=()=>{for(;h.length>d;){const t=h.findIndex(t=>t!==u&&Math.abs(t-u)>2),e=t>=0?t:0,n=h.splice(e,1)[0];void 0!==n&&(l[n]=void 0)}},m=t=>{const e=h.indexOf(t);e>=0&&h.splice(e,1),h.push(t),f()};let u=0,p=0,M=-1,S=0,C=!1,k=!1,R=!1;const $=new Set,q=document.createElement("video");q.muted=!0,q.playsInline=!0,q.preload="auto",q.crossOrigin=L.crossOrigin||"anonymous",q.src=L.currentSrc||L.src,Object.assign(q.style,{position:"fixed",top:"0",left:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none",zIndex:"-1"}),document.body.appendChild(q),q.readyState<HTMLMediaElement.HAVE_METADATA&&await new Promise((t,e)=>{const n=()=>{q.removeEventListener("loadedmetadata",o),q.removeEventListener("error",r)},o=()=>{n(),t()},r=()=>{n(),e(new Error("asciifyVideo: cache video failed to load metadata."))};q.addEventListener("loadedmetadata",o),q.addEventListener("error",r),q.load()}),q.pause(),L.paused&&await L.play().catch(()=>{});const U=t=>o+i*t/Math.max(1,c-1),N=t=>Math.max(0,Math.min(c-1,Math.round(t*(c-1)))),D=O(L),Y=V(L,D,j,z);Y.rows.length>0&&(l[0]=Y,m(0),B(F,Y,D,j,z),R=!0,x?.(L),y?.());const G=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[u])return u;for(const t of $)if(!l[t])return t;for(let t=1;t<c;t++){const e=u-t,n=u+t;if(e>=0&&!l[e])return e;if(n<c&&!l[n])return n}return-1},et=t=>{t<0||t>=c||l[t]||($.add(t),ot())},ot=async()=>{if(C||k)return;const t=Z();if(!(t<0)){$.delete(t),k=!0;try{if(await nt(q,U(t)),!C){const e=O(q),n=V(q,e,j,z);n.rows.length>0&&(l[t]=n,m(t))}}finally{k=!1,C||requestAnimationFrame(()=>{ot()})}}},rt=()=>{if(C)return;const t=G(u);if(t>=0&&t!==M){const e=l[t];e&&(B(F,e,T,j,z),M=t,R||(R=!0,x?.(L)),y?.())}else if(t<0||M<0){const t=performance.now();if(_<=0||t-X>=_){const e=O(L),n=V(L,e,j,z);n.rows.length>0&&(B(F,n,e,j,z),X=t,R||(R=!0,x?.(L)),y?.())}}et(u),S=requestAnimationFrame(rt)};return K=at(n,t,e=>{const n=function(t,e,n={}){if(!Number.isFinite(t.duration)||t.duration<=0)return null;const o=n.from??0,r=n.to??t.duration,a=Math.max(o,Math.min(r,t.duration)),i=tt(e,n),s=o+(a-o)*i;return{progress:i,time:Math.min(Math.max(o,s),Math.max(o,a-.04))}}(L,e,{...t,from:o,to:a});p=n?.progress??J(e),u=N(p),et(u),et(u-1),et(u+1),et(u-2),et(u+2),et(u-3),et(u+3),t.onUpdate?.(p,L)}),et(0),et(1),S=requestAnimationFrame(rt),I(()=>{C=!0,cancelAnimationFrame(S),K?.(),W?.disconnect(),$.clear(),h.length=0,l.fill(void 0),q.pause(),q.src="",q.removeAttribute("src"),q.load(),q.isConnected&&q.remove(),P&&L.removeEventListener("timeupdate",P),H&&(L.pause(),L.src="",L.removeAttribute("src"),L.load(),L.isConnected&&L.remove())})}if(Y){const t=!0===v?{}:v;K=rt(L,{...t,trigger:t.trigger??A??e,from:t.from??b,to:t.to??E})}let st=-1,lt=0,ft=-1,mt=0;const gt="function"==typeof L.requestVideoFrameCallback,pt=()=>{mt=L.requestVideoFrameCallback(()=>{lt++,pt()})};gt&&pt();let Mt=0,vt=0,wt=null;const xt=S(e,(t,n)=>{if(L.readyState<2||0===e.width||0===e.height)return;if(_>0&&t-X<_&&!n)return;if(b>0&&L.currentTime<b)return;if(void 0!==E&&L.currentTime>=E)return;const o=(gt?lt!==ft:L.currentTime!==st)||Mt!==j||vt!==z;if(o||!(T.hoverStrength<=0)||"none"!==T.animationStyle||T.charsetFrames?.length){if(et){const t=O(L),e=V(L,t,j,z);B(F,e,t,j,z)}else!o&&wt||(wt=q(L,O(L),j,z).frame),G(F,wt,T,j,z,t/1e3,n);st=L.currentTime,ft=lt,Mt=j,vt=z,X=t,D&&(D=!1,x?.(L)),y?.()}},{continuous:!0,interactive:T.hoverStrength>0});return I(()=>{xt.stop(),mt&&L.cancelVideoFrameCallback(mt),K?.(),W?.disconnect(),P&&L.removeEventListener("timeupdate",P),H&&(L.pause(),L.src="",L.removeAttribute("src"),L.load(),L.isConnected&&L.remove())})}function pt(t,e,n,o="#505050",r=100){if(!t||e<=0||n<=0)return[];const a=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},i=t,s=i.length;return Array.from({length:n},(t,n)=>Array.from({length:e},(t,o)=>({char:i[(n*e+o)%s],r:a.r,g:a.g,b:a.b,a:r})))}var Mt=new WeakMap;function vt(t,{format:e="png",quality:n=.92,scale:o=1}={}){return new Promise((r,a)=>{let i=t;if(1!==o){const e=document.createElement("canvas");e.width=Math.round(t.width*o),e.height=Math.round(t.height*o);const n=e.getContext("2d");if(!n)return void a(new Error("captureSnapshot: could not get 2d context"));n.drawImage(t,0,0,e.width,e.height),i=e}i.toBlob(t=>t?r(t):a(new Error("captureSnapshot: toBlob returned null")),`image/${e}`,n)})}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]??"█",a=Math.max(1,Math.floor(o)),i=7*a,s=a,c=Array.from({length:i},()=>"");for(let e=0;e<t.length;e++){const n=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(a);for(let e=0;e<a;e++)c[t*a+e]+=o}if(e<t.length-1)for(let t=0;t<i;t++)c[t]+=" ".repeat(s)}return c.join("\n")}exports.ART_STYLE_PRESETS=n,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=o,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.asciiText=function(t,e={},n,o){const a={...r,...e},{frame:i,cols:s}=q(t,a,n,o);if(!i.length||0===s)return"";const c=[];for(const t of i)c.push(t.map(t=>t.char).join(""));return c.join("\n")},exports.asciiTextAnsi=function(t,e={},n,o){const a={...r,...e},{frame:i,cols:s}=q(t,a,n,o);if(!i.length||0===s)return"";const c=[];for(const t of i){let e="";for(const n of t)" "===n.char||n.a<10?e+=" ":e+=`[38;2;${n.r};${n.g};${n.b}m${n.char}`;c.push(e)}return c.join("\n")},exports.asciify=async function(t,e,{fontSize:o,artStyle:a="classic",options:i={}}={}){let s;if("string"==typeof t){const e=new Image;e.crossOrigin="anonymous",await new Promise((n,o)=>{e.onload=()=>n(),e.onerror=()=>o(new Error(`Failed to load image: ${t}`)),e.src=t}),s=e}else t instanceof HTMLImageElement&&!t.complete?(await new Promise((e,n)=>{t.onload=()=>e(),t.onerror=()=>n(new Error("Image failed to load"))}),s=t):s=t;const c=n[a],l=o??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}=dt(f,m),p="undefined"!=typeof window&&window.devicePixelRatio||1,M=8e6,v=u*p*g*p>M?Math.sqrt(M/(u*g)):p;e.width===Math.round(u*v)&&e.height===Math.round(g*v)||(e.width=Math.round(u*v),e.height=Math.round(g*v));const{frame:w}=q(s,h,u,g),x=(t,e)=>{d.save(),d.setTransform(v,0,0,v,0,0),G(d,w,h,u,g,t/1e3,e),d.restore()};return x(0,null),S(e,x,{continuous:"none"!==h.animationStyle||!!h.charsetFrames?.length,interactive:h.hoverStrength>0}).stop},exports.asciifyGif=async function(t,e,{fontSize:o,artStyle:a="classic",options:i={}}={}){const s="string"==typeof t?await fetch(t).then(t=>t.arrayBuffer()):t,c=o??i.fontSize??10;let l={...r,...n[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 D(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 S(e,(t,n)=>{const o=Math.floor((t-m)*f/1e3)%d.length;o===u&&!n&&l.hoverStrength<=0&&"none"===l.animationStyle&&!l.charsetFrames?.length||(G(h,d[o],l,e.width,e.height,(t-m)/1e3,n),u=o)},{continuous:!0,interactive:l.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:e=10,style:o="classic",options:a={},liveOptions:i,mirror:s=!0,constraints:c={facingMode:"user"},dpr:l}={}){if(!navigator.mediaDevices?.getUserMedia)throw new Error("asciifyWebcam: getUserMedia is not supported in this browser.");const h=await navigator.mediaDevices.getUserMedia({video:c}),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,...n[o],...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 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,a=i?{...f,...i()}:f;a.hoverStrength>0?(t.addEventListener("mousemove",p),t.addEventListener("mouseleave",M)):(t.removeEventListener("mousemove",p),t.removeEventListener("mouseleave",M));const{frame:c}=q(d,a,n,o),l=g&&s?{x:1-g.x,y:g.y}:g;s?(m.save(),m.scale(-1,1),m.translate(-n,0),G(m,c,a,n,o,r,l),m.restore()):G(m,c,a,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(){F.clear(),A.clear(),K=new WeakMap,_=new WeakMap,Y=new WeakMap,E=null,C=null},exports.computeCanvasRenderSize=ft,exports.createVideoScrollScrub=rt,exports.gifToAsciiFrames=D,exports.gifToAsciiTextFrames=async function(t,e,n,o,r){const{parseGIF:a,decompressFrames:i}=await import("gifuct-js"),s=a(t),c=i(s,!0);if(0===c.length)return{frames:[],cols:0,rows:0,fps:10};const l=c[0].dims.width,h=c[0].dims.height,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))),C=Math.min(c.length,300);for(let t=0;t<C;t++){const a=c[t],{dims:i,patch:s,disposalType:l}=a;3===l&&(p.clearRect(0,0,d,f),p.drawImage(m,0,0)),M.width!==i.width&&(M.width=i.width),M.height!==i.height&&(M.height=i.height);const h=new ImageData(new Uint8ClampedArray(s.buffer),i.width,i.height);v.putImageData(h,0,0),u.drawImage(M,i.left||0,i.top||0);const b=V(m,e,n,o);w.push(b),x=b.cols,y=b.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)/C)}return{frames:w,cols:x,rows:y,fps:E}},exports.imageToAsciiFrame=q,exports.imageToAsciiTextFrame=V,exports.renderFrameToCanvas=G,exports.renderTextBackground=function(t,e,n,o,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)),p=Math.max(1,Math.floor(n/(s*c))),M=JSON.stringify([o,g,p,l,h]);let v=Mt.get(t);v&&v.key===M||(v={key:M,frame:pt(o,g,p,l,h)},Mt.set(t,v)),G(t,v.frame,{...r,fontSize:s,hoverEffect:d,hoverStrength:f,hoverRadius:m,hoverColor:u},e,n,0,i??null)},exports.renderTextFrameToCanvas=B,exports.renderTextToCanvas=function(t,e,n={}){const{color:o="#d4ff00",bgColor:r,fontSize:a=10}=n,i=bt(e,n);if(!i)return;const s=i.split("\n"),c=Math.max(...s.map(t=>[...t].length));t.width=Math.ceil(c*a*.6),t.height=Math.ceil(s.length*a);const l=t.getContext("2d");r&&"transparent"!==r?(l.fillStyle=r,l.fillRect(0,0,t.width,t.height)):l.clearRect(0,0,t.width,t.height),l.fillStyle=o,l.font=`${a}px monospace`,l.textBaseline="top",s.forEach((t,e)=>l.fillText(t,0,e*a))},exports.snapshotAndDownload=async function(t,e={}){const{filename:n="asciify-snapshot",format:o="png",...r}=e,a=await vt(t,{format:o,...r}),i="jpeg"===o?"jpg":o,s=document.createElement("a");s.href=URL.createObjectURL(a),s.download=`${n}.${i}`,s.click(),setTimeout(()=>URL.revokeObjectURL(s.href),1e4)},exports.videoToAsciiFrames=U,exports.videoToAsciiTextFrames=N;//# sourceMappingURL=core.cjs.map
package/dist/core.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { e as AsciiOptions, d as AsciiFrame, b as ArtStyle, k as HoverEffect } from './types-w2CRgyk6.cjs';
2
- export { A as ART_STYLE_PRESETS, a as AnimationStyle, c as AsciiCell, 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, 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-w2CRgyk6.cjs';
1
+ import { e as AsciiOptions, d as AsciiFrame, b as ArtStyle, k as HoverEffect } from './types-Cixur2pN.cjs';
2
+ export { A as ART_STYLE_PRESETS, a as AnimationStyle, c as AsciiCell, 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, 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-Cixur2pN.cjs';
3
3
 
4
4
  /**
5
5
  * Core frame-to-canvas renderer and source-to-frame converters.
package/dist/core.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { e as AsciiOptions, d as AsciiFrame, b as ArtStyle, k as HoverEffect } from './types-w2CRgyk6.js';
2
- export { A as ART_STYLE_PRESETS, a as AnimationStyle, c as AsciiCell, 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, 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-w2CRgyk6.js';
1
+ import { e as AsciiOptions, d as AsciiFrame, b as ArtStyle, k as HoverEffect } from './types-Cixur2pN.js';
2
+ export { A as ART_STYLE_PRESETS, a as AnimationStyle, c as AsciiCell, 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, 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-Cixur2pN.js';
3
3
 
4
4
  /**
5
5
  * Core frame-to-canvas renderer and source-to-frame converters.