@junobuild/cli-tools 0.9.3 → 0.9.4

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.
@@ -18,7 +18,7 @@ ${i}`,Cp=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),kp=Objec
18
18
  `),n=Math.max(0,a.length-t);return n?Z(i,ie(a.slice(0,n).join(`
19
19
  `)).length+1):i};su=Bt(gs.stdout),ou=su,ru=Bt(gs.stderr)});function mu(e){return e.replace(uu,"")}function du(e){return pu.test(e)}function fu(e,i){let t=0;if(e.length>1)for(let a of e.slice(1))a>="\uFF00"&&a<="\uFFEF"&&(t+=Ve(a.codePointAt(0),i));return t}function ke(e,i={}){if(typeof e!="string"||e.length===0)return 0;let{ambiguousIsNarrow:t=!0,countAnsiEscapeCodes:a=!1}=i,n=e;if(a||(n=ie(n)),n.length===0)return 0;let s=0,o={ambiguousAsWide:!t};for(let{segment:r}of cu.segment(n)){if(du(r))continue;if(lu.test(r)){s+=2;continue}let c=mu(r).codePointAt(0);s+=Ve(c,o),s+=fu(r,o)}return s}var cu,pu,uu,lu,bs=j(()=>{Ge();yi();cu=new Intl.Segmenter,pu=new RegExp("^(?:\\p{Default_Ignorable_Code_Point}|\\p{Control}|\\p{Mark}|\\p{Surrogate})+$","v"),uu=new RegExp("^[\\p{Default_Ignorable_Code_Point}\\p{Control}\\p{Format}\\p{Mark}\\p{Surrogate}]+","v"),lu=new RegExp("^\\p{RGI_Emoji}$","v")});var ws={};ii(ws,{default:()=>Fs});function Ti(e,i,t){if(e.charAt(i)===" ")return i;let a=t?1:-1;for(let n=0;n<=3;n++){let s=i+n*a;if(e.charAt(s)===" ")return s}return i}function Fs(e,i,t={}){let{position:a="end",space:n=!1,preferTruncationOnSpace:s=!1}=t,{truncationCharacter:o="\u2026"}=t;if(typeof e!="string")throw new TypeError(`Expected \`input\` to be a string, got ${typeof e}`);if(typeof i!="number")throw new TypeError(`Expected \`columns\` to be a number, got ${typeof i}`);if(i<1)return"";let r=ke(e);if(r<=i)return e;if(i===1)return o;let c={ESC:27,LEFT_BRACKET:91,LETTER_M:109},p=f=>f>=48&&f<=57||f===59;function u(f){let x=0;for(;x+2<f.length&&f.codePointAt(x)===c.ESC&&f.codePointAt(x+1)===c.LEFT_BRACKET;){let h=x+2;for(;h<f.length&&p(f.codePointAt(h));)h++;if(h<f.length&&f.codePointAt(h)===c.LETTER_M){x=h+1;continue}break}return x}function l(f){let x=f.length;for(;x>1&&f.codePointAt(x-1)===c.LETTER_M;){let h=x-2;for(;h>=0&&p(f.codePointAt(h));)h--;if(h>=1&&f.codePointAt(h-1)===c.ESC&&f.codePointAt(h)===c.LEFT_BRACKET){x=h-1;continue}break}return x}function m(f,x){let h=l(f);return h===f.length?f+x:f.slice(0,h)+x+f.slice(h)}function d(f,x){let h=u(x);return h===0?f+x:x.slice(0,h)+f+x.slice(h)}if(a==="start"){if(s){let x=Ti(e,r-i+1,!0),h=Z(e,x,r).trim();return d(o,h)}n&&(o+=" ");let f=Z(e,r-i+ke(o),r);return d(o,f)}if(a==="middle"){n&&(o=` ${o} `);let f=Math.floor(i/2);if(s){let x=Ti(e,f),h=Ti(e,r-(i-f)+1,!0);return Z(e,0,x)+o+Z(e,h,r).trim()}return Z(e,0,f)+o+Z(e,r-(i-f)+ke(o),r)}if(a==="end"){if(s){let x=Ti(e,i-1),h=Z(e,0,x);return m(h,o)}n&&(o=` ${o}`);let f=Z(e,0,i-ke(o));return m(f,o)}throw new Error(`Expected \`options.position\` to be either \`start\`, \`middle\` or \`end\`, got ${a}`)}var Es=j(()=>{Tt();bs()});import{nonNullish as Mt}from"@dfinity/utils";import{rm as io}from"node:fs/promises";var ml=async({infile:e,outfile:i,banner:t})=>{let{outputFiles:a,...n}=await Nt({infile:e,outfile:i,platform:"browser",treeShaking:!0,define:{self:"globalThis"},banner:t});return n},dl=async({infile:e})=>await Nt({infile:e,platform:"node",treeShaking:!1,banner:{js:`import { createRequire as topLevelCreateRequire } from 'node:module';
20
20
  import { resolve } from 'node:path';
21
- const require = topLevelCreateRequire(resolve(process.cwd(), '.juno-pseudo-require-anchor.mjs'));`}}),Nt=async({infile:e,outfile:i,banner:t,platform:a,define:n,treeShaking:s})=>{let{build:o,version:r}=await to();Mt(i)&&await io(i,{force:!0});let{metafile:c,errors:p,warnings:u,outputFiles:l}=await o({entryPoints:[e],outfile:i,write:Mt(i),bundle:!0,minify:!0,treeShaking:s,format:"esm",platform:a,supported:{"top-level-await":!1,"inline-script":!1},define:n,metafile:!0,banner:t});return{metafile:c,errors:p,warnings:u,outputFiles:l,version:r}},to=()=>{try{return import("esbuild")}catch{console.error("Esbuild is required to build your functions. Please install it by running: npm i esbuild"),process.exit(1)}};import{nonNullish as el,toNullable as il}from"@dfinity/utils";import tl from"ora";var Wt="build",qt=[],$t=[],ae={pattern:"**/*.+(css|js|mjs|html)",mode:"both",algorithm:"gzip"},Ht=[".ds_store","thumbs.db"],Be=50,_i="#dapp",Gt="#_juno/releases";import{nonNullish as ti}from"@dfinity/utils";import{spawn as Zt}from"child_process";import{nonNullish as ao}from"@dfinity/utils";import{stat as no}from"node:fs/promises";import Kt from"node:path";import Yt from"node:process";import{URL as so}from"node:url";var Li=async(e,i,t)=>await oo(e,t)?[Ui(e),i.map(a=>uo(a)),{...t,shell:!0}]:[e,i,t],oo=async(e,{shell:i,cwd:t,env:a=Yt.env})=>Yt.platform==="win32"&&!i&&!await ro(e,t,a),ro=async(e,i,{Path:t="",PATH:a=t})=>Vt.some(n=>e.toLowerCase().endsWith(n))||(co[`${e}\0${i}\0${a}`]??=await po(e,i,a)),co={},po=async(e,i,t)=>{let a=t.split(Kt.delimiter).filter(Boolean).map(n=>n.replace(/^"(.*)"$/,"$1"));try{await Promise.all(Vt.flatMap(n=>[i,...a].filter(ao).map(s=>`${Kt.resolve(s instanceof so?s.toString():s,e)}${n}`)).map(async n=>{try{await no(n)}catch{return}throw 0}))}catch{return!0}return!1},Vt=[".exe",".com"],uo=e=>Ui(Ui(`"${e.replaceAll(/(\\*)"/g,'$1$1\\"').replace(/(\\*)$/,"$1$1")}"`)),Ui=e=>e.replaceAll(/([()\][%!^"`<>&|;, *?])/g,"^$1");var Cl=async({command:e,cwd:i,args:t,env:a,stdout:n,silentOut:s=!1,silentErrors:o=!1})=>await new Promise(async(r,c)=>{let[p,u,l]=await Li(e,t??[],{...ti(i)&&{cwd:i},...ti(a)&&{env:a}}),m=Zt(p,u,l);m.stdout.on("data",d=>{if(ti(n)){n(`${d}`);return}s||console.log(`${d}`)}),m.stderr.on("data",d=>{o||c(new Error(`${d}`))}),m.on("close",d=>{r(d)}),m.on("error",d=>{c(d)})}),Jt=async({command:e,args:i,env:t})=>await new Promise(async a=>{let[n,s,o]=await Li(e,i??[],{stdio:"inherit",...ti(t)&&{env:t}});Zt(n,s??[],o).on("close",c=>{if(c===0){a(c);return}process.exit(1)})});var zi=async e=>{for(let i of e??[]){let[t,...a]=i.split(" ");await Jt({command:t,args:a})}};import{isNullish as Dc,nonNullish as vc}from"@dfinity/utils";import bc from"crypto";import{ReadableStream as Zo}from"node:stream/web";import{pipeline as Pa,PassThrough as Jo,Readable as Xo}from"node:stream";import{stat as ho}from"node:fs/promises";var lo="End-Of-Stream",k=class extends Error{constructor(){super(lo),this.name="EndOfStreamError"}},ne=class extends Error{constructor(i="The operation was aborted"){super(i),this.name="AbortError"}};var ai=class{constructor(){this.resolve=()=>null,this.reject=()=>null,this.promise=new Promise((i,t)=>{this.reject=t,this.resolve=i})}};var se=class{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(i,t=!1){let a=await this.read(i,t);return this.peekQueue.push(i.subarray(0,a)),a}async read(i,t=!1){if(i.length===0)return 0;let a=this.readFromPeekBuffer(i);if(this.endOfStream||(a+=await this.readRemainderFromStream(i.subarray(a),t)),a===0&&!t)throw new k;return a}readFromPeekBuffer(i){let t=i.length,a=0;for(;this.peekQueue.length>0&&t>0;){let n=this.peekQueue.pop();if(!n)throw new Error("peekData should be defined");let s=Math.min(n.length,t);i.set(n.subarray(0,s),a),a+=s,t-=s,s<n.length&&this.peekQueue.push(n.subarray(s))}return a}async readRemainderFromStream(i,t){let a=0;for(;a<i.length&&!this.endOfStream;){if(this.interrupted)throw new ne;let n=await this.readFromStream(i.subarray(a),t);if(n===0)break;a+=n}if(!t&&a<i.length)throw new k;return a}};var Oe=class extends se{constructor(i){if(super(),this.s=i,this.deferred=null,!i.read||!i.once)throw new Error("Expected an instance of stream.Readable");this.s.once("end",()=>{this.endOfStream=!0,this.deferred&&this.deferred.resolve(0)}),this.s.once("error",t=>this.reject(t)),this.s.once("close",()=>this.abort())}async readFromStream(i,t){if(i.length===0)return 0;let a=this.s.read(i.length);if(a)return i.set(a),a.length;let n={buffer:i,mayBeLess:t,deferred:new ai};return this.deferred=n.deferred,this.s.once("readable",()=>{this.readDeferred(n)}),n.deferred.promise}readDeferred(i){let t=this.s.read(i.buffer.length);t?(i.buffer.set(t),i.deferred.resolve(t.length),this.deferred=null):this.s.once("readable",()=>{this.readDeferred(i)})}reject(i){this.interrupted=!0,this.deferred&&(this.deferred.reject(i),this.deferred=null)}async abort(){this.reject(new ne)}async close(){return this.abort()}};var ni=class extends se{constructor(i){super(),this.reader=i}async abort(){return this.close()}async close(){this.reader.releaseLock()}};var Pe=class extends ni{async readFromStream(i,t){if(i.length===0)return 0;let a=await this.reader.read(new Uint8Array(i.length),{min:t?void 0:i.length});return a.done&&(this.endOfStream=a.done),a.value?(i.set(a.value),a.value.length):0}};var he=class extends se{constructor(i){super(),this.reader=i,this.buffer=null}writeChunk(i,t){let a=Math.min(t.length,i.length);return i.set(t.subarray(0,a)),a<t.length?this.buffer=t.subarray(a):this.buffer=null,a}async readFromStream(i,t){if(i.length===0)return 0;let a=0;for(this.buffer&&(a+=this.writeChunk(i,this.buffer));a<i.length&&!this.endOfStream;){let n=await this.reader.read();if(n.done){this.endOfStream=!0;break}n.value&&(a+=this.writeChunk(i.subarray(a),n.value))}if(!t&&a===0&&this.endOfStream)throw new k;return a}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}};function Mi(e){try{let i=e.getReader({mode:"byob"});return i instanceof ReadableStreamDefaultReader?new he(i):new Pe(i)}catch(i){if(i instanceof TypeError)return new he(e.getReader());throw i}}var J=class{constructor(i){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=i?.onClose,i?.abortSignal&&i.abortSignal.addEventListener("abort",()=>{this.abort()})}async readToken(i,t=this.position){let a=new Uint8Array(i.len);if(await this.readBuffer(a,{position:t})<i.len)throw new k;return i.get(a,0)}async peekToken(i,t=this.position){let a=new Uint8Array(i.len);if(await this.peekBuffer(a,{position:t})<i.len)throw new k;return i.get(a,0)}async readNumber(i){if(await this.readBuffer(this.numBuffer,{length:i.len})<i.len)throw new k;return i.get(this.numBuffer,0)}async peekNumber(i){if(await this.peekBuffer(this.numBuffer,{length:i.len})<i.len)throw new k;return i.get(this.numBuffer,0)}async ignore(i){if(this.fileInfo.size!==void 0){let t=this.fileInfo.size-this.position;if(i>t)return this.position+=t,t}return this.position+=i,i}async close(){await this.abort(),await this.onClose?.()}normalizeOptions(i,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:i.length,position:this.position,...t}}abort(){return Promise.resolve()}};var mo=256e3,je=class extends J{constructor(i,t){super(t),this.streamReader=i,this.fileInfo=t?.fileInfo??{}}async readBuffer(i,t){let a=this.normalizeOptions(i,t),n=a.position-this.position;if(n>0)return await this.ignore(n),this.readBuffer(i,t);if(n<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(a.length===0)return 0;let s=await this.streamReader.read(i.subarray(0,a.length),a.mayBeLess);if(this.position+=s,(!t||!t.mayBeLess)&&s<a.length)throw new k;return s}async peekBuffer(i,t){let a=this.normalizeOptions(i,t),n=0;if(a.position){let s=a.position-this.position;if(s>0){let o=new Uint8Array(a.length+s);return n=await this.peekBuffer(o,{mayBeLess:a.mayBeLess}),i.set(o.subarray(s)),n-s}if(s<0)throw new Error("Cannot peek from a negative offset in a stream")}if(a.length>0){try{n=await this.streamReader.peek(i.subarray(0,a.length),a.mayBeLess)}catch(s){if(t?.mayBeLess&&s instanceof k)return 0;throw s}if(!a.mayBeLess&&n<a.length)throw new k}return n}async ignore(i){let t=Math.min(mo,i),a=new Uint8Array(t),n=0;for(;n<i;){let s=i-n,o=await this.readBuffer(a,{length:Math.min(t,s)});if(o<0)return o;n+=o}return n}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}};var si=class extends J{constructor(i,t){super(t),this.uint8Array=i,this.fileInfo={...t?.fileInfo??{},size:i.length}}async readBuffer(i,t){t?.position&&(this.position=t.position);let a=await this.peekBuffer(i,t);return this.position+=a,a}async peekBuffer(i,t){let a=this.normalizeOptions(i,t),n=Math.min(this.uint8Array.length-a.position,a.length);if(!a.mayBeLess&&n<a.length)throw new k;return i.set(this.uint8Array.subarray(a.position,a.position+n)),n}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(i){this.position=i}};var oi=class extends J{constructor(i,t){super(t),this.blob=i,this.fileInfo={...t?.fileInfo??{},size:i.size,mimeType:i.type}}async readBuffer(i,t){t?.position&&(this.position=t.position);let a=await this.peekBuffer(i,t);return this.position+=a,a}async peekBuffer(i,t){let a=this.normalizeOptions(i,t),n=Math.min(this.blob.size-a.position,a.length);if(!a.mayBeLess&&n<a.length)throw new k;let s=await this.blob.slice(a.position,a.position+n).arrayBuffer();return i.set(new Uint8Array(s)),n}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(i){this.position=i}};function Xt(e,i){let t=new Oe(e),a=i??{},n=a.onClose;return a.onClose=async()=>{if(await t.close(),n)return n()},new je(t,a)}function ri(e,i){let t=Mi(e),a=i??{},n=a.onClose;return a.onClose=async()=>{if(await t.close(),n)return n()},new je(t,a)}function Qt(e,i){return new si(e,i)}function ea(e,i){return new oi(e,i)}import{open as xo}from"node:fs/promises";var Re=class e extends J{static async fromFile(i){let t=await xo(i,"r"),a=await t.stat();return new e(t,{fileInfo:{path:i,size:a.size}})}constructor(i,t){super(t),this.fileHandle=i,this.fileInfo=t.fileInfo}async readBuffer(i,t){let a=this.normalizeOptions(i,t);if(this.position=a.position,a.length===0)return 0;let n=await this.fileHandle.read(i,0,a.length,a.position);if(this.position+=n.bytesRead,n.bytesRead<a.length&&(!t||!t.mayBeLess))throw new k;return n.bytesRead}async peekBuffer(i,t){let a=this.normalizeOptions(i,t),n=await this.fileHandle.read(i,0,a.length,a.position);if(!a.mayBeLess&&n.bytesRead<a.length)throw new k;return n.bytesRead}async close(){return await this.fileHandle.close(),super.close()}setPosition(i){this.position=i}supportsRandomAccess(){return!0}};async function ia(e,i){let t=Xt(e,i);if(e.path){let a=await ho(e.path);t.fileInfo.path=e.path,t.fileInfo.size=a.size}return t}var ta=Re.fromFile;var sa=xe(aa(),1);var Wi={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"},Do={};for(let[e,i]of Object.entries(Wi))Do[i]=Number.parseInt(e);function na(e,i="utf-8"){switch(i.toLowerCase()){case"utf-8":case"utf8":return typeof globalThis.TextDecoder<"u"?new globalThis.TextDecoder("utf-8").decode(e):vo(e);case"utf-16le":return bo(e);case"ascii":return Fo(e);case"latin1":case"iso-8859-1":return wo(e);case"windows-1252":return Eo(e);default:throw new RangeError(`Encoding '${i}' not supported`)}}function vo(e){let i="",t=0;for(;t<e.length;){let a=e[t++];if(a<128)i+=String.fromCharCode(a);else if(a<224){let n=e[t++]&63;i+=String.fromCharCode((a&31)<<6|n)}else if(a<240){let n=e[t++]&63,s=e[t++]&63;i+=String.fromCharCode((a&15)<<12|n<<6|s)}else{let n=e[t++]&63,s=e[t++]&63,o=e[t++]&63,r=(a&7)<<18|n<<12|s<<6|o;r-=65536,i+=String.fromCharCode(55296+(r>>10&1023),56320+(r&1023))}}return i}function bo(e){let i="";for(let t=0;t<e.length;t+=2)i+=String.fromCharCode(e[t]|e[t+1]<<8);return i}function Fo(e){return String.fromCharCode(...e.map(i=>i&127))}function wo(e){return String.fromCharCode(...e)}function Eo(e){let i="";for(let t of e)t>=128&&t<=159&&Wi[t]?i+=Wi[t]:i+=String.fromCharCode(t);return i}function $(e){return new DataView(e.buffer,e.byteOffset)}var oa={len:1,get(e,i){return $(e).getUint8(i)},put(e,i,t){return $(e).setUint8(i,t),i+1}},P={len:2,get(e,i){return $(e).getUint16(i,!0)},put(e,i,t){return $(e).setUint16(i,t,!0),i+2}},ge={len:2,get(e,i){return $(e).getUint16(i)},put(e,i,t){return $(e).setUint16(i,t),i+2}};var R={len:4,get(e,i){return $(e).getUint32(i,!0)},put(e,i,t){return $(e).setUint32(i,t,!0),i+4}},ra={len:4,get(e,i){return $(e).getUint32(i)},put(e,i,t){return $(e).setUint32(i,t),i+4}};var ca={len:4,get(e,i){return $(e).getInt32(i)},put(e,i,t){return $(e).setInt32(i,t),i+4}};var pa={len:8,get(e,i){return $(e).getBigUint64(i,!0)},put(e,i,t){return $(e).setBigUint64(i,t,!0),i+8}};var H=class{constructor(i,t){this.len=i,this.encoding=t}get(i,t=0){let a=i.subarray(t,t+this.len);return na(a,this.encoding)}};var Ca=xe(Fa(),1);var le={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},Ki={get(e){return{signature:R.get(e,0),compressedSize:R.get(e,8),uncompressedSize:R.get(e,12)}},len:16},wa={get(e){let i=P.get(e,6);return{signature:R.get(e,0),minVersion:P.get(e,4),dataDescriptor:!!(i&8),compressedMethod:P.get(e,8),compressedSize:R.get(e,18),uncompressedSize:R.get(e,22),filenameLength:P.get(e,26),extraFieldLength:P.get(e,28),filename:null}},len:30},Ea={get(e){return{signature:R.get(e,0),nrOfThisDisk:P.get(e,4),nrOfThisDiskWithTheStart:P.get(e,6),nrOfEntriesOnThisDisk:P.get(e,8),nrOfEntriesOfSize:P.get(e,10),sizeOfCd:R.get(e,12),offsetOfStartOfCd:R.get(e,16),zipFileCommentLength:P.get(e,20)}},len:22},ya={get(e){let i=P.get(e,8);return{signature:R.get(e,0),minVersion:P.get(e,6),dataDescriptor:!!(i&8),compressedMethod:P.get(e,10),compressedSize:R.get(e,20),uncompressedSize:R.get(e,24),filenameLength:P.get(e,28),extraFieldLength:P.get(e,30),fileCommentLength:P.get(e,32),relativeOffsetOfLocalHeader:R.get(e,42),filename:null}},len:46};function ka(e){let i=new Uint8Array(R.len);return R.put(i,0,e),i}var X=(0,Ca.default)("tokenizer:inflate"),Yi=256*1024,Ko=ka(le.DataDescriptor),mi=ka(le.EndOfCentralDirectory),Ie=class e{constructor(i){this.tokenizer=i,this.syncBuffer=new Uint8Array(Yi)}async isZip(){return await this.peekSignature()===le.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(R)}async findEndOfCentralDirectoryLocator(){let i=this.tokenizer,t=Math.min(16*1024,i.fileInfo.size),a=this.syncBuffer.subarray(0,t);await this.tokenizer.readBuffer(a,{position:i.fileInfo.size-t});for(let n=a.length-4;n>=0;n--)if(a[n]===mi[0]&&a[n+1]===mi[1]&&a[n+2]===mi[2]&&a[n+3]===mi[3])return i.fileInfo.size-t+n;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){X("Cannot reading central-directory without random-read support");return}X("Reading central-directory...");let i=this.tokenizer.position,t=await this.findEndOfCentralDirectoryLocator();if(t>0){X("Central-directory 32-bit signature found");let a=await this.tokenizer.readToken(Ea,t),n=[];this.tokenizer.setPosition(a.offsetOfStartOfCd);for(let s=0;s<a.nrOfEntriesOfSize;++s){let o=await this.tokenizer.readToken(ya);if(o.signature!==le.CentralFileHeader)throw new Error("Expected Central-File-Header signature");o.filename=await this.tokenizer.readToken(new H(o.filenameLength,"utf-8")),await this.tokenizer.ignore(o.extraFieldLength),await this.tokenizer.ignore(o.fileCommentLength),n.push(o),X(`Add central-directory file-entry: n=${s+1}/${n.length}: filename=${n[s].filename}`)}return this.tokenizer.setPosition(i),n}this.tokenizer.setPosition(i)}async unzip(i){let t=await this.readCentralDirectory();if(t)return this.iterateOverCentralDirectory(t,i);let a=!1;do{let n=await this.readLocalFileHeader();if(!n)break;let s=i(n);a=!!s.stop;let o;if(await this.tokenizer.ignore(n.extraFieldLength),n.dataDescriptor&&n.compressedSize===0){let r=[],c=Yi;X("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let p=-1;for(;p<0&&c===Yi;){c=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),p=Yo(this.syncBuffer.subarray(0,c),Ko);let u=p>=0?p:c;if(s.handler){let l=new Uint8Array(u);await this.tokenizer.readBuffer(l),r.push(l)}else await this.tokenizer.ignore(u)}X(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),s.handler&&await this.inflate(n,Vo(r),s.handler)}else s.handler?(X(`Reading compressed-file-data: ${n.compressedSize} bytes`),o=new Uint8Array(n.compressedSize),await this.tokenizer.readBuffer(o),await this.inflate(n,o,s.handler)):(X(`Ignoring compressed-file-data: ${n.compressedSize} bytes`),await this.tokenizer.ignore(n.compressedSize));if(X(`Reading data-descriptor at pos=${this.tokenizer.position}`),n.dataDescriptor&&(await this.tokenizer.readToken(Ki)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-Ki.len}`)}while(!a)}async iterateOverCentralDirectory(i,t){for(let a of i){let n=t(a);if(n.handler){this.tokenizer.setPosition(a.relativeOffsetOfLocalHeader);let s=await this.readLocalFileHeader();if(s){await this.tokenizer.ignore(s.extraFieldLength);let o=new Uint8Array(a.compressedSize);await this.tokenizer.readBuffer(o),await this.inflate(s,o,n.handler)}}if(n.stop)break}}async inflate(i,t,a){if(i.compressedMethod===0)return a(t);if(i.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${i.compressedMethod}`);X(`Decompress filename=${i.filename}, compressed-size=${t.length}`);let n=await e.decompressDeflateRaw(t);return a(n)}static async decompressDeflateRaw(i){let t=new ReadableStream({start(s){s.enqueue(i),s.close()}}),a=new DecompressionStream("deflate-raw"),n=t.pipeThrough(a);try{let o=await new Response(n).arrayBuffer();return new Uint8Array(o)}catch(s){let o=s instanceof Error?`Failed to deflate ZIP entry: ${s.message}`:"Unknown decompression error in ZIP entry";throw new TypeError(o)}}async readLocalFileHeader(){let i=await this.tokenizer.peekToken(R);if(i===le.LocalFileHeader){let t=await this.tokenizer.readToken(wa);return t.filename=await this.tokenizer.readToken(new H(t.filenameLength,"utf-8")),t}if(i===le.CentralFileHeader)return!1;throw i===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}};function Yo(e,i){let t=e.length,a=i.length;if(a>t)return-1;for(let n=0;n<=t-a;n++){let s=!0;for(let o=0;o<a;o++)if(e[n+o]!==i[o]){s=!1;break}if(s)return n}return-1}function Vo(e){let i=e.reduce((n,s)=>n+s.length,0),t=new Uint8Array(i),a=0;for(let n of e)t.set(n,a),a+=n.length;return t}var _e=class{constructor(i){this.tokenizer=i}inflate(){let i=this.tokenizer;return new ReadableStream({async pull(t){let a=new Uint8Array(1024),n=await i.readBuffer(a,{mayBeLess:!0});if(n===0){t.close();return}t.enqueue(a.subarray(0,n))}}).pipeThrough(new DecompressionStream("gzip"))}};var Wm={utf8:new globalThis.TextDecoder("utf8")};var qm=new globalThis.TextEncoder;var $m=Array.from({length:256},(e,i)=>i.toString(16).padStart(2,"0"));function Vi(e){let{byteLength:i}=e;if(i===6)return e.getUint16(0)*2**32+e.getUint32(2);if(i===5)return e.getUint8(0)*2**32+e.getUint32(1);if(i===4)return e.getUint32(0);if(i===3)return e.getUint8(0)*2**16+e.getUint16(1);if(i===2)return e.getUint16(0);if(i===1)return e.getUint8(0)}function Aa(e,i){if(i==="utf-16le"){let t=[];for(let a=0;a<e.length;a++){let n=e.charCodeAt(a);t.push(n&255,n>>8&255)}return t}if(i==="utf-16be"){let t=[];for(let a=0;a<e.length;a++){let n=e.charCodeAt(a);t.push(n>>8&255,n&255)}return t}return[...e].map(t=>t.charCodeAt(0))}function Ta(e,i=0){let t=Number.parseInt(new H(6).get(e,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(t))return!1;let a=256;for(let n=i;n<i+148;n++)a+=e[n];for(let n=i+156;n<i+512;n++)a+=e[n];return t===a}var Sa={get:(e,i)=>e[i+3]&127|e[i+2]<<7|e[i+1]<<14|e[i]<<21,len:4};var Ba=["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","rm","ppsm","ppsx","tar.gz","reg","dat"],Oa=["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-ms-regedit","application/x-ft-windows-registry-hive"];var Ue=4100;function Zi(e){switch(e=e.toLowerCase(),e){case"application/epub+zip":return{ext:"epub",mime:e};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:e};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:e};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:e};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:e};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:e};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:e};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:e};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:e};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:e};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:e};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:e};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:e};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:e};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:e};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:e};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 Q(e,i,t){t={offset:0,...t};for(let[a,n]of i.entries())if(t.mask){if(n!==(t.mask[a]&e[a+t.offset]))return!1}else if(n!==e[a+t.offset])return!1;return!0}var di=class{constructor(i){this.options={mpegOffsetTolerance:0,...i},this.detectors=[...i?.customDetectors??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:i?.signal}}async fromTokenizer(i){let t=i.position;for(let a of this.detectors){let n=await a.detect(i);if(n)return n;if(t!==i.position)return}}async fromBuffer(i){if(!(i instanceof Uint8Array||i instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof i}\``);let t=i instanceof Uint8Array?i:new Uint8Array(i);if(t?.length>1)return this.fromTokenizer(Qt(t,this.tokenizerOptions))}async fromBlob(i){let t=ea(i,this.tokenizerOptions);try{return await this.fromTokenizer(t)}finally{await t.close()}}async fromStream(i){let t=ri(i,this.tokenizerOptions);try{return await this.fromTokenizer(t)}finally{await t.close()}}async toDetectionStream(i,t){let{sampleSize:a=Ue}=t,n,s,o=i.getReader({mode:"byob"});try{let{value:p,done:u}=await o.read(new Uint8Array(a));if(s=p,!u&&p)try{n=await this.fromBuffer(p.subarray(0,a))}catch(l){if(!(l instanceof k))throw l;n=void 0}s=p}finally{o.releaseLock()}let r=new TransformStream({async start(p){p.enqueue(s)},transform(p,u){u.enqueue(p)}}),c=i.pipeThrough(r);return c.fileType=n,c}check(i,t){return Q(this.buffer,i,t)}checkString(i,t){return this.check(Aa(i,t?.encoding),t)}detectConfident=async i=>{if(this.buffer=new Uint8Array(Ue),i.fileInfo.size===void 0&&(i.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=i,await i.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 i.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.tokenizer.ignore(3),this.detectConfident(i);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])){let a=new _e(i).inflate(),n=!0;try{let s;try{s=await this.fromStream(a)}catch{n=!1}if(s&&s.ext==="tar")return{ext:"tar.gz",mime:"application/gzip"}}finally{n&&await a.cancel()}return{ext:"gz",mime:"application/gzip"}}if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await i.ignore(6);let t=await i.readToken(Sa);return i.position+t>i.fileInfo.size?{ext:"mp3",mime:"audio/mpeg"}:(await i.ignore(t),this.fromTokenizer(i))}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;return await new Ie(i).unzip(a=>{switch(a.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{async handler(n){let s=new TextDecoder("utf-8").decode(n).trim();t=Zi(s)},stop:!0};case"[Content_Types].xml":return{async handler(n){let s=new TextDecoder("utf-8").decode(n),o=s.indexOf('.main+xml"');if(o===-1){let r="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";s.includes(`ContentType="${r}"`)&&(t=Zi(r))}else{s=s.slice(0,Math.max(0,o));let r=s.lastIndexOf('"'),c=s.slice(Math.max(0,r+1));t=Zi(c)}},stop:!0};default:return/classes\d*\.dex/.test(a.filename)?(t={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}}).catch(a=>{if(!(a instanceof k))throw a}),t??{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await i.ignore(28);let t=new Uint8Array(8);return await i.readBuffer(t),Q(t,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:Q(t,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:Q(t,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:Q(t,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:Q(t,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:Q(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 r=await i.peekNumber(oa),c=128,p=0;for(;(r&c)===0&&c!==0;)++p,c>>=1;let u=new Uint8Array(p+1);return await i.readBuffer(u),u}async function a(){let r=await t(),c=await t();c[0]^=128>>c.length-1;let p=Math.min(6,c.length),u=new DataView(r.buffer),l=new DataView(c.buffer,c.length-p,p);return{id:Vi(u),len:Vi(l)}}async function n(r){for(;r>0;){let c=await a();if(c.id===17026)return(await i.readToken(new H(c.len))).replaceAll(/\00.*$/g,"");await i.ignore(c.len),--r}}let s=await a();switch(await n(s.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([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.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]))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 H(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 i.ignore(8),await i.readToken(new H(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("WEBVTT")&&[`
21
+ const require = topLevelCreateRequire(resolve(process.cwd(), '.juno-pseudo-require-anchor.mjs'));`},define:{"import.meta.url":JSON.stringify("file:///virtual/juno-pseudo-module.js")}}),Nt=async({infile:e,outfile:i,banner:t,platform:a,define:n,treeShaking:s})=>{let{build:o,version:r}=await to();Mt(i)&&await io(i,{force:!0});let{metafile:c,errors:p,warnings:u,outputFiles:l}=await o({entryPoints:[e],outfile:i,write:Mt(i),bundle:!0,minify:!0,treeShaking:s,format:"esm",platform:a,supported:{"top-level-await":!1,"inline-script":!1},external:["esbuild"],define:n,metafile:!0,banner:t});return{metafile:c,errors:p,warnings:u,outputFiles:l,version:r}},to=()=>{try{return import("esbuild")}catch{console.error("Esbuild is required to build your functions. Please install it by running: npm i esbuild"),process.exit(1)}};import{nonNullish as el,toNullable as il}from"@dfinity/utils";import tl from"ora";var Wt="build",qt=[],$t=[],ae={pattern:"**/*.+(css|js|mjs|html)",mode:"both",algorithm:"gzip"},Ht=[".ds_store","thumbs.db"],Be=50,_i="#dapp",Gt="#_juno/releases";import{nonNullish as ti}from"@dfinity/utils";import{spawn as Zt}from"child_process";import{nonNullish as ao}from"@dfinity/utils";import{stat as no}from"node:fs/promises";import Kt from"node:path";import Yt from"node:process";import{URL as so}from"node:url";var Li=async(e,i,t)=>await oo(e,t)?[Ui(e),i.map(a=>uo(a)),{...t,shell:!0}]:[e,i,t],oo=async(e,{shell:i,cwd:t,env:a=Yt.env})=>Yt.platform==="win32"&&!i&&!await ro(e,t,a),ro=async(e,i,{Path:t="",PATH:a=t})=>Vt.some(n=>e.toLowerCase().endsWith(n))||(co[`${e}\0${i}\0${a}`]??=await po(e,i,a)),co={},po=async(e,i,t)=>{let a=t.split(Kt.delimiter).filter(Boolean).map(n=>n.replace(/^"(.*)"$/,"$1"));try{await Promise.all(Vt.flatMap(n=>[i,...a].filter(ao).map(s=>`${Kt.resolve(s instanceof so?s.toString():s,e)}${n}`)).map(async n=>{try{await no(n)}catch{return}throw 0}))}catch{return!0}return!1},Vt=[".exe",".com"],uo=e=>Ui(Ui(`"${e.replaceAll(/(\\*)"/g,'$1$1\\"').replace(/(\\*)$/,"$1$1")}"`)),Ui=e=>e.replaceAll(/([()\][%!^"`<>&|;, *?])/g,"^$1");var Cl=async({command:e,cwd:i,args:t,env:a,stdout:n,silentOut:s=!1,silentErrors:o=!1})=>await new Promise(async(r,c)=>{let[p,u,l]=await Li(e,t??[],{...ti(i)&&{cwd:i},...ti(a)&&{env:a}}),m=Zt(p,u,l);m.stdout.on("data",d=>{if(ti(n)){n(`${d}`);return}s||console.log(`${d}`)}),m.stderr.on("data",d=>{o||c(new Error(`${d}`))}),m.on("close",d=>{r(d)}),m.on("error",d=>{c(d)})}),Jt=async({command:e,args:i,env:t})=>await new Promise(async a=>{let[n,s,o]=await Li(e,i??[],{stdio:"inherit",...ti(t)&&{env:t}});Zt(n,s??[],o).on("close",c=>{if(c===0){a(c);return}process.exit(1)})});var zi=async e=>{for(let i of e??[]){let[t,...a]=i.split(" ");await Jt({command:t,args:a})}};import{isNullish as Dc,nonNullish as vc}from"@dfinity/utils";import bc from"crypto";import{ReadableStream as Zo}from"node:stream/web";import{pipeline as Pa,PassThrough as Jo,Readable as Xo}from"node:stream";import{stat as ho}from"node:fs/promises";var lo="End-Of-Stream",k=class extends Error{constructor(){super(lo),this.name="EndOfStreamError"}},ne=class extends Error{constructor(i="The operation was aborted"){super(i),this.name="AbortError"}};var ai=class{constructor(){this.resolve=()=>null,this.reject=()=>null,this.promise=new Promise((i,t)=>{this.reject=t,this.resolve=i})}};var se=class{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(i,t=!1){let a=await this.read(i,t);return this.peekQueue.push(i.subarray(0,a)),a}async read(i,t=!1){if(i.length===0)return 0;let a=this.readFromPeekBuffer(i);if(this.endOfStream||(a+=await this.readRemainderFromStream(i.subarray(a),t)),a===0&&!t)throw new k;return a}readFromPeekBuffer(i){let t=i.length,a=0;for(;this.peekQueue.length>0&&t>0;){let n=this.peekQueue.pop();if(!n)throw new Error("peekData should be defined");let s=Math.min(n.length,t);i.set(n.subarray(0,s),a),a+=s,t-=s,s<n.length&&this.peekQueue.push(n.subarray(s))}return a}async readRemainderFromStream(i,t){let a=0;for(;a<i.length&&!this.endOfStream;){if(this.interrupted)throw new ne;let n=await this.readFromStream(i.subarray(a),t);if(n===0)break;a+=n}if(!t&&a<i.length)throw new k;return a}};var Oe=class extends se{constructor(i){if(super(),this.s=i,this.deferred=null,!i.read||!i.once)throw new Error("Expected an instance of stream.Readable");this.s.once("end",()=>{this.endOfStream=!0,this.deferred&&this.deferred.resolve(0)}),this.s.once("error",t=>this.reject(t)),this.s.once("close",()=>this.abort())}async readFromStream(i,t){if(i.length===0)return 0;let a=this.s.read(i.length);if(a)return i.set(a),a.length;let n={buffer:i,mayBeLess:t,deferred:new ai};return this.deferred=n.deferred,this.s.once("readable",()=>{this.readDeferred(n)}),n.deferred.promise}readDeferred(i){let t=this.s.read(i.buffer.length);t?(i.buffer.set(t),i.deferred.resolve(t.length),this.deferred=null):this.s.once("readable",()=>{this.readDeferred(i)})}reject(i){this.interrupted=!0,this.deferred&&(this.deferred.reject(i),this.deferred=null)}async abort(){this.reject(new ne)}async close(){return this.abort()}};var ni=class extends se{constructor(i){super(),this.reader=i}async abort(){return this.close()}async close(){this.reader.releaseLock()}};var Pe=class extends ni{async readFromStream(i,t){if(i.length===0)return 0;let a=await this.reader.read(new Uint8Array(i.length),{min:t?void 0:i.length});return a.done&&(this.endOfStream=a.done),a.value?(i.set(a.value),a.value.length):0}};var he=class extends se{constructor(i){super(),this.reader=i,this.buffer=null}writeChunk(i,t){let a=Math.min(t.length,i.length);return i.set(t.subarray(0,a)),a<t.length?this.buffer=t.subarray(a):this.buffer=null,a}async readFromStream(i,t){if(i.length===0)return 0;let a=0;for(this.buffer&&(a+=this.writeChunk(i,this.buffer));a<i.length&&!this.endOfStream;){let n=await this.reader.read();if(n.done){this.endOfStream=!0;break}n.value&&(a+=this.writeChunk(i.subarray(a),n.value))}if(!t&&a===0&&this.endOfStream)throw new k;return a}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}};function Mi(e){try{let i=e.getReader({mode:"byob"});return i instanceof ReadableStreamDefaultReader?new he(i):new Pe(i)}catch(i){if(i instanceof TypeError)return new he(e.getReader());throw i}}var J=class{constructor(i){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=i?.onClose,i?.abortSignal&&i.abortSignal.addEventListener("abort",()=>{this.abort()})}async readToken(i,t=this.position){let a=new Uint8Array(i.len);if(await this.readBuffer(a,{position:t})<i.len)throw new k;return i.get(a,0)}async peekToken(i,t=this.position){let a=new Uint8Array(i.len);if(await this.peekBuffer(a,{position:t})<i.len)throw new k;return i.get(a,0)}async readNumber(i){if(await this.readBuffer(this.numBuffer,{length:i.len})<i.len)throw new k;return i.get(this.numBuffer,0)}async peekNumber(i){if(await this.peekBuffer(this.numBuffer,{length:i.len})<i.len)throw new k;return i.get(this.numBuffer,0)}async ignore(i){if(this.fileInfo.size!==void 0){let t=this.fileInfo.size-this.position;if(i>t)return this.position+=t,t}return this.position+=i,i}async close(){await this.abort(),await this.onClose?.()}normalizeOptions(i,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:i.length,position:this.position,...t}}abort(){return Promise.resolve()}};var mo=256e3,je=class extends J{constructor(i,t){super(t),this.streamReader=i,this.fileInfo=t?.fileInfo??{}}async readBuffer(i,t){let a=this.normalizeOptions(i,t),n=a.position-this.position;if(n>0)return await this.ignore(n),this.readBuffer(i,t);if(n<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(a.length===0)return 0;let s=await this.streamReader.read(i.subarray(0,a.length),a.mayBeLess);if(this.position+=s,(!t||!t.mayBeLess)&&s<a.length)throw new k;return s}async peekBuffer(i,t){let a=this.normalizeOptions(i,t),n=0;if(a.position){let s=a.position-this.position;if(s>0){let o=new Uint8Array(a.length+s);return n=await this.peekBuffer(o,{mayBeLess:a.mayBeLess}),i.set(o.subarray(s)),n-s}if(s<0)throw new Error("Cannot peek from a negative offset in a stream")}if(a.length>0){try{n=await this.streamReader.peek(i.subarray(0,a.length),a.mayBeLess)}catch(s){if(t?.mayBeLess&&s instanceof k)return 0;throw s}if(!a.mayBeLess&&n<a.length)throw new k}return n}async ignore(i){let t=Math.min(mo,i),a=new Uint8Array(t),n=0;for(;n<i;){let s=i-n,o=await this.readBuffer(a,{length:Math.min(t,s)});if(o<0)return o;n+=o}return n}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}};var si=class extends J{constructor(i,t){super(t),this.uint8Array=i,this.fileInfo={...t?.fileInfo??{},size:i.length}}async readBuffer(i,t){t?.position&&(this.position=t.position);let a=await this.peekBuffer(i,t);return this.position+=a,a}async peekBuffer(i,t){let a=this.normalizeOptions(i,t),n=Math.min(this.uint8Array.length-a.position,a.length);if(!a.mayBeLess&&n<a.length)throw new k;return i.set(this.uint8Array.subarray(a.position,a.position+n)),n}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(i){this.position=i}};var oi=class extends J{constructor(i,t){super(t),this.blob=i,this.fileInfo={...t?.fileInfo??{},size:i.size,mimeType:i.type}}async readBuffer(i,t){t?.position&&(this.position=t.position);let a=await this.peekBuffer(i,t);return this.position+=a,a}async peekBuffer(i,t){let a=this.normalizeOptions(i,t),n=Math.min(this.blob.size-a.position,a.length);if(!a.mayBeLess&&n<a.length)throw new k;let s=await this.blob.slice(a.position,a.position+n).arrayBuffer();return i.set(new Uint8Array(s)),n}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(i){this.position=i}};function Xt(e,i){let t=new Oe(e),a=i??{},n=a.onClose;return a.onClose=async()=>{if(await t.close(),n)return n()},new je(t,a)}function ri(e,i){let t=Mi(e),a=i??{},n=a.onClose;return a.onClose=async()=>{if(await t.close(),n)return n()},new je(t,a)}function Qt(e,i){return new si(e,i)}function ea(e,i){return new oi(e,i)}import{open as xo}from"node:fs/promises";var Re=class e extends J{static async fromFile(i){let t=await xo(i,"r"),a=await t.stat();return new e(t,{fileInfo:{path:i,size:a.size}})}constructor(i,t){super(t),this.fileHandle=i,this.fileInfo=t.fileInfo}async readBuffer(i,t){let a=this.normalizeOptions(i,t);if(this.position=a.position,a.length===0)return 0;let n=await this.fileHandle.read(i,0,a.length,a.position);if(this.position+=n.bytesRead,n.bytesRead<a.length&&(!t||!t.mayBeLess))throw new k;return n.bytesRead}async peekBuffer(i,t){let a=this.normalizeOptions(i,t),n=await this.fileHandle.read(i,0,a.length,a.position);if(!a.mayBeLess&&n.bytesRead<a.length)throw new k;return n.bytesRead}async close(){return await this.fileHandle.close(),super.close()}setPosition(i){this.position=i}supportsRandomAccess(){return!0}};async function ia(e,i){let t=Xt(e,i);if(e.path){let a=await ho(e.path);t.fileInfo.path=e.path,t.fileInfo.size=a.size}return t}var ta=Re.fromFile;var sa=xe(aa(),1);var Wi={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"},Do={};for(let[e,i]of Object.entries(Wi))Do[i]=Number.parseInt(e);function na(e,i="utf-8"){switch(i.toLowerCase()){case"utf-8":case"utf8":return typeof globalThis.TextDecoder<"u"?new globalThis.TextDecoder("utf-8").decode(e):vo(e);case"utf-16le":return bo(e);case"ascii":return Fo(e);case"latin1":case"iso-8859-1":return wo(e);case"windows-1252":return Eo(e);default:throw new RangeError(`Encoding '${i}' not supported`)}}function vo(e){let i="",t=0;for(;t<e.length;){let a=e[t++];if(a<128)i+=String.fromCharCode(a);else if(a<224){let n=e[t++]&63;i+=String.fromCharCode((a&31)<<6|n)}else if(a<240){let n=e[t++]&63,s=e[t++]&63;i+=String.fromCharCode((a&15)<<12|n<<6|s)}else{let n=e[t++]&63,s=e[t++]&63,o=e[t++]&63,r=(a&7)<<18|n<<12|s<<6|o;r-=65536,i+=String.fromCharCode(55296+(r>>10&1023),56320+(r&1023))}}return i}function bo(e){let i="";for(let t=0;t<e.length;t+=2)i+=String.fromCharCode(e[t]|e[t+1]<<8);return i}function Fo(e){return String.fromCharCode(...e.map(i=>i&127))}function wo(e){return String.fromCharCode(...e)}function Eo(e){let i="";for(let t of e)t>=128&&t<=159&&Wi[t]?i+=Wi[t]:i+=String.fromCharCode(t);return i}function $(e){return new DataView(e.buffer,e.byteOffset)}var oa={len:1,get(e,i){return $(e).getUint8(i)},put(e,i,t){return $(e).setUint8(i,t),i+1}},P={len:2,get(e,i){return $(e).getUint16(i,!0)},put(e,i,t){return $(e).setUint16(i,t,!0),i+2}},ge={len:2,get(e,i){return $(e).getUint16(i)},put(e,i,t){return $(e).setUint16(i,t),i+2}};var R={len:4,get(e,i){return $(e).getUint32(i,!0)},put(e,i,t){return $(e).setUint32(i,t,!0),i+4}},ra={len:4,get(e,i){return $(e).getUint32(i)},put(e,i,t){return $(e).setUint32(i,t),i+4}};var ca={len:4,get(e,i){return $(e).getInt32(i)},put(e,i,t){return $(e).setInt32(i,t),i+4}};var pa={len:8,get(e,i){return $(e).getBigUint64(i,!0)},put(e,i,t){return $(e).setBigUint64(i,t,!0),i+8}};var H=class{constructor(i,t){this.len=i,this.encoding=t}get(i,t=0){let a=i.subarray(t,t+this.len);return na(a,this.encoding)}};var Ca=xe(Fa(),1);var le={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},Ki={get(e){return{signature:R.get(e,0),compressedSize:R.get(e,8),uncompressedSize:R.get(e,12)}},len:16},wa={get(e){let i=P.get(e,6);return{signature:R.get(e,0),minVersion:P.get(e,4),dataDescriptor:!!(i&8),compressedMethod:P.get(e,8),compressedSize:R.get(e,18),uncompressedSize:R.get(e,22),filenameLength:P.get(e,26),extraFieldLength:P.get(e,28),filename:null}},len:30},Ea={get(e){return{signature:R.get(e,0),nrOfThisDisk:P.get(e,4),nrOfThisDiskWithTheStart:P.get(e,6),nrOfEntriesOnThisDisk:P.get(e,8),nrOfEntriesOfSize:P.get(e,10),sizeOfCd:R.get(e,12),offsetOfStartOfCd:R.get(e,16),zipFileCommentLength:P.get(e,20)}},len:22},ya={get(e){let i=P.get(e,8);return{signature:R.get(e,0),minVersion:P.get(e,6),dataDescriptor:!!(i&8),compressedMethod:P.get(e,10),compressedSize:R.get(e,20),uncompressedSize:R.get(e,24),filenameLength:P.get(e,28),extraFieldLength:P.get(e,30),fileCommentLength:P.get(e,32),relativeOffsetOfLocalHeader:R.get(e,42),filename:null}},len:46};function ka(e){let i=new Uint8Array(R.len);return R.put(i,0,e),i}var X=(0,Ca.default)("tokenizer:inflate"),Yi=256*1024,Ko=ka(le.DataDescriptor),mi=ka(le.EndOfCentralDirectory),Ie=class e{constructor(i){this.tokenizer=i,this.syncBuffer=new Uint8Array(Yi)}async isZip(){return await this.peekSignature()===le.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(R)}async findEndOfCentralDirectoryLocator(){let i=this.tokenizer,t=Math.min(16*1024,i.fileInfo.size),a=this.syncBuffer.subarray(0,t);await this.tokenizer.readBuffer(a,{position:i.fileInfo.size-t});for(let n=a.length-4;n>=0;n--)if(a[n]===mi[0]&&a[n+1]===mi[1]&&a[n+2]===mi[2]&&a[n+3]===mi[3])return i.fileInfo.size-t+n;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){X("Cannot reading central-directory without random-read support");return}X("Reading central-directory...");let i=this.tokenizer.position,t=await this.findEndOfCentralDirectoryLocator();if(t>0){X("Central-directory 32-bit signature found");let a=await this.tokenizer.readToken(Ea,t),n=[];this.tokenizer.setPosition(a.offsetOfStartOfCd);for(let s=0;s<a.nrOfEntriesOfSize;++s){let o=await this.tokenizer.readToken(ya);if(o.signature!==le.CentralFileHeader)throw new Error("Expected Central-File-Header signature");o.filename=await this.tokenizer.readToken(new H(o.filenameLength,"utf-8")),await this.tokenizer.ignore(o.extraFieldLength),await this.tokenizer.ignore(o.fileCommentLength),n.push(o),X(`Add central-directory file-entry: n=${s+1}/${n.length}: filename=${n[s].filename}`)}return this.tokenizer.setPosition(i),n}this.tokenizer.setPosition(i)}async unzip(i){let t=await this.readCentralDirectory();if(t)return this.iterateOverCentralDirectory(t,i);let a=!1;do{let n=await this.readLocalFileHeader();if(!n)break;let s=i(n);a=!!s.stop;let o;if(await this.tokenizer.ignore(n.extraFieldLength),n.dataDescriptor&&n.compressedSize===0){let r=[],c=Yi;X("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let p=-1;for(;p<0&&c===Yi;){c=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),p=Yo(this.syncBuffer.subarray(0,c),Ko);let u=p>=0?p:c;if(s.handler){let l=new Uint8Array(u);await this.tokenizer.readBuffer(l),r.push(l)}else await this.tokenizer.ignore(u)}X(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),s.handler&&await this.inflate(n,Vo(r),s.handler)}else s.handler?(X(`Reading compressed-file-data: ${n.compressedSize} bytes`),o=new Uint8Array(n.compressedSize),await this.tokenizer.readBuffer(o),await this.inflate(n,o,s.handler)):(X(`Ignoring compressed-file-data: ${n.compressedSize} bytes`),await this.tokenizer.ignore(n.compressedSize));if(X(`Reading data-descriptor at pos=${this.tokenizer.position}`),n.dataDescriptor&&(await this.tokenizer.readToken(Ki)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-Ki.len}`)}while(!a)}async iterateOverCentralDirectory(i,t){for(let a of i){let n=t(a);if(n.handler){this.tokenizer.setPosition(a.relativeOffsetOfLocalHeader);let s=await this.readLocalFileHeader();if(s){await this.tokenizer.ignore(s.extraFieldLength);let o=new Uint8Array(a.compressedSize);await this.tokenizer.readBuffer(o),await this.inflate(s,o,n.handler)}}if(n.stop)break}}async inflate(i,t,a){if(i.compressedMethod===0)return a(t);if(i.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${i.compressedMethod}`);X(`Decompress filename=${i.filename}, compressed-size=${t.length}`);let n=await e.decompressDeflateRaw(t);return a(n)}static async decompressDeflateRaw(i){let t=new ReadableStream({start(s){s.enqueue(i),s.close()}}),a=new DecompressionStream("deflate-raw"),n=t.pipeThrough(a);try{let o=await new Response(n).arrayBuffer();return new Uint8Array(o)}catch(s){let o=s instanceof Error?`Failed to deflate ZIP entry: ${s.message}`:"Unknown decompression error in ZIP entry";throw new TypeError(o)}}async readLocalFileHeader(){let i=await this.tokenizer.peekToken(R);if(i===le.LocalFileHeader){let t=await this.tokenizer.readToken(wa);return t.filename=await this.tokenizer.readToken(new H(t.filenameLength,"utf-8")),t}if(i===le.CentralFileHeader)return!1;throw i===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}};function Yo(e,i){let t=e.length,a=i.length;if(a>t)return-1;for(let n=0;n<=t-a;n++){let s=!0;for(let o=0;o<a;o++)if(e[n+o]!==i[o]){s=!1;break}if(s)return n}return-1}function Vo(e){let i=e.reduce((n,s)=>n+s.length,0),t=new Uint8Array(i),a=0;for(let n of e)t.set(n,a),a+=n.length;return t}var _e=class{constructor(i){this.tokenizer=i}inflate(){let i=this.tokenizer;return new ReadableStream({async pull(t){let a=new Uint8Array(1024),n=await i.readBuffer(a,{mayBeLess:!0});if(n===0){t.close();return}t.enqueue(a.subarray(0,n))}}).pipeThrough(new DecompressionStream("gzip"))}};var Wm={utf8:new globalThis.TextDecoder("utf8")};var qm=new globalThis.TextEncoder;var $m=Array.from({length:256},(e,i)=>i.toString(16).padStart(2,"0"));function Vi(e){let{byteLength:i}=e;if(i===6)return e.getUint16(0)*2**32+e.getUint32(2);if(i===5)return e.getUint8(0)*2**32+e.getUint32(1);if(i===4)return e.getUint32(0);if(i===3)return e.getUint8(0)*2**16+e.getUint16(1);if(i===2)return e.getUint16(0);if(i===1)return e.getUint8(0)}function Aa(e,i){if(i==="utf-16le"){let t=[];for(let a=0;a<e.length;a++){let n=e.charCodeAt(a);t.push(n&255,n>>8&255)}return t}if(i==="utf-16be"){let t=[];for(let a=0;a<e.length;a++){let n=e.charCodeAt(a);t.push(n>>8&255,n&255)}return t}return[...e].map(t=>t.charCodeAt(0))}function Ta(e,i=0){let t=Number.parseInt(new H(6).get(e,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(t))return!1;let a=256;for(let n=i;n<i+148;n++)a+=e[n];for(let n=i+156;n<i+512;n++)a+=e[n];return t===a}var Sa={get:(e,i)=>e[i+3]&127|e[i+2]<<7|e[i+1]<<14|e[i]<<21,len:4};var Ba=["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","rm","ppsm","ppsx","tar.gz","reg","dat"],Oa=["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-ms-regedit","application/x-ft-windows-registry-hive"];var Ue=4100;function Zi(e){switch(e=e.toLowerCase(),e){case"application/epub+zip":return{ext:"epub",mime:e};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:e};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:e};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:e};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:e};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:e};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:e};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:e};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:e};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:e};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:e};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:e};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:e};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:e};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:e};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:e};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 Q(e,i,t){t={offset:0,...t};for(let[a,n]of i.entries())if(t.mask){if(n!==(t.mask[a]&e[a+t.offset]))return!1}else if(n!==e[a+t.offset])return!1;return!0}var di=class{constructor(i){this.options={mpegOffsetTolerance:0,...i},this.detectors=[...i?.customDetectors??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:i?.signal}}async fromTokenizer(i){let t=i.position;for(let a of this.detectors){let n=await a.detect(i);if(n)return n;if(t!==i.position)return}}async fromBuffer(i){if(!(i instanceof Uint8Array||i instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof i}\``);let t=i instanceof Uint8Array?i:new Uint8Array(i);if(t?.length>1)return this.fromTokenizer(Qt(t,this.tokenizerOptions))}async fromBlob(i){let t=ea(i,this.tokenizerOptions);try{return await this.fromTokenizer(t)}finally{await t.close()}}async fromStream(i){let t=ri(i,this.tokenizerOptions);try{return await this.fromTokenizer(t)}finally{await t.close()}}async toDetectionStream(i,t){let{sampleSize:a=Ue}=t,n,s,o=i.getReader({mode:"byob"});try{let{value:p,done:u}=await o.read(new Uint8Array(a));if(s=p,!u&&p)try{n=await this.fromBuffer(p.subarray(0,a))}catch(l){if(!(l instanceof k))throw l;n=void 0}s=p}finally{o.releaseLock()}let r=new TransformStream({async start(p){p.enqueue(s)},transform(p,u){u.enqueue(p)}}),c=i.pipeThrough(r);return c.fileType=n,c}check(i,t){return Q(this.buffer,i,t)}checkString(i,t){return this.check(Aa(i,t?.encoding),t)}detectConfident=async i=>{if(this.buffer=new Uint8Array(Ue),i.fileInfo.size===void 0&&(i.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=i,await i.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 i.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.tokenizer.ignore(3),this.detectConfident(i);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])){let a=new _e(i).inflate(),n=!0;try{let s;try{s=await this.fromStream(a)}catch{n=!1}if(s&&s.ext==="tar")return{ext:"tar.gz",mime:"application/gzip"}}finally{n&&await a.cancel()}return{ext:"gz",mime:"application/gzip"}}if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await i.ignore(6);let t=await i.readToken(Sa);return i.position+t>i.fileInfo.size?{ext:"mp3",mime:"audio/mpeg"}:(await i.ignore(t),this.fromTokenizer(i))}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;return await new Ie(i).unzip(a=>{switch(a.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{async handler(n){let s=new TextDecoder("utf-8").decode(n).trim();t=Zi(s)},stop:!0};case"[Content_Types].xml":return{async handler(n){let s=new TextDecoder("utf-8").decode(n),o=s.indexOf('.main+xml"');if(o===-1){let r="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";s.includes(`ContentType="${r}"`)&&(t=Zi(r))}else{s=s.slice(0,Math.max(0,o));let r=s.lastIndexOf('"'),c=s.slice(Math.max(0,r+1));t=Zi(c)}},stop:!0};default:return/classes\d*\.dex/.test(a.filename)?(t={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}}).catch(a=>{if(!(a instanceof k))throw a}),t??{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await i.ignore(28);let t=new Uint8Array(8);return await i.readBuffer(t),Q(t,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:Q(t,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:Q(t,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:Q(t,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:Q(t,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:Q(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 r=await i.peekNumber(oa),c=128,p=0;for(;(r&c)===0&&c!==0;)++p,c>>=1;let u=new Uint8Array(p+1);return await i.readBuffer(u),u}async function a(){let r=await t(),c=await t();c[0]^=128>>c.length-1;let p=Math.min(6,c.length),u=new DataView(r.buffer),l=new DataView(c.buffer,c.length-p,p);return{id:Vi(u),len:Vi(l)}}async function n(r){for(;r>0;){let c=await a();if(c.id===17026)return(await i.readToken(new H(c.len))).replaceAll(/\00.*$/g,"");await i.ignore(c.len),--r}}let s=await a();switch(await n(s.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([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.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]))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 H(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 i.ignore(8),await i.readToken(new H(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("WEBVTT")&&[`
22
22
  `,"\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])){await i.ignore(8);async function t(){return{length:await i.readToken(ca),type:await i.readToken(new H(4,"latin1"))}}do{let a=await t();if(a.length<0)return;switch(a.type){case"IDAT":return{ext:"png",mime:"image/png"};case"acTL":return{ext:"apng",mime:"image/apng"};default:await i.ignore(a.length+4)}}while(i.position+8<i.fileInfo.size);return{ext:"png",mime:"image/png"}}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 H(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
23
23
  `))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])){async function t(){let a=new Uint8Array(16);return await i.readBuffer(a),{id:a,size:Number(await i.readToken(pa))}}for(await i.ignore(30);i.position+24<i.fileInfo.size;){let a=await t(),n=a.size-24;if(Q(a.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){let s=new Uint8Array(16);if(n-=await i.readBuffer(s),Q(s,[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(Q(s,[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}await i.ignore(n)}return{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 i.ignore(20),await i.readToken(new H(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 i.peekBuffer(this.buffer,{length:Math.min(256,i.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 a=new TextDecoder().decode(this.buffer.subarray(16,t+16));if(JSON.parse(a).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(await i.peekBuffer(this.buffer,{length:Math.min(512,i.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})&&Ta(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
24
24
  `,{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 i=>{if(this.buffer=new Uint8Array(Ue),await i.peekBuffer(this.buffer,{length:Math.min(8,i.fileInfo.size),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 i.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,i.fileInfo.size),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let t=0;t<=this.options.mpegOffsetTolerance;++t){let a=this.scanMpeg(t);if(a)return a}};async readTiffTag(i){let t=await this.tokenizer.readToken(i?ge:P);switch(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(i){let t=await this.tokenizer.readToken(i?ge:P);for(let a=0;a<t;++a){let n=await this.readTiffTag(i);if(n)return n}}async readTiffHeader(i){let t=(i?ge:P).get(this.buffer,2),a=(i?ra:R).get(this.buffer,4);if(t===42){if(a>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(a>=8){let s=(i?ge:P).get(this.buffer,8),o=(i?ge:P).get(this.buffer,10);if(s===28&&o===254||s===31&&o===11)return{ext:"nef",mime:"image/x-nikon-nef"}}}return await this.tokenizer.ignore(a),await this.readTiffIFD(i)??{ext:"tif",mime:"image/tiff"}}if(t===43)return{ext:"tif",mime:"image/tiff"}}scanMpeg(i){if(this.check([255,224],{offset:i,mask:[255,224]})){if(this.check([16],{offset:i+1,mask:[22]}))return this.check([8],{offset:i+1,mask:[8]})?{ext:"aac",mime:"audio/aac"}:{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:i+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:i+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:i+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}},Qm=new Set(Ba),ed=new Set(Oa);var Ji=class extends di{async fromStream(i){let t=await(i instanceof Zo?ri(i,this.tokenizerOptions):ia(i,this.tokenizerOptions));try{return await super.fromTokenizer(t)}finally{await t.close()}}async fromFile(i){let t=await ta(i);try{return await super.fromTokenizer(t)}finally{await t.close()}}async toDetectionStream(i,t={}){if(!(i instanceof Xo))return super.toDetectionStream(i,t);let{sampleSize:a=Ue}=t;return new Promise((n,s)=>{i.on("error",s),i.once("readable",()=>{(async()=>{try{let o=new Jo,r=Pa?Pa(i,o,()=>{}):i.pipe(o),c=i.read(a)??i.read()??new Uint8Array(0);try{o.fileType=await this.fromBuffer(c)}catch(p){p instanceof k?o.fileType=void 0:s(p)}n(r)}catch(o){s(o)}})()})})}};async function ja(e,i){return new Ji(i).fromFile(e,i)}var gn=xe(Ha(),1);var Qi=(e,i,t)=>{let a=e instanceof RegExp?Ga(e,t):e,n=i instanceof RegExp?Ga(i,t):i,s=a!==null&&n!=null&&rr(a,n,t);return s&&{start:s[0],end:s[1],pre:t.slice(0,s[0]),body:t.slice(s[0]+a.length,s[1]),post:t.slice(s[1]+n.length)}},Ga=(e,i)=>{let t=i.match(e);return t?t[0]:null},rr=(e,i,t)=>{let a,n,s,o,r,c=t.indexOf(e),p=t.indexOf(i,c+1),u=c;if(c>=0&&p>0){if(e===i)return[c,p];for(a=[],s=t.length;u>=0&&!r;){if(u===c)a.push(u),c=t.indexOf(e,u+1);else if(a.length===1){let l=a.pop();l!==void 0&&(r=[l,p])}else n=a.pop(),n!==void 0&&n<s&&(s=n,o=p),p=t.indexOf(i,u+1);u=c<p&&c>=0?c:p}a.length&&o!==void 0&&(r=[s,o])}return r};var Ka="\0SLASH"+Math.random()+"\0",Ya="\0OPEN"+Math.random()+"\0",it="\0CLOSE"+Math.random()+"\0",Va="\0COMMA"+Math.random()+"\0",Za="\0PERIOD"+Math.random()+"\0",cr=new RegExp(Ka,"g"),pr=new RegExp(Ya,"g"),ur=new RegExp(it,"g"),lr=new RegExp(Va,"g"),mr=new RegExp(Za,"g"),dr=/\\\\/g,fr=/\\{/g,xr=/\\}/g,hr=/\\,/g,gr=/\\./g;function et(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Dr(e){return e.replace(dr,Ka).replace(fr,Ya).replace(xr,it).replace(hr,Va).replace(gr,Za)}function vr(e){return e.replace(cr,"\\").replace(pr,"{").replace(ur,"}").replace(lr,",").replace(mr,".")}function Ja(e){if(!e)return[""];let i=[],t=Qi("{","}",e);if(!t)return e.split(",");let{pre:a,body:n,post:s}=t,o=a.split(",");o[o.length-1]+="{"+n+"}";let r=Ja(s);return s.length&&(o[o.length-1]+=r.shift(),o.push.apply(o,r)),i.push.apply(i,o),i}function Xa(e){return e?(e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),Le(Dr(e),!0).map(vr)):[]}function br(e){return"{"+e+"}"}function Fr(e){return/^-?0\d/.test(e)}function wr(e,i){return e<=i}function Er(e,i){return e>=i}function Le(e,i){let t=[],a=Qi("{","}",e);if(!a)return[e];let n=a.pre,s=a.post.length?Le(a.post,!1):[""];if(/\$$/.test(a.pre))for(let o=0;o<s.length;o++){let r=n+"{"+a.body+"}"+s[o];t.push(r)}else{let o=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body),r=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body),c=o||r,p=a.body.indexOf(",")>=0;if(!c&&!p)return a.post.match(/,(?!,).*\}/)?(e=a.pre+"{"+a.body+it+a.post,Le(e)):[e];let u;if(c)u=a.body.split(/\.\./);else if(u=Ja(a.body),u.length===1&&u[0]!==void 0&&(u=Le(u[0],!1).map(br),u.length===1))return s.map(m=>a.pre+u[0]+m);let l;if(c&&u[0]!==void 0&&u[1]!==void 0){let m=et(u[0]),d=et(u[1]),f=Math.max(u[0].length,u[1].length),x=u.length===3&&u[2]!==void 0?Math.abs(et(u[2])):1,h=wr;d<m&&(x*=-1,h=Er);let v=u.some(Fr);l=[];for(let y=m;h(y,d);y+=x){let w;if(r)w=String.fromCharCode(y),w==="\\"&&(w="");else if(w=String(y),v){let _=f-w.length;if(_>0){let U=new Array(_+1).join("0");y<0?w="-"+U+w.slice(1):w=U+w}}l.push(w)}}else{l=[];for(let m=0;m<u.length;m++)l.push.apply(l,Le(u[m],!1))}for(let m=0;m<l.length;m++)for(let d=0;d<s.length;d++){let f=n+l[m]+s[d];(!i||c||f)&&t.push(f)}}return t}var ze=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var yr={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},Me=e=>e.replace(/[[\]\\-]/g,"\\$&"),Cr=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Qa=e=>e.join(""),en=(e,i)=>{let t=i;if(e.charAt(t)!=="[")throw new Error("not in a brace expression");let a=[],n=[],s=t+1,o=!1,r=!1,c=!1,p=!1,u=t,l="";e:for(;s<e.length;){let x=e.charAt(s);if((x==="!"||x==="^")&&s===t+1){p=!0,s++;continue}if(x==="]"&&o&&!c){u=s+1;break}if(o=!0,x==="\\"&&!c){c=!0,s++;continue}if(x==="["&&!c){for(let[h,[O,v,y]]of Object.entries(yr))if(e.startsWith(h,s)){if(l)return["$.",!1,e.length-t,!0];s+=h.length,y?n.push(O):a.push(O),r=r||v;continue e}}if(c=!1,l){x>l?a.push(Me(l)+"-"+Me(x)):x===l&&a.push(Me(x)),l="",s++;continue}if(e.startsWith("-]",s+1)){a.push(Me(x+"-")),s+=2;continue}if(e.startsWith("-",s+1)){l=x,s+=2;continue}a.push(Me(x)),s++}if(u<s)return["",!1,0,!1];if(!a.length&&!n.length)return["$.",!1,e.length-t,!0];if(n.length===0&&a.length===1&&/^\\?.$/.test(a[0])&&!p){let x=a[0].length===2?a[0].slice(-1):a[0];return[Cr(x),!1,u-t,!1]}let m="["+(p?"^":"")+Qa(a)+"]",d="["+(p?"":"^")+Qa(n)+"]";return[a.length&&n.length?"("+m+"|"+d+")":a.length?m:d,r,u-t,!0]};var re=(e,{windowsPathsNoEscape:i=!1,magicalBraces:t=!0}={})=>t?i?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):i?e.replace(/\[([^\/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1");var kr=new Set(["!","?","+","*","@"]),tn=e=>kr.has(e),Ar="(?!(?:^|/)\\.\\.?(?:$|/))",fi="(?!\\.)",Tr=new Set(["[","."]),Sr=new Set(["..","."]),Br=new Set("().*{}+?[]^$\\!"),Or=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),tt="[^/]",an=tt+"*?",nn=tt+"+?",Fe=class e{type;#n;#e;#i=!1;#t=[];#a;#s;#o;#c=!1;#r;#p;#l=!1;constructor(i,t,a={}){this.type=i,i&&(this.#e=!0),this.#a=t,this.#n=this.#a?this.#a.#n:this,this.#r=this.#n===this?a:this.#n.#r,this.#o=this.#n===this?[]:this.#n.#o,i==="!"&&!this.#n.#c&&this.#o.push(this),this.#s=this.#a?this.#a.#t.length:0}get hasMagic(){if(this.#e!==void 0)return this.#e;for(let i of this.#t)if(typeof i!="string"&&(i.type||i.hasMagic))return this.#e=!0;return this.#e}toString(){return this.#p!==void 0?this.#p:this.type?this.#p=this.type+"("+this.#t.map(i=>String(i)).join("|")+")":this.#p=this.#t.map(i=>String(i)).join("")}#d(){if(this!==this.#n)throw new Error("should only call on root");if(this.#c)return this;this.toString(),this.#c=!0;let i;for(;i=this.#o.pop();){if(i.type!=="!")continue;let t=i,a=t.#a;for(;a;){for(let n=t.#s+1;!a.type&&n<a.#t.length;n++)for(let s of i.#t){if(typeof s=="string")throw new Error("string part in extglob AST??");s.copyIn(a.#t[n])}t=a,a=t.#a}}return this}push(...i){for(let t of i)if(t!==""){if(typeof t!="string"&&!(t instanceof e&&t.#a===this))throw new Error("invalid part: "+t);this.#t.push(t)}}toJSON(){let i=this.type===null?this.#t.slice().map(t=>typeof t=="string"?t:t.toJSON()):[this.type,...this.#t.map(t=>t.toJSON())];return this.isStart()&&!this.type&&i.unshift([]),this.isEnd()&&(this===this.#n||this.#n.#c&&this.#a?.type==="!")&&i.push({}),i}isStart(){if(this.#n===this)return!0;if(!this.#a?.isStart())return!1;if(this.#s===0)return!0;let i=this.#a;for(let t=0;t<this.#s;t++){let a=i.#t[t];if(!(a instanceof e&&a.type==="!"))return!1}return!0}isEnd(){if(this.#n===this||this.#a?.type==="!")return!0;if(!this.#a?.isEnd())return!1;if(!this.type)return this.#a?.isEnd();let i=this.#a?this.#a.#t.length:0;return this.#s===i-1}copyIn(i){typeof i=="string"?this.push(i):this.push(i.clone(this))}clone(i){let t=new e(this.type,i);for(let a of this.#t)t.copyIn(a);return t}static#u(i,t,a,n){let s=!1,o=!1,r=-1,c=!1;if(t.type===null){let d=a,f="";for(;d<i.length;){let x=i.charAt(d++);if(s||x==="\\"){s=!s,f+=x;continue}if(o){d===r+1?(x==="^"||x==="!")&&(c=!0):x==="]"&&!(d===r+2&&c)&&(o=!1),f+=x;continue}else if(x==="["){o=!0,r=d,c=!1,f+=x;continue}if(!n.noext&&tn(x)&&i.charAt(d)==="("){t.push(f),f="";let h=new e(x,t);d=e.#u(i,h,d,n),t.push(h);continue}f+=x}return t.push(f),d}let p=a+1,u=new e(null,t),l=[],m="";for(;p<i.length;){let d=i.charAt(p++);if(s||d==="\\"){s=!s,m+=d;continue}if(o){p===r+1?(d==="^"||d==="!")&&(c=!0):d==="]"&&!(p===r+2&&c)&&(o=!1),m+=d;continue}else if(d==="["){o=!0,r=p,c=!1,m+=d;continue}if(tn(d)&&i.charAt(p)==="("){u.push(m),m="";let f=new e(d,u);u.push(f),p=e.#u(i,f,p,n);continue}if(d==="|"){u.push(m),m="",l.push(u),u=new e(null,t);continue}if(d===")")return m===""&&t.#t.length===0&&(t.#l=!0),u.push(m),m="",t.push(...l,u),p;m+=d}return t.type=null,t.#e=void 0,t.#t=[i.substring(a-1)],p}static fromGlob(i,t={}){let a=new e(null,void 0,t);return e.#u(i,a,0,t),a}toMMPattern(){if(this!==this.#n)return this.#n.toMMPattern();let i=this.toString(),[t,a,n,s]=this.toRegExpSource();if(!(n||this.#e||this.#r.nocase&&!this.#r.nocaseMagicOnly&&i.toUpperCase()!==i.toLowerCase()))return a;let r=(this.#r.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${t}$`,r),{_src:t,_glob:i})}get options(){return this.#r}toRegExpSource(i){let t=i??!!this.#r.dot;if(this.#n===this&&this.#d(),!this.type){let c=this.isStart()&&this.isEnd()&&!this.#t.some(d=>typeof d!="string"),p=this.#t.map(d=>{let[f,x,h,O]=typeof d=="string"?e.#f(d,this.#e,c):d.toRegExpSource(i);return this.#e=this.#e||h,this.#i=this.#i||O,f}).join(""),u="";if(this.isStart()&&typeof this.#t[0]=="string"&&!(this.#t.length===1&&Sr.has(this.#t[0]))){let f=Tr,x=t&&f.has(p.charAt(0))||p.startsWith("\\.")&&f.has(p.charAt(2))||p.startsWith("\\.\\.")&&f.has(p.charAt(4)),h=!t&&!i&&f.has(p.charAt(0));u=x?Ar:h?fi:""}let l="";return this.isEnd()&&this.#n.#c&&this.#a?.type==="!"&&(l="(?:$|\\/)"),[u+p+l,re(p),this.#e=!!this.#e,this.#i]}let a=this.type==="*"||this.type==="+",n=this.type==="!"?"(?:(?!(?:":"(?:",s=this.#m(t);if(this.isStart()&&this.isEnd()&&!s&&this.type!=="!"){let c=this.toString();return this.#t=[c],this.type=null,this.#e=void 0,[c,re(this.toString()),!1,!1]}let o=!a||i||t||!fi?"":this.#m(!0);o===s&&(o=""),o&&(s=`(?:${s})(?:${o})*?`);let r="";if(this.type==="!"&&this.#l)r=(this.isStart()&&!t?fi:"")+nn;else{let c=this.type==="!"?"))"+(this.isStart()&&!t&&!i?fi:"")+an+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;r=n+s+c}return[r,re(s),this.#e=!!this.#e,this.#i]}#m(i){return this.#t.map(t=>{if(typeof t=="string")throw new Error("string type in extglob ast??");let[a,n,s,o]=t.toRegExpSource(i);return this.#i=this.#i||o,a}).filter(t=>!(this.isStart()&&this.isEnd())||!!t).join("|")}static#f(i,t,a=!1){let n=!1,s="",o=!1;for(let r=0;r<i.length;r++){let c=i.charAt(r);if(n){n=!1,s+=(Br.has(c)?"\\":"")+c;continue}if(c==="\\"){r===i.length-1?s+="\\\\":n=!0;continue}if(c==="["){let[p,u,l,m]=en(i,r);if(l){s+=p,o=o||u,r+=l-1,t=t||m;continue}}if(c==="*"){s+=a&&i==="*"?nn:an,t=!0;continue}if(c==="?"){s+=tt,t=!0;continue}s+=Or(c)}return[s,re(i),!!t,o]}};var at=(e,{windowsPathsNoEscape:i=!1,magicalBraces:t=!1}={})=>t?i?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):i?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var I=(e,i,t={})=>(ze(i),!t.nocomment&&i.charAt(0)==="#"?!1:new we(i,t).match(e)),Pr=/^\*+([^+@!?\*\[\(]*)$/,jr=e=>i=>!i.startsWith(".")&&i.endsWith(e),Rr=e=>i=>i.endsWith(e),Ir=e=>(e=e.toLowerCase(),i=>!i.startsWith(".")&&i.toLowerCase().endsWith(e)),_r=e=>(e=e.toLowerCase(),i=>i.toLowerCase().endsWith(e)),Ur=/^\*+\.\*+$/,Lr=e=>!e.startsWith(".")&&e.includes("."),zr=e=>e!=="."&&e!==".."&&e.includes("."),Mr=/^\.\*+$/,Nr=e=>e!=="."&&e!==".."&&e.startsWith("."),Wr=/^\*+$/,qr=e=>e.length!==0&&!e.startsWith("."),$r=e=>e.length!==0&&e!=="."&&e!=="..",Hr=/^\?+([^+@!?\*\[\(]*)?$/,Gr=([e,i=""])=>{let t=rn([e]);return i?(i=i.toLowerCase(),a=>t(a)&&a.toLowerCase().endsWith(i)):t},Kr=([e,i=""])=>{let t=cn([e]);return i?(i=i.toLowerCase(),a=>t(a)&&a.toLowerCase().endsWith(i)):t},Yr=([e,i=""])=>{let t=cn([e]);return i?a=>t(a)&&a.endsWith(i):t},Vr=([e,i=""])=>{let t=rn([e]);return i?a=>t(a)&&a.endsWith(i):t},rn=([e])=>{let i=e.length;return t=>t.length===i&&!t.startsWith(".")},cn=([e])=>{let i=e.length;return t=>t.length===i&&t!=="."&&t!==".."},pn=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",sn={win32:{sep:"\\"},posix:{sep:"/"}},Zr=pn==="win32"?sn.win32.sep:sn.posix.sep;I.sep=Zr;var V=Symbol("globstar **");I.GLOBSTAR=V;var Jr="[^/]",Xr=Jr+"*?",Qr="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",ec="(?:(?!(?:\\/|^)\\.).)*?",ic=(e,i={})=>t=>I(t,e,i);I.filter=ic;var Y=(e,i={})=>Object.assign({},e,i),tc=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return I;let i=I;return Object.assign((a,n,s={})=>i(a,n,Y(e,s)),{Minimatch:class extends i.Minimatch{constructor(n,s={}){super(n,Y(e,s))}static defaults(n){return i.defaults(Y(e,n)).Minimatch}},AST:class extends i.AST{constructor(n,s,o={}){super(n,s,Y(e,o))}static fromGlob(n,s={}){return i.AST.fromGlob(n,Y(e,s))}},unescape:(a,n={})=>i.unescape(a,Y(e,n)),escape:(a,n={})=>i.escape(a,Y(e,n)),filter:(a,n={})=>i.filter(a,Y(e,n)),defaults:a=>i.defaults(Y(e,a)),makeRe:(a,n={})=>i.makeRe(a,Y(e,n)),braceExpand:(a,n={})=>i.braceExpand(a,Y(e,n)),match:(a,n,s={})=>i.match(a,n,Y(e,s)),sep:i.sep,GLOBSTAR:V})};I.defaults=tc;var un=(e,i={})=>(ze(e),i.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Xa(e));I.braceExpand=un;var ac=(e,i={})=>new we(e,i).makeRe();I.makeRe=ac;var nc=(e,i,t={})=>{let a=new we(i,t);return e=e.filter(n=>a.match(n)),a.options.nonull&&!e.length&&e.push(i),e};I.match=nc;var on=/[?*]|[+@!]\(.*?\)|\[|\]/,sc=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),we=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(i,t={}){ze(i),t=t||{},this.options=t,this.pattern=i,this.platform=t.platform||pn,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot!==void 0?t.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let i of this.set)for(let t of i)if(typeof t!="string")return!0;return!1}debug(...i){}make(){let i=this.pattern,t=this.options;if(!t.nocomment&&i.charAt(0)==="#"){this.comment=!0;return}if(!i){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...s)=>console.error(...s)),this.debug(this.pattern,this.globSet);let a=this.globSet.map(s=>this.slashSplit(s));this.globParts=this.preprocess(a),this.debug(this.pattern,this.globParts);let n=this.globParts.map((s,o,r)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=s[0]===""&&s[1]===""&&(s[2]==="?"||!on.test(s[2]))&&!on.test(s[3]),p=/^[a-z]:/i.test(s[0]);if(c)return[...s.slice(0,4),...s.slice(4).map(u=>this.parse(u))];if(p)return[s[0],...s.slice(1).map(u=>this.parse(u))]}return s.map(c=>this.parse(c))});if(this.debug(this.pattern,n),this.set=n.filter(s=>s.indexOf(!1)===-1),this.isWindows)for(let s=0;s<this.set.length;s++){let o=this.set[s];o[0]===""&&o[1]===""&&this.globParts[s][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(i){if(this.options.noglobstar)for(let a=0;a<i.length;a++)for(let n=0;n<i[a].length;n++)i[a][n]==="**"&&(i[a][n]="*");let{optimizationLevel:t=1}=this.options;return t>=2?(i=this.firstPhasePreProcess(i),i=this.secondPhasePreProcess(i)):t>=1?i=this.levelOneOptimize(i):i=this.adjascentGlobstarOptimize(i),i}adjascentGlobstarOptimize(i){return i.map(t=>{let a=-1;for(;(a=t.indexOf("**",a+1))!==-1;){let n=a;for(;t[n+1]==="**";)n++;n!==a&&t.splice(a,n-a)}return t})}levelOneOptimize(i){return i.map(t=>(t=t.reduce((a,n)=>{let s=a[a.length-1];return n==="**"&&s==="**"?a:n===".."&&s&&s!==".."&&s!=="."&&s!=="**"?(a.pop(),a):(a.push(n),a)},[]),t.length===0?[""]:t))}levelTwoFileOptimize(i){Array.isArray(i)||(i=this.slashSplit(i));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let n=1;n<i.length-1;n++){let s=i[n];n===1&&s===""&&i[0]===""||(s==="."||s==="")&&(t=!0,i.splice(n,1),n--)}i[0]==="."&&i.length===2&&(i[1]==="."||i[1]==="")&&(t=!0,i.pop())}let a=0;for(;(a=i.indexOf("..",a+1))!==-1;){let n=i[a-1];n&&n!=="."&&n!==".."&&n!=="**"&&(t=!0,i.splice(a-1,2),a-=2)}}while(t);return i.length===0?[""]:i}firstPhasePreProcess(i){let t=!1;do{t=!1;for(let a of i){let n=-1;for(;(n=a.indexOf("**",n+1))!==-1;){let o=n;for(;a[o+1]==="**";)o++;o>n&&a.splice(n+1,o-n);let r=a[n+1],c=a[n+2],p=a[n+3];if(r!==".."||!c||c==="."||c===".."||!p||p==="."||p==="..")continue;t=!0,a.splice(n,1);let u=a.slice(0);u[n]="**",i.push(u),n--}if(!this.preserveMultipleSlashes){for(let o=1;o<a.length-1;o++){let r=a[o];o===1&&r===""&&a[0]===""||(r==="."||r==="")&&(t=!0,a.splice(o,1),o--)}a[0]==="."&&a.length===2&&(a[1]==="."||a[1]==="")&&(t=!0,a.pop())}let s=0;for(;(s=a.indexOf("..",s+1))!==-1;){let o=a[s-1];if(o&&o!=="."&&o!==".."&&o!=="**"){t=!0;let c=s===1&&a[s+1]==="**"?["."]:[];a.splice(s-1,2,...c),a.length===0&&a.push(""),s-=2}}}}while(t);return i}secondPhasePreProcess(i){for(let t=0;t<i.length-1;t++)for(let a=t+1;a<i.length;a++){let n=this.partsMatch(i[t],i[a],!this.preserveMultipleSlashes);if(n){i[t]=[],i[a]=n;break}}return i.filter(t=>t.length)}partsMatch(i,t,a=!1){let n=0,s=0,o=[],r="";for(;n<i.length&&s<t.length;)if(i[n]===t[s])o.push(r==="b"?t[s]:i[n]),n++,s++;else if(a&&i[n]==="**"&&t[s]===i[n+1])o.push(i[n]),n++;else if(a&&t[s]==="**"&&i[n]===t[s+1])o.push(t[s]),s++;else if(i[n]==="*"&&t[s]&&(this.options.dot||!t[s].startsWith("."))&&t[s]!=="**"){if(r==="b")return!1;r="a",o.push(i[n]),n++,s++}else if(t[s]==="*"&&i[n]&&(this.options.dot||!i[n].startsWith("."))&&i[n]!=="**"){if(r==="a")return!1;r="b",o.push(t[s]),n++,s++}else return!1;return i.length===t.length&&o}parseNegate(){if(this.nonegate)return;let i=this.pattern,t=!1,a=0;for(let n=0;n<i.length&&i.charAt(n)==="!";n++)t=!t,a++;a&&(this.pattern=i.slice(a)),this.negate=t}matchOne(i,t,a=!1){let n=this.options;if(this.isWindows){let x=typeof i[0]=="string"&&/^[a-z]:$/i.test(i[0]),h=!x&&i[0]===""&&i[1]===""&&i[2]==="?"&&/^[a-z]:$/i.test(i[3]),O=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),v=!O&&t[0]===""&&t[1]===""&&t[2]==="?"&&typeof t[3]=="string"&&/^[a-z]:$/i.test(t[3]),y=h?3:x?0:void 0,w=v?3:O?0:void 0;if(typeof y=="number"&&typeof w=="number"){let[_,U]=[i[y],t[w]];_.toLowerCase()===U.toLowerCase()&&(t[w]=_,w>y?t=t.slice(w):y>w&&(i=i.slice(y)))}}let{optimizationLevel:s=1}=this.options;s>=2&&(i=this.levelTwoFileOptimize(i)),this.debug("matchOne",this,{file:i,pattern:t}),this.debug("matchOne",i.length,t.length);for(var o=0,r=0,c=i.length,p=t.length;o<c&&r<p;o++,r++){this.debug("matchOne loop");var u=t[r],l=i[o];if(this.debug(t,u,l),u===!1)return!1;if(u===V){this.debug("GLOBSTAR",[t,u,l]);var m=o,d=r+1;if(d===p){for(this.debug("** at the end");o<c;o++)if(i[o]==="."||i[o]===".."||!n.dot&&i[o].charAt(0)===".")return!1;return!0}for(;m<c;){var f=i[m];if(this.debug(`