@junobuild/cli-tools 0.1.7 → 0.1.8-next-2025-04-06
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/node/index.mjs
CHANGED
|
@@ -17,11 +17,11 @@ var Qd=Object.create;var Bo=Object.defineProperty;var Xd=Object.getOwnPropertyDe
|
|
|
17
17
|
`;r=lS(r,fS(t),{trim:!1,hard:!0,wordWrap:!1}),t.write(Wf.eraseLines(i)+r),i=r.split(`
|
|
18
18
|
`).length};return n.clear=()=>{t.write(Wf.eraseLines(i)),i=0},n.done=()=>{i=0,e.showCursor||Vf.show()},n};gn.exports=so(process.stdout);gn.exports.stderr=so(process.stderr);gn.exports.create=so});var Qf=l((l4,Jf)=>{"use strict";var mS=/[|\\{}()[\]^$+*?.]/g;Jf.exports=function(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(mS,"\\$&")}});var Kf=l((f4,Xf)=>{"use strict";function dS(){var t={modifiers:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},colors:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39]},bgColors:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49]}};return t.colors.grey=t.colors.gray,Object.keys(t).forEach(function(e){var i=t[e];Object.keys(i).forEach(function(n){var r=i[n];t[n]=i[n]={open:"\x1B["+r[0]+"m",close:"\x1B["+r[1]+"m"}}),Object.defineProperty(t,e,{value:i,enumerable:!1})}),t}Object.defineProperty(Xf,"exports",{enumerable:!0,get:dS})});var tm=l((m4,em)=>{"use strict";em.exports=function(){return/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PRZcf-nqry=><]/g}});var co=l((d4,im)=>{"use strict";var hS=tm()();im.exports=function(t){return typeof t=="string"?t.replace(hS,""):t}});var rm=l((h4,nm)=>{"use strict";nm.exports=function(){return/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PRZcf-nqry=><]/g}});var uo=l((v4,om)=>{"use strict";var vS=rm(),am=new RegExp(vS().source);om.exports=am.test.bind(am)});var pm=l((x4,um)=>{"use strict";var cm=process.argv,sm=cm.indexOf("--"),$e=function(t){t="--"+t;var e=cm.indexOf(t);return e!==-1&&(sm!==-1?e<sm:!0)};um.exports=function(){return"FORCE_COLOR"in process.env?!0:$e("no-color")||$e("no-colors")||$e("color=false")?!1:$e("color")||$e("colors")||$e("color=true")||$e("color=always")?!0:process.stdout&&!process.stdout.isTTY?!1:process.platform==="win32"||"COLORTERM"in process.env?!0:process.env.TERM==="dumb"?!1:!!/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)}()});var po=l((b4,yt)=>{"use strict";var xS=Qf(),me=Kf(),bS=co(),gS=uo(),lm=pm(),fm=Object.defineProperties,mm=process.platform==="win32"&&!/^xterm/i.test(process.env.TERM);function dm(t){this.enabled=!t||t.enabled===void 0?lm:t.enabled}mm&&(me.blue.open="\x1B[94m");var hm=function(){var t={};return Object.keys(me).forEach(function(e){me[e].closeRe=new RegExp(xS(me[e].close),"g"),t[e]={get:function(){return vm.call(this,this._styles.concat(e))}}}),t}(),yS=fm(function(){},hm);function vm(t){var e=function(){return wS.apply(e,arguments)};return e._styles=t,e.enabled=this.enabled,e.__proto__=yS,e}function wS(){var t=arguments,e=t.length,i=e!==0&&String(arguments[0]);if(e>1)for(var n=1;n<e;n++)i+=" "+t[n];if(!this.enabled||!i)return i;var r=this._styles,a=r.length,o=me.dim.open;for(mm&&(r.indexOf("gray")!==-1||r.indexOf("grey")!==-1)&&(me.dim.open="");a--;){var s=me[r[a]];i=s.open+i.replace(s.closeRe,s.open)+s.close}return me.dim.open=o,i}function _S(){var t={};return Object.keys(hm).forEach(function(e){t[e]={get:function(){return vm.call(this,[e])}}}),t}fm(dm.prototype,_S());yt.exports=new dm;yt.exports.styles=me;yt.exports.hasColor=gS;yt.exports.stripColor=bS;yt.exports.supportsColor=lm});var gm=l((g4,bm)=>{"use strict";var xm=Object.getOwnPropertySymbols,SS=Object.prototype.hasOwnProperty,kS=Object.prototype.propertyIsEnumerable;function OS(t){if(t==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}function ES(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de",Object.getOwnPropertyNames(t)[0]==="5")return!1;for(var e={},i=0;i<10;i++)e["_"+String.fromCharCode(i)]=i;var n=Object.getOwnPropertyNames(e).map(function(a){return e[a]});if(n.join("")!=="0123456789")return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(a){r[a]=a}),Object.keys(Object.assign({},r)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}bm.exports=ES()?Object.assign:function(t,e){for(var i,n=OS(t),r,a=1;a<arguments.length;a++){i=Object(arguments[a]);for(var o in i)SS.call(i,o)&&(n[o]=i[o]);if(xm){r=xm(i);for(var s=0;s<r.length;s++)kS.call(i,r[s])&&(n[r[s]]=i[r[s]])}}return n}});var wm=l((y4,ym)=>{"use strict";var jS=/[|\\{}()[\]^$+*?.]/g;ym.exports=function(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(jS,"\\$&")}});var lo=l((w4,Sm)=>{"use strict";var TS=gm(),AS=wm(),_m=process.platform,ae={tick:"\u2714",cross:"\u2716",star:"\u2605",square:"\u2587",squareSmall:"\u25FB",squareSmallFilled:"\u25FC",play:"\u25B6",circle:"\u25EF",circleFilled:"\u25C9",circleDotted:"\u25CC",circleDouble:"\u25CE",circleCircle:"\u24DE",circleCross:"\u24E7",circlePipe:"\u24BE",circleQuestionMark:"?\u20DD",bullet:"\u25CF",dot:"\u2024",line:"\u2500",ellipsis:"\u2026",pointer:"\u276F",pointerSmall:"\u203A",info:"\u2139",warning:"\u26A0",hamburger:"\u2630",smiley:"\u32E1",mustache:"\u0DF4",heart:"\u2665",arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",radioOn:"\u25C9",radioOff:"\u25EF",checkboxOn:"\u2612",checkboxOff:"\u2610",checkboxCircleOn:"\u24E7",checkboxCircleOff:"\u24BE",questionMarkPrefix:"?\u20DD",oneHalf:"\xBD",oneThird:"\u2153",oneQuarter:"\xBC",oneFifth:"\u2155",oneSixth:"\u2159",oneSeventh:"\u2150",oneEighth:"\u215B",oneNinth:"\u2151",oneTenth:"\u2152",twoThirds:"\u2154",twoFifths:"\u2156",threeQuarters:"\xBE",threeFifths:"\u2157",threeEighths:"\u215C",fourFifths:"\u2158",fiveSixths:"\u215A",fiveEighths:"\u215D",sevenEighths:"\u215E"},CS={tick:"\u221A",cross:"\xD7",star:"*",square:"\u2588",squareSmall:"[ ]",squareSmallFilled:"[\u2588]",play:"\u25BA",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(\u25CB)",circleCross:"(\xD7)",circlePipe:"(\u2502)",circleQuestionMark:"(?)",bullet:"*",dot:".",line:"\u2500",ellipsis:"...",pointer:">",pointerSmall:"\xBB",info:"i",warning:"\u203C",hamburger:"\u2261",smiley:"\u263A",mustache:"\u250C\u2500\u2510",heart:ae.heart,arrowUp:ae.arrowUp,arrowDown:ae.arrowDown,arrowLeft:ae.arrowLeft,arrowRight:ae.arrowRight,radioOn:"(*)",radioOff:"( )",checkboxOn:"[\xD7]",checkboxOff:"[ ]",checkboxCircleOn:"(\xD7)",checkboxCircleOff:"( )",questionMarkPrefix:"\uFF1F",oneHalf:"1/2",oneThird:"1/3",oneQuarter:"1/4",oneFifth:"1/5",oneSixth:"1/6",oneSeventh:"1/7",oneEighth:"1/8",oneNinth:"1/9",oneTenth:"1/10",twoThirds:"2/3",twoFifths:"2/5",threeQuarters:"3/4",threeFifths:"3/5",threeEighths:"3/8",fourFifths:"4/5",fiveSixths:"5/6",fiveEighths:"5/8",sevenEighths:"7/8"};_m==="linux"&&(ae.questionMarkPrefix="?");var yn=_m==="win32"?CS:ae,qS=function(t){return yn===ae||Object.keys(ae).forEach(function(e){ae[e]!==yn[e]&&(t=t.replace(new RegExp(AS(ae[e]),"g"),yn[e]))}),t};Sm.exports=TS(qS,yn)});var Om=l((_4,km)=>{"use strict";km.exports=(t,e,i)=>{let n=typeof i=="object"?Object.assign({indent:" "},i):{indent:i||" "};if(e=e===void 0?1:e,typeof t!="string")throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof t}\``);if(typeof e!="number")throw new TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof e}\``);if(typeof n.indent!="string")throw new TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof n.indent}\``);if(e===0)return t;let r=n.includeEmptyLines?/^/mg:/^(?!\s*$)/mg;return t.replace(r,n.indent.repeat(e))}});var Am=l((S4,Tm)=>{"use strict";var jm=["\x1B","\x9B"],fo=39,FS={0:0,1:22,2:22,3:23,4:24,7:27,8:28,9:29,30:39,31:39,32:39,33:39,34:39,35:39,36:39,37:39,90:39,40:49,41:49,42:49,43:49,44:49,45:49,46:49,47:49};function Em(t){return jm[0]+"["+t+"m"}Tm.exports=function(t,e,i){i=i||t.length;for(var n=!1,r,a=0,o="",s=0;s<t.length;s++){var c=!1,p=t[s];if(jm.indexOf(p)!==-1){n=!0;var u=/[0-9][^m]*/.exec(t.slice(s,s+4));r=u===fo?null:u}else n&&p==="m"&&(n=!1,c=!0);if(!n&&!c&&++a,a>e&&a<=i)o+=p;else if(a===e&&r!==void 0&&r!==fo)o+=Em(r);else if(a>=i){r!==void 0&&(o+=Em(FS[r]||fo));break}}return o}});var qm=l((k4,Cm)=>{"use strict";Cm.exports=function(){return/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PRZcf-nqry=><]/g}});var Mm=l((O4,Fm)=>{"use strict";var MS=qm()();Fm.exports=function(t){return typeof t=="string"?t.replace(MS,""):t}});var Im=l((E4,Pm)=>{"use strict";Pm.exports=function(t,e){if(t==null)throw TypeError();t=String(t);var i=t.length,n=e?Number(e):0;if(Number.isNaN(n)&&(n=0),!(n<0||n>=i)){var r=t.charCodeAt(n);if(r>=55296&&r<=56319&&i>n+1){var a=t.charCodeAt(n+1);if(a>=56320&&a<=57343)return(r-55296)*1024+a-56320+65536}return r}}});var zm=l((j4,Dm)=>{"use strict";Dm.exports=Number.isNaN||function(t){return t!==t}});var Nm=l((T4,Rm)=>{"use strict";var PS=zm();Rm.exports=function(t){return PS(t)?!1:t>=4352&&(t<=4447||t===9001||t===9002||11904<=t&&t<=12871&&t!==12351||12880<=t&&t<=19903||19968<=t&&t<=42182||43360<=t&&t<=43388||44032<=t&&t<=55203||63744<=t&&t<=64255||65040<=t&&t<=65049||65072<=t&&t<=65131||65281<=t&&t<=65376||65504<=t&&t<=65510||110592<=t&&t<=110593||127488<=t&&t<=127569||131072<=t&&t<=262141)}});var Lm=l((A4,Bm)=>{"use strict";var IS=Mm(),DS=Im(),zS=Nm();Bm.exports=function(t){if(typeof t!="string"||t.length===0)return 0;var e=0;t=IS(t);for(var i=0;i<t.length;i++){var n=DS(t,i);n<=31||n>=127&&n<=159||(n>=65536&&i++,zS(n)?e+=2:e++)}return e}});var $m=l((C4,Um)=>{"use strict";var wn=Am(),RS=Lm();Um.exports=function(t,e,i){i=i||{};var n=i.position||"end",r="\u2026";if(typeof t!="string")throw new TypeError("Expected `input` to be a string, got "+typeof t);if(typeof e!="number")throw new TypeError("Expected `columns` to be a number, got "+typeof e);if(e<1)return"";if(e===1)return r;var a=RS(t);if(a<=e)return t;if(n==="start")return r+wn(t,a-e+1,a);if(n==="middle"){var o=Math.floor(e/2);return wn(t,0,o)+r+wn(t,a-(e-o)+1,a)}else if(n==="end")return wn(t,0,e-1)+r;throw new Error("Expected `options.position` to be either `start`, `middle` or `end`, got "+n)}});var Gm=l((q4,Ym)=>{"use strict";var NS=/[|\\{}()[\]^$+*?.]/g;Ym.exports=function(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(NS,"\\$&")}});var Wm=l((F4,Hm)=>{"use strict";function BS(){var t={modifiers:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},colors:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39]},bgColors:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49]}};return t.colors.grey=t.colors.gray,Object.keys(t).forEach(function(e){var i=t[e];Object.keys(i).forEach(function(n){var r=i[n];t[n]=i[n]={open:"\x1B["+r[0]+"m",close:"\x1B["+r[1]+"m"}}),Object.defineProperty(t,e,{value:i,enumerable:!1})}),t}Object.defineProperty(Hm,"exports",{enumerable:!0,get:BS})});var Zm=l((M4,Vm)=>{"use strict";Vm.exports=function(){return/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PRZcf-nqry=><]/g}});var Qm=l((P4,Jm)=>{"use strict";var LS=Zm()();Jm.exports=function(t){return typeof t=="string"?t.replace(LS,""):t}});var td=l((I4,ed)=>{"use strict";var Km=process.argv,Xm=Km.indexOf("--"),Ye=function(t){t="--"+t;var e=Km.indexOf(t);return e!==-1&&(Xm!==-1?e<Xm:!0)};ed.exports=function(){return"FORCE_COLOR"in process.env?!0:Ye("no-color")||Ye("no-colors")||Ye("color=false")?!1:Ye("color")||Ye("colors")||Ye("color=true")||Ye("color=always")?!0:process.stdout&&!process.stdout.isTTY?!1:process.platform==="win32"||"COLORTERM"in process.env?!0:process.env.TERM==="dumb"?!1:!!/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)}()});var cd=l((D4,wt)=>{"use strict";var US=Gm(),de=Wm(),$S=Qm(),YS=uo(),id=td(),nd=Object.defineProperties,rd=process.platform==="win32"&&!/^xterm/i.test(process.env.TERM);function ad(t){this.enabled=!t||t.enabled===void 0?id:t.enabled}rd&&(de.blue.open="\x1B[94m");var od=function(){var t={};return Object.keys(de).forEach(function(e){de[e].closeRe=new RegExp(US(de[e].close),"g"),t[e]={get:function(){return sd.call(this,this._styles.concat(e))}}}),t}(),GS=nd(function(){},od);function sd(t){var e=function(){return HS.apply(e,arguments)};return e._styles=t,e.enabled=this.enabled,e.__proto__=GS,e}function HS(){var t=arguments,e=t.length,i=e!==0&&String(arguments[0]);if(e>1)for(var n=1;n<e;n++)i+=" "+t[n];if(!this.enabled||!i)return i;var r=this._styles,a=r.length,o=de.dim.open;for(rd&&(r.indexOf("gray")!==-1||r.indexOf("grey")!==-1)&&(de.dim.open="");a--;){var s=de[r[a]];i=s.open+i.replace(s.closeRe,s.open)+s.close}return de.dim.open=o,i}function WS(){var t={};return Object.keys(od).forEach(function(e){t[e]={get:function(){return sd.call(this,[e])}}}),t}nd(ad.prototype,WS());wt.exports=new ad;wt.exports.styles=de;wt.exports.hasColor=YS;wt.exports.stripColor=$S;wt.exports.supportsColor=id});var pd=l((z4,ud)=>{"use strict";var Te=cd(),VS={info:Te.blue("\u2139"),success:Te.green("\u2714"),warning:Te.yellow("\u26A0"),error:Te.red("\u2716")},ZS={info:Te.blue("i"),success:Te.green("\u221A"),warning:Te.yellow("\u203C"),error:Te.red("\xD7")};ud.exports=process.platform==="win32"?ZS:VS});var ld=l((R4,ho)=>{"use strict";var mo=process.platform==="win32"?["-","\\","|","/"]:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];ho.exports=function(){var t=0;return function(){return mo[t=++t%mo.length]}};ho.exports.frames=mo});var hd=l(xo=>{"use strict";var vo=po(),fd=pd(),dd=lo(),JS=ld(),md=vo.yellow(dd.pointer),QS=vo.yellow(dd.arrowDown);xo.isDefined=t=>t!=null;xo.getSymbol=(t,e)=>(t.spinner||(t.spinner=JS()),t.isPending()?e.showSubtasks!==!1&&t.subtasks.length>0?md:vo.yellow(t.spinner()):t.isCompleted()?fd.success:t.hasFailed()?t.subtasks.length>0?md:fd.error:t.isSkipped()?QS:" ")});var wd=l((B4,yd)=>{"use strict";var go=Zf(),vd=po(),XS=lo(),xd=Om(),KS=$m(),ek=co(),bo=hd(),gd=(t,e,i)=>{i=i||0;let n=[];for(let r of t)if(r.isEnabled()){let a=r.isSkipped()?` ${vd.dim("[skipped]")}`:"";if(n.push(xd(` ${bo.getSymbol(r,e)} ${r.title}${a}`,i," ")),(r.isPending()||r.isSkipped()||r.hasFailed())&&bo.isDefined(r.output)){let o=r.output;if(typeof o=="string"&&(o=ek(o.trim().split(`
|
|
19
19
|
`).filter(Boolean).pop()),o===""&&(o=void 0)),bo.isDefined(o)){let s=xd(`${XS.arrowRight} ${o}`,i," ");n.push(` ${vd.gray(KS(s,process.stdout.columns-3))}`)}}(r.isPending()||r.hasFailed()||e.collapse===!1)&&(r.hasFailed()||e.showSubtasks!==!1)&&r.subtasks.length>0&&(n=n.concat(gd(r.subtasks,e,i+1)))}return n.join(`
|
|
20
|
-
`)},bd=(t,e)=>{go(gd(t,e))},yo=class{constructor(e,i){this._tasks=e,this._options=Object.assign({showSubtasks:!0,collapse:!0,clearOutput:!1},i)}render(){this._id||(this._id=setInterval(()=>{bd(this._tasks,this._options)},100))}end(e){this._id&&(clearInterval(this._id),this._id=void 0),bd(this._tasks,this._options),this._options.clearOutput&&e===void 0?go.clear():go.done()}};yd.exports=yo});var wo=l(kd=>{"use strict";var _n={silent:Zp(),verbose:Mf(),default:wd()},_d=t=>process.stdout.isTTY===!0||t.nonTTY===!0,Sd=t=>typeof t=="string"?_n[t]||_n.default:typeof t=="function"?t:_n.default;kd.getRenderer=(t,e)=>{let i=Sd(t);return _d(i)||(i=Sd(e),(!i||!_d(i))&&(i=_n.verbose)),i}});var _o=l((U4,Od)=>{"use strict";var _t={PENDING:0,COMPLETED:1,FAILED:2,SKIPPED:3};_t.toString=t=>{switch(t){case _t.PENDING:return"pending";case _t.COMPLETED:return"completed";case _t.FAILED:return"failed";case _t.SKIPPED:return"skipped";default:return"unknown"}};Od.exports=_t});var jd=l(($4,Ed)=>{"use strict";var he=Ed.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 Td=l(So=>{"use strict";Object.defineProperty(So,"__esModule",{value:!0});So.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 Ad=l((Oo,ko)=>{"use strict";Object.defineProperty(Oo,"__esModule",{value:!0});var ik=Td(),nk=rk(ik);function rk(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 ko<"u"?St=ko:St=Function("return this")();var ak=(0,nk.default)(St);Oo.default=ak});var Fd=l((G4,qd)=>{"use strict";var Cd=Ad().default;qd.exports=t=>!!(t&&t[Cd]&&t===t[Cd]())});var Id=l(Sn=>{"use strict";var ok=jd(),Md=typeof Symbol=="function"&&Symbol.observable||"@@observable",Pd=t=>!!(t&&t[Md]&&t===t[Md]())||Fd()(t);Sn.isListr=t=>!!(t&&t.setRenderer&&t.add&&t.run);Sn.isObservable=t=>Pd(t);Sn.isStream=t=>ok(t)&&!Pd(t)});var kn=l((W4,Dd)=>{"use strict";var Eo=class extends Error{constructor(e){super(e),this.name="ListrError"}};Dd.exports=Eo});var Rd=l((V4,zd)=>{"use strict";var sk=Ec(),ck=Dc(),uk=Wp().Subject,pk=wo(),ve=_o(),jo=Id(),lk=kn(),fk=()=>!1,To=class extends uk{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||fk,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=>jo.isListr(r)?(r._options=Object.assign(this._options,r._options),r.exitOnError=r._options.exitOnError,r.setRenderer(pk.getRenderer("silent")),this._subtasks=r.tasks,this.next({type:"SUBTASKS"}),r.run(e)):(jo.isStream(r)&&(r=ck(r)),jo.isObservable(r)&&(r=new Promise((a,o)=>{r.subscribe({next:s=>{this.output=s,this.next({type:"DATA",data:s})},error:o,complete:a})})),sk(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 lk){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()})}};zd.exports=To});var Bd=l((Z4,Nd)=>{"use strict";var mk=_o(),dk=kn(),Ao=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 dk)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=mk.SKIPPED}run(e){return this._task.run(e,this)}};Nd.exports=Ao});var $d=l((J4,Ud)=>{"use strict";var hk=kc(),vk=Rd(),xk=Bd(),Ld=wo(),bk=kn(),gk=(t,e,i)=>t.isEnabled()?new xk(t,i).run(e):Promise.resolve(),Co=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=Ld.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=Ld.getRenderer(e)}add(e){let i=Array.isArray(e)?e:[e];for(let n of i)this._tasks.push(new vk(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),hk(this._tasks,r=>(this._checkAll(e),gk(r,e,i)),{concurrency:this.concurrency}).then(()=>{if(i.length>0){let r=new bk("Something went wrong");throw r.errors=i,r}return this._renderer.end(),e}).catch(r=>{throw r.context=e,this._renderer.end(r),r})}};Ud.exports=Co});import{rm as nh}from"node:fs/promises";var Pk=async({infile:t,outfile:e})=>{await rh();let{build:i,version:n}=await import("esbuild");await nh(e,{force:!0});let{metafile:r,errors:a,warnings:o}=await i({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});return{metafile:r,errors:a,warnings:o,version:n}},rh=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 gi}from"@dfinity/utils";import{spawn as Yo}from"child_process";import{nonNullish as ah}from"@dfinity/utils";import{stat as oh}from"node:fs/promises";import Lo from"node:path";import Uo from"node:process";import{URL as sh}from"node:url";var An=async(t,e,i)=>await ch(t,i)?[Tn(t),e.map(n=>fh(n)),{...i,shell:!0}]:[t,e,i],ch=async(t,{shell:e,cwd:i,env:n=Uo.env})=>Uo.platform==="win32"&&!e&&!await uh(t,i,n),uh=async(t,e,{Path:i="",PATH:n=i})=>$o.some(r=>t.toLowerCase().endsWith(r))||(ph[`${t}\0${e}\0${n}`]??=await lh(t,e,n)),ph={},lh=async(t,e,i)=>{let n=i.split(Lo.delimiter).filter(Boolean).map(r=>r.replace(/^"(.*)"$/,"$1"));try{await Promise.all($o.flatMap(r=>[e,...n].filter(ah).map(a=>`${Lo.resolve(a instanceof sh?a.toString():a,t)}${r}`)).map(async r=>{try{await oh(r)}catch{return}throw 0}))}catch{return!0}return!1},$o=[".exe",".com"],fh=t=>Tn(Tn(`"${t.replaceAll(/(\\*)"/g,'$1$1\\"').replace(/(\\*)$/,"$1$1")}"`)),Tn=t=>t.replaceAll(/([()\][%!^"`<>&|;, *?])/g,"^$1");var Gk=async({command:t,cwd:e,args:i,env:n,stdout:r,silentOut:a=!1,silentErrors:o=!1})=>await new Promise(async(s,c)=>{let[p,u,f]=await An(t,i??[],{shell:!0,...gi(e)&&{cwd:e},...gi(n)&&{env:n}}),m=Yo(p,u,f);m.stdout.on("data",d=>{if(gi(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)})}),Go=async({command:t,args:e,env:i})=>await new Promise(async n=>{let[r,a,o]=await An(t,e??[],{stdio:"inherit",...gi(i)&&{env:i}});Yo(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 Go({command:i,args:n})}};import{isNullish as yc,nonNullish as kx}from"@dfinity/utils";import Ox from"crypto";import{ReadableStream as mv}from"node:stream/web";import{pipeline as Ms,PassThrough as dv,Readable as hv}from"node:stream";import{stat as xh}from"node:fs/promises";var mh="End-Of-Stream",k=class extends Error{constructor(){super(mh),this.name="EndOfStreamError"}},ge=class extends Error{constructor(e="The operation was aborted"){super(e),this.name="AbortError"}};var yi=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.maxStreamReadSize=1*1024*1024,this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(e,i,n){let r=await this.read(e,i,n);return this.peekQueue.push(e.subarray(i,i+r)),r}async read(e,i,n){if(n===0)return 0;let r=this.readFromPeekBuffer(e,i,n);if(r+=await this.readRemainderFromStream(e,i+r,n-r),r===0)throw new k;return r}readFromPeekBuffer(e,i,n){let r=n,a=0;for(;this.peekQueue.length>0&&r>0;){let o=this.peekQueue.pop();if(!o)throw new Error("peekData should be defined");let s=Math.min(o.length,r);e.set(o.subarray(0,s),i+a),a+=s,r-=s,s<o.length&&this.peekQueue.push(o.subarray(s))}return a}async readRemainderFromStream(e,i,n){let r=n,a=0;for(;r>0&&!this.endOfStream;){let o=Math.min(r,this.maxStreamReadSize);if(this.interrupted)throw new ge;let s=await this.readFromStream(e,i+a,o);if(s===0)break;a+=s,r-=s}return a}};var jt=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,n){let r=this.s.read(n);if(r)return e.set(r,i),r.length;let a={buffer:e,offset:i,length:n,deferred:new yi};return this.deferred=a.deferred,this.s.once("readable",()=>{this.readDeferred(a)}),a.deferred.promise}readDeferred(e){let i=this.s.read(e.length);i?(e.buffer.set(i,e.offset),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 wi=class extends ye{constructor(e){super(),this.reader=e}async abort(){return this.close()}async close(){this.reader.releaseLock()}};var Tt=class extends wi{async readFromStream(e,i,n){let r=await this.reader.read(new Uint8Array(n));return r.done&&(this.endOfStream=r.done),r.value?(e.set(r.value,i),r.value.byteLength):0}};var We=class extends ye{constructor(e){super(),this.reader=e,this.buffer=null,this.bufferOffset=0}async readFromStream(e,i,n){let r=0;if(this.buffer){let a=this.buffer.byteLength-this.bufferOffset,o=Math.min(a,n);e.set(this.buffer.subarray(this.bufferOffset,this.bufferOffset+o),i),this.bufferOffset+=o,r+=o,n-=o,i+=o,this.bufferOffset>=this.buffer.byteLength&&(this.buffer=null,this.bufferOffset=0)}for(;n>0&&!this.endOfStream;){let a=await this.reader.read();if(a.done){this.endOfStream=!0;break}if(a.value){let o=a.value;if(o.byteLength>n)return e.set(o.subarray(0,n),i),this.buffer=o,this.bufferOffset=n,r+=n,r;e.set(o,i),r+=o.byteLength,n-=o.byteLength,i+=o.byteLength}}if(r===0&&this.endOfStream)throw new k;return r}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 We(e):new Tt(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 dh=256e3,At=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,0,n.length);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,0,n.length)}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(dh,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 _i=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 Ho(t,e){let i=new jt(t),n=e??{},r=n.onClose;return n.onClose=async()=>{if(await i.close(),r)return r()},new At(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 At(i,n)}function Wo(t,e){return new _i(t,e)}import{open as vh}from"node:fs/promises";var Ct=class t extends pe{static async fromFile(e){let i=await vh(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 Vo(t,e){let i=Ho(t,e);if(t.path){let n=await xh(t.path);i.fileInfo.path=t.path,i.fileInfo.size=n.size}return i}var Zo=Ct.fromFile;var Qo=Et(Jo(),1);function $(t){return new DataView(t.buffer,t.byteOffset)}var Xo={len:1,get(t,e){return $(t).getUint8(e)},put(t,e,i){return $(t).setUint8(e,i),e+1}},O={len:2,get(t,e){return $(t).getUint16(e,!0)},put(t,e,i){return $(t).setUint16(e,i,!0),e+2}},Ve={len:2,get(t,e){return $(t).getUint16(e)},put(t,e,i){return $(t).setUint16(e,i),e+2}};var A={len:4,get(t,e){return $(t).getUint32(e,!0)},put(t,e,i){return $(t).setUint32(e,i,!0),e+4}},Ko={len:4,get(t,e){return $(t).getUint32(e)},put(t,e,i){return $(t).setUint32(e,i),e+4}};var es={len:4,get(t,e){return $(t).getInt32(e)},put(t,e,i){return $(t).setInt32(e,i),e+4}};var ts={len:8,get(t,e){return $(t).getBigUint64(e,!0)},put(t,e,i){return $(t).setBigUint64(e,i,!0),e+8}};var Y=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 yh}from"module";var wh=yh("/"),_h;try{_h=wh("worker_threads").Worker}catch{}var Z=Uint8Array,Ze=Uint16Array,Sh=Int32Array,is=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]),ns=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]),kh=new Z([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),rs=function(t,e){for(var i=new Ze(31),n=0;n<31;++n)i[n]=e+=1<<t[n-1];for(var r=new Sh(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}},as=rs(is,2),os=as.b,Oh=as.r;os[28]=258,Oh[258]=28;var ss=rs(ns,0),Eh=ss.b,$3=ss.r,In=new Ze(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,_,qt=function(t,e,i){for(var n=t.length,r=0,a=new Ze(e);r<n;++r)t[r]&&++a[t[r]-1];var o=new Ze(e);for(r=1;r<e;++r)o[r]=o[r-1]+a[r-1]<<1;var s;if(i){s=new Ze(1<<e);var c=15-e;for(r=0;r<n;++r)if(t[r])for(var p=r<<4|t[r],u=e-t[r],f=o[t[r]-1]++<<u,m=f|(1<<u)-1;f<=m;++f)s[In[f]>>c]=p}else for(s=new Ze(n),r=0;r<n;++r)t[r]&&(s[r]=In[o[t[r]-1]++]>>15-t[r]);return s},Ft=new Z(288);for(_=0;_<144;++_)Ft[_]=8;var _;for(_=144;_<256;++_)Ft[_]=9;var _;for(_=256;_<280;++_)Ft[_]=7;var _;for(_=280;_<288;++_)Ft[_]=8;var _,cs=new Z(32);for(_=0;_<32;++_)cs[_]=5;var _;var jh=qt(Ft,9,1);var Th=qt(cs,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)},Ah=function(t){return(t+7)/8|0},Ch=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 qh=["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||qh[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,V),!i)throw n;return n},Dn=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 p=function(zo){var Ro=i.length;if(zo>Ro){var No=new Z(Math.max(Ro*2,zo));No.set(i),i=No}},u=e.f||0,f=e.p||0,m=e.b||0,d=e.l,x=e.d,h=e.m,g=e.n,j=r*8;do{if(!d){u=ie(t,f,1);var R=ie(t,f+1,3);if(f+=3,R)if(R==1)d=jh,x=Th,h=9,g=5;else if(R==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 N=new Z(xe),kt=new Z(19),Q=0;Q<Ae;++Q)kt[kh[Q]]=ie(t,f+Q*3,7);f+=Ae*3;for(var qo=Mn(kt),Hd=(1<<qo)-1,Wd=qt(kt,qo,1),Q=0;Q<xe;){var Fo=Wd[ie(t,f,Hd)];f+=Fo&15;var T=Fo>>4;if(T<16)N[Q++]=T;else{var Ge=0,bi=0;for(T==16?(bi=3+ie(t,f,3),f+=2,Ge=N[Q-1]):T==17?(bi=3+ie(t,f,7),f+=3):T==18&&(bi=11+ie(t,f,127),f+=7);bi--;)N[Q++]=Ge}}var Mo=N.subarray(0,q),be=N.subarray(q);h=Mn(Mo),g=Mn(be),d=qt(Mo,h,1),x=qt(be,g,1)}else V(1);else{var T=Ah(f)+4,D=t[T-4]|t[T-3]<<8,W=T+D;if(W>r){c&&V(0);break}s&&p(m+D),i.set(t.subarray(T,W),m),e.b=m+=D,e.p=f=W*8,e.f=u;continue}if(f>j){c&&V(0);break}}s&&p(m+131072);for(var Vd=(1<<h)-1,Zd=(1<<g)-1,On=f;;On=f){var Ge=d[Pn(t,f)&Vd],He=Ge>>4;if(f+=Ge&15,f>j){c&&V(0);break}if(Ge||V(2),He<256)i[m++]=He;else if(He==256){On=f,d=null;break}else{var Po=He-254;if(He>264){var Q=He-257,Ot=is[Q];Po=ie(t,f,(1<<Ot)-1)+os[Q],f+=Ot}var En=x[Pn(t,f)&Zd],jn=En>>4;En||V(3),f+=En&15;var be=Eh[jn];if(jn>3){var Ot=ns[jn];be+=Pn(t,f)&(1<<Ot)-1,f+=Ot}if(f>j){c&&V(0);break}s&&p(m+131072);var Io=m+Po;if(m<be){var Do=a-be,Jd=Math.min(be,Io);for(Do+m<0&&V(3);m<Jd;++m)i[m]=n[Do+m]}for(;m<Io;++m)i[m]=i[m-be]}}e.l=d,e.p=On,e.b=m,e.f=u,d&&(u=1,e.m=h,e.d=x,e.n=g)}while(!u);return m!=i.length&&o?Ch(i,0,m):i.subarray(0,m)};var Fh=new Z(0);var Mh=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)},Ph=function(t){var e=t.length;return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0};var Ih=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 Dh(t,e){return Dn(t,{i:2},e&&e.out,e&&e.dictionary)}function zh(t,e){var i=Mh(t);return i+8>t.length&&V(6,"invalid gzip data"),Dn(t.subarray(i,-8),{i:2},e&&e.out||new Z(Ph(t)),e&&e.dictionary)}function Rh(t,e){return Dn(t.subarray(Ih(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?zh(t,e):(t[0]&15)!=8||t[0]>>4>7||(t[0]<<8|t[1])%31?Dh(t,e):Rh(t,e)}var Nh=typeof TextDecoder<"u"&&new TextDecoder,Bh=0;try{Nh.decode(Fh,{stream:!0}),Bh=1}catch{}var Os=Et(ws(),1);var qe={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},Ln={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},_s={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},ks={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,Os.default)("tokenizer:inflate"),Un=256*1024,uv=Es(qe.DataDescriptor),Ti=Es(qe.EndOfCentralDirectory),Ai=class{constructor(e){this.tokenizer=e,this.syncBuffer=new Uint8Array(Un)}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]===Ti[0]&&n[r+1]===Ti[1]&&n[r+2]===Ti[2]&&n[r+3]===Ti[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(ks);if(o.signature!==qe.CentralFileHeader)throw new Error("Expected Central-File-Header signature");o.filename=await this.tokenizer.readToken(new Y(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=Un;se("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let p=-1;for(;p<0&&c===Un;){c=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),p=pv(this.syncBuffer.subarray(0,c),uv);let u=p>=0?p:c;if(a.handler){let f=new Uint8Array(u);await this.tokenizer.readBuffer(f),s.push(f)}else await this.tokenizer.ignore(u)}se(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),a.handler&&await this.inflate(r,lv(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(Ln)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-Ln.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(_s);return i.filename=await this.tokenizer.readToken(new Y(i.filenameLength,"utf-8")),i}if(e===qe.CentralFileHeader)return!1;throw e===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}};function pv(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 lv(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 iO={utf8:new globalThis.TextDecoder("utf8")};var nO=new globalThis.TextEncoder;var rO=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 fv(t,e){let i=t.length,n=e.length;if(n===0||n>i)return-1;let r=i-n;for(let a=0;a<=r;a++){let o=!0;for(let s=0;s<n;s++)if(t[a+s]!==e[s]){o=!1;break}if(o)return a}return-1}function js(t,e){return fv(t,e)!==-1}function Ts(t){return[...t].map(e=>e.charCodeAt(0))}function As(t,e=0){let i=Number.parseInt(new Y(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","ai","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"],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.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/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/x-apache-arrow","video/mp4","audio/midi","video/x-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/x-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/x-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 Mt=4100;function Yn(t){switch(t){case"application/epub+zip":return{ext:"epub",mime:"application/epub+zip"};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:"application/vnd.oasis.opendocument.text"};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:"application/vnd.oasis.opendocument.text-template"};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:"application/vnd.oasis.opendocument.spreadsheet"};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:"application/vnd.oasis.opendocument.spreadsheet-template"};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:"application/vnd.oasis.opendocument.presentation"};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:"application/vnd.oasis.opendocument.presentation-template"};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:"application/vnd.oasis.opendocument.graphics"};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:"application/vnd.oasis.opendocument.graphics-template"};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};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:"application/vnd.openxmlformats-officedocument.spreadsheetml.template"};case"application/vnd.ms-excel.template.macroEnabled":return{ext:"xltm",mime:"application/vnd.ms-excel.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"};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:"application/vnd.openxmlformats-officedocument.wordprocessingml.template"};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:"application/vnd.openxmlformats-officedocument.presentationml.template"};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:"application/vnd.openxmlformats-officedocument.presentationml.presentation"};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 Ci=class{constructor(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(Wo(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=Mt}=i,r,a,o=e.getReader({mode:"byob"});try{let{value:p,done:u}=await o.read(new Uint8Array(n));if(a=p,!u&&p)try{r=await this.fromBuffer(p.slice(0,n))}catch(f){if(!(f instanceof k))throw f;r=void 0}a=p}finally{o.releaseLock()}let s=new TransformStream({async start(p){p.enqueue(a)},transform(p,u){u.enqueue(p)}}),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(Mt),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 Ai(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/x-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")){try{if(await e.ignore(1350)===1350){let r=new Uint8Array(Math.min(10485760,e.fileInfo.size-1350));if(await e.readBuffer(r,{mayBeLess:!0}),js(r,new TextEncoder().encode("AIPrivateData")))return{ext:"ai",mime:"application/postscript"}}}catch(i){if(!(i instanceof k))throw i}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(Xo),c=128,p=0;for(;(s&c)===0&&c!==0;)++p,c>>=1;let u=new Uint8Array(p+1);return await e.readBuffer(u),u}async function n(){let s=await i(),c=await i();c[0]^=128>>c.length-1;let p=Math.min(6,c.length),u=new DataView(s.buffer),f=new DataView(c.buffer,c.length-p,p);return{id:$n(u),len:$n(f)}}async function r(s){for(;s>0;){let c=await n();if(c.id===17026)return(await e.readToken(new Y(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/x-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"))return{ext:"parquet",mime:"application/x-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 Y(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 Y(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("WEBVTT")&&[`
|
|
20
|
+
`)},bd=(t,e)=>{go(gd(t,e))},yo=class{constructor(e,i){this._tasks=e,this._options=Object.assign({showSubtasks:!0,collapse:!0,clearOutput:!1},i)}render(){this._id||(this._id=setInterval(()=>{bd(this._tasks,this._options)},100))}end(e){this._id&&(clearInterval(this._id),this._id=void 0),bd(this._tasks,this._options),this._options.clearOutput&&e===void 0?go.clear():go.done()}};yd.exports=yo});var wo=l(kd=>{"use strict";var _n={silent:Zp(),verbose:Mf(),default:wd()},_d=t=>process.stdout.isTTY===!0||t.nonTTY===!0,Sd=t=>typeof t=="string"?_n[t]||_n.default:typeof t=="function"?t:_n.default;kd.getRenderer=(t,e)=>{let i=Sd(t);return _d(i)||(i=Sd(e),(!i||!_d(i))&&(i=_n.verbose)),i}});var _o=l((U4,Od)=>{"use strict";var _t={PENDING:0,COMPLETED:1,FAILED:2,SKIPPED:3};_t.toString=t=>{switch(t){case _t.PENDING:return"pending";case _t.COMPLETED:return"completed";case _t.FAILED:return"failed";case _t.SKIPPED:return"skipped";default:return"unknown"}};Od.exports=_t});var jd=l(($4,Ed)=>{"use strict";var he=Ed.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 Td=l(So=>{"use strict";Object.defineProperty(So,"__esModule",{value:!0});So.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 Ad=l((Oo,ko)=>{"use strict";Object.defineProperty(Oo,"__esModule",{value:!0});var ik=Td(),nk=rk(ik);function rk(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 ko<"u"?St=ko:St=Function("return this")();var ak=(0,nk.default)(St);Oo.default=ak});var Fd=l((G4,qd)=>{"use strict";var Cd=Ad().default;qd.exports=t=>!!(t&&t[Cd]&&t===t[Cd]())});var Id=l(Sn=>{"use strict";var ok=jd(),Md=typeof Symbol=="function"&&Symbol.observable||"@@observable",Pd=t=>!!(t&&t[Md]&&t===t[Md]())||Fd()(t);Sn.isListr=t=>!!(t&&t.setRenderer&&t.add&&t.run);Sn.isObservable=t=>Pd(t);Sn.isStream=t=>ok(t)&&!Pd(t)});var kn=l((W4,Dd)=>{"use strict";var Eo=class extends Error{constructor(e){super(e),this.name="ListrError"}};Dd.exports=Eo});var Rd=l((V4,zd)=>{"use strict";var sk=Ec(),ck=Dc(),uk=Wp().Subject,pk=wo(),ve=_o(),jo=Id(),lk=kn(),fk=()=>!1,To=class extends uk{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||fk,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=>jo.isListr(r)?(r._options=Object.assign(this._options,r._options),r.exitOnError=r._options.exitOnError,r.setRenderer(pk.getRenderer("silent")),this._subtasks=r.tasks,this.next({type:"SUBTASKS"}),r.run(e)):(jo.isStream(r)&&(r=ck(r)),jo.isObservable(r)&&(r=new Promise((a,o)=>{r.subscribe({next:s=>{this.output=s,this.next({type:"DATA",data:s})},error:o,complete:a})})),sk(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 lk){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()})}};zd.exports=To});var Bd=l((Z4,Nd)=>{"use strict";var mk=_o(),dk=kn(),Ao=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 dk)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=mk.SKIPPED}run(e){return this._task.run(e,this)}};Nd.exports=Ao});var $d=l((J4,Ud)=>{"use strict";var hk=kc(),vk=Rd(),xk=Bd(),Ld=wo(),bk=kn(),gk=(t,e,i)=>t.isEnabled()?new xk(t,i).run(e):Promise.resolve(),Co=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=Ld.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=Ld.getRenderer(e)}add(e){let i=Array.isArray(e)?e:[e];for(let n of i)this._tasks.push(new vk(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),hk(this._tasks,r=>(this._checkAll(e),gk(r,e,i)),{concurrency:this.concurrency}).then(()=>{if(i.length>0){let r=new bk("Something went wrong");throw r.errors=i,r}return this._renderer.end(),e}).catch(r=>{throw r.context=e,this._renderer.end(r),r})}};Ud.exports=Co});import{rm as nh}from"node:fs/promises";var Pk=async({infile:t,outfile:e,banner:i})=>{await rh();let{build:n,version:r}=await import("esbuild");await nh(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}},rh=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 gi}from"@dfinity/utils";import{spawn as Yo}from"child_process";import{nonNullish as ah}from"@dfinity/utils";import{stat as oh}from"node:fs/promises";import Lo from"node:path";import Uo from"node:process";import{URL as sh}from"node:url";var An=async(t,e,i)=>await ch(t,i)?[Tn(t),e.map(n=>fh(n)),{...i,shell:!0}]:[t,e,i],ch=async(t,{shell:e,cwd:i,env:n=Uo.env})=>Uo.platform==="win32"&&!e&&!await uh(t,i,n),uh=async(t,e,{Path:i="",PATH:n=i})=>$o.some(r=>t.toLowerCase().endsWith(r))||(ph[`${t}\0${e}\0${n}`]??=await lh(t,e,n)),ph={},lh=async(t,e,i)=>{let n=i.split(Lo.delimiter).filter(Boolean).map(r=>r.replace(/^"(.*)"$/,"$1"));try{await Promise.all($o.flatMap(r=>[e,...n].filter(ah).map(a=>`${Lo.resolve(a instanceof sh?a.toString():a,t)}${r}`)).map(async r=>{try{await oh(r)}catch{return}throw 0}))}catch{return!0}return!1},$o=[".exe",".com"],fh=t=>Tn(Tn(`"${t.replaceAll(/(\\*)"/g,'$1$1\\"').replace(/(\\*)$/,"$1$1")}"`)),Tn=t=>t.replaceAll(/([()\][%!^"`<>&|;, *?])/g,"^$1");var Gk=async({command:t,cwd:e,args:i,env:n,stdout:r,silentOut:a=!1,silentErrors:o=!1})=>await new Promise(async(s,c)=>{let[p,u,f]=await An(t,i??[],{shell:!0,...gi(e)&&{cwd:e},...gi(n)&&{env:n}}),m=Yo(p,u,f);m.stdout.on("data",d=>{if(gi(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)})}),Go=async({command:t,args:e,env:i})=>await new Promise(async n=>{let[r,a,o]=await An(t,e??[],{stdio:"inherit",...gi(i)&&{env:i}});Yo(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 Go({command:i,args:n})}};import{isNullish as yc,nonNullish as kx}from"@dfinity/utils";import Ox from"crypto";import{ReadableStream as mv}from"node:stream/web";import{pipeline as Ms,PassThrough as dv,Readable as hv}from"node:stream";import{stat as xh}from"node:fs/promises";var mh="End-Of-Stream",k=class extends Error{constructor(){super(mh),this.name="EndOfStreamError"}},ge=class extends Error{constructor(e="The operation was aborted"){super(e),this.name="AbortError"}};var yi=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.maxStreamReadSize=1*1024*1024,this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(e,i,n){let r=await this.read(e,i,n);return this.peekQueue.push(e.subarray(i,i+r)),r}async read(e,i,n){if(n===0)return 0;let r=this.readFromPeekBuffer(e,i,n);if(r+=await this.readRemainderFromStream(e,i+r,n-r),r===0)throw new k;return r}readFromPeekBuffer(e,i,n){let r=n,a=0;for(;this.peekQueue.length>0&&r>0;){let o=this.peekQueue.pop();if(!o)throw new Error("peekData should be defined");let s=Math.min(o.length,r);e.set(o.subarray(0,s),i+a),a+=s,r-=s,s<o.length&&this.peekQueue.push(o.subarray(s))}return a}async readRemainderFromStream(e,i,n){let r=n,a=0;for(;r>0&&!this.endOfStream;){let o=Math.min(r,this.maxStreamReadSize);if(this.interrupted)throw new ge;let s=await this.readFromStream(e,i+a,o);if(s===0)break;a+=s,r-=s}return a}};var jt=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,n){let r=this.s.read(n);if(r)return e.set(r,i),r.length;let a={buffer:e,offset:i,length:n,deferred:new yi};return this.deferred=a.deferred,this.s.once("readable",()=>{this.readDeferred(a)}),a.deferred.promise}readDeferred(e){let i=this.s.read(e.length);i?(e.buffer.set(i,e.offset),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 wi=class extends ye{constructor(e){super(),this.reader=e}async abort(){return this.close()}async close(){this.reader.releaseLock()}};var Tt=class extends wi{async readFromStream(e,i,n){let r=await this.reader.read(new Uint8Array(n));return r.done&&(this.endOfStream=r.done),r.value?(e.set(r.value,i),r.value.byteLength):0}};var We=class extends ye{constructor(e){super(),this.reader=e,this.buffer=null,this.bufferOffset=0}async readFromStream(e,i,n){let r=0;if(this.buffer){let a=this.buffer.byteLength-this.bufferOffset,o=Math.min(a,n);e.set(this.buffer.subarray(this.bufferOffset,this.bufferOffset+o),i),this.bufferOffset+=o,r+=o,n-=o,i+=o,this.bufferOffset>=this.buffer.byteLength&&(this.buffer=null,this.bufferOffset=0)}for(;n>0&&!this.endOfStream;){let a=await this.reader.read();if(a.done){this.endOfStream=!0;break}if(a.value){let o=a.value;if(o.byteLength>n)return e.set(o.subarray(0,n),i),this.buffer=o,this.bufferOffset=n,r+=n,r;e.set(o,i),r+=o.byteLength,n-=o.byteLength,i+=o.byteLength}}if(r===0&&this.endOfStream)throw new k;return r}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 We(e):new Tt(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 dh=256e3,At=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,0,n.length);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,0,n.length)}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(dh,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 _i=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 Ho(t,e){let i=new jt(t),n=e??{},r=n.onClose;return n.onClose=async()=>{if(await i.close(),r)return r()},new At(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 At(i,n)}function Wo(t,e){return new _i(t,e)}import{open as vh}from"node:fs/promises";var Ct=class t extends pe{static async fromFile(e){let i=await vh(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 Vo(t,e){let i=Ho(t,e);if(t.path){let n=await xh(t.path);i.fileInfo.path=t.path,i.fileInfo.size=n.size}return i}var Zo=Ct.fromFile;var Qo=Et(Jo(),1);function $(t){return new DataView(t.buffer,t.byteOffset)}var Xo={len:1,get(t,e){return $(t).getUint8(e)},put(t,e,i){return $(t).setUint8(e,i),e+1}},O={len:2,get(t,e){return $(t).getUint16(e,!0)},put(t,e,i){return $(t).setUint16(e,i,!0),e+2}},Ve={len:2,get(t,e){return $(t).getUint16(e)},put(t,e,i){return $(t).setUint16(e,i),e+2}};var A={len:4,get(t,e){return $(t).getUint32(e,!0)},put(t,e,i){return $(t).setUint32(e,i,!0),e+4}},Ko={len:4,get(t,e){return $(t).getUint32(e)},put(t,e,i){return $(t).setUint32(e,i),e+4}};var es={len:4,get(t,e){return $(t).getInt32(e)},put(t,e,i){return $(t).setInt32(e,i),e+4}};var ts={len:8,get(t,e){return $(t).getBigUint64(e,!0)},put(t,e,i){return $(t).setBigUint64(e,i,!0),e+8}};var Y=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 yh}from"module";var wh=yh("/"),_h;try{_h=wh("worker_threads").Worker}catch{}var Z=Uint8Array,Ze=Uint16Array,Sh=Int32Array,is=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]),ns=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]),kh=new Z([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),rs=function(t,e){for(var i=new Ze(31),n=0;n<31;++n)i[n]=e+=1<<t[n-1];for(var r=new Sh(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}},as=rs(is,2),os=as.b,Oh=as.r;os[28]=258,Oh[258]=28;var ss=rs(ns,0),Eh=ss.b,$3=ss.r,In=new Ze(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,_,qt=function(t,e,i){for(var n=t.length,r=0,a=new Ze(e);r<n;++r)t[r]&&++a[t[r]-1];var o=new Ze(e);for(r=1;r<e;++r)o[r]=o[r-1]+a[r-1]<<1;var s;if(i){s=new Ze(1<<e);var c=15-e;for(r=0;r<n;++r)if(t[r])for(var p=r<<4|t[r],u=e-t[r],f=o[t[r]-1]++<<u,m=f|(1<<u)-1;f<=m;++f)s[In[f]>>c]=p}else for(s=new Ze(n),r=0;r<n;++r)t[r]&&(s[r]=In[o[t[r]-1]++]>>15-t[r]);return s},Ft=new Z(288);for(_=0;_<144;++_)Ft[_]=8;var _;for(_=144;_<256;++_)Ft[_]=9;var _;for(_=256;_<280;++_)Ft[_]=7;var _;for(_=280;_<288;++_)Ft[_]=8;var _,cs=new Z(32);for(_=0;_<32;++_)cs[_]=5;var _;var jh=qt(Ft,9,1);var Th=qt(cs,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)},Ah=function(t){return(t+7)/8|0},Ch=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 qh=["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||qh[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,V),!i)throw n;return n},Dn=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 p=function(zo){var Ro=i.length;if(zo>Ro){var No=new Z(Math.max(Ro*2,zo));No.set(i),i=No}},u=e.f||0,f=e.p||0,m=e.b||0,d=e.l,x=e.d,h=e.m,g=e.n,j=r*8;do{if(!d){u=ie(t,f,1);var R=ie(t,f+1,3);if(f+=3,R)if(R==1)d=jh,x=Th,h=9,g=5;else if(R==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 N=new Z(xe),kt=new Z(19),Q=0;Q<Ae;++Q)kt[kh[Q]]=ie(t,f+Q*3,7);f+=Ae*3;for(var qo=Mn(kt),Hd=(1<<qo)-1,Wd=qt(kt,qo,1),Q=0;Q<xe;){var Fo=Wd[ie(t,f,Hd)];f+=Fo&15;var T=Fo>>4;if(T<16)N[Q++]=T;else{var Ge=0,bi=0;for(T==16?(bi=3+ie(t,f,3),f+=2,Ge=N[Q-1]):T==17?(bi=3+ie(t,f,7),f+=3):T==18&&(bi=11+ie(t,f,127),f+=7);bi--;)N[Q++]=Ge}}var Mo=N.subarray(0,q),be=N.subarray(q);h=Mn(Mo),g=Mn(be),d=qt(Mo,h,1),x=qt(be,g,1)}else V(1);else{var T=Ah(f)+4,D=t[T-4]|t[T-3]<<8,W=T+D;if(W>r){c&&V(0);break}s&&p(m+D),i.set(t.subarray(T,W),m),e.b=m+=D,e.p=f=W*8,e.f=u;continue}if(f>j){c&&V(0);break}}s&&p(m+131072);for(var Vd=(1<<h)-1,Zd=(1<<g)-1,On=f;;On=f){var Ge=d[Pn(t,f)&Vd],He=Ge>>4;if(f+=Ge&15,f>j){c&&V(0);break}if(Ge||V(2),He<256)i[m++]=He;else if(He==256){On=f,d=null;break}else{var Po=He-254;if(He>264){var Q=He-257,Ot=is[Q];Po=ie(t,f,(1<<Ot)-1)+os[Q],f+=Ot}var En=x[Pn(t,f)&Zd],jn=En>>4;En||V(3),f+=En&15;var be=Eh[jn];if(jn>3){var Ot=ns[jn];be+=Pn(t,f)&(1<<Ot)-1,f+=Ot}if(f>j){c&&V(0);break}s&&p(m+131072);var Io=m+Po;if(m<be){var Do=a-be,Jd=Math.min(be,Io);for(Do+m<0&&V(3);m<Jd;++m)i[m]=n[Do+m]}for(;m<Io;++m)i[m]=i[m-be]}}e.l=d,e.p=On,e.b=m,e.f=u,d&&(u=1,e.m=h,e.d=x,e.n=g)}while(!u);return m!=i.length&&o?Ch(i,0,m):i.subarray(0,m)};var Fh=new Z(0);var Mh=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)},Ph=function(t){var e=t.length;return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0};var Ih=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 Dh(t,e){return Dn(t,{i:2},e&&e.out,e&&e.dictionary)}function zh(t,e){var i=Mh(t);return i+8>t.length&&V(6,"invalid gzip data"),Dn(t.subarray(i,-8),{i:2},e&&e.out||new Z(Ph(t)),e&&e.dictionary)}function Rh(t,e){return Dn(t.subarray(Ih(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?zh(t,e):(t[0]&15)!=8||t[0]>>4>7||(t[0]<<8|t[1])%31?Dh(t,e):Rh(t,e)}var Nh=typeof TextDecoder<"u"&&new TextDecoder,Bh=0;try{Nh.decode(Fh,{stream:!0}),Bh=1}catch{}var Os=Et(ws(),1);var qe={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},Ln={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},_s={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},ks={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,Os.default)("tokenizer:inflate"),Un=256*1024,uv=Es(qe.DataDescriptor),Ti=Es(qe.EndOfCentralDirectory),Ai=class{constructor(e){this.tokenizer=e,this.syncBuffer=new Uint8Array(Un)}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]===Ti[0]&&n[r+1]===Ti[1]&&n[r+2]===Ti[2]&&n[r+3]===Ti[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(ks);if(o.signature!==qe.CentralFileHeader)throw new Error("Expected Central-File-Header signature");o.filename=await this.tokenizer.readToken(new Y(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=Un;se("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let p=-1;for(;p<0&&c===Un;){c=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),p=pv(this.syncBuffer.subarray(0,c),uv);let u=p>=0?p:c;if(a.handler){let f=new Uint8Array(u);await this.tokenizer.readBuffer(f),s.push(f)}else await this.tokenizer.ignore(u)}se(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),a.handler&&await this.inflate(r,lv(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(Ln)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-Ln.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(_s);return i.filename=await this.tokenizer.readToken(new Y(i.filenameLength,"utf-8")),i}if(e===qe.CentralFileHeader)return!1;throw e===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}};function pv(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 lv(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 iO={utf8:new globalThis.TextDecoder("utf8")};var nO=new globalThis.TextEncoder;var rO=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 fv(t,e){let i=t.length,n=e.length;if(n===0||n>i)return-1;let r=i-n;for(let a=0;a<=r;a++){let o=!0;for(let s=0;s<n;s++)if(t[a+s]!==e[s]){o=!1;break}if(o)return a}return-1}function js(t,e){return fv(t,e)!==-1}function Ts(t){return[...t].map(e=>e.charCodeAt(0))}function As(t,e=0){let i=Number.parseInt(new Y(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","ai","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"],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.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/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/x-apache-arrow","video/mp4","audio/midi","video/x-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/x-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/x-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 Mt=4100;function Yn(t){switch(t){case"application/epub+zip":return{ext:"epub",mime:"application/epub+zip"};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:"application/vnd.oasis.opendocument.text"};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:"application/vnd.oasis.opendocument.text-template"};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:"application/vnd.oasis.opendocument.spreadsheet"};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:"application/vnd.oasis.opendocument.spreadsheet-template"};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:"application/vnd.oasis.opendocument.presentation"};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:"application/vnd.oasis.opendocument.presentation-template"};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:"application/vnd.oasis.opendocument.graphics"};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:"application/vnd.oasis.opendocument.graphics-template"};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};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:"application/vnd.openxmlformats-officedocument.spreadsheetml.template"};case"application/vnd.ms-excel.template.macroEnabled":return{ext:"xltm",mime:"application/vnd.ms-excel.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"};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:"application/vnd.openxmlformats-officedocument.wordprocessingml.template"};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:"application/vnd.openxmlformats-officedocument.presentationml.template"};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:"application/vnd.openxmlformats-officedocument.presentationml.presentation"};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 Ci=class{constructor(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(Wo(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=Mt}=i,r,a,o=e.getReader({mode:"byob"});try{let{value:p,done:u}=await o.read(new Uint8Array(n));if(a=p,!u&&p)try{r=await this.fromBuffer(p.slice(0,n))}catch(f){if(!(f instanceof k))throw f;r=void 0}a=p}finally{o.releaseLock()}let s=new TransformStream({async start(p){p.enqueue(a)},transform(p,u){u.enqueue(p)}}),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(Mt),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 Ai(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/x-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")){try{if(await e.ignore(1350)===1350){let r=new Uint8Array(Math.min(10485760,e.fileInfo.size-1350));if(await e.readBuffer(r,{mayBeLess:!0}),js(r,new TextEncoder().encode("AIPrivateData")))return{ext:"ai",mime:"application/postscript"}}}catch(i){if(!(i instanceof k))throw i}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(Xo),c=128,p=0;for(;(s&c)===0&&c!==0;)++p,c>>=1;let u=new Uint8Array(p+1);return await e.readBuffer(u),u}async function n(){let s=await i(),c=await i();c[0]^=128>>c.length-1;let p=Math.min(6,c.length),u=new DataView(s.buffer),f=new DataView(c.buffer,c.length-p,p);return{id:$n(u),len:$n(f)}}async function r(s){for(;s>0;){let c=await n();if(c.id===17026)return(await e.readToken(new Y(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/x-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"))return{ext:"parquet",mime:"application/x-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 Y(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 Y(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(es),type:await e.readToken(new Y(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/x-apache-arrow"};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 Y(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(ts))}}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 Y(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.slice(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}),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(Mt),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(this.buffer.length>=2&&this.check([255,224],{offset:0,mask:[255,224]})){if(this.check([16],{offset:1,mask:[22]}))return this.check([8],{offset:1,mask:[8]})?{ext:"aac",mime:"audio/aac"}:{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}};async readTiffTag(e){let i=await this.tokenizer.readToken(e?Ve: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?Ve:O);for(let n=0;n<i;++n){let r=await this.readTiffTag(e);if(r)return r}}async readTiffHeader(e){let i=(e?Ve:O).get(this.buffer,2),n=(e?Ko: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?Ve:O).get(this.buffer,8),o=(e?Ve: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"}}},mO=new Set(qs),dO=new Set(Fs);var Gn=class extends Ci{async fromStream(e){let i=await(e instanceof mv?Si(e,this.tokenizerOptions):Vo(e,this.tokenizerOptions));try{return await super.fromTokenizer(i)}finally{await i.close()}}async fromFile(e){let i=await Zo(e);try{return await super.fromTokenizer(i)}finally{await i.close()}}async toDetectionStream(e,i={}){if(!(e instanceof hv))return super.toDetectionStream(e,i);let{sampleSize:n=Mt}=i;return new Promise((r,a)=>{e.on("error",a),e.once("readable",()=>{(async()=>{try{let o=new dv,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(p){p instanceof k?o.fileType=void 0:a(p)}r(s)}catch(o){a(o)}})()})})}};async function Ps(t,e){return new Gn(e).fromFile(t,e)}var wc=Et(Bs(),1);var sc=Et(Ks(),1);var It=t=>{if(typeof t!="string")throw new TypeError("invalid pattern");if(t.length>65536)throw new TypeError("pattern is too long")};var Cv={"[: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,"\\$&"),qv=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ec=t=>t.join(""),tc=(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,p=!1,u=i,f="";e:for(;a<t.length;){let h=t.charAt(a);if((h==="!"||h==="^")&&a===i+1){p=!0,a++;continue}if(h==="]"&&o&&!c){u=a+1;break}if(o=!0,h==="\\"&&!c){c=!0,a++;continue}if(h==="["&&!c){for(let[g,[j,R,T]]of Object.entries(Cv))if(t.startsWith(g,a)){if(f)return["$.",!1,t.length-i,!0];a+=g.length,T?r.push(j):n.push(j),s=s||R;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(u<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])&&!p){let h=n[0].length===2?n[0].slice(-1):n[0];return[qv(h),!1,u-i,!1]}let m="["+(p?"^":"")+ec(n)+"]",d="["+(p?"":"^")+ec(r)+"]";return[n.length&&r.length?"("+m+"|"+d+")":n.length?m:d,s,u-i,!0]};var _e=(t,{windowsPathsNoEscape:e=!1}={})=>e?t.replace(/\[([^\/\\])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1");var Fv=new Set(["!","?","+","*","@"]),ic=t=>Fv.has(t),Mv="(?!(?:^|/)\\.\\.?(?:$|/))",Fi="(?!\\.)",Pv=new Set(["[","."]),Iv=new Set(["..","."]),Dv=new Set("().*{}+?[]^$\\!"),zv=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Vn="[^/]",nc=Vn+"*?",rc=Vn+"+?",Ke=class t{type;#i;#n;#a=!1;#e=[];#t;#o;#c;#s=!1;#r;#u;#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.#u!==void 0?this.#u:this.type?this.#u=this.type+"("+this.#e.map(e=>String(e)).join("|")+")":this.#u=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#p(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&&ic(h)&&e.charAt(d)==="("){i.push(x),x="";let g=new t(h,i);d=t.#p(e,g,d,r),i.push(g);continue}x+=h}return i.push(x),d}let p=n+1,u=new t(null,i),f=[],m="";for(;p<e.length;){let d=e.charAt(p++);if(a||d==="\\"){a=!a,m+=d;continue}if(o){p===s+1?(d==="^"||d==="!")&&(c=!0):d==="]"&&!(p===s+2&&c)&&(o=!1),m+=d;continue}else if(d==="["){o=!0,s=p,c=!1,m+=d;continue}if(ic(d)&&e.charAt(p)==="("){u.push(m),m="";let x=new t(d,u);u.push(x),p=t.#p(e,x,p,r);continue}if(d==="|"){u.push(m),m="",f.push(u),u=new t(null,i);continue}if(d===")")return m===""&&i.#e.length===0&&(i.#l=!0),u.push(m),m="",i.push(...f,u),p;m+=d}return i.type=null,i.#n=void 0,i.#e=[e.substring(n-1)],p}static fromGlob(e,i={}){let n=new t(null,void 0,i);return t.#p(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(),p=this.#e.map(d=>{let[x,h,g,j]=typeof d=="string"?t.#d(d,this.#n,c):d.toRegExpSource(e);return this.#n=this.#n||g,this.#a=this.#a||j,x}).join(""),u="";if(this.isStart()&&typeof this.#e[0]=="string"&&!(this.#e.length===1&&Iv.has(this.#e[0]))){let x=Pv,h=i&&x.has(p.charAt(0))||p.startsWith("\\.")&&x.has(p.charAt(2))||p.startsWith("\\.\\.")&&x.has(p.charAt(4)),g=!i&&!e&&x.has(p.charAt(0));u=h?Mv:g?Fi:""}let f="";return this.isEnd()&&this.#i.#s&&this.#t?.type==="!"&&(f="(?:$|\\/)"),[u+p+f,_e(p),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:"")+rc;else{let c=this.type==="!"?"))"+(this.isStart()&&!i&&!e?Fi:"")+nc+")":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+=(Dv.has(c)?"\\":"")+c;continue}if(c==="\\"){s===e.length-1?a+="\\\\":r=!0;continue}if(c==="["){let[p,u,f,m]=tc(e,s);if(f){a+=p,o=o||u,s+=f-1,i=i||m;continue}}if(c==="*"){n&&e==="*"?a+=rc:a+=nc,i=!0;continue}if(c==="?"){a+=Vn,i=!0;continue}a+=zv(c)}return[a,_e(e),!!i,o]}};var Zn=(t,{windowsPathsNoEscape:e=!1}={})=>e?t.replace(/[?*()[\]]/g,"[$&]"):t.replace(/[?*()[\]\\]/g,"\\$&");var C=(t,e,i={})=>(It(e),!i.nocomment&&e.charAt(0)==="#"?!1:new et(e,i).match(t)),Rv=/^\*+([^+@!?\*\[\(]*)$/,Nv=t=>e=>!e.startsWith(".")&&e.endsWith(t),Bv=t=>e=>e.endsWith(t),Lv=t=>(t=t.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(t)),Uv=t=>(t=t.toLowerCase(),e=>e.toLowerCase().endsWith(t)),$v=/^\*+\.\*+$/,Yv=t=>!t.startsWith(".")&&t.includes("."),Gv=t=>t!=="."&&t!==".."&&t.includes("."),Hv=/^\.\*+$/,Wv=t=>t!=="."&&t!==".."&&t.startsWith("."),Vv=/^\*+$/,Zv=t=>t.length!==0&&!t.startsWith("."),Jv=t=>t.length!==0&&t!=="."&&t!=="..",Qv=/^\?+([^+@!?\*\[\(]*)?$/,Xv=([t,e=""])=>{let i=cc([t]);return e?(e=e.toLowerCase(),n=>i(n)&&n.toLowerCase().endsWith(e)):i},Kv=([t,e=""])=>{let i=uc([t]);return e?(e=e.toLowerCase(),n=>i(n)&&n.toLowerCase().endsWith(e)):i},ex=([t,e=""])=>{let i=uc([t]);return e?n=>i(n)&&n.endsWith(e):i},tx=([t,e=""])=>{let i=cc([t]);return e?n=>i(n)&&n.endsWith(e):i},cc=([t])=>{let e=t.length;return i=>i.length===e&&!i.startsWith(".")},uc=([t])=>{let e=t.length;return i=>i.length===e&&i!=="."&&i!==".."},pc=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",ac={win32:{sep:"\\"},posix:{sep:"/"}},ix=pc==="win32"?ac.win32.sep:ac.posix.sep;C.sep=ix;var ee=Symbol("globstar **");C.GLOBSTAR=ee;var nx="[^/]",rx=nx+"*?",ax="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",ox="(?:(?!(?:\\/|^)\\.).)*?",sx=(t,e={})=>i=>C(i,t,e);C.filter=sx;var K=(t,e={})=>Object.assign({},t,e),cx=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=cx;var lc=(t,e={})=>(It(t),e.nobrace||!/\{(?:(?!\{).)*\}/.test(t)?[t]:(0,sc.default)(t));C.braceExpand=lc;var ux=(t,e={})=>new et(t,e).makeRe();C.makeRe=ux;var px=(t,e,i={})=>{let n=new et(e,i);return t=t.filter(r=>n.match(r)),n.options.nonull&&!t.length&&t.push(e),t};C.match=px;var oc=/[?*]|[+@!]\(.*?\)|\[|\]/,lx=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),et=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(e,i={}){It(e),i=i||{},this.options=i,this.pattern=e,this.platform=i.platform||pc,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]==="?"||!oc.test(a[2]))&&!oc.test(a[3]),p=/^[a-z]:/i.test(a[0]);if(c)return[...a.slice(0,4),...a.slice(4).map(u=>this.parse(u))];if(p)return[a[0],...a.slice(1).map(u=>this.parse(u))]}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],p=n[r+3];if(s!==".."||!c||c==="."||c===".."||!p||p==="."||p==="..")continue;i=!0,n.splice(r,1);let u=n.slice(0);u[r]="**",e.push(u),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]),j=typeof i[0]=="string"&&/^[a-z]:$/i.test(i[0]),R=!j&&i[0]===""&&i[1]===""&&i[2]==="?"&&typeof i[3]=="string"&&/^[a-z]:$/i.test(i[3]),T=g?3:h?0:void 0,D=R?3:j?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,p=i.length;o<c&&s<p;o++,s++){this.debug("matchOne loop");var u=i[s],f=e[o];if(this.debug(i,u,f),u===!1)return!1;if(u===ee){this.debug("GLOBSTAR",[i,u,f]);var m=o,d=s+1;if(d===p){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
23
|
>>> no match, partial?`,e,m,i,d),m===c))}let h;if(typeof u=="string"?(h=f===u,this.debug("string match",u,f,h)):(h=u.test(f),this.debug("pattern match",u,f,h)),!h)return!1}if(o===c&&s===p)return!0;if(o===c)return n;if(s===p)return o===c-1&&e[o]==="";throw new Error("wtf?")}braceExpand(){return lc(this.pattern,this.options)}parse(e){It(e);let i=this.options;if(e==="**")return ee;if(e==="")return"";let n,r=null;(n=e.match(Vv))?r=i.dot?Jv:Zv:(n=e.match(Rv))?r=(i.nocase?i.dot?Uv:Lv:i.dot?Bv:Nv)(n[1]):(n=e.match(Qv))?r=(i.nocase?i.dot?Kv:Xv:i.dot?ex:tx)(n):(n=e.match($v))?r=i.dot?Gv:Yv:(n=e.match(Hv))&&(r=Wv);let a=Ke.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?rx:i.dot?ax:ox,r=new Set(i.nocase?["i"]:[]),a=e.map(c=>{let p=c.map(u=>{if(u instanceof RegExp)for(let f of u.flags.split(""))r.add(f);return typeof u=="string"?lx(u):u===ee?ee:u._src});return p.forEach((u,f)=>{let m=p[f+1],d=p[f-1];u!==ee||d===ee||(d===void 0?m!==void 0&&m!==ee?p[f+1]="(?:\\/|"+n+"\\/)?"+m:p[f]=n:m===void 0?p[f-1]=d+"(?:\\/|"+n+")?":m!==ee&&(p[f-1]=d+"(?:\\/|\\/"+n+"\\/)"+m,p[f+1]=ee))}),p.filter(u=>u!==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],p=r;if(n.matchBase&&c.length===1&&(p=[o]),this.matchOne(p,c,i))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(e){return C.defaults(e).Minimatch}};C.AST=Ke;C.Minimatch=et;C.escape=Zn;C.unescape=_e;import{readFile as Ex}from"node:fs/promises";import{extname as Xn,join as jx}from"node:path";var fc="build",mc=[],dc=[],Mi="**/*.+(css|js|mjs)",hc=[".ds_store","thumbs.db"],vc="#dapp",Jn=20;import{createReadStream as fx,createWriteStream as mx}from"node:fs";import{Readable as dx}from"node:stream";import{createGunzip as hx,createGzip as vx}from"node:zlib";var VO=async({source:t})=>await new Promise((e,i)=>{let n=dx.from(t),r=[],a=hx();n.pipe(a),a.on("data",o=>r.push(o)),a.on("end",()=>{e(Buffer.concat(r))}),a.on("error",i)}),xc=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 xx({source:r})))},xx=async({source:t,destination:e})=>await new Promise((i,n)=>{let r=fx(t),a=e??`${t}.gz`,o=mx(a),s=vx();r.pipe(s).pipe(o),o.on("close",()=>{i(a)}),o.on("error",n)}),ZO=t=>t.length>2&&t[0]===31&&t[1]===139;import{lstatSync as wx}from"node:fs";import{basename as _x}from"node:path";import{lstatSync as bx,readdirSync as gx}from"node:fs";import{access as yx}from"node:fs/promises";import{join as bc}from"node:path";var Qn=t=>gx(t).flatMap(e=>{let i=bc(t,e);return bx(i).isDirectory()?Qn(i):bc(i)}),eE=async t=>{try{return await yx(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,"/"),gc=({sourceAbsolutePath:t,ignore:e})=>Qn(t).filter(n=>Sx({file:n,ignore:e})),Sx=({file:t,ignore:e})=>wx(t).size<=0||hc.includes(_x(t).toLowerCase())?!1:e.find(i=>C(t,i))===void 0;var _c=async({config:t,listAssets:e,assertSourceDirExists:i})=>{let{source:n=fc,ignore:r=mc,encoding:a=dc,gzip:o=Mi}=t,s=jx(process.cwd(),n);return i?.(s),{files:await qx({sourceAbsolutePath:s,ignore:r,encoding:a,gzip:o,listAssets:e}),sourceAbsolutePath:s}},Tx=async({files:t,sourceAbsolutePath:e,listAssets:i})=>{let n=await i({}),r=t.map(async o=>await Cx({file:o,sourceAbsolutePath:e,existingAssets:n}));return(await Promise.all(r)).filter(({upload:o})=>o).map(({file:o})=>o)},Ax=async t=>{let e=await Ex(t);return Ox.createHash("sha256").update(e).digest("base64")},Cx=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(yc(r))return{file:t,upload:!0};let a=await Ax(n);return{file:t,upload:a!==r.encodings.identity?.sha256}},qx=async({sourceAbsolutePath:t,ignore:e,encoding:i,gzip:n,listAssets:r})=>{let a=gc({sourceAbsolutePath:t,ignore:e}),o=await xc({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(kx(x)){let[h,g]=x;return g}if(d==="Z")return"compress";if(d==="gz")return"gzip";if(Xn(m)===".br")return"br";if(Xn(m)===".zlib")return"deflate"},p=({file:m,encodingType:d})=>{if(!yc(d))return s.find(x=>x===m.replace(Xn(m),""))},u=async m=>{let d=await Ps(m),x=c({file:m,ext:d?.ext}),h=p({file:m,encodingType:x}),g=wc.default.lookup(h??m);return{file:m,alternateFile:h,mime:typeof g=="string"?g:void 0,encoding:x}},f=await Promise.all(s.map(u));return await Tx({files:f,sourceAbsolutePath:t,listAssets:r})};var Yd=Et($d(),1);import{isNullish as yk,nonNullish as wk}from"@dfinity/utils";import{Blob as _k}from"buffer";import{readFile as Sk}from"node:fs/promises";import{basename as kk,relative as Ok}from"node:path";var Gd=async({files:t,sourceAbsolutePath:e,uploadFile:i})=>{let n=o=>o.alternateFile??o.file,r=async o=>{let s=n(o);await i({filename:kk(s),fullPath:Pi({file:s,sourceAbsolutePath:e}),data:new _k([await Sk(o.file)]),collection:vc,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 Yd.default(c.map(u=>({title:`Uploading ${Ok(e,u.file)}`,task:async()=>await r(u)})),{concurrent:!0}).run()}};await a(t.filter(({alternateFile:o})=>wk(o))),await a(t.filter(({alternateFile:o})=>yk(o)))};var sT=async({config:{predeploy:t}})=>{await Cn(t)},cT=async({config:{postdeploy:t}})=>{await Cn(t)},uT=async({assertMemory:t,uploadFile:e,...i})=>{let{files:n,sourceAbsolutePath:r}=await _c(i);return n.length===0?(console.log("No new files to upload."),{sourceFiles:n,sourceAbsolutePath:r}):(await t?.(),await Gd({files:n,sourceAbsolutePath:r,uploadFile:e}),console.log(`
|
|
24
|
-
\u{1F680} Deploy complete!`),{sourceFiles:n,sourceAbsolutePath:r})};var lT=({args:t,options:e})=>t?.find(i=>e.includes(i))!==void 0,fT=({args:t,option:e})=>{let i=(t??[]).findIndex(n=>n===e);if(i!==-1)return t?.[i+1]};import{nonNullish as Ek}from"@dfinity/utils";import{get as jk}from"https";var Tk=async t=>await new Promise((e,i)=>{jk(t,async n=>{Ek(n.statusCode)&&[301,302].includes(n.statusCode)&&await Tk(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 Ak}from"node:fs/promises";var bT=async({packageJsonPath:t})=>{let e=await Ak(t,"utf-8"),{dependencies:i,version:n,juno:r}=JSON.parse(e);return{
|
|
24
|
+
\u{1F680} Deploy complete!`),{sourceFiles:n,sourceAbsolutePath:r})};var lT=({args:t,options:e})=>t?.find(i=>e.includes(i))!==void 0,fT=({args:t,option:e})=>{let i=(t??[]).findIndex(n=>n===e);if(i!==-1)return t?.[i+1]};import{nonNullish as Ek}from"@dfinity/utils";import{get as jk}from"https";var Tk=async t=>await new Promise((e,i)=>{jk(t,async n=>{Ek(n.statusCode)&&[301,302].includes(n.statusCode)&&await Tk(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 Ak}from"node:fs/promises";var bT=async({packageJsonPath:t})=>{let e=await Ak(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 Ck,nonNullish as qk}from"@dfinity/utils";var wT=(t,e)=>{(Ck(t)||t==="")&&(qk(e)&&console.error(e),process.exit(1))};export{vc as COLLECTION_DAPP,dc as DEPLOY_DEFAULT_ENCODING,Mi as DEPLOY_DEFAULT_GZIP,mc as DEPLOY_DEFAULT_IGNORE,fc as DEPLOY_DEFAULT_SOURCE,hc as IGNORE_OS_FILES,Jn as UPLOAD_BATCH_SIZE,wT as assertAnswerCtrlC,Pk as buildEsm,uT as deploy,Tk as downloadFromURL,Go as execute,eE as fileExists,Qn as files,VO as gunzipFile,xx as gzipFile,xc as gzipFiles,lT as hasArgs,ZO as isGzip,fT as nextArg,cT as postDeploy,sT as preDeploy,bT as readPackageJson,Gk as spawn};
|
|
25
25
|
/*! Bundled license information:
|
|
26
26
|
|
|
27
27
|
ieee754/index.js:
|