@helia/verified-fetch 7.2.0 → 7.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -811,6 +811,11 @@ Detailed timing is found in the [Server-Timing](https://developer.mozilla.org/en
811
811
  HTTP header that is returned with every response when a resource is requested
812
812
  with the `withServerTiming` init option set to `true`.
813
813
 
814
+ The `dur` field is in milliseconds, so `dur=100` took 100ms. It is possible
815
+ to measure in greater precision, but given these are network operations it's
816
+ better to limit the precision and have a smaller header size, since
817
+ downloading the headers impacts the time to first byte.
818
+
814
819
  To prevent the header value growing too large, PeerIDs/CIDs are truncated to
815
820
  their first 10 characters and common strings are abbreviated.
816
821
 
@@ -833,7 +838,7 @@ follow.
833
838
  A full header might look like:
834
839
 
835
840
  ```
836
- i;dur=0.000,p;dur=0.000;desc="h,bagqbeaawn",p;dur=0.000;desc="h,bagqbeaawn",p;dur=1.000;desc="h,bagqbeaa7n",p;dur=1.000;desc="h,bagqbeaa7n",f;dur=1.000;desc="h,4",f;dur=1.000;desc="h,4",f;dur=144.000;desc="l,0",f;dur=144.000;desc="l,0",c;dur=206.000;desc="t,bagqbeaa7n,h",b;dur=1.000;desc="t,bagqbeaa7n,bafybeigoc"
841
+ i;dur=0,p;dur=0;desc="h,bagqbeaawn",p;dur=0;desc="h,bagqbeaawn",p;dur=1;desc="h,bagqbeaa7n",p;dur=1;desc="h,bagqbeaa7n",f;dur=1;desc="h,4",f;dur=1;desc="h,4",f;dur=144;desc="l,0",f;dur=144;desc="l,0",c;dur=206;desc="t,bagqbeaa7n,h",b;dur=1;desc="t,bagqbeaa7n,bafybeigoc"
837
842
  ```
838
843
 
839
844
  Here resolving a CID to a CID+path took less than a millisecond (e.g. a bare
package/dist/index.min.js CHANGED
@@ -107,10 +107,10 @@ a=ice-pwd:`+e+t)}catch{}return r}var Gb=v("libp2p-webrtc-noise:");function CL(r,
107
107
  `)),r.linkname!=null&&(e+=F9(" linkpath="+r.linkname+`
108
108
  `));let t=r.pax;if(t!=null)for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e+=F9(" "+n+"="+t[n]+`
109
109
  `));return v(e)}function e6(r){let e=new Uint8Array(512),t=r.name,n="";if(r.typeflag===5&&t[t.length-1]!=="/"&&(t+="/"),v(t).byteLength!==t.length)return null;for(;v(t).byteLength>100;){let o=t.indexOf("/");if(o===-1)return null;n+=n!==""?"/"+t.slice(0,o):t.slice(0,o),t=t.slice(o+1)}return v(t).byteLength>100||v(n).byteLength>155||r.linkname!=null&&v(r.linkname).byteLength>100?null:(e.set(v(t),0),e.set(xa(r.mode&See,6),100),e.set(xa(r.uid,6),108),e.set(xa(r.gid,6),116),e.set(xa(r.size,11),124),e.set(xa(r.mtime.getTime()/1e3|0,11),136),e[156]=bee+_ee(r.type),r.linkname!=null&&e.set(v(r.linkname),157),e.set(Eee,Aee),e.set(vee,Tee),r.uname!=null&&e.set(v(r.uname),265),r.gname!=null&&e.set(v(r.gname),297),e.set(xa(r.devmajor??0,6),329),e.set(xa(r.devminor??0,6),337),n!=null&&e.set(v(n),345),e.set(xa(Iee(e),6),148),e)}var{S_IFMT:kee,S_IFBLK:Ree,S_IFCHR:Pee,S_IFDIR:Dee,S_IFIFO:Nee,S_IFLNK:Lee}=hB.default,Oee=parseInt("755",8),Bee=parseInt("644",8),pB=new Uint8Array(1024);function Mee(r=0){switch(r&kee){case Ree:return"block-device";case Pee:return"character-device";case Dee:return"directory";case Nee:return"fifo";case Lee:return"symlink";default:return"file"}}function H9(r){return r&=511,r!==0?pB.subarray(0,512-r):new Uint8Array(0)}function $9(r){if(r.pax==null){let e=e6(r);if(e!=null)return e}return Uee(r)}function Uee(r){let e=fB(r),t={name:"PaxHeader",mode:r.mode,uid:r.uid,gid:r.gid,size:e.length,mtime:r.mtime,type:"pax-header",linkname:r.linkname,uname:r.uname,gname:r.gname,devmajor:r.devmajor,devminor:r.devminor};return new J(e6(t)??new Uint8Array(0),e,H9(e.length),e6({...t,size:r.size,type:r.type})??new Uint8Array(0)).subarray()}function t6(){return async function*(r){for await(let{header:e,body:t}of r){let n={...e,size:e.type==="symlink"?0:e.size??0,type:e.type??Mee(e.mode),mode:e.mode??(e.type==="directory"?Oee:Bee),uid:e.uid??0,gid:e.gid??0,mtime:e.mtime??new Date};if(typeof t=="string"&&(t=v(t)),t instanceof Uint8Array||Gn(t)){n.size=t.length,yield $9(n),yield Gn(t)?t.subarray():t,yield H9(n.size);continue}if(n.type==="symlink"&&n.linkname==null){if(t==null)throw new Error("type was symlink but no linkname or body specified");n.linkname=L(await Ee(t)),yield $9(n);continue}if(yield $9(n),n.type!=="file"&&n.type!=="contiguous-file")continue;let o=0;for await(let i of t??[])o+=i.length,yield Gn(i)?i.subarray():i;if(o!==n.size)throw new Error(`size mismatch, wrote ${o} of ${n.size} bytes`);yield H9(n.size)}yield pB}}var Fee=["file","raw","directory"];function $ee(r,e){let t,n,o=0n;return(r.type==="file"||r.type==="raw"||r.type==="identity")&&(o=r.size),(r.type==="file"||r.type==="directory")&&(t=r.unixfs.mode,n=r.unixfs.mtime!=null?new Date(Number(r.unixfs.mtime.secs*1000n)):void 0),{name:e,mode:t,mtime:n,size:Number(o),type:r.type==="directory"?"directory":"file"}}function mB(r,e){if(!Fee.includes(r.type))throw new Zc(`${r.type} is not a UnixFS node`);let t={header:$ee(r,e)};return(r.type==="file"||r.type==="raw")&&(t.body=r.content()),t}async function*gB(r,e,t){let n=await sd(ga(r,e,t));if(n==null)throw new T(`Could not walk path "${r}"`);let o=await uo(n.cid,e,t);if(o.type==="file"||o.type==="raw"){yield*hn([mB(o,n.path)],t6());return}if(o.type==="directory"){yield*hn(XO(o.cid,e,t),i=>Nt(i,async s=>{let a=await uo(s.cid,e,t);return mB(a,s.path)}),t6());return}throw new Zc("Not a UnixFS node")}var r6=class extends kr{id="tar-plugin";codes=[];canHandle({accept:e}){return e.some(t=>t.contentType.mediaType===ad)}async handle(e){let{terminalElement:t,url:n,resource:o,blockstore:i,range:s}=e;if(t.cid.code!==it&&t.cid.code!==Fe)return nn(o,new Zc("Only UnixFS data can be returned in a TAR file"));if(s!=null)return nn(o,new Error("Range requests are not supported for TAR files"));let a=so(gB(`/ipfs/${t.cid}${n.pathname}`,i,e));return zn(o,a,{redirected:e.redirected,headers:{"content-type":ad,"content-disposition":`attachment; ${tn(n.searchParams.get("filename")??`${t.cid.toString()}.tar`)}`,"accept-ranges":"none"}})}};function Hee(r,e){let t;try{t=new URL(r.toString())}catch{t=e}if(!t.pathname.endsWith("/"))return t.pathname+="/",t.toString()}var n6=class extends kr{id="unixfs-plugin";codes=[it,Fe];canHandle({terminalElement:e,accept:t}){let n=this.codes.includes(e.cid.code),o=t.length===0||t.some(i=>i.contentType.mediaType===nr||i.contentType.mediaType===zp);return n&&o}async handle(e){let{url:t,resource:n,terminalElement:o,ipfsRoots:i,blockstore:s}=e,a=t.searchParams.get("filename")??o.name,c=e.redirected,l;try{l=await uo(o.cid,s,e)}catch(u){if(e?.signal?.throwIfAborted(),u.name==="BlockNotFoundWhileOfflineError")throw u;return this.log.error("could not export %c - %e",o.cid,u),Qc(n,"Unable to stream content")}if(l.type==="directory"){let u=Hee(n,t);if(u!=null){if(this.log.trace("directory url normalization spec requires redirect"),e?.redirect==="error")throw this.log('could not redirect to %s as redirect option was set to "error"',u),new TypeError("Failed to fetch");if(e?.redirect==="manual")return this.log("returning 301 permanent redirect to %s",u),aB(e.resource,u);this.log("following redirect to %s",u),n=u,c=!0}let d=o.cid;if(e?.supportDirectoryIndexes!==!1){let h="index.html";try{this.log.trace("found directory at %c%s, looking for index.html",d,t.pathname);let p=await e.serverTiming.time("exporter-dir","",sd(ga(`/ipfs/${d}/${h}`,e.blockstore,e)));if(p==null)return Qc(n,"Unable to stream content");let y=await e.serverTiming.time("exporter-dir","",uo(p.cid,e.blockstore,e));return y.type!=="file"&&y.type!=="raw"&&y.type!=="identity"?Qc(n,"Unable to stream content"):(a=h,this.log.trace("found directory index at %c%s with cid %c",d,h,l.cid),await this.streamFile(n,y,a,i,c,e.range,e))}catch(p){if(p.name!=="NotFoundError")throw this.log.error("error loading path %c/%s - %e",d,h,p),p}}let f=await Ee(e.blockstore.get(d,e));return zn(n,f,{headers:{"content-type":zp,"content-length":`${f.byteLength}`,"content-disposition":`${t.searchParams.get("download")==="true"?"attachment":"inline"}; ${tn(`${d}.dir`)}`,"x-ipfs-roots":i.map(h=>h.toV1()).join(","),"accept-ranges":"bytes"},redirected:c})}else return l.type==="file"||l.type==="raw"||l.type==="identity"?(this.log("streaming file"),this.streamFile(n,l,a,i,c,e.range,e)):(this.log.error("cannot stream terminal element type %s",l.type),Qc(n,"Unable to stream content"))}async streamFile(e,t,n,o,i,s,a){let c=nr;return s==null&&(c=await this.detectContentType(t,n,a)),s!=null?cd(e,(l,u)=>t.content({...a??{},offset:l,length:u}),s,t.size,{headers:{"content-type":c,"content-disposition":`inline; ${tn(n)}`,"x-ipfs-roots":o.map(l=>l.toV1()).join(","),"accept-ranges":"bytes"},redirected:i}):zn(e,so(t.content(a)),{headers:{"content-type":c,"content-length":`${t.size}`,"content-disposition":`inline; ${tn(n)}`,"x-ipfs-roots":o.map(l=>l.toV1()).join(","),"accept-ranges":"bytes"},redirected:i})}async detectContentType(e,t,n){let o;if(e.type==="raw"||e.type==="identity"?o=e.node:o=await D2(e.content(n)),o==null)throw new Error("stream ended before first block was read");let i;if(this.pluginOptions.contentTypeParser!=null)try{let s=this.pluginOptions.contentTypeParser(o,t);if(Fl(s)){let a=await s;a!=null&&(i=a)}else s!=null&&(i=s);this.log.trace("contentTypeParser returned %s for file with name %s",i,t)}catch(s){this.log.error("error parsing content type - %e",s)}return i??nr}};var Gp=class extends Map{#e=0;#t=new Map;#r=new Map;#o;#a;#c;constructor(e={}){if(super(),!(e.maxSize&&e.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");if(typeof e.maxAge=="number"&&e.maxAge===0)throw new TypeError("`maxAge` must be a number greater than 0");this.#o=e.maxSize,this.#a=e.maxAge||Number.POSITIVE_INFINITY,this.#c=e.onEviction}get __oldCache(){return this.#r}#l(e){if(typeof this.#c=="function")for(let[t,n]of e)this.#c(t,n.value)}#n(e,t){return typeof t.expiry=="number"&&t.expiry<=Date.now()?(typeof this.#c=="function"&&this.#c(e,t.value),this.delete(e)):!1}#m(e,t){if(this.#n(e,t)===!1)return t.value}#h(e,t){return t.expiry?this.#m(e,t):t.value}#p(e,t){let n=t.get(e);return this.#h(e,n)}#u(e,t){this.#t.set(e,t),this.#e++,this.#e>=this.#o&&(this.#e=0,this.#l(this.#r),this.#r=this.#t,this.#t=new Map)}#d(e,t){this.#r.delete(e),this.#u(e,t)}*#i(){for(let e of this.#r){let[t,n]=e;this.#t.has(t)||this.#n(t,n)===!1&&(yield e)}for(let e of this.#t){let[t,n]=e;this.#n(t,n)===!1&&(yield e)}}get(e){if(this.#t.has(e)){let t=this.#t.get(e);return this.#h(e,t)}if(this.#r.has(e)){let t=this.#r.get(e);if(this.#n(e,t)===!1)return this.#d(e,t),t.value}}set(e,t,{maxAge:n=this.#a}={}){let o=typeof n=="number"&&n!==Number.POSITIVE_INFINITY?Date.now()+n:void 0;return this.#t.has(e)?this.#t.set(e,{value:t,expiry:o}):this.#u(e,{value:t,expiry:o}),this}has(e){return this.#t.has(e)?!this.#n(e,this.#t.get(e)):this.#r.has(e)?!this.#n(e,this.#r.get(e)):!1}peek(e){if(this.#t.has(e))return this.#p(e,this.#t);if(this.#r.has(e))return this.#p(e,this.#r)}expiresIn(e){let t=this.#t.get(e)??this.#r.get(e);if(t)return t.expiry?t.expiry-Date.now():Number.POSITIVE_INFINITY}delete(e){let t=this.#t.delete(e);return t&&this.#e--,this.#r.delete(e)||t}clear(){this.#t.clear(),this.#r.clear(),this.#e=0}resize(e){if(!(e&&e>0))throw new TypeError("`maxSize` must be a number greater than 0");let t=[...this.#i()],n=t.length-e;n<0?(this.#t=new Map(t),this.#r=new Map,this.#e=t.length):(n>0&&this.#l(t.slice(0,n)),this.#r=new Map(t.slice(n)),this.#t=new Map,this.#e=0),this.#o=e}evict(e=1){let t=Number(e);if(!t||t<=0)return;let n=[...this.#i()],o=Math.trunc(Math.min(t,Math.max(n.length-1,0)));o<=0||(this.#l(n.slice(0,o)),this.#r=new Map(n.slice(o)),this.#t=new Map,this.#e=0)}*keys(){for(let[e]of this)yield e}*values(){for(let[,e]of this)yield e}*[Symbol.iterator](){for(let e of this.#t){let[t,n]=e;this.#n(t,n)===!1&&(yield[t,n.value])}for(let e of this.#r){let[t,n]=e;this.#t.has(t)||this.#n(t,n)===!1&&(yield[t,n.value])}}*entriesDescending(){let e=[...this.#t];for(let t=e.length-1;t>=0;--t){let n=e[t],[o,i]=n;this.#n(o,i)===!1&&(yield[o,i.value])}e=[...this.#r];for(let t=e.length-1;t>=0;--t){let n=e[t],[o,i]=n;this.#t.has(o)||this.#n(o,i)===!1&&(yield[o,i.value])}}*entriesAscending(){for(let[e,t]of this.#i())yield[e,t.value]}get size(){if(!this.#e)return this.#r.size;let e=0;for(let t of this.#r.keys())this.#t.has(t)||e++;return Math.min(this.#e+e,this.#o)}get maxSize(){return this.#o}get maxAge(){return this.#a}entries(){return this.entriesAscending()}forEach(e,t=this){for(let[n,o]of this.entriesAscending())e.call(t,o,n,this)}get[Symbol.toStringTag](){return"QuickLRU"}toString(){return`QuickLRU(${this.size}/${this.maxSize})`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}};var Vee={"ipfs.resolve":"i","dnsLink.resolve":"d","ipns.resolve":"n","found-provider":"p","find-providers":"f",connect:"c",block:"b","http-gateway-router":"h","libp2p-router":"l","trustless-gateway":"t",bitswap:"b"};function Kn(r){return Vee[r]??r}function yB(r){return Zi.exactMatch(r)?"t":t2.exactMatch(r)||r2.exactMatch(r)?"h":Oo.exactMatch(r)||Ji.exactMatch(r)?"w":Ec.exactMatch(r)?"r":bc.exactMatch(r)?"d":fC.exactMatch(r)||e2.exactMatch(r)?"q":sh.exactMatch(r)?"b":"u"}var _F=ir(SF(),1);var Lne=[200,301,302,303,307,308,404,410,451],AF=65536;function IF(r,e,t={}){try{if(e.length>AF)throw new V4(`_redirects file size cannot exceed ${AF} bytes`);let n=e.split(`
110
- `).filter(o=>(o=o.trim(),o!==""&&!o.startsWith("#"))).map(o=>{let[i,s,a]=o.split(/\s+/).map(f=>f.trim());if(a!=null&&a!==""&&!a.match(/^\d+$/))throw new q4("Invalid status code in _redirects file");let c=parseInt(a);if(isNaN(c)&&(c=301),!Lne.includes(c))throw new z4(`Status code ${c} is not allowed`);let l=new Set,u=i.split("/"),d=u.map((f,h)=>{if(f.startsWith(":")){let p=f.substring(1);if(l.has(p))throw new K4("Duplicate placeholders in from path");return l.add(p),`(?<${p}>[^/]+)`}return f==="*"&&h===u.length-1?"(?<splat>.+)":(0,_F.default)(f)}).join("\\/");return{from:new RegExp(d),to:s,status:c}});for(let{from:o,to:i,status:s}of n){let a=r.pathname.match(o);if(a!=null)return One(r,i,s,a.groups,t)}}catch(n){return new Response(JSON.stringify(Xc(n),null,2),{status:500})}}function One(r,e,t,n,o={}){if(o.redirect==="error")throw new TypeError("Failed to fetch");if(n!=null)for(let[c,l]of Object.entries(n))e=e.replaceAll(`:${c}`,l);let i=Bne(r,new URL(`${r.protocol}//${r.host}${e}`)),s=new URL(`${r.protocol}//${r.host}${e}`),a=new URL(`${r.protocol}//${r.host}${s.pathname}${Mne(i)}${r.hash}`);return o.redirect==="manual"?new Response("",{status:t,headers:{location:a.toString()}}):a}function Bne(r,e){let t={};for(let[n,o]of r.searchParams)e.searchParams.delete(n),TF(n,o,t);for(let[n,o]of e.searchParams)TF(n,o,t);return t}function TF(r,e,t){typeof t[r]=="string"&&(t[r]=[t[r]]),Array.isArray(t[r])?t[r].push(e):t[r]=e}function Mne(r){let e=[...Object.entries(r)].map(([t,n])=>(Array.isArray(n)||(n=[n]),n.map(o=>`${encodeURIComponent(t)}=${encodeURIComponent(o)}`).join("&"))).join("&");return e===""?e:`?${e}`}var wd=class{headers;precision;constructor(){this.headers=[],this.precision=3}getHeader(){return this.headers.join(",")}async time(e,t,n){let o=performance.now();try{return await n}finally{let s=(performance.now()-o).toFixed(this.precision);this.add(e,t,s)}}add(e,t,n){this.headers.push(`${e};dur=${Number(n).toFixed(this.precision)}${t===""?"":`;desc="${t}"`}`)}};var Une=29030400;function Fne(r){return{cid:r,name:r.toString(),path:r.toString(),roots:[r],remainder:[]}}var v6=class{log;components;blockstoreSessions;constructor(e,t={}){this.components=e,this.log=e.helia.logger.forComponent("helia-verified-fetch:url-resolver"),this.blockstoreSessions=new Gp({maxSize:t.sessionCacheSize??100,maxAge:t.sessionTTLms??6e4,onEviction:(n,o)=>{o.close()}})}async resolve(e,t=new wd,n={}){if(e.protocol==="ipfs:")return this.resolveIPFSPath(e,t,n);if(e.protocol==="ipns:")return this.resolveIPNSName(e,t,n);if(e.protocol==="dnslink:")return this.resolveDNSLink(e,t,n);throw new co(`Invalid resource. Unsupported protocol in URL, must be ipfs:, ipns:, or dnslink: ${e}`)}async getBlockstore(e,t={}){if(t.session===!1)return this.components.helia.blockstore;let n=`ipfs:${e}`,o=this.blockstoreSessions.get(n),i=!1;if(o==null&&(this.log("create session with %d initial providers for root %c",t.providers?.length??0,e),i=!0,o=this.components.helia.blockstore.createSession(e,t),this.blockstoreSessions.set(n,o)),!i&&t.providers!=null&&t.providers.length>0){this.log("adding %d providers to existing session for root %c",t.providers.length,e);try{let s=await Promise.all(t.providers.map(async a=>{await o.addPeer(a,t)})??[]);this.log("result was %o",s)}catch(s){this.log.error("could not add provs - %e",s)}}return o}async resolveDNSLink(e,t,n){let i=(await t.time(Kn("dnsLink.resolve"),"",this.components.dnsLink.resolve(e.hostname,n)))?.[0];if(i==null)throw new TypeError(`Invalid resource. Cannot resolve DNSLink from domain: ${e.hostname}`);let s,a=CF(`${i.path}/${e.pathname}`);if(i.namespace==="ipns"){let c=new URL(`ipns://${i.peerId}${a}`);s=await this.resolveIPNSName(c,t,n)}else if(i.namespace==="ipfs"){let c=new URL(`ipfs://${i.cid}${a}`);s=await this.resolveIPFSPath(c,t,n)}else throw new TypeError(`Invalid resource. Unexpected DNSLink namespace ${i.namespace} from domain: ${e.hostname}`);return s instanceof Response?s:{...s,url:e,ttl:i.answer.TTL}}async resolveIPNSName(e,t,n){let o=De(e.hostname),i=await t.time(Kn("ipns.resolve"),"",this.components.ipnsResolver.resolve(o,n)),s=CF(`${i.path??""}/${e.pathname}`),a=new URL(`ipfs://${i.cid}${s}`),c=await this.resolveIPFSPath(a,t,n);return c instanceof Response?c:{...c,url:e,ttl:Number((i.record.ttl??0n)/BigInt(1e9))}}async resolveIPFSPath(e,t,n){let o=await t.time(Kn("ipfs.resolve"),"",this.walkPath(e,n));if(o instanceof Response)return o;if(o.terminalElement.cid.code===114){let i=new URL(`ipns://${$r(o.terminalElement.cid)}`),s=await this.resolveIPNSName(i,t,n);return s instanceof Response?s:{...s,url:e}}return{...o,url:e,ttl:Une,blockstore:o.blockstore}}async walkPath(e,t={}){let n;try{n=q.parse(e.hostname)}catch(i){throw new co(`Could not parse CID - ${i}`)}let o=await this.getBlockstore(n,t);try{let i=[],s,a=$ne(e);for await(let c of ga(a,o,{...t,yieldSubShards:!0}))i.push(c.cid),s=c;if(s==null)throw new J4("No terminal element found");return{ipfsRoots:i,terminalElement:s,blockstore:o,redirected:t.redirected===!0}}catch(i){if(i.name==="NotFoundError"&&t.redirected!==!0){let s;try{s=await uo(`${n}/_redirects`,o,t)}catch(a){if(a.name!=="NotFoundError")throw a}if(s?.type==="file"||s?.type==="raw"){let a=L(await Ee(s.content(t))),c=IF(e,a,t);if(c instanceof Response)return c;if(c instanceof URL)return this.walkPath(c,{...t,redirected:!0})}}if(i.name==="NoResolverError")return{ipfsRoots:[n],terminalElement:Fne(n),blockstore:o,redirected:!1};throw i}}};function $ne(r){return`/ipfs/${r.hostname}${decodeURI(r.pathname)}`}function CF(r){return r=r.split("/").map(e=>e.trim()).filter(Boolean).join("/"),r!==""?`/${r}`:""}var DF=ir(kF(),1);var RF={128:"\u20AC",130:"\u201A",131:"\u0192",132:"\u201E",133:"\u2026",134:"\u2020",135:"\u2021",136:"\u02C6",137:"\u2030",138:"\u0160",139:"\u2039",140:"\u0152",142:"\u017D",145:"\u2018",146:"\u2019",147:"\u201C",148:"\u201D",149:"\u2022",150:"\u2013",151:"\u2014",152:"\u02DC",153:"\u2122",154:"\u0161",155:"\u203A",156:"\u0153",158:"\u017E",159:"\u0178"},Hne={};for(let[r,e]of Object.entries(RF))Hne[e]=Number.parseInt(r,10);var S6;function Vne(){if(!(typeof globalThis.TextDecoder>"u"))return S6??(S6=new globalThis.TextDecoder("utf-8"))}var xd=32*1024,Go=65533;function PF(r,e="utf-8"){switch(e.toLowerCase()){case"utf-8":case"utf8":{let t=Vne();return t?t.decode(r):zne(r)}case"utf-16le":return Kne(r);case"us-ascii":case"ascii":return Gne(r);case"latin1":case"iso-8859-1":return Wne(r);case"windows-1252":return jne(r);default:throw new RangeError(`Encoding '${e}' not supported`)}}function _E(r,e){e.length!==0&&(r.push(String.fromCharCode.apply(null,e)),e.length=0)}function Ot(r,e,t){e.push(t),e.length>=xd&&_E(r,e)}function qne(r,e,t){if(t<=65535){Ot(r,e,t);return}t-=65536,Ot(r,e,55296+(t>>10)),Ot(r,e,56320+(t&1023))}function zne(r){let e=[],t=[],n=0;for(r.length>=3&&r[0]===239&&r[1]===187&&r[2]===191&&(n=3);n<r.length;){let o=r[n];if(o<=127){Ot(e,t,o),n++;continue}if(o<194||o>244){Ot(e,t,Go),n++;continue}if(o<=223){if(n+1>=r.length){Ot(e,t,Go),n++;continue}let u=r[n+1];if((u&192)!==128){Ot(e,t,Go),n++;continue}let d=(o&31)<<6|u&63;Ot(e,t,d),n+=2;continue}if(o<=239){if(n+2>=r.length){Ot(e,t,Go),n++;continue}let u=r[n+1],d=r[n+2];if(!((u&192)===128&&(d&192)===128&&!(o===224&&u<160)&&!(o===237&&u>=160))){Ot(e,t,Go),n++;continue}let h=(o&15)<<12|(u&63)<<6|d&63;Ot(e,t,h),n+=3;continue}if(n+3>=r.length){Ot(e,t,Go),n++;continue}let i=r[n+1],s=r[n+2],a=r[n+3];if(!((i&192)===128&&(s&192)===128&&(a&192)===128&&!(o===240&&i<144)&&!(o===244&&i>143))){Ot(e,t,Go),n++;continue}let l=(o&7)<<18|(i&63)<<12|(s&63)<<6|a&63;qne(e,t,l),n+=4}return _E(e,t),e.join("")}function Kne(r){let e=[],t=[],n=r.length,o=0;for(;o+1<n;){let i=r[o]|r[o+1]<<8;if(o+=2,i>=55296&&i<=56319){if(o+1<n){let s=r[o]|r[o+1]<<8;s>=56320&&s<=57343?(Ot(e,t,i),Ot(e,t,s),o+=2):Ot(e,t,Go)}else Ot(e,t,Go);continue}if(i>=56320&&i<=57343){Ot(e,t,Go);continue}Ot(e,t,i)}return o<n&&Ot(e,t,Go),_E(e,t),e.join("")}function Gne(r){let e=[];for(let t=0;t<r.length;t+=xd){let n=Math.min(r.length,t+xd),o=new Array(n-t);for(let i=t,s=0;i<n;i++,s++)o[s]=r[i]&127;e.push(String.fromCharCode.apply(null,o))}return e.join("")}function Wne(r){let e=[];for(let t=0;t<r.length;t+=xd){let n=Math.min(r.length,t+xd),o=new Array(n-t);for(let i=t,s=0;i<n;i++,s++)o[s]=r[i];e.push(String.fromCharCode.apply(null,o))}return e.join("")}function jne(r){let e=[],t="";for(let n=0;n<r.length;n++){let o=r[n],i=o>=128&&o<=159?RF[o]:void 0;t+=i??String.fromCharCode(o),t.length>=xd&&(e.push(t),t="")}return t&&e.push(t),e.join("")}function on(r){return new DataView(r.buffer,r.byteOffset)}var NF={len:1,get(r,e){return on(r).getUint8(e)},put(r,e,t){return on(r).setUint8(e,t),e+1}},bt={len:2,get(r,e){return on(r).getUint16(e,!0)},put(r,e,t){return on(r).setUint16(e,t,!0),e+2}},el={len:2,get(r,e){return on(r).getUint16(e)},put(r,e,t){return on(r).setUint16(e,t),e+2}};var gt={len:4,get(r,e){return on(r).getUint32(e,!0)},put(r,e,t){return on(r).setUint32(e,t,!0),e+4}},IE={len:4,get(r,e){return on(r).getUint32(e)},put(r,e,t){return on(r).setUint32(e,t),e+4}};var LF={len:4,get(r,e){return on(r).getInt32(e)},put(r,e,t){return on(r).setInt32(e,t),e+4}};var OF={len:8,get(r,e){return on(r).getBigUint64(e,!0)},put(r,e,t){return on(r).setBigUint64(e,t,!0),e+8}};var sn=class{constructor(e,t){this.len=e,this.encoding=t}get(e,t=0){let n=e.subarray(t,t+this.len);return PF(n,this.encoding)}};var Xne="End-Of-Stream",je=class extends Error{constructor(){super(Xne),this.name="EndOfStreamError"}},tl=class extends Error{constructor(e="The operation was aborted"){super(e),this.name="AbortError"}};var rl=class{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(e,t=!1){let n=await this.read(e,t);return this.peekQueue.push(e.subarray(0,n)),n}async read(e,t=!1){if(e.length===0)return 0;let n=this.readFromPeekBuffer(e);if(this.endOfStream||(n+=await this.readRemainderFromStream(e.subarray(n),t)),n===0&&!t)throw new je;return n}readFromPeekBuffer(e){let t=e.length,n=0;for(;this.peekQueue.length>0&&t>0;){let o=this.peekQueue.pop();if(!o)throw new Error("peekData should be defined");let i=Math.min(o.length,t);e.set(o.subarray(0,i),n),n+=i,t-=i,i<o.length&&this.peekQueue.push(o.subarray(i))}return n}async readRemainderFromStream(e,t){let n=0;for(;n<e.length&&!this.endOfStream;){if(this.interrupted)throw new tl;let o=await this.readFromStream(e.subarray(n),t);if(o===0)break;n+=o}if(!t&&n<e.length)throw new je;return n}};var A6=class extends rl{constructor(e){super(),this.reader=e}async abort(){return this.close()}async close(){this.reader.releaseLock()}};var e1=class extends A6{async readFromStream(e,t){if(e.length===0)return 0;let n=await this.reader.read(new Uint8Array(e.length),{min:t?void 0:e.length});return n.done&&(this.endOfStream=n.done),n.value?(e.set(n.value),n.value.length):0}};var bd=class extends rl{constructor(e){super(),this.reader=e,this.buffer=null}writeChunk(e,t){let n=Math.min(t.length,e.length);return e.set(t.subarray(0,n)),n<t.length?this.buffer=t.subarray(n):this.buffer=null,n}async readFromStream(e,t){if(e.length===0)return 0;let n=0;for(this.buffer&&(n+=this.writeChunk(e,this.buffer));n<e.length&&!this.endOfStream;){let o=await this.reader.read();if(o.done){this.endOfStream=!0;break}o.value&&(n+=this.writeChunk(e.subarray(n),o.value))}if(!t&&n===0&&this.endOfStream)throw new je;return n}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}};function CE(r){try{let e=r.getReader({mode:"byob"});return e instanceof ReadableStreamDefaultReader?new bd(e):new e1(e)}catch(e){if(e instanceof TypeError)return new bd(r.getReader());throw e}}var ps=class{constructor(e){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=e?.onClose,e?.abortSignal&&e.abortSignal.addEventListener("abort",()=>{this.abort()})}async readToken(e,t=this.position){let n=new Uint8Array(e.len);if(await this.readBuffer(n,{position:t})<e.len)throw new je;return e.get(n,0)}async peekToken(e,t=this.position){let n=new Uint8Array(e.len);if(await this.peekBuffer(n,{position:t})<e.len)throw new je;return e.get(n,0)}async readNumber(e){if(await this.readBuffer(this.numBuffer,{length:e.len})<e.len)throw new je;return e.get(this.numBuffer,0)}async peekNumber(e){if(await this.peekBuffer(this.numBuffer,{length:e.len})<e.len)throw new je;return e.get(this.numBuffer,0)}async ignore(e){if(e<0)throw new RangeError("ignore length must be \u2265 0 bytes");if(this.fileInfo.size!==void 0){let t=this.fileInfo.size-this.position;if(e>t)return this.position+=t,t}return this.position+=e,e}async close(){await this.abort(),await this.onClose?.()}normalizeOptions(e,t){if(!this.supportsRandomAccess()&&t&&t.position!==void 0&&t.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return{mayBeLess:!1,offset:0,length:e.length,position:this.position,...t}}abort(){return Promise.resolve()}};var Zne=256e3,T6=class extends ps{constructor(e,t){super(t),this.streamReader=e,this.fileInfo=t?.fileInfo??{}}async readBuffer(e,t){let n=this.normalizeOptions(e,t),o=n.position-this.position;if(o>0)return await this.ignore(o),this.readBuffer(e,t);if(o<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(n.length===0)return 0;let i=await this.streamReader.read(e.subarray(0,n.length),n.mayBeLess);if(this.position+=i,(!t||!t.mayBeLess)&&i<n.length)throw new je;return i}async peekBuffer(e,t){let n=this.normalizeOptions(e,t),o=0;if(n.position){let i=n.position-this.position;if(i>0){let s=new Uint8Array(n.length+i);return o=await this.peekBuffer(s,{mayBeLess:n.mayBeLess}),e.set(s.subarray(i)),o-i}if(i<0)throw new Error("Cannot peek from a negative offset in a stream")}if(n.length>0){try{o=await this.streamReader.peek(e.subarray(0,n.length),n.mayBeLess)}catch(i){if(t?.mayBeLess&&i instanceof je)return 0;throw i}if(!n.mayBeLess&&o<n.length)throw new je}return o}async ignore(e){if(e<0)throw new RangeError("ignore length must be \u2265 0 bytes");let t=Math.min(Zne,e),n=new Uint8Array(t),o=0;for(;o<e;){let i=e-o,s=await this.readBuffer(n,{length:Math.min(t,i)});if(s<0)return s;o+=s}return o}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}};var _6=class extends ps{constructor(e,t){super(t),this.uint8Array=e,this.fileInfo={...t?.fileInfo??{},size:e.length}}async readBuffer(e,t){t?.position&&(this.position=t.position);let n=await this.peekBuffer(e,t);return this.position+=n,n}async peekBuffer(e,t){let n=this.normalizeOptions(e,t),o=Math.min(this.uint8Array.length-n.position,n.length);if(!n.mayBeLess&&o<n.length)throw new je;return e.set(this.uint8Array.subarray(n.position,n.position+o)),o}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}};var I6=class extends ps{constructor(e,t){super(t),this.blob=e,this.fileInfo={...t?.fileInfo??{},size:e.size,mimeType:e.type}}async readBuffer(e,t){t?.position&&(this.position=t.position);let n=await this.peekBuffer(e,t);return this.position+=n,n}async peekBuffer(e,t){let n=this.normalizeOptions(e,t),o=Math.min(this.blob.size-n.position,n.length);if(!n.mayBeLess&&o<n.length)throw new je;let i=await this.blob.slice(n.position,n.position+o).arrayBuffer();return e.set(new Uint8Array(i)),o}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}};function BF(r,e){let t=CE(r),n=e??{},o=n.onClose;return n.onClose=async()=>{if(await t.close(),o)return o()},new T6(t,n)}function MF(r,e){return new _6(r,e)}function UF(r,e){return new I6(r,e)}var WF=ir(qF(),1);var ol={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},kE={get(r){return{signature:gt.get(r,0),compressedSize:gt.get(r,8),uncompressedSize:gt.get(r,12)}},len:16},zF={get(r){let e=bt.get(r,6);return{signature:gt.get(r,0),minVersion:bt.get(r,4),dataDescriptor:!!(e&8),compressedMethod:bt.get(r,8),compressedSize:gt.get(r,18),uncompressedSize:gt.get(r,22),filenameLength:bt.get(r,26),extraFieldLength:bt.get(r,28),filename:null}},len:30},KF={get(r){return{signature:gt.get(r,0),nrOfThisDisk:bt.get(r,4),nrOfThisDiskWithTheStart:bt.get(r,6),nrOfEntriesOnThisDisk:bt.get(r,8),nrOfEntriesOfSize:bt.get(r,10),sizeOfCd:gt.get(r,12),offsetOfStartOfCd:gt.get(r,16),zipFileCommentLength:bt.get(r,20)}},len:22},GF={get(r){let e=bt.get(r,8);return{signature:gt.get(r,0),minVersion:bt.get(r,6),dataDescriptor:!!(e&8),compressedMethod:bt.get(r,10),compressedSize:gt.get(r,20),uncompressedSize:gt.get(r,24),filenameLength:bt.get(r,28),extraFieldLength:bt.get(r,30),fileCommentLength:bt.get(r,32),relativeOffsetOfLocalHeader:gt.get(r,42),filename:null}},len:46};function jF(r){let e=new Uint8Array(gt.len);return gt.put(e,0,r),e}var vi=(0,WF.default)("tokenizer:inflate"),RE=256*1024,foe=jF(ol.DataDescriptor),R6=jF(ol.EndOfCentralDirectory),il=class r{constructor(e){this.tokenizer=e,this.syncBuffer=new Uint8Array(RE)}async isZip(){return await this.peekSignature()===ol.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(gt)}async findEndOfCentralDirectoryLocator(){let e=this.tokenizer,t=Math.min(16*1024,e.fileInfo.size),n=this.syncBuffer.subarray(0,t);await this.tokenizer.readBuffer(n,{position:e.fileInfo.size-t});for(let o=n.length-4;o>=0;o--)if(n[o]===R6[0]&&n[o+1]===R6[1]&&n[o+2]===R6[2]&&n[o+3]===R6[3])return e.fileInfo.size-t+o;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){vi("Cannot reading central-directory without random-read support");return}vi("Reading central-directory...");let e=this.tokenizer.position,t=await this.findEndOfCentralDirectoryLocator();if(t>0){vi("Central-directory 32-bit signature found");let n=await this.tokenizer.readToken(KF,t),o=[];this.tokenizer.setPosition(n.offsetOfStartOfCd);for(let i=0;i<n.nrOfEntriesOfSize;++i){let s=await this.tokenizer.readToken(GF);if(s.signature!==ol.CentralFileHeader)throw new Error("Expected Central-File-Header signature");s.filename=await this.tokenizer.readToken(new sn(s.filenameLength,"utf-8")),await this.tokenizer.ignore(s.extraFieldLength),await this.tokenizer.ignore(s.fileCommentLength),o.push(s),vi(`Add central-directory file-entry: n=${i+1}/${o.length}: filename=${o[i].filename}`)}return this.tokenizer.setPosition(e),o}this.tokenizer.setPosition(e)}async unzip(e){let t=await this.readCentralDirectory();if(t)return this.iterateOverCentralDirectory(t,e);let n=!1;do{let o=await this.readLocalFileHeader();if(!o)break;let i=e(o);n=!!i.stop;let s;if(await this.tokenizer.ignore(o.extraFieldLength),o.dataDescriptor&&o.compressedSize===0){let a=[],c=RE;vi("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let l=-1;for(;l<0&&c===RE;){c=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),l=hoe(this.syncBuffer.subarray(0,c),foe);let u=l>=0?l:c;if(i.handler){let d=new Uint8Array(u);await this.tokenizer.readBuffer(d),a.push(d)}else await this.tokenizer.ignore(u)}vi(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),i.handler&&await this.inflate(o,poe(a),i.handler)}else i.handler?(vi(`Reading compressed-file-data: ${o.compressedSize} bytes`),s=new Uint8Array(o.compressedSize),await this.tokenizer.readBuffer(s),await this.inflate(o,s,i.handler)):(vi(`Ignoring compressed-file-data: ${o.compressedSize} bytes`),await this.tokenizer.ignore(o.compressedSize));if(vi(`Reading data-descriptor at pos=${this.tokenizer.position}`),o.dataDescriptor&&(await this.tokenizer.readToken(kE)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-kE.len}`)}while(!n)}async iterateOverCentralDirectory(e,t){for(let n of e){let o=t(n);if(o.handler){this.tokenizer.setPosition(n.relativeOffsetOfLocalHeader);let i=await this.readLocalFileHeader();if(i){await this.tokenizer.ignore(i.extraFieldLength);let s=new Uint8Array(n.compressedSize);await this.tokenizer.readBuffer(s),await this.inflate(i,s,o.handler)}}if(o.stop)break}}async inflate(e,t,n){if(e.compressedMethod===0)return n(t);if(e.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${e.compressedMethod}`);vi(`Decompress filename=${e.filename}, compressed-size=${t.length}`);let o=await r.decompressDeflateRaw(t);return n(o)}static async decompressDeflateRaw(e){let t=new ReadableStream({start(i){i.enqueue(e),i.close()}}),n=new DecompressionStream("deflate-raw"),o=t.pipeThrough(n);try{let s=await new Response(o).arrayBuffer();return new Uint8Array(s)}catch(i){let s=i instanceof Error?`Failed to deflate ZIP entry: ${i.message}`:"Unknown decompression error in ZIP entry";throw new TypeError(s)}}async readLocalFileHeader(){let e=await this.tokenizer.peekToken(gt);if(e===ol.LocalFileHeader){let t=await this.tokenizer.readToken(zF);return t.filename=await this.tokenizer.readToken(new sn(t.filenameLength,"utf-8")),t}if(e===ol.CentralFileHeader)return!1;throw e===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}};function hoe(r,e){let t=r.length,n=e.length;if(n>t)return-1;for(let o=0;o<=t-n;o++){let i=!0;for(let s=0;s<n;s++)if(r[o+s]!==e[s]){i=!1;break}if(i)return o}return-1}function poe(r){let e=r.reduce((o,i)=>o+i.length,0),t=new Uint8Array(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}var t1=class{constructor(e){this.tokenizer=e}inflate(){let e=this.tokenizer;return new ReadableStream({async pull(t){let n=new Uint8Array(1024),o=await e.readBuffer(n,{mayBeLess:!0});if(o===0){t.close();return}t.enqueue(n.subarray(0,o))}}).pipeThrough(new DecompressionStream("gzip"))}};var SXe={utf8:new globalThis.TextDecoder("utf8")};var AXe=new globalThis.TextEncoder;var TXe=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function PE(r){let{byteLength:e}=r;if(e===6)return r.getUint16(0)*2**32+r.getUint32(2);if(e===5)return r.getUint8(0)*2**32+r.getUint32(1);if(e===4)return r.getUint32(0);if(e===3)return r.getUint8(0)*2**16+r.getUint16(1);if(e===2)return r.getUint16(0);if(e===1)return r.getUint8(0)}function YF(r,e){if(e==="utf-16le"){let t=[];for(let n=0;n<r.length;n++){let o=r.charCodeAt(n);t.push(o&255,o>>8&255)}return t}if(e==="utf-16be"){let t=[];for(let n=0;n<r.length;n++){let o=r.charCodeAt(n);t.push(o>>8&255,o&255)}return t}return[...r].map(t=>t.charCodeAt(0))}function XF(r,e=0){let t=Number.parseInt(new sn(6).get(r,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(t))return!1;let n=256;for(let o=e;o<e+148;o++)n+=r[o];for(let o=e+156;o<e+512;o++)n+=r[o];return t===n}var QF={get:(r,e)=>r[e+3]&127|r[e+2]<<7|r[e+1]<<14|r[e]<<21,len:4};var ZF=["jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","elf","macho","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ttc","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","j2c","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp","aac","mp1","it","s3m","xm","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc","fbx","vsdx","vtt","apk","drc","lz4","potx","xltx","dotx","xltm","ott","ots","otp","odg","otg","xlsm","docm","dotm","potm","pptm","jar","jmp","rm","sav","ppsm","ppsx","tar.gz","reg","dat"],JF=["image/jpeg","image/png","image/gif","image/webp","image/flif","image/x-xcf","image/x-canon-cr2","image/x-canon-cr3","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/x-indesign","application/epub+zip","application/x-xpinstall","application/vnd.ms-powerpoint.slideshow.macroenabled.12","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.slideshow","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/vnd.apache.arrow.file","video/mp4","audio/midi","video/matroska","video/webm","video/quicktime","video/vnd.avi","audio/wav","audio/qcelp","audio/x-ms-asf","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","video/ogg","audio/ogg","audio/ogg; codecs=opus","application/ogg","audio/flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-elf","application/x-mach-binary","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","font/collection","image/x-icon","video/x-flv","application/postscript","application/eps","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-cfb","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/j2c","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/icns","image/ktx","application/dicom","audio/x-musepack","text/calendar","text/vcard","text/vtt","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a","image/apng","image/x-olympus-orf","image/x-sony-arw","image/x-adobe-dng","image/x-nikon-nef","image/x-panasonic-rw2","image/x-fujifilm-raf","video/x-m4v","video/3gpp2","application/x-esri-shape","audio/aac","audio/x-it","audio/x-s3m","audio/x-xm","video/MP1S","video/MP2P","application/vnd.sketchup.skp","image/avif","application/x-lzh-compressed","application/pgp-encrypted","application/x-asar","model/stl","application/vnd.ms-htmlhelp","model/3mf","image/jxl","application/zstd","image/jls","application/vnd.ms-outlook","image/vnd.dwg","application/vnd.apache.parquet","application/java-vm","application/x-arj","application/x-cpio","application/x-ace-compressed","application/avro","application/vnd.iccprofile","application/x.autodesk.fbx","application/vnd.visio","application/vnd.android.package-archive","application/vnd.google.draco","application/x-lz4","application/vnd.openxmlformats-officedocument.presentationml.template","application/vnd.openxmlformats-officedocument.spreadsheetml.template","application/vnd.openxmlformats-officedocument.wordprocessingml.template","application/vnd.ms-excel.template.macroenabled.12","application/vnd.oasis.opendocument.text-template","application/vnd.oasis.opendocument.spreadsheet-template","application/vnd.oasis.opendocument.presentation-template","application/vnd.oasis.opendocument.graphics","application/vnd.oasis.opendocument.graphics-template","application/vnd.ms-excel.sheet.macroenabled.12","application/vnd.ms-word.document.macroenabled.12","application/vnd.ms-word.template.macroenabled.12","application/vnd.ms-powerpoint.template.macroenabled.12","application/vnd.ms-powerpoint.presentation.macroenabled.12","application/java-archive","application/vnd.rn-realmedia","application/x-spss-sav","application/x-ms-regedit","application/x-ft-windows-registry-hive","application/x-jmp-data"];var r1=4100,moe=r1-2,Ai=1024*1024,e$=1024,goe=2**31-1,fo=16*1024*1024,D6=Ai,t$=Ai,yoe=fo,woe=1,r$=100,DE=fo,n$=64,o$=D6,xoe=256,boe=512,Eoe=fo,voe=512,Soe=512,i$=256,s$=D6,a$=D6,Aoe=D6,c$=fo,Toe=new Set(["Unexpected signature","Encrypted ZIP","Expected Central-File-Header signature"]),_oe=["ZIP entry count exceeds ","Unsupported ZIP compression method:","ZIP entry compressed data exceeds ","ZIP entry decompressed data exceeds ","Expected data-descriptor-signature at position "],Ioe=new Set(["Z_BUF_ERROR","Z_DATA_ERROR","ERR_INVALID_STATE"]),ms=class extends Error{};function Coe(r){let e=r?.streamReader;if(e?.constructor?.name!=="WebStreamByobReader")return r;let{reader:t}=e,n=async()=>{await t.cancel(),t.releaseLock()};return e.close=n,e.abort=async()=>{e.interrupted=!0,await n()},r}function OE(r,e,t){if(!Number.isFinite(r)||r<0||r>e)throw new ms(`${t} has invalid size ${r} (maximum ${e} bytes)`);return r}async function Ea(r,e,{maximumLength:t=fo,reason:n="skip"}={}){let o=OE(e,t,n);await r.ignore(o)}async function NE(r,e,t,{maximumLength:n=e.length,reason:o="read"}={}){let i=t?.length??e.length,s=OE(i,n,o);return r.readBuffer(e,{...t,length:s})}async function koe(r,{maximumLength:e=Ai}={}){let o=new ReadableStream({start(l){l.enqueue(r),l.close()}}).pipeThrough(new DecompressionStream("deflate-raw")).getReader(),i=[],s=0;try{for(;;){let{done:l,value:u}=await o.read();if(l)break;if(s+=u.length,s>e)throw await o.cancel(),new Error(`ZIP entry decompressed data exceeds ${e} bytes`);i.push(u)}}finally{o.releaseLock()}let a=new Uint8Array(s),c=0;for(let l of i)a.set(l,c),c+=l.length;return a}var f$=134695760,P6=16,Roe=P6-1;function Poe(r,e){if(r.length<P6)return-1;let t=r.length-P6;for(let n=0;n<=t;n++)if(gt.get(r,n)===f$&&gt.get(r,n+8)===e+n)return n;return-1}function Doe(r){return(r.codePointAt(0)&32)!==0}function Noe(r,e){let t=new Uint8Array(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}async function Loe(r,{shouldBuffer:e,maximumLength:t=Ai}={}){let{syncBuffer:n}=r,{length:o}=n,i=[],s=0;for(;;){let a=await r.tokenizer.peekBuffer(n,{mayBeLess:!0}),c=Poe(n.subarray(0,a),s),l=c>=0?0:a===o?Math.min(Roe,a-1):0,u=c>=0?c:a-l;if(u===0)break;if(s+=u,s>t)throw new Error(`ZIP entry compressed data exceeds ${t} bytes`);if(e){let d=new Uint8Array(u);await r.tokenizer.readBuffer(d),i.push(d)}else await r.tokenizer.ignore(u);if(c>=0)break}if(Gr(r.tokenizer)||(r.knownSizeDescriptorScannedBytes+=s),!!e)return Noe(i,s)}function Ooe(r,e){return Gr(r.tokenizer)?Math.max(0,fo-(r.tokenizer.position-e)):Math.max(0,Ai-r.knownSizeDescriptorScannedBytes)}async function Boe(r,e,{shouldBuffer:t,maximumDescriptorLength:n=Ai}={}){if(e.dataDescriptor&&e.compressedSize===0)return Loe(r,{shouldBuffer:t,maximumLength:n});if(!t){await Ea(r.tokenizer,e.compressedSize,{maximumLength:Gr(r.tokenizer)?Ai:r.tokenizer.fileInfo.size,reason:"ZIP entry compressed data"});return}let o=Voe(r.tokenizer);if(!Number.isFinite(e.compressedSize)||e.compressedSize<0||e.compressedSize>o)throw new Error(`ZIP entry compressed data exceeds ${o} bytes`);let i=new Uint8Array(e.compressedSize);return await r.tokenizer.readBuffer(i),i}il.prototype.inflate=async function(r,e,t){if(r.compressedMethod===0)return t(e);if(r.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${r.compressedMethod}`);let n=await koe(e,{maximumLength:Ai});return t(n)};il.prototype.unzip=async function(r){let e=!1,t=0,n=this.tokenizer.position;this.knownSizeDescriptorScannedBytes=0;do{if(n1(this.tokenizer,n,fo))throw new ms(`ZIP stream probing exceeds ${fo} bytes`);let o=await this.readLocalFileHeader();if(!o)break;if(t++,t>e$)throw new Error(`ZIP entry count exceeds ${e$}`);let i=r(o);e=!!i.stop,await this.tokenizer.ignore(o.extraFieldLength);let s=await Boe(this,o,{shouldBuffer:!!i.handler,maximumDescriptorLength:Math.min(Ai,Ooe(this,n))});if(i.handler&&await this.inflate(o,s,i.handler),o.dataDescriptor){let a=new Uint8Array(P6);if(await this.tokenizer.readBuffer(a),gt.get(a,0)!==f$)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-a.length}`)}if(n1(this.tokenizer,n,fo))throw new ms(`ZIP stream probing exceeds ${fo} bytes`)}while(!e)};function Moe(r,e){let t=r.getReader(),n=0,o=!1,i=!1,s=async a=>{o||i||(i=!0,await t.cancel(a))};return new ReadableStream({async pull(a){if(n>=e){a.close(),await s();return}let{done:c,value:l}=await t.read();if(c||!l){o=!0,a.close();return}let u=e-n;if(l.length>u){a.enqueue(l.subarray(0,u)),n+=u,a.close(),await s();return}a.enqueue(l),n+=l.length},async cancel(a){await s(a)}})}async function h$(r,e){return new LE(e).fromBuffer(r)}function l$(r){switch(r=r.toLowerCase(),r){case"application/epub+zip":return{ext:"epub",mime:r};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:r};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:r};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:r};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:r};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:r};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:r};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:r};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:r};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:r};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:r};case"application/vnd.ms-excel.sheet.macroenabled":return{ext:"xlsm",mime:"application/vnd.ms-excel.sheet.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.spreadsheetml.template":return{ext:"xltx",mime:r};case"application/vnd.ms-excel.template.macroenabled":return{ext:"xltm",mime:"application/vnd.ms-excel.template.macroenabled.12"};case"application/vnd.ms-powerpoint.slideshow.macroenabled":return{ext:"ppsm",mime:"application/vnd.ms-powerpoint.slideshow.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return{ext:"docx",mime:r};case"application/vnd.ms-word.document.macroenabled":return{ext:"docm",mime:"application/vnd.ms-word.document.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.template":return{ext:"dotx",mime:r};case"application/vnd.ms-word.template.macroenabledtemplate":return{ext:"dotm",mime:"application/vnd.ms-word.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.template":return{ext:"potx",mime:r};case"application/vnd.ms-powerpoint.template.macroenabled":return{ext:"potm",mime:"application/vnd.ms-powerpoint.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.presentation":return{ext:"pptx",mime:r};case"application/vnd.ms-powerpoint.presentation.macroenabled":return{ext:"pptm",mime:"application/vnd.ms-powerpoint.presentation.macroenabled.12"};case"application/vnd.ms-visio.drawing":return{ext:"vsdx",mime:"application/vnd.visio"};case"application/vnd.ms-package.3dmanufacturing-3dmodel+xml":return{ext:"3mf",mime:"model/3mf"};default:}}function Si(r,e,t){t={offset:0,...t};for(let[n,o]of e.entries())if(t.mask){if(o!==(t.mask[n]&r[n+t.offset]))return!1}else if(o!==r[n+t.offset])return!1;return!0}function Uoe(r){return Number.isFinite(r)?Math.max(1,Math.trunc(r)):r1}function Foe(r,e,t){return t===void 0?r.read(e):(t.throwIfAborted(),new Promise((n,o)=>{let i=()=>{t.removeEventListener("abort",s)},s=()=>{let a=t.reason;i(),(async()=>{try{await r.cancel(a)}catch{}})(),o(a)};t.addEventListener("abort",s,{once:!0}),(async()=>{try{let a=await r.read(e);i(),n(a)}catch(a){i(),o(a)}})()}))}function $oe(r){return Number.isFinite(r)?Math.max(0,Math.min(moe,Math.trunc(r))):0}function Hoe(r){return Number.isFinite(r)?Math.max(0,r):Number.MAX_SAFE_INTEGER}function Gr(r){let e=r.fileInfo.size;return!Number.isFinite(e)||e===Number.MAX_SAFE_INTEGER}function n1(r,e,t){return Gr(r)&&r.position-e>t}function Voe(r){let e=r.fileInfo.size,t=Number.isFinite(e)?Math.max(0,e-r.position):Number.MAX_SAFE_INTEGER;return Math.min(t,goe)}function qoe(r){if(r instanceof je||r instanceof ms)return!0;if(!(r instanceof Error))return!1;if(Toe.has(r.message)||Ioe.has(r.code))return!0;for(let e of _oe)if(r.message.startsWith(e))return!0;return!1}function u$(r,e=Ai){let t=[r.compressedSize,r.uncompressedSize];for(let n of t)if(!Number.isFinite(n)||n<0||n>e)return!1;return!0}function zoe(){return{hasContentTypesEntry:!1,hasParsedContentTypesEntry:!1,isParsingContentTypes:!1,hasUnparseableContentTypes:!1,hasWordDirectory:!1,hasPresentationDirectory:!1,hasSpreadsheetDirectory:!1,hasThreeDimensionalModelEntry:!1}}function Koe(r,e){e.startsWith("word/")&&(r.hasWordDirectory=!0),e.startsWith("ppt/")&&(r.hasPresentationDirectory=!0),e.startsWith("xl/")&&(r.hasSpreadsheetDirectory=!0),e.startsWith("3D/")&&e.endsWith(".model")&&(r.hasThreeDimensionalModelEntry=!0)}function d$(r){if(!(!r.hasContentTypesEntry||r.hasUnparseableContentTypes||r.isParsingContentTypes||r.hasParsedContentTypesEntry)){if(r.hasWordDirectory)return{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"};if(r.hasPresentationDirectory)return{ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"};if(r.hasSpreadsheetDirectory)return{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};if(r.hasThreeDimensionalModelEntry)return{ext:"3mf",mime:"model/3mf"}}}function Goe(r){let e=r.indexOf('.main+xml"');if(e===-1){let o="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";return r.includes(`ContentType="${o}"`)?o:void 0}let t=r.slice(0,e),n=t.lastIndexOf('"');return t.slice(n+1)}var LE=class r{constructor(e){let t=$oe(e?.mpegOffsetTolerance);this.options={...e,mpegOffsetTolerance:t},this.detectors=[...this.options.customDetectors??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:this.options.signal},this.gzipProbeDepth=0}getTokenizerOptions(){return{...this.tokenizerOptions}}createTokenizerFromWebStream(e){return Coe(BF(e,this.getTokenizerOptions()))}async parseTokenizer(e,t=0){this.detectionReentryCount=t;let n=e.position;for(let o of this.detectors){let i;try{i=await o.detect(e)}catch(s){if(s instanceof je||s instanceof ms)return;throw s}if(i)return i;if(n!==e.position)return}}async fromTokenizer(e){try{return await this.parseTokenizer(e)}finally{await e.close()}}async fromBuffer(e){if(!(e instanceof Uint8Array||e instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``);let t=e instanceof Uint8Array?e:new Uint8Array(e);if(t?.length>1)return this.fromTokenizer(MF(t,this.getTokenizerOptions()))}async fromBlob(e){this.options.signal?.throwIfAborted();let t=UF(e,this.getTokenizerOptions());return this.fromTokenizer(t)}async fromStream(e){this.options.signal?.throwIfAborted();let t=this.createTokenizerFromWebStream(e);return this.fromTokenizer(t)}async toDetectionStream(e,t){let n=Uoe(t?.sampleSize??r1),o,i,s=e.getReader({mode:"byob"});try{let{value:l,done:u}=await Foe(s,new Uint8Array(n),this.options.signal);if(i=l,!u&&l)try{o=await this.fromBuffer(l.subarray(0,n))}catch(d){if(!(d instanceof je))throw d;o=void 0}i=l}finally{s.releaseLock()}let a=new TransformStream({async start(l){l.enqueue(i)},transform(l,u){u.enqueue(l)}}),c=e.pipeThrough(a);return c.fileType=o,c}async detectGzip(e){if(this.gzipProbeDepth>=woe)return{ext:"gz",mime:"application/gzip"};let t=new t1(e),n=Moe(t.inflate(),yoe),o=Gr(e),i,s,a,c;if(o){let l=new AbortController;i=setTimeout(()=>{l.abort(new DOMException(`Operation timed out after ${r$} ms`,"TimeoutError"))},r$),s=this.options.signal===void 0?l.signal:AbortSignal.any([this.options.signal,l.signal]),a=new r({...this.options,signal:s}),a.gzipProbeDepth=this.gzipProbeDepth+1}else this.gzipProbeDepth++;try{c=await(a??this).fromStream(n)}catch(l){if(l?.name==="AbortError"&&s?.reason?.name!=="TimeoutError")throw l}finally{clearTimeout(i),o||this.gzipProbeDepth--}return c?.ext==="tar"?{ext:"tar.gz",mime:"application/gzip"}:{ext:"gz",mime:"application/gzip"}}check(e,t){return Si(this.buffer,e,t)}checkString(e,t){return this.check(YF(e,t?.encoding),t)}detectConfident=async e=>{if(this.buffer=new Uint8Array(r1),e.fileInfo.size===void 0&&(e.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=e,Gr(e)&&(await e.peekBuffer(this.buffer,{length:3,mayBeLess:!0}),this.check([31,139,8])))return this.detectGzip(e);if(await e.peekBuffer(this.buffer,{length:32,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await e.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};if(this.check([239,187,191]))return this.detectionReentryCount>=i$?void 0:(this.detectionReentryCount++,await this.tokenizer.ignore(3),this.detectConfident(e));if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8]))return this.detectGzip(e);if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await Ea(e,6,{maximumLength:6,reason:"ID3 header prefix"});let t=await e.readToken(QF),n=Gr(e);if(!Number.isFinite(t)||t<0||n&&(t>DE||e.position+t>DE))return;if(e.position+t>e.fileInfo.size)return n?void 0:{ext:"mp3",mime:"audio/mpeg"};try{await Ea(e,t,{maximumLength:n?DE:e.fileInfo.size,reason:"ID3 payload"})}catch(o){if(o instanceof je)return;throw o}return this.detectionReentryCount>=i$?void 0:(this.detectionReentryCount++,this.parseTokenizer(e,this.detectionReentryCount))}if(this.checkString("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((this.buffer[0]===67||this.buffer[0]===70)&&this.check([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:"jls",mime:"image/jls"}:{ext:"jpg",mime:"image/jpeg"};if(this.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};if(this.checkString("FLIF"))return{ext:"flif",mime:"image/flif"};if(this.checkString("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(this.checkString("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(this.checkString("FORM"))return{ext:"aif",mime:"audio/aiff"};if(this.checkString("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};if(this.check([80,75,3,4])){let t,n=zoe();try{await new il(e).unzip(o=>{Koe(n,o.filename);let i=o.filename==="[Content_Types].xml",s=d$(n);if(!i&&s)return t=s,{stop:!0};switch(o.filename){case"META-INF/mozilla.rsa":return t={ext:"xpi",mime:"application/x-xpinstall"},{stop:!0};case"META-INF/MANIFEST.MF":return t={ext:"jar",mime:"application/java-archive"},{stop:!0};case"mimetype":return u$(o,t$)?{async handler(a){let c=new TextDecoder("utf-8").decode(a).trim();t=l$(c)},stop:!0}:{};case"[Content_Types].xml":return n.hasContentTypesEntry=!0,u$(o,t$)?(n.isParsingContentTypes=!0,{async handler(a){let c=new TextDecoder("utf-8").decode(a),l=Goe(c);l&&(t=l$(l)),n.hasParsedContentTypesEntry=!0,n.isParsingContentTypes=!1},stop:!0}):(n.hasUnparseableContentTypes=!0,{});default:return/classes\d*\.dex/.test(o.filename)?(t={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}})}catch(o){if(!qoe(o))throw o;n.isParsingContentTypes&&(n.isParsingContentTypes=!1,n.hasUnparseableContentTypes=!0)}return t??d$(n)??{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await e.ignore(28);let t=new Uint8Array(8);return await e.readBuffer(t),Si(t,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:Si(t,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:Si(t,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:Si(t,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:Si(t,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:Si(t,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(this.check([80,75])&&(this.buffer[2]===3||this.buffer[2]===5||this.buffer[2]===7)&&(this.buffer[3]===4||this.buffer[3]===6||this.buffer[3]===8))return{ext:"zip",mime:"application/zip"};if(this.checkString("MThd"))return{ext:"mid",mime:"audio/midi"};if(this.checkString("wOFF")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(this.checkString("wOF2")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(this.checkString("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(this.checkString("LZIP"))return{ext:"lz",mime:"application/x-lzip"};if(this.checkString("fLaC"))return{ext:"flac",mime:"audio/flac"};if(this.check([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(this.checkString("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(this.checkString("%PDF"))return{ext:"pdf",mime:"application/pdf"};if(this.check([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(this.check([73,73])){let t=await this.readTiffHeader(!1);if(t)return t}if(this.check([77,77])){let t=await this.readTiffHeader(!0);if(t)return t}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function t(){let c=await e.peekNumber(NF),l=128,u=0;for(;(c&l)===0&&l!==0;)++u,l>>=1;let d=new Uint8Array(u+1);return await NE(e,d,void 0,{maximumLength:d.length,reason:"EBML field"}),d}async function n(){let c=await t(),l=await t();l[0]^=128>>l.length-1;let u=Math.min(6,l.length),d=new DataView(c.buffer),f=new DataView(l.buffer,l.length-u,u);return{id:PE(d),len:PE(f)}}async function o(c){let l=0;for(;c>0;){if(l++,l>xoe||n1(e,s,fo))return;let u=e.position,d=await n();if(d.id===17026){if(d.len>n$)return;let f=OE(d.len,n$,"EBML DocType");return(await e.readToken(new sn(f))).replaceAll(/\00.*$/g,"")}if(Gr(e)&&(!Number.isFinite(d.len)||d.len<0||d.len>o$)||(await Ea(e,d.len,{maximumLength:Gr(e)?o$:e.fileInfo.size,reason:"EBML payload"}),--c,e.position<=u))return}}let i=await n(),s=e.position;switch(await o(i.len)){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/matroska"};default:return}}if(this.checkString("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(this.check([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(this.checkString("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(this.checkString("MSCF")||this.checkString("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};if(this.check([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(this.check([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(this.check([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(this.check([127,69,76,70]))return{ext:"elf",mime:"application/x-elf"};if(this.check([33,66,68,78]))return{ext:"pst",mime:"application/vnd.ms-outlook"};if(this.checkString("PAR1")||this.checkString("PARE"))return{ext:"parquet",mime:"application/vnd.apache.parquet"};if(this.checkString("ttcf"))return{ext:"ttc",mime:"font/collection"};if(this.check([254,237,250,206])||this.check([254,237,250,207])||this.check([206,250,237,254])||this.check([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};if(this.check([4,34,77,24]))return{ext:"lz4",mime:"application/x-lz4"};if(this.checkString("regf"))return{ext:"dat",mime:"application/x-ft-windows-registry-hive"};if(this.checkString("$FL2")||this.checkString("$FL3"))return{ext:"sav",mime:"application/x-spss-sav"};if(this.check([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(this.checkString("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(this.checkString("{\\rtf"))return{ext:"rtf",mime:"application/rtf"};if(this.check([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(this.checkString("IMPM"))return{ext:"it",mime:"audio/x-it"};if(this.checkString("-lh0-",{offset:2})||this.checkString("-lh1-",{offset:2})||this.checkString("-lh2-",{offset:2})||this.checkString("-lh3-",{offset:2})||this.checkString("-lh4-",{offset:2})||this.checkString("-lh5-",{offset:2})||this.checkString("-lh6-",{offset:2})||this.checkString("-lh7-",{offset:2})||this.checkString("-lzs-",{offset:2})||this.checkString("-lz4-",{offset:2})||this.checkString("-lz5-",{offset:2})||this.checkString("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(this.check([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(this.checkString("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(this.check([202,254,186,190])){let t=IE.get(this.buffer,4),n=el.get(this.buffer,6);if(t>0&&t<=30)return{ext:"macho",mime:"application/x-mach-binary"};if(n>30)return{ext:"class",mime:"application/java-vm"}}if(this.checkString(".RMF"))return{ext:"rm",mime:"application/vnd.rn-realmedia"};if(this.checkString("DRACO"))return{ext:"drc",mime:"application/vnd.google.draco"};if(this.check([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(this.checkString("<?xml "))return{ext:"xml",mime:"application/xml"};if(this.check([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(this.check([82,97,114,33,26,7])&&(this.buffer[6]===0||this.buffer[6]===1))return{ext:"rar",mime:"application/x-rar-compressed"};if(this.checkString("solid "))return{ext:"stl",mime:"model/stl"};if(this.checkString("AC")){let t=new sn(4,"latin1").get(this.buffer,2);if(t.match("^d*")&&t>=1e3&&t<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>"))return await e.ignore(8),await e.readToken(new sn(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("WEBVTT")&&[`
110
+ `).filter(o=>(o=o.trim(),o!==""&&!o.startsWith("#"))).map(o=>{let[i,s,a]=o.split(/\s+/).map(f=>f.trim());if(a!=null&&a!==""&&!a.match(/^\d+$/))throw new q4("Invalid status code in _redirects file");let c=parseInt(a);if(isNaN(c)&&(c=301),!Lne.includes(c))throw new z4(`Status code ${c} is not allowed`);let l=new Set,u=i.split("/"),d=u.map((f,h)=>{if(f.startsWith(":")){let p=f.substring(1);if(l.has(p))throw new K4("Duplicate placeholders in from path");return l.add(p),`(?<${p}>[^/]+)`}return f==="*"&&h===u.length-1?"(?<splat>.+)":(0,_F.default)(f)}).join("\\/");return{from:new RegExp(d),to:s,status:c}});for(let{from:o,to:i,status:s}of n){let a=r.pathname.match(o);if(a!=null)return One(r,i,s,a.groups,t)}}catch(n){return new Response(JSON.stringify(Xc(n),null,2),{status:500})}}function One(r,e,t,n,o={}){if(o.redirect==="error")throw new TypeError("Failed to fetch");if(n!=null)for(let[c,l]of Object.entries(n))e=e.replaceAll(`:${c}`,l);let i=Bne(r,new URL(`${r.protocol}//${r.host}${e}`)),s=new URL(`${r.protocol}//${r.host}${e}`),a=new URL(`${r.protocol}//${r.host}${s.pathname}${Mne(i)}${r.hash}`);return o.redirect==="manual"?new Response("",{status:t,headers:{location:a.toString()}}):a}function Bne(r,e){let t={};for(let[n,o]of r.searchParams)e.searchParams.delete(n),TF(n,o,t);for(let[n,o]of e.searchParams)TF(n,o,t);return t}function TF(r,e,t){typeof t[r]=="string"&&(t[r]=[t[r]]),Array.isArray(t[r])?t[r].push(e):t[r]=e}function Mne(r){let e=[...Object.entries(r)].map(([t,n])=>(Array.isArray(n)||(n=[n]),n.map(o=>`${encodeURIComponent(t)}=${encodeURIComponent(o)}`).join("&"))).join("&");return e===""?e:`?${e}`}var wd=class{headers;constructor(){this.headers=[]}getHeader(){return this.headers.join(",")}async time(e,t,n){let o=performance.now();try{return await n}finally{let s=performance.now()-o;this.add(e,t,s)}}add(e,t,n){this.headers.push(`${e};dur=${Math.round(n)}${t===""?"":`;desc="${t}"`}`)}};var Une=29030400;function Fne(r){return{cid:r,name:r.toString(),path:r.toString(),roots:[r],remainder:[]}}var v6=class{log;components;blockstoreSessions;constructor(e,t={}){this.components=e,this.log=e.helia.logger.forComponent("helia-verified-fetch:url-resolver"),this.blockstoreSessions=new Gp({maxSize:t.sessionCacheSize??100,maxAge:t.sessionTTLms??6e4,onEviction:(n,o)=>{o.close()}})}async resolve(e,t=new wd,n={}){if(e.protocol==="ipfs:")return this.resolveIPFSPath(e,t,n);if(e.protocol==="ipns:")return this.resolveIPNSName(e,t,n);if(e.protocol==="dnslink:")return this.resolveDNSLink(e,t,n);throw new co(`Invalid resource. Unsupported protocol in URL, must be ipfs:, ipns:, or dnslink: ${e}`)}async getBlockstore(e,t={}){if(t.session===!1)return this.components.helia.blockstore;let n=`ipfs:${e}`,o=this.blockstoreSessions.get(n),i=!1;if(o==null&&(this.log("create session with %d initial providers for root %c",t.providers?.length??0,e),i=!0,o=this.components.helia.blockstore.createSession(e,t),this.blockstoreSessions.set(n,o)),!i&&t.providers!=null&&t.providers.length>0){this.log("adding %d providers to existing session for root %c",t.providers.length,e);try{let s=await Promise.all(t.providers.map(async a=>{await o.addPeer(a,t)})??[]);this.log("result was %o",s)}catch(s){this.log.error("could not add provs - %e",s)}}return o}async resolveDNSLink(e,t,n){let i=(await t.time(Kn("dnsLink.resolve"),"",this.components.dnsLink.resolve(e.hostname,n)))?.[0];if(i==null)throw new TypeError(`Invalid resource. Cannot resolve DNSLink from domain: ${e.hostname}`);let s,a=CF(`${i.path}/${e.pathname}`);if(i.namespace==="ipns"){let c=new URL(`ipns://${i.peerId}${a}`);s=await this.resolveIPNSName(c,t,n)}else if(i.namespace==="ipfs"){let c=new URL(`ipfs://${i.cid}${a}`);s=await this.resolveIPFSPath(c,t,n)}else throw new TypeError(`Invalid resource. Unexpected DNSLink namespace ${i.namespace} from domain: ${e.hostname}`);return s instanceof Response?s:{...s,url:e,ttl:i.answer.TTL}}async resolveIPNSName(e,t,n){let o=De(e.hostname),i=await t.time(Kn("ipns.resolve"),"",this.components.ipnsResolver.resolve(o,n)),s=CF(`${i.path??""}/${e.pathname}`),a=new URL(`ipfs://${i.cid}${s}`),c=await this.resolveIPFSPath(a,t,n);return c instanceof Response?c:{...c,url:e,ttl:Number((i.record.ttl??0n)/BigInt(1e9))}}async resolveIPFSPath(e,t,n){let o=await t.time(Kn("ipfs.resolve"),"",this.walkPath(e,n));if(o instanceof Response)return o;if(o.terminalElement.cid.code===114){let i=new URL(`ipns://${$r(o.terminalElement.cid)}`),s=await this.resolveIPNSName(i,t,n);return s instanceof Response?s:{...s,url:e}}return{...o,url:e,ttl:Une,blockstore:o.blockstore}}async walkPath(e,t={}){let n;try{n=q.parse(e.hostname)}catch(i){throw new co(`Could not parse CID - ${i}`)}let o=await this.getBlockstore(n,t);try{let i=[],s,a=$ne(e);for await(let c of ga(a,o,{...t,yieldSubShards:!0}))i.push(c.cid),s=c;if(s==null)throw new J4("No terminal element found");return{ipfsRoots:i,terminalElement:s,blockstore:o,redirected:t.redirected===!0}}catch(i){if(i.name==="NotFoundError"&&t.redirected!==!0){let s;try{s=await uo(`${n}/_redirects`,o,t)}catch(a){if(a.name!=="NotFoundError")throw a}if(s?.type==="file"||s?.type==="raw"){let a=L(await Ee(s.content(t))),c=IF(e,a,t);if(c instanceof Response)return c;if(c instanceof URL)return this.walkPath(c,{...t,redirected:!0})}}if(i.name==="NoResolverError")return{ipfsRoots:[n],terminalElement:Fne(n),blockstore:o,redirected:!1};throw i}}};function $ne(r){return`/ipfs/${r.hostname}${decodeURI(r.pathname)}`}function CF(r){return r=r.split("/").map(e=>e.trim()).filter(Boolean).join("/"),r!==""?`/${r}`:""}var DF=ir(kF(),1);var RF={128:"\u20AC",130:"\u201A",131:"\u0192",132:"\u201E",133:"\u2026",134:"\u2020",135:"\u2021",136:"\u02C6",137:"\u2030",138:"\u0160",139:"\u2039",140:"\u0152",142:"\u017D",145:"\u2018",146:"\u2019",147:"\u201C",148:"\u201D",149:"\u2022",150:"\u2013",151:"\u2014",152:"\u02DC",153:"\u2122",154:"\u0161",155:"\u203A",156:"\u0153",158:"\u017E",159:"\u0178"},Hne={};for(let[r,e]of Object.entries(RF))Hne[e]=Number.parseInt(r,10);var S6;function Vne(){if(!(typeof globalThis.TextDecoder>"u"))return S6??(S6=new globalThis.TextDecoder("utf-8"))}var xd=32*1024,Go=65533;function PF(r,e="utf-8"){switch(e.toLowerCase()){case"utf-8":case"utf8":{let t=Vne();return t?t.decode(r):zne(r)}case"utf-16le":return Kne(r);case"us-ascii":case"ascii":return Gne(r);case"latin1":case"iso-8859-1":return Wne(r);case"windows-1252":return jne(r);default:throw new RangeError(`Encoding '${e}' not supported`)}}function _E(r,e){e.length!==0&&(r.push(String.fromCharCode.apply(null,e)),e.length=0)}function Ot(r,e,t){e.push(t),e.length>=xd&&_E(r,e)}function qne(r,e,t){if(t<=65535){Ot(r,e,t);return}t-=65536,Ot(r,e,55296+(t>>10)),Ot(r,e,56320+(t&1023))}function zne(r){let e=[],t=[],n=0;for(r.length>=3&&r[0]===239&&r[1]===187&&r[2]===191&&(n=3);n<r.length;){let o=r[n];if(o<=127){Ot(e,t,o),n++;continue}if(o<194||o>244){Ot(e,t,Go),n++;continue}if(o<=223){if(n+1>=r.length){Ot(e,t,Go),n++;continue}let u=r[n+1];if((u&192)!==128){Ot(e,t,Go),n++;continue}let d=(o&31)<<6|u&63;Ot(e,t,d),n+=2;continue}if(o<=239){if(n+2>=r.length){Ot(e,t,Go),n++;continue}let u=r[n+1],d=r[n+2];if(!((u&192)===128&&(d&192)===128&&!(o===224&&u<160)&&!(o===237&&u>=160))){Ot(e,t,Go),n++;continue}let h=(o&15)<<12|(u&63)<<6|d&63;Ot(e,t,h),n+=3;continue}if(n+3>=r.length){Ot(e,t,Go),n++;continue}let i=r[n+1],s=r[n+2],a=r[n+3];if(!((i&192)===128&&(s&192)===128&&(a&192)===128&&!(o===240&&i<144)&&!(o===244&&i>143))){Ot(e,t,Go),n++;continue}let l=(o&7)<<18|(i&63)<<12|(s&63)<<6|a&63;qne(e,t,l),n+=4}return _E(e,t),e.join("")}function Kne(r){let e=[],t=[],n=r.length,o=0;for(;o+1<n;){let i=r[o]|r[o+1]<<8;if(o+=2,i>=55296&&i<=56319){if(o+1<n){let s=r[o]|r[o+1]<<8;s>=56320&&s<=57343?(Ot(e,t,i),Ot(e,t,s),o+=2):Ot(e,t,Go)}else Ot(e,t,Go);continue}if(i>=56320&&i<=57343){Ot(e,t,Go);continue}Ot(e,t,i)}return o<n&&Ot(e,t,Go),_E(e,t),e.join("")}function Gne(r){let e=[];for(let t=0;t<r.length;t+=xd){let n=Math.min(r.length,t+xd),o=new Array(n-t);for(let i=t,s=0;i<n;i++,s++)o[s]=r[i]&127;e.push(String.fromCharCode.apply(null,o))}return e.join("")}function Wne(r){let e=[];for(let t=0;t<r.length;t+=xd){let n=Math.min(r.length,t+xd),o=new Array(n-t);for(let i=t,s=0;i<n;i++,s++)o[s]=r[i];e.push(String.fromCharCode.apply(null,o))}return e.join("")}function jne(r){let e=[],t="";for(let n=0;n<r.length;n++){let o=r[n],i=o>=128&&o<=159?RF[o]:void 0;t+=i??String.fromCharCode(o),t.length>=xd&&(e.push(t),t="")}return t&&e.push(t),e.join("")}function on(r){return new DataView(r.buffer,r.byteOffset)}var NF={len:1,get(r,e){return on(r).getUint8(e)},put(r,e,t){return on(r).setUint8(e,t),e+1}},bt={len:2,get(r,e){return on(r).getUint16(e,!0)},put(r,e,t){return on(r).setUint16(e,t,!0),e+2}},el={len:2,get(r,e){return on(r).getUint16(e)},put(r,e,t){return on(r).setUint16(e,t),e+2}};var gt={len:4,get(r,e){return on(r).getUint32(e,!0)},put(r,e,t){return on(r).setUint32(e,t,!0),e+4}},IE={len:4,get(r,e){return on(r).getUint32(e)},put(r,e,t){return on(r).setUint32(e,t),e+4}};var LF={len:4,get(r,e){return on(r).getInt32(e)},put(r,e,t){return on(r).setInt32(e,t),e+4}};var OF={len:8,get(r,e){return on(r).getBigUint64(e,!0)},put(r,e,t){return on(r).setBigUint64(e,t,!0),e+8}};var sn=class{constructor(e,t){this.len=e,this.encoding=t}get(e,t=0){let n=e.subarray(t,t+this.len);return PF(n,this.encoding)}};var Xne="End-Of-Stream",je=class extends Error{constructor(){super(Xne),this.name="EndOfStreamError"}},tl=class extends Error{constructor(e="The operation was aborted"){super(e),this.name="AbortError"}};var rl=class{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(e,t=!1){let n=await this.read(e,t);return this.peekQueue.push(e.subarray(0,n)),n}async read(e,t=!1){if(e.length===0)return 0;let n=this.readFromPeekBuffer(e);if(this.endOfStream||(n+=await this.readRemainderFromStream(e.subarray(n),t)),n===0&&!t)throw new je;return n}readFromPeekBuffer(e){let t=e.length,n=0;for(;this.peekQueue.length>0&&t>0;){let o=this.peekQueue.pop();if(!o)throw new Error("peekData should be defined");let i=Math.min(o.length,t);e.set(o.subarray(0,i),n),n+=i,t-=i,i<o.length&&this.peekQueue.push(o.subarray(i))}return n}async readRemainderFromStream(e,t){let n=0;for(;n<e.length&&!this.endOfStream;){if(this.interrupted)throw new tl;let o=await this.readFromStream(e.subarray(n),t);if(o===0)break;n+=o}if(!t&&n<e.length)throw new je;return n}};var A6=class extends rl{constructor(e){super(),this.reader=e}async abort(){return this.close()}async close(){this.reader.releaseLock()}};var e1=class extends A6{async readFromStream(e,t){if(e.length===0)return 0;let n=await this.reader.read(new Uint8Array(e.length),{min:t?void 0:e.length});return n.done&&(this.endOfStream=n.done),n.value?(e.set(n.value),n.value.length):0}};var bd=class extends rl{constructor(e){super(),this.reader=e,this.buffer=null}writeChunk(e,t){let n=Math.min(t.length,e.length);return e.set(t.subarray(0,n)),n<t.length?this.buffer=t.subarray(n):this.buffer=null,n}async readFromStream(e,t){if(e.length===0)return 0;let n=0;for(this.buffer&&(n+=this.writeChunk(e,this.buffer));n<e.length&&!this.endOfStream;){let o=await this.reader.read();if(o.done){this.endOfStream=!0;break}o.value&&(n+=this.writeChunk(e.subarray(n),o.value))}if(!t&&n===0&&this.endOfStream)throw new je;return n}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}};function CE(r){try{let e=r.getReader({mode:"byob"});return e instanceof ReadableStreamDefaultReader?new bd(e):new e1(e)}catch(e){if(e instanceof TypeError)return new bd(r.getReader());throw e}}var ps=class{constructor(e){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=e?.onClose,e?.abortSignal&&e.abortSignal.addEventListener("abort",()=>{this.abort()})}async readToken(e,t=this.position){let n=new Uint8Array(e.len);if(await this.readBuffer(n,{position:t})<e.len)throw new je;return e.get(n,0)}async peekToken(e,t=this.position){let n=new Uint8Array(e.len);if(await this.peekBuffer(n,{position:t})<e.len)throw new je;return e.get(n,0)}async readNumber(e){if(await this.readBuffer(this.numBuffer,{length:e.len})<e.len)throw new je;return e.get(this.numBuffer,0)}async peekNumber(e){if(await this.peekBuffer(this.numBuffer,{length:e.len})<e.len)throw new je;return e.get(this.numBuffer,0)}async ignore(e){if(e<0)throw new RangeError("ignore length must be \u2265 0 bytes");if(this.fileInfo.size!==void 0){let t=this.fileInfo.size-this.position;if(e>t)return this.position+=t,t}return this.position+=e,e}async close(){await this.abort(),await this.onClose?.()}normalizeOptions(e,t){if(!this.supportsRandomAccess()&&t&&t.position!==void 0&&t.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return{mayBeLess:!1,offset:0,length:e.length,position:this.position,...t}}abort(){return Promise.resolve()}};var Zne=256e3,T6=class extends ps{constructor(e,t){super(t),this.streamReader=e,this.fileInfo=t?.fileInfo??{}}async readBuffer(e,t){let n=this.normalizeOptions(e,t),o=n.position-this.position;if(o>0)return await this.ignore(o),this.readBuffer(e,t);if(o<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(n.length===0)return 0;let i=await this.streamReader.read(e.subarray(0,n.length),n.mayBeLess);if(this.position+=i,(!t||!t.mayBeLess)&&i<n.length)throw new je;return i}async peekBuffer(e,t){let n=this.normalizeOptions(e,t),o=0;if(n.position){let i=n.position-this.position;if(i>0){let s=new Uint8Array(n.length+i);return o=await this.peekBuffer(s,{mayBeLess:n.mayBeLess}),e.set(s.subarray(i)),o-i}if(i<0)throw new Error("Cannot peek from a negative offset in a stream")}if(n.length>0){try{o=await this.streamReader.peek(e.subarray(0,n.length),n.mayBeLess)}catch(i){if(t?.mayBeLess&&i instanceof je)return 0;throw i}if(!n.mayBeLess&&o<n.length)throw new je}return o}async ignore(e){if(e<0)throw new RangeError("ignore length must be \u2265 0 bytes");let t=Math.min(Zne,e),n=new Uint8Array(t),o=0;for(;o<e;){let i=e-o,s=await this.readBuffer(n,{length:Math.min(t,i)});if(s<0)return s;o+=s}return o}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}};var _6=class extends ps{constructor(e,t){super(t),this.uint8Array=e,this.fileInfo={...t?.fileInfo??{},size:e.length}}async readBuffer(e,t){t?.position&&(this.position=t.position);let n=await this.peekBuffer(e,t);return this.position+=n,n}async peekBuffer(e,t){let n=this.normalizeOptions(e,t),o=Math.min(this.uint8Array.length-n.position,n.length);if(!n.mayBeLess&&o<n.length)throw new je;return e.set(this.uint8Array.subarray(n.position,n.position+o)),o}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}};var I6=class extends ps{constructor(e,t){super(t),this.blob=e,this.fileInfo={...t?.fileInfo??{},size:e.size,mimeType:e.type}}async readBuffer(e,t){t?.position&&(this.position=t.position);let n=await this.peekBuffer(e,t);return this.position+=n,n}async peekBuffer(e,t){let n=this.normalizeOptions(e,t),o=Math.min(this.blob.size-n.position,n.length);if(!n.mayBeLess&&o<n.length)throw new je;let i=await this.blob.slice(n.position,n.position+o).arrayBuffer();return e.set(new Uint8Array(i)),o}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}};function BF(r,e){let t=CE(r),n=e??{},o=n.onClose;return n.onClose=async()=>{if(await t.close(),o)return o()},new T6(t,n)}function MF(r,e){return new _6(r,e)}function UF(r,e){return new I6(r,e)}var WF=ir(qF(),1);var ol={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},kE={get(r){return{signature:gt.get(r,0),compressedSize:gt.get(r,8),uncompressedSize:gt.get(r,12)}},len:16},zF={get(r){let e=bt.get(r,6);return{signature:gt.get(r,0),minVersion:bt.get(r,4),dataDescriptor:!!(e&8),compressedMethod:bt.get(r,8),compressedSize:gt.get(r,18),uncompressedSize:gt.get(r,22),filenameLength:bt.get(r,26),extraFieldLength:bt.get(r,28),filename:null}},len:30},KF={get(r){return{signature:gt.get(r,0),nrOfThisDisk:bt.get(r,4),nrOfThisDiskWithTheStart:bt.get(r,6),nrOfEntriesOnThisDisk:bt.get(r,8),nrOfEntriesOfSize:bt.get(r,10),sizeOfCd:gt.get(r,12),offsetOfStartOfCd:gt.get(r,16),zipFileCommentLength:bt.get(r,20)}},len:22},GF={get(r){let e=bt.get(r,8);return{signature:gt.get(r,0),minVersion:bt.get(r,6),dataDescriptor:!!(e&8),compressedMethod:bt.get(r,10),compressedSize:gt.get(r,20),uncompressedSize:gt.get(r,24),filenameLength:bt.get(r,28),extraFieldLength:bt.get(r,30),fileCommentLength:bt.get(r,32),relativeOffsetOfLocalHeader:gt.get(r,42),filename:null}},len:46};function jF(r){let e=new Uint8Array(gt.len);return gt.put(e,0,r),e}var vi=(0,WF.default)("tokenizer:inflate"),RE=256*1024,foe=jF(ol.DataDescriptor),R6=jF(ol.EndOfCentralDirectory),il=class r{constructor(e){this.tokenizer=e,this.syncBuffer=new Uint8Array(RE)}async isZip(){return await this.peekSignature()===ol.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(gt)}async findEndOfCentralDirectoryLocator(){let e=this.tokenizer,t=Math.min(16*1024,e.fileInfo.size),n=this.syncBuffer.subarray(0,t);await this.tokenizer.readBuffer(n,{position:e.fileInfo.size-t});for(let o=n.length-4;o>=0;o--)if(n[o]===R6[0]&&n[o+1]===R6[1]&&n[o+2]===R6[2]&&n[o+3]===R6[3])return e.fileInfo.size-t+o;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){vi("Cannot reading central-directory without random-read support");return}vi("Reading central-directory...");let e=this.tokenizer.position,t=await this.findEndOfCentralDirectoryLocator();if(t>0){vi("Central-directory 32-bit signature found");let n=await this.tokenizer.readToken(KF,t),o=[];this.tokenizer.setPosition(n.offsetOfStartOfCd);for(let i=0;i<n.nrOfEntriesOfSize;++i){let s=await this.tokenizer.readToken(GF);if(s.signature!==ol.CentralFileHeader)throw new Error("Expected Central-File-Header signature");s.filename=await this.tokenizer.readToken(new sn(s.filenameLength,"utf-8")),await this.tokenizer.ignore(s.extraFieldLength),await this.tokenizer.ignore(s.fileCommentLength),o.push(s),vi(`Add central-directory file-entry: n=${i+1}/${o.length}: filename=${o[i].filename}`)}return this.tokenizer.setPosition(e),o}this.tokenizer.setPosition(e)}async unzip(e){let t=await this.readCentralDirectory();if(t)return this.iterateOverCentralDirectory(t,e);let n=!1;do{let o=await this.readLocalFileHeader();if(!o)break;let i=e(o);n=!!i.stop;let s;if(await this.tokenizer.ignore(o.extraFieldLength),o.dataDescriptor&&o.compressedSize===0){let a=[],c=RE;vi("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let l=-1;for(;l<0&&c===RE;){c=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),l=hoe(this.syncBuffer.subarray(0,c),foe);let u=l>=0?l:c;if(i.handler){let d=new Uint8Array(u);await this.tokenizer.readBuffer(d),a.push(d)}else await this.tokenizer.ignore(u)}vi(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),i.handler&&await this.inflate(o,poe(a),i.handler)}else i.handler?(vi(`Reading compressed-file-data: ${o.compressedSize} bytes`),s=new Uint8Array(o.compressedSize),await this.tokenizer.readBuffer(s),await this.inflate(o,s,i.handler)):(vi(`Ignoring compressed-file-data: ${o.compressedSize} bytes`),await this.tokenizer.ignore(o.compressedSize));if(vi(`Reading data-descriptor at pos=${this.tokenizer.position}`),o.dataDescriptor&&(await this.tokenizer.readToken(kE)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-kE.len}`)}while(!n)}async iterateOverCentralDirectory(e,t){for(let n of e){let o=t(n);if(o.handler){this.tokenizer.setPosition(n.relativeOffsetOfLocalHeader);let i=await this.readLocalFileHeader();if(i){await this.tokenizer.ignore(i.extraFieldLength);let s=new Uint8Array(n.compressedSize);await this.tokenizer.readBuffer(s),await this.inflate(i,s,o.handler)}}if(o.stop)break}}async inflate(e,t,n){if(e.compressedMethod===0)return n(t);if(e.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${e.compressedMethod}`);vi(`Decompress filename=${e.filename}, compressed-size=${t.length}`);let o=await r.decompressDeflateRaw(t);return n(o)}static async decompressDeflateRaw(e){let t=new ReadableStream({start(i){i.enqueue(e),i.close()}}),n=new DecompressionStream("deflate-raw"),o=t.pipeThrough(n);try{let s=await new Response(o).arrayBuffer();return new Uint8Array(s)}catch(i){let s=i instanceof Error?`Failed to deflate ZIP entry: ${i.message}`:"Unknown decompression error in ZIP entry";throw new TypeError(s)}}async readLocalFileHeader(){let e=await this.tokenizer.peekToken(gt);if(e===ol.LocalFileHeader){let t=await this.tokenizer.readToken(zF);return t.filename=await this.tokenizer.readToken(new sn(t.filenameLength,"utf-8")),t}if(e===ol.CentralFileHeader)return!1;throw e===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}};function hoe(r,e){let t=r.length,n=e.length;if(n>t)return-1;for(let o=0;o<=t-n;o++){let i=!0;for(let s=0;s<n;s++)if(r[o+s]!==e[s]){i=!1;break}if(i)return o}return-1}function poe(r){let e=r.reduce((o,i)=>o+i.length,0),t=new Uint8Array(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}var t1=class{constructor(e){this.tokenizer=e}inflate(){let e=this.tokenizer;return new ReadableStream({async pull(t){let n=new Uint8Array(1024),o=await e.readBuffer(n,{mayBeLess:!0});if(o===0){t.close();return}t.enqueue(n.subarray(0,o))}}).pipeThrough(new DecompressionStream("gzip"))}};var SXe={utf8:new globalThis.TextDecoder("utf8")};var AXe=new globalThis.TextEncoder;var TXe=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function PE(r){let{byteLength:e}=r;if(e===6)return r.getUint16(0)*2**32+r.getUint32(2);if(e===5)return r.getUint8(0)*2**32+r.getUint32(1);if(e===4)return r.getUint32(0);if(e===3)return r.getUint8(0)*2**16+r.getUint16(1);if(e===2)return r.getUint16(0);if(e===1)return r.getUint8(0)}function YF(r,e){if(e==="utf-16le"){let t=[];for(let n=0;n<r.length;n++){let o=r.charCodeAt(n);t.push(o&255,o>>8&255)}return t}if(e==="utf-16be"){let t=[];for(let n=0;n<r.length;n++){let o=r.charCodeAt(n);t.push(o>>8&255,o&255)}return t}return[...r].map(t=>t.charCodeAt(0))}function XF(r,e=0){let t=Number.parseInt(new sn(6).get(r,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(t))return!1;let n=256;for(let o=e;o<e+148;o++)n+=r[o];for(let o=e+156;o<e+512;o++)n+=r[o];return t===n}var QF={get:(r,e)=>r[e+3]&127|r[e+2]<<7|r[e+1]<<14|r[e]<<21,len:4};var ZF=["jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","elf","macho","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ttc","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","j2c","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp","aac","mp1","it","s3m","xm","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc","fbx","vsdx","vtt","apk","drc","lz4","potx","xltx","dotx","xltm","ott","ots","otp","odg","otg","xlsm","docm","dotm","potm","pptm","jar","jmp","rm","sav","ppsm","ppsx","tar.gz","reg","dat"],JF=["image/jpeg","image/png","image/gif","image/webp","image/flif","image/x-xcf","image/x-canon-cr2","image/x-canon-cr3","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/x-indesign","application/epub+zip","application/x-xpinstall","application/vnd.ms-powerpoint.slideshow.macroenabled.12","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.slideshow","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/vnd.apache.arrow.file","video/mp4","audio/midi","video/matroska","video/webm","video/quicktime","video/vnd.avi","audio/wav","audio/qcelp","audio/x-ms-asf","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","video/ogg","audio/ogg","audio/ogg; codecs=opus","application/ogg","audio/flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-elf","application/x-mach-binary","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","font/collection","image/x-icon","video/x-flv","application/postscript","application/eps","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-cfb","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/j2c","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/icns","image/ktx","application/dicom","audio/x-musepack","text/calendar","text/vcard","text/vtt","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a","image/apng","image/x-olympus-orf","image/x-sony-arw","image/x-adobe-dng","image/x-nikon-nef","image/x-panasonic-rw2","image/x-fujifilm-raf","video/x-m4v","video/3gpp2","application/x-esri-shape","audio/aac","audio/x-it","audio/x-s3m","audio/x-xm","video/MP1S","video/MP2P","application/vnd.sketchup.skp","image/avif","application/x-lzh-compressed","application/pgp-encrypted","application/x-asar","model/stl","application/vnd.ms-htmlhelp","model/3mf","image/jxl","application/zstd","image/jls","application/vnd.ms-outlook","image/vnd.dwg","application/vnd.apache.parquet","application/java-vm","application/x-arj","application/x-cpio","application/x-ace-compressed","application/avro","application/vnd.iccprofile","application/x.autodesk.fbx","application/vnd.visio","application/vnd.android.package-archive","application/vnd.google.draco","application/x-lz4","application/vnd.openxmlformats-officedocument.presentationml.template","application/vnd.openxmlformats-officedocument.spreadsheetml.template","application/vnd.openxmlformats-officedocument.wordprocessingml.template","application/vnd.ms-excel.template.macroenabled.12","application/vnd.oasis.opendocument.text-template","application/vnd.oasis.opendocument.spreadsheet-template","application/vnd.oasis.opendocument.presentation-template","application/vnd.oasis.opendocument.graphics","application/vnd.oasis.opendocument.graphics-template","application/vnd.ms-excel.sheet.macroenabled.12","application/vnd.ms-word.document.macroenabled.12","application/vnd.ms-word.template.macroenabled.12","application/vnd.ms-powerpoint.template.macroenabled.12","application/vnd.ms-powerpoint.presentation.macroenabled.12","application/java-archive","application/vnd.rn-realmedia","application/x-spss-sav","application/x-ms-regedit","application/x-ft-windows-registry-hive","application/x-jmp-data"];var r1=4100,moe=r1-2,Ai=1024*1024,e$=1024,goe=2**31-1,fo=16*1024*1024,D6=Ai,t$=Ai,yoe=fo,woe=1,r$=100,DE=fo,n$=64,o$=D6,xoe=256,boe=512,Eoe=fo,voe=512,Soe=512,i$=256,s$=D6,a$=D6,Aoe=D6,c$=fo,Toe=new Set(["Unexpected signature","Encrypted ZIP","Expected Central-File-Header signature"]),_oe=["ZIP entry count exceeds ","Unsupported ZIP compression method:","ZIP entry compressed data exceeds ","ZIP entry decompressed data exceeds ","Expected data-descriptor-signature at position "],Ioe=new Set(["Z_BUF_ERROR","Z_DATA_ERROR","ERR_INVALID_STATE"]),ms=class extends Error{};function Coe(r){let e=r?.streamReader;if(e?.constructor?.name!=="WebStreamByobReader")return r;let{reader:t}=e,n=async()=>{await t.cancel(),t.releaseLock()};return e.close=n,e.abort=async()=>{e.interrupted=!0,await n()},r}function OE(r,e,t){if(!Number.isFinite(r)||r<0||r>e)throw new ms(`${t} has invalid size ${r} (maximum ${e} bytes)`);return r}async function Ea(r,e,{maximumLength:t=fo,reason:n="skip"}={}){let o=OE(e,t,n);await r.ignore(o)}async function NE(r,e,t,{maximumLength:n=e.length,reason:o="read"}={}){let i=t?.length??e.length,s=OE(i,n,o);return r.readBuffer(e,{...t,length:s})}async function koe(r,{maximumLength:e=Ai}={}){let o=new ReadableStream({start(l){l.enqueue(r),l.close()}}).pipeThrough(new DecompressionStream("deflate-raw")).getReader(),i=[],s=0;try{for(;;){let{done:l,value:u}=await o.read();if(l)break;if(s+=u.length,s>e)throw await o.cancel(),new Error(`ZIP entry decompressed data exceeds ${e} bytes`);i.push(u)}}finally{o.releaseLock()}let a=new Uint8Array(s),c=0;for(let l of i)a.set(l,c),c+=l.length;return a}var f$=134695760,P6=16,Roe=P6-1;function Poe(r,e){if(r.length<P6)return-1;let t=r.length-P6;for(let n=0;n<=t;n++)if(gt.get(r,n)===f$&&gt.get(r,n+8)===e+n)return n;return-1}function Doe(r){return(r.codePointAt(0)&32)!==0}function Noe(r,e){let t=new Uint8Array(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}async function Loe(r,{shouldBuffer:e,maximumLength:t=Ai}={}){let{syncBuffer:n}=r,{length:o}=n,i=[],s=0;for(;;){let a=await r.tokenizer.peekBuffer(n,{mayBeLess:!0}),c=Poe(n.subarray(0,a),s),l=c>=0?0:a===o?Math.min(Roe,a-1):0,u=c>=0?c:a-l;if(u===0)break;if(s+=u,s>t)throw new Error(`ZIP entry compressed data exceeds ${t} bytes`);if(e){let d=new Uint8Array(u);await r.tokenizer.readBuffer(d),i.push(d)}else await r.tokenizer.ignore(u);if(c>=0)break}if(Gr(r.tokenizer)||(r.knownSizeDescriptorScannedBytes+=s),!!e)return Noe(i,s)}function Ooe(r,e){return Gr(r.tokenizer)?Math.max(0,fo-(r.tokenizer.position-e)):Math.max(0,Ai-r.knownSizeDescriptorScannedBytes)}async function Boe(r,e,{shouldBuffer:t,maximumDescriptorLength:n=Ai}={}){if(e.dataDescriptor&&e.compressedSize===0)return Loe(r,{shouldBuffer:t,maximumLength:n});if(!t){await Ea(r.tokenizer,e.compressedSize,{maximumLength:Gr(r.tokenizer)?Ai:r.tokenizer.fileInfo.size,reason:"ZIP entry compressed data"});return}let o=Voe(r.tokenizer);if(!Number.isFinite(e.compressedSize)||e.compressedSize<0||e.compressedSize>o)throw new Error(`ZIP entry compressed data exceeds ${o} bytes`);let i=new Uint8Array(e.compressedSize);return await r.tokenizer.readBuffer(i),i}il.prototype.inflate=async function(r,e,t){if(r.compressedMethod===0)return t(e);if(r.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${r.compressedMethod}`);let n=await koe(e,{maximumLength:Ai});return t(n)};il.prototype.unzip=async function(r){let e=!1,t=0,n=this.tokenizer.position;this.knownSizeDescriptorScannedBytes=0;do{if(n1(this.tokenizer,n,fo))throw new ms(`ZIP stream probing exceeds ${fo} bytes`);let o=await this.readLocalFileHeader();if(!o)break;if(t++,t>e$)throw new Error(`ZIP entry count exceeds ${e$}`);let i=r(o);e=!!i.stop,await this.tokenizer.ignore(o.extraFieldLength);let s=await Boe(this,o,{shouldBuffer:!!i.handler,maximumDescriptorLength:Math.min(Ai,Ooe(this,n))});if(i.handler&&await this.inflate(o,s,i.handler),o.dataDescriptor){let a=new Uint8Array(P6);if(await this.tokenizer.readBuffer(a),gt.get(a,0)!==f$)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-a.length}`)}if(n1(this.tokenizer,n,fo))throw new ms(`ZIP stream probing exceeds ${fo} bytes`)}while(!e)};function Moe(r,e){let t=r.getReader(),n=0,o=!1,i=!1,s=async a=>{o||i||(i=!0,await t.cancel(a))};return new ReadableStream({async pull(a){if(n>=e){a.close(),await s();return}let{done:c,value:l}=await t.read();if(c||!l){o=!0,a.close();return}let u=e-n;if(l.length>u){a.enqueue(l.subarray(0,u)),n+=u,a.close(),await s();return}a.enqueue(l),n+=l.length},async cancel(a){await s(a)}})}async function h$(r,e){return new LE(e).fromBuffer(r)}function l$(r){switch(r=r.toLowerCase(),r){case"application/epub+zip":return{ext:"epub",mime:r};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:r};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:r};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:r};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:r};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:r};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:r};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:r};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:r};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:r};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:r};case"application/vnd.ms-excel.sheet.macroenabled":return{ext:"xlsm",mime:"application/vnd.ms-excel.sheet.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.spreadsheetml.template":return{ext:"xltx",mime:r};case"application/vnd.ms-excel.template.macroenabled":return{ext:"xltm",mime:"application/vnd.ms-excel.template.macroenabled.12"};case"application/vnd.ms-powerpoint.slideshow.macroenabled":return{ext:"ppsm",mime:"application/vnd.ms-powerpoint.slideshow.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return{ext:"docx",mime:r};case"application/vnd.ms-word.document.macroenabled":return{ext:"docm",mime:"application/vnd.ms-word.document.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.template":return{ext:"dotx",mime:r};case"application/vnd.ms-word.template.macroenabledtemplate":return{ext:"dotm",mime:"application/vnd.ms-word.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.template":return{ext:"potx",mime:r};case"application/vnd.ms-powerpoint.template.macroenabled":return{ext:"potm",mime:"application/vnd.ms-powerpoint.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.presentation":return{ext:"pptx",mime:r};case"application/vnd.ms-powerpoint.presentation.macroenabled":return{ext:"pptm",mime:"application/vnd.ms-powerpoint.presentation.macroenabled.12"};case"application/vnd.ms-visio.drawing":return{ext:"vsdx",mime:"application/vnd.visio"};case"application/vnd.ms-package.3dmanufacturing-3dmodel+xml":return{ext:"3mf",mime:"model/3mf"};default:}}function Si(r,e,t){t={offset:0,...t};for(let[n,o]of e.entries())if(t.mask){if(o!==(t.mask[n]&r[n+t.offset]))return!1}else if(o!==r[n+t.offset])return!1;return!0}function Uoe(r){return Number.isFinite(r)?Math.max(1,Math.trunc(r)):r1}function Foe(r,e,t){return t===void 0?r.read(e):(t.throwIfAborted(),new Promise((n,o)=>{let i=()=>{t.removeEventListener("abort",s)},s=()=>{let a=t.reason;i(),(async()=>{try{await r.cancel(a)}catch{}})(),o(a)};t.addEventListener("abort",s,{once:!0}),(async()=>{try{let a=await r.read(e);i(),n(a)}catch(a){i(),o(a)}})()}))}function $oe(r){return Number.isFinite(r)?Math.max(0,Math.min(moe,Math.trunc(r))):0}function Hoe(r){return Number.isFinite(r)?Math.max(0,r):Number.MAX_SAFE_INTEGER}function Gr(r){let e=r.fileInfo.size;return!Number.isFinite(e)||e===Number.MAX_SAFE_INTEGER}function n1(r,e,t){return Gr(r)&&r.position-e>t}function Voe(r){let e=r.fileInfo.size,t=Number.isFinite(e)?Math.max(0,e-r.position):Number.MAX_SAFE_INTEGER;return Math.min(t,goe)}function qoe(r){if(r instanceof je||r instanceof ms)return!0;if(!(r instanceof Error))return!1;if(Toe.has(r.message)||Ioe.has(r.code))return!0;for(let e of _oe)if(r.message.startsWith(e))return!0;return!1}function u$(r,e=Ai){let t=[r.compressedSize,r.uncompressedSize];for(let n of t)if(!Number.isFinite(n)||n<0||n>e)return!1;return!0}function zoe(){return{hasContentTypesEntry:!1,hasParsedContentTypesEntry:!1,isParsingContentTypes:!1,hasUnparseableContentTypes:!1,hasWordDirectory:!1,hasPresentationDirectory:!1,hasSpreadsheetDirectory:!1,hasThreeDimensionalModelEntry:!1}}function Koe(r,e){e.startsWith("word/")&&(r.hasWordDirectory=!0),e.startsWith("ppt/")&&(r.hasPresentationDirectory=!0),e.startsWith("xl/")&&(r.hasSpreadsheetDirectory=!0),e.startsWith("3D/")&&e.endsWith(".model")&&(r.hasThreeDimensionalModelEntry=!0)}function d$(r){if(!(!r.hasContentTypesEntry||r.hasUnparseableContentTypes||r.isParsingContentTypes||r.hasParsedContentTypesEntry)){if(r.hasWordDirectory)return{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"};if(r.hasPresentationDirectory)return{ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"};if(r.hasSpreadsheetDirectory)return{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};if(r.hasThreeDimensionalModelEntry)return{ext:"3mf",mime:"model/3mf"}}}function Goe(r){let e=r.indexOf('.main+xml"');if(e===-1){let o="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";return r.includes(`ContentType="${o}"`)?o:void 0}let t=r.slice(0,e),n=t.lastIndexOf('"');return t.slice(n+1)}var LE=class r{constructor(e){let t=$oe(e?.mpegOffsetTolerance);this.options={...e,mpegOffsetTolerance:t},this.detectors=[...this.options.customDetectors??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:this.options.signal},this.gzipProbeDepth=0}getTokenizerOptions(){return{...this.tokenizerOptions}}createTokenizerFromWebStream(e){return Coe(BF(e,this.getTokenizerOptions()))}async parseTokenizer(e,t=0){this.detectionReentryCount=t;let n=e.position;for(let o of this.detectors){let i;try{i=await o.detect(e)}catch(s){if(s instanceof je||s instanceof ms)return;throw s}if(i)return i;if(n!==e.position)return}}async fromTokenizer(e){try{return await this.parseTokenizer(e)}finally{await e.close()}}async fromBuffer(e){if(!(e instanceof Uint8Array||e instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``);let t=e instanceof Uint8Array?e:new Uint8Array(e);if(t?.length>1)return this.fromTokenizer(MF(t,this.getTokenizerOptions()))}async fromBlob(e){this.options.signal?.throwIfAborted();let t=UF(e,this.getTokenizerOptions());return this.fromTokenizer(t)}async fromStream(e){this.options.signal?.throwIfAborted();let t=this.createTokenizerFromWebStream(e);return this.fromTokenizer(t)}async toDetectionStream(e,t){let n=Uoe(t?.sampleSize??r1),o,i,s=e.getReader({mode:"byob"});try{let{value:l,done:u}=await Foe(s,new Uint8Array(n),this.options.signal);if(i=l,!u&&l)try{o=await this.fromBuffer(l.subarray(0,n))}catch(d){if(!(d instanceof je))throw d;o=void 0}i=l}finally{s.releaseLock()}let a=new TransformStream({async start(l){l.enqueue(i)},transform(l,u){u.enqueue(l)}}),c=e.pipeThrough(a);return c.fileType=o,c}async detectGzip(e){if(this.gzipProbeDepth>=woe)return{ext:"gz",mime:"application/gzip"};let t=new t1(e),n=Moe(t.inflate(),yoe),o=Gr(e),i,s,a,c;if(o){let l=new AbortController;i=setTimeout(()=>{l.abort(new DOMException(`Operation timed out after ${r$} ms`,"TimeoutError"))},r$),s=this.options.signal===void 0?l.signal:AbortSignal.any([this.options.signal,l.signal]),a=new r({...this.options,signal:s}),a.gzipProbeDepth=this.gzipProbeDepth+1}else this.gzipProbeDepth++;try{c=await(a??this).fromStream(n)}catch(l){if(l?.name==="AbortError"&&s?.reason?.name!=="TimeoutError")throw l}finally{clearTimeout(i),o||this.gzipProbeDepth--}return c?.ext==="tar"?{ext:"tar.gz",mime:"application/gzip"}:{ext:"gz",mime:"application/gzip"}}check(e,t){return Si(this.buffer,e,t)}checkString(e,t){return this.check(YF(e,t?.encoding),t)}detectConfident=async e=>{if(this.buffer=new Uint8Array(r1),e.fileInfo.size===void 0&&(e.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=e,Gr(e)&&(await e.peekBuffer(this.buffer,{length:3,mayBeLess:!0}),this.check([31,139,8])))return this.detectGzip(e);if(await e.peekBuffer(this.buffer,{length:32,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await e.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};if(this.check([239,187,191]))return this.detectionReentryCount>=i$?void 0:(this.detectionReentryCount++,await this.tokenizer.ignore(3),this.detectConfident(e));if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8]))return this.detectGzip(e);if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await Ea(e,6,{maximumLength:6,reason:"ID3 header prefix"});let t=await e.readToken(QF),n=Gr(e);if(!Number.isFinite(t)||t<0||n&&(t>DE||e.position+t>DE))return;if(e.position+t>e.fileInfo.size)return n?void 0:{ext:"mp3",mime:"audio/mpeg"};try{await Ea(e,t,{maximumLength:n?DE:e.fileInfo.size,reason:"ID3 payload"})}catch(o){if(o instanceof je)return;throw o}return this.detectionReentryCount>=i$?void 0:(this.detectionReentryCount++,this.parseTokenizer(e,this.detectionReentryCount))}if(this.checkString("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((this.buffer[0]===67||this.buffer[0]===70)&&this.check([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:"jls",mime:"image/jls"}:{ext:"jpg",mime:"image/jpeg"};if(this.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};if(this.checkString("FLIF"))return{ext:"flif",mime:"image/flif"};if(this.checkString("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(this.checkString("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(this.checkString("FORM"))return{ext:"aif",mime:"audio/aiff"};if(this.checkString("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};if(this.check([80,75,3,4])){let t,n=zoe();try{await new il(e).unzip(o=>{Koe(n,o.filename);let i=o.filename==="[Content_Types].xml",s=d$(n);if(!i&&s)return t=s,{stop:!0};switch(o.filename){case"META-INF/mozilla.rsa":return t={ext:"xpi",mime:"application/x-xpinstall"},{stop:!0};case"META-INF/MANIFEST.MF":return t={ext:"jar",mime:"application/java-archive"},{stop:!0};case"mimetype":return u$(o,t$)?{async handler(a){let c=new TextDecoder("utf-8").decode(a).trim();t=l$(c)},stop:!0}:{};case"[Content_Types].xml":return n.hasContentTypesEntry=!0,u$(o,t$)?(n.isParsingContentTypes=!0,{async handler(a){let c=new TextDecoder("utf-8").decode(a),l=Goe(c);l&&(t=l$(l)),n.hasParsedContentTypesEntry=!0,n.isParsingContentTypes=!1},stop:!0}):(n.hasUnparseableContentTypes=!0,{});default:return/classes\d*\.dex/.test(o.filename)?(t={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}})}catch(o){if(!qoe(o))throw o;n.isParsingContentTypes&&(n.isParsingContentTypes=!1,n.hasUnparseableContentTypes=!0)}return t??d$(n)??{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await e.ignore(28);let t=new Uint8Array(8);return await e.readBuffer(t),Si(t,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:Si(t,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:Si(t,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:Si(t,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:Si(t,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:Si(t,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(this.check([80,75])&&(this.buffer[2]===3||this.buffer[2]===5||this.buffer[2]===7)&&(this.buffer[3]===4||this.buffer[3]===6||this.buffer[3]===8))return{ext:"zip",mime:"application/zip"};if(this.checkString("MThd"))return{ext:"mid",mime:"audio/midi"};if(this.checkString("wOFF")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(this.checkString("wOF2")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(this.checkString("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(this.checkString("LZIP"))return{ext:"lz",mime:"application/x-lzip"};if(this.checkString("fLaC"))return{ext:"flac",mime:"audio/flac"};if(this.check([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(this.checkString("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(this.checkString("%PDF"))return{ext:"pdf",mime:"application/pdf"};if(this.check([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(this.check([73,73])){let t=await this.readTiffHeader(!1);if(t)return t}if(this.check([77,77])){let t=await this.readTiffHeader(!0);if(t)return t}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function t(){let c=await e.peekNumber(NF),l=128,u=0;for(;(c&l)===0&&l!==0;)++u,l>>=1;let d=new Uint8Array(u+1);return await NE(e,d,void 0,{maximumLength:d.length,reason:"EBML field"}),d}async function n(){let c=await t(),l=await t();l[0]^=128>>l.length-1;let u=Math.min(6,l.length),d=new DataView(c.buffer),f=new DataView(l.buffer,l.length-u,u);return{id:PE(d),len:PE(f)}}async function o(c){let l=0;for(;c>0;){if(l++,l>xoe||n1(e,s,fo))return;let u=e.position,d=await n();if(d.id===17026){if(d.len>n$)return;let f=OE(d.len,n$,"EBML DocType");return(await e.readToken(new sn(f))).replaceAll(/\00.*$/g,"")}if(Gr(e)&&(!Number.isFinite(d.len)||d.len<0||d.len>o$)||(await Ea(e,d.len,{maximumLength:Gr(e)?o$:e.fileInfo.size,reason:"EBML payload"}),--c,e.position<=u))return}}let i=await n(),s=e.position;switch(await o(i.len)){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/matroska"};default:return}}if(this.checkString("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(this.check([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(this.checkString("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(this.checkString("MSCF")||this.checkString("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};if(this.check([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(this.check([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(this.check([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(this.check([127,69,76,70]))return{ext:"elf",mime:"application/x-elf"};if(this.check([33,66,68,78]))return{ext:"pst",mime:"application/vnd.ms-outlook"};if(this.checkString("PAR1")||this.checkString("PARE"))return{ext:"parquet",mime:"application/vnd.apache.parquet"};if(this.checkString("ttcf"))return{ext:"ttc",mime:"font/collection"};if(this.check([254,237,250,206])||this.check([254,237,250,207])||this.check([206,250,237,254])||this.check([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};if(this.check([4,34,77,24]))return{ext:"lz4",mime:"application/x-lz4"};if(this.checkString("regf"))return{ext:"dat",mime:"application/x-ft-windows-registry-hive"};if(this.checkString("$FL2")||this.checkString("$FL3"))return{ext:"sav",mime:"application/x-spss-sav"};if(this.check([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(this.checkString("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(this.checkString("{\\rtf"))return{ext:"rtf",mime:"application/rtf"};if(this.check([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(this.checkString("IMPM"))return{ext:"it",mime:"audio/x-it"};if(this.checkString("-lh0-",{offset:2})||this.checkString("-lh1-",{offset:2})||this.checkString("-lh2-",{offset:2})||this.checkString("-lh3-",{offset:2})||this.checkString("-lh4-",{offset:2})||this.checkString("-lh5-",{offset:2})||this.checkString("-lh6-",{offset:2})||this.checkString("-lh7-",{offset:2})||this.checkString("-lzs-",{offset:2})||this.checkString("-lz4-",{offset:2})||this.checkString("-lz5-",{offset:2})||this.checkString("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(this.check([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(this.checkString("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(this.check([202,254,186,190])){let t=IE.get(this.buffer,4),n=el.get(this.buffer,6);if(t>0&&t<=30)return{ext:"macho",mime:"application/x-mach-binary"};if(n>30)return{ext:"class",mime:"application/java-vm"}}if(this.checkString(".RMF"))return{ext:"rm",mime:"application/vnd.rn-realmedia"};if(this.checkString("DRACO"))return{ext:"drc",mime:"application/vnd.google.draco"};if(this.check([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(this.checkString("<?xml "))return{ext:"xml",mime:"application/xml"};if(this.check([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(this.check([82,97,114,33,26,7])&&(this.buffer[6]===0||this.buffer[6]===1))return{ext:"rar",mime:"application/x-rar-compressed"};if(this.checkString("solid "))return{ext:"stl",mime:"model/stl"};if(this.checkString("AC")){let t=new sn(4,"latin1").get(this.buffer,2);if(t.match("^d*")&&t>=1e3&&t<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>"))return await e.ignore(8),await e.readToken(new sn(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("WEBVTT")&&[`
111
111
  `,"\r"," "," ","\0"].some(t=>this.checkString(t,{offset:6})))return{ext:"vtt",mime:"text/vtt"};if(this.check([137,80,78,71,13,10,26,10])){let t={ext:"png",mime:"image/png"},n={ext:"apng",mime:"image/apng"};await e.ignore(8);async function o(){return{length:await e.readToken(LF),type:await e.readToken(new sn(4,"latin1"))}}let i=Gr(e),s=e.position,a=0,c=!1;do{if(a++,a>boe||n1(e,s,Eoe))break;let l=e.position,u=await o();if(u.length<0)return;if(u.type==="IHDR"){if(u.length!==13)return;c=!0}switch(u.type){case"IDAT":return t;case"acTL":return n;default:if(!c&&u.type!=="CgBI")return;if(i&&u.length>s$)return c&&Doe(u.type)?t:void 0;try{await Ea(e,u.length+4,{maximumLength:i?s$+4:e.fileInfo.size,reason:"PNG chunk payload"})}catch(d){if(!i&&(d instanceof ms||d instanceof je))return t;throw d}}if(e.position<=l)break}while(e.position+8<e.fileInfo.size);return t}if(this.check([65,82,82,79,87,49,0,0]))return{ext:"arrow",mime:"application/vnd.apache.arrow.file"};if(this.check([103,108,84,70,2,0,0,0]))return{ext:"glb",mime:"model/gltf-binary"};if(this.check([102,114,101,101],{offset:4})||this.check([109,100,97,116],{offset:4})||this.check([109,111,111,118],{offset:4})||this.check([119,105,100,101],{offset:4}))return{ext:"mov",mime:"video/quicktime"};if(this.check([73,73,82,79,8,0,0,0,24]))return{ext:"orf",mime:"image/x-olympus-orf"};if(this.checkString("gimp xcf "))return{ext:"xcf",mime:"image/x-xcf"};if(this.checkString("ftyp",{offset:4})&&(this.buffer[8]&96)!==0){let t=new sn(4,"latin1").get(this.buffer,8).replace("\0"," ").trim();switch(t){case"avif":case"avis":return{ext:"avif",mime:"image/avif"};case"mif1":return{ext:"heic",mime:"image/heif"};case"msf1":return{ext:"heic",mime:"image/heif-sequence"};case"heic":case"heix":return{ext:"heic",mime:"image/heic"};case"hevc":case"hevx":return{ext:"heic",mime:"image/heic-sequence"};case"qt":return{ext:"mov",mime:"video/quicktime"};case"M4V":case"M4VH":case"M4VP":return{ext:"m4v",mime:"video/x-m4v"};case"M4P":return{ext:"m4p",mime:"video/mp4"};case"M4B":return{ext:"m4b",mime:"audio/mp4"};case"M4A":return{ext:"m4a",mime:"audio/x-m4a"};case"F4V":return{ext:"f4v",mime:"video/mp4"};case"F4P":return{ext:"f4p",mime:"video/mp4"};case"F4A":return{ext:"f4a",mime:"audio/mp4"};case"F4B":return{ext:"f4b",mime:"audio/mp4"};case"crx":return{ext:"cr3",mime:"image/x-canon-cr3"};default:return t.startsWith("3g")?t.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(this.checkString(`REGEDIT4\r
112
112
  `))return{ext:"reg",mime:"application/x-ms-regedit"};if(this.check([82,73,70,70])){if(this.checkString("WEBP",{offset:8}))return{ext:"webp",mime:"image/webp"};if(this.check([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(this.check([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/wav"};if(this.check([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(this.check([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-panasonic-rw2"};if(this.check([48,38,178,117,142,102,207,17,166,217])){let t=!1;try{async function n(){let a=new Uint8Array(16);return await NE(e,a,void 0,{maximumLength:a.length,reason:"ASF header GUID"}),{id:a,size:Number(await e.readToken(OF))}}await Ea(e,30,{maximumLength:30,reason:"ASF header prelude"});let o=Gr(e),i=e.position,s=0;for(;e.position+24<e.fileInfo.size&&(s++,!(s>voe||n1(e,i,fo)));){let a=e.position,c=await n(),l=c.size-24;if(!Number.isFinite(l)||l<0){t=!0;break}if(Si(c.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){let u=new Uint8Array(16);if(l-=await NE(e,u,void 0,{maximumLength:u.length,reason:"ASF stream type GUID"}),Si(u,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"audio/x-ms-asf"};if(Si(u,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"video/x-ms-asf"};break}if(o&&l>a$){t=!0;break}if(await Ea(e,l,{maximumLength:o?a$:e.fileInfo.size,reason:"ASF header payload"}),e.position<=a){t=!0;break}}}catch(n){if(n instanceof je||n instanceof ms)Gr(e)&&(t=!0);else throw n}return t?void 0:{ext:"asf",mime:"application/vnd.ms-asf"}}if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:"ktx",mime:"image/ktx"};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:"mie",mime:"application/x-mie"};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:"shp",mime:"application/x-esri-shape"};if(this.check([255,79,255,81]))return{ext:"j2c",mime:"image/j2c"};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10]))switch(await e.ignore(20),await e.readToken(new sn(4,"ascii"))){case"jp2 ":return{ext:"jp2",mime:"image/jp2"};case"jpx ":return{ext:"jpx",mime:"image/jpx"};case"jpm ":return{ext:"jpm",mime:"image/jpm"};case"mjp2":return{ext:"mj2",mime:"image/mj2"};default:return}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:"jxl",mime:"image/jxl"};if(this.check([254,255]))return this.checkString("<?xml ",{offset:2,encoding:"utf-16be"})?{ext:"xml",mime:"application/xml"}:void 0;if(this.check([208,207,17,224,161,177,26,225]))return{ext:"cfb",mime:"application/x-cfb"};if(await e.peekBuffer(this.buffer,{length:Math.min(256,e.fileInfo.size),mayBeLess:!0}),this.check([97,99,115,112],{offset:36}))return{ext:"icc",mime:"application/vnd.iccprofile"};if(this.checkString("**ACE",{offset:7})&&this.checkString("**",{offset:12}))return{ext:"ace",mime:"application/x-ace-compressed"};if(this.checkString("BEGIN:")){if(this.checkString("VCARD",{offset:6}))return{ext:"vcf",mime:"text/vcard"};if(this.checkString("VCALENDAR",{offset:6}))return{ext:"ics",mime:"text/calendar"}}if(this.checkString("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(this.checkString("Extended Module:"))return{ext:"xm",mime:"audio/x-xm"};if(this.checkString("Creative Voice File"))return{ext:"voc",mime:"audio/x-voc"};if(this.check([4,0,0,0])&&this.buffer.length>=16){let t=new DataView(this.buffer.buffer).getUint32(12,!0);if(t>12&&this.buffer.length>=t+16)try{let n=new TextDecoder().decode(this.buffer.subarray(16,t+16));if(JSON.parse(n).files)return{ext:"asar",mime:"application/x-asar"}}catch{}}if(this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2]))return{ext:"mxf",mime:"application/mxf"};if(this.checkString("SCRM",{offset:44}))return{ext:"s3m",mime:"audio/x-s3m"};if(this.check([71])&&this.check([71],{offset:188}))return{ext:"mts",mime:"video/mp2t"};if(this.check([71],{offset:4})&&this.check([71],{offset:196}))return{ext:"mts",mime:"video/mp2t"};if(this.check([66,79,79,75,77,79,66,73],{offset:60}))return{ext:"mobi",mime:"application/x-mobipocket-ebook"};if(this.check([68,73,67,77],{offset:128}))return{ext:"dcm",mime:"application/dicom"};if(this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70]))return{ext:"lnk",mime:"application/x.ms.shortcut"};if(this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0]))return{ext:"alias",mime:"application/x.apple.alias"};if(this.checkString("Kaydara FBX Binary \0"))return{ext:"fbx",mime:"application/x.autodesk.fbx"};if(this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8})))return{ext:"eot",mime:"application/vnd.ms-fontobject"};if(this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29]))return{ext:"indd",mime:"application/x-indesign"};if(this.check([255,255,0,0,7,0,0,0,4,0,0,0,1,0,1,0])||this.check([0,0,255,255,0,0,0,7,0,0,0,4,0,1,0,1]))return{ext:"jmp",mime:"application/x-jmp-data"};if(await e.peekBuffer(this.buffer,{length:Math.min(512,e.fileInfo.size),mayBeLess:!0}),this.checkString("ustar",{offset:257})&&(this.checkString("\0",{offset:262})||this.checkString(" ",{offset:262}))||this.check([0,0,0,0,0,0],{offset:257})&&XF(this.buffer))return{ext:"tar",mime:"application/x-tar"};if(this.check([255,254])){let t="utf-16le";return this.checkString("<?xml ",{offset:2,encoding:t})?{ext:"xml",mime:"application/xml"}:this.check([255,14],{offset:2})&&this.checkString("SketchUp Model",{offset:4,encoding:t})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:this.checkString(`Windows Registry Editor Version 5.00\r
113
- `,{offset:2,encoding:t})?{ext:"reg",mime:"application/x-ms-regedit"}:void 0}if(this.checkString("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"}};detectImprecise=async e=>{this.buffer=new Uint8Array(r1);let t=Hoe(e.fileInfo.size);if(await e.peekBuffer(this.buffer,{length:Math.min(8,t),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(await e.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,t),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let n=0;n<=this.options.mpegOffsetTolerance;++n){let o=this.scanMpeg(n);if(o)return o}};async readTiffTag(e){let t=await this.tokenizer.readToken(e?el:bt);switch(await this.tokenizer.ignore(10),t){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"};default:}}async readTiffIFD(e){let t=await this.tokenizer.readToken(e?el:bt);if(!(t>Soe)&&!(Gr(this.tokenizer)&&2+t*12>c$))for(let n=0;n<t;++n){let o=await this.readTiffTag(e);if(o)return o}}async readTiffHeader(e){let t={ext:"tif",mime:"image/tiff"},n=(e?el:bt).get(this.buffer,2),o=(e?IE:gt).get(this.buffer,4);if(n===42){if(o>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(o>=8){let a=(e?el:bt).get(this.buffer,8),c=(e?el:bt).get(this.buffer,10);if(a===28&&c===254||a===31&&c===11)return{ext:"nef",mime:"image/x-nikon-nef"}}}if(Gr(this.tokenizer)&&o>Aoe)return t;let i=Gr(this.tokenizer)?c$:this.tokenizer.fileInfo.size;try{await Ea(this.tokenizer,o,{maximumLength:i,reason:"TIFF IFD offset"})}catch(a){if(a instanceof je)return;throw a}let s;try{s=await this.readTiffIFD(e)}catch(a){if(a instanceof je)return;throw a}return s??t}if(n===43)return t}scanMpeg(e){if(this.check([255,224],{offset:e,mask:[255,224]})){if(this.check([16],{offset:e+1,mask:[22]}))return this.check([8],{offset:e+1,mask:[8]})?{ext:"aac",mime:"audio/aac"}:{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:e+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:e+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:e+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}},LXe=new Set(ZF),OXe=new Set(JF);var p$="application/octet-stream";function Woe(r){return/^(<\?xml[^>]+>)?[^<^\w]+<svg/ig.test(r)}async function joe(r){try{return JSON.parse(r),!0}catch{return!1}}function Yoe(r){let e=new TextDecoder("utf-8",{fatal:!0});try{return e.decode(r)}catch{return null}}async function Xoe(r){return/^\s*<(?:!doctype\s+html|html|head|body)\b/i.test(r)}async function m$(r,e){let t=(await h$(r))?.mime;if(t!=null)return t==="application/xml"&&e?.toLowerCase().endsWith(".svg")?"image/svg+xml":t;if(e==null||e.includes(".")===!1){let n=Yoe(r);return n!=null?Woe(n)?"image/svg+xml":await joe(n)?"application/json":await Xoe(n)?"text/html; charset=utf-8":"text/plain; charset=utf-8":p$}switch(e.split(".").pop()){case"css":return"text/css";case"html":return"text/html; charset=utf-8";case"js":return"application/javascript";case"json":return"application/json";case"txt":return"text/plain";case"woff2":return"font/woff2";case"svg":return"image/svg+xml";case"csv":return"text/csv";case"doc":return"application/msword";case"xls":return"application/vnd.ms-excel";case"ppt":return"application/vnd.ms-powerpoint";case"msi":return"application/x-msdownload";default:return p$}}function g$(r,e,t){if(t?.signal?.throwIfAborted(),["AbortError"].includes(e.name))throw e;return["InvalidParametersError"].includes(e.name)?nn(r,e):e.code==="ECONNREFUSED"||e.code==="ECANCELLED"||e.name==="DNSQueryFailedError"?G4(r,e):["NotUnixFSError"].includes(e.name)?Qc(r,e):e.code==="ETIMEOUT"||e.name==="TimeoutError"?G4(r,e):["ERR_BAD_PATH","ERR_NO_TERMINAL_ELEMENT","ERR_NOT_FOUND"].includes(e.code)?M9(r):["DoesNotExistError"].includes(e.name)?M9(r):["BlockNotFoundWhileOfflineError"].includes(e.name)?cB(r):["RecordNotFoundError","LoadBlockFailedError"].includes(e.name)?G4(r,e):O9(r,e)}function y$({cid:r,contentType:e,ranges:t,contentPrefix:n}){let o=e.immutable?"":"W/",i=e.etag;if(t?.length!=null&&t?.length>0){let s=t.filter(a=>a.start!=null||a.end!=null);s.length>0&&(i+="."+s.map(a=>`${a.start??0}-${a.end??"N"}`).join(","))}return`${o}"${n??""}${r.toString()}${i}"`}function BE(r,e){let t=(e?.get("if-none-match")??"").split(",").map(n=>(n=n.trim(),n.startsWith("W/")&&(n=n.substring(2)),n));return r.startsWith("W/")&&(r=r.substring(2)),t.includes("*")||t.includes(r)}function ME(r){if(r==null||r==="")return;let e=Number(r);if(isNaN(e))throw new rn(`Invalid range specification: could not parse "${e}" as number`);return e}function Qoe(r){if(r==null||r==="")return[];if(!r.startsWith("bytes="))throw new rn("Invalid range request");let t=r.substring(6).split(",").map(o=>o.trim()),n=[];for(let o of t){let i=o.match(/^(?<start>\d+)?-(?<end>\d+)?$/);if(i?.groups==null)throw new rn(`Invalid range specification: ${o}`);if(o.startsWith("-"))n.push({end:ME(o)});else{let{start:s,end:a}=i.groups;n.push({start:ME(s),end:ME(a)})}}return n}function w$(r,e){let t=e.get("range");if(t!=null)try{let n=Qoe(t);return n.length===0?void 0:{multipartBoundary:`multipart_byteranges_${Math.floor(Math.random()*1e9)}`,ranges:n}}catch(n){return n.name==="InvalidRangeError"?W4(r):nn(r,n)}}function Zoe(r){if(!r.startsWith("/ipfs/")&&!r.startsWith("/ipns/"))throw new T(`Path ${r} did not start with /ipfs/ or /ipns/`);let e=new URL(`not-http://example.com${r}`),[,t,n,...o]=e.pathname.split("/");return`${t}://${n}${o.length>0?`/${o.join("/")}`:""}${e.search}${e.hash}`}function x$(r){if((r.startsWith("/ipfs/")||r.startsWith("/ipns/"))&&(r=Zoe(r)),r.startsWith("ipfs://")||r.startsWith("ipns://")||r.startsWith("dnslink://")){let e=new URL(r);if(e.protocol==="ipns:")try{q.parse(e.hostname)}catch{try{De(e.hostname)}catch{e.protocol="dnslink"}}return e}throw new T(`URL did not start with ipfs:// or ipns:// - ${r}`)}function Joe(r){if(r!=null)return{...r,signal:r?.signal==null?void 0:r?.signal}}function eie(r){let e=r.get("accept")?.split(",")??[];return e.length!==1?!1:e[0].split(";")[0]===Wc}function N6(r){return`${r}`.substring(0,10)}var L6=class{helia;ipnsResolver;dnsLink;log;contentTypeParser;withServerTiming;plugins=[];urlResolver;constructor(e,t={}){this.helia=e,this.log=e.logger.forComponent("helia:verified-fetch"),this.ipnsResolver=t.ipnsResolver??YL(e),this.dnsLink=t.dnsLink??qL(e),this.contentTypeParser=t.contentTypeParser??m$,this.withServerTiming=t?.withServerTiming??!1,this.urlResolver=new v6({ipnsResolver:this.ipnsResolver,dnsLink:this.dnsLink,helia:this.helia},t);let n={...t,logger:e.logger.forComponent("verified-fetch"),helia:e,contentTypeParser:this.contentTypeParser,ipnsResolver:this.ipnsResolver},o=[new n6(n),new Y4(n),new j4(n),new r6(n),new X4(n),new Q4(n)],i=t.plugins?.map(s=>s(n))??[];if(i.length>0){let s=new Map(o.map(c=>[c.id,c])),a=new Map(i.map(c=>[c.id,c]));this.plugins=o.map(c=>a.get(c.id)??c),this.plugins.unshift(...i.filter(c=>!s.has(c.id)))}else this.plugins=o}async fetch(e,t){this.log("fetch %s %s",t?.method??"GET",e);try{if(t?.method==="OPTIONS")return this.handleFinalResponse(new Response(null,{status:200}));let n=Joe(t),o=new Headers(n?.headers),i=new wd;n!=null&&(n.offline??=o.get("cache-control")==="only-if-cached"),n?.onProgress?.(new P("verified-fetch:request:start",{resource:e}));let s=w$(e,o);if(s instanceof Response)return this.handleFinalResponse(s);let a=this.parseResource(e);if(a.protocol==="ipfs:"&&a.pathname===""&&BE(`"${a.hostname}"`,o))return U9(e,new Headers({etag:`"${a.hostname}"`,"cache-control":"public, max-age=29030400, immutable"}));let c=tie(a,o.get("accept"));if(eie(o)){if(a.protocol!=="ipns:")return wa(a,c,[Yc]);let g=this.plugins.find(m=>m.id==="ipns-record-plugin");return g==null?wa(e,c,[]):this.handleFinalResponse(await g.handle({...n,range:s,url:a,resource:e,redirected:!1}))}let l=await this.urlResolver.resolve(a,i,n);if(l instanceof Response)return this.handleFinalResponse(l);n?.onProgress?.(new P("verified-fetch:request:resolve",{cid:l.terminalElement.cid,path:l.url.pathname}));let u=this.getAcceptHeader(l.url,c,l.terminalElement.cid);if(u instanceof Response)return this.log("allowed media types for requested CID did not contain anything the client can understand"),this.handleFinalResponse(u);let d={},f={},h={},p={...n,...l,resource:e,accept:u,range:s,serverTiming:i,headers:o,requestedMimeTypes:c,onProgress:g=>{if(n?.onProgress?.(g),g.type==="helia:routing:find-providers:start")d[g.detail.routing]={start:Date.now(),found:0};else if(g.type==="helia:routing:find-providers:provider"){if(d[g.detail.routing]==null)return;d[g.detail.routing].found++,i.add(Kn("found-provider"),`${Kn(g.detail.routing)},${N6(g.detail.provider.id)}`,Date.now()-d[g.detail.routing].start)}else if(g.type==="helia:routing:find-providers:end"){let m=d[g.detail.routing];if(m==null)return;i.add(Kn("find-providers"),`${Kn(g.detail.routing)},${m.found}`,Date.now()-m.start)}else if(g.type==="helia:block-broker:connect")f[`connect-${g.detail.broker}-${g.detail.provider}`]={start:Date.now(),transport:""};else if(g.type==="helia:block-broker:connected"){let m=f[`connect-${g.detail.broker}-${g.detail.provider}`];if(m==null)return;i.add(Kn("connect"),`${Kn(g.detail.broker)},${N6(g.detail.provider)},${yB(g.detail.address)}`,Date.now()-m.start)}else if(g.type==="helia:block-broker:request-block")h[`block-${g.detail.broker}-${g.detail.cid}-${g.detail.provider}`]=Date.now();else if(g.type==="helia:block-broker:receive-block"){let m=h[`block-${g.detail.broker}-${g.detail.cid}-${g.detail.provider}`];if(m==null)return;i.add(Kn("block"),`${Kn(g.detail.broker)},${N6(g.detail.provider)},${N6(g.detail.cid)}`,Date.now()-m)}}};this.log.trace('finding handler for cid code "0x%s" and response content types %s',l.terminalElement.cid.code.toString(16),u.map(g=>g.contentType.mediaType).join(", "));let y=await this.runPluginPipeline(p);return n?.onProgress?.(new P("verified-fetch:request:end",{cid:l.terminalElement.cid,path:l.url.pathname})),y==null&&this.log.error("no plugin could handle request for %s",e),this.handleFinalResponse(y,!!n?.withServerTiming||!!this.withServerTiming,p)}catch(n){return this.log.error("error fetching resource %s - %e",e,n),this.handleFinalResponse(g$(e,n,t))}}getAcceptHeader(e,t,n){let o=tB(e.protocol,n),i=[];for(let s of t){let[a,c]=s.mediaType.split("/");for(let l of o){let[u,d]=l.mediaType.split("/");s.mediaType.includes(l.mediaType)&&i.push({contentType:l,options:s.options}),s.mediaType==="*/*"&&i.push({contentType:l,options:s.options}),s.mediaType.startsWith("*/")&&d===c&&i.push({contentType:l,options:s.options}),s.mediaType.endsWith("/*")&&u===a&&i.push({contentType:l,options:s.options})}}return i.length===0?(this.log("requested %o",t.map(({mediaType:s})=>s)),this.log("supported %o",o.map(({mediaType:s})=>s)),wa(e,t,o)):i}parseResource(e){return(Et(e)||p1(e))&&(e=`/ipns/${e}`),(q.asCID(e)===e||e instanceof q)&&(e=`/ipfs/${e}`),new URL(x$(e.toString()))}handleFinalResponse(e,t,n){let o=eB(e.headers.get("content-type"))??H4;if(t===!0&&n?.serverTiming!=null){let i=n?.serverTiming.getHeader();i!==""&&e.headers.set("server-timing",i)}if(n?.url?.protocol!=null&&n.ttl!=null&&iB({response:e,ttl:n.ttl,protocol:n.url.protocol}),n?.terminalElement.cid!=null){let i=decodeURI(n?.url.pathname),s=L(v(i),"ascii");e.headers.set("x-ipfs-path",`/${n.url.protocol==="ipfs:"?"ipfs":"ipns"}/${n?.url.hostname}${s==="/"?"":s}`)}if(e.headers.set("access-control-allow-origin","*"),e.headers.set("access-control-allow-methods","GET, HEAD, OPTIONS"),e.headers.set("access-control-allow-headers","Content-Type, Range, User-Agent, X-Requested-With"),e.headers.set("access-control-expose-headers","Content-Range, Content-Length, X-Ipfs-Path, X-Ipfs-Roots, X-Chunked-Output, X-Stream-Output"),n?.terminalElement.cid!=null&&e.headers.get("etag")==null){let i=y$({cid:n.terminalElement.cid,contentType:o,ranges:n?.range?.ranges});if(e.headers.set("etag",i),BE(i,n?.headers))return U9(e.url,e.headers)}return n?.method==="HEAD"?new Response(null,{status:200,headers:e.headers}):(e.status>399&&e.headers.delete("content-disposition"),e)}async runPluginPipeline(e){let t,n=new Set;this.log.trace("checking which plugins can handle %c%s with accept %s",e.terminalElement.cid,e.url.pathname,e.accept.map(a=>a.contentType.mediaType).join(", "));let o=this.plugins.filter(a=>!n.has(a.id)).filter(a=>a.canHandle(e));if(o.length===0)return this.log.trace("no plugins found that can handle request; exiting pipeline"),B9(e.resource);this.log.trace("plugins ready to handle request: %s",o.map(a=>a.id).join(", "));let i=!1,s=!1;for(let a of o){this.log("invoking plugin: %s",a.id),n.add(a.id);let c=await a.handle(e);if(this.log("plugin response %s %o",a.id,c),c!=null){t=c,s=!0;break}if(t!=null){this.log.trace("plugin %s produced final response",a.id);break}if(s&&t!=null)break;if(!i){this.log.trace("no context changes and no final response; exiting pipeline.");break}}return t??B9(e.resource,JSON.stringify({error:Xc(new Error("No verified fetch plugin could handle the request"))}),{headers:{"content-type":"application/json"}})}async start(){await this.helia.start()}async stop(){await this.helia.stop()}};function tie(r,e){return(e==null||e==="")&&(e="*/*"),e.split(",").map(t=>{let n=t.trim().split(";"),o={q:"1"};for(let i=1;i<n.length;i++){let[s,a]=n[i].split("=").map(c=>c.trim());o[s]=a}return{mediaType:`${n[0]}`.trim(),options:o}}).sort((t,n)=>t.options.q===n.options.q?0:t.options.q>n.options.q?-1:1)}var o1,O6=async function(e,t){return o1==null&&(o1=await UE()),o1(e,t)};O6.start=async function(){await o1?.start()};O6.stop=async function(){await o1?.stop()};async function UE(r,e){let t;if(!rie(r)){let n=nie(r?.dnsResolvers),o=$L();o.dns=n;let i=r?.routers??["https://delegated-ipfs.dev"];for(let c=0;c<i.length;c++)o.services[`delegatedRouting${c}`]=M2({url:i[c]});r?.libp2pConfig!=null&&Object.assign(o,r.libp2pConfig),t=await Tg(o);let s=[oh()],a=[bh(t)];(r?.gateways==null||r.gateways.length>0)&&(s.push(ah({allowInsecure:r?.allowInsecure,allowLocal:r?.allowLocal})),a.push(xh({gateways:r?.gateways??["https://trustless-gateway.link"]}))),r=await FL({libp2p:t,blockBrokers:s,dns:n,routers:a,hashers:r?.hashers}),r.logger.forComponent("helia:verified-fetch").trace("created verified-fetch with libp2p config: %j",o)}return b$(r,e)}async function b$(r,e){let t=new L6(r,e);async function n(o,i){return t.fetch(o,i)}return n.start=t.start.bind(t),n.stop=t.stop.bind(t),n}function rie(r){return r?.blockstore!=null&&r?.datastore!=null&&r?.gc!=null&&r?.stop!=null&&r?.start!=null}function nie(r){if(r!=null)return Array.isArray(r)?cc({resolvers:{".":r}}):cc({resolvers:r})}return _$(oie);})();
113
+ `,{offset:2,encoding:t})?{ext:"reg",mime:"application/x-ms-regedit"}:void 0}if(this.checkString("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"}};detectImprecise=async e=>{this.buffer=new Uint8Array(r1);let t=Hoe(e.fileInfo.size);if(await e.peekBuffer(this.buffer,{length:Math.min(8,t),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(await e.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,t),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let n=0;n<=this.options.mpegOffsetTolerance;++n){let o=this.scanMpeg(n);if(o)return o}};async readTiffTag(e){let t=await this.tokenizer.readToken(e?el:bt);switch(await this.tokenizer.ignore(10),t){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"};default:}}async readTiffIFD(e){let t=await this.tokenizer.readToken(e?el:bt);if(!(t>Soe)&&!(Gr(this.tokenizer)&&2+t*12>c$))for(let n=0;n<t;++n){let o=await this.readTiffTag(e);if(o)return o}}async readTiffHeader(e){let t={ext:"tif",mime:"image/tiff"},n=(e?el:bt).get(this.buffer,2),o=(e?IE:gt).get(this.buffer,4);if(n===42){if(o>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(o>=8){let a=(e?el:bt).get(this.buffer,8),c=(e?el:bt).get(this.buffer,10);if(a===28&&c===254||a===31&&c===11)return{ext:"nef",mime:"image/x-nikon-nef"}}}if(Gr(this.tokenizer)&&o>Aoe)return t;let i=Gr(this.tokenizer)?c$:this.tokenizer.fileInfo.size;try{await Ea(this.tokenizer,o,{maximumLength:i,reason:"TIFF IFD offset"})}catch(a){if(a instanceof je)return;throw a}let s;try{s=await this.readTiffIFD(e)}catch(a){if(a instanceof je)return;throw a}return s??t}if(n===43)return t}scanMpeg(e){if(this.check([255,224],{offset:e,mask:[255,224]})){if(this.check([16],{offset:e+1,mask:[22]}))return this.check([8],{offset:e+1,mask:[8]})?{ext:"aac",mime:"audio/aac"}:{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:e+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:e+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:e+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}},LXe=new Set(ZF),OXe=new Set(JF);var p$="application/octet-stream";function Woe(r){return/^(<\?xml[^>]+>)?[^<^\w]+<svg/ig.test(r)}async function joe(r){try{return JSON.parse(r),!0}catch{return!1}}function Yoe(r){let e=new TextDecoder("utf-8",{fatal:!0});try{return e.decode(r)}catch{return null}}async function Xoe(r){return/^\s*<(?:!doctype\s+html|html|head|body)\b/i.test(r)}async function m$(r,e){let t=(await h$(r))?.mime;if(t!=null)return t==="application/xml"&&e?.toLowerCase().endsWith(".svg")?"image/svg+xml":t;if(e==null||e.includes(".")===!1){let n=Yoe(r);return n!=null?Woe(n)?"image/svg+xml":await joe(n)?"application/json":await Xoe(n)?"text/html; charset=utf-8":"text/plain; charset=utf-8":p$}switch(e.split(".").pop()){case"css":return"text/css";case"html":return"text/html; charset=utf-8";case"js":return"application/javascript";case"json":return"application/json";case"txt":return"text/plain";case"woff2":return"font/woff2";case"svg":return"image/svg+xml";case"csv":return"text/csv";case"doc":return"application/msword";case"xls":return"application/vnd.ms-excel";case"ppt":return"application/vnd.ms-powerpoint";case"msi":return"application/x-msdownload";default:return p$}}function g$(r,e,t){if(t?.signal?.throwIfAborted(),["AbortError"].includes(e.name))throw e;return["InvalidParametersError"].includes(e.name)?nn(r,e):e.code==="ECONNREFUSED"||e.code==="ECANCELLED"||e.name==="DNSQueryFailedError"?G4(r,e):["NotUnixFSError"].includes(e.name)?Qc(r,e):e.code==="ETIMEOUT"||e.name==="TimeoutError"?G4(r,e):["ERR_BAD_PATH","ERR_NO_TERMINAL_ELEMENT","ERR_NOT_FOUND"].includes(e.code)?M9(r):["DoesNotExistError"].includes(e.name)?M9(r):["BlockNotFoundWhileOfflineError"].includes(e.name)?cB(r):["RecordNotFoundError","LoadBlockFailedError"].includes(e.name)?G4(r,e):O9(r,e)}function y$({cid:r,contentType:e,ranges:t,contentPrefix:n}){let o=e.immutable?"":"W/",i=e.etag;if(t?.length!=null&&t?.length>0){let s=t.filter(a=>a.start!=null||a.end!=null);s.length>0&&(i+="."+s.map(a=>`${a.start??0}-${a.end??"N"}`).join(","))}return`${o}"${n??""}${r.toString()}${i}"`}function BE(r,e){let t=(e?.get("if-none-match")??"").split(",").map(n=>(n=n.trim(),n.startsWith("W/")&&(n=n.substring(2)),n));return r.startsWith("W/")&&(r=r.substring(2)),t.includes("*")||t.includes(r)}function ME(r){if(r==null||r==="")return;let e=Number(r);if(isNaN(e))throw new rn(`Invalid range specification: could not parse "${e}" as number`);return e}function Qoe(r){if(r==null||r==="")return[];if(!r.startsWith("bytes="))throw new rn("Invalid range request");let t=r.substring(6).split(",").map(o=>o.trim()),n=[];for(let o of t){let i=o.match(/^(?<start>\d+)?-(?<end>\d+)?$/);if(i?.groups==null)throw new rn(`Invalid range specification: ${o}`);if(o.startsWith("-"))n.push({end:ME(o)});else{let{start:s,end:a}=i.groups;n.push({start:ME(s),end:ME(a)})}}return n}function w$(r,e){let t=e.get("range");if(t!=null)try{let n=Qoe(t);return n.length===0?void 0:{multipartBoundary:`multipart_byteranges_${Math.floor(Math.random()*1e9)}`,ranges:n}}catch(n){return n.name==="InvalidRangeError"?W4(r):nn(r,n)}}function Zoe(r){if(!r.startsWith("/ipfs/")&&!r.startsWith("/ipns/"))throw new T(`Path ${r} did not start with /ipfs/ or /ipns/`);let e=new URL(`not-http://example.com${r}`),[,t,n,...o]=e.pathname.split("/");return`${t}://${n}${o.length>0?`/${o.join("/")}`:""}${e.search}${e.hash}`}function x$(r){if((r.startsWith("/ipfs/")||r.startsWith("/ipns/"))&&(r=Zoe(r)),r.startsWith("ipfs://")||r.startsWith("ipns://")||r.startsWith("dnslink://")){let e=new URL(r);if(e.protocol==="ipns:")try{q.parse(e.hostname)}catch{try{De(e.hostname)}catch{e.protocol="dnslink"}}return e}throw new T(`URL did not start with ipfs:// or ipns:// - ${r}`)}function Joe(r){if(r!=null)return{...r,signal:r?.signal==null?void 0:r?.signal}}function eie(r){let e=r.get("accept")?.split(",")??[];return e.length!==1?!1:e[0].split(";")[0]===Wc}function N6(r){return`${r}`.substring(0,10)}var L6=class{helia;ipnsResolver;dnsLink;log;contentTypeParser;withServerTiming;plugins=[];urlResolver;constructor(e,t={}){this.helia=e,this.log=e.logger.forComponent("helia:verified-fetch"),this.ipnsResolver=t.ipnsResolver??YL(e),this.dnsLink=t.dnsLink??qL(e),this.contentTypeParser=t.contentTypeParser??m$,this.withServerTiming=t?.withServerTiming??!1,this.urlResolver=new v6({ipnsResolver:this.ipnsResolver,dnsLink:this.dnsLink,helia:this.helia},t);let n={...t,logger:e.logger.forComponent("verified-fetch"),helia:e,contentTypeParser:this.contentTypeParser,ipnsResolver:this.ipnsResolver},o=[new n6(n),new Y4(n),new j4(n),new r6(n),new X4(n),new Q4(n)],i=t.plugins?.map(s=>s(n))??[];if(i.length>0){let s=new Map(o.map(c=>[c.id,c])),a=new Map(i.map(c=>[c.id,c]));this.plugins=o.map(c=>a.get(c.id)??c),this.plugins.unshift(...i.filter(c=>!s.has(c.id)))}else this.plugins=o}async fetch(e,t){this.log("fetch %s %s",t?.method??"GET",e);try{if(t?.method==="OPTIONS")return this.handleFinalResponse(new Response(null,{status:200}));let n=Joe(t),o=new Headers(n?.headers),i=new wd;n!=null&&(n.offline??=o.get("cache-control")==="only-if-cached"),n?.onProgress?.(new P("verified-fetch:request:start",{resource:e}));let s=w$(e,o);if(s instanceof Response)return this.handleFinalResponse(s);let a=this.parseResource(e);if(a.protocol==="ipfs:"&&a.pathname===""&&BE(`"${a.hostname}"`,o))return U9(e,new Headers({etag:`"${a.hostname}"`,"cache-control":"public, max-age=29030400, immutable"}));let c=tie(a,o.get("accept"));if(eie(o)){if(a.protocol!=="ipns:")return wa(a,c,[Yc]);let g=this.plugins.find(m=>m.id==="ipns-record-plugin");return g==null?wa(e,c,[]):this.handleFinalResponse(await g.handle({...n,range:s,url:a,resource:e,redirected:!1}))}let l=await this.urlResolver.resolve(a,i,n);if(l instanceof Response)return this.handleFinalResponse(l);n?.onProgress?.(new P("verified-fetch:request:resolve",{cid:l.terminalElement.cid,path:l.url.pathname}));let u=this.getAcceptHeader(l.url,c,l.terminalElement.cid);if(u instanceof Response)return this.log("allowed media types for requested CID did not contain anything the client can understand"),this.handleFinalResponse(u);let d={},f={},h={},p={...n,...l,resource:e,accept:u,range:s,serverTiming:i,headers:o,requestedMimeTypes:c,onProgress:g=>{if(n?.onProgress?.(g),g.type==="helia:routing:find-providers:start")d[g.detail.routing]={start:performance.now(),found:0};else if(g.type==="helia:routing:find-providers:provider"){if(d[g.detail.routing]==null)return;d[g.detail.routing].found++,i.add(Kn("found-provider"),`${Kn(g.detail.routing)},${N6(g.detail.provider.id)}`,performance.now()-d[g.detail.routing].start)}else if(g.type==="helia:routing:find-providers:end"){let m=d[g.detail.routing];if(m==null)return;i.add(Kn("find-providers"),`${Kn(g.detail.routing)},${m.found}`,performance.now()-m.start)}else if(g.type==="helia:block-broker:connect")f[`connect-${g.detail.broker}-${g.detail.provider}`]={start:performance.now(),transport:""};else if(g.type==="helia:block-broker:connected"){let m=f[`connect-${g.detail.broker}-${g.detail.provider}`];if(m==null)return;i.add(Kn("connect"),`${Kn(g.detail.broker)},${N6(g.detail.provider)},${yB(g.detail.address)}`,performance.now()-m.start)}else if(g.type==="helia:block-broker:request-block")h[`block-${g.detail.broker}-${g.detail.cid}-${g.detail.provider}`]=performance.now();else if(g.type==="helia:block-broker:receive-block"){let m=h[`block-${g.detail.broker}-${g.detail.cid}-${g.detail.provider}`];if(m==null)return;i.add(Kn("block"),`${Kn(g.detail.broker)},${N6(g.detail.provider)},${N6(g.detail.cid)}`,performance.now()-m)}}};this.log.trace('finding handler for cid code "0x%s" and response content types %s',l.terminalElement.cid.code.toString(16),u.map(g=>g.contentType.mediaType).join(", "));let y=await this.runPluginPipeline(p);return n?.onProgress?.(new P("verified-fetch:request:end",{cid:l.terminalElement.cid,path:l.url.pathname})),y==null&&this.log.error("no plugin could handle request for %s",e),this.handleFinalResponse(y,!!n?.withServerTiming||!!this.withServerTiming,p)}catch(n){return this.log.error("error fetching resource %s - %e",e,n),this.handleFinalResponse(g$(e,n,t))}}getAcceptHeader(e,t,n){let o=tB(e.protocol,n),i=[];for(let s of t){let[a,c]=s.mediaType.split("/");for(let l of o){let[u,d]=l.mediaType.split("/");s.mediaType.includes(l.mediaType)&&i.push({contentType:l,options:s.options}),s.mediaType==="*/*"&&i.push({contentType:l,options:s.options}),s.mediaType.startsWith("*/")&&d===c&&i.push({contentType:l,options:s.options}),s.mediaType.endsWith("/*")&&u===a&&i.push({contentType:l,options:s.options})}}return i.length===0?(this.log("requested %o",t.map(({mediaType:s})=>s)),this.log("supported %o",o.map(({mediaType:s})=>s)),wa(e,t,o)):i}parseResource(e){return(Et(e)||p1(e))&&(e=`/ipns/${e}`),(q.asCID(e)===e||e instanceof q)&&(e=`/ipfs/${e}`),new URL(x$(e.toString()))}handleFinalResponse(e,t,n){let o=eB(e.headers.get("content-type"))??H4;if(t===!0&&n?.serverTiming!=null){let i=n?.serverTiming.getHeader();i!==""&&e.headers.set("server-timing",i)}if(n?.url?.protocol!=null&&n.ttl!=null&&iB({response:e,ttl:n.ttl,protocol:n.url.protocol}),n?.terminalElement.cid!=null){let i=decodeURI(n?.url.pathname),s=L(v(i),"ascii");e.headers.set("x-ipfs-path",`/${n.url.protocol==="ipfs:"?"ipfs":"ipns"}/${n?.url.hostname}${s==="/"?"":s}`)}if(e.headers.set("access-control-allow-origin","*"),e.headers.set("access-control-allow-methods","GET, HEAD, OPTIONS"),e.headers.set("access-control-allow-headers","Content-Type, Range, User-Agent, X-Requested-With"),e.headers.set("access-control-expose-headers","Content-Range, Content-Length, X-Ipfs-Path, X-Ipfs-Roots, X-Chunked-Output, X-Stream-Output"),n?.terminalElement.cid!=null&&e.headers.get("etag")==null){let i=y$({cid:n.terminalElement.cid,contentType:o,ranges:n?.range?.ranges});if(e.headers.set("etag",i),BE(i,n?.headers))return U9(e.url,e.headers)}return n?.method==="HEAD"?new Response(null,{status:200,headers:e.headers}):(e.status>399&&e.headers.delete("content-disposition"),e)}async runPluginPipeline(e){let t,n=new Set;this.log.trace("checking which plugins can handle %c%s with accept %s",e.terminalElement.cid,e.url.pathname,e.accept.map(a=>a.contentType.mediaType).join(", "));let o=this.plugins.filter(a=>!n.has(a.id)).filter(a=>a.canHandle(e));if(o.length===0)return this.log.trace("no plugins found that can handle request; exiting pipeline"),B9(e.resource);this.log.trace("plugins ready to handle request: %s",o.map(a=>a.id).join(", "));let i=!1,s=!1;for(let a of o){this.log("invoking plugin: %s",a.id),n.add(a.id);let c=await a.handle(e);if(this.log("plugin response %s %o",a.id,c),c!=null){t=c,s=!0;break}if(t!=null){this.log.trace("plugin %s produced final response",a.id);break}if(s&&t!=null)break;if(!i){this.log.trace("no context changes and no final response; exiting pipeline.");break}}return t??B9(e.resource,JSON.stringify({error:Xc(new Error("No verified fetch plugin could handle the request"))}),{headers:{"content-type":"application/json"}})}async start(){await this.helia.start()}async stop(){await this.helia.stop()}};function tie(r,e){return(e==null||e==="")&&(e="*/*"),e.split(",").map(t=>{let n=t.trim().split(";"),o={q:"1"};for(let i=1;i<n.length;i++){let[s,a]=n[i].split("=").map(c=>c.trim());o[s]=a}return{mediaType:`${n[0]}`.trim(),options:o}}).sort((t,n)=>t.options.q===n.options.q?0:t.options.q>n.options.q?-1:1)}var o1,O6=async function(e,t){return o1==null&&(o1=await UE()),o1(e,t)};O6.start=async function(){await o1?.start()};O6.stop=async function(){await o1?.stop()};async function UE(r,e){let t;if(!rie(r)){let n=nie(r?.dnsResolvers),o=$L();o.dns=n;let i=r?.routers??["https://delegated-ipfs.dev"];for(let c=0;c<i.length;c++)o.services[`delegatedRouting${c}`]=M2({url:i[c]});r?.libp2pConfig!=null&&Object.assign(o,r.libp2pConfig),t=await Tg(o);let s=[oh()],a=[bh(t)];(r?.gateways==null||r.gateways.length>0)&&(s.push(ah({allowInsecure:r?.allowInsecure,allowLocal:r?.allowLocal})),a.push(xh({gateways:r?.gateways??["https://trustless-gateway.link"]}))),r=await FL({libp2p:t,blockBrokers:s,dns:n,routers:a,hashers:r?.hashers}),r.logger.forComponent("helia:verified-fetch").trace("created verified-fetch with libp2p config: %j",o)}return b$(r,e)}async function b$(r,e){let t=new L6(r,e);async function n(o,i){return t.fetch(o,i)}return n.start=t.start.bind(t),n.stop=t.stop.bind(t),n}function rie(r){return r?.blockstore!=null&&r?.datastore!=null&&r?.gc!=null&&r?.stop!=null&&r?.start!=null}function nie(r){if(r!=null)return Array.isArray(r)?cc({resolvers:{".":r}}):cc({resolvers:r})}return _$(oie);})();
114
114
  /*! Bundled license information:
115
115
 
116
116
  pvtsutils/build/index.js: