@junobuild/cli-tools 0.2.0-next-2025-05-29 → 0.2.0-next-2025-05-30

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,10 +20,10 @@ var rh=Object.create;var Uo=Object.defineProperty;var ah=Object.getOwnPropertyDe
20
20
  `)},Sd=(t,e)=>{yo(Od(t,e))},wo=class{constructor(e,i){this._tasks=e,this._options=Object.assign({showSubtasks:!0,collapse:!0,clearOutput:!1},i)}render(){this._id||(this._id=setInterval(()=>{Sd(this._tasks,this._options)},100))}end(e){this._id&&(clearInterval(this._id),this._id=void 0),Sd(this._tasks,this._options),this._options.clearOutput&&e===void 0?yo.clear():yo.done()}};jd.exports=wo});var _o=l(Cd=>{"use strict";var _n={silent:tl(),verbose:Nf(),default:Ed()},Td=t=>process.stdout.isTTY===!0||t.nonTTY===!0,Ad=t=>typeof t=="string"?_n[t]||_n.default:typeof t=="function"?t:_n.default;Cd.getRenderer=(t,e)=>{let i=Ad(t);return Td(i)||(i=Ad(e),(!i||!Td(i))&&(i=_n.verbose)),i}});var ko=l((tT,qd)=>{"use strict";var kt={PENDING:0,COMPLETED:1,FAILED:2,SKIPPED:3};kt.toString=t=>{switch(t){case kt.PENDING:return"pending";case kt.COMPLETED:return"completed";case kt.FAILED:return"failed";case kt.SKIPPED:return"skipped";default:return"unknown"}};qd.exports=kt});var Md=l((iT,Fd)=>{"use strict";var he=Fd.exports=function(t){return t!==null&&typeof t=="object"&&typeof t.pipe=="function"};he.writable=function(t){return he(t)&&t.writable!==!1&&typeof t._write=="function"&&typeof t._writableState=="object"};he.readable=function(t){return he(t)&&t.readable!==!1&&typeof t._read=="function"&&typeof t._readableState=="object"};he.duplex=function(t){return he.writable(t)&&he.readable(t)};he.transform=function(t){return he.duplex(t)&&typeof t._transform=="function"&&typeof t._transformState=="object"}});var Pd=l(So=>{"use strict";Object.defineProperty(So,"__esModule",{value:!0});So.default=cS;function cS(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 Id=l((jo,Oo)=>{"use strict";Object.defineProperty(jo,"__esModule",{value:!0});var pS=Pd(),uS=lS(pS);function lS(t){return t&&t.__esModule?t:{default:t}}var St;typeof self<"u"?St=self:typeof window<"u"?St=window:typeof global<"u"?St=global:typeof Oo<"u"?St=Oo:St=Function("return this")();var fS=(0,uS.default)(St);jo.default=fS});var Rd=l((rT,Dd)=>{"use strict";var zd=Id().default;Dd.exports=t=>!!(t&&t[zd]&&t===t[zd]())});var Ud=l(kn=>{"use strict";var mS=Md(),Nd=typeof Symbol=="function"&&Symbol.observable||"@@observable",Bd=t=>!!(t&&t[Nd]&&t===t[Nd]())||Rd()(t);kn.isListr=t=>!!(t&&t.setRenderer&&t.add&&t.run);kn.isObservable=t=>Bd(t);kn.isStream=t=>mS(t)&&!Bd(t)});var Sn=l((oT,Ld)=>{"use strict";var Eo=class extends Error{constructor(e){super(e),this.name="ListrError"}};Ld.exports=Eo});var Yd=l((sT,$d)=>{"use strict";var dS=Fc(),hS=Lc(),vS=Ku().Subject,xS=_o(),ve=ko(),To=Ud(),bS=Sn(),gS=()=>!1,Ao=class extends vS{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||gS,this.task=i.task}get subtasks(){return this._subtasks}set state(e){this._state=e,this.next({type:"STATE"})}get state(){return ve.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===ve.PENDING}isSkipped(){return this._state===ve.SKIPPED}isCompleted(){return this._state===ve.COMPLETED}isEnabled(){return this._isEnabled}hasFailed(){return this._state===ve.FAILED}run(e,i){let n=r=>To.isListr(r)?(r._options=Object.assign(this._options,r._options),r.exitOnError=r._options.exitOnError,r.setRenderer(xS.getRenderer("silent")),this._subtasks=r.tasks,this.next({type:"SUBTASKS"}),r.run(e)):(To.isStream(r)&&(r=hS(r)),To.isObservable(r)&&(r=new Promise((a,o)=>{r.subscribe({next:s=>{this.output=s,this.next({type:"DATA",data:s})},error:o,complete:a})})),dS(r)?r.then(n):r);return Promise.resolve().then(()=>(this.state=ve.PENDING,this.skip(e))).then(r=>{if(r){typeof r=="string"&&(this.output=r),this.state=ve.SKIPPED;return}return n(this.task(e,i))}).then(()=>{this.isPending()&&(this.state=ve.COMPLETED)}).catch(r=>{if(this.state=ve.FAILED,r instanceof bS){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()})}};$d.exports=Ao});var Hd=l((cT,Gd)=>{"use strict";var yS=ko(),wS=Sn(),Co=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 wS)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=yS.SKIPPED}run(e){return this._task.run(e,this)}};Gd.exports=Co});var Zd=l((pT,Vd)=>{"use strict";var _S=Cc(),kS=Yd(),SS=Hd(),Wd=_o(),OS=Sn(),jS=(t,e,i)=>t.isEnabled()?new SS(t,i).run(e):Promise.resolve(),qo=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=Wd.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=Wd.getRenderer(e)}add(e){let i=Array.isArray(e)?e:[e];for(let n of i)this._tasks.push(new kS(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),_S(this._tasks,r=>(this._checkAll(e),jS(r,e,i)),{concurrency:this.concurrency}).then(()=>{if(i.length>0){let r=new OS("Something went wrong");throw r.errors=i,r}return this._renderer.end(),e}).catch(r=>{throw r.context=e,this._renderer.end(r),r})}};Vd.exports=qo});import{rm as uh}from"node:fs/promises";var HS=async({infile:t,outfile:e,banner:i})=>{await lh();let{build:n,version:r}=await import("esbuild");await uh(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}},lh=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{nonNullish as yi}from"@dfinity/utils";import{spawn as Go}from"child_process";import{nonNullish as fh}from"@dfinity/utils";import{stat as mh}from"node:fs/promises";import Lo from"node:path";import $o from"node:process";import{URL as dh}from"node:url";var An=async(t,e,i)=>await hh(t,i)?[Tn(t),e.map(n=>gh(n)),{...i,shell:!0}]:[t,e,i],hh=async(t,{shell:e,cwd:i,env:n=$o.env})=>$o.platform==="win32"&&!e&&!await vh(t,i,n),vh=async(t,e,{Path:i="",PATH:n=i})=>Yo.some(r=>t.toLowerCase().endsWith(r))||(xh[`${t}\0${e}\0${n}`]??=await bh(t,e,n)),xh={},bh=async(t,e,i)=>{let n=i.split(Lo.delimiter).filter(Boolean).map(r=>r.replace(/^"(.*)"$/,"$1"));try{await Promise.all(Yo.flatMap(r=>[e,...n].filter(fh).map(a=>`${Lo.resolve(a instanceof dh?a.toString():a,t)}${r}`)).map(async r=>{try{await mh(r)}catch{return}throw 0}))}catch{return!0}return!1},Yo=[".exe",".com"],gh=t=>Tn(Tn(`"${t.replaceAll(/(\\*)"/g,'$1$1\\"').replace(/(\\*)$/,"$1$1")}"`)),Tn=t=>t.replaceAll(/([()\][%!^"`<>&|;, *?])/g,"^$1");var n3=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,f]=await An(t,i??[],{shell:!0,...yi(e)&&{cwd:e},...yi(n)&&{env:n}}),m=Go(u,p,f);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)})}),Ho=async({command:t,args:e,env:i})=>await new Promise(async n=>{let[r,a,o]=await An(t,e??[],{stdio:"inherit",...yi(i)&&{env:i}});Go(r,a??[],o).on("close",c=>{if(c===0){n(c);return}process.exit(1)})});var Cn=async t=>{for(let e of t??[]){let[i,...n]=e.split(" ");await Ho({command:i,args:n})}};import{isNullish as jc,nonNullish as qx}from"@dfinity/utils";import Fx from"crypto";import{ReadableStream as gv}from"node:stream/web";import{pipeline as Ms,PassThrough as yv,Readable as wv}from"node:stream";import{stat as Sh}from"node:fs/promises";var yh="End-Of-Stream",S=class extends Error{constructor(){super(yh),this.name="EndOfStreamError"}},ge=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 ye=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 S;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 ge;let r=await this.readFromStream(e.subarray(n),i);if(r===0)break;n+=r}if(!i&&n<e.length)throw new S;return n}};var Tt=class extends ye{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 ge)}async close(){return this.abort()}};var _i=class extends ye{constructor(e){super(),this.reader=e}async abort(){return this.close()}async close(){this.reader.releaseLock()}};var At=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 Ve=class extends ye{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 S;return n}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}};function qn(t){try{let e=t.getReader({mode:"byob"});return e instanceof ReadableStreamDefaultReader?new Ve(e):new At(e)}catch(e){if(e instanceof TypeError)return new Ve(t.getReader());throw e}}var ue=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 S;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 S;return e.get(n,0)}async readNumber(e){if(await this.readBuffer(this.numBuffer,{length:e.len})<e.len)throw new S;return e.get(this.numBuffer,0)}async peekNumber(e){if(await this.peekBuffer(this.numBuffer,{length:e.len})<e.len)throw new S;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 wh=256e3,Ct=class extends ue{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 S;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 S)return 0;throw a}if(!n.mayBeLess&&r<n.length)throw new S}return r}async ignore(e){let i=Math.min(wh,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 ki=class extends ue{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 S;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 Wo(t,e){let i=new Tt(t),n=e??{},r=n.onClose;return n.onClose=async()=>{if(await i.close(),r)return r()},new Ct(i,n)}function Si(t,e){let i=qn(t),n=e??{},r=n.onClose;return n.onClose=async()=>{if(await i.close(),r)return r()},new Ct(i,n)}function Vo(t,e){return new ki(t,e)}import{open as kh}from"node:fs/promises";var qt=class t extends ue{static async fromFile(e){let i=await kh(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 S;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 S;return r.bytesRead}async close(){return await this.fileHandle.close(),super.close()}setPosition(e){this.position=e}supportsRandomAccess(){return!0}};async function Zo(t,e){let i=Wo(t,e);if(t.path){let n=await Sh(t.path);i.fileInfo.path=t.path,i.fileInfo.size=n.size}return i}var Jo=qt.fromFile;var Xo=Et(Qo(),1);function Y(t){return new DataView(t.buffer,t.byteOffset)}var Ko={len:1,get(t,e){return Y(t).getUint8(e)},put(t,e,i){return Y(t).setUint8(e,i),e+1}},O={len:2,get(t,e){return Y(t).getUint16(e,!0)},put(t,e,i){return Y(t).setUint16(e,i,!0),e+2}},Ze={len:2,get(t,e){return Y(t).getUint16(e)},put(t,e,i){return Y(t).setUint16(e,i),e+2}};var A={len:4,get(t,e){return Y(t).getUint32(e,!0)},put(t,e,i){return Y(t).setUint32(e,i,!0),e+4}},es={len:4,get(t,e){return Y(t).getUint32(e)},put(t,e,i){return Y(t).setUint32(e,i),e+4}};var ts={len:4,get(t,e){return Y(t).getInt32(e)},put(t,e,i){return Y(t).setInt32(e,i),e+4}};var is={len:8,get(t,e){return Y(t).getBigUint64(e,!0)},put(t,e,i){return Y(t).setBigUint64(e,i,!0),e+8}};var G=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 Eh}from"module";var Th=Eh("/"),Ah;try{Ah=Th("worker_threads").Worker}catch{}var Z=Uint8Array,Je=Uint16Array,Ch=Int32Array,ns=new Z([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]),rs=new Z([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]),qh=new Z([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),as=function(t,e){for(var i=new Je(31),n=0;n<31;++n)i[n]=e+=1<<t[n-1];for(var r=new Ch(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}},os=as(ns,2),ss=os.b,Fh=os.r;ss[28]=258,Fh[258]=28;var cs=as(rs,0),Mh=cs.b,tO=cs.r,In=new Je(32768);for(_=0;_<32768;++_)le=(_&43690)>>1|(_&21845)<<1,le=(le&52428)>>2|(le&13107)<<2,le=(le&61680)>>4|(le&3855)<<4,In[_]=((le&65280)>>8|(le&255)<<8)>>1;var le,_,Ft=function(t,e,i){for(var n=t.length,r=0,a=new Je(e);r<n;++r)t[r]&&++a[t[r]-1];var o=new Je(e);for(r=1;r<e;++r)o[r]=o[r-1]+a[r-1]<<1;var s;if(i){s=new Je(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],f=o[t[r]-1]++<<p,m=f|(1<<p)-1;f<=m;++f)s[In[f]>>c]=u}else for(s=new Je(n),r=0;r<n;++r)t[r]&&(s[r]=In[o[t[r]-1]++]>>15-t[r]);return s},Mt=new Z(288);for(_=0;_<144;++_)Mt[_]=8;var _;for(_=144;_<256;++_)Mt[_]=9;var _;for(_=256;_<280;++_)Mt[_]=7;var _;for(_=280;_<288;++_)Mt[_]=8;var _,ps=new Z(32);for(_=0;_<32;++_)ps[_]=5;var _;var Ph=Ft(Mt,9,1);var Ih=Ft(ps,5,1),Mn=function(t){for(var e=t[0],i=1;i<t.length;++i)t[i]>e&&(e=t[i]);return e},ie=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]<<8)>>(e&7)&i},Pn=function(t,e){var i=e/8|0;return(t[i]|t[i+1]<<8|t[i+2]<<16)>>(e&7)},zh=function(t){return(t+7)/8|0},Dh=function(t,e,i){return(e==null||e<0)&&(e=0),(i==null||i>t.length)&&(i=t.length),new Z(t.subarray(e,i))};var Rh=["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"],V=function(t,e,i){var n=new Error(e||Rh[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,V),!i)throw n;return n},zn=function(t,e,i,n){var r=t.length,a=n?n.length:0;if(!r||e.f&&!e.l)return i||new Z(0);var o=!i,s=o||e.i!=2,c=e.i;o&&(i=new Z(r*3));var u=function(Ro){var No=i.length;if(Ro>No){var Bo=new Z(Math.max(No*2,Ro));Bo.set(i),i=Bo}},p=e.f||0,f=e.p||0,m=e.b||0,d=e.l,x=e.d,h=e.m,g=e.n,E=r*8;do{if(!d){p=ie(t,f,1);var N=ie(t,f+1,3);if(f+=3,N)if(N==1)d=Ph,x=Ih,h=9,g=5;else if(N==2){var q=ie(t,f,31)+257,Ae=ie(t,f+10,15)+4,xe=q+ie(t,f+5,31)+1;f+=14;for(var B=new Z(xe),Ot=new Z(19),Q=0;Q<Ae;++Q)Ot[qh[Q]]=ie(t,f+Q*3,7);f+=Ae*3;for(var Fo=Mn(Ot),Kd=(1<<Fo)-1,eh=Ft(Ot,Fo,1),Q=0;Q<xe;){var Mo=eh[ie(t,f,Kd)];f+=Mo&15;var T=Mo>>4;if(T<16)B[Q++]=T;else{var He=0,gi=0;for(T==16?(gi=3+ie(t,f,3),f+=2,He=B[Q-1]):T==17?(gi=3+ie(t,f,7),f+=3):T==18&&(gi=11+ie(t,f,127),f+=7);gi--;)B[Q++]=He}}var Po=B.subarray(0,q),be=B.subarray(q);h=Mn(Po),g=Mn(be),d=Ft(Po,h,1),x=Ft(be,g,1)}else V(1);else{var T=zh(f)+4,D=t[T-4]|t[T-3]<<8,W=T+D;if(W>r){c&&V(0);break}s&&u(m+D),i.set(t.subarray(T,W),m),e.b=m+=D,e.p=f=W*8,e.f=p;continue}if(f>E){c&&V(0);break}}s&&u(m+131072);for(var th=(1<<h)-1,ih=(1<<g)-1,On=f;;On=f){var He=d[Pn(t,f)&th],We=He>>4;if(f+=He&15,f>E){c&&V(0);break}if(He||V(2),We<256)i[m++]=We;else if(We==256){On=f,d=null;break}else{var Io=We-254;if(We>264){var Q=We-257,jt=ns[Q];Io=ie(t,f,(1<<jt)-1)+ss[Q],f+=jt}var jn=x[Pn(t,f)&ih],En=jn>>4;jn||V(3),f+=jn&15;var be=Mh[En];if(En>3){var jt=rs[En];be+=Pn(t,f)&(1<<jt)-1,f+=jt}if(f>E){c&&V(0);break}s&&u(m+131072);var zo=m+Io;if(m<be){var Do=a-be,nh=Math.min(be,zo);for(Do+m<0&&V(3);m<nh;++m)i[m]=n[Do+m]}for(;m<zo;++m)i[m]=i[m-be]}}e.l=d,e.p=On,e.b=m,e.f=p,d&&(p=1,e.m=h,e.d=x,e.n=g)}while(!p);return m!=i.length&&o?Dh(i,0,m):i.subarray(0,m)};var Nh=new Z(0);var Bh=function(t){(t[0]!=31||t[1]!=139||t[2]!=8)&&V(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)},Uh=function(t){var e=t.length;return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0};var Lh=function(t,e){return((t[0]&15)!=8||t[0]>>4>7||(t[0]<<8|t[1])%31)&&V(6,"invalid zlib data"),(t[1]>>5&1)==+!e&&V(6,"invalid zlib data: "+(t[1]&32?"need":"unexpected")+" dictionary"),(t[1]>>3&4)+2};function $h(t,e){return zn(t,{i:2},e&&e.out,e&&e.dictionary)}function Yh(t,e){var i=Bh(t);return i+8>t.length&&V(6,"invalid gzip data"),zn(t.subarray(i,-8),{i:2},e&&e.out||new Z(Uh(t)),e&&e.dictionary)}function Gh(t,e){return zn(t.subarray(Lh(t,e&&e.dictionary),-4),{i:2},e&&e.out,e&&e.dictionary)}function us(t,e){return t[0]==31&&t[1]==139&&t[2]==8?Yh(t,e):(t[0]&15)!=8||t[0]>>4>7||(t[0]<<8|t[1])%31?$h(t,e):Gh(t,e)}var Hh=typeof TextDecoder<"u"&&new TextDecoder,Wh=0;try{Hh.decode(Nh,{stream:!0}),Wh=1}catch{}var js=Et(_s(),1);var qe={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},Un={get(t){let e=O.get(t,6);return{signature:A.get(t,0),compressedSize:A.get(t,8),uncompressedSize:A.get(t,12)}},len:16},ks={get(t){let e=O.get(t,6);return{signature:A.get(t,0),minVersion:O.get(t,4),dataDescriptor:!!(e&8),compressedMethod:O.get(t,8),compressedSize:A.get(t,18),uncompressedSize:A.get(t,22),filenameLength:O.get(t,26),extraFieldLength:O.get(t,28),filename:null}},len:30},Ss={get(t){return{signature:A.get(t,0),nrOfThisDisk:O.get(t,4),nrOfThisDiskWithTheStart:O.get(t,6),nrOfEntriesOnThisDisk:O.get(t,8),nrOfEntriesOfSize:O.get(t,10),sizeOfCd:A.get(t,12),offsetOfStartOfCd:A.get(t,16),zipFileCommentLength:O.get(t,20)}},len:22},Os={get(t){let e=O.get(t,8);return{signature:A.get(t,0),minVersion:O.get(t,6),dataDescriptor:!!(e&8),compressedMethod:O.get(t,10),compressedSize:A.get(t,20),uncompressedSize:A.get(t,24),filenameLength:O.get(t,28),extraFieldLength:O.get(t,30),fileCommentLength:O.get(t,32),relativeOffsetOfLocalHeader:A.get(t,42),filename:null}},len:46};function Es(t){let e=new Uint8Array(A.len);return A.put(e,0,t),e}var se=(0,js.default)("tokenizer:inflate"),Ln=256*1024,vv=Es(qe.DataDescriptor),Ai=Es(qe.EndOfCentralDirectory),Ci=class{constructor(e){this.tokenizer=e,this.syncBuffer=new Uint8Array(Ln)}async isZip(){return await this.peekSignature()===qe.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(A)}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()){se("Cannot reading central-directory without random-read support");return}se("Reading central-directory...");let e=this.tokenizer.position,i=await this.findEndOfCentralDirectoryLocator();if(i>0){se("Central-directory 32-bit signature found");let n=await this.tokenizer.readToken(Ss,i),r=[];this.tokenizer.setPosition(n.offsetOfStartOfCd);for(let a=0;a<n.nrOfEntriesOfSize;++a){let o=await this.tokenizer.readToken(Os);if(o.signature!==qe.CentralFileHeader)throw new Error("Expected Central-File-Header signature");o.filename=await this.tokenizer.readToken(new G(o.filenameLength,"utf-8")),await this.tokenizer.ignore(o.extraFieldLength),await this.tokenizer.ignore(o.fileCommentLength),r.push(o),se(`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=Ln;se("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let u=-1;for(;u<0&&c===Ln;){c=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),u=xv(this.syncBuffer.subarray(0,c),vv);let p=u>=0?u:c;if(a.handler){let f=new Uint8Array(p);await this.tokenizer.readBuffer(f),s.push(f)}else await this.tokenizer.ignore(p)}se(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),a.handler&&await this.inflate(r,bv(s),a.handler)}else a.handler?(se(`Reading compressed-file-data: ${r.compressedSize} bytes`),o=new Uint8Array(r.compressedSize),await this.tokenizer.readBuffer(o),await this.inflate(r,o,a.handler)):(se(`Ignoring compressed-file-data: ${r.compressedSize} bytes`),await this.tokenizer.ignore(r.compressedSize));if(se(`Reading data-descriptor at pos=${this.tokenizer.position}`),r.dataDescriptor&&(await this.tokenizer.readToken(Un)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-Un.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);se(`Decompress filename=${e.filename}, compressed-size=${i.length}`);let r=us(i);return n(r)}async readLocalFileHeader(){let e=await this.tokenizer.peekToken(A);if(e===qe.LocalFileHeader){let i=await this.tokenizer.readToken(ks);return i.filename=await this.tokenizer.readToken(new G(i.filenameLength,"utf-8")),i}if(e===qe.CentralFileHeader)return!1;throw e===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}};function xv(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 bv(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 dO={utf8:new globalThis.TextDecoder("utf8")};var hO=new globalThis.TextEncoder;var vO=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function $n(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 Ts(t){return[...t].map(e=>e.charCodeAt(0))}function As(t,e=0){let i=Number.parseInt(new G(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 Cs={get:(t,e)=>t[e+3]&127|t[e+2]<<7|t[e+1]<<14|t[e]<<21,len:4};var qs=["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"],Fs=["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 Pt=4100;function Yn(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 ce(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(Vo(i,this.tokenizerOptions))}async fromBlob(e){return this.fromStream(e.stream())}async fromStream(e){let i=await Si(e,this.tokenizerOptions);try{return await this.fromTokenizer(i)}finally{await i.close()}}async toDetectionStream(e,i){let{sampleSize:n=Pt}=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(f){if(!(f instanceof S))throw f;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 ce(this.buffer,e,i)}checkString(e,i){return this.check(Ts(e),i)}detectConfident=async e=>{if(this.buffer=new Uint8Array(Pt),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(Cs);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=Yn(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=Yn(s))}else{a=a.slice(0,Math.max(0,o));let s=a.lastIndexOf('"'),c=a.slice(Math.max(0,s+1));i=Yn(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),ce(i,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:ce(i,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:ce(i,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:ce(i,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:ce(i,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:ce(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(Ko),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),f=new DataView(c.buffer,c.length-u,u);return{id:$n(p),len:$n(f)}}async function r(s){for(;s>0;){let c=await n();if(c.id===17026)return(await e.readToken(new G(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 G(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 G(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(ts),type:await e.readToken(new G(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 G(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(is))}}for(await e.ignore(30);e.position+24<e.fileInfo.size;){let n=await i(),r=n.size-24;if(ce(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),ce(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(ce(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 G(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})&&As(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(Pt),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?Ze:O);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?Ze:O);for(let n=0;n<i;++n){let r=await this.readTiffTag(e);if(r)return r}}async readTiffHeader(e){let i=(e?Ze:O).get(this.buffer,2),n=(e?es:A).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?Ze:O).get(this.buffer,8),o=(e?Ze:O).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"}}}},OO=new Set(qs),jO=new Set(Fs);var Gn=class extends qi{async fromStream(e){let i=await(e instanceof gv?Si(e,this.tokenizerOptions):Zo(e,this.tokenizerOptions));try{return await super.fromTokenizer(i)}finally{await i.close()}}async fromFile(e){let i=await Jo(e);try{return await super.fromTokenizer(i)}finally{await i.close()}}async toDetectionStream(e,i={}){if(!(e instanceof wv))return super.toDetectionStream(e,i);let{sampleSize:n=Pt}=i;return new Promise((r,a)=>{e.on("error",a),e.once("readable",()=>{(async()=>{try{let o=new yv,s=Ms?Ms(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 S?o.fileType=void 0:a(u)}r(s)}catch(o){a(o)}})()})})}};async function Ps(t,e){return new Gn(e).fromFile(t,e)}var Ec=Et(Hs(),1);var mc=Et(ac(),1);var zt=t=>{if(typeof t!="string")throw new TypeError("invalid pattern");if(t.length>65536)throw new TypeError("pattern is too long")};var Dv={"[: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]},Dt=t=>t.replace(/[[\]\\-]/g,"\\$&"),Rv=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),oc=t=>t.join(""),sc=(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,f="";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,[E,N,T]]of Object.entries(Dv))if(t.startsWith(g,a)){if(f)return["$.",!1,t.length-i,!0];a+=g.length,T?r.push(E):n.push(E),s=s||N;continue e}}if(c=!1,f){h>f?n.push(Dt(f)+"-"+Dt(h)):h===f&&n.push(Dt(h)),f="",a++;continue}if(t.startsWith("-]",a+1)){n.push(Dt(h+"-")),a+=2;continue}if(t.startsWith("-",a+1)){f=h,a+=2;continue}n.push(Dt(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[Rv(h),!1,p-i,!1]}let m="["+(u?"^":"")+oc(n)+"]",d="["+(u?"":"^")+oc(r)+"]";return[n.length&&r.length?"("+m+"|"+d+")":n.length?m:d,s,p-i,!0]};var _e=(t,{windowsPathsNoEscape:e=!1}={})=>e?t.replace(/\[([^\/\\])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1");var Nv=new Set(["!","?","+","*","@"]),cc=t=>Nv.has(t),Bv="(?!(?:^|/)\\.\\.?(?:$|/))",Fi="(?!\\.)",Uv=new Set(["[","."]),Lv=new Set(["..","."]),$v=new Set("().*{}+?[]^$\\!"),Yv=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Zn="[^/]",pc=Zn+"*?",uc=Zn+"+?",et=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,x="";for(;d<e.length;){let h=e.charAt(d++);if(a||h==="\\"){a=!a,x+=h;continue}if(o){d===s+1?(h==="^"||h==="!")&&(c=!0):h==="]"&&!(d===s+2&&c)&&(o=!1),x+=h;continue}else if(h==="["){o=!0,s=d,c=!1,x+=h;continue}if(!r.noext&&cc(h)&&e.charAt(d)==="("){i.push(x),x="";let g=new t(h,i);d=t.#u(e,g,d,r),i.push(g);continue}x+=h}return i.push(x),d}let u=n+1,p=new t(null,i),f=[],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(cc(d)&&e.charAt(u)==="("){p.push(m),m="";let x=new t(d,p);p.push(x),u=t.#u(e,x,u,r);continue}if(d==="|"){p.push(m),m="",f.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(...f,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[x,h,g,E]=typeof d=="string"?t.#d(d,this.#n,c):d.toRegExpSource(e);return this.#n=this.#n||g,this.#a=this.#a||E,x}).join(""),p="";if(this.isStart()&&typeof this.#e[0]=="string"&&!(this.#e.length===1&&Lv.has(this.#e[0]))){let x=Uv,h=i&&x.has(u.charAt(0))||u.startsWith("\\.")&&x.has(u.charAt(2))||u.startsWith("\\.\\.")&&x.has(u.charAt(4)),g=!i&&!e&&x.has(u.charAt(0));p=h?Bv:g?Fi:""}let f="";return this.isEnd()&&this.#i.#s&&this.#t?.type==="!"&&(f="(?:$|\\/)"),[p+u+f,_e(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,_e(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:"")+uc;else{let c=this.type==="!"?"))"+(this.isStart()&&!i&&!e?Fi:"")+pc+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;s=r+a+c}return[s,_e(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+=($v.has(c)?"\\":"")+c;continue}if(c==="\\"){s===e.length-1?a+="\\\\":r=!0;continue}if(c==="["){let[u,p,f,m]=sc(e,s);if(f){a+=u,o=o||p,s+=f-1,i=i||m;continue}}if(c==="*"){n&&e==="*"?a+=uc:a+=pc,i=!0;continue}if(c==="?"){a+=Zn,i=!0;continue}a+=Yv(c)}return[a,_e(e),!!i,o]}};var Jn=(t,{windowsPathsNoEscape:e=!1}={})=>e?t.replace(/[?*()[\]]/g,"[$&]"):t.replace(/[?*()[\]\\]/g,"\\$&");var C=(t,e,i={})=>(zt(e),!i.nocomment&&e.charAt(0)==="#"?!1:new tt(e,i).match(t)),Gv=/^\*+([^+@!?\*\[\(]*)$/,Hv=t=>e=>!e.startsWith(".")&&e.endsWith(t),Wv=t=>e=>e.endsWith(t),Vv=t=>(t=t.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(t)),Zv=t=>(t=t.toLowerCase(),e=>e.toLowerCase().endsWith(t)),Jv=/^\*+\.\*+$/,Qv=t=>!t.startsWith(".")&&t.includes("."),Xv=t=>t!=="."&&t!==".."&&t.includes("."),Kv=/^\.\*+$/,ex=t=>t!=="."&&t!==".."&&t.startsWith("."),tx=/^\*+$/,ix=t=>t.length!==0&&!t.startsWith("."),nx=t=>t.length!==0&&t!=="."&&t!=="..",rx=/^\?+([^+@!?\*\[\(]*)?$/,ax=([t,e=""])=>{let i=dc([t]);return e?(e=e.toLowerCase(),n=>i(n)&&n.toLowerCase().endsWith(e)):i},ox=([t,e=""])=>{let i=hc([t]);return e?(e=e.toLowerCase(),n=>i(n)&&n.toLowerCase().endsWith(e)):i},sx=([t,e=""])=>{let i=hc([t]);return e?n=>i(n)&&n.endsWith(e):i},cx=([t,e=""])=>{let i=dc([t]);return e?n=>i(n)&&n.endsWith(e):i},dc=([t])=>{let e=t.length;return i=>i.length===e&&!i.startsWith(".")},hc=([t])=>{let e=t.length;return i=>i.length===e&&i!=="."&&i!==".."},vc=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",lc={win32:{sep:"\\"},posix:{sep:"/"}},px=vc==="win32"?lc.win32.sep:lc.posix.sep;C.sep=px;var ee=Symbol("globstar **");C.GLOBSTAR=ee;var ux="[^/]",lx=ux+"*?",fx="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",mx="(?:(?!(?:\\/|^)\\.).)*?",dx=(t,e={})=>i=>C(i,t,e);C.filter=dx;var K=(t,e={})=>Object.assign({},t,e),hx=t=>{if(!t||typeof t!="object"||!Object.keys(t).length)return C;let e=C;return Object.assign((n,r,a={})=>e(n,r,K(t,a)),{Minimatch:class extends e.Minimatch{constructor(r,a={}){super(r,K(t,a))}static defaults(r){return e.defaults(K(t,r)).Minimatch}},AST:class extends e.AST{constructor(r,a,o={}){super(r,a,K(t,o))}static fromGlob(r,a={}){return e.AST.fromGlob(r,K(t,a))}},unescape:(n,r={})=>e.unescape(n,K(t,r)),escape:(n,r={})=>e.escape(n,K(t,r)),filter:(n,r={})=>e.filter(n,K(t,r)),defaults:n=>e.defaults(K(t,n)),makeRe:(n,r={})=>e.makeRe(n,K(t,r)),braceExpand:(n,r={})=>e.braceExpand(n,K(t,r)),match:(n,r,a={})=>e.match(n,r,K(t,a)),sep:e.sep,GLOBSTAR:ee})};C.defaults=hx;var xc=(t,e={})=>(zt(t),e.nobrace||!/\{(?:(?!\{).)*\}/.test(t)?[t]:(0,mc.default)(t));C.braceExpand=xc;var vx=(t,e={})=>new tt(t,e).makeRe();C.makeRe=vx;var xx=(t,e,i={})=>{let n=new tt(e,i);return t=t.filter(r=>n.match(r)),n.options.nonull&&!t.length&&t.push(e),t};C.match=xx;var fc=/[?*]|[+@!]\(.*?\)|\[|\]/,bx=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),tt=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(e,i={}){zt(e),i=i||{},this.options=i,this.pattern=e,this.platform=i.platform||vc,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]==="?"||!fc.test(a[2]))&&!fc.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]),E=typeof i[0]=="string"&&/^[a-z]:$/i.test(i[0]),N=!E&&i[0]===""&&i[1]===""&&i[2]==="?"&&typeof i[3]=="string"&&/^[a-z]:$/i.test(i[3]),T=g?3:h?0:void 0,D=N?3:E?0:void 0;if(typeof T=="number"&&typeof D=="number"){let[W,q]=[e[T],i[D]];W.toLowerCase()===q.toLowerCase()&&(i[D]=W,D>T?i=i.slice(D):T>D&&(e=e.slice(T)))}}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],f=e[o];if(this.debug(i,p,f),p===!1)return!1;if(p===ee){this.debug("GLOBSTAR",[i,p,f]);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 x=e[m];if(this.debug(`
22
22
  globstar while`,e,m,i,d,x),this.matchOne(e.slice(m),i.slice(d),n))return this.debug("globstar found match!",m,c,x),!0;if(x==="."||x===".."||!r.dot&&x.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=f===p,this.debug("string match",p,f,h)):(h=p.test(f),this.debug("pattern match",p,f,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 xc(this.pattern,this.options)}parse(e){zt(e);let i=this.options;if(e==="**")return ee;if(e==="")return"";let n,r=null;(n=e.match(tx))?r=i.dot?nx:ix:(n=e.match(Gv))?r=(i.nocase?i.dot?Zv:Vv:i.dot?Wv:Hv)(n[1]):(n=e.match(rx))?r=(i.nocase?i.dot?ox:ax:i.dot?sx:cx)(n):(n=e.match(Jv))?r=i.dot?Xv:Qv:(n=e.match(Kv))&&(r=ex);let a=et.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?lx:i.dot?fx:mx,r=new Set(i.nocase?["i"]:[]),a=e.map(c=>{let u=c.map(p=>{if(p instanceof RegExp)for(let f of p.flags.split(""))r.add(f);return typeof p=="string"?bx(p):p===ee?ee:p._src});return u.forEach((p,f)=>{let m=u[f+1],d=u[f-1];p!==ee||d===ee||(d===void 0?m!==void 0&&m!==ee?u[f+1]="(?:\\/|"+n+"\\/)?"+m:u[f]=n:m===void 0?u[f-1]=d+"(?:\\/|"+n+")?":m!==ee&&(u[f-1]=d+"(?:\\/|\\/"+n+"\\/)"+m,u[f+1]=ee))}),u.filter(p=>p!==ee).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 C.defaults(e).Minimatch}};C.AST=et;C.Minimatch=tt;C.escape=Jn;C.unescape=_e;import{readFile as Mx}from"node:fs/promises";import{extname as Kn,join as Px}from"node:path";var bc="build",gc=[],yc=[],Mi="**/*.+(css|js|mjs)",wc=[".ds_store","thumbs.db"],_c="#dapp",Qn=20;import{createReadStream as gx,createWriteStream as yx}from"node:fs";import{Readable as wx}from"node:stream";import{createGunzip as _x,createGzip as kx}from"node:zlib";var sj=async({source:t})=>await new Promise((e,i)=>{let n=wx.from(t),r=[],a=_x();n.pipe(a),a.on("data",o=>r.push(o)),a.on("end",()=>{e(Buffer.concat(r))}),a.on("error",i)}),kc=async({sourceFiles:t,gzip:e})=>{if(e===!1)return[];let i=e===!0?Mi:e,n=t.filter(r=>C(r,i));return await Promise.all(n.map(async r=>await Sx({source:r})))},Sx=async({source:t,destination:e})=>await new Promise((i,n)=>{let r=gx(t),a=e??`${t}.gz`,o=yx(a),s=kx();r.pipe(s).pipe(o),o.on("close",()=>{i(a)}),o.on("error",n)}),cj=t=>t.length>2&&t[0]===31&&t[1]===139;import{lstatSync as Tx}from"node:fs";import{basename as Ax}from"node:path";import{lstatSync as Ox,readdirSync as jx}from"node:fs";import{access as Ex}from"node:fs/promises";import{join as Sc}from"node:path";var Xn=t=>jx(t).flatMap(e=>{let i=Sc(t,e);return Ox(i).isDirectory()?Xn(i):Sc(i)}),mj=async t=>{try{return await Ex(t),!0}catch(e){if(e instanceof Error&&"code"in e&&e.code==="ENOENT")return!1;throw e}};var Pi=({file:t,sourceAbsolutePath:e})=>t.replace(e,"").replace(/\\/g,"/"),Oc=({sourceAbsolutePath:t,ignore:e})=>Xn(t).filter(n=>Cx({file:n,ignore:e})),Cx=({file:t,ignore:e})=>Tx(t).size<=0||wc.includes(Ax(t).toLowerCase())?!1:e.find(i=>C(t,i))===void 0;var Tc=async({config:t,listAssets:e,assertSourceDirExists:i})=>{let{source:n=bc,ignore:r=gc,encoding:a=yc,gzip:o=Mi}=t,s=Px(process.cwd(),n);return i?.(s),{files:await Rx({sourceAbsolutePath:s,ignore:r,encoding:a,gzip:o,listAssets:e}),sourceAbsolutePath:s}},Ix=async({files:t,sourceAbsolutePath:e,listAssets:i})=>{let n=await i({}),r=t.map(async o=>await Dx({file:o,sourceAbsolutePath:e,existingAssets:n}));return(await Promise.all(r)).filter(({upload:o})=>o).map(({file:o})=>o)},zx=async t=>{let e=await Mx(t);return Fx.createHash("sha256").update(e).digest("base64")},Dx=async({file:t,existingAssets:e,sourceAbsolutePath:i})=>{let n=t.alternateFile??t.file,r=e.find(({fullPath:o})=>o===Pi({file:n,sourceAbsolutePath:i}));if(jc(r))return{file:t,upload:!0};let a=await zx(n);return{file:t,upload:a!==r.encodings.identity?.sha256}},Rx=async({sourceAbsolutePath:t,ignore:e,encoding:i,gzip:n,listAssets:r})=>{let a=Oc({sourceAbsolutePath:t,ignore:e}),o=await kc({sourceFiles:a,gzip:n}),s=[...a,...o.filter(m=>!a.includes(m))],c=({file:m,ext:d})=>{let x=i.find(([h,g])=>C(m,h));if(qx(x)){let[h,g]=x;return g}if(d==="Z")return"compress";if(d==="gz")return"gzip";if(Kn(m)===".br")return"br";if(Kn(m)===".zlib")return"deflate"},u=({file:m,encodingType:d})=>{if(!jc(d))return s.find(x=>x===m.replace(Kn(m),""))},p=async m=>{let d=await Ps(m),x=c({file:m,ext:d?.ext}),h=u({file:m,encodingType:x}),g=Ec.default.lookup(h??m);return{file:m,alternateFile:h,mime:typeof g=="string"?g:void 0,encoding:x}},f=await Promise.all(s.map(p));return await Ix({files:f,sourceAbsolutePath:t,listAssets:r})};var Jd=Et(Zd(),1);import{isNullish as ES,nonNullish as TS}from"@dfinity/utils";import{Blob as AS}from"buffer";import{readFile as CS}from"node:fs/promises";import{basename as qS,relative as FS}from"node:path";var Qd=async({files:t,sourceAbsolutePath:e,uploadFile:i})=>{let n=o=>o.alternateFile??o.file,r=async o=>{let s=n(o);await i({filename:qS(s),fullPath:Pi({file:s,sourceAbsolutePath:e}),data:new AS([await CS(o.file)]),collection:_c,headers:[...o.mime===void 0?[]:[["Content-Type",o.mime]]],encoding:o.encoding})},a=async o=>{for(let s=0;s<o.length;s+=20){let c=o.slice(s,s+20);await new Jd.default(c.map(p=>({title:`Uploading ${FS(e,p.file)}`,task:async()=>await r(p)})),{concurrent:!0}).run()}};await a(t.filter(({alternateFile:o})=>TS(o))),await a(t.filter(({alternateFile:o})=>ES(o)))};var yT=async({config:{predeploy:t}})=>{await Cn(t)},wT=async({config:{postdeploy:t}})=>{await Cn(t)},_T=async({assertMemory:t,uploadFile:e,...i})=>{let{files:n,sourceAbsolutePath:r}=await Tc(i);return n.length===0?(console.log("\u26A0\uFE0F No files detected. Upload skipped."),{result:"skipped"}):(await t?.(),await Qd({files:n,sourceAbsolutePath:r,uploadFile:e}),console.log(`
23
+ >>> no match, partial?`,e,m,i,d),m===c))}let h;if(typeof p=="string"?(h=f===p,this.debug("string match",p,f,h)):(h=p.test(f),this.debug("pattern match",p,f,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 xc(this.pattern,this.options)}parse(e){zt(e);let i=this.options;if(e==="**")return ee;if(e==="")return"";let n,r=null;(n=e.match(tx))?r=i.dot?nx:ix:(n=e.match(Gv))?r=(i.nocase?i.dot?Zv:Vv:i.dot?Wv:Hv)(n[1]):(n=e.match(rx))?r=(i.nocase?i.dot?ox:ax:i.dot?sx:cx)(n):(n=e.match(Jv))?r=i.dot?Xv:Qv:(n=e.match(Kv))&&(r=ex);let a=et.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?lx:i.dot?fx:mx,r=new Set(i.nocase?["i"]:[]),a=e.map(c=>{let u=c.map(p=>{if(p instanceof RegExp)for(let f of p.flags.split(""))r.add(f);return typeof p=="string"?bx(p):p===ee?ee:p._src});return u.forEach((p,f)=>{let m=u[f+1],d=u[f-1];p!==ee||d===ee||(d===void 0?m!==void 0&&m!==ee?u[f+1]="(?:\\/|"+n+"\\/)?"+m:u[f]=n:m===void 0?u[f-1]=d+"(?:\\/|"+n+")?":m!==ee&&(u[f-1]=d+"(?:\\/|\\/"+n+"\\/)"+m,u[f+1]=ee))}),u.filter(p=>p!==ee).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 C.defaults(e).Minimatch}};C.AST=et;C.Minimatch=tt;C.escape=Jn;C.unescape=_e;import{readFile as Mx}from"node:fs/promises";import{extname as Kn,join as Px}from"node:path";var bc="build",gc=[],yc=[],Mi="**/*.+(css|js|mjs|html)",wc=[".ds_store","thumbs.db"],_c="#dapp",Qn=20;import{createReadStream as gx,createWriteStream as yx}from"node:fs";import{Readable as wx}from"node:stream";import{createGunzip as _x,createGzip as kx}from"node:zlib";var sj=async({source:t})=>await new Promise((e,i)=>{let n=wx.from(t),r=[],a=_x();n.pipe(a),a.on("data",o=>r.push(o)),a.on("end",()=>{e(Buffer.concat(r))}),a.on("error",i)}),kc=async({sourceFiles:t,gzip:e})=>{if(e===!1)return[];let i=e===!0?Mi:e,n=t.filter(r=>C(r,i));return await Promise.all(n.map(async r=>await Sx({source:r})))},Sx=async({source:t,destination:e})=>await new Promise((i,n)=>{let r=gx(t),a=e??`${t}.gz`,o=yx(a),s=kx();r.pipe(s).pipe(o),o.on("close",()=>{i(a)}),o.on("error",n)}),cj=t=>t.length>2&&t[0]===31&&t[1]===139;import{lstatSync as Tx}from"node:fs";import{basename as Ax}from"node:path";import{lstatSync as Ox,readdirSync as jx}from"node:fs";import{access as Ex}from"node:fs/promises";import{join as Sc}from"node:path";var Xn=t=>jx(t).flatMap(e=>{let i=Sc(t,e);return Ox(i).isDirectory()?Xn(i):Sc(i)}),mj=async t=>{try{return await Ex(t),!0}catch(e){if(e instanceof Error&&"code"in e&&e.code==="ENOENT")return!1;throw e}};var Pi=({file:t,sourceAbsolutePath:e})=>t.replace(e,"").replace(/\\/g,"/"),Oc=({sourceAbsolutePath:t,ignore:e})=>Xn(t).filter(n=>Cx({file:n,ignore:e})),Cx=({file:t,ignore:e})=>Tx(t).size<=0||wc.includes(Ax(t).toLowerCase())?!1:e.find(i=>C(t,i))===void 0;var Tc=async({config:t,listAssets:e,assertSourceDirExists:i})=>{let{source:n=bc,ignore:r=gc,encoding:a=yc,gzip:o=Mi}=t,s=Px(process.cwd(),n);return i?.(s),{files:await Rx({sourceAbsolutePath:s,ignore:r,encoding:a,gzip:o,listAssets:e}),sourceAbsolutePath:s}},Ix=async({files:t,sourceAbsolutePath:e,listAssets:i})=>{let n=await i({}),r=t.map(async o=>await Dx({file:o,sourceAbsolutePath:e,existingAssets:n}));return(await Promise.all(r)).filter(({upload:o})=>o).map(({file:o})=>o)},zx=async t=>{let e=await Mx(t);return Fx.createHash("sha256").update(e).digest("base64")},Dx=async({file:t,existingAssets:e,sourceAbsolutePath:i})=>{let n=t.alternateFile??t.file,r=e.find(({fullPath:o})=>o===Pi({file:n,sourceAbsolutePath:i}));if(jc(r))return{file:t,upload:!0};let a=await zx(n);return{file:t,upload:a!==r.encodings.identity?.sha256}},Rx=async({sourceAbsolutePath:t,ignore:e,encoding:i,gzip:n,listAssets:r})=>{let a=Oc({sourceAbsolutePath:t,ignore:e}),o=await kc({sourceFiles:a,gzip:n}),s=[...a,...o.filter(m=>!a.includes(m))],c=({file:m,ext:d})=>{let x=i.find(([h,g])=>C(m,h));if(qx(x)){let[h,g]=x;return g}if(d==="Z")return"compress";if(d==="gz")return"gzip";if(Kn(m)===".br")return"br";if(Kn(m)===".zlib")return"deflate"},u=({file:m,encodingType:d})=>{if(!jc(d))return s.find(x=>x===m.replace(Kn(m),""))},p=async m=>{let d=await Ps(m),x=c({file:m,ext:d?.ext}),h=u({file:m,encodingType:x}),g=Ec.default.lookup(h??m);return{file:m,alternateFile:h,mime:typeof g=="string"?g:void 0,encoding:x}},f=await Promise.all(s.map(p));return await Ix({files:f,sourceAbsolutePath:t,listAssets:r})};var Jd=Et(Zd(),1);import{isNullish as ES,nonNullish as TS}from"@dfinity/utils";import{Blob as AS}from"buffer";import{readFile as CS}from"node:fs/promises";import{basename as qS,relative as FS}from"node:path";var Qd=async({files:t,sourceAbsolutePath:e,uploadFile:i})=>{let n=o=>o.alternateFile??o.file,r=async o=>{let s=n(o);await i({filename:qS(s),fullPath:Pi({file:s,sourceAbsolutePath:e}),data:new AS([await CS(o.file)]),collection:_c,headers:[...o.mime===void 0?[]:[["Content-Type",o.mime]]],encoding:o.encoding})},a=async o=>{for(let s=0;s<o.length;s+=20){let c=o.slice(s,s+20);await new Jd.default(c.map(p=>({title:`Uploading ${FS(e,p.file)}`,task:async()=>await r(p)})),{concurrent:!0}).run()}};await a(t.filter(({alternateFile:o})=>TS(o))),await a(t.filter(({alternateFile:o})=>ES(o)))};var yT=async({config:{predeploy:t}})=>{await Cn(t)},wT=async({config:{postdeploy:t}})=>{await Cn(t)},_T=async({assertMemory:t,uploadFile:e,...i})=>{let{files:n,sourceAbsolutePath:r}=await Tc(i);return n.length===0?(console.log("\u26A0\uFE0F No files detected. Upload skipped."),{result:"skipped"}):(await t?.(),await Qd({files:n,sourceAbsolutePath:r,uploadFile:e}),console.log(`
24
24
  \u{1F680} Deploy complete!`),{result:"deployed",files:n})};import{fromNullable as MS,isNullish as PS,uint8ArrayToHexString as IS}from"@dfinity/utils";import{commitProposal as zS,initProposal as DS,submitProposal as RS}from"@junobuild/cdn";var jT=async({proposalType:t,cdn:e,deploy:i,autoCommit:n})=>{let[r,a]=await DS({proposalType:t,cdn:e}),{result:o}=await i(r);o==="skipped"&&process.exit(0);let[s,{sha256:c,status:u}]=await RS({cdn:e,proposalId:r}),p=MS(c);console.log(`
25
25
  Change submitted.
26
- `),console.log("\u{1F194} ",r),console.log("\u23F3 ",u),PS(p)&&(console.log("\u274C Hash undefined. This is unexpected."),process.exit(1)),console.log("\u{1F512} ",IS(p)),n&&(await zS({commitProposal:{proposal_id:r,sha256:p},cdn:e}),console.log(`\u{1F3AF} Change ${r} committed.`))};var TT=({args:t,options:e})=>t?.find(i=>e.includes(i))!==void 0,AT=({args:t,option:e})=>{let i=(t??[]).findIndex(n=>n===e);if(i!==-1)return t?.[i+1]};import{nonNullish as Xd}from"@dfinity/utils";import{get as NS}from"https";var BS=async t=>await new Promise((e,i)=>{NS(t,async n=>{Xd(n.statusCode)&&Xd(n.headers.location)&&[301,302].includes(n.statusCode)&&await BS(n.headers.location).then(e,i);let r=[];n.on("data",a=>r.push(a)),n.on("end",()=>{e(Buffer.concat(r))}),n.on("error",i)})});import{readFile as US}from"node:fs/promises";var IT=async({packageJsonPath:t})=>{let e=await US(t,"utf-8"),{dependencies:i,version:n,juno:r,name:a}=JSON.parse(e);return{name:a,version:n,dependencies:i,juno:r}};import{isNullish as LS,nonNullish as $S}from"@dfinity/utils";var RT=(t,e)=>{(LS(t)||t==="")&&($S(e)&&console.error(e),process.exit(1))};export{_c as COLLECTION_DAPP,yc as DEPLOY_DEFAULT_ENCODING,Mi as DEPLOY_DEFAULT_GZIP,gc as DEPLOY_DEFAULT_IGNORE,bc as DEPLOY_DEFAULT_SOURCE,wc as IGNORE_OS_FILES,Qn as UPLOAD_BATCH_SIZE,RT as assertAnswerCtrlC,HS as buildEsm,_T as deploy,jT as deployWithProposal,BS as downloadFromURL,Ho as execute,mj as fileExists,Xn as files,sj as gunzipFile,Sx as gzipFile,kc as gzipFiles,TT as hasArgs,cj as isGzip,AT as nextArg,wT as postDeploy,yT as preDeploy,IT as readPackageJson,n3 as spawn};
26
+ `),console.log("\u{1F194} ",r),console.log("\u23F3 ",u),PS(p)&&(console.log("\u274C Hash undefined. This is unexpected."),process.exit(1)),console.log("\u{1F512} ",IS(p)),n&&(await zS({proposal:{proposal_id:r,sha256:p},cdn:e}),console.log(`\u{1F3AF} Change ${r} committed.`))};var TT=({args:t,options:e})=>t?.find(i=>e.includes(i))!==void 0,AT=({args:t,option:e})=>{let i=(t??[]).findIndex(n=>n===e);if(i!==-1)return t?.[i+1]};import{nonNullish as Xd}from"@dfinity/utils";import{get as NS}from"https";var BS=async t=>await new Promise((e,i)=>{NS(t,async n=>{Xd(n.statusCode)&&Xd(n.headers.location)&&[301,302].includes(n.statusCode)&&await BS(n.headers.location).then(e,i);let r=[];n.on("data",a=>r.push(a)),n.on("end",()=>{e(Buffer.concat(r))}),n.on("error",i)})});import{readFile as US}from"node:fs/promises";var IT=async({packageJsonPath:t})=>{let e=await US(t,"utf-8"),{dependencies:i,version:n,juno:r,name:a}=JSON.parse(e);return{name:a,version:n,dependencies:i,juno:r}};import{isNullish as LS,nonNullish as $S}from"@dfinity/utils";var RT=(t,e)=>{(LS(t)||t==="")&&($S(e)&&console.error(e),process.exit(1))};export{_c as COLLECTION_DAPP,yc as DEPLOY_DEFAULT_ENCODING,Mi as DEPLOY_DEFAULT_GZIP,gc as DEPLOY_DEFAULT_IGNORE,bc as DEPLOY_DEFAULT_SOURCE,wc as IGNORE_OS_FILES,Qn as UPLOAD_BATCH_SIZE,RT as assertAnswerCtrlC,HS as buildEsm,_T as deploy,jT as deployWithProposal,BS as downloadFromURL,Ho as execute,mj as fileExists,Xn as files,sj as gunzipFile,Sx as gzipFile,kc as gzipFiles,TT as hasArgs,cj as isGzip,AT as nextArg,wT as postDeploy,yT as preDeploy,IT as readPackageJson,n3 as spawn};
27
27
  /*! Bundled license information:
28
28
 
29
29
  ieee754/index.js: