@omnimedia/omnitool 1.1.0-84 → 1.1.0-85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/s/demo/routines/timeline-setup.ts +1 -1
- package/s/timeline/parts/item.ts +2 -2
- package/s/timeline/renderers/parts/handy.ts +24 -5
- package/s/timeline/sugar/o.ts +1 -1
- package/x/demo/demo.bundle.min.js +4 -4
- package/x/demo/demo.bundle.min.js.map +3 -3
- package/x/demo/routines/timeline-setup.js +1 -1
- package/x/demo/routines/timeline-setup.js.map +1 -1
- package/x/index.html +2 -2
- package/x/tests.bundle.min.js +40 -40
- package/x/tests.bundle.min.js.map +3 -3
- package/x/tests.html +1 -1
- package/x/timeline/parts/item.d.ts +2 -2
- package/x/timeline/renderers/parts/handy.js +20 -5
- package/x/timeline/renderers/parts/handy.js.map +1 -1
- package/x/timeline/sugar/o.js +1 -1
- package/x/timeline/sugar/o.js.map +1 -1
package/x/tests.bundle.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"./chunk-ZLGNQFUI.js";import{c as ur,j as qa,k as Ha,l as Ki,n as Yi,u as mr}from"./chunk-73XOWA4F.js";import"./chunk-IAWJKNX5.js";import"./chunk-23FOBGX6.js";import"./chunk-KCMVLWBS.js";import{b as Wn,e as Qi}from"./chunk-VCUJJYRJ.js";import{Ca as _,F as ji,G as Xi,J as ae,K as J,P as $i,S as Ga,T as en,V as cr,a as rd,b as La,c as nd,d as qn,e as Va,fa as I,g as Q,h as Je,ha as A,i as Hi,j as Wi,k as Zr,m as Jr,o as N,qa as fr,sa as Hn}from"./chunk-XNIZ4L5W.js";var Xp=rd((
|
|
1
|
+
import"./chunk-ZLGNQFUI.js";import{c as ur,j as qa,k as Ha,l as Ki,n as Yi,u as mr}from"./chunk-73XOWA4F.js";import"./chunk-IAWJKNX5.js";import"./chunk-23FOBGX6.js";import"./chunk-KCMVLWBS.js";import{b as Wn,e as Qi}from"./chunk-VCUJJYRJ.js";import{Ca as _,F as ji,G as Xi,J as ae,K as J,P as $i,S as Ga,T as en,V as cr,a as rd,b as La,c as nd,d as qn,e as Va,fa as I,g as Q,h as Je,ha as A,i as Hi,j as Wi,k as Zr,m as Jr,o as N,qa as fr,sa as Hn}from"./chunk-XNIZ4L5W.js";var Xp=rd((HE,jp)=>{jp.exports=[{name:"Bounce",paramsTypes:{shadow_colour:"vec4",shadow_height:"float",bounces:"float"},defaultParams:{shadow_colour:[0,0,0,.6],shadow_height:.075,bounces:3},glsl:`// Author: Adrian Purser
|
|
2
2
|
// License: MIT
|
|
3
3
|
|
|
4
4
|
uniform vec4 shadow_colour; // = vec4(0.,0.,0.,.6)
|
|
@@ -2335,7 +2335,7 @@ vec4 transition(vec2 uv) {
|
|
|
2335
2335
|
`):Ne()?await Deno.stdout.write(new TextEncoder().encode(r+`
|
|
2336
2336
|
`)):console.log(r)}async function os(r){Le()?process.stderr.write(r+`
|
|
2337
2337
|
`):Ne()?await Deno.stderr.write(new TextEncoder().encode(r+`
|
|
2338
|
-
`)):console.error(r)}async function is(r){for(let e of r.outputs)e instanceof Dt?await os(e.line):await ns(e.line);rs(r.code)}function ss(r,e){let{verbose:t,theme:{icons:n,colors:o}}=e,i=[...r.experiments.values()].filter(S=>S.fail),s=[...r.experiments.values()].filter(S=>!S.fail),a=r.tubes.length,l=s.length,c=i.length,f=r.tubes.filter(S=>S.skip).length,u=r.tubes.filter(S=>S.only).length,m=[],p=S=>m.push(new an(S)),d=S=>m.push(new Dt(S)),g=0;function x(S,k){let C=S.only?o.only(` ${n.only} [ONLY]`):S.skip?o.skip(` ${n.skip} [SKIP]`):"";return k&&k.fail?o.errorLabel(n.testFail)+C:k?o.successLabel(n.testSuccess)+C:o.neutral(n.testNeutral)+C}function y(S,k){g+=1;let C=S.path,O=o.errorLabel(S.label),E=[...C.map(o.errorPath),O].join(o.errorGrammar(n.pathSeparator)),V=o.errorMessage(k.fail??"unknown fail"),q=o.errorTime(`${n.timeSeparator}${tn(k.time)}`),G=x(S,k);d(`${G} ${E}${o.errorGrammar(n.messageSeparator)}${V}${q}`)}function v(S,k){g+=1;let C=S.path,O=o.successLabel(S.label),E=[...C.map(o.successPath),O].join(o.successGrammar(n.pathSeparator)),V=o.successTime(`${n.timeSeparator}${tn(k.time)}`),q=x(S,k);p(`${q} ${E}${V}`)}function T(S){g+=1;let k=S.path,C=o.neutralLabel(S.label),O=[...k.map(o.neutral),C].join(o.neutral(n.pathSeparator)),E=x(S,void 0);p(`${E} ${O}`)}for(let S of r.tubes){let k=r.experiments.get(S);k?k.fail?y(S,k):t&&v(S,k):t&&T(S)}if(g>0&&p(""),u){let S=a-u;p(o.only(`${n.only} only ran ${u} test${jn(u)} (${S} ignored)`))}else f&&p(o.skip(`${n.skip} skipped ${f} test${jn(f)}`));if(c===0){let S=o.successSuite(n.suiteSuccess),k=o.successLabel(`${l} happy tests`),C=o.successTime(`- ${tn(r.time)}`);p(`${S} ${k} ${C}`)}else{let S=o.errorSuite(n.suiteFail),k=o.errorSuite(`${c} failure${jn(c)}`),C=o.errorDidnt(`(${l} succeeded)`),O=o.errorTime(`- ${tn(r.time)}`);d(`${S} ${k} ${C} ${O}`)}return{execution:r,outputs:m,code:c>0?1:0}}function fd(r){return r}var pr={plain:{colors:{skip:M.none,only:M.none,neutral:M.none,neutralLabel:M.none,successSuite:M.none,successPath:M.none,successGrammar:M.none,successLabel:M.none,successTime:M.none,errorSuite:M.none,errorDidnt:M.none,errorPath:M.none,errorLabel:M.none,errorGrammar:M.none,errorMessage:M.none,errorTime:M.none},icons:{skip:"\u23ED",only:"*",testFail:"\u2718 ",testSuccess:" \u2022",testNeutral:" \u2022",suiteFail:"FAIL!!",suiteSuccess:"good:",timeSeparator:" - ",pathSeparator:" > ",messageSeparator:" :: "}},redgreen:{colors:{skip:M.yellow,only:M.yellow,neutral:r=>M.dim(M.white(r)),neutralLabel:M.white,successSuite:M.brightGreen,successPath:M.green,successGrammar:r=>M.dim(M.green(r)),successLabel:r=>M.bold(M.brightGreen(r)),successTime:r=>M.dim(M.green(r)),errorSuite:M.brightRed,errorDidnt:M.red,errorPath:M.red,errorLabel:r=>M.bold(M.brightRed(r)),errorGrammar:r=>M.dim(M.red(r)),errorMessage:M.red,errorTime:r=>M.dim(M.red(r))},icons:{skip:"\u{1F47B}",only:"\u{1F6A7}",testFail:"\u274C",testSuccess:" \u2022",testNeutral:" \u2022",suiteFail:"\u{1F525}",suiteSuccess:"\u2705",timeSeparator:" - ",pathSeparator:" > ",messageSeparator:" :: "}},seaside:{colors:{skip:M.yellow,only:M.yellow,neutral:r=>M.dim(M.white(r)),neutralLabel:M.white,successSuite:M.brightBlue,successPath:M.blue,successGrammar:r=>M.dim(M.blue(r)),successLabel:r=>M.bold(M.brightBlue(r)),successTime:r=>M.dim(M.blue(r)),errorSuite:M.brightRed,errorDidnt:M.red,errorPath:M.red,errorLabel:r=>M.bold(M.brightRed(r)),errorGrammar:r=>M.dim(M.red(r)),errorMessage:M.red,errorTime:r=>M.dim(M.red(r))},icons:{skip:"\u{1F47B}",only:"\u{1F6A7}",testFail:"\u274C",testSuccess:" \u2022",testNeutral:" \u2022",suiteFail:"\u{1F525}",suiteSuccess:"\u2705",timeSeparator:" - ",pathSeparator:" > ",messageSeparator:" :: "}}};function md(r){let e=[];function t(...n){let o=r(...n);return o!=null&&typeof o.then=="function"?o.then(i=>(e.push({args:n,ret:i}),i)):(e.push({args:n,ret:o}),o)}return t.spy={calls:e,get args(){return e.map(n=>n.args)},get rets(){return e.map(n=>n.ret)}},t}var Qa=r=>({verbose:r.verbose??(Kn("--verbose")||Yn("--verbose")==="1"||Kn("-v")||Qn("SCIENCE_VERBOSE")==="1"),theme:r.theme??(()=>{let e=Yn("--theme")||Qn("SCIENCE_THEME");if(e){let t=pr[e];if(!t)throw new Error(`theme not found "${e}"`);return t}return pr.redgreen})()});var Za=r=>({...r,colors:ts()?r.colors:pr.plain.colors});async function pd(r,e={}){let{verbose:t,theme:n}=Qa(e),o=Za(n),i=await es(r),s=ss(i,{verbose:t,theme:o});await is(s)}function ln(r){return r}ln.only=r=>(r[be]={kind:"only"},r);ln.skip=r=>(r[be]={kind:"skip"},r);function as(r){return r}as.only=r=>(r[be]={kind:"only"},r);as.skip=r=>(r[be]={kind:"skip"},r);var dr=Object.freeze({eq(r,e){if(r.length!==e.length)return!1;for(let t=0;t<=r.length;t++)if(r.at(t)!==e.at(t))return!1;return!0},random(r){return crypto.getRandomValues(new Uint8Array(r))}});var he=class{lexicon;static lexicons=Object.freeze({base2:{characters:"01"},hex:{characters:"0123456789abcdef"},base36:{characters:"0123456789abcdefghijklmnopqrstuvwxyz"},base58:{characters:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"},base62:{characters:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"},base64url:{negativePrefix:"~",characters:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"},base64:{characters:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",padding:{character:"=",size:4}}});lookup;negativePrefix;constructor(e){this.lexicon=e,this.lookup=Object.fromEntries([...e.characters].map((t,n)=>[t,n])),this.negativePrefix=e.negativePrefix??"-"}toBytes(e){let t=Math.log2(this.lexicon.characters.length);if(Number.isInteger(t)){let a=0,l=0,c=[];for(let f of e){if(f===this.lexicon.padding?.character)continue;let u=this.lookup[f];if(u===void 0)throw new Error(`Invalid character: ${f}`);for(a=a<<t|u,l+=t;l>=8;)l-=8,c.push(a>>l&255)}return new Uint8Array(c)}let n=0n,o=BigInt(this.lexicon.characters.length),i=!1;e.startsWith(this.negativePrefix)&&(e=e.slice(this.negativePrefix.length),i=!0);for(let a of e){let l=this.lookup[a];if(l===void 0)throw new Error(`Invalid character: ${a}`);n=n*o+BigInt(l)}let s=[];for(;n>0n;)s.unshift(Number(n%256n)),n=n/256n;return new Uint8Array(s)}fromBytes(e){let t=Math.log2(this.lexicon.characters.length);if(Number.isInteger(t)){let s=0,a=0,l="";for(let c of e)for(s=s<<8|c,a+=8;a>=t;){a-=t;let f=s>>a&(1<<t)-1;l+=this.lexicon.characters[f]}if(a>0){let c=s<<t-a&(1<<t)-1;l+=this.lexicon.characters[c]}if(this.lexicon.padding)for(;l.length%this.lexicon.padding.size!==0;)l+=this.lexicon.padding.character;return l}let n=0n;for(let s of e)n=(n<<8n)+BigInt(s);if(n===0n)return this.lexicon.characters[0];let o=BigInt(this.lexicon.characters.length),i="";for(;n>0n;)i=this.lexicon.characters[Number(n%o)]+i,n=n/o;return i}toInteger(e){if(!e)return 0;let t=0n,n=!1,o=BigInt(this.lexicon.characters.length);e.startsWith(this.negativePrefix)&&(e=e.slice(this.negativePrefix.length),n=!0);for(let i of e){let s=this.lookup[i];if(s===void 0)throw new Error(`Invalid character: ${i}`);t=t*o+BigInt(s)}return Number(n?-t:t)}fromInteger(e){e=Math.floor(e);let t=e<0,n=BigInt(t?-e:e);if(n===0n)return this.lexicon.characters[0];let o=BigInt(this.lexicon.characters.length),i="";for(;n>0n;)i=this.lexicon.characters[Number(n%o)]+i,n=n/o;return t?`${this.negativePrefix}${i}`:i}random(e=32){return this.fromBytes(dr.random(e))}};var Ve=new he(he.lexicons.hex),Jg=new he(he.lexicons.base2),ex=new he(he.lexicons.base36),ls=new he(he.lexicons.base58),tx=new he(he.lexicons.base62),rx=new he(he.lexicons.base64),nx=new he(he.lexicons.base64url);var cs=["doz","mar","bin","wan","sam","lit","sig","hid","fid","lis","sog","dir","wac","sab","wis","sib","rig","sol","dop","mod","fog","lid","hop","dar","dor","lor","hod","fol","rin","tog","sil","mir","hol","pas","lac","rov","liv","dal","sat","lib","tab","han","tic","pid","tor","bol","fos","dot","los","dil","for","pil","ram","tir","win","tad","bic","dif","roc","wid","bis","das","mid","lop","ril","nar","dap","mol","san","loc","nov","sit","nid","tip","sic","rop","wit","nat","pan","min","rit","pod","mot","tam","tol","sav","pos","nap","nop","som","fin","fon","ban","mor","wor","sip","ron","nor","bot","wic","soc","wat","dol","mag","pic","dav","bid","bal","tim","tas","mal","lig","siv","tag","pad","sal","div","dac","tan","sid","fab","tar","mon","ran","nis","wol","mis","pal","las","dis","map","rab","tob","rol","lat","lon","nod","nav","fig","nom","nib","pag","sop","ral","bil","had","doc","rid","moc","pac","rav","rip","fal","tod","til","tin","hap","mic","fan","pat","tac","lab","mog","sim","son","pin","lom","ric","tap","fir","has","bos","bat","poc","hac","tid","hav","sap","lin","dib","hos","dab","bit","bar","rac","par","lod","dos","bor","toc","hil","mac","tom","dig","fil","fas","mit","hob","har","mig","hin","rad","mas","hal","rag","lag","fad","top","mop","hab","nil","nos","mil","fop","fam","dat","nol","din","hat","nac","ris","fot","rib","hoc","nim","lar","fit","wal","rap","sar","nal","mos","lan","don","dan","lad","dov","riv","bac","pol","lap","tal","pit","nam","bon","ros","ton","fod","pon","sov","noc","sor","lav","mat","mip","fip"];var us=["zod","nec","bud","wes","sev","per","sut","let","ful","pen","syt","dur","wep","ser","wyl","sun","ryp","syx","dyr","nup","heb","peg","lup","dep","dys","put","lug","hec","ryt","tyv","syd","nex","lun","mep","lut","sep","pes","del","sul","ped","tem","led","tul","met","wen","byn","hex","feb","pyl","dul","het","mev","rut","tyl","wyd","tep","bes","dex","sef","wyc","bur","der","nep","pur","rys","reb","den","nut","sub","pet","rul","syn","reg","tyd","sup","sem","wyn","rec","meg","net","sec","mul","nym","tev","web","sum","mut","nyx","rex","teb","fus","hep","ben","mus","wyx","sym","sel","ruc","dec","wex","syr","wet","dyl","myn","mes","det","bet","bel","tux","tug","myr","pel","syp","ter","meb","set","dut","deg","tex","sur","fel","tud","nux","rux","ren","wyt","nub","med","lyt","dus","neb","rum","tyn","seg","lyx","pun","res","red","fun","rev","ref","mec","ted","rus","bex","leb","dux","ryn","num","pyx","ryg","ryx","fep","tyr","tus","tyc","leg","nem","fer","mer","ten","lus","nus","syl","tec","mex","pub","rym","tuc","fyl","lep","deb","ber","mug","hut","tun","byl","sud","pem","dev","lur","def","bus","bep","run","mel","pex","dyt","byt","typ","lev","myl","wed","duc","fur","fex","nul","luc","len","ner","lex","rup","ned","lec","ryd","lyd","fen","wel","nyd","hus","rel","rud","nes","hes","fet","des","ret","dun","ler","nyr","seb","hul","ryl","lud","rem","lys","fyn","wer","ryc","sug","nys","nyl","lyn","dyn","dem","lux","fed","sed","bec","mun","lyr","tes","mud","nyt","byr","sen","weg","fyr","mur","tel","rep","teg","pec","nel","nev","fes"];var et={defaults:{groupSize:4,wordSeparator:".",groupSeparator:" "},random(r,e){let t=dr.random(r);return this.fromBytes(t,e)},fromBytes(r,e={}){let{groupSize:t=et.defaults.groupSize,wordSeparator:n=et.defaults.wordSeparator,groupSeparator:o=et.defaults.groupSeparator}=e,i=[],s=[];r.forEach((l,c)=>{let f=c%2===0?cs:us;s.push(f[l]),s.length===2&&(i.push(s.join("")),s=[])}),s.length&&i.push(s.join(""));let a=[];for(let l=0;l<i.length;l+=t)a.push(i.slice(l,l+t).join(n));return a.join(o)},toBytes(r){let e=r.toLowerCase().replace(/[^a-z]/g,"");if(e.length/3%1!==0)throw new Error(`invalid triplet count, ${e.length} does not divide into triplets`);let n=[];for(let o=0;o<e.length;o+=3)n.push(e.slice(o,o+3));return new Uint8Array(n.map((o,i)=>{let a=(i%2===0?cs:us).findIndex(l=>l===o);if(a===-1)throw new Error(`unknown triplet ${o}`);return a}))},toHex(r){return Ve.fromBytes(et.toBytes(r))},fromHex(r,e){return et.fromBytes(Ve.toBytes(r),e)}};var Ge={defaults:{delimiter:".",sigilBytes:4,previewBytes:8},toBytes(r){r=r.trim();let e=r.split(/[^a-zA-Z0-9]+/m).filter(Boolean).map(o=>o.trim());if(e.length<2)return et.toBytes(e.join(""));let t=e.pop(),n=e.join("");return new Uint8Array([...et.toBytes(n),...ls.toBytes(t)])},parse(r,e){let t=Ge.toBytes(r);return Ge.build.fromBytes(t,e)},build:{fromBytes(r,e={}){let{delimiter:t,previewBytes:n,sigilBytes:o}={...Ge.defaults,...e},i=f=>r.length>0?et.fromBytes(r.slice(0,f),{wordSeparator:t,groupSeparator:t}):"",s=i(o),a=i(n),l=r.length>n?ls.fromBytes(r.slice(n)):"",c=[a,l].filter(f=>f.length>0).join(t);return{raw:r,full:c,preview:a,bulk:l,sigil:s,bytes:r,thumbprint:c}},fromHex(r,e){let t=Ve.toBytes(r);return Ge.build.fromBytes(t,e)}},toHex(r){let e=Ge.toBytes(r);return Ve.fromBytes(e)},fromBytes(r,e){return Ge.build.fromBytes(r,e).full},fromHex(r,e){return Ge.fromBytes(Ve.toBytes(r),e)},sigil:{fromHex(r,e){return Ge.build.fromHex(r,e).sigil},fromBytes(r,e){return Ge.build.fromBytes(r,e).sigil}}},Ja=Ge;var Zn=Object.freeze({fromBytes(r){return[...r].map(e=>e.toString(16).padStart(2,"0")).join("")},toBytes(r){if(r.length%2!==0)throw new Error("must have even number of hex characters");let e=new Uint8Array(r.length/2);for(let t=0;t<r.length;t+=2)e[t/2]=parseInt(r.slice(t,t+2),16);return e},random(r=32){return this.fromBytes(dr.random(r))},string(r){return Zn.fromBytes(r)},bytes(r){return Zn.toBytes(r)}});function qe(){let r,e,t=new Promise((o,i)=>{r=o,e=i});function n(o){return o.then(r).catch(e),t}return{promise:t,resolve:r,reject:e,entangle:n}}var Jn=Object.freeze({happy:r=>r!=null,sad:r=>r==null,boolean:r=>typeof r=="boolean",number:r=>typeof r=="number",string:r=>typeof r=="string",bigint:r=>typeof r=="bigint",object:r=>typeof r=="object"&&r!==null,array:r=>Array.isArray(r),fn:r=>typeof r=="function",symbol:r=>typeof r=="symbol"});var eo=class r extends Map{static require(e,t){if(e.has(t))return e.get(t);throw new Error(`required key not found: "${t}"`)}static guarantee(e,t,n){if(e.has(t))return e.get(t);{let o=n();return e.set(t,o),o}}array(){return[...this]}require(e){return r.require(this,e)}guarantee(e,t){return r.guarantee(this,e,t)}};var cn=class extends Error{milliseconds;name=this.constructor.name;constructor(e){super(`deadline exceeded (${(e/1e3).toFixed(1)} seconds)`),this.milliseconds=e}};function el(r,e){return r<=0||r===1/0?e():new Promise((t,n)=>{let o=setTimeout(()=>n(new cn(r)),r);e().then(t).catch(n).finally(()=>clearTimeout(o))})}function to(){let r=[];function e(){for(let t of r)t();r=[]}return e.schedule=(...t)=>(r.push(...t),e),e}function tl(r,e){let t=r;for(let n of e)if(t=t[n],Jn.sad(t))break;return t}function dd(){let r=new Set;async function e(...l){await Promise.all([...r].map(c=>c(...l)))}function t(l){return r.add(l),()=>{r.delete(l)}}async function n(...l){return e(...l)}function o(l){return t(l)}async function i(l){let{promise:c,resolve:f}=qe(),u=o(async(...m)=>{l&&await l(...m),f(m),u()});return c}function s(){r.clear()}let a={pub:n,sub:o,publish:e,subscribe:t,on:t,next:i,clear:s};return Object.assign(o,a),Object.assign(n,a),a}function Ee(r){let e=dd();return r&&e.sub(r),e.pub}var b=(r,e,t,n)=>({type:"number",min:r,max:e,default:t,...n===void 0?{}:{step:n}}),tt=r=>({type:"color",default:r}),He=r=>({type:"boolean",default:r}),ro=(r,e)=>({type:"choice",options:r,default:e}),oe=r=>({type:"object",properties:r}),hd=r=>({type:"array",items:r}),rl=[3,5,7,9,11,13,15,17,19,21,23,25],gd={TRANSPARENT:0,ORIGINAL:1,LOOP:2,CLAMP:3,MIRROR:4},W=()=>(r,e={})=>({type:r,schema:e}),nl={adjustment:W()("AdjustmentFilter",{gamma:b(0,5,1),saturation:b(0,5,1),contrast:b(0,5,1),brightness:b(0,5,1),red:b(0,5,1),green:b(0,5,1),blue:b(0,5,1),alpha:b(0,1,1,.01)}),advancedBloom:W()("AdvancedBloomFilter",{threshold:b(.1,.9,.5,.01),bloomScale:b(.5,1.5,1,.01),brightness:b(.5,1.5,1,.01),blur:b(0,20,8,.1),quality:b(1,20,4,1)}),alpha:W()("AlphaFilter",{alpha:b(0,1,1,.01)}),ascii:W()("AsciiFilter",{size:b(2,20,8,1),color:tt("#ffffff"),replaceColor:He(!1)}),backdropBlur:W()("BackdropBlurFilter",{strength:b(0,100,8,.1),quality:b(1,10,4,1)}),bevel:W()("BevelFilter",{rotation:b(0,360,45,1),thickness:b(0,10,2,.1),lightColor:tt("#ffffff"),lightAlpha:b(0,1,.7,.01),shadowColor:tt("#000000"),shadowAlpha:b(0,1,.7,.01)}),bloom:W()("BloomFilter",{strength:oe({x:b(0,20,2,.1),y:b(0,20,2,.1)}),quality:b(1,20,4,1),resolution:b(.25,4,1,.01),kernelSize:ro([5,7,9,11,13,15],5)}),blur:W()("BlurFilter",{strength:b(0,100,8,.1),quality:b(1,10,4,1)}),bulgePinch:W()("BulgePinchFilter",{radius:b(0,1e3,100,1),strength:b(-1,1,1,.01),center:oe({x:b(0,1,.5,.01),y:b(0,1,.5,.01)})}),colorGradient:W()("ColorGradientFilter"),colorMatrix:W()("ColorMatrixFilter"),colorOverlay:W()("ColorOverlayFilter",{color:tt("#ff0000"),alpha:b(0,1,.5,.01)}),colorReplace:W()("ColorReplaceFilter",{originalColor:tt("#ff0000"),targetColor:tt("#000000"),tolerance:b(0,1,.4,.01)}),convolution:W()("ConvolutionFilter",{width:b(0,500,300,1),height:b(0,500,300,1),matrix:hd([b(0,1,0),b(0,1,.5,.01),b(0,1,0),b(0,1,.5,.01),b(0,1,1,.01),b(0,1,.5,.01),b(0,1,0),b(0,1,.5,.01),b(0,1,0)])}),crossHatch:W()("CrossHatchFilter"),crt:W()("CRTFilter",{curvature:b(0,10,1,.01),lineWidth:b(0,5,3,.01),lineContrast:b(0,1,.3,.01),verticalLine:He(!1),noise:b(0,1,.2,.01),noiseSize:b(1,10,1,.1),vignetting:b(0,1,.3,.01),vignettingAlpha:b(0,1,1,.01),vignettingBlur:b(0,1,.3,.01),seed:b(0,1,0,.01),time:b(.5,20,.5,.01)}),dot:W()("DotFilter",{scale:b(.3,1,1,.01),angle:b(0,5,5,.01),grayscale:He(!0)}),dropShadow:W()("DropShadowFilter",{blur:b(0,20,2,.1),quality:b(1,20,3,1),alpha:b(0,1,.5,.01),offset:oe({x:b(-50,50,4,1),y:b(-50,50,4,1)}),color:tt("#000000"),shadowOnly:He(!1)}),emboss:W()("EmbossFilter",{strength:b(0,20,5,.1)}),glitch:W()("GlitchFilter",{slices:b(0,64,5,1),seed:b(0,1,.5,.01),offset:b(-400,400,100,1),direction:b(-180,180,0,1),fillMode:ro(gd,"LOOP"),average:He(!1),minSize:b(0,64,8,1),sampleSize:b(1,2048,512,1),red:oe({x:b(-50,50,2,1),y:b(-50,50,2,1)}),blue:oe({x:b(-50,50,10,1),y:b(-50,50,-4,1)}),green:oe({x:b(-50,50,-10,1),y:b(-50,50,4,1)})}),glow:W()("GlowFilter",{distance:b(0,20,15,.1),innerStrength:b(0,20,0,.1),outerStrength:b(0,20,2,.1),color:tt("#ffffff"),quality:b(0,1,.2,.01),alpha:b(0,1,1,.01),knockout:He(!1)}),godray:W()("GodrayFilter",{time:b(0,1,0,.01),gain:b(0,1,.6,.01),lacunarity:b(0,5,2.75,.01),alpha:b(0,1,1,.01),parallel:He(!0),angle:b(-60,60,30,1),center:oe({x:b(-100,2012,956,1),y:b(-1e3,-100,-100,1)})}),grayscale:W()("GrayscaleFilter"),hslAdjustment:W()("HslAdjustmentFilter",{hue:b(-180,180,0,1),saturation:b(-1,1,0,.01),lightness:b(-1,1,0,.01),colorize:He(!1),alpha:b(0,1,1,.01)}),kawaseBlur:W()("KawaseBlurFilter",{strength:b(0,20,4,.1),quality:b(1,20,3,1),pixelSize:oe({x:b(0,10,1,.1),y:b(0,10,1,.1)})}),motionBlur:W()("MotionBlurFilter",{velocity:oe({x:b(-90,90,40,1),y:b(-90,90,40,1)}),kernelSize:ro(rl,15),offset:b(-150,150,0,1)}),multiColorReplace:W()("MultiColorReplaceFilter"),noise:W()("NoiseFilter",{noise:b(0,1,.5,.01),seed:b(.01,10,.5,.01)}),oldFilm:W()("OldFilmFilter",{sepia:b(0,1,.3,.01),noise:b(0,1,.3,.01),noiseSize:b(1,10,1,.1),scratch:b(-1,1,.5,.01),scratchDensity:b(0,1,.3,.01),scratchWidth:b(1,20,1,.1),vignetting:b(0,1,.3,.01),vignettingAlpha:b(0,1,1,.01),vignettingBlur:b(0,1,.3,.01)}),outline:W()("OutlineFilter",{thickness:b(0,10,4,.1),color:tt("#000000"),alpha:b(0,1,1,.01),knockout:He(!1)}),pixelate:W()("PixelateFilter",{size:oe({x:b(4,40,10,1),y:b(4,40,10,1)})}),radialBlur:W()("RadialBlurFilter",{angle:b(-180,180,20,1),radius:b(-1,1912,300,1),center:oe({x:b(0,1912,956,1),y:b(0,920,460,1)}),kernelSize:ro(rl,15)}),reflection:W()("ReflectionFilter",{mirror:He(!0),boundary:b(0,1,.5,.01),amplitude:oe({start:b(0,50,0,.1),end:b(0,50,20,.1)}),waveLength:oe({start:b(10,200,30,1),end:b(10,200,100,1)}),alpha:oe({start:b(0,1,1,.01),end:b(0,1,1,.01)}),time:b(0,20,0,.01)}),rgbSplit:W()("RGBSplitFilter",{red:oe({x:b(-20,20,-10,1),y:b(-20,20,0,1)}),blue:oe({x:b(-20,20,0,1),y:b(-20,20,0,1)}),green:oe({x:b(-20,20,0,1),y:b(-20,20,10,1)})}),shockwave:W()("ShockwaveFilter",{speed:b(500,2e3,500,1),amplitude:b(1,100,30,1),wavelength:b(2,400,160,1),brightness:b(.2,2,1,.01),radius:b(100,2e3,-1,1),center:oe({x:b(0,1912,956,1),y:b(0,920,460,1)})}),simplexNoise:W()("SimplexNoiseFilter",{strength:b(0,1,.5,.01),noiseScale:b(0,50,10,.1),offsetX:b(0,5,0,.01),offsetY:b(0,5,0,.01),offsetZ:b(0,5,0,.01),step:b(-1,1,-1,.01)}),tiltShift:W()("TiltShiftFilter",{blur:b(0,200,100,.1),gradientBlur:b(0,1e3,600,1),start:oe({x:b(0,1912,0,1),y:b(0,920,460,1)}),end:oe({x:b(0,1912,1912,1),y:b(0,920,460,1)})}),twist:W()("TwistFilter",{angle:b(-10,10,4,.01),radius:b(0,1912,200,1),offset:oe({x:b(0,1912,956,1),y:b(0,920,460,1)})}),zoomBlur:W()("ZoomBlurFilter",{strength:b(.01,.5,.1,.01),center:oe({x:b(0,1912,956,1),y:b(0,920,460,1)}),innerRadius:b(0,956,80,1),radius:b(0,956,-1,1)})};var fs={slideIn:{type:"motion",label:"Slide in",defaults:{duration:700,from:[-400,0],to:[0,0],terp:"easeOut"},transform:{from:{position:[-400,0]},to:{position:[0,0]}}},slideOut:{type:"motion",label:"Slide out",defaults:{duration:700,from:[0,0],to:[400,0],terp:"easeIn"},transform:{from:{position:[0,0]},to:{position:[400,0]}}},spinIn:{type:"motion",label:"Spin in",defaults:{duration:700,from:[0,0],to:[0,0],terp:"easeOut"},transform:{from:{scale:[0,0],rotation:-Math.PI},to:{scale:[1,1],rotation:0}}},spinOut:{type:"motion",label:"Spin out",defaults:{duration:700,from:[0,0],to:[0,0],terp:"easeIn"},transform:{from:{scale:[1,1],rotation:0},to:{scale:[0,0],rotation:Math.PI}}},zoomIn:{type:"motion",label:"Zoom in",defaults:{duration:700,from:[0,0],to:[0,0],terp:"easeOut"},transform:{from:{scale:[0,0]},to:{scale:[1,1]}}},zoomOut:{type:"motion",label:"Zoom out",defaults:{duration:700,from:[0,0],to:[0,0],terp:"easeIn"},transform:{from:{scale:[1,1]},to:{scale:[0,0]}}},bounceIn:{type:"motion",label:"Bounce in",defaults:{duration:700,from:[0,0],to:[0,0],terp:"bounce"},transform:{from:{scale:[0,0]},to:{scale:[1,1]}}},bounceOut:{type:"motion",label:"Bounce out",defaults:{duration:700,from:[0,0],to:[0,0],terp:"bounce"},transform:{from:{scale:[1,1]},to:{scale:[0,0]}}},fadeIn:{type:"scalar",label:"Fade in",defaults:{duration:700,from:0,to:1,terp:"easeIn"}},fadeOut:{type:"scalar",label:"Fade out",defaults:{duration:700,from:1,to:0,terp:"easeOut"}}};var xd={transform:{type:"transform",defaultTerp:"linear",channels:[{path:"position.x",type:"number",default:0,unit:"pixel"},{path:"position.y",type:"number",default:0,unit:"pixel"},{path:"scale.x",type:"number",default:1,unit:"scale"},{path:"scale.y",type:"number",default:1,unit:"scale"},{path:"rotation",type:"number",default:0,unit:"radian"}]}},ms={opacity:{type:"scalar",defaultTerp:"linear",channels:[{type:"number",default:1,unit:"ratio",range:[0,1]}]}},vd={...xd,...ms};function ol(r,e,t){let n=Object.entries(fs).map(([o,i])=>{let s=i.type==="motion"?a=>{let l=a?.offset??0;return e(a?.terp??i.defaults.terp,[[l,t({...i.transform.from,...a?.from===void 0?{}:{position:a.from}})],[l+(a?.duration??i.defaults.duration),t({...i.transform.to,...a?.to===void 0?{}:{position:a.to}})]])}:a=>{let l=a?.offset??0;return r(a?.terp??i.defaults.terp,[[l,a?.from??i.defaults.from],[l+(a?.duration??i.defaults.duration),a?.to??i.defaults.to]])};return[o,s]});return Object.fromEntries(n)}var H;(function(r){r[r.Sequence=0]="Sequence",r[r.Stack=1]="Stack",r[r.Video=2]="Video",r[r.Audio=3]="Audio",r[r.Text=4]="Text",r[r.Gap=5]="Gap",r[r.Spatial=6]="Spatial",r[r.AnimatedSpatial=7]="AnimatedSpatial",r[r.Animation=8]="Animation",r[r.Transition=9]="Transition",r[r.TextStyle=10]="TextStyle",r[r.Filter=11]="Filter"})(H||(H={}));var no;(function(r){r[r.Crossfade=0]="Crossfade"})(no||(no={}));var re=class{state;constructor(e){this.state=e}require(e){return e===void 0?void 0:this.state.timeline.items.find(n=>n.id===e)}get timeline(){return this.state.timeline}getId(){return Ve.toInteger(Ve.random())}#e(e){this.state.timeline=e(this.state.timeline)}register(e){this.#e(t=>({...t,items:[...t.items,e]}))}textStyle=e=>{let t={id:this.getId(),kind:H.TextStyle,style:e};return this.register(t),t};spatial=(e,t)=>{let n={id:this.getId(),kind:H.Spatial,transform:e??this.transform(),crop:t,enabled:!0};return this.register(n),n};animatedSpatial=(e,t)=>{let n={id:this.getId(),kind:H.AnimatedSpatial,anim:e,crop:t,enabled:!0};return this.register(n),n};#t=e=>{let t={id:this.getId(),kind:H.Animation,anims:e,enabled:!0};return this.register(t),t};#r=(e,t)=>{let n={position:{x:[],y:[]},scale:{x:[],y:[]},rotation:[]};for(let[o,[i,s,a]]of t)n.position.x.push([o,i[0]]),n.position.y.push([o,i[1]]),n.scale.x.push([o,s[0]]),n.scale.y.push([o,s[1]]),n.rotation.push([o,a]);return{terp:e,track:n}};anim={scalar:(e,t)=>({terp:e,track:t}),vec2:(e,t)=>{let n={x:[],y:[]};for(let[o,[i,s]]of t)n.x.push([o,i]),n.y.push([o,s]);return{terp:e,track:n}},transform:this.#r,presets:ol((e,t)=>({terp:e,track:t}),this.#r,e=>this.transform(e))};#n=e=>{let t=o=>{let i={id:this.getId(),kind:H.Filter,type:e,params:o,enabled:!0};return this.register(i),i},n=((o,i)=>{let s=t(i),a={...o,filterIds:[...o.filterIds??[],s.id]};return this.set(o.id,a),a});return n.make=t,n};#o=()=>{let e=Object.entries(nl).map(([t,n])=>[t,this.#n(n.type)]);return Object.fromEntries(e)};filter=this.#o();#i=e=>{let t=(o,i)=>this.#t({[e]:this.anim.scalar(o,i)}),n=((o,i,s)=>{let a=t(i,s),l={...o,animationId:a.id};return this.set(o.id,l),l});return n.make=t,n};#s=()=>{let e=Object.keys(ms).map(t=>[t,this.#i(t)]);return Object.fromEntries(e)};animate=this.#s();sequence=(...e)=>{let t={id:this.getId(),kind:H.Sequence,childrenIds:e.map(n=>n.id)};return this.register(t),t};stack=(...e)=>{let t={kind:H.Stack,id:this.getId(),childrenIds:e.map(n=>n.id)};return this.register(t),t};video=(e,t)=>{if(!e.hasVideo)throw new Error(`Video clip error: media "${e.datafile.filename}" has no video track.`);let n={kind:H.Video,id:this.getId(),mediaHash:e.datafile.checksum.hash,start:t?.start??0,duration:t?.duration??e.duration};return this.register(n),n};audio=(e,t)=>{if(!e.hasAudio)throw new Error(`Audio clip error: media "${e.datafile.filename}" has no audio track.`);let n={kind:H.Audio,id:this.getId(),mediaHash:e.datafile.checksum.hash,start:t?.start??0,duration:t?.duration??e.duration,gain:t?.gain??1};return this.register(n),n};text=(e,t)=>{let n={id:this.getId(),content:e,kind:H.Text,duration:t?.duration??2e3};return t?.styles&&(n.styleId=this.textStyle(t.styles).id),this.register(n),n};gap=e=>{let t={id:this.getId(),kind:H.Gap,duration:e};return this.register(t),t};transition={crossfade:e=>{let t={id:this.getId(),kind:H.Transition,effect:no.Crossfade,duration:e};return this.register(t),t}};transform=e=>{let t=[e?.position?.[0]??0,e?.position?.[1]??0],n=[e?.scale?.[0]??1,e?.scale?.[1]??1],o=e?.rotation??0;return[t,n,o]};addChildren(e,...t){this.#e(n=>(n.items.find(({id:i})=>i===e.id).childrenIds.push(...t.map(i=>i.id)),n))}set=(e,t)=>{this.#e(n=>({...n,items:n.items.map(o=>o.id===e?{...o,...t}:o)}))}};var xt=r=>r;function h(r){if(!r)throw new Error("Assertion failed.")}var oo=r=>{let e=(r%360+360)%360;if(e===0||e===90||e===180||e===270)return e;throw new Error(`Invalid rotation ${r}.`)},xe=r=>r&&r[r.length-1];var Z=class r{constructor(e){this.bytes=e,this.pos=0}seekToByte(e){this.pos=8*e}readBit(){let e=Math.floor(this.pos/8),t=this.bytes[e]??0,n=7-(this.pos&7),o=(t&1<<n)>>n;return this.pos++,o}readBits(e){if(e===1)return this.readBit();let t=0;for(let n=0;n<e;n++)t<<=1,t|=this.readBit();return t}writeBits(e,t){let n=this.pos+e;for(let o=this.pos;o<n;o++){let i=Math.floor(o/8),s=this.bytes[i],a=7-(o&7);s&=~(1<<a),s|=(t&1<<n-o-1)>>n-o-1<<a,this.bytes[i]=s}this.pos=n}readAlignedByte(){if(this.pos%8!==0)throw new Error("Bitstream is not byte-aligned.");let e=this.pos/8,t=this.bytes[e]??0;return this.pos+=8,t}skipBits(e){this.pos+=e}getBitsLeft(){return this.bytes.length*8-this.pos}clone(){let e=new r(this.bytes);return e.pos=this.pos,e}},R=r=>{let e=0;for(;r.readBits(1)===0&&e<32;)e++;if(e>=32)throw new Error("Invalid exponential-Golomb code.");return(1<<e)-1+r.readBits(e)},je=r=>{let e=R(r);return(e&1)===0?-(e>>1):e+1>>1};var ze=r=>r.constructor===Uint8Array?r:ArrayBuffer.isView(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r),K=r=>r.constructor===DataView?r:ArrayBuffer.isView(r)?new DataView(r.buffer,r.byteOffset,r.byteLength):new DataView(r),me=new TextDecoder;var xs=r=>Object.fromEntries(Object.entries(r).map(([e,t])=>[t,e])),vs={bt709:1,bt470bg:5,smpte170m:6,bt2020:9,smpte432:12},io=xs(vs),ys={bt709:1,smpte170m:6,linear:8,"iec61966-2-1":13,pq:16,hlg:18},so=xs(ys),bs={rgb:0,bt709:1,bt470bg:5,smpte170m:6,"bt2020-ncl":9},ao=xs(bs);var lo=r=>r instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&r instanceof SharedArrayBuffer||ArrayBuffer.isView(r),We=class{constructor(){this.currentPromise=Promise.resolve()}async acquire(){let e,t=new Promise(o=>{e=o}),n=this.currentPromise;return this.currentPromise=t,await n,e}},Ss=r=>[...r].map(e=>e.toString(16).padStart(2,"0")).join(""),Ts=r=>(r=r>>1&1431655765|(r&1431655765)<<1,r=r>>2&858993459|(r&858993459)<<2,r=r>>4&252645135|(r&252645135)<<4,r=r>>8&16711935|(r&16711935)<<8,r=r>>16&65535|(r&65535)<<16,r>>>0),Ot=(r,e,t)=>{let n=0,o=r.length-1,i=-1;for(;n<=o;){let s=n+o>>1,a=t(r[s]);a===e?(i=s,o=s-1):a<e?n=s+1:o=s-1}return i},$=(r,e,t)=>{let n=0,o=r.length-1,i=-1;for(;n<=o;){let s=n+(o-n+1)/2|0;t(r[s])<=e?(i=s,n=s+1):o=s-1}return i},ws=(r,e,t)=>{let n=$(r,t(e),t);r.splice(n+1,0,e)},ve=()=>{let r,e;return{promise:new Promise((n,o)=>{r=n,e=o}),resolve:r,reject:e}};var Cs=(r,e)=>{for(let t=r.length-1;t>=0;t--)if(e(r[t]))return r[t]},co=(r,e)=>{for(let t=r.length-1;t>=0;t--)if(e(r[t]))return t;return-1},sl=async function*(r){Symbol.iterator in r?yield*r[Symbol.iterator]():yield*r[Symbol.asyncIterator]()},al=r=>{if(!(Symbol.iterator in r)&&!(Symbol.asyncIterator in r))throw new TypeError("Argument must be an iterable or async iterable.")},Ae=r=>{throw new Error(`Unexpected value: ${r}`)},Rt=(r,e,t)=>{let n=r.getUint8(e),o=r.getUint8(e+1),i=r.getUint8(e+2);return t?n|o<<8|i<<16:n<<16|o<<8|i},ll=(r,e,t)=>Rt(r,e,t)<<8>>8,cl=(r,e,t,n)=>{t=t>>>0,t=t&16777215,n?(r.setUint8(e,t&255),r.setUint8(e+1,t>>>8&255),r.setUint8(e+2,t>>>16&255)):(r.setUint8(e,t>>>16&255),r.setUint8(e+1,t>>>8&255),r.setUint8(e+2,t&255))};var Mt=(r,e,t)=>Math.max(e,Math.min(t,r)),pe="und",Bt=r=>{let e=Math.round(r);return Math.abs(r/e-1)<10*Number.EPSILON?e:r},ul=(r,e)=>Math.round(r/e)*e,fl=r=>{let e=0;for(;r;)e++,r>>=1;return e},yd=/^[a-z]{3}$/,uo=r=>yd.test(r),Xe=1e6*(1+Number.EPSILON),ks=(r,e)=>{let t={...r,...e};if(r.headers||e.headers){let n=r.headers?il(r.headers):{},o=e.headers?il(e.headers):{},i={...n};Object.entries(o).forEach(([s,a])=>{let l=Object.keys(i).find(c=>c.toLowerCase()===s.toLowerCase());l&&delete i[l],i[s]=a}),t.headers=i}return t},il=r=>{if(r instanceof Headers){let e={};return r.forEach((t,n)=>{e[n]=t}),e}if(Array.isArray(r)){let e={};return r.forEach(([t,n])=>{e[t]=n}),e}return r},Ps=async(r,e,t,n,o)=>{let i=0;for(;;)try{return await r(e,t)}catch(s){if(o())throw s;i++;let a=n(i,s,e);if(a===null)throw s;if(console.error("Retrying failed fetch. Error:",s),!Number.isFinite(a)||a<0)throw new TypeError("Retry delay must be a non-negative finite number.");if(a>0&&await new Promise(l=>setTimeout(l,1e3*a)),o())throw s}};var un=class{constructor(){this.currentPromise=Promise.resolve()}call(e){return this.currentPromise=this.currentPromise.then(e)}},ps=null,vt=()=>ps!==null?ps:ps=!!(typeof navigator<"u"&&(navigator.vendor?.match(/apple/i)||/AppleWebKit/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)||/\b(iPad|iPhone|iPod)\b/.test(navigator.userAgent))),ds=null,_s=()=>ds!==null?ds:ds=typeof navigator<"u"&&navigator.userAgent?.includes("Firefox"),hs=null,fn=()=>hs!==null?hs:hs=!!(typeof navigator<"u"&&(navigator.vendor?.includes("Google Inc")||/Chrome/.test(navigator.userAgent))),gs=null,ml=()=>{if(gs!==null)return gs;if(typeof navigator>"u")return null;let r=/\bChrome\/(\d+)/.exec(navigator.userAgent);return r?gs=Number(r[1]):null},Ut=(r,e)=>r!==-1?r:e,fo=(r,e,t,n)=>r<=n&&t<=e;var pl=r=>{let e=atob(r),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t};var mo=()=>{Symbol.dispose??=Symbol("Symbol.dispose")},mn=r=>typeof r=="number"&&!Number.isNaN(r);var yt=class{constructor(e,t){if(this.data=e,this.mimeType=t,!(e instanceof Uint8Array))throw new TypeError("data must be a Uint8Array.");if(typeof t!="string")throw new TypeError("mimeType must be a string.")}},po=class{constructor(e,t,n,o){if(this.data=e,this.mimeType=t,this.name=n,this.description=o,!(e instanceof Uint8Array))throw new TypeError("data must be a Uint8Array.");if(t!==void 0&&typeof t!="string")throw new TypeError("mimeType, when provided, must be a string.");if(n!==void 0&&typeof n!="string")throw new TypeError("name, when provided, must be a string.");if(o!==void 0&&typeof o!="string")throw new TypeError("description, when provided, must be a string.")}};var Se={default:!0,forced:!1,original:!1,commentary:!1,hearingImpaired:!1,visuallyImpaired:!1};var bt=["pcm-s16","pcm-s16be","pcm-s24","pcm-s24be","pcm-s32","pcm-s32be","pcm-f32","pcm-f32be","pcm-f64","pcm-f64be","pcm-u8","pcm-s8","ulaw","alaw"],bd=["aac","opus","mp3","vorbis","flac"],$x=[...bd,...bt];var Nt=[{maxPictureSize:36864,maxBitrate:2e5,level:10},{maxPictureSize:73728,maxBitrate:8e5,level:11},{maxPictureSize:122880,maxBitrate:18e5,level:20},{maxPictureSize:245760,maxBitrate:36e5,level:21},{maxPictureSize:552960,maxBitrate:72e5,level:30},{maxPictureSize:983040,maxBitrate:12e6,level:31},{maxPictureSize:2228224,maxBitrate:18e6,level:40},{maxPictureSize:2228224,maxBitrate:3e7,level:41},{maxPictureSize:8912896,maxBitrate:6e7,level:50},{maxPictureSize:8912896,maxBitrate:12e7,level:51},{maxPictureSize:8912896,maxBitrate:18e7,level:52},{maxPictureSize:35651584,maxBitrate:18e7,level:60},{maxPictureSize:35651584,maxBitrate:24e7,level:61},{maxPictureSize:35651584,maxBitrate:48e7,level:62}];var dl=".01.01.01.01.00",hl=".0.110.01.01.01.0";var ho=r=>{let{codec:e,codecDescription:t,colorSpace:n,avcCodecInfo:o,hevcCodecInfo:i,vp9CodecInfo:s,av1CodecInfo:a}=r;if(e==="avc"){if(h(r.avcType!==null),o){let l=new Uint8Array([o.avcProfileIndication,o.profileCompatibility,o.avcLevelIndication]);return`avc${r.avcType}.${Ss(l)}`}if(!t||t.byteLength<4)throw new TypeError("AVC decoder description is not provided or is not at least 4 bytes long.");return`avc${r.avcType}.${Ss(t.subarray(1,4))}`}else if(e==="hevc"){let l,c,f,u,m,p;if(i)l=i.generalProfileSpace,c=i.generalProfileIdc,f=Ts(i.generalProfileCompatibilityFlags),u=i.generalTierFlag,m=i.generalLevelIdc,p=[...i.generalConstraintIndicatorFlags];else{if(!t||t.byteLength<23)throw new TypeError("HEVC decoder description is not provided or is not at least 23 bytes long.");let g=K(t),x=g.getUint8(1);l=x>>6&3,c=x&31,f=Ts(g.getUint32(2)),u=x>>5&1,m=g.getUint8(12),p=[];for(let y=0;y<6;y++)p.push(g.getUint8(6+y))}let d="hev1.";for(d+=["","A","B","C"][l]+c,d+=".",d+=f.toString(16).toUpperCase(),d+=".",d+=u===0?"L":"H",d+=m;p.length>0&&p[p.length-1]===0;)p.pop();return p.length>0&&(d+=".",d+=p.map(g=>g.toString(16).toUpperCase()).join(".")),d}else{if(e==="vp8")return"vp8";if(e==="vp9"){if(!s){let y=r.width*r.height,v=xe(Nt).level;for(let T of Nt)if(y<=T.maxPictureSize){v=T.level;break}return`vp09.00.${v.toString().padStart(2,"0")}.08`}let l=s.profile.toString().padStart(2,"0"),c=s.level.toString().padStart(2,"0"),f=s.bitDepth.toString().padStart(2,"0"),u=s.chromaSubsampling.toString().padStart(2,"0"),m=s.colourPrimaries.toString().padStart(2,"0"),p=s.transferCharacteristics.toString().padStart(2,"0"),d=s.matrixCoefficients.toString().padStart(2,"0"),g=s.videoFullRangeFlag.toString().padStart(2,"0"),x=`vp09.${l}.${c}.${f}.${u}`;return x+=`.${m}.${p}.${d}.${g}`,x.endsWith(dl)&&(x=x.slice(0,-dl.length)),x}else if(e==="av1"){if(!a){let T=r.width*r.height,S=xe(Nt).level;for(let k of Nt)if(T<=k.maxPictureSize){S=k.level;break}return`av01.0.${S.toString().padStart(2,"0")}M.08`}let l=a.profile,c=a.level.toString().padStart(2,"0"),f=a.tier?"H":"M",u=a.bitDepth.toString().padStart(2,"0"),m=a.monochrome?"1":"0",p=100*a.chromaSubsamplingX+10*a.chromaSubsamplingY+1*(a.chromaSubsamplingX&&a.chromaSubsamplingY?a.chromaSamplePosition:0),d=n?.primaries?vs[n.primaries]:1,g=n?.transfer?ys[n.transfer]:1,x=n?.matrix?bs[n.matrix]:1,y=n?.fullRange?1:0,v=`av01.${l}.${c}${f}.${u}`;return v+=`.${m}.${p.toString().padStart(3,"0")}`,v+=`.${d.toString().padStart(2,"0")}`,v+=`.${g.toString().padStart(2,"0")}`,v+=`.${x.toString().padStart(2,"0")}`,v+=`.${y}`,v.endsWith(hl)&&(v=v.slice(0,-hl.length)),v}}throw new TypeError(`Unhandled codec '${e}'.`)};var go=r=>{let{codec:e,codecDescription:t,aacCodecInfo:n}=r;if(e==="aac"){if(!n)throw new TypeError("AAC codec info must be provided.");return n.isMpeg2?"mp4a.67":`mp4a.40.${As(t).objectType}`}else{if(e==="mp3")return"mp3";if(e==="opus")return"opus";if(e==="vorbis")return"vorbis";if(e==="flac")return"flac";if(e&&bt.includes(e))return e}throw new TypeError(`Unhandled codec '${e}'.`)},pn=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],Is=[-1,1,2,3,4,5,6,8],As=r=>{if(!r||r.byteLength<2)throw new TypeError("AAC description must be at least 2 bytes long.");let e=new Z(r),t=e.readBits(5);t===31&&(t=32+e.readBits(6));let n=e.readBits(4),o=null;n===15?o=e.readBits(24):n<pn.length&&(o=pn[n]);let i=e.readBits(4),s=null;return i>=1&&i<=7&&(s=Is[i]),{objectType:t,frequencyIndex:n,sampleRate:o,channelConfiguration:i,numberOfChannels:s}};var Lt=48e3,Sd=/^pcm-([usf])(\d+)+(be)?$/,xo=r=>{if(h(bt.includes(r)),r==="ulaw")return{dataType:"ulaw",sampleSize:1,littleEndian:!0,silentValue:255};if(r==="alaw")return{dataType:"alaw",sampleSize:1,littleEndian:!0,silentValue:213};let e=Sd.exec(r);h(e);let t;e[1]==="u"?t="unsigned":e[1]==="s"?t="signed":t="float";let n=Number(e[2])/8,o=e[3]!=="be",i=r==="pcm-u8"?2**7:0;return{dataType:t,sampleSize:n,littleEndian:o,silentValue:i}};var Vt;(function(r){r[r.IDR=5]="IDR",r[r.SEI=6]="SEI",r[r.SPS=7]="SPS",r[r.PPS=8]="PPS",r[r.SPS_EXT=13]="SPS_EXT"})(Vt||(Vt={}));var ye;(function(r){r[r.RASL_N=8]="RASL_N",r[r.RASL_R=9]="RASL_R",r[r.BLA_W_LP=16]="BLA_W_LP",r[r.RSV_IRAP_VCL23=23]="RSV_IRAP_VCL23",r[r.VPS_NUT=32]="VPS_NUT",r[r.SPS_NUT=33]="SPS_NUT",r[r.PPS_NUT=34]="PPS_NUT",r[r.PREFIX_SEI_NUT=39]="PREFIX_SEI_NUT",r[r.SUFFIX_SEI_NUT=40]="SUFFIX_SEI_NUT"})(ye||(ye={}));var yo=r=>{let e=[],t=0;for(;t<r.length;){let n=-1,o=0;for(let i=t;i<r.length-3;i++){if(r[i]===0&&r[i+1]===0&&r[i+2]===1){n=i,o=3;break}if(i<r.length-4&&r[i]===0&&r[i+1]===0&&r[i+2]===0&&r[i+3]===1){n=i,o=4;break}}if(n===-1)break;if(t>0&&n>t){let i=r.subarray(t,n);i.length>0&&e.push(i)}t=n+o}if(t<r.length){let n=r.subarray(t);n.length>0&&e.push(n)}return e},vl=(r,e)=>{let t=[],n=0,o=new DataView(r.buffer,r.byteOffset,r.byteLength);for(;n+e<=r.length;){let i;e===1?i=o.getUint8(n):e===2?i=o.getUint16(n,!1):e===3?i=Rt(o,n,!1):e===4?i=o.getUint32(n,!1):(Ae(e),h(!1)),n+=e;let s=r.subarray(n,n+i);t.push(s),n+=i}return t},vo=r=>{let e=[],t=r.length;for(let n=0;n<t;n++)n+2<t&&r[n]===0&&r[n+1]===0&&r[n+2]===3?(e.push(0,0),n+=2):e.push(r[n]);return new Uint8Array(e)},Fs=new Uint8Array([0,0,0,1]),wd=r=>{let e=r.reduce((o,i)=>o+Fs.byteLength+i.byteLength,0),t=new Uint8Array(e),n=0;for(let o of r)t.set(Fs,n),n+=Fs.byteLength,t.set(o,n),n+=o.byteLength;return t},Cd=(r,e)=>{let t=r.reduce((i,s)=>i+e+s.byteLength,0),n=new Uint8Array(t),o=0;for(let i of r){let s=new DataView(n.buffer,n.byteOffset,n.byteLength);switch(e){case 1:s.setUint8(o,i.byteLength);break;case 2:s.setUint16(o,i.byteLength,!1);break;case 3:cl(s,o,i.byteLength,!1);break;case 4:s.setUint32(o,i.byteLength,!1);break}o+=e,n.set(i,o),o+=i.byteLength}return n},Es=(r,e)=>{if(e.description){let o=(ze(e.description)[4]&3)+1;return vl(r,o)}else return yo(r)},yl=(r,e)=>{if(e.description){let o=(ze(e.description)[4]&3)+1;return Cd(r,o)}else return wd(r)},Gt=r=>r[0]&31,bl=r=>{try{let e=yo(r),t=e.filter(l=>Gt(l)===Vt.SPS),n=e.filter(l=>Gt(l)===Vt.PPS),o=e.filter(l=>Gt(l)===Vt.SPS_EXT);if(t.length===0||n.length===0)return null;let i=t[0],s=zs(i);h(s!==null);let a=s.profileIdc===100||s.profileIdc===110||s.profileIdc===122||s.profileIdc===144;return{configurationVersion:1,avcProfileIndication:s.profileIdc,profileCompatibility:s.constraintFlags,avcLevelIndication:s.levelIdc,lengthSizeMinusOne:3,sequenceParameterSets:t,pictureParameterSets:n,chromaFormat:a?s.chromaFormatIdc:null,bitDepthLumaMinus8:a?s.bitDepthLumaMinus8:null,bitDepthChromaMinus8:a?s.bitDepthChromaMinus8:null,sequenceParameterSetExt:a?o:null}}catch(e){return console.error("Error building AVC Decoder Configuration Record:",e),null}};var Sl=r=>{try{let e=K(r),t=0,n=e.getUint8(t++),o=e.getUint8(t++),i=e.getUint8(t++),s=e.getUint8(t++),a=e.getUint8(t++)&3,l=e.getUint8(t++)&31,c=[];for(let p=0;p<l;p++){let d=e.getUint16(t,!1);t+=2,c.push(r.subarray(t,t+d)),t+=d}let f=e.getUint8(t++),u=[];for(let p=0;p<f;p++){let d=e.getUint16(t,!1);t+=2,u.push(r.subarray(t,t+d)),t+=d}let m={configurationVersion:n,avcProfileIndication:o,profileCompatibility:i,avcLevelIndication:s,lengthSizeMinusOne:a,sequenceParameterSets:c,pictureParameterSets:u,chromaFormat:null,bitDepthLumaMinus8:null,bitDepthChromaMinus8:null,sequenceParameterSetExt:null};if((o===100||o===110||o===122||o===144)&&t+4<=r.length){let p=e.getUint8(t++)&3,d=e.getUint8(t++)&7,g=e.getUint8(t++)&7,x=e.getUint8(t++);m.chromaFormat=p,m.bitDepthLumaMinus8=d,m.bitDepthChromaMinus8=g;let y=[];for(let v=0;v<x;v++){let T=e.getUint16(t,!1);t+=2,y.push(r.subarray(t,t+T)),t+=T}m.sequenceParameterSetExt=y}return m}catch(e){return console.error("Error deserializing AVC Decoder Configuration Record:",e),null}},zs=r=>{try{let e=new Z(vo(r));if(e.skipBits(1),e.skipBits(2),e.readBits(5)!==7)return null;let n=e.readAlignedByte(),o=e.readAlignedByte(),i=e.readAlignedByte();R(e);let s=null,a=null,l=null;if((n===100||n===110||n===122||n===244||n===44||n===83||n===86||n===118||n===128)&&(s=R(e),s===3&&e.skipBits(1),a=R(e),l=R(e),e.skipBits(1),e.readBits(1))){for(let m=0;m<(s!==3?8:12);m++)if(e.readBits(1)){let d=m<6?16:64,g=8,x=8;for(let y=0;y<d;y++){if(x!==0){let v=je(e);x=(g+v+256)%256}g=x===0?g:x}}}R(e);let c=R(e);if(c===0)R(e);else if(c===1){e.skipBits(1),je(e),je(e);let u=R(e);for(let m=0;m<u;m++)je(e)}R(e),e.skipBits(1),R(e),R(e);let f=e.readBits(1);return{profileIdc:n,constraintFlags:o,levelIdc:i,frameMbsOnlyFlag:f,chromaFormatIdc:s,bitDepthLumaMinus8:a,bitDepthChromaMinus8:l}}catch(e){return console.error("Error parsing AVC SPS:",e),null}},Ds=(r,e)=>{if(e.description){let o=(ze(e.description)[21]&3)+1;return vl(r,o)}else return yo(r)},rt=r=>r[0]>>1&63,Tl=r=>{try{let e=yo(r),t=e.filter(q=>rt(q)===ye.VPS_NUT),n=e.filter(q=>rt(q)===ye.SPS_NUT),o=e.filter(q=>rt(q)===ye.PPS_NUT),i=e.filter(q=>rt(q)===ye.PREFIX_SEI_NUT||rt(q)===ye.SUFFIX_SEI_NUT);if(n.length===0||o.length===0)return null;let s=n[0],a=new Z(vo(s));a.skipBits(16),a.readBits(4);let l=a.readBits(3),c=a.readBits(1),{general_profile_space:f,general_tier_flag:u,general_profile_idc:m,general_profile_compatibility_flags:p,general_constraint_indicator_flags:d,general_level_idc:g}=kd(a,l);R(a);let x=R(a);x===3&&a.skipBits(1),R(a),R(a),a.readBits(1)&&(R(a),R(a),R(a),R(a));let y=R(a),v=R(a);R(a);let S=a.readBits(1)?0:l;for(let q=S;q<=l;q++)R(a),R(a),R(a);R(a),R(a),R(a),R(a),R(a),R(a),a.readBits(1)&&a.readBits(1)&&Pd(a),a.skipBits(1),a.skipBits(1),a.readBits(1)&&(a.skipBits(4),a.skipBits(4),R(a),R(a),a.skipBits(1));let k=R(a);if(_d(a,k),a.readBits(1)){let q=R(a);for(let G=0;G<q;G++)R(a),a.skipBits(1)}a.skipBits(1),a.skipBits(1);let C=0;a.readBits(1)&&(C=Ad(a,l));let O=0;if(o.length>0){let q=o[0],G=new Z(vo(q));G.skipBits(16),R(G),R(G),G.skipBits(1),G.skipBits(1),G.skipBits(3),G.skipBits(1),G.skipBits(1),R(G),R(G),je(G),G.skipBits(1),G.skipBits(1),G.readBits(1)&&R(G),je(G),je(G),G.skipBits(1),G.skipBits(1),G.skipBits(1),G.skipBits(1);let ie=G.readBits(1),Ue=G.readBits(1);!ie&&!Ue?O=0:ie&&!Ue?O=2:!ie&&Ue?O=3:O=0}let E=[...t.length?[{arrayCompleteness:1,nalUnitType:ye.VPS_NUT,nalUnits:t}]:[],...n.length?[{arrayCompleteness:1,nalUnitType:ye.SPS_NUT,nalUnits:n}]:[],...o.length?[{arrayCompleteness:1,nalUnitType:ye.PPS_NUT,nalUnits:o}]:[],...i.length?[{arrayCompleteness:1,nalUnitType:rt(i[0]),nalUnits:i}]:[]];return{configurationVersion:1,generalProfileSpace:f,generalTierFlag:u,generalProfileIdc:m,generalProfileCompatibilityFlags:p,generalConstraintIndicatorFlags:d,generalLevelIdc:g,minSpatialSegmentationIdc:C,parallelismType:O,chromaFormatIdc:x,bitDepthLumaMinus8:y,bitDepthChromaMinus8:v,avgFrameRate:0,constantFrameRate:0,numTemporalLayers:l+1,temporalIdNested:c,lengthSizeMinusOne:3,arrays:E}}catch(e){return console.error("Error building HEVC Decoder Configuration Record:",e),null}},kd=(r,e)=>{let t=r.readBits(2),n=r.readBits(1),o=r.readBits(5),i=0;for(let f=0;f<32;f++)i=i<<1|r.readBits(1);let s=new Uint8Array(6);for(let f=0;f<6;f++)s[f]=r.readBits(8);let a=r.readBits(8),l=[],c=[];for(let f=0;f<e;f++)l.push(r.readBits(1)),c.push(r.readBits(1));if(e>0)for(let f=e;f<8;f++)r.skipBits(2);for(let f=0;f<e;f++)l[f]&&r.skipBits(88),c[f]&&r.skipBits(8);return{general_profile_space:t,general_tier_flag:n,general_profile_idc:o,general_profile_compatibility_flags:i,general_constraint_indicator_flags:s,general_level_idc:a}},Pd=r=>{for(let e=0;e<4;e++)for(let t=0;t<(e===3?2:6);t++)if(!r.readBits(1))R(r);else{let o=Math.min(64,1<<4+(e<<1));e>1&&je(r);for(let i=0;i<o;i++)je(r)}},_d=(r,e)=>{let t=[];for(let n=0;n<e;n++)t[n]=Id(r,n,e,t)},Id=(r,e,t,n)=>{let o=0,i=0,s=0;if(e!==0&&(i=r.readBits(1)),i){if(e===t){let l=R(r);s=e-(l+1)}else s=e-1;r.readBits(1),R(r);let a=n[s]??0;for(let l=0;l<=a;l++)r.readBits(1)||r.readBits(1);o=n[s]}else{let a=R(r),l=R(r);for(let c=0;c<a;c++)R(r),r.readBits(1);for(let c=0;c<l;c++)R(r),r.readBits(1);o=a+l}return o},Ad=(r,e)=>{if(r.readBits(1)&&r.readBits(8)===255&&(r.readBits(16),r.readBits(16)),r.readBits(1)&&r.readBits(1),r.readBits(1)&&(r.readBits(3),r.readBits(1),r.readBits(1)&&(r.readBits(8),r.readBits(8),r.readBits(8))),r.readBits(1)&&(R(r),R(r)),r.readBits(1),r.readBits(1),r.readBits(1),r.readBits(1)&&(R(r),R(r),R(r),R(r)),r.readBits(1)&&(r.readBits(32),r.readBits(32),r.readBits(1)&&R(r),r.readBits(1)&&Fd(r,!0,e)),r.readBits(1)){r.readBits(1),r.readBits(1),r.readBits(1);let t=R(r);return R(r),R(r),R(r),R(r),t}return 0},Fd=(r,e,t)=>{let n=!1,o=!1,i=!1;e&&(n=r.readBits(1)===1,o=r.readBits(1)===1,(n||o)&&(i=r.readBits(1)===1,i&&(r.readBits(8),r.readBits(5),r.readBits(1),r.readBits(5)),r.readBits(4),r.readBits(4),i&&r.readBits(4),r.readBits(5),r.readBits(5),r.readBits(5)));for(let s=0;s<=t;s++){let a=r.readBits(1)===1,l=!0;a||(l=r.readBits(1)===1);let c=!1;l?R(r):c=r.readBits(1)===1;let f=1;c||(f=R(r)+1),n&&gl(r,f,i),o&&gl(r,f,i)}},gl=(r,e,t)=>{for(let n=0;n<e;n++)R(r),R(r),t&&(R(r),R(r)),r.readBits(1)};var bo=r=>{let e=new Z(r);if(e.readBits(2)!==2)return null;let n=e.readBits(1),i=(e.readBits(1)<<1)+n;if(i===3&&e.skipBits(1),e.readBits(1)===1||e.readBits(1)!==0||(e.skipBits(2),e.readBits(24)!==4817730))return null;let c=8;i>=2&&(c=e.readBits(1)?12:10);let f=e.readBits(3),u=0,m=0;if(f!==7)if(m=e.readBits(1),i===1||i===3){let O=e.readBits(1),E=e.readBits(1);u=!O&&!E?3:O&&!E?2:1,e.skipBits(1)}else u=1;else u=3,m=1;let p=e.readBits(16),d=e.readBits(16),g=p+1,x=d+1,y=g*x,v=xe(Nt).level;for(let C of Nt)if(y<=C.maxPictureSize){v=C.level;break}return{profile:i,level:v,bitDepth:c,chromaSubsampling:u,videoFullRangeFlag:m,colourPrimaries:f===2?1:f===1?6:2,transferCharacteristics:f===2?1:f===1?6:2,matrixCoefficients:f===7?0:f===2?1:f===1?6:2}},wl=function*(r){let e=new Z(r),t=()=>{let n=0;for(let o=0;o<8;o++){let i=e.readAlignedByte();if(n|=(i&127)<<o*7,!(i&128))break;if(o===7&&i&128)return null}return n>=2**32-1?null:n};for(;e.getBitsLeft()>=8;){e.skipBits(1);let n=e.readBits(4),o=e.readBits(1),i=e.readBits(1);e.skipBits(1),o&&e.skipBits(8);let s;if(i){let a=t();if(a===null)return;s=a}else s=Math.floor(e.getBitsLeft()/8);h(e.pos%8===0),yield{type:n,data:r.subarray(e.pos/8,e.pos/8+s)},e.skipBits(s*8)}},So=r=>{for(let{type:e,data:t}of wl(r)){if(e!==1)continue;let n=new Z(t),o=n.readBits(3),i=n.readBits(1),s=n.readBits(1),a=0,l=0,c=0;if(s)a=n.readBits(5);else{if(n.readBits(1)&&(n.skipBits(32),n.skipBits(32),n.readBits(1)))return null;let C=n.readBits(1);C&&(c=n.readBits(5),n.skipBits(32),n.skipBits(5),n.skipBits(5));let O=n.readBits(5);for(let E=0;E<=O;E++){n.skipBits(12);let V=n.readBits(5);if(E===0&&(a=V),V>7){let G=n.readBits(1);E===0&&(l=G)}if(C&&n.readBits(1)){let ie=c+1;n.skipBits(ie),n.skipBits(ie),n.skipBits(1)}n.readBits(1)&&n.skipBits(4)}}let f=n.readBits(4),u=n.readBits(4),m=f+1;n.skipBits(m);let p=u+1;n.skipBits(p);let d=0;if(s?d=0:d=n.readBits(1),d&&(n.skipBits(4),n.skipBits(3)),n.skipBits(1),n.skipBits(1),n.skipBits(1),!s){n.skipBits(1),n.skipBits(1),n.skipBits(1),n.skipBits(1);let k=n.readBits(1);k&&(n.skipBits(1),n.skipBits(1));let C=n.readBits(1),O=0;C?O=2:O=n.readBits(1),O>0&&(n.readBits(1)||n.skipBits(1)),k&&n.skipBits(3)}n.skipBits(1),n.skipBits(1),n.skipBits(1);let g=n.readBits(1),x=8;o===2&&g?x=n.readBits(1)?12:10:o<=2&&(x=g?10:8);let y=0;o!==1&&(y=n.readBits(1));let v=1,T=1,S=0;return y||(o===0?(v=1,T=1):o===1?(v=0,T=0):x===12&&(v=n.readBits(1),v&&(T=n.readBits(1))),v&&T&&(S=n.readBits(2))),{profile:o,level:a,tier:l,bitDepth:x,monochrome:y,chromaSubsamplingX:v,chromaSubsamplingY:T,chromaSamplePosition:S}}return null},Cl=r=>{let e=K(r),t=e.getUint8(9),n=e.getUint16(10,!0),o=e.getUint32(12,!0),i=e.getInt16(16,!0),s=e.getUint8(18),a=null;return s&&(a=r.subarray(19,21+t)),{outputChannelCount:t,preSkip:n,inputSampleRate:o,outputGain:i,channelMappingFamily:s,channelMappingTable:a}},Ed=[480,960,1920,2880,480,960,1920,2880,480,960,1920,2880,480,960,480,960,120,240,480,960,120,240,480,960,120,240,480,960,120,240,480,960],kl=r=>{let e=r[0]>>3;return{durationInSamples:Ed[e]}},Pl=r=>{if(r.length<7)throw new Error("Setup header is too short.");if(r[0]!==5)throw new Error("Wrong packet type in Setup header.");if(String.fromCharCode(...r.slice(1,7))!=="vorbis")throw new Error("Invalid packet signature in Setup header.");let t=r.length,n=new Uint8Array(t);for(let u=0;u<t;u++)n[u]=r[t-1-u];let o=new Z(n),i=0;for(;o.getBitsLeft()>97;)if(o.readBits(1)===1){i=o.pos;break}if(i===0)throw new Error("Invalid Setup header: framing bit not found.");let s=0,a=!1,l=0;for(;o.getBitsLeft()>=97;){let u=o.pos,m=o.readBits(8),p=o.readBits(16),d=o.readBits(16);if(m>63||p!==0||d!==0){o.pos=u;break}if(o.skipBits(1),s++,s>64)break;o.clone().readBits(6)+1===s&&(a=!0,l=s)}if(!a)throw new Error("Invalid Setup header: mode header not found.");if(l>63)throw new Error(`Unsupported mode count: ${l}.`);let c=l;o.pos=0,o.skipBits(i);let f=Array(c).fill(0);for(let u=c-1;u>=0;u--)o.skipBits(40),f[u]=o.readBits(1);return{modeBlockflags:f}},To=(r,e,t)=>{switch(r){case"avc":{let n=Es(t,e),o=n.some(i=>Gt(i)===Vt.IDR);if(!o&&(!fn()||ml()>=144))for(let i of n){if(Gt(i)!==Vt.SEI)continue;let a=vo(i),l=1;do{let c=0;for(;;){let m=a[l++];if(m===void 0||(c+=m,m<255))break}let f=0;for(;;){let m=a[l++];if(m===void 0||(f+=m,m<255))break}if(c===6){let m=new Z(a);m.pos=8*l;let p=R(m),d=m.readBits(1);if(p===0&&d===1){o=!0;break}}l+=f}while(l<a.length-1)}return o?"key":"delta"}case"hevc":return Ds(t,e).some(i=>{let s=rt(i);return ye.BLA_W_LP<=s&&s<=ye.RSV_IRAP_VCL23})?"key":"delta";case"vp8":return(t[0]&1)===0?"key":"delta";case"vp9":{let n=new Z(t);if(n.readBits(2)!==2)return null;let o=n.readBits(1);return(n.readBits(1)<<1)+o===3&&n.skipBits(1),n.readBits(1)?null:n.readBits(1)===0?"key":"delta"}case"av1":{let n=!1;for(let{type:o,data:i}of wl(t))if(o===1){let s=new Z(i);s.skipBits(4),n=!!s.readBits(1)}else if(o===3||o===6||o===7){if(n)return"key";let s=new Z(i);return s.readBits(1)?null:s.readBits(2)===0?"key":"delta"}return null}default:Ae(r),h(!1)}},St;(function(r){r[r.STREAMINFO=0]="STREAMINFO",r[r.VORBIS_COMMENT=4]="VORBIS_COMMENT",r[r.PICTURE=6]="PICTURE"})(St||(St={}));var dn=(r,e)=>{let t=K(r),n=0,o=t.getUint32(n,!0);n+=4;let i=me.decode(r.subarray(n,n+o));n+=o,o>0&&(e.raw??={},e.raw.vendor??=i);let s=t.getUint32(n,!0);n+=4;for(let a=0;a<s;a++){let l=t.getUint32(n,!0);n+=4;let c=me.decode(r.subarray(n,n+l));n+=l;let f=c.indexOf("=");if(f===-1)continue;let u=c.slice(0,f).toUpperCase(),m=c.slice(f+1);switch(e.raw??={},e.raw[u]??=m,u){case"TITLE":e.title??=m;break;case"DESCRIPTION":e.description??=m;break;case"ARTIST":e.artist??=m;break;case"ALBUM":e.album??=m;break;case"ALBUMARTIST":e.albumArtist??=m;break;case"COMMENT":e.comment??=m;break;case"LYRICS":e.lyrics??=m;break;case"TRACKNUMBER":{let p=m.split("/"),d=Number.parseInt(p[0],10),g=p[1]&&Number.parseInt(p[1],10);Number.isInteger(d)&&d>0&&(e.trackNumber??=d),g&&Number.isInteger(g)&&g>0&&(e.tracksTotal??=g)}break;case"TRACKTOTAL":{let p=Number.parseInt(m,10);Number.isInteger(p)&&p>0&&(e.tracksTotal??=p)}break;case"DISCNUMBER":{let p=m.split("/"),d=Number.parseInt(p[0],10),g=p[1]&&Number.parseInt(p[1],10);Number.isInteger(d)&&d>0&&(e.discNumber??=d),g&&Number.isInteger(g)&&g>0&&(e.discsTotal??=g)}break;case"DISCTOTAL":{let p=Number.parseInt(m,10);Number.isInteger(p)&&p>0&&(e.discsTotal??=p)}break;case"DATE":{let p=new Date(m);Number.isNaN(p.getTime())||(e.date??=p)}break;case"GENRE":e.genre??=m;break;case"METADATA_BLOCK_PICTURE":{let p=pl(m),d=K(p),g=d.getUint32(0,!1),x=d.getUint32(4,!1),y=String.fromCharCode(...p.subarray(8,8+x)),v=d.getUint32(8+x,!1),T=me.decode(p.subarray(12+x,12+x+v)),S=d.getUint32(x+v+28),k=p.subarray(x+v+32,x+v+32+S);e.images??=[],e.images.push({data:k,mimeType:y,kind:g===3?"coverFront":g===4?"coverBack":"unknown",name:void 0,description:T||void 0})}break}}};var ge=class{constructor(e){this.input=e}};var wo=[],Co=[];var le=new Uint8Array(0),te=class r{constructor(e,t,n,o,i=-1,s,a){if(this.data=e,this.type=t,this.timestamp=n,this.duration=o,this.sequenceNumber=i,e===le&&s===void 0)throw new Error("Internal error: byteLength must be explicitly provided when constructing metadata-only packets.");if(s===void 0&&(s=e.byteLength),!(e instanceof Uint8Array))throw new TypeError("data must be a Uint8Array.");if(t!=="key"&&t!=="delta")throw new TypeError('type must be either "key" or "delta".');if(!Number.isFinite(n))throw new TypeError("timestamp must be a number.");if(!Number.isFinite(o)||o<0)throw new TypeError("duration must be a non-negative number.");if(!Number.isFinite(i))throw new TypeError("sequenceNumber must be a number.");if(!Number.isInteger(s)||s<0)throw new TypeError("byteLength must be a non-negative integer.");if(a!==void 0&&(typeof a!="object"||!a))throw new TypeError("sideData, when provided, must be an object.");if(a?.alpha!==void 0&&!(a.alpha instanceof Uint8Array))throw new TypeError("sideData.alpha, when provided, must be a Uint8Array.");if(a?.alphaByteLength!==void 0&&(!Number.isInteger(a.alphaByteLength)||a.alphaByteLength<0))throw new TypeError("sideData.alphaByteLength, when provided, must be a non-negative integer.");this.byteLength=s,this.sideData=a??{},this.sideData.alpha&&this.sideData.alphaByteLength===void 0&&(this.sideData.alphaByteLength=this.sideData.alpha.byteLength)}get isMetadataOnly(){return this.data===le}get microsecondTimestamp(){return Math.trunc(Xe*this.timestamp)}get microsecondDuration(){return Math.trunc(Xe*this.duration)}toEncodedVideoChunk(){if(this.isMetadataOnly)throw new TypeError("Metadata-only packets cannot be converted to a video chunk.");if(typeof EncodedVideoChunk>"u")throw new Error("Your browser does not support EncodedVideoChunk.");return new EncodedVideoChunk({data:this.data,type:this.type,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}alphaToEncodedVideoChunk(e=this.type){if(!this.sideData.alpha)throw new TypeError("This packet does not contain alpha side data.");if(this.isMetadataOnly)throw new TypeError("Metadata-only packets cannot be converted to a video chunk.");if(typeof EncodedVideoChunk>"u")throw new Error("Your browser does not support EncodedVideoChunk.");return new EncodedVideoChunk({data:this.sideData.alpha,type:e,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}toEncodedAudioChunk(){if(this.isMetadataOnly)throw new TypeError("Metadata-only packets cannot be converted to an audio chunk.");if(typeof EncodedAudioChunk>"u")throw new Error("Your browser does not support EncodedAudioChunk.");return new EncodedAudioChunk({data:this.data,type:this.type,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}static fromEncodedChunk(e,t){if(!(e instanceof EncodedVideoChunk||e instanceof EncodedAudioChunk))throw new TypeError("chunk must be an EncodedVideoChunk or EncodedAudioChunk.");let n=new Uint8Array(e.byteLength);return e.copyTo(n),new r(n,e.type,e.timestamp/1e6,(e.duration??0)/1e6,void 0,void 0,t)}clone(e){if(e!==void 0&&(typeof e!="object"||e===null))throw new TypeError("options, when provided, must be an object.");if(e?.timestamp!==void 0&&!Number.isFinite(e.timestamp))throw new TypeError("options.timestamp, when provided, must be a number.");if(e?.duration!==void 0&&!Number.isFinite(e.duration))throw new TypeError("options.duration, when provided, must be a number.");return new r(this.data,this.type,e?.timestamp??this.timestamp,e?.duration??this.duration,this.sequenceNumber,this.byteLength)}};var _l=r=>{let t=0,n=0,o=~r;o&128&&(o&=-129,t=-1),n=((o&240)>>4)+5;let i=(1<<n|(o&15)<<n-4|1<<n-5)-33;return t===0?i:-i};var Il=r=>{let e=0,t=0,n=r^85;n&128&&(n&=-129,e=-1),t=((n&240)>>4)+4;let o=0;return t!==4?o=1<<t|(n&15)<<t-4|1<<t-5:o=n<<1|1,e===0?o:-o};mo();var Al=-1/0,Fl=-1/0,xn=null;typeof FinalizationRegistry<"u"&&(xn=new FinalizationRegistry(r=>{let e=Date.now();r.type==="video"?(e-Al>=1e3&&(console.error("A VideoSample was garbage collected without first being closed. For proper resource management, make sure to call close() on all your VideoSamples as soon as you're done using them."),Al=e),typeof VideoFrame<"u"&&r.data instanceof VideoFrame&&r.data.close()):(e-Fl>=1e3&&(console.error("An AudioSample was garbage collected without first being closed. For proper resource management, make sure to call close() on all your AudioSamples as soon as you're done using them."),Fl=e),typeof AudioData<"u"&&r.data instanceof AudioData&&r.data.close())}));var zl=["I420","I420P10","I420P12","I420A","I420AP10","I420AP12","I422","I422P10","I422P12","I422A","I422AP10","I422AP12","I444","I444P10","I444P12","I444A","I444AP10","I444AP12","NV12","RGBA","RGBX","BGRA","BGRX"],zd=new Set(zl),gr=class r{get displayWidth(){return this.rotation%180===0?this.codedWidth:this.codedHeight}get displayHeight(){return this.rotation%180===0?this.codedHeight:this.codedWidth}get microsecondTimestamp(){return Math.trunc(Xe*this.timestamp)}get microsecondDuration(){return Math.trunc(Xe*this.duration)}get hasAlpha(){return this.format&&this.format.includes("A")}constructor(e,t){if(this._closed=!1,e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer||ArrayBuffer.isView(e)){if(!t||typeof t!="object")throw new TypeError("init must be an object.");if(t.format===void 0||!zd.has(t.format))throw new TypeError("init.format must be one of: "+zl.join(", "));if(!Number.isInteger(t.codedWidth)||t.codedWidth<=0)throw new TypeError("init.codedWidth must be a positive integer.");if(!Number.isInteger(t.codedHeight)||t.codedHeight<=0)throw new TypeError("init.codedHeight must be a positive integer.");if(t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw new TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");if(!Number.isFinite(t.timestamp))throw new TypeError("init.timestamp must be a number.");if(t.duration!==void 0&&(!Number.isFinite(t.duration)||t.duration<0))throw new TypeError("init.duration, when provided, must be a non-negative number.");this._data=ze(e).slice(),this._layout=t.layout??Dd(t.format,t.codedWidth,t.codedHeight),this.format=t.format,this.codedWidth=t.codedWidth,this.codedHeight=t.codedHeight,this.rotation=t.rotation??0,this.timestamp=t.timestamp,this.duration=t.duration??0,this.colorSpace=new gn(t.colorSpace)}else if(typeof VideoFrame<"u"&&e instanceof VideoFrame){if(t?.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw new TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");if(t?.timestamp!==void 0&&!Number.isFinite(t?.timestamp))throw new TypeError("init.timestamp, when provided, must be a number.");if(t?.duration!==void 0&&(!Number.isFinite(t.duration)||t.duration<0))throw new TypeError("init.duration, when provided, must be a non-negative number.");this._data=e,this._layout=null,this.format=e.format,this.codedWidth=e.displayWidth,this.codedHeight=e.displayHeight,this.rotation=t?.rotation??0,this.timestamp=t?.timestamp??e.timestamp/1e6,this.duration=t?.duration??(e.duration??0)/1e6,this.colorSpace=new gn(e.colorSpace)}else if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof SVGImageElement<"u"&&e instanceof SVGImageElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas){if(!t||typeof t!="object")throw new TypeError("init must be an object.");if(t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw new TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");if(!Number.isFinite(t.timestamp))throw new TypeError("init.timestamp must be a number.");if(t.duration!==void 0&&(!Number.isFinite(t.duration)||t.duration<0))throw new TypeError("init.duration, when provided, must be a non-negative number.");if(typeof VideoFrame<"u")return new r(new VideoFrame(e,{timestamp:Math.trunc(t.timestamp*Xe),duration:Math.trunc((t.duration??0)*Xe)||void 0}),t);let n=0,o=0;if("naturalWidth"in e?(n=e.naturalWidth,o=e.naturalHeight):"videoWidth"in e?(n=e.videoWidth,o=e.videoHeight):"width"in e&&(n=Number(e.width),o=Number(e.height)),!n||!o)throw new TypeError("Could not determine dimensions.");let i=new OffscreenCanvas(n,o),s=i.getContext("2d",{alpha:_s(),willReadFrequently:!0});h(s),s.drawImage(e,0,0),this._data=i,this._layout=null,this.format="RGBX",this.codedWidth=n,this.codedHeight=o,this.rotation=t.rotation??0,this.timestamp=t.timestamp,this.duration=t.duration??0,this.colorSpace=new gn({matrix:"rgb",primaries:"bt709",transfer:"iec61966-2-1",fullRange:!0})}else throw new TypeError("Invalid data type: Must be a BufferSource or CanvasImageSource.");xn?.register(this,{type:"video",data:this._data},this)}clone(){if(this._closed)throw new Error("VideoSample is closed.");return h(this._data!==null),qt(this._data)?new r(this._data.clone(),{timestamp:this.timestamp,duration:this.duration,rotation:this.rotation}):this._data instanceof Uint8Array?(h(this._layout),new r(this._data,{format:this.format,layout:this._layout,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.timestamp,duration:this.duration,colorSpace:this.colorSpace,rotation:this.rotation})):new r(this._data,{format:this.format,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.timestamp,duration:this.duration,colorSpace:this.colorSpace,rotation:this.rotation})}close(){this._closed||(xn?.unregister(this),qt(this._data)?this._data.close():this._data=null,this._closed=!0)}allocationSize(e={}){if(El(e),this._closed)throw new Error("VideoSample is closed.");if((e.format??this.format)===null)throw new Error("Cannot get allocation size when format is null. Please manually provide an RGB pixel format in the options instead.");if(h(this._data!==null),!qt(this._data)&&(e.colorSpace||e.format&&e.format!==this.format||e.layout||e.rect)){let t=this.toVideoFrame(),n=t.allocationSize(e);return t.close(),n}return qt(this._data)?this._data.allocationSize(e):this._data instanceof Uint8Array?this._data.byteLength:this.codedWidth*this.codedHeight*4}async copyTo(e,t={}){if(!lo(e))throw new TypeError("destination must be an ArrayBuffer or an ArrayBuffer view.");if(El(t),this._closed)throw new Error("VideoSample is closed.");if((t.format??this.format)===null)throw new Error("Cannot copy video sample data when format is null. Please manually provide an RGB pixel format in the options instead.");if(h(this._data!==null),!qt(this._data)&&(t.colorSpace||t.format&&t.format!==this.format||t.layout||t.rect)){let n=this.toVideoFrame(),o=await n.copyTo(e,t);return n.close(),o}if(qt(this._data))return this._data.copyTo(e,t);if(this._data instanceof Uint8Array)return h(this._layout),ze(e).set(this._data),this._layout;{let o=this._data.getContext("2d");h(o);let i=o.getImageData(0,0,this.codedWidth,this.codedHeight);return ze(e).set(i.data),[{offset:0,stride:4*this.codedWidth}]}}toVideoFrame(){if(this._closed)throw new Error("VideoSample is closed.");return h(this._data!==null),qt(this._data)?new VideoFrame(this._data,{timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0}):this._data instanceof Uint8Array?new VideoFrame(this._data,{format:this.format,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0,colorSpace:this.colorSpace}):new VideoFrame(this._data,{timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0})}draw(e,t,n,o,i,s,a,l,c){let f=0,u=0,m=this.displayWidth,p=this.displayHeight,d=0,g=0,x=this.displayWidth,y=this.displayHeight;if(s!==void 0?(f=t,u=n,m=o,p=i,d=s,g=a,l!==void 0?(x=l,y=c):(x=m,y=p)):(d=t,g=n,o!==void 0&&(x=o,y=i)),!(typeof CanvasRenderingContext2D<"u"&&e instanceof CanvasRenderingContext2D||typeof OffscreenCanvasRenderingContext2D<"u"&&e instanceof OffscreenCanvasRenderingContext2D))throw new TypeError("context must be a CanvasRenderingContext2D or OffscreenCanvasRenderingContext2D.");if(!Number.isFinite(f))throw new TypeError("sx must be a number.");if(!Number.isFinite(u))throw new TypeError("sy must be a number.");if(!Number.isFinite(m)||m<0)throw new TypeError("sWidth must be a non-negative number.");if(!Number.isFinite(p)||p<0)throw new TypeError("sHeight must be a non-negative number.");if(!Number.isFinite(d))throw new TypeError("dx must be a number.");if(!Number.isFinite(g))throw new TypeError("dy must be a number.");if(!Number.isFinite(x)||x<0)throw new TypeError("dWidth must be a non-negative number.");if(!Number.isFinite(y)||y<0)throw new TypeError("dHeight must be a non-negative number.");if(this._closed)throw new Error("VideoSample is closed.");({sx:f,sy:u,sWidth:m,sHeight:p}=this._rotateSourceRegion(f,u,m,p,this.rotation));let v=this.toCanvasImageSource();e.save();let T=d+x/2,S=g+y/2;e.translate(T,S),e.rotate(this.rotation*Math.PI/180);let k=this.rotation%180===0?1:x/y;e.scale(1/k,k),e.drawImage(v,f,u,m,p,-x/2,-y/2,x,y),e.restore()}drawWithFit(e,t){if(!(typeof CanvasRenderingContext2D<"u"&&e instanceof CanvasRenderingContext2D||typeof OffscreenCanvasRenderingContext2D<"u"&&e instanceof OffscreenCanvasRenderingContext2D))throw new TypeError("context must be a CanvasRenderingContext2D or OffscreenCanvasRenderingContext2D.");if(!t||typeof t!="object")throw new TypeError("options must be an object.");if(!["fill","contain","cover"].includes(t.fit))throw new TypeError("options.fit must be 'fill', 'contain', or 'cover'.");if(t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw new TypeError("options.rotation, when provided, must be 0, 90, 180, or 270.");t.crop!==void 0&&Ol(t.crop,"options.");let n=e.canvas.width,o=e.canvas.height,i=t.rotation??this.rotation,[s,a]=i%180===0?[this.codedWidth,this.codedHeight]:[this.codedHeight,this.codedWidth];t.crop&&Dl(t.crop,s,a);let l,c,f,u,{sx:m,sy:p,sWidth:d,sHeight:g}=this._rotateSourceRegion(t.crop?.left??0,t.crop?.top??0,t.crop?.width??s,t.crop?.height??a,i);if(t.fit==="fill")l=0,c=0,f=n,u=o;else{let[y,v]=t.crop?[t.crop.width,t.crop.height]:[s,a],T=t.fit==="contain"?Math.min(n/y,o/v):Math.max(n/y,o/v);f=y*T,u=v*T,l=(n-f)/2,c=(o-u)/2}e.save();let x=i%180===0?1:f/u;e.translate(n/2,o/2),e.rotate(i*Math.PI/180),e.scale(1/x,x),e.translate(-n/2,-o/2),e.drawImage(this.toCanvasImageSource(),m,p,d,g,l,c,f,u),e.restore()}_rotateSourceRegion(e,t,n,o,i){return i===90?[e,t,n,o]=[t,this.codedHeight-e-n,o,n]:i===180?[e,t]=[this.codedWidth-e-n,this.codedHeight-t-o]:i===270&&([e,t,n,o]=[this.codedWidth-t-o,e,o,n]),{sx:e,sy:t,sWidth:n,sHeight:o}}toCanvasImageSource(){if(this._closed)throw new Error("VideoSample is closed.");if(h(this._data!==null),this._data instanceof Uint8Array){let e=this.toVideoFrame();return queueMicrotask(()=>e.close()),e}else return this._data}setRotation(e){if(![0,90,180,270].includes(e))throw new TypeError("newRotation must be 0, 90, 180, or 270.");this.rotation=e}setTimestamp(e){if(!Number.isFinite(e))throw new TypeError("newTimestamp must be a number.");this.timestamp=e}setDuration(e){if(!Number.isFinite(e)||e<0)throw new TypeError("newDuration must be a non-negative number.");this.duration=e}[Symbol.dispose](){this.close()}},gn=class{constructor(e){this.primaries=e?.primaries??null,this.transfer=e?.transfer??null,this.matrix=e?.matrix??null,this.fullRange=e?.fullRange??null}toJSON(){return{primaries:this.primaries,transfer:this.transfer,matrix:this.matrix,fullRange:this.fullRange}}},qt=r=>typeof VideoFrame<"u"&&r instanceof VideoFrame,Dl=(r,e,t)=>{r.left=Math.min(r.left,e),r.top=Math.min(r.top,t),r.width=Math.min(r.width,e-r.left),r.height=Math.min(r.height,t-r.top),h(r.width>=0),h(r.height>=0)},Ol=(r,e)=>{if(!r||typeof r!="object")throw new TypeError(e+"crop, when provided, must be an object.");if(!Number.isInteger(r.left)||r.left<0)throw new TypeError(e+"crop.left must be a non-negative integer.");if(!Number.isInteger(r.top)||r.top<0)throw new TypeError(e+"crop.top must be a non-negative integer.");if(!Number.isInteger(r.width)||r.width<0)throw new TypeError(e+"crop.width must be a non-negative integer.");if(!Number.isInteger(r.height)||r.height<0)throw new TypeError(e+"crop.height must be a non-negative integer.")},El=r=>{if(!r||typeof r!="object")throw new TypeError("options must be an object.");if(r.colorSpace!==void 0&&!["display-p3","srgb"].includes(r.colorSpace))throw new TypeError("options.colorSpace, when provided, must be 'display-p3' or 'srgb'.");if(r.format!==void 0&&typeof r.format!="string")throw new TypeError("options.format, when provided, must be a string.");if(r.layout!==void 0){if(!Array.isArray(r.layout))throw new TypeError("options.layout, when provided, must be an array.");for(let e of r.layout){if(!e||typeof e!="object")throw new TypeError("Each entry in options.layout must be an object.");if(!Number.isInteger(e.offset)||e.offset<0)throw new TypeError("plane.offset must be a non-negative integer.");if(!Number.isInteger(e.stride)||e.stride<0)throw new TypeError("plane.stride must be a non-negative integer.")}}if(r.rect!==void 0){if(!r.rect||typeof r.rect!="object")throw new TypeError("options.rect, when provided, must be an object.");if(r.rect.x!==void 0&&(!Number.isInteger(r.rect.x)||r.rect.x<0))throw new TypeError("options.rect.x, when provided, must be a non-negative integer.");if(r.rect.y!==void 0&&(!Number.isInteger(r.rect.y)||r.rect.y<0))throw new TypeError("options.rect.y, when provided, must be a non-negative integer.");if(r.rect.width!==void 0&&(!Number.isInteger(r.rect.width)||r.rect.width<0))throw new TypeError("options.rect.width, when provided, must be a non-negative integer.");if(r.rect.height!==void 0&&(!Number.isInteger(r.rect.height)||r.rect.height<0))throw new TypeError("options.rect.height, when provided, must be a non-negative integer.")}},Dd=(r,e,t)=>{let n=Od(r),o=[],i=0;for(let s of n){let a=Math.ceil(e/s.widthDivisor),l=Math.ceil(t/s.heightDivisor),c=a*s.sampleBytes,f=c*l;o.push({offset:i,stride:c}),i+=f}return o},Od=r=>{let e=(t,n,o,i,s)=>{let a=[{sampleBytes:t,widthDivisor:1,heightDivisor:1},{sampleBytes:n,widthDivisor:o,heightDivisor:i},{sampleBytes:n,widthDivisor:o,heightDivisor:i}];return s&&a.push({sampleBytes:t,widthDivisor:1,heightDivisor:1}),a};switch(r){case"I420":return e(1,1,2,2,!1);case"I420P10":case"I420P12":return e(2,2,2,2,!1);case"I420A":return e(1,1,2,2,!0);case"I420AP10":case"I420AP12":return e(2,2,2,2,!0);case"I422":return e(1,1,2,1,!1);case"I422P10":case"I422P12":return e(2,2,2,1,!1);case"I422A":return e(1,1,2,1,!0);case"I422AP10":case"I422AP12":return e(2,2,2,1,!0);case"I444":return e(1,1,1,1,!1);case"I444P10":case"I444P12":return e(2,2,1,1,!1);case"I444A":return e(1,1,1,1,!0);case"I444AP10":case"I444AP12":return e(2,2,1,1,!0);case"NV12":return[{sampleBytes:1,widthDivisor:1,heightDivisor:1},{sampleBytes:2,widthDivisor:2,heightDivisor:2}];case"RGBA":case"RGBX":case"BGRA":case"BGRX":return[{sampleBytes:4,widthDivisor:1,heightDivisor:1}];default:Ae(r),h(!1)}},Os=new Set(["f32","f32-planar","s16","s16-planar","s32","s32-planar","u8","u8-planar"]),xr=class r{get microsecondTimestamp(){return Math.trunc(Xe*this.timestamp)}get microsecondDuration(){return Math.trunc(Xe*this.duration)}constructor(e){if(this._closed=!1,hn(e)){if(e.format===null)throw new TypeError("AudioData with null format is not supported.");this._data=e,this.format=e.format,this.sampleRate=e.sampleRate,this.numberOfFrames=e.numberOfFrames,this.numberOfChannels=e.numberOfChannels,this.timestamp=e.timestamp/1e6,this.duration=e.numberOfFrames/e.sampleRate}else{if(!e||typeof e!="object")throw new TypeError("Invalid AudioDataInit: must be an object.");if(!Os.has(e.format))throw new TypeError("Invalid AudioDataInit: invalid format.");if(!Number.isFinite(e.sampleRate)||e.sampleRate<=0)throw new TypeError("Invalid AudioDataInit: sampleRate must be > 0.");if(!Number.isInteger(e.numberOfChannels)||e.numberOfChannels===0)throw new TypeError("Invalid AudioDataInit: numberOfChannels must be an integer > 0.");if(!Number.isFinite(e?.timestamp))throw new TypeError("init.timestamp must be a number.");let t=e.data.byteLength/(Ht(e.format)*e.numberOfChannels);if(!Number.isInteger(t))throw new TypeError("Invalid AudioDataInit: data size is not a multiple of frame size.");this.format=e.format,this.sampleRate=e.sampleRate,this.numberOfFrames=t,this.numberOfChannels=e.numberOfChannels,this.timestamp=e.timestamp,this.duration=t/e.sampleRate;let n;if(e.data instanceof ArrayBuffer)n=new Uint8Array(e.data);else if(ArrayBuffer.isView(e.data))n=new Uint8Array(e.data.buffer,e.data.byteOffset,e.data.byteLength);else throw new TypeError("Invalid AudioDataInit: data is not a BufferSource.");let o=this.numberOfFrames*this.numberOfChannels*Ht(this.format);if(n.byteLength<o)throw new TypeError("Invalid AudioDataInit: insufficient data size.");this._data=n}xn?.register(this,{type:"audio",data:this._data},this)}allocationSize(e){if(!e||typeof e!="object")throw new TypeError("options must be an object.");if(!Number.isInteger(e.planeIndex)||e.planeIndex<0)throw new TypeError("planeIndex must be a non-negative integer.");if(e.format!==void 0&&!Os.has(e.format))throw new TypeError("Invalid format.");if(e.frameOffset!==void 0&&(!Number.isInteger(e.frameOffset)||e.frameOffset<0))throw new TypeError("frameOffset must be a non-negative integer.");if(e.frameCount!==void 0&&(!Number.isInteger(e.frameCount)||e.frameCount<0))throw new TypeError("frameCount must be a non-negative integer.");if(this._closed)throw new Error("AudioSample is closed.");let t=e.format??this.format,n=e.frameOffset??0;if(n>=this.numberOfFrames)throw new RangeError("frameOffset out of range");let o=e.frameCount!==void 0?e.frameCount:this.numberOfFrames-n;if(o>this.numberOfFrames-n)throw new RangeError("frameCount out of range");let i=Ht(t),s=hr(t);if(s&&e.planeIndex>=this.numberOfChannels)throw new RangeError("planeIndex out of range");if(!s&&e.planeIndex!==0)throw new RangeError("planeIndex out of range");return(s?o:o*this.numberOfChannels)*i}copyTo(e,t){if(!lo(e))throw new TypeError("destination must be an ArrayBuffer or an ArrayBuffer view.");if(!t||typeof t!="object")throw new TypeError("options must be an object.");if(!Number.isInteger(t.planeIndex)||t.planeIndex<0)throw new TypeError("planeIndex must be a non-negative integer.");if(t.format!==void 0&&!Os.has(t.format))throw new TypeError("Invalid format.");if(t.frameOffset!==void 0&&(!Number.isInteger(t.frameOffset)||t.frameOffset<0))throw new TypeError("frameOffset must be a non-negative integer.");if(t.frameCount!==void 0&&(!Number.isInteger(t.frameCount)||t.frameCount<0))throw new TypeError("frameCount must be a non-negative integer.");if(this._closed)throw new Error("AudioSample is closed.");let{planeIndex:n,format:o,frameCount:i,frameOffset:s}=t,a=this.format,l=o??this.format;if(!l)throw new Error("Destination format not determined");let c=this.numberOfFrames,f=this.numberOfChannels,u=s??0;if(u>=c)throw new RangeError("frameOffset out of range");let m=i!==void 0?i:c-u;if(m>c-u)throw new RangeError("frameCount out of range");let p=Ht(l),d=hr(l);if(d&&n>=f)throw new RangeError("planeIndex out of range");if(!d&&n!==0)throw new RangeError("planeIndex out of range");let x=(d?m:m*f)*p;if(e.byteLength<x)throw new RangeError("Destination buffer is too small");let y=K(e),v=Ml(l);if(hn(this._data))vt()&&f>2&&l!==a?Rd(this._data,y,a,l,f,n,u,m):this._data.copyTo(e,{planeIndex:n,frameOffset:u,frameCount:m,format:l});else{let T=this._data,S=K(T),k=Rl(a),C=Ht(a),O=hr(a);for(let E=0;E<m;E++)if(d){let V=E*p,q;O?q=(n*c+(E+u))*C:q=((E+u)*f+n)*C;let G=k(S,q);v(y,V,G)}else for(let V=0;V<f;V++){let G=(E*f+V)*p,ie;O?ie=(V*c+(E+u))*C:ie=((E+u)*f+V)*C;let Ue=k(S,ie);v(y,G,Ue)}}}clone(){if(this._closed)throw new Error("AudioSample is closed.");if(hn(this._data)){let e=new r(this._data.clone());return e.setTimestamp(this.timestamp),e}else return new r({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.timestamp,data:this._data})}close(){this._closed||(xn?.unregister(this),hn(this._data)?this._data.close():this._data=new Uint8Array(0),this._closed=!0)}toAudioData(){if(this._closed)throw new Error("AudioSample is closed.");if(hn(this._data)){if(this._data.timestamp===this.microsecondTimestamp)return this._data.clone();if(hr(this.format)){let e=this.allocationSize({planeIndex:0,format:this.format}),t=new ArrayBuffer(e*this.numberOfChannels);for(let n=0;n<this.numberOfChannels;n++)this.copyTo(new Uint8Array(t,n*e,e),{planeIndex:n,format:this.format});return new AudioData({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.microsecondTimestamp,data:t})}else{let e=new ArrayBuffer(this.allocationSize({planeIndex:0,format:this.format}));return this.copyTo(e,{planeIndex:0,format:this.format}),new AudioData({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.microsecondTimestamp,data:e})}}else return new AudioData({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.microsecondTimestamp,data:this._data.buffer instanceof ArrayBuffer?this._data.buffer:this._data.slice()})}toAudioBuffer(){if(this._closed)throw new Error("AudioSample is closed.");let e=new AudioBuffer({numberOfChannels:this.numberOfChannels,length:this.numberOfFrames,sampleRate:this.sampleRate}),t=new Float32Array(this.allocationSize({planeIndex:0,format:"f32-planar"})/4);for(let n=0;n<this.numberOfChannels;n++)this.copyTo(t,{planeIndex:n,format:"f32-planar"}),e.copyToChannel(t,n);return e}setTimestamp(e){if(!Number.isFinite(e))throw new TypeError("newTimestamp must be a number.");this.timestamp=e}[Symbol.dispose](){this.close()}static*_fromAudioBuffer(e,t){if(!(e instanceof AudioBuffer))throw new TypeError("audioBuffer must be an AudioBuffer.");let n=48e3*5,o=e.numberOfChannels,i=e.sampleRate,s=e.length,a=Math.floor(n/o),l=0,c=s;for(;c>0;){let f=Math.min(a,c),u=new Float32Array(o*f);for(let m=0;m<o;m++)e.copyFromChannel(u.subarray(m*f,(m+1)*f),m,l);yield new r({format:"f32-planar",sampleRate:i,numberOfFrames:f,numberOfChannels:o,timestamp:t+l/i,data:u}),l+=f,c-=f}}static fromAudioBuffer(e,t){if(!(e instanceof AudioBuffer))throw new TypeError("audioBuffer must be an AudioBuffer.");let n=48e3*5,o=e.numberOfChannels,i=e.sampleRate,s=e.length,a=Math.floor(n/o),l=0,c=s,f=[];for(;c>0;){let u=Math.min(a,c),m=new Float32Array(o*u);for(let d=0;d<o;d++)e.copyFromChannel(m.subarray(d*u,(d+1)*u),d,l);let p=new r({format:"f32-planar",sampleRate:i,numberOfFrames:u,numberOfChannels:o,timestamp:t+l/i,data:m});f.push(p),l+=u,c-=u}return f}},Ht=r=>{switch(r){case"u8":case"u8-planar":return 1;case"s16":case"s16-planar":return 2;case"s32":case"s32-planar":return 4;case"f32":case"f32-planar":return 4;default:throw new Error("Unknown AudioSampleFormat")}},hr=r=>{switch(r){case"u8-planar":case"s16-planar":case"s32-planar":case"f32-planar":return!0;default:return!1}},Rl=r=>{switch(r){case"u8":case"u8-planar":return(e,t)=>(e.getUint8(t)-128)/128;case"s16":case"s16-planar":return(e,t)=>e.getInt16(t,!0)/32768;case"s32":case"s32-planar":return(e,t)=>e.getInt32(t,!0)/2147483648;case"f32":case"f32-planar":return(e,t)=>e.getFloat32(t,!0)}},Ml=r=>{switch(r){case"u8":case"u8-planar":return(e,t,n)=>e.setUint8(t,Mt((n+1)*127.5,0,255));case"s16":case"s16-planar":return(e,t,n)=>e.setInt16(t,Mt(Math.round(n*32767),-32768,32767),!0);case"s32":case"s32-planar":return(e,t,n)=>e.setInt32(t,Mt(Math.round(n*2147483647),-2147483648,2147483647),!0);case"f32":case"f32-planar":return(e,t,n)=>e.setFloat32(t,n,!0)}},hn=r=>typeof AudioData<"u"&&r instanceof AudioData,Rd=(r,e,t,n,o,i,s,a)=>{let l=Rl(t),c=Ml(n),f=Ht(t),u=Ht(n),m=hr(t);if(hr(n))if(m){let d=new ArrayBuffer(a*f),g=K(d);r.copyTo(d,{planeIndex:i,frameOffset:s,frameCount:a,format:t});for(let x=0;x<a;x++){let y=x*f,v=x*u,T=l(g,y);c(e,v,T)}}else{let d=new ArrayBuffer(a*o*f),g=K(d);r.copyTo(d,{planeIndex:0,frameOffset:s,frameCount:a,format:t});for(let x=0;x<a;x++){let y=(x*o+i)*f,v=x*u,T=l(g,y);c(e,v,T)}}else if(m){let d=a*f,g=new ArrayBuffer(d),x=K(g);for(let y=0;y<o;y++){r.copyTo(g,{planeIndex:y,frameOffset:s,frameCount:a,format:t});for(let v=0;v<a;v++){let T=v*f,S=(v*o+y)*u,k=l(x,T);c(e,S,k)}}}else{let d=new ArrayBuffer(a*o*f),g=K(d);r.copyTo(d,{planeIndex:0,frameOffset:s,frameCount:a,format:t});for(let x=0;x<a;x++)for(let y=0;y<o;y++){let v=x*o+y,T=v*f,S=v*u,k=l(g,T);c(e,S,k)}}};var vr=r=>{if(!r||typeof r!="object")throw new TypeError("options must be an object.");if(r.metadataOnly!==void 0&&typeof r.metadataOnly!="boolean")throw new TypeError("options.metadataOnly, when defined, must be a boolean.");if(r.verifyKeyPackets!==void 0&&typeof r.verifyKeyPackets!="boolean")throw new TypeError("options.verifyKeyPackets, when defined, must be a boolean.");if(r.verifyKeyPackets&&r.metadataOnly)throw new TypeError("options.verifyKeyPackets and options.metadataOnly cannot be enabled together.")},Wt=r=>{if(!mn(r))throw new TypeError("timestamp must be a number.")},Rs=(r,e,t)=>t.verifyKeyPackets?e.then(async n=>{if(!n||n.type==="delta")return n;let o=await r.determinePacketType(n);return o&&(n.type=o),n}):e,jt=class{constructor(e){if(!(e instanceof yr))throw new TypeError("track must be an InputTrack.");this._track=e}getFirstPacket(e={}){if(vr(e),this._track.input._disposed)throw new ce;return Rs(this._track,this._track._backing.getFirstPacket(e),e)}getPacket(e,t={}){if(Wt(e),vr(t),this._track.input._disposed)throw new ce;return Rs(this._track,this._track._backing.getPacket(e,t),t)}getNextPacket(e,t={}){if(!(e instanceof te))throw new TypeError("packet must be an EncodedPacket.");if(vr(t),this._track.input._disposed)throw new ce;return Rs(this._track,this._track._backing.getNextPacket(e,t),t)}async getKeyPacket(e,t={}){if(Wt(e),vr(t),this._track.input._disposed)throw new ce;if(!t.verifyKeyPackets)return this._track._backing.getKeyPacket(e,t);let n=await this._track._backing.getKeyPacket(e,t);return n&&(h(n.type==="key"),await this._track.determinePacketType(n)==="delta"?this.getKeyPacket(n.timestamp-1/this._track.timeResolution,t):n)}async getNextKeyPacket(e,t={}){if(!(e instanceof te))throw new TypeError("packet must be an EncodedPacket.");if(vr(t),this._track.input._disposed)throw new ce;if(!t.verifyKeyPackets)return this._track._backing.getNextKeyPacket(e,t);let n=await this._track._backing.getNextKeyPacket(e,t);return n&&(h(n.type==="key"),await this._track.determinePacketType(n)==="delta"?this.getNextKeyPacket(n,t):n)}packets(e,t,n={}){if(e!==void 0&&!(e instanceof te))throw new TypeError("startPacket must be an EncodedPacket.");if(e!==void 0&&e.isMetadataOnly&&!n?.metadataOnly)throw new TypeError("startPacket can only be metadata-only if options.metadataOnly is enabled.");if(t!==void 0&&!(t instanceof te))throw new TypeError("endPacket must be an EncodedPacket.");if(vr(n),this._track.input._disposed)throw new ce;let o=[],{promise:i,resolve:s}=ve(),{promise:a,resolve:l}=ve(),c=!1,f=!1,u=null,m=[],p=()=>Math.max(2,m.length);(async()=>{let g=e??await this.getFirstPacket(n);for(;g&&!f&&!this._track.input._disposed&&!(t&&g.sequenceNumber>=t?.sequenceNumber);){if(o.length>p()){({promise:a,resolve:l}=ve()),await a;continue}o.push(g),s(),{promise:i,resolve:s}=ve(),g=await this.getNextPacket(g,n)}c=!0,s()})().catch(g=>{u||(u=g,s())});let d=this._track;return{async next(){for(;;){if(d.input._disposed)throw new ce;if(f)return{value:void 0,done:!0};if(u)throw u;if(o.length>0){let g=o.shift(),x=performance.now();for(m.push(x);m.length>0&&x-m[0]>=1e3;)m.shift();return l(),{value:g,done:!1}}else{if(c)return{value:void 0,done:!0};await i}}},async return(){return f=!0,l(),s(),{value:void 0,done:!0}},async throw(g){throw g},[Symbol.asyncIterator](){return this}}}},vn=class{constructor(e,t){this.onSample=e,this.onError=t}},yn=class{mediaSamplesInRange(e=0,t=1/0){Wt(e),Wt(t);let n=[],o=!1,i=null,{promise:s,resolve:a}=ve(),{promise:l,resolve:c}=ve(),f=!1,u=!1,m=!1,p=null;(async()=>{let x=await this._createDecoder(C=>{if(c(),C.timestamp>=t&&(u=!0),u){C.close();return}i&&(C.timestamp>e?(n.push(i),o=!0):i.close()),C.timestamp>=e&&(n.push(C),o=!0),i=o?null:C,n.length>0&&(a(),{promise:s,resolve:a}=ve())},C=>{p||(p=C,a())}),y=this._createPacketSink(),v=await y.getKeyPacket(e,{verifyKeyPackets:!0})??await y.getFirstPacket(),T=v,S;if(t<1/0){let C=await y.getPacket(t),O=C?C.type==="key"&&C.timestamp===t?C:await y.getNextKeyPacket(C,{verifyKeyPackets:!0}):null;O&&(S=O)}let k=y.packets(v??void 0,S);for(await k.next();T&&!u&&!this._track.input._disposed;){let C=Bl(n.length);if(n.length+x.getDecodeQueueSize()>C){({promise:l,resolve:c}=ve()),await l;continue}x.decode(T);let O=await k.next();if(O.done)break;T=O.value}await k.return(),!m&&!this._track.input._disposed&&await x.flush(),x.close(),!o&&i&&n.push(i),f=!0,a()})().catch(x=>{p||(p=x,a())});let d=this._track,g=()=>{i?.close();for(let x of n)x.close()};return{async next(){for(;;){if(d.input._disposed)throw g(),new ce;if(m)return{value:void 0,done:!0};if(p)throw g(),p;if(n.length>0){let x=n.shift();return c(),{value:x,done:!1}}else if(!f)await s;else return{value:void 0,done:!0}}},async return(){return m=!0,u=!0,c(),a(),g(),{value:void 0,done:!0}},async throw(x){throw x},[Symbol.asyncIterator](){return this}}}mediaSamplesAtTimestamps(e){al(e);let t=sl(e),n=[],o=[],{promise:i,resolve:s}=ve(),{promise:a,resolve:l}=ve(),c=!1,f=!1,u=null,m=g=>{o.push(g),s(),{promise:i,resolve:s}=ve()};(async()=>{let g=await this._createDecoder(C=>{if(l(),f){C.close();return}let O=0;for(;n.length>0&&C.timestamp-n[0]>-1e-10;)O++,n.shift();if(O>0)for(let E=0;E<O;E++)m(E<O-1?C.clone():C);else C.close()},C=>{u||(u=C,s())}),x=this._createPacketSink(),y=null,v=null,T=-1,S=async()=>{h(v);let C=v;for(g.decode(C);C.sequenceNumber<T;){let O=Bl(o.length);for(;o.length+g.getDecodeQueueSize()>O&&!f;)({promise:a,resolve:l}=ve()),await a;if(f)break;let E=await x.getNextPacket(C);h(E),g.decode(E),C=E}T=-1},k=async()=>{await g.flush();for(let C=0;C<n.length;C++)m(null);n.length=0};for await(let C of t){if(Wt(C),f||this._track.input._disposed)break;let O=await x.getPacket(C),E=O&&await x.getKeyPacket(C,{verifyKeyPackets:!0});if(!E){T!==-1&&(await S(),await k()),m(null),y=null;continue}y&&(E.sequenceNumber!==v.sequenceNumber||O.timestamp<y.timestamp)&&(await S(),await k()),n.push(O.timestamp),T=Math.max(O.sequenceNumber,T),y=O,v=E}!f&&!this._track.input._disposed&&(T!==-1&&await S(),await k()),g.close(),c=!0,s()})().catch(g=>{u||(u=g,s())});let p=this._track,d=()=>{for(let g of o)g?.close()};return{async next(){for(;;){if(p.input._disposed)throw d(),new ce;if(f)return{value:void 0,done:!0};if(u)throw d(),u;if(o.length>0){let g=o.shift();return h(g!==void 0),l(),{value:g,done:!1}}else if(!c)await i;else return{value:void 0,done:!0}}},async return(){return f=!0,l(),s(),d(),{value:void 0,done:!0}},async throw(g){throw g},[Symbol.asyncIterator](){return this}}}},Bl=r=>r===0?40:8,Ms=class extends vn{constructor(e,t,n,o,i,s){super(e,t),this.codec=n,this.decoderConfig=o,this.rotation=i,this.timeResolution=s,this.decoder=null,this.customDecoder=null,this.customDecoderCallSerializer=new un,this.customDecoderQueueSize=0,this.inputTimestamps=[],this.sampleQueue=[],this.currentPacketIndex=0,this.raslSkipped=!1,this.alphaDecoder=null,this.alphaHadKeyframe=!1,this.colorQueue=[],this.alphaQueue=[],this.merger=null,this.mergerCreationFailed=!1,this.decodedAlphaChunkCount=0,this.alphaDecoderQueueSize=0,this.nullAlphaFrameQueue=[],this.currentAlphaPacketIndex=0,this.alphaRaslSkipped=!1;let a=wo.find(l=>l.supports(n,o));if(a)this.customDecoder=new a,this.customDecoder.codec=n,this.customDecoder.config=o,this.customDecoder.onSample=l=>{if(!(l instanceof gr))throw new TypeError("The argument passed to onSample must be a VideoSample.");this.finalizeAndEmitSample(l)},this.customDecoderCallSerializer.call(()=>this.customDecoder.init());else{let l=f=>{if(this.alphaQueue.length>0){let u=this.alphaQueue.shift();h(u!==void 0),this.mergeAlpha(f,u)}else this.colorQueue.push(f)};if(n==="avc"&&this.decoderConfig.description&&fn()){let f=Sl(ze(this.decoderConfig.description));if(f&&f.sequenceParameterSets.length>0){let u=zs(f.sequenceParameterSets[0]);u&&u.frameMbsOnlyFlag===0&&(this.decoderConfig={...this.decoderConfig,hardwareAcceleration:"prefer-software"})}}let c=new Error("Decoding error").stack;this.decoder=new VideoDecoder({output:f=>{try{l(f)}catch(u){this.onError(u)}},error:f=>{f.stack=c,this.onError(f)}}),this.decoder.configure(this.decoderConfig)}}getDecodeQueueSize(){return this.customDecoder?this.customDecoderQueueSize:(h(this.decoder),Math.max(this.decoder.decodeQueueSize,this.alphaDecoder?.decodeQueueSize??0))}decode(e){if(this.codec==="hevc"&&this.currentPacketIndex>0&&!this.raslSkipped){if(this.hasHevcRaslPicture(e.data))return;this.raslSkipped=!0}if(this.customDecoder)this.customDecoderQueueSize++,this.customDecoderCallSerializer.call(()=>this.customDecoder.decode(e)).then(()=>this.customDecoderQueueSize--);else{if(h(this.decoder),vt()||ws(this.inputTimestamps,e.timestamp,t=>t),fn()&&this.currentPacketIndex===0&&this.codec==="avc"){let n=Es(e.data,this.decoderConfig).filter(i=>{let s=Gt(i);return!(s>=20&&s<=31)}),o=yl(n,this.decoderConfig);e=new te(o,e.type,e.timestamp,e.duration)}this.decoder.decode(e.toEncodedVideoChunk()),this.decodeAlphaData(e)}this.currentPacketIndex++}decodeAlphaData(e){if(!e.sideData.alpha||this.mergerCreationFailed){this.pushNullAlphaFrame();return}if(!this.merger)try{this.merger=new Bs}catch(n){console.error("Due to an error, only color data will be decoded.",n),this.mergerCreationFailed=!0,this.decodeAlphaData(e);return}if(!this.alphaDecoder){let n=i=>{if(this.alphaDecoderQueueSize--,this.colorQueue.length>0){let s=this.colorQueue.shift();h(s!==void 0),this.mergeAlpha(s,i)}else this.alphaQueue.push(i);for(this.decodedAlphaChunkCount++;this.nullAlphaFrameQueue.length>0&&this.nullAlphaFrameQueue[0]===this.decodedAlphaChunkCount;)if(this.nullAlphaFrameQueue.shift(),this.colorQueue.length>0){let s=this.colorQueue.shift();h(s!==void 0),this.mergeAlpha(s,null)}else this.alphaQueue.push(null)},o=new Error("Decoding error").stack;this.alphaDecoder=new VideoDecoder({output:i=>{try{n(i)}catch(s){this.onError(s)}},error:i=>{i.stack=o,this.onError(i)}}),this.alphaDecoder.configure(this.decoderConfig)}let t=To(this.codec,this.decoderConfig,e.sideData.alpha);if(this.alphaHadKeyframe||(this.alphaHadKeyframe=t==="key"),this.alphaHadKeyframe){if(this.codec==="hevc"&&this.currentAlphaPacketIndex>0&&!this.alphaRaslSkipped){if(this.hasHevcRaslPicture(e.sideData.alpha)){this.pushNullAlphaFrame();return}this.alphaRaslSkipped=!0}this.currentAlphaPacketIndex++,this.alphaDecoder.decode(e.alphaToEncodedVideoChunk(t??e.type)),this.alphaDecoderQueueSize++}else this.pushNullAlphaFrame()}pushNullAlphaFrame(){this.alphaDecoderQueueSize===0?this.alphaQueue.push(null):this.nullAlphaFrameQueue.push(this.decodedAlphaChunkCount+this.alphaDecoderQueueSize)}hasHevcRaslPicture(e){return Ds(e,this.decoderConfig).some(n=>{let o=rt(n);return o===ye.RASL_N||o===ye.RASL_R})}sampleHandler(e){if(vt()){if(this.sampleQueue.length>0&&e.timestamp>=xe(this.sampleQueue).timestamp){for(let t of this.sampleQueue)this.finalizeAndEmitSample(t);this.sampleQueue.length=0}ws(this.sampleQueue,e,t=>t.timestamp)}else{let t=this.inputTimestamps.shift();h(t!==void 0),e.setTimestamp(t),this.finalizeAndEmitSample(e)}}finalizeAndEmitSample(e){e.setTimestamp(Math.round(e.timestamp*this.timeResolution)/this.timeResolution),e.setDuration(Math.round(e.duration*this.timeResolution)/this.timeResolution),e.setRotation(this.rotation),this.onSample(e)}mergeAlpha(e,t){if(!t){let i=new gr(e);this.sampleHandler(i);return}h(this.merger),this.merger.update(e,t),e.close(),t.close();let n=new VideoFrame(this.merger.canvas,{timestamp:e.timestamp,duration:e.duration??void 0}),o=new gr(n);this.sampleHandler(o)}async flush(){if(this.customDecoder?await this.customDecoderCallSerializer.call(()=>this.customDecoder.flush()):(h(this.decoder),await Promise.all([this.decoder.flush(),this.alphaDecoder?.flush()]),this.colorQueue.forEach(e=>e.close()),this.colorQueue.length=0,this.alphaQueue.forEach(e=>e?.close()),this.alphaQueue.length=0,this.alphaHadKeyframe=!1,this.decodedAlphaChunkCount=0,this.alphaDecoderQueueSize=0,this.nullAlphaFrameQueue.length=0,this.currentAlphaPacketIndex=0,this.alphaRaslSkipped=!1),vt()){for(let e of this.sampleQueue)this.finalizeAndEmitSample(e);this.sampleQueue.length=0}this.currentPacketIndex=0,this.raslSkipped=!1}close(){this.customDecoder?this.customDecoderCallSerializer.call(()=>this.customDecoder.close()):(h(this.decoder),this.decoder.close(),this.alphaDecoder?.close(),this.colorQueue.forEach(e=>e.close()),this.colorQueue.length=0,this.alphaQueue.forEach(e=>e?.close()),this.alphaQueue.length=0,this.merger?.close());for(let e of this.sampleQueue)e.close();this.sampleQueue.length=0}},Bs=class{constructor(){typeof OffscreenCanvas<"u"?this.canvas=new OffscreenCanvas(300,150):this.canvas=document.createElement("canvas");let e=this.canvas.getContext("webgl2",{premultipliedAlpha:!1});if(!e)throw new Error("Couldn't acquire WebGL 2 context.");this.gl=e,this.program=this.createProgram(),this.vao=this.createVAO(),this.colorTexture=this.createTexture(),this.alphaTexture=this.createTexture(),this.gl.useProgram(this.program),this.gl.uniform1i(this.gl.getUniformLocation(this.program,"u_colorTexture"),0),this.gl.uniform1i(this.gl.getUniformLocation(this.program,"u_alphaTexture"),1)}createProgram(){let e=this.createShader(this.gl.VERTEX_SHADER,`#version 300 es
|
|
2338
|
+
`)):console.error(r)}async function is(r){for(let e of r.outputs)e instanceof Dt?await os(e.line):await ns(e.line);rs(r.code)}function ss(r,e){let{verbose:t,theme:{icons:n,colors:o}}=e,i=[...r.experiments.values()].filter(S=>S.fail),s=[...r.experiments.values()].filter(S=>!S.fail),a=r.tubes.length,l=s.length,c=i.length,f=r.tubes.filter(S=>S.skip).length,u=r.tubes.filter(S=>S.only).length,m=[],p=S=>m.push(new an(S)),d=S=>m.push(new Dt(S)),g=0;function x(S,k){let C=S.only?o.only(` ${n.only} [ONLY]`):S.skip?o.skip(` ${n.skip} [SKIP]`):"";return k&&k.fail?o.errorLabel(n.testFail)+C:k?o.successLabel(n.testSuccess)+C:o.neutral(n.testNeutral)+C}function y(S,k){g+=1;let C=S.path,O=o.errorLabel(S.label),E=[...C.map(o.errorPath),O].join(o.errorGrammar(n.pathSeparator)),V=o.errorMessage(k.fail??"unknown fail"),q=o.errorTime(`${n.timeSeparator}${tn(k.time)}`),G=x(S,k);d(`${G} ${E}${o.errorGrammar(n.messageSeparator)}${V}${q}`)}function v(S,k){g+=1;let C=S.path,O=o.successLabel(S.label),E=[...C.map(o.successPath),O].join(o.successGrammar(n.pathSeparator)),V=o.successTime(`${n.timeSeparator}${tn(k.time)}`),q=x(S,k);p(`${q} ${E}${V}`)}function T(S){g+=1;let k=S.path,C=o.neutralLabel(S.label),O=[...k.map(o.neutral),C].join(o.neutral(n.pathSeparator)),E=x(S,void 0);p(`${E} ${O}`)}for(let S of r.tubes){let k=r.experiments.get(S);k?k.fail?y(S,k):t&&v(S,k):t&&T(S)}if(g>0&&p(""),u){let S=a-u;p(o.only(`${n.only} only ran ${u} test${jn(u)} (${S} ignored)`))}else f&&p(o.skip(`${n.skip} skipped ${f} test${jn(f)}`));if(c===0){let S=o.successSuite(n.suiteSuccess),k=o.successLabel(`${l} happy tests`),C=o.successTime(`- ${tn(r.time)}`);p(`${S} ${k} ${C}`)}else{let S=o.errorSuite(n.suiteFail),k=o.errorSuite(`${c} failure${jn(c)}`),C=o.errorDidnt(`(${l} succeeded)`),O=o.errorTime(`- ${tn(r.time)}`);d(`${S} ${k} ${C} ${O}`)}return{execution:r,outputs:m,code:c>0?1:0}}function fd(r){return r}var pr={plain:{colors:{skip:M.none,only:M.none,neutral:M.none,neutralLabel:M.none,successSuite:M.none,successPath:M.none,successGrammar:M.none,successLabel:M.none,successTime:M.none,errorSuite:M.none,errorDidnt:M.none,errorPath:M.none,errorLabel:M.none,errorGrammar:M.none,errorMessage:M.none,errorTime:M.none},icons:{skip:"\u23ED",only:"*",testFail:"\u2718 ",testSuccess:" \u2022",testNeutral:" \u2022",suiteFail:"FAIL!!",suiteSuccess:"good:",timeSeparator:" - ",pathSeparator:" > ",messageSeparator:" :: "}},redgreen:{colors:{skip:M.yellow,only:M.yellow,neutral:r=>M.dim(M.white(r)),neutralLabel:M.white,successSuite:M.brightGreen,successPath:M.green,successGrammar:r=>M.dim(M.green(r)),successLabel:r=>M.bold(M.brightGreen(r)),successTime:r=>M.dim(M.green(r)),errorSuite:M.brightRed,errorDidnt:M.red,errorPath:M.red,errorLabel:r=>M.bold(M.brightRed(r)),errorGrammar:r=>M.dim(M.red(r)),errorMessage:M.red,errorTime:r=>M.dim(M.red(r))},icons:{skip:"\u{1F47B}",only:"\u{1F6A7}",testFail:"\u274C",testSuccess:" \u2022",testNeutral:" \u2022",suiteFail:"\u{1F525}",suiteSuccess:"\u2705",timeSeparator:" - ",pathSeparator:" > ",messageSeparator:" :: "}},seaside:{colors:{skip:M.yellow,only:M.yellow,neutral:r=>M.dim(M.white(r)),neutralLabel:M.white,successSuite:M.brightBlue,successPath:M.blue,successGrammar:r=>M.dim(M.blue(r)),successLabel:r=>M.bold(M.brightBlue(r)),successTime:r=>M.dim(M.blue(r)),errorSuite:M.brightRed,errorDidnt:M.red,errorPath:M.red,errorLabel:r=>M.bold(M.brightRed(r)),errorGrammar:r=>M.dim(M.red(r)),errorMessage:M.red,errorTime:r=>M.dim(M.red(r))},icons:{skip:"\u{1F47B}",only:"\u{1F6A7}",testFail:"\u274C",testSuccess:" \u2022",testNeutral:" \u2022",suiteFail:"\u{1F525}",suiteSuccess:"\u2705",timeSeparator:" - ",pathSeparator:" > ",messageSeparator:" :: "}}};function md(r){let e=[];function t(...n){let o=r(...n);return o!=null&&typeof o.then=="function"?o.then(i=>(e.push({args:n,ret:i}),i)):(e.push({args:n,ret:o}),o)}return t.spy={calls:e,get args(){return e.map(n=>n.args)},get rets(){return e.map(n=>n.ret)}},t}var Qa=r=>({verbose:r.verbose??(Kn("--verbose")||Yn("--verbose")==="1"||Kn("-v")||Qn("SCIENCE_VERBOSE")==="1"),theme:r.theme??(()=>{let e=Yn("--theme")||Qn("SCIENCE_THEME");if(e){let t=pr[e];if(!t)throw new Error(`theme not found "${e}"`);return t}return pr.redgreen})()});var Za=r=>({...r,colors:ts()?r.colors:pr.plain.colors});async function pd(r,e={}){let{verbose:t,theme:n}=Qa(e),o=Za(n),i=await es(r),s=ss(i,{verbose:t,theme:o});await is(s)}function ln(r){return r}ln.only=r=>(r[be]={kind:"only"},r);ln.skip=r=>(r[be]={kind:"skip"},r);function as(r){return r}as.only=r=>(r[be]={kind:"only"},r);as.skip=r=>(r[be]={kind:"skip"},r);var dr=Object.freeze({eq(r,e){if(r.length!==e.length)return!1;for(let t=0;t<=r.length;t++)if(r.at(t)!==e.at(t))return!1;return!0},random(r){return crypto.getRandomValues(new Uint8Array(r))}});var he=class{lexicon;static lexicons=Object.freeze({base2:{characters:"01"},hex:{characters:"0123456789abcdef"},base36:{characters:"0123456789abcdefghijklmnopqrstuvwxyz"},base58:{characters:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"},base62:{characters:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"},base64url:{negativePrefix:"~",characters:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"},base64:{characters:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",padding:{character:"=",size:4}}});lookup;negativePrefix;constructor(e){this.lexicon=e,this.lookup=Object.fromEntries([...e.characters].map((t,n)=>[t,n])),this.negativePrefix=e.negativePrefix??"-"}toBytes(e){let t=Math.log2(this.lexicon.characters.length);if(Number.isInteger(t)){let a=0,l=0,c=[];for(let f of e){if(f===this.lexicon.padding?.character)continue;let u=this.lookup[f];if(u===void 0)throw new Error(`Invalid character: ${f}`);for(a=a<<t|u,l+=t;l>=8;)l-=8,c.push(a>>l&255)}return new Uint8Array(c)}let n=0n,o=BigInt(this.lexicon.characters.length),i=!1;e.startsWith(this.negativePrefix)&&(e=e.slice(this.negativePrefix.length),i=!0);for(let a of e){let l=this.lookup[a];if(l===void 0)throw new Error(`Invalid character: ${a}`);n=n*o+BigInt(l)}let s=[];for(;n>0n;)s.unshift(Number(n%256n)),n=n/256n;return new Uint8Array(s)}fromBytes(e){let t=Math.log2(this.lexicon.characters.length);if(Number.isInteger(t)){let s=0,a=0,l="";for(let c of e)for(s=s<<8|c,a+=8;a>=t;){a-=t;let f=s>>a&(1<<t)-1;l+=this.lexicon.characters[f]}if(a>0){let c=s<<t-a&(1<<t)-1;l+=this.lexicon.characters[c]}if(this.lexicon.padding)for(;l.length%this.lexicon.padding.size!==0;)l+=this.lexicon.padding.character;return l}let n=0n;for(let s of e)n=(n<<8n)+BigInt(s);if(n===0n)return this.lexicon.characters[0];let o=BigInt(this.lexicon.characters.length),i="";for(;n>0n;)i=this.lexicon.characters[Number(n%o)]+i,n=n/o;return i}toInteger(e){if(!e)return 0;let t=0n,n=!1,o=BigInt(this.lexicon.characters.length);e.startsWith(this.negativePrefix)&&(e=e.slice(this.negativePrefix.length),n=!0);for(let i of e){let s=this.lookup[i];if(s===void 0)throw new Error(`Invalid character: ${i}`);t=t*o+BigInt(s)}return Number(n?-t:t)}fromInteger(e){e=Math.floor(e);let t=e<0,n=BigInt(t?-e:e);if(n===0n)return this.lexicon.characters[0];let o=BigInt(this.lexicon.characters.length),i="";for(;n>0n;)i=this.lexicon.characters[Number(n%o)]+i,n=n/o;return t?`${this.negativePrefix}${i}`:i}random(e=32){return this.fromBytes(dr.random(e))}};var Ve=new he(he.lexicons.hex),ex=new he(he.lexicons.base2),tx=new he(he.lexicons.base36),ls=new he(he.lexicons.base58),rx=new he(he.lexicons.base62),nx=new he(he.lexicons.base64),ox=new he(he.lexicons.base64url);var cs=["doz","mar","bin","wan","sam","lit","sig","hid","fid","lis","sog","dir","wac","sab","wis","sib","rig","sol","dop","mod","fog","lid","hop","dar","dor","lor","hod","fol","rin","tog","sil","mir","hol","pas","lac","rov","liv","dal","sat","lib","tab","han","tic","pid","tor","bol","fos","dot","los","dil","for","pil","ram","tir","win","tad","bic","dif","roc","wid","bis","das","mid","lop","ril","nar","dap","mol","san","loc","nov","sit","nid","tip","sic","rop","wit","nat","pan","min","rit","pod","mot","tam","tol","sav","pos","nap","nop","som","fin","fon","ban","mor","wor","sip","ron","nor","bot","wic","soc","wat","dol","mag","pic","dav","bid","bal","tim","tas","mal","lig","siv","tag","pad","sal","div","dac","tan","sid","fab","tar","mon","ran","nis","wol","mis","pal","las","dis","map","rab","tob","rol","lat","lon","nod","nav","fig","nom","nib","pag","sop","ral","bil","had","doc","rid","moc","pac","rav","rip","fal","tod","til","tin","hap","mic","fan","pat","tac","lab","mog","sim","son","pin","lom","ric","tap","fir","has","bos","bat","poc","hac","tid","hav","sap","lin","dib","hos","dab","bit","bar","rac","par","lod","dos","bor","toc","hil","mac","tom","dig","fil","fas","mit","hob","har","mig","hin","rad","mas","hal","rag","lag","fad","top","mop","hab","nil","nos","mil","fop","fam","dat","nol","din","hat","nac","ris","fot","rib","hoc","nim","lar","fit","wal","rap","sar","nal","mos","lan","don","dan","lad","dov","riv","bac","pol","lap","tal","pit","nam","bon","ros","ton","fod","pon","sov","noc","sor","lav","mat","mip","fip"];var us=["zod","nec","bud","wes","sev","per","sut","let","ful","pen","syt","dur","wep","ser","wyl","sun","ryp","syx","dyr","nup","heb","peg","lup","dep","dys","put","lug","hec","ryt","tyv","syd","nex","lun","mep","lut","sep","pes","del","sul","ped","tem","led","tul","met","wen","byn","hex","feb","pyl","dul","het","mev","rut","tyl","wyd","tep","bes","dex","sef","wyc","bur","der","nep","pur","rys","reb","den","nut","sub","pet","rul","syn","reg","tyd","sup","sem","wyn","rec","meg","net","sec","mul","nym","tev","web","sum","mut","nyx","rex","teb","fus","hep","ben","mus","wyx","sym","sel","ruc","dec","wex","syr","wet","dyl","myn","mes","det","bet","bel","tux","tug","myr","pel","syp","ter","meb","set","dut","deg","tex","sur","fel","tud","nux","rux","ren","wyt","nub","med","lyt","dus","neb","rum","tyn","seg","lyx","pun","res","red","fun","rev","ref","mec","ted","rus","bex","leb","dux","ryn","num","pyx","ryg","ryx","fep","tyr","tus","tyc","leg","nem","fer","mer","ten","lus","nus","syl","tec","mex","pub","rym","tuc","fyl","lep","deb","ber","mug","hut","tun","byl","sud","pem","dev","lur","def","bus","bep","run","mel","pex","dyt","byt","typ","lev","myl","wed","duc","fur","fex","nul","luc","len","ner","lex","rup","ned","lec","ryd","lyd","fen","wel","nyd","hus","rel","rud","nes","hes","fet","des","ret","dun","ler","nyr","seb","hul","ryl","lud","rem","lys","fyn","wer","ryc","sug","nys","nyl","lyn","dyn","dem","lux","fed","sed","bec","mun","lyr","tes","mud","nyt","byr","sen","weg","fyr","mur","tel","rep","teg","pec","nel","nev","fes"];var et={defaults:{groupSize:4,wordSeparator:".",groupSeparator:" "},random(r,e){let t=dr.random(r);return this.fromBytes(t,e)},fromBytes(r,e={}){let{groupSize:t=et.defaults.groupSize,wordSeparator:n=et.defaults.wordSeparator,groupSeparator:o=et.defaults.groupSeparator}=e,i=[],s=[];r.forEach((l,c)=>{let f=c%2===0?cs:us;s.push(f[l]),s.length===2&&(i.push(s.join("")),s=[])}),s.length&&i.push(s.join(""));let a=[];for(let l=0;l<i.length;l+=t)a.push(i.slice(l,l+t).join(n));return a.join(o)},toBytes(r){let e=r.toLowerCase().replace(/[^a-z]/g,"");if(e.length/3%1!==0)throw new Error(`invalid triplet count, ${e.length} does not divide into triplets`);let n=[];for(let o=0;o<e.length;o+=3)n.push(e.slice(o,o+3));return new Uint8Array(n.map((o,i)=>{let a=(i%2===0?cs:us).findIndex(l=>l===o);if(a===-1)throw new Error(`unknown triplet ${o}`);return a}))},toHex(r){return Ve.fromBytes(et.toBytes(r))},fromHex(r,e){return et.fromBytes(Ve.toBytes(r),e)}};var Ge={defaults:{delimiter:".",sigilBytes:4,previewBytes:8},toBytes(r){r=r.trim();let e=r.split(/[^a-zA-Z0-9]+/m).filter(Boolean).map(o=>o.trim());if(e.length<2)return et.toBytes(e.join(""));let t=e.pop(),n=e.join("");return new Uint8Array([...et.toBytes(n),...ls.toBytes(t)])},parse(r,e){let t=Ge.toBytes(r);return Ge.build.fromBytes(t,e)},build:{fromBytes(r,e={}){let{delimiter:t,previewBytes:n,sigilBytes:o}={...Ge.defaults,...e},i=f=>r.length>0?et.fromBytes(r.slice(0,f),{wordSeparator:t,groupSeparator:t}):"",s=i(o),a=i(n),l=r.length>n?ls.fromBytes(r.slice(n)):"",c=[a,l].filter(f=>f.length>0).join(t);return{raw:r,full:c,preview:a,bulk:l,sigil:s,bytes:r,thumbprint:c}},fromHex(r,e){let t=Ve.toBytes(r);return Ge.build.fromBytes(t,e)}},toHex(r){let e=Ge.toBytes(r);return Ve.fromBytes(e)},fromBytes(r,e){return Ge.build.fromBytes(r,e).full},fromHex(r,e){return Ge.fromBytes(Ve.toBytes(r),e)},sigil:{fromHex(r,e){return Ge.build.fromHex(r,e).sigil},fromBytes(r,e){return Ge.build.fromBytes(r,e).sigil}}},Ja=Ge;var Zn=Object.freeze({fromBytes(r){return[...r].map(e=>e.toString(16).padStart(2,"0")).join("")},toBytes(r){if(r.length%2!==0)throw new Error("must have even number of hex characters");let e=new Uint8Array(r.length/2);for(let t=0;t<r.length;t+=2)e[t/2]=parseInt(r.slice(t,t+2),16);return e},random(r=32){return this.fromBytes(dr.random(r))},string(r){return Zn.fromBytes(r)},bytes(r){return Zn.toBytes(r)}});function qe(){let r,e,t=new Promise((o,i)=>{r=o,e=i});function n(o){return o.then(r).catch(e),t}return{promise:t,resolve:r,reject:e,entangle:n}}var Jn=Object.freeze({happy:r=>r!=null,sad:r=>r==null,boolean:r=>typeof r=="boolean",number:r=>typeof r=="number",string:r=>typeof r=="string",bigint:r=>typeof r=="bigint",object:r=>typeof r=="object"&&r!==null,array:r=>Array.isArray(r),fn:r=>typeof r=="function",symbol:r=>typeof r=="symbol"});var eo=class r extends Map{static require(e,t){if(e.has(t))return e.get(t);throw new Error(`required key not found: "${t}"`)}static guarantee(e,t,n){if(e.has(t))return e.get(t);{let o=n();return e.set(t,o),o}}array(){return[...this]}require(e){return r.require(this,e)}guarantee(e,t){return r.guarantee(this,e,t)}};var cn=class extends Error{milliseconds;name=this.constructor.name;constructor(e){super(`deadline exceeded (${(e/1e3).toFixed(1)} seconds)`),this.milliseconds=e}};function el(r,e){return r<=0||r===1/0?e():new Promise((t,n)=>{let o=setTimeout(()=>n(new cn(r)),r);e().then(t).catch(n).finally(()=>clearTimeout(o))})}function to(){let r=[];function e(){for(let t of r)t();r=[]}return e.schedule=(...t)=>(r.push(...t),e),e}function tl(r,e){let t=r;for(let n of e)if(t=t[n],Jn.sad(t))break;return t}function dd(){let r=new Set;async function e(...l){await Promise.all([...r].map(c=>c(...l)))}function t(l){return r.add(l),()=>{r.delete(l)}}async function n(...l){return e(...l)}function o(l){return t(l)}async function i(l){let{promise:c,resolve:f}=qe(),u=o(async(...m)=>{l&&await l(...m),f(m),u()});return c}function s(){r.clear()}let a={pub:n,sub:o,publish:e,subscribe:t,on:t,next:i,clear:s};return Object.assign(o,a),Object.assign(n,a),a}function Ee(r){let e=dd();return r&&e.sub(r),e.pub}var b=(r,e,t,n)=>({type:"number",min:r,max:e,default:t,...n===void 0?{}:{step:n}}),tt=r=>({type:"color",default:r}),He=r=>({type:"boolean",default:r}),ro=(r,e)=>({type:"choice",options:r,default:e}),oe=r=>({type:"object",properties:r}),hd=r=>({type:"array",items:r}),rl=[3,5,7,9,11,13,15,17,19,21,23,25],gd={TRANSPARENT:0,ORIGINAL:1,LOOP:2,CLAMP:3,MIRROR:4},W=()=>(r,e={})=>({type:r,schema:e}),nl={adjustment:W()("AdjustmentFilter",{gamma:b(0,5,1),saturation:b(0,5,1),contrast:b(0,5,1),brightness:b(0,5,1),red:b(0,5,1),green:b(0,5,1),blue:b(0,5,1),alpha:b(0,1,1,.01)}),advancedBloom:W()("AdvancedBloomFilter",{threshold:b(.1,.9,.5,.01),bloomScale:b(.5,1.5,1,.01),brightness:b(.5,1.5,1,.01),blur:b(0,20,8,.1),quality:b(1,20,4,1)}),alpha:W()("AlphaFilter",{alpha:b(0,1,1,.01)}),ascii:W()("AsciiFilter",{size:b(2,20,8,1),color:tt("#ffffff"),replaceColor:He(!1)}),backdropBlur:W()("BackdropBlurFilter",{strength:b(0,100,8,.1),quality:b(1,10,4,1)}),bevel:W()("BevelFilter",{rotation:b(0,360,45,1),thickness:b(0,10,2,.1),lightColor:tt("#ffffff"),lightAlpha:b(0,1,.7,.01),shadowColor:tt("#000000"),shadowAlpha:b(0,1,.7,.01)}),bloom:W()("BloomFilter",{strength:oe({x:b(0,20,2,.1),y:b(0,20,2,.1)}),quality:b(1,20,4,1),resolution:b(.25,4,1,.01),kernelSize:ro([5,7,9,11,13,15],5)}),blur:W()("BlurFilter",{strength:b(0,100,8,.1),quality:b(1,10,4,1)}),bulgePinch:W()("BulgePinchFilter",{radius:b(0,1e3,100,1),strength:b(-1,1,1,.01),center:oe({x:b(0,1,.5,.01),y:b(0,1,.5,.01)})}),colorGradient:W()("ColorGradientFilter"),colorMatrix:W()("ColorMatrixFilter"),colorOverlay:W()("ColorOverlayFilter",{color:tt("#ff0000"),alpha:b(0,1,.5,.01)}),colorReplace:W()("ColorReplaceFilter",{originalColor:tt("#ff0000"),targetColor:tt("#000000"),tolerance:b(0,1,.4,.01)}),convolution:W()("ConvolutionFilter",{width:b(0,500,300,1),height:b(0,500,300,1),matrix:hd([b(0,1,0),b(0,1,.5,.01),b(0,1,0),b(0,1,.5,.01),b(0,1,1,.01),b(0,1,.5,.01),b(0,1,0),b(0,1,.5,.01),b(0,1,0)])}),crossHatch:W()("CrossHatchFilter"),crt:W()("CRTFilter",{curvature:b(0,10,1,.01),lineWidth:b(0,5,3,.01),lineContrast:b(0,1,.3,.01),verticalLine:He(!1),noise:b(0,1,.2,.01),noiseSize:b(1,10,1,.1),vignetting:b(0,1,.3,.01),vignettingAlpha:b(0,1,1,.01),vignettingBlur:b(0,1,.3,.01),seed:b(0,1,0,.01),time:b(.5,20,.5,.01)}),dot:W()("DotFilter",{scale:b(.3,1,1,.01),angle:b(0,5,5,.01),grayscale:He(!0)}),dropShadow:W()("DropShadowFilter",{blur:b(0,20,2,.1),quality:b(1,20,3,1),alpha:b(0,1,.5,.01),offset:oe({x:b(-50,50,4,1),y:b(-50,50,4,1)}),color:tt("#000000"),shadowOnly:He(!1)}),emboss:W()("EmbossFilter",{strength:b(0,20,5,.1)}),glitch:W()("GlitchFilter",{slices:b(0,64,5,1),seed:b(0,1,.5,.01),offset:b(-400,400,100,1),direction:b(-180,180,0,1),fillMode:ro(gd,"LOOP"),average:He(!1),minSize:b(0,64,8,1),sampleSize:b(1,2048,512,1),red:oe({x:b(-50,50,2,1),y:b(-50,50,2,1)}),blue:oe({x:b(-50,50,10,1),y:b(-50,50,-4,1)}),green:oe({x:b(-50,50,-10,1),y:b(-50,50,4,1)})}),glow:W()("GlowFilter",{distance:b(0,20,15,.1),innerStrength:b(0,20,0,.1),outerStrength:b(0,20,2,.1),color:tt("#ffffff"),quality:b(0,1,.2,.01),alpha:b(0,1,1,.01),knockout:He(!1)}),godray:W()("GodrayFilter",{time:b(0,1,0,.01),gain:b(0,1,.6,.01),lacunarity:b(0,5,2.75,.01),alpha:b(0,1,1,.01),parallel:He(!0),angle:b(-60,60,30,1),center:oe({x:b(-100,2012,956,1),y:b(-1e3,-100,-100,1)})}),grayscale:W()("GrayscaleFilter"),hslAdjustment:W()("HslAdjustmentFilter",{hue:b(-180,180,0,1),saturation:b(-1,1,0,.01),lightness:b(-1,1,0,.01),colorize:He(!1),alpha:b(0,1,1,.01)}),kawaseBlur:W()("KawaseBlurFilter",{strength:b(0,20,4,.1),quality:b(1,20,3,1),pixelSize:oe({x:b(0,10,1,.1),y:b(0,10,1,.1)})}),motionBlur:W()("MotionBlurFilter",{velocity:oe({x:b(-90,90,40,1),y:b(-90,90,40,1)}),kernelSize:ro(rl,15),offset:b(-150,150,0,1)}),multiColorReplace:W()("MultiColorReplaceFilter"),noise:W()("NoiseFilter",{noise:b(0,1,.5,.01),seed:b(.01,10,.5,.01)}),oldFilm:W()("OldFilmFilter",{sepia:b(0,1,.3,.01),noise:b(0,1,.3,.01),noiseSize:b(1,10,1,.1),scratch:b(-1,1,.5,.01),scratchDensity:b(0,1,.3,.01),scratchWidth:b(1,20,1,.1),vignetting:b(0,1,.3,.01),vignettingAlpha:b(0,1,1,.01),vignettingBlur:b(0,1,.3,.01)}),outline:W()("OutlineFilter",{thickness:b(0,10,4,.1),color:tt("#000000"),alpha:b(0,1,1,.01),knockout:He(!1)}),pixelate:W()("PixelateFilter",{size:oe({x:b(4,40,10,1),y:b(4,40,10,1)})}),radialBlur:W()("RadialBlurFilter",{angle:b(-180,180,20,1),radius:b(-1,1912,300,1),center:oe({x:b(0,1912,956,1),y:b(0,920,460,1)}),kernelSize:ro(rl,15)}),reflection:W()("ReflectionFilter",{mirror:He(!0),boundary:b(0,1,.5,.01),amplitude:oe({start:b(0,50,0,.1),end:b(0,50,20,.1)}),waveLength:oe({start:b(10,200,30,1),end:b(10,200,100,1)}),alpha:oe({start:b(0,1,1,.01),end:b(0,1,1,.01)}),time:b(0,20,0,.01)}),rgbSplit:W()("RGBSplitFilter",{red:oe({x:b(-20,20,-10,1),y:b(-20,20,0,1)}),blue:oe({x:b(-20,20,0,1),y:b(-20,20,0,1)}),green:oe({x:b(-20,20,0,1),y:b(-20,20,10,1)})}),shockwave:W()("ShockwaveFilter",{speed:b(500,2e3,500,1),amplitude:b(1,100,30,1),wavelength:b(2,400,160,1),brightness:b(.2,2,1,.01),radius:b(100,2e3,-1,1),center:oe({x:b(0,1912,956,1),y:b(0,920,460,1)})}),simplexNoise:W()("SimplexNoiseFilter",{strength:b(0,1,.5,.01),noiseScale:b(0,50,10,.1),offsetX:b(0,5,0,.01),offsetY:b(0,5,0,.01),offsetZ:b(0,5,0,.01),step:b(-1,1,-1,.01)}),tiltShift:W()("TiltShiftFilter",{blur:b(0,200,100,.1),gradientBlur:b(0,1e3,600,1),start:oe({x:b(0,1912,0,1),y:b(0,920,460,1)}),end:oe({x:b(0,1912,1912,1),y:b(0,920,460,1)})}),twist:W()("TwistFilter",{angle:b(-10,10,4,.01),radius:b(0,1912,200,1),offset:oe({x:b(0,1912,956,1),y:b(0,920,460,1)})}),zoomBlur:W()("ZoomBlurFilter",{strength:b(.01,.5,.1,.01),center:oe({x:b(0,1912,956,1),y:b(0,920,460,1)}),innerRadius:b(0,956,80,1),radius:b(0,956,-1,1)})};var fs={slideIn:{type:"motion",label:"Slide in",defaults:{duration:700,from:[-400,0],to:[0,0],terp:"easeOut"},transform:{from:{position:[-400,0]},to:{position:[0,0]}}},slideOut:{type:"motion",label:"Slide out",defaults:{duration:700,from:[0,0],to:[400,0],terp:"easeIn"},transform:{from:{position:[0,0]},to:{position:[400,0]}}},spinIn:{type:"motion",label:"Spin in",defaults:{duration:700,from:[0,0],to:[0,0],terp:"easeOut"},transform:{from:{scale:[0,0],rotation:-Math.PI},to:{scale:[1,1],rotation:0}}},spinOut:{type:"motion",label:"Spin out",defaults:{duration:700,from:[0,0],to:[0,0],terp:"easeIn"},transform:{from:{scale:[1,1],rotation:0},to:{scale:[0,0],rotation:Math.PI}}},zoomIn:{type:"motion",label:"Zoom in",defaults:{duration:700,from:[0,0],to:[0,0],terp:"easeOut"},transform:{from:{scale:[0,0]},to:{scale:[1,1]}}},zoomOut:{type:"motion",label:"Zoom out",defaults:{duration:700,from:[0,0],to:[0,0],terp:"easeIn"},transform:{from:{scale:[1,1]},to:{scale:[0,0]}}},bounceIn:{type:"motion",label:"Bounce in",defaults:{duration:700,from:[0,0],to:[0,0],terp:"bounce"},transform:{from:{scale:[0,0]},to:{scale:[1,1]}}},bounceOut:{type:"motion",label:"Bounce out",defaults:{duration:700,from:[0,0],to:[0,0],terp:"bounce"},transform:{from:{scale:[1,1]},to:{scale:[0,0]}}},fadeIn:{type:"scalar",label:"Fade in",defaults:{duration:700,from:0,to:1,terp:"easeIn"}},fadeOut:{type:"scalar",label:"Fade out",defaults:{duration:700,from:1,to:0,terp:"easeOut"}}};var xd={transform:{type:"transform",defaultTerp:"linear",channels:[{path:"position.x",type:"number",default:0,unit:"pixel"},{path:"position.y",type:"number",default:0,unit:"pixel"},{path:"scale.x",type:"number",default:1,unit:"scale"},{path:"scale.y",type:"number",default:1,unit:"scale"},{path:"rotation",type:"number",default:0,unit:"radian"}]}},ms={opacity:{type:"scalar",defaultTerp:"linear",channels:[{type:"number",default:1,unit:"ratio",range:[0,1]}]}},vd={...xd,...ms};function ol(r,e,t){let n=Object.entries(fs).map(([o,i])=>{let s=i.type==="motion"?a=>{let l=a?.offset??0;return e(a?.terp??i.defaults.terp,[[l,t({...i.transform.from,...a?.from===void 0?{}:{position:a.from}})],[l+(a?.duration??i.defaults.duration),t({...i.transform.to,...a?.to===void 0?{}:{position:a.to}})]])}:a=>{let l=a?.offset??0;return r(a?.terp??i.defaults.terp,[[l,a?.from??i.defaults.from],[l+(a?.duration??i.defaults.duration),a?.to??i.defaults.to]])};return[o,s]});return Object.fromEntries(n)}var H;(function(r){r[r.Sequence=0]="Sequence",r[r.Stack=1]="Stack",r[r.Video=2]="Video",r[r.Audio=3]="Audio",r[r.Text=4]="Text",r[r.Gap=5]="Gap",r[r.Spatial=6]="Spatial",r[r.AnimatedSpatial=7]="AnimatedSpatial",r[r.Animation=8]="Animation",r[r.Transition=9]="Transition",r[r.TextStyle=10]="TextStyle",r[r.Filter=11]="Filter"})(H||(H={}));var no;(function(r){r[r.Crossfade=0]="Crossfade"})(no||(no={}));var re=class{state;constructor(e){this.state=e}require(e){return e===void 0?void 0:this.state.timeline.items.find(n=>n.id===e)}get timeline(){return this.state.timeline}getId(){return Ve.toInteger(Ve.random())}#e(e){this.state.timeline=e(this.state.timeline)}register(e){this.#e(t=>({...t,items:[...t.items,e]}))}textStyle=e=>{let t={id:this.getId(),kind:H.TextStyle,style:e};return this.register(t),t};spatial=(e,t)=>{let n={id:this.getId(),kind:H.Spatial,transform:e??this.transform(),crop:t,enabled:!0};return this.register(n),n};animatedSpatial=(e,t)=>{let n={id:this.getId(),kind:H.AnimatedSpatial,anim:e,crop:t,enabled:!0};return this.register(n),n};#t=e=>{let t={id:this.getId(),kind:H.Animation,anims:e,enabled:!0};return this.register(t),t};#r=(e,t)=>{let n={position:{x:[],y:[]},scale:{x:[],y:[]},rotation:[]};for(let[o,[i,s,a]]of t)n.position.x.push([o,i[0]]),n.position.y.push([o,i[1]]),n.scale.x.push([o,s[0]]),n.scale.y.push([o,s[1]]),n.rotation.push([o,a]);return{terp:e,track:n}};anim={scalar:(e,t)=>({terp:e,track:t}),vec2:(e,t)=>{let n={x:[],y:[]};for(let[o,[i,s]]of t)n.x.push([o,i]),n.y.push([o,s]);return{terp:e,track:n}},transform:this.#r,presets:ol((e,t)=>({terp:e,track:t}),this.#r,e=>this.transform(e))};#n=e=>{let t=o=>{let i={id:this.getId(),kind:H.Filter,type:e,params:o,enabled:!0};return this.register(i),i},n=((o,i)=>{let s=t(i),a={...o,filterIds:[...o.filterIds??[],s.id]};return this.set(o.id,a),a});return n.make=t,n};#o=()=>{let e=Object.entries(nl).map(([t,n])=>[t,this.#n(n.type)]);return Object.fromEntries(e)};filter=this.#o();#i=e=>{let t=(o,i)=>this.#t({[e]:this.anim.scalar(o,i)}),n=((o,i,s)=>{let a=t(i,s),l={...o,animationIds:[...o.animationIds??[],a.id]};return this.set(o.id,l),l});return n.make=t,n};#s=()=>{let e=Object.keys(ms).map(t=>[t,this.#i(t)]);return Object.fromEntries(e)};animate=this.#s();sequence=(...e)=>{let t={id:this.getId(),kind:H.Sequence,childrenIds:e.map(n=>n.id)};return this.register(t),t};stack=(...e)=>{let t={kind:H.Stack,id:this.getId(),childrenIds:e.map(n=>n.id)};return this.register(t),t};video=(e,t)=>{if(!e.hasVideo)throw new Error(`Video clip error: media "${e.datafile.filename}" has no video track.`);let n={kind:H.Video,id:this.getId(),mediaHash:e.datafile.checksum.hash,start:t?.start??0,duration:t?.duration??e.duration};return this.register(n),n};audio=(e,t)=>{if(!e.hasAudio)throw new Error(`Audio clip error: media "${e.datafile.filename}" has no audio track.`);let n={kind:H.Audio,id:this.getId(),mediaHash:e.datafile.checksum.hash,start:t?.start??0,duration:t?.duration??e.duration,gain:t?.gain??1};return this.register(n),n};text=(e,t)=>{let n={id:this.getId(),content:e,kind:H.Text,duration:t?.duration??2e3};return t?.styles&&(n.styleId=this.textStyle(t.styles).id),this.register(n),n};gap=e=>{let t={id:this.getId(),kind:H.Gap,duration:e};return this.register(t),t};transition={crossfade:e=>{let t={id:this.getId(),kind:H.Transition,effect:no.Crossfade,duration:e};return this.register(t),t}};transform=e=>{let t=[e?.position?.[0]??0,e?.position?.[1]??0],n=[e?.scale?.[0]??1,e?.scale?.[1]??1],o=e?.rotation??0;return[t,n,o]};addChildren(e,...t){this.#e(n=>(n.items.find(({id:i})=>i===e.id).childrenIds.push(...t.map(i=>i.id)),n))}set=(e,t)=>{this.#e(n=>({...n,items:n.items.map(o=>o.id===e?{...o,...t}:o)}))}};var xt=r=>r;function h(r){if(!r)throw new Error("Assertion failed.")}var oo=r=>{let e=(r%360+360)%360;if(e===0||e===90||e===180||e===270)return e;throw new Error(`Invalid rotation ${r}.`)},xe=r=>r&&r[r.length-1];var Z=class r{constructor(e){this.bytes=e,this.pos=0}seekToByte(e){this.pos=8*e}readBit(){let e=Math.floor(this.pos/8),t=this.bytes[e]??0,n=7-(this.pos&7),o=(t&1<<n)>>n;return this.pos++,o}readBits(e){if(e===1)return this.readBit();let t=0;for(let n=0;n<e;n++)t<<=1,t|=this.readBit();return t}writeBits(e,t){let n=this.pos+e;for(let o=this.pos;o<n;o++){let i=Math.floor(o/8),s=this.bytes[i],a=7-(o&7);s&=~(1<<a),s|=(t&1<<n-o-1)>>n-o-1<<a,this.bytes[i]=s}this.pos=n}readAlignedByte(){if(this.pos%8!==0)throw new Error("Bitstream is not byte-aligned.");let e=this.pos/8,t=this.bytes[e]??0;return this.pos+=8,t}skipBits(e){this.pos+=e}getBitsLeft(){return this.bytes.length*8-this.pos}clone(){let e=new r(this.bytes);return e.pos=this.pos,e}},R=r=>{let e=0;for(;r.readBits(1)===0&&e<32;)e++;if(e>=32)throw new Error("Invalid exponential-Golomb code.");return(1<<e)-1+r.readBits(e)},je=r=>{let e=R(r);return(e&1)===0?-(e>>1):e+1>>1};var ze=r=>r.constructor===Uint8Array?r:ArrayBuffer.isView(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r),K=r=>r.constructor===DataView?r:ArrayBuffer.isView(r)?new DataView(r.buffer,r.byteOffset,r.byteLength):new DataView(r),me=new TextDecoder;var xs=r=>Object.fromEntries(Object.entries(r).map(([e,t])=>[t,e])),vs={bt709:1,bt470bg:5,smpte170m:6,bt2020:9,smpte432:12},io=xs(vs),ys={bt709:1,smpte170m:6,linear:8,"iec61966-2-1":13,pq:16,hlg:18},so=xs(ys),bs={rgb:0,bt709:1,bt470bg:5,smpte170m:6,"bt2020-ncl":9},ao=xs(bs);var lo=r=>r instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&r instanceof SharedArrayBuffer||ArrayBuffer.isView(r),We=class{constructor(){this.currentPromise=Promise.resolve()}async acquire(){let e,t=new Promise(o=>{e=o}),n=this.currentPromise;return this.currentPromise=t,await n,e}},Ss=r=>[...r].map(e=>e.toString(16).padStart(2,"0")).join(""),Ts=r=>(r=r>>1&1431655765|(r&1431655765)<<1,r=r>>2&858993459|(r&858993459)<<2,r=r>>4&252645135|(r&252645135)<<4,r=r>>8&16711935|(r&16711935)<<8,r=r>>16&65535|(r&65535)<<16,r>>>0),Ot=(r,e,t)=>{let n=0,o=r.length-1,i=-1;for(;n<=o;){let s=n+o>>1,a=t(r[s]);a===e?(i=s,o=s-1):a<e?n=s+1:o=s-1}return i},$=(r,e,t)=>{let n=0,o=r.length-1,i=-1;for(;n<=o;){let s=n+(o-n+1)/2|0;t(r[s])<=e?(i=s,n=s+1):o=s-1}return i},ws=(r,e,t)=>{let n=$(r,t(e),t);r.splice(n+1,0,e)},ve=()=>{let r,e;return{promise:new Promise((n,o)=>{r=n,e=o}),resolve:r,reject:e}};var Cs=(r,e)=>{for(let t=r.length-1;t>=0;t--)if(e(r[t]))return r[t]},co=(r,e)=>{for(let t=r.length-1;t>=0;t--)if(e(r[t]))return t;return-1},sl=async function*(r){Symbol.iterator in r?yield*r[Symbol.iterator]():yield*r[Symbol.asyncIterator]()},al=r=>{if(!(Symbol.iterator in r)&&!(Symbol.asyncIterator in r))throw new TypeError("Argument must be an iterable or async iterable.")},Ae=r=>{throw new Error(`Unexpected value: ${r}`)},Rt=(r,e,t)=>{let n=r.getUint8(e),o=r.getUint8(e+1),i=r.getUint8(e+2);return t?n|o<<8|i<<16:n<<16|o<<8|i},ll=(r,e,t)=>Rt(r,e,t)<<8>>8,cl=(r,e,t,n)=>{t=t>>>0,t=t&16777215,n?(r.setUint8(e,t&255),r.setUint8(e+1,t>>>8&255),r.setUint8(e+2,t>>>16&255)):(r.setUint8(e,t>>>16&255),r.setUint8(e+1,t>>>8&255),r.setUint8(e+2,t&255))};var Mt=(r,e,t)=>Math.max(e,Math.min(t,r)),pe="und",Bt=r=>{let e=Math.round(r);return Math.abs(r/e-1)<10*Number.EPSILON?e:r},ul=(r,e)=>Math.round(r/e)*e,fl=r=>{let e=0;for(;r;)e++,r>>=1;return e},yd=/^[a-z]{3}$/,uo=r=>yd.test(r),Xe=1e6*(1+Number.EPSILON),ks=(r,e)=>{let t={...r,...e};if(r.headers||e.headers){let n=r.headers?il(r.headers):{},o=e.headers?il(e.headers):{},i={...n};Object.entries(o).forEach(([s,a])=>{let l=Object.keys(i).find(c=>c.toLowerCase()===s.toLowerCase());l&&delete i[l],i[s]=a}),t.headers=i}return t},il=r=>{if(r instanceof Headers){let e={};return r.forEach((t,n)=>{e[n]=t}),e}if(Array.isArray(r)){let e={};return r.forEach(([t,n])=>{e[t]=n}),e}return r},Ps=async(r,e,t,n,o)=>{let i=0;for(;;)try{return await r(e,t)}catch(s){if(o())throw s;i++;let a=n(i,s,e);if(a===null)throw s;if(console.error("Retrying failed fetch. Error:",s),!Number.isFinite(a)||a<0)throw new TypeError("Retry delay must be a non-negative finite number.");if(a>0&&await new Promise(l=>setTimeout(l,1e3*a)),o())throw s}};var un=class{constructor(){this.currentPromise=Promise.resolve()}call(e){return this.currentPromise=this.currentPromise.then(e)}},ps=null,vt=()=>ps!==null?ps:ps=!!(typeof navigator<"u"&&(navigator.vendor?.match(/apple/i)||/AppleWebKit/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)||/\b(iPad|iPhone|iPod)\b/.test(navigator.userAgent))),ds=null,_s=()=>ds!==null?ds:ds=typeof navigator<"u"&&navigator.userAgent?.includes("Firefox"),hs=null,fn=()=>hs!==null?hs:hs=!!(typeof navigator<"u"&&(navigator.vendor?.includes("Google Inc")||/Chrome/.test(navigator.userAgent))),gs=null,ml=()=>{if(gs!==null)return gs;if(typeof navigator>"u")return null;let r=/\bChrome\/(\d+)/.exec(navigator.userAgent);return r?gs=Number(r[1]):null},Ut=(r,e)=>r!==-1?r:e,fo=(r,e,t,n)=>r<=n&&t<=e;var pl=r=>{let e=atob(r),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t};var mo=()=>{Symbol.dispose??=Symbol("Symbol.dispose")},mn=r=>typeof r=="number"&&!Number.isNaN(r);var yt=class{constructor(e,t){if(this.data=e,this.mimeType=t,!(e instanceof Uint8Array))throw new TypeError("data must be a Uint8Array.");if(typeof t!="string")throw new TypeError("mimeType must be a string.")}},po=class{constructor(e,t,n,o){if(this.data=e,this.mimeType=t,this.name=n,this.description=o,!(e instanceof Uint8Array))throw new TypeError("data must be a Uint8Array.");if(t!==void 0&&typeof t!="string")throw new TypeError("mimeType, when provided, must be a string.");if(n!==void 0&&typeof n!="string")throw new TypeError("name, when provided, must be a string.");if(o!==void 0&&typeof o!="string")throw new TypeError("description, when provided, must be a string.")}};var Se={default:!0,forced:!1,original:!1,commentary:!1,hearingImpaired:!1,visuallyImpaired:!1};var bt=["pcm-s16","pcm-s16be","pcm-s24","pcm-s24be","pcm-s32","pcm-s32be","pcm-f32","pcm-f32be","pcm-f64","pcm-f64be","pcm-u8","pcm-s8","ulaw","alaw"],bd=["aac","opus","mp3","vorbis","flac"],Kx=[...bd,...bt];var Nt=[{maxPictureSize:36864,maxBitrate:2e5,level:10},{maxPictureSize:73728,maxBitrate:8e5,level:11},{maxPictureSize:122880,maxBitrate:18e5,level:20},{maxPictureSize:245760,maxBitrate:36e5,level:21},{maxPictureSize:552960,maxBitrate:72e5,level:30},{maxPictureSize:983040,maxBitrate:12e6,level:31},{maxPictureSize:2228224,maxBitrate:18e6,level:40},{maxPictureSize:2228224,maxBitrate:3e7,level:41},{maxPictureSize:8912896,maxBitrate:6e7,level:50},{maxPictureSize:8912896,maxBitrate:12e7,level:51},{maxPictureSize:8912896,maxBitrate:18e7,level:52},{maxPictureSize:35651584,maxBitrate:18e7,level:60},{maxPictureSize:35651584,maxBitrate:24e7,level:61},{maxPictureSize:35651584,maxBitrate:48e7,level:62}];var dl=".01.01.01.01.00",hl=".0.110.01.01.01.0";var ho=r=>{let{codec:e,codecDescription:t,colorSpace:n,avcCodecInfo:o,hevcCodecInfo:i,vp9CodecInfo:s,av1CodecInfo:a}=r;if(e==="avc"){if(h(r.avcType!==null),o){let l=new Uint8Array([o.avcProfileIndication,o.profileCompatibility,o.avcLevelIndication]);return`avc${r.avcType}.${Ss(l)}`}if(!t||t.byteLength<4)throw new TypeError("AVC decoder description is not provided or is not at least 4 bytes long.");return`avc${r.avcType}.${Ss(t.subarray(1,4))}`}else if(e==="hevc"){let l,c,f,u,m,p;if(i)l=i.generalProfileSpace,c=i.generalProfileIdc,f=Ts(i.generalProfileCompatibilityFlags),u=i.generalTierFlag,m=i.generalLevelIdc,p=[...i.generalConstraintIndicatorFlags];else{if(!t||t.byteLength<23)throw new TypeError("HEVC decoder description is not provided or is not at least 23 bytes long.");let g=K(t),x=g.getUint8(1);l=x>>6&3,c=x&31,f=Ts(g.getUint32(2)),u=x>>5&1,m=g.getUint8(12),p=[];for(let y=0;y<6;y++)p.push(g.getUint8(6+y))}let d="hev1.";for(d+=["","A","B","C"][l]+c,d+=".",d+=f.toString(16).toUpperCase(),d+=".",d+=u===0?"L":"H",d+=m;p.length>0&&p[p.length-1]===0;)p.pop();return p.length>0&&(d+=".",d+=p.map(g=>g.toString(16).toUpperCase()).join(".")),d}else{if(e==="vp8")return"vp8";if(e==="vp9"){if(!s){let y=r.width*r.height,v=xe(Nt).level;for(let T of Nt)if(y<=T.maxPictureSize){v=T.level;break}return`vp09.00.${v.toString().padStart(2,"0")}.08`}let l=s.profile.toString().padStart(2,"0"),c=s.level.toString().padStart(2,"0"),f=s.bitDepth.toString().padStart(2,"0"),u=s.chromaSubsampling.toString().padStart(2,"0"),m=s.colourPrimaries.toString().padStart(2,"0"),p=s.transferCharacteristics.toString().padStart(2,"0"),d=s.matrixCoefficients.toString().padStart(2,"0"),g=s.videoFullRangeFlag.toString().padStart(2,"0"),x=`vp09.${l}.${c}.${f}.${u}`;return x+=`.${m}.${p}.${d}.${g}`,x.endsWith(dl)&&(x=x.slice(0,-dl.length)),x}else if(e==="av1"){if(!a){let T=r.width*r.height,S=xe(Nt).level;for(let k of Nt)if(T<=k.maxPictureSize){S=k.level;break}return`av01.0.${S.toString().padStart(2,"0")}M.08`}let l=a.profile,c=a.level.toString().padStart(2,"0"),f=a.tier?"H":"M",u=a.bitDepth.toString().padStart(2,"0"),m=a.monochrome?"1":"0",p=100*a.chromaSubsamplingX+10*a.chromaSubsamplingY+1*(a.chromaSubsamplingX&&a.chromaSubsamplingY?a.chromaSamplePosition:0),d=n?.primaries?vs[n.primaries]:1,g=n?.transfer?ys[n.transfer]:1,x=n?.matrix?bs[n.matrix]:1,y=n?.fullRange?1:0,v=`av01.${l}.${c}${f}.${u}`;return v+=`.${m}.${p.toString().padStart(3,"0")}`,v+=`.${d.toString().padStart(2,"0")}`,v+=`.${g.toString().padStart(2,"0")}`,v+=`.${x.toString().padStart(2,"0")}`,v+=`.${y}`,v.endsWith(hl)&&(v=v.slice(0,-hl.length)),v}}throw new TypeError(`Unhandled codec '${e}'.`)};var go=r=>{let{codec:e,codecDescription:t,aacCodecInfo:n}=r;if(e==="aac"){if(!n)throw new TypeError("AAC codec info must be provided.");return n.isMpeg2?"mp4a.67":`mp4a.40.${As(t).objectType}`}else{if(e==="mp3")return"mp3";if(e==="opus")return"opus";if(e==="vorbis")return"vorbis";if(e==="flac")return"flac";if(e&&bt.includes(e))return e}throw new TypeError(`Unhandled codec '${e}'.`)},pn=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],Is=[-1,1,2,3,4,5,6,8],As=r=>{if(!r||r.byteLength<2)throw new TypeError("AAC description must be at least 2 bytes long.");let e=new Z(r),t=e.readBits(5);t===31&&(t=32+e.readBits(6));let n=e.readBits(4),o=null;n===15?o=e.readBits(24):n<pn.length&&(o=pn[n]);let i=e.readBits(4),s=null;return i>=1&&i<=7&&(s=Is[i]),{objectType:t,frequencyIndex:n,sampleRate:o,channelConfiguration:i,numberOfChannels:s}};var Lt=48e3,Sd=/^pcm-([usf])(\d+)+(be)?$/,xo=r=>{if(h(bt.includes(r)),r==="ulaw")return{dataType:"ulaw",sampleSize:1,littleEndian:!0,silentValue:255};if(r==="alaw")return{dataType:"alaw",sampleSize:1,littleEndian:!0,silentValue:213};let e=Sd.exec(r);h(e);let t;e[1]==="u"?t="unsigned":e[1]==="s"?t="signed":t="float";let n=Number(e[2])/8,o=e[3]!=="be",i=r==="pcm-u8"?2**7:0;return{dataType:t,sampleSize:n,littleEndian:o,silentValue:i}};var Vt;(function(r){r[r.IDR=5]="IDR",r[r.SEI=6]="SEI",r[r.SPS=7]="SPS",r[r.PPS=8]="PPS",r[r.SPS_EXT=13]="SPS_EXT"})(Vt||(Vt={}));var ye;(function(r){r[r.RASL_N=8]="RASL_N",r[r.RASL_R=9]="RASL_R",r[r.BLA_W_LP=16]="BLA_W_LP",r[r.RSV_IRAP_VCL23=23]="RSV_IRAP_VCL23",r[r.VPS_NUT=32]="VPS_NUT",r[r.SPS_NUT=33]="SPS_NUT",r[r.PPS_NUT=34]="PPS_NUT",r[r.PREFIX_SEI_NUT=39]="PREFIX_SEI_NUT",r[r.SUFFIX_SEI_NUT=40]="SUFFIX_SEI_NUT"})(ye||(ye={}));var yo=r=>{let e=[],t=0;for(;t<r.length;){let n=-1,o=0;for(let i=t;i<r.length-3;i++){if(r[i]===0&&r[i+1]===0&&r[i+2]===1){n=i,o=3;break}if(i<r.length-4&&r[i]===0&&r[i+1]===0&&r[i+2]===0&&r[i+3]===1){n=i,o=4;break}}if(n===-1)break;if(t>0&&n>t){let i=r.subarray(t,n);i.length>0&&e.push(i)}t=n+o}if(t<r.length){let n=r.subarray(t);n.length>0&&e.push(n)}return e},vl=(r,e)=>{let t=[],n=0,o=new DataView(r.buffer,r.byteOffset,r.byteLength);for(;n+e<=r.length;){let i;e===1?i=o.getUint8(n):e===2?i=o.getUint16(n,!1):e===3?i=Rt(o,n,!1):e===4?i=o.getUint32(n,!1):(Ae(e),h(!1)),n+=e;let s=r.subarray(n,n+i);t.push(s),n+=i}return t},vo=r=>{let e=[],t=r.length;for(let n=0;n<t;n++)n+2<t&&r[n]===0&&r[n+1]===0&&r[n+2]===3?(e.push(0,0),n+=2):e.push(r[n]);return new Uint8Array(e)},Fs=new Uint8Array([0,0,0,1]),wd=r=>{let e=r.reduce((o,i)=>o+Fs.byteLength+i.byteLength,0),t=new Uint8Array(e),n=0;for(let o of r)t.set(Fs,n),n+=Fs.byteLength,t.set(o,n),n+=o.byteLength;return t},Cd=(r,e)=>{let t=r.reduce((i,s)=>i+e+s.byteLength,0),n=new Uint8Array(t),o=0;for(let i of r){let s=new DataView(n.buffer,n.byteOffset,n.byteLength);switch(e){case 1:s.setUint8(o,i.byteLength);break;case 2:s.setUint16(o,i.byteLength,!1);break;case 3:cl(s,o,i.byteLength,!1);break;case 4:s.setUint32(o,i.byteLength,!1);break}o+=e,n.set(i,o),o+=i.byteLength}return n},Es=(r,e)=>{if(e.description){let o=(ze(e.description)[4]&3)+1;return vl(r,o)}else return yo(r)},yl=(r,e)=>{if(e.description){let o=(ze(e.description)[4]&3)+1;return Cd(r,o)}else return wd(r)},Gt=r=>r[0]&31,bl=r=>{try{let e=yo(r),t=e.filter(l=>Gt(l)===Vt.SPS),n=e.filter(l=>Gt(l)===Vt.PPS),o=e.filter(l=>Gt(l)===Vt.SPS_EXT);if(t.length===0||n.length===0)return null;let i=t[0],s=zs(i);h(s!==null);let a=s.profileIdc===100||s.profileIdc===110||s.profileIdc===122||s.profileIdc===144;return{configurationVersion:1,avcProfileIndication:s.profileIdc,profileCompatibility:s.constraintFlags,avcLevelIndication:s.levelIdc,lengthSizeMinusOne:3,sequenceParameterSets:t,pictureParameterSets:n,chromaFormat:a?s.chromaFormatIdc:null,bitDepthLumaMinus8:a?s.bitDepthLumaMinus8:null,bitDepthChromaMinus8:a?s.bitDepthChromaMinus8:null,sequenceParameterSetExt:a?o:null}}catch(e){return console.error("Error building AVC Decoder Configuration Record:",e),null}};var Sl=r=>{try{let e=K(r),t=0,n=e.getUint8(t++),o=e.getUint8(t++),i=e.getUint8(t++),s=e.getUint8(t++),a=e.getUint8(t++)&3,l=e.getUint8(t++)&31,c=[];for(let p=0;p<l;p++){let d=e.getUint16(t,!1);t+=2,c.push(r.subarray(t,t+d)),t+=d}let f=e.getUint8(t++),u=[];for(let p=0;p<f;p++){let d=e.getUint16(t,!1);t+=2,u.push(r.subarray(t,t+d)),t+=d}let m={configurationVersion:n,avcProfileIndication:o,profileCompatibility:i,avcLevelIndication:s,lengthSizeMinusOne:a,sequenceParameterSets:c,pictureParameterSets:u,chromaFormat:null,bitDepthLumaMinus8:null,bitDepthChromaMinus8:null,sequenceParameterSetExt:null};if((o===100||o===110||o===122||o===144)&&t+4<=r.length){let p=e.getUint8(t++)&3,d=e.getUint8(t++)&7,g=e.getUint8(t++)&7,x=e.getUint8(t++);m.chromaFormat=p,m.bitDepthLumaMinus8=d,m.bitDepthChromaMinus8=g;let y=[];for(let v=0;v<x;v++){let T=e.getUint16(t,!1);t+=2,y.push(r.subarray(t,t+T)),t+=T}m.sequenceParameterSetExt=y}return m}catch(e){return console.error("Error deserializing AVC Decoder Configuration Record:",e),null}},zs=r=>{try{let e=new Z(vo(r));if(e.skipBits(1),e.skipBits(2),e.readBits(5)!==7)return null;let n=e.readAlignedByte(),o=e.readAlignedByte(),i=e.readAlignedByte();R(e);let s=null,a=null,l=null;if((n===100||n===110||n===122||n===244||n===44||n===83||n===86||n===118||n===128)&&(s=R(e),s===3&&e.skipBits(1),a=R(e),l=R(e),e.skipBits(1),e.readBits(1))){for(let m=0;m<(s!==3?8:12);m++)if(e.readBits(1)){let d=m<6?16:64,g=8,x=8;for(let y=0;y<d;y++){if(x!==0){let v=je(e);x=(g+v+256)%256}g=x===0?g:x}}}R(e);let c=R(e);if(c===0)R(e);else if(c===1){e.skipBits(1),je(e),je(e);let u=R(e);for(let m=0;m<u;m++)je(e)}R(e),e.skipBits(1),R(e),R(e);let f=e.readBits(1);return{profileIdc:n,constraintFlags:o,levelIdc:i,frameMbsOnlyFlag:f,chromaFormatIdc:s,bitDepthLumaMinus8:a,bitDepthChromaMinus8:l}}catch(e){return console.error("Error parsing AVC SPS:",e),null}},Ds=(r,e)=>{if(e.description){let o=(ze(e.description)[21]&3)+1;return vl(r,o)}else return yo(r)},rt=r=>r[0]>>1&63,Tl=r=>{try{let e=yo(r),t=e.filter(q=>rt(q)===ye.VPS_NUT),n=e.filter(q=>rt(q)===ye.SPS_NUT),o=e.filter(q=>rt(q)===ye.PPS_NUT),i=e.filter(q=>rt(q)===ye.PREFIX_SEI_NUT||rt(q)===ye.SUFFIX_SEI_NUT);if(n.length===0||o.length===0)return null;let s=n[0],a=new Z(vo(s));a.skipBits(16),a.readBits(4);let l=a.readBits(3),c=a.readBits(1),{general_profile_space:f,general_tier_flag:u,general_profile_idc:m,general_profile_compatibility_flags:p,general_constraint_indicator_flags:d,general_level_idc:g}=kd(a,l);R(a);let x=R(a);x===3&&a.skipBits(1),R(a),R(a),a.readBits(1)&&(R(a),R(a),R(a),R(a));let y=R(a),v=R(a);R(a);let S=a.readBits(1)?0:l;for(let q=S;q<=l;q++)R(a),R(a),R(a);R(a),R(a),R(a),R(a),R(a),R(a),a.readBits(1)&&a.readBits(1)&&Pd(a),a.skipBits(1),a.skipBits(1),a.readBits(1)&&(a.skipBits(4),a.skipBits(4),R(a),R(a),a.skipBits(1));let k=R(a);if(_d(a,k),a.readBits(1)){let q=R(a);for(let G=0;G<q;G++)R(a),a.skipBits(1)}a.skipBits(1),a.skipBits(1);let C=0;a.readBits(1)&&(C=Ad(a,l));let O=0;if(o.length>0){let q=o[0],G=new Z(vo(q));G.skipBits(16),R(G),R(G),G.skipBits(1),G.skipBits(1),G.skipBits(3),G.skipBits(1),G.skipBits(1),R(G),R(G),je(G),G.skipBits(1),G.skipBits(1),G.readBits(1)&&R(G),je(G),je(G),G.skipBits(1),G.skipBits(1),G.skipBits(1),G.skipBits(1);let ie=G.readBits(1),Ue=G.readBits(1);!ie&&!Ue?O=0:ie&&!Ue?O=2:!ie&&Ue?O=3:O=0}let E=[...t.length?[{arrayCompleteness:1,nalUnitType:ye.VPS_NUT,nalUnits:t}]:[],...n.length?[{arrayCompleteness:1,nalUnitType:ye.SPS_NUT,nalUnits:n}]:[],...o.length?[{arrayCompleteness:1,nalUnitType:ye.PPS_NUT,nalUnits:o}]:[],...i.length?[{arrayCompleteness:1,nalUnitType:rt(i[0]),nalUnits:i}]:[]];return{configurationVersion:1,generalProfileSpace:f,generalTierFlag:u,generalProfileIdc:m,generalProfileCompatibilityFlags:p,generalConstraintIndicatorFlags:d,generalLevelIdc:g,minSpatialSegmentationIdc:C,parallelismType:O,chromaFormatIdc:x,bitDepthLumaMinus8:y,bitDepthChromaMinus8:v,avgFrameRate:0,constantFrameRate:0,numTemporalLayers:l+1,temporalIdNested:c,lengthSizeMinusOne:3,arrays:E}}catch(e){return console.error("Error building HEVC Decoder Configuration Record:",e),null}},kd=(r,e)=>{let t=r.readBits(2),n=r.readBits(1),o=r.readBits(5),i=0;for(let f=0;f<32;f++)i=i<<1|r.readBits(1);let s=new Uint8Array(6);for(let f=0;f<6;f++)s[f]=r.readBits(8);let a=r.readBits(8),l=[],c=[];for(let f=0;f<e;f++)l.push(r.readBits(1)),c.push(r.readBits(1));if(e>0)for(let f=e;f<8;f++)r.skipBits(2);for(let f=0;f<e;f++)l[f]&&r.skipBits(88),c[f]&&r.skipBits(8);return{general_profile_space:t,general_tier_flag:n,general_profile_idc:o,general_profile_compatibility_flags:i,general_constraint_indicator_flags:s,general_level_idc:a}},Pd=r=>{for(let e=0;e<4;e++)for(let t=0;t<(e===3?2:6);t++)if(!r.readBits(1))R(r);else{let o=Math.min(64,1<<4+(e<<1));e>1&&je(r);for(let i=0;i<o;i++)je(r)}},_d=(r,e)=>{let t=[];for(let n=0;n<e;n++)t[n]=Id(r,n,e,t)},Id=(r,e,t,n)=>{let o=0,i=0,s=0;if(e!==0&&(i=r.readBits(1)),i){if(e===t){let l=R(r);s=e-(l+1)}else s=e-1;r.readBits(1),R(r);let a=n[s]??0;for(let l=0;l<=a;l++)r.readBits(1)||r.readBits(1);o=n[s]}else{let a=R(r),l=R(r);for(let c=0;c<a;c++)R(r),r.readBits(1);for(let c=0;c<l;c++)R(r),r.readBits(1);o=a+l}return o},Ad=(r,e)=>{if(r.readBits(1)&&r.readBits(8)===255&&(r.readBits(16),r.readBits(16)),r.readBits(1)&&r.readBits(1),r.readBits(1)&&(r.readBits(3),r.readBits(1),r.readBits(1)&&(r.readBits(8),r.readBits(8),r.readBits(8))),r.readBits(1)&&(R(r),R(r)),r.readBits(1),r.readBits(1),r.readBits(1),r.readBits(1)&&(R(r),R(r),R(r),R(r)),r.readBits(1)&&(r.readBits(32),r.readBits(32),r.readBits(1)&&R(r),r.readBits(1)&&Fd(r,!0,e)),r.readBits(1)){r.readBits(1),r.readBits(1),r.readBits(1);let t=R(r);return R(r),R(r),R(r),R(r),t}return 0},Fd=(r,e,t)=>{let n=!1,o=!1,i=!1;e&&(n=r.readBits(1)===1,o=r.readBits(1)===1,(n||o)&&(i=r.readBits(1)===1,i&&(r.readBits(8),r.readBits(5),r.readBits(1),r.readBits(5)),r.readBits(4),r.readBits(4),i&&r.readBits(4),r.readBits(5),r.readBits(5),r.readBits(5)));for(let s=0;s<=t;s++){let a=r.readBits(1)===1,l=!0;a||(l=r.readBits(1)===1);let c=!1;l?R(r):c=r.readBits(1)===1;let f=1;c||(f=R(r)+1),n&&gl(r,f,i),o&&gl(r,f,i)}},gl=(r,e,t)=>{for(let n=0;n<e;n++)R(r),R(r),t&&(R(r),R(r)),r.readBits(1)};var bo=r=>{let e=new Z(r);if(e.readBits(2)!==2)return null;let n=e.readBits(1),i=(e.readBits(1)<<1)+n;if(i===3&&e.skipBits(1),e.readBits(1)===1||e.readBits(1)!==0||(e.skipBits(2),e.readBits(24)!==4817730))return null;let c=8;i>=2&&(c=e.readBits(1)?12:10);let f=e.readBits(3),u=0,m=0;if(f!==7)if(m=e.readBits(1),i===1||i===3){let O=e.readBits(1),E=e.readBits(1);u=!O&&!E?3:O&&!E?2:1,e.skipBits(1)}else u=1;else u=3,m=1;let p=e.readBits(16),d=e.readBits(16),g=p+1,x=d+1,y=g*x,v=xe(Nt).level;for(let C of Nt)if(y<=C.maxPictureSize){v=C.level;break}return{profile:i,level:v,bitDepth:c,chromaSubsampling:u,videoFullRangeFlag:m,colourPrimaries:f===2?1:f===1?6:2,transferCharacteristics:f===2?1:f===1?6:2,matrixCoefficients:f===7?0:f===2?1:f===1?6:2}},wl=function*(r){let e=new Z(r),t=()=>{let n=0;for(let o=0;o<8;o++){let i=e.readAlignedByte();if(n|=(i&127)<<o*7,!(i&128))break;if(o===7&&i&128)return null}return n>=2**32-1?null:n};for(;e.getBitsLeft()>=8;){e.skipBits(1);let n=e.readBits(4),o=e.readBits(1),i=e.readBits(1);e.skipBits(1),o&&e.skipBits(8);let s;if(i){let a=t();if(a===null)return;s=a}else s=Math.floor(e.getBitsLeft()/8);h(e.pos%8===0),yield{type:n,data:r.subarray(e.pos/8,e.pos/8+s)},e.skipBits(s*8)}},So=r=>{for(let{type:e,data:t}of wl(r)){if(e!==1)continue;let n=new Z(t),o=n.readBits(3),i=n.readBits(1),s=n.readBits(1),a=0,l=0,c=0;if(s)a=n.readBits(5);else{if(n.readBits(1)&&(n.skipBits(32),n.skipBits(32),n.readBits(1)))return null;let C=n.readBits(1);C&&(c=n.readBits(5),n.skipBits(32),n.skipBits(5),n.skipBits(5));let O=n.readBits(5);for(let E=0;E<=O;E++){n.skipBits(12);let V=n.readBits(5);if(E===0&&(a=V),V>7){let G=n.readBits(1);E===0&&(l=G)}if(C&&n.readBits(1)){let ie=c+1;n.skipBits(ie),n.skipBits(ie),n.skipBits(1)}n.readBits(1)&&n.skipBits(4)}}let f=n.readBits(4),u=n.readBits(4),m=f+1;n.skipBits(m);let p=u+1;n.skipBits(p);let d=0;if(s?d=0:d=n.readBits(1),d&&(n.skipBits(4),n.skipBits(3)),n.skipBits(1),n.skipBits(1),n.skipBits(1),!s){n.skipBits(1),n.skipBits(1),n.skipBits(1),n.skipBits(1);let k=n.readBits(1);k&&(n.skipBits(1),n.skipBits(1));let C=n.readBits(1),O=0;C?O=2:O=n.readBits(1),O>0&&(n.readBits(1)||n.skipBits(1)),k&&n.skipBits(3)}n.skipBits(1),n.skipBits(1),n.skipBits(1);let g=n.readBits(1),x=8;o===2&&g?x=n.readBits(1)?12:10:o<=2&&(x=g?10:8);let y=0;o!==1&&(y=n.readBits(1));let v=1,T=1,S=0;return y||(o===0?(v=1,T=1):o===1?(v=0,T=0):x===12&&(v=n.readBits(1),v&&(T=n.readBits(1))),v&&T&&(S=n.readBits(2))),{profile:o,level:a,tier:l,bitDepth:x,monochrome:y,chromaSubsamplingX:v,chromaSubsamplingY:T,chromaSamplePosition:S}}return null},Cl=r=>{let e=K(r),t=e.getUint8(9),n=e.getUint16(10,!0),o=e.getUint32(12,!0),i=e.getInt16(16,!0),s=e.getUint8(18),a=null;return s&&(a=r.subarray(19,21+t)),{outputChannelCount:t,preSkip:n,inputSampleRate:o,outputGain:i,channelMappingFamily:s,channelMappingTable:a}},Ed=[480,960,1920,2880,480,960,1920,2880,480,960,1920,2880,480,960,480,960,120,240,480,960,120,240,480,960,120,240,480,960,120,240,480,960],kl=r=>{let e=r[0]>>3;return{durationInSamples:Ed[e]}},Pl=r=>{if(r.length<7)throw new Error("Setup header is too short.");if(r[0]!==5)throw new Error("Wrong packet type in Setup header.");if(String.fromCharCode(...r.slice(1,7))!=="vorbis")throw new Error("Invalid packet signature in Setup header.");let t=r.length,n=new Uint8Array(t);for(let u=0;u<t;u++)n[u]=r[t-1-u];let o=new Z(n),i=0;for(;o.getBitsLeft()>97;)if(o.readBits(1)===1){i=o.pos;break}if(i===0)throw new Error("Invalid Setup header: framing bit not found.");let s=0,a=!1,l=0;for(;o.getBitsLeft()>=97;){let u=o.pos,m=o.readBits(8),p=o.readBits(16),d=o.readBits(16);if(m>63||p!==0||d!==0){o.pos=u;break}if(o.skipBits(1),s++,s>64)break;o.clone().readBits(6)+1===s&&(a=!0,l=s)}if(!a)throw new Error("Invalid Setup header: mode header not found.");if(l>63)throw new Error(`Unsupported mode count: ${l}.`);let c=l;o.pos=0,o.skipBits(i);let f=Array(c).fill(0);for(let u=c-1;u>=0;u--)o.skipBits(40),f[u]=o.readBits(1);return{modeBlockflags:f}},To=(r,e,t)=>{switch(r){case"avc":{let n=Es(t,e),o=n.some(i=>Gt(i)===Vt.IDR);if(!o&&(!fn()||ml()>=144))for(let i of n){if(Gt(i)!==Vt.SEI)continue;let a=vo(i),l=1;do{let c=0;for(;;){let m=a[l++];if(m===void 0||(c+=m,m<255))break}let f=0;for(;;){let m=a[l++];if(m===void 0||(f+=m,m<255))break}if(c===6){let m=new Z(a);m.pos=8*l;let p=R(m),d=m.readBits(1);if(p===0&&d===1){o=!0;break}}l+=f}while(l<a.length-1)}return o?"key":"delta"}case"hevc":return Ds(t,e).some(i=>{let s=rt(i);return ye.BLA_W_LP<=s&&s<=ye.RSV_IRAP_VCL23})?"key":"delta";case"vp8":return(t[0]&1)===0?"key":"delta";case"vp9":{let n=new Z(t);if(n.readBits(2)!==2)return null;let o=n.readBits(1);return(n.readBits(1)<<1)+o===3&&n.skipBits(1),n.readBits(1)?null:n.readBits(1)===0?"key":"delta"}case"av1":{let n=!1;for(let{type:o,data:i}of wl(t))if(o===1){let s=new Z(i);s.skipBits(4),n=!!s.readBits(1)}else if(o===3||o===6||o===7){if(n)return"key";let s=new Z(i);return s.readBits(1)?null:s.readBits(2)===0?"key":"delta"}return null}default:Ae(r),h(!1)}},St;(function(r){r[r.STREAMINFO=0]="STREAMINFO",r[r.VORBIS_COMMENT=4]="VORBIS_COMMENT",r[r.PICTURE=6]="PICTURE"})(St||(St={}));var dn=(r,e)=>{let t=K(r),n=0,o=t.getUint32(n,!0);n+=4;let i=me.decode(r.subarray(n,n+o));n+=o,o>0&&(e.raw??={},e.raw.vendor??=i);let s=t.getUint32(n,!0);n+=4;for(let a=0;a<s;a++){let l=t.getUint32(n,!0);n+=4;let c=me.decode(r.subarray(n,n+l));n+=l;let f=c.indexOf("=");if(f===-1)continue;let u=c.slice(0,f).toUpperCase(),m=c.slice(f+1);switch(e.raw??={},e.raw[u]??=m,u){case"TITLE":e.title??=m;break;case"DESCRIPTION":e.description??=m;break;case"ARTIST":e.artist??=m;break;case"ALBUM":e.album??=m;break;case"ALBUMARTIST":e.albumArtist??=m;break;case"COMMENT":e.comment??=m;break;case"LYRICS":e.lyrics??=m;break;case"TRACKNUMBER":{let p=m.split("/"),d=Number.parseInt(p[0],10),g=p[1]&&Number.parseInt(p[1],10);Number.isInteger(d)&&d>0&&(e.trackNumber??=d),g&&Number.isInteger(g)&&g>0&&(e.tracksTotal??=g)}break;case"TRACKTOTAL":{let p=Number.parseInt(m,10);Number.isInteger(p)&&p>0&&(e.tracksTotal??=p)}break;case"DISCNUMBER":{let p=m.split("/"),d=Number.parseInt(p[0],10),g=p[1]&&Number.parseInt(p[1],10);Number.isInteger(d)&&d>0&&(e.discNumber??=d),g&&Number.isInteger(g)&&g>0&&(e.discsTotal??=g)}break;case"DISCTOTAL":{let p=Number.parseInt(m,10);Number.isInteger(p)&&p>0&&(e.discsTotal??=p)}break;case"DATE":{let p=new Date(m);Number.isNaN(p.getTime())||(e.date??=p)}break;case"GENRE":e.genre??=m;break;case"METADATA_BLOCK_PICTURE":{let p=pl(m),d=K(p),g=d.getUint32(0,!1),x=d.getUint32(4,!1),y=String.fromCharCode(...p.subarray(8,8+x)),v=d.getUint32(8+x,!1),T=me.decode(p.subarray(12+x,12+x+v)),S=d.getUint32(x+v+28),k=p.subarray(x+v+32,x+v+32+S);e.images??=[],e.images.push({data:k,mimeType:y,kind:g===3?"coverFront":g===4?"coverBack":"unknown",name:void 0,description:T||void 0})}break}}};var ge=class{constructor(e){this.input=e}};var wo=[],Co=[];var le=new Uint8Array(0),te=class r{constructor(e,t,n,o,i=-1,s,a){if(this.data=e,this.type=t,this.timestamp=n,this.duration=o,this.sequenceNumber=i,e===le&&s===void 0)throw new Error("Internal error: byteLength must be explicitly provided when constructing metadata-only packets.");if(s===void 0&&(s=e.byteLength),!(e instanceof Uint8Array))throw new TypeError("data must be a Uint8Array.");if(t!=="key"&&t!=="delta")throw new TypeError('type must be either "key" or "delta".');if(!Number.isFinite(n))throw new TypeError("timestamp must be a number.");if(!Number.isFinite(o)||o<0)throw new TypeError("duration must be a non-negative number.");if(!Number.isFinite(i))throw new TypeError("sequenceNumber must be a number.");if(!Number.isInteger(s)||s<0)throw new TypeError("byteLength must be a non-negative integer.");if(a!==void 0&&(typeof a!="object"||!a))throw new TypeError("sideData, when provided, must be an object.");if(a?.alpha!==void 0&&!(a.alpha instanceof Uint8Array))throw new TypeError("sideData.alpha, when provided, must be a Uint8Array.");if(a?.alphaByteLength!==void 0&&(!Number.isInteger(a.alphaByteLength)||a.alphaByteLength<0))throw new TypeError("sideData.alphaByteLength, when provided, must be a non-negative integer.");this.byteLength=s,this.sideData=a??{},this.sideData.alpha&&this.sideData.alphaByteLength===void 0&&(this.sideData.alphaByteLength=this.sideData.alpha.byteLength)}get isMetadataOnly(){return this.data===le}get microsecondTimestamp(){return Math.trunc(Xe*this.timestamp)}get microsecondDuration(){return Math.trunc(Xe*this.duration)}toEncodedVideoChunk(){if(this.isMetadataOnly)throw new TypeError("Metadata-only packets cannot be converted to a video chunk.");if(typeof EncodedVideoChunk>"u")throw new Error("Your browser does not support EncodedVideoChunk.");return new EncodedVideoChunk({data:this.data,type:this.type,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}alphaToEncodedVideoChunk(e=this.type){if(!this.sideData.alpha)throw new TypeError("This packet does not contain alpha side data.");if(this.isMetadataOnly)throw new TypeError("Metadata-only packets cannot be converted to a video chunk.");if(typeof EncodedVideoChunk>"u")throw new Error("Your browser does not support EncodedVideoChunk.");return new EncodedVideoChunk({data:this.sideData.alpha,type:e,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}toEncodedAudioChunk(){if(this.isMetadataOnly)throw new TypeError("Metadata-only packets cannot be converted to an audio chunk.");if(typeof EncodedAudioChunk>"u")throw new Error("Your browser does not support EncodedAudioChunk.");return new EncodedAudioChunk({data:this.data,type:this.type,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}static fromEncodedChunk(e,t){if(!(e instanceof EncodedVideoChunk||e instanceof EncodedAudioChunk))throw new TypeError("chunk must be an EncodedVideoChunk or EncodedAudioChunk.");let n=new Uint8Array(e.byteLength);return e.copyTo(n),new r(n,e.type,e.timestamp/1e6,(e.duration??0)/1e6,void 0,void 0,t)}clone(e){if(e!==void 0&&(typeof e!="object"||e===null))throw new TypeError("options, when provided, must be an object.");if(e?.timestamp!==void 0&&!Number.isFinite(e.timestamp))throw new TypeError("options.timestamp, when provided, must be a number.");if(e?.duration!==void 0&&!Number.isFinite(e.duration))throw new TypeError("options.duration, when provided, must be a number.");return new r(this.data,this.type,e?.timestamp??this.timestamp,e?.duration??this.duration,this.sequenceNumber,this.byteLength)}};var _l=r=>{let t=0,n=0,o=~r;o&128&&(o&=-129,t=-1),n=((o&240)>>4)+5;let i=(1<<n|(o&15)<<n-4|1<<n-5)-33;return t===0?i:-i};var Il=r=>{let e=0,t=0,n=r^85;n&128&&(n&=-129,e=-1),t=((n&240)>>4)+4;let o=0;return t!==4?o=1<<t|(n&15)<<t-4|1<<t-5:o=n<<1|1,e===0?o:-o};mo();var Al=-1/0,Fl=-1/0,xn=null;typeof FinalizationRegistry<"u"&&(xn=new FinalizationRegistry(r=>{let e=Date.now();r.type==="video"?(e-Al>=1e3&&(console.error("A VideoSample was garbage collected without first being closed. For proper resource management, make sure to call close() on all your VideoSamples as soon as you're done using them."),Al=e),typeof VideoFrame<"u"&&r.data instanceof VideoFrame&&r.data.close()):(e-Fl>=1e3&&(console.error("An AudioSample was garbage collected without first being closed. For proper resource management, make sure to call close() on all your AudioSamples as soon as you're done using them."),Fl=e),typeof AudioData<"u"&&r.data instanceof AudioData&&r.data.close())}));var zl=["I420","I420P10","I420P12","I420A","I420AP10","I420AP12","I422","I422P10","I422P12","I422A","I422AP10","I422AP12","I444","I444P10","I444P12","I444A","I444AP10","I444AP12","NV12","RGBA","RGBX","BGRA","BGRX"],zd=new Set(zl),gr=class r{get displayWidth(){return this.rotation%180===0?this.codedWidth:this.codedHeight}get displayHeight(){return this.rotation%180===0?this.codedHeight:this.codedWidth}get microsecondTimestamp(){return Math.trunc(Xe*this.timestamp)}get microsecondDuration(){return Math.trunc(Xe*this.duration)}get hasAlpha(){return this.format&&this.format.includes("A")}constructor(e,t){if(this._closed=!1,e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer||ArrayBuffer.isView(e)){if(!t||typeof t!="object")throw new TypeError("init must be an object.");if(t.format===void 0||!zd.has(t.format))throw new TypeError("init.format must be one of: "+zl.join(", "));if(!Number.isInteger(t.codedWidth)||t.codedWidth<=0)throw new TypeError("init.codedWidth must be a positive integer.");if(!Number.isInteger(t.codedHeight)||t.codedHeight<=0)throw new TypeError("init.codedHeight must be a positive integer.");if(t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw new TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");if(!Number.isFinite(t.timestamp))throw new TypeError("init.timestamp must be a number.");if(t.duration!==void 0&&(!Number.isFinite(t.duration)||t.duration<0))throw new TypeError("init.duration, when provided, must be a non-negative number.");this._data=ze(e).slice(),this._layout=t.layout??Dd(t.format,t.codedWidth,t.codedHeight),this.format=t.format,this.codedWidth=t.codedWidth,this.codedHeight=t.codedHeight,this.rotation=t.rotation??0,this.timestamp=t.timestamp,this.duration=t.duration??0,this.colorSpace=new gn(t.colorSpace)}else if(typeof VideoFrame<"u"&&e instanceof VideoFrame){if(t?.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw new TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");if(t?.timestamp!==void 0&&!Number.isFinite(t?.timestamp))throw new TypeError("init.timestamp, when provided, must be a number.");if(t?.duration!==void 0&&(!Number.isFinite(t.duration)||t.duration<0))throw new TypeError("init.duration, when provided, must be a non-negative number.");this._data=e,this._layout=null,this.format=e.format,this.codedWidth=e.displayWidth,this.codedHeight=e.displayHeight,this.rotation=t?.rotation??0,this.timestamp=t?.timestamp??e.timestamp/1e6,this.duration=t?.duration??(e.duration??0)/1e6,this.colorSpace=new gn(e.colorSpace)}else if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof SVGImageElement<"u"&&e instanceof SVGImageElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas){if(!t||typeof t!="object")throw new TypeError("init must be an object.");if(t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw new TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");if(!Number.isFinite(t.timestamp))throw new TypeError("init.timestamp must be a number.");if(t.duration!==void 0&&(!Number.isFinite(t.duration)||t.duration<0))throw new TypeError("init.duration, when provided, must be a non-negative number.");if(typeof VideoFrame<"u")return new r(new VideoFrame(e,{timestamp:Math.trunc(t.timestamp*Xe),duration:Math.trunc((t.duration??0)*Xe)||void 0}),t);let n=0,o=0;if("naturalWidth"in e?(n=e.naturalWidth,o=e.naturalHeight):"videoWidth"in e?(n=e.videoWidth,o=e.videoHeight):"width"in e&&(n=Number(e.width),o=Number(e.height)),!n||!o)throw new TypeError("Could not determine dimensions.");let i=new OffscreenCanvas(n,o),s=i.getContext("2d",{alpha:_s(),willReadFrequently:!0});h(s),s.drawImage(e,0,0),this._data=i,this._layout=null,this.format="RGBX",this.codedWidth=n,this.codedHeight=o,this.rotation=t.rotation??0,this.timestamp=t.timestamp,this.duration=t.duration??0,this.colorSpace=new gn({matrix:"rgb",primaries:"bt709",transfer:"iec61966-2-1",fullRange:!0})}else throw new TypeError("Invalid data type: Must be a BufferSource or CanvasImageSource.");xn?.register(this,{type:"video",data:this._data},this)}clone(){if(this._closed)throw new Error("VideoSample is closed.");return h(this._data!==null),qt(this._data)?new r(this._data.clone(),{timestamp:this.timestamp,duration:this.duration,rotation:this.rotation}):this._data instanceof Uint8Array?(h(this._layout),new r(this._data,{format:this.format,layout:this._layout,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.timestamp,duration:this.duration,colorSpace:this.colorSpace,rotation:this.rotation})):new r(this._data,{format:this.format,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.timestamp,duration:this.duration,colorSpace:this.colorSpace,rotation:this.rotation})}close(){this._closed||(xn?.unregister(this),qt(this._data)?this._data.close():this._data=null,this._closed=!0)}allocationSize(e={}){if(El(e),this._closed)throw new Error("VideoSample is closed.");if((e.format??this.format)===null)throw new Error("Cannot get allocation size when format is null. Please manually provide an RGB pixel format in the options instead.");if(h(this._data!==null),!qt(this._data)&&(e.colorSpace||e.format&&e.format!==this.format||e.layout||e.rect)){let t=this.toVideoFrame(),n=t.allocationSize(e);return t.close(),n}return qt(this._data)?this._data.allocationSize(e):this._data instanceof Uint8Array?this._data.byteLength:this.codedWidth*this.codedHeight*4}async copyTo(e,t={}){if(!lo(e))throw new TypeError("destination must be an ArrayBuffer or an ArrayBuffer view.");if(El(t),this._closed)throw new Error("VideoSample is closed.");if((t.format??this.format)===null)throw new Error("Cannot copy video sample data when format is null. Please manually provide an RGB pixel format in the options instead.");if(h(this._data!==null),!qt(this._data)&&(t.colorSpace||t.format&&t.format!==this.format||t.layout||t.rect)){let n=this.toVideoFrame(),o=await n.copyTo(e,t);return n.close(),o}if(qt(this._data))return this._data.copyTo(e,t);if(this._data instanceof Uint8Array)return h(this._layout),ze(e).set(this._data),this._layout;{let o=this._data.getContext("2d");h(o);let i=o.getImageData(0,0,this.codedWidth,this.codedHeight);return ze(e).set(i.data),[{offset:0,stride:4*this.codedWidth}]}}toVideoFrame(){if(this._closed)throw new Error("VideoSample is closed.");return h(this._data!==null),qt(this._data)?new VideoFrame(this._data,{timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0}):this._data instanceof Uint8Array?new VideoFrame(this._data,{format:this.format,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0,colorSpace:this.colorSpace}):new VideoFrame(this._data,{timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0})}draw(e,t,n,o,i,s,a,l,c){let f=0,u=0,m=this.displayWidth,p=this.displayHeight,d=0,g=0,x=this.displayWidth,y=this.displayHeight;if(s!==void 0?(f=t,u=n,m=o,p=i,d=s,g=a,l!==void 0?(x=l,y=c):(x=m,y=p)):(d=t,g=n,o!==void 0&&(x=o,y=i)),!(typeof CanvasRenderingContext2D<"u"&&e instanceof CanvasRenderingContext2D||typeof OffscreenCanvasRenderingContext2D<"u"&&e instanceof OffscreenCanvasRenderingContext2D))throw new TypeError("context must be a CanvasRenderingContext2D or OffscreenCanvasRenderingContext2D.");if(!Number.isFinite(f))throw new TypeError("sx must be a number.");if(!Number.isFinite(u))throw new TypeError("sy must be a number.");if(!Number.isFinite(m)||m<0)throw new TypeError("sWidth must be a non-negative number.");if(!Number.isFinite(p)||p<0)throw new TypeError("sHeight must be a non-negative number.");if(!Number.isFinite(d))throw new TypeError("dx must be a number.");if(!Number.isFinite(g))throw new TypeError("dy must be a number.");if(!Number.isFinite(x)||x<0)throw new TypeError("dWidth must be a non-negative number.");if(!Number.isFinite(y)||y<0)throw new TypeError("dHeight must be a non-negative number.");if(this._closed)throw new Error("VideoSample is closed.");({sx:f,sy:u,sWidth:m,sHeight:p}=this._rotateSourceRegion(f,u,m,p,this.rotation));let v=this.toCanvasImageSource();e.save();let T=d+x/2,S=g+y/2;e.translate(T,S),e.rotate(this.rotation*Math.PI/180);let k=this.rotation%180===0?1:x/y;e.scale(1/k,k),e.drawImage(v,f,u,m,p,-x/2,-y/2,x,y),e.restore()}drawWithFit(e,t){if(!(typeof CanvasRenderingContext2D<"u"&&e instanceof CanvasRenderingContext2D||typeof OffscreenCanvasRenderingContext2D<"u"&&e instanceof OffscreenCanvasRenderingContext2D))throw new TypeError("context must be a CanvasRenderingContext2D or OffscreenCanvasRenderingContext2D.");if(!t||typeof t!="object")throw new TypeError("options must be an object.");if(!["fill","contain","cover"].includes(t.fit))throw new TypeError("options.fit must be 'fill', 'contain', or 'cover'.");if(t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw new TypeError("options.rotation, when provided, must be 0, 90, 180, or 270.");t.crop!==void 0&&Ol(t.crop,"options.");let n=e.canvas.width,o=e.canvas.height,i=t.rotation??this.rotation,[s,a]=i%180===0?[this.codedWidth,this.codedHeight]:[this.codedHeight,this.codedWidth];t.crop&&Dl(t.crop,s,a);let l,c,f,u,{sx:m,sy:p,sWidth:d,sHeight:g}=this._rotateSourceRegion(t.crop?.left??0,t.crop?.top??0,t.crop?.width??s,t.crop?.height??a,i);if(t.fit==="fill")l=0,c=0,f=n,u=o;else{let[y,v]=t.crop?[t.crop.width,t.crop.height]:[s,a],T=t.fit==="contain"?Math.min(n/y,o/v):Math.max(n/y,o/v);f=y*T,u=v*T,l=(n-f)/2,c=(o-u)/2}e.save();let x=i%180===0?1:f/u;e.translate(n/2,o/2),e.rotate(i*Math.PI/180),e.scale(1/x,x),e.translate(-n/2,-o/2),e.drawImage(this.toCanvasImageSource(),m,p,d,g,l,c,f,u),e.restore()}_rotateSourceRegion(e,t,n,o,i){return i===90?[e,t,n,o]=[t,this.codedHeight-e-n,o,n]:i===180?[e,t]=[this.codedWidth-e-n,this.codedHeight-t-o]:i===270&&([e,t,n,o]=[this.codedWidth-t-o,e,o,n]),{sx:e,sy:t,sWidth:n,sHeight:o}}toCanvasImageSource(){if(this._closed)throw new Error("VideoSample is closed.");if(h(this._data!==null),this._data instanceof Uint8Array){let e=this.toVideoFrame();return queueMicrotask(()=>e.close()),e}else return this._data}setRotation(e){if(![0,90,180,270].includes(e))throw new TypeError("newRotation must be 0, 90, 180, or 270.");this.rotation=e}setTimestamp(e){if(!Number.isFinite(e))throw new TypeError("newTimestamp must be a number.");this.timestamp=e}setDuration(e){if(!Number.isFinite(e)||e<0)throw new TypeError("newDuration must be a non-negative number.");this.duration=e}[Symbol.dispose](){this.close()}},gn=class{constructor(e){this.primaries=e?.primaries??null,this.transfer=e?.transfer??null,this.matrix=e?.matrix??null,this.fullRange=e?.fullRange??null}toJSON(){return{primaries:this.primaries,transfer:this.transfer,matrix:this.matrix,fullRange:this.fullRange}}},qt=r=>typeof VideoFrame<"u"&&r instanceof VideoFrame,Dl=(r,e,t)=>{r.left=Math.min(r.left,e),r.top=Math.min(r.top,t),r.width=Math.min(r.width,e-r.left),r.height=Math.min(r.height,t-r.top),h(r.width>=0),h(r.height>=0)},Ol=(r,e)=>{if(!r||typeof r!="object")throw new TypeError(e+"crop, when provided, must be an object.");if(!Number.isInteger(r.left)||r.left<0)throw new TypeError(e+"crop.left must be a non-negative integer.");if(!Number.isInteger(r.top)||r.top<0)throw new TypeError(e+"crop.top must be a non-negative integer.");if(!Number.isInteger(r.width)||r.width<0)throw new TypeError(e+"crop.width must be a non-negative integer.");if(!Number.isInteger(r.height)||r.height<0)throw new TypeError(e+"crop.height must be a non-negative integer.")},El=r=>{if(!r||typeof r!="object")throw new TypeError("options must be an object.");if(r.colorSpace!==void 0&&!["display-p3","srgb"].includes(r.colorSpace))throw new TypeError("options.colorSpace, when provided, must be 'display-p3' or 'srgb'.");if(r.format!==void 0&&typeof r.format!="string")throw new TypeError("options.format, when provided, must be a string.");if(r.layout!==void 0){if(!Array.isArray(r.layout))throw new TypeError("options.layout, when provided, must be an array.");for(let e of r.layout){if(!e||typeof e!="object")throw new TypeError("Each entry in options.layout must be an object.");if(!Number.isInteger(e.offset)||e.offset<0)throw new TypeError("plane.offset must be a non-negative integer.");if(!Number.isInteger(e.stride)||e.stride<0)throw new TypeError("plane.stride must be a non-negative integer.")}}if(r.rect!==void 0){if(!r.rect||typeof r.rect!="object")throw new TypeError("options.rect, when provided, must be an object.");if(r.rect.x!==void 0&&(!Number.isInteger(r.rect.x)||r.rect.x<0))throw new TypeError("options.rect.x, when provided, must be a non-negative integer.");if(r.rect.y!==void 0&&(!Number.isInteger(r.rect.y)||r.rect.y<0))throw new TypeError("options.rect.y, when provided, must be a non-negative integer.");if(r.rect.width!==void 0&&(!Number.isInteger(r.rect.width)||r.rect.width<0))throw new TypeError("options.rect.width, when provided, must be a non-negative integer.");if(r.rect.height!==void 0&&(!Number.isInteger(r.rect.height)||r.rect.height<0))throw new TypeError("options.rect.height, when provided, must be a non-negative integer.")}},Dd=(r,e,t)=>{let n=Od(r),o=[],i=0;for(let s of n){let a=Math.ceil(e/s.widthDivisor),l=Math.ceil(t/s.heightDivisor),c=a*s.sampleBytes,f=c*l;o.push({offset:i,stride:c}),i+=f}return o},Od=r=>{let e=(t,n,o,i,s)=>{let a=[{sampleBytes:t,widthDivisor:1,heightDivisor:1},{sampleBytes:n,widthDivisor:o,heightDivisor:i},{sampleBytes:n,widthDivisor:o,heightDivisor:i}];return s&&a.push({sampleBytes:t,widthDivisor:1,heightDivisor:1}),a};switch(r){case"I420":return e(1,1,2,2,!1);case"I420P10":case"I420P12":return e(2,2,2,2,!1);case"I420A":return e(1,1,2,2,!0);case"I420AP10":case"I420AP12":return e(2,2,2,2,!0);case"I422":return e(1,1,2,1,!1);case"I422P10":case"I422P12":return e(2,2,2,1,!1);case"I422A":return e(1,1,2,1,!0);case"I422AP10":case"I422AP12":return e(2,2,2,1,!0);case"I444":return e(1,1,1,1,!1);case"I444P10":case"I444P12":return e(2,2,1,1,!1);case"I444A":return e(1,1,1,1,!0);case"I444AP10":case"I444AP12":return e(2,2,1,1,!0);case"NV12":return[{sampleBytes:1,widthDivisor:1,heightDivisor:1},{sampleBytes:2,widthDivisor:2,heightDivisor:2}];case"RGBA":case"RGBX":case"BGRA":case"BGRX":return[{sampleBytes:4,widthDivisor:1,heightDivisor:1}];default:Ae(r),h(!1)}},Os=new Set(["f32","f32-planar","s16","s16-planar","s32","s32-planar","u8","u8-planar"]),xr=class r{get microsecondTimestamp(){return Math.trunc(Xe*this.timestamp)}get microsecondDuration(){return Math.trunc(Xe*this.duration)}constructor(e){if(this._closed=!1,hn(e)){if(e.format===null)throw new TypeError("AudioData with null format is not supported.");this._data=e,this.format=e.format,this.sampleRate=e.sampleRate,this.numberOfFrames=e.numberOfFrames,this.numberOfChannels=e.numberOfChannels,this.timestamp=e.timestamp/1e6,this.duration=e.numberOfFrames/e.sampleRate}else{if(!e||typeof e!="object")throw new TypeError("Invalid AudioDataInit: must be an object.");if(!Os.has(e.format))throw new TypeError("Invalid AudioDataInit: invalid format.");if(!Number.isFinite(e.sampleRate)||e.sampleRate<=0)throw new TypeError("Invalid AudioDataInit: sampleRate must be > 0.");if(!Number.isInteger(e.numberOfChannels)||e.numberOfChannels===0)throw new TypeError("Invalid AudioDataInit: numberOfChannels must be an integer > 0.");if(!Number.isFinite(e?.timestamp))throw new TypeError("init.timestamp must be a number.");let t=e.data.byteLength/(Ht(e.format)*e.numberOfChannels);if(!Number.isInteger(t))throw new TypeError("Invalid AudioDataInit: data size is not a multiple of frame size.");this.format=e.format,this.sampleRate=e.sampleRate,this.numberOfFrames=t,this.numberOfChannels=e.numberOfChannels,this.timestamp=e.timestamp,this.duration=t/e.sampleRate;let n;if(e.data instanceof ArrayBuffer)n=new Uint8Array(e.data);else if(ArrayBuffer.isView(e.data))n=new Uint8Array(e.data.buffer,e.data.byteOffset,e.data.byteLength);else throw new TypeError("Invalid AudioDataInit: data is not a BufferSource.");let o=this.numberOfFrames*this.numberOfChannels*Ht(this.format);if(n.byteLength<o)throw new TypeError("Invalid AudioDataInit: insufficient data size.");this._data=n}xn?.register(this,{type:"audio",data:this._data},this)}allocationSize(e){if(!e||typeof e!="object")throw new TypeError("options must be an object.");if(!Number.isInteger(e.planeIndex)||e.planeIndex<0)throw new TypeError("planeIndex must be a non-negative integer.");if(e.format!==void 0&&!Os.has(e.format))throw new TypeError("Invalid format.");if(e.frameOffset!==void 0&&(!Number.isInteger(e.frameOffset)||e.frameOffset<0))throw new TypeError("frameOffset must be a non-negative integer.");if(e.frameCount!==void 0&&(!Number.isInteger(e.frameCount)||e.frameCount<0))throw new TypeError("frameCount must be a non-negative integer.");if(this._closed)throw new Error("AudioSample is closed.");let t=e.format??this.format,n=e.frameOffset??0;if(n>=this.numberOfFrames)throw new RangeError("frameOffset out of range");let o=e.frameCount!==void 0?e.frameCount:this.numberOfFrames-n;if(o>this.numberOfFrames-n)throw new RangeError("frameCount out of range");let i=Ht(t),s=hr(t);if(s&&e.planeIndex>=this.numberOfChannels)throw new RangeError("planeIndex out of range");if(!s&&e.planeIndex!==0)throw new RangeError("planeIndex out of range");return(s?o:o*this.numberOfChannels)*i}copyTo(e,t){if(!lo(e))throw new TypeError("destination must be an ArrayBuffer or an ArrayBuffer view.");if(!t||typeof t!="object")throw new TypeError("options must be an object.");if(!Number.isInteger(t.planeIndex)||t.planeIndex<0)throw new TypeError("planeIndex must be a non-negative integer.");if(t.format!==void 0&&!Os.has(t.format))throw new TypeError("Invalid format.");if(t.frameOffset!==void 0&&(!Number.isInteger(t.frameOffset)||t.frameOffset<0))throw new TypeError("frameOffset must be a non-negative integer.");if(t.frameCount!==void 0&&(!Number.isInteger(t.frameCount)||t.frameCount<0))throw new TypeError("frameCount must be a non-negative integer.");if(this._closed)throw new Error("AudioSample is closed.");let{planeIndex:n,format:o,frameCount:i,frameOffset:s}=t,a=this.format,l=o??this.format;if(!l)throw new Error("Destination format not determined");let c=this.numberOfFrames,f=this.numberOfChannels,u=s??0;if(u>=c)throw new RangeError("frameOffset out of range");let m=i!==void 0?i:c-u;if(m>c-u)throw new RangeError("frameCount out of range");let p=Ht(l),d=hr(l);if(d&&n>=f)throw new RangeError("planeIndex out of range");if(!d&&n!==0)throw new RangeError("planeIndex out of range");let x=(d?m:m*f)*p;if(e.byteLength<x)throw new RangeError("Destination buffer is too small");let y=K(e),v=Ml(l);if(hn(this._data))vt()&&f>2&&l!==a?Rd(this._data,y,a,l,f,n,u,m):this._data.copyTo(e,{planeIndex:n,frameOffset:u,frameCount:m,format:l});else{let T=this._data,S=K(T),k=Rl(a),C=Ht(a),O=hr(a);for(let E=0;E<m;E++)if(d){let V=E*p,q;O?q=(n*c+(E+u))*C:q=((E+u)*f+n)*C;let G=k(S,q);v(y,V,G)}else for(let V=0;V<f;V++){let G=(E*f+V)*p,ie;O?ie=(V*c+(E+u))*C:ie=((E+u)*f+V)*C;let Ue=k(S,ie);v(y,G,Ue)}}}clone(){if(this._closed)throw new Error("AudioSample is closed.");if(hn(this._data)){let e=new r(this._data.clone());return e.setTimestamp(this.timestamp),e}else return new r({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.timestamp,data:this._data})}close(){this._closed||(xn?.unregister(this),hn(this._data)?this._data.close():this._data=new Uint8Array(0),this._closed=!0)}toAudioData(){if(this._closed)throw new Error("AudioSample is closed.");if(hn(this._data)){if(this._data.timestamp===this.microsecondTimestamp)return this._data.clone();if(hr(this.format)){let e=this.allocationSize({planeIndex:0,format:this.format}),t=new ArrayBuffer(e*this.numberOfChannels);for(let n=0;n<this.numberOfChannels;n++)this.copyTo(new Uint8Array(t,n*e,e),{planeIndex:n,format:this.format});return new AudioData({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.microsecondTimestamp,data:t})}else{let e=new ArrayBuffer(this.allocationSize({planeIndex:0,format:this.format}));return this.copyTo(e,{planeIndex:0,format:this.format}),new AudioData({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.microsecondTimestamp,data:e})}}else return new AudioData({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.microsecondTimestamp,data:this._data.buffer instanceof ArrayBuffer?this._data.buffer:this._data.slice()})}toAudioBuffer(){if(this._closed)throw new Error("AudioSample is closed.");let e=new AudioBuffer({numberOfChannels:this.numberOfChannels,length:this.numberOfFrames,sampleRate:this.sampleRate}),t=new Float32Array(this.allocationSize({planeIndex:0,format:"f32-planar"})/4);for(let n=0;n<this.numberOfChannels;n++)this.copyTo(t,{planeIndex:n,format:"f32-planar"}),e.copyToChannel(t,n);return e}setTimestamp(e){if(!Number.isFinite(e))throw new TypeError("newTimestamp must be a number.");this.timestamp=e}[Symbol.dispose](){this.close()}static*_fromAudioBuffer(e,t){if(!(e instanceof AudioBuffer))throw new TypeError("audioBuffer must be an AudioBuffer.");let n=48e3*5,o=e.numberOfChannels,i=e.sampleRate,s=e.length,a=Math.floor(n/o),l=0,c=s;for(;c>0;){let f=Math.min(a,c),u=new Float32Array(o*f);for(let m=0;m<o;m++)e.copyFromChannel(u.subarray(m*f,(m+1)*f),m,l);yield new r({format:"f32-planar",sampleRate:i,numberOfFrames:f,numberOfChannels:o,timestamp:t+l/i,data:u}),l+=f,c-=f}}static fromAudioBuffer(e,t){if(!(e instanceof AudioBuffer))throw new TypeError("audioBuffer must be an AudioBuffer.");let n=48e3*5,o=e.numberOfChannels,i=e.sampleRate,s=e.length,a=Math.floor(n/o),l=0,c=s,f=[];for(;c>0;){let u=Math.min(a,c),m=new Float32Array(o*u);for(let d=0;d<o;d++)e.copyFromChannel(m.subarray(d*u,(d+1)*u),d,l);let p=new r({format:"f32-planar",sampleRate:i,numberOfFrames:u,numberOfChannels:o,timestamp:t+l/i,data:m});f.push(p),l+=u,c-=u}return f}},Ht=r=>{switch(r){case"u8":case"u8-planar":return 1;case"s16":case"s16-planar":return 2;case"s32":case"s32-planar":return 4;case"f32":case"f32-planar":return 4;default:throw new Error("Unknown AudioSampleFormat")}},hr=r=>{switch(r){case"u8-planar":case"s16-planar":case"s32-planar":case"f32-planar":return!0;default:return!1}},Rl=r=>{switch(r){case"u8":case"u8-planar":return(e,t)=>(e.getUint8(t)-128)/128;case"s16":case"s16-planar":return(e,t)=>e.getInt16(t,!0)/32768;case"s32":case"s32-planar":return(e,t)=>e.getInt32(t,!0)/2147483648;case"f32":case"f32-planar":return(e,t)=>e.getFloat32(t,!0)}},Ml=r=>{switch(r){case"u8":case"u8-planar":return(e,t,n)=>e.setUint8(t,Mt((n+1)*127.5,0,255));case"s16":case"s16-planar":return(e,t,n)=>e.setInt16(t,Mt(Math.round(n*32767),-32768,32767),!0);case"s32":case"s32-planar":return(e,t,n)=>e.setInt32(t,Mt(Math.round(n*2147483647),-2147483648,2147483647),!0);case"f32":case"f32-planar":return(e,t,n)=>e.setFloat32(t,n,!0)}},hn=r=>typeof AudioData<"u"&&r instanceof AudioData,Rd=(r,e,t,n,o,i,s,a)=>{let l=Rl(t),c=Ml(n),f=Ht(t),u=Ht(n),m=hr(t);if(hr(n))if(m){let d=new ArrayBuffer(a*f),g=K(d);r.copyTo(d,{planeIndex:i,frameOffset:s,frameCount:a,format:t});for(let x=0;x<a;x++){let y=x*f,v=x*u,T=l(g,y);c(e,v,T)}}else{let d=new ArrayBuffer(a*o*f),g=K(d);r.copyTo(d,{planeIndex:0,frameOffset:s,frameCount:a,format:t});for(let x=0;x<a;x++){let y=(x*o+i)*f,v=x*u,T=l(g,y);c(e,v,T)}}else if(m){let d=a*f,g=new ArrayBuffer(d),x=K(g);for(let y=0;y<o;y++){r.copyTo(g,{planeIndex:y,frameOffset:s,frameCount:a,format:t});for(let v=0;v<a;v++){let T=v*f,S=(v*o+y)*u,k=l(x,T);c(e,S,k)}}}else{let d=new ArrayBuffer(a*o*f),g=K(d);r.copyTo(d,{planeIndex:0,frameOffset:s,frameCount:a,format:t});for(let x=0;x<a;x++)for(let y=0;y<o;y++){let v=x*o+y,T=v*f,S=v*u,k=l(g,T);c(e,S,k)}}};var vr=r=>{if(!r||typeof r!="object")throw new TypeError("options must be an object.");if(r.metadataOnly!==void 0&&typeof r.metadataOnly!="boolean")throw new TypeError("options.metadataOnly, when defined, must be a boolean.");if(r.verifyKeyPackets!==void 0&&typeof r.verifyKeyPackets!="boolean")throw new TypeError("options.verifyKeyPackets, when defined, must be a boolean.");if(r.verifyKeyPackets&&r.metadataOnly)throw new TypeError("options.verifyKeyPackets and options.metadataOnly cannot be enabled together.")},Wt=r=>{if(!mn(r))throw new TypeError("timestamp must be a number.")},Rs=(r,e,t)=>t.verifyKeyPackets?e.then(async n=>{if(!n||n.type==="delta")return n;let o=await r.determinePacketType(n);return o&&(n.type=o),n}):e,jt=class{constructor(e){if(!(e instanceof yr))throw new TypeError("track must be an InputTrack.");this._track=e}getFirstPacket(e={}){if(vr(e),this._track.input._disposed)throw new ce;return Rs(this._track,this._track._backing.getFirstPacket(e),e)}getPacket(e,t={}){if(Wt(e),vr(t),this._track.input._disposed)throw new ce;return Rs(this._track,this._track._backing.getPacket(e,t),t)}getNextPacket(e,t={}){if(!(e instanceof te))throw new TypeError("packet must be an EncodedPacket.");if(vr(t),this._track.input._disposed)throw new ce;return Rs(this._track,this._track._backing.getNextPacket(e,t),t)}async getKeyPacket(e,t={}){if(Wt(e),vr(t),this._track.input._disposed)throw new ce;if(!t.verifyKeyPackets)return this._track._backing.getKeyPacket(e,t);let n=await this._track._backing.getKeyPacket(e,t);return n&&(h(n.type==="key"),await this._track.determinePacketType(n)==="delta"?this.getKeyPacket(n.timestamp-1/this._track.timeResolution,t):n)}async getNextKeyPacket(e,t={}){if(!(e instanceof te))throw new TypeError("packet must be an EncodedPacket.");if(vr(t),this._track.input._disposed)throw new ce;if(!t.verifyKeyPackets)return this._track._backing.getNextKeyPacket(e,t);let n=await this._track._backing.getNextKeyPacket(e,t);return n&&(h(n.type==="key"),await this._track.determinePacketType(n)==="delta"?this.getNextKeyPacket(n,t):n)}packets(e,t,n={}){if(e!==void 0&&!(e instanceof te))throw new TypeError("startPacket must be an EncodedPacket.");if(e!==void 0&&e.isMetadataOnly&&!n?.metadataOnly)throw new TypeError("startPacket can only be metadata-only if options.metadataOnly is enabled.");if(t!==void 0&&!(t instanceof te))throw new TypeError("endPacket must be an EncodedPacket.");if(vr(n),this._track.input._disposed)throw new ce;let o=[],{promise:i,resolve:s}=ve(),{promise:a,resolve:l}=ve(),c=!1,f=!1,u=null,m=[],p=()=>Math.max(2,m.length);(async()=>{let g=e??await this.getFirstPacket(n);for(;g&&!f&&!this._track.input._disposed&&!(t&&g.sequenceNumber>=t?.sequenceNumber);){if(o.length>p()){({promise:a,resolve:l}=ve()),await a;continue}o.push(g),s(),{promise:i,resolve:s}=ve(),g=await this.getNextPacket(g,n)}c=!0,s()})().catch(g=>{u||(u=g,s())});let d=this._track;return{async next(){for(;;){if(d.input._disposed)throw new ce;if(f)return{value:void 0,done:!0};if(u)throw u;if(o.length>0){let g=o.shift(),x=performance.now();for(m.push(x);m.length>0&&x-m[0]>=1e3;)m.shift();return l(),{value:g,done:!1}}else{if(c)return{value:void 0,done:!0};await i}}},async return(){return f=!0,l(),s(),{value:void 0,done:!0}},async throw(g){throw g},[Symbol.asyncIterator](){return this}}}},vn=class{constructor(e,t){this.onSample=e,this.onError=t}},yn=class{mediaSamplesInRange(e=0,t=1/0){Wt(e),Wt(t);let n=[],o=!1,i=null,{promise:s,resolve:a}=ve(),{promise:l,resolve:c}=ve(),f=!1,u=!1,m=!1,p=null;(async()=>{let x=await this._createDecoder(C=>{if(c(),C.timestamp>=t&&(u=!0),u){C.close();return}i&&(C.timestamp>e?(n.push(i),o=!0):i.close()),C.timestamp>=e&&(n.push(C),o=!0),i=o?null:C,n.length>0&&(a(),{promise:s,resolve:a}=ve())},C=>{p||(p=C,a())}),y=this._createPacketSink(),v=await y.getKeyPacket(e,{verifyKeyPackets:!0})??await y.getFirstPacket(),T=v,S;if(t<1/0){let C=await y.getPacket(t),O=C?C.type==="key"&&C.timestamp===t?C:await y.getNextKeyPacket(C,{verifyKeyPackets:!0}):null;O&&(S=O)}let k=y.packets(v??void 0,S);for(await k.next();T&&!u&&!this._track.input._disposed;){let C=Bl(n.length);if(n.length+x.getDecodeQueueSize()>C){({promise:l,resolve:c}=ve()),await l;continue}x.decode(T);let O=await k.next();if(O.done)break;T=O.value}await k.return(),!m&&!this._track.input._disposed&&await x.flush(),x.close(),!o&&i&&n.push(i),f=!0,a()})().catch(x=>{p||(p=x,a())});let d=this._track,g=()=>{i?.close();for(let x of n)x.close()};return{async next(){for(;;){if(d.input._disposed)throw g(),new ce;if(m)return{value:void 0,done:!0};if(p)throw g(),p;if(n.length>0){let x=n.shift();return c(),{value:x,done:!1}}else if(!f)await s;else return{value:void 0,done:!0}}},async return(){return m=!0,u=!0,c(),a(),g(),{value:void 0,done:!0}},async throw(x){throw x},[Symbol.asyncIterator](){return this}}}mediaSamplesAtTimestamps(e){al(e);let t=sl(e),n=[],o=[],{promise:i,resolve:s}=ve(),{promise:a,resolve:l}=ve(),c=!1,f=!1,u=null,m=g=>{o.push(g),s(),{promise:i,resolve:s}=ve()};(async()=>{let g=await this._createDecoder(C=>{if(l(),f){C.close();return}let O=0;for(;n.length>0&&C.timestamp-n[0]>-1e-10;)O++,n.shift();if(O>0)for(let E=0;E<O;E++)m(E<O-1?C.clone():C);else C.close()},C=>{u||(u=C,s())}),x=this._createPacketSink(),y=null,v=null,T=-1,S=async()=>{h(v);let C=v;for(g.decode(C);C.sequenceNumber<T;){let O=Bl(o.length);for(;o.length+g.getDecodeQueueSize()>O&&!f;)({promise:a,resolve:l}=ve()),await a;if(f)break;let E=await x.getNextPacket(C);h(E),g.decode(E),C=E}T=-1},k=async()=>{await g.flush();for(let C=0;C<n.length;C++)m(null);n.length=0};for await(let C of t){if(Wt(C),f||this._track.input._disposed)break;let O=await x.getPacket(C),E=O&&await x.getKeyPacket(C,{verifyKeyPackets:!0});if(!E){T!==-1&&(await S(),await k()),m(null),y=null;continue}y&&(E.sequenceNumber!==v.sequenceNumber||O.timestamp<y.timestamp)&&(await S(),await k()),n.push(O.timestamp),T=Math.max(O.sequenceNumber,T),y=O,v=E}!f&&!this._track.input._disposed&&(T!==-1&&await S(),await k()),g.close(),c=!0,s()})().catch(g=>{u||(u=g,s())});let p=this._track,d=()=>{for(let g of o)g?.close()};return{async next(){for(;;){if(p.input._disposed)throw d(),new ce;if(f)return{value:void 0,done:!0};if(u)throw d(),u;if(o.length>0){let g=o.shift();return h(g!==void 0),l(),{value:g,done:!1}}else if(!c)await i;else return{value:void 0,done:!0}}},async return(){return f=!0,l(),s(),d(),{value:void 0,done:!0}},async throw(g){throw g},[Symbol.asyncIterator](){return this}}}},Bl=r=>r===0?40:8,Ms=class extends vn{constructor(e,t,n,o,i,s){super(e,t),this.codec=n,this.decoderConfig=o,this.rotation=i,this.timeResolution=s,this.decoder=null,this.customDecoder=null,this.customDecoderCallSerializer=new un,this.customDecoderQueueSize=0,this.inputTimestamps=[],this.sampleQueue=[],this.currentPacketIndex=0,this.raslSkipped=!1,this.alphaDecoder=null,this.alphaHadKeyframe=!1,this.colorQueue=[],this.alphaQueue=[],this.merger=null,this.mergerCreationFailed=!1,this.decodedAlphaChunkCount=0,this.alphaDecoderQueueSize=0,this.nullAlphaFrameQueue=[],this.currentAlphaPacketIndex=0,this.alphaRaslSkipped=!1;let a=wo.find(l=>l.supports(n,o));if(a)this.customDecoder=new a,this.customDecoder.codec=n,this.customDecoder.config=o,this.customDecoder.onSample=l=>{if(!(l instanceof gr))throw new TypeError("The argument passed to onSample must be a VideoSample.");this.finalizeAndEmitSample(l)},this.customDecoderCallSerializer.call(()=>this.customDecoder.init());else{let l=f=>{if(this.alphaQueue.length>0){let u=this.alphaQueue.shift();h(u!==void 0),this.mergeAlpha(f,u)}else this.colorQueue.push(f)};if(n==="avc"&&this.decoderConfig.description&&fn()){let f=Sl(ze(this.decoderConfig.description));if(f&&f.sequenceParameterSets.length>0){let u=zs(f.sequenceParameterSets[0]);u&&u.frameMbsOnlyFlag===0&&(this.decoderConfig={...this.decoderConfig,hardwareAcceleration:"prefer-software"})}}let c=new Error("Decoding error").stack;this.decoder=new VideoDecoder({output:f=>{try{l(f)}catch(u){this.onError(u)}},error:f=>{f.stack=c,this.onError(f)}}),this.decoder.configure(this.decoderConfig)}}getDecodeQueueSize(){return this.customDecoder?this.customDecoderQueueSize:(h(this.decoder),Math.max(this.decoder.decodeQueueSize,this.alphaDecoder?.decodeQueueSize??0))}decode(e){if(this.codec==="hevc"&&this.currentPacketIndex>0&&!this.raslSkipped){if(this.hasHevcRaslPicture(e.data))return;this.raslSkipped=!0}if(this.customDecoder)this.customDecoderQueueSize++,this.customDecoderCallSerializer.call(()=>this.customDecoder.decode(e)).then(()=>this.customDecoderQueueSize--);else{if(h(this.decoder),vt()||ws(this.inputTimestamps,e.timestamp,t=>t),fn()&&this.currentPacketIndex===0&&this.codec==="avc"){let n=Es(e.data,this.decoderConfig).filter(i=>{let s=Gt(i);return!(s>=20&&s<=31)}),o=yl(n,this.decoderConfig);e=new te(o,e.type,e.timestamp,e.duration)}this.decoder.decode(e.toEncodedVideoChunk()),this.decodeAlphaData(e)}this.currentPacketIndex++}decodeAlphaData(e){if(!e.sideData.alpha||this.mergerCreationFailed){this.pushNullAlphaFrame();return}if(!this.merger)try{this.merger=new Bs}catch(n){console.error("Due to an error, only color data will be decoded.",n),this.mergerCreationFailed=!0,this.decodeAlphaData(e);return}if(!this.alphaDecoder){let n=i=>{if(this.alphaDecoderQueueSize--,this.colorQueue.length>0){let s=this.colorQueue.shift();h(s!==void 0),this.mergeAlpha(s,i)}else this.alphaQueue.push(i);for(this.decodedAlphaChunkCount++;this.nullAlphaFrameQueue.length>0&&this.nullAlphaFrameQueue[0]===this.decodedAlphaChunkCount;)if(this.nullAlphaFrameQueue.shift(),this.colorQueue.length>0){let s=this.colorQueue.shift();h(s!==void 0),this.mergeAlpha(s,null)}else this.alphaQueue.push(null)},o=new Error("Decoding error").stack;this.alphaDecoder=new VideoDecoder({output:i=>{try{n(i)}catch(s){this.onError(s)}},error:i=>{i.stack=o,this.onError(i)}}),this.alphaDecoder.configure(this.decoderConfig)}let t=To(this.codec,this.decoderConfig,e.sideData.alpha);if(this.alphaHadKeyframe||(this.alphaHadKeyframe=t==="key"),this.alphaHadKeyframe){if(this.codec==="hevc"&&this.currentAlphaPacketIndex>0&&!this.alphaRaslSkipped){if(this.hasHevcRaslPicture(e.sideData.alpha)){this.pushNullAlphaFrame();return}this.alphaRaslSkipped=!0}this.currentAlphaPacketIndex++,this.alphaDecoder.decode(e.alphaToEncodedVideoChunk(t??e.type)),this.alphaDecoderQueueSize++}else this.pushNullAlphaFrame()}pushNullAlphaFrame(){this.alphaDecoderQueueSize===0?this.alphaQueue.push(null):this.nullAlphaFrameQueue.push(this.decodedAlphaChunkCount+this.alphaDecoderQueueSize)}hasHevcRaslPicture(e){return Ds(e,this.decoderConfig).some(n=>{let o=rt(n);return o===ye.RASL_N||o===ye.RASL_R})}sampleHandler(e){if(vt()){if(this.sampleQueue.length>0&&e.timestamp>=xe(this.sampleQueue).timestamp){for(let t of this.sampleQueue)this.finalizeAndEmitSample(t);this.sampleQueue.length=0}ws(this.sampleQueue,e,t=>t.timestamp)}else{let t=this.inputTimestamps.shift();h(t!==void 0),e.setTimestamp(t),this.finalizeAndEmitSample(e)}}finalizeAndEmitSample(e){e.setTimestamp(Math.round(e.timestamp*this.timeResolution)/this.timeResolution),e.setDuration(Math.round(e.duration*this.timeResolution)/this.timeResolution),e.setRotation(this.rotation),this.onSample(e)}mergeAlpha(e,t){if(!t){let i=new gr(e);this.sampleHandler(i);return}h(this.merger),this.merger.update(e,t),e.close(),t.close();let n=new VideoFrame(this.merger.canvas,{timestamp:e.timestamp,duration:e.duration??void 0}),o=new gr(n);this.sampleHandler(o)}async flush(){if(this.customDecoder?await this.customDecoderCallSerializer.call(()=>this.customDecoder.flush()):(h(this.decoder),await Promise.all([this.decoder.flush(),this.alphaDecoder?.flush()]),this.colorQueue.forEach(e=>e.close()),this.colorQueue.length=0,this.alphaQueue.forEach(e=>e?.close()),this.alphaQueue.length=0,this.alphaHadKeyframe=!1,this.decodedAlphaChunkCount=0,this.alphaDecoderQueueSize=0,this.nullAlphaFrameQueue.length=0,this.currentAlphaPacketIndex=0,this.alphaRaslSkipped=!1),vt()){for(let e of this.sampleQueue)this.finalizeAndEmitSample(e);this.sampleQueue.length=0}this.currentPacketIndex=0,this.raslSkipped=!1}close(){this.customDecoder?this.customDecoderCallSerializer.call(()=>this.customDecoder.close()):(h(this.decoder),this.decoder.close(),this.alphaDecoder?.close(),this.colorQueue.forEach(e=>e.close()),this.colorQueue.length=0,this.alphaQueue.forEach(e=>e?.close()),this.alphaQueue.length=0,this.merger?.close());for(let e of this.sampleQueue)e.close();this.sampleQueue.length=0}},Bs=class{constructor(){typeof OffscreenCanvas<"u"?this.canvas=new OffscreenCanvas(300,150):this.canvas=document.createElement("canvas");let e=this.canvas.getContext("webgl2",{premultipliedAlpha:!1});if(!e)throw new Error("Couldn't acquire WebGL 2 context.");this.gl=e,this.program=this.createProgram(),this.vao=this.createVAO(),this.colorTexture=this.createTexture(),this.alphaTexture=this.createTexture(),this.gl.useProgram(this.program),this.gl.uniform1i(this.gl.getUniformLocation(this.program,"u_colorTexture"),0),this.gl.uniform1i(this.gl.getUniformLocation(this.program,"u_alphaTexture"),1)}createProgram(){let e=this.createShader(this.gl.VERTEX_SHADER,`#version 300 es
|
|
2339
2339
|
in vec2 a_position;
|
|
2340
2340
|
in vec2 a_texCoord;
|
|
2341
2341
|
out vec2 v_texCoord;
|
|
@@ -2862,13 +2862,13 @@ fn mainFragment(
|
|
|
2862
2862
|
sample.b *= sample.a;
|
|
2863
2863
|
|
|
2864
2864
|
return sample;
|
|
2865
|
-
}`;var qc=class Hc extends _{constructor(e={}){e={...Hc.defaultOptions,...e};let t=A.from({vertex:{source:ca,entryPoint:"mainVertex"},fragment:{source:ca,entryPoint:"mainFragment"}}),n=I.from({vertex:mr,fragment:Gc,name:"noise-filter"}),{noise:o,seed:i,...s}=e;super({...s,gpuProgram:t,glProgram:n,resources:{noiseUniforms:new fr({uNoise:{value:1,type:"f32"},uSeed:{value:1,type:"f32"}})}}),this.noise=o,this.seed=i??Math.random()}get noise(){return this.resources.noiseUniforms.uniforms.uNoise}set noise(e){this.resources.noiseUniforms.uniforms.uNoise=e}get seed(){return this.resources.noiseUniforms.uniforms.uSeed}set seed(e){this.resources.noiseUniforms.uniforms.uSeed=e}};qc.defaultOptions={noise:.5};var ua=qc;var oi=class extends Ga{constructor(e,t){let{text:n,resolution:o,style:i,anchor:s,width:a,height:l,roundPixels:c,...f}=e;super({...f}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=t,this.text=n??"",this.style=i,this.resolution=o??null,this.allowChildren=!1,this._anchor=new Zr({_onUpdate:()=>{this.onViewUpdate()}}),s&&(this.anchor=s),this.roundPixels=c??!1,a!==void 0&&(this.width=a),l!==void 0&&(this.height=l)}get anchor(){return this._anchor}set anchor(e){typeof e=="number"?this._anchor.set(e):this._anchor.copyFrom(e)}set text(e){e=e.toString(),this._text!==e&&(this._text=e,this.onViewUpdate())}get text(){return this._text}set resolution(e){this._autoResolution=e===null,this._resolution=e,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(e){e||(e={}),this._style?.off("update",this.onViewUpdate,this),e instanceof this._styleClass?this._style=e:this._style=new this._styleClass(e),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(e){this._setWidth(e,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(e){this._setHeight(e,this.bounds.height)}getSize(e){return e||(e={}),e.width=Math.abs(this.scale.x)*this.bounds.width,e.height=Math.abs(this.scale.y)*this.bounds.height,e}setSize(e,t){typeof e=="object"?(t=e.height??e.width,e=e.width):t??(t=e),e!==void 0&&this._setWidth(e,this.bounds.width),t!==void 0&&this._setHeight(t,this.bounds.height)}containsPoint(e){let t=this.bounds.width,n=this.bounds.height,o=-t*this.anchor.x,i=0;return e.x>=o&&e.x<=o+t&&(i=-n*this.anchor.y,e.y>=i&&e.y<=i+n)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}destroy(e=!1){super.destroy(e),this.owner=null,this._bounds=null,this._anchor=null,(typeof e=="boolean"?e:e?.style)&&this._style.destroy(e),this._style=null,this._text=null}get styleKey(){return`${this._text}:${this._style.styleKey}:${this._resolution}`}};function Wc(r,e){let t=r[0]??{};return(typeof t=="string"||r[1])&&(N(Jr,`use new ${e}({ text: "hi!", style }) instead`),t={text:t,style:r[1]}),t}var Dn=class extends oi{constructor(...e){let t=Wc(e,"Text");super(t,qa),this.renderPipeId="text",t.textureStyle&&(this.textureStyle=t.textureStyle instanceof ji?t.textureStyle:new ji(t.textureStyle))}updateBounds(){let e=this._bounds,t=this._anchor,n=0,o=0;if(this._style.trim){let{frame:i,canvasAndContext:s}=Ki.getCanvasAndContext({text:this.text,style:this._style,resolution:1});Ki.returnCanvasAndContext(s),n=i.width,o=i.height}else{let i=Ha.measureText(this._text,this._style);n=i.width,o=i.height}e.minX=-t._x*n,e.maxX=e.minX+n,e.minY=-t._y*o,e.maxY=e.minY+o}};Va.add(Pc,_c);var jc=r=>{let[e,t,n]=r,[o,i]=e,[s,a]=t,l=n*Math.PI/180,c=Math.cos(l),f=Math.sin(l);return[c*s,f*s,-f*a,c*a,o,i]},Xc=([r,e,t,n,o,i])=>new Wi(r,e,t,n,o,i);var $c=(r,e)=>{let[t,n,o,i,s,a]=r,[l,c,f,u,m,p]=e;return[t*l+o*c,n*l+i*c,t*f+o*u,n*f+i*u,t*m+o*p+s,n*m+i*p+a]};var Kc=[1,0,0,1,0,0];var fa=class{keys;index;constructor(e,t){this.keys=e,this.index=t}near(e){return this.keys[Math.max(0,Math.min(this.keys.length-1,this.index+e))][1]}},Yc=r=>r,On=r=>Yc((e,t)=>r(e,t.near(0),t.near(1))),Rn=(r,e,t)=>e+(t-e)*r,Kd={linear:On(Rn),ease:On((r,e,t)=>{let n=r<.5?4*r*r*r:1-Math.pow(-2*r+2,3)/2;return Rn(n,e,t)}),easeIn:On((r,e,t)=>Rn(r*r*r,e,t)),easeOut:On((r,e,t)=>Rn(1-Math.pow(1-r,3),e,t)),bounce:On((r,e,t)=>{let i=r<.36363636363636365?7.5625*r*r:r<.7272727272727273?7.5625*(r-.5454545454545454)**2+.75:r<.9090909090909091?7.5625*(r-.8181818181818182)**2+.9375:7.5625*(r-.9545454545454546)**2+.984375;return Rn(i,e,t)}),catmullRom:Yc((r,e)=>{let t=e.near(-1),n=e.near(0),o=e.near(1),i=e.near(2),s=r*r,a=s*r;return .5*(2*n+(-t+o)*r+(2*t-5*n+4*o-i)*s+(-t+3*n-3*o+i)*a)})},Qc=(r,e,t,n)=>{let o=Kd[r];if(!o)throw new Error(`unknown terp "${r}"`);return o(e,new fa(t,n))};var Rr=(r,e,t,n=0)=>{if(e.length===0)return n;if(e.length===1)return e[0][1];let o=[...e].sort((u,m)=>u[0]-m[0]);if(r<=o[0][0])return o[0][1];let i=o[o.length-1];if(r>=i[0])return i[1];let s=0;for(let u=0;u<o.length-1;u++){let m=o[u],p=o[u+1];if(r>=m[0]&&r<=p[0]){s=u;break}}let[a]=o[s],[l]=o[s+1],c=l-a,f=c===0?0:(r-a)/c;return Qc(t,f,o,s)},ma=(r,e)=>[[Rr(r,e.track.position.x,e.terp),Rr(r,e.track.position.y,e.terp)],[Rr(r,e.track.scale.x,e.terp,1),Rr(r,e.track.scale.y,e.terp,1)],Rr(r,e.track.rotation,e.terp)],Zc=(r,e)=>Rr(r,e.track,e.terp),Jc=(r,e)=>r.kind===H.AnimatedSpatial?ma(e,r.anim):r.transform;function tu(r){return"duration"in r}function ru(r){let e=[],t=new Map(r.timeline.items.map(n=>[n.id,n]));return pa(r.timeline.rootId,t,r.from,{sequence:()=>{},stack:()=>{},video:(n,o,i)=>e.push({item:n,localTime:o,ancestors:i}),text:(n,o,i)=>e.push({item:n,localTime:o,ancestors:i}),audio:(n,o,i)=>e.push({item:n,localTime:o,ancestors:i})}),e}function nu(r,e,t,n){let o=Kc;for(let i of e)o=eu(r,i.item,o,i.localTime);return eu(r,t,o,n)}function eu(r,e,t,n){if("spatialId"in e&&e.spatialId){let o=r.get(e.spatialId);if(o?.enabled){let i=jc(Jc(o,n));return $c(i,t)}}return t}function pa(r,e,t,n,o=[]){let i=e.get(r);if(i)switch(i.kind){case H.Stack:n.stack(i,t,o);for(let s of i.childrenIds)pa(s,e,t,n,[...o,{item:i,localTime:t}]);break;case H.Sequence:{n.sequence(i,t,o);let s=X(0);for(let a of i.childrenIds){let l=e.get(a);if(!l||!tu(l))continue;let c=X(s+l.duration);if(t>=c){s=c;continue}let f=X(Math.max(0,t-s));pa(a,e,f,n,[...o,{item:i,localTime:t}]),s=c}break}case H.Video:n.video(i,t,o);break;case H.Text:n.text(i,t,o);break;case H.Audio:n.audio(i,t,o);break}}function ee(r,e){let t=e.items.find(n=>n.id===r);if(!t)return X(0);switch(t.kind){case H.Sequence:{let n=t.childrenIds.map(i=>e.items.find(s=>s.id===i)).filter(Boolean),o=X(0);for(let i=0;i<n.length;i++){let s=n[i];if(s.kind===H.Transition){let a=n[i-1],l=n[i+1];if(a&&l&&a.kind!==H.Transition&&l.kind!==H.Transition){let c=ee(a.id,e),f=ee(l.id,e),u=Math.max(0,Math.min(s.duration,c,f));o=X(o-u)}continue}o=X(o+ee(s.id,e))}return o}case H.Stack:{let n=X(0);for(let o of t.childrenIds){let i=ee(o,e);i>n&&(n=i)}return n}default:return tu(t)?t.duration:X(0)}}function ou(r,e,t){if(!("animationId"in e)||e.animationId===void 0)return 1;let n=r.items.get(e.animationId);return n?.enabled&&n.anims.opacity?Zc(t,n.anims.opacity):1}var Mn=r=>r;var ii=class{resolveMedia;#e=new Map;constructor(e){this.resolveMedia=e}async getSink(e){let t=this.#e.get(e);if(t)return t.sink;let n=new Pe({formats:Be,source:await $e(this.resolveMedia(e))}),o=await n.getPrimaryVideoTrack(),s=!!o&&await o.canDecode()&&o?new bn(o):null;return this.#e.set(e,{input:n,sink:s}),s}};async function iu(r,e,t,n){let[o,i]=await Promise.all([t,n]),s=o.find(c=>c.kind==="image")?.frame,a=i.find(c=>c.kind==="image")?.frame,l=[...o.filter(c=>c.kind!=="image"),...i.filter(c=>c.kind!=="image")];return s&&a?[{id:r.id,kind:"transition",name:"circle",progress:e,from:s,to:a},...l]:l}async function su(r,e,t,n){let o=Yd(r,e,t);if(!o)return[];let i=[...n,{item:e,localTime:t}];return o.isTransitioning?iu(o.transition,o.progress,Jt(r,o.outgoing,o.outgoingTime,i),Jt(r,o.incoming,o.incomingTime,i)):Jt(r,o.item,o.localTime,i)}function Yd(r,e,t){let n=e.childrenIds.map(i=>r.items.get(i)).filter(i=>!!i),o=X(0);for(let i=0;i<n.length;i++){let s=n[i];if(s.kind===H.Transition)continue;let a=o,l=ee(s.id,r.timeline),c=X(a+l),f=n[i+1];if(!(f?.kind===H.Transition)){if(t<c)return{isTransitioning:!1,item:s,localTime:X(t-a)};o=c;continue}let m=f,p=n[i+2];if(!p||p.kind===H.Transition){o=c;continue}let d=ee(p.id,r.timeline),g=Math.max(0,Math.min(m.duration,l,d)),x=X(c-g);if(t<x)return{isTransitioning:!1,item:s,localTime:X(t-a)};if(t<c){let y=X(t-x),v=X(t-a);return{isTransitioning:!0,incoming:p,outgoing:s,outgoingTime:v,incomingTime:y,progress:g>0?y/g:1,transition:m}}o=x,i++}return null}async function Jt(r,e,t,n){let o=nu(r.items,n,e,t),i=ou(r,e,t),s="spatialId"in e&&e.spatialId?r.items.get(e.spatialId)?.crop:void 0,a="filterIds"in e&&e.filterIds?e.filterIds.map(l=>r.items.get(l)).filter(l=>!!l?.enabled).map(l=>({type:l.type,params:l.params})):void 0;switch(e.kind){case H.Stack:{let l=[...n,{item:e,localTime:t}];return(await Promise.all(e.childrenIds.map(f=>r.items.get(f)).filter(f=>!!f).map(f=>Jt(r,f,t,l)))).flat()}case H.Sequence:return su(r,e,t,n);case H.Video:{if(t<0||t>=e.duration)return[];let l=await r.videoSampler(e,t);return l?[{kind:"image",frame:l,matrix:o,alpha:i,crop:s,filters:a,id:e.id}]:[]}case H.Text:{if(t<0||t>=e.duration)return[];let l=e.styleId?r.items.get(e.styleId)?.style:void 0;return[{id:e.id,kind:"text",content:e.content,style:l,matrix:o,alpha:i,crop:s,filters:a}]}case H.Gap:return[{id:e.id,kind:"gap"}];default:return[]}}function au(r){return async(e,t)=>{let o=await(await r.getSink(e.mediaHash))?.getSample(t/1e3),i=o?.toVideoFrame();return o?.close(),i??void 0}}function Mr(r,e){let t=new ii(r),n=e??au(t);return{async sample(o,i){let s=new Map(o.items.map(l=>[l.id,l])),a=s.get(o.rootId);return a?Jt({videoSampler:n,timeline:o,items:s},a,i,[]):[]}}}var It=class{driver;resolveMedia;timeline;#e=-1/0;#t=new Map;#r;constructor(e,t,n){this.driver=e,this.resolveMedia=t,this.timeline=n,this.#r=Mr(this.resolveMedia,(o,i)=>{let s=lu(i),a=this.#t.get(o.id);if(!a){let l=this.resolveMedia(o.mediaHash),c=lu(X(o.start+o.duration));a=this.#n(l,s,c),this.#t.set(o.id,a)}return a.next(s)})}next(e){if(e<this.#e)throw new Error(`Forward-only cursor regression: ${e}ms < ${this.#e}ms`);return this.#e=e,this.#r.sample(this.timeline,e)}async cancel(){await Promise.all([...this.#t.values()].map(e=>e.cancel())),this.#t.clear()}#n(e,t,n){let o=this.driver.decodeVideo({source:e,start:t/1e6,end:n/1e6}),i=o.readable.getReader(),s=null,a=null,l=!1,c=async()=>{if(l)return null;let{done:f,value:u}=await i.read();if(f)return l=!0,null;let m=new VideoFrame(u);return u.close(),m};return{async next(f){if(s??=await c(),!!s)for(;;){a??=c();let u=await a;if(!u)return new VideoFrame(s);let m=s.timestamp??-1/0,p=u.timestamp??m;if(p<f){s.close(),s=u,a=null;continue}if(Math.abs(p-f)<Math.abs(m-f)){s.close(),s=u,a=null;continue}return new VideoFrame(s)}},async cancel(){let f=a;a=null,l=!0,(await f?.catch(()=>null))?.close(),s?.close(),s=null,o.cancel()}}}},lu=r=>Math.round(r*1e3);async function cu(r,e,t){return(await Promise.all(e.map(async({item:o,localTime:i})=>{if(o.kind!==H.Audio)return;let s=await r.getSink(o.mediaHash);if(!s)return;let a=o.start+i,l=Mn((t-a)/1e3),c=s.samples(a/1e3),f=await c.next();if(f.done)return;let u=f.value,m=c.next();return{offset:l,gain:o.gain??1,get currentSample(){return u},timelineTime:()=>Mn(l+u.timestamp),output:()=>({sample:u,timestamp:l+u.timestamp,gain:o.gain??1}),advance:async()=>{let p=await m;return p.done?!1:(u=p.value,m=c.next(),!0)}}}))).filter(o=>!!o)}var si=class{resolveMedia;#e=new Map;constructor(e){this.resolveMedia=e}async getSink(e){let t=this.#e.get(e);if(t)return t.sink;let n=new Pe({formats:Be,source:await $e(this.resolveMedia(e))}),o=await n.getPrimaryAudioTrack(),s=!!o&&await o.canDecode()&&o?new Sn(o):null;return this.#e.set(e,{input:n,sink:s}),s}};function uu(r){let e={index:0,stream:r[0],time:r[0].timelineTime()};for(let[t,n]of r.entries()){let o=n.timelineTime();o<e.time&&(e={time:o,stream:n,index:t})}return e}function ai(r){let e=new si(r);return{async*sampleAudio(t,n){let o=ru({timeline:t,from:n}),i=await cu(e,o,n);for(;i.length>0;){let{stream:s,index:a}=uu(i);yield s.output(),await s.advance()||i.splice(a,1)}}}}var li=class{driver;timeline;resolveMedia;audioSampler;seekVisualSampler;playVisualSampler=null;#e=X(0);#t=null;#r=Cc();onTick=this.#r.onTick;audioContext=new AudioContext({sampleRate:48e3});audioGain=this.audioContext.createGain();audioNodes=new Set;#n=null;constructor(e,t,n){this.driver=e,this.timeline=t,this.resolveMedia=n,this.audioGain.connect(this.audioContext.destination),this.audioGain.gain.value=.7**2,this.seekVisualSampler=Mr(this.resolveMedia),this.audioSampler=ai(this.resolveMedia),this.#o()}update(e){this.timeline=e}get isPlaying(){return this.#r.isPlaying()}async#o(){for await(let e of this.#r.ticks()){let t=await this.playVisualSampler?.next(this.currentTime)??[];(await this.driver.composite(t)).close(),this.currentTime>=this.duration&&this.pause()}}async seek(e){return this.pause(),this.#e=e,await this.seekVisualSampler.sample(this.timeline,e)}async start(){if(!this.#r.isPlaying()){await this.audioContext.resume(),this.#e=this.currentTime,this.#t=this.audioContext.currentTime,this.#n?.abort(),this.#n=new AbortController;for(let e of this.audioNodes)e.stop();this.audioNodes.clear(),this.playVisualSampler=new It(this.driver,this.resolveMedia,this.timeline),this.#r.play(),this.#i(this.#n.signal,Mn(this.#e/1e3))}}pause(){this.#e=this.currentTime,this.#r.pause(),this.#n?.abort();for(let e of this.audioNodes)e.stop();this.audioNodes.clear(),this.playVisualSampler&&(this.playVisualSampler.cancel(),this.playVisualSampler=null)}get duration(){return ee(this.timeline.rootId,this.timeline)}get currentTime(){if(!this.#r.isPlaying()||this.#t===null)return this.#e;let e=(this.audioContext.currentTime-this.#t)*1e3;return X(this.#e+e)}setFps(e){this.#r.setFPS(e)}async#i(e,t){let n=this.audioContext;if(this.#t!==null)for await(let{sample:o,timestamp:i}of this.audioSampler.sampleAudio(this.timeline,X(t*1e3))){if(e.aborted||!this.#r.isPlaying())return;for(;i-(n.currentTime-this.#t+t)>.75;)await new Promise(l=>setTimeout(l,25));let s=n.createBufferSource();s.buffer=o.toAudioBuffer(),s.connect(this.audioGain),s.onended=()=>this.audioNodes.delete(s),this.audioNodes.add(s);let a=this.#t+i-t;a>=n.currentTime?s.start(a):s.start(n.currentTime,n.currentTime-a)}}};var ci=class{driver;canvas;playback;#e=null;#t=null;constructor(e,t,n){this.driver=e,this.playback=new li(e,n,t),this.canvas=e.compositor.pixi.renderer.canvas}async play(){await this.playback.start()}pause(){this.playback.pause()}seek(e){return this.#e=e,this.#t??=this.#r().finally(()=>this.#t=null)}setFPS(e){this.playback.setFps(xt(e))}get isSeeking(){return this.#t!==null}get isPlaying(){return this.playback.isPlaying}get duration(){return this.playback.duration}get currentTime(){return this.playback.currentTime}update(e){this.playback.update(e)}async#r(){for(;this.#e!==null;){let e=this.#e;this.#e=null;let t=await this.playback.seek(X(e));(await this.driver.composite(t)).close()}}};var Ke=class{#e;#t;constructor(e={}){this.#e=e.chunkFrames??1024,this.#t=e.clamp??!0}async*mix(e){let t=this.#e,n=null,o=null,i=[],s=0,a=0;for await(let l of e){if(o===null)o=l.planes.length,n=l.sampleRate;else{if(l.planes.length!==o)throw new Error("Channel count changed");if(l.sampleRate!==n)throw new Error("Sample rate changed")}let c=Math.round(l.timestamp*n),f=l.planes[0]?.length??0;for(;s+t<=c;)yield this.#r(i,s,o,n),s+=t;i.push({startFrame:c,endFrame:c+f,data:l.planes}),a=Math.max(a,c+f)}if(o!==null&&n!==null)for(;s<a;)yield this.#r(i,s,o,n),s+=t}#r(e,t,n,o){let i=this.#e,s=new Float32Array(n*i),a=t+i;for(let l=0;l<n;l++){let c=l*i,f=s.subarray(c,c+i);for(let u of e){let m=u.data[l];if(!m)continue;let p=Math.max(t,u.startFrame),d=Math.min(a,u.endFrame);if(p>=d)continue;let g=p-t,x=p-u.startFrame,y=d-p;for(let v=0;v<y;v++)f[g+v]+=m[x+v]}if(this.#t)for(let u=0;u<i;u++){let m=f[u];f[u]=m<-1?-1:m>1?1:m}}for(let l=e.length-1;l>=0;l--)e[l].endFrame<=a&&e.splice(l,1);return{planar:s,sampleRate:o,channels:n,frames:i,startFrame:t}}};var Qd=(r,e,t)=>{if(e===t)return r;let n=t/e,o=Math.max(1,Math.round(r.length*n)),i=new Float32Array(o);for(let s=0;s<o;s++){let a=s/n,l=Math.floor(a),c=Math.min(l+1,r.length-1),f=a-l;i[s]=r[l]*(1-f)+r[c]*f}return i},Ye=(r,e)=>{let t=r.numberOfChannels,n=new Array(t),o=0;for(let i=0;i<t;i++){let s=new Float32Array(r.numberOfFrames);r.copyTo(s,{planeIndex:i,format:"f32-planar"});let a=Qd(s,r.sampleRate,e);n[i]=a,o=a.length}return{data:n,frames:o}};var Br=(r,e)=>{if(e!==1)for(let t of r)for(let n=0;n<t.length;n++)t[n]*=e};function ui({timeline:r,resolveMedia:e}){let t=new Ke,n=Zd(r,e),o=new TransformStream,i=o.writable.getWriter();async function s(){for await(let a of t.mix(n)){let l=new AudioData({format:"f32-planar",sampleRate:a.sampleRate,numberOfFrames:a.frames,numberOfChannels:a.channels,timestamp:Math.round(a.startFrame/a.sampleRate*1e6),data:new Float32Array(a.planar)});await i.write(l)}await i.close()}return s(),o.readable}async function*Zd(r,e){let t=ai(e);for await(let{sample:n,timestamp:o,gain:i}of t.sampleAudio(r,X(0))){let{data:s}=Ye(n,48e3);Br(s,i),yield{planes:s,sampleRate:48e3,timestamp:o},n.close()}}function fi({timeline:r,fps:e,driver:t,resolveMedia:n}){let o=new TransformStream,i=o.writable.getWriter(),s=new It(t,n,r),a=1/e,l=ee(r.rootId,r);async function c(){await kc({fps:e,duration:l},async(f,u)=>{let m=await s.next(f),p=await t.composite(m),d=new VideoFrame(p,{timestamp:Math.round(u*a*1e6),duration:Math.round(a*1e6)});await i.write(d),p.close()}),await i.close()}return c(),o.readable}function fu(r){let e=ui({...r}),t=fi({...r});return r.driver.encode({video:t,audio:e,config:{audio:{codec:"opus",bitrate:128e3},video:{codec:"vp9",bitrate:1e6}}})}var At=class{driver;resources=new ei;constructor(e){this.driver=e}load=async e=>Object.fromEntries(await Promise.all(Object.entries(e).map(async([t,n])=>[t,await this.resources.store(await n)])));timeline=e=>{let t=new re({timeline:{format:"timeline",info:"https://omniclip.app/",version:0,items:[],rootId:0}}),n=e(t);return t.timeline.rootId=n.id,t.timeline};playback=async e=>new ci(this.driver,t=>this.resources.require(t).url,e);render=async(e,t=30)=>fu({timeline:e,fps:xt(t),driver:this.driver,resolveMedia:n=>this.resources.require(n).url})};function da(r,e){return{error:t=>r.error({...e,...t}),rpcRequest:t=>r.rpcRequest({...e,...t}),rpcError:t=>r.rpcError({...e,...t})}}var mi=()=>r=>({plain:r.none,errMessage:r.mix(r.brightRed,r.bold),errName:r.red,errStack:r.mix(r.red,r.dim),timestamp:r.blue,timestampErr:r.red});function mu(){return mi()}var Ft=Object.freeze({black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",brightBlack:"\x1B[90m",brightRed:"\x1B[91m",brightGreen:"\x1B[92m",brightYellow:"\x1B[93m",brightBlue:"\x1B[94m",brightMagenta:"\x1B[95m",brightCyan:"\x1B[96m",brightWhite:"\x1B[97m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bgBrightBlack:"\x1B[100m",bgBrightRed:"\x1B[101m",bgBrightGreen:"\x1B[102m",bgBrightYellow:"\x1B[103m",bgBrightBlue:"\x1B[104m",bgBrightMagenta:"\x1B[105m",bgBrightCyan:"\x1B[106m",bgBrightWhite:"\x1B[107m",bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",inverse:"\x1B[7m",hidden:"\x1B[8m",strikethrough:"\x1B[9m",reset:"\x1B[0m"});var pi=()=>({none:r=>r,uncolor:eh,mix:th,hex:rh,rgb:pu,bgRgb:nh});function eh(r){return r.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,"")}function th(...r){return e=>{for(let t of r)e=t(e);return e}}function rh(r){r=r.replace(/^#/,"");let e,t,n,o;if(r.length===3)e=parseInt(r.split("").map(i=>i+i).join(""),16);else if(r.length===6)e=parseInt(r,16);else throw new Error("Invalid hex color");return t=e>>16&255,n=e>>8&255,o=e&255,pu(t,n,o)}function pu(r,e,t){let n=`\x1B[38;2;${r};${e};${t}m`;return o=>`${n}${o}${Ft.reset}`}function nh(r,e,t){let n=`\x1B[48;2;${r};${e};${t}m`;return o=>`${n}${o}${Ft.reset}`}var Bn={...Object.fromEntries(Object.entries(Ft).map(([r])=>[r,e=>e])),...pi()};var Un={...Object.fromEntries(Object.entries(Ft).map(([r,e])=>[r,t=>`${e}${t}${Ft.reset}`])),...pi()};function ha(){return typeof Deno<"u"&&typeof Deno.version<"u"}function ga(){return typeof process<"u"&&process.versions&&process.versions.node}function du(){return ga()?process.env.FORCE_COLOR||process.stdout.isTTY&&process.env.TERM!=="dumb":ha()?Deno.env.get("FORCE_COLOR")||Deno.isatty(Deno.stdout.rid)&&Deno.env.get("TERM")!=="dumb":!1}var xa=()=>du()?Un:Bn;var di=()=>({colors:r,theme:e})=>{let t=e(r);function n(s){let a=s.stack?`
|
|
2865
|
+
}`;var qc=class Hc extends _{constructor(e={}){e={...Hc.defaultOptions,...e};let t=A.from({vertex:{source:ca,entryPoint:"mainVertex"},fragment:{source:ca,entryPoint:"mainFragment"}}),n=I.from({vertex:mr,fragment:Gc,name:"noise-filter"}),{noise:o,seed:i,...s}=e;super({...s,gpuProgram:t,glProgram:n,resources:{noiseUniforms:new fr({uNoise:{value:1,type:"f32"},uSeed:{value:1,type:"f32"}})}}),this.noise=o,this.seed=i??Math.random()}get noise(){return this.resources.noiseUniforms.uniforms.uNoise}set noise(e){this.resources.noiseUniforms.uniforms.uNoise=e}get seed(){return this.resources.noiseUniforms.uniforms.uSeed}set seed(e){this.resources.noiseUniforms.uniforms.uSeed=e}};qc.defaultOptions={noise:.5};var ua=qc;var oi=class extends Ga{constructor(e,t){let{text:n,resolution:o,style:i,anchor:s,width:a,height:l,roundPixels:c,...f}=e;super({...f}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=t,this.text=n??"",this.style=i,this.resolution=o??null,this.allowChildren=!1,this._anchor=new Zr({_onUpdate:()=>{this.onViewUpdate()}}),s&&(this.anchor=s),this.roundPixels=c??!1,a!==void 0&&(this.width=a),l!==void 0&&(this.height=l)}get anchor(){return this._anchor}set anchor(e){typeof e=="number"?this._anchor.set(e):this._anchor.copyFrom(e)}set text(e){e=e.toString(),this._text!==e&&(this._text=e,this.onViewUpdate())}get text(){return this._text}set resolution(e){this._autoResolution=e===null,this._resolution=e,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(e){e||(e={}),this._style?.off("update",this.onViewUpdate,this),e instanceof this._styleClass?this._style=e:this._style=new this._styleClass(e),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(e){this._setWidth(e,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(e){this._setHeight(e,this.bounds.height)}getSize(e){return e||(e={}),e.width=Math.abs(this.scale.x)*this.bounds.width,e.height=Math.abs(this.scale.y)*this.bounds.height,e}setSize(e,t){typeof e=="object"?(t=e.height??e.width,e=e.width):t??(t=e),e!==void 0&&this._setWidth(e,this.bounds.width),t!==void 0&&this._setHeight(t,this.bounds.height)}containsPoint(e){let t=this.bounds.width,n=this.bounds.height,o=-t*this.anchor.x,i=0;return e.x>=o&&e.x<=o+t&&(i=-n*this.anchor.y,e.y>=i&&e.y<=i+n)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}destroy(e=!1){super.destroy(e),this.owner=null,this._bounds=null,this._anchor=null,(typeof e=="boolean"?e:e?.style)&&this._style.destroy(e),this._style=null,this._text=null}get styleKey(){return`${this._text}:${this._style.styleKey}:${this._resolution}`}};function Wc(r,e){let t=r[0]??{};return(typeof t=="string"||r[1])&&(N(Jr,`use new ${e}({ text: "hi!", style }) instead`),t={text:t,style:r[1]}),t}var Dn=class extends oi{constructor(...e){let t=Wc(e,"Text");super(t,qa),this.renderPipeId="text",t.textureStyle&&(this.textureStyle=t.textureStyle instanceof ji?t.textureStyle:new ji(t.textureStyle))}updateBounds(){let e=this._bounds,t=this._anchor,n=0,o=0;if(this._style.trim){let{frame:i,canvasAndContext:s}=Ki.getCanvasAndContext({text:this.text,style:this._style,resolution:1});Ki.returnCanvasAndContext(s),n=i.width,o=i.height}else{let i=Ha.measureText(this._text,this._style);n=i.width,o=i.height}e.minX=-t._x*n,e.maxX=e.minX+n,e.minY=-t._y*o,e.maxY=e.minY+o}};Va.add(Pc,_c);var jc=r=>{let[e,t,n]=r,[o,i]=e,[s,a]=t,l=n*Math.PI/180,c=Math.cos(l),f=Math.sin(l);return[c*s,f*s,-f*a,c*a,o,i]},Xc=([r,e,t,n,o,i])=>new Wi(r,e,t,n,o,i);var $c=(r,e)=>{let[t,n,o,i,s,a]=r,[l,c,f,u,m,p]=e;return[t*l+o*c,n*l+i*c,t*f+o*u,n*f+i*u,t*m+o*p+s,n*m+i*p+a]};var Kc=[1,0,0,1,0,0];var fa=class{keys;index;constructor(e,t){this.keys=e,this.index=t}near(e){return this.keys[Math.max(0,Math.min(this.keys.length-1,this.index+e))][1]}},Yc=r=>r,On=r=>Yc((e,t)=>r(e,t.near(0),t.near(1))),Rn=(r,e,t)=>e+(t-e)*r,Kd={linear:On(Rn),ease:On((r,e,t)=>{let n=r<.5?4*r*r*r:1-Math.pow(-2*r+2,3)/2;return Rn(n,e,t)}),easeIn:On((r,e,t)=>Rn(r*r*r,e,t)),easeOut:On((r,e,t)=>Rn(1-Math.pow(1-r,3),e,t)),bounce:On((r,e,t)=>{let i=r<.36363636363636365?7.5625*r*r:r<.7272727272727273?7.5625*(r-.5454545454545454)**2+.75:r<.9090909090909091?7.5625*(r-.8181818181818182)**2+.9375:7.5625*(r-.9545454545454546)**2+.984375;return Rn(i,e,t)}),catmullRom:Yc((r,e)=>{let t=e.near(-1),n=e.near(0),o=e.near(1),i=e.near(2),s=r*r,a=s*r;return .5*(2*n+(-t+o)*r+(2*t-5*n+4*o-i)*s+(-t+3*n-3*o+i)*a)})},Qc=(r,e,t,n)=>{let o=Kd[r];if(!o)throw new Error(`unknown terp "${r}"`);return o(e,new fa(t,n))};var Rr=(r,e,t,n=0)=>{if(e.length===0)return n;if(e.length===1)return e[0][1];let o=[...e].sort((u,m)=>u[0]-m[0]);if(r<=o[0][0])return o[0][1];let i=o[o.length-1];if(r>=i[0])return i[1];let s=0;for(let u=0;u<o.length-1;u++){let m=o[u],p=o[u+1];if(r>=m[0]&&r<=p[0]){s=u;break}}let[a]=o[s],[l]=o[s+1],c=l-a,f=c===0?0:(r-a)/c;return Qc(t,f,o,s)},ma=(r,e)=>[[Rr(r,e.track.position.x,e.terp),Rr(r,e.track.position.y,e.terp)],[Rr(r,e.track.scale.x,e.terp,1),Rr(r,e.track.scale.y,e.terp,1)],Rr(r,e.track.rotation,e.terp)],Zc=(r,e)=>Rr(r,e.track,e.terp),Jc=(r,e)=>r.kind===H.AnimatedSpatial?ma(e,r.anim):r.transform;function tu(r){return"duration"in r}function ru(r){let e=[],t=new Map(r.timeline.items.map(n=>[n.id,n]));return pa(r.timeline.rootId,t,r.from,{sequence:()=>{},stack:()=>{},video:(n,o,i)=>e.push({item:n,localTime:o,ancestors:i}),text:(n,o,i)=>e.push({item:n,localTime:o,ancestors:i}),audio:(n,o,i)=>e.push({item:n,localTime:o,ancestors:i})}),e}function nu(r,e,t,n){let o=Kc;for(let i of e)o=eu(r,i.item,o,i.localTime);return eu(r,t,o,n)}function eu(r,e,t,n){if("spatialId"in e&&e.spatialId){let o=r.get(e.spatialId);if(o?.enabled){let i=jc(Jc(o,n));return $c(i,t)}}return t}function pa(r,e,t,n,o=[]){let i=e.get(r);if(i)switch(i.kind){case H.Stack:n.stack(i,t,o);for(let s of i.childrenIds)pa(s,e,t,n,[...o,{item:i,localTime:t}]);break;case H.Sequence:{n.sequence(i,t,o);let s=X(0);for(let a of i.childrenIds){let l=e.get(a);if(!l||!tu(l))continue;let c=X(s+l.duration);if(t>=c){s=c;continue}let f=X(Math.max(0,t-s));pa(a,e,f,n,[...o,{item:i,localTime:t}]),s=c}break}case H.Video:n.video(i,t,o);break;case H.Text:n.text(i,t,o);break;case H.Audio:n.audio(i,t,o);break}}function ee(r,e){let t=e.items.find(n=>n.id===r);if(!t)return X(0);switch(t.kind){case H.Sequence:{let n=t.childrenIds.map(i=>e.items.find(s=>s.id===i)).filter(Boolean),o=X(0);for(let i=0;i<n.length;i++){let s=n[i];if(s.kind===H.Transition){let a=n[i-1],l=n[i+1];if(a&&l&&a.kind!==H.Transition&&l.kind!==H.Transition){let c=ee(a.id,e),f=ee(l.id,e),u=Math.max(0,Math.min(s.duration,c,f));o=X(o-u)}continue}o=X(o+ee(s.id,e))}return o}case H.Stack:{let n=X(0);for(let o of t.childrenIds){let i=ee(o,e);i>n&&(n=i)}return n}default:return tu(t)?t.duration:X(0)}}function ou(r,e,t){if(!("animationIds"in e)||e.animationIds===void 0)return 1;let n=1;for(let o of e.animationIds){let i=r.items.get(o),s=i?.anims.opacity;i?.enabled&&s&&Yd(s.track,t)&&(n=Zc(t,s))}return n}function Yd(r,e){if(r.length===0)return!1;let t=r[0][0],n=r[0][0];for(let[o]of r)t=Math.min(t,o),n=Math.max(n,o);return e>=t&&e<=n}var Mn=r=>r;var ii=class{resolveMedia;#e=new Map;constructor(e){this.resolveMedia=e}async getSink(e){let t=this.#e.get(e);if(t)return t.sink;let n=new Pe({formats:Be,source:await $e(this.resolveMedia(e))}),o=await n.getPrimaryVideoTrack(),s=!!o&&await o.canDecode()&&o?new bn(o):null;return this.#e.set(e,{input:n,sink:s}),s}};async function iu(r,e,t,n){let[o,i]=await Promise.all([t,n]),s=o.find(c=>c.kind==="image")?.frame,a=i.find(c=>c.kind==="image")?.frame,l=[...o.filter(c=>c.kind!=="image"),...i.filter(c=>c.kind!=="image")];return s&&a?[{id:r.id,kind:"transition",name:"circle",progress:e,from:s,to:a},...l]:l}async function su(r,e,t,n){let o=Qd(r,e,t);if(!o)return[];let i=[...n,{item:e,localTime:t}];return o.isTransitioning?iu(o.transition,o.progress,Jt(r,o.outgoing,o.outgoingTime,i),Jt(r,o.incoming,o.incomingTime,i)):Jt(r,o.item,o.localTime,i)}function Qd(r,e,t){let n=e.childrenIds.map(i=>r.items.get(i)).filter(i=>!!i),o=X(0);for(let i=0;i<n.length;i++){let s=n[i];if(s.kind===H.Transition)continue;let a=o,l=ee(s.id,r.timeline),c=X(a+l),f=n[i+1];if(!(f?.kind===H.Transition)){if(t<c)return{isTransitioning:!1,item:s,localTime:X(t-a)};o=c;continue}let m=f,p=n[i+2];if(!p||p.kind===H.Transition){o=c;continue}let d=ee(p.id,r.timeline),g=Math.max(0,Math.min(m.duration,l,d)),x=X(c-g);if(t<x)return{isTransitioning:!1,item:s,localTime:X(t-a)};if(t<c){let y=X(t-x),v=X(t-a);return{isTransitioning:!0,incoming:p,outgoing:s,outgoingTime:v,incomingTime:y,progress:g>0?y/g:1,transition:m}}o=x,i++}return null}async function Jt(r,e,t,n){let o=nu(r.items,n,e,t),i=ou(r,e,t),s="spatialId"in e&&e.spatialId?r.items.get(e.spatialId)?.crop:void 0,a="filterIds"in e&&e.filterIds?e.filterIds.map(l=>r.items.get(l)).filter(l=>!!l?.enabled).map(l=>({type:l.type,params:l.params})):void 0;switch(e.kind){case H.Stack:{let l=[...n,{item:e,localTime:t}];return(await Promise.all(e.childrenIds.map(f=>r.items.get(f)).filter(f=>!!f).map(f=>Jt(r,f,t,l)))).flat()}case H.Sequence:return su(r,e,t,n);case H.Video:{if(t<0||t>=e.duration)return[];let l=await r.videoSampler(e,t);return l?[{kind:"image",frame:l,matrix:o,alpha:i,crop:s,filters:a,id:e.id}]:[]}case H.Text:{if(t<0||t>=e.duration)return[];let l=e.styleId?r.items.get(e.styleId)?.style:void 0;return[{id:e.id,kind:"text",content:e.content,style:l,matrix:o,alpha:i,crop:s,filters:a}]}case H.Gap:return[{id:e.id,kind:"gap"}];default:return[]}}function au(r){return async(e,t)=>{let o=await(await r.getSink(e.mediaHash))?.getSample(t/1e3),i=o?.toVideoFrame();return o?.close(),i??void 0}}function Mr(r,e){let t=new ii(r),n=e??au(t);return{async sample(o,i){let s=new Map(o.items.map(l=>[l.id,l])),a=s.get(o.rootId);return a?Jt({videoSampler:n,timeline:o,items:s},a,i,[]):[]}}}var It=class{driver;resolveMedia;timeline;#e=-1/0;#t=new Map;#r;constructor(e,t,n){this.driver=e,this.resolveMedia=t,this.timeline=n,this.#r=Mr(this.resolveMedia,(o,i)=>{let s=lu(i),a=this.#t.get(o.id);if(!a){let l=this.resolveMedia(o.mediaHash),c=lu(X(o.start+o.duration));a=this.#n(l,s,c),this.#t.set(o.id,a)}return a.next(s)})}next(e){if(e<this.#e)throw new Error(`Forward-only cursor regression: ${e}ms < ${this.#e}ms`);return this.#e=e,this.#r.sample(this.timeline,e)}async cancel(){await Promise.all([...this.#t.values()].map(e=>e.cancel())),this.#t.clear()}#n(e,t,n){let o=this.driver.decodeVideo({source:e,start:t/1e6,end:n/1e6}),i=o.readable.getReader(),s=null,a=null,l=!1,c=async()=>{if(l)return null;let{done:f,value:u}=await i.read();if(f)return l=!0,null;let m=new VideoFrame(u);return u.close(),m};return{async next(f){if(s??=await c(),!!s)for(;;){a??=c();let u=await a;if(!u)return new VideoFrame(s);let m=s.timestamp??-1/0,p=u.timestamp??m;if(p<f){s.close(),s=u,a=null;continue}if(Math.abs(p-f)<Math.abs(m-f)){s.close(),s=u,a=null;continue}return new VideoFrame(s)}},async cancel(){let f=a;a=null,l=!0,(await f?.catch(()=>null))?.close(),s?.close(),s=null,o.cancel()}}}},lu=r=>Math.round(r*1e3);async function cu(r,e,t){return(await Promise.all(e.map(async({item:o,localTime:i})=>{if(o.kind!==H.Audio)return;let s=await r.getSink(o.mediaHash);if(!s)return;let a=o.start+i,l=Mn((t-a)/1e3),c=s.samples(a/1e3),f=await c.next();if(f.done)return;let u=f.value,m=c.next();return{offset:l,gain:o.gain??1,get currentSample(){return u},timelineTime:()=>Mn(l+u.timestamp),output:()=>({sample:u,timestamp:l+u.timestamp,gain:o.gain??1}),advance:async()=>{let p=await m;return p.done?!1:(u=p.value,m=c.next(),!0)}}}))).filter(o=>!!o)}var si=class{resolveMedia;#e=new Map;constructor(e){this.resolveMedia=e}async getSink(e){let t=this.#e.get(e);if(t)return t.sink;let n=new Pe({formats:Be,source:await $e(this.resolveMedia(e))}),o=await n.getPrimaryAudioTrack(),s=!!o&&await o.canDecode()&&o?new Sn(o):null;return this.#e.set(e,{input:n,sink:s}),s}};function uu(r){let e={index:0,stream:r[0],time:r[0].timelineTime()};for(let[t,n]of r.entries()){let o=n.timelineTime();o<e.time&&(e={time:o,stream:n,index:t})}return e}function ai(r){let e=new si(r);return{async*sampleAudio(t,n){let o=ru({timeline:t,from:n}),i=await cu(e,o,n);for(;i.length>0;){let{stream:s,index:a}=uu(i);yield s.output(),await s.advance()||i.splice(a,1)}}}}var li=class{driver;timeline;resolveMedia;audioSampler;seekVisualSampler;playVisualSampler=null;#e=X(0);#t=null;#r=Cc();onTick=this.#r.onTick;audioContext=new AudioContext({sampleRate:48e3});audioGain=this.audioContext.createGain();audioNodes=new Set;#n=null;constructor(e,t,n){this.driver=e,this.timeline=t,this.resolveMedia=n,this.audioGain.connect(this.audioContext.destination),this.audioGain.gain.value=.7**2,this.seekVisualSampler=Mr(this.resolveMedia),this.audioSampler=ai(this.resolveMedia),this.#o()}update(e){this.timeline=e}get isPlaying(){return this.#r.isPlaying()}async#o(){for await(let e of this.#r.ticks()){let t=await this.playVisualSampler?.next(this.currentTime)??[];(await this.driver.composite(t)).close(),this.currentTime>=this.duration&&this.pause()}}async seek(e){return this.pause(),this.#e=e,await this.seekVisualSampler.sample(this.timeline,e)}async start(){if(!this.#r.isPlaying()){await this.audioContext.resume(),this.#e=this.currentTime,this.#t=this.audioContext.currentTime,this.#n?.abort(),this.#n=new AbortController;for(let e of this.audioNodes)e.stop();this.audioNodes.clear(),this.playVisualSampler=new It(this.driver,this.resolveMedia,this.timeline),this.#r.play(),this.#i(this.#n.signal,Mn(this.#e/1e3))}}pause(){this.#e=this.currentTime,this.#r.pause(),this.#n?.abort();for(let e of this.audioNodes)e.stop();this.audioNodes.clear(),this.playVisualSampler&&(this.playVisualSampler.cancel(),this.playVisualSampler=null)}get duration(){return ee(this.timeline.rootId,this.timeline)}get currentTime(){if(!this.#r.isPlaying()||this.#t===null)return this.#e;let e=(this.audioContext.currentTime-this.#t)*1e3;return X(this.#e+e)}setFps(e){this.#r.setFPS(e)}async#i(e,t){let n=this.audioContext;if(this.#t!==null)for await(let{sample:o,timestamp:i}of this.audioSampler.sampleAudio(this.timeline,X(t*1e3))){if(e.aborted||!this.#r.isPlaying())return;for(;i-(n.currentTime-this.#t+t)>.75;)await new Promise(l=>setTimeout(l,25));let s=n.createBufferSource();s.buffer=o.toAudioBuffer(),s.connect(this.audioGain),s.onended=()=>this.audioNodes.delete(s),this.audioNodes.add(s);let a=this.#t+i-t;a>=n.currentTime?s.start(a):s.start(n.currentTime,n.currentTime-a)}}};var ci=class{driver;canvas;playback;#e=null;#t=null;constructor(e,t,n){this.driver=e,this.playback=new li(e,n,t),this.canvas=e.compositor.pixi.renderer.canvas}async play(){await this.playback.start()}pause(){this.playback.pause()}seek(e){return this.#e=e,this.#t??=this.#r().finally(()=>this.#t=null)}setFPS(e){this.playback.setFps(xt(e))}get isSeeking(){return this.#t!==null}get isPlaying(){return this.playback.isPlaying}get duration(){return this.playback.duration}get currentTime(){return this.playback.currentTime}update(e){this.playback.update(e)}async#r(){for(;this.#e!==null;){let e=this.#e;this.#e=null;let t=await this.playback.seek(X(e));(await this.driver.composite(t)).close()}}};var Ke=class{#e;#t;constructor(e={}){this.#e=e.chunkFrames??1024,this.#t=e.clamp??!0}async*mix(e){let t=this.#e,n=null,o=null,i=[],s=0,a=0;for await(let l of e){if(o===null)o=l.planes.length,n=l.sampleRate;else{if(l.planes.length!==o)throw new Error("Channel count changed");if(l.sampleRate!==n)throw new Error("Sample rate changed")}let c=Math.round(l.timestamp*n),f=l.planes[0]?.length??0;for(;s+t<=c;)yield this.#r(i,s,o,n),s+=t;i.push({startFrame:c,endFrame:c+f,data:l.planes}),a=Math.max(a,c+f)}if(o!==null&&n!==null)for(;s<a;)yield this.#r(i,s,o,n),s+=t}#r(e,t,n,o){let i=this.#e,s=new Float32Array(n*i),a=t+i;for(let l=0;l<n;l++){let c=l*i,f=s.subarray(c,c+i);for(let u of e){let m=u.data[l];if(!m)continue;let p=Math.max(t,u.startFrame),d=Math.min(a,u.endFrame);if(p>=d)continue;let g=p-t,x=p-u.startFrame,y=d-p;for(let v=0;v<y;v++)f[g+v]+=m[x+v]}if(this.#t)for(let u=0;u<i;u++){let m=f[u];f[u]=m<-1?-1:m>1?1:m}}for(let l=e.length-1;l>=0;l--)e[l].endFrame<=a&&e.splice(l,1);return{planar:s,sampleRate:o,channels:n,frames:i,startFrame:t}}};var Zd=(r,e,t)=>{if(e===t)return r;let n=t/e,o=Math.max(1,Math.round(r.length*n)),i=new Float32Array(o);for(let s=0;s<o;s++){let a=s/n,l=Math.floor(a),c=Math.min(l+1,r.length-1),f=a-l;i[s]=r[l]*(1-f)+r[c]*f}return i},Ye=(r,e)=>{let t=r.numberOfChannels,n=new Array(t),o=0;for(let i=0;i<t;i++){let s=new Float32Array(r.numberOfFrames);r.copyTo(s,{planeIndex:i,format:"f32-planar"});let a=Zd(s,r.sampleRate,e);n[i]=a,o=a.length}return{data:n,frames:o}};var Br=(r,e)=>{if(e!==1)for(let t of r)for(let n=0;n<t.length;n++)t[n]*=e};function ui({timeline:r,resolveMedia:e}){let t=new Ke,n=Jd(r,e),o=new TransformStream,i=o.writable.getWriter();async function s(){for await(let a of t.mix(n)){let l=new AudioData({format:"f32-planar",sampleRate:a.sampleRate,numberOfFrames:a.frames,numberOfChannels:a.channels,timestamp:Math.round(a.startFrame/a.sampleRate*1e6),data:new Float32Array(a.planar)});await i.write(l)}await i.close()}return s(),o.readable}async function*Jd(r,e){let t=ai(e);for await(let{sample:n,timestamp:o,gain:i}of t.sampleAudio(r,X(0))){let{data:s}=Ye(n,48e3);Br(s,i),yield{planes:s,sampleRate:48e3,timestamp:o},n.close()}}function fi({timeline:r,fps:e,driver:t,resolveMedia:n}){let o=new TransformStream,i=o.writable.getWriter(),s=new It(t,n,r),a=1/e,l=ee(r.rootId,r);async function c(){await kc({fps:e,duration:l},async(f,u)=>{let m=await s.next(f),p=await t.composite(m),d=new VideoFrame(p,{timestamp:Math.round(u*a*1e6),duration:Math.round(a*1e6)});await i.write(d),p.close()}),await i.close()}return c(),o.readable}function fu(r){let e=ui({...r}),t=fi({...r});return r.driver.encode({video:t,audio:e,config:{audio:{codec:"opus",bitrate:128e3},video:{codec:"vp9",bitrate:1e6}}})}var At=class{driver;resources=new ei;constructor(e){this.driver=e}load=async e=>Object.fromEntries(await Promise.all(Object.entries(e).map(async([t,n])=>[t,await this.resources.store(await n)])));timeline=e=>{let t=new re({timeline:{format:"timeline",info:"https://omniclip.app/",version:0,items:[],rootId:0}}),n=e(t);return t.timeline.rootId=n.id,t.timeline};playback=async e=>new ci(this.driver,t=>this.resources.require(t).url,e);render=async(e,t=30)=>fu({timeline:e,fps:xt(t),driver:this.driver,resolveMedia:n=>this.resources.require(n).url})};function da(r,e){return{error:t=>r.error({...e,...t}),rpcRequest:t=>r.rpcRequest({...e,...t}),rpcError:t=>r.rpcError({...e,...t})}}var mi=()=>r=>({plain:r.none,errMessage:r.mix(r.brightRed,r.bold),errName:r.red,errStack:r.mix(r.red,r.dim),timestamp:r.blue,timestampErr:r.red});function mu(){return mi()}var Ft=Object.freeze({black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",brightBlack:"\x1B[90m",brightRed:"\x1B[91m",brightGreen:"\x1B[92m",brightYellow:"\x1B[93m",brightBlue:"\x1B[94m",brightMagenta:"\x1B[95m",brightCyan:"\x1B[96m",brightWhite:"\x1B[97m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bgBrightBlack:"\x1B[100m",bgBrightRed:"\x1B[101m",bgBrightGreen:"\x1B[102m",bgBrightYellow:"\x1B[103m",bgBrightBlue:"\x1B[104m",bgBrightMagenta:"\x1B[105m",bgBrightCyan:"\x1B[106m",bgBrightWhite:"\x1B[107m",bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",inverse:"\x1B[7m",hidden:"\x1B[8m",strikethrough:"\x1B[9m",reset:"\x1B[0m"});var pi=()=>({none:r=>r,uncolor:th,mix:rh,hex:nh,rgb:pu,bgRgb:oh});function th(r){return r.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,"")}function rh(...r){return e=>{for(let t of r)e=t(e);return e}}function nh(r){r=r.replace(/^#/,"");let e,t,n,o;if(r.length===3)e=parseInt(r.split("").map(i=>i+i).join(""),16);else if(r.length===6)e=parseInt(r,16);else throw new Error("Invalid hex color");return t=e>>16&255,n=e>>8&255,o=e&255,pu(t,n,o)}function pu(r,e,t){let n=`\x1B[38;2;${r};${e};${t}m`;return o=>`${n}${o}${Ft.reset}`}function oh(r,e,t){let n=`\x1B[48;2;${r};${e};${t}m`;return o=>`${n}${o}${Ft.reset}`}var Bn={...Object.fromEntries(Object.entries(Ft).map(([r])=>[r,e=>e])),...pi()};var Un={...Object.fromEntries(Object.entries(Ft).map(([r,e])=>[r,t=>`${e}${t}${Ft.reset}`])),...pi()};function ha(){return typeof Deno<"u"&&typeof Deno.version<"u"}function ga(){return typeof process<"u"&&process.versions&&process.versions.node}function du(){return ga()?process.env.FORCE_COLOR||process.stdout.isTTY&&process.env.TERM!=="dumb":ha()?Deno.env.get("FORCE_COLOR")||Deno.isatty(Deno.stdout.rid)&&Deno.env.get("TERM")!=="dumb":!1}var xa=()=>du()?Un:Bn;var di=()=>({colors:r,theme:e})=>{let t=e(r);function n(s){let a=s.stack?`
|
|
2866
2866
|
`+s.stack+`
|
|
2867
|
-
`:"";return[t.errName(s.name+":"),t.errMessage(s.message)].join(" ")+t.errStack(a)}function o(s){return s&&s instanceof Error?n(s):s}function i(s){return s&&s instanceof Error?n(s):t.errMessage(s)}return{stdout:s=>s.map(o),stderr:s=>s.map(i)}};function Nn(...r){return e=>({stdout:t=>{for(let n of r)t=n(e).stdout(t);return t},stderr:t=>{for(let n of r)t=n(e).stderr(t);return t}})}function
|
|
2867
|
+
`:"";return[t.errName(s.name+":"),t.errMessage(s.message)].join(" ")+t.errStack(a)}function o(s){return s&&s instanceof Error?n(s):s}function i(s){return s&&s instanceof Error?n(s):t.errMessage(s)}return{stdout:s=>s.map(o),stderr:s=>s.map(i)}};function Nn(...r){return e=>({stdout:t=>{for(let n of r)t=n(e).stdout(t);return t},stderr:t=>{for(let n of r)t=n(e).stderr(t);return t}})}function ih(){return{icon:"\u{1F6A8}",now:()=>Date.now()}}var hi=r=>({colors:e,theme:t})=>{let n={...ih(),...r},o=t(e),i=new Date(n.now()),s=i.getUTCFullYear().toString().padStart(4,"0"),a=(i.getUTCMonth()+1).toString().padStart(2,"0"),l=i.getUTCDate().toString().padStart(2,"0"),c=`${s}-${a}-${l}`,f=i.getUTCHours().toString().padStart(2,"0"),u=i.getUTCMinutes().toString().padStart(2,"0"),m=i.getUTCSeconds().toString().padStart(2,"0"),p=i.getUTCMilliseconds().toString().padStart(3,"0"),d=`${f}:${u}:${m}.${p}`,g=`${c}::${d}`;return{stdout:x=>[o.timestamp(g),...x],stderr:x=>[o.timestampErr(g),...[n.icon].filter(Boolean),...x]}};function hu(){return Nn(di(),hi())}var gi=()=>({stdout:async r=>{await Deno.stdout.write(new TextEncoder().encode(r+`
|
|
2868
2868
|
`))},stderr:async r=>{await Deno.stderr.write(new TextEncoder().encode(r+`
|
|
2869
2869
|
`))}});var xi=()=>({stdout:async r=>{process.stdout.write(r+`
|
|
2870
2870
|
`)},stderr:async r=>{process.stderr.write(r+`
|
|
2871
|
-
`)}});var vi=()=>({stdout:async r=>console.log(r),stderr:async r=>console.error(r)});var gu=()=>ha()?gi():ga()?xi():vi();var xu=()=>({stdout:async()=>{},stderr:async()=>{}});function vu(){return()=>({stdout:r=>r,stderr:r=>r})}var Ur=class r{static writers={auto:gu,void:xu,deno:gi,node:xi,console:vi};static colors={auto:xa,colorful:()=>Un,colorless:()=>Bn};static themes={auto:mu,basic:mi};static shapers={auto:hu,none:vu,errors:di,timestamp:hi};writer=r.writers.auto();colors=r.colors.auto();theme=r.themes.auto();shaper=r.shapers.auto();async log(...e){await this.writer.stdout(this.shaper(this).stdout(e).join(" "))}async error(...e){await this.writer.stderr(this.shaper(this).stderr(e).join(" "))}setWriter(e){return this.writer=e,this}setColors(e){return this.colors=e,this}setTheme(e){return this.theme=e,this}setShaper(...e){return this.shaper=Nn(...e),this}};var Ln=class extends Ur{static dummy(){return new this().setWriter(Ur.writers.void())}rpcRequest=async({request:e,...t})=>{let n=this.colors.none;this.log(...this.#e(t),n(`${e.method}()`))};rpcError=async({request:e,error:t,...n})=>{this.error(...this.#e(n),`${e.method}()`,t)};#e({meta:e,label:t,remote:n}){let o=this.colors.mix(this.colors.blue,this.colors.dim),i=this.colors.mix(this.colors.cyan,this.colors.dim);return[e?this.#t(e):void 0,t||void 0,n===void 0?void 0:n?o("<-"):i("->")].filter(Boolean)}#t(e){let{headers:t}=e.request;return[this.colors.yellow(`[${e.ip}]`),this.colors.green(t.origin?t.origin:"(no-origin)")].join(" ")}};var Qe=class extends Ln{rpcRequest=async()=>{}};var ut;(function(r){r.version="2.0";function e(t){return"id"in t?t.id:null}r.getId=e,r.errorCodes={serverError:-32e3,unexposedError:-32001}})(ut||(ut={}));var yi=class extends Error{name=this.constructor.name},er=class extends Error{name=this.constructor.name};async function yu({tap:r,request:e,action:t}){let n=ut.getId(e);try{let o=await t();return n===null?null:{id:n,result:o,jsonrpc:ut.version}}catch(o){return r.rpcError({request:e,error:o}),n===null?null:{id:n,jsonrpc:ut.version,error:o instanceof yi?{code:ut.errorCodes.serverError,message:o.message}:{code:ut.errorCodes.unexposedError,message:"unexposed error"}}}}function bi(r){let e=r.tap??new Qe;return async t=>{let n=t.method.split("."),o=tl(r.fns,n),i=async()=>await o(...t.params);return e.rpcRequest({request:t}),await yu({tap:e,request:t,action:i})}}var Nr=Symbol("tune"),
|
|
2871
|
+
`)}});var vi=()=>({stdout:async r=>console.log(r),stderr:async r=>console.error(r)});var gu=()=>ha()?gi():ga()?xi():vi();var xu=()=>({stdout:async()=>{},stderr:async()=>{}});function vu(){return()=>({stdout:r=>r,stderr:r=>r})}var Ur=class r{static writers={auto:gu,void:xu,deno:gi,node:xi,console:vi};static colors={auto:xa,colorful:()=>Un,colorless:()=>Bn};static themes={auto:mu,basic:mi};static shapers={auto:hu,none:vu,errors:di,timestamp:hi};writer=r.writers.auto();colors=r.colors.auto();theme=r.themes.auto();shaper=r.shapers.auto();async log(...e){await this.writer.stdout(this.shaper(this).stdout(e).join(" "))}async error(...e){await this.writer.stderr(this.shaper(this).stderr(e).join(" "))}setWriter(e){return this.writer=e,this}setColors(e){return this.colors=e,this}setTheme(e){return this.theme=e,this}setShaper(...e){return this.shaper=Nn(...e),this}};var Ln=class extends Ur{static dummy(){return new this().setWriter(Ur.writers.void())}rpcRequest=async({request:e,...t})=>{let n=this.colors.none;this.log(...this.#e(t),n(`${e.method}()`))};rpcError=async({request:e,error:t,...n})=>{this.error(...this.#e(n),`${e.method}()`,t)};#e({meta:e,label:t,remote:n}){let o=this.colors.mix(this.colors.blue,this.colors.dim),i=this.colors.mix(this.colors.cyan,this.colors.dim);return[e?this.#t(e):void 0,t||void 0,n===void 0?void 0:n?o("<-"):i("->")].filter(Boolean)}#t(e){let{headers:t}=e.request;return[this.colors.yellow(`[${e.ip}]`),this.colors.green(t.origin?t.origin:"(no-origin)")].join(" ")}};var Qe=class extends Ln{rpcRequest=async()=>{}};var ut;(function(r){r.version="2.0";function e(t){return"id"in t?t.id:null}r.getId=e,r.errorCodes={serverError:-32e3,unexposedError:-32001}})(ut||(ut={}));var yi=class extends Error{name=this.constructor.name},er=class extends Error{name=this.constructor.name};async function yu({tap:r,request:e,action:t}){let n=ut.getId(e);try{let o=await t();return n===null?null:{id:n,result:o,jsonrpc:ut.version}}catch(o){return r.rpcError({request:e,error:o}),n===null?null:{id:n,jsonrpc:ut.version,error:o instanceof yi?{code:ut.errorCodes.serverError,message:o.message}:{code:ut.errorCodes.unexposedError,message:"unexposed error"}}}}function bi(r){let e=r.tap??new Qe;return async t=>{let n=t.method.split("."),o=tl(r.fns,n),i=async()=>await o(...t.params);return e.rpcRequest({request:t}),await yu({tap:e,request:t,action:i})}}var Nr=Symbol("tune"),sh=Symbol("query"),ah=Symbol("notify"),lh=Symbol("settings");function bu(r){function e(t){let n={notify:void 0};return new Proxy((()=>{}),{apply:(o,i,s)=>r(t,s,n),get:(o,i)=>{if(i!=="then")return i===Nr?s=>(...a)=>r(t,a,{...n,...s}):i===ah?(...s)=>r(t,s,{...n,notify:!0}):i===sh?(...s)=>r(t,s,{...n,notify:!1}):i===lh?n:(o[i]||(o[i]=e([...t,i])),o[i])},set:(o,i,s)=>(o[i]=s,!0)})}return e([])}function tr(r){let{endpoint:e,tap:t=new Qe}=r,n=1;return bu(async(o,i,s)=>{let a=s.notify??r.notify??!1,l=s.transfer,c={jsonrpc:"2.0",method:o.join("."),params:i},f=a?c:{...c,id:n++};t.rpcRequest({request:f});let u=await e(f,{transfer:l});if(a&&!u)return null;if(!u)throw new er("response was null, but shouldn't be, because the request was not a notification");if("error"in u)throw new er(r.label?`${r.label}: ${u.error.message}`:u.error.message);return u.result})}function Vn(r){return tr({endpoint:bi(r),tap:r.tap})}var rr=class{recv=Ee();sendRequest=Ee();sendResponse=Ee();static makeEntangledPair({origin:e="example.e280.org"}={}){let t=new this,n=new this,o=[t.sendRequest.sub(s=>n.recv(s,{origin:e})),t.sendResponse.sub(s=>n.recv(s,{origin:e})),n.sendRequest.sub(s=>t.recv(s,{origin:e})),n.sendResponse.sub(s=>t.recv(s,{origin:e}))];return[t,n,()=>o.forEach(s=>s())]}};function Si(r,e){return r.addEventListener("message",e),()=>r.removeEventListener("message",e)}function Su(r,e){return async(t,{transfer:n}={})=>{if("id"in t){let o=qe();return e(t,n,o.promise),r.wait(t.id,t.method).then(i=>(o.resolve(i),i))}else{let o=Promise.resolve(null);return e(t,n,o),o}}}function Tu(r){let e=[],t=[];for(let n of Array.isArray(r)?r:[r])"method"in n?e.push(n):t.push(n);return{requests:e,responses:t}}async function wu(r,e){let t=(await Promise.all(e.map(async n=>r(n)))).filter(n=>n!==null);return t.length===0?null:t.length===1?t[0]:t}var Lr=class extends rr{dispose=to();constructor(e){super(),this.dispose.schedule(this.sendRequest.sub((t,n)=>e.postMessage(t,n)),this.sendResponse.sub((t,n)=>e.postMessage(t,n)),Si(e,t=>this.recv(t.data,t)))}};var Ti=class{remote;transfer;constructor(e){this.remote=e}};var va=Object.freeze({timeout:6e4,maxRequestBytes:1e7});var wi=class{timeout;pending=new Map;constructor(e){this.timeout=e}async wait(e,t){let n=qe();return this.pending.set(e,{method:t,deferred:n}),await el(this.timeout,()=>n.promise).catch(o=>{throw o instanceof cn&&(o.message=`request #${e} ${t}(), ${o.message}`),o})}deliverResponse(e){let t=this.pending.get(e.id);t&&("error"in e?t.deferred.reject(new er(e.error.message)):t.deferred.resolve(e))}};var nr=class{options;remote;remoteEndpoint;dispose=to();#e;constructor(e){this.options=e;let{conduit:t,tap:n}=e;this.#e=new wi(e.timeout??va.timeout),this.remoteEndpoint=Su(this.#e,t.sendRequest.pub.bind(t.sendRequest)),this.remote=tr({endpoint:this.remoteEndpoint,tap:n&&da(n,{remote:!0})}),this.dispose.schedule(t.recv.sub(o=>this.recv(o)))}async recv(e){let t=new Ti(this.remote),{conduit:n,rpc:o,tap:i}=this.options,{requests:s,responses:a}=Tu(e);for(let u of a)this.#e.deliverResponse(u);if(!o)return;let l=await o(t),c=bi({fns:l,tap:i&&da(i,{remote:!1})}),f=await wu(c,s);f&&await n.sendResponse(f,t.transfer)}};var ft={derive:{host:r=>({host:r.remote.host,get transfer(){return r.transfer},set transfer(e){r.transfer=e}}),work:r=>({work:r.remote,get transfer(){return r.transfer},set transfer(e){r.transfer=e}})},mock:{host:()=>({host:void 0,transfer:void 0}),work:()=>({work:void 0,transfer:void 0})}};var mt=new Qe;async function Cu(r,e,t={}){let n=t.tap??mt,o=new nr({tap:n,timeout:t.timeout??1/0,conduit:new Lr(r.getSelf()),rpc:async i=>e(ft.derive.host(i))});return await o.remote.infra.ready(),o.remote.host}var Vr=class{worker;messenger;constructor(e,t){this.worker=e,this.messenger=t}static async make(e,t){let n=t.tap??mt,o=t.label??"comrade",i=e.loadWorker(t.workerUrl,o),s=qe(),a={async ready(){s.resolve()}},l=new nr({tap:n,timeout:t.timeout??1/0,conduit:new Lr(i),rpc:async c=>({infra:a,host:t.setupHost(ft.derive.work(c))})});return await s.promise,new this(i,l)}get work(){return this.messenger.remote}terminate(){this.worker.terminate()}};var Ci=class{threads;static async make(e,t){let n=t.workerCount??e.guessOptimalThreadCount(),o=await Promise.all([...Array(n)].map(async(i,s)=>Vr.make(e,{...t,label:t.label??`${t.label??"comrade"}_${s+1}`})));return new this(o,{tap:t.tap})}work;#e=new Set;#t=[];constructor(e,t={}){this.threads=e;let n=t.tap??mt,o=async(i,s)=>this.#r({request:i,prom:qe(),transfer:s?.transfer});this.work=tr({tap:n,endpoint:o}),e.forEach(i=>this.#e.add(i))}get threadCount(){return this.threads.length}terminate(){for(let e of this.threads)e.terminate()}#r(e){return this.#t.push(e),this.#n(),e.prom.promise}#n(){for(;this.#e.size>0&&this.#t.length>0;){let e=[...this.#e].pop();this.#e.delete(e);let t=this.#t.shift();this.#e.delete(e);let n=e.messenger.remoteEndpoint(t.request,{transfer:t.transfer});t.prom.entangle(n).finally(()=>{this.#e.add(e),this.#n()})}}};var ku=r=>({thread:e=>Vr.make(r,e),cluster:e=>Ci.make(r,e),worker:(e,t={})=>Cu(r,e,t),work:e=>e,host:e=>e,mocks(e){let{setupWork:t,setupHost:n,tap:o=mt}=e,i=ft.mock.host(),s=ft.mock.work();return s.work=Vn({tap:o,fns:t(i)}),i.host=Vn({tap:o,fns:n(s)}),{workShell:s,hostShell:i,work:s.work,host:i.host}},mockWork(e,t=mt){let n=ft.mock.host(),o=ft.mock.work();return o.work=Vn({tap:t,fns:e(n)}),{workShell:o,hostShell:n,work:o.work,mockHost:i=>(n.host=Vn({tap:t,fns:i(o)}),{workShell:o,hostShell:n,work:o.work,host:n.host})}}});var Pu=()=>({getSelf(){return self},guessOptimalThreadCount(){let r=navigator.hardwareConcurrency??1;return Math.max(1,r-1)},loadWorker(r,e){return new window.Worker(r,{name:e,type:"module"})},async loadWasm(r){return WebAssembly.instantiateStreaming(fetch(r))}});var fh=Pu(),ki=ku(fh);var Pi=class{count=0};var Li={};La(Li,{AdjustmentFilter:()=>zu,AdvancedBloomFilter:()=>Ku,AsciiFilter:()=>ef,BackdropBlurFilter:()=>_i,BevelFilter:()=>lf,BloomFilter:()=>ff,BulgePinchFilter:()=>xf,CRTFilter:()=>Kf,ColorGradientFilter:()=>Sf,ColorMapFilter:()=>Pf,ColorOverlayFilter:()=>Ef,ColorReplaceFilter:()=>Mf,ConvolutionFilter:()=>Gf,CrossHatchFilter:()=>zi,DotFilter:()=>em,DropShadowFilter:()=>im,EmbossFilter:()=>Xr,GlitchFilter:()=>mm,GlowFilter:()=>xm,GodrayFilter:()=>Cm,GrayscaleFilter:()=>Oi,HslAdjustmentFilter:()=>Em,KawaseBlurFilter:()=>Gr,MotionBlurFilter:()=>Mm,MultiColorReplaceFilter:()=>Vm,OldFilmFilter:()=>jm,OutlineFilter:()=>Km,PixelateFilter:()=>Kr,RGBSplitFilter:()=>pp,RadialBlurFilter:()=>rp,ReflectionFilter:()=>ap,ShockwaveFilter:()=>vp,SimpleLightmapFilter:()=>wp,SimplexNoiseFilter:()=>Ip,TiltShiftAxisFilter:()=>Yr,TiltShiftFilter:()=>Ni,TwistFilter:()=>Up,ZoomBlurFilter:()=>Hp,angleFromCssOrientation:()=>ka,angleFromDirectionalValue:()=>Pa,colorAsStringFromCssStop:()=>wa,offsetsFromCssColorStops:()=>Ca,parseCssGradient:()=>Ai,stopsFromCssStops:()=>Ta,trimCssGradient:()=>_a,typeFromCssType:()=>Sa,vertex:()=>z,wgslVertex:()=>D});var z=`in vec2 aPosition;
|
|
2872
2872
|
out vec2 vTextureCoord;
|
|
2873
2873
|
|
|
2874
2874
|
uniform vec4 uInputSize;
|
|
@@ -3006,7 +3006,7 @@ fn mainFragment(
|
|
|
3006
3006
|
}
|
|
3007
3007
|
|
|
3008
3008
|
return sample * color.a;
|
|
3009
|
-
}`;var
|
|
3009
|
+
}`;var mh=Object.defineProperty,ph=(r,e,t)=>e in r?mh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Au=(r,e,t)=>(ph(r,typeof e!="symbol"?e+"":e,t),t),Fu=class Eu extends _{constructor(e){e={...Eu.DEFAULT_OPTIONS,...e};let t=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:Iu,entryPoint:"mainFragment"}}),n=I.from({vertex:z,fragment:_u,name:"adjustment-filter"});super({gpuProgram:t,glProgram:n,resources:{adjustmentUniforms:{uGamma:{value:e.gamma,type:"f32"},uContrast:{value:e.contrast,type:"f32"},uSaturation:{value:e.saturation,type:"f32"},uBrightness:{value:e.brightness,type:"f32"},uColor:{value:[e.red,e.green,e.blue,e.alpha],type:"vec4<f32>"}}}}),Au(this,"uniforms"),this.uniforms=this.resources.adjustmentUniforms.uniforms}get gamma(){return this.uniforms.uGamma}set gamma(e){this.uniforms.uGamma=e}get contrast(){return this.uniforms.uContrast}set contrast(e){this.uniforms.uContrast=e}get saturation(){return this.uniforms.uSaturation}set saturation(e){this.uniforms.uSaturation=e}get brightness(){return this.uniforms.uBrightness}set brightness(e){this.uniforms.uBrightness=e}get red(){return this.uniforms.uColor[0]}set red(e){this.uniforms.uColor[0]=e}get green(){return this.uniforms.uColor[1]}set green(e){this.uniforms.uColor[1]=e}get blue(){return this.uniforms.uColor[2]}set blue(e){this.uniforms.uColor[2]=e}get alpha(){return this.uniforms.uColor[3]}set alpha(e){this.uniforms.uColor[3]=e}};Au(Fu,"DEFAULT_OPTIONS",{gamma:1,contrast:1,saturation:1,brightness:1,red:1,green:1,blue:1,alpha:1});var zu=Fu;var Du=`
|
|
3010
3010
|
in vec2 vTextureCoord;
|
|
3011
3011
|
out vec4 finalColor;
|
|
3012
3012
|
|
|
@@ -3131,7 +3131,7 @@ fn mainFragment(
|
|
|
3131
3131
|
color *= 0.25;
|
|
3132
3132
|
|
|
3133
3133
|
return color;
|
|
3134
|
-
}`;var
|
|
3134
|
+
}`;var dh=Object.defineProperty,hh=(r,e,t)=>e in r?dh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,or=(r,e,t)=>(hh(r,typeof e!="symbol"?e+"":e,t),t),Bu=class Uu extends _{constructor(...e){let t=e[0]??{};(typeof t=="number"||Array.isArray(t))&&(N("6.0.0","KawaseBlurFilter constructor params are now options object. See params: { strength, quality, clamp, pixelSize }"),t={strength:t},e[1]!==void 0&&(t.quality=e[1]),e[2]!==void 0&&(t.clamp=e[2])),t={...Uu.DEFAULT_OPTIONS,...t};let n=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:t?.clamp?Mu:Ou,entryPoint:"mainFragment"}}),o=I.from({vertex:z,fragment:t?.clamp?Ru:Du,name:"kawase-blur-filter"});super({gpuProgram:n,glProgram:o,resources:{kawaseBlurUniforms:{uOffset:{value:new Float32Array(2),type:"vec2<f32>"}}}}),or(this,"uniforms"),or(this,"_pixelSize",{x:0,y:0}),or(this,"_clamp"),or(this,"_kernels",[]),or(this,"_blur"),or(this,"_quality"),this.uniforms=this.resources.kawaseBlurUniforms.uniforms,this.pixelSize=t.pixelSize??{x:1,y:1},Array.isArray(t.strength)?this.kernels=t.strength:typeof t.strength=="number"&&(this._blur=t.strength,this.quality=t.quality??3),this._clamp=!!t.clamp}apply(e,t,n,o){let i=this.pixelSizeX/t.source.width,s=this.pixelSizeY/t.source.height,a;if(this._quality===1||this._blur===0)a=this._kernels[0]+.5,this.uniforms.uOffset[0]=a*i,this.uniforms.uOffset[1]=a*s,e.applyFilter(this,t,n,o);else{let l=J.getSameSizeTexture(t),c=t,f=l,u,m=this._quality-1;for(let p=0;p<m;p++)a=this._kernels[p]+.5,this.uniforms.uOffset[0]=a*i,this.uniforms.uOffset[1]=a*s,e.applyFilter(this,c,f,!0),u=c,c=f,f=u;a=this._kernels[m]+.5,this.uniforms.uOffset[0]=a*i,this.uniforms.uOffset[1]=a*s,e.applyFilter(this,c,n,o),J.returnTexture(l)}}get strength(){return this._blur}set strength(e){this._blur=e,this._generateKernels()}get quality(){return this._quality}set quality(e){this._quality=Math.max(1,Math.round(e)),this._generateKernels()}get kernels(){return this._kernels}set kernels(e){Array.isArray(e)&&e.length>0?(this._kernels=e,this._quality=e.length,this._blur=Math.max(...e)):(this._kernels=[0],this._quality=1)}get pixelSize(){return this._pixelSize}set pixelSize(e){if(typeof e=="number"){this.pixelSizeX=this.pixelSizeY=e;return}if(Array.isArray(e)){this.pixelSizeX=e[0],this.pixelSizeY=e[1];return}this._pixelSize=e}get pixelSizeX(){return this.pixelSize.x}set pixelSizeX(e){this.pixelSize.x=e}get pixelSizeY(){return this.pixelSize.y}set pixelSizeY(e){this.pixelSize.y=e}get clamp(){return this._clamp}_updatePadding(){this.padding=Math.ceil(this._kernels.reduce((e,t)=>e+t+.5,0))}_generateKernels(){let e=this._blur,t=this._quality,n=[e];if(e>0){let o=e,i=e/t;for(let s=1;s<t;s++)o-=i,n.push(o)}this._kernels=n,this._updatePadding()}};or(Bu,"DEFAULT_OPTIONS",{strength:4,quality:3,clamp:!1,pixelSize:{x:1,y:1}});var Gr=Bu;var Nu=`in vec2 vTextureCoord;
|
|
3135
3135
|
out vec4 finalColor;
|
|
3136
3136
|
|
|
3137
3137
|
uniform sampler2D uTexture;
|
|
@@ -3214,7 +3214,7 @@ fn mainFragment(
|
|
|
3214
3214
|
|
|
3215
3215
|
return select(vec4<f32>(0.), color, brightness > extractBrightnessUniforms.uThreshold);
|
|
3216
3216
|
}
|
|
3217
|
-
`;var
|
|
3217
|
+
`;var gh=Object.defineProperty,xh=(r,e,t)=>e in r?gh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,qu=(r,e,t)=>(xh(r,typeof e!="symbol"?e+"":e,t),t),Hu=class Wu extends _{constructor(e){e={...Wu.DEFAULT_OPTIONS,...e};let t=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:Gu,entryPoint:"mainFragment"}}),n=I.from({vertex:z,fragment:Vu,name:"extract-brightness-filter"});super({gpuProgram:t,glProgram:n,resources:{extractBrightnessUniforms:{uThreshold:{value:e.threshold,type:"f32"}}}}),qu(this,"uniforms"),this.uniforms=this.resources.extractBrightnessUniforms.uniforms}get threshold(){return this.uniforms.uThreshold}set threshold(e){this.uniforms.uThreshold=e}};qu(Hu,"DEFAULT_OPTIONS",{threshold:.5});var ju=Hu;var vh=Object.defineProperty,yh=(r,e,t)=>e in r?vh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,qr=(r,e,t)=>(yh(r,typeof e!="symbol"?e+"":e,t),t),Xu=class $u extends _{constructor(e){e={...$u.DEFAULT_OPTIONS,...e};let t=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:Lu,entryPoint:"mainFragment"}}),n=I.from({vertex:z,fragment:Nu,name:"advanced-bloom-filter"});super({gpuProgram:t,glProgram:n,resources:{advancedBloomUniforms:{uBloomScale:{value:e.bloomScale,type:"f32"},uBrightness:{value:e.brightness,type:"f32"}},uMapTexture:ae.WHITE}}),qr(this,"uniforms"),qr(this,"bloomScale",1),qr(this,"brightness",1),qr(this,"_extractFilter"),qr(this,"_blurFilter"),this.uniforms=this.resources.advancedBloomUniforms.uniforms,this._extractFilter=new ju({threshold:e.threshold}),this._blurFilter=new Gr({strength:e.kernels??e.blur,quality:e.kernels?void 0:e.quality}),Object.assign(this,e)}apply(e,t,n,o){let i=J.getSameSizeTexture(t);this._extractFilter.apply(e,t,i,!0);let s=J.getSameSizeTexture(t);this._blurFilter.apply(e,i,s,!0),this.uniforms.uBloomScale=this.bloomScale,this.uniforms.uBrightness=this.brightness,this.resources.uMapTexture=s.source,e.applyFilter(this,t,n,o),J.returnTexture(s),J.returnTexture(i)}get threshold(){return this._extractFilter.threshold}set threshold(e){this._extractFilter.threshold=e}get kernels(){return this._blurFilter.kernels}set kernels(e){this._blurFilter.kernels=e}get blur(){return this._blurFilter.strength}set blur(e){this._blurFilter.strength=e}get quality(){return this._blurFilter.quality}set quality(e){this._blurFilter.quality=e}get pixelSize(){return this._blurFilter.pixelSize}set pixelSize(e){typeof e=="number"&&(e={x:e,y:e}),Array.isArray(e)&&(e={x:e[0],y:e[1]}),this._blurFilter.pixelSize=e}get pixelSizeX(){return this._blurFilter.pixelSizeX}set pixelSizeX(e){this._blurFilter.pixelSizeX=e}get pixelSizeY(){return this._blurFilter.pixelSizeY}set pixelSizeY(e){this._blurFilter.pixelSizeY=e}};qr(Xu,"DEFAULT_OPTIONS",{threshold:.5,bloomScale:1,brightness:1,blur:8,quality:4,pixelSize:{x:1,y:1}});var Ku=Xu;var Yu=`precision highp float;
|
|
3218
3218
|
in vec2 vTextureCoord;
|
|
3219
3219
|
out vec4 finalColor;
|
|
3220
3220
|
|
|
@@ -3412,7 +3412,7 @@ fn unmapCoord(coord: vec2<f32> ) -> vec2<f32>
|
|
|
3412
3412
|
mappedCoord -= gfu.uOutputFrame.xy;
|
|
3413
3413
|
mappedCoord /= gfu.uInputSize.xy;
|
|
3414
3414
|
return mappedCoord;
|
|
3415
|
-
}`;var
|
|
3415
|
+
}`;var bh=Object.defineProperty,Sh=(r,e,t)=>e in r?bh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ya=(r,e,t)=>(Sh(r,typeof e!="symbol"?e+"":e,t),t),Zu=class Ju extends _{constructor(...e){let t=e[0]??{};typeof t=="number"&&(N("6.0.0","AsciiFilter constructor params are now options object. See params: { size, color, replaceColor }"),t={size:t});let n=t?.color&&t.replaceColor!==!1;t={...Ju.DEFAULT_OPTIONS,...t};let o=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:Qu,entryPoint:"mainFragment"}}),i=I.from({vertex:z,fragment:Yu,name:"ascii-filter"});super({gpuProgram:o,glProgram:i,resources:{asciiUniforms:{uSize:{value:t.size,type:"f32"},uColor:{value:new Float32Array(3),type:"vec3<f32>"},uReplaceColor:{value:Number(n),type:"f32"}}}}),ya(this,"uniforms"),ya(this,"_color"),this.uniforms=this.resources.asciiUniforms.uniforms,this._color=new Q,this.color=t.color??16777215}get size(){return this.uniforms.uSize}set size(e){this.uniforms.uSize=e}get color(){return this._color.value}set color(e){this._color.setValue(e);let[t,n,o]=this._color.toArray();this.uniforms.uColor[0]=t,this.uniforms.uColor[1]=n,this.uniforms.uColor[2]=o}get replaceColor(){return this.uniforms.uReplaceColor>.5}set replaceColor(e){this.uniforms.uReplaceColor=e?1:0}};ya(Zu,"DEFAULT_OPTIONS",{size:8,color:16777215,replaceColor:!1});var ef=Zu;var tf=`precision highp float;
|
|
3416
3416
|
in vec2 vTextureCoord;
|
|
3417
3417
|
out vec4 finalColor;
|
|
3418
3418
|
|
|
@@ -3449,7 +3449,7 @@ fn mainFragment(
|
|
|
3449
3449
|
var color: vec3<f32> = mix(back.rgb, front.rgb / front.a, front.a);
|
|
3450
3450
|
|
|
3451
3451
|
return vec4<f32>(color, 1.0);
|
|
3452
|
-
}`;var
|
|
3452
|
+
}`;var Th=Object.defineProperty,wh=(r,e,t)=>e in r?Th(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ch=(r,e,t)=>(wh(r,typeof e!="symbol"?e+"":e,t),t),_i=class extends _t{constructor(e){super(e),Ch(this,"_blendPass"),this.blendRequired=!0,this.padding=0,this._blendPass=new _({gpuProgram:A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:rf,entryPoint:"mainFragment"}}),glProgram:I.from({vertex:z,fragment:tf,name:"drop-shadow-filter"}),resources:{uBackground:ae.EMPTY}})}apply(e,t,n,o){let i=e._activeFilterData.backTexture,s=J.getSameSizeTexture(t);super.apply(e,i,s,!0),this._blendPass.resources.uBackground=s.source,this._blendPass.apply(e,t,n,o),J.returnTexture(s)}updatePadding(){this.padding=0}};var nf=`precision highp float;
|
|
3453
3453
|
in vec2 vTextureCoord;
|
|
3454
3454
|
out vec4 finalColor;
|
|
3455
3455
|
|
|
@@ -3512,7 +3512,7 @@ fn mainFragment(
|
|
|
3512
3512
|
color = vec4<f32>(mix(color.rgb, shadow.rgb, clamp((color.a - shadowSample) * shadow.a, 0.0, 1.0)), color.a);
|
|
3513
3513
|
|
|
3514
3514
|
return vec4<f32>(color.rgb * color.a, color.a);
|
|
3515
|
-
}`;var
|
|
3515
|
+
}`;var kh=Object.defineProperty,Ph=(r,e,t)=>e in r?kh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Hr=(r,e,t)=>(Ph(r,typeof e!="symbol"?e+"":e,t),t),sf=class af extends _{constructor(e){e={...af.DEFAULT_OPTIONS,...e};let t=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:of,entryPoint:"mainFragment"}}),n=I.from({vertex:z,fragment:nf,name:"bevel-filter"});super({gpuProgram:t,glProgram:n,resources:{bevelUniforms:{uLightColor:{value:new Float32Array(3),type:"vec3<f32>"},uLightAlpha:{value:e.lightAlpha,type:"f32"},uShadowColor:{value:new Float32Array(3),type:"vec3<f32>"},uShadowAlpha:{value:e.shadowAlpha,type:"f32"},uTransform:{value:new Float32Array(2),type:"vec2<f32>"}}},padding:1}),Hr(this,"uniforms"),Hr(this,"_thickness"),Hr(this,"_rotation"),Hr(this,"_lightColor"),Hr(this,"_shadowColor"),this.uniforms=this.resources.bevelUniforms.uniforms,this._lightColor=new Q,this._shadowColor=new Q,this.lightColor=e.lightColor??16777215,this.shadowColor=e.shadowColor??0,Object.assign(this,e)}get rotation(){return this._rotation/Je}set rotation(e){this._rotation=e*Je,this._updateTransform()}get thickness(){return this._thickness}set thickness(e){this._thickness=e,this._updateTransform()}get lightColor(){return this._lightColor.value}set lightColor(e){this._lightColor.setValue(e);let[t,n,o]=this._lightColor.toArray();this.uniforms.uLightColor[0]=t,this.uniforms.uLightColor[1]=n,this.uniforms.uLightColor[2]=o}get lightAlpha(){return this.uniforms.uLightAlpha}set lightAlpha(e){this.uniforms.uLightAlpha=e}get shadowColor(){return this._shadowColor.value}set shadowColor(e){this._shadowColor.setValue(e);let[t,n,o]=this._shadowColor.toArray();this.uniforms.uShadowColor[0]=t,this.uniforms.uShadowColor[1]=n,this.uniforms.uShadowColor[2]=o}get shadowAlpha(){return this.uniforms.uShadowAlpha}set shadowAlpha(e){this.uniforms.uShadowAlpha=e}_updateTransform(){this.uniforms.uTransform[0]=this.thickness*Math.cos(this._rotation),this.uniforms.uTransform[1]=this.thickness*Math.sin(this._rotation)}};Hr(sf,"DEFAULT_OPTIONS",{rotation:45,thickness:2,lightColor:16777215,lightAlpha:.7,shadowColor:0,shadowAlpha:.7});var lf=sf;var _h=Object.defineProperty,Ih=(r,e,t)=>e in r?_h(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ii=(r,e,t)=>(Ih(r,typeof e!="symbol"?e+"":e,t),t),cf=class uf extends zn{constructor(...e){let t=e[0]??{};if(typeof t=="number"||Array.isArray(t)||"x"in t&&"y"in t){N("6.0.0","BloomFilter constructor params are now options object. See params: { strength, quality, resolution, kernelSize }");let n=t;Array.isArray(n)&&(n={x:n[0],y:n[1]}),t={strength:n},e[1]!==void 0&&(t.quality=e[1]),e[2]!==void 0&&(t.resolution=e[2]),e[3]!==void 0&&(t.kernelSize=e[3])}t={...uf.DEFAULT_OPTIONS,...t},super(),Ii(this,"_blurXFilter"),Ii(this,"_blurYFilter"),Ii(this,"_strength"),this._strength={x:2,y:2},t.strength&&(typeof t.strength=="number"?(this._strength.x=t.strength,this._strength.y=t.strength):(this._strength.x=t.strength.x,this._strength.y=t.strength.y)),this._blurXFilter=new Pt({...t,horizontal:!0,strength:this.strengthX}),this._blurYFilter=new Pt({...t,horizontal:!1,strength:this.strengthY}),this._blurYFilter.blendMode="screen",Object.assign(this,t)}apply(e,t,n,o){let i=J.getSameSizeTexture(t);e.applyFilter(this,t,n,o),this._blurXFilter.apply(e,t,i,!0),this._blurYFilter.apply(e,i,n,!1),J.returnTexture(i)}get strength(){return this._strength}set strength(e){this._strength=typeof e=="number"?{x:e,y:e}:e,this._updateStrength()}get strengthX(){return this.strength.x}set strengthX(e){this.strength.x=e,this._updateStrength()}get strengthY(){return this.strength.y}set strengthY(e){this.strength.y=e,this._updateStrength()}_updateStrength(){this._blurXFilter.blur=this.strengthX,this._blurYFilter.blur=this.strengthY}get blur(){return N("6.0.0","BloomFilter.blur is deprecated, please use BloomFilter.strength instead"),this.strengthX}set blur(e){N("6.0.0","BloomFilter.blur is deprecated, please use BloomFilter.strength instead"),this.strength=e}get blurX(){return N("6.0.0","BloomFilter.blurX is deprecated, please use BloomFilter.strengthX instead"),this.strengthX}set blurX(e){N("6.0.0","BloomFilter.blurX is deprecated, please use BloomFilter.strengthX instead"),this.strengthX=e}get blurY(){return N("6.0.0","BloomFilter.blurY is deprecated, please use BloomFilter.strengthY instead"),this.strengthY}set blurY(e){N("6.0.0","BloomFilter.blurY is deprecated, please use BloomFilter.strengthY instead"),this.strengthY=e}};Ii(cf,"DEFAULT_OPTIONS",{strength:{x:2,y:2},quality:4,resolution:1,kernelSize:5});var ff=cf;var mf=`precision highp float;
|
|
3516
3516
|
in vec2 vTextureCoord;
|
|
3517
3517
|
out vec4 finalColor;
|
|
3518
3518
|
|
|
@@ -3614,7 +3614,7 @@ fn compareVec2(x: vec2<f32>, y: vec2<f32>) -> bool
|
|
|
3614
3614
|
}
|
|
3615
3615
|
|
|
3616
3616
|
return false;
|
|
3617
|
-
}`;var
|
|
3617
|
+
}`;var Ah=Object.defineProperty,Fh=(r,e,t)=>e in r?Ah(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,df=(r,e,t)=>(Fh(r,typeof e!="symbol"?e+"":e,t),t),hf=class gf extends _{constructor(e){e={...gf.DEFAULT_OPTIONS,...e};let t=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:pf,entryPoint:"mainFragment"}}),n=I.from({vertex:z,fragment:mf,name:"bulge-pinch-filter"});super({gpuProgram:t,glProgram:n,resources:{bulgePinchUniforms:{uDimensions:{value:[0,0],type:"vec2<f32>"},uCenter:{value:{x:0,y:0},type:"vec2<f32>"},uRadius:{value:e.radius,type:"f32"},uStrength:{value:e.strength,type:"f32"}}}}),df(this,"uniforms"),this.uniforms=this.resources.bulgePinchUniforms.uniforms,Object.assign(this,e)}apply(e,t,n,o){this.uniforms.uDimensions[0]=t.frame.width,this.uniforms.uDimensions[1]=t.frame.height,e.applyFilter(this,t,n,o)}get center(){return this.uniforms.uCenter}set center(e){typeof e=="number"&&(e={x:e,y:e}),Array.isArray(e)&&(e={x:e[0],y:e[1]}),this.uniforms.uCenter=e}get centerX(){return this.uniforms.uCenter.x}set centerX(e){this.uniforms.uCenter.x=e}get centerY(){return this.uniforms.uCenter.y}set centerY(e){this.uniforms.uCenter.y=e}get radius(){return this.uniforms.uRadius}set radius(e){this.uniforms.uRadius=e}get strength(){return this.uniforms.uStrength}set strength(e){this.uniforms.uStrength=e}};df(hf,"DEFAULT_OPTIONS",{center:{x:.5,y:.5},radius:100,strength:1});var xf=hf;var vf=`precision highp float;
|
|
3618
3618
|
in vec2 vTextureCoord;
|
|
3619
3619
|
in vec2 vFilterCoord;
|
|
3620
3620
|
out vec4 finalColor;
|
|
@@ -3984,7 +3984,7 @@ const PI_2: f32 = PI * 2.0;
|
|
|
3984
3984
|
const TYPE_LINEAR: i32 = 0;
|
|
3985
3985
|
const TYPE_RADIAL: i32 = 1;
|
|
3986
3986
|
const TYPE_CONIC: i32 = 2;
|
|
3987
|
-
const MAX_STOPS: i32 = 32;`;var ir=ir||{};ir.stringify=(function(){var r={"visit_linear-gradient":function(e){return r.visit_gradient(e)},"visit_repeating-linear-gradient":function(e){return r.visit_gradient(e)},"visit_radial-gradient":function(e){return r.visit_gradient(e)},"visit_repeating-radial-gradient":function(e){return r.visit_gradient(e)},visit_gradient:function(e){var t=r.visit(e.orientation);return t&&(t+=", "),e.type+"("+t+r.visit(e.colorStops)+")"},visit_shape:function(e){var t=e.value,n=r.visit(e.at),o=r.visit(e.style);return o&&(t+=" "+o),n&&(t+=" at "+n),t},"visit_default-radial":function(e){var t="",n=r.visit(e.at);return n&&(t+=n),t},"visit_extent-keyword":function(e){var t=e.value,n=r.visit(e.at);return n&&(t+=" at "+n),t},"visit_position-keyword":function(e){return e.value},visit_position:function(e){return r.visit(e.value.x)+" "+r.visit(e.value.y)},"visit_%":function(e){return e.value+"%"},visit_em:function(e){return e.value+"em"},visit_px:function(e){return e.value+"px"},visit_literal:function(e){return r.visit_color(e.value,e)},visit_hex:function(e){return r.visit_color("#"+e.value,e)},visit_rgb:function(e){return r.visit_color("rgb("+e.value.join(", ")+")",e)},visit_rgba:function(e){return r.visit_color("rgba("+e.value.join(", ")+")",e)},visit_color:function(e,t){var n=e,o=r.visit(t.length);return o&&(n+=" "+o),n},visit_angular:function(e){return e.value+"deg"},visit_directional:function(e){return"to "+e.value},visit_array:function(e){var t="",n=e.length;return e.forEach(function(o,i){t+=r.visit(o),i<n-1&&(t+=", ")}),t},visit:function(e){if(!e)return"";var t="";if(e instanceof Array)return r.visit_array(e,t);if(e.type){var n=r["visit_"+e.type];if(n)return n(e);throw Error("Missing visitor visit_"+e.type)}else throw Error("Invalid node.")}};return function(e){return r.visit(e)}})();var ir=ir||{};ir.parse=(function(){var r={linearGradient:/^(\-(webkit|o|ms|moz)\-)?(linear\-gradient)/i,repeatingLinearGradient:/^(\-(webkit|o|ms|moz)\-)?(repeating\-linear\-gradient)/i,radialGradient:/^(\-(webkit|o|ms|moz)\-)?(radial\-gradient)/i,repeatingRadialGradient:/^(\-(webkit|o|ms|moz)\-)?(repeating\-radial\-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|left|right|top|bottom)/i,extentKeywords:/^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,percentageValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,emValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,angleValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^\#([0-9a-fA-F]+)/,literalColor:/^([a-zA-Z]+)/,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,number:/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/},e="";function t(L){var Y=new Error(e+": "+L);throw Y.source=e,Y}function n(){var L=o();return e.length>0&&t("Invalid input not EOF"),L}function o(){return T(i)}function i(){return s("linear-gradient",r.linearGradient,l)||s("repeating-linear-gradient",r.repeatingLinearGradient,l)||s("radial-gradient",r.radialGradient,u)||s("repeating-radial-gradient",r.repeatingRadialGradient,u)}function s(L,Y,se){return a(Y,function(ht){var Na=se();return Na&&(dt(r.comma)||t("Missing comma before color stops")),{type:L,orientation:Na,colorStops:T(S)}})}function a(L,Y){var se=dt(L);if(se){dt(r.startCall)||t("Missing (");var ht=Y(se);return dt(r.endCall)||t("Missing )"),ht}}function l(){return c()||f()}function c(){return we("directional",r.sideOrCorner,1)}function f(){return we("angular",r.angleValue,1)}function u(){var L,Y=m(),se;return Y&&(L=[],L.push(Y),se=e,dt(r.comma)&&(Y=m(),Y?L.push(Y):e=se)),L}function m(){var L=p()||d();if(L)L.at=x();else{var Y=g();if(Y){L=Y;var se=x();se&&(L.at=se)}else{var ht=y();ht&&(L={type:"default-radial",at:ht})}}return L}function p(){var L=we("shape",/^(circle)/i,0);return L&&(L.style=Ue()||g()),L}function d(){var L=we("shape",/^(ellipse)/i,0);return L&&(L.style=G()||g()),L}function g(){return we("extent-keyword",r.extentKeywords,1)}function x(){if(we("position",/^at/,0)){var L=y();return L||t("Missing positioning value"),L}}function y(){var L=v();if(L.x||L.y)return{type:"position",value:L}}function v(){return{x:G(),y:G()}}function T(L){var Y=L(),se=[];if(Y)for(se.push(Y);dt(r.comma);)Y=L(),Y?se.push(Y):t("One extra comma");return se}function S(){var L=k();return L||t("Expected color definition"),L.length=G(),L}function k(){return O()||V()||E()||C()}function C(){return we("literal",r.literalColor,0)}function O(){return we("hex",r.hexColor,1)}function E(){return a(r.rgbColor,function(){return{type:"rgb",value:T(q)}})}function V(){return a(r.rgbaColor,function(){return{type:"rgba",value:T(q)}})}function q(){return dt(r.number)[1]}function G(){return we("%",r.percentageValue,1)||ie()||Ue()}function ie(){return we("position-keyword",r.positionKeywords,1)}function Ue(){return we("px",r.pixelValue,1)||we("em",r.emValue,1)}function we(L,Y,se){var ht=dt(Y);if(ht)return{type:L,value:ht[se]}}function dt(L){var Y,se;return se=/^[\n\r\t\s]+/.exec(e),se&&Ua(se[0].length),Y=L.exec(e),Y&&Ua(Y[0].length),Y}function Ua(L){e=e.substr(L)}return function(L){return e=L.toString(),n()}})();var bf=ir.parse;ir.stringify;function Ai(r){let e=bf(_a(r));if(e.length===0)throw new Error("Invalid CSS gradient.");if(e.length!==1)throw new Error("Unsupported CSS gradient (multiple gradients is not supported).");let t=e[0],n=Sa(t.type),o=Ta(t.colorStops),i=ka(t.orientation);return{type:n,stops:o,angle:i}}function Sa(r){let e={"linear-gradient":0,"radial-gradient":1};if(!(r in e))throw new Error(`Unsupported gradient type "${r}"`);return e[r]}function Ta(r){let e=Ca(r),t=[],n=new Q;for(let o=0;o<r.length;o++){let i=wa(r[o]),s=n.setValue(i).toArray();t.push({offset:e[o],color:s.slice(0,3),alpha:s[3]})}return t}function wa(r){switch(r.type){case"hex":return`#${r.value}`;case"literal":return r.value;default:return`${r.type}(${r.value.join(",")})`}}function Ca(r){let e=[];for(let i=0;i<r.length;i++){let s=r[i],a=-1;s.type==="literal"&&s.length&&"type"in s.length&&s.length.type==="%"&&"value"in s.length&&(a=parseFloat(s.length.value)/100),e.push(a)}let n=i=>{for(let s=i;s<e.length;s++)if(e[s]!==-1)return{indexDelta:s-i,offset:e[s]};return{indexDelta:e.length-1-i,offset:1}},o=0;for(let i=0;i<e.length;i++){let s=e[i];if(s!==-1)o=s;else if(i===0)e[i]=0;else if(i+1===e.length)e[i]=1;else{let a=n(i),c=(a.offset-o)/(1+a.indexDelta);for(let f=0;f<=a.indexDelta;f++)e[i+f]=o+(f+1)*c;i+=a.indexDelta,o=e[i]}}return e.map(
|
|
3987
|
+
const MAX_STOPS: i32 = 32;`;var ir=ir||{};ir.stringify=(function(){var r={"visit_linear-gradient":function(e){return r.visit_gradient(e)},"visit_repeating-linear-gradient":function(e){return r.visit_gradient(e)},"visit_radial-gradient":function(e){return r.visit_gradient(e)},"visit_repeating-radial-gradient":function(e){return r.visit_gradient(e)},visit_gradient:function(e){var t=r.visit(e.orientation);return t&&(t+=", "),e.type+"("+t+r.visit(e.colorStops)+")"},visit_shape:function(e){var t=e.value,n=r.visit(e.at),o=r.visit(e.style);return o&&(t+=" "+o),n&&(t+=" at "+n),t},"visit_default-radial":function(e){var t="",n=r.visit(e.at);return n&&(t+=n),t},"visit_extent-keyword":function(e){var t=e.value,n=r.visit(e.at);return n&&(t+=" at "+n),t},"visit_position-keyword":function(e){return e.value},visit_position:function(e){return r.visit(e.value.x)+" "+r.visit(e.value.y)},"visit_%":function(e){return e.value+"%"},visit_em:function(e){return e.value+"em"},visit_px:function(e){return e.value+"px"},visit_literal:function(e){return r.visit_color(e.value,e)},visit_hex:function(e){return r.visit_color("#"+e.value,e)},visit_rgb:function(e){return r.visit_color("rgb("+e.value.join(", ")+")",e)},visit_rgba:function(e){return r.visit_color("rgba("+e.value.join(", ")+")",e)},visit_color:function(e,t){var n=e,o=r.visit(t.length);return o&&(n+=" "+o),n},visit_angular:function(e){return e.value+"deg"},visit_directional:function(e){return"to "+e.value},visit_array:function(e){var t="",n=e.length;return e.forEach(function(o,i){t+=r.visit(o),i<n-1&&(t+=", ")}),t},visit:function(e){if(!e)return"";var t="";if(e instanceof Array)return r.visit_array(e,t);if(e.type){var n=r["visit_"+e.type];if(n)return n(e);throw Error("Missing visitor visit_"+e.type)}else throw Error("Invalid node.")}};return function(e){return r.visit(e)}})();var ir=ir||{};ir.parse=(function(){var r={linearGradient:/^(\-(webkit|o|ms|moz)\-)?(linear\-gradient)/i,repeatingLinearGradient:/^(\-(webkit|o|ms|moz)\-)?(repeating\-linear\-gradient)/i,radialGradient:/^(\-(webkit|o|ms|moz)\-)?(radial\-gradient)/i,repeatingRadialGradient:/^(\-(webkit|o|ms|moz)\-)?(repeating\-radial\-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|left|right|top|bottom)/i,extentKeywords:/^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,percentageValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,emValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,angleValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^\#([0-9a-fA-F]+)/,literalColor:/^([a-zA-Z]+)/,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,number:/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/},e="";function t(L){var Y=new Error(e+": "+L);throw Y.source=e,Y}function n(){var L=o();return e.length>0&&t("Invalid input not EOF"),L}function o(){return T(i)}function i(){return s("linear-gradient",r.linearGradient,l)||s("repeating-linear-gradient",r.repeatingLinearGradient,l)||s("radial-gradient",r.radialGradient,u)||s("repeating-radial-gradient",r.repeatingRadialGradient,u)}function s(L,Y,se){return a(Y,function(ht){var Na=se();return Na&&(dt(r.comma)||t("Missing comma before color stops")),{type:L,orientation:Na,colorStops:T(S)}})}function a(L,Y){var se=dt(L);if(se){dt(r.startCall)||t("Missing (");var ht=Y(se);return dt(r.endCall)||t("Missing )"),ht}}function l(){return c()||f()}function c(){return we("directional",r.sideOrCorner,1)}function f(){return we("angular",r.angleValue,1)}function u(){var L,Y=m(),se;return Y&&(L=[],L.push(Y),se=e,dt(r.comma)&&(Y=m(),Y?L.push(Y):e=se)),L}function m(){var L=p()||d();if(L)L.at=x();else{var Y=g();if(Y){L=Y;var se=x();se&&(L.at=se)}else{var ht=y();ht&&(L={type:"default-radial",at:ht})}}return L}function p(){var L=we("shape",/^(circle)/i,0);return L&&(L.style=Ue()||g()),L}function d(){var L=we("shape",/^(ellipse)/i,0);return L&&(L.style=G()||g()),L}function g(){return we("extent-keyword",r.extentKeywords,1)}function x(){if(we("position",/^at/,0)){var L=y();return L||t("Missing positioning value"),L}}function y(){var L=v();if(L.x||L.y)return{type:"position",value:L}}function v(){return{x:G(),y:G()}}function T(L){var Y=L(),se=[];if(Y)for(se.push(Y);dt(r.comma);)Y=L(),Y?se.push(Y):t("One extra comma");return se}function S(){var L=k();return L||t("Expected color definition"),L.length=G(),L}function k(){return O()||V()||E()||C()}function C(){return we("literal",r.literalColor,0)}function O(){return we("hex",r.hexColor,1)}function E(){return a(r.rgbColor,function(){return{type:"rgb",value:T(q)}})}function V(){return a(r.rgbaColor,function(){return{type:"rgba",value:T(q)}})}function q(){return dt(r.number)[1]}function G(){return we("%",r.percentageValue,1)||ie()||Ue()}function ie(){return we("position-keyword",r.positionKeywords,1)}function Ue(){return we("px",r.pixelValue,1)||we("em",r.emValue,1)}function we(L,Y,se){var ht=dt(Y);if(ht)return{type:L,value:ht[se]}}function dt(L){var Y,se;return se=/^[\n\r\t\s]+/.exec(e),se&&Ua(se[0].length),Y=L.exec(e),Y&&Ua(Y[0].length),Y}function Ua(L){e=e.substr(L)}return function(L){return e=L.toString(),n()}})();var bf=ir.parse;ir.stringify;function Ai(r){let e=bf(_a(r));if(e.length===0)throw new Error("Invalid CSS gradient.");if(e.length!==1)throw new Error("Unsupported CSS gradient (multiple gradients is not supported).");let t=e[0],n=Sa(t.type),o=Ta(t.colorStops),i=ka(t.orientation);return{type:n,stops:o,angle:i}}function Sa(r){let e={"linear-gradient":0,"radial-gradient":1};if(!(r in e))throw new Error(`Unsupported gradient type "${r}"`);return e[r]}function Ta(r){let e=Ca(r),t=[],n=new Q;for(let o=0;o<r.length;o++){let i=wa(r[o]),s=n.setValue(i).toArray();t.push({offset:e[o],color:s.slice(0,3),alpha:s[3]})}return t}function wa(r){switch(r.type){case"hex":return`#${r.value}`;case"literal":return r.value;default:return`${r.type}(${r.value.join(",")})`}}function Ca(r){let e=[];for(let i=0;i<r.length;i++){let s=r[i],a=-1;s.type==="literal"&&s.length&&"type"in s.length&&s.length.type==="%"&&"value"in s.length&&(a=parseFloat(s.length.value)/100),e.push(a)}let n=i=>{for(let s=i;s<e.length;s++)if(e[s]!==-1)return{indexDelta:s-i,offset:e[s]};return{indexDelta:e.length-1-i,offset:1}},o=0;for(let i=0;i<e.length;i++){let s=e[i];if(s!==-1)o=s;else if(i===0)e[i]=0;else if(i+1===e.length)e[i]=1;else{let a=n(i),c=(a.offset-o)/(1+a.indexDelta);for(let f=0;f<=a.indexDelta;f++)e[i+f]=o+(f+1)*c;i+=a.indexDelta,o=e[i]}}return e.map(Eh)}function Eh(r){return r.toString().length>6?parseFloat(r.toString().substring(0,6)):r}function ka(r){if(typeof r>"u")return 0;if("type"in r&&"value"in r)switch(r.type){case"angular":return parseFloat(r.value);case"directional":return Pa(r.value)}return 0}function Pa(r){let e={left:270,top:0,bottom:180,right:90,"left top":315,"top left":315,"left bottom":225,"bottom left":225,"right top":45,"top right":45,"right bottom":135,"bottom right":135};if(!(r in e))throw new Error(`Unsupported directional value "${r}"`);return e[r]}function _a(r){let e=r.replace(/\s{2,}/gu," ");return e=e.replace(/;/g,""),e=e.replace(/ ,/g,","),e=e.replace(/\( /g,"("),e=e.replace(/ \)/g,")"),e.trim()}var zh=Object.defineProperty,Dh=(r,e,t)=>e in r?zh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,sr=(r,e,t)=>(Dh(r,typeof e!="symbol"?e+"":e,t),t),Ia=90;function Oh(r){return[...r].sort((e,t)=>e.offset-t.offset)}var Wr=class Fi extends _{constructor(e){if(e&&"css"in e?e={...Ai(e.css||""),alpha:e.alpha??Fi.defaults.alpha,maxColors:e.maxColors??Fi.defaults.maxColors}:e={...Fi.defaults,...e},!e.stops||e.stops.length<2)throw new Error("ColorGradientFilter requires at least 2 color stops.");let t=A.from({vertex:{source:ba,entryPoint:"mainVertex"},fragment:{source:ba,entryPoint:"mainFragment"}}),n=I.from({vertex:yf,fragment:vf,name:"color-gradient-filter"}),o=32;super({gpuProgram:t,glProgram:n,resources:{baseUniforms:{uOptions:{value:[e.type,e.angle??Ia,e.alpha,e.replace?1:0],type:"vec4<f32>"},uCounts:{value:[e.stops.length,e.maxColors],type:"vec2<f32>"}},stopsUniforms:{uColors:{value:new Float32Array(o*3),type:"vec3<f32>",size:o},uStops:{value:new Float32Array(o*4),type:"vec4<f32>",size:o}}}}),sr(this,"baseUniforms"),sr(this,"stopsUniforms"),sr(this,"_stops",[]),this.baseUniforms=this.resources.baseUniforms.uniforms,this.stopsUniforms=this.resources.stopsUniforms.uniforms,Object.assign(this,e)}get stops(){return this._stops}set stops(e){let t=Oh(e),n=new Q,o,i,s;for(let a=0;a<t.length;a++){n.setValue(t[a].color);let l=a*3;[o,i,s]=n.toArray(),this.stopsUniforms.uColors[l]=o,this.stopsUniforms.uColors[l+1]=i,this.stopsUniforms.uColors[l+2]=s,this.stopsUniforms.uStops[a*4]=t[a].offset,this.stopsUniforms.uStops[a*4+1]=t[a].alpha}this.baseUniforms.uCounts[0]=t.length,this._stops=t}get type(){return this.baseUniforms.uOptions[0]}set type(e){this.baseUniforms.uOptions[0]=e}get angle(){return this.baseUniforms.uOptions[1]+Ia}set angle(e){this.baseUniforms.uOptions[1]=e-Ia}get alpha(){return this.baseUniforms.uOptions[2]}set alpha(e){this.baseUniforms.uOptions[2]=e}get maxColors(){return this.baseUniforms.uCounts[1]}set maxColors(e){this.baseUniforms.uCounts[1]=e}get replace(){return this.baseUniforms.uOptions[3]>.5}set replace(e){this.baseUniforms.uOptions[3]=e?1:0}};sr(Wr,"LINEAR",0);sr(Wr,"RADIAL",1);sr(Wr,"CONIC",2);sr(Wr,"defaults",{type:Wr.LINEAR,stops:[{offset:0,color:16711680,alpha:1},{offset:1,color:255,alpha:1}],alpha:1,angle:90,maxColors:0,replace:!1});var Sf=Wr;var Tf=`in vec2 vTextureCoord;
|
|
3988
3988
|
out vec4 finalColor;
|
|
3989
3989
|
|
|
3990
3990
|
uniform sampler2D uTexture;
|
|
@@ -4058,7 +4058,7 @@ fn mainFragment(
|
|
|
4058
4058
|
let realColor: vec4<f32> = select(color, altColor, color.a > 0.0);
|
|
4059
4059
|
|
|
4060
4060
|
return vec4<f32>(mix(realColor, adjusted, colorMapUniforms.uMix).rgb, realColor.a);
|
|
4061
|
-
}`;var
|
|
4061
|
+
}`;var Rh=Object.defineProperty,Mh=(r,e,t)=>e in r?Rh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,pt=(r,e,t)=>(Mh(r,typeof e!="symbol"?e+"":e,t),t),Cf=class kf extends _{constructor(...e){let t=e[0]??{};if((t instanceof ae||t instanceof Xi)&&(N("6.0.0","ColorMapFilter constructor params are now options object. See params: { colorMap, nearest, mix }"),t={colorMap:t},e[1]!==void 0&&(t.nearest=e[1]),e[2]!==void 0&&(t.mix=e[2])),t={...kf.DEFAULT_OPTIONS,...t},!t.colorMap)throw Error("No color map texture source was provided to ColorMapFilter");let n=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:wf,entryPoint:"mainFragment"}}),o=I.from({vertex:z,fragment:Tf,name:"color-map-filter"});super({gpuProgram:n,glProgram:o,resources:{colorMapUniforms:{uMix:{value:t.mix,type:"f32"},uSize:{value:0,type:"f32"},uSliceSize:{value:0,type:"f32"},uSlicePixelSize:{value:0,type:"f32"},uSliceInnerSize:{value:0,type:"f32"}},uMapTexture:t.colorMap.source,uMapSampler:t.colorMap.source.style}}),pt(this,"uniforms"),pt(this,"_size",0),pt(this,"_sliceSize",0),pt(this,"_slicePixelSize",0),pt(this,"_sliceInnerSize",0),pt(this,"_nearest",!1),pt(this,"_scaleMode","linear"),pt(this,"_colorMap"),this.uniforms=this.resources.colorMapUniforms.uniforms,Object.assign(this,t)}get mix(){return this.uniforms.uMix}set mix(e){this.uniforms.uMix=e}get colorSize(){return this._size}get colorMap(){return this._colorMap}set colorMap(e){if(!e||e===this.colorMap)return;let t=e instanceof ae?e.source:e;t.style.scaleMode=this._scaleMode,t.autoGenerateMipmaps=!1,this._size=t.height,this._sliceSize=1/this._size,this._slicePixelSize=this._sliceSize/this._size,this._sliceInnerSize=this._slicePixelSize*(this._size-1),this.uniforms.uSize=this._size,this.uniforms.uSliceSize=this._sliceSize,this.uniforms.uSlicePixelSize=this._slicePixelSize,this.uniforms.uSliceInnerSize=this._sliceInnerSize,this.resources.uMapTexture=t,this._colorMap=e}get nearest(){return this._nearest}set nearest(e){this._nearest=e,this._scaleMode=e?"nearest":"linear";let t=this._colorMap;t&&t.source&&(t.source.scaleMode=this._scaleMode,t.source.autoGenerateMipmaps=!1,t.source.style.update(),t.source.update())}updateColorMap(){let e=this._colorMap;e?.source&&(e.source.update(),this.colorMap=e)}destroy(){this._colorMap?.destroy(),super.destroy()}};pt(Cf,"DEFAULT_OPTIONS",{colorMap:ae.WHITE,nearest:!1,mix:1});var Pf=Cf;var _f=`in vec2 vTextureCoord;
|
|
4062
4062
|
out vec4 finalColor;
|
|
4063
4063
|
|
|
4064
4064
|
uniform sampler2D uTexture;
|
|
@@ -4085,7 +4085,7 @@ fn mainFragment(
|
|
|
4085
4085
|
let c = textureSample(uTexture, uSampler, uv);
|
|
4086
4086
|
return vec4<f32>(mix(c.rgb, colorOverlayUniforms.uColor.rgb * c.a, colorOverlayUniforms.uAlpha), c.a);
|
|
4087
4087
|
}
|
|
4088
|
-
`;var
|
|
4088
|
+
`;var Bh=Object.defineProperty,Uh=(r,e,t)=>e in r?Bh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Aa=(r,e,t)=>(Uh(r,typeof e!="symbol"?e+"":e,t),t),Af=class Ff extends _{constructor(...e){let t=e[0]??{};(typeof t=="number"||Array.isArray(t)||t instanceof Float32Array)&&(N("6.0.0","ColorOverlayFilter constructor params are now options object. See params: { color, alpha }"),t={color:t},e[1]!==void 0&&(t.alpha=e[1])),t={...Ff.DEFAULT_OPTIONS,...t};let n=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:If,entryPoint:"mainFragment"}}),o=I.from({vertex:z,fragment:_f,name:"color-overlay-filter"});super({gpuProgram:n,glProgram:o,resources:{colorOverlayUniforms:{uColor:{value:new Float32Array(3),type:"vec3<f32>"},uAlpha:{value:t.alpha,type:"f32"}}}}),Aa(this,"uniforms"),Aa(this,"_color"),this.uniforms=this.resources.colorOverlayUniforms.uniforms,this._color=new Q,this.color=t.color??0}get color(){return this._color.value}set color(e){this._color.setValue(e);let[t,n,o]=this._color.toArray();this.uniforms.uColor[0]=t,this.uniforms.uColor[1]=n,this.uniforms.uColor[2]=o}get alpha(){return this.uniforms.uAlpha}set alpha(e){this.uniforms.uAlpha=e}};Aa(Af,"DEFAULT_OPTIONS",{color:0,alpha:1});var Ef=Af;var zf=`in vec2 vTextureCoord;
|
|
4089
4089
|
out vec4 finalColor;
|
|
4090
4090
|
|
|
4091
4091
|
uniform sampler2D uTexture;
|
|
@@ -4122,7 +4122,7 @@ fn mainFragment(
|
|
|
4122
4122
|
let doReplace: f32 = step(colorDistance, colorReplaceUniforms.uTolerance);
|
|
4123
4123
|
|
|
4124
4124
|
return vec4<f32>(mix(sample.rgb, (colorReplaceUniforms.uTargetColor + colorDiff) * sample.a, doReplace), sample.a);
|
|
4125
|
-
}`;var
|
|
4125
|
+
}`;var Nh=Object.defineProperty,Lh=(r,e,t)=>e in r?Nh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ei=(r,e,t)=>(Lh(r,typeof e!="symbol"?e+"":e,t),t),Of=class Rf extends _{constructor(...e){let t=e[0]??{};(typeof t=="number"||Array.isArray(t)||t instanceof Float32Array)&&(N("6.0.0","ColorReplaceFilter constructor params are now options object. See params: { originalColor, targetColor, tolerance }"),t={originalColor:t},e[1]!==void 0&&(t.targetColor=e[1]),e[2]!==void 0&&(t.tolerance=e[2])),t={...Rf.DEFAULT_OPTIONS,...t};let n=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:Df,entryPoint:"mainFragment"}}),o=I.from({vertex:z,fragment:zf,name:"color-replace-filter"});super({gpuProgram:n,glProgram:o,resources:{colorReplaceUniforms:{uOriginalColor:{value:new Float32Array(3),type:"vec3<f32>"},uTargetColor:{value:new Float32Array(3),type:"vec3<f32>"},uTolerance:{value:t.tolerance,type:"f32"}}}}),Ei(this,"uniforms"),Ei(this,"_originalColor"),Ei(this,"_targetColor"),this.uniforms=this.resources.colorReplaceUniforms.uniforms,this._originalColor=new Q,this._targetColor=new Q,this.originalColor=t.originalColor??16711680,this.targetColor=t.targetColor??0,Object.assign(this,t)}get originalColor(){return this._originalColor.value}set originalColor(e){this._originalColor.setValue(e);let[t,n,o]=this._originalColor.toArray();this.uniforms.uOriginalColor[0]=t,this.uniforms.uOriginalColor[1]=n,this.uniforms.uOriginalColor[2]=o}get targetColor(){return this._targetColor.value}set targetColor(e){this._targetColor.setValue(e);let[t,n,o]=this._targetColor.toArray();this.uniforms.uTargetColor[0]=t,this.uniforms.uTargetColor[1]=n,this.uniforms.uTargetColor[2]=o}get tolerance(){return this.uniforms.uTolerance}set tolerance(e){this.uniforms.uTolerance=e}set newColor(e){N("6.0.0","ColorReplaceFilter.newColor is deprecated, please use ColorReplaceFilter.targetColor instead"),this.targetColor=e}get newColor(){return N("6.0.0","ColorReplaceFilter.newColor is deprecated, please use ColorReplaceFilter.targetColor instead"),this.targetColor}set epsilon(e){N("6.0.0","ColorReplaceFilter.epsilon is deprecated, please use ColorReplaceFilter.tolerance instead"),this.tolerance=e}get epsilon(){return N("6.0.0","ColorReplaceFilter.epsilon is deprecated, please use ColorReplaceFilter.tolerance instead"),this.tolerance}};Ei(Of,"DEFAULT_OPTIONS",{originalColor:16711680,targetColor:0,tolerance:.4});var Mf=Of;var Bf=`in vec2 vTextureCoord;
|
|
4126
4126
|
out vec4 finalColor;
|
|
4127
4127
|
|
|
4128
4128
|
uniform sampler2D uTexture;
|
|
@@ -4187,7 +4187,7 @@ fn mainFragment(
|
|
|
4187
4187
|
finalColor.a = c22.a;
|
|
4188
4188
|
|
|
4189
4189
|
return finalColor;
|
|
4190
|
-
}`;var
|
|
4190
|
+
}`;var Vh=Object.defineProperty,Gh=(r,e,t)=>e in r?Vh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Nf=(r,e,t)=>(Gh(r,typeof e!="symbol"?e+"":e,t),t),Lf=class Vf extends _{constructor(...e){let t=e[0]??{};Array.isArray(t)&&(N("6.0.0","ConvolutionFilter constructor params are now options object. See params: { matrix, width, height }"),t={matrix:t},e[1]!==void 0&&(t.width=e[1]),e[2]!==void 0&&(t.height=e[2])),t={...Vf.DEFAULT_OPTIONS,...t};let n=t.width??200,o=t.height??200,i=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:Uf,entryPoint:"mainFragment"}}),s=I.from({vertex:z,fragment:Bf,name:"convolution-filter"});super({gpuProgram:i,glProgram:s,resources:{convolutionUniforms:{uMatrix:{value:t.matrix,type:"mat3x3<f32>"},uTexelSize:{value:{x:1/n,y:1/o},type:"vec2<f32>"}}}}),Nf(this,"uniforms"),this.uniforms=this.resources.convolutionUniforms.uniforms,this.width=n,this.height=o}get matrix(){return this.uniforms.uMatrix}set matrix(e){e.forEach((t,n)=>{this.uniforms.uMatrix[n]=t})}get width(){return 1/this.uniforms.uTexelSize.x}set width(e){this.uniforms.uTexelSize.x=1/e}get height(){return 1/this.uniforms.uTexelSize.y}set height(e){this.uniforms.uTexelSize.y=1/e}};Nf(Lf,"DEFAULT_OPTIONS",{matrix:new Float32Array(9),width:200,height:200});var Gf=Lf;var qf=`in vec2 vTextureCoord;
|
|
4191
4191
|
out vec4 finalColor;
|
|
4192
4192
|
|
|
4193
4193
|
uniform sampler2D uTexture;
|
|
@@ -4474,7 +4474,7 @@ fn interlaceLines(co: vec3<f32>, coord: vec2<f32>) -> vec3<f32>
|
|
|
4474
4474
|
color *= 0.99 + ceil(segment) * 0.015;
|
|
4475
4475
|
|
|
4476
4476
|
return color;
|
|
4477
|
-
}`;var
|
|
4477
|
+
}`;var qh=Object.defineProperty,Hh=(r,e,t)=>e in r?qh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Di=(r,e,t)=>(Hh(r,typeof e!="symbol"?e+"":e,t),t),Xf=class $f extends _{constructor(e){e={...$f.DEFAULT_OPTIONS,...e};let t=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:jf,entryPoint:"mainFragment"}}),n=I.from({vertex:z,fragment:Wf,name:"crt-filter"});super({gpuProgram:t,glProgram:n,resources:{crtUniforms:{uLine:{value:new Float32Array(4),type:"vec4<f32>"},uNoise:{value:new Float32Array(2),type:"vec2<f32>"},uVignette:{value:new Float32Array(3),type:"vec3<f32>"},uSeed:{value:e.seed,type:"f32"},uTime:{value:e.time,type:"f32"},uDimensions:{value:new Float32Array(2),type:"vec2<f32>"}}}}),Di(this,"uniforms"),Di(this,"seed"),Di(this,"time"),this.uniforms=this.resources.crtUniforms.uniforms,Object.assign(this,e)}apply(e,t,n,o){this.uniforms.uDimensions[0]=t.frame.width,this.uniforms.uDimensions[1]=t.frame.height,this.uniforms.uSeed=this.seed,this.uniforms.uTime=this.time,e.applyFilter(this,t,n,o)}get curvature(){return this.uniforms.uLine[0]}set curvature(e){this.uniforms.uLine[0]=e}get lineWidth(){return this.uniforms.uLine[1]}set lineWidth(e){this.uniforms.uLine[1]=e}get lineContrast(){return this.uniforms.uLine[2]}set lineContrast(e){this.uniforms.uLine[2]=e}get verticalLine(){return this.uniforms.uLine[3]>.5}set verticalLine(e){this.uniforms.uLine[3]=e?1:0}get noise(){return this.uniforms.uNoise[0]}set noise(e){this.uniforms.uNoise[0]=e}get noiseSize(){return this.uniforms.uNoise[1]}set noiseSize(e){this.uniforms.uNoise[1]=e}get vignetting(){return this.uniforms.uVignette[0]}set vignetting(e){this.uniforms.uVignette[0]=e}get vignettingAlpha(){return this.uniforms.uVignette[1]}set vignettingAlpha(e){this.uniforms.uVignette[1]=e}get vignettingBlur(){return this.uniforms.uVignette[2]}set vignettingBlur(e){this.uniforms.uVignette[2]=e}};Di(Xf,"DEFAULT_OPTIONS",{curvature:1,lineWidth:1,lineContrast:.25,verticalLine:!1,noise:0,noiseSize:1,vignetting:.3,vignettingAlpha:1,vignettingBlur:.3,time:0,seed:0});var Kf=Xf;var Yf=`precision highp float;
|
|
4478
4478
|
in vec2 vTextureCoord;
|
|
4479
4479
|
out vec4 finalColor;
|
|
4480
4480
|
|
|
@@ -4555,7 +4555,7 @@ fn pattern(uv: vec2<f32>) -> f32
|
|
|
4555
4555
|
) * dotUniforms.uScale;
|
|
4556
4556
|
|
|
4557
4557
|
return (sin(p.x) * sin(p.y)) * 4.0;
|
|
4558
|
-
}`;var
|
|
4558
|
+
}`;var Wh=Object.defineProperty,jh=(r,e,t)=>e in r?Wh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Xh=(r,e,t)=>(jh(r,typeof e!="symbol"?e+"":e,t),t),Zf=class Jf extends _{constructor(...e){let t=e[0]??{};typeof t=="number"&&(N("6.0.0","DotFilter constructor params are now options object. See params: { scale, angle, grayscale }"),t={scale:t},e[1]!==void 0&&(t.angle=e[1]),e[2]!==void 0&&(t.grayscale=e[2])),t={...Jf.DEFAULT_OPTIONS,...t};let n={uScale:{value:t.scale,type:"f32"},uAngle:{value:t.angle,type:"f32"},uGrayScale:{value:t.grayscale?1:0,type:"f32"}},o=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:Qf,entryPoint:"mainFragment"}}),i=I.from({vertex:z,fragment:Yf,name:"dot-filter"});super({gpuProgram:o,glProgram:i,resources:{dotUniforms:n}})}get scale(){return this.resources.dotUniforms.uniforms.uScale}set scale(e){this.resources.dotUniforms.uniforms.uScale=e}get angle(){return this.resources.dotUniforms.uniforms.uAngle}set angle(e){this.resources.dotUniforms.uniforms.uAngle=e}get grayscale(){return this.resources.dotUniforms.uniforms.uGrayScale===1}set grayscale(e){this.resources.dotUniforms.uniforms.uGrayScale=e?1:0}};Xh(Zf,"DEFAULT_OPTIONS",{scale:1,angle:5,grayscale:!0});var em=Zf;var tm=`precision highp float;
|
|
4559
4559
|
in vec2 vTextureCoord;
|
|
4560
4560
|
out vec4 finalColor;
|
|
4561
4561
|
|
|
@@ -4610,7 +4610,7 @@ fn mainFragment(
|
|
|
4610
4610
|
color *= dropShadowUniforms.uAlpha;
|
|
4611
4611
|
|
|
4612
4612
|
return color;
|
|
4613
|
-
}`;var
|
|
4613
|
+
}`;var $h=Object.defineProperty,Kh=(r,e,t)=>e in r?$h(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,jr=(r,e,t)=>(Kh(r,typeof e!="symbol"?e+"":e,t),t),nm=class om extends _{constructor(e){e={...om.DEFAULT_OPTIONS,...e};let t=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:rm,entryPoint:"mainFragment"}}),n=I.from({vertex:z,fragment:tm,name:"drop-shadow-filter"});super({gpuProgram:t,glProgram:n,resources:{dropShadowUniforms:{uAlpha:{value:e.alpha,type:"f32"},uColor:{value:new Float32Array(3),type:"vec3<f32>"},uOffset:{value:e.offset,type:"vec2<f32>"}}},resolution:e.resolution}),jr(this,"uniforms"),jr(this,"shadowOnly",!1),jr(this,"_color"),jr(this,"_blurFilter"),jr(this,"_basePass"),this.uniforms=this.resources.dropShadowUniforms.uniforms,this._color=new Q,this.color=e.color??0,this._blurFilter=new Gr({strength:e.kernels??e.blur,quality:e.kernels?void 0:e.quality}),this._basePass=new _({gpuProgram:A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:`
|
|
4614
4614
|
@group(0) @binding(1) var uTexture: texture_2d<f32>;
|
|
4615
4615
|
@group(0) @binding(2) var uSampler: sampler;
|
|
4616
4616
|
@fragment
|
|
@@ -4689,7 +4689,7 @@ fn mainFragment(
|
|
|
4689
4689
|
let blendColor: vec4<f32> = textureSample(uTexture, uSampler, uv);
|
|
4690
4690
|
|
|
4691
4691
|
return vec4<f32>(color.rgb * blendColor.a, blendColor.a);
|
|
4692
|
-
}`;var
|
|
4692
|
+
}`;var Yh=Object.defineProperty,Qh=(r,e,t)=>e in r?Yh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Zh=(r,e,t)=>(Qh(r,typeof e!="symbol"?e+"":e,t),t),Xr=class extends _{constructor(e=5){let t=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:am,entryPoint:"mainFragment"}}),n=I.from({vertex:z,fragment:sm,name:"emboss-filter"});super({gpuProgram:t,glProgram:n,resources:{embossUniforms:{uStrength:{value:e,type:"f32"}}}}),Zh(this,"uniforms"),this.uniforms=this.resources.embossUniforms.uniforms}get strength(){return this.uniforms.uStrength}set strength(e){this.uniforms.uStrength=e}};var lm=`precision highp float;
|
|
4693
4693
|
in vec2 vTextureCoord;
|
|
4694
4694
|
out vec4 finalColor;
|
|
4695
4695
|
|
|
@@ -4918,7 +4918,7 @@ const TRANSPARENT: i32 = 0;
|
|
|
4918
4918
|
const ORIGINAL: i32 = 1;
|
|
4919
4919
|
const LOOP: i32 = 2;
|
|
4920
4920
|
const CLAMP: i32 = 3;
|
|
4921
|
-
const MIRROR: i32 = 4;`;var
|
|
4921
|
+
const MIRROR: i32 = 4;`;var Jh=Object.defineProperty,e0=(r,e,t)=>e in r?Jh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ze=(r,e,t)=>(e0(r,typeof e!="symbol"?e+"":e,t),t),um=class fm extends _{constructor(e){e={...fm.defaults,...e};let t=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:cm,entryPoint:"mainFragment"}}),n=I.from({vertex:z,fragment:lm,name:"glitch-filter"}),o=document.createElement("canvas");o.width=4,o.height=e.sampleSize??512;let i=new ae({source:new ur({resource:o})});super({gpuProgram:t,glProgram:n,resources:{glitchUniforms:{uSeed:{value:e?.seed??0,type:"f32"},uDimensions:{value:new Float32Array(2),type:"vec2<f32>"},uAspect:{value:1,type:"f32"},uFillMode:{value:e?.fillMode??0,type:"f32"},uOffset:{value:e?.offset??100,type:"f32"},uDirection:{value:e?.direction??0,type:"f32"},uRed:{value:{x:0,y:0},type:"vec2<f32>"},uGreen:{value:{x:0,y:0},type:"vec2<f32>"},uBlue:{value:{x:0,y:0},type:"vec2<f32>"}},uDisplacementMap:i.source,uDisplacementSampler:i.source.style}}),Ze(this,"uniforms"),Ze(this,"average",!1),Ze(this,"minSize",8),Ze(this,"sampleSize",512),Ze(this,"_canvas"),Ze(this,"texture"),Ze(this,"_slices",0),Ze(this,"_sizes",new Float32Array(1)),Ze(this,"_offsets",new Float32Array(1)),this.uniforms=this.resources.glitchUniforms.uniforms,this._canvas=o,this.texture=i,Object.assign(this,e)}apply(e,t,n,o){let{width:i,height:s}=t.frame;this.uniforms.uDimensions[0]=i,this.uniforms.uDimensions[1]=s,this.uniforms.uAspect=s/i,e.applyFilter(this,t,n,o)}_randomizeSizes(){let e=this._sizes,t=this._slices-1,n=this.sampleSize,o=Math.min(this.minSize/n,.9/this._slices);if(this.average){let i=this._slices,s=1;for(let a=0;a<t;a++){let l=s/(i-a),c=Math.max(l*(1-Math.random()*.6),o);e[a]=c,s-=c}e[t]=s}else{let i=1,s=Math.sqrt(1/this._slices);for(let a=0;a<t;a++){let l=Math.max(s*i*Math.random(),o);e[a]=l,i-=l}e[t]=i}this.shuffle()}shuffle(){let e=this._sizes,t=this._slices-1;for(let n=t;n>0;n--){let o=Math.random()*n>>0,i=e[n];e[n]=e[o],e[o]=i}}_randomizeOffsets(){for(let e=0;e<this._slices;e++)this._offsets[e]=Math.random()*(Math.random()<.5?-1:1)}refresh(){this._randomizeSizes(),this._randomizeOffsets(),this.redraw()}redraw(){let e=this.sampleSize,t=this.texture,n=this._canvas.getContext("2d");n.clearRect(0,0,8,e);let o,i=0;for(let s=0;s<this._slices;s++){o=Math.floor(this._offsets[s]*256);let a=this._sizes[s]*e,l=o>0?o:0,c=o<0?-o:0;n.fillStyle=`rgba(${l}, ${c}, 0, 1)`,n.fillRect(0,i>>0,e,a+1>>0),i+=a}t.source.update()}set sizes(e){let t=Math.min(this._slices,e.length);for(let n=0;n<t;n++)this._sizes[n]=e[n]}get sizes(){return this._sizes}set offsets(e){let t=Math.min(this._slices,e.length);for(let n=0;n<t;n++)this._offsets[n]=e[n]}get offsets(){return this._offsets}get slices(){return this._slices}set slices(e){this._slices!==e&&(this._slices=e,this._sizes=new Float32Array(e),this._offsets=new Float32Array(e),this.refresh())}get offset(){return this.uniforms.uOffset}set offset(e){this.uniforms.uOffset=e}get seed(){return this.uniforms.uSeed}set seed(e){this.uniforms.uSeed=e}get fillMode(){return this.uniforms.uFillMode}set fillMode(e){this.uniforms.uFillMode=e}get direction(){return this.uniforms.uDirection/Je}set direction(e){this.uniforms.uDirection=e*Je}get red(){return this.uniforms.uRed}set red(e){Array.isArray(e)&&(e={x:e[0],y:e[1]}),this.uniforms.uRed=e}get green(){return this.uniforms.uGreen}set green(e){Array.isArray(e)&&(e={x:e[0],y:e[1]}),this.uniforms.uGreen=e}get blue(){return this.uniforms.uBlue}set blue(e){Array.isArray(e)&&(e={x:e[0],y:e[1]}),this.uniforms.uBlue=e}destroy(){this.texture?.destroy(!0),this.texture=this._canvas=this.red=this.green=this.blue=this._sizes=this._offsets=null}};Ze(um,"defaults",{slices:5,offset:100,direction:0,fillMode:0,average:!1,seed:0,red:{x:0,y:0},green:{x:0,y:0},blue:{x:0,y:0},minSize:8,sampleSize:512});var mm=um;var pm=`precision highp float;
|
|
4922
4922
|
in vec2 vTextureCoord;
|
|
4923
4923
|
out vec4 finalColor;
|
|
4924
4924
|
|
|
@@ -5062,7 +5062,7 @@ fn mainFragment(
|
|
|
5062
5062
|
}
|
|
5063
5063
|
}
|
|
5064
5064
|
|
|
5065
|
-
const PI: f32 = 3.14159265358979323846264;`;var
|
|
5065
|
+
const PI: f32 = 3.14159265358979323846264;`;var t0=Object.defineProperty,r0=(r,e,t)=>e in r?t0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Fa=(r,e,t)=>(r0(r,typeof e!="symbol"?e+"":e,t),t),hm=class gm extends _{constructor(e){e={...gm.DEFAULT_OPTIONS,...e};let t=e.distance??10,n=e.quality??.1,o=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:dm,entryPoint:"mainFragment"}}),i=I.from({vertex:z,fragment:pm.replace(/__ANGLE_STEP_SIZE__/gi,`${(1/n/t).toFixed(7)}`).replace(/__DIST__/gi,`${t.toFixed(0)}.0`),name:"glow-filter"});super({gpuProgram:o,glProgram:i,resources:{glowUniforms:{uDistance:{value:t,type:"f32"},uStrength:{value:[e.innerStrength,e.outerStrength],type:"vec2<f32>"},uColor:{value:new Float32Array(3),type:"vec3<f32>"},uAlpha:{value:e.alpha,type:"f32"},uQuality:{value:n,type:"f32"},uKnockout:{value:e?.knockout??!1?1:0,type:"f32"}}},padding:t}),Fa(this,"uniforms"),Fa(this,"_color"),this.uniforms=this.resources.glowUniforms.uniforms,this._color=new Q,this.color=e.color??16777215}get distance(){return this.uniforms.uDistance}set distance(e){this.uniforms.uDistance=this.padding=e}get innerStrength(){return this.uniforms.uStrength[0]}set innerStrength(e){this.uniforms.uStrength[0]=e}get outerStrength(){return this.uniforms.uStrength[1]}set outerStrength(e){this.uniforms.uStrength[1]=e}get color(){return this._color.value}set color(e){this._color.setValue(e);let[t,n,o]=this._color.toArray();this.uniforms.uColor[0]=t,this.uniforms.uColor[1]=n,this.uniforms.uColor[2]=o}get alpha(){return this.uniforms.uAlpha}set alpha(e){this.uniforms.uAlpha=e}get quality(){return this.uniforms.uQuality}set quality(e){this.uniforms.uQuality=e}get knockout(){return this.uniforms.uKnockout===1}set knockout(e){this.uniforms.uKnockout=e?1:0}};Fa(hm,"DEFAULT_OPTIONS",{distance:10,outerStrength:4,innerStrength:0,color:16777215,alpha:1,quality:.1,knockout:!1});var xm=hm;var vm=`precision highp float;
|
|
5066
5066
|
in vec2 vTextureCoord;
|
|
5067
5067
|
out vec4 finalColor;
|
|
5068
5068
|
|
|
@@ -5414,7 +5414,7 @@ fn turb(P: vec3<f32>, rep: vec3<f32>, lacunarity: f32, gain: f32) -> f32
|
|
|
5414
5414
|
totalgain *= gain;
|
|
5415
5415
|
}
|
|
5416
5416
|
return abs(sum);
|
|
5417
|
-
}`;var
|
|
5417
|
+
}`;var n0=Object.defineProperty,o0=(r,e,t)=>e in r?n0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,$r=(r,e,t)=>(o0(r,typeof e!="symbol"?e+"":e,t),t),Tm=class wm extends _{constructor(e){e={...wm.DEFAULT_OPTIONS,...e};let t=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:ym.replace("${PERLIN}",Sm),entryPoint:"mainFragment"}}),n=I.from({vertex:z,fragment:vm.replace("${PERLIN}",bm),name:"god-ray-filter"});super({gpuProgram:t,glProgram:n,resources:{godrayUniforms:{uLight:{value:new Float32Array(2),type:"vec2<f32>"},uParallel:{value:0,type:"f32"},uAspect:{value:0,type:"f32"},uTime:{value:e.time,type:"f32"},uRay:{value:new Float32Array(3),type:"vec3<f32>"},uDimensions:{value:new Float32Array(2),type:"vec2<f32>"}}}}),$r(this,"uniforms"),$r(this,"time",0),$r(this,"_angleLight",[0,0]),$r(this,"_angle",0),$r(this,"_center"),this.uniforms=this.resources.godrayUniforms.uniforms,Object.assign(this,e)}apply(e,t,n,o){let i=t.frame.width,s=t.frame.height;this.uniforms.uLight[0]=this.parallel?this._angleLight[0]:this._center.x,this.uniforms.uLight[1]=this.parallel?this._angleLight[1]:this._center.y,this.uniforms.uDimensions[0]=i,this.uniforms.uDimensions[1]=s,this.uniforms.uAspect=s/i,this.uniforms.uTime=this.time,e.applyFilter(this,t,n,o)}get angle(){return this._angle}set angle(e){this._angle=e;let t=e*Je;this._angleLight[0]=Math.cos(t),this._angleLight[1]=Math.sin(t)}get parallel(){return this.uniforms.uParallel>.5}set parallel(e){this.uniforms.uParallel=e?1:0}get center(){return this._center}set center(e){Array.isArray(e)&&(e={x:e[0],y:e[1]}),this._center=e}get centerX(){return this.center.x}set centerX(e){this.center.x=e}get centerY(){return this.center.y}set centerY(e){this.center.y=e}get gain(){return this.uniforms.uRay[0]}set gain(e){this.uniforms.uRay[0]=e}get lacunarity(){return this.uniforms.uRay[1]}set lacunarity(e){this.uniforms.uRay[1]=e}get alpha(){return this.uniforms.uRay[2]}set alpha(e){this.uniforms.uRay[2]=e}};$r(Tm,"DEFAULT_OPTIONS",{angle:30,gain:.5,lacunarity:2.5,parallel:!0,time:0,center:{x:0,y:0},alpha:1});var Cm=Tm;var km=`in vec2 vTextureCoord;
|
|
5418
5418
|
|
|
5419
5419
|
out vec4 finalColor;
|
|
5420
5420
|
|
|
@@ -5561,7 +5561,7 @@ fn hueShift(color: vec3<f32>, angle: f32) -> vec3<f32>
|
|
|
5561
5561
|
cross(k, color) * sin(angle) +
|
|
5562
5562
|
k * dot(k, color) * (1.0 - cosAngle)
|
|
5563
5563
|
);
|
|
5564
|
-
}`;var
|
|
5564
|
+
}`;var i0=Object.defineProperty,s0=(r,e,t)=>e in r?i0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ea=(r,e,t)=>(s0(r,typeof e!="symbol"?e+"":e,t),t),Am=class Fm extends _{constructor(e){e={...Fm.DEFAULT_OPTIONS,...e};let t=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:Im,entryPoint:"mainFragment"}}),n=I.from({vertex:z,fragment:_m,name:"hsl-adjustment-filter"});super({gpuProgram:t,glProgram:n,resources:{hslUniforms:{uHsl:{value:new Float32Array(3),type:"vec3<f32>"},uColorize:{value:e.colorize?1:0,type:"f32"},uAlpha:{value:e.alpha,type:"f32"}}}}),Ea(this,"uniforms"),Ea(this,"_hue"),this.uniforms=this.resources.hslUniforms.uniforms,Object.assign(this,e)}get hue(){return this._hue}set hue(e){this._hue=e,this.uniforms.uHsl[0]=e*(Math.PI/180)}get saturation(){return this.uniforms.uHsl[1]}set saturation(e){this.uniforms.uHsl[1]=e}get lightness(){return this.uniforms.uHsl[2]}set lightness(e){this.uniforms.uHsl[2]=e}get colorize(){return this.uniforms.uColorize===1}set colorize(e){this.uniforms.uColorize=e?1:0}get alpha(){return this.uniforms.uAlpha}set alpha(e){this.uniforms.uAlpha=e}};Ea(Am,"DEFAULT_OPTIONS",{hue:0,saturation:0,lightness:0,colorize:!1,alpha:1});var Em=Am;var zm=`precision highp float;
|
|
5565
5565
|
in vec2 vTextureCoord;
|
|
5566
5566
|
out vec4 finalColor;
|
|
5567
5567
|
|
|
@@ -5647,7 +5647,7 @@ fn mainFragment(
|
|
|
5647
5647
|
return select(color / f32(uKernelSize), textureSample(uTexture, uSampler, uv), uKernelSize == 0);
|
|
5648
5648
|
}
|
|
5649
5649
|
|
|
5650
|
-
const MAX_KERNEL_SIZE: i32 = 2048;`;var
|
|
5650
|
+
const MAX_KERNEL_SIZE: i32 = 2048;`;var a0=Object.defineProperty,l0=(r,e,t)=>e in r?a0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,za=(r,e,t)=>(l0(r,typeof e!="symbol"?e+"":e,t),t),Om=class Rm extends _{constructor(...e){let t=e[0]??{};if(Array.isArray(t)||"x"in t&&"y"in t||t instanceof Zr){N("6.0.0","MotionBlurFilter constructor params are now options object. See params: { velocity, kernelSize, offset }");let i="x"in t?t.x:t[0],s="y"in t?t.y:t[1];t={velocity:{x:i,y:s}},e[1]!==void 0&&(t.kernelSize=e[1]),e[2]!==void 0&&(t.offset=e[2])}t={...Rm.DEFAULT_OPTIONS,...t};let n=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:Dm,entryPoint:"mainFragment"}}),o=I.from({vertex:z,fragment:zm,name:"motion-blur-filter"});super({gpuProgram:n,glProgram:o,resources:{motionBlurUniforms:{uVelocity:{value:{x:0,y:0},type:"vec2<f32>"},uKernelSize:{value:Math.trunc(t.kernelSize??5),type:"i32"},uOffset:{value:t.offset,type:"f32"}}}}),za(this,"uniforms"),za(this,"_kernelSize"),this.uniforms=this.resources.motionBlurUniforms.uniforms,Object.assign(this,t)}get velocity(){return this.uniforms.uVelocity}set velocity(e){Array.isArray(e)&&(e={x:e[0],y:e[1]}),this.uniforms.uVelocity=e,this._updateDirty()}get velocityX(){return this.velocity.x}set velocityX(e){this.velocity.x=e,this._updateDirty()}get velocityY(){return this.velocity.y}set velocityY(e){this.velocity.y=e,this._updateDirty()}get kernelSize(){return this._kernelSize}set kernelSize(e){this._kernelSize=e,this._updateDirty()}get offset(){return this.uniforms.uOffset}set offset(e){this.uniforms.uOffset=e}_updateDirty(){this.padding=(Math.max(Math.abs(this.velocityX),Math.abs(this.velocityY))>>0)+1,this.uniforms.uKernelSize=this.velocityX!==0||this.velocityY!==0?this._kernelSize:0}};za(Om,"DEFAULT_OPTIONS",{velocity:{x:0,y:0},kernelSize:5,offset:0});var Mm=Om;var Bm=`in vec2 vTextureCoord;
|
|
5651
5651
|
out vec4 finalColor;
|
|
5652
5652
|
|
|
5653
5653
|
const int MAX_COLORS = \${MAX_COLORS};
|
|
@@ -5733,7 +5733,7 @@ fn mainFragment(
|
|
|
5733
5733
|
return color;
|
|
5734
5734
|
}
|
|
5735
5735
|
|
|
5736
|
-
const MAX_COLORS: i32 = \${MAX_COLORS};`;var
|
|
5736
|
+
const MAX_COLORS: i32 = \${MAX_COLORS};`;var c0=Object.defineProperty,u0=(r,e,t)=>e in r?c0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ri=(r,e,t)=>(u0(r,typeof e!="symbol"?e+"":e,t),t),Nm=class Lm extends _{constructor(...e){let t=e[0]??{};Array.isArray(t)&&(N("6.0.0","MultiColorReplaceFilter constructor params are now options object. See params: { replacements, tolerance, maxColors }"),t={replacements:t},e[1]&&(t.tolerance=e[1]),e[2]&&(t.maxColors=e[2])),t={...Lm.DEFAULT_OPTIONS,...t};let n=t.maxColors??t.replacements.length,o=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:Um.replace(/\$\{MAX_COLORS\}/g,n.toFixed(0)),entryPoint:"mainFragment"}}),i=I.from({vertex:z,fragment:Bm.replace(/\$\{MAX_COLORS\}/g,n.toFixed(0)),name:"multi-color-replace-filter"});super({gpuProgram:o,glProgram:i,resources:{multiColorReplaceUniforms:{uOriginalColors:{value:new Float32Array(3*n),type:"vec3<f32>",size:n},uTargetColors:{value:new Float32Array(3*n),type:"vec3<f32>",size:n},uTolerance:{value:t.tolerance,type:"f32"}}}}),Ri(this,"uniforms"),Ri(this,"_replacements",[]),Ri(this,"_maxColors"),this._maxColors=n,this.uniforms=this.resources.multiColorReplaceUniforms.uniforms,this.replacements=t.replacements}set replacements(e){let t=this.uniforms.uOriginalColors,n=this.uniforms.uTargetColors,o=e.length,i=new Q;if(o>this._maxColors)throw new Error(`Length of replacements (${o}) exceeds the maximum colors length (${this._maxColors})`);t[o*3]=-1;let s,a,l;for(let c=0;c<o;c++){let f=e[c];i.setValue(f[0]),[s,a,l]=i.toArray(),t[c*3]=s,t[c*3+1]=a,t[c*3+2]=l,i.setValue(f[1]),[s,a,l]=i.toArray(),n[c*3]=s,n[c*3+1]=a,n[c*3+2]=l}this._replacements=e}get replacements(){return this._replacements}refresh(){this.replacements=this._replacements}get maxColors(){return this._maxColors}get tolerance(){return this.uniforms.uTolerance}set tolerance(e){this.uniforms.uTolerance=e}set epsilon(e){N("6.0.0","MultiColorReplaceFilter.epsilon is deprecated, please use MultiColorReplaceFilter.tolerance instead"),this.tolerance=e}get epsilon(){return N("6.0.0","MultiColorReplaceFilter.epsilon is deprecated, please use MultiColorReplaceFilter.tolerance instead"),this.tolerance}};Ri(Nm,"DEFAULT_OPTIONS",{replacements:[[16711680,255]],tolerance:.05,maxColors:void 0});var Vm=Nm;var Gm=`precision highp float;
|
|
5737
5737
|
in vec2 vTextureCoord;
|
|
5738
5738
|
out vec4 finalColor;
|
|
5739
5739
|
|
|
@@ -5999,7 +5999,7 @@ fn noise(coord: vec2<f32>) -> f32
|
|
|
5999
5999
|
pixelCoord.x = floor(pixelCoord.x / uNoise[1]);
|
|
6000
6000
|
pixelCoord.y = floor(pixelCoord.y / uNoise[1]);
|
|
6001
6001
|
return (rand(pixelCoord * uNoise[1] * uSeed) - 0.5) * uNoise[0];
|
|
6002
|
-
}`;var
|
|
6002
|
+
}`;var f0=Object.defineProperty,m0=(r,e,t)=>e in r?f0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Da=(r,e,t)=>(m0(r,typeof e!="symbol"?e+"":e,t),t),Hm=class Wm extends _{constructor(e){e={...Wm.DEFAULT_OPTIONS,...e};let t=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:qm,entryPoint:"mainFragment"}}),n=I.from({vertex:z,fragment:Gm,name:"old-film-filter"});super({gpuProgram:t,glProgram:n,resources:{oldFilmUniforms:{uSepia:{value:e.sepia,type:"f32"},uNoise:{value:new Float32Array(2),type:"vec2<f32>"},uScratch:{value:new Float32Array(3),type:"vec3<f32>"},uVignetting:{value:new Float32Array(3),type:"vec3<f32>"},uSeed:{value:e.seed,type:"f32"},uDimensions:{value:new Float32Array(2),type:"vec2<f32>"}}}}),Da(this,"uniforms"),Da(this,"seed"),this.uniforms=this.resources.oldFilmUniforms.uniforms,Object.assign(this,e)}apply(e,t,n,o){this.uniforms.uDimensions[0]=t.frame.width,this.uniforms.uDimensions[1]=t.frame.height,this.uniforms.uSeed=this.seed,e.applyFilter(this,t,n,o)}get sepia(){return this.uniforms.uSepia}set sepia(e){this.uniforms.uSepia=e}get noise(){return this.uniforms.uNoise[0]}set noise(e){this.uniforms.uNoise[0]=e}get noiseSize(){return this.uniforms.uNoise[1]}set noiseSize(e){this.uniforms.uNoise[1]=e}get scratch(){return this.uniforms.uScratch[0]}set scratch(e){this.uniforms.uScratch[0]=e}get scratchDensity(){return this.uniforms.uScratch[1]}set scratchDensity(e){this.uniforms.uScratch[1]=e}get scratchWidth(){return this.uniforms.uScratch[2]}set scratchWidth(e){this.uniforms.uScratch[2]=e}get vignetting(){return this.uniforms.uVignetting[0]}set vignetting(e){this.uniforms.uVignetting[0]=e}get vignettingAlpha(){return this.uniforms.uVignetting[1]}set vignettingAlpha(e){this.uniforms.uVignetting[1]=e}get vignettingBlur(){return this.uniforms.uVignetting[2]}set vignettingBlur(e){this.uniforms.uVignetting[2]=e}};Da(Hm,"DEFAULT_OPTIONS",{sepia:.3,noise:.3,noiseSize:1,scratch:.5,scratchDensity:.3,scratchWidth:1,vignetting:.3,vignettingAlpha:1,vignettingBlur:.3,seed:0});var jm=Hm;var Xm=`precision highp float;
|
|
6003
6003
|
in vec2 vTextureCoord;
|
|
6004
6004
|
out vec4 finalColor;
|
|
6005
6005
|
|
|
@@ -6104,7 +6104,7 @@ fn outlineMaxAlphaAtPos(uv: vec2<f32>) -> f32 {
|
|
|
6104
6104
|
return maxAlpha;
|
|
6105
6105
|
}
|
|
6106
6106
|
|
|
6107
|
-
const DOUBLE_PI: f32 = 3.14159265358979323846264 * 2.;`;var
|
|
6107
|
+
const DOUBLE_PI: f32 = 3.14159265358979323846264 * 2.;`;var p0=Object.defineProperty,d0=(r,e,t)=>e in r?p0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,lr=(r,e,t)=>(d0(r,typeof e!="symbol"?e+"":e,t),t),Mi=class ar extends _{constructor(...e){let t=e[0]??{};typeof t=="number"&&(N("6.0.0","OutlineFilter constructor params are now options object. See params: { thickness, color, quality, alpha, knockout }"),t={thickness:t},e[1]!==void 0&&(t.color=e[1]),e[2]!==void 0&&(t.quality=e[2]),e[3]!==void 0&&(t.alpha=e[3]),e[4]!==void 0&&(t.knockout=e[4])),t={...ar.DEFAULT_OPTIONS,...t};let n=t.quality??.1,o=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:$m,entryPoint:"mainFragment"}}),i=I.from({vertex:z,fragment:Xm.replace(/\$\{ANGLE_STEP\}/,ar.getAngleStep(n).toFixed(7)),name:"outline-filter"});super({gpuProgram:o,glProgram:i,resources:{outlineUniforms:{uThickness:{value:new Float32Array(2),type:"vec2<f32>"},uColor:{value:new Float32Array(3),type:"vec3<f32>"},uAlpha:{value:t.alpha,type:"f32"},uAngleStep:{value:0,type:"f32"},uKnockout:{value:t.knockout?1:0,type:"f32"}}}}),lr(this,"uniforms"),lr(this,"_thickness"),lr(this,"_quality"),lr(this,"_color"),this.uniforms=this.resources.outlineUniforms.uniforms,this.uniforms.uAngleStep=ar.getAngleStep(n),this._color=new Q,this.color=t.color??0,Object.assign(this,t)}apply(e,t,n,o){this.uniforms.uThickness[0]=this.thickness/t.source.width,this.uniforms.uThickness[1]=this.thickness/t.source.height,e.applyFilter(this,t,n,o)}static getAngleStep(e){return parseFloat((Math.PI*2/Math.max(e*ar.MAX_SAMPLES,ar.MIN_SAMPLES)).toFixed(7))}get thickness(){return this._thickness}set thickness(e){this._thickness=this.padding=e}get color(){return this._color.value}set color(e){this._color.setValue(e);let[t,n,o]=this._color.toArray();this.uniforms.uColor[0]=t,this.uniforms.uColor[1]=n,this.uniforms.uColor[2]=o}get alpha(){return this.uniforms.uAlpha}set alpha(e){this.uniforms.uAlpha=e}get quality(){return this._quality}set quality(e){this._quality=e,this.uniforms.uAngleStep=ar.getAngleStep(e)}get knockout(){return this.uniforms.uKnockout===1}set knockout(e){this.uniforms.uKnockout=e?1:0}};lr(Mi,"DEFAULT_OPTIONS",{thickness:1,color:0,alpha:1,quality:.1,knockout:!1});lr(Mi,"MIN_SAMPLES",1);lr(Mi,"MAX_SAMPLES",100);var Km=Mi;var Ym=`precision highp float;
|
|
6108
6108
|
in vec2 vTextureCoord;
|
|
6109
6109
|
out vec4 finalColor;
|
|
6110
6110
|
|
|
@@ -6355,7 +6355,7 @@ fn mainFragment(
|
|
|
6355
6355
|
return select(color / f32(uKernelSize), baseColor, returnColorOnly);
|
|
6356
6356
|
}
|
|
6357
6357
|
|
|
6358
|
-
const MAX_KERNEL_SIZE: i32 = 2048;`;var
|
|
6358
|
+
const MAX_KERNEL_SIZE: i32 = 2048;`;var h0=Object.defineProperty,g0=(r,e,t)=>e in r?h0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Bi=(r,e,t)=>(g0(r,typeof e!="symbol"?e+"":e,t),t),ep=class tp extends _{constructor(...e){let t=e[0]??{};if(typeof t=="number"){if(N("6.0.0","RadialBlurFilter constructor params are now options object. See params: { angle, center, kernelSize, radius }"),t={angle:t},e[1]){let i="x"in e[1]?e[1].x:e[1][0],s="y"in e[1]?e[1].y:e[1][1];t.center={x:i,y:s}}e[2]&&(t.kernelSize=e[2]),e[3]&&(t.radius=e[3])}t={...tp.DEFAULT_OPTIONS,...t};let n=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:Jm,entryPoint:"mainFragment"}}),o=I.from({vertex:z,fragment:Zm,name:"radial-blur-filter"});super({gpuProgram:n,glProgram:o,resources:{radialBlurUniforms:{uRadian:{value:0,type:"f32"},uCenter:{value:{x:0,y:0},type:"vec2<f32>"},uKernelSize:{value:t.kernelSize,type:"i32"},uRadius:{value:t.radius,type:"f32"}}}}),Bi(this,"uniforms"),Bi(this,"_angle"),Bi(this,"_kernelSize"),this.uniforms=this.resources.radialBlurUniforms.uniforms,Object.assign(this,t)}_updateKernelSize(){this.uniforms.uKernelSize=this._angle!==0?this.kernelSize:0}get angle(){return this._angle}set angle(e){this._angle=e,this.uniforms.uRadian=e*Math.PI/180,this._updateKernelSize()}get center(){return this.uniforms.uCenter}set center(e){Array.isArray(e)&&(e={x:e[0],y:e[1]}),this.uniforms.uCenter=e}get centerX(){return this.center.x}set centerX(e){this.center.x=e}get centerY(){return this.center.y}set centerY(e){this.center.y=e}get kernelSize(){return this._kernelSize}set kernelSize(e){this._kernelSize=e,this._updateKernelSize()}get radius(){return this.uniforms.uRadius}set radius(e){this.uniforms.uRadius=e<0||e===1/0?-1:e}};Bi(ep,"DEFAULT_OPTIONS",{angle:0,center:{x:0,y:0},kernelSize:5,radius:-1});var rp=ep;var np=`precision highp float;
|
|
6359
6359
|
in vec2 vTextureCoord;
|
|
6360
6360
|
out vec4 finalColor;
|
|
6361
6361
|
|
|
@@ -6465,7 +6465,7 @@ fn mainFragment(
|
|
|
6465
6465
|
fn rand(co: vec2<f32>) -> f32
|
|
6466
6466
|
{
|
|
6467
6467
|
return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
|
|
6468
|
-
}`;var
|
|
6468
|
+
}`;var x0=Object.defineProperty,v0=(r,e,t)=>e in r?x0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Oa=(r,e,t)=>(v0(r,typeof e!="symbol"?e+"":e,t),t),ip=class sp extends _{constructor(e){e={...sp.DEFAULT_OPTIONS,...e};let t=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:op,entryPoint:"mainFragment"}}),n=I.from({vertex:z,fragment:np,name:"reflection-filter"});super({gpuProgram:t,glProgram:n,resources:{reflectionUniforms:{uMirror:{value:e.mirror?1:0,type:"f32"},uBoundary:{value:e.boundary,type:"f32"},uAmplitude:{value:e.amplitude,type:"vec2<f32>"},uWavelength:{value:e.waveLength,type:"vec2<f32>"},uAlpha:{value:e.alpha,type:"vec2<f32>"},uTime:{value:e.time,type:"f32"},uDimensions:{value:new Float32Array(2),type:"vec2<f32>"}}}}),Oa(this,"uniforms"),Oa(this,"time",0),this.uniforms=this.resources.reflectionUniforms.uniforms,Object.assign(this,e)}apply(e,t,n,o){this.uniforms.uDimensions[0]=t.frame.width,this.uniforms.uDimensions[1]=t.frame.height,this.uniforms.uTime=this.time,e.applyFilter(this,t,n,o)}get mirror(){return this.uniforms.uMirror>.5}set mirror(e){this.uniforms.uMirror=e?1:0}get boundary(){return this.uniforms.uBoundary}set boundary(e){this.uniforms.uBoundary=e}get amplitude(){return Array.from(this.uniforms.uAmplitude)}set amplitude(e){this.uniforms.uAmplitude[0]=e[0],this.uniforms.uAmplitude[1]=e[1]}get amplitudeStart(){return this.uniforms.uAmplitude[0]}set amplitudeStart(e){this.uniforms.uAmplitude[0]=e}get amplitudeEnd(){return this.uniforms.uAmplitude[1]}set amplitudeEnd(e){this.uniforms.uAmplitude[1]=e}get waveLength(){return Array.from(this.uniforms.uWavelength)}set waveLength(e){this.uniforms.uWavelength[0]=e[0],this.uniforms.uWavelength[1]=e[1]}get wavelengthStart(){return this.uniforms.uWavelength[0]}set wavelengthStart(e){this.uniforms.uWavelength[0]=e}get wavelengthEnd(){return this.uniforms.uWavelength[1]}set wavelengthEnd(e){this.uniforms.uWavelength[1]=e}get alpha(){return Array.from(this.uniforms.uAlpha)}set alpha(e){this.uniforms.uAlpha[0]=e[0],this.uniforms.uAlpha[1]=e[1]}get alphaStart(){return this.uniforms.uAlpha[0]}set alphaStart(e){this.uniforms.uAlpha[0]=e}get alphaEnd(){return this.uniforms.uAlpha[1]}set alphaEnd(e){this.uniforms.uAlpha[1]=e}};Oa(ip,"DEFAULT_OPTIONS",{mirror:!0,boundary:.5,amplitude:[0,20],waveLength:[30,100],alpha:[1,1],time:0});var ap=ip;var lp=`precision highp float;
|
|
6469
6469
|
in vec2 vTextureCoord;
|
|
6470
6470
|
out vec4 finalColor;
|
|
6471
6471
|
|
|
@@ -6515,7 +6515,7 @@ fn mainFragment(
|
|
|
6515
6515
|
let a = textureSample(uTexture, uSampler, uv).a;
|
|
6516
6516
|
return vec4<f32>(r, g, b, a);
|
|
6517
6517
|
}
|
|
6518
|
-
`;var
|
|
6518
|
+
`;var y0=Object.defineProperty,b0=(r,e,t)=>e in r?y0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,up=(r,e,t)=>(b0(r,typeof e!="symbol"?e+"":e,t),t),fp=class mp extends _{constructor(...e){let t=e[0]??{};(Array.isArray(t)||"x"in t&&"y"in t)&&(N("6.0.0","RGBSplitFilter constructor params are now options object. See params: { red, green, blue }"),t={red:t},e[1]!==void 0&&(t.green=e[1]),e[2]!==void 0&&(t.blue=e[2])),t={...mp.DEFAULT_OPTIONS,...t};let n=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:cp,entryPoint:"mainFragment"}}),o=I.from({vertex:z,fragment:lp,name:"rgb-split-filter"});super({gpuProgram:n,glProgram:o,resources:{rgbSplitUniforms:{uRed:{value:{x:0,y:0},type:"vec2<f32>"},uGreen:{value:{x:0,y:0},type:"vec2<f32>"},uBlue:{value:{x:0,y:0},type:"vec2<f32>"}}}}),up(this,"uniforms"),this.uniforms=this.resources.rgbSplitUniforms.uniforms,Object.assign(this,t)}get red(){return this.uniforms.uRed}set red(e){Array.isArray(e)&&(e={x:e[0],y:e[1]}),this.uniforms.uRed=e}get redX(){return this.red.x}set redX(e){this.red.x=e}get redY(){return this.red.y}set redY(e){this.red.y=e}get green(){return this.uniforms.uGreen}set green(e){Array.isArray(e)&&(e={x:e[0],y:e[1]}),this.uniforms.uGreen=e}get greenX(){return this.green.x}set greenX(e){this.green.x=e}get greenY(){return this.green.y}set greenY(e){this.green.y=e}get blue(){return this.uniforms.uBlue}set blue(e){Array.isArray(e)&&(e={x:e[0],y:e[1]}),this.uniforms.uBlue=e}get blueX(){return this.blue.x}set blueX(e){this.blue.x=e}get blueY(){return this.blue.y}set blueY(e){this.blue.y=e}};up(fp,"DEFAULT_OPTIONS",{red:{x:-10,y:0},green:{x:0,y:10},blue:{x:0,y:0}});var pp=fp;var dp=`
|
|
6519
6519
|
precision highp float;
|
|
6520
6520
|
in vec2 vTextureCoord;
|
|
6521
6521
|
out vec4 finalColor;
|
|
@@ -6676,7 +6676,7 @@ fn boolVec2(x: vec2<f32>, y: vec2<f32>) -> bool
|
|
|
6676
6676
|
}
|
|
6677
6677
|
|
|
6678
6678
|
const PI: f32 = 3.14159265358979323846264;
|
|
6679
|
-
`;var
|
|
6679
|
+
`;var S0=Object.defineProperty,T0=(r,e,t)=>e in r?S0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ra=(r,e,t)=>(T0(r,typeof e!="symbol"?e+"":e,t),t),gp=class xp extends _{constructor(...e){let t=e[0]??{};(Array.isArray(t)||"x"in t&&"y"in t)&&(N("6.0.0","ShockwaveFilter constructor params are now options object. See params: { center, speed, amplitude, wavelength, brightness, radius, time }"),t={center:t,...e[1]},e[2]!==void 0&&(t.time=e[2])),t={...xp.DEFAULT_OPTIONS,...t};let n=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:hp,entryPoint:"mainFragment"}}),o=I.from({vertex:z,fragment:dp,name:"shockwave-filter"});super({gpuProgram:n,glProgram:o,resources:{shockwaveUniforms:{uTime:{value:t.time,type:"f32"},uCenter:{value:t.center,type:"vec2<f32>"},uSpeed:{value:t.speed,type:"f32"},uWave:{value:new Float32Array(4),type:"vec4<f32>"}}}}),Ra(this,"uniforms"),Ra(this,"time"),this.time=0,this.uniforms=this.resources.shockwaveUniforms.uniforms,Object.assign(this,t)}apply(e,t,n,o){this.uniforms.uTime=this.time,e.applyFilter(this,t,n,o)}get center(){return this.uniforms.uCenter}set center(e){Array.isArray(e)&&(e={x:e[0],y:e[1]}),this.uniforms.uCenter=e}get centerX(){return this.uniforms.uCenter.x}set centerX(e){this.uniforms.uCenter.x=e}get centerY(){return this.uniforms.uCenter.y}set centerY(e){this.uniforms.uCenter.y=e}get speed(){return this.uniforms.uSpeed}set speed(e){this.uniforms.uSpeed=e}get amplitude(){return this.uniforms.uWave[0]}set amplitude(e){this.uniforms.uWave[0]=e}get wavelength(){return this.uniforms.uWave[1]}set wavelength(e){this.uniforms.uWave[1]=e}get brightness(){return this.uniforms.uWave[2]}set brightness(e){this.uniforms.uWave[2]=e}get radius(){return this.uniforms.uWave[3]}set radius(e){this.uniforms.uWave[3]=e}};Ra(gp,"DEFAULT_OPTIONS",{center:{x:0,y:0},speed:500,amplitude:30,wavelength:160,brightness:1,radius:-1});var vp=gp;var yp=`precision highp float;
|
|
6680
6680
|
in vec2 vTextureCoord;
|
|
6681
6681
|
out vec4 finalColor;
|
|
6682
6682
|
|
|
@@ -6736,7 +6736,7 @@ fn mainFragment(
|
|
|
6736
6736
|
let intensity: vec3<f32> = ambient + light.rgb;
|
|
6737
6737
|
let finalColor: vec3<f32> = diffuseColor.rgb * intensity;
|
|
6738
6738
|
return vec4<f32>(finalColor, diffuseColor.a);
|
|
6739
|
-
}`;var
|
|
6739
|
+
}`;var w0=Object.defineProperty,C0=(r,e,t)=>e in r?w0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ui=(r,e,t)=>(C0(r,typeof e!="symbol"?e+"":e,t),t),Sp=class Tp extends _{constructor(...e){let t=e[0]??{};if(t instanceof ae&&(N("6.0.0","SimpleLightmapFilter constructor params are now options object. See params: { lightMap, color, alpha }"),t={lightMap:t},e[1]!==void 0&&(t.color=e[1]),e[2]!==void 0&&(t.alpha=e[2])),t={...Tp.DEFAULT_OPTIONS,...t},!t.lightMap)throw Error("No light map texture source was provided to SimpleLightmapFilter");let n=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:bp,entryPoint:"mainFragment"}}),o=I.from({vertex:z,fragment:yp,name:"simple-lightmap-filter"});super({gpuProgram:n,glProgram:o,resources:{simpleLightmapUniforms:{uColor:{value:new Float32Array(3),type:"vec3<f32>"},uAlpha:{value:t.alpha,type:"f32"},uDimensions:{value:new Float32Array(2),type:"vec2<f32>"}},uMapTexture:t.lightMap.source,uMapSampler:t.lightMap.source.style}}),Ui(this,"uniforms"),Ui(this,"_color"),Ui(this,"_lightMap"),this.uniforms=this.resources.simpleLightmapUniforms.uniforms,this._color=new Q,this.color=t.color??0,Object.assign(this,t)}apply(e,t,n,o){this.uniforms.uDimensions[0]=t.frame.width,this.uniforms.uDimensions[1]=t.frame.height,e.applyFilter(this,t,n,o)}get lightMap(){return this._lightMap}set lightMap(e){this._lightMap=e,this.resources.uMapTexture=e.source,this.resources.uMapSampler=e.source.style}get color(){return this._color.value}set color(e){this._color.setValue(e);let[t,n,o]=this._color.toArray();this.uniforms.uColor[0]=t,this.uniforms.uColor[1]=n,this.uniforms.uColor[2]=o}get alpha(){return this.uniforms.uAlpha}set alpha(e){this.uniforms.uAlpha=e}};Ui(Sp,"DEFAULT_OPTIONS",{lightMap:ae.WHITE,color:0,alpha:1});var wp=Sp;var Cp=`precision highp float;
|
|
6740
6740
|
in vec2 vTextureCoord;
|
|
6741
6741
|
out vec4 finalColor;
|
|
6742
6742
|
|
|
@@ -6857,7 +6857,7 @@ fn simplex_noise(p: vec3<f32>) -> f32 {
|
|
|
6857
6857
|
let h: vec4<f32> = max(vec4<f32>(0.6) - vec4<f32>(dot(d0, d0), dot(d1, d1), dot(d2, d2), dot(d3, d3)), vec4<f32>(0.0));
|
|
6858
6858
|
let n: vec4<f32> = h * h * h * h * vec4<f32>(dot(d0, hash33(i)), dot(d1, hash33(i + i1)), dot(d2, hash33(i + i2)), dot(d3, hash33(i + 1.)));
|
|
6859
6859
|
return dot(vec4<f32>(31.316), n);
|
|
6860
|
-
} `;var
|
|
6860
|
+
} `;var k0=Object.defineProperty,P0=(r,e,t)=>e in r?k0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,_0=(r,e,t)=>(P0(r,typeof e!="symbol"?e+"":e,t),t),Pp=class _p extends _{constructor(e){e={..._p.defaults,...e};let t=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:kp,entryPoint:"mainFragment"}}),n=I.from({vertex:z,fragment:Cp,name:"simplex-filter"});super({gpuProgram:t,glProgram:n,resources:{simplexUniforms:{uStrength:{value:e?.strength??0,type:"f32"},uNoiseScale:{value:e?.noiseScale??0,type:"f32"},uOffsetX:{value:e?.offsetX??0,type:"f32"},uOffsetY:{value:e?.offsetY??0,type:"f32"},uOffsetZ:{value:e?.offsetZ??0,type:"f32"},uStep:{value:e?.step??0,type:"f32"}}}})}get strength(){return this.resources.simplexUniforms.uniforms.uStrength}set strength(e){this.resources.simplexUniforms.uniforms.uStrength=e}get noiseScale(){return this.resources.simplexUniforms.uniforms.uNoiseScale}set noiseScale(e){this.resources.simplexUniforms.uniforms.uNoiseScale=e}get offsetX(){return this.resources.simplexUniforms.uniforms.uOffsetX}set offsetX(e){this.resources.simplexUniforms.uniforms.uOffsetX=e}get offsetY(){return this.resources.simplexUniforms.uniforms.uOffsetY}set offsetY(e){this.resources.simplexUniforms.uniforms.uOffsetY=e}get offsetZ(){return this.resources.simplexUniforms.uniforms.uOffsetZ}set offsetZ(e){this.resources.simplexUniforms.uniforms.uOffsetZ=e}get step(){return this.resources.simplexUniforms.uniforms.uStep}set step(e){this.resources.simplexUniforms.uniforms.uStep=e}};_0(Pp,"defaults",{strength:.5,noiseScale:10,offsetX:0,offsetY:0,offsetZ:0,step:-1});var Ip=Pp;var Ap=`precision highp float;
|
|
6861
6861
|
in vec2 vTextureCoord;
|
|
6862
6862
|
out vec4 finalColor;
|
|
6863
6863
|
|
|
@@ -6955,7 +6955,7 @@ fn mainFragment(
|
|
|
6955
6955
|
fn random(position: vec4<f32>, scale: vec3<f32>, seed: f32) -> f32
|
|
6956
6956
|
{
|
|
6957
6957
|
return fract(sin(dot(position.xyz + seed, scale)) * 43758.5453 + seed);
|
|
6958
|
-
}`;var
|
|
6958
|
+
}`;var I0=Object.defineProperty,A0=(r,e,t)=>e in r?I0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ma=(r,e,t)=>(A0(r,typeof e!="symbol"?e+"":e,t),t),Ep=class zp extends _{constructor(e){let{width:t,height:n}=Qi.defaultOptions;e={...zp.DEFAULT_OPTIONS,start:{x:0,y:n/2},end:{x:t,y:n/2},...e};let o=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:Fp,entryPoint:"mainFragment"}}),i=I.from({vertex:z,fragment:Ap,name:"tilt-shift-axis-filter"});super({gpuProgram:o,glProgram:i,resources:{tiltShiftUniforms:{uBlur:{value:new Float32Array([e.blur,e.gradientBlur]),type:"vec2<f32>"},uStart:{value:e.start,type:"vec2<f32>"},uEnd:{value:e.end,type:"vec2<f32>"},uDelta:{value:new Float32Array([0,0]),type:"vec2<f32>"}}}}),Ma(this,"uniforms"),Ma(this,"_tiltAxis"),this.uniforms=this.resources.tiltShiftUniforms.uniforms,this._tiltAxis=e.axis}updateDelta(){if(this.uniforms.uDelta[0]=0,this.uniforms.uDelta[1]=0,this._tiltAxis===void 0)return;let e=this.uniforms.uEnd,t=this.uniforms.uStart,n=e.x-t.x,o=e.y-t.y,i=Math.sqrt(n*n+o*o),s=this._tiltAxis==="vertical";this.uniforms.uDelta[0]=s?-o/i:n/i,this.uniforms.uDelta[1]=s?n/i:o/i}};Ma(Ep,"DEFAULT_OPTIONS",{blur:100,gradientBlur:600});var Yr=Ep;var F0=Object.defineProperty,E0=(r,e,t)=>e in r?F0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,z0=(r,e,t)=>(E0(r,typeof e!="symbol"?e+"":e,t),t),Ni=class extends Yr{constructor(e){e={...Yr.DEFAULT_OPTIONS,...e},super({...e,axis:"horizontal"}),z0(this,"_tiltShiftYFilter"),this._tiltShiftYFilter=new Yr({...e,axis:"vertical"}),this.updateDelta(),Object.assign(this,e)}apply(e,t,n,o){let i=J.getSameSizeTexture(t);e.applyFilter(this,t,i,!0),e.applyFilter(this._tiltShiftYFilter,i,n,o),J.returnTexture(i)}updateDelta(){super.updateDelta(),this._tiltShiftYFilter.updateDelta()}get blur(){return this.uniforms.uBlur[0]}set blur(e){this.uniforms.uBlur[0]=this._tiltShiftYFilter.uniforms.uBlur[0]=e}get gradientBlur(){return this.uniforms.uBlur[1]}set gradientBlur(e){this.uniforms.uBlur[1]=this._tiltShiftYFilter.uniforms.uBlur[1]=e}get start(){return this.uniforms.uStart}set start(e){this.uniforms.uStart=this._tiltShiftYFilter.uniforms.uStart=e,this.updateDelta()}get startX(){return this.start.x}set startX(e){this.start.x=e,this.updateDelta()}get startY(){return this.start.y}set startY(e){this.start.y=e,this.updateDelta()}get end(){return this.uniforms.uEnd}set end(e){this.uniforms.uEnd=this._tiltShiftYFilter.uniforms.uEnd=e,this.updateDelta()}get endX(){return this.end.x}set endX(e){this.end.x=e,this.updateDelta()}get endY(){return this.end.y}set endY(e){this.end.y=e,this.updateDelta()}};var Dp=`precision highp float;
|
|
6959
6959
|
in vec2 vTextureCoord;
|
|
6960
6960
|
out vec4 finalColor;
|
|
6961
6961
|
|
|
@@ -7076,7 +7076,7 @@ fn twist(coord: vec2<f32>) -> vec2<f32>
|
|
|
7076
7076
|
twistedCoord += uOffset;
|
|
7077
7077
|
return twistedCoord;
|
|
7078
7078
|
}
|
|
7079
|
-
`;var
|
|
7079
|
+
`;var D0=Object.defineProperty,O0=(r,e,t)=>e in r?D0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Rp=(r,e,t)=>(O0(r,typeof e!="symbol"?e+"":e,t),t),Mp=class Bp extends _{constructor(e){e={...Bp.DEFAULT_OPTIONS,...e};let t=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:Op,entryPoint:"mainFragment"}}),n=I.from({vertex:z,fragment:Dp,name:"twist-filter"});super({gpuProgram:t,glProgram:n,resources:{twistUniforms:{uTwist:{value:[e.radius??0,e.angle??0],type:"vec2<f32>"},uOffset:{value:e.offset,type:"vec2<f32>"}}},...e}),Rp(this,"uniforms"),this.uniforms=this.resources.twistUniforms.uniforms}get radius(){return this.uniforms.uTwist[0]}set radius(e){this.uniforms.uTwist[0]=e}get angle(){return this.uniforms.uTwist[1]}set angle(e){this.uniforms.uTwist[1]=e}get offset(){return this.uniforms.uOffset}set offset(e){this.uniforms.uOffset=e}get offsetX(){return this.offset.x}set offsetX(e){this.offset.x=e}get offsetY(){return this.offset.y}set offsetY(e){this.offset.y=e}};Rp(Mp,"DEFAULT_OPTIONS",{padding:20,radius:200,angle:4,offset:{x:0,y:0}});var Up=Mp;var Np=`precision highp float;
|
|
7080
7080
|
in vec2 vTextureCoord;
|
|
7081
7081
|
out vec4 finalColor;
|
|
7082
7082
|
|
|
@@ -7273,7 +7273,7 @@ fn rand(co: vec2<f32>, seed: f32) -> f32
|
|
|
7273
7273
|
let dt: f32 = dot(co + seed, vec2<f32>(a, b));
|
|
7274
7274
|
let sn: f32 = modulo(dt, 3.14159);
|
|
7275
7275
|
return fract(sin(sn) * c + seed);
|
|
7276
|
-
}`;var
|
|
7276
|
+
}`;var R0=Object.defineProperty,M0=(r,e,t)=>e in r?R0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Vp=(r,e,t)=>(M0(r,typeof e!="symbol"?e+"":e,t),t),Gp=class qp extends _{constructor(e){e={...qp.DEFAULT_OPTIONS,...e};let t=e.maxKernelSize??32,n=A.from({vertex:{source:D,entryPoint:"mainVertex"},fragment:{source:Lp.replace("${MAX_KERNEL_SIZE}",t.toFixed(1)),entryPoint:"mainFragment"}}),o=I.from({vertex:z,fragment:Np.replace("${MAX_KERNEL_SIZE}",t.toFixed(1)),name:"zoom-blur-filter"});super({gpuProgram:n,glProgram:o,resources:{zoomBlurUniforms:{uStrength:{value:e.strength,type:"f32"},uCenter:{value:{x:0,y:0},type:"vec2<f32>"},uRadii:{value:new Float32Array(2),type:"vec2<f32>"}}}}),Vp(this,"uniforms"),this.uniforms=this.resources.zoomBlurUniforms.uniforms,Object.assign(this,e)}get strength(){return this.uniforms.uStrength}set strength(e){this.uniforms.uStrength=e}get center(){return this.uniforms.uCenter}set center(e){Array.isArray(e)&&(e={x:e[0],y:e[1]}),this.uniforms.uCenter=e}get centerX(){return this.uniforms.uCenter.x}set centerX(e){this.uniforms.uCenter.x=e}get centerY(){return this.uniforms.uCenter.y}set centerY(e){this.uniforms.uCenter.y=e}get innerRadius(){return this.uniforms.uRadii[0]}set innerRadius(e){this.uniforms.uRadii[0]=e}get radius(){return this.uniforms.uRadii[1]}set radius(e){this.uniforms.uRadii[1]=e<0||e===1/0?-1:e}};Vp(Gp,"DEFAULT_OPTIONS",{strength:.1,center:{x:0,y:0},innerRadius:0,radius:-1,maxKernelSize:32});var Hp=Gp;var B0={AlphaFilter:zn,BlurFilter:_t,ColorMatrixFilter:Zt,NoiseFilter:ua,...Li};function Wp(r){return B0[r]}var Yp=nd(Xp(),1);var $p=`
|
|
7277
7277
|
in vec2 aPosition;
|
|
7278
7278
|
varying vec2 _uv; // gl-transition
|
|
7279
7279
|
uniform mat3 projectionMatrix;
|
|
@@ -7303,7 +7303,7 @@ fn rand(co: vec2<f32>, seed: f32) -> f32
|
|
|
7303
7303
|
vTextureCoord = filterTextureCoord();
|
|
7304
7304
|
_uv = vec2(0.5, 0.5) * (aPosition +vec2(1.0, 1.0)); // gl-transition
|
|
7305
7305
|
}
|
|
7306
|
-
`;var Ba={custom:r=>Object.fromEntries(Object.entries(r.defaultParams).map(([e,t])=>[e,{value:t,type:
|
|
7306
|
+
`;var Ba={custom:r=>Object.fromEntries(Object.entries(r.defaultParams).map(([e,t])=>[e,{value:t,type:U0(r.paramsTypes[e])}])),basics:{_fromR:{value:1,type:"f32"},_toR:{value:1,type:"f32"},ratio:{value:1,type:"f32"},progress:{value:0,type:"f32"},customUniform:{value:0,type:"f32"}}},U0=r=>r==="f32"||r==="i32"?r:r==="float"?"f32":`${r}<f32>`;var Kp=r=>`
|
|
7307
7307
|
precision highp float;
|
|
7308
7308
|
varying vec2 vTextureCoord;
|
|
7309
7309
|
varying vec2 _uv;
|
|
@@ -7326,7 +7326,7 @@ fn rand(co: vec2<f32>, seed: f32) -> f32
|
|
|
7326
7326
|
vec2 uv = vTextureCoord.xy;
|
|
7327
7327
|
gl_FragColor = transition(vTextureCoord);
|
|
7328
7328
|
}
|
|
7329
|
-
`;function Qp({name:r,renderer:e}){let t=Yp.default.find(l=>l.name===r),n=new cr,o=new ae,i=new ur({}),s=new ur({}),a=new _({glProgram:new I({vertex:$p,fragment:Kp(t.glsl)}),resources:{from:i,to:s,uniforms:{...Ba.basics,...Ba.custom(t)}}});return n.filters=[a],{render({width:l,height:c,from:f,to:u,progress:m}){return(n.width!==l||n.height!==c)&&(n.setSize({width:l,height:c}),o.source.resize(l,c)),i.resource=f,s.resource=u,i.update(),s.update(),a.resources.uniforms.uniforms.progress=m,e.render({container:n,target:o,clear:!1,width:l,height:c}),o}}}var Vi=class{pixi;onPointerDown=Ee();onPointerMove=Ee();onPointerUp=Ee();onDispose=Ee();static async setup(){let e=await sa({width:1920,height:1080,preference:"webgl",background:"black",preferWebGLVersion:2}),t=new $i;return t.interactive=!0,new this({renderer:e,stage:t})}constructor(e){this.pixi=e}#e=new Map;#t=new Map;#r=new WeakMap;async composite(e){let{stage:t,renderer:n}=this.pixi;this.#p(this.#m(e));let{dispose:o}=await this.#n(e,t);n.render(t);let i=new VideoFrame(n.canvas,{timestamp:0,duration:0});return o(),i}getActiveObject(e){return this.#t.get(e)?.sprite}async#n(e,t){if(Array.isArray(e)){let n=[];for(let o of[...e].reverse()){let i=await this.#n(o,t);n.push(i.dispose)}return{dispose:()=>n.forEach(o=>o())}}switch(e.kind){case"text":return this.#o(e,t);case"image":return this.#i(e,t);case"transition":return this.#s(e,t);case"gap":return this.pixi?.renderer.clear(),{dispose:()=>{}};default:return console.warn("Unknown layer kind",e.kind),{dispose:()=>{}}}}#o(e,t){let n=this.#f(e);return this.#a(n,e.matrix),this.#l(n,e.alpha),this.#c(n,e.crop),this.#u(n,e.filters),t.addChild(n),{dispose:()=>{}}}#i(e,t){let n=this.#f(e);n.texture&&n.texture!==ae.EMPTY&&n.texture.destroy(!0);let o=ae.from(e.frame);return n.texture=o,this.#a(n,e.matrix),this.#l(n,e.alpha),this.#c(n,e.crop),this.#u(n,e.filters),t.addChild(n),{dispose:()=>{e.frame.close()}}}#s({from:e,to:t,progress:n,name:o},i){let a=(this.#e.get(o)??(this.#e.set(o,Qp({name:"circle",renderer:this.pixi.renderer})),this.#e.get(o))).render({from:e,to:t,progress:n,width:e.displayWidth,height:e.displayHeight}),l=new cr(a);return i.addChild(l),{dispose:()=>l.destroy(!1)}}#a(e,t){if(!t)return;let n=Xc(t);e.setFromMatrix(n)}#l(e,t){e.alpha=t??1}#c(e,t){let n=this.#r.get(e);if(n&&(e.mask===n&&(e.mask=null),n.removeFromParent(),n.clear()),!t||t.every(g=>g===0))return;let[o,i,s,a]=t,l=e.mask;e.mask=null;let c=e.getLocalBounds();e.mask=l;let f=c.x+c.width*a,u=c.y+c.height*o,m=c.width*Math.max(0,1-a-i),p=c.height*Math.max(0,1-o-s),d=n??new Yi;d.clear(),d.beginFill(16777215),d.drawRect(f,u,m,p),d.endFill(),e.addChild(d),e.mask=d,this.#r.set(e,d)}#u(e,t){if(!t?.length){e.filters=null;return}e.filters=t.map(n=>{switch(n.type){case"ColorMatrixFilter":{let{matrix:o,...i}=n.params??{},s=new Zt(i);return o&&(s.matrix=o),s}case"EmbossFilter":return new Xr(n.params?.strength);case"PixelateFilter":return new Kr(n.params?.size);default:{let o=Wp(n.type);return o?new o(n.params):void 0}}}).filter(n=>!!n)}#f(e){let t=this.#t.get(e.id);if(t)return t.sprite;switch(e.kind){case"text":{let n=new Dn({text:e.content,style:e.style});n.eventMode="static";let o=a=>this.onPointerDown.publish({event:a,id:e.id,object:n}),i=a=>this.onPointerUp.publish({event:a,id:e.id,object:n}),s=a=>this.onPointerUp.publish({event:a,id:e.id,object:n});return n.on("pointerdown",o),n.on("pointerup",i),n.on("pointermove",s),this.#t.set(e.id,{sprite:n,dispose:()=>{this.onDispose.publish({id:e.id,object:n}),n.off("pointermove",s),n.off("pointerdown",o),n.off("pointerup",i)}}).get(e.id)?.sprite}case"image":{let n=new cr;n.eventMode="static";let o=a=>this.onPointerDown.publish({event:a,id:e.id,object:n}),i=a=>this.onPointerUp.publish({event:a,id:e.id,object:n}),s=a=>this.onPointerUp.publish({event:a,id:e.id,object:n});return n.on("pointerdown",o),n.on("pointermove",s),n.on("pointerup",i),this.#t.set(e.id,{sprite:n,dispose:()=>{this.onDispose.publish({id:e.id,object:n}),n.off("pointerdown",o),n.off("pointermove",s),n.off("pointerup",i)}}).get(e.id)?.sprite}}}#m(e){let t=new Set,n=o=>{if(Array.isArray(o))for(let i of o)n(i);else t.add(o.id)};return n(e),t}#p(e){for(let t of this.#t.keys())if(!e.has(t)){let{sprite:n,dispose:o}=this.#t.get(t);o(),n.destroy(!0),this.#t.delete(t)}}};var Zp=r=>ki.host(e=>({async world(){r.count++}}));var Et=class{machina;thread;compositor;static async setup(e){let t=new Pi,n=await ki.thread({label:"OmnitoolDriver",workerUrl:e?.workerUrl??"/node_modules/@omnimedia/omnitool/x/driver/driver.worker.bundle.min.js",setupHost:Zp(t)}),o=await Vi.setup();return new this(t,n,o)}constructor(e,t,n){this.machina=e,this.thread=t,this.compositor=n}async hello(){return this.thread.work.hello()}async getAudioDuration(e){let n=await new Pe({source:await $e(e),formats:Be}).getPrimaryAudioTrack();if(!n)throw new Error("primary audio track not found");return await n.computeDuration()}async getVideoDuration(e){return await(await new Pe({source:await $e(e),formats:Be}).getPrimaryVideoTrack())?.computeDuration()}decodeVideo(e){let t=null,{port1:n,port2:o}=new MessageChannel,i=new TransformStream({async transform(s,a){let l=await e.onFrame?.(s)??s;t?.close(),a.enqueue(l),t=l}});return this.thread.work.decodeVideo[Nr]({transfer:[i.writable,o]})({source:e.source,cancel:o,video:i.writable,start:e.start,end:e.end}),{readable:i.readable,cancel(){n.postMessage("close"),n.close()}}}decodeAudio(e){let t=new TransformStream,{port1:n,port2:o}=new MessageChannel;return this.thread.work.decodeAudio[Nr]({transfer:[t.writable,o]})({source:e.source,cancel:o,audio:t.writable,start:e.start,end:e.end}),{readable:t.readable,cancel(){n.postMessage("close"),n.close()}}}encode({audio:e,video:t,config:n}){let{readable:o,writable:i}=new TransformStream,s=[e,t,i].filter(Jn.happy),a=this.thread.work.encode[Nr]({transfer:s})({audio:e,video:t,config:n,writable:i});return{readable:o,done:a}}async composite(e){return await this.compositor.composite(e)}};var Gi=class{data;bytes;hash;nickname;constructor(e,t,n,o){this.data=e,this.bytes=t,this.hash=n,this.nickname=o}static async make(e){let t=new Uint8Array(e),n=new Uint8Array(await crypto.subtle.digest("SHA-256",t)),o=Zn.fromBytes(n),i=Ja.sigil.fromBytes(n);return new this(e,n,o,i)}};var zt=class{url;bytes;blob;filename;checksum;constructor(e,t,n,o,i){this.url=e,this.bytes=t,this.blob=n,this.filename=o,this.checksum=i}static async make(e,t){let n=await e.arrayBuffer(),o=new Uint8Array(n),i=await Gi.make(o),s=t??i.nickname,a=URL.createObjectURL(e);return new this(a,o,e,s,i)}static async load(e){}};async function Qr(r){return fetch(r).then(e=>e.blob())}var Jp=new URL("../driver/driver.worker.bundle.min.js",import.meta.url);async function _e(){let r=await Et.setup({workerUrl:Jp}),e=new At(r),t=await Qr("/assets/temp/test.mp4"),{videoA:n}=await e.load({videoA:zt.make(t,"test.mp4")});return{driver:r,omni:e,testVideo:t,videoA:n}}var ed=gt.suite({"basic demo":async()=>{let r=await Et.setup({workerUrl:new URL("../driver/driver.worker.bundle.min.js",import.meta.url)}),e=new At(r),t=await Qr("/assets/temp/test.mp4"),{videoA:n}=await e.load({videoA:zt.make(t,"test.mp4")}),o=new re({timeline:e.timeline(c=>c.sequence())}),i=o.require(o.timeline.rootId),s=o.video(n);o.addChildren(i,s);let a=ee(s.id,o.timeline),l=ee(o.timeline.rootId,o.timeline);P(a).is(l)},"sequence duration is 3x":async()=>{let{omni:r,videoA:e}=await _e(),t=new re({timeline:r.timeline(o=>o.sequence(o.video(e),o.video(e),o.video(e)))}),n=ee(t.timeline.rootId,t.timeline);P(n).is(e.duration*3)},"stack duration is 1x":async()=>{let{omni:r,videoA:e}=await _e(),t=new re({timeline:r.timeline(o=>o.stack(o.video(e),o.video(e),o.video(e)))}),n=ee(t.timeline.rootId,t.timeline);P(n).is(e.duration)},"nested stack inside sequence":async()=>{let{omni:r,videoA:e}=await _e(),t=new re({timeline:r.timeline(o=>o.sequence(o.video(e),o.stack(o.video(e),o.video(e)),o.video(e)))}),n=ee(t.timeline.rootId,t.timeline);P(n).is(e.duration*3)},"nested sequence inside stack":async()=>{let{omni:r,videoA:e}=await _e(),t=new re({timeline:r.timeline(o=>o.stack(o.video(e),o.sequence(o.video(e),o.video(e))))}),n=ee(t.timeline.rootId,t.timeline);P(n).is(e.duration*2)},"empty timeline duration is 0":async()=>{let{omni:r}=await _e(),e=new re({timeline:r.timeline(i=>i.sequence())}),t=new re({timeline:r.timeline(i=>i.stack())}),n=ee(e.timeline.rootId,e.timeline),o=ee(t.timeline.rootId,t.timeline);P(n).is(0),P(o).is(0)},"transition in a sequence":async()=>{let{omni:r,videoA:e}=await _e(),t=1e3,n=new re({timeline:r.timeline(s=>s.sequence(s.video(e),s.transition.crossfade(t),s.video(e)))}),o=ee(n.timeline.rootId,n.timeline),i=e.duration*2-t;P(o).is(i)},"transition in a stack":async()=>{let{omni:r,videoA:e}=await _e(),t=1e3,n=new re({timeline:r.timeline(i=>i.stack(i.video(e),i.transition.crossfade(t),i.video(e)))}),o=ee(n.timeline.rootId,n.timeline);P(o).is(e.duration)},"ignore invalid transition":async()=>{let{omni:r,videoA:e}=await _e(),t=new re({timeline:r.timeline(o=>o.sequence(o.transition.crossfade(1e3),o.video(e),o.video(e),o.transition.crossfade(1e3)))}),n=ee(t.timeline.rootId,t.timeline);P(n).is(e.duration*2)},"clamp transition duration on overflow":async()=>{let{omni:r,videoA:e}=await _e(),t=3e3,n=new re({timeline:r.timeline(i=>i.sequence(i.video(e,{duration:t}),i.transition.crossfade(t*2),i.video(e,{duration:t})))}),o=ee(n.timeline.rootId,n.timeline);P(o).is(t)},"multiple transitions":async()=>{let{omni:r,videoA:e}=await _e(),t=1e3,n=new re({timeline:r.timeline(s=>s.sequence(s.video(e),s.transition.crossfade(t),s.video(e),s.transition.crossfade(t),s.video(e)))}),o=ee(n.timeline.rootId,n.timeline),i=e.duration*3-t*2;P(o).is(i)},"gap item in a sequence":async()=>{let{omni:r,videoA:e}=await _e(),t=1e3,n=new re({timeline:r.timeline(s=>s.sequence(s.video(e),s.gap(t),s.video(e)))}),o=ee(n.timeline.rootId,n.timeline),i=e.duration*2+t;P(o).is(i)},"gap item in a stack":async()=>{let{omni:r,videoA:e}=await _e(),t=new re({timeline:r.timeline(o=>o.stack(o.video(e),o.gap(1e3),o.video(e)))}),n=ee(t.timeline.rootId,t.timeline);P(n).is(e.duration)},"load media into Omni":async()=>{let r=await Et.setup({workerUrl:Jp}),e=new At(r),t=await Qr("/assets/temp/test.mp4"),{videoA:n}=await e.load({videoA:zt.make(t,"test.mp4")});P(e.resources.require(n.datafile.checksum.hash)).happy()},"playback seeks to correct time":async()=>{let{omni:r,videoA:e}=await _e(),t=new re({timeline:r.timeline(o=>o.sequence(o.video(e,{duration:2e3}),o.gap(500),o.video(e,{duration:2500})))}),n=await r.playback(t.timeline);await n.seek(1e3),P(n.currentTime).is(1e3)}});var U0=new URL("../driver/driver.worker.bundle.min.js",import.meta.url);async function qi(){let r=await Et.setup({workerUrl:U0}),e=new At(r),t=await Qr("/assets/temp/test.mp4"),{videoA:n}=await e.load({videoA:zt.make(t,"test.mp4")});return{driver:r,omni:e,testVideo:t,videoA:n,resolveMedia:i=>e.resources.require(i).blob}}async function Gn(r){let e=[];for await(let t of r)e.push(t);return e}var de=(r,e,t=1e-6)=>Math.abs(r-e)<t,td=gt.suite({"empty transform animation tracks resolve to identity transform defaults":async()=>{let r=ma(X(100),{terp:"linear",track:{position:{x:[],y:[]},scale:{x:[],y:[]},rotation:[]}});P(r[0][0]).is(0),P(r[0][1]).is(0),P(r[1][0]).is(1),P(r[1][1]).is(1),P(r[2]).is(0)},"cursor visual sampler cannot get previous samples":async()=>{let{omni:r,videoA:e,resolveMedia:t,driver:n}=await qi(),{timeline:o}=new re({timeline:r.timeline(s=>s.sequence(s.video(e,{duration:2e3}),s.gap(500),s.video(e,{duration:2e3}),s.audio(e,{duration:500})))}),i=new It(n,t,o);await i.next(X(1e3)),await P(async()=>await i.next(X(100))).throwsAsync()},"visual sampler gives correct layer at x time":async()=>{let{omni:r,videoA:e,resolveMedia:t}=await qi(),{timeline:n}=new re({timeline:r.timeline(c=>c.sequence(c.video(e,{duration:2e3}),c.gap(500),c.video(e,{duration:2e3}),c.audio(e,{duration:500}),c.text("123",{duration:1e3})))}),o=Mr(t),i=await o.sample(n,X(1e3));P(i[0].kind).is("image");let s=await o.sample(n,X(2300));P(s[0].kind).is("gap");let a=await o.sample(n,X(2700));P(a[0].kind).is("image");let l=await o.sample(n,X(5500));P(l[0].kind).is("text")},"audio mix sums overlapping chunks":async()=>{let r=new Ke({chunkFrames:4,clamp:!1});async function*e(){yield{planes:[new Float32Array([.25,.25,.25,.25])],sampleRate:4,timestamp:0},yield{planes:[new Float32Array([.5,.5,.5,.5])],sampleRate:4,timestamp:.5}}let t=await Gn(r.mix(e()));P(t.length).is(2),P(t[0].startFrame).is(0),P(t[0].frames).is(4),P(t[0].channels).is(1),P(t[0].planar[0]).is(.25),P(t[0].planar[1]).is(.25),P(t[0].planar[2]).is(.75),P(t[0].planar[3]).is(.75),P(t[1].startFrame).is(4),P(t[1].planar[0]).is(.5),P(t[1].planar[1]).is(.5),P(t[1].planar[2]).is(0),P(t[1].planar[3]).is(0)},"audio mix clamps output to [-1, 1]":async()=>{let r=new Ke({chunkFrames:4,clamp:!0});async function*e(){yield{planes:[new Float32Array([.9,.9,.9,.9])],sampleRate:4,timestamp:0},yield{planes:[new Float32Array([.8,.8,.8,.8])],sampleRate:4,timestamp:0}}let t=await Gn(r.mix(e()));P(t.length).is(1),P(t[0].planar[0]).is(1),P(t[0].planar[1]).is(1),P(t[0].planar[2]).is(1),P(t[0].planar[3]).is(1)},"audio mix fills gaps with silence":async()=>{let r=new Ke({chunkFrames:4,clamp:!1});async function*e(){yield{planes:[new Float32Array([1,1,1,1])],sampleRate:4,timestamp:0},yield{planes:[new Float32Array([2,2,2,2])],sampleRate:4,timestamp:2}}let t=await Gn(r.mix(e()));P(t.length).is(3),P(t[0].startFrame).is(0),P(t[0].planar[0]).is(1),P(t[1].startFrame).is(4),P(t[1].planar[0]).is(0),P(t[1].planar[3]).is(0),P(t[2].startFrame).is(8),P(t[2].planar[0]).is(2)},"audio mix truncates negative timestamps":async()=>{let r=new Ke({chunkFrames:4,clamp:!1});async function*e(){yield{planes:[new Float32Array([1,2,3,4])],sampleRate:4,timestamp:-.5}}let t=await Gn(r.mix(e()));P(t.length).is(1),P(t[0].startFrame).is(0),P(t[0].planar[0]).is(3),P(t[0].planar[1]).is(4),P(t[0].planar[2]).is(0),P(t[0].planar[3]).is(0)},"audio mix handles stereo planar layout":async()=>{let r=new Ke({chunkFrames:4,clamp:!1});async function*e(){yield{planes:[new Float32Array([1,1,1,1]),new Float32Array([2,2,2,2])],sampleRate:4,timestamp:0}}let t=await Gn(r.mix(e()));P(t.length).is(1),P(t[0].channels).is(2),P(t[0].planar.length).is(8),P(t[0].planar[0]).is(1),P(t[0].planar[4]).is(2)},"applyGainToPlanar scales values across multiple channels":async()=>{let r=[new Float32Array([.2,-.4]),new Float32Array([.6,-.8])];Br(r,.5),P(de(r[0][0],.1)).ok(),P(de(r[0][1],-.2)).ok(),P(de(r[1][0],.3)).ok(),P(de(r[1][1],-.4)).ok()},"applyGainToPlanar does not mutate when gain is 1":async()=>{let r=[new Float32Array([.5,-.5])];Br(r,1),P(de(r[0][0],.5)).ok(),P(de(r[0][1],-.5)).ok()},"applyGainToPlanar mutes entirely when gain is 0":async()=>{let r=[new Float32Array([.9,-.9])];Br(r,0),P(r[0][0]).is(0),P(r[0][1]).is(0)},"resampleToPlanar returns original data when sample rates match":async()=>{let e=Ye({numberOfFrames:3,numberOfChannels:1,sampleRate:48e3,copyTo:t=>t.set([.1,.2,.3])},48e3);P(e.frames).is(3),P(e.data.length).is(1),P(de(e.data[0][0],.1)).ok(),P(de(e.data[0][1],.2)).ok(),P(de(e.data[0][2],.3)).ok()},"resampleToPlanar upsamples using linear interpolation":async()=>{let e=Ye({numberOfFrames:2,numberOfChannels:1,sampleRate:1,copyTo:t=>t.set([10,20])},2);P(e.frames).is(4),P(de(e.data[0][0],10)).ok(),P(de(e.data[0][1],15)).ok(),P(de(e.data[0][2],20)).ok(),P(de(e.data[0][3],20)).ok()},"resampleToPlanar downsamples correctly":async()=>{let e=Ye({numberOfFrames:4,numberOfChannels:1,sampleRate:4,copyTo:t=>t.set([1,2,3,4])},2);P(e.frames).is(2),P(de(e.data[0][0],1)).ok(),P(de(e.data[0][1],3)).ok()},"resampleToPlanar processes multi-channel planar data":async()=>{let r=[new Float32Array([1,2]),new Float32Array([3,4])],t=Ye({numberOfFrames:2,numberOfChannels:2,sampleRate:1,copyTo:(n,o)=>{n.set(r[o.planeIndex])}},2);P(t.data.length).is(2),P(de(t.data[0][1],1.5)).ok(),P(de(t.data[1][1],3.5)).ok()},"resampleToPlanar handles zero channels gracefully":async()=>{let e=Ye({numberOfFrames:10,numberOfChannels:0,sampleRate:48e3,copyTo:()=>{throw new Error("Should not be called")}},44100);P(e.data.length).is(0),P(e.frames).is(0)},"resampleToPlanar enforces minimum of 1 frame on aggressive downsample":async()=>{let e=Ye({numberOfFrames:1,numberOfChannels:1,sampleRate:48e3,copyTo:t=>t.set([.8])},8e3);P(e.frames).is(1),P(e.data[0].length).is(1),P(de(e.data[0][0],.8)).ok()},"resampleToPlanar calls copyTo with strict contract shape":async()=>{let r=null;Ye({numberOfFrames:2,numberOfChannels:1,sampleRate:48e3,copyTo:(t,n)=>{r=n}},44100),P(r).not.is(null),P(r.planeIndex).is(0),P(r.format).is("f32-planar")},"5s long export at 30fps renders exacly 150 frames":async()=>{let{omni:r,videoA:e,driver:t,resolveMedia:n}=await qi(),{timeline:o}=new re({timeline:r.timeline(a=>a.sequence(a.video(e,{duration:2e3}),a.gap(500),a.video(e,{duration:2e3}),a.audio(e,{duration:500})))}),i=fi({timeline:o,fps:xt(30),driver:t,resolveMedia:n}),s=0;for await(let a of i)a.close(),s++;P(s).is(150)},"5s long audio export at 48000Hz renders exactly 240000 frames":async()=>{let{omni:r,videoA:e,resolveMedia:t}=await qi(),{timeline:n}=new re({timeline:r.timeline(s=>s.sequence(s.video(e,{duration:2e3}),s.gap(500),s.video(e,{duration:2e3}),s.audio(e,{duration:500})))}),o=ui({timeline:n,resolveMedia:t}),i=0;for await(let s of o)i+=s.numberOfFrames,s.close();P(i).is(24e4)}});await gt.run({omniTest:ed,renderersTest:td});
|
|
7329
|
+
`;function Qp({name:r,renderer:e}){let t=Yp.default.find(l=>l.name===r),n=new cr,o=new ae,i=new ur({}),s=new ur({}),a=new _({glProgram:new I({vertex:$p,fragment:Kp(t.glsl)}),resources:{from:i,to:s,uniforms:{...Ba.basics,...Ba.custom(t)}}});return n.filters=[a],{render({width:l,height:c,from:f,to:u,progress:m}){return(n.width!==l||n.height!==c)&&(n.setSize({width:l,height:c}),o.source.resize(l,c)),i.resource=f,s.resource=u,i.update(),s.update(),a.resources.uniforms.uniforms.progress=m,e.render({container:n,target:o,clear:!1,width:l,height:c}),o}}}var Vi=class{pixi;onPointerDown=Ee();onPointerMove=Ee();onPointerUp=Ee();onDispose=Ee();static async setup(){let e=await sa({width:1920,height:1080,preference:"webgl",background:"black",preferWebGLVersion:2}),t=new $i;return t.interactive=!0,new this({renderer:e,stage:t})}constructor(e){this.pixi=e}#e=new Map;#t=new Map;#r=new WeakMap;async composite(e){let{stage:t,renderer:n}=this.pixi;this.#p(this.#m(e));let{dispose:o}=await this.#n(e,t);n.render(t);let i=new VideoFrame(n.canvas,{timestamp:0,duration:0});return o(),i}getActiveObject(e){return this.#t.get(e)?.sprite}async#n(e,t){if(Array.isArray(e)){let n=[];for(let o of[...e].reverse()){let i=await this.#n(o,t);n.push(i.dispose)}return{dispose:()=>n.forEach(o=>o())}}switch(e.kind){case"text":return this.#o(e,t);case"image":return this.#i(e,t);case"transition":return this.#s(e,t);case"gap":return this.pixi?.renderer.clear(),{dispose:()=>{}};default:return console.warn("Unknown layer kind",e.kind),{dispose:()=>{}}}}#o(e,t){let n=this.#f(e);return this.#a(n,e.matrix),this.#l(n,e.alpha),this.#c(n,e.crop),this.#u(n,e.filters),t.addChild(n),{dispose:()=>{}}}#i(e,t){let n=this.#f(e);n.texture&&n.texture!==ae.EMPTY&&n.texture.destroy(!0);let o=ae.from(e.frame);return n.texture=o,this.#a(n,e.matrix),this.#l(n,e.alpha),this.#c(n,e.crop),this.#u(n,e.filters),t.addChild(n),{dispose:()=>{e.frame.close()}}}#s({from:e,to:t,progress:n,name:o},i){let a=(this.#e.get(o)??(this.#e.set(o,Qp({name:"circle",renderer:this.pixi.renderer})),this.#e.get(o))).render({from:e,to:t,progress:n,width:e.displayWidth,height:e.displayHeight}),l=new cr(a);return i.addChild(l),{dispose:()=>l.destroy(!1)}}#a(e,t){if(!t)return;let n=Xc(t);e.setFromMatrix(n)}#l(e,t){e.alpha=t??1}#c(e,t){let n=this.#r.get(e);if(n&&(e.mask===n&&(e.mask=null),n.removeFromParent(),n.clear()),!t||t.every(g=>g===0))return;let[o,i,s,a]=t,l=e.mask;e.mask=null;let c=e.getLocalBounds();e.mask=l;let f=c.x+c.width*a,u=c.y+c.height*o,m=c.width*Math.max(0,1-a-i),p=c.height*Math.max(0,1-o-s),d=n??new Yi;d.clear(),d.beginFill(16777215),d.drawRect(f,u,m,p),d.endFill(),e.addChild(d),e.mask=d,this.#r.set(e,d)}#u(e,t){if(!t?.length){e.filters=null;return}e.filters=t.map(n=>{switch(n.type){case"ColorMatrixFilter":{let{matrix:o,...i}=n.params??{},s=new Zt(i);return o&&(s.matrix=o),s}case"EmbossFilter":return new Xr(n.params?.strength);case"PixelateFilter":return new Kr(n.params?.size);default:{let o=Wp(n.type);return o?new o(n.params):void 0}}}).filter(n=>!!n)}#f(e){let t=this.#t.get(e.id);if(t)return t.sprite;switch(e.kind){case"text":{let n=new Dn({text:e.content,style:e.style});n.eventMode="static";let o=a=>this.onPointerDown.publish({event:a,id:e.id,object:n}),i=a=>this.onPointerUp.publish({event:a,id:e.id,object:n}),s=a=>this.onPointerUp.publish({event:a,id:e.id,object:n});return n.on("pointerdown",o),n.on("pointerup",i),n.on("pointermove",s),this.#t.set(e.id,{sprite:n,dispose:()=>{this.onDispose.publish({id:e.id,object:n}),n.off("pointermove",s),n.off("pointerdown",o),n.off("pointerup",i)}}).get(e.id)?.sprite}case"image":{let n=new cr;n.eventMode="static";let o=a=>this.onPointerDown.publish({event:a,id:e.id,object:n}),i=a=>this.onPointerUp.publish({event:a,id:e.id,object:n}),s=a=>this.onPointerUp.publish({event:a,id:e.id,object:n});return n.on("pointerdown",o),n.on("pointermove",s),n.on("pointerup",i),this.#t.set(e.id,{sprite:n,dispose:()=>{this.onDispose.publish({id:e.id,object:n}),n.off("pointerdown",o),n.off("pointermove",s),n.off("pointerup",i)}}).get(e.id)?.sprite}}}#m(e){let t=new Set,n=o=>{if(Array.isArray(o))for(let i of o)n(i);else t.add(o.id)};return n(e),t}#p(e){for(let t of this.#t.keys())if(!e.has(t)){let{sprite:n,dispose:o}=this.#t.get(t);o(),n.destroy(!0),this.#t.delete(t)}}};var Zp=r=>ki.host(e=>({async world(){r.count++}}));var Et=class{machina;thread;compositor;static async setup(e){let t=new Pi,n=await ki.thread({label:"OmnitoolDriver",workerUrl:e?.workerUrl??"/node_modules/@omnimedia/omnitool/x/driver/driver.worker.bundle.min.js",setupHost:Zp(t)}),o=await Vi.setup();return new this(t,n,o)}constructor(e,t,n){this.machina=e,this.thread=t,this.compositor=n}async hello(){return this.thread.work.hello()}async getAudioDuration(e){let n=await new Pe({source:await $e(e),formats:Be}).getPrimaryAudioTrack();if(!n)throw new Error("primary audio track not found");return await n.computeDuration()}async getVideoDuration(e){return await(await new Pe({source:await $e(e),formats:Be}).getPrimaryVideoTrack())?.computeDuration()}decodeVideo(e){let t=null,{port1:n,port2:o}=new MessageChannel,i=new TransformStream({async transform(s,a){let l=await e.onFrame?.(s)??s;t?.close(),a.enqueue(l),t=l}});return this.thread.work.decodeVideo[Nr]({transfer:[i.writable,o]})({source:e.source,cancel:o,video:i.writable,start:e.start,end:e.end}),{readable:i.readable,cancel(){n.postMessage("close"),n.close()}}}decodeAudio(e){let t=new TransformStream,{port1:n,port2:o}=new MessageChannel;return this.thread.work.decodeAudio[Nr]({transfer:[t.writable,o]})({source:e.source,cancel:o,audio:t.writable,start:e.start,end:e.end}),{readable:t.readable,cancel(){n.postMessage("close"),n.close()}}}encode({audio:e,video:t,config:n}){let{readable:o,writable:i}=new TransformStream,s=[e,t,i].filter(Jn.happy),a=this.thread.work.encode[Nr]({transfer:s})({audio:e,video:t,config:n,writable:i});return{readable:o,done:a}}async composite(e){return await this.compositor.composite(e)}};var Gi=class{data;bytes;hash;nickname;constructor(e,t,n,o){this.data=e,this.bytes=t,this.hash=n,this.nickname=o}static async make(e){let t=new Uint8Array(e),n=new Uint8Array(await crypto.subtle.digest("SHA-256",t)),o=Zn.fromBytes(n),i=Ja.sigil.fromBytes(n);return new this(e,n,o,i)}};var zt=class{url;bytes;blob;filename;checksum;constructor(e,t,n,o,i){this.url=e,this.bytes=t,this.blob=n,this.filename=o,this.checksum=i}static async make(e,t){let n=await e.arrayBuffer(),o=new Uint8Array(n),i=await Gi.make(o),s=t??i.nickname,a=URL.createObjectURL(e);return new this(a,o,e,s,i)}static async load(e){}};async function Qr(r){return fetch(r).then(e=>e.blob())}var Jp=new URL("../driver/driver.worker.bundle.min.js",import.meta.url);async function _e(){let r=await Et.setup({workerUrl:Jp}),e=new At(r),t=await Qr("/assets/temp/test.mp4"),{videoA:n}=await e.load({videoA:zt.make(t,"test.mp4")});return{driver:r,omni:e,testVideo:t,videoA:n}}var ed=gt.suite({"basic demo":async()=>{let r=await Et.setup({workerUrl:new URL("../driver/driver.worker.bundle.min.js",import.meta.url)}),e=new At(r),t=await Qr("/assets/temp/test.mp4"),{videoA:n}=await e.load({videoA:zt.make(t,"test.mp4")}),o=new re({timeline:e.timeline(c=>c.sequence())}),i=o.require(o.timeline.rootId),s=o.video(n);o.addChildren(i,s);let a=ee(s.id,o.timeline),l=ee(o.timeline.rootId,o.timeline);P(a).is(l)},"sequence duration is 3x":async()=>{let{omni:r,videoA:e}=await _e(),t=new re({timeline:r.timeline(o=>o.sequence(o.video(e),o.video(e),o.video(e)))}),n=ee(t.timeline.rootId,t.timeline);P(n).is(e.duration*3)},"stack duration is 1x":async()=>{let{omni:r,videoA:e}=await _e(),t=new re({timeline:r.timeline(o=>o.stack(o.video(e),o.video(e),o.video(e)))}),n=ee(t.timeline.rootId,t.timeline);P(n).is(e.duration)},"nested stack inside sequence":async()=>{let{omni:r,videoA:e}=await _e(),t=new re({timeline:r.timeline(o=>o.sequence(o.video(e),o.stack(o.video(e),o.video(e)),o.video(e)))}),n=ee(t.timeline.rootId,t.timeline);P(n).is(e.duration*3)},"nested sequence inside stack":async()=>{let{omni:r,videoA:e}=await _e(),t=new re({timeline:r.timeline(o=>o.stack(o.video(e),o.sequence(o.video(e),o.video(e))))}),n=ee(t.timeline.rootId,t.timeline);P(n).is(e.duration*2)},"empty timeline duration is 0":async()=>{let{omni:r}=await _e(),e=new re({timeline:r.timeline(i=>i.sequence())}),t=new re({timeline:r.timeline(i=>i.stack())}),n=ee(e.timeline.rootId,e.timeline),o=ee(t.timeline.rootId,t.timeline);P(n).is(0),P(o).is(0)},"transition in a sequence":async()=>{let{omni:r,videoA:e}=await _e(),t=1e3,n=new re({timeline:r.timeline(s=>s.sequence(s.video(e),s.transition.crossfade(t),s.video(e)))}),o=ee(n.timeline.rootId,n.timeline),i=e.duration*2-t;P(o).is(i)},"transition in a stack":async()=>{let{omni:r,videoA:e}=await _e(),t=1e3,n=new re({timeline:r.timeline(i=>i.stack(i.video(e),i.transition.crossfade(t),i.video(e)))}),o=ee(n.timeline.rootId,n.timeline);P(o).is(e.duration)},"ignore invalid transition":async()=>{let{omni:r,videoA:e}=await _e(),t=new re({timeline:r.timeline(o=>o.sequence(o.transition.crossfade(1e3),o.video(e),o.video(e),o.transition.crossfade(1e3)))}),n=ee(t.timeline.rootId,t.timeline);P(n).is(e.duration*2)},"clamp transition duration on overflow":async()=>{let{omni:r,videoA:e}=await _e(),t=3e3,n=new re({timeline:r.timeline(i=>i.sequence(i.video(e,{duration:t}),i.transition.crossfade(t*2),i.video(e,{duration:t})))}),o=ee(n.timeline.rootId,n.timeline);P(o).is(t)},"multiple transitions":async()=>{let{omni:r,videoA:e}=await _e(),t=1e3,n=new re({timeline:r.timeline(s=>s.sequence(s.video(e),s.transition.crossfade(t),s.video(e),s.transition.crossfade(t),s.video(e)))}),o=ee(n.timeline.rootId,n.timeline),i=e.duration*3-t*2;P(o).is(i)},"gap item in a sequence":async()=>{let{omni:r,videoA:e}=await _e(),t=1e3,n=new re({timeline:r.timeline(s=>s.sequence(s.video(e),s.gap(t),s.video(e)))}),o=ee(n.timeline.rootId,n.timeline),i=e.duration*2+t;P(o).is(i)},"gap item in a stack":async()=>{let{omni:r,videoA:e}=await _e(),t=new re({timeline:r.timeline(o=>o.stack(o.video(e),o.gap(1e3),o.video(e)))}),n=ee(t.timeline.rootId,t.timeline);P(n).is(e.duration)},"load media into Omni":async()=>{let r=await Et.setup({workerUrl:Jp}),e=new At(r),t=await Qr("/assets/temp/test.mp4"),{videoA:n}=await e.load({videoA:zt.make(t,"test.mp4")});P(e.resources.require(n.datafile.checksum.hash)).happy()},"playback seeks to correct time":async()=>{let{omni:r,videoA:e}=await _e(),t=new re({timeline:r.timeline(o=>o.sequence(o.video(e,{duration:2e3}),o.gap(500),o.video(e,{duration:2500})))}),n=await r.playback(t.timeline);await n.seek(1e3),P(n.currentTime).is(1e3)}});var N0=new URL("../driver/driver.worker.bundle.min.js",import.meta.url);async function qi(){let r=await Et.setup({workerUrl:N0}),e=new At(r),t=await Qr("/assets/temp/test.mp4"),{videoA:n}=await e.load({videoA:zt.make(t,"test.mp4")});return{driver:r,omni:e,testVideo:t,videoA:n,resolveMedia:i=>e.resources.require(i).blob}}async function Gn(r){let e=[];for await(let t of r)e.push(t);return e}var de=(r,e,t=1e-6)=>Math.abs(r-e)<t,td=gt.suite({"empty transform animation tracks resolve to identity transform defaults":async()=>{let r=ma(X(100),{terp:"linear",track:{position:{x:[],y:[]},scale:{x:[],y:[]},rotation:[]}});P(r[0][0]).is(0),P(r[0][1]).is(0),P(r[1][0]).is(1),P(r[1][1]).is(1),P(r[2]).is(0)},"cursor visual sampler cannot get previous samples":async()=>{let{omni:r,videoA:e,resolveMedia:t,driver:n}=await qi(),{timeline:o}=new re({timeline:r.timeline(s=>s.sequence(s.video(e,{duration:2e3}),s.gap(500),s.video(e,{duration:2e3}),s.audio(e,{duration:500})))}),i=new It(n,t,o);await i.next(X(1e3)),await P(async()=>await i.next(X(100))).throwsAsync()},"visual sampler gives correct layer at x time":async()=>{let{omni:r,videoA:e,resolveMedia:t}=await qi(),{timeline:n}=new re({timeline:r.timeline(c=>c.sequence(c.video(e,{duration:2e3}),c.gap(500),c.video(e,{duration:2e3}),c.audio(e,{duration:500}),c.text("123",{duration:1e3})))}),o=Mr(t),i=await o.sample(n,X(1e3));P(i[0].kind).is("image");let s=await o.sample(n,X(2300));P(s[0].kind).is("gap");let a=await o.sample(n,X(2700));P(a[0].kind).is("image");let l=await o.sample(n,X(5500));P(l[0].kind).is("text")},"audio mix sums overlapping chunks":async()=>{let r=new Ke({chunkFrames:4,clamp:!1});async function*e(){yield{planes:[new Float32Array([.25,.25,.25,.25])],sampleRate:4,timestamp:0},yield{planes:[new Float32Array([.5,.5,.5,.5])],sampleRate:4,timestamp:.5}}let t=await Gn(r.mix(e()));P(t.length).is(2),P(t[0].startFrame).is(0),P(t[0].frames).is(4),P(t[0].channels).is(1),P(t[0].planar[0]).is(.25),P(t[0].planar[1]).is(.25),P(t[0].planar[2]).is(.75),P(t[0].planar[3]).is(.75),P(t[1].startFrame).is(4),P(t[1].planar[0]).is(.5),P(t[1].planar[1]).is(.5),P(t[1].planar[2]).is(0),P(t[1].planar[3]).is(0)},"audio mix clamps output to [-1, 1]":async()=>{let r=new Ke({chunkFrames:4,clamp:!0});async function*e(){yield{planes:[new Float32Array([.9,.9,.9,.9])],sampleRate:4,timestamp:0},yield{planes:[new Float32Array([.8,.8,.8,.8])],sampleRate:4,timestamp:0}}let t=await Gn(r.mix(e()));P(t.length).is(1),P(t[0].planar[0]).is(1),P(t[0].planar[1]).is(1),P(t[0].planar[2]).is(1),P(t[0].planar[3]).is(1)},"audio mix fills gaps with silence":async()=>{let r=new Ke({chunkFrames:4,clamp:!1});async function*e(){yield{planes:[new Float32Array([1,1,1,1])],sampleRate:4,timestamp:0},yield{planes:[new Float32Array([2,2,2,2])],sampleRate:4,timestamp:2}}let t=await Gn(r.mix(e()));P(t.length).is(3),P(t[0].startFrame).is(0),P(t[0].planar[0]).is(1),P(t[1].startFrame).is(4),P(t[1].planar[0]).is(0),P(t[1].planar[3]).is(0),P(t[2].startFrame).is(8),P(t[2].planar[0]).is(2)},"audio mix truncates negative timestamps":async()=>{let r=new Ke({chunkFrames:4,clamp:!1});async function*e(){yield{planes:[new Float32Array([1,2,3,4])],sampleRate:4,timestamp:-.5}}let t=await Gn(r.mix(e()));P(t.length).is(1),P(t[0].startFrame).is(0),P(t[0].planar[0]).is(3),P(t[0].planar[1]).is(4),P(t[0].planar[2]).is(0),P(t[0].planar[3]).is(0)},"audio mix handles stereo planar layout":async()=>{let r=new Ke({chunkFrames:4,clamp:!1});async function*e(){yield{planes:[new Float32Array([1,1,1,1]),new Float32Array([2,2,2,2])],sampleRate:4,timestamp:0}}let t=await Gn(r.mix(e()));P(t.length).is(1),P(t[0].channels).is(2),P(t[0].planar.length).is(8),P(t[0].planar[0]).is(1),P(t[0].planar[4]).is(2)},"applyGainToPlanar scales values across multiple channels":async()=>{let r=[new Float32Array([.2,-.4]),new Float32Array([.6,-.8])];Br(r,.5),P(de(r[0][0],.1)).ok(),P(de(r[0][1],-.2)).ok(),P(de(r[1][0],.3)).ok(),P(de(r[1][1],-.4)).ok()},"applyGainToPlanar does not mutate when gain is 1":async()=>{let r=[new Float32Array([.5,-.5])];Br(r,1),P(de(r[0][0],.5)).ok(),P(de(r[0][1],-.5)).ok()},"applyGainToPlanar mutes entirely when gain is 0":async()=>{let r=[new Float32Array([.9,-.9])];Br(r,0),P(r[0][0]).is(0),P(r[0][1]).is(0)},"resampleToPlanar returns original data when sample rates match":async()=>{let e=Ye({numberOfFrames:3,numberOfChannels:1,sampleRate:48e3,copyTo:t=>t.set([.1,.2,.3])},48e3);P(e.frames).is(3),P(e.data.length).is(1),P(de(e.data[0][0],.1)).ok(),P(de(e.data[0][1],.2)).ok(),P(de(e.data[0][2],.3)).ok()},"resampleToPlanar upsamples using linear interpolation":async()=>{let e=Ye({numberOfFrames:2,numberOfChannels:1,sampleRate:1,copyTo:t=>t.set([10,20])},2);P(e.frames).is(4),P(de(e.data[0][0],10)).ok(),P(de(e.data[0][1],15)).ok(),P(de(e.data[0][2],20)).ok(),P(de(e.data[0][3],20)).ok()},"resampleToPlanar downsamples correctly":async()=>{let e=Ye({numberOfFrames:4,numberOfChannels:1,sampleRate:4,copyTo:t=>t.set([1,2,3,4])},2);P(e.frames).is(2),P(de(e.data[0][0],1)).ok(),P(de(e.data[0][1],3)).ok()},"resampleToPlanar processes multi-channel planar data":async()=>{let r=[new Float32Array([1,2]),new Float32Array([3,4])],t=Ye({numberOfFrames:2,numberOfChannels:2,sampleRate:1,copyTo:(n,o)=>{n.set(r[o.planeIndex])}},2);P(t.data.length).is(2),P(de(t.data[0][1],1.5)).ok(),P(de(t.data[1][1],3.5)).ok()},"resampleToPlanar handles zero channels gracefully":async()=>{let e=Ye({numberOfFrames:10,numberOfChannels:0,sampleRate:48e3,copyTo:()=>{throw new Error("Should not be called")}},44100);P(e.data.length).is(0),P(e.frames).is(0)},"resampleToPlanar enforces minimum of 1 frame on aggressive downsample":async()=>{let e=Ye({numberOfFrames:1,numberOfChannels:1,sampleRate:48e3,copyTo:t=>t.set([.8])},8e3);P(e.frames).is(1),P(e.data[0].length).is(1),P(de(e.data[0][0],.8)).ok()},"resampleToPlanar calls copyTo with strict contract shape":async()=>{let r=null;Ye({numberOfFrames:2,numberOfChannels:1,sampleRate:48e3,copyTo:(t,n)=>{r=n}},44100),P(r).not.is(null),P(r.planeIndex).is(0),P(r.format).is("f32-planar")},"5s long export at 30fps renders exacly 150 frames":async()=>{let{omni:r,videoA:e,driver:t,resolveMedia:n}=await qi(),{timeline:o}=new re({timeline:r.timeline(a=>a.sequence(a.video(e,{duration:2e3}),a.gap(500),a.video(e,{duration:2e3}),a.audio(e,{duration:500})))}),i=fi({timeline:o,fps:xt(30),driver:t,resolveMedia:n}),s=0;for await(let a of i)a.close(),s++;P(s).is(150)},"5s long audio export at 48000Hz renders exactly 240000 frames":async()=>{let{omni:r,videoA:e,resolveMedia:t}=await qi(),{timeline:n}=new re({timeline:r.timeline(s=>s.sequence(s.video(e,{duration:2e3}),s.gap(500),s.video(e,{duration:2e3}),s.audio(e,{duration:500})))}),o=ui({timeline:n,resolveMedia:t}),i=0;for await(let s of o)i+=s.numberOfFrames,s.close();P(i).is(24e4)}});await gt.run({omniTest:ed,renderersTest:td});
|
|
7330
7330
|
/*! Bundled license information:
|
|
7331
7331
|
|
|
7332
7332
|
mediabunny/dist/modules/src/misc.js:
|