forge-terminal 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +1317 -2
- package/dist/chunks/adm-zip-SQKLKBDP.js +3 -0
- package/dist/chunks/available-2VX7K7W6.js +3 -0
- package/dist/chunks/boot-ODZZHFUI.js +3 -0
- package/dist/chunks/cfb-V6M2PYOD.js +13 -0
- package/dist/chunks/chunk-2WYHI73Y.js +3 -0
- package/dist/chunks/chunk-4YHKTP7I.js +3 -0
- package/dist/chunks/chunk-5PYTOHLZ.js +3 -0
- package/dist/chunks/chunk-7YQR2MVH.js +3 -0
- package/dist/chunks/chunk-DRBA23IQ.js +3 -0
- package/dist/chunks/chunk-EOYBXOCV.js +4 -0
- package/dist/chunks/chunk-FQV57RMH.js +3 -0
- package/dist/chunks/chunk-IMKI5F4I.js +4 -0
- package/dist/chunks/chunk-J7FLFHQJ.js +3 -0
- package/dist/chunks/chunk-L2WK7CJG.js +3 -0
- package/dist/chunks/chunk-LFE3WRU4.js +3 -0
- package/dist/chunks/chunk-MHFY7HF6.js +10 -0
- package/dist/chunks/chunk-PBIS2ONZ.js +3 -0
- package/dist/chunks/chunk-QVACE4IE.js +3 -0
- package/dist/chunks/chunk-TMUK2DD3.js +3 -0
- package/dist/chunks/chunk-UNVHKJW4.js +41 -0
- package/dist/chunks/chunk-V4GHQGQM.js +4 -0
- package/dist/chunks/chunk-VB665HTV.js +3 -0
- package/dist/chunks/chunk-YHK5VE5R.js +3 -0
- package/dist/chunks/colour-QV2C3R7R.js +3 -0
- package/dist/chunks/config-command-UXJY623L.js +3 -0
- package/dist/chunks/dist-J2V6ITHG.js +29 -0
- package/dist/chunks/es-T2U7NBLD.js +3 -0
- package/dist/chunks/execute-4WJCUM7J.js +3 -0
- package/dist/chunks/extensions-command-6WZV2AES.js +3 -0
- package/dist/chunks/launch-2OI4ZLBQ.js +66 -0
- package/dist/chunks/lib-TPEJ5CJJ.js +46 -0
- package/dist/chunks/lock-R6GZXCCW.js +3 -0
- package/dist/chunks/manager-H52ENJOH.js +4 -0
- package/dist/chunks/paths-XY2345OS.js +3 -0
- package/dist/chunks/pdf-compress-IMRFBLZF.js +3 -0
- package/dist/chunks/react-devtools-core-UM4FS6CU.js +3 -0
- package/dist/chunks/run-N3F4EM7E.js +4 -0
- package/dist/chunks/server-5RWSVTOM.js +73 -0
- package/dist/chunks/theme-GW7CQPUO.js +3 -0
- package/dist/chunks/word-OGQ2KZAJ.js +24 -0
- package/dist/index.js +68 -0
- package/dist/third-party-licenses.txt +2856 -0
- package/package.json +84 -4
- package/skills/forge/SKILL.md +128 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a as j,c as H}from"./chunk-TMUK2DD3.js";var ee=H((it,se)=>{se.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var b=H(ce=>{var fe={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",MAX_OUTPUT_EXCEEDED:"Decompressed data exceeds the declared uncompressed size",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DUPLICATE_ENTRY:"Duplicate entry name {0}",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",ZIP64_VALUE_TOO_LARGE:"Zip64 value exceeds the maximum safe integer",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function Pe(t){return function(...o){return o.length&&(t=t.replace(/\{(\d)\}/g,(n,c)=>o[c]||"")),new Error("ADM-ZIP: "+t)}}for(let t of Object.keys(fe))ce[t]=Pe(fe[t])});var de=H((st,Ee)=>{var Me=j("fs"),R=j("path"),ue=ee(),te=b(),ze=typeof process=="object"&&process.platform==="win32",ae=t=>typeof t=="object"&&t!==null,le=new Uint32Array(256).map((t,o)=>{for(let n=0;n<8;n++)(o&1)!==0?o=3988292384^o>>>1:o>>>=1;return o>>>0});function w(t){this.sep=R.sep,this.fs=Me,ae(t)&&ae(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}Ee.exports=w;w.prototype.makeDir=function(t){let o=this;function n(c){let a=c.split(o.sep)[0];c.split(o.sep).forEach(function(d){if(!(!d||d.substr(-1,1)===":")){a+=o.sep+d;var r;try{r=o.fs.statSync(a)}catch(I){if(I.message&&I.message.startsWith("ENOENT"))o.fs.mkdirSync(a);else throw I}if(r&&r.isFile())throw te.FILE_IN_THE_WAY(`"${a}"`)}})}n(t)};w.prototype.writeFileTo=function(t,o,n,c){let a=this;if(a.fs.existsSync(t)){if(!n)return!1;var d=a.fs.statSync(t);if(d.isDirectory())return!1}var r=R.dirname(t);a.fs.existsSync(r)||a.makeDir(r);var I;try{I=a.fs.openSync(t,"w",438)}catch{a.fs.chmodSync(t,438),I=a.fs.openSync(t,"w",438)}if(I)try{a.fs.writeSync(I,o,0,o.length,0)}finally{a.fs.closeSync(I)}return a.fs.chmodSync(t,c||438),!0};w.prototype.writeFileToAsync=function(t,o,n,c,a){typeof c=="function"&&(a=c,c=void 0);let d=this;d.fs.exists(t,function(r){if(r&&!n)return a(!1);d.fs.stat(t,function(I,C){if(r&&C&&C.isDirectory())return a(!1);var S=R.dirname(t);d.fs.exists(S,function(_){if(!_)try{d.makeDir(S)}catch{return a(!1)}let y=function(p){d.fs.write(p,o,0,o.length,0,function(O){d.fs.close(p,function(){if(O)return a(!1);d.fs.chmod(t,c||438,function(){a(!0)})})})};d.fs.open(t,"w",438,function(p,O){p?d.fs.chmod(t,438,function(){d.fs.open(t,"w",438,function(i,s){if(i||!s)return a(!1);y(s)})}):O?y(O):a(!1)})})})})};w.prototype.assertPathSafe=function(t,o){let n=this;if(typeof n.fs.lstatSync!="function")return;let c=R.resolve(t),a=R.resolve(o);if(a===c)return;let d=R.relative(c,a);if(!d||d===".."||d.startsWith(".."+R.sep)||R.isAbsolute(d))return;let r=c;for(let I of d.split(R.sep)){if(!I||I===".")continue;r=R.join(r,I);let C;try{C=n.fs.lstatSync(r)}catch{break}if(C.isSymbolicLink())throw te.FILE_IN_THE_WAY(`"${r}"`)}};w.prototype.findFiles=function(t){let o=this,n=typeof o.fs.lstatSync=="function",c=o.fs.realpathSync(t);function a(r){if(!n||!o.fs.lstatSync(r).isSymbolicLink())return!1;let I;try{I=o.fs.realpathSync(r)}catch{return!0}return!(I===c||I.startsWith(c+R.sep))}function d(r,I,C,S){typeof I=="boolean"&&(C=I,I=void 0);let _=[];return o.fs.readdirSync(r).forEach(function(y){let p=R.join(r,y);if(a(p))return;let O=o.fs.statSync(p);if((!I||I.test(p))&&_.push(R.normalize(p)+(O.isDirectory()?o.sep:"")),O.isDirectory()&&C){let i=o.fs.realpathSync(p);S.has(i)||(S.add(i),_=_.concat(d(p,I,C,S)))}}),_}return d(t,void 0,!0,new Set([c]))};w.prototype.findFilesAsync=function(t,o){let n=this,c=[],a=!1,d=function(_){a||(a=!0,o(_,_?void 0:c))},r=typeof n.fs.lstat=="function",I=null,C=function(_,y){if(!r)return y(null,!1);n.fs.lstat(_,function(p,O){if(p)return y(p);if(!O||!O.isSymbolicLink())return y(null,!1);n.fs.realpath(_,function(i,s){if(i)return y(null,!0);y(null,!(s===I||s.startsWith(I+R.sep)))})})},S=function(_,y,p){n.fs.readdir(_,function(O,i){if(O)return p(O);let s=i.length;if(!s)return p();i.forEach(function(f){let l=R.join(_,f);C(l,function(E,e){if(E)return p(E);if(e){--s||p();return}n.fs.stat(l,function(u,m){if(u)return p(u);if(!m){--s||p();return}if(c.push(R.normalize(l)+(m.isDirectory()?n.sep:"")),!m.isDirectory()){--s||p();return}n.fs.realpath(l,function(D,L){if(D)return p(D);if(y.has(L)){--s||p();return}y.add(L),S(l,y,function(N){if(N)return p(N);--s||p()})})})})})})};n.fs.realpath(t,function(_,y){if(_)return d(_);I=y,S(t,new Set([y]),d)})};w.prototype.getAttributes=function(){};w.prototype.setAttributes=function(){};w.crc32update=function(t,o){return le[(t^o)&255]^t>>>8};w.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let o=t.length,n=-1;for(let c=0;c<o;)n=w.crc32update(n,t[c++]);return~n>>>0};w.methodToString=function(t){switch(t){case ue.STORED:return"STORED ("+t+")";case ue.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};w.canonical=function(t){if(!t)return"";let o=R.posix.normalize("/"+t.split("\\").join("/"));return R.join(".",o)};w.zipnamefix=function(t){if(!t)return"";let o=R.posix.normalize("/"+t.split("\\").join("/"));return R.posix.join(".",o)};w.findLast=function(t,o){if(!Array.isArray(t))throw new TypeError("arr is not array");let n=t.length>>>0;for(let c=n-1;c>=0;c--)if(o(t[c],c,t))return t[c]};w.sanitize=function(t,o){t=R.resolve(R.normalize(t));for(var n=o.split("/"),c=0,a=n.length;c<a;c++){var d=R.normalize(R.join(t,n.slice(c,a).join(R.sep)));if(d===t||d.startsWith(t+R.sep))return d}return R.normalize(R.join(t,R.basename(o)))};w.toBuffer=function(o,n){return Buffer.isBuffer(o)?o:o instanceof Uint8Array?Buffer.from(o):typeof o=="string"?n(o):Buffer.alloc(0)};w.readBigUInt64LE=function(t,o){let n=t.readUInt32LE(o),a=t.readUInt32LE(o+4)*4294967296+n;if(a>Number.MAX_SAFE_INTEGER)throw te.ZIP64_VALUE_TOO_LARGE();return a};w.writeBigUInt64LE=function(t,o,n){let c=o>>>0,a=Math.floor(o/4294967296)>>>0;t.writeUInt32LE(c,n),t.writeUInt32LE(a,n+4)};w.fromDOS2Date=function(t){return new Date((t>>25&127)+1980,Math.max((t>>21&15)-1,0),Math.max(t>>16&31,1),t>>11&31,t>>5&63,(t&31)<<1)};w.fromDate2DOS=function(t){let o=0,n=0;return t.getFullYear()>1979&&(o=(t.getFullYear()-1980&127)<<9|t.getMonth()+1<<5|t.getDate(),n=t.getHours()<<11|t.getMinutes()<<5|t.getSeconds()>>1),o<<16|n};w.isWin=ze;w.crcTable=le});var he=H((ft,Ie)=>{var Ge=j("path");Ie.exports=function(t,{fs:o}){var n=t||"",c=d(),a=null;function d(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return n&&o.existsSync(n)?(a=o.statSync(n),c.directory=a.isDirectory(),c.mtime=a.mtime,c.atime=a.atime,c.executable=(73&a.mode)!==0,c.readonly=(128&a.mode)===0,c.hidden=Ge.basename(n)[0]==="."):console.warn("Invalid path: "+n),{get directory(){return c.directory},get readOnly(){return c.readonly},get hidden(){return c.hidden},get mtime(){return c.mtime},get atime(){return c.atime},get executable(){return c.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:n,isDirectory:c.directory,isReadOnly:c.readonly,isHidden:c.hidden,isExecutable:c.executable,mTime:c.mtime,aTime:c.atime}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Le=H((ct,me)=>{me.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var W=H((ut,q)=>{q.exports=de();q.exports.Constants=ee();q.exports.Errors=b();q.exports.FileAttr=he();q.exports.decoder=Le()});var Ne=H((at,De)=>{var G=W(),h=G.Constants;De.exports=function(){var t=20,o=10,n=0,c=0,a=0,d=0,r=0,I=0,C=0,S=0,_=0,y=0,p=0,O=0,i=0;t|=G.isWin?2560:768,n|=h.FLG_EFS;let s={extraLen:0},f=e=>Math.max(0,e)>>>0,l=e=>Math.max(0,e)&65535,E=e=>Math.max(0,e)&255;return a=G.fromDate2DOS(new Date),{get made(){return t},set made(e){t=e},get version(){return o},set version(e){o=e},get flags(){return n},set flags(e){n=e},get flags_efs(){return(n&h.FLG_EFS)>0},set flags_efs(e){e?n|=h.FLG_EFS:n&=~h.FLG_EFS},get flags_desc(){return(n&h.FLG_DESC)>0},set flags_desc(e){e?n|=h.FLG_DESC:n&=~h.FLG_DESC},get method(){return c},set method(e){switch(e){case h.STORED:this.version=10;break;case h.DEFLATED:default:this.version=20}c=e},get time(){return G.fromDOS2Date(this.timeval)},set time(e){e=new Date(e),this.timeval=G.fromDate2DOS(e)},get timeval(){return a},set timeval(e){a=f(e)},get timeHighByte(){return E(a>>>8)},get crc(){return d},set crc(e){d=f(e)},get compressedSize(){return r},set compressedSize(e){r=f(e)},get size(){return I},set size(e){I=f(e)},get fileNameLength(){return C},set fileNameLength(e){C=e},get extraLength(){return S},set extraLength(e){S=e},get extraLocalLength(){return s.extraLen},set extraLocalLength(e){s.extraLen=e},get commentLength(){return _},set commentLength(e){_=e},get diskNumStart(){return y},set diskNumStart(e){y=f(e)},get inAttr(){return p},set inAttr(e){p=f(e)},get attr(){return O},set attr(e){O=f(e)},get fileAttr(){return(O||0)>>16&511},get offset(){return i},set offset(e){i=f(e)},get encrypted(){return(n&h.FLG_ENC)===h.FLG_ENC},get centralHeaderSize(){return h.CENHDR+C+S+_},get realDataOffset(){return i+h.LOCHDR+s.fnameLen+s.extraLen},get localHeader(){return s},loadLocalHeaderFromBinary:function(e){if(i<0||i+h.LOCHDR>e.length)throw G.Errors.INVALID_LOC();var u=e.slice(i,i+h.LOCHDR);if(u.readUInt32LE(0)!==h.LOCSIG)throw G.Errors.INVALID_LOC();s.version=u.readUInt16LE(h.LOCVER),s.flags=u.readUInt16LE(h.LOCFLG),s.flags_desc=(s.flags&h.FLG_DESC)>0,s.method=u.readUInt16LE(h.LOCHOW),s.time=u.readUInt32LE(h.LOCTIM),s.crc=u.readUInt32LE(h.LOCCRC),s.compressedSize=u.readUInt32LE(h.LOCSIZ),s.size=u.readUInt32LE(h.LOCLEN),s.fnameLen=u.readUInt16LE(h.LOCNAM),s.extraLen=u.readUInt16LE(h.LOCEXT);let m=i+h.LOCHDR+s.fnameLen,D=m+s.extraLen;return e.slice(m,D)},loadFromBinary:function(e){if(e.length!==h.CENHDR||e.readUInt32LE(0)!==h.CENSIG)throw G.Errors.INVALID_CEN();t=e.readUInt16LE(h.CENVEM),o=e.readUInt16LE(h.CENVER),n=e.readUInt16LE(h.CENFLG),c=e.readUInt16LE(h.CENHOW),a=e.readUInt32LE(h.CENTIM),d=e.readUInt32LE(h.CENCRC),r=e.readUInt32LE(h.CENSIZ),I=e.readUInt32LE(h.CENLEN),C=e.readUInt16LE(h.CENNAM),S=e.readUInt16LE(h.CENEXT),_=e.readUInt16LE(h.CENCOM),y=e.readUInt16LE(h.CENDSK),p=e.readUInt16LE(h.CENATT),O=e.readUInt32LE(h.CENATX),i=e.readUInt32LE(h.CENOFF)},localHeaderToBinary:function(){var e=Buffer.alloc(h.LOCHDR);return e.writeUInt32LE(h.LOCSIG,0),e.writeUInt16LE(o,h.LOCVER),e.writeUInt16LE(n&~h.FLG_DESC,h.LOCFLG),e.writeUInt16LE(c,h.LOCHOW),e.writeUInt32LE(a,h.LOCTIM),e.writeUInt32LE(d,h.LOCCRC),e.writeUInt32LE(r,h.LOCSIZ),e.writeUInt32LE(I,h.LOCLEN),e.writeUInt16LE(C,h.LOCNAM),e.writeUInt16LE(s.extraLen,h.LOCEXT),e},centralHeaderToBinary:function(){var e=Buffer.alloc(h.CENHDR+C+S+_);return e.writeUInt32LE(h.CENSIG,0),e.writeUInt16LE(t,h.CENVEM),e.writeUInt16LE(o,h.CENVER),e.writeUInt16LE(n&~h.FLG_DESC,h.CENFLG),e.writeUInt16LE(c,h.CENHOW),e.writeUInt32LE(a,h.CENTIM),e.writeUInt32LE(d,h.CENCRC),e.writeUInt32LE(r,h.CENSIZ),e.writeUInt32LE(I,h.CENLEN),e.writeUInt16LE(C,h.CENNAM),e.writeUInt16LE(S,h.CENEXT),e.writeUInt16LE(_,h.CENCOM),e.writeUInt16LE(y,h.CENDSK),e.writeUInt16LE(p,h.CENATT),e.writeUInt32LE(O,h.CENATX),e.writeUInt32LE(i,h.CENOFF),e},toJSON:function(){let e=function(u){return u+" bytes"};return{made:t,version:o,flags:n,method:G.methodToString(c),time:this.time,crc:"0x"+d.toString(16).toUpperCase(),compressedSize:e(r),size:e(I),fileNameLength:e(C),extraLength:e(S),commentLength:e(_),diskNumStart:y,inAttr:p,attr:O,offset:i,centralHeaderSize:e(h.CENHDR+C+S+_)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var _e=H((lt,ge)=>{var z=W(),g=z.Constants;ge.exports=function(){var t=0,o=0,n=0,c=0,a=0;let d=()=>t>g.EF_ZIP64_OR_16||o>g.EF_ZIP64_OR_16||n>g.EF_ZIP64_OR_32||c>g.EF_ZIP64_OR_32;return{get diskEntries(){return t},set diskEntries(r){t=o=r},get totalEntries(){return o},set totalEntries(r){o=t=r},get size(){return n},set size(r){n=r},get offset(){return c},set offset(r){c=r},get commentLength(){return a},set commentLength(r){a=r},get mainHeaderSize(){return(d()?g.ZIP64HDR+g.END64HDR:0)+g.ENDHDR+a},loadFromBinary:function(r){if((r.length!==g.ENDHDR||r.readUInt32LE(0)!==g.ENDSIG)&&(r.length<g.ZIP64HDR||r.readUInt32LE(0)!==g.ZIP64SIG))throw z.Errors.INVALID_END();r.readUInt32LE(0)===g.ENDSIG?(t=r.readUInt16LE(g.ENDSUB),o=r.readUInt16LE(g.ENDTOT),n=r.readUInt32LE(g.ENDSIZ),c=r.readUInt32LE(g.ENDOFF),a=r.readUInt16LE(g.ENDCOM)):(t=z.readBigUInt64LE(r,g.ZIP64SUB),o=z.readBigUInt64LE(r,g.ZIP64TOT),n=z.readBigUInt64LE(r,g.ZIP64SIZB),c=z.readBigUInt64LE(r,g.ZIP64OFF),a=0)},toBinary:function(){if(!d()){var r=Buffer.alloc(g.ENDHDR+a);return r.writeUInt32LE(g.ENDSIG,0),r.writeUInt32LE(0,4),r.writeUInt16LE(t,g.ENDSUB),r.writeUInt16LE(o,g.ENDTOT),r.writeUInt32LE(n,g.ENDSIZ),r.writeUInt32LE(c,g.ENDOFF),r.writeUInt16LE(a,g.ENDCOM),r.fill(" ",g.ENDHDR),r}var r=Buffer.alloc(this.mainHeaderSize);let I=0;r.writeUInt32LE(g.ZIP64SIG,I),z.writeBigUInt64LE(r,g.ZIP64HDR-g.ZIP64LEAD,I+g.ZIP64SIZE),r.writeUInt16LE(45,I+g.ZIP64VEM),r.writeUInt16LE(45,I+g.ZIP64VER),r.writeUInt32LE(0,I+g.ZIP64DSK),r.writeUInt32LE(0,I+g.ZIP64DSKDIR),z.writeBigUInt64LE(r,t,I+g.ZIP64SUB),z.writeBigUInt64LE(r,o,I+g.ZIP64TOT),z.writeBigUInt64LE(r,n,I+g.ZIP64SIZB),z.writeBigUInt64LE(r,c,I+g.ZIP64OFF);let C=c+n;return I+=g.ZIP64HDR,r.writeUInt32LE(g.END64SIG,I),r.writeUInt32LE(0,I+g.END64START),z.writeBigUInt64LE(r,C,I+g.END64OFF),r.writeUInt32LE(1,I+g.END64NUMDISKS),I+=g.END64HDR,r.writeUInt32LE(g.ENDSIG,I),r.writeUInt32LE(0,I+4),r.writeUInt16LE(Math.min(t,g.EF_ZIP64_OR_16),I+g.ENDSUB),r.writeUInt16LE(Math.min(o,g.EF_ZIP64_OR_16),I+g.ENDTOT),r.writeUInt32LE(Math.min(n,g.EF_ZIP64_OR_32),I+g.ENDSIZ),r.writeUInt32LE(Math.min(c,g.EF_ZIP64_OR_32),I+g.ENDOFF),r.writeUInt16LE(a,I+g.ENDCOM),r.fill(" ",I+g.ENDHDR),r},toJSON:function(){let r=function(I,C){let S=I.toString(16).toUpperCase();for(;S.length<C;)S="0"+S;return"0x"+S};return{diskEntries:t,totalEntries:o,size:n+" bytes",offset:r(c,4),commentLength:a}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var re=H(ne=>{ne.EntryHeader=Ne();ne.MainHeader=_e()});var Ce=H((dt,ye)=>{ye.exports=function(t){var o=j("zlib"),n={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:function(){return o.deflateRawSync(t,n)},deflateAsync:function(c){var a=o.createDeflateRaw(n),d=[],r=0;a.on("data",function(I){d.push(I),r+=I.length}),a.on("end",function(){var I=Buffer.alloc(r),C=0;I.fill(0);for(var S=0;S<d.length;S++){var _=d[S];_.copy(I,C),C+=_.length}c&&c(I)}),a.end(t)}}}});var pe=H((It,Se)=>{var Ve=+(process?.versions?.node??"").split(".")[0]||0,je=b();Se.exports=function(t,o){var n=j("zlib");let c=o>0?o:1,a=Ve>=15?{maxOutputLength:c}:{};return{inflate:function(){return n.inflateRawSync(t,a)},inflateAsync:function(d){var r=n.createInflateRaw(a),I=[],C=0,S=!1;let _=function(y){S||(S=!0,r.destroy(),d&&d(Buffer.alloc(0),y))};r.on("error",function(y){_(y)}),r.on("data",function(y){if(!S){if(C+=y.length,C>c)return _(je.MAX_OUTPUT_EXCEEDED());I.push(y)}}),r.on("end",function(){if(!S){S=!0;var y=Buffer.alloc(C),p=0;y.fill(0);for(var O=0;O<I.length;O++){var i=I[O];i.copy(y,p),p+=i.length}d&&d(y)}}),r.end(t)}}}});var Re=H((ht,Fe)=>{"use strict";var{randomFillSync:Oe}=j("crypto"),Xe=b(),qe=new Uint32Array(256).map((t,o)=>{for(let n=0;n<8;n++)(o&1)!==0?o=o>>>1^3988292384:o>>>=1;return o>>>0}),Ae=(t,o)=>Math.imul(t,o)>>>0,Te=(t,o)=>qe[(t^o)&255]^t>>>8,Y=()=>typeof Oe=="function"?Oe(Buffer.alloc(12)):Y.node();Y.node=()=>{let t=Buffer.alloc(12),o=t.length;for(let n=0;n<o;n++)t[n]=Math.random()*256&255;return t};var $={genSalt:Y};function Q(t){let o=Buffer.isBuffer(t)?t:Buffer.from(t);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let n=0;n<o.length;n++)this.updateKeys(o[n])}Q.prototype.updateKeys=function(t){let o=this.keys;return o[0]=Te(o[0],t),o[1]+=o[0]&255,o[1]=Ae(o[1],134775813)+1,o[2]=Te(o[2],o[1]>>>24),t};Q.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return Ae(t,t^1)>>8&255};function We(t){let o=new Q(t);return function(n){let c=Buffer.alloc(n.length),a=0;for(let d of n)c[a++]=o.updateKeys(d^o.next());return c}}function Ke(t){let o=new Q(t);return function(n,c,a=0){c||(c=Buffer.alloc(n.length));for(let d of n){let r=o.next();c[a++]=d^r,o.updateKeys(d)}return c}}function be(t,o,n){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let c=We(n),a=c(t.slice(0,12)),d=(o.flags&8)===8?o.timeHighByte:o.crc>>>24;if(a[11]!==d)throw Xe.WRONG_PASSWORD();return c(t.slice(12))}function Ye(t){Buffer.isBuffer(t)&&t.length>=12?$.genSalt=function(){return t.slice(0,12)}:t==="node"?$.genSalt=Y.node:$.genSalt=Y}function Je(t,o,n,c=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let a=Ke(n),d=$.genSalt();d[11]=o.crc>>>24&255,c&&(d[10]=o.crc>>>16&255);let r=Buffer.alloc(t.length+12);return a(d,r),a(t,r,12)}Fe.exports={decrypt:be,encrypt:Je,_salter:Ye}});var Ue=H(k=>{k.Deflater=Ce();k.Inflater=pe();k.ZipCrypto=Re()});var oe=H((Lt,we)=>{var U=W(),$e=re(),M=U.Constants,ie=Ue();we.exports=function(t,o){var n=new $e.EntryHeader,c=Buffer.alloc(0),a=Buffer.alloc(0),d=!1,r=null,I=Buffer.alloc(0),C=Buffer.alloc(0),S=!0;let _=t,y=typeof _.decoder=="object"?_.decoder:U.decoder;S=y.hasOwnProperty("efs")?y.efs:!1;function p(){if(!o||!(o instanceof Uint8Array))return Buffer.alloc(0);C=n.loadLocalHeaderFromBinary(o);let e=n.realDataOffset,u=e+n.compressedSize;if(e<0||u<e||u>o.length)throw U.Errors.INVALID_LOC();return o.slice(e,u)}function O(e){let u=n.flags_desc||n.localHeader.flags_desc?n.crc:n.localHeader.crc;return U.crc32(e)===u}function i(e,u,m){if(typeof u>"u"&&typeof e=="string"&&(m=e,e=void 0),d)return e&&u&&u(Buffer.alloc(0),U.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var D;try{if(D=p(),D.length===0)return e&&u&&u(D),D;if(n.encrypted){if(typeof m!="string"&&!Buffer.isBuffer(m))throw U.Errors.INVALID_PASS_PARAM();D=ie.ZipCrypto.decrypt(D,n,m)}}catch(T){if(e&&u)return u(Buffer.alloc(0),T),Buffer.alloc(0);throw T}var L;switch(n.method){case U.Constants.STORED:if(L=Buffer.alloc(D.length),D.copy(L),O(L))return e&&u&&u(L),L;throw e&&u&&u(L,U.Errors.BAD_CRC()),U.Errors.BAD_CRC();case U.Constants.DEFLATED:var N=new ie.Inflater(D,n.size);if(e)N.inflateAsync(function(T,A){u&&(A?u(Buffer.alloc(0),A):O(T)?u(T):u(T,U.Errors.BAD_CRC()))});else{if(L=N.inflate(),!O(L))throw U.Errors.BAD_CRC(`"${y.decode(c)}"`);return L}break;default:throw e&&u&&u(Buffer.alloc(0),U.Errors.UNKNOWN_METHOD()),U.Errors.UNKNOWN_METHOD()}}function s(e,u){if((!r||!r.length)&&Buffer.isBuffer(o))return e&&u&&u(p()),p();if(r.length&&!d){var m;switch(n.method){case U.Constants.STORED:return n.compressedSize=n.size,m=Buffer.alloc(r.length),r.copy(m),e&&u&&u(m),m;default:case U.Constants.DEFLATED:var D=new ie.Deflater(r);if(e)D.deflateAsync(function(N){m=Buffer.alloc(N.length),n.compressedSize=N.length,N.copy(m),u&&u(m)});else{var L=D.deflate();return n.compressedSize=L.length,L}D=null;break}}else if(e&&u)u(Buffer.alloc(0));else return Buffer.alloc(0)}function f(e,u){return U.readBigUInt64LE(e,u)}function l(e){try{for(var u=0,m,D,L;u+4<e.length;)m=e.readUInt16LE(u),u+=2,D=e.readUInt16LE(u),u+=2,L=e.slice(u,u+D),u+=D,M.ID_ZIP64===m&&E(L)}catch{throw U.Errors.EXTRA_FIELD_PARSE_ERROR()}}function E(e){var u,m,D,L;e.length>=M.EF_ZIP64_SCOMP&&(u=f(e,M.EF_ZIP64_SUNCOMP),n.size===M.EF_ZIP64_OR_32&&(n.size=u)),e.length>=M.EF_ZIP64_RHO&&(m=f(e,M.EF_ZIP64_SCOMP),n.compressedSize===M.EF_ZIP64_OR_32&&(n.compressedSize=m)),e.length>=M.EF_ZIP64_DSN&&(D=f(e,M.EF_ZIP64_RHO),n.offset===M.EF_ZIP64_OR_32&&(n.offset=D)),e.length>=M.EF_ZIP64_DSN+4&&(L=e.readUInt32LE(M.EF_ZIP64_DSN),n.diskNumStart===M.EF_ZIP64_OR_16&&(n.diskNumStart=L))}return{get entryName(){return y.decode(c)},get rawEntryName(){return c},set entryName(e){c=U.toBuffer(e,y.encode);var u=c[c.length-1];d=u===47||u===92,n.fileNameLength=c.length},get efs(){return typeof S=="function"?S(this.entryName):S},get extra(){return I},set extra(e){I=e,n.extraLength=e.length,l(e)},get comment(){return y.decode(a)},set comment(e){if(a=U.toBuffer(e,y.encode),n.commentLength=a.length,a.length>65535)throw U.Errors.COMMENT_TOO_LONG()},get name(){let e=y.decode(c);return d?e.replace(/[/\\]$/,"").split("/").pop():e.split("/").pop()},get isDirectory(){return d},getCompressedData:function(){return s(!1,null)},getCompressedDataAsync:function(e){s(!0,e)},setData:function(e){r=U.toBuffer(e,U.decoder.encode),!d&&r.length?(n.size=r.length,n.method=U.Constants.DEFLATED,n.crc=U.crc32(e),n.changed=!0):n.method=U.Constants.STORED},getData:function(e){return n.changed?r:i(!1,null,e)},getDataAsync:function(e,u){n.changed?e(r):i(!0,e,u)},set attr(e){n.attr=e},get attr(){return n.attr},set header(e){n.loadFromBinary(e)},get header(){return n},packCentralHeader:function(){n.flags_efs=this.efs,n.extraLength=I.length;var e=n.centralHeaderToBinary(),u=U.Constants.CENHDR;return c.copy(e,u),u+=c.length,I.copy(e,u),u+=n.extraLength,a.copy(e,u),e},packLocalHeader:function(){let e=0;n.flags_efs=this.efs,n.extraLocalLength=C.length;let u=n.localHeaderToBinary(),m=Buffer.alloc(u.length+c.length+n.extraLocalLength);return u.copy(m,e),e+=u.length,c.copy(m,e),e+=c.length,C.copy(m,e),e+=C.length,m},toJSON:function(){let e=function(u){return"<"+(u&&u.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:n.toJSON(),compressedData:e(o),data:e(r)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Ze=H((Dt,Be)=>{var xe=oe(),Qe=re(),P=W();Be.exports=function(t,o){var n=[],c=Object.create(null),a=Buffer.alloc(0),d=new Qe.MainHeader,r=!1,I=null;let C=new Set,S=o,{noSort:_,decoder:y}=S;t?i(S.readEntries):r=!0;function p(){let f=new Set;for(let l of Object.keys(c)){let E=l.split("/");if(E.pop(),!!E.length)for(let e=0;e<E.length;e++){let u=E.slice(0,e+1).join("/")+"/";f.add(u)}}for(let l of f)if(!(l in c)){let E=new xe(S);E.entryName=l,E.attr=16,E.temporary=!0,n.push(E),c[E.entryName]=E,C.add(E)}}function O(){if(r=!0,c=Object.create(null),d.diskEntries>(t.length-d.offset)/P.Constants.CENHDR)throw P.Errors.DISK_ENTRY_TOO_LARGE();n=new Array(d.diskEntries);for(var f=d.offset,l=0;l<n.length;l++){var E=f,e=new xe(S,t);if(e.header=t.slice(E,E+=P.Constants.CENHDR),e.entryName=t.slice(E,E+=e.header.fileNameLength),e.header.extraLength&&(e.extra=t.slice(E,E+=e.header.extraLength)),e.header.commentLength&&(e.comment=t.slice(E,E+e.header.commentLength)),f+=e.header.centralHeaderSize,e.entryName in c)throw P.Errors.DUPLICATE_ENTRY(`"${e.entryName}"`);n[l]=e,c[e.entryName]=e}C.clear(),p()}function i(f){var l=t.length-P.Constants.ENDHDR,E=Math.max(0,l-65535),e=E,u=t.length,m=-1,D=0;for(typeof S.trailingSpace=="boolean"&&S.trailingSpace&&(E=0),l;l>=e;l--)if(t[l]===80){if(t.readUInt32LE(l)===P.Constants.ENDSIG){m=l,D=l,u=l+P.Constants.ENDHDR,e=l-P.Constants.END64HDR;continue}if(t.readUInt32LE(l)===P.Constants.END64SIG){e=E;continue}if(t.readUInt32LE(l)===P.Constants.ZIP64SIG){m=l,u=l+P.readBigUInt64LE(t,l+P.Constants.ZIP64SIZE)+P.Constants.ZIP64LEAD;break}}if(m==-1)throw P.Errors.INVALID_FORMAT();d.loadFromBinary(t.slice(m,u)),d.commentLength&&(a=t.slice(D+P.Constants.ENDHDR)),f&&O()}function s(){n.length>1&&!_&&(n=n.map(f=>({entry:f,key:f.entryName.toLowerCase()})).sort((f,l)=>f.key.localeCompare(l.key)).map(f=>f.entry))}return{get entries(){return r||O(),n.filter(f=>!C.has(f))},get comment(){return y.decode(a)},set comment(f){a=P.toBuffer(f,y.encode),d.commentLength=a.length},getEntryCount:function(){return r?n.length:d.diskEntries},forEach:function(f){this.entries.forEach(f)},getEntry:function(f){return r||O(),c[f]||null},setEntry:function(f){r||O(),n.push(f),c[f.entryName]=f,d.totalEntries=n.length},deleteFile:function(f,l=!0){r||O();let E=c[f];this.getEntryChildren(E,l).map(u=>u.entryName).forEach(this.deleteEntry)},deleteEntry:function(f){r||O();let l=c[f],E=n.indexOf(l);E>=0&&(n.splice(E,1),delete c[f],d.totalEntries=n.length)},getEntryChildren:function(f,l=!0){if(r||O(),typeof f=="object")if(f.isDirectory&&l){let E=[],e=f.entryName;for(let u of n)u.entryName.startsWith(e)&&E.push(u);return E}else return[f];return[]},getChildCount:function(f){if(f&&f.isDirectory){let l=this.getEntryChildren(f);return l.includes(f)?l.length-1:l.length}return 0},compressToBuffer:function(){r||O(),s();let f=[],l=[],E=0,e=0;d.size=0,d.offset=0;let u=0;for(let L of this.entries){let N=L.getCompressedData();L.header.offset=e;let T=L.packLocalHeader(),A=T.length+N.length;e+=A,f.push(T),f.push(N);let F=L.packCentralHeader();l.push(F),d.size+=F.length,E+=A+F.length,u++}E+=d.mainHeaderSize,d.offset=e,d.totalEntries=u,e=0;let m=Buffer.alloc(E);for(let L of f)L.copy(m,e),e+=L.length;for(let L of l)L.copy(m,e),e+=L.length;let D=d.toBinary();return a&&a.copy(D,D.length-a.length),D.copy(m,e),t=m,r=!1,m},toAsyncBuffer:function(f,l,E,e){try{r||O(),s();let u=[],m=[],D=0,L=0,N=0;d.size=0,d.offset=0;let T=function(A){if(A.length>0){let F=A.shift(),Z=F.entryName+F.extra.toString();E&&E(Z),F.getCompressedDataAsync(function(v){e&&e(Z),F.header.offset=L;let V=F.packLocalHeader(),J=V.length+v.length;L+=J,u.push(V),u.push(v);let K=F.packCentralHeader();m.push(K),d.size+=K.length,D+=J+K.length,N++,T(A)})}else{D+=d.mainHeaderSize,d.offset=L,d.totalEntries=N,L=0;let F=Buffer.alloc(D);u.forEach(function(v){v.copy(F,L),L+=v.length}),m.forEach(function(v){v.copy(F,L),L+=v.length});let Z=d.toBinary();a&&a.copy(Z,Z.length-a.length),Z.copy(F,L),t=F,r=!1,f(F)}};T(Array.from(this.entries))}catch(u){l(u)}}}}});var rt=H((Nt,He)=>{var B=W(),x=j("path"),ke=oe(),et=Ze(),X=(...t)=>B.findLast(t,o=>typeof o=="boolean"),ve=(...t)=>B.findLast(t,o=>typeof o=="string"),tt=(...t)=>B.findLast(t,o=>typeof o=="function"),nt={noSort:!1,readEntries:!1,method:B.Constants.NONE,fs:null};He.exports=function(t,o){let n=null,c=Object.assign(Object.create(null),nt);t&&typeof t=="object"&&(t instanceof Uint8Array||(Object.assign(c,t),t=c.input?c.input:void 0,c.input&&delete c.input),Buffer.isBuffer(t)&&(n=t,c.method=B.Constants.BUFFER,t=void 0)),Object.assign(c,o);let a=new B(c),d=i=>{i.filter(s=>s.attr).sort((s,f)=>f.path.length-s.path.length).forEach(s=>a.fs.chmodSync(s.path,s.attr))};if((typeof c.decoder!="object"||typeof c.decoder.encode!="function"||typeof c.decoder.decode!="function")&&(c.decoder=B.decoder),t&&typeof t=="string")if(a.fs.existsSync(t))c.method=B.Constants.FILE,c.filename=t,n=a.fs.readFileSync(t);else throw B.Errors.INVALID_FILENAME();let r=new et(n,c),{canonical:I,sanitize:C,zipnamefix:S}=B;function _(i){if(i&&r){var s;if(typeof i=="string"&&(s=r.getEntry(x.posix.normalize(i))),typeof i=="object"&&typeof i.entryName<"u"&&typeof i.header<"u"&&(s=r.getEntry(i.entryName)),s)return s}return null}function y(i){let{join:s,normalize:f,sep:l}=x.posix;return s(x.isAbsolute(i)?"/":".",f(l+i.split("\\").join(l)+l))}function p(i){return i instanceof RegExp?(function(s){return function(f){return s.test(f)}})(i):typeof i!="function"?()=>!0:i}let O=(i,s)=>{let f=s.slice(-1);return f=f===a.sep?a.sep:"",x.relative(i,s)+f};return{readFile:function(i,s){var f=_(i);return f&&f.getData(s)||null},childCount:function(i){let s=_(i);if(s)return r.getChildCount(s)},readFileAsync:function(i,s){var f=_(i);f?f.getDataAsync(s):s(null,"getEntry failed for:"+i)},readAsText:function(i,s){var f=_(i);if(f){var l=f.getData();if(l&&l.length)return l.toString(s||"utf8")}return""},readAsTextAsync:function(i,s,f){var l=_(i);l?l.getDataAsync(function(E,e){if(e){s(E,e);return}E&&E.length?s(E.toString(f||"utf8")):s("")}):s("")},deleteFile:function(i,s=!0){var f=_(i);f&&r.deleteFile(f.entryName,s)},deleteEntry:function(i){var s=_(i);s&&r.deleteEntry(s.entryName)},addZipComment:function(i){r.comment=i},getZipComment:function(){return r.comment||""},addZipEntryComment:function(i,s){var f=_(i);f&&(f.comment=s)},getZipEntryComment:function(i){var s=_(i);return s&&s.comment||""},updateFile:function(i,s){var f=_(i);f&&f.setData(s)},addLocalFile:function(i,s,f,l){if(a.fs.existsSync(i)){s=s?y(s):"";let E=x.win32.basename(x.win32.normalize(i));s+=f||E;let e=a.fs.statSync(i),u=e.isFile()?a.fs.readFileSync(i):Buffer.alloc(0);e.isDirectory()&&(s+=a.sep),this.addFile(s,u,l,e)}else throw B.Errors.FILE_NOT_FOUND(i)},addLocalFileAsync:function(i,s){i=typeof i=="object"?i:{localPath:i};let f=x.resolve(i.localPath),{comment:l}=i,{zipPath:E,zipName:e}=i,u=this;a.fs.stat(f,function(m,D){if(m)return s(m,!1);E=E?y(E):"";let L=x.win32.basename(x.win32.normalize(f));if(E+=e||L,D.isFile())a.fs.readFile(f,function(N,T){return N?s(N,!1):(u.addFile(E,T,l,D),setImmediate(s,void 0,!0))});else if(D.isDirectory())return E+=a.sep,u.addFile(E,Buffer.alloc(0),l,D),setImmediate(s,void 0,!0)})},addLocalFolder:function(i,s,f){if(f=p(f),s=s?y(s):"",i=x.normalize(i),a.fs.existsSync(i)){let l=a.findFiles(i),E=this;if(l.length)for(let e of l){let u=x.join(s,O(i,e));f(u)&&E.addLocalFile(e,x.dirname(u))}}else throw B.Errors.FILE_NOT_FOUND(i)},addLocalFolderAsync:function(i,s,f,l){l=p(l),f=f?y(f):"",i=x.normalize(i);var E=this;a.fs.open(i,"r",function(e){if(e&&e.code==="ENOENT")s(void 0,B.Errors.FILE_NOT_FOUND(i));else if(e)s(void 0,e);else{var u=a.findFiles(i),m=-1,D=function(){if(m+=1,m<u.length){var L=u[m],N=O(i,L).split("\\").join("/");N=N.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),l(N)?a.fs.stat(L,function(T,A){T&&s(void 0,T),A.isFile()?a.fs.readFile(L,function(F,Z){F?s(void 0,F):(E.addFile(f+N,Z,"",A),D())}):(E.addFile(f+N+"/",Buffer.alloc(0),"",A),D())}):process.nextTick(()=>{D()})}else s(!0,void 0)};D()}})},addLocalFolderAsync2:function(i,s){let f=this;i=typeof i=="object"?i:{localPath:i};let l=x.resolve(i.localPath),{zipPath:E,filter:e,namefix:u}=i;e instanceof RegExp?e=(function(L){return function(N){return L.test(N)}})(e):typeof e!="function"&&(e=function(){return!0}),E=E?y(E):"",u==="latin1"&&(u=L=>L.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof u!="function"&&(u=L=>L);let m=L=>x.join(E,u(O(l,L))),D=L=>x.win32.basename(x.win32.normalize(u(L)));a.fs.open(l,"r",function(L){L&&L.code==="ENOENT"?s(B.Errors.FILE_NOT_FOUND(l),!1):L?s(L,!1):a.findFilesAsync(l,function(N,T){if(N)return s(N,!1);if(T=T.filter(A=>e(m(A))),!T.length)return s(void 0,!0);setImmediate(T.reverse().reduce(function(A,F){return function(Z,v){if(Z||v===!1)return setImmediate(A,Z,!1);f.addLocalFileAsync({localPath:F,zipPath:x.dirname(m(F)),zipName:D(F)},A)}},s))})})},addLocalFolderPromise:function(i,s){return new Promise((f,l)=>{this.addLocalFolderAsync2(Object.assign({localPath:i},s),(E,e)=>{if(E)return l(E);e&&f(this)})})},addFile:function(i,s,f,l){i=S(i);let E=_(i),e=E!=null;e||(E=new ke(c),E.entryName=i),E.comment=f||"";let u=typeof l=="object"&&l instanceof a.fs.Stats;u&&(E.header.time=l.mtime);var m=E.isDirectory?16:0;let D=E.isDirectory?16384:32768;return u?D|=4095&l.mode:typeof l=="number"?D|=4095&l:D|=E.isDirectory?493:420,m=(m|D<<16)>>>0,E.attr=m,E.setData(s),e||r.setEntry(E),E},getEntries:function(i){return r.password=i,r?r.entries:[]},getEntry:function(i){return _(i)},getEntryCount:function(){return r.getEntryCount()},forEach:function(i){return r.forEach(i)},extractEntryTo:function(i,s,f,l,E,e){l=X(!1,l),E=X(!1,E),f=X(!0,f),e=ve(E,e);var u=_(i);if(!u)throw B.Errors.NO_ENTRY();var m=I(u.entryName),D=C(s,e&&!u.isDirectory?I(e):f?m:x.basename(m));if(u.isDirectory){var L=r.getEntryChildren(u);return L.forEach(function(A){if(A.isDirectory)return;var F=A.getData();if(!F)throw B.Errors.CANT_EXTRACT_FILE();var Z=I(f?A.entryName:A.entryName.substring(u.entryName.length)),v=C(s,Z);a.assertPathSafe(s,v);let V=E?A.header.fileAttr:void 0;a.writeFileTo(v,F,l,V)}),!0}var N=u.getData(r.password);if(!N)throw B.Errors.CANT_EXTRACT_FILE();if(a.assertPathSafe(s,D),a.fs.existsSync(D)&&!l)throw B.Errors.CANT_OVERRIDE();let T=E?i.header.fileAttr:void 0;return a.writeFileTo(D,N,l,T),!0},test:function(i){if(!r)return!1;for(var s of r.entries)try{if(s.isDirectory)continue;var f=s.getData(i);if(!f)return!1}catch{return!1}return!0},extractAllTo:function(i,s,f,l){if(f=X(!1,f),l=ve(f,l),s=X(!1,s),!r)throw B.Errors.NO_ZIP();let E=[];r.entries.forEach(function(e){var u=C(i,I(e.entryName));if(a.assertPathSafe(i,u),e.isDirectory){a.makeDir(u),f&&E.push({path:u,attr:e.header.fileAttr});return}var m=e.getData(l);if(!m)throw B.Errors.CANT_EXTRACT_FILE();let D=f?e.header.fileAttr:void 0;a.writeFileTo(u,m,s,D);try{a.fs.utimesSync(u,e.header.time,e.header.time)}catch{}}),d(E)},extractAllToAsync:function(i,s,f,l){if(l=tt(s,f,l),f=X(!1,f),s=X(!1,s),!l)return new Promise((N,T)=>{this.extractAllToAsync(i,s,f,function(A){A?T(A):N(this)})});if(!r){l(B.Errors.NO_ZIP());return}i=x.resolve(i);let E=N=>C(i,x.normalize(I(N.entryName))),e=(N,T)=>new Error(N+': "'+T+'"'),u=[],m=[];r.entries.forEach(N=>{N.isDirectory?u.push(N):m.push(N)});let D=[];for(let N of u){let T=E(N),A=f?N.header.fileAttr:void 0;try{a.assertPathSafe(i,T),a.makeDir(T)}catch{l(e("Unable to create folder",T));continue}A&&D.push({path:T,attr:A});try{a.fs.utimesSync(T,N.header.time,N.header.time)}catch{}}let L=N=>{if(!N)try{d(D)}catch(T){return l(e("Unable to set folder permissions",T.path||""))}l(N)};m.reverse().reduce(function(N,T){return function(A){if(A)N(A);else{let F=x.normalize(I(T.entryName)),Z=C(i,F);try{a.assertPathSafe(i,Z)}catch(v){return N(v)}T.getDataAsync(function(v,V){if(V)N(V);else if(!v)N(B.Errors.CANT_EXTRACT_FILE());else{let J=f?T.header.fileAttr:void 0;a.writeFileToAsync(Z,v,s,J,function(K){if(!K)return N(e("Unable to write file",Z));a.fs.utimes(Z,T.header.time,T.header.time,function(){N()})})}})}}},L)()},writeZip:function(i,s){if(arguments.length===1&&typeof i=="function"&&(s=i,i=""),!i&&c.filename&&(i=c.filename),!!i){var f=r.compressToBuffer();if(f){var l=a.writeFileTo(i,f,!0);typeof s=="function"&&s(l?null:new Error("failed"),"")}}},writeZipPromise:function(i,s){let{overwrite:f,perm:l}=Object.assign({overwrite:!0},s);return new Promise((E,e)=>{!i&&c.filename&&(i=c.filename),i||e("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(u=>{let m=D=>D?E(D):e("ADM-ZIP: Wasn't able to write zip file");a.writeFileToAsync(i,u,f,l,m)},e)})},toBufferPromise:function(){return new Promise((i,s)=>{r.toAsyncBuffer(i,s)})},toBuffer:function(i,s,f,l){return typeof i=="function"?(r.toAsyncBuffer(i,s,f,l),null):r.compressToBuffer()}}}});export default rt();
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a as i,e as t}from"./chunk-5PYTOHLZ.js";import"./chunk-TMUK2DD3.js";async function l(){let e=await Promise.all(i.map(async n=>await t(n.id)?n.id:null));return new Set(e.filter(n=>n!==null))}export{l as installedExtensionIds};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{m as l}from"./chunk-V4GHQGQM.js";import{d as a}from"./chunk-EOYBXOCV.js";import"./chunk-TMUK2DD3.js";var i={loadPreferences:a,loadShell:()=>import("./launch-2OI4ZLBQ.js")};async function p(e=i){let o=e.loadShell();o.catch(()=>{});let{prefs:t,warning:r}=await e.loadPreferences(),n=l(t.theme),{launchShell:s}=await o;await s({prefs:t,palette:n,...r===void 0?{}:{warning:r}})}export{p as bootShell};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a as Mr,c as Le}from"./chunk-TMUK2DD3.js";var Ve=Le((Xe,Lr)=>{var V="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Qr(o){for(var c="",d=0,C=0,y=0,z=0,M=0,L=0,D=0,U=0;U<o.length;)d=o.charCodeAt(U++),z=d>>2,C=o.charCodeAt(U++),M=(d&3)<<4|C>>4,y=o.charCodeAt(U++),L=(C&15)<<2|y>>6,D=y&63,isNaN(C)?L=D=64:isNaN(y)&&(D=64),c+=V.charAt(z)+V.charAt(M)+V.charAt(L)+V.charAt(D);return c}function br(o){var c="",d=0,C=0,y=0,z=0,M=0,L=0,D=0;o=o.replace(/[^\w\+\/\=]/g,"");for(var U=0;U<o.length;)z=V.indexOf(o.charAt(U++)),M=V.indexOf(o.charAt(U++)),d=z<<2|M>>4,c+=String.fromCharCode(d),L=V.indexOf(o.charAt(U++)),C=(M&15)<<4|L>>2,L!==64&&(c+=String.fromCharCode(C)),D=V.indexOf(o.charAt(U++)),y=(L&3)<<6|D,D!==64&&(c+=String.fromCharCode(y));return c}var O=(function(){return typeof Buffer<"u"&&typeof process<"u"&&typeof process.versions<"u"&&!!process.versions.node})(),Nr=(function(){if(typeof Buffer<"u"){var o=!Buffer.from;if(!o)try{Buffer.from("foo","utf8")}catch{o=!0}return o?function(c,d){return d?new Buffer(c,d):new Buffer(c)}:Buffer.from.bind(Buffer)}return function(){}})();function ie(o){if(O){if(Buffer.alloc)return Buffer.alloc(o);var c=new Buffer(o);return c.fill(0),c}return typeof Uint8Array<"u"?new Uint8Array(o):new Array(o)}function re(o){return O?Buffer.allocUnsafe?Buffer.allocUnsafe(o):new Buffer(o):typeof Uint8Array<"u"?new Uint8Array(o):new Array(o)}var W=function(c){return O?Nr(c,"binary"):c.split("").map(function(d){return d.charCodeAt(0)&255})},ar=/\u0000/g,_r=/[\u0001-\u0006]/g,wr=function(o){for(var c=[],d=0;d<o[0].length;++d)c.push.apply(c,o[0][d]);return c},Ne=wr,Or=function(o,c,d){for(var C=[],y=c;y<d;y+=2)C.push(String.fromCharCode(ae(o,y)));return C.join("").replace(ar,"")},Oe=Or,Fr=function(o,c,d){for(var C=[],y=c;y<c+d;++y)C.push(("0"+o[y].toString(16)).slice(-2));return C.join("")},ze=Fr,ne=function(o){if(Array.isArray(o[0]))return[].concat.apply([],o);var c=0,d=0;for(d=0;d<o.length;++d)c+=o[d].length;var C=new Uint8Array(c);for(d=0,c=0;d<o.length;c+=o[d].length,++d)C.set(o[d],c);return C},K=ne;O&&(Or=function(o,c,d){return Buffer.isBuffer(o)?o.toString("utf16le",c,d).replace(ar,""):Oe(o,c,d)},Fr=function(o,c,d){return Buffer.isBuffer(o)?o.toString("hex",c,c+d):ze(o,c,d)},wr=function(o){return o[0].length>0&&Buffer.isBuffer(o[0][0])?Buffer.concat(o[0]):Ne(o)},W=function(o){return Nr(o,"binary")},K=function(o){return Buffer.isBuffer(o[0])?Buffer.concat(o):ne(o)});var He=function(o,c){return o[c]},ae=function(o,c){return o[c+1]*256+o[c]},je=function(o,c){var d=o[c+1]*256+o[c];return d<32768?d:(65535-d+1)*-1},ee=function(o,c){return o[c+3]*(1<<24)+(o[c+2]<<16)+(o[c+1]<<8)+o[c]},Q=function(o,c){return(o[c+3]<<24)+(o[c+2]<<16)+(o[c+1]<<8)+o[c]};function fe(o,c){var d,C,y=0;switch(o){case 1:d=He(this,this.l);break;case 2:d=(c!=="i"?ae:je)(this,this.l);break;case 4:d=Q(this,this.l);break;case 16:y=2,C=Fr(this,this.l,o)}return this.l+=o,y===0?d:C}var $e=function(o,c,d){o[d]=c&255,o[d+1]=c>>>8&255,o[d+2]=c>>>16&255,o[d+3]=c>>>24&255},Ge=function(o,c,d){o[d]=c&255,o[d+1]=c>>8&255,o[d+2]=c>>16&255,o[d+3]=c>>24&255};function Je(o,c,d){var C=0,y=0;switch(d){case"hex":for(;y<o;++y)this[this.l++]=parseInt(c.slice(2*y,2*y+2),16)||0;return this;case"utf16le":var z=this.l+o;for(y=0;y<Math.min(c.length,o);++y){var M=c.charCodeAt(y);this[this.l++]=M&255,this[this.l++]=M>>8}for(;this.l<z;)this[this.l++]=0;return this}switch(o){case 1:C=1,this[this.l]=c&255;break;case 2:C=2,this[this.l]=c&255,c>>>=8,this[this.l+1]=c&255;break;case 4:C=4,$e(this,c,this.l);break;case-4:C=4,Ge(this,c,this.l);break}return this.l+=C,this}function se(o,c){var d=Fr(this,this.l,o.length>>1);if(d!==o)throw new Error(c+"Expected "+o+" saw "+d);this.l+=o.length>>1}function J(o,c){o.l=c,o.read_shift=fe,o.chk=se,o.write_shift=Je}function j(o){var c=ie(o);return J(c,0),c}var te=(function(){var o={};o.version="1.2.1";function c(){for(var x=0,P=new Array(256),p=0;p!=256;++p)x=p,x=x&1?-306674912^x>>>1:x>>>1,x=x&1?-306674912^x>>>1:x>>>1,x=x&1?-306674912^x>>>1:x>>>1,x=x&1?-306674912^x>>>1:x>>>1,x=x&1?-306674912^x>>>1:x>>>1,x=x&1?-306674912^x>>>1:x>>>1,x=x&1?-306674912^x>>>1:x>>>1,x=x&1?-306674912^x>>>1:x>>>1,P[p]=x;return typeof Int32Array<"u"?new Int32Array(P):P}var d=c();function C(x){var P=0,p=0,A=0,I=typeof Int32Array<"u"?new Int32Array(4096):new Array(4096);for(A=0;A!=256;++A)I[A]=x[A];for(A=0;A!=256;++A)for(p=x[A],P=256+A;P<4096;P+=256)p=I[P]=p>>>8^x[p&255];var S=[];for(A=1;A!=16;++A)S[A-1]=typeof Int32Array<"u"?I.subarray(A*256,A*256+256):I.slice(A*256,A*256+256);return S}var y=C(d),z=y[0],M=y[1],L=y[2],D=y[3],U=y[4],X=y[5],dr=y[6],xr=y[7],gr=y[8],pr=y[9],yr=y[10],fr=y[11],mr=y[12],Cr=y[13],Ar=y[14];function sr(x,P){for(var p=P^-1,A=0,I=x.length;A<I;)p=p>>>8^d[(p^x.charCodeAt(A++))&255];return~p}function Ir(x,P){for(var p=P^-1,A=x.length-15,I=0;I<A;)p=Ar[x[I++]^p&255]^Cr[x[I++]^p>>8&255]^mr[x[I++]^p>>16&255]^fr[x[I++]^p>>>24]^yr[x[I++]]^pr[x[I++]]^gr[x[I++]]^xr[x[I++]]^dr[x[I++]]^X[x[I++]]^U[x[I++]]^D[x[I++]]^L[x[I++]]^M[x[I++]]^z[x[I++]]^d[x[I++]];for(A+=15;I<A;)p=p>>>8^d[(p^x[I++])&255];return~p}function Er(x,P){for(var p=P^-1,A=0,I=x.length,S=0,R=0;A<I;)S=x.charCodeAt(A++),S<128?p=p>>>8^d[(p^S)&255]:S<2048?(p=p>>>8^d[(p^(192|S>>6&31))&255],p=p>>>8^d[(p^(128|S&63))&255]):S>=55296&&S<57344?(S=(S&1023)+64,R=x.charCodeAt(A++)&1023,p=p>>>8^d[(p^(240|S>>8&7))&255],p=p>>>8^d[(p^(128|S>>2&63))&255],p=p>>>8^d[(p^(128|R>>6&15|(S&3)<<4))&255],p=p>>>8^d[(p^(128|R&63))&255]):(p=p>>>8^d[(p^(224|S>>12&15))&255],p=p>>>8^d[(p^(128|S>>6&63))&255],p=p>>>8^d[(p^(128|S&63))&255]);return~p}return o.table=d,o.bstr=sr,o.buf=Ir,o.str=Er,o})(),b=(function(){var c={};c.version="1.2.2";function d(r,i){for(var e=r.split("/"),t=i.split("/"),n=0,a=0,s=Math.min(e.length,t.length);n<s;++n){if(a=e[n].length-t[n].length)return a;if(e[n]!=t[n])return e[n]<t[n]?-1:1}return e.length-t.length}function C(r){if(r.charAt(r.length-1)=="/")return r.slice(0,-1).indexOf("/")===-1?r:C(r.slice(0,-1));var i=r.lastIndexOf("/");return i===-1?r:r.slice(0,i+1)}function y(r){if(r.charAt(r.length-1)=="/")return y(r.slice(0,-1));var i=r.lastIndexOf("/");return i===-1?r:r.slice(i+1)}function z(r,i){typeof i=="string"&&(i=new Date(i));var e=i.getHours();e=e<<6|i.getMinutes(),e=e<<5|i.getSeconds()>>>1,r.write_shift(2,e);var t=i.getFullYear()-1980;t=t<<4|i.getMonth()+1,t=t<<5|i.getDate(),r.write_shift(2,t)}function M(r){var i=r.read_shift(2)&65535,e=r.read_shift(2)&65535,t=new Date,n=e&31;e>>>=5;var a=e&15;e>>>=4,t.setMilliseconds(0),t.setFullYear(e+1980),t.setMonth(a-1),t.setDate(n);var s=i&31;i>>>=5;var u=i&63;return i>>>=6,t.setHours(i),t.setMinutes(u),t.setSeconds(s<<1),t}function L(r){J(r,0);for(var i={},e=0;r.l<=r.length-4;){var t=r.read_shift(2),n=r.read_shift(2),a=r.l+n,s={};t===21589&&(e=r.read_shift(1),e&1&&(s.mtime=r.read_shift(4)),n>5&&(e&2&&(s.atime=r.read_shift(4)),e&4&&(s.ctime=r.read_shift(4))),s.mtime&&(s.mt=new Date(s.mtime*1e3))),r.l=a,i[t]=s}return i}var D;function U(){return D||(D=Mr("fs"))}function X(r,i){if(r[0]==80&&r[1]==75)return Kr(r,i);if((r[0]|32)==109&&(r[1]|32)==105)return Te(r,i);if(r.length<512)throw new Error("CFB file size "+r.length+" < 512");var e=3,t=512,n=0,a=0,s=0,u=0,f=0,h=[],l=r.slice(0,512);J(l,0);var v=dr(l);switch(e=v[0],e){case 3:t=512;break;case 4:t=4096;break;case 0:if(v[1]==0)return Kr(r,i);default:throw new Error("Major Version: Expected 3 or 4 saw "+e)}t!==512&&(l=r.slice(0,t),J(l,28));var _=r.slice(0,t);xr(l,e);var g=l.read_shift(4,"i");if(e===3&&g!==0)throw new Error("# Directory Sectors: Expected 0 saw "+g);l.l+=4,s=l.read_shift(4,"i"),l.l+=4,l.chk("00100000","Mini Stream Cutoff Size: "),u=l.read_shift(4,"i"),n=l.read_shift(4,"i"),f=l.read_shift(4,"i"),a=l.read_shift(4,"i");for(var w=-1,F=0;F<109&&(w=l.read_shift(4,"i"),!(w<0));++F)h[F]=w;var m=gr(r,t);fr(f,a,m,t,h);var E=Cr(m,s,h,t);E[s].name="!Directory",n>0&&u!==R&&(E[u].name="!MiniFAT"),E[h[0]].name="!FAT",E.fat_addrs=h,E.ssz=t;var T={},k=[],N=[],ir=[];Ar(s,E,m,k,n,T,N,u),pr(N,ir,k),k.shift();var nr={FileIndex:N,FullPaths:ir};return i&&i.raw&&(nr.raw={header:_,sectors:m}),nr}function dr(r){if(r[r.l]==80&&r[r.l+1]==75)return[0,0];r.chk(zr,"Header Signature: "),r.l+=16;var i=r.read_shift(2,"u");return[r.read_shift(2,"u"),i]}function xr(r,i){var e=9;switch(r.l+=2,e=r.read_shift(2)){case 9:if(i!=3)throw new Error("Sector Shift: Expected 9 saw "+e);break;case 12:if(i!=4)throw new Error("Sector Shift: Expected 12 saw "+e);break;default:throw new Error("Sector Shift: Expected 9 or 12 saw "+e)}r.chk("0600","Mini Sector Shift: "),r.chk("000000000000","Reserved: ")}function gr(r,i){for(var e=Math.ceil(r.length/i)-1,t=[],n=1;n<e;++n)t[n-1]=r.slice(n*i,(n+1)*i);return t[e-1]=r.slice(e*i),t}function pr(r,i,e){for(var t=0,n=0,a=0,s=0,u=0,f=e.length,h=[],l=[];t<f;++t)h[t]=l[t]=t,i[t]=e[t];for(;u<l.length;++u)t=l[u],n=r[t].L,a=r[t].R,s=r[t].C,h[t]===t&&(n!==-1&&h[n]!==n&&(h[t]=h[n]),a!==-1&&h[a]!==a&&(h[t]=h[a])),s!==-1&&(h[s]=t),n!==-1&&t!=h[t]&&(h[n]=h[t],l.lastIndexOf(n)<u&&l.push(n)),a!==-1&&t!=h[t]&&(h[a]=h[t],l.lastIndexOf(a)<u&&l.push(a));for(t=1;t<f;++t)h[t]===t&&(a!==-1&&h[a]!==a?h[t]=h[a]:n!==-1&&h[n]!==n&&(h[t]=h[n]));for(t=1;t<f;++t)if(r[t].type!==0){if(u=t,u!=h[u])do u=h[u],i[t]=i[u]+"/"+i[t];while(u!==0&&h[u]!==-1&&u!=h[u]);h[t]=-1}for(i[0]+="/",t=1;t<f;++t)r[t].type!==2&&(i[t]+="/")}function yr(r,i,e){for(var t=r.start,n=r.size,a=[],s=t;e&&n>0&&s>=0;)a.push(i.slice(s*S,s*S+S)),n-=S,s=Q(e,s*4);return a.length===0?j(0):K(a).slice(0,r.size)}function fr(r,i,e,t,n){var a=R;if(r===R){if(i!==0)throw new Error("DIFAT chain shorter than expected")}else if(r!==-1){var s=e[r],u=(t>>>2)-1;if(!s)return;for(var f=0;f<u&&(a=Q(s,f*4))!==R;++f)n.push(a);i>=1&&fr(Q(s,t-4),i-1,e,t,n)}}function mr(r,i,e,t,n){var a=[],s=[];n||(n=[]);var u=t-1,f=0,h=0;for(f=i;f>=0;){n[f]=!0,a[a.length]=f,s.push(r[f]);var l=e[Math.floor(f*4/t)];if(h=f*4&u,t<4+h)throw new Error("FAT boundary crossed: "+f+" 4 "+t);if(!r[l])break;f=Q(r[l],h)}return{nodes:a,data:wr([s])}}function Cr(r,i,e,t){var n=r.length,a=[],s=[],u=[],f=[],h=t-1,l=0,v=0,_=0,g=0;for(l=0;l<n;++l)if(u=[],_=l+i,_>=n&&(_-=n),!s[_]){f=[];var w=[];for(v=_;v>=0;){w[v]=!0,s[v]=!0,u[u.length]=v,f.push(r[v]);var F=e[Math.floor(v*4/t)];if(g=v*4&h,t<4+g)throw new Error("FAT boundary crossed: "+v+" 4 "+t);if(!r[F]||(v=Q(r[F],g),w[v]))break}a[_]={nodes:u,data:wr([f])}}return a}function Ar(r,i,e,t,n,a,s,u){for(var f=0,h=t.length?2:0,l=i[r].data,v=0,_=0,g;v<l.length;v+=128){var w=l.slice(v,v+128);J(w,64),_=w.read_shift(2),g=Or(w,0,_-h),t.push(g);var F={name:g,type:w.read_shift(1),color:w.read_shift(1),L:w.read_shift(4,"i"),R:w.read_shift(4,"i"),C:w.read_shift(4,"i"),clsid:w.read_shift(16),state:w.read_shift(4,"i"),start:0,size:0},m=w.read_shift(2)+w.read_shift(2)+w.read_shift(2)+w.read_shift(2);m!==0&&(F.ct=sr(w,w.l-8));var E=w.read_shift(2)+w.read_shift(2)+w.read_shift(2)+w.read_shift(2);E!==0&&(F.mt=sr(w,w.l-8)),F.start=w.read_shift(4,"i"),F.size=w.read_shift(4,"i"),F.size<0&&F.start<0&&(F.size=F.type=0,F.start=R,F.name=""),F.type===5?(f=F.start,n>0&&f!==R&&(i[f].name="!StreamData")):F.size>=4096?(F.storage="fat",i[F.start]===void 0&&(i[F.start]=mr(e,F.start,i.fat_addrs,i.ssz)),i[F.start].name=F.name,F.content=i[F.start].data.slice(0,F.size)):(F.storage="minifat",F.size<0?F.size=0:f!==R&&F.start!==R&&i[f]&&(F.content=yr(F,i[f].data,(i[u]||{}).data))),F.content&&J(F.content,0),a[g]=F,s.push(F)}}function sr(r,i){return new Date((ee(r,i+4)/1e7*Math.pow(2,32)+ee(r,i)/1e7-11644473600)*1e3)}function Ir(r,i){return U(),X(D.readFileSync(r),i)}function Er(r,i){var e=i&&i.type;switch(e||O&&Buffer.isBuffer(r)&&(e="buffer"),e||"base64"){case"file":return Ir(r,i);case"base64":return X(W(br(r)),i);case"binary":return X(W(r),i)}return X(r,i)}function x(r,i){var e=i||{},t=e.root||"Root Entry";if(r.FullPaths||(r.FullPaths=[]),r.FileIndex||(r.FileIndex=[]),r.FullPaths.length!==r.FileIndex.length)throw new Error("inconsistent CFB structure");r.FullPaths.length===0&&(r.FullPaths[0]=t+"/",r.FileIndex[0]={name:t,type:5}),e.CLSID&&(r.FileIndex[0].clsid=e.CLSID),P(r)}function P(r){var i="Sh33tJ5";if(!b.find(r,"/"+i)){var e=j(4);e[0]=55,e[1]=e[3]=50,e[2]=54,r.FileIndex.push({name:i,type:2,content:e,size:4,L:69,R:69,C:69}),r.FullPaths.push(r.FullPaths[0]+i),p(r)}}function p(r,i){x(r);for(var e=!1,t=!1,n=r.FullPaths.length-1;n>=0;--n){var a=r.FileIndex[n];switch(a.type){case 0:t?e=!0:(r.FileIndex.pop(),r.FullPaths.pop());break;case 1:case 2:case 5:t=!0,isNaN(a.R*a.L*a.C)&&(e=!0),a.R>-1&&a.L>-1&&a.R==a.L&&(e=!0);break;default:e=!0;break}}if(!(!e&&!i)){var s=new Date(1987,1,19),u=0,f=Object.create?Object.create(null):{},h=[];for(n=0;n<r.FullPaths.length;++n)f[r.FullPaths[n]]=!0,r.FileIndex[n].type!==0&&h.push([r.FullPaths[n],r.FileIndex[n]]);for(n=0;n<h.length;++n){var l=C(h[n][0]);for(t=f[l];!t;){for(;C(l)&&!f[C(l)];)l=C(l);h.push([l,{name:y(l).replace("/",""),type:1,clsid:Sr,ct:s,mt:s,content:null}]),f[l]=!0,l=C(h[n][0]),t=f[l]}}for(h.sort(function(g,w){return d(g[0],w[0])}),r.FullPaths=[],r.FileIndex=[],n=0;n<h.length;++n)r.FullPaths[n]=h[n][0],r.FileIndex[n]=h[n][1];for(n=0;n<h.length;++n){var v=r.FileIndex[n],_=r.FullPaths[n];if(v.name=y(_).replace("/",""),v.L=v.R=v.C=-(v.color=1),v.size=v.content?v.content.length:0,v.start=0,v.clsid=v.clsid||Sr,n===0)v.C=h.length>1?1:-1,v.size=0,v.type=5;else if(_.slice(-1)=="/"){for(u=n+1;u<h.length&&C(r.FullPaths[u])!=_;++u);for(v.C=u>=h.length?-1:u,u=n+1;u<h.length&&C(r.FullPaths[u])!=C(_);++u);v.R=u>=h.length?-1:u,v.type=1}else C(r.FullPaths[n+1]||"")==C(_)&&(v.R=n+1),v.type=2}}}function A(r,i){var e=i||{};if(e.fileType=="mad")return De(r,e);if(p(r),e.fileType==="zip")return Ae(r,e);var t=(function(g){for(var w=0,F=0,m=0;m<g.FileIndex.length;++m){var E=g.FileIndex[m];if(E.content){var T=E.content.length;T>0&&(T<4096?w+=T+63>>6:F+=T+511>>9)}}for(var k=g.FullPaths.length+3>>2,N=w+7>>3,ir=w+127>>7,nr=N+F+k+ir,Y=nr+127>>7,Br=Y<=109?0:Math.ceil((Y-109)/127);nr+Y+Br+127>>7>Y;)Br=++Y<=109?0:Math.ceil((Y-109)/127);var G=[1,Br,Y,ir,k,F,w,0];return g.FileIndex[0].size=w<<6,G[7]=(g.FileIndex[0].start=G[0]+G[1]+G[2]+G[3]+G[4]+G[5])+(G[6]+7>>3),G})(r),n=j(t[7]<<9),a=0,s=0;{for(a=0;a<8;++a)n.write_shift(1,he[a]);for(a=0;a<8;++a)n.write_shift(2,0);for(n.write_shift(2,62),n.write_shift(2,3),n.write_shift(2,65534),n.write_shift(2,9),n.write_shift(2,6),a=0;a<3;++a)n.write_shift(2,0);for(n.write_shift(4,0),n.write_shift(4,t[2]),n.write_shift(4,t[0]+t[1]+t[2]+t[3]-1),n.write_shift(4,0),n.write_shift(4,4096),n.write_shift(4,t[3]?t[0]+t[1]+t[2]-1:R),n.write_shift(4,t[3]),n.write_shift(-4,t[1]?t[0]-1:R),n.write_shift(4,t[1]),a=0;a<109;++a)n.write_shift(-4,a<t[2]?t[1]+a:-1)}if(t[1])for(s=0;s<t[1];++s){for(;a<236+s*127;++a)n.write_shift(-4,a<t[2]?t[1]+a:-1);n.write_shift(-4,s===t[1]-1?R:s+1)}var u=function(g){for(s+=g;a<s-1;++a)n.write_shift(-4,a+1);g&&(++a,n.write_shift(-4,R))};for(s=a=0,s+=t[1];a<s;++a)n.write_shift(-4,rr.DIFSECT);for(s+=t[2];a<s;++a)n.write_shift(-4,rr.FATSECT);u(t[3]),u(t[4]);for(var f=0,h=0,l=r.FileIndex[0];f<r.FileIndex.length;++f)l=r.FileIndex[f],l.content&&(h=l.content.length,!(h<4096)&&(l.start=s,u(h+511>>9)));for(u(t[6]+7>>3);n.l&511;)n.write_shift(-4,rr.ENDOFCHAIN);for(s=a=0,f=0;f<r.FileIndex.length;++f)l=r.FileIndex[f],l.content&&(h=l.content.length,!(!h||h>=4096)&&(l.start=s,u(h+63>>6)));for(;n.l&511;)n.write_shift(-4,rr.ENDOFCHAIN);for(a=0;a<t[4]<<2;++a){var v=r.FullPaths[a];if(!v||v.length===0){for(f=0;f<17;++f)n.write_shift(4,0);for(f=0;f<3;++f)n.write_shift(4,-1);for(f=0;f<12;++f)n.write_shift(4,0);continue}l=r.FileIndex[a],a===0&&(l.start=l.size?l.start-1:R);var _=a===0&&e.root||l.name;if(_.length>32&&(console.error("Name "+_+" will be truncated to "+_.slice(0,32)),_=_.slice(0,32)),h=2*(_.length+1),n.write_shift(64,_,"utf16le"),n.write_shift(2,h),n.write_shift(1,l.type),n.write_shift(1,l.color),n.write_shift(-4,l.L),n.write_shift(-4,l.R),n.write_shift(-4,l.C),l.clsid)n.write_shift(16,l.clsid,"hex");else for(f=0;f<4;++f)n.write_shift(4,0);n.write_shift(4,l.state||0),n.write_shift(4,0),n.write_shift(4,0),n.write_shift(4,0),n.write_shift(4,0),n.write_shift(4,l.start),n.write_shift(4,l.size),n.write_shift(4,0)}for(a=1;a<r.FileIndex.length;++a)if(l=r.FileIndex[a],l.size>=4096)if(n.l=l.start+1<<9,O&&Buffer.isBuffer(l.content))l.content.copy(n,n.l,0,l.size),n.l+=l.size+511&-512;else{for(f=0;f<l.size;++f)n.write_shift(1,l.content[f]);for(;f&511;++f)n.write_shift(1,0)}for(a=1;a<r.FileIndex.length;++a)if(l=r.FileIndex[a],l.size>0&&l.size<4096)if(O&&Buffer.isBuffer(l.content))l.content.copy(n,n.l,0,l.size),n.l+=l.size+63&-64;else{for(f=0;f<l.size;++f)n.write_shift(1,l.content[f]);for(;f&63;++f)n.write_shift(1,0)}if(O)n.l=n.length;else for(;n.l<n.length;)n.write_shift(1,0);return n}function I(r,i){var e=r.FullPaths.map(function(f){return f.toUpperCase()}),t=e.map(function(f){var h=f.split("/");return h[h.length-(f.slice(-1)=="/"?2:1)]}),n=!1;i.charCodeAt(0)===47?(n=!0,i=e[0].slice(0,-1)+i):n=i.indexOf("/")!==-1;var a=i.toUpperCase(),s=n===!0?e.indexOf(a):t.indexOf(a);if(s!==-1)return r.FileIndex[s];var u=!a.match(_r);for(a=a.replace(ar,""),u&&(a=a.replace(_r,"!")),s=0;s<e.length;++s)if((u?e[s].replace(_r,"!"):e[s]).replace(ar,"")==a||(u?t[s].replace(_r,"!"):t[s]).replace(ar,"")==a)return r.FileIndex[s];return null}var S=64,R=-2,zr="d0cf11e0a1b11ae1",he=[208,207,17,224,161,177,26,225],Sr="00000000000000000000000000000000",rr={MAXREGSECT:-6,DIFSECT:-4,FATSECT:-3,ENDOFCHAIN:R,FREESECT:-1,HEADER_SIGNATURE:zr,HEADER_MINOR_VERSION:"3e00",MAXREGSID:-6,NOSTREAM:-1,HEADER_CLSID:Sr,EntryTypes:["unknown","storage","stream","lockbytes","property","root"]};function le(r,i,e){U();var t=A(r,e);D.writeFileSync(i,t)}function er(r){for(var i=new Array(r.length),e=0;e<r.length;++e)i[e]=String.fromCharCode(r[e]);return i.join("")}function ue(r,i){var e=A(r,i);switch(i&&i.type||"buffer"){case"file":return U(),D.writeFileSync(i.filename,e),e;case"binary":return typeof e=="string"?e:er(e);case"base64":return Qr(typeof e=="string"?e:er(e));case"buffer":if(O)return Buffer.isBuffer(e)?e:Nr(e);case"array":return typeof e=="string"?W(e):e}return e}var tr;function oe(r){try{var i=r.InflateRaw,e=new i;if(e._processChunk(new Uint8Array([3,0]),e._finishFlushFlag),e.bytesRead)tr=r;else throw new Error("zlib does not expose bytesRead")}catch(t){console.error("cannot use native zlib: "+(t.message||t))}}function ce(r,i){if(!tr)return Wr(r,i);var e=tr.InflateRaw,t=new e,n=t._processChunk(r.slice(r.l),t._finishFlushFlag);return r.l+=t.bytesRead,n}function ve(r){return tr?tr.deflateRawSync(r):Jr(r)}var _e=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],hr=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258],lr=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577];function we(r){var i=(r<<1|r<<11)&139536|(r<<5|r<<15)&558144;return(i>>16|i>>8|i)&255}for(var B=typeof Uint8Array<"u",$=B?new Uint8Array(256):[],ur=0;ur<256;++ur)$[ur]=we(ur);function Fe(r,i){var e=$[r&255];return i<=8?e>>>8-i:(e=e<<8|$[r>>8&255],i<=16?e>>>16-i:(e=e<<8|$[r>>16&255],e>>>24-i))}function de(r,i){var e=i&7,t=i>>>3;return(r[t]|(e<=6?0:r[t+1]<<8))>>>e&3}function kr(r,i){var e=i&7,t=i>>>3;return(r[t]|(e<=5?0:r[t+1]<<8))>>>e&7}function xe(r,i){var e=i&7,t=i>>>3;return(r[t]|(e<=4?0:r[t+1]<<8))>>>e&15}function Hr(r,i){var e=i&7,t=i>>>3;return(r[t]|(e<=3?0:r[t+1]<<8))>>>e&31}function jr(r,i){var e=i&7,t=i>>>3;return(r[t]|(e<=1?0:r[t+1]<<8))>>>e&127}function or(r,i,e){var t=i&7,n=i>>>3,a=(1<<e)-1,s=r[n]>>>t;return e<8-t||(s|=r[n+1]<<8-t,e<16-t)||(s|=r[n+2]<<16-t,e<24-t)||(s|=r[n+3]<<24-t),s&a}function $r(r,i,e){var t=i&7,n=i>>>3;return t<=5?r[n]|=(e&7)<<t:(r[n]|=e<<t&255,r[n+1]=(e&7)>>8-t),i+3}function ge(r,i,e){var t=i&7,n=i>>>3;return e=(e&1)<<t,r[n]|=e,i+1}function q(r,i,e){var t=i&7,n=i>>>3;return e<<=t,r[n]|=e&255,e>>>=8,r[n+1]=e,i+8}function Gr(r,i,e){var t=i&7,n=i>>>3;return e<<=t,r[n]|=e&255,e>>>=8,r[n+1]=e&255,r[n+2]=e>>>8,i+16}function Rr(r,i){var e=r.length,t=2*e>i?2*e:i+5,n=0;if(e>=i)return r;if(O){var a=re(t);if(r.copy)r.copy(a);else for(;n<r.length;++n)a[n]=r[n];return a}else if(B){var s=new Uint8Array(t);if(s.set)s.set(r);else for(;n<e;++n)s[n]=r[n];return s}return r.length=t,r}function H(r){for(var i=new Array(r),e=0;e<r;++e)i[e]=0;return i}function cr(r,i,e){var t=1,n=0,a=0,s=0,u=0,f=r.length,h=B?new Uint16Array(32):H(32);for(a=0;a<32;++a)h[a]=0;for(a=f;a<e;++a)r[a]=0;f=r.length;var l=B?new Uint16Array(f):H(f);for(a=0;a<f;++a)h[n=r[a]]++,t<n&&(t=n),l[a]=0;for(h[0]=0,a=1;a<=t;++a)h[a+16]=u=u+h[a-1]<<1;for(a=0;a<f;++a)u=r[a],u!=0&&(l[a]=h[u+16]++);var v=0;for(a=0;a<f;++a)if(v=r[a],v!=0)for(u=Fe(l[a],t)>>t-v,s=(1<<t+4-v)-1;s>=0;--s)i[u|s<<v]=v&15|a<<4;return t}var Tr=B?new Uint16Array(512):H(512),Dr=B?new Uint16Array(32):H(32);if(!B){for(var Z=0;Z<512;++Z)Tr[Z]=0;for(Z=0;Z<32;++Z)Dr[Z]=0}(function(){for(var r=[],i=0;i<32;i++)r.push(5);cr(r,Dr,32);var e=[];for(i=0;i<=143;i++)e.push(8);for(;i<=255;i++)e.push(9);for(;i<=279;i++)e.push(7);for(;i<=287;i++)e.push(8);cr(e,Tr,288)})();var pe=(function(){for(var i=B?new Uint8Array(32768):[],e=0,t=0;e<lr.length-1;++e)for(;t<lr[e+1];++t)i[t]=e;for(;t<32768;++t)i[t]=29;var n=B?new Uint8Array(259):[];for(e=0,t=0;e<hr.length-1;++e)for(;t<hr[e+1];++t)n[t]=e;function a(u,f){for(var h=0;h<u.length;){var l=Math.min(65535,u.length-h),v=h+l==u.length;for(f.write_shift(1,+v),f.write_shift(2,l),f.write_shift(2,~l&65535);l-- >0;)f[f.l++]=u[h++]}return f.l}function s(u,f){for(var h=0,l=0,v=B?new Uint16Array(32768):[];l<u.length;){var _=Math.min(65535,u.length-l);if(_<10){for(h=$r(f,h,+(l+_==u.length)),h&7&&(h+=8-(h&7)),f.l=h/8|0,f.write_shift(2,_),f.write_shift(2,~_&65535);_-- >0;)f[f.l++]=u[l++];h=f.l*8;continue}h=$r(f,h,+(l+_==u.length)+2);for(var g=0;_-- >0;){var w=u[l];g=(g<<5^w)&32767;var F=-1,m=0;if((F=v[g])&&(F|=l&-32768,F>l&&(F-=32768),F<l))for(;u[F+m]==u[l+m]&&m<250;)++m;if(m>2){w=n[m],w<=22?h=q(f,h,$[w+1]>>1)-1:(q(f,h,3),h+=5,q(f,h,$[w-23]>>5),h+=3);var E=w<8?0:w-4>>2;E>0&&(Gr(f,h,m-hr[w]),h+=E),w=i[l-F],h=q(f,h,$[w]>>3),h-=3;var T=w<4?0:w-2>>1;T>0&&(Gr(f,h,l-F-lr[w]),h+=T);for(var k=0;k<m;++k)v[g]=l&32767,g=(g<<5^u[l])&32767,++l;_-=m-1}else w<=143?w=w+48:h=ge(f,h,1),h=q(f,h,$[w]),v[g]=l&32767,++l}h=q(f,h,0)-1}return f.l=(h+7)/8|0,f.l}return function(f,h){return f.length<8?a(f,h):s(f,h)}})();function Jr(r){var i=j(50+Math.floor(r.length*1.1)),e=pe(r,i);return i.slice(0,e)}var Vr=B?new Uint16Array(32768):H(32768),Xr=B?new Uint16Array(32768):H(32768),Zr=B?new Uint16Array(128):H(128),Yr=1,qr=1;function ye(r,i){var e=Hr(r,i)+257;i+=5;var t=Hr(r,i)+1;i+=5;var n=xe(r,i)+4;i+=4;for(var a=0,s=B?new Uint8Array(19):H(19),u=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],f=1,h=B?new Uint8Array(8):H(8),l=B?new Uint8Array(8):H(8),v=s.length,_=0;_<n;++_)s[_e[_]]=a=kr(r,i),f<a&&(f=a),h[a]++,i+=3;var g=0;for(h[0]=0,_=1;_<=f;++_)l[_]=g=g+h[_-1]<<1;for(_=0;_<v;++_)(g=s[_])!=0&&(u[_]=l[g]++);var w=0;for(_=0;_<v;++_)if(w=s[_],w!=0){g=$[u[_]]>>8-w;for(var F=(1<<7-w)-1;F>=0;--F)Zr[g|F<<w]=w&7|_<<3}var m=[];for(f=1;m.length<e+t;)switch(g=Zr[jr(r,i)],i+=g&7,g>>>=3){case 16:for(a=3+de(r,i),i+=2,g=m[m.length-1];a-- >0;)m.push(g);break;case 17:for(a=3+kr(r,i),i+=3;a-- >0;)m.push(0);break;case 18:for(a=11+jr(r,i),i+=7;a-- >0;)m.push(0);break;default:m.push(g),f<g&&(f=g);break}var E=m.slice(0,e),T=m.slice(e);for(_=e;_<286;++_)E[_]=0;for(_=t;_<30;++_)T[_]=0;return Yr=cr(E,Vr,286),qr=cr(T,Xr,30),i}function me(r,i){if(r[0]==3&&!(r[1]&3))return[ie(i),2];for(var e=0,t=0,n=re(i||1<<18),a=0,s=n.length>>>0,u=0,f=0;(t&1)==0;){if(t=kr(r,e),e+=3,t>>>1)t>>1==1?(u=9,f=5):(e=ye(r,e),u=Yr,f=qr);else{e&7&&(e+=8-(e&7));var h=r[e>>>3]|r[(e>>>3)+1]<<8;if(e+=32,h>0)for(!i&&s<a+h&&(n=Rr(n,a+h),s=n.length);h-- >0;)n[a++]=r[e>>>3],e+=8;continue}for(;;){!i&&s<a+32767&&(n=Rr(n,a+32767),s=n.length);var l=or(r,e,u),v=t>>>1==1?Tr[l]:Vr[l];if(e+=v&15,v>>>=4,(v>>>8&255)===0)n[a++]=v;else{if(v==256)break;v-=257;var _=v<8?0:v-4>>2;_>5&&(_=0);var g=a+hr[v];_>0&&(g+=or(r,e,_),e+=_),l=or(r,e,f),v=t>>>1==1?Dr[l]:Xr[l],e+=v&15,v>>>=4;var w=v<4?0:v-2>>1,F=lr[v];for(w>0&&(F+=or(r,e,w),e+=w),!i&&s<g&&(n=Rr(n,g+100),s=n.length);a<g;)n[a]=n[a-F],++a}}}return i?[n,e+7>>>3]:[n.slice(0,a),e+7>>>3]}function Wr(r,i){var e=r.slice(r.l||0),t=me(e,i);return r.l+=t[1],t[0]}function Ur(r,i){if(r)typeof console<"u"&&console.error(i);else throw new Error(i)}function Kr(r,i){var e=r;J(e,0);var t=[],n=[],a={FileIndex:t,FullPaths:n};x(a,{root:i.root});for(var s=e.length-4;(e[s]!=80||e[s+1]!=75||e[s+2]!=5||e[s+3]!=6)&&s>=0;)--s;e.l=s+4,e.l+=4;var u=e.read_shift(2);e.l+=6;var f=e.read_shift(4);for(e.l=f,s=0;s<u;++s){e.l+=20;var h=e.read_shift(4),l=e.read_shift(4),v=e.read_shift(2),_=e.read_shift(2),g=e.read_shift(2);e.l+=8;var w=e.read_shift(4),F=L(e.slice(e.l+v,e.l+v+_));e.l+=v+_+g;var m=e.l;e.l=w+4,Ce(e,h,l,a,F),e.l=m}return a}function Ce(r,i,e,t,n){r.l+=2;var a=r.read_shift(2),s=r.read_shift(2),u=M(r);if(a&8257)throw new Error("Unsupported ZIP encryption");for(var f=r.read_shift(4),h=r.read_shift(4),l=r.read_shift(4),v=r.read_shift(2),_=r.read_shift(2),g="",w=0;w<v;++w)g+=String.fromCharCode(r[r.l++]);if(_){var F=L(r.slice(r.l,r.l+_));(F[21589]||{}).mt&&(u=F[21589].mt),((n||{})[21589]||{}).mt&&(u=n[21589].mt)}r.l+=_;var m=r.slice(r.l,r.l+h);switch(s){case 8:m=ce(r,l);break;case 0:break;default:throw new Error("Unsupported ZIP Compression method "+s)}var E=!1;a&8&&(f=r.read_shift(4),f==134695760&&(f=r.read_shift(4),E=!0),h=r.read_shift(4),l=r.read_shift(4)),h!=i&&Ur(E,"Bad compressed size: "+i+" != "+h),l!=e&&Ur(E,"Bad uncompressed size: "+e+" != "+l);var T=te.buf(m,0);f>>0!=T>>0&&Ur(E,"Bad CRC32 checksum: "+f+" != "+T),Pr(t,g,m,{unsafe:!0,mt:u})}function Ae(r,i){var e=i||{},t=[],n=[],a=j(1),s=e.compression?8:0,u=0,f=!1;f&&(u|=8);var h=0,l=0,v=0,_=0,g=r.FullPaths[0],w=g,F=r.FileIndex[0],m=[],E=0;for(h=1;h<r.FullPaths.length;++h)if(w=r.FullPaths[h].slice(g.length),F=r.FileIndex[h],!(!F.size||!F.content||w=="Sh33tJ5")){var T=v,k=j(w.length);for(l=0;l<w.length;++l)k.write_shift(1,w.charCodeAt(l)&127);k=k.slice(0,k.l),m[_]=te.buf(F.content,0);var N=F.content;s==8&&(N=ve(N)),a=j(30),a.write_shift(4,67324752),a.write_shift(2,20),a.write_shift(2,u),a.write_shift(2,s),F.mt?z(a,F.mt):a.write_shift(4,0),a.write_shift(-4,u&8?0:m[_]),a.write_shift(4,u&8?0:N.length),a.write_shift(4,u&8?0:F.content.length),a.write_shift(2,k.length),a.write_shift(2,0),v+=a.length,t.push(a),v+=k.length,t.push(k),v+=N.length,t.push(N),u&8&&(a=j(12),a.write_shift(-4,m[_]),a.write_shift(4,N.length),a.write_shift(4,F.content.length),v+=a.l,t.push(a)),a=j(46),a.write_shift(4,33639248),a.write_shift(2,0),a.write_shift(2,20),a.write_shift(2,u),a.write_shift(2,s),a.write_shift(4,0),a.write_shift(-4,m[_]),a.write_shift(4,N.length),a.write_shift(4,F.content.length),a.write_shift(2,k.length),a.write_shift(2,0),a.write_shift(2,0),a.write_shift(2,0),a.write_shift(2,0),a.write_shift(4,0),a.write_shift(4,T),E+=a.l,n.push(a),E+=k.length,n.push(k),++_}return a=j(22),a.write_shift(4,101010256),a.write_shift(2,0),a.write_shift(2,0),a.write_shift(2,_),a.write_shift(2,_),a.write_shift(4,E),a.write_shift(4,v),a.write_shift(2,0),K([K(t),K(n),a])}var vr={htm:"text/html",xml:"text/xml",gif:"image/gif",jpg:"image/jpeg",png:"image/png",mso:"application/x-mso",thmx:"application/vnd.ms-officetheme",sh33tj5:"application/octet-stream"};function Ie(r,i){if(r.ctype)return r.ctype;var e=r.name||"",t=e.match(/\.([^\.]+)$/);return t&&vr[t[1]]||i&&(t=(e=i).match(/[\.\\]([^\.\\])+$/),t&&vr[t[1]])?vr[t[1]]:"application/octet-stream"}function Ee(r){for(var i=Qr(r),e=[],t=0;t<i.length;t+=76)e.push(i.slice(t,t+76));return e.join(`\r
|
|
4
|
+
`)+`\r
|
|
5
|
+
`}function Se(r){var i=r.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7E-\xFF=]/g,function(h){var l=h.charCodeAt(0).toString(16).toUpperCase();return"="+(l.length==1?"0"+l:l)});i=i.replace(/ $/mg,"=20").replace(/\t$/mg,"=09"),i.charAt(0)==`
|
|
6
|
+
`&&(i="=0D"+i.slice(1)),i=i.replace(/\r(?!\n)/mg,"=0D").replace(/\n\n/mg,`
|
|
7
|
+
=0A`).replace(/([^\r\n])\n/mg,"$1=0A");for(var e=[],t=i.split(`\r
|
|
8
|
+
`),n=0;n<t.length;++n){var a=t[n];if(a.length==0){e.push("");continue}for(var s=0;s<a.length;){var u=76,f=a.slice(s,s+u);f.charAt(u-1)=="="?u--:f.charAt(u-2)=="="?u-=2:f.charAt(u-3)=="="&&(u-=3),f=a.slice(s,s+u),s+=u,s<a.length&&(f+="="),e.push(f)}}return e.join(`\r
|
|
9
|
+
`)}function ke(r){for(var i=[],e=0;e<r.length;++e){for(var t=r[e];e<=r.length&&t.charAt(t.length-1)=="=";)t=t.slice(0,t.length-1)+r[++e];i.push(t)}for(var n=0;n<i.length;++n)i[n]=i[n].replace(/[=][0-9A-Fa-f]{2}/g,function(a){return String.fromCharCode(parseInt(a.slice(1),16))});return W(i.join(`\r
|
|
10
|
+
`))}function Re(r,i,e){for(var t="",n="",a="",s,u=0;u<10;++u){var f=i[u];if(!f||f.match(/^\s*$/))break;var h=f.match(/^(.*?):\s*([^\s].*)$/);if(h)switch(h[1].toLowerCase()){case"content-location":t=h[2].trim();break;case"content-type":a=h[2].trim();break;case"content-transfer-encoding":n=h[2].trim();break}}switch(++u,n.toLowerCase()){case"base64":s=W(br(i.slice(u).join("")));break;case"quoted-printable":s=ke(i.slice(u));break;default:throw new Error("Unsupported Content-Transfer-Encoding "+n)}var l=Pr(r,t.slice(e.length),s,{unsafe:!0});a&&(l.ctype=a)}function Te(r,i){if(er(r.slice(0,13)).toLowerCase()!="mime-version:")throw new Error("Unsupported MAD header");var e=i&&i.root||"",t=(O&&Buffer.isBuffer(r)?r.toString("binary"):er(r)).split(`\r
|
|
11
|
+
`),n=0,a="";for(n=0;n<t.length;++n)if(a=t[n],!!/^Content-Location:/i.test(a)&&(a=a.slice(a.indexOf("file")),e||(e=a.slice(0,a.lastIndexOf("/")+1)),a.slice(0,e.length)!=e))for(;e.length>0&&(e=e.slice(0,e.length-1),e=e.slice(0,e.lastIndexOf("/")+1),a.slice(0,e.length)!=e););var s=(t[1]||"").match(/boundary="(.*?)"/);if(!s)throw new Error("MAD cannot find boundary");var u="--"+(s[1]||""),f=[],h=[],l={FileIndex:f,FullPaths:h};x(l);var v,_=0;for(n=0;n<t.length;++n){var g=t[n];g!==u&&g!==u+"--"||(_++&&Re(l,t.slice(v,n),e),v=n)}return l}function De(r,i){var e=i||{},t=e.boundary||"SheetJS";t="------="+t;for(var n=["MIME-Version: 1.0",'Content-Type: multipart/related; boundary="'+t.slice(2)+'"',"","",""],a=r.FullPaths[0],s=a,u=r.FileIndex[0],f=1;f<r.FullPaths.length;++f)if(s=r.FullPaths[f].slice(a.length),u=r.FileIndex[f],!(!u.size||!u.content||s=="Sh33tJ5")){s=s.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7E-\xFF]/g,function(m){return"_x"+m.charCodeAt(0).toString(16)+"_"}).replace(/[\u0080-\uFFFF]/g,function(m){return"_u"+m.charCodeAt(0).toString(16)+"_"});for(var h=u.content,l=O&&Buffer.isBuffer(h)?h.toString("binary"):er(h),v=0,_=Math.min(1024,l.length),g=0,w=0;w<=_;++w)(g=l.charCodeAt(w))>=32&&g<128&&++v;var F=v>=_*4/5;n.push(t),n.push("Content-Location: "+(e.root||"file:///C:/SheetJS/")+s),n.push("Content-Transfer-Encoding: "+(F?"quoted-printable":"base64")),n.push("Content-Type: "+Ie(u,s)),n.push(""),n.push(F?Se(l):Ee(l))}return n.push(t+`--\r
|
|
12
|
+
`),n.join(`\r
|
|
13
|
+
`)}function Ue(r){var i={};return x(i,r),i}function Pr(r,i,e,t){var n=t&&t.unsafe;n||x(r);var a=!n&&b.find(r,i);if(!a){var s=r.FullPaths[0];i.slice(0,s.length)==s?s=i:(s.slice(-1)!="/"&&(s+="/"),s=(s+i).replace("//","/")),a={name:y(i),type:2},r.FileIndex.push(a),r.FullPaths.push(s),n||b.utils.cfb_gc(r)}return a.content=e,a.size=e?e.length:0,t&&(t.CLSID&&(a.clsid=t.CLSID),t.mt&&(a.mt=t.mt),t.ct&&(a.ct=t.ct)),a}function Pe(r,i){x(r);var e=b.find(r,i);if(e){for(var t=0;t<r.FileIndex.length;++t)if(r.FileIndex[t]==e)return r.FileIndex.splice(t,1),r.FullPaths.splice(t,1),!0}return!1}function Be(r,i,e){x(r);var t=b.find(r,i);if(t){for(var n=0;n<r.FileIndex.length;++n)if(r.FileIndex[n]==t)return r.FileIndex[n].name=y(e),r.FullPaths[n]=e,!0}return!1}function Me(r){p(r,!0)}return c.find=I,c.read=Er,c.parse=X,c.write=ue,c.writeFile=le,c.utils={cfb_new:Ue,cfb_add:Pr,cfb_del:Pe,cfb_mov:Be,cfb_gc:Me,ReadShift:fe,CheckField:se,prep_blob:J,bconcat:K,use_zlib:oe,_deflateRaw:Jr,_inflateRaw:Wr,consts:rr},c})();typeof Mr<"u"&&typeof Lr<"u"&&typeof DO_NOT_EXPORT_CFB>"u"&&(Lr.exports=b)});export default Ve();
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
var u=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function a(t,f){if(t.isTTY!==!0)return{update:()=>{},tick:()=>{},stop:()=>{}};let r=0,n="",e=!1,i=60,o=()=>{e||t.write(`\r${" ".repeat(i)}\r${u[r%u.length]} ${f}${n}`)};return{update(s){n=s===""?"":` \xB7 ${s}`,r++,o()},tick(){r++,o()},stop(){e||(e=!0,t.write(`\r${" ".repeat(i)}\r`))}}}var R=new Set(["iTerm.app","WezTerm","ghostty","vscode"]),O=new Set(["xterm-kitty","xterm-ghostty"]);function E(t=process.env){return t.FORGE_POWERLINE==="1"?!0:t.FORGE_POWERLINE==="0"||t.NO_COLOR!==void 0&&t.NO_COLOR!==""?!1:R.has(t.TERM_PROGRAM??"")||O.has(t.TERM??"")}function c(t=process.env){return t.FORGE_TRUECOLOR==="1"?!0:t.FORGE_TRUECOLOR==="0"||t.NO_COLOR!==void 0&&t.NO_COLOR!==""?!1:t.COLORTERM==="truecolor"||t.COLORTERM==="24bit"?!0:R.has(t.TERM_PROGRAM??"")||O.has(t.TERM??"")}export{u as a,a as b,E as c,c as d};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{g as Se,h as vt,i as it,k as Ae,l as It,m as wt,n as Mt}from"./chunk-L2WK7CJG.js";import{c as ye}from"./chunk-EOYBXOCV.js";import{A as ge,E as be,F as st,R as gt,a as B,b as ce,c as mt,d as nt,e as Nt,p as le,s as pe,t as fe,x as de,y as he,z as me}from"./chunk-DRBA23IQ.js";import{c as ot,e as Mn}from"./chunk-TMUK2DD3.js";var yt=ot((du,un)=>{"use strict";var nn="[^\\\\/]",go="(?=.)",rn="[^/]",zt="(?:\\/|$)",on="(?:^|\\/)",Qt=`\\.{1,2}${zt}`,bo="(?!\\.)",yo=`(?!${on}${Qt})`,So=`(?!\\.{0,1}${zt})`,Ao=`(?!${Qt})`,xo="[^.\\/]",Ro=`${rn}*?`,Eo="/",sn={DOT_LITERAL:"\\.",PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:"\\/",ONE_CHAR:go,QMARK:rn,END_ANCHOR:zt,DOTS_SLASH:Qt,NO_DOT:bo,NO_DOTS:yo,NO_DOT_SLASH:So,NO_DOTS_SLASH:Ao,QMARK_NO_DOT:xo,STAR:Ro,START_ANCHOR:on,SEP:Eo},_o={...sn,SLASH_LITERAL:"[\\\\/]",QMARK:nn,STAR:`${nn}*?`,DOTS_SLASH:"\\.{1,2}(?:[\\\\/]|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:[\\\\/]|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:[\\\\/]|$))",QMARK_NO_DOT:"[^.\\\\/]",START_ANCHOR:"(?:^|[\\\\/])",END_ANCHOR:"(?:[\\\\/]|$)",SEP:"\\"},vo={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};un.exports={DEFAULT_MAX_EXTGLOB_RECURSION:0,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:vo,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars(t){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${t.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(t){return t===!0?_o:sn}}});var St=ot(U=>{"use strict";var{REGEX_BACKSLASH:Io,REGEX_REMOVE_BACKSLASH:wo,REGEX_SPECIAL_CHARS:ko,REGEX_SPECIAL_CHARS_GLOBAL:Oo}=yt();U.isObject=t=>t!==null&&typeof t=="object"&&!Array.isArray(t);U.hasRegexChars=t=>ko.test(t);U.isRegexChar=t=>t.length===1&&U.hasRegexChars(t);U.escapeRegex=t=>t.replace(Oo,"\\$1");U.toPosixSlashes=t=>t.replace(Io,"/");U.isWindows=()=>{if(typeof navigator<"u"&&navigator.platform){let t=navigator.platform.toLowerCase();return t==="win32"||t==="windows"}return typeof process<"u"&&process.platform?process.platform==="win32":!1};U.removeBackslashes=t=>t.replace(wo,e=>e==="\\"?"":e);U.escapeLast=(t,e,n)=>{let r=t.lastIndexOf(e,n);return r===-1?t:t[r-1]==="\\"?U.escapeLast(t,e,r-1):`${t.slice(0,r)}\\${t.slice(r)}`};U.removePrefix=(t,e={})=>{let n=t;return n.startsWith("./")&&(n=n.slice(2),e.prefix="./"),n};U.wrapOutput=(t,e={},n={})=>{let r=n.contains?"":"^",o=n.contains?"":"$",s=`${r}(?:${t})${o}`;return e.negated===!0&&(s=`(?:^(?!${s}).*$)`),s};U.basename=(t,{windows:e}={})=>{let n=t.split(e?/[\\/]/:"/"),r=n[n.length-1];return r===""?n[n.length-2]:r}});var mn=ot((mu,hn)=>{"use strict";var an=St(),{CHAR_ASTERISK:Yt,CHAR_AT:Co,CHAR_BACKWARD_SLASH:At,CHAR_COMMA:$o,CHAR_DOT:Zt,CHAR_EXCLAMATION_MARK:Vt,CHAR_FORWARD_SLASH:dn,CHAR_LEFT_CURLY_BRACE:te,CHAR_LEFT_PARENTHESES:ee,CHAR_LEFT_SQUARE_BRACKET:To,CHAR_PLUS:Po,CHAR_QUESTION_MARK:cn,CHAR_RIGHT_CURLY_BRACE:Lo,CHAR_RIGHT_PARENTHESES:ln,CHAR_RIGHT_SQUARE_BRACKET:Fo}=yt(),pn=t=>t===dn||t===At,fn=t=>{t.isPrefix!==!0&&(t.depth=t.isGlobstar?1/0:1)},Do=(t,e)=>{let n=e||{},r=t.length-1,o=n.parts===!0||n.scanToEnd===!0,s=[],i=[],u=[],p=t,m=-1,g=0,b=0,f=!1,y=!1,S=!1,x=!1,R=!1,T=!1,A=!1,G=!1,Q=!1,F=!1,C=0,k,E,I={value:"",depth:0,isGlob:!1},l=()=>m>=r,W=()=>p.charCodeAt(m+1),N=()=>(k=E,p.charCodeAt(++m));for(;m<r;){E=N();let w;if(E===At){A=I.backslashes=!0,E=N(),E===te&&(T=!0);continue}if(T===!0||E===te){for(C++;l()!==!0&&(E=N());){if(E===At){A=I.backslashes=!0,N();continue}if(E===te){C++;continue}if(T!==!0&&E===Zt&&(E=N())===Zt){if(f=I.isBrace=!0,S=I.isGlob=!0,F=!0,o===!0)continue;break}if(T!==!0&&E===$o){if(f=I.isBrace=!0,S=I.isGlob=!0,F=!0,o===!0)continue;break}if(E===Lo&&(C--,C===0)){T=!1,f=I.isBrace=!0,F=!0;break}}if(o===!0)continue;break}if(E===dn){if(s.push(m),i.push(I),I={value:"",depth:0,isGlob:!1},F===!0)continue;if(k===Zt&&m===g+1){g+=2;continue}b=m+1;continue}if(n.noext!==!0&&(E===Po||E===Co||E===Yt||E===cn||E===Vt)===!0&&W()===ee){if(S=I.isGlob=!0,x=I.isExtglob=!0,F=!0,E===Vt&&m===g&&(Q=!0),o===!0){for(;l()!==!0&&(E=N());){if(E===At){A=I.backslashes=!0,E=N();continue}if(E===ln){S=I.isGlob=!0,F=!0;break}}continue}break}if(E===Yt){if(k===Yt&&(R=I.isGlobstar=!0),S=I.isGlob=!0,F=!0,o===!0)continue;break}if(E===cn){if(S=I.isGlob=!0,F=!0,o===!0)continue;break}if(E===To){for(;l()!==!0&&(w=N());){if(w===At){A=I.backslashes=!0,N();continue}if(w===Fo){y=I.isBracket=!0,S=I.isGlob=!0,F=!0;break}}if(o===!0)continue;break}if(n.nonegate!==!0&&E===Vt&&m===g){G=I.negated=!0,g++;continue}if(n.noparen!==!0&&E===ee){if(S=I.isGlob=!0,o===!0){for(;l()!==!0&&(E=N());){if(E===ee){A=I.backslashes=!0,E=N();continue}if(E===ln){F=!0;break}}continue}break}if(S===!0){if(F=!0,o===!0)continue;break}}n.noext===!0&&(x=!1,S=!1);let D=p,c="",a="";g>0&&(c=p.slice(0,g),p=p.slice(g),b-=g),D&&S===!0&&b>0?(D=p.slice(0,b),a=p.slice(b)):S===!0?(D="",a=p):D=p,D&&D!==""&&D!=="/"&&D!==p&&pn(D.charCodeAt(D.length-1))&&(D=D.slice(0,-1)),n.unescape===!0&&(a&&(a=an.removeBackslashes(a)),D&&A===!0&&(D=an.removeBackslashes(D)));let X={prefix:c,input:t,start:g,base:D,glob:a,isBrace:f,isBracket:y,isGlob:S,isExtglob:x,isGlobstar:R,negated:G,negatedExtglob:Q};if(n.tokens===!0&&(X.maxDepth=0,pn(E)||i.push(I),X.tokens=i),n.parts===!0||n.tokens===!0){let w;for(let L=0;L<s.length;L++){let V=w?w+1:g,K=s[L],tt=t.slice(V,K);n.tokens&&(L===0&&g!==0?(i[L].isPrefix=!0,i[L].value=c):i[L].value=tt,fn(i[L]),X.maxDepth+=i[L].depth),(L!==0||tt!=="")&&u.push(tt),w=K}if(w&&w+1<t.length){let L=t.slice(w+1);u.push(L),n.tokens&&(i[i.length-1].value=L,fn(i[i.length-1]),X.maxDepth+=i[i.length-1].depth)}X.slashes=s,X.parts=u}return X};hn.exports=Do});var Sn=ot((gu,yn)=>{"use strict";var xt=yt(),J=St(),{MAX_LENGTH:Ht,POSIX_REGEX_SOURCE:Ho,REGEX_NON_SPECIAL_CHARS:No,REGEX_SPECIAL_CHARS_BACKREF:Mo,REPLACEMENTS:gn}=xt,Bo=(t,e)=>{if(typeof e.expandRange=="function")return e.expandRange(...t,e);t.sort();let n=`[${t.join("-")}]`;try{new RegExp(n)}catch{return t.map(o=>J.escapeRegex(o)).join("..")}return n},dt=(t,e)=>`Missing ${t}: "${e}" - use "\\\\${e}" to match literal characters`,bn=t=>{let e=[],n=0,r=0,o=0,s="",i=!1;for(let u of t){if(i===!0){s+=u,i=!1;continue}if(u==="\\"){s+=u,i=!0;continue}if(u==='"'){o=o===1?0:1,s+=u;continue}if(o===0){if(u==="[")n++;else if(u==="]"&&n>0)n--;else if(n===0){if(u==="(")r++;else if(u===")"&&r>0)r--;else if(u==="|"&&r===0){e.push(s),s="";continue}}}s+=u}return e.push(s),e},qo=t=>{let e=!1;for(let n of t){if(e===!0){e=!1;continue}if(n==="\\"){e=!0;continue}if(/[?*+@!()[\]{}]/.test(n))return!1}return!0},re=t=>{let e=t.trim(),n=!0;for(;n===!0;)n=!1,/^@\([^\\()[\]{}|]+\)$/.test(e)&&(e=e.slice(2,-1),n=!0);if(qo(e))return e.replace(/\\(.)/g,"$1")},Go=t=>{let e=t.map(re).filter(Boolean);for(let n=0;n<e.length;n++)for(let r=n+1;r<e.length;r++){let o=e[n],s=e[r],i=o[0];if(!(!i||o!==i.repeat(o.length)||s!==i.repeat(s.length))&&(o===s||o.startsWith(s)||s.startsWith(o)))return!0}return!1},ne=(t,e=!0)=>{if(t[0]!=="+"&&t[0]!=="*"||t[1]!=="(")return;let n=0,r=0,o=0,s=!1;for(let i=1;i<t.length;i++){let u=t[i];if(s===!0){s=!1;continue}if(u==="\\"){s=!0;continue}if(u==='"'){o=o===1?0:1;continue}if(o!==1){if(u==="["){n++;continue}if(u==="]"&&n>0){n--;continue}if(!(n>0)){if(u==="("){r++;continue}if(u===")"&&(r--,r===0))return e===!0&&i!==t.length-1?void 0:{type:t[0],body:t.slice(2,i),end:i}}}}},Wo=t=>`${t.length===1?J.escapeRegex(t[0]):`[${t.map(n=>J.escapeRegex(n)).join("")}]`}*`,jo=t=>{let e=0,n=[];for(;e<t.length;){let r=ne(t.slice(e),!1);if(!r||r.type!=="*")return;let o=bn(r.body).map(i=>i.trim());if(o.length!==1)return;let s=re(o[0]);if(!s||s.length!==1)return;n.push(s),e+=r.end+1}if(!(n.length<1))return n},Uo=t=>{let e=0,n=t.trim(),r=ne(n);for(;r;)e++,n=r.body.trim(),r=ne(n);return e},Jo=(t,e)=>{if(e.maxExtglobRecursion===!1)return{risky:!1};let n=typeof e.maxExtglobRecursion=="number"?e.maxExtglobRecursion:xt.DEFAULT_MAX_EXTGLOB_RECURSION,r=bn(t).map(u=>u.trim());if(r.length>1&&(r.some(u=>u==="")||r.some(u=>/^[*?]+$/.test(u))||Go(r)))return{risky:!0};let o=[],s=!1,i=!0;for(let u of r){let p=jo(u);if(p){s=!0,o.push(...p);continue}let m=re(u);if(m&&m.length===1){o.push(m);continue}if(i=!1,Uo(u)>n)return{risky:!0}}return s?i?{risky:!0,safeOutput:Wo([...new Set(o)])}:{risky:!0}:{risky:!1}},oe=(t,e)=>{if(typeof t!="string")throw new TypeError("Expected a string");t=gn[t]||t;let n={...e},r=typeof n.maxLength=="number"?Math.min(Ht,n.maxLength):Ht,o=t.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);let s={type:"bos",value:"",output:n.prepend||""},i=[s],u=n.capture?"":"?:",p=xt.globChars(n.windows),m=xt.extglobChars(p),{DOT_LITERAL:g,PLUS_LITERAL:b,SLASH_LITERAL:f,ONE_CHAR:y,DOTS_SLASH:S,NO_DOT:x,NO_DOT_SLASH:R,NO_DOTS_SLASH:T,QMARK:A,QMARK_NO_DOT:G,STAR:Q,START_ANCHOR:F}=p,C=h=>`(${u}(?:(?!${F}${h.dot?S:g}).)*?)`,k=n.dot?"":x,E=n.dot?A:G,I=n.bash===!0?C(n):Q;n.capture&&(I=`(${I})`),typeof n.noext=="boolean"&&(n.noextglob=n.noext);let l={input:t,index:-1,start:0,dot:n.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:i};t=J.removePrefix(t,l),o=t.length;let W=[],N=[],D=[],c=s,a,X=()=>l.index===o-1,w=l.peek=(h=1)=>t[l.index+h],L=l.advance=()=>t[++l.index]||"",V=()=>t.slice(l.index+1),K=(h="",P=0)=>{l.consumed+=h,l.index+=P},tt=h=>{l.output+=h.output!=null?h.output:h.value,K(h.value)},Hn=()=>{let h=1;for(;w()==="!"&&(w(2)!=="("||w(3)==="?");)L(),l.start++,h++;return h%2===0?!1:(l.negated=!0,l.start++,!0)},Et=h=>{l[h]++,D.push(h)},et=h=>{l[h]--,D.pop()},_=h=>{if(c.type==="globstar"){let P=l.braces>0&&(h.type==="comma"||h.type==="brace"),d=h.extglob===!0||W.length&&(h.type==="pipe"||h.type==="paren");h.type!=="slash"&&h.type!=="paren"&&!P&&!d&&(l.output=l.output.slice(0,-c.output.length),c.type="star",c.value="*",c.output=I,l.output+=c.output)}if(W.length&&h.type!=="paren"&&(W[W.length-1].inner+=h.value),(h.value||h.output)&&tt(h),c&&c.type==="text"&&h.type==="text"){c.output=(c.output||c.value)+h.value,c.value+=h.value;return}h.prev=c,i.push(h),c=h},_t=(h,P)=>{let d={...m[P],conditions:1,inner:""};d.prev=c,d.parens=l.parens,d.output=l.output,d.startIndex=l.index,d.tokensIndex=i.length;let v=(n.capture?"(":"")+d.open;Et("parens"),_({type:h,value:P,output:l.output?"":y}),_({type:"paren",extglob:!0,value:L(),output:v}),W.push(d)},Nn=h=>{let P=t.slice(h.startIndex,l.index+1),d=t.slice(h.startIndex+2,l.index),v=Jo(d,n);if((h.type==="plus"||h.type==="star")&&v.risky){let O=v.safeOutput?(h.output?"":y)+(n.capture?`(${v.safeOutput})`:v.safeOutput):void 0,Y=i[h.tokensIndex];Y.type="text",Y.value=P,Y.output=O||J.escapeRegex(P);for(let Z=h.tokensIndex+1;Z<i.length;Z++)i[Z].value="",i[Z].output="",delete i[Z].suffix;l.output=h.output+Y.output,l.backtrack=!0,_({type:"paren",extglob:!0,value:a,output:""}),et("parens");return}let $=h.close+(n.capture?")":""),M;if(h.type==="negate"){let O=I;if(h.inner&&h.inner.length>1&&h.inner.includes("/")&&(O=C(n)),(O!==I||X()||/^\)+$/.test(V()))&&($=h.close=`)$))${O}`),h.inner.includes("*")&&(M=V())&&/^\.[^\\/.]+$/.test(M)){let Y=oe(M,{...e,fastpaths:!1}).output;$=h.close=`)${Y})${O})`}h.prev.type==="bos"&&(l.negatedExtglob=!0)}_({type:"paren",extglob:!0,value:a,output:$}),et("parens")};if(n.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(t)){let h=!1,P=t.replace(Mo,(d,v,$,M,O,Y)=>M==="\\"?(h=!0,d):M==="?"?v?v+M+(O?A.repeat(O.length):""):Y===0?E+(O?A.repeat(O.length):""):A.repeat($.length):M==="."?g.repeat($.length):M==="*"?v?v+M+(O?I:""):I:v?d:`\\${d}`);return h===!0&&(n.unescape===!0?P=P.replace(/\\/g,""):P=P.replace(/\\+/g,d=>d.length%2===0?"\\\\":d?"\\":"")),P===t&&n.contains===!0?(l.output=t,l):(l.output=J.wrapOutput(P,l,e),l)}for(;!X();){if(a=L(),a==="\0")continue;if(a==="\\"){let d=w();if(d==="/"&&n.bash!==!0||d==="."||d===";")continue;if(!d){a+="\\",_({type:"text",value:a});continue}let v=/^\\+/.exec(V()),$=0;if(v&&v[0].length>2&&($=v[0].length,l.index+=$,$%2!==0&&(a+="\\")),n.unescape===!0?a=L():a+=L(),l.brackets===0){_({type:"text",value:a});continue}}if(l.brackets>0&&(a!=="]"||c.value==="["||c.value==="[^")){if(n.posix!==!1&&a===":"){let d=c.value.slice(1);if(d.includes("[")&&(c.posix=!0,d.includes(":"))){let v=c.value.lastIndexOf("["),$=c.value.slice(0,v),M=c.value.slice(v+2),O=Ho[M];if(O){c.value=$+O,l.backtrack=!0,L(),!s.output&&i.indexOf(c)===1&&(s.output=y);continue}}}(a==="["&&w()!==":"||a==="-"&&w()==="]")&&(a=`\\${a}`),a==="]"&&(c.value==="["||c.value==="[^")&&(a=`\\${a}`),n.posix===!0&&a==="!"&&c.value==="["&&(a="^"),c.value+=a,tt({value:a});continue}if(l.quotes===1&&a!=='"'){a=J.escapeRegex(a),c.value+=a,tt({value:a});continue}if(a==='"'){l.quotes=l.quotes===1?0:1,n.keepQuotes===!0&&_({type:"text",value:a});continue}if(a==="("){Et("parens"),_({type:"paren",value:a});continue}if(a===")"){if(l.parens===0&&n.strictBrackets===!0)throw new SyntaxError(dt("opening","("));let d=W[W.length-1];if(d&&l.parens===d.parens+1){Nn(W.pop());continue}_({type:"paren",value:a,output:l.parens?")":"\\)"}),et("parens");continue}if(a==="["){if(n.nobracket===!0||!V().includes("]")){if(n.nobracket!==!0&&n.strictBrackets===!0)throw new SyntaxError(dt("closing","]"));a=`\\${a}`}else Et("brackets");_({type:"bracket",value:a});continue}if(a==="]"){if(n.nobracket===!0||c&&c.type==="bracket"&&c.value.length===1){_({type:"text",value:a,output:`\\${a}`});continue}if(l.brackets===0){if(n.strictBrackets===!0)throw new SyntaxError(dt("opening","["));_({type:"text",value:a,output:`\\${a}`});continue}et("brackets");let d=c.value.slice(1);if(c.posix!==!0&&d[0]==="^"&&!d.includes("/")&&(a=`/${a}`),c.value+=a,tt({value:a}),n.literalBrackets===!1||J.hasRegexChars(d))continue;let v=J.escapeRegex(c.value);if(l.output=l.output.slice(0,-c.value.length),n.literalBrackets===!0){l.output+=v,c.value=v;continue}c.value=`(${u}${v}|${c.value})`,l.output+=c.value;continue}if(a==="{"&&n.nobrace!==!0){Et("braces");let d={type:"brace",value:a,output:"(",outputIndex:l.output.length,tokensIndex:l.tokens.length};N.push(d),_(d);continue}if(a==="}"){let d=N[N.length-1];if(n.nobrace===!0||!d){_({type:"text",value:a,output:a});continue}let v=")";if(d.dots===!0){let $=i.slice(),M=[];for(let O=$.length-1;O>=0&&(i.pop(),$[O].type!=="brace");O--)$[O].type!=="dots"&&M.unshift($[O].value);v=Bo(M,n),l.backtrack=!0}if(d.comma!==!0&&d.dots!==!0){let $=l.output.slice(0,d.outputIndex),M=l.tokens.slice(d.tokensIndex);d.value=d.output="\\{",a=v="\\}",l.output=$;for(let O of M)l.output+=O.output||O.value}_({type:"brace",value:a,output:v}),et("braces"),N.pop();continue}if(a==="|"){W.length>0&&W[W.length-1].conditions++,_({type:"text",value:a});continue}if(a===","){let d=a,v=N[N.length-1];v&&D[D.length-1]==="braces"&&(v.comma=!0,d="|"),_({type:"comma",value:a,output:d});continue}if(a==="/"){if(c.type==="dot"&&l.index===l.start+1){l.start=l.index+1,l.consumed="",l.output="",i.pop(),c=s;continue}_({type:"slash",value:a,output:f});continue}if(a==="."){if(l.braces>0&&c.type==="dot"){c.value==="."&&(c.output=g);let d=N[N.length-1];c.type="dots",c.output+=a,c.value+=a,d.dots=!0;continue}if(l.braces+l.parens===0&&c.type!=="bos"&&c.type!=="slash"){_({type:"text",value:a,output:g});continue}_({type:"dot",value:a,output:g});continue}if(a==="?"){if(!(c&&c.value==="(")&&n.noextglob!==!0&&w()==="("&&w(2)!=="?"){_t("qmark",a);continue}if(c&&c.type==="paren"){let v=w(),$=a;(c.value==="("&&!/[!=<:]/.test(v)||v==="<"&&!/<([!=]|\w+>)/.test(V()))&&($=`\\${a}`),_({type:"text",value:a,output:$});continue}if(n.dot!==!0&&(c.type==="slash"||c.type==="bos")){_({type:"qmark",value:a,output:G});continue}_({type:"qmark",value:a,output:A});continue}if(a==="!"){if(n.noextglob!==!0&&w()==="("&&(w(2)!=="?"||!/[!=<:]/.test(w(3)))){_t("negate",a);continue}if(n.nonegate!==!0&&l.index===0){Hn();continue}}if(a==="+"){if(n.noextglob!==!0&&w()==="("&&w(2)!=="?"){_t("plus",a);continue}if(c&&c.value==="("||n.regex===!1){_({type:"plus",value:a,output:b});continue}if(c&&(c.type==="bracket"||c.type==="paren"||c.type==="brace")||l.parens>0){_({type:"plus",value:a});continue}_({type:"plus",value:b});continue}if(a==="@"){if(n.noextglob!==!0&&w()==="("&&w(2)!=="?"){_({type:"at",extglob:!0,value:a,output:""});continue}_({type:"text",value:a});continue}if(a!=="*"){(a==="$"||a==="^")&&(a=`\\${a}`);let d=No.exec(V());d&&(a+=d[0],l.index+=d[0].length),_({type:"text",value:a});continue}if(c&&(c.type==="globstar"||c.star===!0)){c.type="star",c.star=!0,c.value+=a,c.output=I,l.backtrack=!0,l.globstar=!0,K(a);continue}let h=V();if(n.noextglob!==!0&&/^\([^?]/.test(h)){_t("star",a);continue}if(c.type==="star"){if(n.noglobstar===!0){K(a);continue}let d=c.prev,v=d.prev,$=d.type==="slash"||d.type==="bos",M=v&&(v.type==="star"||v.type==="globstar");if(n.bash===!0&&(!$||h[0]&&h[0]!=="/")){_({type:"star",value:a,output:""});continue}let O=l.braces>0&&(d.type==="comma"||d.type==="brace"),Y=W.length&&(d.type==="pipe"||d.type==="paren");if(!$&&d.type!=="paren"&&!O&&!Y){_({type:"star",value:a,output:""});continue}for(;h.slice(0,3)==="/**";){let Z=t[l.index+4];if(Z&&Z!=="/")break;h=h.slice(3),K("/**",3)}if(d.type==="bos"&&X()){c.type="globstar",c.value+=a,c.output=C(n),l.output=c.output,l.globstar=!0,K(a);continue}if(d.type==="slash"&&d.prev.type!=="bos"&&!M&&X()){l.output=l.output.slice(0,-(d.output+c.output).length),d.output=`(?:${d.output}`,c.type="globstar",c.output=C(n)+(n.strictSlashes?")":"|$)"),c.value+=a,l.globstar=!0,l.output+=d.output+c.output,K(a);continue}if(d.type==="slash"&&d.prev.type!=="bos"&&h[0]==="/"){let Z=h[1]!==void 0?"|$":"";l.output=l.output.slice(0,-(d.output+c.output).length),d.output=`(?:${d.output}`,c.type="globstar",c.output=`${C(n)}${f}|${f}${Z})`,c.value+=a,l.output+=d.output+c.output,l.globstar=!0,K(a+L()),_({type:"slash",value:"/",output:""});continue}if(d.type==="bos"&&h[0]==="/"){c.type="globstar",c.value+=a,c.output=`(?:^|${f}|${C(n)}${f})`,l.output=c.output,l.globstar=!0,K(a+L()),_({type:"slash",value:"/",output:""});continue}l.output=l.output.slice(0,-c.output.length),c.type="globstar",c.output=C(n),c.value+=a,l.output+=c.output,l.globstar=!0,K(a);continue}let P={type:"star",value:a,output:I};if(n.bash===!0){P.output=".*?",(c.type==="bos"||c.type==="slash")&&(P.output=k+P.output),_(P);continue}if(c&&(c.type==="bracket"||c.type==="paren")&&n.regex===!0){P.output=a,_(P);continue}(l.index===l.start||c.type==="slash"||c.type==="dot")&&(c.type==="dot"?(l.output+=R,c.output+=R):n.dot===!0?(l.output+=T,c.output+=T):(l.output+=k,c.output+=k),w()!=="*"&&(l.output+=y,c.output+=y)),_(P)}for(;l.brackets>0;){if(n.strictBrackets===!0)throw new SyntaxError(dt("closing","]"));l.output=J.escapeLast(l.output,"["),et("brackets")}for(;l.parens>0;){if(n.strictBrackets===!0)throw new SyntaxError(dt("closing",")"));l.output=J.escapeLast(l.output,"("),et("parens")}for(;l.braces>0;){if(n.strictBrackets===!0)throw new SyntaxError(dt("closing","}"));l.output=J.escapeLast(l.output,"{"),et("braces")}if(n.strictSlashes!==!0&&(c.type==="star"||c.type==="bracket")&&_({type:"maybe_slash",value:"",output:`${f}?`}),l.backtrack===!0){l.output="";for(let h of l.tokens)l.output+=h.output!=null?h.output:h.value,h.suffix&&(l.output+=h.suffix)}return l};oe.fastpaths=(t,e)=>{let n={...e},r=typeof n.maxLength=="number"?Math.min(Ht,n.maxLength):Ht,o=t.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);t=gn[t]||t;let{DOT_LITERAL:s,SLASH_LITERAL:i,ONE_CHAR:u,DOTS_SLASH:p,NO_DOT:m,NO_DOTS:g,NO_DOTS_SLASH:b,STAR:f,START_ANCHOR:y}=xt.globChars(n.windows),S=n.dot?g:m,x=n.dot?b:m,R=n.capture?"":"?:",T={negated:!1,prefix:""},A=n.bash===!0?".*?":f;n.capture&&(A=`(${A})`);let G=k=>k.noglobstar===!0?A:`(${R}(?:(?!${y}${k.dot?p:s}).)*?)`,Q=k=>{switch(k){case"*":return`${S}${u}${A}`;case".*":return`${s}${u}${A}`;case"*.*":return`${S}${A}${s}${u}${A}`;case"*/*":return`${S}${A}${i}${u}${x}${A}`;case"**":return S+G(n);case"**/*":return`(?:${S}${G(n)}${i})?${x}${u}${A}`;case"**/*.*":return`(?:${S}${G(n)}${i})?${x}${A}${s}${u}${A}`;case"**/.*":return`(?:${S}${G(n)}${i})?${s}${u}${A}`;default:{let E=/^(.*?)\.(\w+)$/.exec(k);if(!E)return;let I=Q(E[1]);return I?I+s+E[2]:void 0}}},F=J.removePrefix(t,T),C=Q(F);return C&&n.strictSlashes!==!0&&(C+=`${i}?`),C};yn.exports=oe});var Rn=ot((bu,xn)=>{"use strict";var Xo=mn(),se=Sn(),An=St(),Ko=yt(),zo=t=>t&&typeof t=="object"&&!Array.isArray(t),H=(t,e,n=!1)=>{if(Array.isArray(t)){let g=t.map(f=>H(f,e,n));return f=>{for(let y of g){let S=y(f);if(S)return S}return!1}}let r=zo(t)&&t.tokens&&t.input;if(t===""||typeof t!="string"&&!r)throw new TypeError("Expected pattern to be a non-empty string");let o=e||{},s=o.windows,i=r?H.compileRe(t,e):H.makeRe(t,e,!1,!0),u=i.state;delete i.state;let p=()=>!1;if(o.ignore){let g={...e,ignore:null,onMatch:null,onResult:null};p=H(o.ignore,g,n)}let m=(g,b=!1)=>{let{isMatch:f,match:y,output:S}=H.test(g,i,e,{glob:t,posix:s}),x={glob:t,state:u,regex:i,posix:s,input:g,output:S,match:y,isMatch:f};return typeof o.onResult=="function"&&o.onResult(x),f===!1?(x.isMatch=!1,b?x:!1):p(g)?(typeof o.onIgnore=="function"&&o.onIgnore(x),x.isMatch=!1,b?x:!1):(typeof o.onMatch=="function"&&o.onMatch(x),b?x:!0)};return n&&(m.state=u),m};H.test=(t,e,n,{glob:r,posix:o}={})=>{if(typeof t!="string")throw new TypeError("Expected input to be a string");if(t==="")return{isMatch:!1,output:""};let s=n||{},i=s.format||(o?An.toPosixSlashes:null),u=t===r,p=u&&i?i(t):t;return u===!1&&(p=i?i(t):t,u=p===r),(u===!1||s.capture===!0)&&(s.matchBase===!0||s.basename===!0?u=H.matchBase(t,e,n,o):u=e.exec(p)),{isMatch:!!u,match:u,output:p}};H.matchBase=(t,e,n,r=n&&n.windows)=>(e instanceof RegExp?e:H.makeRe(e,n)).test(An.basename(t,{windows:r}));H.isMatch=(t,e,n)=>H(e,n)(t);H.parse=(t,e)=>Array.isArray(t)?t.map(n=>H.parse(n,e)):se(t,{...e,fastpaths:!1});H.scan=(t,e)=>Xo(t,e);H.compileRe=(t,e,n=!1,r=!1)=>{if(n===!0)return t.output;let o=e||{},s=o.contains?"":"^",i=o.contains?"":"$",u=`${s}(?:${t.output})${i}`;t&&t.negated===!0&&(u=`^(?!${u}).*$`);let p=H.toRegex(u,e);return r===!0&&(p.state=t),p};H.makeRe=(t,e={},n=!1,r=!1)=>{if(!t||typeof t!="string")throw new TypeError("Expected a non-empty string");let o={negated:!1,fastpaths:!0};return e.fastpaths!==!1&&(t[0]==="."||t[0]==="*")&&(o.output=se.fastpaths(t,e)),o.output||(o=se(t,e)),H.compileRe(o,e,n,r)};H.toRegex=(t,e)=>{try{let n=e||{};return new RegExp(t,n.flags||(n.nocase?"i":""))}catch(n){if(e&&e.debug===!0)throw n;return/$^/}};H.constants=Ko;xn.exports=H});var In=ot((yu,vn)=>{"use strict";var En=Rn(),Qo=St();function _n(t,e,n=!1){return e&&(e.windows===null||e.windows===void 0)&&(e={...e,windows:Qo.isWindows()}),En(t,e,n)}Object.assign(_n,En);vn.exports=_n});import{dirname as Gn}from"node:path";import{homedir as kt}from"node:os";import{dirname as Bn,join as ut}from"node:path";function qn(t,e){return t===e?"Same folder":t===ut(kt(),"Desktop")?"Desktop":t===ut(kt(),"Downloads")?"Downloads":t===ut(e,"converted")?"New subfolder":t.split("/").pop()||t}function Ot(t,e,{subfolder:n=!1}={}){let r=Bn(t.path),o=ye(e.defaultOutput),s=[{label:qn(o,r),path:o},{label:"Desktop",path:ut(kt(),"Desktop")},{label:"Same folder",path:r},{label:"Downloads",path:ut(kt(),"Downloads")},...n?[{label:"New subfolder",path:ut(r,"converted")}]:[]],i=new Set,u=s.filter(p=>i.has(p.path)?!1:(i.add(p.path),!0));return{kind:"path",id:"destination",label:"Save to",default:o,presets:u}}var j=t=>typeof t=="string"&&t!==""?t:void 0;var Wn=t=>t.length===1&&t[0]?.kind==="image"?t[0]:void 0,jn=t=>t.length===1&&t[0]?.kind==="document"?t[0]:void 0,Un="-small",xe={id:"compress",label:"Compress",verb:"Compressing",hint:"make it smaller",appliesTo:t=>{let e=Wn(t);return e!==void 0?B[e.format].lossy:(jn(t)?.images?.compressible??0)>0},options(t,e,n){let r=t[0];if(!r)return[];let o=[{kind:"select",id:"mode",label:`Compress ${r.path.split("/").pop()??"this file"}`,choices:[{value:"quality",label:"By quality",hint:"pick a level, see the result"},{value:"size",label:"To a target size",hint:"smallest quality that fits"}],default:"quality"}];if(e.mode==="quality")o.push({kind:"slider",id:"quality",label:"Quality",min:1,max:100,step:5,default:n.quality});else if(e.mode==="size")o.push({kind:"text",id:"size",label:"Target size",placeholder:"e.g. 500kb or 2mb"});else return o;return o.push(Ot(r,n)),o},plan(t,e){let n=e.mode;if(n!=="quality"&&n!=="size")throw st(`compressAction.plan() needs a mode of "quality" or "size", got ${JSON.stringify(n)}.`,"This is a caller bug, not a user-facing condition: walk options() before calling plan().");let r=t[0];if(!r)return[];let o=(r.path.split("/").pop()??"file").replace(/\.[^.]+$/,""),i=`${typeof e.destination=="string"?e.destination:Gn(r.path)}/${o}${Un}${mt(r.format)}`;return[{op:"convert",sources:[r],target:r.format,outputs:[i],options:{background:"#ffffff",keepMetadata:!1,...n==="quality"&&typeof e.quality=="number"?{quality:e.quality}:{}}}]}};function Ct(t){let e=Object.keys(B);return[...t].sort((n,r)=>e.indexOf(n)-e.indexOf(r))}function Bt(t){let e=new Set;for(let n of It)if(n.reads.has(t.format))for(let r of n.writes)e.add(r);return Ct([...e])}function Re(t){return Bt(t).map(e=>({id:e,label:B[e].label,hint:B[e].hint,lossy:B[e].lossy}))}function Jn(){let t=new Set;for(let e of It)for(let n of e.reads)t.add(n);return Ct([...t])}function Xn(){let t=new Set;for(let e of It)for(let n of e.writes)t.add(n);return Ct([...t])}function qt(t){return Se.writes.has(t)}function Xs(){let t=new Set(Jn()),e=new Set(Xn());return Ct([...new Set([...t,...e])]).map(n=>({id:n,label:B[n].label,extensions:[...B[n].extensions],read:t.has(n),write:e.has(n),lossy:B[n].lossy}))}import{existsSync as Gt,statSync as Kn}from"node:fs";import{basename as at,dirname as zn,extname as ct,isAbsolute as Qn,join as z,relative as Yn,resolve as q,sep as Zn}from"node:path";function Ee(t){return t.endsWith("/")||t.endsWith(Zn)||Gt(t)&&Kn(t).isDirectory()?!0:ct(t)===""}function Vn(t,e){let n=at(t),r=ct(n);return(r?n.slice(0,-r.length):n)+mt(e)}function _e(t,e,n){if(!n)return t;let r=Yn(q(n),e);return!r||r.startsWith("..")?t:z(t,r)}function Wt(t){let e=q(t.sourcePath),n=Vn(e,t.target);if(!t.output)return z(q(e,".."),n);let r=Qn(t.output)?t.output:q(t.output);return Ee(t.output)?z(_e(r,q(e,".."),t.sourceRoot),n):q(r)}function jt(t){let e=Wt(t);if(t.output&&!Ee(t.output))return e;let n=ct(e);return z(q(e,".."),`${at(e,n)}-${t.suffix}${n}`)}function Zs(t){if(!Gt(t))return t;let e=q(t,".."),n=at(t),r=ct(n),o=r?n.slice(0,-r.length):n;for(let s=1;s<1e4;s++){let i=z(e,`${o} (${s})${r}`);if(!Gt(i))return i}throw new Error(`no free name beside ${n}`)}function $t(t){let e=q(t,".."),n=at(t),r=ct(n);return{dir:e,stem:r?n.slice(0,-r.length):n,ext:r||".pdf"}}function lt(t,e){let{dir:n,stem:r,ext:o}=$t(q(t));return z(n,`${r}-${e}${o}`)}function ve(t,e){let{dir:n,stem:r,ext:o}=$t(q(t)),s=String(e).length;return Array.from({length:e},(i,u)=>z(n,`${r}-${String(u+1).padStart(s,"0")}${o}`))}function Ie(t,e,n,r,o){let{stem:s}=$t(q(t)),i=r?_e(q(r),q(t,".."),o):q(t,".."),u=mt(n),p=String(Math.max(1,...e.map(f=>f+1))).length,m=e.map(f=>z(i,`${s}-${String(f+1).padStart(p,"0")}${u}`)),[g,...b]=m;if(g===void 0)throw new Error("rasterOutputPaths requires at least one selected page");return[g,...b]}function we(t,e,n){if(!n)return[lt(t,"extract")];let{dir:r,stem:o,ext:s}=$t(q(t));return e.map(i=>z(r,`${o}-p${i+1}${s}`))}function ke(t){let e=q(t[0]??"merged.pdf");if(new Set(t.map(r=>q(r,".."))).size===1){let r=q(e,"..");return z(r,`${at(r)}-merged.pdf`)}return lt(e,"merged")}function bt(t,e,n){let r=e?t.map(s=>z(e,at(s))):t,[o]=r;return!n||r.length!==1||o===void 0?r:[z(zn(o),`${n}${ct(o)}`)]}function pt(t,e,n){return bt([t],e,n)[0]??t}function tr(t){return{kind:"select",id:"pages",label:"Pages",default:"all",choices:[{value:"all",label:"All pages",hint:`${t.pages} pages`},{value:"first",label:"First page only"},{value:"choose",label:"Choose pages",hint:"pick which ones"}]}}function er(){return{kind:"select",id:"dpi",label:"Resolution",default:"150",choices:[{value:"72",label:"72 dpi",hint:"screen"},{value:"150",label:"150 dpi",badge:"default"},{value:"300",label:"300 dpi",hint:"print"}]}}function nr(t,e){return Array.isArray(e)?it(e):e==="first"?[0]:typeof e=="string"&&e!=="all"&&e!==""?it(vt(e,t.pages)):Array.from({length:t.pages},(n,r)=>r)}function rr(t,e){let n=B[t.format].lossy,r=B[e].lossy;if(n&&!r)return{hint:"likely bigger",tone:"warn"};if(!n&&r)return{hint:"likely smaller",tone:"ok"}}function or(t){let e=Re(t).filter(r=>r.id!==t.format),n=e[0];return{kind:"select",id:"target",label:`Convert ${B[t.format].label} to`,choices:e.map(r=>{let o=rr(t,r.id);return{value:r.id,label:r.label,hint:o?.hint??r.hint,...o===void 0?{}:{tone:o.tone}}}),default:n?n.id:""}}function sr(t){let e=t.target,n=typeof e=="string"?ce(e):void 0;if(!n)throw st(`convertAction.plan() requires a valid target format, got ${JSON.stringify(e)}.`,"This is a caller bug, not a user-facing condition: call options() and pass one of the target select choices before calling plan().");return n}var Oe={id:"convert",label:"Convert",verb:"Converting",hint:"to another format",appliesTo:t=>t.length>=1,options(t,e,n){let r=t[0];if(!r)return[];let o=[or(r)],s=e.target;return typeof s!="string"||(r.kind==="document"&&qt(s)&&o.push(tr(r),er()),B[s]?.lossy&&o.push({kind:"slider",id:"quality",label:"Quality",min:1,max:100,step:5,default:n.quality}),o.push(Ot(r,n,{subfolder:!0}))),o},plan(t,e){let n=t[0];if(!n)return[];let r=sr(e),o=r.id,s={background:typeof e.background=="string"?e.background:"#ffffff",keepMetadata:e.keepMetadata===!0};r.lossy&&typeof e.quality=="number"&&(s.quality=e.quality);let i=typeof e.destination=="string"?e.destination:void 0;if(n.kind==="document"&&qt(o)){let p=Number(e.dpi);s.dpi=Number.isFinite(p)&&p>0?p:150;let m=nr(n,e.pages);s.pages=m;let g=typeof e.sourceRoot=="string"?e.sourceRoot:void 0,b=Ie(n.path,m,o,i,g);return[{op:"convert",sources:[n],outputs:b,target:o,options:s}]}let u=Wt({sourcePath:n.path,target:o,...i===void 0?{}:{output:`${i}/`}});return[{op:"convert",sources:[n],outputs:[u],target:o,options:s}]}};var Tt=t=>t.length>0&&t.every(e=>e.kind==="image")?t:void 0;function di(t,e){let n=Bt(t);return n.includes(e)?void 0:fe(t,e,n)}function Ce(t){return{target:t.target??"png",background:typeof t.background=="string"?t.background:"#ffffff",keepMetadata:t.keepMetadata===!0,...typeof t.output=="string"?{output:t.output}:{},...t.roots instanceof Map?{roots:t.roots}:{},...typeof t.quality=="number"?{quality:t.quality}:{}}}var $e=()=>({kind:"select",id:"target",label:"Save as",default:"png",choices:[{value:"png",label:"PNG",hint:B.png.hint}]}),ir=t=>t===1?"sharp":`${t}x`,Te={id:"boost",label:"Boost resolution",verb:"Boosting",hint:"sharper, at its size or at 2\xD7 or 4\xD7",requires:"boost",appliesTo:t=>Tt(t)!==void 0,unavailable:()=>"images only",options:()=>[{kind:"select",id:"scale",label:"Scale",default:"2",choices:[{value:"1",label:"Sharpen",hint:"the same size, sharper"},{value:"2",label:"2\xD7",hint:"twice the width and height"},{value:"4",label:"4\xD7",hint:"four times the width and height"}]},$e()],plan(t,e){let n=Tt(t);if(!n)return[];let r=Ce(e),o=Number(e.scale??2),s=o===4?4:o===1?1:2;return n.map(i=>({op:"boost",sources:[i],outputs:[jt({sourcePath:i.path,target:r.target,suffix:ir(s),...r.output===void 0?{}:{output:r.output},...r.roots?.get(i.path)===void 0?{}:{sourceRoot:r.roots.get(i.path)}})],scale:s,target:r.target,options:{background:r.background,keepMetadata:r.keepMetadata,...r.quality===void 0?{}:{quality:r.quality}}}))}},Pe={id:"remove-background",label:"Remove background",verb:"Removing",hint:"cut out the subject",requires:"remove-background",appliesTo:t=>Tt(t)!==void 0,unavailable:()=>"images only",options:()=>[$e()],plan(t,e){let n=Tt(t);if(!n)return[];let r=Ce(e);return n.map(o=>({op:"remove-background",sources:[o],outputs:[jt({sourcePath:o.path,target:r.target,suffix:"cutout",...r.output===void 0?{}:{output:r.output},...r.roots?.get(o.path)===void 0?{}:{sourceRoot:r.roots.get(o.path)}})],target:r.target,options:{background:r.background,keepMetadata:r.keepMetadata,...r.quality===void 0?{}:{quality:r.quality}}}))}};var Pt=t=>t.length===1&&t[0]?.kind==="document"&&t[0].format==="pdf"?t[0]:void 0,Le={id:"split",label:"Split",verb:"Splitting",hint:"into several files",appliesTo:t=>(Pt(t)?.pages??0)>1,unavailable:t=>Pt(t)===void 0?"one PDF at a time":"only one page",options(t){let e=Pt(t);return e?[{kind:"select",id:"mode",label:"How",default:"every-page",choices:[{value:"every-page",label:"Every page",hint:`${e.pages} files`},{value:"every-n",label:"Every N pages",hint:"ask how many"},{value:"points",label:"At points I choose",hint:"grid"}]}]:[]},plan(t,e){let n=Pt(t);if(!n)return[];let r=Array.isArray(e.cuts)?e.cuts:[],o=Ae(r,n.pages).length,s=bt(ve(n.path,o),j(e.destination),j(e.name));return[{op:"split",sources:[n],outputs:s,cuts:r}]}};function Si(t){return Array.from({length:Math.max(0,t-1)},(e,n)=>n)}function Ai(t,e){if(!Number.isInteger(e)||e<1)throw st("Splitting every N pages needs N to be a whole number, at least 1.");let n=[];for(let r=e;r<t;r+=e)n.push(r-1);return n}var ft=t=>t.length===1&&t[0]?.kind==="document"&&t[0].format==="pdf"?t[0]:void 0;function Fe(t,e){return Array.isArray(e.pages)?it(e.pages):typeof e.pages=="string"?it(vt(e.pages,t.pages)):[]}var De=t=>({kind:"text",id:"pages",label:"Pages",placeholder:`1-${t.pages}`}),He={id:"extract",label:"Extract",verb:"Extracting",hint:"keep only some pages",appliesTo:t=>ft(t)!==void 0,unavailable:()=>"one PDF at a time",options:t=>{let e=ft(t);return e?[De(e),{kind:"select",id:"separate",label:"Output",default:"one",choices:[{value:"one",label:"One file",hint:"all selected pages together"},{value:"many",label:"Separate files",hint:"one per page"}]}]:[]},plan(t,e){let n=ft(t);if(!n)return[];let r=Fe(n,e),o=e.separate==="many";return[{op:"extract",sources:[n],outputs:bt(we(n.path,r,o),j(e.destination),j(e.name)),pages:r,separate:o}]}},Ne={id:"delete",label:"Delete",verb:"Deleting",hint:"drop some pages",appliesTo:t=>ft(t)!==void 0,unavailable:()=>"one PDF at a time",options:t=>{let e=ft(t);return e?[De(e)]:[]},plan(t,e){let n=ft(t);return n?[{op:"delete",sources:[n],outputs:[pt(lt(n.path,"trimmed"),j(e.destination),j(e.name))],pages:Fe(n,e)}]:[]}};var Ut=t=>t.filter(e=>e.kind==="document"&&e.format==="pdf"),Me={id:"merge",label:"Merge",verb:"Merging",hint:"several files into one",appliesTo:t=>Ut(t).length>=2&&Ut(t).length===t.length,unavailable:t=>Ut(t).length!==t.length?"PDFs only":"needs 2+ files",options:()=>[],plan(t,e){let n=pt(ke(t.map(r=>r.path)),j(e.destination),j(e.name));return[{op:"merge",sources:t,outputs:[n]}]}};var Be=t=>t.length===1&&t[0]?.kind==="document"&&t[0].format==="pdf"?t[0]:void 0,qe={id:"rotate",label:"Rotate",verb:"Rotating",hint:"turn pages",appliesTo:t=>Be(t)!==void 0,unavailable:()=>"one PDF at a time",options:()=>[{kind:"select",id:"degrees",label:"Turn",default:"90",choices:[{value:"90",label:"90\xB0 right",hint:"a quarter turn"},{value:"180",label:"180\xB0",hint:"upside down"},{value:"270",label:"90\xB0 left",hint:"a quarter turn back"}]}],plan(t,e){let n=Be(t);if(!n)return[];let o=Number(e.degrees??90)/90%4||1;return[{op:"rotate",sources:[n],outputs:[pt(lt(n.path,"rotated"),j(e.destination),j(e.name))],turns:o}]}};var ur=[Oe,xe,Me,Le,He,Ne,qe],ar=[Te,Pe];function Mi(t,e=new Set){return[...ur,...ar.filter(n=>n.requires&&e.has(n.requires))].filter(n=>n.appliesTo(t))}function Bi(t,e){return t.appliesTo(e)?void 0:t.unavailable?.(e)}function cr(t=1,e=100){let n=Math.max(1,e-t+1);return 1+Math.max(0,Math.ceil(Math.log2(n)))}async function Ge(t){let e=t.min??1,n=t.max??100,r=cr(e,n),o=0,s=async f=>(o+=1,t.onAttempt?.(o,r),t.encode(f)),i=()=>t.signal?.aborted===!0,u=await s(n);if(i())return{quality:n,bytes:u,missed:!1,cancelled:!0};if(u<=t.targetBytes)return{quality:n,bytes:u,missed:!1};let p=e,m=n,g;for(;p<=m;){let f=Math.floor((p+m)/2),y=await s(f);if(i())return{quality:f,bytes:y,missed:!1,cancelled:!0};y<=t.targetBytes?(g={quality:f,bytes:y,missed:!1},p=f+1):m=f-1}if(g)return g;let b=await t.encode(e);return{quality:e,bytes:b,missed:!0}}import{cpus as lr}from"node:os";function pr(){return Math.max(1,Math.min(lr().length,4))}function Lt(t){let e=t!==void 0&&Number.isFinite(t)?t:void 0;return Math.max(1,e??pr())}async function Jt(t,e,n){let r=0,o=async()=>{for(;r<t.length;){let i=r++;await n(t[i],i)}},s=Math.min(Lt(e),t.length);await Promise.all(Array.from({length:s},o))}async function We(t,e){let n=e.onEvent??(()=>{}),r=e.engineFor??wt,o=Lt(e.concurrency),s=t.length,i=[],u=[],p=0;await Jt(t,o,async(f,y)=>{n({type:"job:start",job:f,index:y,total:s});let S=r(f);if(!S){p++;let x=f.sources[0].path,R={path:x,error:gt(x,new Error(`no engine runs ${f.op}`))};u[y]=R,n({type:"job:error",job:f,failure:R,completed:p,total:s});return}try{let x=await S.run(f,R=>n({type:"job:phase",job:f,progress:R}),e.signal);i[y]=x,p++,n({type:"job:done",job:f,result:x,completed:p,total:s})}catch(x){p++;let R=f.sources[0].path,T=nt(x)?x:gt(R,x),A={path:R,error:T};u[y]=A,n({type:"job:error",job:f,failure:A,completed:p,total:s})}});let m=i.filter(f=>f!==void 0),g=u.filter(f=>f!==void 0),b={results:m,failures:g,inputBytes:m.reduce((f,y)=>f+y.job.sources[0].bytes,0),outputBytes:m.reduce((f,y)=>f+y.outputBytes,0)};return n({type:"batch:done",summary:b}),b}import{existsSync as fr}from"node:fs";import{resolve as Ft}from"node:path";function dr(t){let e=t.sources[0]?.path??t.outputs[0]??"",n=new Set;for(let r of t.outputs){let o=Ft(r);if(n.has(o))return{output:r,error:me(e,r)};n.add(o)}}function hr(t,e,n){let r=dr(t);if(r)return r;let o=new Set(t.sources.map(i=>Ft(i.path))),s=t.sources[0]?.path??t.outputs[0]??"";for(let i of t.outputs){let u=Ft(i);if(o.has(u)&&!n)return{output:i,error:ge(i,t.op)};let p=e.get(u);if(p){let m=p.sources[0]?.path??p.outputs[0]??"";return{output:i,error:he([m,s],i)}}if(fr(u)&&!n)return{output:i,error:de(i,t.op)}}}function je(t,e){let n=[],r=[],o=new Map;for(let s of t){let i=hr(s,o,e.force);if(i){let u=s.sources[0]?.path??i.output;r.push({path:u,error:i.error});continue}for(let u of s.outputs)o.set(Ft(u),s);n.push(s)}return{jobs:n,failures:r}}async function mr(t,e,n,r,o){let s=t.sources[0].path,i=f=>({kind:"failed",failure:{path:s,error:nt(f)?f:gt(s,f)}}),u;try{u=await n(t)?.measurer?.(t)}catch(f){return i(f)}if(!u||u.ladder.length===0)return{kind:"refused",failure:{path:s,error:le(t.sources[0],t.target)}};let p=u;if(o?.aborted)return{kind:"cancelled"};let m=Number.POSITIVE_INFINITY,g;try{for(let f of p.ladder){let y=await Ge({encode:S=>p.measure({...t.options,...f,quality:S}),targetBytes:e,onAttempt:(S,x)=>r({type:"search:attempt",job:t,attempt:S,of:x,rung:f}),...o===void 0?{}:{signal:o}});if(y.cancelled)return{kind:"cancelled"};if(y.bytes<m&&(m=y.bytes,g={...f,quality:y.quality}),!y.missed)return t.options={...t.options,...f,quality:y.quality},{kind:"ready"}}}catch(f){return i(f)}return{kind:"unreachable",entry:{job:t,smallest:m,settings:g??{quality:1},error:pe(t.sources[0],e,m)}}}async function nu(t,e){let n=e.onEvent??(()=>{}),r=e.engineFor??wt,o=e.targetBytes,s=je(t,{force:e.force}),i=o===void 0?0:s.jobs.filter(R=>R.op==="convert").length,u=[],p=0;await Jt(s.jobs,Lt(e.concurrency),async(R,T)=>{if(o===void 0||R.op!=="convert"){u[T]={kind:"ready"};return}if(e.signal?.aborted){u[T]={kind:"cancelled"};return}let A=await mr(R,o,r,n,e.signal);u[T]=A,A.kind!=="cancelled"&&(p+=1,n({type:"search:settled",job:R,completed:p,total:i}))});let m=[...s.failures],g=[],b=[],f=[],y=!1;for(let[R,T]of s.jobs.entries()){let A=u[R]??{kind:"ready"};A.kind==="ready"?f.push(T):A.kind==="refused"?m.push(A.failure):A.kind==="failed"?b.push(A.failure):A.kind==="unreachable"?g.push(A.entry):y=!0}if(y)return{results:[],refusals:m,unreachable:[],failures:[],inputBytes:0,outputBytes:0,cancelled:!0};let S=new Set,x=await We(f,{...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.engineFor===void 0?{}:{engineFor:e.engineFor},...e.signal===void 0?{}:{signal:e.signal},onEvent:R=>{R.type==="job:error"&&!e.signal?.aborted&&S.add(R.failure),n(R)}});if(e.signal?.aborted&&x.failures.length>0){let R=x.failures.filter(T=>S.has(T));return{...x,refusals:m,unreachable:g,failures:[...b,...R],cancelled:!0}}return{results:x.results,refusals:m,unreachable:g,failures:[...b,...x.failures],inputBytes:x.inputBytes,outputBytes:x.outputBytes}}import{existsSync as ws}from"node:fs";import{stat as ks}from"node:fs/promises";import{resolve as ae}from"node:path";import{readdir as Yo,readdirSync as Zo,realpath as Vo,realpathSync as ts,stat as es,statSync as ns}from"fs";import{isAbsolute as rs,posix as rt,resolve as os}from"path";import{fileURLToPath as ss}from"url";import{createRequire as gr}from"module";import{basename as br,dirname as Kt,normalize as yr,relative as Sr,resolve as Ar,sep as Xe}from"path";import*as xr from"fs";var Ue=gr(import.meta.url);function Rr(t){let e=yr(t);return e.length>1&&e[e.length-1]===Xe&&(e=e.substring(0,e.length-1)),e}var Er=/[\\/]/g;function Ke(t,e){return t.replace(Er,e)}var _r=/^[a-z]:[\\/]$/i;function vr(t){return t==="/"||_r.test(t)}function Xt(t,e){let{resolvePaths:n,normalizePath:r,pathSeparator:o}=e,s=process.platform==="win32"&&t.includes("/")||t.startsWith(".");if(n&&(t=Ar(t)),(r||s)&&(t=Rr(t)),t===".")return"";let i=t[t.length-1]!==o;return Ke(i?t+o:t,o)}function ze(t,e){return e+t}function Ir(t,e){return function(n,r){return r.startsWith(t)?r.slice(t.length)+n:Ke(Sr(t,r),e.pathSeparator)+e.pathSeparator+n}}function wr(t){return t}function kr(t,e,n){return e+t+n}function Or(t,e){let{relativePaths:n,includeBasePath:r}=e;return n&&t?Ir(t,e):r?ze:wr}function Cr(t){return function(e,n){n.push(e.substring(t.length)||".")}}function $r(t){return function(e,n,r){let o=e.substring(t.length)||".";r.every(s=>s(o,!0))&&n.push(o)}}var Tr=(t,e)=>{e.push(t||".")},Pr=(t,e,n)=>{let r=t||".";n.every(o=>o(r,!0))&&e.push(r)},Lr=()=>{};function Fr(t,e){let{includeDirs:n,filters:r,relativePaths:o}=e;return n?o?r&&r.length?$r(t):Cr(t):r&&r.length?Pr:Tr:Lr}var Dr=(t,e,n,r)=>{r.every(o=>o(t,!1))&&n.files++},Hr=(t,e,n,r)=>{r.every(o=>o(t,!1))&&e.push(t)},Nr=(t,e,n,r)=>{n.files++},Mr=(t,e)=>{e.push(t)},Br=()=>{};function qr(t){let{excludeFiles:e,filters:n,onlyCounts:r}=t;return e?Br:n&&n.length?r?Dr:Hr:r?Nr:Mr}var Gr=t=>t,Wr=()=>[""].slice(0,0);function jr(t){return t.group?Wr:Gr}var Ur=(t,e,n)=>{t.push({directory:e,files:n,dir:e})},Jr=()=>{};function Xr(t){return t.group?Ur:Jr}var Kr=function(t,e,n){let{queue:r,fs:o,options:{suppressErrors:s}}=e;r.enqueue(),o.realpath(t,(i,u)=>{if(i)return r.dequeue(s?null:i,e);o.stat(u,(p,m)=>{if(p)return r.dequeue(s?null:p,e);if(m.isDirectory()&&Qe(t,u,e))return r.dequeue(null,e);n(m,u),r.dequeue(null,e)})})},zr=function(t,e,n){let{queue:r,fs:o,options:{suppressErrors:s}}=e;r.enqueue();try{let i=o.realpathSync(t),u=o.statSync(i);if(u.isDirectory()&&Qe(t,i,e))return;n(u,i)}catch(i){if(!s)throw i}};function Qr(t,e){return!t.resolveSymlinks||t.excludeSymlinks?null:e?zr:Kr}function Qe(t,e,n){if(n.options.useRealPaths)return Yr(e,n);let r=Kt(t),o=1;for(;r!==n.root&&o<2;){let s=n.symlinks.get(r);!!s&&(s===e||s.startsWith(e)||e.startsWith(s))?o++:r=Kt(r)}return n.symlinks.set(t,e),o>1}function Yr(t,e){return e.visited.includes(t+e.options.pathSeparator)}var Zr=t=>t.counts,Vr=t=>t.groups,to=t=>t.paths,eo=t=>t.paths.slice(0,t.options.maxFiles),no=(t,e,n)=>(Dt(e,n,t.counts,t.options.suppressErrors),null),ro=(t,e,n)=>(Dt(e,n,t.paths,t.options.suppressErrors),null),oo=(t,e,n)=>(Dt(e,n,t.paths.slice(0,t.options.maxFiles),t.options.suppressErrors),null),so=(t,e,n)=>(Dt(e,n,t.groups,t.options.suppressErrors),null);function Dt(t,e,n,r){e(t&&!r?t:null,n)}function io(t,e){let{onlyCounts:n,group:r,maxFiles:o}=t;return n?e?Zr:no:r?e?Vr:so:o?e?eo:oo:e?to:ro}var Ye={withFileTypes:!0},uo=(t,e,n,r,o)=>{if(t.queue.enqueue(),r<0)return t.queue.dequeue(null,t);let{fs:s}=t;t.visited.push(e),t.counts.directories++,s.readdir(e||".",Ye,(i,u=[])=>{o(u,n,r),t.queue.dequeue(t.options.suppressErrors?null:i,t)})},ao=(t,e,n,r,o)=>{let{fs:s}=t;if(r<0)return;t.visited.push(e),t.counts.directories++;let i=[];try{i=s.readdirSync(e||".",Ye)}catch(u){if(!t.options.suppressErrors)throw u}o(i,n,r)};function co(t){return t?ao:uo}var lo=class{count=0;constructor(t){this.onQueueEmpty=t}enqueue(){return this.count++,this.count}dequeue(t,e){this.onQueueEmpty&&(--this.count<=0||t)&&(this.onQueueEmpty(t,e),t&&(e.controller.abort(),this.onQueueEmpty=void 0))}},po=class{_files=0;_directories=0;set files(t){this._files=t}get files(){return this._files}set directories(t){this._directories=t}get directories(){return this._directories}get dirs(){return this._directories}},fo=class{aborted=!1;abort(){this.aborted=!0}},Ze=class{root;isSynchronous;state;joinPath;pushDirectory;pushFile;getArray;groupFiles;resolveSymlink;walkDirectory;callbackInvoker;constructor(t,e,n){this.isSynchronous=!n,this.callbackInvoker=io(e,this.isSynchronous),this.root=Xt(t,e),this.state={root:vr(this.root)?this.root:this.root.slice(0,-1),paths:[""].slice(0,0),groups:[],counts:new po,options:e,queue:new lo((r,o)=>this.callbackInvoker(o,r,n)),symlinks:new Map,visited:[""].slice(0,0),controller:new fo,fs:e.fs||xr},this.joinPath=Or(this.root,e),this.pushDirectory=Fr(this.root,e),this.pushFile=qr(e),this.getArray=jr(e),this.groupFiles=Xr(e),this.resolveSymlink=Qr(e,this.isSynchronous),this.walkDirectory=co(this.isSynchronous)}start(){return this.pushDirectory(this.root,this.state.paths,this.state.options.filters),this.walkDirectory(this.state,this.root,this.root,this.state.options.maxDepth,this.walk),this.isSynchronous?this.callbackInvoker(this.state,null):null}walk=(t,e,n)=>{let{paths:r,options:{filters:o,resolveSymlinks:s,excludeSymlinks:i,exclude:u,maxFiles:p,signal:m,useRealPaths:g,pathSeparator:b},controller:f}=this.state;if(f.aborted||m&&m.aborted||p&&r.length>p)return;let y=this.getArray(this.state.paths);for(let S=0;S<t.length;++S){let x=t[S];if(x.isFile()||x.isSymbolicLink()&&!s&&!i){let R=this.joinPath(x.name,e);this.pushFile(R,y,this.state.counts,o)}else if(x.isDirectory()){let R=kr(x.name,e,this.state.options.pathSeparator);if(u&&u(x.name,R))continue;this.pushDirectory(R,r,o),this.walkDirectory(this.state,R,R,n-1,this.walk)}else if(this.resolveSymlink&&x.isSymbolicLink()){let R=ze(x.name,e);this.resolveSymlink(R,this.state,(T,A)=>{if(T.isDirectory()){if(A=Xt(A,this.state.options),u&&u(x.name,g?A:R+b))return;this.walkDirectory(this.state,A,g?A:R+b,n-1,this.walk)}else{A=g?A:R;let G=br(A),Q=Xt(Kt(A),this.state.options);A=this.joinPath(G,Q),this.pushFile(A,y,this.state.counts,o)}})}}this.groupFiles(this.state.groups,e,y)}};function ho(t,e){return new Promise((n,r)=>{Ve(t,e,(o,s)=>{if(o)return r(o);n(s)})})}function Ve(t,e,n){new Ze(t,e,n).start()}function mo(t,e){return new Ze(t,e).start()}var Je=class{constructor(t,e){this.root=t,this.options=e}withPromise(){return ho(this.root,this.options)}withCallback(t){Ve(this.root,this.options,t)}sync(){return mo(this.root,this.options)}},tn=null;try{Ue.resolve("picomatch"),tn=Ue("picomatch")}catch{}var en=class{globCache={};options={maxDepth:1/0,suppressErrors:!0,pathSeparator:Xe,filters:[]};globFunction;constructor(t){this.options={...this.options,...t},this.globFunction=this.options.globFunction}group(){return this.options.group=!0,this}withPathSeparator(t){return this.options.pathSeparator=t,this}withBasePath(){return this.options.includeBasePath=!0,this}withRelativePaths(){return this.options.relativePaths=!0,this}withDirs(){return this.options.includeDirs=!0,this}withMaxDepth(t){return this.options.maxDepth=t,this}withMaxFiles(t){return this.options.maxFiles=t,this}withFullPaths(){return this.options.resolvePaths=!0,this.options.includeBasePath=!0,this}withErrors(){return this.options.suppressErrors=!1,this}withSymlinks({resolvePaths:t=!0}={}){return this.options.resolveSymlinks=!0,this.options.useRealPaths=t,this.withFullPaths()}withAbortSignal(t){return this.options.signal=t,this}normalize(){return this.options.normalizePath=!0,this}filter(t){return this.options.filters.push(t),this}onlyDirs(){return this.options.excludeFiles=!0,this.options.includeDirs=!0,this}exclude(t){return this.options.exclude=t,this}onlyCounts(){return this.options.onlyCounts=!0,this}crawl(t){return new Je(t||".",this.options)}withGlobFunction(t){return this.globFunction=t,this}crawlWithOptions(t,e){return this.options={...this.options,...e},new Je(t||".",this.options)}glob(...t){return this.globFunction?this.globWithOptions(t):this.globWithOptions(t,{dot:!0})}globWithOptions(t,...e){let n=this.globFunction||tn;if(!n)throw new Error("Please specify a glob function to use glob matching.");var r=this.globCache[t.join("\0")];return r||(r=n(t,...e),this.globCache[t.join("\0")]=r),this.options.filters.push(o=>r(o)),this}};var ht=Mn(In(),1),is=Array.isArray,Cn=/\\/g,us=/^[A-Za-z]:$/,$n=process.platform==="win32",as=/^(\/?\.\.)+$/;function cs(t,e={}){let n=t.length,r=Array(n),o=Array(n),s,i;for(s=0;s<n;s++){let u=Tn(t[s]);r[s]=u;let p=u.length,m=Array(p);for(i=0;i<p;i++)m[i]=(0,ht.default)(u[i],e);o[s]=m}return u=>{let p=u.split("/");if(p[0]===".."&&as.test(u))return!0;for(s=0;s<n;s++){let m=r[s],g=o[s],b=p.length,f=Math.min(b,m.length);for(i=0;i<f;){let y=m[i];if(y.includes("/"))return!0;if(!g[i](p[i]))break;if(!e.noglobstar&&y==="**")return!0;i++}if(i===b)return!0}return!1}}var ls=/^[A-Z]:\/$/i,ps=$n?t=>ls.test(t):t=>t==="/";function wn(t,e,n){if(t===e||e.startsWith(`${t}/`)){if(n){let o=t.length+ +!ps(t);return(s,i)=>s.slice(o,i?-1:void 0)||"."}let r=e.slice(t.length+1);return r?(o,s)=>{if(o===".")return r;let i=`${r}/${o}`;return s?i.slice(0,-1):i}:(o,s)=>s&&o!=="."?o.slice(0,-1):o}return n?r=>rt.relative(t,r)||".":r=>rt.relative(t,`${e}/${r}`)||"."}function fs(t,e){if(e.startsWith(`${t}/`)){let n=e.slice(t.length+1);return r=>`${n}/${r}`}return n=>{let r=rt.relative(t,`${e}/${n}`);return n[n.length-1]==="/"&&r!==""?`${r}/`:r||"."}}function kn(t){return t.replace(us,e=>`${e}/`)}var ds={parts:!0};function Tn(t){var e;let n=ht.default.scan(t,ds);return!((e=n.parts)===null||e===void 0)&&e.length?n.parts:[t]}var hs=/(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g,ms=/(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g,gs=t=>t.replace(hs,"\\$&"),bs=t=>t.replace(ms,"\\$&"),ys=$n?bs:gs;function Ss(t,e){if(e?.caseSensitiveMatch===!1)return!0;let n=ht.default.scan(t);return n.isGlob||n.negated}function Rt(...t){console.log(`[tinyglobby ${new Date().toLocaleTimeString("es")}]`,...t)}function Pn(t){return typeof t=="string"?[t]:t??[]}var As=/^(\/?\.\.)+/,xs=/\\(?=[()[\]{}!*+?@|])/g;function ie(t,e,n,r){var o;let s=e.cwd,i=t;t[t.length-1]==="/"&&(i=t.slice(0,-1)),i[i.length-1]!=="*"&&e.expandDirectories&&(i+="/**");let u=ys(s);i=rs(i.replace(xs,""))?rt.relative(u,i):rt.normalize(i);let p=(o=As.exec(i))===null||o===void 0?void 0:o[0],m=Tn(i);if(p){let b=(p.length+1)/3,f=0,y=u.split("/");for(;f<b&&m[f+b]===y[y.length+f-b];)i=i.slice(0,(b-f-1)*3)+i.slice((b-f)*3+m[f+b].length+1)||".",f++;let S=rt.join(s,p.slice(f*3));S[0]!=="."&&n.root.length>S.length&&(n.root=kn(S),n.depthOffset=-b+f)}if(!r&&n.depthOffset>=0){var g;(g=n.commonPath)!==null&&g!==void 0||(n.commonPath=m);let b=[],f=Math.min(n.commonPath.length,m.length);for(let y=0;y<f;y++){let S=m[y];if(S==="**"&&!m[y+1]){b.pop();break}if(y===m.length-1||S!==n.commonPath[y]||Ss(S))break;b.push(S)}n.depthOffset=b.length,n.commonPath=b,n.root=kn(b.length>0?rt.join(s,...b):s)}return i}function Rs(t,e,n){let r=[],o=[];for(let s of t.ignore)s&&(s[0]!=="!"||s[1]==="(")&&o.push(ie(s,t,n,!0));for(let s of e)s&&(s[0]!=="!"||s[1]==="("?r.push(ie(s,t,n,!1)):(s[1]!=="!"||s[2]==="(")&&o.push(ie(s.slice(1),t,n,!0)));return{match:r,ignore:o}}function Es(t,e){let n=t.cwd,r={root:n,depthOffset:0},o=Rs(t,e,r);t.debug&&Rt("internal processing patterns:",o);let{absolute:s,caseSensitiveMatch:i,debug:u,dot:p,followSymbolicLinks:m,onlyDirectories:g}=t,b=r.root.replace(Cn,""),f={dot:p,nobrace:t.braceExpansion===!1,nocase:!i,noextglob:t.extglob===!1,noglobstar:t.globstar===!1,posix:!0},y=(0,ht.default)(o.match,f),S=(0,ht.default)(o.ignore,f),x=cs(o.match,f),R=wn(n,b,s),T=s?R:wn(n,b,!0),A=(F,C)=>{let k=T(C,!0);return k!=="."&&!x(k)||S(k)},G;t.deep!==void 0&&(G=Math.round(t.deep-r.depthOffset));let Q=new en({filters:[u?(F,C)=>{let k=R(F,C),E=y(k)&&!S(k);return E&&Rt(`matched ${k}`),E}:(F,C)=>{let k=R(F,C);return y(k)&&!S(k)}],exclude:u?(F,C)=>{let k=A(F,C);return Rt(`${k?"skipped":"crawling"} ${C}`),k}:A,fs:t.fs,pathSeparator:"/",relativePaths:!s,resolvePaths:s,includeBasePath:s,resolveSymlinks:m,excludeSymlinks:!m,excludeFiles:g,includeDirs:g||!t.onlyFiles,maxDepth:G,signal:t.signal}).crawl(b);return t.debug&&Rt("internal properties:",{...r,root:b}),[Q,n!==b&&!s&&fs(n,b)]}function _s(t,e){if(e)for(let n=t.length-1;n>=0;n--)t[n]=e(t[n]);return t}var On={caseSensitiveMatch:!0,debug:!!process.env.TINYGLOBBY_DEBUG,expandDirectories:!0,followSymbolicLinks:!0,onlyFiles:!0};function vs(t){let e=Object.assign({},t);for(let n in On)e[n]===void 0&&Object.assign(e,{[n]:On[n]});return e.cwd=(e.cwd instanceof URL?ss(e.cwd):os(e.cwd||process.cwd())).replace(Cn,"/"),e.ignore=Pn(e.ignore),e.fs&&(e.fs={readdir:e.fs.readdir||Yo,readdirSync:e.fs.readdirSync||Zo,realpath:e.fs.realpath||Vo,realpathSync:e.fs.realpathSync||ts,stat:e.fs.stat||es,statSync:e.fs.statSync||ns}),e.debug&&Rt("globbing with options:",e),e}function Is(t,e={}){var n;if(t&&e?.patterns)throw new Error("Cannot pass patterns as both an argument and an option");let r=is(t)||typeof t=="string",o=Pn((n=r?t:t.patterns)!==null&&n!==void 0?n:"**/*"),s=vs(r?e:t);return o.length>0?Es(s,o):[]}async function ue(t,e){let[n,r]=Is(t,e);return n?_s(await n.withPromise(),r):[]}var Ln=Object.values(B).flatMap(t=>t.extensions).map(t=>t.slice(1));function Os(t){return/[*?[\]{}]/.test(t)}async function Cs(t,e){let n=e?`**/*.{${Ln.join(",")}}`:`*.{${Ln.join(",")}}`;return(await ue([n],{cwd:t,absolute:!0,onlyFiles:!0,caseSensitiveMatch:!1})).sort()}async function Fn(t,e,n,r){let o=await Cs(t,e);if(o.length===0){n.push({path:t,error:be(t)});return}for(let s of o)await r(s,t,!1)}async function $u(t,e){let n=[],r=[],o=new Map,s=ae(t);return await Fn(s,e.recursive,r,async(i,u)=>{try{n.push(await Mt(i)),o.set(i,u)}catch(p){nt(p)&&r.push({path:i,error:p})}}),{sources:n,failures:r,roots:o}}async function Tu(t,e){let n=[],r=[],o=new Map,s=new Set,i=async(u,p,m)=>{let g=ae(u);if(!s.has(g)){s.add(g);try{n.push(await Mt(g)),p&&o.set(g,p)}catch(b){if(nt(b))r.push({path:g,error:b});else if(m)throw b}}};for(let u of t){let p=ae(u);if(Os(u)&&!ws(p)){let g=await ue([u],{absolute:!0,onlyFiles:!0});g.length===0&&r.push({path:p,error:Nt(p)});for(let b of g.sort())await i(b,void 0,!1);continue}let m;try{m=await ks(p)}catch{r.push({path:p,error:Nt(p)});continue}if(m.isDirectory()){await Fn(p,e.recursive,r,i);continue}await i(p,void 0,!0)}return{sources:n,failures:r,roots:o}}import{homedir as $s}from"node:os";import{isAbsolute as Ts,relative as Ps,sep as Ls}from"node:path";function Dn(t,e){let n=Ps(e,t);if(n==="")return"";if(!(n===".."||n.startsWith(`..${Ls}`)||Ts(n)))return n}function Du(t,e={}){if(e.cwd!==void 0){let r=Dn(t,e.cwd);if(r!==void 0)return r===""?".":r}let n=Dn(t,e.home??$s());return n!==void 0?n===""?"~":`~/${n}`:t}export{Ot as a,xe as b,Bt as c,Jn as d,Xn as e,qt as f,Xs as g,Ee as h,Wt as i,Zs as j,Oe as k,di as l,Te as m,Pe as n,qe as o,Le as p,Si as q,Ai as r,ur as s,Mi as t,Bi as u,je as v,nu as w,$u as x,Tu as y,Du as z};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{access as b,readFile as l}from"node:fs/promises";import{homedir as x}from"node:os";import{join as n}from"node:path";var u="https://github.com/AtharvaN16/forge-terminal/releases/download",p=[{id:"boost",title:"Boost resolution",summary:"Sharpen, or boost resolution 2x or 4x, with a local AI model",version:"1.0.0",minMacos:14,assets:{arm64:{url:`${u}/ext-boost-v1.0.0/forge-ext-boost-1.0.0-arm64.tar.gz`,bytes:14866325,sha256:"7af24c92f95b1cd34618adde4a90926c91a8db4347d640be4921f1dc706a9a2e"}},licence:"Real-ESRGAN general-x4v3 (BSD-3-Clause), ONNX Runtime (MIT)"},{id:"remove-background",title:"Remove background",summary:"Cut the subject out of a photo, on this Mac",version:"1.0.0",minMacos:14,assets:{universal:{url:`${u}/ext-remove-background-v1.0.0/forge-ext-remove-background-1.0.0-universal.tar.gz`,bytes:32489,sha256:"9f6e055c0ce25f7504e10c7871e506a813bc75d6536396a675a8c075c4eb4686"}},licence:"Uses Apple Vision on-device; helper is MIT"}];function f(e){return p.find(t=>t.id===e)}function y(){let e=process.env.XDG_CONFIG_HOME,t=e!==void 0&&e.length>0?e:n(x(),".config");return n(t,"forge","extensions")}var v=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;async function C(e){if(f(e)!==void 0)try{let t=n(y(),e),r=(await l(n(t,"current"),"utf8")).trim();if(!v.test(r))return;let o=n(t,r),i=JSON.parse(await l(n(o,"manifest.json"),"utf8"));if(typeof i!="object"||i===null)return;let{id:m,version:g,entry:s,kind:a,files:d}=i;if(m!==e||g!==r||a!=="node"&&a!=="exec"||typeof s!="string"||typeof d!="object"||d===null||!(s in d))return;let c=n(o,s);return c.startsWith(`${o}/`)?(await b(c),{id:e,version:r,dir:o,entry:c,kind:a}):void 0}catch{return}}export{p as a,f as b,y as c,v as d,C as e};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{b as n,d as f,e as u}from"./chunk-EOYBXOCV.js";import{F as o}from"./chunk-DRBA23IQ.js";var d=["output","theme","quality"];async function c(r){if(r.action==="path")return{stdout:[n()],exitCode:0,config:{path:n()},warnings:[]};if(r.action==="list"){let{prefs:t,warning:i}=await f(),s=[`output ${t.defaultOutput}`,`theme ${t.theme??"not set"}`,`quality ${t.quality}`,"",n()];return i!==void 0&&s.unshift(`\u26A0 ${i}`,""),{stdout:s,exitCode:0,config:{output:t.defaultOutput,theme:t.theme??null,quality:t.quality,path:n()},warnings:i===void 0?[]:[{code:"config-unreadable",message:i}]}}let{key:a,value:e}=r;if(a==="theme"){if(e!=="dark"&&e!=="light")throw o(`Theme must be dark or light, not ${e}.`);return await u({theme:e}),{stdout:[`theme is now ${e}`],exitCode:0,config:{theme:e},warnings:[]}}if(a==="quality"){let t=Number(e);if(!Number.isInteger(t)||t<1||t>100)throw o(`Quality must be a whole number between 1 and 100, not ${e}.`);return await u({quality:t}),{stdout:[`quality is now ${t}`],exitCode:0,config:{quality:t},warnings:[]}}if(e.trim().length===0)throw o("Output must be a folder path.");return await u({defaultOutput:e}),{stdout:[`output is now ${e}`],exitCode:0,config:{output:e},warnings:[]}}export{d as a,c as b};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a}from"./chunk-J7FLFHQJ.js";import{basename as n,dirname as d}from"node:path";var i={jpeg:{id:"jpeg",label:"JPEG",extensions:[".jpg",".jpeg"],hasAlpha:!1,animatable:!1,lossy:!0,hint:"universal",defaultQuality:82},png:{id:"png",label:"PNG",extensions:[".png"],hasAlpha:!0,animatable:!1,lossy:!1,hint:"lossless"},webp:{id:"webp",label:"WebP",extensions:[".webp"],hasAlpha:!0,animatable:!0,lossy:!0,hint:"smaller, modern",defaultQuality:80},avif:{id:"avif",label:"AVIF",extensions:[".avif"],hasAlpha:!0,animatable:!0,lossy:!0,hint:"smallest",defaultQuality:50},heic:{id:"heic",label:"HEIC",extensions:[".heic",".heif"],hasAlpha:!0,animatable:!1,lossy:!0,hint:"Apple photos"},gif:{id:"gif",label:"GIF",extensions:[".gif"],hasAlpha:!0,animatable:!0,lossy:!1,hint:"animation"},tiff:{id:"tiff",label:"TIFF",extensions:[".tif",".tiff"],hasAlpha:!0,animatable:!1,lossy:!1,hint:"archival"},pdf:{id:"pdf",label:"PDF",extensions:[".pdf"],hasAlpha:!1,animatable:!1,lossy:!1,hint:"document"},docx:{id:"docx",label:"DOCX",extensions:[".docx"],hasAlpha:!1,animatable:!1,lossy:!1,hint:"Word document"},doc:{id:"doc",label:"DOC",extensions:[".doc"],hasAlpha:!1,animatable:!1,lossy:!1,hint:"legacy Word"}},h=Object.keys(i);function g(e){return i[e.toLowerCase()]}function f(e){let t=i[e].extensions[0];if(!t)throw new Error(`format ${e} declares no extensions`);return t}var o=class extends Error{code;title;detail;short;hint;shellHint;constructor(t){super(`${t.title}: ${t.detail}`,t.cause===void 0?void 0:{cause:t.cause}),this.name="ForgeError",this.code=t.code,this.title=t.title,this.detail=t.detail,this.short=t.short,this.hint=t.hint,this.shellHint=t.shellHint}};function u(e){return e instanceof o}function y(e){return new o({code:"file-not-found",title:"File not found",detail:`${n(e)} could not be found.`,short:`${n(e)} could not be found.`,hint:"Check the filename and try again."})}function $(e){return new o({code:"not-a-file",title:"Not a file",detail:`${n(e)} is not a file.`,short:`${n(e)} is not a file.`,hint:"Point Forge at an image, or at a directory of images."})}function F(e){return new o({code:"permission-denied",title:"Permission denied",detail:`${n(e)} could not be read.`,short:`${n(e)} could not be read.`,hint:"Check the file permissions and try again."})}function E(e){return new o({code:"not-a-directory",title:"Invalid path",detail:`${n(e)} could not be found: part of its path is not a directory.`,short:`part of ${n(e)}'s path is not a folder.`,hint:"Check the path and try again."})}function v(e){return new o({code:"symlink-loop",title:"Too many symbolic links",detail:`${n(e)} could not be resolved: its path contains a symbolic-link loop.`,short:`${n(e)}'s path loops back on itself.`,hint:"Check for a circular symlink somewhere in the path."})}function k(e){return new o({code:"path-too-long",title:"Path too long",detail:`${n(e)}'s path is too long for the filesystem to resolve.`,short:`${n(e)}'s path is too long.`,hint:"Use a shorter path and try again."})}function C(e,t){return new o({code:"unreadable-path",title:"Could not read path",detail:`${n(e)} could not be checked.`,short:`${n(e)} could not be checked.`,hint:"Check the path and try again.",cause:t})}function I(e,t){return new o({code:"unsupported-source",title:"Unsupported file type",detail:`${n(e)} is ${t}, which Forge cannot read.`,short:`${n(e)} is ${t}, which Forge cannot read.`,hint:"Forge 0.1 handles images only."})}function T(e,t){return new o({code:"unsupported-source",title:"Not an image",detail:`${n(e)} is ${t}, not an image.`,hint:"A palette is taken from a photo, a screenshot or artwork."})}function S(e){return new o({code:"unsupported-source",title:"Nothing to take colours from",detail:`${n(e)} has no visible pixels.`})}function H(e){return new o({code:"heic-decoder-unavailable",title:"Cannot read HEIC here",detail:`${n(e)} is a HEIC photo, which Forge decodes with the macOS sips tool.`,short:"HEIC needs sips, which could not be run.",hint:"sips could not be run. It ships with macOS at /usr/bin/sips."})}function P(e,t){let r=n(e.path);if(t!==void 0&&t!==e.format){let s=i[t].label;return i[t].lossy?new o({code:"unsupported-compress",title:"Cannot fit that to a size",detail:`Forge cannot search ${r} \u2192 ${s} toward a size yet.`,hint:"Convert it first, then compress the result with --max-size.",shellHint:"Convert it first, then /compress the result to a size."}):new o({code:"unsupported-compress",title:"Cannot fit that to a size",detail:`${s} is lossless \u2014 there is no quality to trade away, so ${r} cannot be made to fit as ${s}.`,hint:"Drop --max-size, or choose a lossy target. forge --formats lists them.",shellHint:"Choose a lossy target to aim for a size."})}if(e.kind==="document"&&e.format==="pdf"){let s=e.images?.skipped??0;return new o({code:"unsupported-compress",title:"Nothing to compress",detail:s>0?`${r}'s images are a kind Forge cannot re-encode, so there is nothing to make smaller.`:`${r} has no images \u2014 it is text and layout, which compression cannot shrink.`,hint:"Try a page operation such as --extract to keep fewer pages, or --to <format> to turn its pages into images.",shellHint:"Try /pdf to keep fewer pages, or /convert to turn its pages into images."})}return e.kind==="document"?new o({code:"unsupported-compress",title:"Nothing to compress",detail:`${r} is ${i[e.format].label}, which has no images Forge can re-encode.`,hint:`Use --to pdf to change it to PDF instead: forge ${r} --to pdf`,shellHint:"Use /convert to change it to PDF instead."}):new o({code:"unsupported-compress",title:"Nothing to compress",detail:`${r} is ${i[e.format].label}, which is lossless \u2014 there is no quality to trade away.`,hint:"Use --to to change it to a smaller format instead. forge --formats lists them.",shellHint:"Use /convert to change it to a smaller format instead."})}function D(e){let t=n(e.path);return new o({code:"unsupported-pdf",title:"/pdf needs a PDF",detail:`${t} is ${i[e.format].label}, not a PDF.`,hint:"Converting it instead."})}function A(e,t,r){return new o({code:"unsupported-operation",title:`Cannot ${e} these files`,detail:`Not available for these files: ${t}.`,hint:r??"Page operations work on PDFs: --merge takes two or more, the others take one.",shellHint:r??"Use /pdf with a PDF staged \u2014 two or more for merge."})}function j(e,t,r){return new o({code:"target-unreachable",title:"Cannot get that small",detail:`${n(e.path)} is ${a(r)} even at the lowest quality, which is still over ${a(t)}.`,hint:"Try a larger --max-size, or --to a smaller format.",shellHint:"Try a larger target, or /convert to a smaller format."})}function O(e,t,r){return new o({code:"unsupported-target",title:`Can't convert ${n(e.path)} to ${t}`,detail:`${n(e.path)} is a ${i[e.format].label} ${e.kind==="image"?"image":"document"}.`,hint:`Available: ${r.join(", ")}`})}function N(e,t){return new o({code:"corrupt-source",title:"Damaged file",detail:`${n(e)} could not be read. It may be damaged, or not a format Forge recognises.`,short:`${n(e)} could not be read.`,hint:"The file may be incomplete or corrupted.",cause:t})}function R(e,t,r){return new o({code:"corrupt-source",title:`Damaged ${i[t].label}`,detail:`${n(e)} is a ${i[t].label} file, but its content could not be read.`,short:`${n(e)} could not be read.`,hint:"The file may be incomplete or corrupted.",cause:r})}function U(e,t={}){let r=n(e);return new o({code:"encrypted-source",title:"This PDF is password-protected",detail:`${r} is password-protected.`,short:`${r} is password-protected.`,hint:t.attempted?"That password didn't open it. Check it and try again.":`Convert it to images instead: forge ${r} --to jpeg --password-stdin`})}var l=e=>e==="convert"||e==="boost"||e==="remove-background";function M(e,t="convert"){return new o({code:"output-exists",title:"File already exists",detail:`${n(e)} is already there.`,hint:l(t)?"Pass --force to replace it, or choose a different --output.":"Pass --force to replace it, or move the existing file out of the way.",shellHint:"Run it again and Forge will ask before replacing it."})}function z(e,t){return new o({code:"output-collision",title:"Two files want the same output",detail:`${n(e[0])} and ${n(e[1])} would both become ${n(t)}.`,hint:"Convert them separately, or use --output to send them to different folders.",shellHint:"Convert them one at a time."})}function W(e,t){return new o({code:"output-collision",title:"One output, written twice",detail:`${n(e)} would write ${n(t)} twice, and only the second would survive.`,hint:"Every output has to be its own file. Check the selection for a repeated page."})}function J(e,t="convert"){return new o({code:"output-is-input",title:"Output would replace the original",detail:`${n(e)} is both the input and the output.`,hint:l(t)?"Choose a different --output, or pass --force to overwrite in place.":"Move or rename that file first, or pass --force to overwrite it in place.",shellHint:l(t)?"Choose a different folder to save it in.":"Move or rename that file first."})}function c(e,t){return new o({code:"permission-denied",title:"Permission denied",detail:`${n(d(e))} is not a folder you can write to.`,hint:"Choose a different --output, or check the folder permissions.",shellHint:"Choose a different folder, or check its permissions.",cause:t})}var p=new Set(["EACCES","EPERM","EROFS"]);function L(e,t){if(u(t))return t;let r=t?.code;return r!==void 0&&p.has(r)?c(e,t):t}function _(e,t){return new o({code:"output-invalid",title:"Cannot write there",detail:`${e} could not be written to.`,hint:"Check that the path is valid and that you have permission to write to it.",cause:t})}function B(e){return new o({code:"empty-directory",title:"No images found",detail:`${n(e)} contains no images Forge can convert.`,hint:"Try --recursive to look inside subfolders.",shellHint:"Only files directly inside a folder are read \u2014 drop the files themselves, or the folder that holds them."})}function G(e,t){return new o({code:"invalid-arguments",title:"Invalid arguments",detail:e,hint:t})}function q(e,t,r){return new o({code:"invalid-page-range",title:"Page range not understood",detail:t,hint:`This document has ${r} pages. Use numbers and spans, like "3-7, 12, 20-".`})}function Q(e){return new o({code:"empty-selection",title:"Nothing to write",detail:e,hint:"Select at least one page to keep."})}function V(e){return new o({code:"invalid-dpi",title:"Invalid resolution",detail:`${String(e)} is not a resolution Forge can use.`,hint:"Give a number between 36 and 600. The default is 150."})}function X(e){return new o({code:"extension-missing",title:"Extension not installed",detail:`${e} is an optional extension and is not installed.`,hint:`Install it with: forge extensions add ${e}`,shellHint:"Open /extensions to install it."})}function Y(e,t){return new o({code:"extension-corrupt",title:"Extension failed verification",detail:`${e}: ${t}`,hint:`Nothing was installed. Try again with: forge extensions add ${e}`,shellHint:"Nothing was installed. Try again from /extensions."})}function K(e,t){return new o({code:"extension-unsupported",title:"Extension not available here",detail:`${e} cannot be installed on this Mac: ${t}`,hint:"See what is available with: forge extensions",shellHint:"See what is available in /extensions."})}function Z(e,t){return new o({code:"extension-download-failed",title:"Download failed",detail:`${e}: ${t}`,hint:`Check your connection (and HTTPS_PROXY if you use a proxy), then run: forge extensions add ${e}`,shellHint:"Check your connection, then try again from /extensions."})}function ee(e,t){return new o({code:"extension-download-failed",title:"Not enough disk space",detail:`${e}: ${t}`,hint:`Free some disk space, then run: forge extensions add ${e}`,shellHint:"Free some disk space, then try again from /extensions."})}function te(e,t,r){let s=t?t.what?`${t.what} (forge, pid ${t.pid})`:`another forge (pid ${t.pid}) is using it`:"another forge is using it";return new o({code:"extension-in-use",title:"Extension in use",detail:`${e} is in use: ${s}.`,hint:r==="remove"?`Wait for that job to finish, then run: forge extensions remove ${e}`:"Wait for that job to finish, then try again.",shellHint:r==="remove"?"It can be removed when that job finishes.":"Try again when that job finishes."})}function oe(e){return new o({code:"no-subject",title:"No subject found",detail:`${n(e)} has no clear subject to cut out.`,hint:"Try a photo where the subject stands apart from the background."})}function ne(e,t,r){return r===1?new o({code:"boost-too-large",title:"Too large to sharpen",detail:`${n(e)} is too large to sharpen.`,hint:"Sharpen works on images up to 16,384 px a side and 100 megapixels."}):new o({code:"boost-too-large",title:"Too large to boost",detail:t>=2?`${n(e)} is too large to boost that far; ${t}x is the most it can take.`:`${n(e)} is already too large to boost.`,hint:t>=2?`Try --boost ${t}.`:"Boost works on images up to 100 megapixels.",shellHint:t>=2?`Choose ${t}x instead.`:void 0})}function re(e,t){return new o({code:"conversion-failed",title:"Conversion failed",detail:`${n(e)} could not be converted.`,hint:"Run again with --debug for the underlying error.",shellHint:"Run the same conversion with forge --debug from the command line to see why.",cause:t})}function ie(e){return new o({code:"unexpected",title:"Something went wrong",detail:e instanceof Error?e.message:String(e),hint:"This was not expected. Try again \u2014 if it keeps happening, it may be worth reporting.",cause:e})}function se(e,t={}){let r=[`\u2715 ${e.title}`,"",` ${e.detail}`];return e.hint&&r.push("",` ${e.hint}`),t.debug&&e.cause instanceof Error&&r.push("",` ${e.cause.stack??e.cause.message}`),r}export{i as a,g as b,f as c,u as d,y as e,$ as f,F as g,E as h,v as i,k as j,C as k,I as l,T as m,S as n,H as o,P as p,D as q,A as r,j as s,O as t,N as u,R as v,U as w,M as x,z as y,W as z,J as A,c as B,L as C,_ as D,B as E,G as F,q as G,Q as H,V as I,X as J,Y as K,K as L,Z as M,ee as N,te as O,oe as P,ne as Q,re as R,ie as S,se as T};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{mkdir as g,readFile as d,rename as p,unlink as h,writeFile as m}from"node:fs/promises";import{homedir as o}from"node:os";import{dirname as y,join as f}from"node:path";var u={defaultOutput:"~/Desktop",quality:80};function c(){let e=process.env.XDG_CONFIG_HOME,t=e!==void 0&&e.length>0?e:f(o(),".config");return f(t,"forge","config.json")}function E(e){return e==="~"?o():e.startsWith("~/")?f(o(),e.slice(2)):e}function l(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function O(e){let t={...u},r=[];if(e.theme!==void 0&&(e.theme==="dark"||e.theme==="light"?t.theme=e.theme:r.push("theme")),e.defaultOutput!==void 0&&(typeof e.defaultOutput=="string"&&e.defaultOutput.trim().length>0?t.defaultOutput=e.defaultOutput:r.push("defaultOutput")),e.quality!==void 0){let n=e.quality;typeof n=="number"&&Number.isInteger(n)&&n>=1&&n<=100?t.quality=n:r.push("quality")}return{prefs:t,rejected:r}}async function P(){let e;try{e=await d(c(),"utf8")}catch{return}try{let t=JSON.parse(e);return l(t)?t:void 0}catch{return}}async function N(){let e=c(),t;try{t=await d(e,"utf8")}catch(s){return s.code==="ENOENT"?{prefs:u}:{prefs:u,warning:`Could not read the config at ${e} \u2014 using defaults.`}}let r;try{r=JSON.parse(t)}catch{return{prefs:u,warning:`The config at ${e} is not valid JSON \u2014 using defaults.`}}if(!l(r))return{prefs:u,warning:`The config at ${e} is not an object \u2014 using defaults.`};let{prefs:n,rejected:i}=O(r);return i.length===0?{prefs:n}:{prefs:n,warning:`Ignored invalid config ${i.length===1?"setting":"settings"}: ${i.join(", ")}.`}}async function j(e){let t=c();await g(y(t),{recursive:!0});let n={...await P()??{}};for(let[s,a]of Object.entries(e))a!==void 0&&(n[s]=a);let i=`${t}.${process.pid}.tmp`;try{await m(i,`${JSON.stringify(n,null,2)}
|
|
4
|
+
`,"utf8"),await p(i,t)}catch(s){throw await h(i).catch(()=>{}),s}}export{u as a,c as b,E as c,N as d,j as e};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{F as u,a as s}from"./chunk-DRBA23IQ.js";function d(e){if(s[e].hasAlpha)return;let t=Object.keys(s).filter(r=>s[r].hasAlpha&&r!=="heic").join(", ");return u(`${s[e].label} cannot hold transparency, so a cutout cannot be saved as one.`,`Choose a format that can: ${t}.`)}var a=16384,i=1e8;function f(e,t,r){let n=Math.max(e,t)*r;if(n>a)return{side:n};let o=e*r*t*r;if(o>i)return{megapixels:Math.round(o/1e6)}}function c(e){switch(e.op){case"convert":return e.target===e.sources[0].format?"compressed":"converted";case"merge":return"merged";case"split":return"split";case"extract":return"extracted";case"delete":return"deleted from";case"rotate":return"rotated";case"boost":return e.scale===1?"sharpened":"boosted";case"remove-background":return"cut out";default:{let t=e;throw new Error(`describeResult has no verb for ${JSON.stringify(t)}`)}}}function l(e){let{job:t}=e,r=t.sources.map(o=>({path:o.path,bytes:o.bytes})),n=r.length===1&&t.outputs.length===1?r[0]:void 0;return{verb:c(t),sources:r,outputs:[...t.outputs],outputBytes:e.outputBytes,...n?{size:{from:n.bytes,to:e.outputBytes}}:{},warnings:e.warnings}}export{d as a,a as b,f as c,l as d};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{b as C,c as I,d as X,e as Z,f as $,g as _,h as ee,i as R,k,l as te,m as re,n as oe,q as se,r as ne,s as ae,t as ue,u as ie,w as x,y as m,z as P}from"./chunk-4YHKTP7I.js";import{f as U}from"./chunk-L2WK7CJG.js";import{c as L,d as V,e as H,f as Y,g as K,h as Q}from"./chunk-VB665HTV.js";import{a as G}from"./chunk-FQV57RMH.js";import{a as l}from"./chunk-V4GHQGQM.js";import{F as D,G as W,J as q,T as z,a as v,d as w,p as M,r as O,t as A,w as E}from"./chunk-DRBA23IQ.js";import{a as f,b as T}from"./chunk-J7FLFHQJ.js";import{readFile as ke}from"node:fs/promises";import{basename as Fe,dirname as xe,resolve as Se}from"node:path";async function pe(e){let r=[],t=[...e.resolved.failures];for(let o of e.resolved.sources){let s=I(o);if(!s.includes(e.target)){t.push({path:o.path,error:A(o,e.target,s)});continue}let a=R({sourcePath:o.path,target:e.target,output:e.output,sourceRoot:e.resolved.roots.get(o.path)});r.push({op:"convert",sources:[o],outputs:[a],target:e.target,options:e.options})}return{jobs:r,failures:t}}import{resolve as Pe}from"node:path";function ve(e,r=new Set){let t={path:Pe(e.path),kind:e.kind,format:e.format,bytes:e.bytes},o=e.kind==="document"&&e.encrypted===!0,s={targets:I(e).filter(a=>!o||$(a)),actions:ue([e],r).filter(a=>!o||a.id===k.id).map(a=>a.id)};return e.kind==="image"?{...t,width:e.width,height:e.height,...s}:{...t,pages:e.pages,encrypted:e.encrypted,...s}}async function ce(e){let r=await m(e,{recursive:!1}),{installedExtensionIds:t}=await import("./available-2VX7K7W6.js"),o=await t();return{probes:r.sources.map(s=>ve(s,o)),failures:r.failures}}import{basename as F,dirname as Ie}from"node:path";var S=e=>({cwd:e.cwd??process.cwd(),...e.home===void 0?{}:{home:e.home}});function de(e,r){let t=P(Ie(e),S(r));return t==="."?"":` in ${t.endsWith("/")?t:`${t}/`}`}function fe(e,r){let{pct:t,direction:o}=T(e,r);return o==="same"?"same size":`${t}% ${o}`}function le(e,r={}){let t=e.results[0];if(!t)return[];let o=t.job.sources[0],s=t.job.outputs;if(s.length>1){let n=[`\u2713 ${F(o.path)} \u2192 ${s.length} files${de(s[0],r)}`,` ${s.map(u=>F(u)).join(", ")}`,` ${f(o.bytes)} \u2192 ${f(t.outputBytes)} total`];for(let u of t.warnings)n.push("",`\u26A0 ${u.message}`);return n}let a=[`\u2713 ${F(o.path)} \u2192 ${P(s[0],S(r))}`,` ${f(o.bytes)} \u2192 ${f(t.outputBytes)} \xB7 ${fe(o.bytes,t.outputBytes)}`];for(let n of t.warnings)a.push("",`\u26A0 ${n.message}`);return a}function me(e,r={}){let t=[`\u2713 ${e.results.length} converted`,` ${f(e.inputBytes)} \u2192 ${f(e.outputBytes)} \xB7 ${fe(e.inputBytes,e.outputBytes)}`];for(let s of e.results)for(let a of s.job.outputs)t.push(` ${P(a,S(r))}`);let o=e.results.flatMap(s=>s.warnings);if(o.length>0){t.push("");for(let s of o)t.push(`\u26A0 ${s.message}`)}return t}function ge(e,r={}){let t=e.results.flatMap(i=>i.job.outputs),o=t.map(i=>F(i)).join(", "),s=t.length===1?"file":"files",a=t[0]===void 0?"":de(t[0],r),n=[`\u2713 ${t.length} ${s} \xB7 ${o}${a}`],u=e.results.flatMap(i=>i.warnings);for(let i of u)n.push("",`\u26A0 ${i.message}`);return n}function j(e,r){if(e.length===0)return[];let t=[];for(let o of e)t.push(...z(o.error,{debug:r.debug}),"");return t}function he(){let e=new Set(X()),r=new Set(Z()),t=["Formats",""];for(let s of e){let a=v[s],n=r.has(s)?"read and write":"read only";t.push(` ${a.label.padEnd(6)} ${a.extensions.join(" ").padEnd(12)} ${n}`)}let o=[...e].filter(s=>!r.has(s)).map(s=>v[s].label);if(o.length>0){let s=o.join(", "),[a,n]=o.length===1?["is","it"]:["are","them"];t.push("",`${s} ${a} read only because Forge cannot yet write ${n}.`)}return t}function ye(e,r={}){let t=[v[e.format].label,f(e.bytes)];return e.width!==void 0&&e.height!==void 0&&t.push(`${e.width}\xD7${e.height}`),e.pages!==void 0&&t.push(`${e.pages} ${e.pages===1?"page":"pages"}`),e.encrypted&&t.push("password-protected"),[`${P(e.path,S(r))} \xB7 ${t.join(" \xB7 ")}`,` converts to ${e.targets.join(", ")}`,` actions ${e.actions.join(", ")}`]}import{createInterface as be}from"node:readline";import{PassThrough as $e}from"node:stream";function Re(e){return new Promise(r=>{let t=be({input:e,terminal:!1}),o=!1,s=a=>{if(o)return;o=!0,t.close(),e.pause(),e.unref?.(),r(a.replace(/\r$/,""))};t.once("line",s),t.once("close",()=>s(""))})}async function we(e){if(e.stdin)return Re(process.stdin);if(!process.stdin.isTTY)return;let r=new $e,t=be({input:process.stdin,output:r,terminal:!0});try{return process.stderr.write("Password: "),await new Promise(o=>t.question("",o))}finally{process.stderr.write(`
|
|
4
|
+
`),t.close()}}function J(e){return e.length===0?0:e.some(r=>r.error.code==="invalid-arguments")?2:1}function je(e,r){if(e.action==="merge")return{};if(e.action==="rotate")return{degrees:e.rotate};if(e.action==="extract")return{pages:e.pages,separate:e.separate?"many":"one"};if(e.action==="delete")return{pages:e.pages};let t=r.find(n=>n.kind==="document"),o=t?.pages??0,s=e.split;if(!s)throw D("--split needs a mode: every-page, every=N or at=N,N.");if(s.mode==="every-page")return{cuts:se(o)};if(s.mode==="every-n")return{cuts:ne(o,s.n)};let a=Math.max(o-1,0);for(let n of s.after)if(!Number.isInteger(n)||n<1||n>a)throw W(String(n),`"${n}" is outside 1 and ${a} \u2014 ${t?Fe(t.path):"the document"} has ${o} pages.`,o);return{cuts:s.after.map(n=>n-1)}}function Be(e,r){let t;return()=>r?(t??=we({stdin:e}).then(o=>e&&o===""?void 0:o),t):Promise.resolve(void 0)}async function Oe(e,r,t,o){let s;if(e.encrypted){if(s=r.password??await t(),s===void 0)return{failure:{path:e.path,error:E(e.path)}};let u;try{u=await U(await ke(e.path),s)}catch{return{failure:{path:e.path,error:E(e.path,{attempted:!0})}}}u.destroy()}let a;try{a=k.plan([e],{target:r.target,background:r.options.background,keepMetadata:r.options.keepMetadata,dpi:String(r.dpi??150),...r.options.quality===void 0?{}:{quality:r.options.quality},...r.pages===void 0?{}:{pages:r.pages},...r.output===void 0?{}:{destination:r.output},...o===void 0?{}:{sourceRoot:o}})}catch(u){if(!w(u))throw u;return{failure:{path:e.path,error:u}}}let n=a[0];if(n?.op!=="convert")throw new Error(`convertAction.plan() did not return a convert job for ${e.path}`);return s!==void 0&&(n.options.password=s),{job:n}}function N(e,r){return t=>{if(t.type==="search:attempt"){r||e.onSearch?.(t.rung.dpi===void 0?`attempt ${t.attempt} of ${t.of}`:`${t.rung.dpi} dpi \xB7 attempt ${t.attempt} of ${t.of}`);return}if(t.type==="search:settled"){r&&e.onSearch?.(`${t.completed} of ${t.total} searched`);return}r&&(t.type==="job:done"||t.type==="job:error")&&e.onProgress?.({completed:t.completed,total:t.total})}}var y=(e,r)=>({kind:e,results:[],failures:r,inputBytes:0,outputBytes:0});async function Ee(e){let r=await m(e.inputs,{recursive:!1});if(r.sources.length===0)return y("pageop",r.failures);let t=ae.find(n=>n.id===e.action);if(!t)throw new Error(`no action registered for "${e.action}"`);let o=r.sources[0]?.path??"";if(!t.appliesTo(r.sources)){let n=ie(t,r.sources)??"not available for these files";return y("pageop",[...r.failures,{path:o,error:O(e.action,n)}])}let s;try{s=t.plan(r.sources,je(e,r.sources))}catch(n){if(!w(n))throw n;return y("pageop",[...r.failures,{path:o,error:n}])}let a=await x(s,{force:e.force});return{kind:"pageop",results:a.results,failures:[...r.failures,...a.refusals,...a.failures],inputBytes:a.inputBytes,outputBytes:a.outputBytes}}async function Ce(e,r){let t=await m(e.inputs,{recursive:e.recursive}),o=[],s=[];for(let u of t.sources){if(!C.appliesTo([u])){s.push({path:u.path,error:M(u)});continue}let i=e.output!==void 0&&!ee(e.output)?Se(e.output):void 0,g=e.output===void 0||i!==void 0?xe(u.path):xe(R({sourcePath:u.path,target:u.format,output:e.output,sourceRoot:t.roots.get(u.path)})),[p]=C.plan([u],{mode:e.maxBytes===void 0?"quality":"size",...e.quality===void 0?{}:{quality:e.quality},destination:g});p?.op==="convert"&&(i!==void 0&&(p.outputs=[i]),e.dpi!==void 0&&(p.options.dpi=e.dpi),o.push(p))}let a=o.length>1;a&&r.onProgress?.({completed:0,total:o.length});let n=await x(o,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},onEvent:N(r,a)});return{kind:"compress",results:n.results,failures:[...t.failures,...s,...n.refusals,...n.unreachable.map(u=>({path:u.job.sources[0].path,error:u.error})),...n.failures],inputBytes:n.inputBytes,outputBytes:n.outputBytes}}async function Je(e,r){let t=e.kind,o=e.op==="remove-background"?G(e.target):void 0;if(o)return y(t,[{path:"",error:o}]);let{installed:s}=await import("./paths-XY2345OS.js");if(!await s(e.op))return y(t,[{path:"",error:q(e.op)}]);let a=await m(e.inputs,{recursive:e.recursive}),n=e.op==="boost"?re:oe,u=[],i=[];for(let d of a.sources){if(!n.appliesTo([d])){i.push({path:d.path,error:O(e.op,"it works on images, not documents","Try an image such as a JPEG, PNG, WebP or HEIC file.")});continue}let b=te(d,e.target);if(b){i.push({path:d.path,error:b});continue}u.push(...n.plan([d],{target:e.target,background:e.options.background,keepMetadata:e.options.keepMetadata,...e.scale===void 0?{}:{scale:e.scale},...e.options.quality===void 0?{}:{quality:e.options.quality},...e.output===void 0?{}:{output:e.output},roots:a.roots}))}let g=u.length>1;g&&r.onProgress?.({completed:0,total:u.length});let p=await x(u,{force:e.force,concurrency:1,...r.signal===void 0?{}:{signal:r.signal},onEvent:N(r,g)});return{kind:t,results:p.results,failures:[...a.failures,...i,...p.refusals,...p.failures],inputBytes:p.inputBytes,outputBytes:p.outputBytes}}async function Ne(e,r){let t=await m(e.inputs,{recursive:e.recursive}),o=c=>c.kind==="document"&&c.format==="pdf",s=$(e.target),a=s?t.sources.filter(o):[],n=s?t.sources.filter(c=>!o(c)):t.sources,u=[],i=[],g=Be(e.passwordStdin??!1,r.interactive??!0);for(let c of a){let B=await Oe(c,e,g,t.roots.get(c.path));"failure"in B?i.push(B.failure):u.push(B.job)}let p=await pe({resolved:{sources:n,failures:[],roots:t.roots},target:e.target,options:e.options,force:e.force,...e.output===void 0?{}:{output:e.output}}),d=[...p.jobs,...u],b=d.length>1;b&&r.onProgress?.({completed:0,total:d.length});let h=await x(d,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},onEvent:N(r,b)});return{kind:"convert",results:h.results,failures:[...t.failures,...i,...p.failures,...h.refusals,...h.unreachable.map(c=>({path:c.job.sources[0].path,error:c.error})),...h.failures],inputBytes:h.inputBytes,outputBytes:h.outputBytes}}async function Te(e,r={}){try{return e.kind==="pageop"?await Ee(e):e.kind==="extension-op"?await Je(e,r):e.kind==="compress"?await Ce(e,r):await Ne(e,r)}catch(t){if(!w(t))throw t;return y(e.kind,[{path:"",error:t}])}}function Me(e,r){let t=J(e.failures);if(r.json)return{exitCode:t,stdout:[JSON.stringify(L(l,e))],stderr:[]};let o=e.results.length===0?[]:e.kind==="pageop"?ge(e):e.results.length===1?le(e):me(e);return{exitCode:t,stdout:o,stderr:j(e.failures,{debug:r.debug})}}function Ae(e,r){let t=[{path:"",error:e}],o=J(t);return r.json?{exitCode:o,stdout:[JSON.stringify(V(l,e))],stderr:[]}:{exitCode:o,stdout:[],stderr:j(t,{debug:r.debug})}}async function De(e,r){let{runConfig:t}=await import("./config-command-UXJY623L.js"),o=await t(e);return r?{exitCode:0,stdout:[JSON.stringify(K(l,o.config,o.warnings))],stderr:[]}:{exitCode:0,stdout:o.stdout,stderr:[]}}async function It(e,r={}){let t=r.json??!1,o="debug"in e?e.debug:!1;try{if(e.kind==="config")return await De(e,t);if(e.kind==="extensions"){let{runExtensions:s}=await import("./extensions-command-6WZV2AES.js"),a=await s(e,{onDownload:r.onDownload});return{exitCode:0,stdout:t?[JSON.stringify(Q(l,a.data))]:a.stdout,stderr:[]}}if(e.kind==="formats")return t?{exitCode:0,stdout:[JSON.stringify(H(l,_()))],stderr:[]}:{exitCode:0,stdout:he(),stderr:[]};if(e.kind==="probe"){let{probes:s,failures:a}=await ce(e.inputs),n=J(a);return t?{exitCode:n,stdout:[JSON.stringify(Y(l,{probes:s,failures:a}))],stderr:[]}:{exitCode:n,stdout:s.flatMap((u,i)=>[...i>0?[""]:[],...ye(u)]),stderr:j(a,{debug:o})}}if(e.kind==="palette"||e.kind==="scale"){let{runPalette:s,runScale:a}=await import("./colour-QV2C3R7R.js"),n={json:t,colour:r.colour??!1};return e.kind==="palette"?await s(e,n):await a(e,n)}return e.kind==="shell"?{exitCode:0,stdout:[],stderr:[]}:Me(await Te(e,r),{json:t,debug:o})}catch(s){if(!w(s))throw s;return Ae(s,{json:t,debug:o})}}export{ce as a,J as b,Te as c,Me as d,It as e};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
function o(n){let[e,r]=n>=1e9?[n/1e9,"GB"]:n>=1e6?[n/1e6,"MB"]:n>=1e3?[n/1e3,"KB"]:[n,"B"];return r==="B"?`${Math.round(e)} B`:`${e>=100?Math.round(e).toString():(Math.round(e*10)/10).toString()} ${r}`}function c(n,e){if(n===e)return{pct:0,direction:"same"};if(n===0)return{pct:0,direction:"larger"};let r=(n-e)/n*100;return{pct:Math.round(Math.abs(r)*10)/10,direction:r>0?"smaller":"larger"}}var i={b:1,kb:1e3,mb:1e6,gb:1e9},u={b:"B",kb:"KB",mb:"MB",gb:"GB"};function s(n){if(d(n)===void 0)return;let e=/^\s*(\d+(?:\.\d+)?)\s*(b|kb|mb|gb)?\s*$/i.exec(n);if(e)return`${Number(e[1])} ${u[(e[2]??"b").toLowerCase()]}`}function d(n){let e=/^\s*(\d+(?:\.\d+)?)\s*(b|kb|mb|gb)?\s*$/i.exec(n);if(!e)return;let r=Number(e[1]);if(!Number.isFinite(r)||r<=0)return;let t=i[(e[2]??"b").toLowerCase()];if(t!==void 0)return Math.round(r*t)}export{o as a,c as b,s as c,d};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{c as me}from"./chunk-FQV57RMH.js";import{B as pe,C as D,D as fe,G as R,H as C,J as de,Q as ue,R as S,a as l,d as E,e as te,f as re,g as M,h as oe,i as ne,j as ae,k as ie,l as se,o as T,u as ce,v as _,w as v}from"./chunk-DRBA23IQ.js";import{readFile as It,rm as Dt}from"node:fs/promises";import{randomBytes as Ge}from"node:crypto";import{constants as Ue}from"node:fs";import{access as Ke,mkdir as Ve,rename as Ze,rm as Qe,writeFile as Ye}from"node:fs/promises";import{dirname as Xe}from"node:path";async function $(e){let t=Xe(e);try{await Ve(t,{recursive:!0})}catch(r){let o=D(e,r);throw o===r?fe(e,r):o}try{await Ke(t,Ue.W_OK)}catch(r){throw pe(e,r)}}async function m(e,t){await $(e);let r=`${e}.${Ge(6).toString("hex")}.tmp`;try{return await Ye(r,t),await Ze(r,e),t.byteLength}catch(o){throw await Qe(r,{force:!0}).catch(()=>{}),D(e,o)}}import{randomBytes as pt}from"node:crypto";import{constants as ft}from"node:fs";import{access as dt,readFile as Ee,rename as ut,rm as mt,stat as gt,writeFile as lt}from"node:fs/promises";import{basename as ve,dirname as wt,join as ht}from"node:path";import{execFile as je}from"node:child_process";import{randomBytes as et}from"node:crypto";import{open as tt,rm as rt}from"node:fs/promises";import{tmpdir as ot}from"node:os";import{join as nt}from"node:path";import{promisify as at}from"node:util";var H=at(je),A;async function k(){if(A!==void 0)return A;try{await H("/usr/bin/sips",["--help"],{timeout:5e3}),A=!0}catch{A=!1}return A}async function q(e){let t=nt(ot(),`forge-heic-${et(8).toString("hex")}.png`),r=async()=>{await rt(t,{force:!0}).catch(()=>{})};try{return await H("/usr/bin/sips",["-s","format","png",e,"--out",t],{timeout:12e4}),{path:t,cleanup:r}}catch(o){throw await r(),o}}var it=new Set(["heic","heix","hevc","hevx","heim","heis","mif1","msf1"]),st=new Set(["avif","avis"]);async function ge(e){let t;try{t=await tt(e,"r")}catch{return!1}try{let r=Buffer.alloc(64),{bytesRead:o}=await t.read(r,0,64,0);if(o<12||r.toString("latin1",4,8)!=="ftyp")return!1;let n=Math.min(r.readUInt32BE(0),o),a=[];for(let i=8;i+4<=n;i+=4)a.push(r.toString("latin1",i,i+4));return a.some(i=>st.has(i))?!1:a.some(i=>it.has(i))}catch{return!1}finally{await t.close().catch(()=>{})}}async function le(e){let{stdout:t}=await H("/usr/bin/sips",["-g","pixelWidth","-g","pixelHeight","-g","hasAlpha",e],{timeout:3e4});return{width:Number(/pixelWidth:\s*(\d+)/.exec(t)?.[1]??0),height:Number(/pixelHeight:\s*(\d+)/.exec(t)?.[1]??0),hasAlpha:/hasAlpha:\s*yes/i.test(t)}}function w(e){let t;return()=>(t??=e(),t)}var h=w(async()=>(await import("sharp")).default),y=w(()=>import("./es-T2U7NBLD.js")),we=w(()=>import("@hyzyla/pdfium")),he=w(async()=>(await import("./lib-TPEJ5CJJ.js")).default),ye=w(async()=>(await import("./word-OGQ2KZAJ.js")).default),xe=w(async()=>(await import("./adm-zip-SQKLKBDP.js")).default),Pe=w(async()=>(await import("./cfb-V6M2PYOD.js")).default);async function ct(){let e=Object.getOwnPropertyDescriptor(globalThis,"localStorage");if(!e?.configurable)return import("./dist-J2V6ITHG.js");Object.defineProperty(globalThis,"localStorage",{value:void 0,configurable:!0,enumerable:e.enumerable??!1,writable:!0});try{return await import("./dist-J2V6ITHG.js")}finally{Object.defineProperty(globalThis,"localStorage",e)}}var be=w(ct);var yt=new Set(["jpeg","png","webp","avif","heic","gif","tiff"]),xt=new Set(["jpeg","png","webp","avif","gif","tiff"]),Pt={jpeg:"jpeg",png:"png",webp:"webp",gif:"gif",tiff:"tiff"};function bt(e,t){if(t.format==="heif")return t.compression==="av1"?"avif":"heic";let r=Pt[t.format??""];if(!r)throw se(e,t.format??"an unknown format");return r}async function Et(e){let t;try{t=await gt(e)}catch(n){let a=n.code;throw a==="ENOENT"?te(e):a==="EACCES"||a==="EPERM"?M(e):a==="ENOTDIR"?oe(e):a==="ELOOP"?ne(e):a==="ENAMETOOLONG"?ae(e):ie(e,n)}if(!t.isFile())throw re(e);try{await dt(e,ft.R_OK)}catch{throw M(e)}if(await ge(e)){if(!await k())throw T(e);let n;try{n=await le(e)}catch(a){throw _(e,"heic",a)}if(n.width===0||n.height===0)throw _(e,"heic",void 0);return{kind:"image",path:e,format:"heic",width:n.width,height:n.height,bytes:t.size,hasAlpha:n.hasAlpha,frames:1}}let r=await h(),o;try{o=await r(e).metadata()}catch(n){throw ce(e,n)}return{kind:"image",path:e,format:bt(e,o),width:o.width??0,height:o.height??0,bytes:t.size,hasAlpha:o.hasAlpha??!1,frames:o.pages??1}}function P(e,t,r){let o=r??l[t].defaultQuality;switch(t){case"jpeg":return e.jpeg({quality:o,mozjpeg:!0});case"webp":return e.webp({quality:o});case"avif":return e.avif({quality:o});case"png":return e.png({compressionLevel:9});case"gif":return e.gif();case"tiff":return e.tiff({compression:"deflate"});case"heic":throw new Error("heic is not writable; the capability graph should have prevented this");case"pdf":throw new Error("pdf is not an image target; the capability graph should have prevented this");case"docx":throw new Error("docx is not an image target; the capability graph should have prevented this");case"doc":throw new Error("doc is not an image target; the capability graph should have prevented this")}}async function z(e,t){let r=wt(t);await $(t);let o=ht(r,`.forge-tmp-${pt(6).toString("hex")}-${ve(t)}`);try{return await lt(o,e),await ut(o,t),e.length}catch(n){throw await mt(o,{force:!0}).catch(()=>{}),D(t,n)}}async function B(e,t,r,o,n){if(e.kind!=="image")throw new Error("pipelineFor received a non-image source");if(n===void 0&&e.format==="heic"&&!await k())throw T(e.path);let a=n===void 0&&e.format==="heic"?await q(e.path):void 0,i=async()=>{await a?.cleanup()},c=(await h())(n??a?.path??e.path,o?{animated:!0}:{});return c=c.rotate(),e.hasAlpha&&!l[t].hasAlpha&&(c=c.flatten({background:r.background})),c=r.keepMetadata?c.keepMetadata():c.keepIccProfile(),{pipeline:c,cleanup:i}}async function Se(e,t){let r={background:"#ffffff",keepMetadata:!1},{pipeline:o,cleanup:n}=await B(e,"png",r,!1);try{await o.png({compressionLevel:1}).toFile(t)}finally{await n()}}async function zr(e,t,r){let{pipeline:o,cleanup:n}=await B(e,t,r,!1);try{return await P(o,t,r.quality).toBuffer()}finally{await n()}}async function vt(e,t){if(e.op!=="convert")throw new Error(`image engine cannot ${e.op}`);let r=e.sources[0],o=e.outputs[0];if(r.kind!=="image")throw new Error("the image engine cannot convert a document source");let n=l[e.target],a=[];t({phase:"reading"});let i=r.frames>1,s=i&&n.animatable;i&&!n.animatable&&a.push({code:"animation-flattened",message:`${ve(r.path)} has ${r.frames} frames, and ${n.label} cannot animate. Only the first frame was converted.`}),t({phase:"decoding"});let{pipeline:c,cleanup:p}=await B(r,e.target,e.options,s);try{await $(o),t({phase:"encoding"});let f=await P(c,e.target,e.options.quality).toBuffer();t({phase:"writing"});let u=await z(f,o);return{job:e,outputBytes:u,warnings:a}}catch(f){throw E(f)?f:S(r.path,f)}finally{await p()}}async function St(e){if(e.format!=="heic")return Ee(e.path);if(!await k())throw T(e.path);let t=await q(e.path);try{return await Ee(t.path)}finally{await t.cleanup()}}async function Ft(e){if(e.op!=="convert"||!l[e.target].lossy)return;let t=e.sources[0];if(t.kind!=="image")return;let r=await St(t);return{ladder:[{}],measure:async o=>{let{pipeline:n}=await B(t,e.target,o,!1,r);return(await P(n,e.target,o.quality).toBuffer()).length}}}var Fe={id:"image",reads:yt,writes:xt,ops:new Set(["convert"]),probe:Et,run:vt,measurer:Ft};var Rt=new Set(["pdf"]),At=new Set(["jpeg","png"]),Tt=new Set(["convert"]),Ie;function $t(){return Ie??=we().then(e=>e.PDFiumLibrary.init()),Ie}async function De(e,t){return await(await $t()).loadDocument(e,t)}async function Re(e){let t=await De(e);try{let r=[];for(let o=0;o<t.getPageCount();o++)r.push(t.getPage(o).getText());return r}finally{t.destroy()}}var Ae={id:"pdfium",reads:Rt,writes:At,ops:Tt,probe(){throw new Error("pdfium does not probe; engines/pdf.ts classifies PDFs")},async run(e,t){if(e.op!=="convert")throw new Error(`pdfium cannot ${e.op}`);let r=e.sources[0];if(r.kind!=="document")throw new Error("the pdfium engine can only rasterise a document source");if(r.encrypted&&e.options.password===void 0)throw v(r.path);let o=e.options.dpi??150,n=e.options.pages??Array.from({length:r.pages},(s,c)=>c);if(n.length!==e.outputs.length)throw new Error(`pdfium was given ${n.length} pages but ${e.outputs.length} outputs`);for(let s of n)if(s<0||s>=r.pages)throw new Error(`pdfium was asked for page ${s}, but ${r.path} has ${r.pages} pages`);let a=await h(),i=await De(await It(r.path),e.options.password);try{let s=[],c=0;try{for(let[p,f]of n.entries()){let u=await i.getPage(f).render({scale:o/72,render:"bitmap",transparent:!0}),d=a(u.data,{raw:{width:u.width,height:u.height,channels:4}}).flatten({background:e.options.background}),g=await P(d,e.target,e.options.quality).toBuffer(),x=e.outputs[p];c+=await m(x,g),s.push(x),t({phase:"page",done:p+1,total:n.length})}}catch(p){throw await Promise.all(s.map(f=>Dt(f,{force:!0}))),p}return{job:e,outputBytes:c,warnings:[]}}finally{i.destroy()}}};function jr(e,t){let r=e.split(",").map(a=>a.trim()).filter(a=>a!=="");if(r.length===0)throw R(e,"That selects no pages.",t);let o=new Set,n=(a,i)=>{if(!Number.isInteger(a)||a<1||a>t)throw R(i,`"${i}" is outside 1 and ${t}.`,t);return a};for(let a of r){let i=a.match(/^(\d+)\s*-\s*(\d*)$/);if(i?.[1]!==void 0){let s=n(Number(i[1]),a),c=i[2]===""?t:n(Number(i[2]),a);if(c<s)throw R(a,`"${a}" ends before it starts.`,t);for(let p=s;p<=c;p++)o.add(p-1);continue}if(!/^\d+$/.test(a))throw R(a,`"${a}" is not a page number.`,t);o.add(n(Number(a),a)-1)}return[...o].sort((a,i)=>a-i)}function Te(e){return[...new Set(e)].sort((t,r)=>t-r)}function eo(e){if(e.length===0)return"";let t=[...new Set(e)].sort((a,i)=>a-i),r=[],o=t[0],n=o;for(let a of t.slice(1)){if(a===n+1){n=a;continue}r.push(o===n?`${o+1}`:`${o+1}-${n+1}`),o=a,n=a}return r.push(o===n?`${o+1}`:`${o+1}-${n+1}`),r.join(", ")}function $e(e,t){let r=[...new Set(e)].sort((a,i)=>a-i).filter(a=>a>=0&&a<t-1),o=[],n=0;for(let a of r)o.push({from:n,to:a}),n=a+1;return o.push({from:n,to:t-1}),o}import{mkdtemp as kt,rm as Bt}from"node:fs/promises";import{tmpdir as Lt}from"node:os";import{basename as ke,join as L}from"node:path";var Le=(e,t,r)=>me(e,t,r)===void 0;function Be(e,t,r=Number.POSITIVE_INFINITY){return[4,2].find(o=>o<r&&Le(e,t,o))??0}async function Ot(e,t,r){if(e.op!=="boost"&&e.op!=="remove-background")throw new Error(`the extension engine cannot ${e.op}`);if(r?.aborted)throw r.reason??new Error("aborted");let o=e.sources[0],n=e.outputs[0],a=e.op;if(e.op==="boost"&&!Le(o.width,o.height,e.scale))throw ue(o.path,Be(o.width,o.height),e.scale);let{installed:i,extensionsRoot:s}=await import("./paths-XY2345OS.js"),c=await i(a);if(!c)throw de(a);let{runExtension:p}=await import("./run-N3F4EM7E.js"),f=[];o.frames>1&&f.push({code:"animation-flattened",message:`${ke(o.path)} has ${o.frames} frames. Only the first frame was used.`});let u=await kt(L(Lt(),"forge-ext-"));try{t({phase:"decoding"});let d=L(u,"in.png"),g=L(u,"out.png");await Se(o,d);let x=e.op==="boost"?["--in",d,"--out",g,"--scale",String(e.scale),"--cache",L(s(),"boost","cache")]:[d,g];await p(c,x,{subject:o.path,what:`${Jt(e)} is running on ${ke(o.path)}`,onWait:()=>t({phase:"waiting"}),onStart:()=>t({phase:"encoding"}),...e.op==="boost"?{maxScale:Be(o.width,o.height,e.scale)}:{},...r===void 0?{}:{signal:r}});let N=(await h())(g);l[e.target].hasAlpha||(N=N.flatten({background:e.options.background}));let qe=await P(N,e.target,e.options.quality).toBuffer();t({phase:"writing"});let ze=await z(qe,n);return{job:e,outputBytes:ze,warnings:f}}catch(d){throw E(d)?d:S(o.path,d)}finally{await Bt(u,{recursive:!0,force:!0}).catch(()=>{})}}function Jt(e){return e.op!=="boost"?"Remove background":e.scale===2||e.scale===4?`Boost resolution ${e.scale}\xD7`:"Sharpen"}var Oe={id:"extension",reads:new Set,writes:new Set,ops:new Set(["boost","remove-background"]),probe:()=>Promise.reject(new Error("the extension engine reads no files")),run:Ot};import{readFile as O,rm as Je,stat as Wt}from"node:fs/promises";import{basename as Nt}from"node:path";var U=w(()=>import("./pdf-compress-IMRFBLZF.js")),Mt=new Set(["pdf","jpeg","png","webp","avif","gif","tiff"]),_t=new Set(["pdf"]);async function F(e){return(await y()).PDFDocument.load(await O(e),{ignoreEncryption:!0})}async function Ct(e){let{surveyDocument:t}=await U(),r=await F(e),{size:o}=await Wt(e);return{kind:"document",path:e,format:"pdf",bytes:o,pages:r.getPageCount(),encrypted:r.isEncrypted,images:t(r)}}function I(e){for(let t of e)if(t.encrypted)throw v(t.path)}async function Ht(e,t,r){let o=await h(),n=t.format==="jpeg"||t.format==="png",a=n?(await o(r).metadata()).orientation:void 0;if(n&&(a===void 0||a===1))return t.format==="jpeg"?e.embedJpg(r):e.embedPng(r);if(t.format==="jpeg"){let i=await o(r).rotate().jpeg({quality:l.jpeg.defaultQuality,mozjpeg:!0}).toBuffer();return e.embedJpg(i)}return e.embedPng(await o(r).rotate().png().toBuffer())}async function qt(e,t){let r=e.sources[0];if(r.kind!=="image")throw new Error("the pdf engine cannot embed a document source");let o=[];r.frames>1&&o.push({code:"animation-flattened",message:`${Nt(r.path)} has ${r.frames} frames, and ${l.pdf.label} cannot animate. Only the first frame was converted.`}),t({phase:"reading"});let n=await O(r.path);t({phase:"encoding"});let i=await(await y()).PDFDocument.create(),s=await Ht(i,r,n);i.addPage([s.width,s.height]).drawImage(s,{x:0,y:0,width:s.width,height:s.height}),t({phase:"writing"});let p=await m(e.outputs[0],await i.save());return{job:e,outputBytes:p,warnings:o}}async function zt(e,t){I(e.sources.filter(i=>i.kind==="document"));let o=await(await y()).PDFDocument.create();for(let i of e.sources){t({phase:"reading"});let s=await F(i.path),c=await o.copyPages(s,s.getPageIndices());for(let p of c)o.addPage(p)}t({phase:"writing"});let n=await o.save(),a=await m(e.outputs[0],n);return{job:e,outputBytes:a,warnings:[]}}async function Gt(e,t){let r=e.sources[0];I([r]);let o=await y();t({phase:"reading"});let n=await F(r.path),a=$e(e.cuts,n.getPageCount()),i=[],s=0;try{for(let[c,p]of a.entries()){let f=await o.PDFDocument.create(),u=Array.from({length:p.to-p.from+1},(x,ee)=>p.from+ee),d=await f.copyPages(n,u);for(let x of d)f.addPage(x);let g=e.outputs[c];if(g===void 0)throw new Error(`split produced ${a.length} parts but was given ${e.outputs.length} outputs`);s+=await m(g,await f.save()),i.push(g),t({phase:"page",done:c+1,total:a.length})}}catch(c){throw await Promise.all(i.map(p=>Je(p,{force:!0}))),c}return{job:e,outputBytes:s,warnings:[]}}async function G(e,t){let o=await(await y()).PDFDocument.create(),n=await o.copyPages(e,t);for(let a of n)o.addPage(a);return o.save()}async function Ut(e,t){let r=e.sources[0];if(I([r]),e.pages.length===0)throw C("That extract selects no pages.");t({phase:"reading"});let o=await F(r.path),n=Te(e.pages),a=[],i=0;try{if(e.separate)for(let[s,c]of n.entries()){let p=e.outputs[s];i+=await m(p,await G(o,[c])),a.push(p),t({phase:"page",done:s+1,total:n.length})}else{t({phase:"writing"});let s=e.outputs[0];i=await m(s,await G(o,n)),a.push(s)}}catch(s){throw await Promise.all(a.map(c=>Je(c,{force:!0}))),s}return{job:e,outputBytes:i,warnings:[]}}async function Kt(e,t){let r=e.sources[0];I([r]),t({phase:"reading"});let o=await F(r.path),n=new Set(e.pages),a=o.getPageIndices().filter(s=>!n.has(s));if(a.length===0)throw C("That would delete every page.");t({phase:"writing"});let i=await m(e.outputs[0],await G(o,a));return{job:e,outputBytes:i,warnings:[]}}async function Vt(e,t){let r=e.sources[0];I([r]);let o=await y();t({phase:"reading"});let n=await F(r.path);for(let i of n.getPages()){let c=((i.getRotation().angle+e.turns*90)%360+360)%360;i.setRotation(o.degrees(c))}t({phase:"writing"});let a=await m(e.outputs[0],await n.save());return{job:e,outputBytes:a,warnings:[]}}async function Zt(e,t){let r=e.sources[0];I([r]);let{compressPdf:o}=await U();t({phase:"reading"});let n=await O(r.path);t({phase:"encoding"});let{bytes:a,recompressed:i,skipped:s,fromDpi:c,toDpi:p}=await o(n,{quality:e.options.quality??60,dpi:e.options.dpi??150});t({phase:"writing"});let f=await m(e.outputs[0],a),u=g=>g===1?"":"s",d=[];return i===0&&s===0?d.push({code:"pdf-no-images",message:"This PDF has no images to re-encode, so its size is almost unchanged."}):i===0?d.push({code:"pdf-no-images",message:`None of its ${s} image${u(s)} could be re-encoded \u2014 they are not JPEG data.`}):s>0&&d.push({code:"pdf-images-skipped",message:`${i} image${u(i)} recompressed, ${s} skipped (not JPEG).`}),c!==void 0&&p!==void 0&&d.push({code:"pdf-downsampled",message:`Images reduced from ${c} to ${p} dpi. Pass --dpi ${c} to keep them.`}),{job:e,outputBytes:f,warnings:d}}async function Qt(e){if(e.op!=="convert")return;let t=e.sources[0];if(t.kind!=="document")return;let{compressPdf:r}=await U(),o=await O(t.path);return{ladder:[e.options.dpi??150,120,96,72].map(n=>({dpi:n})),measure:async n=>(await r(o,{quality:n.quality??60,...n.dpi===void 0?{}:{dpi:n.dpi}})).bytes.byteLength}}var We={id:"pdf",measurer:Qt,reads:Mt,writes:_t,ops:new Set(["convert","merge","split","extract","delete","rotate"]),probe:Ct,async run(e,t){switch(e.op){case"convert":if(e.target!=="pdf")throw new Error("the pdf engine only converts to pdf");return e.sources[0].kind==="document"?Zt(e,t):qt(e,t);case"merge":return zt(e,t);case"split":return Gt(e,t);case"extract":return Ut(e,t);case"delete":return Kt(e,t);case"rotate":return Vt(e,t);default:throw new Error(`the pdf engine cannot ${e.op}`)}}};import{execFile as Yt}from"node:child_process";import{mkdtemp as Xt,readFile as Y,rm as jt}from"node:fs/promises";import{tmpdir as er}from"node:os";import{basename as tr,extname as rr,join as Ne}from"node:path";import{promisify as or}from"node:util";var Q=or(Yt),K=Buffer.from([208,207,17,224,161,177,26,225]);async function nr(e){if(e.length<K.length||!e.subarray(0,K.length).equals(K))return!1;let t=await Pe();try{return t.find(t.parse(e),"WordDocument")!==null}catch{return!1}}async function ar(e){let t=await xe();try{let r=new t(e);if(!r.getEntry("word/document.xml"))return;let o=0,n=r.getEntry("docProps/app.xml");if(n){let a=/<Pages>(\d+)<\/Pages>/.exec(r.readAsText(n));a?.[1]&&(o=Number(a[1]))}return{pages:o}}catch{return}}async function ir(e){let t=await Y(e),r=await ar(t);if(r)return{kind:"document",path:e,format:"docx",bytes:t.byteLength,pages:r.pages,encrypted:!1};if(await nr(t))return{kind:"document",path:e,format:"doc",bytes:t.byteLength,pages:0,encrypted:!1};throw new Error(`${e} is not a Word document`)}var Me="/Applications/LibreOffice.app/Contents/MacOS/soffice",sr=0;async function cr(){sr++;try{return await Q("soffice",["--version"],{timeout:5e3}),"soffice"}catch{}try{return await Q(Me,["--version"],{timeout:5e3}),Me}catch{return}}var _e,pr=!1,fr;async function dr(){return pr?fr:(_e??=cr(),_e)}var X="\f";function J(e){return e.split(/\r?\n/).map(t=>t.trim()).filter(t=>t.length>0)}async function ur(e){if(e.format==="docx"){let r=await he(),{value:o}=await r.extractRawText({path:e.path});return J(o)}if(e.format==="doc"){let r=await ye(),n=await new r().extract(e.path);return J(n.getBody())}return(await Re(await Y(e.path))).flatMap((r,o)=>o===0?J(r):[X,...J(r)])}var V=612,W=792,b=54,Z=11,Ce=14;async function mr(e){let{PDFDocument:t,StandardFonts:r}=await y(),o=await t.create(),n=await o.embedFont(r.Helvetica),a=V-b*2,i=o.addPage([V,W]),s=W-b,c=()=>{i=o.addPage([V,W]),s=W-b};for(let p of e){if(p===X){c();continue}let f="";for(let u of p.split(/\s+/).filter(Boolean)){let d=f?`${f} ${u}`:u;f&&n.widthOfTextAtSize(d,Z)>a?(s<b&&c(),i.drawText(f,{x:b,y:s,size:Z,font:n}),s-=Ce,f=u):f=d}f&&(s<b&&c(),i.drawText(f,{x:b,y:s,size:Z,font:n}),s-=Ce)}return o.save()}async function gr(e){let{Document:t,Packer:r,PageBreak:o,Paragraph:n}=await be(),a=e.map(s=>s===X?new n({children:[new o]}):new n(s)),i=new t({sections:[{children:a}]});return r.toBuffer(i)}var lr=new Set(["docx","doc","pdf"]),wr=new Set(["docx","pdf"]),hr=new Set(["convert"]),yr={code:"word-basic-fidelity",message:"Converted with basic formatting only \u2014 tables, images, and complex layouts weren't preserved. Install LibreOffice for full-fidelity conversion: brew install --cask libreoffice"};async function xr(e,t,r){let o=await Xt(Ne(er(),"forge-word-"));try{await Q(e,[`-env:UserInstallation=file://${o}/profile`,"--headless","--convert-to",r,"--outdir",o,t],{timeout:12e4});let n=tr(t,rr(t));return await Y(Ne(o,`${n}.${r}`))}finally{await jt(o,{recursive:!0,force:!0})}}async function Pr(e,t){if(e.op!=="convert")throw new Error(`the word engine cannot ${e.op}`);let r=e.sources[0];if(r.kind!=="document")throw new Error("the word engine can only convert a document source");if(r.encrypted)throw v(r.path);t({phase:"reading"});let o=await dr();t({phase:"encoding"});let n=[],a;try{if(o!==void 0)a=await xr(o,r.path,e.target);else{let s=await ur(r);a=e.target==="pdf"?await mr(s):await gr(s),n.push(yr)}}catch(s){throw S(r.path,s)}t({phase:"writing"});let i=await m(e.outputs[0],a);return{job:e,outputBytes:i,warnings:n}}var He={id:"word",reads:lr,writes:wr,ops:hr,probe:ir,run:Pr};var j=[Fe,We,He,Oe,Ae];function Jo(e){if(e.op==="convert"){let t=e.sources[0].format;return j.find(r=>r.reads.has(t)&&r.writes.has(e.target))}return j.find(t=>t.ops.has(e.op))}async function Wo(e){let t;for(let r of j)try{return await r.probe(e)}catch(o){E(t)||(t=o)}throw t}export{k as a,q as b,ge as c,h as d,zr as e,De as f,Ae as g,jr as h,Te as i,eo as j,$e as k,j as l,Jo as m,Wo as n};
|