@hyperframes/producer 0.8.204 → 0.8.205
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/distributed.js +17 -5
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +1 -1
- package/dist/index.js +17 -5
- package/dist/public-server.js +17 -5
- package/package.json +7 -7
package/dist/distributed.js
CHANGED
|
@@ -1828,6 +1828,8 @@ import {
|
|
|
1828
1828
|
readDeclaredDefaults,
|
|
1829
1829
|
parseHostVariableValues,
|
|
1830
1830
|
headStyleRuns,
|
|
1831
|
+
isAlwaysAppliedStyle,
|
|
1832
|
+
dedupeFontFaceRules,
|
|
1831
1833
|
inlineScriptRuns,
|
|
1832
1834
|
parsesAsScript,
|
|
1833
1835
|
styleElementsFor,
|
|
@@ -2120,12 +2122,12 @@ function resolveClipWindowSeconds(img, compositionDuration) {
|
|
|
2120
2122
|
}
|
|
2121
2123
|
return null;
|
|
2122
2124
|
}
|
|
2123
|
-
function resolvePreparedPlayback(metadata,
|
|
2125
|
+
function resolvePreparedPlayback(metadata, loopOverride, windowSeconds) {
|
|
2124
2126
|
const gifDuration = metadata.durationSeconds > 0 ? metadata.durationSeconds : null;
|
|
2125
2127
|
let loopIterations = 1;
|
|
2126
|
-
if (
|
|
2128
|
+
if (resolveLoop(metadata, loopOverride)) {
|
|
2127
2129
|
loopIterations = windowSeconds != null && gifDuration != null ? Math.min(MAX_LOOP_ITERATIONS, Math.max(1, Math.ceil(windowSeconds / gifDuration))) : 1;
|
|
2128
|
-
} else if (metadata.loopCount != null && metadata.loopCount > 1) {
|
|
2130
|
+
} else if (loopOverride == null && metadata.loopCount != null && metadata.loopCount > 1) {
|
|
2129
2131
|
loopIterations = Math.min(MAX_LOOP_ITERATIONS, metadata.loopCount);
|
|
2130
2132
|
}
|
|
2131
2133
|
let padSeconds = 0;
|
|
@@ -2292,9 +2294,14 @@ async function prepareAnimatedGifInputs(html, options) {
|
|
|
2292
2294
|
const bytes = readFileSync2(sourcePath);
|
|
2293
2295
|
const metadata = parseAnimatedGifMetadata(bytes);
|
|
2294
2296
|
if (!metadata?.animated) continue;
|
|
2295
|
-
const
|
|
2297
|
+
const loopOverride = readLoopOverride(img);
|
|
2298
|
+
const loop = resolveLoop(metadata, loopOverride);
|
|
2296
2299
|
const windowSeconds = resolveClipWindowSeconds(img, compositionDuration);
|
|
2297
|
-
const { loopIterations, padSeconds } = resolvePreparedPlayback(
|
|
2300
|
+
const { loopIterations, padSeconds } = resolvePreparedPlayback(
|
|
2301
|
+
metadata,
|
|
2302
|
+
loopOverride,
|
|
2303
|
+
windowSeconds
|
|
2304
|
+
);
|
|
2298
2305
|
const hash = computePreparedGifHash(bytes, loopIterations, padSeconds);
|
|
2299
2306
|
const filename = `${CACHE_SCHEMA}-${hash.slice(0, 24)}.webm`;
|
|
2300
2307
|
const cachePath = join4(cacheDir, filename);
|
|
@@ -2960,6 +2967,11 @@ function coalesceHeadStylesAndBodyScripts(html) {
|
|
|
2960
2967
|
const head = document2.querySelector("head");
|
|
2961
2968
|
const body = document2.querySelector("body");
|
|
2962
2969
|
if (!head && !body) return html;
|
|
2970
|
+
const liveStyles = [...document2.querySelectorAll("style")].filter(isAlwaysAppliedStyle);
|
|
2971
|
+
const dedupedStyles = dedupeFontFaceRules(liveStyles.map((el) => el.textContent || ""));
|
|
2972
|
+
liveStyles.forEach((el, i) => {
|
|
2973
|
+
el.textContent = dedupedStyles[i] ?? "";
|
|
2974
|
+
});
|
|
2963
2975
|
const styleEls = head ? Array.from(head.querySelectorAll("style")) : [];
|
|
2964
2976
|
const importRe = /@import\s+url\([^)]*\)\s*;|@import\s+["'][^"']+["']\s*;/gi;
|
|
2965
2977
|
for (const run of styleEls.length > 1 ? headStyleRuns(styleEls) : []) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "0.1.0",
|
|
3
3
|
"buildId": "dev",
|
|
4
|
-
"sha256": "
|
|
4
|
+
"sha256": "5eb70bc91857dda413466347acea0d0d51a916f954755c7294546bb4e0465065",
|
|
5
5
|
"artifacts": {
|
|
6
6
|
"iife": "hyperframe.runtime.iife.js",
|
|
7
7
|
"esm": "hyperframe.runtime.mjs"
|
|
@@ -361,7 +361,7 @@ ${e.replace(/<\/(script)/gi,"<\\/$1")}
|
|
|
361
361
|
};
|
|
362
362
|
__hfFindRoot();
|
|
363
363
|
__hfRecordAnimations(__hfRun);
|
|
364
|
-
})();`}function _l(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function WL(e){return _l(e)&&Object.values(e).every(_l)}var qS=(e,t)=>e&&Object.fromEntries(Object.entries(e).map(([n,r])=>[n,typeof r=="string"?t(r):null]));function zS(e,t){let n;try{n=JSON.parse(e)}catch{return null}if(!_l(n))return null;let{imports:r,scopes:o}=n;return r!==void 0&&!_l(r)||o!==void 0&&!WL(o)?null:{imports:qS(r,t),scopes:o&&Object.fromEntries(Object.entries(o).map(([i,a])=>[t(i),qS(a,t)??{}]))}}var Cf="text/hf-after-fonts",KS=`${Cf}+module`,YS=`script[type="${Cf}"], script[type="${KS}"]`,XS="__hfAfterFontsClaimed",VL="data-hf-inlined-src";var JS=`[defer][src], [defer][${VL}]`;function Cl(e){let t=e.getAttribute("type");return t===Cf?null:t===KS?"module":t}function $L(e){let t=e.getAttribute("type")??"",n=e.tagName.toLowerCase()==="link"?t.split(";")[0].trim():t;if(n!==""&&n.toLowerCase()!=="text/css")return;let r=(e.getAttribute("media")??"").trim().toLowerCase();return JSON.stringify([r==="all"?"":r,e.getAttribute("title")??""])}var l5=JSON.stringify(["",""]);function jS(e){return JSON.stringify([e.getAttribute("href"),(e.getAttribute("rel")??"").trim().toLowerCase(),$L(e)??e.getAttribute("type"),e.hasAttribute("disabled")])}function QS(e,t){let n=jS(t);return[...e.querySelectorAll("link[href]")].some(r=>!r.closest("noscript")&&jS(r)===n)}var et="id",Tf="data-hf-authored-id",mo=/(url\(\s*)(["']?)#([^"')\s]+)\2(\s*\))/gi;function eE(e){return e==="href"||e.endsWith(":href")}function qL(e){return e.replace(/[^a-zA-Z0-9_-]/g,"-")}function Rf(e,t){return!e||!e.toLowerCase().includes("url(")?e:e.replace(mo,(n,r,o,i,a)=>{let l=t.get(i);return l?`${r}${o}#${l}${o}${a}`:n})}function zL(e,t,n){if(eE(e)&&t.startsWith("#")){let o=n.get(t.slice(1));return o?`#${o}`:t}mo.lastIndex=0;let r=mo.test(t);return mo.lastIndex=0,r?Rf(t,n):null}function jL(e,t,n){if(e.name===_t||e.name===et)return{kind:"skip"};let r=t&&e.value===t.after?t.before:e.value,o=zL(e.name,r,n);return o!==null?{kind:"managed",before:r,after:o}:t?{kind:"retain",alias:t}:{kind:"skip"}}function KL(e,t,n,r){let o=e.namespaceURI===void 0&&e.name==="xlink:href"&&r;return{name:e.name,localName:o?"href":e.localName,namespaceURI:o?"http://www.w3.org/1999/xlink":e.namespaceURI??null,before:t,after:n}}function YL(e,t){let n=new Map(nr(e,_t,!1).map(i=>[i.name,i])),r=[...n.values()].filter(i=>i.name===et),o=!!e.closest("svg");for(let i of e.attributes?Array.from(e.attributes):[]){let a=jL(i,n.get(i.name),t);if(a.kind!=="skip"){if(a.kind==="retain"){r.push(a.alias);continue}a.after!==i.value&&(i.namespaceURI?e.setAttributeNS(i.namespaceURI,i.name,a.after):e.setAttribute(i.name,a.after)),r.push(KL(i,a.before,a.after,o))}}r.length&&e.setAttribute(_t,JSON.stringify(r))}function ZS(e,t,n){let r;for(mo.lastIndex=0;r=mo.exec(e);){let o=r[3];t.has(o)&&n.add(o)}}function XL(e,t,n){if(eE(e.name)&&e.value.startsWith("#")){let r=e.value.slice(1);t.has(r)&&n.add(r)}}function JL(e,t,n){let r=new Set;for(let o of e)for(let i of o.attributes?Array.from(o.attributes):[])!i.value||i.name===_t||(XL(i,n,r),i.value.toLowerCase().includes("url(")&&ZS(i.value,n,r));for(let o of t)o.toLowerCase().includes("url(")&&ZS(o,n,r);return r}function tE(e,t){return t.some(n=>n===e||n.contains(e))}function QL(e){let t=e.exclude??[],n=[...e.root.querySelectorAll("*")],r=t.length?n.filter(o=>!tE(o,t)):n;return[e.root,...r]}function ZL(e){let t=e.exclude??[],n=[...e.root.querySelectorAll("svg [id], svg[id]")];return t.length?n.filter(r=>!tE(r,t)):n}function eN(e){let t=QL(e),n=new Set;if(!e.namespace)return{elements:t,renamable:n};let r=ZL(e),o=new Set;for(let a of r){let l=a.getAttribute(et);l&&o.add(l)}if(o.size===0)return{elements:t,renamable:n};let i=JL(t,e.cssTexts??[],o);for(let a of r){let l=a.getAttribute(et);l&&i.has(l)&&n.add(a)}return{elements:t,renamable:n}}function nE(e){if(!e.closest("svg"))return null;let t=nr(e,_t,!1).find(n=>n.name===et);return t?e.getAttribute(et)===t.after?t.before:null:e.getAttribute(Tf)}function tN(e){let t=new Map,n=new Set;for(let r of e.querySelectorAll("[id]")){let o=r.getAttribute(et);if(!o)continue;n.add(o);let i=t.get(o);i?i.push(r):t.set(o,[r]);let a=nE(r);if(a&&a!==o){let l=t.get(a);l?l.push(r):t.set(a,[r])}}return{elementsById:t,usedIds:n}}function nN(e,t,n){let r=`${qL(e)}--${t}`,o=r;for(let i=2;n.has(o);i+=1)o=`${r}-${i}`;return n.add(o),o}function rN(e,t,n){let r=t.find(a=>!n.has(a))??t[0],i=t.filter(a=>a!==r&&a.getAttribute(et)===e).map(a=>n.get(a));return new Set(i.filter(a=>a!==void 0))}function oN(e,t,n){let r=t.map(()=>new Map);for(let[o,i]of e.elementsById)if(!(i.length<2))for(let a of rN(o,i,n))r[a].set(o,nN(t[a].namespace,o,e.usedIds));return r}function iN(e,t,n){let r=new Map;for(let[o,i]of e.elementsById){let a=i[0],l=a.getAttribute(et);if(l!==o){r.set(o,l);continue}let s=n.get(a),c=s===void 0?void 0:t[s].get(o);c&&r.set(o,c)}return r}function aN(e){let t=new Set(e.map(r=>r.getAttribute(et))),n=new Map;for(let r of e){let o=nE(r),i=r.getAttribute(et);!o||!i||(t.add(o),n.set(o,i))}return{ids:t,renamed:n}}function sN(e,t){for(let n of e.elements){let r=n.getAttribute(et);if(r&&e.renamable.has(n)&&t.has(r)){n.hasAttribute(Tf)||n.setAttribute(Tf,r);let o=t.get(r),i=nr(n,_t,!1);i.push({name:et,localName:et,namespaceURI:null,before:r,after:o}),n.setAttribute(_t,JSON.stringify(i)),n.setAttribute(et,o)}YL(n,t)}}function rE(e,t,n){if(t.length===0)return[];let r=tN(e),o=t.map(eN),i=o.flatMap(({renamable:d})=>[...d]);if(n)for(let d of o)for(let f of d.renamable)n.has(f)&&d.renamable.delete(f);let a=new Map;o.forEach(({renamable:d},f)=>{for(let m of d)a.set(m,f)});let l=oN(r,t,a),s=iN(r,l,a),c=o.map((d,f)=>{let m=aN(t[f].referenceTarget==="document"?[]:d.elements),p=[...s].filter(([b])=>!m.ids.has(b));return new Map([...p,...m.renamed,...l[f]])});c.forEach((d,f)=>{sN(o[f],d)});for(let d of i)n?.add(d);return c}function oE(e,t,n=[]){if(!e||t.size===0&&n.length===0||!e.includes("#")&&!e.includes("[")&&!e.toLowerCase().includes("url("))return e;let r;try{r=wl.parse(e)}catch{return e}let o=!1,i=new Set(n.filter(l=>l.name===et).map(l=>l.before)),a=[...t].filter(([l])=>!i.has(l)).map(([l,s])=>({id:l,replacement:`:is(#${Xt(l)}, #${Xt(s)})`}));return r.walkRules(l=>{let s=l.selectors.map(c=>qa(c,a,n));s.some((c,d)=>c!==l.selectors[d])&&(l.selectors=s,o=!0)}),r.walkDecls(l=>{let s=Rf(l.value,t);s!==l.value&&(l.value=s,o=!0)}),r.walkAtRules(l=>{if(!l.params)return;let s=Rf(l.params,t);s!==l.params&&(l.params=s,o=!0)}),o?r.toResult({map:!1}).css:e}var Mf=5e3;window[XS]=!0;async function Vi(){let e=document.fonts;if(!e)return;document.body?.offsetHeight;let t,n=await Promise.race([e.ready.then(()=>!1),new Promise(o=>t=setTimeout(o,Mf,!0))]);if(clearTimeout(t),!n)return;let r=[...new Set(Array.from(e).filter(o=>o.status==="loading").map(o=>o.family))];globalThis.console.warn(`[hyperframes] fonts still loading after ${Mf} ms, composition scripts run without them: ${r.join(", ")}`),Ce({source:"hf-preview",type:"diagnostic",code:"runtime_font_wait_timeout",details:{loadingFamilies:r,timeoutMs:Mf}})}function lN(e,t){let n=Object.getOwnPropertyDescriptor(e,"addEventListener"),r=e.addEventListener,o=(i,a,l)=>{if(!a)return;i==="DOMContentLoaded"||i==="load"&&e===window&&document.readyState==="complete"?t.push({target:e,type:i,listener:a}):r.call(e,i,a,l)};return e.addEventListener=o,()=>{e.addEventListener===o&&(n?Object.defineProperty(e,"addEventListener",n):delete e.addEventListener)}}function uN(e){if(!e.isConnected)return;let t=document.createElement("script");for(let{name:r,value:o}of Array.from(e.attributes))t.setAttribute(r,o);let n=Cl(e);return n===null?t.removeAttribute("type"):t.setAttribute("type",n),t.async=e.hasAttribute("async"),t.text=e.textContent??"",e.replaceWith(t),t}var cN=50,dN=()=>!window.__HF_VIRTUAL_TIME__;function fN(){let e=globalThis.scheduler;return typeof e?.yield=="function"?e.yield():new Promise(t=>{let n=new MessageChannel;n.port1.onmessage=()=>{n.port1.close(),t()},n.port2.postMessage(null)})}var mN=e=>new Promise(t=>{e.addEventListener("load",t),e.addEventListener("error",t)});function pN(){let e=document.createElement("script");e.type="module",e.async=!1,e.text='document.dispatchEvent(new Event("hf-after-fonts-modules"))';let t=new Promise(n=>document.addEventListener("hf-after-fonts-modules",n,{once:!0}));return document.body.appendChild(e),t.then(()=>e.remove())}async function Tl(e,t){await Vi();let n=l=>Cl(l)==="module"||l.matches(JS),r=[],o=[document,window].map(l=>lN(l,r)),i=dN(),a=performance.now();for(let l of[...e.filter(s=>!n(s)),...e.filter(n)]){i&&performance.now()-a>cN&&(await fN(),a=performance.now());let s=uN(l);s?.hasAttribute("src")&&!s.async&&!s.noModule?await mN(s):Cl(l)==="module"&&await pN()}for(let l of o)l();t?.();for(let{target:l,type:s,listener:c}of r){let d=new Event(s);try{typeof c=="function"?c.call(l,d):c.handleEvent(d)}catch(f){reportError(f)}}}var hN=["data-composition-id","data-composition-file","data-start","data-duration","data-end","data-track-index","data-track","data-composition-src","data-hf-authored-duration","data-hf-authored-end"];function iE(e){let t=e.getAttribute("id")?.trim();for(let n of hN)e.removeAttribute(n);t&&(e.removeAttribute("id"),e.setAttribute("data-hf-authored-id",t)),e.setAttribute("data-hf-inner-root","true")}var gN=8e3,bN=/^(?![a-zA-Z][a-zA-Z\d+\-.]*:)(?!\/\/)(?!\/)(?!\.\.?\/).+/,yN=/\burl\(\s*(["']?)([^)"']+)\1\s*\)/g,xN=["src","href"];function SN(e){return!e||e.startsWith("http://")||e.startsWith("https://")||e.startsWith("//")||e.startsWith("data:")||e.startsWith("#")||e.startsWith("/")}function dE(e,t){if(!t)return e;let n=e.trim();if(SN(n)||!n.startsWith("../")&&n!=="..")return e;try{return new URL(n,t).href}catch{return e}}function fE(e,t){return!t||!e?e:e.replace(yN,(n,r,o)=>{let i=dE(o||"",t);return i===o?n:`url(${r||""}${i}${r||""})`})}function EN(e,t){for(let n of Array.from(e.querySelectorAll("[src], [href]")))for(let r of xN){let o=n.getAttribute(r);if(o==null)continue;let i=dE(o,t);i!==o&&n.setAttribute(r,i)}}function vN(e,t){for(let n of Array.from(e.querySelectorAll("[style]"))){let r=n.getAttribute("style");if(r==null)continue;let o=fE(r,t);o!==r&&n.setAttribute("style",o)}}function AN(e,t){for(let n of Array.from(e.querySelectorAll("style"))){let r=n.textContent||"",o=fE(r,t);o!==r&&(n.textContent=o)}}function mE(e,t){if(t){EN(e,t),vN(e,t),AN(e,t);for(let n of Array.from(e.querySelectorAll("template")))mE(n.content,t)}}function aE(e,t){return`${e}__hf${t}`}var wN=e=>new Promise(t=>{let n=!1,r=Date.now(),o=null,i=a=>{n||(n=!0,o!=null&&window.clearTimeout(o),t({status:a,elapsedMs:Math.max(0,Date.now()-r)}))};e.addEventListener("load",()=>i("load"),{once:!0}),e.addEventListener("error",()=>i("error"),{once:!0}),o=window.setTimeout(()=>i("timeout"),gN)});function Nf(e){for(;e.firstChild;)e.removeChild(e.firstChild);e.textContent=""}function kf(e){for(let t of sx(e))t.remove()}function _N(e){let t=document.importNode(e,!0);iE(t);let n=dr(t.getAttribute("data-width")),r=dr(t.getAttribute("data-height"));return t.style.width=n===null?"100%":`${n}px`,t.style.height=r===null?"100%":`${r}px`,t}function sE(e,t){let n=e.trim();if(!n)return e;try{return bN.test(n)&&!n.startsWith("#")&&!n.startsWith("?")?new URL(n,document.baseURI).toString():t?new URL(n,t).toString():new URL(n,document.baseURI).toString()}catch{return e}}function lE(e,t){try{let n=new URL(e),r=new URL(t);return n.search="",n.hash="",r.search="",r.hash="",n.href===r.href}catch{return!1}}function $i(e){let t=(e.getAttribute("data-composition-id")||"").trim()||null;return{authoredCompositionId:(e.getAttribute("data-hf-original-composition-id")||t||"").trim()||null,runtimeCompositionId:t}}function CN(e){let t=new Map;for(let n of e){let r=$i(n).authoredCompositionId||"";r&&t.set(r,(t.get(r)||0)+1)}return ux(t,e),t}function pE(e){let t=$i(e).authoredCompositionId;return t?!!document.querySelector(`template#${CSS.escape(t)}-template`):!1}function TN(e){return!!e.querySelector('[data-hf-inner-root="true"]')}function uE(e){return e.hasAttribute("data-composition-src")?!0:pE(e)?e.children.length===0||e.hasAttribute("data-hf-original-composition-id")?!0:TN(e):!1}function Rl(){return Array.from(document.querySelectorAll("[data-composition-src], [data-composition-id]")).filter(t=>t.hasAttribute("data-composition-src")?!0:pE(t))}function Ff(){let e=window.__hfVariablesByComp;if(!e)return;let t=new Set(Rl().map(n=>$i(n).runtimeCompositionId).filter(n=>!!n));for(let n of Object.keys(e))t.has(n)||delete e[n]}function hE(e,t){let n=CN(e),r=new Set(e.flatMap(a=>{let l=$i(a),s=l.authoredCompositionId?[l.authoredCompositionId]:[];return(t.has(a)||!uE(a))&&l.runtimeCompositionId&&s.push(l.runtimeCompositionId),s})),o=new Map,i=new Map;for(let a of e){let{authoredCompositionId:l,runtimeCompositionId:s}=$i(a),c=!t.has(a)&&uE(a);if(!l){i.set(a,{authoredCompositionId:null,runtimeCompositionId:s});continue}let d=(n.get(l)||0)>1,f=s||l;if(c){let m=d?(o.get(l)||0)+1:0;if(d){for(;r.has(aE(l,m));)m+=1;o.set(l,m)}f=d?aE(l,m):l,r.add(f),d?a.setAttribute("data-hf-original-composition-id",l):a.removeAttribute("data-hf-original-composition-id"),a.setAttribute("data-composition-id",f)}i.set(a,{authoredCompositionId:l,runtimeCompositionId:f})}return Ff(),i}async function gE(e){let t=lx({contentNode:e.sourceNode,head:e.head,hasTemplate:e.hasTemplate,compositionId:e.authoredCompositionId}),n=we(t.innerRoot)?t.innerRoot:null,r=n??e.sourceNode,o=t.authoredCompositionId,i=t.scriptCompositionId,a=e.runtimeCompositionId||null,l=t.authoredRootId,s=a?`[data-composition-id="${CSS.escape(a)}"]`:void 0;for(let y of t.linkSources){let x=(y.getAttribute("href")||"").trim();if(!x)continue;let E=e.compositionUrl?new URL(x,e.compositionUrl).href:x;if(e.compositionUrl&&lE(E,e.compositionUrl))continue;let v=y.cloneNode(!0);Zh(v)&&(v.href=E,!QS(document.head,v)&&(document.head.appendChild(v),e.injectedLinks.push(v)))}let c=[];(y=>{for(let x of y){let E=x.cloneNode(!0);if(!Qh(E))continue;o&&(E.textContent=WS(E.textContent||"",o,s,l,{scopeRootSelectors:!0})),document.head.appendChild(E),e.injectedStyles.push(E);let v=E.textContent||"";c.push({element:E,authored:v,applied:v})}})(t.styleSources);let f=y=>{let x=y.getAttribute("type")?.trim()??"",E=y.getAttribute("src")?.trim()??"";if(E){let _=sE(E,e.compositionUrl);return e.compositionUrl&&lE(_,e.compositionUrl)?null:{kind:"external",src:_,type:x}}let v=y.textContent?.trim()??"";return v?{kind:"inline",content:v,type:x,scopeCompositionId:i}:null},m=t.scriptSources.map(f).filter(y=>y!==null);if(n){let y=n.getAttribute("data-width"),x=n.getAttribute("data-height"),E=e.parseDimensionPx(y),v=e.parseDimensionPx(x);y&&e.host.setAttribute("data-width",y),x&&e.host.setAttribute("data-height",x),E&&we(e.host)&&(e.host.style.width=E),v&&we(e.host)&&(e.host.style.height=v),n.hasAttribute("data-timeline-locked")&&e.host.setAttribute("data-timeline-locked","");let _=_N(n);!e.authoredCompositionId&&o&&_.setAttribute("data-composition-id",o),kf(_),e.host.appendChild(_)}else if(e.hasTemplate){let y=document.importNode(r,!0);kf(y),e.host.appendChild(y)}else e.host.innerHTML=e.fallbackBodyInnerHtml,kf(e.host);for(let y of t.inertScriptsOutsideRoot)e.host.appendChild(document.importNode(y,!0));a&&MN(e,r,a);let p=Array.from(e.host.childNodes),b=()=>e.host.isConnected&&(p.length>0||e.host.childNodes.length===0)&&p.every(y=>y.parentNode===e.host);return{host:e.host,namespace:a||o||"",styles:c,isCurrent:b,runScripts:async()=>{if(m.length>0&&await Vi(),!!b())for(let y of m){let x=document.createElement("script");if(y.type&&(x.type=y.type),x.async=!1,y.kind==="external")x.src=y.src;else if(y.type.toLowerCase()==="importmap"){let E=zS(y.content,v=>sE(v,e.compositionUrl));x.textContent=E?JSON.stringify(E):y.content}else if(y.type.toLowerCase()==="module"){let E=y.scopeCompositionId?$S(a||y.scopeCompositionId,e.compositionUrl?.href):"";x.textContent=E+y.content}else y.scopeCompositionId?x.textContent=_f(y.content,y.scopeCompositionId,"[HyperFrames] composition script error:",s,a||y.scopeCompositionId,l,e.compositionUrl?.href):x.textContent=`(function(){${y.content}})();`;if(document.body.appendChild(x),e.injectedScripts.push(x),y.kind==="external"){let E=await wN(x);E.status!=="load"&&e.onDiagnostic?.({code:"external_composition_script_load_issue",details:{hostCompositionId:e.authoredCompositionId,runtimeCompositionId:e.runtimeCompositionId,hostCompositionSrc:e.hostCompositionSrc,resolvedScriptSrc:y.src,loadStatus:E.status,elapsedMs:E.elapsedMs}})}}}}}async function cE(e,t){let n=Rl();if(Ff(),n.length===0)return[];let r=hE(n,t),o=n.filter(a=>{if(t.has(a)||a.hasAttribute("data-composition-src")||a.children.length>0)return!1;let l=r.get(a)?.authoredCompositionId;return l?!!document.querySelector(`template#${CSS.escape(l)}-template`):!1}),i=[];for(let a of o){let l=r.get(a),s=l?.authoredCompositionId;if(!s)continue;let c=document.querySelector(`template#${CSS.escape(s)}-template`);Nf(a);let d=await gE({host:a,authoredCompositionId:s,runtimeCompositionId:l?.runtimeCompositionId||s,hostCompositionSrc:`template#${s}-template`,sourceNode:c.content,hasTemplate:!0,fallbackBodyInnerHtml:"",compositionUrl:null,injectedStyles:e.injectedStyles,injectedScripts:e.injectedScripts,injectedLinks:e.injectedLinks,parseDimensionPx:e.parseDimensionPx,onDiagnostic:e.onDiagnostic});i.push(d)}return i}async function RN(e){let t=Rl();if(Ff(),t.length===0)return[];let n=hE(t,new Set),r=t.filter(i=>i.hasAttribute("data-composition-src"));return(await Promise.all(r.map(async i=>{let a=i.getAttribute("data-composition-src");if(!a)return null;let l=n.get(i),s=l?.authoredCompositionId||null,c=l?.runtimeCompositionId||s||null,d=null;try{d=new URL(a,document.baseURI)}catch{d=null}Nf(i);let f=p=>{e.onDiagnostic?.({code:"external_composition_load_failed",details:{hostCompositionId:s,runtimeCompositionId:c,hostCompositionSrc:a,errorMessage:p instanceof Error?p.message:"unknown_error"}}),Nf(i)},m=async p=>{let b=await gE(p),y=b.runScripts;return b.runScripts=async()=>{try{await y()}catch(x){f(x)}},b};try{let p=s!=null?document.querySelector(`template#${CSS.escape(s)}-template`):null;if(p)return await m({host:i,authoredCompositionId:s,runtimeCompositionId:c,hostCompositionSrc:a,sourceNode:p.content,hasTemplate:!0,fallbackBodyInnerHtml:"",compositionUrl:d,injectedStyles:e.injectedStyles,injectedScripts:e.injectedScripts,injectedLinks:e.injectedLinks,parseDimensionPx:e.parseDimensionPx,onDiagnostic:e.onDiagnostic});let b=await fetch(a);if(!b.ok)throw new Error(`HTTP ${b.status}`);let y=await b.text(),E=new DOMParser().parseFromString(y,"text/html");mE(E,d);let v=(s?E.querySelector(`template#${CSS.escape(s)}-template`):null)??E.querySelector("template"),_=v?v.content:E.body;return await m({host:i,authoredCompositionId:s,runtimeCompositionId:c,hostCompositionSrc:a,sourceNode:_,hasTemplate:!!v,fallbackBodyInnerHtml:E.body.innerHTML,compositionUrl:d,injectedStyles:e.injectedStyles,injectedScripts:e.injectedScripts,injectedLinks:e.injectedLinks,parseDimensionPx:e.parseDimensionPx,head:E.head,declaredVariableDefaults:bi(E.documentElement),variableDeclarer:E.documentElement,onDiagnostic:e.onDiagnostic})}catch(p){return f(p),null}}))).filter(i=>i!==null)}async function bE(e){let t=new Set,n={host:document.documentElement,namespace:"",referenceTarget:"document",styles:[...document.querySelectorAll("style")].map(f=>({element:f,authored:f.textContent??"",applied:f.textContent??""}))},r=await RN(e),o=await cE(e,new Set(r.map(({host:f})=>f))),i=[...r,...o];Lf([...i,n],t),await Promise.all(r.map(f=>f.runScripts()));let a=o.filter(f=>{if(f.isCurrent())return!0;for(let m of f.styles)m.element.remove();return window.__hfVariablesByComp&&delete window.__hfVariablesByComp[f.namespace],!1}),l=[...r.filter(f=>f.host.isConnected),...a],s=await cE(e,new Set(l.map(({host:f})=>f)));s.length&&Lf([...l,...s,n],t);let c=new Map([...a,...s].map(f=>[f.host,f]));for(let f of Rl()){let m=c.get(f);m&&await m.runScripts()}let d=[...l,...s].filter(f=>f.host.isConnected);Lf([...d,n],t)}function Lf(e,t){for(let{styles:r}of e)for(let o of r){let i=o.element.textContent??"";i!==o.applied&&(o.authored=i,o.applied=i)}rE(document,e.map(({host:r,namespace:o,styles:i,referenceTarget:a})=>({root:r,namespace:o,referenceTarget:a,exclude:e.filter(l=>l.host!==r&&r.contains(l.host)).map(l=>l.host),cssTexts:i.map(l=>l.authored)})),t).forEach((r,o)=>{let i=nr(e[o].host,_t);if(!(r.size===0&&i.length===0))for(let a of e[o].styles){let l=oE(a.authored,r,i);l!==a.applied&&(a.element.textContent=l),a.applied=l}}),rr()}function MN(e,t,n){let o={...e.declaredVariableDefaults??(Oe(t)?bi(t):{}),...vb(e.host)};gd(e.variableDeclarer??(Oe(t)?t:null),o,n),Sb(e.host),Object.keys(o).length>0?(window.__hfVariablesByComp||(window.__hfVariablesByComp={}),window.__hfVariablesByComp[n]=o,bd(e.host,{...xb(e.host,o,window),...Us()})):window.__hfVariablesByComp&&delete window.__hfVariablesByComp[n]}function kN(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function LN(e){if(!Array.isArray(e))throw new Error("expected a JSON array");if(!e.every(kN))throw new Error("every array entry must be an object");return e}function NN(e){let n=e.vars.data?.captionState;return n==="dim"||n==="active"?n:void 0}function FN(e){return we(e)?e.dataset.captionWrapper!=="true"?e:e.querySelector(":scope > span")??null:null}function PN(){let e=[],t=document.querySelectorAll(".caption-group");for(let n of t)for(let r of n.children){if(!we(r))continue;let o=r.dataset.captionWrapper==="true"?r.querySelector(":scope > span"):r.tagName==="SPAN"?r:null;o&&e.push(o)}return e}function IN(e){let t=e.parentElement;if(t?.dataset.captionWrapper==="true")return t;let n=document.createElement("span");return n.style.display="inline-block",n.dataset.captionWrapper="true",e.parentNode?.insertBefore(n,e),n.appendChild(e),n}var If=()=>window.gsap,xE=()=>fetch("caption-overrides.json").then(e=>e.ok?e.json():null),SE=e=>e===null?[]:LN(e);function EE(e){let t=e instanceof Error?e.message:String(e);globalThis.console.error(`[HyperFrames] Invalid caption-overrides.json: ${t}`)}function Df(){return If()?xE().then(SE).catch(e=>(EE(e),[])):Promise.resolve([])}function Of(e,t){return!If()||document.querySelectorAll(".caption-group").length===0?Promise.resolve():xE().then(n=>Hf(SE(n),e,t)).catch(EE)}function DN(e,t){return(e.wordId?FN(document.getElementById(e.wordId)):null)??(e.wordIndex!==void 0?t[e.wordIndex]??null:null)}function yE(e,t){return Object.fromEntries(t.filter(n=>e[n]!==void 0).map(n=>[n,e[n]]))}function Pf(e,t){let n=e.style.color;e.style.color=t;let r=getComputedStyle(e).color;return e.style.color=n,r}function ON(e,t){let n=t[0]?.vars.startAt;return Pf(e,n?.color===void 0?"":String(n.color))}function HN(e,t,n,r){let o=NN(e);if(o)return o;let i=String(e.vars.color);return/var\(|currentcolor/i.test(i)?Pf(t,i)===n?"dim":"active":(r.has(i)||r.set(i,Pf(t,i)),r.get(i)===n?"dim":"active")}function GN(e,t,n){if(e.dimColor)return e.dimColor;if(!(t.length===0||t.some(r=>r.vars.runBackwards)))return n}function BN(e,t,n,r){let o=e.getTweensOf(t).filter(l=>l.vars.color!==void 0).sort((l,s)=>l.startTime()-s.startTime()),i=ON(t,o);for(let l of o){let c=HN(l,t,i,r)==="dim"?n.dimColor:n.activeColor;c&&(l.vars.color=c),l.vars.runBackwards||l.invalidate?.()}let a=GN(n,o,i);a&&e.set(t,{color:a})}function UN(e,t,n,r){let o=yE(n,["x","y","scale","rotation"]),i=yE(n,["opacity","fontWeight","fontFamily"]);if(n.fontSize!==void 0&&(i.fontSize=`${n.fontSize}px`),(n.activeColor||n.dimColor)&&BN(e,t,n,r),Object.keys(i).length>0&&e.set(t,i),Object.keys(o).length>0){let a=IN(t);e.set(a,o)}}function Hf(e,t,n=()=>{}){let r=If();if(!r||e.length===0)return;n();let o=PN(),i=new Map;for(let a of e){let l=DN(a,o);!l||t&&!t.some(s=>s.contains(l))||UN(r,l,a,i)}}var Bf="data-hf-edit-base-x",Uf="data-hf-edit-base-y",Bn="data-hf-edit-original-translate",Ml=e=>{let t=parseFloat(e??"");return Number.isFinite(t)?t:0},WN=e=>{let t=[],n=0,r="";for(let o of e.trim())o==="("&&(n+=1),o===")"&&(n=Math.max(0,n-1)),/\s/.test(o)&&n===0?(r&&t.push(r),r=""):r+=o;return r&&t.push(r),t},vE=/^-?(?:\d+(?:\.\d+)?|\.\d+)px$/,Gf=(e,t)=>vE.test(e)&&vE.test(t)?`${parseFloat(e)+parseFloat(t)}px`:`calc(${e} + ${t})`,VN=(e,t,n)=>{if(!e||e==="none")return`${t} ${n}`;let[r,o,i]=WN(e);if(r===void 0)return`${t} ${n}`;if(o===void 0)return`${Gf(r,t)} ${n}`;let a=i===void 0?"":` ${i}`;return`${Gf(r,t)} ${Gf(o,n)}${a}`},$N=e=>{try{e.ownerDocument.defaultView?.gsap?.getProperty?.(e,"x")}catch{}},qN=e=>{let t=e.style.getPropertyValue("translate").trim();if(t)return t==="none"?"":t;try{let n=e.ownerDocument.defaultView,r=n?n.getComputedStyle(e).getPropertyValue("translate").trim():"";return r==="none"?"":r}catch{return""}},kl=new WeakMap;function TE(e){kl.delete(e)}function zN(e,t){let n=kl.get(e);if(!t?.force&&n!==void 0&&e.style.getPropertyValue("translate")!==n){St("position_edit_fold_skipped",{hfId:e.getAttribute("data-hf-id")});return}let r=Ml(e.getAttribute("data-x"))-Ml(e.getAttribute(Bf)),o=Ml(e.getAttribute("data-y"))-Ml(e.getAttribute(Uf));e.hasAttribute(Bn)||e.setAttribute(Bn,qN(e)),n===void 0&&$N(e);let i=e.getAttribute(Bn)??"",a=VN(i,`${r}px`,`${o}px`);e.style.setProperty("translate",a),kl.set(e,e.style.getPropertyValue("translate"))}function qi(e,t){let n=e.querySelectorAll(`[${Bn}]:not([${Bf}]):not([${Uf}])`);for(let i=0;i<n.length;i++){let a=n[i];if(a===void 0||!ar(a))continue;let l=a.getAttribute(Bn)??"";l===""?a.style.removeProperty("translate"):a.style.setProperty("translate",l),a.removeAttribute(Bn),kl.delete(a)}let r=e.querySelectorAll(`[${Bf}], [${Uf}]`),o=0;for(let i=0;i<r.length;i++){let a=r[i];a===void 0||!ar(a)||(zN(a,t),o+=1)}return o}var AE="__hfPositionEditsSeekReapplyWrapped",wE=new WeakSet,_E=new WeakMap,CE=new WeakMap;function RE(e){let t=e,n=()=>{try{qi(t.document)}catch{}},r=f=>typeof f=="function"&&(wE.has(f)||!!f[AE]),o=f=>{wE.add(f);try{Object.defineProperty(f,AE,{value:!0})}catch{}},i=f=>{if(typeof f!="function"||r(f))return f;let m=function(...p){let b=f.apply(this,p);return n(),b};return o(m),m},a=(f,m)=>{let p=_E.get(f);if(p?.has(m))return!0;let b=Object.getOwnPropertyDescriptor(f,m);if(b?.configurable===!1){let E=f[m];return typeof E=="function"&&(f[m]=i(E),n()),!1}let y=f[m],x=b?.set;return Object.defineProperty(f,m,{configurable:!0,enumerable:b?.enumerable??!0,get:()=>y,set:E=>{y=i(E),x?.call(f,E)}}),y=i(y),p??(p=new Set),p.add(m),_E.set(f,p),n(),!0},l=(f,m)=>{let p=CE.get(t),b=Object.getOwnPropertyDescriptor(t,f);if(!p?.has(f)){if(b?.configurable===!1){let E=t[f];return E?a(E,m):!1}let x=t[f];Object.defineProperty(t,f,{configurable:!0,enumerable:b?.enumerable??!0,get:()=>x,set:E=>{x=E,x&&a(x,m)}}),p??(p=new Set),p.add(f),CE.set(t,p)}let y=t[f];return y?a(y,m):!1},s=()=>{let f=l("__hf","seek"),m=l("__player","renderSeek");return f&&m};if(s())return;let c=120,d=t.setInterval(()=>{if(s()){t.clearInterval(d);return}c-=1,c<=0&&t.clearInterval(d)},50)}function Ll(e){let t=window,r=e.closest("[data-composition-id]")?.getAttribute("data-composition-id")?.trim()??"",o=r?t.__hfVariablesByComp?.[r]:void 0;if(o)return o;let i=t.__hyperframes?.getVariables?.();return i&&typeof i=="object"?i:t.__hfVariables??{}}function Nl(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function Wf(e){let t=e.replace(/[\u0000-\u0020]/g,""),n=/^([a-z][a-z0-9+.-]*):/i.exec(t);if(!n)return!0;let r=n[1]?.toLowerCase();return r?r==="https"||r==="http"||r==="blob"?!0:r==="data"?/^data:image\//i.test(t):!1:!1}var ME=new Set(["img","video","audio","source"]);function jN(e){if(typeof e=="string"&&e.length>0)return e;if(e!==null&&typeof e=="object"){let t=e.url;if(typeof t=="string"&&t.length>0)return t}return null}function KN(e){return e.replace(/[;{}<>\r\n]/g,"")}function YN(e){if(Nl(e))return String(e);if(e!==null&&typeof e=="object"){let t=e.name;if(typeof t=="string"&&t.length>0)return t}return null}function Vf(e,t){let n=e.closest("[data-composition-id]"),r=t.get(n);if(r)return r;let o=Ll(e);return t.set(n,o),o}function XN(e,t){if(e.childElementCount===0){e.textContent=t;return}let n=!1;for(let r of Array.from(e.childNodes))r.nodeType===Node.TEXT_NODE&&(r.nodeValue=n?"":t,n=!0);n||e.insertBefore(e.ownerDocument.createTextNode(t),e.firstChild)}function JN(e){return e.querySelector("[data-hf-root]")??e.getElementById("stage")??e.body?.firstElementChild??e.body}function QN(e,t){for(let n of new Set(e)){let r=Vf(n,t);for(let[o,i]of Object.entries(r)){let a=YN(i);a!==null&&we(n)&&n.style.setProperty(`--${o}`,KN(a))}}}function kE(e,t,n=!0){let r=e.getAttribute("data-var-src")?.trim();if(!r)return null;if(!ME.has(e.tagName.toLowerCase()))return n&&globalThis.console.warn(`[hyperframes] Ignoring data-var-src on <${e.tagName.toLowerCase()}>: variable-bound src is only allowed on ${Array.from(ME).join("/")}.`),null;let o=jN(Vf(e,t)[r]);return o===null?null:Wf(o)?o:(n&&globalThis.console.warn(`[hyperframes] Ignoring data-var-src="${r}": unsafe URL protocol.`),null)}function LE(e){return kE(e,new Map,!1)??xi(e)}function Fl(e,t){let n=new Map,r=i=>t?[...t.matches(i)?[t]:[],...t.querySelectorAll(i)]:Array.from(e.querySelectorAll(i)),o=t?null:JN(e);QN([...o?[o]:[],...r("[data-composition-id]")],n);for(let i of r("[data-var-src]")){let a=kE(i,n);a!==null&&xi(i)!==a&&i.setAttribute("src",a)}for(let i of r("[data-var-text]")){let a=i.getAttribute("data-var-text")?.trim();if(!a)continue;let l=Vf(i,n)[a];Nl(l)&&XN(i,String(l))}}var ZN=["video","audio","source","script",tn];function $f(e,t=()=>!1){let n=r=>r.nodeType===Node.ELEMENT_NODE&&(r.matches(e)||r.querySelector(e)!==null||t(r));return r=>r.some(o=>o.type==="attributes"||Array.from(o.addedNodes).some(n)||Array.from(o.removedNodes).some(n))}var NE=e=>$f([...ZN,...e.map(t=>`[${t}]`)].join(","));var eF=3e3,ln=new Map,tF="data-hf-color-grading-canvas",nF="__hf_color_grading_canvas__";function qE(){if(typeof MutationObserver>"u"||typeof document>"u")return;let e=document.documentElement;if(!e)return;let t=r=>{we(r)&&(r.hasAttribute(br)||r.setAttribute(br,r.style.opacity))},n=r=>{if(Oe(r)){r.matches("video, img")&&t(r);for(let o of r.querySelectorAll("video, img"))t(o)}};n(e),new MutationObserver(r=>{for(let o of r)for(let i of o.addedNodes)n(i)}).observe(e,{childList:!0,subtree:!0})}var rF=16,oF=4,Ar={enabled:!1,position:.5,softness:0,lineWidth:2},qf=["#000000","#ffffff"],iF=["#1a1a1a","#f5f5dc"],Qi=3,aF=Qi-1,sF=5,Sr=`${Wt}.0`,FE=`${Wt-1}.0`,PE=`${Qi}.0`,lF=`${(aF+.5)/Qi}`;function zi(e){let t=e.getAttribute(nl);return t==null?null:jy(t,Ll(e))}var uF=["attribute vec2 a_pos;","varying vec2 v_uv;","void main(){"," v_uv = a_pos * 0.5 + 0.5;"," gl_Position = vec4(a_pos, 0.0, 1.0);","}"].join(`
|
|
364
|
+
})();`}function _l(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function WL(e){return _l(e)&&Object.values(e).every(_l)}var qS=(e,t)=>e&&Object.fromEntries(Object.entries(e).map(([n,r])=>[n,typeof r=="string"?t(r):null]));function zS(e,t){let n;try{n=JSON.parse(e)}catch{return null}if(!_l(n))return null;let{imports:r,scopes:o}=n;return r!==void 0&&!_l(r)||o!==void 0&&!WL(o)?null:{imports:qS(r,t),scopes:o&&Object.fromEntries(Object.entries(o).map(([i,a])=>[t(i),qS(a,t)??{}]))}}var Cf="text/hf-after-fonts",KS=`${Cf}+module`,YS=`script[type="${Cf}"], script[type="${KS}"]`,XS="__hfAfterFontsClaimed",VL="data-hf-inlined-src";var JS=`[defer][src], [defer][${VL}]`;function Cl(e){let t=e.getAttribute("type");return t===Cf?null:t===KS?"module":t}function $L(e){let t=e.getAttribute("type")??"",n=e.tagName.toLowerCase()==="link"?t.split(";")[0].trim():t;if(n!==""&&n.toLowerCase()!=="text/css")return;let r=(e.getAttribute("media")??"").trim().toLowerCase();return JSON.stringify([r==="all"?"":r,e.getAttribute("title")??""])}var l5=JSON.stringify(["",""]);function jS(e){return JSON.stringify([e.getAttribute("href"),(e.getAttribute("rel")??"").trim().toLowerCase(),$L(e)??e.getAttribute("type"),e.hasAttribute("disabled")])}function QS(e,t){let n=jS(t);return[...e.querySelectorAll("link[href]")].some(r=>!r.closest("noscript")&&jS(r)===n)}var et="id",Tf="data-hf-authored-id",mo=/(url\(\s*)(["']?)#([^"')\s]+)\2(\s*\))/gi;function eE(e){return e==="href"||e.endsWith(":href")}function qL(e){return e.replace(/[^a-zA-Z0-9_-]/g,"-")}function Rf(e,t){return!e||!e.toLowerCase().includes("url(")?e:e.replace(mo,(n,r,o,i,a)=>{let l=t.get(i);return l?`${r}${o}#${l}${o}${a}`:n})}function zL(e,t,n){if(eE(e)&&t.startsWith("#")){let o=n.get(t.slice(1));return o?`#${o}`:t}mo.lastIndex=0;let r=mo.test(t);return mo.lastIndex=0,r?Rf(t,n):null}function jL(e,t,n){if(e.name===_t||e.name===et)return{kind:"skip"};let r=t&&e.value===t.after?t.before:e.value,o=zL(e.name,r,n);return o!==null?{kind:"managed",before:r,after:o}:t?{kind:"retain",alias:t}:{kind:"skip"}}function KL(e,t,n,r){let o=e.namespaceURI===void 0&&e.name==="xlink:href"&&r;return{name:e.name,localName:o?"href":e.localName,namespaceURI:o?"http://www.w3.org/1999/xlink":e.namespaceURI??null,before:t,after:n}}function YL(e,t){let n=new Map(nr(e,_t,!1).map(i=>[i.name,i])),r=[...n.values()].filter(i=>i.name===et),o=!!e.closest("svg");for(let i of e.attributes?Array.from(e.attributes):[]){let a=jL(i,n.get(i.name),t);if(a.kind!=="skip"){if(a.kind==="retain"){r.push(a.alias);continue}a.after!==i.value&&(i.namespaceURI?e.setAttributeNS(i.namespaceURI,i.name,a.after):e.setAttribute(i.name,a.after)),r.push(KL(i,a.before,a.after,o))}}r.length&&e.setAttribute(_t,JSON.stringify(r))}function ZS(e,t,n){let r;for(mo.lastIndex=0;r=mo.exec(e);){let o=r[3];t.has(o)&&n.add(o)}}function XL(e,t,n){if(eE(e.name)&&e.value.startsWith("#")){let r=e.value.slice(1);t.has(r)&&n.add(r)}}function JL(e,t,n){let r=new Set;for(let o of e)for(let i of o.attributes?Array.from(o.attributes):[])!i.value||i.name===_t||(XL(i,n,r),i.value.toLowerCase().includes("url(")&&ZS(i.value,n,r));for(let o of t)o.toLowerCase().includes("url(")&&ZS(o,n,r);return r}function tE(e,t){return t.some(n=>n===e||n.contains(e))}function QL(e){let t=e.exclude??[],n=[...e.root.querySelectorAll("*")],r=t.length?n.filter(o=>!tE(o,t)):n;return[e.root,...r]}function ZL(e){let t=e.exclude??[],n=[...e.root.querySelectorAll("svg [id], svg[id]")];return t.length?n.filter(r=>!tE(r,t)):n}function eN(e){let t=QL(e),n=new Set;if(!e.namespace)return{elements:t,renamable:n};let r=ZL(e),o=new Set;for(let a of r){let l=a.getAttribute(et);l&&o.add(l)}if(o.size===0)return{elements:t,renamable:n};let i=JL(t,e.cssTexts??[],o);for(let a of r){let l=a.getAttribute(et);l&&i.has(l)&&n.add(a)}return{elements:t,renamable:n}}function nE(e){if(!e.closest("svg"))return null;let t=nr(e,_t,!1).find(n=>n.name===et);return t?e.getAttribute(et)===t.after?t.before:null:e.getAttribute(Tf)}function tN(e){let t=new Map,n=new Set;for(let r of e.querySelectorAll("[id]")){let o=r.getAttribute(et);if(!o)continue;n.add(o);let i=t.get(o);i?i.push(r):t.set(o,[r]);let a=nE(r);if(a&&a!==o){let l=t.get(a);l?l.push(r):t.set(a,[r])}}return{elementsById:t,usedIds:n}}function nN(e,t,n){let r=`${qL(e)}--${t}`,o=r;for(let i=2;n.has(o);i+=1)o=`${r}-${i}`;return n.add(o),o}function rN(e,t,n){let r=t.find(a=>!n.has(a))??t[0],i=t.filter(a=>a!==r&&a.getAttribute(et)===e).map(a=>n.get(a));return new Set(i.filter(a=>a!==void 0))}function oN(e,t,n){let r=t.map(()=>new Map);for(let[o,i]of e.elementsById)if(!(i.length<2))for(let a of rN(o,i,n))r[a].set(o,nN(t[a].namespace,o,e.usedIds));return r}function iN(e,t,n){let r=new Map;for(let[o,i]of e.elementsById){let a=i[0],l=a.getAttribute(et);if(l!==o){r.set(o,l);continue}let s=n.get(a),c=s===void 0?void 0:t[s].get(o);c&&r.set(o,c)}return r}function aN(e){let t=new Set(e.map(r=>r.getAttribute(et))),n=new Map;for(let r of e){let o=nE(r),i=r.getAttribute(et);!o||!i||(t.add(o),n.set(o,i))}return{ids:t,renamed:n}}function sN(e,t){for(let n of e.elements){let r=n.getAttribute(et);if(r&&e.renamable.has(n)&&t.has(r)){n.hasAttribute(Tf)||n.setAttribute(Tf,r);let o=t.get(r),i=nr(n,_t,!1);i.push({name:et,localName:et,namespaceURI:null,before:r,after:o}),n.setAttribute(_t,JSON.stringify(i)),n.setAttribute(et,o)}YL(n,t)}}function rE(e,t,n){if(t.length===0)return[];let r=tN(e),o=t.map(eN),i=o.flatMap(({renamable:d})=>[...d]);if(n)for(let d of o)for(let f of d.renamable)n.has(f)&&d.renamable.delete(f);let a=new Map;o.forEach(({renamable:d},f)=>{for(let m of d)a.set(m,f)});let l=oN(r,t,a),s=iN(r,l,a),c=o.map((d,f)=>{let m=aN(t[f].referenceTarget==="document"?[]:d.elements),p=[...s].filter(([b])=>!m.ids.has(b));return new Map([...p,...m.renamed,...l[f]])});c.forEach((d,f)=>{sN(o[f],d)});for(let d of i)n?.add(d);return c}function oE(e,t,n=[]){if(!e||t.size===0&&n.length===0||!e.includes("#")&&!e.includes("[")&&!e.toLowerCase().includes("url("))return e;let r;try{r=wl.parse(e)}catch{return e}let o=!1,i=new Set(n.filter(l=>l.name===et).map(l=>l.before)),a=[...t].filter(([l])=>!i.has(l)).map(([l,s])=>({id:l,replacement:`:is(#${Xt(l)}, #${Xt(s)})`}));return r.walkRules(l=>{let s=l.selectors.map(c=>qa(c,a,n));s.some((c,d)=>c!==l.selectors[d])&&(l.selectors=s,o=!0)}),r.walkDecls(l=>{let s=Rf(l.value,t);s!==l.value&&(l.value=s,o=!0)}),r.walkAtRules(l=>{if(!l.params)return;let s=Rf(l.params,t);s!==l.params&&(l.params=s,o=!0)}),o?r.toResult({map:!1}).css:e}var Mf=5e3;window[XS]=!0;async function Vi(){let e=document.fonts;if(!e)return;document.body?.offsetHeight;for(let o of Array.from(e))o.status==="unloaded"&&o.load().catch(()=>{});let t,n=await Promise.race([e.ready.then(()=>!1),new Promise(o=>t=setTimeout(o,Mf,!0))]);if(clearTimeout(t),!n)return;let r=[...new Set(Array.from(e).filter(o=>o.status==="loading").map(o=>o.family))];globalThis.console.warn(`[hyperframes] fonts still loading after ${Mf} ms, composition scripts run without them: ${r.join(", ")}`),Ce({source:"hf-preview",type:"diagnostic",code:"runtime_font_wait_timeout",details:{loadingFamilies:r,timeoutMs:Mf}})}function lN(e,t){let n=Object.getOwnPropertyDescriptor(e,"addEventListener"),r=e.addEventListener,o=(i,a,l)=>{if(!a)return;i==="DOMContentLoaded"||i==="load"&&e===window&&document.readyState==="complete"?t.push({target:e,type:i,listener:a}):r.call(e,i,a,l)};return e.addEventListener=o,()=>{e.addEventListener===o&&(n?Object.defineProperty(e,"addEventListener",n):delete e.addEventListener)}}function uN(e){if(!e.isConnected)return;let t=document.createElement("script");for(let{name:r,value:o}of Array.from(e.attributes))t.setAttribute(r,o);let n=Cl(e);return n===null?t.removeAttribute("type"):t.setAttribute("type",n),t.async=e.hasAttribute("async"),t.text=e.textContent??"",e.replaceWith(t),t}var cN=50,dN=()=>!window.__HF_VIRTUAL_TIME__;function fN(){let e=globalThis.scheduler;return typeof e?.yield=="function"?e.yield():new Promise(t=>{let n=new MessageChannel;n.port1.onmessage=()=>{n.port1.close(),t()},n.port2.postMessage(null)})}var mN=e=>new Promise(t=>{e.addEventListener("load",t),e.addEventListener("error",t)});function pN(){let e=document.createElement("script");e.type="module",e.async=!1,e.text='document.dispatchEvent(new Event("hf-after-fonts-modules"))';let t=new Promise(n=>document.addEventListener("hf-after-fonts-modules",n,{once:!0}));return document.body.appendChild(e),t.then(()=>e.remove())}async function Tl(e,t){await Vi();let n=l=>Cl(l)==="module"||l.matches(JS),r=[],o=[document,window].map(l=>lN(l,r)),i=dN(),a=performance.now();for(let l of[...e.filter(s=>!n(s)),...e.filter(n)]){i&&performance.now()-a>cN&&(await fN(),a=performance.now());let s=uN(l);s?.hasAttribute("src")&&!s.async&&!s.noModule?await mN(s):Cl(l)==="module"&&await pN()}for(let l of o)l();t?.();for(let{target:l,type:s,listener:c}of r){let d=new Event(s);try{typeof c=="function"?c.call(l,d):c.handleEvent(d)}catch(f){reportError(f)}}}var hN=["data-composition-id","data-composition-file","data-start","data-duration","data-end","data-track-index","data-track","data-composition-src","data-hf-authored-duration","data-hf-authored-end"];function iE(e){let t=e.getAttribute("id")?.trim();for(let n of hN)e.removeAttribute(n);t&&(e.removeAttribute("id"),e.setAttribute("data-hf-authored-id",t)),e.setAttribute("data-hf-inner-root","true")}var gN=8e3,bN=/^(?![a-zA-Z][a-zA-Z\d+\-.]*:)(?!\/\/)(?!\/)(?!\.\.?\/).+/,yN=/\burl\(\s*(["']?)([^)"']+)\1\s*\)/g,xN=["src","href"];function SN(e){return!e||e.startsWith("http://")||e.startsWith("https://")||e.startsWith("//")||e.startsWith("data:")||e.startsWith("#")||e.startsWith("/")}function dE(e,t){if(!t)return e;let n=e.trim();if(SN(n)||!n.startsWith("../")&&n!=="..")return e;try{return new URL(n,t).href}catch{return e}}function fE(e,t){return!t||!e?e:e.replace(yN,(n,r,o)=>{let i=dE(o||"",t);return i===o?n:`url(${r||""}${i}${r||""})`})}function EN(e,t){for(let n of Array.from(e.querySelectorAll("[src], [href]")))for(let r of xN){let o=n.getAttribute(r);if(o==null)continue;let i=dE(o,t);i!==o&&n.setAttribute(r,i)}}function vN(e,t){for(let n of Array.from(e.querySelectorAll("[style]"))){let r=n.getAttribute("style");if(r==null)continue;let o=fE(r,t);o!==r&&n.setAttribute("style",o)}}function AN(e,t){for(let n of Array.from(e.querySelectorAll("style"))){let r=n.textContent||"",o=fE(r,t);o!==r&&(n.textContent=o)}}function mE(e,t){if(t){EN(e,t),vN(e,t),AN(e,t);for(let n of Array.from(e.querySelectorAll("template")))mE(n.content,t)}}function aE(e,t){return`${e}__hf${t}`}var wN=e=>new Promise(t=>{let n=!1,r=Date.now(),o=null,i=a=>{n||(n=!0,o!=null&&window.clearTimeout(o),t({status:a,elapsedMs:Math.max(0,Date.now()-r)}))};e.addEventListener("load",()=>i("load"),{once:!0}),e.addEventListener("error",()=>i("error"),{once:!0}),o=window.setTimeout(()=>i("timeout"),gN)});function Nf(e){for(;e.firstChild;)e.removeChild(e.firstChild);e.textContent=""}function kf(e){for(let t of sx(e))t.remove()}function _N(e){let t=document.importNode(e,!0);iE(t);let n=dr(t.getAttribute("data-width")),r=dr(t.getAttribute("data-height"));return t.style.width=n===null?"100%":`${n}px`,t.style.height=r===null?"100%":`${r}px`,t}function sE(e,t){let n=e.trim();if(!n)return e;try{return bN.test(n)&&!n.startsWith("#")&&!n.startsWith("?")?new URL(n,document.baseURI).toString():t?new URL(n,t).toString():new URL(n,document.baseURI).toString()}catch{return e}}function lE(e,t){try{let n=new URL(e),r=new URL(t);return n.search="",n.hash="",r.search="",r.hash="",n.href===r.href}catch{return!1}}function $i(e){let t=(e.getAttribute("data-composition-id")||"").trim()||null;return{authoredCompositionId:(e.getAttribute("data-hf-original-composition-id")||t||"").trim()||null,runtimeCompositionId:t}}function CN(e){let t=new Map;for(let n of e){let r=$i(n).authoredCompositionId||"";r&&t.set(r,(t.get(r)||0)+1)}return ux(t,e),t}function pE(e){let t=$i(e).authoredCompositionId;return t?!!document.querySelector(`template#${CSS.escape(t)}-template`):!1}function TN(e){return!!e.querySelector('[data-hf-inner-root="true"]')}function uE(e){return e.hasAttribute("data-composition-src")?!0:pE(e)?e.children.length===0||e.hasAttribute("data-hf-original-composition-id")?!0:TN(e):!1}function Rl(){return Array.from(document.querySelectorAll("[data-composition-src], [data-composition-id]")).filter(t=>t.hasAttribute("data-composition-src")?!0:pE(t))}function Ff(){let e=window.__hfVariablesByComp;if(!e)return;let t=new Set(Rl().map(n=>$i(n).runtimeCompositionId).filter(n=>!!n));for(let n of Object.keys(e))t.has(n)||delete e[n]}function hE(e,t){let n=CN(e),r=new Set(e.flatMap(a=>{let l=$i(a),s=l.authoredCompositionId?[l.authoredCompositionId]:[];return(t.has(a)||!uE(a))&&l.runtimeCompositionId&&s.push(l.runtimeCompositionId),s})),o=new Map,i=new Map;for(let a of e){let{authoredCompositionId:l,runtimeCompositionId:s}=$i(a),c=!t.has(a)&&uE(a);if(!l){i.set(a,{authoredCompositionId:null,runtimeCompositionId:s});continue}let d=(n.get(l)||0)>1,f=s||l;if(c){let m=d?(o.get(l)||0)+1:0;if(d){for(;r.has(aE(l,m));)m+=1;o.set(l,m)}f=d?aE(l,m):l,r.add(f),d?a.setAttribute("data-hf-original-composition-id",l):a.removeAttribute("data-hf-original-composition-id"),a.setAttribute("data-composition-id",f)}i.set(a,{authoredCompositionId:l,runtimeCompositionId:f})}return Ff(),i}async function gE(e){let t=lx({contentNode:e.sourceNode,head:e.head,hasTemplate:e.hasTemplate,compositionId:e.authoredCompositionId}),n=we(t.innerRoot)?t.innerRoot:null,r=n??e.sourceNode,o=t.authoredCompositionId,i=t.scriptCompositionId,a=e.runtimeCompositionId||null,l=t.authoredRootId,s=a?`[data-composition-id="${CSS.escape(a)}"]`:void 0;for(let y of t.linkSources){let x=(y.getAttribute("href")||"").trim();if(!x)continue;let E=e.compositionUrl?new URL(x,e.compositionUrl).href:x;if(e.compositionUrl&&lE(E,e.compositionUrl))continue;let v=y.cloneNode(!0);Zh(v)&&(v.href=E,!QS(document.head,v)&&(document.head.appendChild(v),e.injectedLinks.push(v)))}let c=[];(y=>{for(let x of y){let E=x.cloneNode(!0);if(!Qh(E))continue;o&&(E.textContent=WS(E.textContent||"",o,s,l,{scopeRootSelectors:!0})),document.head.appendChild(E),e.injectedStyles.push(E);let v=E.textContent||"";c.push({element:E,authored:v,applied:v})}})(t.styleSources);let f=y=>{let x=y.getAttribute("type")?.trim()??"",E=y.getAttribute("src")?.trim()??"";if(E){let _=sE(E,e.compositionUrl);return e.compositionUrl&&lE(_,e.compositionUrl)?null:{kind:"external",src:_,type:x}}let v=y.textContent?.trim()??"";return v?{kind:"inline",content:v,type:x,scopeCompositionId:i}:null},m=t.scriptSources.map(f).filter(y=>y!==null);if(n){let y=n.getAttribute("data-width"),x=n.getAttribute("data-height"),E=e.parseDimensionPx(y),v=e.parseDimensionPx(x);y&&e.host.setAttribute("data-width",y),x&&e.host.setAttribute("data-height",x),E&&we(e.host)&&(e.host.style.width=E),v&&we(e.host)&&(e.host.style.height=v),n.hasAttribute("data-timeline-locked")&&e.host.setAttribute("data-timeline-locked","");let _=_N(n);!e.authoredCompositionId&&o&&_.setAttribute("data-composition-id",o),kf(_),e.host.appendChild(_)}else if(e.hasTemplate){let y=document.importNode(r,!0);kf(y),e.host.appendChild(y)}else e.host.innerHTML=e.fallbackBodyInnerHtml,kf(e.host);for(let y of t.inertScriptsOutsideRoot)e.host.appendChild(document.importNode(y,!0));a&&MN(e,r,a);let p=Array.from(e.host.childNodes),b=()=>e.host.isConnected&&(p.length>0||e.host.childNodes.length===0)&&p.every(y=>y.parentNode===e.host);return{host:e.host,namespace:a||o||"",styles:c,isCurrent:b,runScripts:async()=>{if(m.length>0&&await Vi(),!!b())for(let y of m){let x=document.createElement("script");if(y.type&&(x.type=y.type),x.async=!1,y.kind==="external")x.src=y.src;else if(y.type.toLowerCase()==="importmap"){let E=zS(y.content,v=>sE(v,e.compositionUrl));x.textContent=E?JSON.stringify(E):y.content}else if(y.type.toLowerCase()==="module"){let E=y.scopeCompositionId?$S(a||y.scopeCompositionId,e.compositionUrl?.href):"";x.textContent=E+y.content}else y.scopeCompositionId?x.textContent=_f(y.content,y.scopeCompositionId,"[HyperFrames] composition script error:",s,a||y.scopeCompositionId,l,e.compositionUrl?.href):x.textContent=`(function(){${y.content}})();`;if(document.body.appendChild(x),e.injectedScripts.push(x),y.kind==="external"){let E=await wN(x);E.status!=="load"&&e.onDiagnostic?.({code:"external_composition_script_load_issue",details:{hostCompositionId:e.authoredCompositionId,runtimeCompositionId:e.runtimeCompositionId,hostCompositionSrc:e.hostCompositionSrc,resolvedScriptSrc:y.src,loadStatus:E.status,elapsedMs:E.elapsedMs}})}}}}}async function cE(e,t){let n=Rl();if(Ff(),n.length===0)return[];let r=hE(n,t),o=n.filter(a=>{if(t.has(a)||a.hasAttribute("data-composition-src")||a.children.length>0)return!1;let l=r.get(a)?.authoredCompositionId;return l?!!document.querySelector(`template#${CSS.escape(l)}-template`):!1}),i=[];for(let a of o){let l=r.get(a),s=l?.authoredCompositionId;if(!s)continue;let c=document.querySelector(`template#${CSS.escape(s)}-template`);Nf(a);let d=await gE({host:a,authoredCompositionId:s,runtimeCompositionId:l?.runtimeCompositionId||s,hostCompositionSrc:`template#${s}-template`,sourceNode:c.content,hasTemplate:!0,fallbackBodyInnerHtml:"",compositionUrl:null,injectedStyles:e.injectedStyles,injectedScripts:e.injectedScripts,injectedLinks:e.injectedLinks,parseDimensionPx:e.parseDimensionPx,onDiagnostic:e.onDiagnostic});i.push(d)}return i}async function RN(e){let t=Rl();if(Ff(),t.length===0)return[];let n=hE(t,new Set),r=t.filter(i=>i.hasAttribute("data-composition-src"));return(await Promise.all(r.map(async i=>{let a=i.getAttribute("data-composition-src");if(!a)return null;let l=n.get(i),s=l?.authoredCompositionId||null,c=l?.runtimeCompositionId||s||null,d=null;try{d=new URL(a,document.baseURI)}catch{d=null}Nf(i);let f=p=>{e.onDiagnostic?.({code:"external_composition_load_failed",details:{hostCompositionId:s,runtimeCompositionId:c,hostCompositionSrc:a,errorMessage:p instanceof Error?p.message:"unknown_error"}}),Nf(i)},m=async p=>{let b=await gE(p),y=b.runScripts;return b.runScripts=async()=>{try{await y()}catch(x){f(x)}},b};try{let p=s!=null?document.querySelector(`template#${CSS.escape(s)}-template`):null;if(p)return await m({host:i,authoredCompositionId:s,runtimeCompositionId:c,hostCompositionSrc:a,sourceNode:p.content,hasTemplate:!0,fallbackBodyInnerHtml:"",compositionUrl:d,injectedStyles:e.injectedStyles,injectedScripts:e.injectedScripts,injectedLinks:e.injectedLinks,parseDimensionPx:e.parseDimensionPx,onDiagnostic:e.onDiagnostic});let b=await fetch(a);if(!b.ok)throw new Error(`HTTP ${b.status}`);let y=await b.text(),E=new DOMParser().parseFromString(y,"text/html");mE(E,d);let v=(s?E.querySelector(`template#${CSS.escape(s)}-template`):null)??E.querySelector("template"),_=v?v.content:E.body;return await m({host:i,authoredCompositionId:s,runtimeCompositionId:c,hostCompositionSrc:a,sourceNode:_,hasTemplate:!!v,fallbackBodyInnerHtml:E.body.innerHTML,compositionUrl:d,injectedStyles:e.injectedStyles,injectedScripts:e.injectedScripts,injectedLinks:e.injectedLinks,parseDimensionPx:e.parseDimensionPx,head:E.head,declaredVariableDefaults:bi(E.documentElement),variableDeclarer:E.documentElement,onDiagnostic:e.onDiagnostic})}catch(p){return f(p),null}}))).filter(i=>i!==null)}async function bE(e){let t=new Set,n={host:document.documentElement,namespace:"",referenceTarget:"document",styles:[...document.querySelectorAll("style")].map(f=>({element:f,authored:f.textContent??"",applied:f.textContent??""}))},r=await RN(e),o=await cE(e,new Set(r.map(({host:f})=>f))),i=[...r,...o];Lf([...i,n],t),await Promise.all(r.map(f=>f.runScripts()));let a=o.filter(f=>{if(f.isCurrent())return!0;for(let m of f.styles)m.element.remove();return window.__hfVariablesByComp&&delete window.__hfVariablesByComp[f.namespace],!1}),l=[...r.filter(f=>f.host.isConnected),...a],s=await cE(e,new Set(l.map(({host:f})=>f)));s.length&&Lf([...l,...s,n],t);let c=new Map([...a,...s].map(f=>[f.host,f]));for(let f of Rl()){let m=c.get(f);m&&await m.runScripts()}let d=[...l,...s].filter(f=>f.host.isConnected);Lf([...d,n],t)}function Lf(e,t){for(let{styles:r}of e)for(let o of r){let i=o.element.textContent??"";i!==o.applied&&(o.authored=i,o.applied=i)}rE(document,e.map(({host:r,namespace:o,styles:i,referenceTarget:a})=>({root:r,namespace:o,referenceTarget:a,exclude:e.filter(l=>l.host!==r&&r.contains(l.host)).map(l=>l.host),cssTexts:i.map(l=>l.authored)})),t).forEach((r,o)=>{let i=nr(e[o].host,_t);if(!(r.size===0&&i.length===0))for(let a of e[o].styles){let l=oE(a.authored,r,i);l!==a.applied&&(a.element.textContent=l),a.applied=l}}),rr()}function MN(e,t,n){let o={...e.declaredVariableDefaults??(Oe(t)?bi(t):{}),...vb(e.host)};gd(e.variableDeclarer??(Oe(t)?t:null),o,n),Sb(e.host),Object.keys(o).length>0?(window.__hfVariablesByComp||(window.__hfVariablesByComp={}),window.__hfVariablesByComp[n]=o,bd(e.host,{...xb(e.host,o,window),...Us()})):window.__hfVariablesByComp&&delete window.__hfVariablesByComp[n]}function kN(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function LN(e){if(!Array.isArray(e))throw new Error("expected a JSON array");if(!e.every(kN))throw new Error("every array entry must be an object");return e}function NN(e){let n=e.vars.data?.captionState;return n==="dim"||n==="active"?n:void 0}function FN(e){return we(e)?e.dataset.captionWrapper!=="true"?e:e.querySelector(":scope > span")??null:null}function PN(){let e=[],t=document.querySelectorAll(".caption-group");for(let n of t)for(let r of n.children){if(!we(r))continue;let o=r.dataset.captionWrapper==="true"?r.querySelector(":scope > span"):r.tagName==="SPAN"?r:null;o&&e.push(o)}return e}function IN(e){let t=e.parentElement;if(t?.dataset.captionWrapper==="true")return t;let n=document.createElement("span");return n.style.display="inline-block",n.dataset.captionWrapper="true",e.parentNode?.insertBefore(n,e),n.appendChild(e),n}var If=()=>window.gsap,xE=()=>fetch("caption-overrides.json").then(e=>e.ok?e.json():null),SE=e=>e===null?[]:LN(e);function EE(e){let t=e instanceof Error?e.message:String(e);globalThis.console.error(`[HyperFrames] Invalid caption-overrides.json: ${t}`)}function Df(){return If()?xE().then(SE).catch(e=>(EE(e),[])):Promise.resolve([])}function Of(e,t){return!If()||document.querySelectorAll(".caption-group").length===0?Promise.resolve():xE().then(n=>Hf(SE(n),e,t)).catch(EE)}function DN(e,t){return(e.wordId?FN(document.getElementById(e.wordId)):null)??(e.wordIndex!==void 0?t[e.wordIndex]??null:null)}function yE(e,t){return Object.fromEntries(t.filter(n=>e[n]!==void 0).map(n=>[n,e[n]]))}function Pf(e,t){let n=e.style.color;e.style.color=t;let r=getComputedStyle(e).color;return e.style.color=n,r}function ON(e,t){let n=t[0]?.vars.startAt;return Pf(e,n?.color===void 0?"":String(n.color))}function HN(e,t,n,r){let o=NN(e);if(o)return o;let i=String(e.vars.color);return/var\(|currentcolor/i.test(i)?Pf(t,i)===n?"dim":"active":(r.has(i)||r.set(i,Pf(t,i)),r.get(i)===n?"dim":"active")}function GN(e,t,n){if(e.dimColor)return e.dimColor;if(!(t.length===0||t.some(r=>r.vars.runBackwards)))return n}function BN(e,t,n,r){let o=e.getTweensOf(t).filter(l=>l.vars.color!==void 0).sort((l,s)=>l.startTime()-s.startTime()),i=ON(t,o);for(let l of o){let c=HN(l,t,i,r)==="dim"?n.dimColor:n.activeColor;c&&(l.vars.color=c),l.vars.runBackwards||l.invalidate?.()}let a=GN(n,o,i);a&&e.set(t,{color:a})}function UN(e,t,n,r){let o=yE(n,["x","y","scale","rotation"]),i=yE(n,["opacity","fontWeight","fontFamily"]);if(n.fontSize!==void 0&&(i.fontSize=`${n.fontSize}px`),(n.activeColor||n.dimColor)&&BN(e,t,n,r),Object.keys(i).length>0&&e.set(t,i),Object.keys(o).length>0){let a=IN(t);e.set(a,o)}}function Hf(e,t,n=()=>{}){let r=If();if(!r||e.length===0)return;n();let o=PN(),i=new Map;for(let a of e){let l=DN(a,o);!l||t&&!t.some(s=>s.contains(l))||UN(r,l,a,i)}}var Bf="data-hf-edit-base-x",Uf="data-hf-edit-base-y",Bn="data-hf-edit-original-translate",Ml=e=>{let t=parseFloat(e??"");return Number.isFinite(t)?t:0},WN=e=>{let t=[],n=0,r="";for(let o of e.trim())o==="("&&(n+=1),o===")"&&(n=Math.max(0,n-1)),/\s/.test(o)&&n===0?(r&&t.push(r),r=""):r+=o;return r&&t.push(r),t},vE=/^-?(?:\d+(?:\.\d+)?|\.\d+)px$/,Gf=(e,t)=>vE.test(e)&&vE.test(t)?`${parseFloat(e)+parseFloat(t)}px`:`calc(${e} + ${t})`,VN=(e,t,n)=>{if(!e||e==="none")return`${t} ${n}`;let[r,o,i]=WN(e);if(r===void 0)return`${t} ${n}`;if(o===void 0)return`${Gf(r,t)} ${n}`;let a=i===void 0?"":` ${i}`;return`${Gf(r,t)} ${Gf(o,n)}${a}`},$N=e=>{try{e.ownerDocument.defaultView?.gsap?.getProperty?.(e,"x")}catch{}},qN=e=>{let t=e.style.getPropertyValue("translate").trim();if(t)return t==="none"?"":t;try{let n=e.ownerDocument.defaultView,r=n?n.getComputedStyle(e).getPropertyValue("translate").trim():"";return r==="none"?"":r}catch{return""}},kl=new WeakMap;function TE(e){kl.delete(e)}function zN(e,t){let n=kl.get(e);if(!t?.force&&n!==void 0&&e.style.getPropertyValue("translate")!==n){St("position_edit_fold_skipped",{hfId:e.getAttribute("data-hf-id")});return}let r=Ml(e.getAttribute("data-x"))-Ml(e.getAttribute(Bf)),o=Ml(e.getAttribute("data-y"))-Ml(e.getAttribute(Uf));e.hasAttribute(Bn)||e.setAttribute(Bn,qN(e)),n===void 0&&$N(e);let i=e.getAttribute(Bn)??"",a=VN(i,`${r}px`,`${o}px`);e.style.setProperty("translate",a),kl.set(e,e.style.getPropertyValue("translate"))}function qi(e,t){let n=e.querySelectorAll(`[${Bn}]:not([${Bf}]):not([${Uf}])`);for(let i=0;i<n.length;i++){let a=n[i];if(a===void 0||!ar(a))continue;let l=a.getAttribute(Bn)??"";l===""?a.style.removeProperty("translate"):a.style.setProperty("translate",l),a.removeAttribute(Bn),kl.delete(a)}let r=e.querySelectorAll(`[${Bf}], [${Uf}]`),o=0;for(let i=0;i<r.length;i++){let a=r[i];a===void 0||!ar(a)||(zN(a,t),o+=1)}return o}var AE="__hfPositionEditsSeekReapplyWrapped",wE=new WeakSet,_E=new WeakMap,CE=new WeakMap;function RE(e){let t=e,n=()=>{try{qi(t.document)}catch{}},r=f=>typeof f=="function"&&(wE.has(f)||!!f[AE]),o=f=>{wE.add(f);try{Object.defineProperty(f,AE,{value:!0})}catch{}},i=f=>{if(typeof f!="function"||r(f))return f;let m=function(...p){let b=f.apply(this,p);return n(),b};return o(m),m},a=(f,m)=>{let p=_E.get(f);if(p?.has(m))return!0;let b=Object.getOwnPropertyDescriptor(f,m);if(b?.configurable===!1){let E=f[m];return typeof E=="function"&&(f[m]=i(E),n()),!1}let y=f[m],x=b?.set;return Object.defineProperty(f,m,{configurable:!0,enumerable:b?.enumerable??!0,get:()=>y,set:E=>{y=i(E),x?.call(f,E)}}),y=i(y),p??(p=new Set),p.add(m),_E.set(f,p),n(),!0},l=(f,m)=>{let p=CE.get(t),b=Object.getOwnPropertyDescriptor(t,f);if(!p?.has(f)){if(b?.configurable===!1){let E=t[f];return E?a(E,m):!1}let x=t[f];Object.defineProperty(t,f,{configurable:!0,enumerable:b?.enumerable??!0,get:()=>x,set:E=>{x=E,x&&a(x,m)}}),p??(p=new Set),p.add(f),CE.set(t,p)}let y=t[f];return y?a(y,m):!1},s=()=>{let f=l("__hf","seek"),m=l("__player","renderSeek");return f&&m};if(s())return;let c=120,d=t.setInterval(()=>{if(s()){t.clearInterval(d);return}c-=1,c<=0&&t.clearInterval(d)},50)}function Ll(e){let t=window,r=e.closest("[data-composition-id]")?.getAttribute("data-composition-id")?.trim()??"",o=r?t.__hfVariablesByComp?.[r]:void 0;if(o)return o;let i=t.__hyperframes?.getVariables?.();return i&&typeof i=="object"?i:t.__hfVariables??{}}function Nl(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function Wf(e){let t=e.replace(/[\u0000-\u0020]/g,""),n=/^([a-z][a-z0-9+.-]*):/i.exec(t);if(!n)return!0;let r=n[1]?.toLowerCase();return r?r==="https"||r==="http"||r==="blob"?!0:r==="data"?/^data:image\//i.test(t):!1:!1}var ME=new Set(["img","video","audio","source"]);function jN(e){if(typeof e=="string"&&e.length>0)return e;if(e!==null&&typeof e=="object"){let t=e.url;if(typeof t=="string"&&t.length>0)return t}return null}function KN(e){return e.replace(/[;{}<>\r\n]/g,"")}function YN(e){if(Nl(e))return String(e);if(e!==null&&typeof e=="object"){let t=e.name;if(typeof t=="string"&&t.length>0)return t}return null}function Vf(e,t){let n=e.closest("[data-composition-id]"),r=t.get(n);if(r)return r;let o=Ll(e);return t.set(n,o),o}function XN(e,t){if(e.childElementCount===0){e.textContent=t;return}let n=!1;for(let r of Array.from(e.childNodes))r.nodeType===Node.TEXT_NODE&&(r.nodeValue=n?"":t,n=!0);n||e.insertBefore(e.ownerDocument.createTextNode(t),e.firstChild)}function JN(e){return e.querySelector("[data-hf-root]")??e.getElementById("stage")??e.body?.firstElementChild??e.body}function QN(e,t){for(let n of new Set(e)){let r=Vf(n,t);for(let[o,i]of Object.entries(r)){let a=YN(i);a!==null&&we(n)&&n.style.setProperty(`--${o}`,KN(a))}}}function kE(e,t,n=!0){let r=e.getAttribute("data-var-src")?.trim();if(!r)return null;if(!ME.has(e.tagName.toLowerCase()))return n&&globalThis.console.warn(`[hyperframes] Ignoring data-var-src on <${e.tagName.toLowerCase()}>: variable-bound src is only allowed on ${Array.from(ME).join("/")}.`),null;let o=jN(Vf(e,t)[r]);return o===null?null:Wf(o)?o:(n&&globalThis.console.warn(`[hyperframes] Ignoring data-var-src="${r}": unsafe URL protocol.`),null)}function LE(e){return kE(e,new Map,!1)??xi(e)}function Fl(e,t){let n=new Map,r=i=>t?[...t.matches(i)?[t]:[],...t.querySelectorAll(i)]:Array.from(e.querySelectorAll(i)),o=t?null:JN(e);QN([...o?[o]:[],...r("[data-composition-id]")],n);for(let i of r("[data-var-src]")){let a=kE(i,n);a!==null&&xi(i)!==a&&i.setAttribute("src",a)}for(let i of r("[data-var-text]")){let a=i.getAttribute("data-var-text")?.trim();if(!a)continue;let l=Vf(i,n)[a];Nl(l)&&XN(i,String(l))}}var ZN=["video","audio","source","script",tn];function $f(e,t=()=>!1){let n=r=>r.nodeType===Node.ELEMENT_NODE&&(r.matches(e)||r.querySelector(e)!==null||t(r));return r=>r.some(o=>o.type==="attributes"||Array.from(o.addedNodes).some(n)||Array.from(o.removedNodes).some(n))}var NE=e=>$f([...ZN,...e.map(t=>`[${t}]`)].join(","));var eF=3e3,ln=new Map,tF="data-hf-color-grading-canvas",nF="__hf_color_grading_canvas__";function qE(){if(typeof MutationObserver>"u"||typeof document>"u")return;let e=document.documentElement;if(!e)return;let t=r=>{we(r)&&(r.hasAttribute(br)||r.setAttribute(br,r.style.opacity))},n=r=>{if(Oe(r)){r.matches("video, img")&&t(r);for(let o of r.querySelectorAll("video, img"))t(o)}};n(e),new MutationObserver(r=>{for(let o of r)for(let i of o.addedNodes)n(i)}).observe(e,{childList:!0,subtree:!0})}var rF=16,oF=4,Ar={enabled:!1,position:.5,softness:0,lineWidth:2},qf=["#000000","#ffffff"],iF=["#1a1a1a","#f5f5dc"],Qi=3,aF=Qi-1,sF=5,Sr=`${Wt}.0`,FE=`${Wt-1}.0`,PE=`${Qi}.0`,lF=`${(aF+.5)/Qi}`;function zi(e){let t=e.getAttribute(nl);return t==null?null:jy(t,Ll(e))}var uF=["attribute vec2 a_pos;","varying vec2 v_uv;","void main(){"," v_uv = a_pos * 0.5 + 0.5;"," gl_Position = vec4(a_pos, 0.0, 1.0);","}"].join(`
|
|
365
365
|
`),zE=["#ifdef GL_FRAGMENT_PRECISION_HIGH","precision highp float;","#else","precision mediump float;","#endif","varying vec2 v_uv;","uniform sampler2D u_source;","uniform sampler2D u_blurSource;","uniform sampler2D u_bloomSource;","uniform sampler2D u_kuwaharaSource;","uniform sampler2D u_lut;","uniform sampler2D u_advanced;","uniform vec2 u_resolution;","uniform vec2 u_uvScale;","uniform vec2 u_uvOffset;","uniform float u_blurReady;","uniform float u_bloomReady;","uniform float u_kuwaharaReady;","uniform float u_lutEnabled;","uniform float u_lutSize;","uniform vec2 u_lutTextureSize;","uniform vec3 u_lutDomainMin;","uniform vec3 u_lutDomainMax;","uniform float u_lutIntensity;","uniform vec3 u_shadowWheel;","uniform vec3 u_midtoneWheel;","uniform vec3 u_highlightWheel;","uniform float u_rgbCurvesEnabled;","uniform float u_hueCurvesEnabled;","uniform float u_secondaryCount;","uniform float u_exposure;","uniform float u_contrast;","uniform float u_highlights;","uniform float u_shadows;","uniform float u_whites;","uniform float u_blacks;","uniform float u_temperature;","uniform float u_tint;","uniform float u_vibrance;","uniform float u_saturation;","uniform float u_vignette;","uniform float u_vignetteMidpoint;","uniform float u_vignetteRoundness;","uniform float u_vignetteFeather;","uniform float u_grain;","uniform float u_grainSize;","uniform float u_grainRoughness;","uniform float u_grainSeed;","uniform float u_effectTime;","uniform float u_blur;","uniform float u_bloom;","uniform float u_kuwahara;","uniform float u_pixelate;","uniform float u_chromaBleed;","uniform float u_tapeDamage;","uniform float u_tapeTracking;","uniform float u_tapeNoise;","uniform float u_tapeSpeed;","uniform float u_filmArtifacts;","uniform float u_halftone;","uniform float u_halftoneSize;","uniform float u_twoInkPrint;","uniform float u_twoInkPrintSize;","uniform float u_ascii;","uniform float u_asciiSize;","uniform float u_asciiInvert;","uniform float u_asciiStyle;","uniform float u_asciiColor;","uniform float u_asciiRotation;","uniform float u_dither;","uniform float u_ditherSize;","uniform float u_monoScreen;","uniform float u_monoScreenSize;","uniform float u_monoScreenAngle;","uniform float u_monoScreenSpread;","uniform float u_monoScreenShape;","uniform float u_monoScreenInvert;","uniform float u_scanlines;","uniform float u_scanlineCount;","uniform float u_scanlineSoftness;","uniform float u_chromaticAberration;","uniform float u_chromaticAngle;","uniform float u_crtCurvature;","uniform float u_digitalGlitch;","uniform float u_digitalGlitchColorSplit;","uniform float u_digitalGlitchLineTear;","uniform float u_digitalGlitchPixelate;","uniform float u_digitalGlitchBlockAmount;","uniform float u_digitalGlitchBlockDisplacement;","uniform float u_digitalGlitchBlockOpacity;","uniform float u_digitalGlitchSpeed;","uniform float u_engraving;","uniform float u_engravingSpacing;","uniform float u_engravingMinThickness;","uniform float u_engravingMaxThickness;","uniform float u_engravingAngle;","uniform float u_engravingContrast;","uniform float u_engravingSharpness;","uniform float u_engravingWave;","uniform float u_engravingWaveFrequency;","uniform float u_crosshatch;","uniform float u_crosshatchSpacing;","uniform float u_crosshatchThickness;","uniform float u_crosshatchAngle;","uniform float u_crosshatchContrast;","uniform float u_crosshatchEdges;","uniform float u_crosshatchLineWeight;","uniform float u_crosshatchWave;","uniform float u_crosshatchWaveFrequency;","uniform float u_paletteSize;","uniform vec3 u_palette0;","uniform vec3 u_palette1;","uniform vec3 u_palette2;","uniform vec3 u_palette3;","uniform vec3 u_palette4;","uniform vec3 u_palette5;","uniform float u_intensity;","uniform float u_compareEnabled;","uniform float u_comparePosition;","uniform float u_compareSoftness;","uniform float u_compareLineWidth;","const float PI = 3.14159265359;","float lumaOf(vec3 c){ return dot(c, vec3(0.2126, 0.7152, 0.0722)); }","float bt601Luma(vec3 c){ return dot(c, vec3(0.299, 0.587, 0.114)); }","float grainHash(vec2 p){ return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123); }","float digitalHash(vec2 p){"," vec2 q = mod(floor(p), 251.0);"," float x = mod(q.x * q.x * 157.0 + q.x * 89.0, 251.0);"," float y = mod(q.y * q.y * 113.0 + q.y * 47.0, 251.0);"," float xy = mod(q.x * q.y * 71.0, 251.0);"," return mod(x + y + xy + 19.0, 251.0) / 251.0;","}","float colorSaturation(vec3 c){ return max(max(c.r, c.g), c.b) - min(min(c.r, c.g), c.b); }","vec2 clampUv(vec2 uv){ return clamp(uv, vec2(0.0), vec2(1.0)); }","vec2 applyCrtWarp(vec2 uv){"," vec2 centered = uv * 2.0 - 1.0;"," float curvature = clamp(u_crtCurvature, 0.0, 1.0) * 0.5;"," float dist = dot(centered, centered);"," centered *= 1.0 + curvature * dist;"," return centered * 0.5 + 0.5;","}","vec4 sampleSource(vec2 uv){ return texture2D(u_source, clampUv(uv)); }","vec4 sampleBlur(vec2 uv){ return texture2D(u_blurSource, clampUv(uv)); }","vec3 sampleBloom(vec2 uv){ return texture2D(u_bloomSource, clampUv(uv)).rgb; }","vec3 sampleKuwahara(vec2 uv){"," vec2 displayUv = uv * u_uvScale + u_uvOffset;"," return texture2D(u_kuwaharaSource, clampUv(displayUv)).rgb;","}","vec4 samplePrepared(vec2 uv){"," vec4 base = sampleSource(uv);","#ifdef HF_STAGE_BLUR"," float blur = clamp(u_blur, 0.0, 1.0);"," if (blur > 0.0 && u_blurReady > 0.5) base = mix(base, sampleBlur(uv), blur);","#endif","#ifdef HF_STAGE_KUWAHARA"," float kuwahara = clamp(u_kuwahara, 0.0, 1.0);"," if (kuwahara > 0.0 && u_kuwaharaReady > 0.5) {"," base.rgb = mix(base.rgb, sampleKuwahara(uv), kuwahara);"," }","#endif"," return base;","}","float tapeTrackingBand(float y, float center, float width){"," float offset = fract(y - center + 0.5) - 0.5;"," float triangle = max(0.0, 1.0 - abs(offset) / max(width, 0.0001));"," return triangle * triangle * (3.0 - 2.0 * triangle);","}","vec4 sampleMedia(vec2 uv){"," float pixel = clamp(u_pixelate, 0.0, 1.0);"," vec2 sampleUv = uv;","#ifdef HF_STAGE_PIXELATE"," if (pixel > 0.0) {"," float blockSize = mix(1.0, 48.0, pixel);"," vec2 cells = max(u_resolution / blockSize, vec2(1.0));"," sampleUv = (floor(clamp(uv, vec2(0.0), vec2(0.999999)) * cells) + 0.5) / cells;"," }","#endif","#ifdef HF_STAGE_TAPE"," float tapeDamage = clamp(u_tapeDamage, 0.0, 1.0);"," float tapeTracking = clamp(u_tapeTracking, 0.0, 1.0);"," float tapeNoise = clamp(u_tapeNoise, 0.0, 1.0);"," float tapeTime = u_effectTime * mix(0.0, 2.0, clamp(u_tapeSpeed, 0.0, 1.0));"," float tapeFrame = floor(tapeTime * 60.0);"," float tapeLine = floor(sampleUv.y * u_resolution.y * 0.5);"," float lineJitter = (digitalHash(vec2(tapeLine, floor(tapeFrame * 0.5))) - 0.5) * 1.8 * tapeNoise;"," float slowWobble = sin(sampleUv.y * 32.0 + tapeTime * 2.6) * 0.55;"," float headSwitch = smoothstep(0.88, 1.0, sampleUv.y) * sin(sampleUv.y * 240.0 + tapeTime * 8.0) * 4.0;"," float trackingShift = tapeTrackingBand(sampleUv.y, fract(0.08 + tapeTime * 0.083), 0.035);"," trackingShift -= tapeTrackingBand(sampleUv.y, fract(0.28 + tapeTime * 0.061), 0.03) * 0.8;"," trackingShift += tapeTrackingBand(sampleUv.y, fract(0.5 + tapeTime * 0.047), 0.04) * 0.75;"," trackingShift -= tapeTrackingBand(sampleUv.y, fract(0.72 + tapeTime * 0.037), 0.028) * 0.65;"," trackingShift += tapeTrackingBand(sampleUv.y, fract(0.89 + tapeTime * 0.029), 0.032) * 0.55;"," trackingShift *= tapeTracking * 48.0;"," float tapeShift = (lineJitter + slowWobble + headSwitch + trackingShift) * tapeDamage;","#endif"," float texelX = 1.0 / max(u_resolution.x * max(u_uvScale.x, 0.00001), 1.0);","#ifdef HF_STAGE_TAPE"," vec2 tapeUv = sampleUv + vec2(tapeShift * texelX, 0.0);","#else"," vec2 tapeUv = sampleUv;","#endif"," vec4 base = samplePrepared(tapeUv);","#ifdef HF_STAGE_TAPE"," if (tapeDamage > 0.0) {"," vec2 lumaStep = vec2(texelX * mix(1.0, 3.5, tapeDamage), 0.0);"," vec3 leftTape = samplePrepared(tapeUv - lumaStep).rgb;"," vec3 rightTape = samplePrepared(tapeUv + lumaStep).rgb;"," float tapeLuma = (bt601Luma(leftTape) + bt601Luma(base.rgb) * 2.0 + bt601Luma(rightTape)) * 0.25;"," vec3 centerChroma = base.rgb - vec3(bt601Luma(base.rgb));"," vec3 tapeColor = vec3(tapeLuma) + centerChroma;"," vec3 ghost = samplePrepared(tapeUv - vec2(texelX * 12.0, 0.0)).rgb;"," tapeColor = mix(tapeColor, ghost, 0.045 * tapeDamage);"," float fineNoise = digitalHash(floor(gl_FragCoord.xy) + vec2(tapeFrame * 17.0, tapeFrame * 3.0)) - 0.5;"," float band = digitalHash(vec2(floor(sampleUv.y * 92.0), floor(tapeFrame / 3.0)));"," float dropout = smoothstep(0.985, 1.0, band) * (digitalHash(vec2(floor(sampleUv.x * 18.0), tapeLine)) - 0.5);"," tapeColor += (fineNoise * 0.035 + dropout * 0.12) * tapeDamage * tapeNoise;"," base.rgb = mix(base.rgb, clamp(tapeColor, 0.0, 1.0), tapeDamage);"," }","#endif","#ifdef HF_STAGE_CHROMA_BLEED"," float chromaBleed = clamp(u_chromaBleed, 0.0, 1.0);"," if (chromaBleed > 0.0) {"," float radius = mix(1.0, 4.0, chromaBleed);"," vec2 stepUv = vec2(texelX * radius, 0.0);"," vec3 c0 = base.rgb;"," vec3 c1 = samplePrepared(tapeUv - stepUv).rgb;"," vec3 c2 = samplePrepared(tapeUv + stepUv).rgb;"," vec3 c3 = samplePrepared(tapeUv - stepUv * 2.0).rgb;"," vec3 c4 = samplePrepared(tapeUv + stepUv * 2.0).rgb;"," float centerLuma = lumaOf(base.rgb);"," vec3 blurredChroma = ((c0 - vec3(lumaOf(c0))) * 6.0 + (c1 - vec3(lumaOf(c1))) * 4.0 + (c2 - vec3(lumaOf(c2))) * 4.0 + (c3 - vec3(lumaOf(c3))) + (c4 - vec3(lumaOf(c4)))) / 16.0;"," base.rgb = mix(base.rgb, clamp(vec3(centerLuma) + blurredChroma, 0.0, 1.0), chromaBleed);"," }","#endif"," return base;","}","#ifdef HF_STAGE_CHROMATIC","vec4 sampleChromaticMedia(vec2 uv, vec4 center){"," float amount = clamp(u_chromaticAberration, 0.0, 1.0);"," if (amount <= 0.0) return center;"," float angle = clamp(u_chromaticAngle, 0.0, 1.0) * PI * 2.0;"," vec2 offset = vec2(cos(angle), sin(angle)) * amount * 0.02;"," vec4 positive = sampleMedia(uv + offset);"," vec4 negative = sampleMedia(uv - offset);"," vec3 split = vec3(positive.r, center.g, negative.b);"," return vec4(split, center.a);","}","#else","vec4 sampleChromaticMedia(vec2 uv, vec4 center){ return center; }","#endif","vec3 sampleDigitalSplit(vec2 uv, vec2 block, float time, float amount){"," float split = amount * 0.06;"," float direction = digitalHash(block * 0.4 + vec2(floor(time * 3.7), floor(time * 5.3)));"," vec2 axis = direction > 0.66 ? vec2(1.0, 0.0) : direction > 0.33 ? vec2(0.0, 1.0) : vec2(0.7071);"," vec4 center = sampleMedia(uv);"," return vec3(sampleMedia(uv + axis * split).r, center.g, sampleMedia(uv - axis * split).b);","}","#ifdef HF_STAGE_GLITCH","vec3 applyDigitalGlitch(vec2 uv, vec3 source){"," float amount = clamp(u_digitalGlitch, 0.0, 1.0);"," if (amount <= 0.0) return source;"," float colorSplit = clamp(u_digitalGlitchColorSplit, 0.0, 1.0) * 2.0;"," float lineTear = clamp(u_digitalGlitchLineTear, 0.0, 1.0) * 2.0;"," float pixelate = clamp(u_digitalGlitchPixelate, 0.0, 1.0) * 2.0;"," float blockAmount = clamp(u_digitalGlitchBlockAmount, 0.0, 1.0);"," float blockDisplacement = clamp(u_digitalGlitchBlockDisplacement, 0.0, 1.0) * 2.0;"," float blockOpacity = clamp(u_digitalGlitchBlockOpacity, 0.0, 1.0);"," float speed = clamp(u_digitalGlitchSpeed, 0.0, 1.0) * 2.0;"," float time = u_effectTime * speed;"," float blockCount = 8.0 + blockAmount * 60.0;"," vec2 block = floor(uv * blockCount);"," float randomA = digitalHash(block + vec2(floor(time * 7.3), floor(time * 11.1)));"," float randomB = digitalHash(block * 0.7 + vec2(17.3 + floor(time * 6.6), 29.1));"," float randomC = digitalHash(block + vec2(floor(time * 5.7) * 13.0, 41.0));"," float randomD = digitalHash(block * 1.3 + vec2(7.0, floor(time * 3.2) * 7.0));"," vec2 displaced = uv;"," if (blockDisplacement > 0.0 && blockOpacity > 0.0) {"," float threshold = 1.0 - blockDisplacement * 0.4;"," if (randomA > threshold) {"," displaced += vec2((randomB - 0.5) * blockDisplacement * 0.5, (randomC - 0.5) * blockDisplacement * 0.3);"," }"," if (randomD > 0.92 && blockDisplacement > 0.5) {"," displaced.x += (digitalHash(vec2(block.y, floor(time * 8.0))) - 0.5) * blockDisplacement;"," }"," displaced = mix(uv, displaced, blockOpacity);"," }"," if (lineTear > 0.0) {"," float row = floor(uv.y * (50.0 + lineTear * 150.0));"," float tearA = digitalHash(vec2(row * 7.3 + floor(time * 12.0 + row * 0.1) * 3.7, 13.0));"," float tearB = digitalHash(vec2(row * 13.7 + floor(time * 8.3) * 5.1, 31.0));"," if (tearA > 1.0 - lineTear * 0.5) displaced.x += (tearB - 0.5) * lineTear * 0.4;"," if (tearB > 0.95 && lineTear > 0.3) displaced.x += (tearA - 0.5) * lineTear * 0.8;"," }"," if (pixelate > 0.0) {"," float pixelRandom = digitalHash(block * 0.5 + vec2(floor(time * 4.9), 53.0));"," if (pixelRandom > 1.0 - pixelate * 0.35) {"," float cells = 4.0 + (1.0 - pixelRandom) * pixelate * 40.0;"," displaced = (floor(clampUv(displaced) * cells) + 0.5) / cells;"," }"," }"," displaced = clampUv(displaced);"," vec3 glitch = sampleDigitalSplit(displaced, block, time, colorSplit);"," if (blockDisplacement > 0.2 && blockOpacity > 0.0) {"," float corruption = digitalHash(block * 1.1 + vec2(floor(time * 11.9), 67.0));"," vec3 changed = glitch;"," if (corruption > 0.9) changed = 1.0 - glitch;"," else if (corruption > 0.85) changed = corruption > 0.875 ? glitch.gbr : glitch.brg;"," else if (corruption > 0.8) {"," float channel = digitalHash(block + vec2(73.0));"," if (channel > 0.66) changed.r = min(changed.r * 2.0, 1.0);"," else if (channel > 0.33) changed.g = min(changed.g * 2.0, 1.0);"," else changed.b = min(changed.b * 2.0, 1.0);"," }"," glitch = mix(glitch, changed, blockOpacity);"," }"," if (blockOpacity > 0.0) {"," float flash = digitalHash(block * 0.8 + vec2(floor(time * 14.7), 83.0));"," vec3 flashed = flash > 0.97 ? min(glitch * 1.8, vec3(1.0)) : flash > 0.94 ? glitch * 0.3 : glitch;"," glitch = mix(glitch, flashed, blockOpacity * 0.6);"," }"," if (lineTear > 0.1) {"," float interference = pow(sin(uv.y * (300.0 + randomA * 200.0) + time * 30.0) * 0.5 + 0.5, 6.0);"," glitch -= interference * 0.08 * lineTear;"," }"," return mix(source, clamp(glitch, 0.0, 1.0), amount);","}","#else","vec3 applyDigitalGlitch(vec2 uv, vec3 source){ return source; }","#endif","float dustMask(vec2 uv, float frameBucket){"," vec2 grid = vec2(128.0, 72.0);"," vec2 cell = floor(uv * grid);"," vec2 local = fract(uv * grid) - 0.5;"," float chance = grainHash(cell + frameBucket * 19.13);"," float radius = mix(0.05, 0.34, grainHash(cell + 7.1));"," return step(0.9975, chance) * (1.0 - smoothstep(radius, radius + 0.08, length(local)));","}","float screenDot(vec2 p, float ink, float angle, float sharpness){"," float c = cos(angle);"," float s = sin(angle);"," vec2 q = mat2(c, -s, s, c) * p;"," vec2 d = fract(q) - 0.5;"," float radius = sqrt(clamp(ink, 0.0, 1.0)) * 0.68;"," float edge = mix(0.16, 0.025, sharpness);"," return 1.0 - smoothstep(radius - edge, radius + edge, length(d));","}","vec3 paletteColor(float index);","float monoScreenMask(vec2 local, float radius, float shape, float softness){"," vec2 centered = local - 0.5;"," float distanceToInk = length(centered);"," if (shape > 0.5 && shape < 1.5) distanceToInk = max(abs(centered.x), abs(centered.y));"," if (shape > 1.5 && shape < 2.5) distanceToInk = abs(centered.x) + abs(centered.y);"," if (shape > 2.5 && shape < 3.5) distanceToInk = max(abs(centered.x) * 0.86 + centered.y * 0.5, -centered.y);"," if (shape > 3.5) distanceToInk = abs(centered.y);"," float shapeRadius = shape > 3.5 ? radius * 0.45 : radius;"," return 1.0 - smoothstep(shapeRadius, shapeRadius + softness, distanceToInk);","}","#ifdef HF_STAGE_MONO_SCREEN","vec3 applyMonoScreen(vec3 source, float amount){"," if (amount <= 0.0) return source;"," float invert = step(0.5, u_monoScreenInvert);"," float coverage = mix(1.0 - lumaOf(source), lumaOf(source), invert);"," coverage = pow(clamp(coverage, 0.0, 1.0), mix(1.7, 0.58, clamp(u_monoScreenSpread, 0.0, 1.0)));"," float scale = max(min(u_resolution.x, u_resolution.y) / 540.0, 0.25);"," float cellPx = mix(4.0, 18.0, clamp(u_monoScreenSize, 0.0, 1.0)) * scale;"," float angle = clamp(u_monoScreenAngle, 0.0, 1.0) * PI * 0.5;"," float cosine = cos(angle);"," float sine = sin(angle);"," vec2 point = mat2(cosine, -sine, sine, cosine) * gl_FragCoord.xy / max(cellPx, 1.0);"," float radius = sqrt(coverage) * 0.68;"," float inkMask = monoScreenMask(fract(point), radius, floor(u_monoScreenShape + 0.5), 0.035);"," vec3 ink = paletteColor(0.0);"," vec3 paper = paletteColor(max(u_paletteSize - 1.0, 1.0));"," return mix(source, mix(paper, ink, inkMask), amount);","}","#else","vec3 applyMonoScreen(vec3 source, float amount){ return source; }","#endif","#ifdef HF_STAGE_ENGRAVING","vec3 applyEngraving(vec3 source, float amount){"," if (amount <= 0.0) return source;"," float spacing = mix(3.0, 20.0, clamp(u_engravingSpacing, 0.0, 1.0));"," float minThickness = mix(0.0, 2.0, clamp(u_engravingMinThickness, 0.0, 1.0));"," float maxThickness = mix(1.0, 8.0, clamp(u_engravingMaxThickness, 0.0, 1.0));"," float angle = clamp(u_engravingAngle, 0.0, 1.0) * PI;"," vec2 alongAxis = vec2(cos(angle), sin(angle));"," vec2 acrossAxis = vec2(-alongAxis.y, alongAxis.x);"," float along = dot(gl_FragCoord.xy, alongAxis);"," float across = dot(gl_FragCoord.xy, acrossAxis);"," float frequency = mix(1.0, 10.0, clamp(u_engravingWaveFrequency, 0.0, 1.0));"," float wave = sin(along * frequency * 0.01);"," across += wave * clamp(u_engravingWave, 0.0, 1.0) * 3.0;"," float lineIndex = floor(across / max(spacing, 1.0));"," float lineDistance = abs(fract(across / max(spacing, 1.0)) - 0.5) * spacing;"," float contrast = mix(0.5, 2.0, clamp(u_engravingContrast, 0.0, 1.0));"," float darkness = 1.0 - pow(clamp(lumaOf(source), 0.0, 1.0), contrast);"," float variation = mix(0.88, 1.12, digitalHash(vec2(lineIndex, 73.0)));"," float thickness = mix(minThickness, maxThickness, darkness) * variation;"," float edge = mix(1.0, 0.3, clamp(u_engravingSharpness, 0.0, 1.0));"," float inkMask = 1.0 - smoothstep(max(thickness * 0.5 - edge, 0.0), thickness * 0.5 + edge, lineDistance);"," inkMask *= smoothstep(0.015, 0.12, darkness);"," vec3 ink = paletteColor(0.0);"," vec3 paper = paletteColor(max(u_paletteSize - 1.0, 1.0));"," return mix(source, mix(paper, ink, inkMask), amount);","}","#else","vec3 applyEngraving(vec3 source, float amount){ return source; }","#endif","float crosshatchLine(vec2 pixel, float angle, float spacing, float thickness, float seed){"," vec2 alongAxis = vec2(cos(angle), sin(angle));"," vec2 acrossAxis = vec2(-alongAxis.y, alongAxis.x);"," float along = dot(pixel, alongAxis);"," float across = dot(pixel, acrossAxis);"," float frequency = mix(1.0, 10.0, clamp(u_crosshatchWaveFrequency, 0.0, 1.0));"," across += sin(along * frequency * 0.02 + u_effectTime + seed) * clamp(u_crosshatchWave, 0.0, 1.0) * 5.0;"," float lineIndex = floor(across / max(spacing, 1.0));"," float distanceToLine = abs(fract(across / max(spacing, 1.0)) - 0.5) * spacing;"," float variation = mix(1.0, 0.5 + digitalHash(vec2(lineIndex, seed)), clamp(u_crosshatchLineWeight, 0.0, 1.0));"," float halfWidth = thickness * variation * 0.5;"," return 1.0 - smoothstep(max(halfWidth - 0.5, 0.0), halfWidth + 0.5, distanceToLine);","}","float crosshatchEdge(vec2 uv){"," vec2 texel = 1.0 / max(u_resolution * u_uvScale, vec2(1.0));"," float tl = lumaOf(sampleMedia(uv + texel * vec2(-1.0, -1.0)).rgb);"," float tc = lumaOf(sampleMedia(uv + texel * vec2( 0.0, -1.0)).rgb);"," float tr = lumaOf(sampleMedia(uv + texel * vec2( 1.0, -1.0)).rgb);"," float ml = lumaOf(sampleMedia(uv + texel * vec2(-1.0, 0.0)).rgb);"," float mr = lumaOf(sampleMedia(uv + texel * vec2( 1.0, 0.0)).rgb);"," float bl = lumaOf(sampleMedia(uv + texel * vec2(-1.0, 1.0)).rgb);"," float bc = lumaOf(sampleMedia(uv + texel * vec2( 0.0, 1.0)).rgb);"," float br = lumaOf(sampleMedia(uv + texel * vec2( 1.0, 1.0)).rgb);"," float gx = -tl - 2.0 * ml - bl + tr + 2.0 * mr + br;"," float gy = -tl - 2.0 * tc - tr + bl + 2.0 * bc + br;"," return length(vec2(gx, gy));","}","#ifdef HF_STAGE_CROSSHATCH","vec3 applyCrosshatch(vec2 uv, vec3 source, float amount){"," if (amount <= 0.0) return source;"," float spacing = mix(5.0, 30.0, clamp(u_crosshatchSpacing, 0.0, 1.0));"," float thickness = mix(1.0, 5.0, clamp(u_crosshatchThickness, 0.0, 1.0));"," float baseAngle = -clamp(u_crosshatchAngle, 0.0, 1.0) * PI;"," float contrast = mix(0.5, 2.0, clamp(u_crosshatchContrast, 0.0, 1.0));"," float darkness = 1.0 - pow(clamp(lumaOf(source), 0.0, 1.0), contrast);"," vec3 ink = paletteColor(0.0);"," vec3 paper = paletteColor(max(u_paletteSize - 1.0, 1.0));"," vec3 result = paper;"," float layer = crosshatchLine(gl_FragCoord.xy, baseAngle, spacing, thickness, 1.0) * smoothstep(0.2, 0.4, darkness);"," result = mix(result, ink, layer);"," layer = crosshatchLine(gl_FragCoord.xy, baseAngle + PI * 0.5, spacing * 0.95, thickness * 0.9, 2.0) * smoothstep(0.4, 0.6, darkness);"," result = mix(result, ink, layer);"," layer = crosshatchLine(gl_FragCoord.xy, baseAngle + PI * 0.25, spacing * 0.9, thickness * 0.8, 3.0) * smoothstep(0.6, 0.8, darkness);"," result = mix(result, ink, layer);"," layer = crosshatchLine(gl_FragCoord.xy, baseAngle - PI * 0.25, spacing * 0.85, thickness * 0.7, 4.0) * smoothstep(0.75, 0.9, darkness);"," result = mix(result, ink, layer);"," result = mix(result, ink, smoothstep(0.9, 1.0, darkness) * 0.8);"," float edgeStrength = mix(0.0, 2.0, clamp(u_crosshatchEdges, 0.0, 1.0));"," float edge = smoothstep(0.1, 0.3, crosshatchEdge(uv)) * edgeStrength;"," result = mix(result, ink, clamp(edge, 0.0, 1.0));"," return mix(source, result, amount);","}","#else","vec3 applyCrosshatch(vec2 uv, vec3 source, float amount){ return source; }","#endif","#ifdef HF_STAGE_HALFTONE","vec3 applyHalftone(vec3 source, float amount){"," if (amount <= 0.0) return source;"," vec3 cmy = 1.0 - source;"," float k = min(cmy.r, min(cmy.g, cmy.b));"," vec3 inks = max(cmy - vec3(k * 0.72), 0.0);"," float scale = min(u_resolution.x, u_resolution.y) / 540.0;"," float cellPx = mix(5.0, 14.0, clamp(u_halftoneSize, 0.0, 1.0)) * max(scale, 0.25);"," vec2 p = gl_FragCoord.xy / max(cellPx, 1.0);"," float cyan = screenDot(p, inks.r, 0.261799, 0.78);"," float magenta = screenDot(p, inks.g, 1.308997, 0.78);"," float yellow = screenDot(p, inks.b, 0.0, 0.78);"," float blackInk = screenDot(p, k, 0.785398, 0.82);"," vec3 printColor = vec3(0.975, 0.962, 0.925);"," printColor *= mix(vec3(1.0), vec3(0.05, 0.79, 0.86), cyan);"," printColor *= mix(vec3(1.0), vec3(0.91, 0.08, 0.48), magenta);"," printColor *= mix(vec3(1.0), vec3(0.98, 0.83, 0.08), yellow);"," printColor *= mix(vec3(1.0), vec3(0.035), blackInk * 0.92);"," return mix(source, printColor, amount);","}","#else","vec3 applyHalftone(vec3 source, float amount){ return source; }","#endif","#ifdef HF_STAGE_TWO_INK_PRINT","vec3 applyTwoInkPrint(vec3 source, float amount){"," if (amount <= 0.0) return source;"," float sourceLuma = lumaOf(source);"," float darkness = 1.0 - sourceLuma;"," float warmBias = clamp(source.r - (source.g + source.b) * 0.5, -0.35, 0.35);"," float coolBias = clamp((source.g + source.b) * 0.5 - source.r, -0.35, 0.35);"," float redTone = smoothstep(0.08, 0.72, darkness) * (1.0 - 0.68 * smoothstep(0.66, 1.0, darkness));"," float tealTone = smoothstep(0.30, 0.92, darkness);"," float redCoverage = clamp(redTone + warmBias * 1.35 - coolBias * 0.35, 0.0, 1.0);"," float tealCoverage = clamp(tealTone + coolBias * 1.1 - warmBias * 0.45, 0.0, 1.0);"," float scale = min(u_resolution.x, u_resolution.y) / 540.0;"," float cellPx = mix(4.5, 12.0, clamp(u_twoInkPrintSize, 0.0, 1.0)) * max(scale, 0.25);"," vec2 p = gl_FragCoord.xy / max(cellPx, 1.0);"," float redDot = screenDot(p, redCoverage, 0.261799, 0.84);"," float tealDot = screenDot(p + vec2(0.12, -0.08), tealCoverage, 1.308997, 0.84);"," float paperNoise = grainHash(floor(gl_FragCoord.xy * 0.5)) - 0.5;"," vec3 paper = vec3(0.955, 0.910, 0.795) + paperNoise * 0.018;"," vec3 vermilion = vec3(0.88, 0.13, 0.075);"," vec3 teal = vec3(0.035, 0.285, 0.355);"," vec3 overprint = vec3(0.045, 0.055, 0.052);"," vec3 printColor = paper * (1.0 - redDot) * (1.0 - tealDot);"," printColor += vermilion * redDot * (1.0 - tealDot);"," printColor += teal * (1.0 - redDot) * tealDot;"," printColor += overprint * redDot * tealDot;"," return mix(source, clamp(printColor, 0.0, 1.0), amount);","}","#else","vec3 applyTwoInkPrint(vec3 source, float amount){ return source; }","#endif","vec3 paletteColor(float index){"," if (index < 0.5) return u_palette0;"," if (index < 1.5) return u_palette1;"," if (index < 2.5) return u_palette2;"," if (index < 3.5) return u_palette3;"," if (index < 4.5) return u_palette4;"," return u_palette5;","}","float bayer4(vec2 point){"," vec2 cell = mod(floor(point), 4.0);"," if (cell.y < 0.5) {"," if (cell.x < 0.5) return 0.5 / 16.0;"," if (cell.x < 1.5) return 8.5 / 16.0;"," if (cell.x < 2.5) return 2.5 / 16.0;"," return 10.5 / 16.0;"," }"," if (cell.y < 1.5) {"," if (cell.x < 0.5) return 12.5 / 16.0;"," if (cell.x < 1.5) return 4.5 / 16.0;"," if (cell.x < 2.5) return 14.5 / 16.0;"," return 6.5 / 16.0;"," }"," if (cell.y < 2.5) {"," if (cell.x < 0.5) return 3.5 / 16.0;"," if (cell.x < 1.5) return 11.5 / 16.0;"," if (cell.x < 2.5) return 1.5 / 16.0;"," return 9.5 / 16.0;"," }"," if (cell.x < 0.5) return 15.5 / 16.0;"," if (cell.x < 1.5) return 7.5 / 16.0;"," if (cell.x < 2.5) return 13.5 / 16.0;"," return 5.5 / 16.0;","}","float standardAsciiSample(float brightness, vec2 grid){"," if (brightness < 0.1) return 0.0;"," if (brightness < 0.2) return grid.x == 2.0 && grid.y == 5.0 ? 1.0 : 0.0;"," if (brightness < 0.3) return grid.x == 2.0 && (grid.y == 2.0 || grid.y == 4.0) ? 1.0 : 0.0;"," if (brightness < 0.4) return (grid.y == 2.0 || grid.y == 4.0) && grid.x >= 1.0 && grid.x <= 3.0 ? 1.0 : 0.0;"," if (brightness < 0.5) {"," bool cross = (grid.x == 2.0 && grid.y >= 2.0 && grid.y <= 4.0) || (grid.y == 3.0 && grid.x >= 1.0 && grid.x <= 3.0);"," bool diagonals = (grid.x == 1.0 || grid.x == 3.0) && (grid.y == 2.0 || grid.y == 4.0);"," return cross || diagonals ? 1.0 : 0.0;"," }"," if (brightness < 0.6) {"," bool ring = ((grid.y == 2.0 || grid.y == 4.0) && grid.x >= 1.0 && grid.x <= 3.0) || ((grid.x == 1.0 || grid.x == 3.0) && grid.y == 3.0);"," return ring ? 1.0 : 0.0;"," }"," bool outline = ((grid.y == 1.0 || grid.y == 5.0) && grid.x >= 1.0 && grid.x <= 3.0) || ((grid.x == 0.0 || grid.x == 4.0) && grid.y >= 2.0 && grid.y <= 4.0) || ((grid.x == 1.0 || grid.x == 3.0) && grid.y >= 1.0 && grid.y <= 5.0);"," if (brightness < 0.7) return outline ? 1.0 : 0.0;"," if (brightness < 0.8) {"," bool slash = abs(grid.x - 2.0) == abs(grid.y - 3.0) && grid.x >= 1.0 && grid.x <= 3.0;"," return outline || slash ? 1.0 : 0.0;"," }"," if (brightness < 0.9) {"," bool loops = ((grid.y == 1.0 || grid.y == 3.0 || grid.y == 5.0) && grid.x >= 1.0 && grid.x <= 3.0) || ((grid.x == 1.0 || grid.x == 3.0) && (grid.y == 2.0 || grid.y == 4.0));"," return loops ? 1.0 : 0.0;"," }"," return 1.0;","}","float asciiStyleSample(float style, float brightness, vec2 uv){"," vec2 grid = floor(uv * vec2(5.0, 7.0));"," if (style < 0.5) return standardAsciiSample(brightness, grid);"," if (style < 1.5) {"," float checker = mod(grid.x + grid.y, 2.0);"," float ruled = mod(grid.x, 2.0) == 0.0 || mod(grid.y, 2.0) == 0.0 ? 1.0 : 0.0;"," if (brightness < 0.125) return 0.0;"," if (brightness < 0.25) return checker == 0.0 ? 0.5 : 0.0;"," if (brightness < 0.375) return ruled * 0.6;"," if (brightness < 0.5) return checker == 0.0 ? 1.0 : 0.0;"," if (brightness < 0.625) return ruled > 0.5 ? 1.0 : 0.3;"," if (brightness < 0.75) return checker == 0.0 ? 1.0 : 0.7;"," if (brightness < 0.875) return ruled > 0.5 ? 1.0 : 0.85;"," return 1.0;"," }"," if (style < 2.5) {"," if (brightness < 0.14) return 0.0;"," if (brightness < 0.28) return grid.x == 2.0 && grid.y == 1.0 ? 1.0 : 0.0;"," if (brightness < 0.42) return grid.x == 2.0 && grid.y == 5.0 ? 1.0 : 0.0;"," if (brightness < 0.56) return grid.y == 3.0 && grid.x >= 1.0 && grid.x <= 3.0 ? 1.0 : 0.0;"," if (brightness < 0.7) return (grid.x == 2.0 && grid.y >= 2.0 && grid.y <= 4.0) || (grid.y == 3.0 && grid.x >= 1.0 && grid.x <= 3.0) ? 1.0 : 0.0;"," if (brightness < 0.84) return abs(grid.x - 2.0) == abs(grid.y - 3.0) && grid.y >= 2.0 && grid.y <= 4.0 ? 1.0 : 0.0;"," return grid.x == 1.0 || grid.x == 3.0 || grid.y == 2.0 || grid.y == 4.0 ? 1.0 : 0.0;"," }"," if (style < 3.5) return grid.y >= 6.0 - brightness * 7.0 ? 1.0 : 0.0;"," if (style < 4.5) {"," vec2 dots = floor(uv * vec2(2.0, 4.0));"," if (brightness < 0.125) return 0.0;"," if (brightness < 0.25) return dots.y == 3.0 ? 1.0 : 0.0;"," if (brightness < 0.375) return dots.y >= 2.0 ? 1.0 : 0.0;"," if (brightness < 0.5) return dots.y >= 1.0 ? 1.0 : 0.0;"," if (brightness < 0.625) return dots.y >= 1.0 || dots.x == 1.0 ? 1.0 : 0.0;"," if (brightness < 0.75) return 1.0;"," if (brightness < 0.875) return mod(grid.x + grid.y, 2.0) < 1.5 ? 1.0 : 0.7;"," return 1.0;"," }"," if (style < 5.5) {"," if (brightness < 0.125) return 0.0;"," if (brightness < 0.25) return grid.x == 2.0 && grid.y == 3.0 ? 1.0 : 0.0;"," if (brightness < 0.375) return grid.y == 3.0 && grid.x >= 1.0 && grid.x <= 3.0 ? 1.0 : 0.0;"," if (brightness < 0.5) return grid.x + grid.y == 5.0 || grid.x + grid.y == 6.0 ? 1.0 : 0.0;"," if (brightness < 0.625) return grid.x == 2.0 ? 1.0 : 0.0;"," if (brightness < 0.75) return abs(grid.x - grid.y / 1.4) < 0.7 && grid.x >= 1.0 && grid.x <= 3.0 ? 1.0 : 0.0;"," if (brightness < 0.875) return grid.x == 2.0 || grid.y == 3.0 ? 1.0 : 0.0;"," return grid.x == 1.0 || grid.x == 3.0 || grid.y == 2.0 || grid.y == 4.0 ? 1.0 : 0.0;"," }"," if (style < 6.5) {"," bool top = grid.y == 0.0 && grid.x >= 1.0 && grid.x <= 3.0;"," bool topLeft = grid.x == 1.0 && grid.y <= 3.0;"," bool topRight = grid.x == 3.0 && grid.y <= 3.0;"," bool middle = grid.y == 3.0 && grid.x >= 1.0 && grid.x <= 3.0;"," bool bottomLeft = grid.x == 1.0 && grid.y >= 3.0;"," bool bottomRight = grid.x == 3.0 && grid.y >= 3.0;"," bool bottom = grid.y == 6.0 && grid.x >= 1.0 && grid.x <= 3.0;"," if (brightness < 0.1) return 0.0;"," if (brightness < 0.2) return topRight || bottomRight ? 1.0 : 0.0;"," if (brightness < 0.3) return top || topRight || middle || bottomLeft || bottom ? 1.0 : 0.0;"," if (brightness < 0.4) return top || topRight || middle || bottomRight || bottom ? 1.0 : 0.0;"," if (brightness < 0.5) return topLeft || middle || topRight || bottomRight ? 1.0 : 0.0;"," if (brightness < 0.6) return top || topLeft || middle || bottomRight || bottom ? 1.0 : 0.0;"," if (brightness < 0.7) return top || topLeft || middle || bottomLeft || bottomRight || bottom ? 1.0 : 0.0;"," if (brightness < 0.8) return top || topRight || bottomRight ? 1.0 : 0.0;"," if (brightness < 0.9) return top || topLeft || topRight || middle || bottomLeft || bottomRight || bottom ? 1.0 : 0.0;"," return top || topLeft || topRight || middle || bottomRight || bottom ? 1.0 : 0.0;"," }"," float slash = grid.x - grid.y;"," float backslash = grid.x + grid.y;"," if (brightness < 0.16) return 0.0;"," if (brightness < 0.33) return mod(slash, 3.0) < 0.5 ? 1.0 : 0.0;"," if (brightness < 0.5) return mod(slash, 2.0) < 0.5 ? 1.0 : 0.0;"," bool diagonalA = mod(slash, 2.0) < 0.5;"," bool diagonalB = mod(backslash, 2.0) < 0.5;"," if (brightness < 0.66) return diagonalA || diagonalB ? 1.0 : 0.0;"," if (brightness < 0.83) return mod(slash, 1.5) < 0.5 || mod(backslash, 1.5) < 0.5 ? 1.0 : 0.2;"," return mod(slash, 1.0) < 0.6 || mod(backslash, 1.0) < 0.6 ? 1.0 : 0.5;","}","vec3 rgbToHsv(vec3 color){"," float maximum = max(max(color.r, color.g), color.b);"," float minimum = min(min(color.r, color.g), color.b);"," float delta = maximum - minimum;"," float hue = 0.0;"," if (delta > 0.00001) {"," if (maximum == color.r) hue = mod((color.g - color.b) / delta, 6.0);"," else if (maximum == color.g) hue = (color.b - color.r) / delta + 2.0;"," else hue = (color.r - color.g) / delta + 4.0;"," hue = fract(hue / 6.0);"," }"," return vec3(hue, maximum > 0.00001 ? delta / maximum : 0.0, maximum);","}","vec3 hsvToRgb(vec3 color){"," vec3 bands = abs(fract(color.xxx + vec3(0.0, 0.6666667, 0.3333333)) * 6.0 - 3.0);"," return color.z * mix(vec3(1.0), clamp(bands - 1.0, 0.0, 1.0), color.y);","}","vec4 sampleAdvancedCurve(float coordinate, float row){",` float position = clamp(coordinate, 0.0, 1.0) * ${FE};`," float lower = floor(position);",` float upper = min(lower + 1.0, ${FE});`,` float y = (row + 0.5) / ${PE};`,` vec4 before = texture2D(u_advanced, vec2((lower + 0.5) / ${Sr}, y));`,` vec4 after = texture2D(u_advanced, vec2((upper + 0.5) / ${Sr}, y));`," return mix(before, after, position - lower);","}","vec4 sampleHueCurve(float coordinate){",` float position = fract(coordinate) * ${Sr};`," float lower = floor(position);",` float upper = mod(lower + 1.0, ${Sr});`,` float y = 1.5 / ${PE};`,` vec4 before = texture2D(u_advanced, vec2((lower + 0.5) / ${Sr}, y));`,` vec4 after = texture2D(u_advanced, vec2((upper + 0.5) / ${Sr}, y));`," return mix(before, after, position - lower);","}","vec4 advancedConfig(float index){",` return texture2D(u_advanced, vec2((index + 0.5) / ${Sr}, ${lF}));`,"}","vec3 wheelDirection(float hue){"," vec3 direction = hsvToRgb(vec3(fract(hue), 1.0, 1.0));"," direction -= vec3(lumaOf(direction));"," return direction / max(max(max(abs(direction.r), abs(direction.g)), abs(direction.b)), 0.0001);","}","vec3 applyTonalWheels(vec3 color){"," float luma = lumaOf(color);"," float shadows = 1.0 - smoothstep(0.0, 0.6, luma);"," float highlights = smoothstep(0.4, 1.0, luma);"," float midtones = max(0.0, 1.0 - shadows - highlights);"," float total = max(shadows + midtones + highlights, 0.0001);"," vec3 weights = vec3(shadows, midtones, highlights) / total;"," color += wheelDirection(u_shadowWheel.x) * u_shadowWheel.y * weights.x * 0.18;"," color += wheelDirection(u_midtoneWheel.x) * u_midtoneWheel.y * weights.y * 0.18;"," color += wheelDirection(u_highlightWheel.x) * u_highlightWheel.y * weights.z * 0.18;"," color += u_shadowWheel.z * weights.x * 0.25;"," color += u_midtoneWheel.z * weights.y * 0.25;"," color += u_highlightWheel.z * weights.z * 0.25;"," return color;","}","#ifdef HF_STAGE_RGB_CURVES","vec3 applyRgbCurves(vec3 color){"," if (u_rgbCurvesEnabled < 0.5) return color;"," vec3 master = vec3("," sampleAdvancedCurve(color.r, 0.0).a,"," sampleAdvancedCurve(color.g, 0.0).a,"," sampleAdvancedCurve(color.b, 0.0).a"," );"," return vec3("," sampleAdvancedCurve(master.r, 0.0).r,"," sampleAdvancedCurve(master.g, 0.0).g,"," sampleAdvancedCurve(master.b, 0.0).b"," );","}","#else","vec3 applyRgbCurves(vec3 color){ return color; }","#endif","float decodeSigned(float value){ return (value * 255.0 - 128.0) / 127.0; }","#ifdef HF_STAGE_HUE_CURVES","vec3 applyHueCurves(vec3 color){"," if (u_hueCurvesEnabled < 0.5) return color;"," vec3 hsv = rgbToHsv(clamp(color, 0.0, 1.0));"," vec3 curves = sampleHueCurve(hsv.x).rgb;"," float originalLuma = lumaOf(color);"," hsv.x = fract(hsv.x + decodeSigned(curves.r) * 0.5);"," hsv.y = clamp(hsv.y * max(0.0, 1.0 + decodeSigned(curves.g)), 0.0, 1.0);"," vec3 shifted = hsvToRgb(hsv);"," shifted += vec3(originalLuma - lumaOf(shifted) + decodeSigned(curves.b));"," return shifted;","}","#else","vec3 applyHueCurves(vec3 color){ return color; }","#endif","float softRangeMask(float value, float minimum, float maximum, float softness){"," if (value < minimum) {"," if (softness <= 0.0) return 0.0;"," return smoothstep(minimum - softness, minimum, value);"," }"," if (value > maximum) {"," if (softness <= 0.0) return 0.0;"," return 1.0 - smoothstep(maximum, maximum + softness, value);"," }"," return 1.0;","}","float hueRangeMask(float hue, float saturation, vec3 key){"," float distance = abs(fract(hue - key.x + 0.5) - 0.5) * 360.0;"," float range = key.y * 180.0;"," float softness = key.z * 180.0;"," if (range < 179.999 && saturation < 0.001) return 0.0;"," if (distance <= range) return 1.0;"," if (softness <= 0.0) return 0.0;"," return 1.0 - smoothstep(range, range + softness, distance);","}","vec3 applySecondary(vec3 color, float index){"," float base = index * 5.0;"," vec4 hueKey = advancedConfig(base);"," vec4 saturationKey = advancedConfig(base + 1.0);"," vec4 lumaKey = advancedConfig(base + 2.0);"," vec4 correction = advancedConfig(base + 3.0);"," vec4 tintCorrection = advancedConfig(base + 4.0);"," vec3 hsv = rgbToHsv(clamp(color, 0.0, 1.0));"," float luma = lumaOf(color);"," float mask = hueRangeMask(hsv.x, hsv.y, hueKey.rgb);"," mask *= softRangeMask(hsv.y, saturationKey.x, saturationKey.y, saturationKey.z * 0.5);"," mask *= softRangeMask(luma, lumaKey.x, lumaKey.y, lumaKey.z * 0.5);"," if (mask <= 0.0) return color;"," hsv.x = fract(hsv.x + decodeSigned(correction.x) * 0.5);"," vec3 corrected = hsvToRgb(hsv);"," float correctedLuma = lumaOf(corrected);"," corrected = mix(vec3(correctedLuma), corrected, max(0.0, 1.0 + decodeSigned(correction.y)));"," corrected += vec3(decodeSigned(correction.z));"," float temperature = decodeSigned(correction.w);"," float tint = decodeSigned(tintCorrection.x);"," corrected.r += temperature * 0.08 + tint * 0.04;"," corrected.b -= temperature * 0.08 - tint * 0.04;"," corrected.g -= tint * 0.08;"," return mix(color, corrected, mask);","}","vec3 applyAdvancedGrade(vec3 color){"," color = applyTonalWheels(color);"," color = applyRgbCurves(color);"," color = applyHueCurves(color);","#ifdef HF_STAGE_SECONDARIES"," if (u_secondaryCount > 0.5) color = applySecondary(color, 0.0);"," if (u_secondaryCount > 1.5) color = applySecondary(color, 1.0);"," if (u_secondaryCount > 2.5) color = applySecondary(color, 2.0);"," if (u_secondaryCount > 3.5) color = applySecondary(color, 3.0);","#endif"," return color;","}","vec3 sampleLut(float r, float g, float b){"," float size = max(u_lutSize, 2.0);"," float x = (r + b * size + 0.5) / max(u_lutTextureSize.x, 1.0);"," float y = (g + 0.5) / max(u_lutTextureSize.y, 1.0);"," return texture2D(u_lut, vec2(x, y)).rgb;","}","#ifdef HF_STAGE_LUT","vec3 applyLut(vec3 color){"," if (u_lutEnabled < 0.5) return color;"," float size = max(u_lutSize, 2.0);"," vec3 span = max(u_lutDomainMax - u_lutDomainMin, vec3(0.00001));"," vec3 scaled = clamp((color - u_lutDomainMin) / span, 0.0, 1.0) * (size - 1.0);"," vec3 lo = floor(scaled);"," vec3 hi = min(lo + 1.0, vec3(size - 1.0));"," vec3 f = scaled - lo;"," vec3 c000 = sampleLut(lo.r, lo.g, lo.b);"," vec3 c100 = sampleLut(hi.r, lo.g, lo.b);"," vec3 c010 = sampleLut(lo.r, hi.g, lo.b);"," vec3 c110 = sampleLut(hi.r, hi.g, lo.b);"," vec3 c001 = sampleLut(lo.r, lo.g, hi.b);"," vec3 c101 = sampleLut(hi.r, lo.g, hi.b);"," vec3 c011 = sampleLut(lo.r, hi.g, hi.b);"," vec3 c111 = sampleLut(hi.r, hi.g, hi.b);"," vec3 c00 = mix(c000, c100, f.r);"," vec3 c10 = mix(c010, c110, f.r);"," vec3 c01 = mix(c001, c101, f.r);"," vec3 c11 = mix(c011, c111, f.r);"," vec3 c0 = mix(c00, c10, f.g);"," vec3 c1 = mix(c01, c11, f.g);"," vec3 lutColor = mix(c0, c1, f.b);"," return mix(color, lutColor, clamp(u_lutIntensity, 0.0, 1.0));","}","#else","vec3 applyLut(vec3 color){ return color; }","#endif","vec3 applyPrimaryGrade(vec3 color){"," color *= pow(2.0, u_exposure);"," float y = lumaOf(color);"," float shadowMask = 1.0 - smoothstep(0.0, 0.65, y);"," float highlightMask = smoothstep(0.35, 1.0, y);"," color += u_shadows * 0.35 * shadowMask;"," color += u_highlights * 0.35 * highlightMask;"," float blackPoint = clamp(u_blacks * 0.18, -0.18, 0.18);"," float whitePoint = clamp(1.0 - u_whites * 0.18, 0.82, 1.18);"," color = (color - blackPoint) / max(whitePoint - blackPoint, 0.2);"," color.r += u_temperature * 0.08 + u_tint * 0.04;"," color.b -= u_temperature * 0.08 - u_tint * 0.04;"," color.g -= u_tint * 0.08;"," color = (color - 0.5) * max(0.0, 1.0 + u_contrast) + 0.5;"," float satLuma = lumaOf(color);"," float currentSat = clamp(colorSaturation(color), 0.0, 1.0);"," float skinLike = smoothstep(0.02, 0.18, color.r - color.g) * smoothstep(0.0, 0.16, color.g - color.b) * smoothstep(0.18, 0.82, satLuma);"," float vibranceWeight = (1.0 - currentSat * 0.72) * mix(1.0, 0.55, skinLike);"," color = mix(vec3(satLuma), color, max(0.0, 1.0 + u_vibrance * vibranceWeight));"," color = mix(vec3(satLuma), color, max(0.0, 1.0 + u_saturation));"," return color;","}","vec3 applyColorGrade(vec3 color){"," color = applyPrimaryGrade(color);"," color = applyAdvancedGrade(color);"," return clamp(applyLut(clamp(color, 0.0, 1.0)), 0.0, 1.0);","}","#ifdef HF_STAGE_DITHER","vec3 applyDither(vec3 source, float amount){"," if (amount <= 0.0) return source;"," float scale = max(min(u_resolution.x, u_resolution.y) / 540.0, 0.25);"," float pixelSize = mix(1.0, 5.0, clamp(u_ditherSize, 0.0, 1.0)) * scale;"," vec2 block = floor(gl_FragCoord.xy / max(pixelSize, 1.0));"," float levels = clamp(u_paletteSize, 2.0, 6.0);"," float index = floor(clamp(lumaOf(source) * (levels - 1.0) + bayer4(block), 0.0, levels - 1.0));"," return mix(source, paletteColor(index), amount);","}","#else","vec3 applyDither(vec3 source, float amount){ return source; }","#endif","vec2 asciiEdgeDirection(vec2 uv, vec2 stepUv){"," float topLeft = bt601Luma(sampleMedia(uv + vec2(-stepUv.x, -stepUv.y)).rgb);"," float top = bt601Luma(sampleMedia(uv + vec2(0.0, -stepUv.y)).rgb);"," float topRight = bt601Luma(sampleMedia(uv + vec2(stepUv.x, -stepUv.y)).rgb);"," float left = bt601Luma(sampleMedia(uv + vec2(-stepUv.x, 0.0)).rgb);"," float right = bt601Luma(sampleMedia(uv + vec2(stepUv.x, 0.0)).rgb);"," float bottomLeft = bt601Luma(sampleMedia(uv + vec2(-stepUv.x, stepUv.y)).rgb);"," float bottom = bt601Luma(sampleMedia(uv + vec2(0.0, stepUv.y)).rgb);"," float bottomRight = bt601Luma(sampleMedia(uv + stepUv).rgb);"," float x = -topLeft - 2.0 * left - bottomLeft + topRight + 2.0 * right + bottomRight;"," float y = -topLeft - 2.0 * top - topRight + bottomLeft + 2.0 * bottom + bottomRight;"," return vec2(x, y);","}","vec2 rotateAsciiUv(vec2 uv, float angle){"," float cosine = cos(angle);"," float sine = sin(angle);"," vec2 centered = uv - 0.5;"," return vec2(centered.x * cosine - centered.y * sine, centered.x * sine + centered.y * cosine) + 0.5;","}","#ifdef HF_STAGE_ASCII","vec3 applyAscii(vec3 source, float amount){"," if (amount <= 0.0) return source;"," float scale = max(min(u_resolution.x, u_resolution.y) / 540.0, 0.25);"," float cellHeight = mix(4.0, 80.0, clamp(u_asciiSize, 0.0, 1.0)) * scale;"," vec2 cellSize = vec2(cellHeight);"," vec2 cell = floor(gl_FragCoord.xy / cellSize);"," vec2 cellVuv = (cell + 0.5) * cellSize / max(u_resolution, vec2(1.0));"," vec2 cellUv = (cellVuv - u_uvOffset) / u_uvScale;"," cellUv = applyCrtWarp(cellUv);"," vec3 cellColor = applyColorGrade(sampleMedia(cellUv).rgb);"," float brightness = bt601Luma(cellColor);"," float invert = step(0.5, u_asciiInvert);"," brightness = mix(brightness, 1.0 - brightness, invert);"," vec2 glyphUv = fract(gl_FragCoord.xy / cellSize);"," float rotation = clamp(u_asciiRotation, 0.0, 1.0);"," if (rotation > 0.0) {"," vec2 cellStepUv = cellSize / max(u_resolution * u_uvScale, vec2(1.0));"," vec2 edge = asciiEdgeDirection(cellUv, cellStepUv);"," if (length(edge) > 0.1) glyphUv = mix(glyphUv, rotateAsciiUv(glyphUv, atan(edge.y, edge.x)), rotation);"," }"," float ink = asciiStyleSample(floor(u_asciiStyle + 0.5), brightness, glyphUv);"," vec3 background = paletteColor(0.0);"," vec3 inkColor = mix(paletteColor(max(u_paletteSize - 1.0, 1.0)), cellColor, clamp(u_asciiColor, 0.0, 1.0));"," vec3 asciiColor = mix(background, inkColor, ink);"," return mix(source, asciiColor, amount);","}","#else","vec3 applyAscii(vec3 source, float amount){ return source; }","#endif","#ifdef HF_STAGE_SCANLINES","vec3 applyScanlines(vec3 source, float amount){"," if (amount <= 0.0) return source;"," float count = mix(50.0, 500.0, clamp(u_scanlineCount, 0.0, 1.0));"," float softness = clamp(u_scanlineSoftness, 0.0, 1.0);"," float wave = 0.5 + 0.5 * sin(v_uv.y * count * PI);"," float line = mix(1.0 - wave, pow(1.0 - wave, 2.2), softness);"," return source * (1.0 - line * amount);","}","#else","vec3 applyScanlines(vec3 source, float amount){ return source; }","#endif","void main(){"," vec2 uv = (v_uv - u_uvOffset) / u_uvScale;"," if (uv.x < 0.0 || uv.y < 0.0 || uv.x > 1.0 || uv.y > 1.0) {"," gl_FragColor = vec4(0.0);"," return;"," }"," vec4 originalSample = sampleSource(uv);"," uv = applyCrtWarp(uv);","#ifdef HF_STAGE_CRT"," vec2 displayEdge = smoothstep(vec2(0.0), vec2(0.006), uv) * (1.0 - smoothstep(vec2(0.994), vec2(1.0), uv));"," float displayMask = displayEdge.x * displayEdge.y;","#endif"," vec4 sampleColor = sampleMedia(uv);"," sampleColor = sampleChromaticMedia(uv, sampleColor);"," sampleColor.rgb = applyDigitalGlitch(uv, sampleColor.rgb);"," vec3 original = originalSample.rgb;"," vec3 color = mix(sampleColor.rgb, applyColorGrade(sampleColor.rgb), u_intensity);","#ifdef HF_STAGE_GRAIN"," float grainAmount = clamp(u_grain, 0.0, 1.0);"," if (grainAmount > 0.0) {"," float grainPixelSize = mix(1.0, 6.0, clamp(u_grainSize, 0.0, 1.0));"," vec2 grainCoord = floor(gl_FragCoord.xy / grainPixelSize) + vec2(u_grainSeed, u_grainSeed * 1.37);"," float grainBase = grainHash(grainCoord) - grainHash(grainCoord + vec2(19.19, 73.31));"," float grainFine = grainHash(gl_FragCoord.xy + vec2(u_grainSeed * 2.11, u_grainSeed * 0.71)) - 0.5;"," float grain = mix(grainBase * 0.7, grainBase + grainFine * 0.35, clamp(u_grainRoughness, 0.0, 1.0));"," float grainLuma = lumaOf(color);"," float grainMask = smoothstep(0.02, 0.55, grainLuma) * (1.0 - smoothstep(0.88, 1.0, grainLuma));"," color += grain * grainAmount * mix(0.025, 0.08, grainMask);"," }","#endif","#ifdef HF_STAGE_FILM_ARTIFACTS"," float filmArtifacts = clamp(u_filmArtifacts, 0.0, 1.0);"," if (filmArtifacts > 0.0) {"," float filmFrame = floor(u_grainSeed);"," float dust = dustMask(v_uv, floor(filmFrame / 3.0));"," float dustTone = grainHash(vec2(floor(filmFrame / 3.0), 8.0));"," color = mix(color, vec3(dustTone > 0.5 ? 0.95 : 0.02), dust * 0.72 * filmArtifacts);"," float scratchBucket = floor(filmFrame / 12.0);"," float scratchX = grainHash(vec2(scratchBucket, 4.2));"," float scratchLife = step(0.78, grainHash(vec2(scratchBucket, 8.4)));"," float scratch = (1.0 - smoothstep(0.0, 1.4 / max(u_resolution.x, 1.0), abs(v_uv.x - scratchX))) * scratchLife;"," color = mix(color, vec3(0.94, 0.88, 0.76), scratch * 0.28 * filmArtifacts);"," }","#endif"," color = applyMonoScreen(clamp(color, 0.0, 1.0), clamp(u_monoScreen, 0.0, 1.0));"," color = applyEngraving(clamp(color, 0.0, 1.0), clamp(u_engraving, 0.0, 1.0));"," color = applyCrosshatch(uv, clamp(color, 0.0, 1.0), clamp(u_crosshatch, 0.0, 1.0));"," color = applyHalftone(clamp(color, 0.0, 1.0), clamp(u_halftone, 0.0, 1.0));"," color = applyTwoInkPrint(clamp(color, 0.0, 1.0), clamp(u_twoInkPrint, 0.0, 1.0));"," color = applyDither(clamp(color, 0.0, 1.0), clamp(u_dither, 0.0, 1.0));"," color = applyAscii(clamp(color, 0.0, 1.0), clamp(u_ascii, 0.0, 1.0));","#ifdef HF_STAGE_BLOOM"," if (u_bloomReady > 0.5 && u_bloom > 0.0) color += sampleBloom(uv) * u_bloom;","#endif"," color = applyScanlines(clamp(color, 0.0, 1.0), clamp(u_scanlines, 0.0, 1.0));","#ifdef HF_STAGE_VIGNETTE"," vec2 vignetteAspect = u_resolution.x > u_resolution.y"," ? vec2(u_resolution.x / max(u_resolution.y, 1.0), 1.0)"," : vec2(1.0, u_resolution.y / max(u_resolution.x, 1.0));"," vec2 vignetteUv = abs((v_uv - vec2(0.5)) * 2.0) * vignetteAspect;"," float vignettePower = mix(8.0, 1.8, clamp(u_vignetteRoundness * 0.5 + 0.5, 0.0, 1.0));"," float vignetteDistance = pow(pow(vignetteUv.x, vignettePower) + pow(vignetteUv.y, vignettePower), 1.0 / vignettePower);"," float vignetteMidpoint = mix(0.22, 1.08, clamp(u_vignetteMidpoint, 0.0, 1.0));"," float vignetteFeather = mix(0.08, 0.72, clamp(u_vignetteFeather, 0.0, 1.0));"," float vignetteMask = smoothstep(vignetteMidpoint, vignetteMidpoint + vignetteFeather, vignetteDistance);"," color *= 1.0 - vignetteMask * clamp(u_vignette, 0.0, 1.0) * 0.75;","#endif","#ifdef HF_STAGE_CRT"," float warpActive = step(0.0001, u_crtCurvature);"," color *= mix(1.0, displayMask, warpActive);","#endif"," vec3 graded = clamp(color, 0.0, 1.0);","#ifdef HF_STAGE_COMPARE"," if (u_compareEnabled > 0.5) {"," float pos = clamp(u_comparePosition, 0.0, 1.0);"," float softness = max(u_compareSoftness, 0.00001);"," float afterMask = smoothstep(pos - softness, pos + softness, v_uv.x);"," vec3 splitColor = mix(original, graded, afterMask);"," float lineMask = 0.0;"," if (u_compareLineWidth > 0.0) {"," float lineWidth = max(u_compareLineWidth / max(u_resolution.x, 1.0), 0.00001);"," lineMask = 1.0 - smoothstep(lineWidth, lineWidth * 1.8, abs(v_uv.x - pos));"," }"," gl_FragColor = vec4(mix(splitColor, vec3(1.0), lineMask * 0.82), sampleColor.a);"," return;"," }","#endif"," gl_FragColor = vec4(graded, sampleColor.a);","}"].join(`
|
|
366
366
|
`),jE=[["HF_STAGE_BLUR",e=>e.effects.blur>0],["HF_STAGE_KUWAHARA",e=>e.effects.kuwahara>0],["HF_STAGE_PIXELATE",e=>e.effects.pixelate>0],["HF_STAGE_TAPE",e=>e.effects.tapeDamage>0],["HF_STAGE_CHROMA_BLEED",e=>e.effects.chromaBleed>0],["HF_STAGE_CHROMATIC",e=>e.effects.chromaticAberration>0],["HF_STAGE_CRT",e=>e.effects.crtCurvature>0],["HF_STAGE_GLITCH",e=>e.effects.digitalGlitch>0],["HF_STAGE_GRAIN",e=>e.details.grain>0],["HF_STAGE_FILM_ARTIFACTS",e=>e.effects.filmArtifacts>0],["HF_STAGE_MONO_SCREEN",e=>e.effects.monoScreen>0],["HF_STAGE_ENGRAVING",e=>e.effects.engraving>0],["HF_STAGE_CROSSHATCH",e=>e.effects.crosshatch>0],["HF_STAGE_HALFTONE",e=>e.effects.halftone>0],["HF_STAGE_TWO_INK_PRINT",e=>e.effects.twoInkPrint>0],["HF_STAGE_DITHER",e=>e.effects.dither>0],["HF_STAGE_ASCII",e=>e.effects.ascii>0],["HF_STAGE_BLOOM",e=>e.effects.bloom>0],["HF_STAGE_SCANLINES",e=>e.effects.scanlines>0],["HF_STAGE_VIGNETTE",e=>e.details.vignette>0],["HF_STAGE_RGB_CURVES",e=>Il(e).rgbCurvesEnabled],["HF_STAGE_HUE_CURVES",e=>Il(e).hueCurvesEnabled],["HF_STAGE_SECONDARIES",e=>Il(e).secondaryCount>0],["HF_STAGE_LUT",e=>e.lut!==null],["HF_STAGE_COMPARE",(e,t)=>t.enabled]];function cF(e,t){let n="";for(let[r,o]of jE)o(e,t)&&(n+=`#define ${r}
|
|
367
367
|
`);return n}var IE=jE.map(([e])=>`#define ${e}
|
package/dist/index.js
CHANGED
|
@@ -5609,6 +5609,8 @@ import {
|
|
|
5609
5609
|
readDeclaredDefaults,
|
|
5610
5610
|
parseHostVariableValues,
|
|
5611
5611
|
headStyleRuns,
|
|
5612
|
+
isAlwaysAppliedStyle,
|
|
5613
|
+
dedupeFontFaceRules,
|
|
5612
5614
|
inlineScriptRuns,
|
|
5613
5615
|
parsesAsScript,
|
|
5614
5616
|
styleElementsFor,
|
|
@@ -5901,12 +5903,12 @@ function resolveClipWindowSeconds(img, compositionDuration) {
|
|
|
5901
5903
|
}
|
|
5902
5904
|
return null;
|
|
5903
5905
|
}
|
|
5904
|
-
function resolvePreparedPlayback(metadata,
|
|
5906
|
+
function resolvePreparedPlayback(metadata, loopOverride, windowSeconds) {
|
|
5905
5907
|
const gifDuration = metadata.durationSeconds > 0 ? metadata.durationSeconds : null;
|
|
5906
5908
|
let loopIterations = 1;
|
|
5907
|
-
if (
|
|
5909
|
+
if (resolveLoop(metadata, loopOverride)) {
|
|
5908
5910
|
loopIterations = windowSeconds != null && gifDuration != null ? Math.min(MAX_LOOP_ITERATIONS, Math.max(1, Math.ceil(windowSeconds / gifDuration))) : 1;
|
|
5909
|
-
} else if (metadata.loopCount != null && metadata.loopCount > 1) {
|
|
5911
|
+
} else if (loopOverride == null && metadata.loopCount != null && metadata.loopCount > 1) {
|
|
5910
5912
|
loopIterations = Math.min(MAX_LOOP_ITERATIONS, metadata.loopCount);
|
|
5911
5913
|
}
|
|
5912
5914
|
let padSeconds = 0;
|
|
@@ -6073,9 +6075,14 @@ async function prepareAnimatedGifInputs(html, options) {
|
|
|
6073
6075
|
const bytes = readFileSync5(sourcePath);
|
|
6074
6076
|
const metadata = parseAnimatedGifMetadata(bytes);
|
|
6075
6077
|
if (!metadata?.animated) continue;
|
|
6076
|
-
const
|
|
6078
|
+
const loopOverride = readLoopOverride(img);
|
|
6079
|
+
const loop = resolveLoop(metadata, loopOverride);
|
|
6077
6080
|
const windowSeconds = resolveClipWindowSeconds(img, compositionDuration);
|
|
6078
|
-
const { loopIterations, padSeconds } = resolvePreparedPlayback(
|
|
6081
|
+
const { loopIterations, padSeconds } = resolvePreparedPlayback(
|
|
6082
|
+
metadata,
|
|
6083
|
+
loopOverride,
|
|
6084
|
+
windowSeconds
|
|
6085
|
+
);
|
|
6079
6086
|
const hash = computePreparedGifHash(bytes, loopIterations, padSeconds);
|
|
6080
6087
|
const filename = `${CACHE_SCHEMA}-${hash.slice(0, 24)}.webm`;
|
|
6081
6088
|
const cachePath = join13(cacheDir, filename);
|
|
@@ -6741,6 +6748,11 @@ function coalesceHeadStylesAndBodyScripts(html) {
|
|
|
6741
6748
|
const head = document2.querySelector("head");
|
|
6742
6749
|
const body = document2.querySelector("body");
|
|
6743
6750
|
if (!head && !body) return html;
|
|
6751
|
+
const liveStyles = [...document2.querySelectorAll("style")].filter(isAlwaysAppliedStyle);
|
|
6752
|
+
const dedupedStyles = dedupeFontFaceRules(liveStyles.map((el) => el.textContent || ""));
|
|
6753
|
+
liveStyles.forEach((el, i) => {
|
|
6754
|
+
el.textContent = dedupedStyles[i] ?? "";
|
|
6755
|
+
});
|
|
6744
6756
|
const styleEls = head ? Array.from(head.querySelectorAll("style")) : [];
|
|
6745
6757
|
const importRe = /@import\s+url\([^)]*\)\s*;|@import\s+["'][^"']+["']\s*;/gi;
|
|
6746
6758
|
for (const run of styleEls.length > 1 ? headStyleRuns(styleEls) : []) {
|
package/dist/public-server.js
CHANGED
|
@@ -5629,6 +5629,8 @@ import {
|
|
|
5629
5629
|
readDeclaredDefaults,
|
|
5630
5630
|
parseHostVariableValues,
|
|
5631
5631
|
headStyleRuns,
|
|
5632
|
+
isAlwaysAppliedStyle,
|
|
5633
|
+
dedupeFontFaceRules,
|
|
5632
5634
|
inlineScriptRuns,
|
|
5633
5635
|
parsesAsScript,
|
|
5634
5636
|
styleElementsFor,
|
|
@@ -5921,12 +5923,12 @@ function resolveClipWindowSeconds(img, compositionDuration) {
|
|
|
5921
5923
|
}
|
|
5922
5924
|
return null;
|
|
5923
5925
|
}
|
|
5924
|
-
function resolvePreparedPlayback(metadata,
|
|
5926
|
+
function resolvePreparedPlayback(metadata, loopOverride, windowSeconds) {
|
|
5925
5927
|
const gifDuration = metadata.durationSeconds > 0 ? metadata.durationSeconds : null;
|
|
5926
5928
|
let loopIterations = 1;
|
|
5927
|
-
if (
|
|
5929
|
+
if (resolveLoop(metadata, loopOverride)) {
|
|
5928
5930
|
loopIterations = windowSeconds != null && gifDuration != null ? Math.min(MAX_LOOP_ITERATIONS, Math.max(1, Math.ceil(windowSeconds / gifDuration))) : 1;
|
|
5929
|
-
} else if (metadata.loopCount != null && metadata.loopCount > 1) {
|
|
5931
|
+
} else if (loopOverride == null && metadata.loopCount != null && metadata.loopCount > 1) {
|
|
5930
5932
|
loopIterations = Math.min(MAX_LOOP_ITERATIONS, metadata.loopCount);
|
|
5931
5933
|
}
|
|
5932
5934
|
let padSeconds = 0;
|
|
@@ -6093,9 +6095,14 @@ async function prepareAnimatedGifInputs(html, options) {
|
|
|
6093
6095
|
const bytes = readFileSync5(sourcePath);
|
|
6094
6096
|
const metadata = parseAnimatedGifMetadata(bytes);
|
|
6095
6097
|
if (!metadata?.animated) continue;
|
|
6096
|
-
const
|
|
6098
|
+
const loopOverride = readLoopOverride(img);
|
|
6099
|
+
const loop = resolveLoop(metadata, loopOverride);
|
|
6097
6100
|
const windowSeconds = resolveClipWindowSeconds(img, compositionDuration);
|
|
6098
|
-
const { loopIterations, padSeconds } = resolvePreparedPlayback(
|
|
6101
|
+
const { loopIterations, padSeconds } = resolvePreparedPlayback(
|
|
6102
|
+
metadata,
|
|
6103
|
+
loopOverride,
|
|
6104
|
+
windowSeconds
|
|
6105
|
+
);
|
|
6099
6106
|
const hash = computePreparedGifHash(bytes, loopIterations, padSeconds);
|
|
6100
6107
|
const filename = `${CACHE_SCHEMA}-${hash.slice(0, 24)}.webm`;
|
|
6101
6108
|
const cachePath = join13(cacheDir, filename);
|
|
@@ -6761,6 +6768,11 @@ function coalesceHeadStylesAndBodyScripts(html) {
|
|
|
6761
6768
|
const head = document2.querySelector("head");
|
|
6762
6769
|
const body = document2.querySelector("body");
|
|
6763
6770
|
if (!head && !body) return html;
|
|
6771
|
+
const liveStyles = [...document2.querySelectorAll("style")].filter(isAlwaysAppliedStyle);
|
|
6772
|
+
const dedupedStyles = dedupeFontFaceRules(liveStyles.map((el) => el.textContent || ""));
|
|
6773
|
+
liveStyles.forEach((el, i) => {
|
|
6774
|
+
el.textContent = dedupedStyles[i] ?? "";
|
|
6775
|
+
});
|
|
6764
6776
|
const styleEls = head ? Array.from(head.querySelectorAll("style")) : [];
|
|
6765
6777
|
const importRe = /@import\s+url\([^)]*\)\s*;|@import\s+["'][^"']+["']\s*;/gi;
|
|
6766
6778
|
for (const run of styleEls.length > 1 ? headStyleRuns(styleEls) : []) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/producer",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.205",
|
|
4
4
|
"description": "HTML-to-video rendering engine using Chrome's BeginFrame API",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"postcss": "^8.4.0",
|
|
36
36
|
"puppeteer": "^25.2.1",
|
|
37
37
|
"puppeteer-core": "^25.2.1",
|
|
38
|
-
"@hyperframes/
|
|
39
|
-
"@hyperframes/
|
|
40
|
-
"@hyperframes/
|
|
41
|
-
"@hyperframes/parsers": "0.8.
|
|
42
|
-
"@hyperframes/studio-server": "0.8.
|
|
38
|
+
"@hyperframes/core": "0.8.205",
|
|
39
|
+
"@hyperframes/engine": "0.8.205",
|
|
40
|
+
"@hyperframes/lint": "0.8.205",
|
|
41
|
+
"@hyperframes/parsers": "0.8.205",
|
|
42
|
+
"@hyperframes/studio-server": "0.8.205"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/node": "^25.0.10",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"tsx": "^4.21.0",
|
|
49
49
|
"typescript": "^5.7.2",
|
|
50
50
|
"vitest": "^4.1.11",
|
|
51
|
-
"@hyperframes/aws-lambda": "0.8.
|
|
51
|
+
"@hyperframes/aws-lambda": "0.8.205"
|
|
52
52
|
},
|
|
53
53
|
"engines": {
|
|
54
54
|
"node": ">=22"
|