@designcombo/frames
Version:
8 lines • 190 kB
JavaScript
(function(U,z){typeof exports=="object"&&typeof module<"u"?z(exports):typeof define=="function"&&define.amd?define(["exports"],z):(U=typeof globalThis<"u"?globalThis:U||self,z(U.frames={}))})(this,function(U){"use strict";var an=Object.defineProperty;var Ke=U=>{throw TypeError(U)};var on=(U,z,k)=>z in U?an(U,z,{enumerable:!0,configurable:!0,writable:!0,value:k}):U[z]=k;var G=(U,z,k)=>on(U,typeof z!="symbol"?z+"":z,k),Qe=(U,z,k)=>z.has(U)||Ke("Cannot "+k);var m=(U,z,k)=>(Qe(U,z,"read from private field"),k?k.call(U):z.get(U)),B=(U,z,k)=>z.has(U)?Ke("Cannot add the same private member more than once"):z instanceof WeakSet?z.add(U):z.set(U,k),A=(U,z,k,Wt)=>(Qe(U,z,"write to private field"),Wt?Wt.call(U,k):z.set(U,k),k);var Pt,Lt,kt,Y,q,Dt,at,St,xt,Ut,X,tt,R,ut,pt,Rt,_t,K,O,ot,gt,Et,ht,Mt,yt,ne,Ot,Nt,Q,mt,J,et,$,Gt,Ht,se,re,it;function z(l){return document.createElement(l)}function k(l,r){const h=z("pre");h.style.cssText=`margin: 0; ${r}; visibility: hidden; position: fixed;`,h.textContent=l,document.body.appendChild(h);const{width:a,height:f}=h.getBoundingClientRect();h.remove(),h.style.visibility="visible";const d=new Image;d.width=a,d.height=f;const p=`
<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${f}">
<foreignObject width="100%" height="100%">
<div xmlns="http://www.w3.org/1999/xhtml">${h.outerHTML}</div>
</foreignObject>
</svg>
`.replace(/\t/g,"").replace(/#/g,"%23");return d.src=`data:image/svg+xml;charset=utf-8,${p}`,d}async function Wt(l,r){const h=k(l,r);await new Promise(d=>{h.onload=d});const a=new OffscreenCanvas(h.width,h.height),f=a.getContext("2d");return f==null||f.drawImage(h,0,0,h.width,h.height),await createImageBitmap(a)}var Se=l=>{throw TypeError(l)},xe=(l,r,h)=>r.has(l)||Se("Cannot "+h),C=(l,r,h)=>(xe(l,r,"read from private field"),h?h.call(l):r.get(l)),H=(l,r,h)=>r.has(l)?Se("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(l):r.set(l,h),N=(l,r,h,a)=>(xe(l,r,"write to private field"),r.set(l,h),h);const Ue="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIHUobil7aWYobj09PSIvIilyZXR1cm57cGFyZW50Om51bGwsbmFtZToiIn07Y29uc3QgZT1uLnNwbGl0KCIvIikuZmlsdGVyKGk9PmkubGVuZ3RoPjApO2lmKGUubGVuZ3RoPT09MCl0aHJvdyBFcnJvcigiSW52YWxpZCBwYXRoIik7Y29uc3QgYT1lW2UubGVuZ3RoLTFdLHI9Ii8iK2Uuc2xpY2UoMCwtMSkuam9pbigiLyIpO3JldHVybntuYW1lOmEscGFyZW50OnJ9fWFzeW5jIGZ1bmN0aW9uIHcobixlKXtjb25zdHtwYXJlbnQ6YSxuYW1lOnJ9PXUobik7aWYoYT09bnVsbClyZXR1cm4gYXdhaXQgbmF2aWdhdG9yLnN0b3JhZ2UuZ2V0RGlyZWN0b3J5KCk7Y29uc3QgaT1hLnNwbGl0KCIvIikuZmlsdGVyKHQ9PnQubGVuZ3RoPjApO3RyeXtsZXQgdD1hd2FpdCBuYXZpZ2F0b3Iuc3RvcmFnZS5nZXREaXJlY3RvcnkoKTtmb3IoY29uc3QgcyBvZiBpKXQ9YXdhaXQgdC5nZXREaXJlY3RvcnlIYW5kbGUocyx7Y3JlYXRlOmUuY3JlYXRlfSk7aWYoZS5pc0ZpbGUpcmV0dXJuIGF3YWl0IHQuZ2V0RmlsZUhhbmRsZShyLHtjcmVhdGU6ZS5jcmVhdGV9KX1jYXRjaCh0KXtpZih0Lm5hbWU9PT0iTm90Rm91bmRFcnJvciIpcmV0dXJuIG51bGw7dGhyb3cgdH19Y29uc3QgZj17fTtzZWxmLm9ubWVzc2FnZT1hc3luYyBuPT57dmFyIGk7Y29uc3R7ZXZ0VHlwZTplLGFyZ3M6YX09bi5kYXRhO2xldCByPWZbYS5maWxlSWRdO3RyeXtsZXQgdDtjb25zdCBzPVtdO2lmKGU9PT0icmVnaXN0ZXIiKXtjb25zdCBsPWF3YWl0IHcoYS5maWxlUGF0aCx7Y3JlYXRlOiEwLGlzRmlsZTohMH0pO2lmKGw9PW51bGwpdGhyb3cgRXJyb3IoYG5vdCBmb3VuZCBmaWxlOiAke2EuZmlsZUlkfWApO3I9YXdhaXQgbC5jcmVhdGVTeW5jQWNjZXNzSGFuZGxlKHttb2RlOmEubW9kZX0pLGZbYS5maWxlSWRdPXJ9ZWxzZSBpZihlPT09ImNsb3NlIilhd2FpdCByLmNsb3NlKCksZGVsZXRlIGZbYS5maWxlSWRdO2Vsc2UgaWYoZT09PSJ0cnVuY2F0ZSIpYXdhaXQgci50cnVuY2F0ZShhLm5ld1NpemUpO2Vsc2UgaWYoZT09PSJ3cml0ZSIpe2NvbnN0e2RhdGE6bCxvcHRzOm99PW4uZGF0YS5hcmdzO3Q9YXdhaXQgci53cml0ZShsLG8pfWVsc2UgaWYoZT09PSJyZWFkIil7Y29uc3R7b2Zmc2V0Omwsc2l6ZTpvfT1uLmRhdGEuYXJncyxnPW5ldyBVaW50OEFycmF5KG8pLGQ9YXdhaXQgci5yZWFkKGcse2F0Omx9KSxjPWcuYnVmZmVyO3Q9ZD09PW8/YzooKGk9Yy50cmFuc2Zlcik9PW51bGw/dm9pZCAwOmkuY2FsbChjLGQpKT8/Yy5zbGljZSgwLGQpLHMucHVzaCh0KX1lbHNlIGU9PT0iZ2V0U2l6ZSI/dD1hd2FpdCByLmdldFNpemUoKTplPT09ImZsdXNoIiYmYXdhaXQgci5mbHVzaCgpO3NlbGYucG9zdE1lc3NhZ2Uoe2V2dFR5cGU6ImNhbGxiYWNrIixjYklkOm4uZGF0YS5jYklkLHJldHVyblZhbDp0fSxzKX1jYXRjaCh0KXtjb25zdCBzPXQ7c2VsZi5wb3N0TWVzc2FnZSh7ZXZ0VHlwZToidGhyb3dFcnJvciIsY2JJZDpuLmRhdGEuY2JJZCxlcnJNc2c6cy5uYW1lKyI6ICIrcy5tZXNzYWdlK2AKYCtKU09OLnN0cmluZ2lmeShuLmRhdGEpfSl9fX0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPW9wZnMtd29ya2VyLUY0UldscWNfLmpzLm1hcAo=",$e=l=>Uint8Array.from(atob(l),r=>r.charCodeAt(0)),Ee=typeof self<"u"&&self.Blob&&new Blob([$e(Ue)],{type:"text/javascript;charset=utf-8"});function qe(l){let r;try{if(r=Ee&&(self.URL||self.webkitURL).createObjectURL(Ee),!r)throw"";const h=new Worker(r,{name:l==null?void 0:l.name});return h.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(r)}),h}catch{return new Worker("data:text/javascript;base64,"+Ue,{name:l==null?void 0:l.name})}finally{r&&(self.URL||self.webkitURL).revokeObjectURL(r)}}async function ti(l,r,h){const a=ei();return await a("register",{fileId:l,filePath:r,mode:h}),{read:async(f,d)=>await a("read",{fileId:l,offset:f,size:d}),write:async(f,d)=>await a("write",{fileId:l,data:f,opts:d},[ArrayBuffer.isView(f)?f.buffer:f]),close:async()=>await a("close",{fileId:l}),truncate:async f=>await a("truncate",{fileId:l,newSize:f}),getSize:async()=>await a("getSize",{fileId:l}),flush:async()=>await a("flush",{fileId:l})}}const Zt=[];let oe=0;function ei(){if(Zt.length<3){const r=l();return Zt.push(r),r}else{const r=Zt[oe];return oe=(oe+1)%Zt.length,r}function l(){const r=new qe;let h=0,a={};return r.onmessage=({data:f})=>{var d,p;f.evtType==="callback"?(d=a[f.cbId])==null||d.resolve(f.returnVal):f.evtType==="throwError"&&((p=a[f.cbId])==null||p.reject(Error(f.errMsg))),delete a[f.cbId]},async function(f,d,p=[]){h+=1;const n=new Promise((v,b)=>{a[h]={resolve:v,reject:b}});return r.postMessage({cbId:h,evtType:f,args:d},p),n}}}function jt(l){if(l==="/")return{parent:null,name:""};const r=l.split("/").filter(f=>f.length>0);if(r.length===0)throw Error("Invalid path");const h=r[r.length-1],a="/"+r.slice(0,-1).join("/");return{name:h,parent:a}}async function nt(l,r){const{parent:h,name:a}=jt(l);if(h==null)return await navigator.storage.getDirectory();const f=h.split("/").filter(d=>d.length>0);try{let d=await navigator.storage.getDirectory();for(const p of f)d=await d.getDirectoryHandle(p,{create:r.create});return r.isFile?await d.getFileHandle(a,{create:r.create}):await d.getDirectoryHandle(a,{create:r.create})}catch(d){if(d.name==="NotFoundError")return null;throw d}}async function Ae(l){const{parent:r,name:h}=jt(l);if(r==null){const f=await navigator.storage.getDirectory();for await(const d of f.keys())await f.removeEntry(d,{recursive:!0});return}const a=await nt(r,{create:!1,isFile:!1});a!=null&&await a.removeEntry(h,{recursive:!0})}function he(l,r){return`${l}/${r}`.replace("//","/")}function wt(l){return new Be(l)}var W,Xt,Bt;class Be{constructor(r){H(this,W),H(this,Xt),H(this,Bt),N(this,W,r);const{parent:h,name:a}=jt(r);N(this,Xt,a),N(this,Bt,h)}get kind(){return"dir"}get name(){return C(this,Xt)}get path(){return C(this,W)}get parent(){return C(this,Bt)==null?null:wt(C(this,Bt))}async create(){return await nt(C(this,W),{create:!0,isFile:!1}),wt(C(this,W))}async exists(){return await nt(C(this,W),{create:!1,isFile:!1})instanceof FileSystemDirectoryHandle}async remove(){for(const r of await this.children())try{await r.remove()}catch(h){console.warn(h)}try{await Ae(C(this,W))}catch(r){console.warn(r)}}async children(){const r=await nt(C(this,W),{create:!1,isFile:!1});if(r==null)return[];const h=[];for await(const a of r.values())h.push((a.kind==="file"?dt:wt)(he(C(this,W),a.name)));return h}async copyTo(r){if(!await this.exists())throw Error(`dir ${this.path} not exists`);const h=await r.exists()?wt(he(r.path,this.name)):r;return await h.create(),await Promise.all((await this.children()).map(a=>a.copyTo(h))),h}async moveTo(r){const h=await this.copyTo(r);return await this.remove(),h}}W=new WeakMap,Xt=new WeakMap,Bt=new WeakMap;const Fe=new Map;function dt(l,r="rw"){if(r==="rw"){const h=Fe.get(l)??new $t(l,r);return Fe.set(l,h),h}return new $t(l,r)}async function Ft(l,r,h={overwrite:!0}){if(r instanceof $t){await Ft(l,await r.stream(),h);return}const a=await(l instanceof $t?l:dt(l,"rw")).createWriter();try{if(h.overwrite&&await a.truncate(0),r instanceof ReadableStream){const f=r.getReader();for(;;){const{done:d,value:p}=await f.read();if(d)break;await a.write(p)}}else await a.write(r)}catch(f){throw f}finally{await a.close()}}let ii=0;const ni=()=>++ii;var Z,It,Kt,Ct,Qt,st,Jt,Tt;const si=class Je{constructor(r,h){H(this,Z),H(this,It),H(this,Kt),H(this,Ct),H(this,Qt),H(this,st,0),H(this,Jt,(()=>{let d=null;return()=>(N(this,st,C(this,st)+1),d??(d=new Promise(async(p,n)=>{try{const v=await ti(C(this,Qt),C(this,Z),C(this,Ct));p([v,async()=>{N(this,st,C(this,st)-1),!(C(this,st)>0)&&(d=null,await v.close())}])}catch(v){n(v)}})))})()),H(this,Tt,!1),N(this,Qt,ni()),N(this,Z,r),N(this,Ct,{r:"read-only",rw:"readwrite","rw-unsafe":"readwrite-unsafe"}[h]);const{parent:a,name:f}=jt(r);N(this,Kt,f),N(this,It,a)}get kind(){return"file"}get path(){return C(this,Z)}get name(){return C(this,Kt)}get parent(){return C(this,It)==null?null:wt(C(this,It))}async createWriter(){if(C(this,Ct)==="read-only")throw Error("file is read-only");if(C(this,Tt))throw Error("Other writer have not been closed");N(this,Tt,!0);const r=new TextEncoder,[h,a]=await C(this,Jt).call(this);let f=await h.getSize(),d=!1;return{write:async(p,n={})=>{if(d)throw Error("Writer is closed");const v=typeof p=="string"?r.encode(p):p,b=n.at??f,y=v.byteLength;return f=b+y,await h.write(v,{at:b})},truncate:async p=>{if(d)throw Error("Writer is closed");await h.truncate(p),f>p&&(f=p)},flush:async()=>{if(d)throw Error("Writer is closed");await h.flush()},close:async()=>{if(d)throw Error("Writer is closed");d=!0,N(this,Tt,!1),await a()}}}async createReader(){const[r,h]=await C(this,Jt).call(this);let a=!1,f=0;return{read:async(d,p={})=>{if(a)throw Error("Reader is closed");const n=p.at??f,v=await r.read(n,d);return f=n+v.byteLength,v},getSize:async()=>{if(a)throw Error("Reader is closed");return await r.getSize()},close:async()=>{a||(a=!0,await h())}}}async text(){return new TextDecoder().decode(await this.arrayBuffer())}async arrayBuffer(){const r=await nt(C(this,Z),{create:!1,isFile:!0});return r==null?new ArrayBuffer(0):(await r.getFile()).arrayBuffer()}async stream(){const r=await this.getOriginFile();return r==null?new ReadableStream({pull:h=>{h.close()}}):r.stream()}async getOriginFile(){var r;return(r=await nt(C(this,Z),{create:!1,isFile:!0}))==null?void 0:r.getFile()}async getSize(){const r=await nt(C(this,Z),{create:!1,isFile:!0});return r==null?0:(await r.getFile()).size}async exists(){return await nt(C(this,Z),{create:!1,isFile:!0})instanceof FileSystemFileHandle}async remove(){if(C(this,st))throw Error("exists unclosed reader/writer");await Ae(C(this,Z))}async copyTo(r){if(!await this.exists())throw Error(`file ${this.path} not exists`);if(r instanceof Je)return dt(r.path)===this?this:(await Ft(r.path,this),dt(r.path));if(r instanceof Be)return await this.copyTo(dt(he(r.path,this.name)));throw Error("Illegal target type")}async moveTo(r){const h=await this.copyTo(r);return await this.remove(),h}};Z=new WeakMap,It=new WeakMap,Kt=new WeakMap,Ct=new WeakMap,Qt=new WeakMap,st=new WeakMap,Jt=new WeakMap,Tt=new WeakMap;let $t=si;const le="/.opfs-tools-temp-dir";async function Ie(l){try{if(l.kind==="file"){if(!await l.exists())return!0;const r=await l.createWriter();await r.truncate(0),await r.close(),await l.remove()}else await l.remove();return!0}catch(r){return console.warn(r),!1}}function ri(){setInterval(async()=>{for(const l of await wt(le).children()){const r=/^\d+-(\d+)$/.exec(l.name);(r==null||Date.now()-Number(r[1])>2592e5)&&await Ie(l)}},60*1e3)}const fe=[];let Ce=!1;async function ai(){if(globalThis.localStorage==null)return;const l="OPFS_TOOLS_EXPIRES_TMP_FILES";Ce||(Ce=!0,globalThis.addEventListener("unload",()=>{fe.length!==0&&localStorage.setItem(l,`${localStorage.getItem(l)??""},${fe.join(",")}`)}));let r=localStorage.getItem(l)??"";for(const h of r.split(","))h.length!==0&&await Ie(dt(`${le}/${h}`))&&(r=r.replace(h,""));localStorage.setItem(l,r.replace(/,{2,}/g,","))}(async function(){var l;globalThis.__opfs_tools_tmpfile_init__!==!0&&(globalThis.__opfs_tools_tmpfile_init__=!0,!(globalThis.FileSystemDirectoryHandle==null||globalThis.FileSystemFileHandle==null||((l=globalThis.navigator)==null?void 0:l.storage.getDirectory)==null)&&(ri(),await ai()))})();function qt(){const l=`${Math.random().toString().slice(2)}-${Date.now()}`;return fe.push(l),dt(`${le}/${l}`)}function oi(l){return l instanceof Error?String(l):typeof l=="object"?JSON.stringify(l,(r,h)=>h instanceof Error?String(h):h):String(l)}function hi(){const l=new Date;return`${l.getHours()}:${l.getMinutes()}:${l.getSeconds()}.${l.getMilliseconds()}`}let Te=1;const ze=qt();let ct=null;const Pe=["debug","info","warn","error"].reduce((l,r,h)=>Object.assign(l,{[r]:(...a)=>{Te<=h&&(console[r](...a),ct==null||ct.write(`[${r}][${hi()}] ${a.map(f=>oi(f)).join(" ")}
`))}}),{}),zt=new Map,P={setLogLevel:l=>{Te=zt.get(l)??1},...Pe,create:l=>Object.fromEntries(Object.entries(Pe).map(([r,h])=>[r,(...a)=>h(l,...a)])),async dump(){return await fi,await(ct==null?void 0:ct.flush()),await ze.text()}};zt.set(P.debug,0),zt.set(P.info,1),zt.set(P.warn,2),zt.set(P.error,3);async function li(){try{ct=await ze.createWriter(),P.info(navigator.userAgent),P.info("date: "+new Date().toLocaleDateString())}catch(l){if(!(l instanceof Error))throw l;if(l.message.includes("createSyncAccessHandle is not a function"))console.warn(l);else throw l}}const fi=globalThis.navigator==null?null:li(),di=()=>{let l,r=16.6;self.onmessage=h=>{h.data.event==="start"&&(self.clearInterval(l),l=self.setInterval(()=>{self.postMessage({})},r)),h.data.event==="stop"&&self.clearInterval(l)}},ci=()=>{const l=new Blob([`(${di.toString()})()`]),r=URL.createObjectURL(l);return new Worker(r)},bt=new Map;let de=1,rt=null;globalThis.Worker!=null&&(rt=ci(),rt.onmessage=()=>{de+=1;for(const[l,r]of bt)if(de%l===0)for(const h of r)h()});const ce=(l,r)=>{const h=Math.round(r/16.6),a=bt.get(h)??new Set;return a.add(l),bt.set(h,a),bt.size===1&&a.size===1&&(rt==null||rt.postMessage({event:"start"})),()=>{a.delete(l),a.size===0&&bt.delete(h),bt.size===0&&(de=0,rt==null||rt.postMessage({event:"stop"}))}};class ui{constructor(r,h,a){this.length_=r,this.scaleFactor_=(r-1)/h,this.interpolate=this.cubic,a.method==="point"?this.interpolate=this.point:a.method==="linear"?this.interpolate=this.linear:a.method==="sinc"&&(this.interpolate=this.sinc),this.tangentFactor_=1-Math.max(0,Math.min(1,a.tension||0)),this.sincFilterSize_=a.sincFilterSize||1,this.kernel_=_i(a.sincWindow||pi)}point(r,h){return this.getClippedInput_(Math.round(this.scaleFactor_*r),h)}linear(r,h){r=this.scaleFactor_*r;let a=Math.floor(r);return r-=a,(1-r)*this.getClippedInput_(a,h)+r*this.getClippedInput_(a+1,h)}cubic(r,h){r=this.scaleFactor_*r;let a=Math.floor(r),f=[this.getTangent_(a,h),this.getTangent_(a+1,h)],d=[this.getClippedInput_(a,h),this.getClippedInput_(a+1,h)];r-=a;let p=r*r,n=r*p;return(2*n-3*p+1)*d[0]+(n-2*p+r)*f[0]+(-2*n+3*p)*d[1]+(n-p)*f[1]}sinc(r,h){r=this.scaleFactor_*r;let a=Math.floor(r),f=a-this.sincFilterSize_+1,d=a+this.sincFilterSize_,p=0;for(let n=f;n<=d;n++)p+=this.kernel_(r-n)*this.getClippedInput_(n,h);return p}getTangent_(r,h){return this.tangentFactor_*(this.getClippedInput_(r+1,h)-this.getClippedInput_(r-1,h))/2}getClippedInput_(r,h){return 0<=r&&r<this.length_?h[r]:0}}function pi(l){return Math.exp(-l/2*l/2)}function _i(l){return function(r){return gi(r)*l(r)}}function gi(l){return l===0?1:Math.sin(Math.PI*l)/(Math.PI*l)}class yi{constructor(r,h,a){let f=2*Math.PI*a/h,d=0;this.filters=[];for(let p=0;p<=r;p++)p-r/2===0?this.filters[p]=f:(this.filters[p]=Math.sin(f*(p-r/2))/(p-r/2),this.filters[p]*=.54-.46*Math.cos(2*Math.PI*p/r)),d=d+this.filters[p];for(let p=0;p<=r;p++)this.filters[p]/=d;this.z=this.initZ_()}filter(r){this.z.buf[this.z.pointer]=r;let h=0;for(let a=0,f=this.z.buf.length;a<f;a++)h+=this.filters[a]*this.z.buf[(this.z.pointer+a)%this.z.buf.length];return this.z.pointer=(this.z.pointer+1)%this.z.buf.length,h}reset(){this.z=this.initZ_()}initZ_(){let r=[];for(let h=0;h<this.filters.length-1;h++)r.push(0);return{buf:r,pointer:0}}}class mi{constructor(r,h,a){let f=[];for(let d=0;d<r;d++)f.push(this.getCoeffs_({Fs:h,Fc:a,Q:.5/Math.sin(Math.PI/(r*2)*(d+.5))}));this.stages=[];for(let d=0;d<f.length;d++)this.stages[d]={b0:f[d].b[0],b1:f[d].b[1],b2:f[d].b[2],a1:f[d].a[0],a2:f[d].a[1],k:f[d].k,z:[0,0]}}filter(r){let h=r;for(let a=0,f=this.stages.length;a<f;a++)h=this.runStage_(a,h);return h}getCoeffs_(r){let h={};h.z=[0,0],h.a=[],h.b=[];let a=this.preCalc_(r,h);return h.k=1,h.b.push((1-a.cw)/(2*a.a0)),h.b.push(2*h.b[0]),h.b.push(h.b[0]),h}preCalc_(r,h){let a={},f=2*Math.PI*r.Fc/r.Fs;return a.alpha=Math.sin(f)/(2*r.Q),a.cw=Math.cos(f),a.a0=1+a.alpha,h.a0=a.a0,h.a.push(-2*a.cw/a.a0),h.k=1,h.a.push((1-a.alpha)/a.a0),a}runStage_(r,h){let a=h*this.stages[r].k-this.stages[r].a1*this.stages[r].z[0]-this.stages[r].a2*this.stages[r].z[1],f=this.stages[r].b0*a+this.stages[r].b1*this.stages[r].z[0]+this.stages[r].b2*this.stages[r].z[1];return this.stages[r].z[1]=this.stages[r].z[0],this.stages[r].z[0]=a,f}reset(){for(let r=0;r<this.stages.length;r++)this.stages[r].z=[0,0]}}const vi={point:!1,linear:!1,cubic:!0,sinc:!0},Le={IIR:16,FIR:71},wi={IIR:mi,FIR:yi};function bi(l,r,h,a={}){let f=(h-r)/r+1,d=new Float64Array(l.length*f);a.method=a.method||"cubic";let p=new ui(l.length,d.length,{method:a.method,tension:a.tension||0,sincFilterSize:a.sincFilterSize||6,sincWindow:a.sincWindow||void 0});if(a.LPF===void 0&&(a.LPF=vi[a.method]),a.LPF){a.LPFType=a.LPFType||"IIR";const n=wi[a.LPFType];if(h>r){let v=new n(a.LPFOrder||Le[a.LPFType],h,r/2);Si(l,d,p,v)}else{let v=new n(a.LPFOrder||Le[a.LPFType],r,h/2);xi(l,d,p,v)}}else ke(l,d,p);return d}function ke(l,r,h){for(let a=0,f=r.length;a<f;a++)r[a]=h.interpolate(a,l)}function Si(l,r,h,a){for(let f=0,d=r.length;f<d;f++)r[f]=a.filter(h.interpolate(f,l));a.reset();for(let f=r.length-1;f>=0;f--)r[f]=a.filter(r[f])}function xi(l,r,h,a){for(let f=0,d=l.length;f<d;f++)l[f]=a.filter(l[f]);a.reset();for(let f=l.length-1;f>=0;f--)l[f]=a.filter(l[f]);ke(l,r,h)}function ue(l){const r=new Float32Array(l.map(a=>a.length).reduce((a,f)=>a+f));let h=0;for(const a of l)r.set(a,h),h+=a.length;return r}function De(l){const r=[];for(let h=0;h<l.length;h+=1)for(let a=0;a<l[h].length;a+=1)r[a]==null&&(r[a]=[]),r[a].push(l[h][a]);return r.map(ue)}function te(l){if(l.format==="f32-planar"){const r=[];for(let h=0;h<l.numberOfChannels;h+=1){const a=l.allocationSize({planeIndex:h}),f=new ArrayBuffer(a);l.copyTo(f,{planeIndex:h}),r.push(new Float32Array(f))}return r}else if(l.format==="f32"){const r=new ArrayBuffer(l.allocationSize({planeIndex:0}));return l.copyTo(r,{planeIndex:0}),Ei(new Float32Array(r),l.numberOfChannels)}else if(l.format==="s16"){const r=new ArrayBuffer(l.allocationSize({planeIndex:0}));return l.copyTo(r,{planeIndex:0}),Ui(new Int16Array(r),l.numberOfChannels)}throw Error("Unsupported audio data format")}function Ui(l,r){const h=l.length/r,a=Array.from({length:r},()=>new Float32Array(h));for(let f=0;f<h;f++)for(let d=0;d<r;d++){const p=l[f*r+d];a[d][f]=p/32768}return a}function Ei(l,r){const h=l.length/r,a=Array.from({length:r},()=>new Float32Array(h));for(let f=0;f<h;f++)for(let d=0;d<r;d++)a[d][f]=l[f*r+d];return a}function pe(l){return Array(l.numberOfChannels).fill(0).map((r,h)=>l.getChannelData(h))}function Ai(l,r){const h=new Float32Array(ue(te(l))).map(f=>f*r),a=new AudioData({sampleRate:l.sampleRate,numberOfChannels:l.numberOfChannels,timestamp:l.timestamp,format:l.format,numberOfFrames:l.numberOfFrames,data:h});return l.close(),a}async function Bi(l,r){var p;const h={type:r,data:l},a=new ImageDecoder(h);await Promise.all([a.completed,a.tracks.ready]);let f=((p=a.tracks.selectedTrack)==null?void 0:p.frameCount)??1;const d=[];for(let n=0;n<f;n+=1)d.push((await a.decode({frameIndex:n})).image);return d}function _e(l){var a,f;const r=Math.max(...l.map(d=>{var p;return((p=d[0])==null?void 0:p.length)??0})),h=new Float32Array(r*2);for(let d=0;d<r;d++){let p=0,n=0;for(let v=0;v<l.length;v++){const b=((a=l[v][0])==null?void 0:a[d])??0,y=((f=l[v][1])==null?void 0:f[d])??b;p+=b,n+=y}h[d]=p,h[d+r]=n}return h}async function Re(l,r,h){const a=l.length,f=Array(h.chanCount).fill(0).map(()=>new Float32Array(0));if(a===0)return f;const d=Math.max(...l.map(b=>b.length));if(d===0)return f;if(globalThis.OfflineAudioContext==null)return l.map(b=>new Float32Array(bi(b,r,h.rate,{method:"sinc",LPF:!1})));const p=new globalThis.OfflineAudioContext(h.chanCount,d*h.rate/r,h.rate),n=p.createBufferSource(),v=p.createBuffer(a,d,r);return l.forEach((b,y)=>v.copyToChannel(b,y)),n.buffer=v,n.connect(p.destination),n.start(),pe(await p.startRendering())}function Me(l){return new Promise(r=>{const h=ce(()=>{h(),r()},l)})}function Oe(l,r,h){const a=h-r,f=new Float32Array(a);let d=0;for(;d<a;)f[d]=l[(r+d)%l.length],d+=1;return f}function ee(l,r){let h=!1;async function a(){const f=l.getReader();for(;!h;){const{value:d,done:p}=await f.read();if(p){r.onDone();return}await r.onChunk(d)}f.releaseLock(),await l.cancel()}return a().catch(P.error),()=>{h=!0}}function Fi(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}var Ne={};(function(l){var r=function(){var t=new Date,e=4,i=3,s=2,o=1,c=e,u={setLogLevel:function(_){_==this.debug?c=o:_==this.info?c=s:_==this.warn?c=i:(_==this.error,c=e)},debug:function(_,g){console.debug===void 0&&(console.debug=console.log),o>=c&&console.debug("["+r.getDurationString(new Date-t,1e3)+"]","["+_+"]",g)},log:function(_,g){this.debug(_.msg)},info:function(_,g){s>=c&&console.info("["+r.getDurationString(new Date-t,1e3)+"]","["+_+"]",g)},warn:function(_,g){i>=c&&console.warn("["+r.getDurationString(new Date-t,1e3)+"]","["+_+"]",g)},error:function(_,g){e>=c&&console.error("["+r.getDurationString(new Date-t,1e3)+"]","["+_+"]",g)}};return u}();r.getDurationString=function(t,e){var i;function s(w,S){for(var E=""+w,T=E.split(".");T[0].length<S;)T[0]="0"+T[0];return T.join(".")}t<0?(i=!0,t=-t):i=!1;var o=e||1,c=t/o,u=Math.floor(c/3600);c-=u*3600;var _=Math.floor(c/60);c-=_*60;var g=c*1e3;return c=Math.floor(c),g-=c*1e3,g=Math.floor(g),(i?"-":"")+u+":"+s(_,2)+":"+s(c,2)+"."+s(g,3)},r.printRanges=function(t){var e=t.length;if(e>0){for(var i="",s=0;s<e;s++)s>0&&(i+=","),i+="["+r.getDurationString(t.start(s))+","+r.getDurationString(t.end(s))+"]";return i}else return"(empty)"},l.Log=r;var h=function(t){if(t instanceof ArrayBuffer)this.buffer=t,this.dataview=new DataView(t);else throw"Needs an array buffer";this.position=0};h.prototype.getPosition=function(){return this.position},h.prototype.getEndPosition=function(){return this.buffer.byteLength},h.prototype.getLength=function(){return this.buffer.byteLength},h.prototype.seek=function(t){var e=Math.max(0,Math.min(this.buffer.byteLength,t));return this.position=isNaN(e)||!isFinite(e)?0:e,!0},h.prototype.isEos=function(){return this.getPosition()>=this.getEndPosition()},h.prototype.readAnyInt=function(t,e){var i=0;if(this.position+t<=this.buffer.byteLength){switch(t){case 1:e?i=this.dataview.getInt8(this.position):i=this.dataview.getUint8(this.position);break;case 2:e?i=this.dataview.getInt16(this.position):i=this.dataview.getUint16(this.position);break;case 3:if(e)throw"No method for reading signed 24 bits values";i=this.dataview.getUint8(this.position)<<16,i|=this.dataview.getUint8(this.position+1)<<8,i|=this.dataview.getUint8(this.position+2);break;case 4:e?i=this.dataview.getInt32(this.position):i=this.dataview.getUint32(this.position);break;case 8:if(e)throw"No method for reading signed 64 bits values";i=this.dataview.getUint32(this.position)<<32,i|=this.dataview.getUint32(this.position+4);break;default:throw"readInt method not implemented for size: "+t}return this.position+=t,i}else throw"Not enough bytes in buffer"},h.prototype.readUint8=function(){return this.readAnyInt(1,!1)},h.prototype.readUint16=function(){return this.readAnyInt(2,!1)},h.prototype.readUint24=function(){return this.readAnyInt(3,!1)},h.prototype.readUint32=function(){return this.readAnyInt(4,!1)},h.prototype.readUint64=function(){return this.readAnyInt(8,!1)},h.prototype.readString=function(t){if(this.position+t<=this.buffer.byteLength){for(var e="",i=0;i<t;i++)e+=String.fromCharCode(this.readUint8());return e}else throw"Not enough bytes in buffer"},h.prototype.readCString=function(){for(var t=[];;){var e=this.readUint8();if(e!==0)t.push(e);else break}return String.fromCharCode.apply(null,t)},h.prototype.readInt8=function(){return this.readAnyInt(1,!0)},h.prototype.readInt16=function(){return this.readAnyInt(2,!0)},h.prototype.readInt32=function(){return this.readAnyInt(4,!0)},h.prototype.readInt64=function(){return this.readAnyInt(8,!1)},h.prototype.readUint8Array=function(t){for(var e=new Uint8Array(t),i=0;i<t;i++)e[i]=this.readUint8();return e},h.prototype.readInt16Array=function(t){for(var e=new Int16Array(t),i=0;i<t;i++)e[i]=this.readInt16();return e},h.prototype.readUint16Array=function(t){for(var e=new Int16Array(t),i=0;i<t;i++)e[i]=this.readUint16();return e},h.prototype.readUint32Array=function(t){for(var e=new Uint32Array(t),i=0;i<t;i++)e[i]=this.readUint32();return e},h.prototype.readInt32Array=function(t){for(var e=new Int32Array(t),i=0;i<t;i++)e[i]=this.readInt32();return e},l.MP4BoxStream=h;var a=function(t,e,i){this._byteOffset=e||0,t instanceof ArrayBuffer?this.buffer=t:typeof t=="object"?(this.dataView=t,e&&(this._byteOffset+=e)):this.buffer=new ArrayBuffer(t||0),this.position=0,this.endianness=i??a.LITTLE_ENDIAN};a.prototype={},a.prototype.getPosition=function(){return this.position},a.prototype._realloc=function(t){if(this._dynamicSize){var e=this._byteOffset+this.position+t,i=this._buffer.byteLength;if(e<=i){e>this._byteLength&&(this._byteLength=e);return}for(i<1&&(i=1);e>i;)i*=2;var s=new ArrayBuffer(i),o=new Uint8Array(this._buffer),c=new Uint8Array(s,0,o.length);c.set(o),this.buffer=s,this._byteLength=e}},a.prototype._trimAlloc=function(){if(this._byteLength!=this._buffer.byteLength){var t=new ArrayBuffer(this._byteLength),e=new Uint8Array(t),i=new Uint8Array(this._buffer,0,e.length);e.set(i),this.buffer=t}},a.BIG_ENDIAN=!1,a.LITTLE_ENDIAN=!0,a.prototype._byteLength=0,Object.defineProperty(a.prototype,"byteLength",{get:function(){return this._byteLength-this._byteOffset}}),Object.defineProperty(a.prototype,"buffer",{get:function(){return this._trimAlloc(),this._buffer},set:function(t){this._buffer=t,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._buffer.byteLength}}),Object.defineProperty(a.prototype,"byteOffset",{get:function(){return this._byteOffset},set:function(t){this._byteOffset=t,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._buffer.byteLength}}),Object.defineProperty(a.prototype,"dataView",{get:function(){return this._dataView},set:function(t){this._byteOffset=t.byteOffset,this._buffer=t.buffer,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._byteOffset+t.byteLength}}),a.prototype.seek=function(t){var e=Math.max(0,Math.min(this.byteLength,t));this.position=isNaN(e)||!isFinite(e)?0:e},a.prototype.isEof=function(){return this.position>=this._byteLength},a.prototype.mapUint8Array=function(t){this._realloc(t*1);var e=new Uint8Array(this._buffer,this.byteOffset+this.position,t);return this.position+=t*1,e},a.prototype.readInt32Array=function(t,e){t=t??this.byteLength-this.position/4;var i=new Int32Array(t);return a.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,t*i.BYTES_PER_ELEMENT),a.arrayToNative(i,e??this.endianness),this.position+=i.byteLength,i},a.prototype.readInt16Array=function(t,e){t=t??this.byteLength-this.position/2;var i=new Int16Array(t);return a.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,t*i.BYTES_PER_ELEMENT),a.arrayToNative(i,e??this.endianness),this.position+=i.byteLength,i},a.prototype.readInt8Array=function(t){t=t??this.byteLength-this.position;var e=new Int8Array(t);return a.memcpy(e.buffer,0,this.buffer,this.byteOffset+this.position,t*e.BYTES_PER_ELEMENT),this.position+=e.byteLength,e},a.prototype.readUint32Array=function(t,e){t=t??this.byteLength-this.position/4;var i=new Uint32Array(t);return a.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,t*i.BYTES_PER_ELEMENT),a.arrayToNative(i,e??this.endianness),this.position+=i.byteLength,i},a.prototype.readUint16Array=function(t,e){t=t??this.byteLength-this.position/2;var i=new Uint16Array(t);return a.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,t*i.BYTES_PER_ELEMENT),a.arrayToNative(i,e??this.endianness),this.position+=i.byteLength,i},a.prototype.readUint8Array=function(t){t=t??this.byteLength-this.position;var e=new Uint8Array(t);return a.memcpy(e.buffer,0,this.buffer,this.byteOffset+this.position,t*e.BYTES_PER_ELEMENT),this.position+=e.byteLength,e},a.prototype.readFloat64Array=function(t,e){t=t??this.byteLength-this.position/8;var i=new Float64Array(t);return a.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,t*i.BYTES_PER_ELEMENT),a.arrayToNative(i,e??this.endianness),this.position+=i.byteLength,i},a.prototype.readFloat32Array=function(t,e){t=t??this.byteLength-this.position/4;var i=new Float32Array(t);return a.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,t*i.BYTES_PER_ELEMENT),a.arrayToNative(i,e??this.endianness),this.position+=i.byteLength,i},a.prototype.readInt32=function(t){var e=this._dataView.getInt32(this.position,t??this.endianness);return this.position+=4,e},a.prototype.readInt16=function(t){var e=this._dataView.getInt16(this.position,t??this.endianness);return this.position+=2,e},a.prototype.readInt8=function(){var t=this._dataView.getInt8(this.position);return this.position+=1,t},a.prototype.readUint32=function(t){var e=this._dataView.getUint32(this.position,t??this.endianness);return this.position+=4,e},a.prototype.readUint16=function(t){var e=this._dataView.getUint16(this.position,t??this.endianness);return this.position+=2,e},a.prototype.readUint8=function(){var t=this._dataView.getUint8(this.position);return this.position+=1,t},a.prototype.readFloat32=function(t){var e=this._dataView.getFloat32(this.position,t??this.endianness);return this.position+=4,e},a.prototype.readFloat64=function(t){var e=this._dataView.getFloat64(this.position,t??this.endianness);return this.position+=8,e},a.endianness=new Int8Array(new Int16Array([1]).buffer)[0]>0,a.memcpy=function(t,e,i,s,o){var c=new Uint8Array(t,e,o),u=new Uint8Array(i,s,o);c.set(u)},a.arrayToNative=function(t,e){return e==this.endianness?t:this.flipArrayEndianness(t)},a.nativeToEndian=function(t,e){return this.endianness==e?t:this.flipArrayEndianness(t)},a.flipArrayEndianness=function(t){for(var e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),i=0;i<t.byteLength;i+=t.BYTES_PER_ELEMENT)for(var s=i+t.BYTES_PER_ELEMENT-1,o=i;s>o;s--,o++){var c=e[o];e[o]=e[s],e[s]=c}return t},a.prototype.failurePosition=0,String.fromCharCodeUint8=function(t){for(var e=[],i=0;i<t.length;i++)e[i]=t[i];return String.fromCharCode.apply(null,e)},a.prototype.readString=function(t,e){return e==null||e=="ASCII"?String.fromCharCodeUint8.apply(null,[this.mapUint8Array(t??this.byteLength-this.position)]):new TextDecoder(e).decode(this.mapUint8Array(t))},a.prototype.readCString=function(t){var e=this.byteLength-this.position,i=new Uint8Array(this._buffer,this._byteOffset+this.position),s=e;t!=null&&(s=Math.min(t,e));for(var o=0;o<s&&i[o]!==0;o++);var c=String.fromCharCodeUint8.apply(null,[this.mapUint8Array(o)]);return t!=null?this.position+=s-o:o!=e&&(this.position+=1),c};var f=Math.pow(2,32);a.prototype.readInt64=function(){return this.readInt32()*f+this.readUint32()},a.prototype.readUint64=function(){return this.readUint32()*f+this.readUint32()},a.prototype.readInt64=function(){return this.readUint32()*f+this.readUint32()},a.prototype.readUint24=function(){return(this.readUint8()<<16)+(this.readUint8()<<8)+this.readUint8()},l.DataStream=a,a.prototype.save=function(t){var e=new Blob([this.buffer]);if(window.URL&&URL.createObjectURL){var i=window.URL.createObjectURL(e),s=document.createElement("a");document.body.appendChild(s),s.setAttribute("href",i),s.setAttribute("download",t),s.setAttribute("target","_self"),s.click(),window.URL.revokeObjectURL(i)}else throw"DataStream.save: Can't create object URL."},a.prototype._dynamicSize=!0,Object.defineProperty(a.prototype,"dynamicSize",{get:function(){return this._dynamicSize},set:function(t){t||this._trimAlloc(),this._dynamicSize=t}}),a.prototype.shift=function(t){var e=new ArrayBuffer(this._byteLength-t),i=new Uint8Array(e),s=new Uint8Array(this._buffer,t,i.length);i.set(s),this.buffer=e,this.position-=t},a.prototype.writeInt32Array=function(t,e){if(this._realloc(t.length*4),t instanceof Int32Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)a.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapInt32Array(t.length,e);else for(var i=0;i<t.length;i++)this.writeInt32(t[i],e)},a.prototype.writeInt16Array=function(t,e){if(this._realloc(t.length*2),t instanceof Int16Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)a.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapInt16Array(t.length,e);else for(var i=0;i<t.length;i++)this.writeInt16(t[i],e)},a.prototype.writeInt8Array=function(t){if(this._realloc(t.length*1),t instanceof Int8Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)a.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapInt8Array(t.length);else for(var e=0;e<t.length;e++)this.writeInt8(t[e])},a.prototype.writeUint32Array=function(t,e){if(this._realloc(t.length*4),t instanceof Uint32Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)a.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapUint32Array(t.length,e);else for(var i=0;i<t.length;i++)this.writeUint32(t[i],e)},a.prototype.writeUint16Array=function(t,e){if(this._realloc(t.length*2),t instanceof Uint16Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)a.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapUint16Array(t.length,e);else for(var i=0;i<t.length;i++)this.writeUint16(t[i],e)},a.prototype.writeUint8Array=function(t){if(this._realloc(t.length*1),t instanceof Uint8Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)a.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapUint8Array(t.length);else for(var e=0;e<t.length;e++)this.writeUint8(t[e])},a.prototype.writeFloat64Array=function(t,e){if(this._realloc(t.length*8),t instanceof Float64Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)a.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapFloat64Array(t.length,e);else for(var i=0;i<t.length;i++)this.writeFloat64(t[i],e)},a.prototype.writeFloat32Array=function(t,e){if(this._realloc(t.length*4),t instanceof Float32Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)a.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapFloat32Array(t.length,e);else for(var i=0;i<t.length;i++)this.writeFloat32(t[i],e)},a.prototype.writeInt32=function(t,e){this._realloc(4),this._dataView.setInt32(this.position,t,e??this.endianness),this.position+=4},a.prototype.writeInt16=function(t,e){this._realloc(2),this._dataView.setInt16(this.position,t,e??this.endianness),this.position+=2},a.prototype.writeInt8=function(t){this._realloc(1),this._dataView.setInt8(this.position,t),this.position+=1},a.prototype.writeUint32=function(t,e){this._realloc(4),this._dataView.setUint32(this.position,t,e??this.endianness),this.position+=4},a.prototype.writeUint16=function(t,e){this._realloc(2),this._dataView.setUint16(this.position,t,e??this.endianness),this.position+=2},a.prototype.writeUint8=function(t){this._realloc(1),this._dataView.setUint8(this.position,t),this.position+=1},a.prototype.writeFloat32=function(t,e){this._realloc(4),this._dataView.setFloat32(this.position,t,e??this.endianness),this.position+=4},a.prototype.writeFloat64=function(t,e){this._realloc(8),this._dataView.setFloat64(this.position,t,e??this.endianness),this.position+=8},a.prototype.writeUCS2String=function(t,e,i){i==null&&(i=t.length);for(var s=0;s<t.length&&s<i;s++)this.writeUint16(t.charCodeAt(s),e);for(;s<i;s++)this.writeUint16(0)},a.prototype.writeString=function(t,e,i){var s=0;if(e==null||e=="ASCII")if(i!=null){var o=Math.min(t.length,i);for(s=0;s<o;s++)this.writeUint8(t.charCodeAt(s));for(;s<i;s++)this.writeUint8(0)}else for(s=0;s<t.length;s++)this.writeUint8(t.charCodeAt(s));else this.writeUint8Array(new TextEncoder(e).encode(t.substring(0,i)))},a.prototype.writeCString=function(t,e){var i=0;if(e!=null){var s=Math.min(t.length,e);for(i=0;i<s;i++)this.writeUint8(t.charCodeAt(i));for(;i<e;i++)this.writeUint8(0)}else{for(i=0;i<t.length;i++)this.writeUint8(t.charCodeAt(i));this.writeUint8(0)}},a.prototype.writeStruct=function(t,e){for(var i=0;i<t.length;i+=2){var s=t[i+1];this.writeType(s,e[t[i]],e)}},a.prototype.writeType=function(t,e,i){var s;if(typeof t=="function")return t(this,e);if(typeof t=="object"&&!(t instanceof Array))return t.set(this,e,i);var o=null,c="ASCII",u=this.position;switch(typeof t=="string"&&/:/.test(t)&&(s=t.split(":"),t=s[0],o=parseInt(s[1])),typeof t=="string"&&/,/.test(t)&&(s=t.split(","),t=s[0],c=parseInt(s[1])),t){case"uint8":this.writeUint8(e);break;case"int8":this.writeInt8(e);break;case"uint16":this.writeUint16(e,this.endianness);break;case"int16":this.writeInt16(e,this.endianness);break;case"uint32":this.writeUint32(e,this.endianness);break;case"int32":this.writeInt32(e,this.endianness);break;case"float32":this.writeFloat32(e,this.endianness);break;case"float64":this.writeFloat64(e,this.endianness);break;case"uint16be":this.writeUint16(e,a.BIG_ENDIAN);break;case"int16be":this.writeInt16(e,a.BIG_ENDIAN);break;case"uint32be":this.writeUint32(e,a.BIG_ENDIAN);break;case"int32be":this.writeInt32(e,a.BIG_ENDIAN);break;case"float32be":this.writeFloat32(e,a.BIG_ENDIAN);break;case"float64be":this.writeFloat64(e,a.BIG_ENDIAN);break;case"uint16le":this.writeUint16(e,a.LITTLE_ENDIAN);break;case"int16le":this.writeInt16(e,a.LITTLE_ENDIAN);break;case"uint32le":this.writeUint32(e,a.LITTLE_ENDIAN);break;case"int32le":this.writeInt32(e,a.LITTLE_ENDIAN);break;case"float32le":this.writeFloat32(e,a.LITTLE_ENDIAN);break;case"float64le":this.writeFloat64(e,a.LITTLE_ENDIAN);break;case"cstring":this.writeCString(e,o);break;case"string":this.writeString(e,c,o);break;case"u16string":this.writeUCS2String(e,this.endianness,o);break;case"u16stringle":this.writeUCS2String(e,a.LITTLE_ENDIAN,o);break;case"u16stringbe":this.writeUCS2String(e,a.BIG_ENDIAN,o);break;default:if(t.length==3){for(var _=t[1],g=0;g<e.length;g++)this.writeType(_,e[g]);break}else{this.writeStruct(t,e);break}}o!=null&&(this.position=u,this._realloc(o),this.position=u+o)},a.prototype.writeUint64=function(t){var e=Math.floor(t/f);this.writeUint32(e),this.writeUint32(t&4294967295)},a.prototype.writeUint24=function(t){this.writeUint8((t&16711680)>>16),this.writeUint8((t&65280)>>8),this.writeUint8(t&255)},a.prototype.adjustUint32=function(t,e){var i=this.position;this.seek(t),this.writeUint32(e),this.seek(i)},a.prototype.mapInt32Array=function(t,e){this._realloc(t*4);var i=new Int32Array(this._buffer,this.byteOffset+this.position,t);return a.arrayToNative(i,e??this.endianness),this.position+=t*4,i},a.prototype.mapInt16Array=function(t,e){this._realloc(t*2);var i=new Int16Array(this._buffer,this.byteOffset+this.position,t);return a.arrayToNative(i,e??this.endianness),this.position+=t*2,i},a.prototype.mapInt8Array=function(t){this._realloc(t*1);var e=new Int8Array(this._buffer,this.byteOffset+this.position,t);return this.position+=t*1,e},a.prototype.mapUint32Array=function(t,e){this._realloc(t*4);var i=new Uint32Array(this._buffer,this.byteOffset+this.position,t);return a.arrayToNative(i,e??this.endianness),this.position+=t*4,i},a.prototype.mapUint16Array=function(t,e){this._realloc(t*2);var i=new Uint16Array(this._buffer,this.byteOffset+this.position,t);return a.arrayToNative(i,e??this.endianness),this.position+=t*2,i},a.prototype.mapFloat64Array=function(t,e){this._realloc(t*8);var i=new Float64Array(this._buffer,this.byteOffset+this.position,t);return a.arrayToNative(i,e??this.endianness),this.position+=t*8,i},a.prototype.mapFloat32Array=function(t,e){this._realloc(t*4);var i=new Float32Array(this._buffer,this.byteOffset+this.position,t);return a.arrayToNative(i,e??this.endianness),this.position+=t*4,i};var d=function(t){this.buffers=[],this.bufferIndex=-1,t&&(this.insertBuffer(t),this.bufferIndex=0)};d.prototype=new a(new ArrayBuffer,0,a.BIG_ENDIAN),d.prototype.initialized=function(){var t;return this.bufferIndex>-1?!0:this.buffers.length>0?(t=this.buffers[0],t.fileStart===0?(this.buffer=t,this.bufferIndex=0,r.debug("MultiBufferStream","Stream ready for parsing"),!0):(r.warn("MultiBufferStream","The first buffer should have a fileStart of 0"),this.logBufferLevel(),!1)):(r.warn("MultiBufferStream","No buffer to start parsing from"),this.logBufferLevel(),!1)},ArrayBuffer.concat=function(t,e){r.debug("ArrayBuffer","Trying to create a new buffer of size: "+(t.byteLength+e.byteLength));var i=new Uint8Array(t.byteLength+e.byteLength);return i.set(new Uint8Array(t),0),i.set(new Uint8Array(e),t.byteLength),i.buffer},d.prototype.reduceBuffer=function(t,e,i){var s;return s=new Uint8Array(i),s.set(new Uint8Array(t,e,i)),s.buffer.fileStart=t.fileStart+e,s.buffer.usedBytes=0,s.buffer},d.prototype.insertBuffer=function(t){for(var e=!0,i=0;i<this.buffers.length;i++){var s=this.buffers[i];if(t.fileStart<=s.fileStart){if(t.fileStart===s.fileStart)if(t.byteLength>s.byteLength){this.buffers.splice(i,1),i--;continue}else r.warn("MultiBufferStream","Buffer (fileStart: "+t.fileStart+" - Length: "+t.byteLength+") already appended, ignoring");else t.fileStart+t.byteLength<=s.fileStart||(t=this.reduceBuffer(t,0,s.fileStart-t.fileStart)),r.debug("MultiBufferStream","Appending new buffer (fileStart: "+t.fileStart+" - Length: "+t.byteLength+")"),this.buffers.splice(i,0,t),i===0&&(this.buffer=t);e=!1;break}else if(t.fileStart<s.fileStart+s.byteLength){var o=s.fileStart+s.byteLength-t.fileStart,c=t.byteLength-o;if(c>0)t=this.reduceBuffer(t,o,c);else{e=!1;break}}}e&&(r.debug("MultiBufferStream","Appending new buffer (fileStart: "+t.fileStart+" - Length: "+t.byteLength+")"),this.buffers.push(t),i===0&&(this.buffer=t))},d.prototype.logBufferLevel=function(t){var e,i,s,o,c=[],u,_="";for(s=0,o=0,e=0;e<this.buffers.length;e++)i=this.buffers[e],e===0?(u={},c.push(u),u.start=i.fileStart,u.end=i.fileStart+i.byteLength,_+="["+u.start+"-"):u.end===i.fileStart?u.end=i.fileStart+i.byteLength:(u={},u.start=i.fileStart,_+=c[c.length-1].end-1+"], ["+u.start+"-",u.end=i.fileStart+i.byteLength,c.push(u)),s+=i.usedBytes,o+=i.byteLength;c.length>0&&(_+=u.end-1+"]");var g=t?r.info:r.debug;this.buffers.length===0?g("MultiBufferStream","No more buffer in memory"):g("MultiBufferStream",""+this.buffers.length+" stored buffer(s) ("+s+"/"+o+" bytes), continuous ranges: "+_)},d.prototype.cleanBuffers=function(){var t,e;for(t=0;t<this.buffers.length;t++)e=this.buffers[t],e.usedBytes===e.byteLength&&(r.debug("MultiBufferStream","Removing buffer #"+t),this.buffers.splice(t,1),t--)},d.prototype.mergeNextBuffer=function(){var t;if(this.bufferIndex+1<this.buffers.length)if(t=this.buffers[this.bufferIndex+1],t.fileStart===this.buffer.fileStart+this.buffer.byteLength){var e=this.buffer.byteLength,i=this.buffer.usedBytes,s=this.buffer.fileStart;return this.buffers[this.bufferIndex]=ArrayBuffer.concat(this.buffer,t),this.buffer=this.buffers[this.bufferIndex],this.buffers.splice(this.bufferIndex+1,1),this.buffer.usedBytes=i,this.buffer.fileStart=s,r.debug("ISOFile","Concatenating buffer for box parsing (length: "+e+"->"+this.buffer.byteLength+")"),!0}else return!1;else return!1},d.prototype.findPosition=function(t,e,i){var s,o=null,c=-1;for(t===!0?s=0:s=this.bufferIndex;s<this.buffers.length&&(o=this.buffers[s],o.fileStart<=e);){c=s,i&&(o.fileStart+o.byteLength<=e?o.usedBytes=o.byteLength:o.usedBytes=e-o.fileStart,this.logBufferLevel());s++}return c!==-1?(o=this.buffers[c],o.fileStart+o.byteLength>=e?(r.debug("MultiBufferStream","Found position in existing buffer #"+c),c):-1):-1},d.prototype.findEndContiguousBuf=function(t){var e,i,s,o=t!==void 0?t:this.bufferIndex;if(i=this.buffers[o],this.buffers.length>o+1)for(e=o+1;e<this.buffers.length&&(s=this.buffers[e],s.fileStart===i.fileStart+i.byteLength);e++)i=s;return i.fileStart+i.byteLength},d.prototype.getEndFilePositionAfter=function(t){var e=this.findPosition(!0,t,!1);return e!==-1?this.findEndContiguousBuf(e):t},d.prototype.addUsedBytes=function(t){this.buffer.usedBytes+=t,this.logBufferLevel()},d.prototype.setAllUsedBytes=function(){this.buffer.usedBytes=this.buffer.byteLength,this.logBufferLevel()},d.prototype.seek=function(t,e,i){var s;return s=this.findPosition(e,t,i),s!==-1?(this.buffer=this.buffers[s],this.bufferIndex=s,this.position=t-this.buffer.fileStart,r.debug("MultiBufferStream","Repositioning parser at buffer position: "+this.position),!0):(r.debug("MultiBufferStream","Position "+t+" not found in buffered data"),!1)},d.prototype.getPosition=function(){if(this.bufferIndex===-1||this.buffers[this.bufferIndex]===null)throw"Error accessing position in the MultiBufferStream";return this.buffers[this.bufferIndex].fileStart+this.position},d.prototype.getLength=function(){return this.byteLength},d.prototype.getEndPosition=function(){if(this.bufferIndex===-1||this.buffers[this.bufferIndex]===null)throw"Error accessing position in the MultiBufferStream";return this.buffers[this.bufferIndex].fileStart+this.byteLength},l.MultiBufferStream=d;var p=function(){var t=3,e=4,i=5,s=6,o=[];o[t]="ES_Descriptor",o[e]="DecoderConfigDescriptor",o[i]="DecoderSpecificInfo",o[s]="SLConfigDescriptor",this.getDescriptorName=function(_){return o[_]};var c=this,u={};return this.parseOneDescriptor=function(_){var g=0,w,S,E;for(w=_.readUint8(),E=_.readUint8();E&128;)g=(E&127)<<7,E=_.readUint8();return g+=E&127,r.debug("MPEG4DescriptorParser","Found "+(o[w]||"Descriptor "+w)+", size "+g+" at position "+_.getPosition()),o[w]?S=new u[o[w]](g):S=new u.Descriptor(g),S.parse(_),S},u.Descriptor=function(_,g){this.tag=_,this.size=g,this.descs=[]},u.Descriptor.prototype.parse=function(_){this.data=_.readUint8Array(this.size)},u.Descriptor.prototype.findDescriptor=function(_){for(var g=0;g<this.descs.length;g++)if(this.descs[g].tag==_)return this.descs[g];return null},u.Descriptor.prototype.parseRemainingDescriptors=function(_){for(var g=_.position;_.position<g+this.size;){var w=c.parseOneDescriptor(_);this.descs.push(w)}},u.ES_Descriptor=function(_){u.Descriptor.call(this,t,_)},u.ES_Descriptor.prototype=new u.Descriptor,u.ES_Descriptor.prototype.parse=function(_){if(this.ES_ID=_.readUint16(),this.flags=_.readUint8(),this.size-=3,this.flags&128?(this.dependsOn_ES_ID=_.readUint16(),this.size-=2):this.dependsOn_ES_ID=0,this.flags&64){var g=_.readUint8();this.URL=_.readString(g),this.size-=g+1}else this.URL="";this.flags&32?(this.OCR_ES_ID=_.readUint16(),this.size-=2):this.OCR_ES_ID=0,this.parseRemainingDescriptors(_)},u.ES_Descriptor.prototype.getOTI=function(_){var g=this.findDescriptor(e);return g?g.oti:0},u.ES_Descriptor.prototype.getAudioConfig=function(_){var g=this.findDescriptor(e);if(!g)return null;var w=g.findDescriptor(i);if(w&&w.data){var S=(w.data[0]&248)>>3;return S===31&&w.data.length>=2&&(S=32+((w.data[0]&7)<<3)+((w.data[1]&224)>>5)),S}else return null},u.DecoderConfigDescriptor=function(_){u.Descriptor.call(this,e,_)},u.DecoderConfigDescriptor.prototype=new u.Descriptor,u.DecoderConfigDescriptor.prototype.parse=function(_){this.oti=_.readUint8(),this.streamType=_.readUint8(),this.bufferSize=_.readUint24(),this.maxBitrate=_.readUint32(),this.avgBitrate=_.readUint32(),this.size-=13,this.parseRemainingDescriptors(_)},u.DecoderSpecificInfo=function(_){u.Descriptor.call(this,i,_)},u.DecoderSpecificInfo.prototype=new u.Descriptor,u.SLConfigDescriptor=function(_){u.Descriptor.call(this,s,_)},u.SLConfigDescriptor.prototype=new u.Descriptor,this};l.MPEG4DescriptorParser=p;var n={ERR_INVALID_DATA:-1,ERR_NOT_ENOUGH_DATA:0,OK:1,BASIC_BOXES:["mdat","idat","free","skip","meco","strk"],FULL_BOXES:["hmhd","nmhd","iods","xml ","bxml","ipro","mere"],CONTAINER_BOXES:[["moov",["trak","pssh"]],["trak"],["edts"],["mdia"],["minf"],["dinf"],["stbl",["sgpd","sbgp"]],["mvex",["trex"]],["moof",["traf"]],["traf",["trun","sgpd","sbgp"]],["vttc"],["tref"],["iref"],["mfra",["tfra"]],["meco"],["hnti"],["hinf"],["strk"],["strd"],["sinf"],["rinf"],["schi"],["trgr"],["udta",["kind"]],["iprp",["ipma"]],["ipco"]],boxCodes:[],fullBoxCodes:[],containerBoxCodes:[],sampleEntryCodes:{},sampleGroupEntryCodes:[],trackGroupTypes:[],UUIDBoxes:{},UUIDs:[],initialize:function(){n.FullBox.prototype=new n.Box,n.ContainerBox.prototype=new n.Box,n.SampleEntry.prototype=new n.Box,n.TrackGroupTypeBox.prototype=new n.FullBox,n.BASIC_BOXES.forEach(function(t){n.createBoxCtor(t)}),n.FULL_BOXES.forEach(function(t){n.createFullBoxCtor(t)}),n.CONTAINER_BOXES.forEach(function(t){n.createContainerBoxCtor(t[0],null,t[1])})},Box:function(t,e,i){this.type=t,this.size=e,this.uuid=i},FullBox:function(t,e,i){n.Box.call(this,t,e,i),this.flags=0,this.version=0},ContainerBox:function(t,e,i){n.Box.call(this,t,e,i),this.boxes=[]},SampleEntry:function(t,e,i,s){n.ContainerBox.call(this,t,e),this.hdr_size=i,this.start=s},SampleGroupEntry:function(t){this.grouping_type=t},TrackGroupTypeBox:function(t,e){n.FullBox.call(this,t,e)},createBoxCtor:function(t,e){n.boxCodes.push(t),n[t+"Box"]=function(i){n.Box.call(this,t,i)},n[t+"Box"].prototy