@junobuild/cli-tools 0.2.0-next-2025-06-12 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,7 +20,7 @@ var ph=Object.create;var Vo=Object.defineProperty;var uh=Object.getOwnPropertyDe
20
20
  `)},Ed=(t,e)=>{Oo(jd(t,e))},Eo=class{constructor(e,i){this._tasks=e,this._options=Object.assign({showSubtasks:!0,collapse:!0,clearOutput:!1},i)}render(){this._id||(this._id=setInterval(()=>{Ed(this._tasks,this._options)},100))}end(e){this._id&&(clearInterval(this._id),this._id=void 0),Ed(this._tasks,this._options),this._options.clearOutput&&e===void 0?Oo.clear():Oo.done()}};Td.exports=Eo});var jo=f(Pd=>{"use strict";var _n={silent:nl(),verbose:Uf(),default:Ad()},Cd=t=>process.stdout.isTTY===!0||t.nonTTY===!0,qd=t=>typeof t=="string"?_n[t]||_n.default:typeof t=="function"?t:_n.default;Pd.getRenderer=(t,e)=>{let i=qd(t);return Cd(i)||(i=qd(e),(!i||!Cd(i))&&(i=_n.verbose)),i}});var To=f((kT,Fd)=>{"use strict";var wt={PENDING:0,COMPLETED:1,FAILED:2,SKIPPED:3};wt.toString=t=>{switch(t){case wt.PENDING:return"pending";case wt.COMPLETED:return"completed";case wt.FAILED:return"failed";case wt.SKIPPED:return"skipped";default:return"unknown"}};Fd.exports=wt});var Id=f((OT,Md)=>{"use strict";var de=Md.exports=function(t){return t!==null&&typeof t=="object"&&typeof t.pipe=="function"};de.writable=function(t){return de(t)&&t.writable!==!1&&typeof t._write=="function"&&typeof t._writableState=="object"};de.readable=function(t){return de(t)&&t.readable!==!1&&typeof t._read=="function"&&typeof t._readableState=="object"};de.duplex=function(t){return de.writable(t)&&de.readable(t)};de.transform=function(t){return de.duplex(t)&&typeof t._transform=="function"&&typeof t._transformState=="object"}});var Dd=f(Ao=>{"use strict";Object.defineProperty(Ao,"__esModule",{value:!0});Ao.default=Tk;function Tk(t){var e,i=t.Symbol;return typeof i=="function"?i.observable?e=i.observable:(e=i("observable"),i.observable=e):e="@@observable",e}});var zd=f((qo,Co)=>{"use strict";Object.defineProperty(qo,"__esModule",{value:!0});var Ak=Dd(),Ck=qk(Ak);function qk(t){return t&&t.__esModule?t:{default:t}}var _t;typeof self<"u"?_t=self:typeof window<"u"?_t=window:typeof global<"u"?_t=global:typeof Co<"u"?_t=Co:_t=Function("return this")();var Pk=(0,Ck.default)(_t);qo.default=Pk});var Ld=f((jT,Nd)=>{"use strict";var Rd=zd().default;Nd.exports=t=>!!(t&&t[Rd]&&t===t[Rd]())});var $d=f(Sn=>{"use strict";var Fk=Id(),Ud=typeof Symbol=="function"&&Symbol.observable||"@@observable",Bd=t=>!!(t&&t[Ud]&&t===t[Ud]())||Ld()(t);Sn.isListr=t=>!!(t&&t.setRenderer&&t.add&&t.run);Sn.isObservable=t=>Bd(t);Sn.isStream=t=>Fk(t)&&!Bd(t)});var kn=f((AT,Yd)=>{"use strict";var Po=class extends Error{constructor(e){super(e),this.name="ListrError"}};Yd.exports=Po});var Wd=f((CT,Gd)=>{"use strict";var Mk=Mc(),Ik=Yc(),Dk=tl().Subject,zk=jo(),he=To(),Fo=$d(),Rk=kn(),Nk=()=>!1,Mo=class extends Dk{constructor(e,i,n){if(super(),!i)throw new TypeError("Expected a task");if(typeof i.title!="string")throw new TypeError(`Expected property \`title\` to be of type \`string\`, got \`${typeof i.title}\``);if(typeof i.task!="function")throw new TypeError(`Expected property \`task\` to be of type \`function\`, got \`${typeof i.task}\``);if(i.skip&&typeof i.skip!="function")throw new TypeError(`Expected property \`skip\` to be of type \`function\`, got \`${typeof i.skip}\``);if(i.enabled&&typeof i.enabled!="function")throw new TypeError(`Expected property \`enabled\` to be of type \`function\`, got \`${typeof i.enabled}\``);this._listr=e,this._options=n||{},this._subtasks=[],this._enabledFn=i.enabled,this._isEnabled=!0,this.output=void 0,this.title=i.title,this.skip=i.skip||Nk,this.task=i.task}get subtasks(){return this._subtasks}set state(e){this._state=e,this.next({type:"STATE"})}get state(){return he.toString(this._state)}check(e){if(this._state===void 0&&this._enabledFn){let i=this._enabledFn(e);this._isEnabled!==i&&(this._isEnabled=i,this.next({type:"ENABLED",data:i}))}}hasSubtasks(){return this._subtasks.length>0}isPending(){return this._state===he.PENDING}isSkipped(){return this._state===he.SKIPPED}isCompleted(){return this._state===he.COMPLETED}isEnabled(){return this._isEnabled}hasFailed(){return this._state===he.FAILED}run(e,i){let n=r=>Fo.isListr(r)?(r._options=Object.assign(this._options,r._options),r.exitOnError=r._options.exitOnError,r.setRenderer(zk.getRenderer("silent")),this._subtasks=r.tasks,this.next({type:"SUBTASKS"}),r.run(e)):(Fo.isStream(r)&&(r=Ik(r)),Fo.isObservable(r)&&(r=new Promise((a,o)=>{r.subscribe({next:s=>{this.output=s,this.next({type:"DATA",data:s})},error:o,complete:a})})),Mk(r)?r.then(n):r);return Promise.resolve().then(()=>(this.state=he.PENDING,this.skip(e))).then(r=>{if(r){typeof r=="string"&&(this.output=r),this.state=he.SKIPPED;return}return n(this.task(e,i))}).then(()=>{this.isPending()&&(this.state=he.COMPLETED)}).catch(r=>{if(this.state=he.FAILED,r instanceof Rk){i.report(r);return}if(this.hasSubtasks()||(this.output=r.message),this.next({type:"DATA",data:r.message}),i.report(r),this._listr.exitOnError!==!1)throw r}).then(()=>{this.complete()})}};Gd.exports=Mo});var Vd=f((qT,Hd)=>{"use strict";var Lk=To(),Uk=kn(),Io=class{constructor(e,i){this._task=e,this._errors=i}set title(e){this._task.title=e,this._task.next({type:"TITLE",data:e})}set output(e){this._task.output=e,this._task.next({type:"DATA",data:e})}get title(){return this._task.title}report(e){if(e instanceof Uk)for(let i of e.errors)this._errors.push(i);else this._errors.push(e)}skip(e){if(e&&typeof e!="string")throw new TypeError(`Expected \`message\` to be of type \`string\`, got \`${typeof e}\``);e&&(this._task.output=e),this._task.state=Lk.SKIPPED}run(e){return this._task.run(e,this)}};Hd.exports=Io});var Qd=f((PT,Jd)=>{"use strict";var Bk=Pc(),$k=Wd(),Yk=Vd(),Zd=jo(),Gk=kn(),Wk=(t,e,i)=>t.isEnabled()?new Yk(t,i).run(e):Promise.resolve(),Do=class{constructor(e,i){if(e&&!Array.isArray(e)&&typeof e=="object"){if(typeof e.title=="string"&&typeof e.task=="function")throw new TypeError("Expected an array of tasks or an options object, got a task object");i=e,e=[]}if(e&&!Array.isArray(e))throw new TypeError("Expected an array of tasks");this._options=Object.assign({showSubtasks:!0,concurrent:!1,renderer:"default",nonTTYRenderer:"verbose"},i),this._tasks=[],this.concurrency=1,this._options.concurrent===!0?this.concurrency=1/0:typeof this._options.concurrent=="number"&&(this.concurrency=this._options.concurrent),this._RendererClass=Zd.getRenderer(this._options.renderer,this._options.nonTTYRenderer),this.exitOnError=this._options.exitOnError,this.add(e||[])}_checkAll(e){for(let i of this._tasks)i.check(e)}get tasks(){return this._tasks}setRenderer(e){this._RendererClass=Zd.getRenderer(e)}add(e){let i=Array.isArray(e)?e:[e];for(let n of i)this._tasks.push(new $k(this,n,this._options));return this}render(){return this._renderer||(this._renderer=new this._RendererClass(this._tasks,this._options)),this._renderer.render()}run(e){this.render(),e=e||Object.create(null);let i=[];return this._checkAll(e),Bk(this._tasks,r=>(this._checkAll(e),Wk(r,e,i)),{concurrency:this.concurrency}).then(()=>{if(i.length>0){let r=new Gk("Something went wrong");throw r.errors=i,r}return this._renderer.end(),e}).catch(r=>{throw r.context=e,this._renderer.end(r),r})}};Jd.exports=Do});import{rm as hh}from"node:fs/promises";var u3=async({infile:t,outfile:e,banner:i})=>{await vh();let{build:n,version:r}=await import("esbuild");await hh(e,{force:!0});let{metafile:a,errors:o,warnings:s}=await n({entryPoints:[t],outfile:e,bundle:!0,minify:!0,treeShaking:!0,format:"esm",platform:"browser",write:!0,supported:{"top-level-await":!1,"inline-script":!1},define:{self:"globalThis"},metafile:!0,banner:i});return{metafile:a,errors:o,warnings:s,version:r}},vh=async()=>{try{await import("esbuild")}catch{console.error("Esbuild is required to build your functions. Please install it by running: npm i esbuild"),process.exit(1)}};import{toNullable as t3}from"@dfinity/utils";var Zo="build",Jo=[],Qo=[],gi="**/*.+(css|js|mjs|html)",Xo=[".ds_store","thumbs.db"],qn=20,Pn="#dapp",Ko="#_juno/releases";import{nonNullish as yi}from"@dfinity/utils";import{spawn as ns}from"child_process";import{nonNullish as xh}from"@dfinity/utils";import{stat as bh}from"node:fs/promises";import es from"node:path";import ts from"node:process";import{URL as gh}from"node:url";var Mn=async(t,e,i)=>await yh(t,i)?[Fn(t),e.map(n=>kh(n)),{...i,shell:!0}]:[t,e,i],yh=async(t,{shell:e,cwd:i,env:n=ts.env})=>ts.platform==="win32"&&!e&&!await wh(t,i,n),wh=async(t,e,{Path:i="",PATH:n=i})=>is.some(r=>t.toLowerCase().endsWith(r))||(_h[`${t}\0${e}\0${n}`]??=await Sh(t,e,n)),_h={},Sh=async(t,e,i)=>{let n=i.split(es.delimiter).filter(Boolean).map(r=>r.replace(/^"(.*)"$/,"$1"));try{await Promise.all(is.flatMap(r=>[e,...n].filter(xh).map(a=>`${es.resolve(a instanceof gh?a.toString():a,t)}${r}`)).map(async r=>{try{await bh(r)}catch{return}throw 0}))}catch{return!0}return!1},is=[".exe",".com"],kh=t=>Fn(Fn(`"${t.replaceAll(/(\\*)"/g,'$1$1\\"').replace(/(\\*)$/,"$1$1")}"`)),Fn=t=>t.replaceAll(/([()\][%!^"`<>&|;, *?])/g,"^$1");var _3=async({command:t,cwd:e,args:i,env:n,stdout:r,silentOut:a=!1,silentErrors:o=!1})=>await new Promise(async(s,c)=>{let[u,p,l]=await Mn(t,i??[],{shell:!0,...yi(e)&&{cwd:e},...yi(n)&&{env:n}}),m=ns(u,p,l);m.stdout.on("data",d=>{if(yi(r)){r(`${d}`);return}a||console.log(`${d}`)}),m.stderr.on("data",d=>{o||c(new Error(`${d}`))}),m.on("close",d=>{s(d)}),m.on("error",d=>{c(d)})}),rs=async({command:t,args:e,env:i})=>await new Promise(async n=>{let[r,a,o]=await Mn(t,e??[],{stdio:"inherit",...yi(i)&&{env:i}});ns(r,a??[],o).on("close",c=>{if(c===0){n(c);return}process.exit(1)})});var In=async t=>{for(let e of t??[]){let[i,...n]=e.split(" ");await rs({command:i,args:n})}};import{isNullish as jc,nonNullish as Gx}from"@dfinity/utils";import Wx from"crypto";import{ReadableStream as kv}from"node:stream/web";import{pipeline as Gs,PassThrough as Ov,Readable as Ev}from"node:stream";import{stat as Ah}from"node:fs/promises";var Oh="End-Of-Stream",k=class extends Error{constructor(){super(Oh),this.name="EndOfStreamError"}},xe=class extends Error{constructor(e="The operation was aborted"){super(e),this.name="AbortError"}};var wi=class{constructor(){this.resolve=()=>null,this.reject=()=>null,this.promise=new Promise((e,i)=>{this.reject=i,this.resolve=e})}};var be=class{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(e,i=!1){let n=await this.read(e,i);return this.peekQueue.push(e.subarray(0,n)),n}async read(e,i=!1){if(e.length===0)return 0;let n=this.readFromPeekBuffer(e);if(this.endOfStream||(n+=await this.readRemainderFromStream(e.subarray(n),i)),n===0)throw new k;return n}readFromPeekBuffer(e){let i=e.length,n=0;for(;this.peekQueue.length>0&&i>0;){let r=this.peekQueue.pop();if(!r)throw new Error("peekData should be defined");let a=Math.min(r.length,i);e.set(r.subarray(0,a),n),n+=a,i-=a,a<r.length&&this.peekQueue.push(r.subarray(a))}return n}async readRemainderFromStream(e,i){let n=0;for(;n<e.length&&!this.endOfStream;){if(this.interrupted)throw new xe;let r=await this.readFromStream(e.subarray(n),i);if(r===0)break;n+=r}if(!i&&n<e.length)throw new k;return n}};var Ot=class extends be{constructor(e){if(super(),this.s=e,this.deferred=null,!e.read||!e.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",i=>this.reject(i)),this.s.once("close",()=>this.abort())}async readFromStream(e,i){if(e.length===0)return 0;let n=this.s.read(e.length);if(n)return e.set(n),n.length;let r={buffer:e,mayBeLess:i,deferred:new wi};return this.deferred=r.deferred,this.s.once("readable",()=>{this.readDeferred(r)}),r.deferred.promise}readDeferred(e){let i=this.s.read(e.buffer.length);i?(e.buffer.set(i),e.deferred.resolve(i.length),this.deferred=null):this.s.once("readable",()=>{this.readDeferred(e)})}reject(e){this.interrupted=!0,this.deferred&&(this.deferred.reject(e),this.deferred=null)}async abort(){this.reject(new xe)}async close(){return this.abort()}};var _i=class extends be{constructor(e){super(),this.reader=e}async abort(){return this.close()}async close(){this.reader.releaseLock()}};var Et=class extends _i{async readFromStream(e,i){if(e.length===0)return 0;let n=await this.reader.read(new Uint8Array(e.length),{min:i?void 0:e.length});return n.done&&(this.endOfStream=n.done),n.value?(e.set(n.value),n.value.length):0}};var We=class extends be{constructor(e){super(),this.reader=e,this.buffer=null}writeChunk(e,i){let n=Math.min(i.length,e.length);return e.set(i.subarray(0,n)),n<i.length?this.buffer=i.subarray(n):this.buffer=null,n}async readFromStream(e,i){if(e.length===0)return 0;let n=0;for(this.buffer&&(n+=this.writeChunk(e,this.buffer));n<e.length&&!this.endOfStream;){let r=await this.reader.read();if(r.done){this.endOfStream=!0;break}r.value&&(n+=this.writeChunk(e.subarray(n),r.value))}if(n===0&&this.endOfStream)throw new k;return n}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}};function Dn(t){try{let e=t.getReader({mode:"byob"});return e instanceof ReadableStreamDefaultReader?new We(e):new Et(e)}catch(e){if(e instanceof TypeError)return new We(t.getReader());throw e}}var pe=class{constructor(e){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=e?.onClose,e?.abortSignal&&e.abortSignal.addEventListener("abort",()=>{this.abort()})}async readToken(e,i=this.position){let n=new Uint8Array(e.len);if(await this.readBuffer(n,{position:i})<e.len)throw new k;return e.get(n,0)}async peekToken(e,i=this.position){let n=new Uint8Array(e.len);if(await this.peekBuffer(n,{position:i})<e.len)throw new k;return e.get(n,0)}async readNumber(e){if(await this.readBuffer(this.numBuffer,{length:e.len})<e.len)throw new k;return e.get(this.numBuffer,0)}async peekNumber(e){if(await this.peekBuffer(this.numBuffer,{length:e.len})<e.len)throw new k;return e.get(this.numBuffer,0)}async ignore(e){if(this.fileInfo.size!==void 0){let i=this.fileInfo.size-this.position;if(e>i)return this.position+=i,i}return this.position+=e,e}async close(){await this.abort(),await this.onClose?.()}normalizeOptions(e,i){if(!this.supportsRandomAccess()&&i&&i.position!==void 0&&i.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return{mayBeLess:!1,offset:0,length:e.length,position:this.position,...i}}abort(){return Promise.resolve()}};var Eh=256e3,jt=class extends pe{constructor(e,i){super(i),this.streamReader=e,this.fileInfo=i?.fileInfo??{}}async readBuffer(e,i){let n=this.normalizeOptions(e,i),r=n.position-this.position;if(r>0)return await this.ignore(r),this.readBuffer(e,i);if(r<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(n.length===0)return 0;let a=await this.streamReader.read(e.subarray(0,n.length),n.mayBeLess);if(this.position+=a,(!i||!i.mayBeLess)&&a<n.length)throw new k;return a}async peekBuffer(e,i){let n=this.normalizeOptions(e,i),r=0;if(n.position){let a=n.position-this.position;if(a>0){let o=new Uint8Array(n.length+a);return r=await this.peekBuffer(o,{mayBeLess:n.mayBeLess}),e.set(o.subarray(a)),r-a}if(a<0)throw new Error("Cannot peek from a negative offset in a stream")}if(n.length>0){try{r=await this.streamReader.peek(e.subarray(0,n.length),n.mayBeLess)}catch(a){if(i?.mayBeLess&&a instanceof k)return 0;throw a}if(!n.mayBeLess&&r<n.length)throw new k}return r}async ignore(e){let i=Math.min(Eh,e),n=new Uint8Array(i),r=0;for(;r<e;){let a=e-r,o=await this.readBuffer(n,{length:Math.min(i,a)});if(o<0)return o;r+=o}return r}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}};var Si=class extends pe{constructor(e,i){super(i),this.uint8Array=e,this.fileInfo={...i?.fileInfo??{},size:e.length}}async readBuffer(e,i){i?.position&&(this.position=i.position);let n=await this.peekBuffer(e,i);return this.position+=n,n}async peekBuffer(e,i){let n=this.normalizeOptions(e,i),r=Math.min(this.uint8Array.length-n.position,n.length);if(!n.mayBeLess&&r<n.length)throw new k;return e.set(this.uint8Array.subarray(n.position,n.position+r)),r}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}};function as(t,e){let i=new Ot(t),n=e??{},r=n.onClose;return n.onClose=async()=>{if(await i.close(),r)return r()},new jt(i,n)}function ki(t,e){let i=Dn(t),n=e??{},r=n.onClose;return n.onClose=async()=>{if(await i.close(),r)return r()},new jt(i,n)}function os(t,e){return new Si(t,e)}import{open as Th}from"node:fs/promises";var Tt=class t extends pe{static async fromFile(e){let i=await Th(e,"r"),n=await i.stat();return new t(i,{fileInfo:{path:e,size:n.size}})}constructor(e,i){super(i),this.fileHandle=e,this.fileInfo=i.fileInfo}async readBuffer(e,i){let n=this.normalizeOptions(e,i);if(this.position=n.position,n.length===0)return 0;let r=await this.fileHandle.read(e,0,n.length,n.position);if(this.position+=r.bytesRead,r.bytesRead<n.length&&(!i||!i.mayBeLess))throw new k;return r.bytesRead}async peekBuffer(e,i){let n=this.normalizeOptions(e,i),r=await this.fileHandle.read(e,0,n.length,n.position);if(!n.mayBeLess&&r.bytesRead<n.length)throw new k;return r.bytesRead}async close(){return await this.fileHandle.close(),super.close()}setPosition(e){this.position=e}supportsRandomAccess(){return!0}};async function ss(t,e){let i=as(t,e);if(t.path){let n=await Ah(t.path);i.fileInfo.path=t.path,i.fileInfo.size=n.size}return i}var cs=Tt.fromFile;var us=bi(ps(),1);function B(t){return new DataView(t.buffer,t.byteOffset)}var ls={len:1,get(t,e){return B(t).getUint8(e)},put(t,e,i){return B(t).setUint8(e,i),e+1}},T={len:2,get(t,e){return B(t).getUint16(e,!0)},put(t,e,i){return B(t).setUint16(e,i,!0),e+2}},He={len:2,get(t,e){return B(t).getUint16(e)},put(t,e,i){return B(t).setUint16(e,i),e+2}};var C={len:4,get(t,e){return B(t).getUint32(e,!0)},put(t,e,i){return B(t).setUint32(e,i,!0),e+4}},fs={len:4,get(t,e){return B(t).getUint32(e)},put(t,e,i){return B(t).setUint32(e,i),e+4}};var ms={len:4,get(t,e){return B(t).getInt32(e)},put(t,e,i){return B(t).setInt32(e,i),e+4}};var ds={len:8,get(t,e){return B(t).getBigUint64(e,!0)},put(t,e,i){return B(t).setBigUint64(e,i,!0),e+8}};var $=class{constructor(e,i){this.len=e,this.encoding=i,this.textDecoder=new TextDecoder(i)}get(e,i){return this.textDecoder.decode(e.subarray(i,i+this.len))}};import{createRequire as Ph}from"module";var Fh=Ph("/"),Mh;try{Mh=Fh("worker_threads").Worker}catch{}var H=Uint8Array,Ve=Uint16Array,Ih=Int32Array,hs=new H([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),vs=new H([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Dh=new H([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),xs=function(t,e){for(var i=new Ve(31),n=0;n<31;++n)i[n]=e+=1<<t[n-1];for(var r=new Ih(i[30]),n=1;n<30;++n)for(var a=i[n];a<i[n+1];++a)r[a]=a-i[n]<<5|n;return{b:i,r}},bs=xs(hs,2),gs=bs.b,zh=bs.r;gs[28]=258,zh[258]=28;var ys=xs(vs,0),Rh=ys.b,yO=ys.r,Ln=new Ve(32768);for(_=0;_<32768;++_)ue=(_&43690)>>1|(_&21845)<<1,ue=(ue&52428)>>2|(ue&13107)<<2,ue=(ue&61680)>>4|(ue&3855)<<4,Ln[_]=((ue&65280)>>8|(ue&255)<<8)>>1;var ue,_,At=function(t,e,i){for(var n=t.length,r=0,a=new Ve(e);r<n;++r)t[r]&&++a[t[r]-1];var o=new Ve(e);for(r=1;r<e;++r)o[r]=o[r-1]+a[r-1]<<1;var s;if(i){s=new Ve(1<<e);var c=15-e;for(r=0;r<n;++r)if(t[r])for(var u=r<<4|t[r],p=e-t[r],l=o[t[r]-1]++<<p,m=l|(1<<p)-1;l<=m;++l)s[Ln[l]>>c]=u}else for(s=new Ve(n),r=0;r<n;++r)t[r]&&(s[r]=Ln[o[t[r]-1]++]>>15-t[r]);return s},Ct=new H(288);for(_=0;_<144;++_)Ct[_]=8;var _;for(_=144;_<256;++_)Ct[_]=9;var _;for(_=256;_<280;++_)Ct[_]=7;var _;for(_=280;_<288;++_)Ct[_]=8;var _,ws=new H(32);for(_=0;_<32;++_)ws[_]=5;var _;var Nh=At(Ct,9,1);var Lh=At(ws,5,1),Rn=function(t){for(var e=t[0],i=1;i<t.length;++i)t[i]>e&&(e=t[i]);return e},ee=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]<<8)>>(e&7)&i},Nn=function(t,e){var i=e/8|0;return(t[i]|t[i+1]<<8|t[i+2]<<16)>>(e&7)},Uh=function(t){return(t+7)/8|0},Bh=function(t,e,i){return(e==null||e<0)&&(e=0),(i==null||i>t.length)&&(i=t.length),new H(t.subarray(e,i))};var $h=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],W=function(t,e,i){var n=new Error(e||$h[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,W),!i)throw n;return n},Un=function(t,e,i,n){var r=t.length,a=n?n.length:0;if(!r||e.f&&!e.l)return i||new H(0);var o=!i,s=o||e.i!=2,c=e.i;o&&(i=new H(r*3));var u=function(Go){var Wo=i.length;if(Go>Wo){var Ho=new H(Math.max(Wo*2,Go));Ho.set(i),i=Ho}},p=e.f||0,l=e.p||0,m=e.b||0,d=e.l,v=e.d,h=e.m,g=e.n,O=r*8;do{if(!d){p=ee(t,l,1);var U=ee(t,l+1,3);if(l+=3,U)if(U==1)d=Nh,v=Lh,h=9,g=5;else if(U==2){var V=ee(t,l,31)+257,vi=ee(t,l+10,15)+4,St=V+ee(t,l+5,31)+1;l+=14;for(var je=new H(St),jn=new H(19),Z=0;Z<vi;++Z)jn[Dh[Z]]=ee(t,l+Z*3,7);l+=vi*3;for(var No=Rn(jn),rh=(1<<No)-1,ah=At(jn,No,1),Z=0;Z<St;){var Lo=ah[ee(t,l,rh)];l+=Lo&15;var E=Lo>>4;if(E<16)je[Z++]=E;else{var Ye=0,xi=0;for(E==16?(xi=3+ee(t,l,3),l+=2,Ye=je[Z-1]):E==17?(xi=3+ee(t,l,7),l+=3):E==18&&(xi=11+ee(t,l,127),l+=7);xi--;)je[Z++]=Ye}}var Uo=je.subarray(0,V),ve=je.subarray(V);h=Rn(Uo),g=Rn(ve),d=At(Uo,h,1),v=At(ve,g,1)}else W(1);else{var E=Uh(l)+4,j=t[E-4]|t[E-3]<<8,re=E+j;if(re>r){c&&W(0);break}s&&u(m+j),i.set(t.subarray(E,re),m),e.b=m+=j,e.p=l=re*8,e.f=p;continue}if(l>O){c&&W(0);break}}s&&u(m+131072);for(var oh=(1<<h)-1,sh=(1<<g)-1,Tn=l;;Tn=l){var Ye=d[Nn(t,l)&oh],Ge=Ye>>4;if(l+=Ye&15,l>O){c&&W(0);break}if(Ye||W(2),Ge<256)i[m++]=Ge;else if(Ge==256){Tn=l,d=null;break}else{var Bo=Ge-254;if(Ge>264){var Z=Ge-257,kt=hs[Z];Bo=ee(t,l,(1<<kt)-1)+gs[Z],l+=kt}var An=v[Nn(t,l)&sh],Cn=An>>4;An||W(3),l+=An&15;var ve=Rh[Cn];if(Cn>3){var kt=vs[Cn];ve+=Nn(t,l)&(1<<kt)-1,l+=kt}if(l>O){c&&W(0);break}s&&u(m+131072);var $o=m+Bo;if(m<ve){var Yo=a-ve,ch=Math.min(ve,$o);for(Yo+m<0&&W(3);m<ch;++m)i[m]=n[Yo+m]}for(;m<$o;++m)i[m]=i[m-ve]}}e.l=d,e.p=Tn,e.b=m,e.f=p,d&&(p=1,e.m=h,e.d=v,e.n=g)}while(!p);return m!=i.length&&o?Bh(i,0,m):i.subarray(0,m)};var Yh=new H(0);var Gh=function(t){(t[0]!=31||t[1]!=139||t[2]!=8)&&W(6,"invalid gzip data");var e=t[3],i=10;e&4&&(i+=(t[10]|t[11]<<8)+2);for(var n=(e>>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(e&2)},Wh=function(t){var e=t.length;return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0};var Hh=function(t,e){return((t[0]&15)!=8||t[0]>>4>7||(t[0]<<8|t[1])%31)&&W(6,"invalid zlib data"),(t[1]>>5&1)==+!e&&W(6,"invalid zlib data: "+(t[1]&32?"need":"unexpected")+" dictionary"),(t[1]>>3&4)+2};function Vh(t,e){return Un(t,{i:2},e&&e.out,e&&e.dictionary)}function Zh(t,e){var i=Gh(t);return i+8>t.length&&W(6,"invalid gzip data"),Un(t.subarray(i,-8),{i:2},e&&e.out||new H(Wh(t)),e&&e.dictionary)}function Jh(t,e){return Un(t.subarray(Hh(t,e&&e.dictionary),-4),{i:2},e&&e.out,e&&e.dictionary)}function _s(t,e){return t[0]==31&&t[1]==139&&t[2]==8?Zh(t,e):(t[0]&15)!=8||t[0]>>4>7||(t[0]<<8|t[1])%31?Vh(t,e):Jh(t,e)}var Qh=typeof TextDecoder<"u"&&new TextDecoder,Xh=0;try{Qh.decode(Yh,{stream:!0}),Xh=1}catch{}var Rs=bi(Ms(),1);var Ae={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},Wn={get(t){let e=T.get(t,6);return{signature:C.get(t,0),compressedSize:C.get(t,8),uncompressedSize:C.get(t,12)}},len:16},Is={get(t){let e=T.get(t,6);return{signature:C.get(t,0),minVersion:T.get(t,4),dataDescriptor:!!(e&8),compressedMethod:T.get(t,8),compressedSize:C.get(t,18),uncompressedSize:C.get(t,22),filenameLength:T.get(t,26),extraFieldLength:T.get(t,28),filename:null}},len:30},Ds={get(t){return{signature:C.get(t,0),nrOfThisDisk:T.get(t,4),nrOfThisDiskWithTheStart:T.get(t,6),nrOfEntriesOnThisDisk:T.get(t,8),nrOfEntriesOfSize:T.get(t,10),sizeOfCd:C.get(t,12),offsetOfStartOfCd:C.get(t,16),zipFileCommentLength:T.get(t,20)}},len:22},zs={get(t){let e=T.get(t,8);return{signature:C.get(t,0),minVersion:T.get(t,6),dataDescriptor:!!(e&8),compressedMethod:T.get(t,10),compressedSize:C.get(t,20),uncompressedSize:C.get(t,24),filenameLength:T.get(t,28),extraFieldLength:T.get(t,30),fileCommentLength:T.get(t,32),relativeOffsetOfLocalHeader:C.get(t,42),filename:null}},len:46};function Ns(t){let e=new Uint8Array(C.len);return C.put(e,0,t),e}var oe=(0,Rs.default)("tokenizer:inflate"),Hn=256*1024,wv=Ns(Ae.DataDescriptor),Ai=Ns(Ae.EndOfCentralDirectory),Ci=class{constructor(e){this.tokenizer=e,this.syncBuffer=new Uint8Array(Hn)}async isZip(){return await this.peekSignature()===Ae.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(C)}async findEndOfCentralDirectoryLocator(){let e=this.tokenizer,i=Math.min(16*1024,e.fileInfo.size),n=this.syncBuffer.subarray(0,i);await this.tokenizer.readBuffer(n,{position:e.fileInfo.size-i});for(let r=n.length-4;r>=0;r--)if(n[r]===Ai[0]&&n[r+1]===Ai[1]&&n[r+2]===Ai[2]&&n[r+3]===Ai[3])return e.fileInfo.size-i+r;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){oe("Cannot reading central-directory without random-read support");return}oe("Reading central-directory...");let e=this.tokenizer.position,i=await this.findEndOfCentralDirectoryLocator();if(i>0){oe("Central-directory 32-bit signature found");let n=await this.tokenizer.readToken(Ds,i),r=[];this.tokenizer.setPosition(n.offsetOfStartOfCd);for(let a=0;a<n.nrOfEntriesOfSize;++a){let o=await this.tokenizer.readToken(zs);if(o.signature!==Ae.CentralFileHeader)throw new Error("Expected Central-File-Header signature");o.filename=await this.tokenizer.readToken(new $(o.filenameLength,"utf-8")),await this.tokenizer.ignore(o.extraFieldLength),await this.tokenizer.ignore(o.fileCommentLength),r.push(o),oe(`Add central-directory file-entry: n=${a+1}/${r.length}: filename=${r[a].filename}`)}return this.tokenizer.setPosition(e),r}this.tokenizer.setPosition(e)}async unzip(e){let i=await this.readCentralDirectory();if(i)return this.iterateOverCentralDirectory(i,e);let n=!1;do{let r=await this.readLocalFileHeader();if(!r)break;let a=e(r);n=!!a.stop;let o;if(await this.tokenizer.ignore(r.extraFieldLength),r.dataDescriptor&&r.compressedSize===0){let s=[],c=Hn;oe("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let u=-1;for(;u<0&&c===Hn;){c=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),u=_v(this.syncBuffer.subarray(0,c),wv);let p=u>=0?u:c;if(a.handler){let l=new Uint8Array(p);await this.tokenizer.readBuffer(l),s.push(l)}else await this.tokenizer.ignore(p)}oe(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),a.handler&&await this.inflate(r,Sv(s),a.handler)}else a.handler?(oe(`Reading compressed-file-data: ${r.compressedSize} bytes`),o=new Uint8Array(r.compressedSize),await this.tokenizer.readBuffer(o),await this.inflate(r,o,a.handler)):(oe(`Ignoring compressed-file-data: ${r.compressedSize} bytes`),await this.tokenizer.ignore(r.compressedSize));if(oe(`Reading data-descriptor at pos=${this.tokenizer.position}`),r.dataDescriptor&&(await this.tokenizer.readToken(Wn)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-Wn.len}`)}while(!n)}async iterateOverCentralDirectory(e,i){for(let n of e){let r=i(n);if(r.handler){this.tokenizer.setPosition(n.relativeOffsetOfLocalHeader);let a=await this.readLocalFileHeader();if(a){await this.tokenizer.ignore(a.extraFieldLength);let o=new Uint8Array(n.compressedSize);await this.tokenizer.readBuffer(o),await this.inflate(a,o,r.handler)}}if(r.stop)break}}inflate(e,i,n){if(e.compressedMethod===0)return n(i);oe(`Decompress filename=${e.filename}, compressed-size=${i.length}`);let r=_s(i);return n(r)}async readLocalFileHeader(){let e=await this.tokenizer.peekToken(C);if(e===Ae.LocalFileHeader){let i=await this.tokenizer.readToken(Is);return i.filename=await this.tokenizer.readToken(new $(i.filenameLength,"utf-8")),i}if(e===Ae.CentralFileHeader)return!1;throw e===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}};function _v(t,e){let i=t.length,n=e.length;if(n>i)return-1;for(let r=0;r<=i-n;r++){let a=!0;for(let o=0;o<n;o++)if(t[r+o]!==e[o]){a=!1;break}if(a)return r}return-1}function Sv(t){let e=t.reduce((r,a)=>r+a.length,0),i=new Uint8Array(e),n=0;for(let r of t)i.set(r,n),n+=r.length;return i}var FO={utf8:new globalThis.TextDecoder("utf8")};var MO=new globalThis.TextEncoder;var IO=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Vn(t){let{byteLength:e}=t;if(e===6)return t.getUint16(0)*2**32+t.getUint32(2);if(e===5)return t.getUint8(0)*2**32+t.getUint32(1);if(e===4)return t.getUint32(0);if(e===3)return t.getUint8(0)*2**16+t.getUint16(1);if(e===2)return t.getUint16(0);if(e===1)return t.getUint8(0)}function Ls(t){return[...t].map(e=>e.charCodeAt(0))}function Us(t,e=0){let i=Number.parseInt(new $(6).get(t,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(i))return!1;let n=8*32;for(let r=e;r<e+148;r++)n+=t[r];for(let r=e+156;r<e+512;r++)n+=t[r];return i===n}var Bs={get:(t,e)=>t[e+3]&127|t[e+2]<<7|t[e+1]<<14|t[e]<<21,len:4};var $s=["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"],Ys=["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"];var qt=4100;function Zn(t){switch(t=t.toLowerCase(),t){case"application/epub+zip":return{ext:"epub",mime:t};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:t};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:t};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:t};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:t};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:t};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:t};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:t};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:t};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:t};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:t};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:t};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:t};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:t};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:t};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:t};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 se(t,e,i){i={offset:0,...i};for(let[n,r]of e.entries())if(i.mask){if(r!==(i.mask[n]&t[n+i.offset]))return!1}else if(r!==t[n+i.offset])return!1;return!0}var qi=class{constructor(e){this.options={mpegOffsetTolerance:0,...e},this.detectors=[...e?.customDetectors??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:e?.signal}}async fromTokenizer(e){let i=e.position;for(let n of this.detectors){let r=await n.detect(e);if(r)return r;if(i!==e.position)return}}async fromBuffer(e){if(!(e instanceof Uint8Array||e instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``);let i=e instanceof Uint8Array?e:new Uint8Array(e);if(i?.length>1)return this.fromTokenizer(os(i,this.tokenizerOptions))}async fromBlob(e){return this.fromStream(e.stream())}async fromStream(e){let i=await ki(e,this.tokenizerOptions);try{return await this.fromTokenizer(i)}finally{await i.close()}}async toDetectionStream(e,i){let{sampleSize:n=qt}=i,r,a,o=e.getReader({mode:"byob"});try{let{value:u,done:p}=await o.read(new Uint8Array(n));if(a=u,!p&&u)try{r=await this.fromBuffer(u.subarray(0,n))}catch(l){if(!(l instanceof k))throw l;r=void 0}a=u}finally{o.releaseLock()}let s=new TransformStream({async start(u){u.enqueue(a)},transform(u,p){p.enqueue(u)}}),c=e.pipeThrough(s);return c.fileType=r,c}check(e,i){return se(this.buffer,e,i)}checkString(e,i){return this.check(Ls(e),i)}detectConfident=async e=>{if(this.buffer=new Uint8Array(qt),e.fileInfo.size===void 0&&(e.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=e,await e.peekBuffer(this.buffer,{length:12,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await e.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};if(this.check([239,187,191]))return this.tokenizer.ignore(3),this.detectConfident(e);if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8]))return{ext:"gz",mime:"application/gzip"};if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await e.ignore(6);let i=await e.readToken(Bs);return e.position+i>e.fileInfo.size?{ext:"mp3",mime:"audio/mpeg"}:(await e.ignore(i),this.fromTokenizer(e))}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 i;return await new Ci(e).unzip(n=>{switch(n.filename){case"META-INF/mozilla.rsa":return i={ext:"xpi",mime:"application/x-xpinstall"},{stop:!0};case"META-INF/MANIFEST.MF":return i={ext:"jar",mime:"application/java-archive"},{stop:!0};case"mimetype":return{async handler(r){let a=new TextDecoder("utf-8").decode(r).trim();i=Zn(a)},stop:!0};case"[Content_Types].xml":return{async handler(r){let a=new TextDecoder("utf-8").decode(r),o=a.indexOf('.main+xml"');if(o===-1){let s="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";a.includes(`ContentType="${s}"`)&&(i=Zn(s))}else{a=a.slice(0,Math.max(0,o));let s=a.lastIndexOf('"'),c=a.slice(Math.max(0,s+1));i=Zn(c)}},stop:!0};default:return/classes\d*\.dex/.test(n.filename)?(i={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}}),i??{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await e.ignore(28);let i=new Uint8Array(8);return await e.readBuffer(i),se(i,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:se(i,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:se(i,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:se(i,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:se(i,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:se(i,[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 i=await this.readTiffHeader(!1);if(i)return i}if(this.check([77,77])){let i=await this.readTiffHeader(!0);if(i)return i}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function i(){let s=await e.peekNumber(ls),c=128,u=0;for(;(s&c)===0&&c!==0;)++u,c>>=1;let p=new Uint8Array(u+1);return await e.readBuffer(p),p}async function n(){let s=await i(),c=await i();c[0]^=128>>c.length-1;let u=Math.min(6,c.length),p=new DataView(s.buffer),l=new DataView(c.buffer,c.length-u,u);return{id:Vn(p),len:Vn(l)}}async function r(s){for(;s>0;){let c=await n();if(c.id===17026)return(await e.readToken(new $(c.len))).replaceAll(/\00.*$/g,"");await e.ignore(c.len),--s}}let a=await n();switch(await r(a.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.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 i=new $(4,"latin1").get(this.buffer,2);if(i.match("^d*")&&i>=1e3&&i<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>"))return await e.ignore(8),await e.readToken(new $(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("WEBVTT")&&[`
21
21
  `,"\r"," "," ","\0"].some(i=>this.checkString(i,{offset:6})))return{ext:"vtt",mime:"text/vtt"};if(this.check([137,80,78,71,13,10,26,10])){await e.ignore(8);async function i(){return{length:await e.readToken(ms),type:await e.readToken(new $(4,"latin1"))}}do{let n=await i();if(n.length<0)return;switch(n.type){case"IDAT":return{ext:"png",mime:"image/png"};case"acTL":return{ext:"apng",mime:"image/apng"};default:await e.ignore(n.length+4)}}while(e.position+8<e.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 i=new $(4,"latin1").get(this.buffer,8).replace("\0"," ").trim();switch(i){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 i.startsWith("3g")?i.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}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 i(){let n=new Uint8Array(16);return await e.readBuffer(n),{id:n,size:Number(await e.readToken(ds))}}for(await e.ignore(30);e.position+24<e.fileInfo.size;){let n=await i(),r=n.size-24;if(se(n.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){let a=new Uint8Array(16);if(r-=await e.readBuffer(a),se(a,[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(se(a,[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 e.ignore(r)}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 e.ignore(20),await e.readToken(new $(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.check([0,60,0,63,0,120,0,109,0,108],{offset:2})?{ext:"xml",mime:"application/xml"}:void 0;if(this.check([208,207,17,224,161,177,26,225]))return{ext:"cfb",mime:"application/x-cfb"};if(await e.peekBuffer(this.buffer,{length:Math.min(256,e.fileInfo.size),mayBeLess:!0}),this.check([97,99,115,112],{offset:36}))return{ext:"icc",mime:"application/vnd.iccprofile"};if(this.checkString("**ACE",{offset:7})&&this.checkString("**",{offset:12}))return{ext:"ace",mime:"application/x-ace-compressed"};if(this.checkString("BEGIN:")){if(this.checkString("VCARD",{offset:6}))return{ext:"vcf",mime:"text/vcard"};if(this.checkString("VCALENDAR",{offset:6}))return{ext:"ics",mime:"text/calendar"}}if(this.checkString("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(this.checkString("Extended Module:"))return{ext:"xm",mime:"audio/x-xm"};if(this.checkString("Creative Voice File"))return{ext:"voc",mime:"audio/x-voc"};if(this.check([4,0,0,0])&&this.buffer.length>=16){let i=new DataView(this.buffer.buffer).getUint32(12,!0);if(i>12&&this.buffer.length>=i+16)try{let n=new TextDecoder().decode(this.buffer.subarray(16,i+16));if(JSON.parse(n).files)return{ext:"asar",mime:"application/x-asar"}}catch{}}if(this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2]))return{ext:"mxf",mime:"application/mxf"};if(this.checkString("SCRM",{offset:44}))return{ext:"s3m",mime:"audio/x-s3m"};if(this.check([71])&&this.check([71],{offset:188}))return{ext:"mts",mime:"video/mp2t"};if(this.check([71],{offset:4})&&this.check([71],{offset:196}))return{ext:"mts",mime:"video/mp2t"};if(this.check([66,79,79,75,77,79,66,73],{offset:60}))return{ext:"mobi",mime:"application/x-mobipocket-ebook"};if(this.check([68,73,67,77],{offset:128}))return{ext:"dcm",mime:"application/dicom"};if(this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70]))return{ext:"lnk",mime:"application/x.ms.shortcut"};if(this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0]))return{ext:"alias",mime:"application/x.apple.alias"};if(this.checkString("Kaydara FBX Binary \0"))return{ext:"fbx",mime:"application/x.autodesk.fbx"};if(this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8})))return{ext:"eot",mime:"application/vnd.ms-fontobject"};if(this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29]))return{ext:"indd",mime:"application/x-indesign"};if(await e.peekBuffer(this.buffer,{length:Math.min(512,e.fileInfo.size),mayBeLess:!0}),this.checkString("ustar",{offset:257})&&(this.checkString("\0",{offset:262})||this.checkString(" ",{offset:262}))||this.check([0,0,0,0,0,0],{offset:257})&&Us(this.buffer))return{ext:"tar",mime:"application/x-tar"};if(this.check([255,254]))return this.check([60,0,63,0,120,0,109,0,108,0],{offset:2})?{ext:"xml",mime:"application/xml"}:this.check([255,14,83,0,107,0,101,0,116,0,99,0,104,0,85,0,112,0,32,0,77,0,111,0,100,0,101,0,108,0],{offset:2})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:void 0;if(this.checkString("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"}};detectImprecise=async e=>{if(this.buffer=new Uint8Array(qt),await e.peekBuffer(this.buffer,{length:Math.min(8,e.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 e.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,e.fileInfo.size),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let i=0;i<=this.options.mpegOffsetTolerance;++i){let n=this.scanMpeg(i);if(n)return n}};async readTiffTag(e){let i=await this.tokenizer.readToken(e?He:T);switch(this.tokenizer.ignore(10),i){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"};default:}}async readTiffIFD(e){let i=await this.tokenizer.readToken(e?He:T);for(let n=0;n<i;++n){let r=await this.readTiffTag(e);if(r)return r}}async readTiffHeader(e){let i=(e?He:T).get(this.buffer,2),n=(e?fs:C).get(this.buffer,4);if(i===42){if(n>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(n>=8){let a=(e?He:T).get(this.buffer,8),o=(e?He:T).get(this.buffer,10);if(a===28&&o===254||a===31&&o===11)return{ext:"nef",mime:"image/x-nikon-nef"}}}return await this.tokenizer.ignore(n),await this.readTiffIFD(e)??{ext:"tif",mime:"image/tiff"}}if(i===43)return{ext:"tif",mime:"image/tiff"}}scanMpeg(e){if(this.check([255,224],{offset:e,mask:[255,224]})){if(this.check([16],{offset:e+1,mask:[22]}))return this.check([8],{offset:e+1,mask:[8]})?{ext:"aac",mime:"audio/aac"}:{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:e+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:e+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:e+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}},YO=new Set($s),GO=new Set(Ys);var Jn=class extends qi{async fromStream(e){let i=await(e instanceof kv?ki(e,this.tokenizerOptions):ss(e,this.tokenizerOptions));try{return await super.fromTokenizer(i)}finally{await i.close()}}async fromFile(e){let i=await cs(e);try{return await super.fromTokenizer(i)}finally{await i.close()}}async toDetectionStream(e,i={}){if(!(e instanceof Ev))return super.toDetectionStream(e,i);let{sampleSize:n=qt}=i;return new Promise((r,a)=>{e.on("error",a),e.once("readable",()=>{(async()=>{try{let o=new Ov,s=Gs?Gs(e,o,()=>{}):e.pipe(o),c=e.read(n)??e.read()??new Uint8Array(0);try{o.fileType=await this.fromBuffer(c)}catch(u){u instanceof k?o.fileType=void 0:a(u)}r(s)}catch(o){a(o)}})()})})}};async function Ws(t,e){return new Jn(e).fromFile(t,e)}var Tc=bi(rc(),1);function Pi(t,e,i){t instanceof RegExp&&(t=ac(t,i)),e instanceof RegExp&&(e=ac(e,i));let n=Iv(t,e,i);return n&&{start:n[0],end:n[1],pre:i.slice(0,n[0]),body:i.slice(n[0]+t.length,n[1]),post:i.slice(n[1]+e.length)}}function ac(t,e){let i=e.match(t);return i?i[0]:null}function Iv(t,e,i){let n,r,a,o,s,c=i.indexOf(t),u=i.indexOf(e,c+1),p=c;if(c>=0&&u>0){if(t===e)return[c,u];for(n=[],a=i.length;p>=0&&!s;)p===c?(n.push(p),c=i.indexOf(t,p+1)):n.length===1?s=[n.pop(),u]:(r=n.pop(),r<a&&(a=r,o=u),u=i.indexOf(e,p+1)),p=c<u&&c>=0?c:u;n.length&&(s=[a,o])}return s}var oc="\0SLASH"+Math.random()+"\0",sc="\0OPEN"+Math.random()+"\0",Kn="\0CLOSE"+Math.random()+"\0",cc="\0COMMA"+Math.random()+"\0",pc="\0PERIOD"+Math.random()+"\0",Dv=new RegExp(oc,"g"),zv=new RegExp(sc,"g"),Rv=new RegExp(Kn,"g"),Nv=new RegExp(cc,"g"),Lv=new RegExp(pc,"g"),Uv=/\\\\/g,Bv=/\\{/g,$v=/\\}/g,Yv=/\\,/g,Gv=/\\./g;function Xn(t){return isNaN(t)?t.charCodeAt(0):parseInt(t,10)}function Wv(t){return t.replace(Uv,oc).replace(Bv,sc).replace($v,Kn).replace(Yv,cc).replace(Gv,pc)}function Hv(t){return t.replace(Dv,"\\").replace(zv,"{").replace(Rv,"}").replace(Nv,",").replace(Lv,".")}function uc(t){if(!t)return[""];let e=[],i=Pi("{","}",t);if(!i)return t.split(",");let{pre:n,body:r,post:a}=i,o=n.split(",");o[o.length-1]+="{"+r+"}";let s=uc(a);return a.length&&(o[o.length-1]+=s.shift(),o.push.apply(o,s)),e.push.apply(e,o),e}function er(t){return t?(t.slice(0,2)==="{}"&&(t="\\{\\}"+t.slice(2)),Pt(Wv(t),!0).map(Hv)):[]}function Vv(t){return"{"+t+"}"}function Zv(t){return/^-?0\d/.test(t)}function Jv(t,e){return t<=e}function Qv(t,e){return t>=e}function Pt(t,e){let i=[],n=Pi("{","}",t);if(!n)return[t];let r=n.pre,a=n.post.length?Pt(n.post,!1):[""];if(/\$$/.test(n.pre))for(let o=0;o<a.length;o++){let s=r+"{"+n.body+"}"+a[o];i.push(s)}else{let o=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body),s=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body),c=o||s,u=n.body.indexOf(",")>=0;if(!c&&!u)return n.post.match(/,(?!,).*\}/)?(t=n.pre+"{"+n.body+Kn+n.post,Pt(t)):[t];let p;if(c)p=n.body.split(/\.\./);else if(p=uc(n.body),p.length===1&&(p=Pt(p[0],!1).map(Vv),p.length===1))return a.map(function(m){return n.pre+p[0]+m});let l;if(c){let m=Xn(p[0]),d=Xn(p[1]),v=Math.max(p[0].length,p[1].length),h=p.length===3?Math.abs(Xn(p[2])):1,g=Jv;d<m&&(h*=-1,g=Qv);let U=p.some(Zv);l=[];for(let E=m;g(E,d);E+=h){let j;if(s)j=String.fromCharCode(E),j==="\\"&&(j="");else if(j=String(E),U){let re=v-j.length;if(re>0){let V=new Array(re+1).join("0");E<0?j="-"+V+j.slice(1):j=V+j}}l.push(j)}}else{l=[];for(let m=0;m<p.length;m++)l.push.apply(l,Pt(p[m],!1))}for(let m=0;m<l.length;m++)for(let d=0;d<a.length;d++){let v=r+l[m]+a[d];(!e||c||v)&&i.push(v)}}return i}var Ft=t=>{if(typeof t!="string")throw new TypeError("invalid pattern");if(t.length>65536)throw new TypeError("pattern is too long")};var Xv={"[: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]},Mt=t=>t.replace(/[[\]\\-]/g,"\\$&"),Kv=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),lc=t=>t.join(""),fc=(t,e)=>{let i=e;if(t.charAt(i)!=="[")throw new Error("not in a brace expression");let n=[],r=[],a=i+1,o=!1,s=!1,c=!1,u=!1,p=i,l="";e:for(;a<t.length;){let h=t.charAt(a);if((h==="!"||h==="^")&&a===i+1){u=!0,a++;continue}if(h==="]"&&o&&!c){p=a+1;break}if(o=!0,h==="\\"&&!c){c=!0,a++;continue}if(h==="["&&!c){for(let[g,[O,U,E]]of Object.entries(Xv))if(t.startsWith(g,a)){if(l)return["$.",!1,t.length-i,!0];a+=g.length,E?r.push(O):n.push(O),s=s||U;continue e}}if(c=!1,l){h>l?n.push(Mt(l)+"-"+Mt(h)):h===l&&n.push(Mt(h)),l="",a++;continue}if(t.startsWith("-]",a+1)){n.push(Mt(h+"-")),a+=2;continue}if(t.startsWith("-",a+1)){l=h,a+=2;continue}n.push(Mt(h)),a++}if(p<a)return["",!1,0,!1];if(!n.length&&!r.length)return["$.",!1,t.length-i,!0];if(r.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!u){let h=n[0].length===2?n[0].slice(-1):n[0];return[Kv(h),!1,p-i,!1]}let m="["+(u?"^":"")+lc(n)+"]",d="["+(u?"":"^")+lc(r)+"]";return[n.length&&r.length?"("+m+"|"+d+")":n.length?m:d,s,p-i,!0]};var ye=(t,{windowsPathsNoEscape:e=!1}={})=>e?t.replace(/\[([^\/\\])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1");var ex=new Set(["!","?","+","*","@"]),mc=t=>ex.has(t),tx="(?!(?:^|/)\\.\\.?(?:$|/))",Fi="(?!\\.)",ix=new Set(["[","."]),nx=new Set(["..","."]),rx=new Set("().*{}+?[]^$\\!"),ax=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),tr="[^/]",dc=tr+"*?",hc=tr+"+?",Xe=class t{type;#i;#n;#a=!1;#e=[];#t;#o;#c;#s=!1;#r;#p;#l=!1;constructor(e,i,n={}){this.type=e,e&&(this.#n=!0),this.#t=i,this.#i=this.#t?this.#t.#i:this,this.#r=this.#i===this?n:this.#i.#r,this.#c=this.#i===this?[]:this.#i.#c,e==="!"&&!this.#i.#s&&this.#c.push(this),this.#o=this.#t?this.#t.#e.length:0}get hasMagic(){if(this.#n!==void 0)return this.#n;for(let e of this.#e)if(typeof e!="string"&&(e.type||e.hasMagic))return this.#n=!0;return this.#n}toString(){return this.#p!==void 0?this.#p:this.type?this.#p=this.type+"("+this.#e.map(e=>String(e)).join("|")+")":this.#p=this.#e.map(e=>String(e)).join("")}#m(){if(this!==this.#i)throw new Error("should only call on root");if(this.#s)return this;this.toString(),this.#s=!0;let e;for(;e=this.#c.pop();){if(e.type!=="!")continue;let i=e,n=i.#t;for(;n;){for(let r=i.#o+1;!n.type&&r<n.#e.length;r++)for(let a of e.#e){if(typeof a=="string")throw new Error("string part in extglob AST??");a.copyIn(n.#e[r])}i=n,n=i.#t}}return this}push(...e){for(let i of e)if(i!==""){if(typeof i!="string"&&!(i instanceof t&&i.#t===this))throw new Error("invalid part: "+i);this.#e.push(i)}}toJSON(){let e=this.type===null?this.#e.slice().map(i=>typeof i=="string"?i:i.toJSON()):[this.type,...this.#e.map(i=>i.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#i||this.#i.#s&&this.#t?.type==="!")&&e.push({}),e}isStart(){if(this.#i===this)return!0;if(!this.#t?.isStart())return!1;if(this.#o===0)return!0;let e=this.#t;for(let i=0;i<this.#o;i++){let n=e.#e[i];if(!(n instanceof t&&n.type==="!"))return!1}return!0}isEnd(){if(this.#i===this||this.#t?.type==="!")return!0;if(!this.#t?.isEnd())return!1;if(!this.type)return this.#t?.isEnd();let e=this.#t?this.#t.#e.length:0;return this.#o===e-1}copyIn(e){typeof e=="string"?this.push(e):this.push(e.clone(this))}clone(e){let i=new t(this.type,e);for(let n of this.#e)i.copyIn(n);return i}static#u(e,i,n,r){let a=!1,o=!1,s=-1,c=!1;if(i.type===null){let d=n,v="";for(;d<e.length;){let h=e.charAt(d++);if(a||h==="\\"){a=!a,v+=h;continue}if(o){d===s+1?(h==="^"||h==="!")&&(c=!0):h==="]"&&!(d===s+2&&c)&&(o=!1),v+=h;continue}else if(h==="["){o=!0,s=d,c=!1,v+=h;continue}if(!r.noext&&mc(h)&&e.charAt(d)==="("){i.push(v),v="";let g=new t(h,i);d=t.#u(e,g,d,r),i.push(g);continue}v+=h}return i.push(v),d}let u=n+1,p=new t(null,i),l=[],m="";for(;u<e.length;){let d=e.charAt(u++);if(a||d==="\\"){a=!a,m+=d;continue}if(o){u===s+1?(d==="^"||d==="!")&&(c=!0):d==="]"&&!(u===s+2&&c)&&(o=!1),m+=d;continue}else if(d==="["){o=!0,s=u,c=!1,m+=d;continue}if(mc(d)&&e.charAt(u)==="("){p.push(m),m="";let v=new t(d,p);p.push(v),u=t.#u(e,v,u,r);continue}if(d==="|"){p.push(m),m="",l.push(p),p=new t(null,i);continue}if(d===")")return m===""&&i.#e.length===0&&(i.#l=!0),p.push(m),m="",i.push(...l,p),u;m+=d}return i.type=null,i.#n=void 0,i.#e=[e.substring(n-1)],u}static fromGlob(e,i={}){let n=new t(null,void 0,i);return t.#u(e,n,0,i),n}toMMPattern(){if(this!==this.#i)return this.#i.toMMPattern();let e=this.toString(),[i,n,r,a]=this.toRegExpSource();if(!(r||this.#n||this.#r.nocase&&!this.#r.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return n;let s=(this.#r.nocase?"i":"")+(a?"u":"");return Object.assign(new RegExp(`^${i}$`,s),{_src:i,_glob:e})}get options(){return this.#r}toRegExpSource(e){let i=e??!!this.#r.dot;if(this.#i===this&&this.#m(),!this.type){let c=this.isStart()&&this.isEnd(),u=this.#e.map(d=>{let[v,h,g,O]=typeof d=="string"?t.#d(d,this.#n,c):d.toRegExpSource(e);return this.#n=this.#n||g,this.#a=this.#a||O,v}).join(""),p="";if(this.isStart()&&typeof this.#e[0]=="string"&&!(this.#e.length===1&&nx.has(this.#e[0]))){let v=ix,h=i&&v.has(u.charAt(0))||u.startsWith("\\.")&&v.has(u.charAt(2))||u.startsWith("\\.\\.")&&v.has(u.charAt(4)),g=!i&&!e&&v.has(u.charAt(0));p=h?tx:g?Fi:""}let l="";return this.isEnd()&&this.#i.#s&&this.#t?.type==="!"&&(l="(?:$|\\/)"),[p+u+l,ye(u),this.#n=!!this.#n,this.#a]}let n=this.type==="*"||this.type==="+",r=this.type==="!"?"(?:(?!(?:":"(?:",a=this.#f(i);if(this.isStart()&&this.isEnd()&&!a&&this.type!=="!"){let c=this.toString();return this.#e=[c],this.type=null,this.#n=void 0,[c,ye(this.toString()),!1,!1]}let o=!n||e||i||!Fi?"":this.#f(!0);o===a&&(o=""),o&&(a=`(?:${a})(?:${o})*?`);let s="";if(this.type==="!"&&this.#l)s=(this.isStart()&&!i?Fi:"")+hc;else{let c=this.type==="!"?"))"+(this.isStart()&&!i&&!e?Fi:"")+dc+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;s=r+a+c}return[s,ye(a),this.#n=!!this.#n,this.#a]}#f(e){return this.#e.map(i=>{if(typeof i=="string")throw new Error("string type in extglob ast??");let[n,r,a,o]=i.toRegExpSource(e);return this.#a=this.#a||o,n}).filter(i=>!(this.isStart()&&this.isEnd())||!!i).join("|")}static#d(e,i,n=!1){let r=!1,a="",o=!1;for(let s=0;s<e.length;s++){let c=e.charAt(s);if(r){r=!1,a+=(rx.has(c)?"\\":"")+c;continue}if(c==="\\"){s===e.length-1?a+="\\\\":r=!0;continue}if(c==="["){let[u,p,l,m]=fc(e,s);if(l){a+=u,o=o||p,s+=l-1,i=i||m;continue}}if(c==="*"){n&&e==="*"?a+=hc:a+=dc,i=!0;continue}if(c==="?"){a+=tr,i=!0;continue}a+=ax(c)}return[a,ye(e),!!i,o]}};var ir=(t,{windowsPathsNoEscape:e=!1}={})=>e?t.replace(/[?*()[\]]/g,"[$&]"):t.replace(/[?*()[\]\\]/g,"\\$&");var q=(t,e,i={})=>(Ft(e),!i.nocomment&&e.charAt(0)==="#"?!1:new Ke(e,i).match(t)),ox=/^\*+([^+@!?\*\[\(]*)$/,sx=t=>e=>!e.startsWith(".")&&e.endsWith(t),cx=t=>e=>e.endsWith(t),px=t=>(t=t.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(t)),ux=t=>(t=t.toLowerCase(),e=>e.toLowerCase().endsWith(t)),lx=/^\*+\.\*+$/,fx=t=>!t.startsWith(".")&&t.includes("."),mx=t=>t!=="."&&t!==".."&&t.includes("."),dx=/^\.\*+$/,hx=t=>t!=="."&&t!==".."&&t.startsWith("."),vx=/^\*+$/,xx=t=>t.length!==0&&!t.startsWith("."),bx=t=>t.length!==0&&t!=="."&&t!=="..",gx=/^\?+([^+@!?\*\[\(]*)?$/,yx=([t,e=""])=>{let i=bc([t]);return e?(e=e.toLowerCase(),n=>i(n)&&n.toLowerCase().endsWith(e)):i},wx=([t,e=""])=>{let i=gc([t]);return e?(e=e.toLowerCase(),n=>i(n)&&n.toLowerCase().endsWith(e)):i},_x=([t,e=""])=>{let i=gc([t]);return e?n=>i(n)&&n.endsWith(e):i},Sx=([t,e=""])=>{let i=bc([t]);return e?n=>i(n)&&n.endsWith(e):i},bc=([t])=>{let e=t.length;return i=>i.length===e&&!i.startsWith(".")},gc=([t])=>{let e=t.length;return i=>i.length===e&&i!=="."&&i!==".."},yc=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",vc={win32:{sep:"\\"},posix:{sep:"/"}},kx=yc==="win32"?vc.win32.sep:vc.posix.sep;q.sep=kx;var X=Symbol("globstar **");q.GLOBSTAR=X;var Ox="[^/]",Ex=Ox+"*?",jx="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Tx="(?:(?!(?:\\/|^)\\.).)*?",Ax=(t,e={})=>i=>q(i,t,e);q.filter=Ax;var Q=(t,e={})=>Object.assign({},t,e),Cx=t=>{if(!t||typeof t!="object"||!Object.keys(t).length)return q;let e=q;return Object.assign((n,r,a={})=>e(n,r,Q(t,a)),{Minimatch:class extends e.Minimatch{constructor(r,a={}){super(r,Q(t,a))}static defaults(r){return e.defaults(Q(t,r)).Minimatch}},AST:class extends e.AST{constructor(r,a,o={}){super(r,a,Q(t,o))}static fromGlob(r,a={}){return e.AST.fromGlob(r,Q(t,a))}},unescape:(n,r={})=>e.unescape(n,Q(t,r)),escape:(n,r={})=>e.escape(n,Q(t,r)),filter:(n,r={})=>e.filter(n,Q(t,r)),defaults:n=>e.defaults(Q(t,n)),makeRe:(n,r={})=>e.makeRe(n,Q(t,r)),braceExpand:(n,r={})=>e.braceExpand(n,Q(t,r)),match:(n,r,a={})=>e.match(n,r,Q(t,a)),sep:e.sep,GLOBSTAR:X})};q.defaults=Cx;var wc=(t,e={})=>(Ft(t),e.nobrace||!/\{(?:(?!\{).)*\}/.test(t)?[t]:er(t));q.braceExpand=wc;var qx=(t,e={})=>new Ke(t,e).makeRe();q.makeRe=qx;var Px=(t,e,i={})=>{let n=new Ke(e,i);return t=t.filter(r=>n.match(r)),n.options.nonull&&!t.length&&t.push(e),t};q.match=Px;var xc=/[?*]|[+@!]\(.*?\)|\[|\]/,Fx=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ke=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(e,i={}){Ft(e),i=i||{},this.options=i,this.pattern=e,this.platform=i.platform||yc,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!i.windowsPathsNoEscape||i.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!i.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!i.nonegate,this.comment=!1,this.empty=!1,this.partial=!!i.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=i.windowsNoMagicRoot!==void 0?i.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 e of this.set)for(let i of e)if(typeof i!="string")return!0;return!1}debug(...e){}make(){let e=this.pattern,i=this.options;if(!i.nocomment&&e.charAt(0)==="#"){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],i.debug&&(this.debug=(...a)=>console.error(...a)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(a=>this.slashSplit(a));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let r=this.globParts.map((a,o,s)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=a[0]===""&&a[1]===""&&(a[2]==="?"||!xc.test(a[2]))&&!xc.test(a[3]),u=/^[a-z]:/i.test(a[0]);if(c)return[...a.slice(0,4),...a.slice(4).map(p=>this.parse(p))];if(u)return[a[0],...a.slice(1).map(p=>this.parse(p))]}return a.map(c=>this.parse(c))});if(this.debug(this.pattern,r),this.set=r.filter(a=>a.indexOf(!1)===-1),this.isWindows)for(let a=0;a<this.set.length;a++){let o=this.set[a];o[0]===""&&o[1]===""&&this.globParts[a][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let n=0;n<e.length;n++)for(let r=0;r<e[n].length;r++)e[n][r]==="**"&&(e[n][r]="*");let{optimizationLevel:i=1}=this.options;return i>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):i>=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(i=>{let n=-1;for(;(n=i.indexOf("**",n+1))!==-1;){let r=n;for(;i[r+1]==="**";)r++;r!==n&&i.splice(n,r-n)}return i})}levelOneOptimize(e){return e.map(i=>(i=i.reduce((n,r)=>{let a=n[n.length-1];return r==="**"&&a==="**"?n:r===".."&&a&&a!==".."&&a!=="."&&a!=="**"?(n.pop(),n):(n.push(r),n)},[]),i.length===0?[""]:i))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let i=!1;do{if(i=!1,!this.preserveMultipleSlashes){for(let r=1;r<e.length-1;r++){let a=e[r];r===1&&a===""&&e[0]===""||(a==="."||a==="")&&(i=!0,e.splice(r,1),r--)}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(i=!0,e.pop())}let n=0;for(;(n=e.indexOf("..",n+1))!==-1;){let r=e[n-1];r&&r!=="."&&r!==".."&&r!=="**"&&(i=!0,e.splice(n-1,2),n-=2)}}while(i);return e.length===0?[""]:e}firstPhasePreProcess(e){let i=!1;do{i=!1;for(let n of e){let r=-1;for(;(r=n.indexOf("**",r+1))!==-1;){let o=r;for(;n[o+1]==="**";)o++;o>r&&n.splice(r+1,o-r);let s=n[r+1],c=n[r+2],u=n[r+3];if(s!==".."||!c||c==="."||c===".."||!u||u==="."||u==="..")continue;i=!0,n.splice(r,1);let p=n.slice(0);p[r]="**",e.push(p),r--}if(!this.preserveMultipleSlashes){for(let o=1;o<n.length-1;o++){let s=n[o];o===1&&s===""&&n[0]===""||(s==="."||s==="")&&(i=!0,n.splice(o,1),o--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(i=!0,n.pop())}let a=0;for(;(a=n.indexOf("..",a+1))!==-1;){let o=n[a-1];if(o&&o!=="."&&o!==".."&&o!=="**"){i=!0;let c=a===1&&n[a+1]==="**"?["."]:[];n.splice(a-1,2,...c),n.length===0&&n.push(""),a-=2}}}}while(i);return e}secondPhasePreProcess(e){for(let i=0;i<e.length-1;i++)for(let n=i+1;n<e.length;n++){let r=this.partsMatch(e[i],e[n],!this.preserveMultipleSlashes);if(r){e[i]=[],e[n]=r;break}}return e.filter(i=>i.length)}partsMatch(e,i,n=!1){let r=0,a=0,o=[],s="";for(;r<e.length&&a<i.length;)if(e[r]===i[a])o.push(s==="b"?i[a]:e[r]),r++,a++;else if(n&&e[r]==="**"&&i[a]===e[r+1])o.push(e[r]),r++;else if(n&&i[a]==="**"&&e[r]===i[a+1])o.push(i[a]),a++;else if(e[r]==="*"&&i[a]&&(this.options.dot||!i[a].startsWith("."))&&i[a]!=="**"){if(s==="b")return!1;s="a",o.push(e[r]),r++,a++}else if(i[a]==="*"&&e[r]&&(this.options.dot||!e[r].startsWith("."))&&e[r]!=="**"){if(s==="a")return!1;s="b",o.push(i[a]),r++,a++}else return!1;return e.length===i.length&&o}parseNegate(){if(this.nonegate)return;let e=this.pattern,i=!1,n=0;for(let r=0;r<e.length&&e.charAt(r)==="!";r++)i=!i,n++;n&&(this.pattern=e.slice(n)),this.negate=i}matchOne(e,i,n=!1){let r=this.options;if(this.isWindows){let h=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),g=!h&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[3]),O=typeof i[0]=="string"&&/^[a-z]:$/i.test(i[0]),U=!O&&i[0]===""&&i[1]===""&&i[2]==="?"&&typeof i[3]=="string"&&/^[a-z]:$/i.test(i[3]),E=g?3:h?0:void 0,j=U?3:O?0:void 0;if(typeof E=="number"&&typeof j=="number"){let[re,V]=[e[E],i[j]];re.toLowerCase()===V.toLowerCase()&&(i[j]=re,j>E?i=i.slice(j):E>j&&(e=e.slice(E)))}}let{optimizationLevel:a=1}=this.options;a>=2&&(e=this.levelTwoFileOptimize(e)),this.debug("matchOne",this,{file:e,pattern:i}),this.debug("matchOne",e.length,i.length);for(var o=0,s=0,c=e.length,u=i.length;o<c&&s<u;o++,s++){this.debug("matchOne loop");var p=i[s],l=e[o];if(this.debug(i,p,l),p===!1)return!1;if(p===X){this.debug("GLOBSTAR",[i,p,l]);var m=o,d=s+1;if(d===u){for(this.debug("** at the end");o<c;o++)if(e[o]==="."||e[o]===".."||!r.dot&&e[o].charAt(0)===".")return!1;return!0}for(;m<c;){var v=e[m];if(this.debug(`
22
22
  globstar while`,e,m,i,d,v),this.matchOne(e.slice(m),i.slice(d),n))return this.debug("globstar found match!",m,c,v),!0;if(v==="."||v===".."||!r.dot&&v.charAt(0)==="."){this.debug("dot detected!",e,m,i,d);break}this.debug("globstar swallow a segment, and continue"),m++}return!!(n&&(this.debug(`
23
- >>> no match, partial?`,e,m,i,d),m===c))}let h;if(typeof p=="string"?(h=l===p,this.debug("string match",p,l,h)):(h=p.test(l),this.debug("pattern match",p,l,h)),!h)return!1}if(o===c&&s===u)return!0;if(o===c)return n;if(s===u)return o===c-1&&e[o]==="";throw new Error("wtf?")}braceExpand(){return wc(this.pattern,this.options)}parse(e){Ft(e);let i=this.options;if(e==="**")return X;if(e==="")return"";let n,r=null;(n=e.match(vx))?r=i.dot?bx:xx:(n=e.match(ox))?r=(i.nocase?i.dot?ux:px:i.dot?cx:sx)(n[1]):(n=e.match(gx))?r=(i.nocase?i.dot?wx:yx:i.dot?_x:Sx)(n):(n=e.match(lx))?r=i.dot?mx:fx:(n=e.match(dx))&&(r=hx);let a=Xe.fromGlob(e,this.options).toMMPattern();return r&&typeof a=="object"&&Reflect.defineProperty(a,"test",{value:r}),a}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let i=this.options,n=i.noglobstar?Ex:i.dot?jx:Tx,r=new Set(i.nocase?["i"]:[]),a=e.map(c=>{let u=c.map(p=>{if(p instanceof RegExp)for(let l of p.flags.split(""))r.add(l);return typeof p=="string"?Fx(p):p===X?X:p._src});return u.forEach((p,l)=>{let m=u[l+1],d=u[l-1];p!==X||d===X||(d===void 0?m!==void 0&&m!==X?u[l+1]="(?:\\/|"+n+"\\/)?"+m:u[l]=n:m===void 0?u[l-1]=d+"(?:\\/|"+n+")?":m!==X&&(u[l-1]=d+"(?:\\/|\\/"+n+"\\/)"+m,u[l+1]=X))}),u.filter(p=>p!==X).join("/")}).join("|"),[o,s]=e.length>1?["(?:",")"]:["",""];a="^"+o+a+s+"$",this.negate&&(a="^(?!"+a+").+$");try{this.regexp=new RegExp(a,[...r].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,i=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&i)return!0;let n=this.options;this.isWindows&&(e=e.split("\\").join("/"));let r=this.slashSplit(e);this.debug(this.pattern,"split",r);let a=this.set;this.debug(this.pattern,"set",a);let o=r[r.length-1];if(!o)for(let s=r.length-2;!o&&s>=0;s--)o=r[s];for(let s=0;s<a.length;s++){let c=a[s],u=r;if(n.matchBase&&c.length===1&&(u=[o]),this.matchOne(u,c,i))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(e){return q.defaults(e).Minimatch}};q.AST=Xe;q.Minimatch=Ke;q.escape=ir;q.unescape=ye;import{readFile as Hx}from"node:fs/promises";import{extname as rr,join as Vx}from"node:path";import{createReadStream as Mx,createWriteStream as Ix}from"node:fs";import{Readable as Dx}from"node:stream";import{createGunzip as zx,createGzip as Rx}from"node:zlib";var jE=async({source:t})=>await new Promise((e,i)=>{let n=Dx.from(t),r=[],a=zx();n.pipe(a),a.on("data",o=>r.push(o)),a.on("end",()=>{e(Buffer.concat(r))}),a.on("error",i)}),_c=async({sourceFiles:t,gzip:e})=>{if(e===!1)return[];let i=e===!0?gi:e,n=t.filter(r=>q(r,i));return await Promise.all(n.map(async r=>await Nx({source:r})))},Nx=async({source:t,destination:e})=>await new Promise((i,n)=>{let r=Mx(t),a=e??`${t}.gz`,o=Ix(a),s=Rx();r.pipe(s).pipe(o),o.on("close",()=>{i(a)}),o.on("error",n)}),TE=t=>t.length>2&&t[0]===31&&t[1]===139;import{lstatSync as Bx}from"node:fs";import{basename as $x}from"node:path";import{lstatSync as kc,readdirSync as Lx}from"node:fs";import{access as Ux}from"node:fs/promises";import{join as Sc}from"node:path";var nr=t=>Lx(t).flatMap(e=>{let i=Sc(t,e);return kc(i).isDirectory()?nr(i):Sc(i)}),FE=async t=>{try{return await Ux(t),!0}catch(e){if(e instanceof Error&&"code"in e&&e.code==="ENOENT")return!1;throw e}},Oc=t=>{let{size:e}=kc(t);return e};var Mi=({file:t,sourceAbsolutePath:e})=>t.replace(e,"").replace(/\\/g,"/"),Ec=({sourceAbsolutePath:t,ignore:e})=>nr(t).filter(n=>Yx({file:n,ignore:e})),Yx=({file:t,ignore:e})=>Bx(t).size<=0||Xo.includes($x(t).toLowerCase())?!1:e.find(i=>q(t,i))===void 0;var Ac=async({config:t,listAssets:e,assertSourceDirExists:i,includeAllFiles:n})=>{let{source:r=Zo,ignore:a=Jo,encoding:o=Qo,gzip:s=gi}=t,c=Vx(process.cwd(),r);return i?.(c),{files:await Xx({sourceAbsolutePath:c,ignore:a,encoding:o,gzip:s,listAssets:e,includeAllFiles:n}),sourceAbsolutePath:c}},Zx=async({files:t,sourceAbsolutePath:e,listAssets:i})=>{let n=await i({}),r=t.map(async o=>await Qx({file:o,sourceAbsolutePath:e,existingAssets:n}));return(await Promise.all(r)).filter(({upload:o})=>o).map(({file:o})=>o)},Jx=async t=>{let e=await Hx(t);return Wx.createHash("sha256").update(e).digest("base64")},Qx=async({file:t,existingAssets:e,sourceAbsolutePath:i})=>{let n=t.alternateFile??t.file,r=e.find(({fullPath:o})=>o===Mi({file:n,sourceAbsolutePath:i}));if(jc(r))return{file:t,upload:!0};let a=await Jx(n);return{file:t,upload:a!==r.encodings.identity?.sha256}},Xx=async({sourceAbsolutePath:t,ignore:e,encoding:i,gzip:n,listAssets:r,includeAllFiles:a})=>{let o=Ec({sourceAbsolutePath:t,ignore:e}),s=await _c({sourceFiles:o,gzip:n}),c=[...o,...s.filter(d=>!o.includes(d))],u=({file:d,ext:v})=>{let h=i.find(([g,O])=>q(d,g));if(Gx(h)){let[g,O]=h;return O}if(v==="Z")return"compress";if(v==="gz")return"gzip";if(rr(d)===".br")return"br";if(rr(d)===".zlib")return"deflate"},p=({file:d,encodingType:v})=>{if(!jc(v))return c.find(h=>h===d.replace(rr(d),""))},l=async d=>{let v=await Ws(d),h=u({file:d,ext:v?.ext}),g=p({file:d,encodingType:h}),O=Tc.default.lookup(g??d);return{file:d,alternateFile:g,mime:typeof O=="string"?O:void 0,encoding:h}},m=await Promise.all(c.map(l));return a===!0?m:await Zx({files:m,sourceAbsolutePath:t,listAssets:r})};import{fromNullable as Kx,isNullish as eb,uint8ArrayToHexString as tb}from"@dfinity/utils";import{commitProposal as ib,initProposal as nb,submitProposal as rb}from"@junobuild/cdn";var Cc=async({proposalType:t,cdn:e,executeChanges:i,autoCommit:n})=>{let[r,a]=await nb({proposalType:t,cdn:e});await i(r);let[o,{sha256:s,status:c}]=await rb({cdn:e,proposal_id:r}),u=Kx(s);return console.log(`
23
+ >>> no match, partial?`,e,m,i,d),m===c))}let h;if(typeof p=="string"?(h=l===p,this.debug("string match",p,l,h)):(h=p.test(l),this.debug("pattern match",p,l,h)),!h)return!1}if(o===c&&s===u)return!0;if(o===c)return n;if(s===u)return o===c-1&&e[o]==="";throw new Error("wtf?")}braceExpand(){return wc(this.pattern,this.options)}parse(e){Ft(e);let i=this.options;if(e==="**")return X;if(e==="")return"";let n,r=null;(n=e.match(vx))?r=i.dot?bx:xx:(n=e.match(ox))?r=(i.nocase?i.dot?ux:px:i.dot?cx:sx)(n[1]):(n=e.match(gx))?r=(i.nocase?i.dot?wx:yx:i.dot?_x:Sx)(n):(n=e.match(lx))?r=i.dot?mx:fx:(n=e.match(dx))&&(r=hx);let a=Xe.fromGlob(e,this.options).toMMPattern();return r&&typeof a=="object"&&Reflect.defineProperty(a,"test",{value:r}),a}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let i=this.options,n=i.noglobstar?Ex:i.dot?jx:Tx,r=new Set(i.nocase?["i"]:[]),a=e.map(c=>{let u=c.map(p=>{if(p instanceof RegExp)for(let l of p.flags.split(""))r.add(l);return typeof p=="string"?Fx(p):p===X?X:p._src});return u.forEach((p,l)=>{let m=u[l+1],d=u[l-1];p!==X||d===X||(d===void 0?m!==void 0&&m!==X?u[l+1]="(?:\\/|"+n+"\\/)?"+m:u[l]=n:m===void 0?u[l-1]=d+"(?:\\/|"+n+")?":m!==X&&(u[l-1]=d+"(?:\\/|\\/"+n+"\\/)"+m,u[l+1]=X))}),u.filter(p=>p!==X).join("/")}).join("|"),[o,s]=e.length>1?["(?:",")"]:["",""];a="^"+o+a+s+"$",this.negate&&(a="^(?!"+a+").+$");try{this.regexp=new RegExp(a,[...r].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,i=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&i)return!0;let n=this.options;this.isWindows&&(e=e.split("\\").join("/"));let r=this.slashSplit(e);this.debug(this.pattern,"split",r);let a=this.set;this.debug(this.pattern,"set",a);let o=r[r.length-1];if(!o)for(let s=r.length-2;!o&&s>=0;s--)o=r[s];for(let s=0;s<a.length;s++){let c=a[s],u=r;if(n.matchBase&&c.length===1&&(u=[o]),this.matchOne(u,c,i))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(e){return q.defaults(e).Minimatch}};q.AST=Xe;q.Minimatch=Ke;q.escape=ir;q.unescape=ye;import{readFile as Hx}from"node:fs/promises";import{extname as rr,join as Vx}from"node:path";import{createReadStream as Mx,createWriteStream as Ix}from"node:fs";import{Readable as Dx}from"node:stream";import{createGunzip as zx,createGzip as Rx}from"node:zlib";var jE=async({source:t})=>await new Promise((e,i)=>{let n=Dx.from(t),r=[],a=zx();n.pipe(a),a.on("data",o=>r.push(o)),a.on("end",()=>{e(Buffer.concat(r))}),a.on("error",i)}),_c=async({sourceFiles:t,gzip:e})=>{if(e===!1)return[];let i=e===!0?gi:e,n=t.filter(r=>q(r,i));return await Promise.all(n.map(async r=>await Nx({source:r})))},Nx=async({source:t,destination:e})=>await new Promise((i,n)=>{let r=Mx(t),a=e??`${t}.gz`,o=Ix(a),s=Rx();r.pipe(s).pipe(o),o.on("close",()=>{i(a)}),o.on("error",n)}),TE=t=>t.length>2&&t[0]===31&&t[1]===139;import{lstatSync as Bx}from"node:fs";import{basename as $x}from"node:path";import{lstatSync as kc,readdirSync as Lx}from"node:fs";import{access as Ux}from"node:fs/promises";import{join as Sc}from"node:path";var nr=t=>Lx(t).flatMap(e=>{let i=Sc(t,e);return kc(i).isDirectory()?nr(i):Sc(i)}),FE=async t=>{try{return await Ux(t),!0}catch(e){if(e instanceof Error&&"code"in e&&e.code==="ENOENT")return!1;throw e}},Oc=t=>{let{size:e}=kc(t);return e};var Mi=({file:t,sourceAbsolutePath:e})=>t.replace(e,"").replace(/\\/g,"/"),Ec=({sourceAbsolutePath:t,ignore:e})=>nr(t).filter(n=>Yx({file:n,ignore:e})),Yx=({file:t,ignore:e})=>Bx(t).size<=0||Xo.includes($x(t).toLowerCase())?!1:e.find(i=>q(t,i))===void 0;var Ac=async({config:t,listAssets:e,assertSourceDirExists:i,includeAllFiles:n})=>{let{source:r=Zo,ignore:a=Jo,encoding:o=Qo,gzip:s=gi}=t,c=Vx(process.cwd(),r);return i?.(c),{files:await Xx({sourceAbsolutePath:c,ignore:a,encoding:o,gzip:s,listAssets:e,includeAllFiles:n}),sourceAbsolutePath:c}},Zx=async({files:t,sourceAbsolutePath:e,listAssets:i})=>{let n=await i({}),r=t.map(async o=>await Qx({file:o,sourceAbsolutePath:e,existingAssets:n}));return(await Promise.all(r)).filter(({upload:o})=>o).map(({file:o})=>o)},Jx=async t=>{let e=await Hx(t);return Wx.createHash("sha256").update(e).digest("base64")},Qx=async({file:t,existingAssets:e,sourceAbsolutePath:i})=>{let n=t.alternateFile??t.file,r=e.find(({fullPath:o})=>o===Mi({file:n,sourceAbsolutePath:i}));if(jc(r))return{file:t,upload:!0};let a=await Jx(n);return{file:t,upload:a!==r.encodings.identity?.sha256}},Xx=async({sourceAbsolutePath:t,ignore:e,encoding:i,gzip:n,listAssets:r,includeAllFiles:a})=>{let o=Ec({sourceAbsolutePath:t,ignore:e}),s=await _c({sourceFiles:o,gzip:n}),c=[...o,...s.filter(d=>!o.includes(d))],u=({file:d,ext:v})=>{let h=i.find(([g,O])=>q(d,g));if(Gx(h)){let[g,O]=h;return O}if(v==="Z")return"compress";if(v==="gz")return"gzip";if(rr(d)===".br")return"br";if(rr(d)===".zlib")return"deflate"},p=({file:d,encodingType:v})=>{if(!jc(v))return c.find(h=>h===d.replace(rr(d),""))},l=async d=>{let v=await Ws(d),h=u({file:d,ext:v?.ext}),g=p({file:d,encodingType:h}),O=Tc.default.lookup(g??d);return{file:d,alternateFile:g,mime:typeof O=="string"?O:void 0,encoding:h}},m=await Promise.all(c.map(l));return a===!0?m:await Zx({files:m,sourceAbsolutePath:t,listAssets:r})};import{fromNullable as Kx,isNullish as eb,uint8ArrayToHexString as tb}from"@dfinity/utils";import{commitProposal as ib,initProposal as nb,submitProposal as rb}from"@junobuild/cdn";var Cc=async({proposalType:t,cdn:e,executeChanges:i,autoCommit:n})=>{let[r,a]=await nb({proposalType:t,cdn:e});await i(r);let[o,{sha256:s,status:c}]=await rb({cdn:e,proposalId:r}),u=Kx(s);return console.log(`
24
24
  Change submitted.
25
25
  `),console.log("\u{1F194} ",Number(r)),console.log("\u23F3 ",Object.keys(c)[0]??c),eb(u)&&(console.log("\u274C Hash undefined. This is unexpected."),process.exit(1)),console.log("\u{1F512} ",tb(u)),n?(await ib({proposal:{proposal_id:r,sha256:u},cdn:e}),console.log(`\u{1F3AF} Change #${r} applied.`),{proposalId:r}):{proposalId:r}};var eh=bi(Qd(),1);import{isNullish as Hk,nonNullish as zo,notEmptyString as Kd}from"@dfinity/utils";import{Blob as Vk}from"buffer";import{readFile as Zk}from"node:fs/promises";import{basename as Jk,relative as Qk}from"node:path";var Xd=t=>{let e=t>=1e3?"megabyte":"kilobyte";return new Intl.NumberFormat("en",{style:"unit",unit:e}).format(t/(e==="megabyte"?1e6:1e3))};var On=async({files:t,uploadFile:e,sourceAbsolutePath:i,collection:n})=>{await Kk({files:t,sourceAbsolutePath:i,upload:async({file:a,paths:o})=>{await e3({collection:n,...o,file:a,uploadFile:e})}}),Xk({files:t})},Xk=({files:t})=>{let{count:e,size:i}=t.reduce(({count:n,size:r},{paths:a})=>({count:n+1,size:r+Oc(a.filePath)}),{count:0,size:0});console.log(`
26
26
  \u2714 ${e} files uploaded (total: ${Xd(i)})`)},Kk=async({files:t,sourceAbsolutePath:e,upload:i})=>{let n=async r=>{for(let a=0;a<r.length;a+=20){let o=r.slice(a,a+20);await new eh.default(o.map(({file:c,paths:u})=>({title:`Uploading ${Qk(e,c.file)}`,task:async()=>await i({file:c,paths:u})})),{concurrent:!0}).run()}};await n(t.filter(({file:{alternateFile:r}})=>zo(r))),await n(t.filter(({file:{alternateFile:r}})=>Hk(r)))},e3=async({uploadFile:t,file:e,fullPath:i,collection:n,filePath:r,token:a,description:o})=>{await t({filename:Jk(r),fullPath:i,data:new Vk([await Zk(e.file)]),collection:n,headers:[...e.mime===void 0?[]:[["Content-Type",e.mime]]],encoding:e.encoding,...zo(a)&&Kd(a)&&{token:a},...zo(o)&&Kd(o)&&{description:o}})};var En=async({deploy:{uploadFile:t,files:e,sourceAbsolutePath:i,collection:n},proposal:{proposalType:r,autoCommit:a,...o}})=>{let s=async u=>{await On({files:e,sourceAbsolutePath:i,collection:n,uploadFile:l=>t({...l,proposalId:u})})},{proposalId:c}=await Cc({...o,autoCommit:a,proposalType:r,executeChanges:s});return a?{result:"deployed",files:e.map(u=>u.file),proposalId:c}:{result:"submitted",files:e.map(u=>u.file),proposalId:c}};var XT=async({config:{predeploy:t}})=>{await In(t)},KT=async({config:{postdeploy:t}})=>{await In(t)},eA=async({uploadFile:t,...e})=>{let i=await th(e);if(i.result==="skipped")return{result:"skipped"};let{files:n,sourceAbsolutePath:r}=i,a=ih({files:n,sourceAbsolutePath:r});return await On({files:a,uploadFile:t,sourceAbsolutePath:r,collection:Pn}),console.log(`