forge-terminal 0.1.0 → 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/README.md +305 -24
- 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 +67 -95
- package/dist/third-party-licenses.txt +2856 -0
- package/package.json +28 -21
- package/skills/forge/SKILL.md +128 -0
- package/dist/cli/args.js +0 -278
- package/dist/cli/args.js.map +0 -1
- package/dist/cli/config-command.js +0 -55
- package/dist/cli/config-command.js.map +0 -1
- package/dist/cli/execute.js +0 -377
- package/dist/cli/execute.js.map +0 -1
- package/dist/cli/report.js +0 -123
- package/dist/cli/report.js.map +0 -1
- package/dist/cli/spinner.js +0 -60
- package/dist/cli/spinner.js.map +0 -1
- package/dist/cli/stdin.js +0 -47
- package/dist/cli/stdin.js.map +0 -1
- package/dist/config/preferences.js +0 -143
- package/dist/config/preferences.js.map +0 -1
- package/dist/core/actions/compress.js +0 -157
- package/dist/core/actions/compress.js.map +0 -1
- package/dist/core/actions/convert.js +0 -270
- package/dist/core/actions/convert.js.map +0 -1
- package/dist/core/actions/extract.js +0 -94
- package/dist/core/actions/extract.js.map +0 -1
- package/dist/core/actions/index.js +0 -23
- package/dist/core/actions/index.js.map +0 -1
- package/dist/core/actions/merge.js +0 -16
- package/dist/core/actions/merge.js.map +0 -1
- package/dist/core/actions/rotate.js +0 -36
- package/dist/core/actions/rotate.js.map +0 -1
- package/dist/core/actions/split.js +0 -65
- package/dist/core/actions/split.js.map +0 -1
- package/dist/core/atomic.js +0 -61
- package/dist/core/atomic.js.map +0 -1
- package/dist/core/capabilities.js +0 -59
- package/dist/core/capabilities.js.map +0 -1
- package/dist/core/compress.js +0 -76
- package/dist/core/compress.js.map +0 -1
- package/dist/core/describe.js +0 -49
- package/dist/core/describe.js.map +0 -1
- package/dist/core/errors.js +0 -469
- package/dist/core/errors.js.map +0 -1
- package/dist/core/execute-jobs.js +0 -122
- package/dist/core/execute-jobs.js.map +0 -1
- package/dist/core/formats.js +0 -108
- package/dist/core/formats.js.map +0 -1
- package/dist/core/order.js +0 -44
- package/dist/core/order.js.map +0 -1
- package/dist/core/output-path.js +0 -176
- package/dist/core/output-path.js.map +0 -1
- package/dist/core/pages.js +0 -107
- package/dist/core/pages.js.map +0 -1
- package/dist/core/pdf-compress.js +0 -206
- package/dist/core/pdf-compress.js.map +0 -1
- package/dist/core/plan.js +0 -42
- package/dist/core/plan.js.map +0 -1
- package/dist/core/resolve.js +0 -115
- package/dist/core/resolve.js.map +0 -1
- package/dist/core/run.js +0 -66
- package/dist/core/run.js.map +0 -1
- package/dist/core/suggest.js +0 -50
- package/dist/core/suggest.js.map +0 -1
- package/dist/core/types.js +0 -2
- package/dist/core/types.js.map +0 -1
- package/dist/core/units.js +0 -94
- package/dist/core/units.js.map +0 -1
- package/dist/core/write-safety.js +0 -128
- package/dist/core/write-safety.js.map +0 -1
- package/dist/engines/heic.js +0 -166
- package/dist/engines/heic.js.map +0 -1
- package/dist/engines/image.js +0 -342
- package/dist/engines/image.js.map +0 -1
- package/dist/engines/pdf.js +0 -444
- package/dist/engines/pdf.js.map +0 -1
- package/dist/engines/pdfium.js +0 -161
- package/dist/engines/pdfium.js.map +0 -1
- package/dist/engines/registry.js +0 -65
- package/dist/engines/registry.js.map +0 -1
- package/dist/engines/types.js +0 -2
- package/dist/engines/types.js.map +0 -1
- package/dist/engines/word.js +0 -385
- package/dist/engines/word.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/shell/App.js +0 -1972
- package/dist/shell/App.js.map +0 -1
- package/dist/shell/ClickTargets.js +0 -183
- package/dist/shell/ClickTargets.js.map +0 -1
- package/dist/shell/ThemeContext.js +0 -21
- package/dist/shell/ThemeContext.js.map +0 -1
- package/dist/shell/blocks.js +0 -160
- package/dist/shell/blocks.js.map +0 -1
- package/dist/shell/clipboard.js +0 -64
- package/dist/shell/clipboard.js.map +0 -1
- package/dist/shell/commands.js +0 -51
- package/dist/shell/commands.js.map +0 -1
- package/dist/shell/components/Banner.js +0 -73
- package/dist/shell/components/Banner.js.map +0 -1
- package/dist/shell/components/CommandPalette.js +0 -37
- package/dist/shell/components/CommandPalette.js.map +0 -1
- package/dist/shell/components/FileCard.js +0 -59
- package/dist/shell/components/FileCard.js.map +0 -1
- package/dist/shell/components/HintBar.js +0 -18
- package/dist/shell/components/HintBar.js.map +0 -1
- package/dist/shell/components/Hints.js +0 -21
- package/dist/shell/components/Hints.js.map +0 -1
- package/dist/shell/components/MergeList.js +0 -268
- package/dist/shell/components/MergeList.js.map +0 -1
- package/dist/shell/components/ModeHeader.js +0 -21
- package/dist/shell/components/ModeHeader.js.map +0 -1
- package/dist/shell/components/PageGrid.js +0 -324
- package/dist/shell/components/PageGrid.js.map +0 -1
- package/dist/shell/components/PathInput.js +0 -147
- package/dist/shell/components/PathInput.js.map +0 -1
- package/dist/shell/components/Progress.js +0 -43
- package/dist/shell/components/Progress.js.map +0 -1
- package/dist/shell/components/Prompt.js +0 -667
- package/dist/shell/components/Prompt.js.map +0 -1
- package/dist/shell/components/ResultLinks.js +0 -26
- package/dist/shell/components/ResultLinks.js.map +0 -1
- package/dist/shell/components/Select.js +0 -152
- package/dist/shell/components/Select.js.map +0 -1
- package/dist/shell/components/Slider.js +0 -48
- package/dist/shell/components/Slider.js.map +0 -1
- package/dist/shell/components/StagedFiles.js +0 -92
- package/dist/shell/components/StagedFiles.js.map +0 -1
- package/dist/shell/components/ThemePicker.js +0 -18
- package/dist/shell/components/ThemePicker.js.map +0 -1
- package/dist/shell/components/UnitRow.js +0 -30
- package/dist/shell/components/UnitRow.js.map +0 -1
- package/dist/shell/flows/pdf.js +0 -424
- package/dist/shell/flows/pdf.js.map +0 -1
- package/dist/shell/frame-geometry.js +0 -56
- package/dist/shell/frame-geometry.js.map +0 -1
- package/dist/shell/hyperlink.js +0 -27
- package/dist/shell/hyperlink.js.map +0 -1
- package/dist/shell/intro.js +0 -101
- package/dist/shell/intro.js.map +0 -1
- package/dist/shell/launch.js +0 -75
- package/dist/shell/launch.js.map +0 -1
- package/dist/shell/mark.js +0 -134
- package/dist/shell/mark.js.map +0 -1
- package/dist/shell/mouse.js +0 -209
- package/dist/shell/mouse.js.map +0 -1
- package/dist/shell/redraw.js +0 -36
- package/dist/shell/redraw.js.map +0 -1
- package/dist/shell/reveal.js +0 -24
- package/dist/shell/reveal.js.map +0 -1
- package/dist/shell/stage.js +0 -34
- package/dist/shell/stage.js.map +0 -1
- package/dist/shell/terminal-write.js +0 -16
- package/dist/shell/terminal-write.js.map +0 -1
- package/dist/shell/theme.js +0 -178
- package/dist/shell/theme.js.map +0 -1
- package/dist/shell/useFrameOrigin.js +0 -175
- package/dist/shell/useFrameOrigin.js.map +0 -1
- package/dist/shell/useKeys.js +0 -28
- package/dist/shell/useKeys.js.map +0 -1
- package/dist/shell/useMouse.js +0 -150
- package/dist/shell/useMouse.js.map +0 -1
- package/dist/shell/useMouseRouting.js +0 -69
- package/dist/shell/useMouseRouting.js.map +0 -1
- package/dist/shell/width.js +0 -62
- package/dist/shell/width.js.map +0 -1
- package/dist/utils/display-path.js +0 -31
- package/dist/utils/display-path.js.map +0 -1
- package/dist/utils/unescape-path.js +0 -68
- package/dist/utils/unescape-path.js.map +0 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q}from"./chunk-V4GHQGQM.js";import"./chunk-TMUK2DD3.js";export{o as BAR,c as DARK,d as LIGHT,g as MODE_KEYS,i as MODE_MARKERS,f as MODE_ORDER,e as NEUTRAL,b as SYMBOLS,a as VERSION,q as applyColourPreference,p as colourEnabled,n as colourProp,j as modeColours,h as modeForKey,k as modeGradient,l as modePalette,m as paletteFor};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a as v,c as F}from"./chunk-TMUK2DD3.js";var we=F((Sr,Fe)=>{var Te=Buffer.from("D0CF11E0A1B11AE1","hex"),Lt=class{constructor(){}load(t){for(let e=0;e<Te.length;e++)if(Te[e]!=t[e])return!1;this.secSize=1<<t.readInt16LE(30),this.shortSecSize=1<<t.readInt16LE(32),this.SATSize=t.readInt32LE(44),this.dirSecId=t.readInt32LE(48),this.shortStreamMax=t.readInt32LE(56),this.SSATSecId=t.readInt32LE(60),this.SSATSize=t.readInt32LE(64),this.MSATSecId=t.readInt32LE(68),this.MSATSize=t.readInt32LE(72),this.partialMSAT=new Array(109);for(let e=0;e<109;e++)this.partialMSAT[e]=t.readInt32LE(76+e*4);return!0}};Fe.exports=Lt});var ve=F((Tr,Ae)=>{var Pt=class{constructor(t){this._doc=t}load(t){let e=this._doc,i=e._header;return this._table=new Array(t.length*(i.secSize/4)),e._readSectors(t).then(r=>{for(let n=0;n<r.length/4;n++)this._table[n]=r.readInt32LE(n*4)})}getSecIdChain(t){let e=t,i=[];for(;e>-1;){i.push(e);let r=e;if(e=this._table[e],e===r)break}return i}};Ae.exports=Pt});var De=F((Fr,ye)=>{var Ot=class{constructor(t){this._doc=t}load(t){return this._doc._readSectors(t).then(i=>{let r=i.length/128;this._entries=new Array(r);for(let n=0;n<r;n++){let a=n*128,o=Math.max(i.readInt16LE(64+a)-1,0),c={};c.name=i.toString("utf16le",0+a,o+a),c.type=i.readInt8(66+a),c.nodeColor=i.readInt8(67+a),c.left=i.readInt32LE(68+a),c.right=i.readInt32LE(72+a),c.storageDirId=i.readInt32LE(76+a),c.secId=i.readInt32LE(116+a),c.size=i.readInt32LE(120+a),this._entries[n]=c}this.root=this._entries.find(n=>n.type===5),this._buildHierarchy(this.root)})}_buildHierarchy(t){let e=this._getChildIds(t);t.storages={},t.streams={};for(let i of e){let r=this._entries[i],n=r.name;r.type===1&&(t.storages[n]=r),r.type===2&&(t.streams[n]=r)}for(let i in t.storages)this._buildHierarchy(t.storages[i])}_getChildIds(t){let e=[],i=r=>{r.left!==-1&&(e.push(r.left),i(this._entries[r.left])),r.right!==-1&&(e.push(r.right),i(this._entries[r.right]))};if(t.storageDirId>-1){e.push(t.storageDirId);let r=this._entries[t.storageDirId];i(r)}return e}};ye.exports=Ot});var Re=F((wr,Ie)=>{var{Readable:Xs}=v("stream"),Mt=class extends Xs{constructor(t,e){super(),this._doc=t,this._streamEntry=e,this.initialize()}initialize(){if(this._index=0,this._done=!0,!this._streamEntry)return;let t=this._doc;this._bytes=this._streamEntry.size,this._allocationTable=t._SAT,this._shortStream=!1,this._bytes<t._header.shortStreamMax&&(this._shortStream=!0,this._allocationTable=t._SSAT),this._secIds=this._allocationTable.getSecIdChain(this._streamEntry.secId),this._done=!1}_readSector(t){return this._shortStream?this._doc._readShortSector(t):this._doc._readSector(t)}_read(){return this._done?this.push(null):this._index>=this._secIds.length?(this._done=!0,this.push(null)):this._readSector(this._secIds[this._index]).then(t=>{this._bytes-t.length<0&&(t=t.slice(0,this._bytes)),this._bytes-=t.length,this._index++,this.push(t)})}};Ie.exports=Mt});var Le=F((Ar,Ne)=>{var Ys=Re(),Bt=class s{constructor(t,e){this._doc=t,this._dirEntry=e}storage(t){return new s(this._doc,this._dirEntry.storages[t])}stream(t){return new Ys(this._doc,this._dirEntry.streams[t])}};Ne.exports=Bt});var Me=F((vr,Oe)=>{var Vs=we(),Pe=ve(),js=De(),Gs=Le(),Ut=class{constructor(t){this._reader=t,this._skipBytes=0}read(){return Promise.resolve().then(()=>this._readHeader()).then(()=>this._readMSAT()).then(()=>this._readSAT()).then(()=>this._readSSAT()).then(()=>this._readDirectoryTree()).then(()=>{if(this._skipBytes!=0)return this._readCustomHeader()}).then(()=>this)}_readCustomHeader(){let t=Buffer.alloc(this._skipBytes);return this._reader.read(t,0,this._skipBytes,0).then(e=>{this._customHeaderCallback(e)})}_readHeader(){let t=Buffer.alloc(512);return this._reader.read(t,0,512,0+this._skipBytes).then(e=>{if(!(this._header=new Vs).load(e))throw new Error("Not a valid compound document")})}_readMSAT(){let t=this._header;if(this._MSAT=t.partialMSAT.slice(0),this._MSAT.length=t.SATSize,t.SATSize<=109||t.MSATSize==0)return Promise.resolve();let e=109,i=0,r=(n,a,o)=>n>=t.MSATSize?Promise.resolve():this._readSector(o).then(c=>{let h;for(h=0;h<t.secSize-4&&!(a>=t.SATSize);h+=4)this._MSAT[a]=c.readInt32LE(h),a++;return o=c.readInt32LE(t.secSize-4),r(n+1,a,o)});return r(i,e,t.MSATSecId)}_readSector(t){return this._readSectors([t])}_readSectors(t){let e=this._header,i=Buffer.alloc(t.length*e.secSize),r=n=>{if(n>=t.length)return Promise.resolve(i);let a=n*e.secSize,o=this._getFileOffsetForSec(t[n]);return this._reader.read(i,a,e.secSize,o).then(()=>r(n+1))};return r(0)}_readShortSector(t){return this._readShortSectors([t])}_readShortSectors(t){let e=this._header,i=Buffer.alloc(t.length*e.shortSecSize),r=n=>{if(n>=t.length)return Promise.resolve(i);let a=n*e.shortSecSize,o=this._getFileOffsetForShortSec(t[n]);return this._reader.read(i,a,e.shortSecSize,o).then(()=>r(n+1))};return r(0)}_readSAT(){return this._SAT=new Pe(this),this._SAT.load(this._MSAT)}_readSSAT(){let t=this._header,e=this._SAT.getSecIdChain(t.SSATSecId);return e.length!=t.SSATSize?Promise.reject(new Error("Invalid Short Sector Allocation Table")):(this._SSAT=new Pe(this),this._SSAT.load(e))}_readDirectoryTree(){let t=this._header;this._directoryTree=new js(this);let e=this._SAT.getSecIdChain(t.dirSecId);return this._directoryTree.load(e).then(()=>{let i=this._directoryTree.root;this._rootStorage=new Gs(this,i),this._shortStreamSecIds=this._SAT.getSecIdChain(i.secId)})}_getFileOffsetForSec(t){let e=this._header.secSize;return this._skipBytes+(t+1)*e}_getFileOffsetForShortSec(t){let e=this._header.shortSecSize,i=t*e,r=this._header.secSize,n=Math.floor(i/r),a=i%r,o=this._shortStreamSecIds[n];return this._getFileOffsetForSec(o)+a}storage(t){return this._rootStorage.storage(t)}stream(t){return this._rootStorage.stream(t)}};Oe.exports=Ut});var Ht=F((yr,xt)=>{var P=[];P[2]="\0";P[5]="\0";P[7]=" ";P[8]="\0";P[10]=`
|
|
4
|
+
`;P[11]=`
|
|
5
|
+
`;P[12]=`
|
|
6
|
+
`;P[13]=`
|
|
7
|
+
`;P[30]="\u2011";var b=[];b[130]="\u201A";b[131]="\u0192";b[132]="\u201E";b[133]="\u2026";b[134]="\u2020";b[135]="\u2021";b[136]="\u02C6";b[137]="\u2030";b[138]="\u0160";b[139]="\u2039";b[140]="\u0152";b[142]="\u017D";b[145]="\u2018";b[146]="\u2019";b[147]="\u201C";b[148]="\u201D";b[149]="\u2022";b[150]="\u2013";b[151]="\u2014";b[152]="\u02DC";b[153]="\u2122";b[154]="\u0161";b[155]="\u203A";b[156]="\u0153";b[158]="\u017E";b[159]="\u0178";xt.exports.binaryToUnicode=s=>s.replace(/([\x80-\x9f])/g,t=>b[t.charCodeAt(0)]);xt.exports.clean=s=>{s=s.replace(/([\x02\x05\x07\x08\x0a\x0b\x0c\x0d\x1f])/g,e=>P[e.charCodeAt(0)]);let t=!0;for(;t;)t=!1,s=s.replace(/(?:\x13[^\x13\x14\x15]*\x14?([^\x13\x14\x15]*)\x15)/g,(e,i)=>(t=!0,i));return s.replace(/[\x00-\x07]/g,"")};var O=[];O[8194]=" ";O[8195]=" ";O[8210]="-";O[8211]="-";O[8212]="-";O[8216]="'";O[8217]="'";O[8220]='"';O[8221]='"';xt.exports.filter=s=>s.replace(/[\u2002\u2003\u2012\u2013\u2014\u2018\u2019\u201c\u201d]/g,t=>O[t.charCodeAt(0)])});var zt=F((Dr,Be)=>{var{filter:j}=Ht(),kt=class{constructor(){this._body="",this._footnotes="",this._endnotes="",this._headers="",this._footers="",this._annotations="",this._textboxes="",this._headerTextboxes=""}getBody(t){t=t||{};let e=this._body;return t.filterUnicode==!1?e:j(e)}getFootnotes(t){t=t||{};let e=this._footnotes;return t.filterUnicode==!1?e:j(e)}getEndnotes(t){t=t||{};let e=this._endnotes;return t.filterUnicode==!1?e:j(e)}getHeaders(t){t=t||{};let e=this._headers+(t.includeFooters==!1?"":this._footers);return t.filterUnicode==!1?e:j(e)}getFooters(t){t=t||{};let e=this._footers;return t.filterUnicode==!1?e:j(e)}getAnnotations(t){t=t||{};let e=this._annotations;return t.filterUnicode==!1?e:j(e)}getTextboxes(t){t=t||{};let e=[];t.includeBody!=!1&&e.push(this._textboxes),t.includeHeadersAndFooters!=!1&&e.push(this._headerTextboxes);let i=e.join(`
|
|
8
|
+
`);return t.filterUnicode==!1?i:j(i)}};Be.exports=kt});var We=F((Ir,$e)=>{var Qs=Me(),Ks=zt(),{binaryToUnicode:Zs,clean:$}=Ht(),Js=0,mt=(s,t)=>{for(let e=0;e<s.length;e++){let i=s[e];if(t<=i.endCp)return e}},Ue=(s,t)=>{for(let e=0;e<s.length;e++){let i=s[e];if(t<=i.endFilePos)return e}};function G(s,t,e){let i=mt(s,t),r=mt(s,e),n=[];for(let a=i,o=r;a<=o;a++){let c=s[a],h=a===i?t-c.startCp:0,l=a===r?e-c.startCp:c.endCp;n.push(c.text.substring(h,l))}return n.join("")}function ti(s,t,e,i){let r=s.startCp,n=r+s.length,a=s.text;t<r&&(t=r),e>n&&(e=n);let o=(t==r?"":a.slice(0,t-r))+"".padStart(e-t,i)+(e==n?"":a.slice(e-n));s.text=o}function ei(s,t,e,i){let r=s.startFilePos,n=r+s.size,a=s.text;t<r&&(t=r),e>n&&(e=n);let o=(t==r?"":a.slice(0,(t-r)/s.bpc))+"".padStart((e-t)/s.bpc,i)+(e==n?"":a.slice((e-n)/s.bpc));s.text=o}function He(s,t,e,i){let r=mt(s,t),n=mt(s,e);for(let a=r,o=n;a<=o;a++){let c=s[a];ti(c,t,e,i)}}function qe(s,t,e,i){let r=Ue(s,t),n=Ue(s,e);for(let a=r,o=n;a<=o;a++){let c=s[a];ei(c,t,e,i)}}function ke(s,t,e){qe(s,t,e,"\0")}var ze=(s,t,e)=>{for(;t<s.length-1;){let i=s.readUInt16LE(t),r=i&31,n=i>>9&1,a=i>>10&7,o=i>>13&7;if(t+=2,e(s,t,i,r,n,a,o),o===0){t+=1;continue}else if(o===1){t+=1;continue}else if(o===2){t+=2;continue}else if(o===3){t+=4;continue}else if(o===4||o===5){t+=2;continue}else if(o===6){t+=s.readUInt8(t)+1;continue}else if(o===7){t+=3;continue}else throw new Error("Unparsed sprm")}},qt=class{constructor(){this._pieces=[],this._bookmarks={},this._boundaries={},this._taggedHeaders=[]}extract(t){let e=new Qs(t);return e.read().then(()=>this.documentStream(e,"WordDocument").then(i=>this.streamBuffer(i)).then(i=>this.extractWordDocument(e,i)))}buildDocument(){let t=new Ks,e=this._pieces,i=0;return t._body=$(G(e,i,i+this._boundaries.ccpText)),i+=this._boundaries.ccpText,this._boundaries.ccpFtn&&(t._footnotes=$(G(e,i,i+this._boundaries.ccpFtn-1)),i+=this._boundaries.ccpFtn),this._boundaries.ccpHdd&&(t._headers=$(this._taggedHeaders.filter(r=>r.type==="headers").map(r=>r.text).join("")),t._footers=$(this._taggedHeaders.filter(r=>r.type==="footers").map(r=>r.text).join("")),i+=this._boundaries.ccpHdd),this._boundaries.ccpAtn&&(t._annotations=$(G(e,i,i+this._boundaries.ccpAtn-1)),i+=this._boundaries.ccpAtn),this._boundaries.ccpEdn&&(t._endnotes=$(G(e,i,i+this._boundaries.ccpEdn-1)),i+=this._boundaries.ccpEdn),this._boundaries.ccpTxbx&&(t._textboxes=$(G(e,i,i+this._boundaries.ccpTxbx-1)),i+=this._boundaries.ccpTxbx),this._boundaries.ccpHdrTxbx&&(t._headerTextboxes=$(G(e,i,i+this._boundaries.ccpHdrTxbx-1)),i+=this._boundaries.ccpHdrTxbx),t}extractWordDocument(t,e){let i=e.readUInt16LE(0);if(i!==42476)return Promise.reject(new Error(`This does not seem to be a Word document: Invalid magic number: ${i.toString(16)}`));let n=(e.readUInt16LE(10)&512)!==0?"1Table":"0Table";return this.documentStream(t,n).then(a=>this.streamBuffer(a)).then(a=>(this._boundaries.fcMin=e.readUInt32LE(24),this._boundaries.ccpText=e.readUInt32LE(76),this._boundaries.ccpFtn=e.readUInt32LE(80),this._boundaries.ccpHdd=e.readUInt32LE(84),this._boundaries.ccpAtn=e.readUInt32LE(92),this._boundaries.ccpEdn=e.readUInt32LE(96),this._boundaries.ccpTxbx=e.readUInt32LE(100),this._boundaries.ccpHdrTxbx=e.readUInt32LE(104),this.writeBookmarks(e,a),this.writePieces(e,a),this.writeCharacterProperties(e,a),this.writeParagraphProperties(e,a),this.normalizeHeaders(e,a),this.buildDocument()))}documentStream(t,e){return Promise.resolve(t.stream(e))}streamBuffer(t){return new Promise((e,i)=>{let r=[];return t.on("data",n=>r.push(n)),t.on("error",n=>i(n)),t.on("end",()=>e(Buffer.concat(r))),t})}writeFields(t,e,i){let r=t.readInt32LE(282),n=t.readUInt32LE(286);if(n==0)return;let a=(n-4)/6,o=(a+1)*4,c=e.slice(r,r+n);for(let h=0;h<a;h++){let l=c.readUInt32LE(h*4),x=c.readUInt16LE(o+h*2),d=x&255,m=x>>8;d&31}}writeBookmarks(t,e){let i=t.readUInt32LE(322),r=t.readUInt32LE(326),n=t.readUInt32LE(330),a=t.readUInt32LE(334),o=t.readUInt32LE(338),c=t.readUInt32LE(342);if(r===0)return;let h=e.slice(i,i+r),l=e.slice(n,n+a),x=e.slice(o,o+c),d=h.readUInt16LE(0),m=h.readUInt16LE(2),g=h.readUInt16LE(4);if(d!==65535)throw new Error("Internal error: unexpected single-byte bookmark data");let u=6,p=0;for(;u<r;){let f=h.readUInt16LE(u);f=f*2;let E=h.slice(u+2,u+2+f),T=l.readUInt32LE(p*4),R=x.readUInt32LE(p*4);this._bookmarks[E]={start:T,end:R},u=u+f+2}}writePieces(t,e){let i,r=t.readUInt32LE(418);for(;i=e.readUInt8(r),i===1;){r=r+1;let h=e.readUInt16LE(r);r=r+2+h}if(i=e.readUInt8(r),r=r+1,i!==2)throw new Error("Internal error: ccorrupted Word file");let n=e.readUInt32LE(r);r=r+4;let a=(n-4)/12,o=0,c=0;for(let h=0,l=a-1;h<=l;h++){let x=r+(a+1)*4+h*8+2,d=e.readUInt32LE(x),m=!1;(d&1073741824)===0?m=!0:(d=d&-1073741825,d=Math.floor(d/2));let g=e.readUInt32LE(r+h*4),u=e.readUInt32LE(r+(h+1)*4),p=u-g,f={startCp:o,startStream:c,totLength:p,startFilePos:d,unicode:m,bpc:m?2:1};f.size=f.bpc*(u-g);let E=t.slice(d,d+f.size);m?f.text=E.toString("ucs2"):f.text=Zs(E.toString("binary")),f.length=f.text.length,f.endCp=f.startCp+f.length,f.endStream=f.startStream+f.size,f.endFilePos=f.startFilePos+f.size,o=f.endCp,c=f.endStream,this._pieces.push(f)}}normalizeHeaders(t,e){let i=this._pieces,r=t.readUInt32LE(242),n=t.readUInt32LE(246);if(n<8)return;let a=this._boundaries.ccpText+this._boundaries.ccpFtn,o=this._boundaries.ccpHdd,c=e.slice(r,r+n),h=n/4,l=a+c.readUInt32LE(0);for(let x=1;x<h;x++){let d=a+c.readUInt32LE(x*4);d>a+o&&(d=a+o);let m=G(i,l,d),g=x-1;[0,1,2].includes(g)?this._taggedHeaders.push({type:"footnoteSeparators",text:m}):[3,4,5].includes(g)?this._taggedHeaders.push({type:"endSeparators",text:m}):[0,1,4].includes(g%6)?this._taggedHeaders.push({type:"headers",text:m}):[2,3,5].includes(g%6)&&this._taggedHeaders.push({type:"footers",text:m}),/[^\r\n\u0002-\u0008]/.test(m)?He(i,d-1,d,"\0"):He(i,l,d,"\0"),l=d}}writeParagraphProperties(t,e){let i=this._pieces,r=t.readUInt32LE(258),n=t.readUInt32LE(262),a=(n-4)/8,o=(a+1)*4,c=e.slice(r,r+n);for(let h=0;h<a;h++){let l=c.readUInt32LE(h*4),x=c.readUInt32LE(o+h*4),d=t.slice(x*512,(x+1)*512),m=d.readUInt8(511);for(let g=0;g<m;g++){let u=d.readUInt32LE(g*4),p=d.readUInt32LE((g+1)*4),f=(m+1)*4+g*13,E=d.readUInt8(f)*2,T=d.readUInt8(E),R=null;if(T!==0)R=d.slice(E+1,E+1+2*T-1);else{let Z=d.readUInt8(E+1);R=d.slice(E+2,E+2+2*Z)}let z=R.readUInt16LE(0);ze(R,2,(Z,q,at,Se,gr,br,Cr)=>{at===9239&&qe(i,u,p,`
|
|
9
|
+
`)})}}}writeCharacterProperties(t,e){let i=this._pieces,r=t.readUInt32LE(250),n=t.readUInt32LE(254),a=(n-4)/8,o=(a+1)*4,c=e.slice(r,r+n),h=null;for(let l=0;l<a;l++){let x=c.readUInt32LE(l*4),d=c.readUInt32LE(o+l*4),m=t.slice(d*512,(d+1)*512),g=m.readUInt8(511);for(let u=0;u<g;u++){let p=m.readUInt32LE(u*4),f=m.readUInt32LE((u+1)*4),E=m.readUInt8((g+1)*4+u);if(E==0)continue;let T=E*2,R=m.readUInt8(T),z=m.slice(T+1,T+1+R);ze(z,0,(Z,q,at,Se)=>{if(Se===Js){if((Z[q]&1)!=1)return;h===p?ke(i,h,f):ke(i,p,f),h=f}})}}}};$e.exports=qt});var Ye=F(C=>{"use strict";Object.defineProperty(C,"__esModule",{value:!0});C.CHAR=`
|
|
10
|
+
\r -\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}`;C.S=` \r
|
|
11
|
+
`;C.NAME_START_CHAR=":A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}";C.NAME_CHAR="-"+C.NAME_START_CHAR+".0-9\xB7\u0300-\u036F\u203F-\u2040";C.CHAR_RE=new RegExp("^["+C.CHAR+"]$","u");C.S_RE=new RegExp("^["+C.S+"]+$","u");C.NAME_START_CHAR_RE=new RegExp("^["+C.NAME_START_CHAR+"]$","u");C.NAME_CHAR_RE=new RegExp("^["+C.NAME_CHAR+"]$","u");C.NAME_RE=new RegExp("^["+C.NAME_START_CHAR+"]["+C.NAME_CHAR+"]*$","u");C.NMTOKEN_RE=new RegExp("^["+C.NAME_CHAR+"]+$","u");var $t=9,Wt=10,Xt=13,Yt=32;C.S_LIST=[Yt,Wt,Xt,$t];function si(s){return s>=Yt&&s<=55295||s===Wt||s===Xt||s===$t||s>=57344&&s<=65533||s>=65536&&s<=1114111}C.isChar=si;function ii(s){return s===Yt||s===Wt||s===Xt||s===$t}C.isS=ii;function Xe(s){return s>=65&&s<=90||s>=97&&s<=122||s===58||s===95||s===8204||s===8205||s>=192&&s<=214||s>=216&&s<=246||s>=248&&s<=767||s>=880&&s<=893||s>=895&&s<=8191||s>=8304&&s<=8591||s>=11264&&s<=12271||s>=12289&&s<=55295||s>=63744&&s<=64975||s>=65008&&s<=65533||s>=65536&&s<=983039}C.isNameStartChar=Xe;function ri(s){return Xe(s)||s>=48&&s<=57||s===45||s===46||s===183||s>=768&&s<=879||s>=8255&&s<=8256}C.isNameChar=ri});var Ze=F(_=>{"use strict";Object.defineProperty(_,"__esModule",{value:!0});_.CHAR="-\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}";_.RESTRICTED_CHAR="-\b\v\f-\x7F-\x84\x86-\x9F";_.S=` \r
|
|
12
|
+
`;_.NAME_START_CHAR=":A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}";_.NAME_CHAR="-"+_.NAME_START_CHAR+".0-9\xB7\u0300-\u036F\u203F-\u2040";_.CHAR_RE=new RegExp("^["+_.CHAR+"]$","u");_.RESTRICTED_CHAR_RE=new RegExp("^["+_.RESTRICTED_CHAR+"]$","u");_.S_RE=new RegExp("^["+_.S+"]+$","u");_.NAME_START_CHAR_RE=new RegExp("^["+_.NAME_START_CHAR+"]$","u");_.NAME_CHAR_RE=new RegExp("^["+_.NAME_CHAR+"]$","u");_.NAME_RE=new RegExp("^["+_.NAME_START_CHAR+"]["+_.NAME_CHAR+"]*$","u");_.NMTOKEN_RE=new RegExp("^["+_.NAME_CHAR+"]+$","u");var Ve=9,je=10,Ge=13,Qe=32;_.S_LIST=[Qe,je,Ge,Ve];function ni(s){return s>=1&&s<=55295||s>=57344&&s<=65533||s>=65536&&s<=1114111}_.isChar=ni;function ai(s){return s>=1&&s<=8||s===11||s===12||s>=14&&s<=31||s>=127&&s<=132||s>=134&&s<=159}_.isRestrictedChar=ai;function oi(s){return s===9||s===10||s===13||s>31&&s<127||s===133||s>159&&s<=55295||s>=57344&&s<=65533||s>=65536&&s<=1114111}_.isCharAndNotRestricted=oi;function ci(s){return s===Qe||s===je||s===Ge||s===Ve}_.isS=ci;function Ke(s){return s>=65&&s<=90||s>=97&&s<=122||s===58||s===95||s===8204||s===8205||s>=192&&s<=214||s>=216&&s<=246||s>=248&&s<=767||s>=880&&s<=893||s>=895&&s<=8191||s>=8304&&s<=8591||s>=11264&&s<=12271||s>=12289&&s<=55295||s>=63744&&s<=64975||s>=65008&&s<=65533||s>=65536&&s<=983039}_.isNameStartChar=Ke;function hi(s){return Ke(s)||s>=48&&s<=57||s===45||s===46||s===183||s>=768&&s<=879||s>=8255&&s<=8256}_.isNameChar=hi});var ts=F(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});D.NC_NAME_START_CHAR="A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}";D.NC_NAME_CHAR="-"+D.NC_NAME_START_CHAR+".0-9\xB7\u0300-\u036F\u203F-\u2040";D.NC_NAME_START_CHAR_RE=new RegExp("^["+D.NC_NAME_START_CHAR+"]$","u");D.NC_NAME_CHAR_RE=new RegExp("^["+D.NC_NAME_CHAR+"]$","u");D.NC_NAME_RE=new RegExp("^["+D.NC_NAME_START_CHAR+"]["+D.NC_NAME_CHAR+"]*$","u");function Je(s){return s>=65&&s<=90||s===95||s>=97&&s<=122||s>=192&&s<=214||s>=216&&s<=246||s>=248&&s<=767||s>=880&&s<=893||s>=895&&s<=8191||s>=8204&&s<=8205||s>=8304&&s<=8591||s>=11264&&s<=12271||s>=12289&&s<=55295||s>=63744&&s<=64975||s>=65008&&s<=65533||s>=65536&&s<=983039}D.isNCNameStartChar=Je;function li(s){return Je(s)||s===45||s===46||s>=48&&s<=57||s===183||s>=768&&s<=879||s>=8255&&s<=8256}D.isNCNameChar=li});var bs=F(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});var it=Ye(),di=Ze(),ae=ts(),I=it.isS,fi=it.isChar,ot=it.isNameStartChar,es=it.isNameChar,ms=it.S_LIST,ui=it.NAME_RE,xi=di.isChar,mi=ae.isNCNameStartChar,pi=ae.isNCNameChar,_i=ae.NC_NAME_RE,Ct="http://www.w3.org/XML/1998/namespace",st="http://www.w3.org/2000/xmlns/",Ei={__proto__:null,xml:Ct,xmlns:st},gi={__proto__:null,amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},S=-1,M=-2,ss=0,bi=1,Vt=2,Ci=3,J=4,Si=5,Ti=6,Fi=7,jt=8,wi=9,Ai=10,vi=11,yi=12,y=13,pt=14,Gt=15,Di=16,Qt=17,Ii=18,Ri=19,Kt=20,Ni=21,Li=22,Pi=23,is=24,Zt=25,_t=26,rs=27,Oi=28,Mi=29,ns=30,Bi=31,Ui=32,Q=33,Hi=34,Jt=35,ct=36,te=37,ki=38,as=39,os=40,zi=41,cs=42,qi=43,$i=44,ee=9,N=10,se=13,hs=32,ls=33,ps=34,ht=38,_s=39,Et=45,gt=47,Wi=59,W=60,tt=61,w=62,A=63,Es=91,et=93,ds=133,fs=8232,bt=s=>s===ps||s===_s,gs=[ps,_s],Xi=[...gs,Es,w],Yi=[...gs,W,et],Vi=[tt,A,...ms],ji=[...ms,w,ht,W];function re(s,t,e){switch(t){case"xml":e!==Ct&&s.fail(`xml prefix must be bound to ${Ct}.`);break;case"xmlns":e!==st&&s.fail(`xmlns prefix must be bound to ${st}.`);break;default:}switch(e){case st:s.fail(t===""?`the default namespace may not be set to ${e}.`:`may not assign a prefix (even "xmlns") to the URI ${st}.`);break;case Ct:switch(t){case"xml":break;case"":s.fail(`the default namespace may not be set to ${e}.`);break;default:s.fail("may not assign the xml namespace to another prefix.")}break;default:}}function Gi(s,t){for(let e of Object.keys(t))re(s,e,t[e])}var Qi=s=>_i.test(s),Ki=s=>ui.test(s),K=0,us=1,ie=2;St.EVENTS=["xmldecl","text","processinginstruction","doctype","comment","opentagstart","attribute","opentag","closetag","cdata","error","end","ready"];var xs={xmldecl:"xmldeclHandler",text:"textHandler",processinginstruction:"piHandler",doctype:"doctypeHandler",comment:"commentHandler",opentagstart:"openTagStartHandler",attribute:"attributeHandler",opentag:"openTagHandler",closetag:"closeTagHandler",cdata:"cdataHandler",error:"errorHandler",end:"endHandler",ready:"readyHandler"},ne=class{constructor(t){this.opt=t??{},this.fragmentOpt=!!this.opt.fragment;let e=this.xmlnsOpt=!!this.opt.xmlns;if(this.trackPosition=this.opt.position!==!1,this.fileName=this.opt.fileName,e){this.nameStartCheck=mi,this.nameCheck=pi,this.isName=Qi,this.processAttribs=this.processAttribsNS,this.pushAttrib=this.pushAttribNS,this.ns=Object.assign({__proto__:null},Ei);let i=this.opt.additionalNamespaces;i!=null&&(Gi(this,i),Object.assign(this.ns,i))}else this.nameStartCheck=ot,this.nameCheck=es,this.isName=Ki,this.processAttribs=this.processAttribsPlain,this.pushAttrib=this.pushAttribPlain;this.stateTable=[this.sBegin,this.sBeginWhitespace,this.sDoctype,this.sDoctypeQuote,this.sDTD,this.sDTDQuoted,this.sDTDOpenWaka,this.sDTDOpenWakaBang,this.sDTDComment,this.sDTDCommentEnding,this.sDTDCommentEnded,this.sDTDPI,this.sDTDPIEnding,this.sText,this.sEntity,this.sOpenWaka,this.sOpenWakaBang,this.sComment,this.sCommentEnding,this.sCommentEnded,this.sCData,this.sCDataEnding,this.sCDataEnding2,this.sPIFirstChar,this.sPIRest,this.sPIBody,this.sPIEnding,this.sXMLDeclNameStart,this.sXMLDeclName,this.sXMLDeclEq,this.sXMLDeclValueStart,this.sXMLDeclValue,this.sXMLDeclSeparator,this.sXMLDeclEnding,this.sOpenTag,this.sOpenTagSlash,this.sAttrib,this.sAttribName,this.sAttribNameSawWhite,this.sAttribValue,this.sAttribValueQuoted,this.sAttribValueClosed,this.sAttribValueUnquoted,this.sCloseTag,this.sCloseTagSawWhite],this._init()}get closed(){return this._closed}_init(){var t;this.openWakaBang="",this.text="",this.name="",this.piTarget="",this.entity="",this.q=null,this.tags=[],this.tag=null,this.topNS=null,this.chunk="",this.chunkPosition=0,this.i=0,this.prevI=0,this.carriedFromPrevious=void 0,this.forbiddenState=K,this.attribList=[];let{fragmentOpt:e}=this;this.state=e?y:ss,this.reportedTextBeforeRoot=this.reportedTextAfterRoot=this.closedRoot=this.sawRoot=e,this.xmlDeclPossible=!e,this.xmlDeclExpects=["version"],this.entityReturnState=void 0;let{defaultXMLVersion:i}=this.opt;if(i===void 0){if(this.opt.forceXMLVersion===!0)throw new Error("forceXMLVersion set but defaultXMLVersion is not set");i="1.0"}this.setXMLVersion(i),this.positionAtNewLine=0,this.doctype=!1,this._closed=!1,this.xmlDecl={version:void 0,encoding:void 0,standalone:void 0},this.line=1,this.column=0,this.ENTITIES=Object.create(gi),(t=this.readyHandler)===null||t===void 0||t.call(this)}get position(){return this.chunkPosition+this.i}get columnIndex(){return this.position-this.positionAtNewLine}on(t,e){this[xs[t]]=e}off(t){this[xs[t]]=void 0}makeError(t){var e;let i=(e=this.fileName)!==null&&e!==void 0?e:"";return this.trackPosition&&(i.length>0&&(i+=":"),i+=`${this.line}:${this.column}`),i.length>0&&(i+=": "),new Error(i+t)}fail(t){let e=this.makeError(t),i=this.errorHandler;if(i===void 0)throw e;return i(e),this}write(t){if(this.closed)return this.fail("cannot write after close; assign an onready handler.");let e=!1;t===null?(e=!0,t=""):typeof t=="object"&&(t=t.toString()),this.carriedFromPrevious!==void 0&&(t=`${this.carriedFromPrevious}${t}`,this.carriedFromPrevious=void 0);let i=t.length,r=t.charCodeAt(i-1);!e&&(r===se||r>=55296&&r<=56319)&&(this.carriedFromPrevious=t[i-1],i--,t=t.slice(0,i));let{stateTable:n}=this;for(this.chunk=t,this.i=0;this.i<i;)n[this.state].call(this);return this.chunkPosition+=i,e?this.end():this}close(){return this.write(null)}getCode10(){let{chunk:t,i:e}=this;if(this.prevI=e,this.i=e+1,e>=t.length)return S;let i=t.charCodeAt(e);if(this.column++,i<55296){if(i>=hs||i===ee)return i;switch(i){case N:return this.line++,this.column=0,this.positionAtNewLine=this.position,N;case se:return t.charCodeAt(e+1)===N&&(this.i=e+2),this.line++,this.column=0,this.positionAtNewLine=this.position,M;default:return this.fail("disallowed character."),i}}if(i>56319)return i>=57344&&i<=65533||this.fail("disallowed character."),i;let r=65536+(i-55296)*1024+(t.charCodeAt(e+1)-56320);return this.i=e+2,r>1114111&&this.fail("disallowed character."),r}getCode11(){let{chunk:t,i:e}=this;if(this.prevI=e,this.i=e+1,e>=t.length)return S;let i=t.charCodeAt(e);if(this.column++,i<55296){if(i>31&&i<127||i>159&&i!==fs||i===ee)return i;switch(i){case N:return this.line++,this.column=0,this.positionAtNewLine=this.position,N;case se:{let n=t.charCodeAt(e+1);(n===N||n===ds)&&(this.i=e+2)}case ds:case fs:return this.line++,this.column=0,this.positionAtNewLine=this.position,M;default:return this.fail("disallowed character."),i}}if(i>56319)return i>=57344&&i<=65533||this.fail("disallowed character."),i;let r=65536+(i-55296)*1024+(t.charCodeAt(e+1)-56320);return this.i=e+2,r>1114111&&this.fail("disallowed character."),r}getCodeNorm(){let t=this.getCode();return t===M?N:t}unget(){this.i=this.prevI,this.column--}captureTo(t){let{i:e}=this,{chunk:i}=this;for(;;){let r=this.getCode(),n=r===M,a=n?N:r;if(a===S||t.includes(a))return this.text+=i.slice(e,this.prevI),a;n&&(this.text+=`${i.slice(e,this.prevI)}
|
|
13
|
+
`,e=this.i)}}captureToChar(t){let{i:e}=this,{chunk:i}=this;for(;;){let r=this.getCode();switch(r){case M:this.text+=`${i.slice(e,this.prevI)}
|
|
14
|
+
`,e=this.i,r=N;break;case S:return this.text+=i.slice(e),!1;default:}if(r===t)return this.text+=i.slice(e,this.prevI),!0}}captureNameChars(){let{chunk:t,i:e}=this;for(;;){let i=this.getCode();if(i===S)return this.name+=t.slice(e),S;if(!es(i))return this.name+=t.slice(e,this.prevI),i===M?N:i}}skipSpaces(){for(;;){let t=this.getCodeNorm();if(t===S||!I(t))return t}}setXMLVersion(t){this.currentXMLVersion=t,t==="1.0"?(this.isChar=fi,this.getCode=this.getCode10):(this.isChar=xi,this.getCode=this.getCode11)}sBegin(){this.chunk.charCodeAt(0)===65279&&(this.i++,this.column++),this.state=bi}sBeginWhitespace(){let t=this.i,e=this.skipSpaces();switch(this.prevI!==t&&(this.xmlDeclPossible=!1),e){case W:if(this.state=Gt,this.text.length!==0)throw new Error("no-empty text at start");break;case S:break;default:this.unget(),this.state=y,this.xmlDeclPossible=!1}}sDoctype(){var t;let e=this.captureTo(Xi);switch(e){case w:{(t=this.doctypeHandler)===null||t===void 0||t.call(this,this.text),this.text="",this.state=y,this.doctype=!0;break}case S:break;default:this.text+=String.fromCodePoint(e),e===Es?this.state=J:bt(e)&&(this.state=Ci,this.q=e)}}sDoctypeQuote(){let t=this.q;this.captureToChar(t)&&(this.text+=String.fromCodePoint(t),this.q=null,this.state=Vt)}sDTD(){let t=this.captureTo(Yi);t!==S&&(this.text+=String.fromCodePoint(t),t===et?this.state=Vt:t===W?this.state=Ti:bt(t)&&(this.state=Si,this.q=t))}sDTDQuoted(){let t=this.q;this.captureToChar(t)&&(this.text+=String.fromCodePoint(t),this.state=J,this.q=null)}sDTDOpenWaka(){let t=this.getCodeNorm();switch(this.text+=String.fromCodePoint(t),t){case ls:this.state=Fi,this.openWakaBang="";break;case A:this.state=vi;break;default:this.state=J}}sDTDOpenWakaBang(){let t=String.fromCodePoint(this.getCodeNorm()),e=this.openWakaBang+=t;this.text+=t,e!=="-"&&(this.state=e==="--"?jt:J,this.openWakaBang="")}sDTDComment(){this.captureToChar(Et)&&(this.text+="-",this.state=wi)}sDTDCommentEnding(){let t=this.getCodeNorm();this.text+=String.fromCodePoint(t),this.state=t===Et?Ai:jt}sDTDCommentEnded(){let t=this.getCodeNorm();this.text+=String.fromCodePoint(t),t===w?this.state=J:(this.fail("malformed comment."),this.state=jt)}sDTDPI(){this.captureToChar(A)&&(this.text+="?",this.state=yi)}sDTDPIEnding(){let t=this.getCodeNorm();this.text+=String.fromCodePoint(t),t===w&&(this.state=J)}sText(){this.tags.length!==0?this.handleTextInRoot():this.handleTextOutsideRoot()}sEntity(){let{i:t}=this,{chunk:e}=this;t:for(;;)switch(this.getCode()){case M:this.entity+=`${e.slice(t,this.prevI)}
|
|
15
|
+
`,t=this.i;break;case Wi:{let{entityReturnState:i}=this,r=this.entity+e.slice(t,this.prevI);this.state=i;let n;r===""?(this.fail("empty entity name."),n="&;"):(n=this.parseEntity(r),this.entity=""),(i!==y||this.textHandler!==void 0)&&(this.text+=n);break t}case S:this.entity+=e.slice(t);break t;default:}}sOpenWaka(){let t=this.getCode();if(ot(t))this.state=Hi,this.unget(),this.xmlDeclPossible=!1;else switch(t){case gt:this.state=qi,this.xmlDeclPossible=!1;break;case ls:this.state=Di,this.openWakaBang="",this.xmlDeclPossible=!1;break;case A:this.state=Pi;break;default:this.fail("disallowed character in tag name"),this.state=y,this.xmlDeclPossible=!1}}sOpenWakaBang(){switch(this.openWakaBang+=String.fromCodePoint(this.getCodeNorm()),this.openWakaBang){case"[CDATA[":!this.sawRoot&&!this.reportedTextBeforeRoot&&(this.fail("text data outside of root node."),this.reportedTextBeforeRoot=!0),this.closedRoot&&!this.reportedTextAfterRoot&&(this.fail("text data outside of root node."),this.reportedTextAfterRoot=!0),this.state=Kt,this.openWakaBang="";break;case"--":this.state=Qt,this.openWakaBang="";break;case"DOCTYPE":this.state=Vt,(this.doctype||this.sawRoot)&&this.fail("inappropriately located doctype declaration."),this.openWakaBang="";break;default:this.openWakaBang.length>=7&&this.fail("incorrect syntax.")}}sComment(){this.captureToChar(Et)&&(this.state=Ii)}sCommentEnding(){var t;let e=this.getCodeNorm();e===Et?(this.state=Ri,(t=this.commentHandler)===null||t===void 0||t.call(this,this.text),this.text=""):(this.text+=`-${String.fromCodePoint(e)}`,this.state=Qt)}sCommentEnded(){let t=this.getCodeNorm();t!==w?(this.fail("malformed comment."),this.text+=`--${String.fromCodePoint(t)}`,this.state=Qt):this.state=y}sCData(){this.captureToChar(et)&&(this.state=Ni)}sCDataEnding(){let t=this.getCodeNorm();t===et?this.state=Li:(this.text+=`]${String.fromCodePoint(t)}`,this.state=Kt)}sCDataEnding2(){var t;let e=this.getCodeNorm();switch(e){case w:{(t=this.cdataHandler)===null||t===void 0||t.call(this,this.text),this.text="",this.state=y;break}case et:this.text+="]";break;default:this.text+=`]]${String.fromCodePoint(e)}`,this.state=Kt}}sPIFirstChar(){let t=this.getCodeNorm();this.nameStartCheck(t)?(this.piTarget+=String.fromCodePoint(t),this.state=is):t===A||I(t)?(this.fail("processing instruction without a target."),this.state=t===A?_t:Zt):(this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(t),this.state=is)}sPIRest(){let{chunk:t,i:e}=this;for(;;){let i=this.getCodeNorm();if(i===S){this.piTarget+=t.slice(e);return}if(!this.nameCheck(i)){this.piTarget+=t.slice(e,this.prevI);let r=i===A;r||I(i)?this.piTarget==="xml"?(this.xmlDeclPossible||this.fail("an XML declaration must be at the start of the document."),this.state=r?Q:rs):this.state=r?_t:Zt:(this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(i));break}}}sPIBody(){if(this.text.length===0){let t=this.getCodeNorm();t===A?this.state=_t:I(t)||(this.text=String.fromCodePoint(t))}else this.captureToChar(A)&&(this.state=_t)}sPIEnding(){var t;let e=this.getCodeNorm();if(e===w){let{piTarget:i}=this;i.toLowerCase()==="xml"&&this.fail("the XML declaration must appear at the start of the document."),(t=this.piHandler)===null||t===void 0||t.call(this,{target:i,body:this.text}),this.piTarget=this.text="",this.state=y}else e===A?this.text+="?":(this.text+=`?${String.fromCodePoint(e)}`,this.state=Zt);this.xmlDeclPossible=!1}sXMLDeclNameStart(){let t=this.skipSpaces();if(t===A){this.state=Q;return}t!==S&&(this.state=Oi,this.name=String.fromCodePoint(t))}sXMLDeclName(){let t=this.captureTo(Vi);if(t===A){this.state=Q,this.name+=this.text,this.text="",this.fail("XML declaration is incomplete.");return}if(I(t)||t===tt){if(this.name+=this.text,this.text="",!this.xmlDeclExpects.includes(this.name))switch(this.name.length){case 0:this.fail("did not expect any more name/value pairs.");break;case 1:this.fail(`expected the name ${this.xmlDeclExpects[0]}.`);break;default:this.fail(`expected one of ${this.xmlDeclExpects.join(", ")}`)}this.state=t===tt?ns:Mi}}sXMLDeclEq(){let t=this.getCodeNorm();if(t===A){this.state=Q,this.fail("XML declaration is incomplete.");return}I(t)||(t!==tt&&this.fail("value required."),this.state=ns)}sXMLDeclValueStart(){let t=this.getCodeNorm();if(t===A){this.state=Q,this.fail("XML declaration is incomplete.");return}I(t)||(bt(t)?this.q=t:(this.fail("value must be quoted."),this.q=hs),this.state=Bi)}sXMLDeclValue(){let t=this.captureTo([this.q,A]);if(t===A){this.state=Q,this.text="",this.fail("XML declaration is incomplete.");return}if(t===S)return;let e=this.text;switch(this.text="",this.name){case"version":{this.xmlDeclExpects=["encoding","standalone"];let i=e;this.xmlDecl.version=i,/^1\.[0-9]+$/.test(i)?this.opt.forceXMLVersion||this.setXMLVersion(i):this.fail("version number must match /^1\\.[0-9]+$/.");break}case"encoding":/^[A-Za-z][A-Za-z0-9._-]*$/.test(e)||this.fail("encoding value must match /^[A-Za-z0-9][A-Za-z0-9._-]*$/."),this.xmlDeclExpects=["standalone"],this.xmlDecl.encoding=e;break;case"standalone":e!=="yes"&&e!=="no"&&this.fail('standalone value must match "yes" or "no".'),this.xmlDeclExpects=[],this.xmlDecl.standalone=e;break;default:}this.name="",this.state=Ui}sXMLDeclSeparator(){let t=this.getCodeNorm();if(t===A){this.state=Q;return}I(t)||(this.fail("whitespace required."),this.unget()),this.state=rs}sXMLDeclEnding(){var t;this.getCodeNorm()===w?(this.piTarget!=="xml"?this.fail("processing instructions are not allowed before root."):this.name!=="version"&&this.xmlDeclExpects.includes("version")&&this.fail("XML declaration must contain a version."),(t=this.xmldeclHandler)===null||t===void 0||t.call(this,this.xmlDecl),this.name="",this.piTarget=this.text="",this.state=y):this.fail("The character ? is disallowed anywhere in XML declarations."),this.xmlDeclPossible=!1}sOpenTag(){var t;let e=this.captureNameChars();if(e===S)return;let i=this.tag={name:this.name,attributes:Object.create(null)};switch(this.name="",this.xmlnsOpt&&(this.topNS=i.ns=Object.create(null)),(t=this.openTagStartHandler)===null||t===void 0||t.call(this,i),this.sawRoot=!0,!this.fragmentOpt&&this.closedRoot&&this.fail("documents may contain only one root."),e){case w:this.openTag();break;case gt:this.state=Jt;break;default:I(e)||this.fail("disallowed character in tag name."),this.state=ct}}sOpenTagSlash(){this.getCode()===w?this.openSelfClosingTag():(this.fail("forward-slash in opening tag not followed by >."),this.state=ct)}sAttrib(){let t=this.skipSpaces();t!==S&&(ot(t)?(this.unget(),this.state=te):t===w?this.openTag():t===gt?this.state=Jt:this.fail("disallowed character in attribute name."))}sAttribName(){let t=this.captureNameChars();t===tt?this.state=as:I(t)?this.state=ki:t===w?(this.fail("attribute without value."),this.pushAttrib(this.name,this.name),this.name=this.text="",this.openTag()):t!==S&&this.fail("disallowed character in attribute name.")}sAttribNameSawWhite(){let t=this.skipSpaces();switch(t){case S:return;case tt:this.state=as;break;default:this.fail("attribute without value."),this.text="",this.name="",t===w?this.openTag():ot(t)?(this.unget(),this.state=te):(this.fail("disallowed character in attribute name."),this.state=ct)}}sAttribValue(){let t=this.getCodeNorm();bt(t)?(this.q=t,this.state=os):I(t)||(this.fail("unquoted attribute value."),this.state=cs,this.unget())}sAttribValueQuoted(){let{q:t,chunk:e}=this,{i}=this;for(;;)switch(this.getCode()){case t:this.pushAttrib(this.name,this.text+e.slice(i,this.prevI)),this.name=this.text="",this.q=null,this.state=zi;return;case ht:this.text+=e.slice(i,this.prevI),this.state=pt,this.entityReturnState=os;return;case N:case M:case ee:this.text+=`${e.slice(i,this.prevI)} `,i=this.i;break;case W:this.text+=e.slice(i,this.prevI),this.fail("disallowed character.");return;case S:this.text+=e.slice(i);return;default:}}sAttribValueClosed(){let t=this.getCodeNorm();I(t)?this.state=ct:t===w?this.openTag():t===gt?this.state=Jt:ot(t)?(this.fail("no whitespace between attributes."),this.unget(),this.state=te):this.fail("disallowed character in attribute name.")}sAttribValueUnquoted(){let t=this.captureTo(ji);switch(t){case ht:this.state=pt,this.entityReturnState=cs;break;case W:this.fail("disallowed character.");break;case S:break;default:this.text.includes("]]>")&&this.fail('the string "]]>" is disallowed in char data.'),this.pushAttrib(this.name,this.text),this.name=this.text="",t===w?this.openTag():this.state=ct}}sCloseTag(){let t=this.captureNameChars();t===w?this.closeTag():I(t)?this.state=$i:t!==S&&this.fail("disallowed character in closing tag.")}sCloseTagSawWhite(){switch(this.skipSpaces()){case w:this.closeTag();break;case S:break;default:this.fail("disallowed character in closing tag.")}}handleTextInRoot(){let{i:t,forbiddenState:e}=this,{chunk:i,textHandler:r}=this;t:for(;;)switch(this.getCode()){case W:{if(this.state=Gt,r!==void 0){let{text:n}=this,a=i.slice(t,this.prevI);n.length!==0?(r(n+a),this.text=""):a.length!==0&&r(a)}e=K;break t}case ht:this.state=pt,this.entityReturnState=y,r!==void 0&&(this.text+=i.slice(t,this.prevI)),e=K;break t;case et:switch(e){case K:e=us;break;case us:e=ie;break;case ie:break;default:throw new Error("impossible state")}break;case w:e===ie&&this.fail('the string "]]>" is disallowed in char data.'),e=K;break;case M:r!==void 0&&(this.text+=`${i.slice(t,this.prevI)}
|
|
16
|
+
`),t=this.i,e=K;break;case S:r!==void 0&&(this.text+=i.slice(t));break t;default:e=K}this.forbiddenState=e}handleTextOutsideRoot(){let{i:t}=this,{chunk:e,textHandler:i}=this,r=!1;t:for(;;){let n=this.getCode();switch(n){case W:{if(this.state=Gt,i!==void 0){let{text:a}=this,o=e.slice(t,this.prevI);a.length!==0?(i(a+o),this.text=""):o.length!==0&&i(o)}break t}case ht:this.state=pt,this.entityReturnState=y,i!==void 0&&(this.text+=e.slice(t,this.prevI)),r=!0;break t;case M:i!==void 0&&(this.text+=`${e.slice(t,this.prevI)}
|
|
17
|
+
`),t=this.i;break;case S:i!==void 0&&(this.text+=e.slice(t));break t;default:I(n)||(r=!0)}}r&&(!this.sawRoot&&!this.reportedTextBeforeRoot&&(this.fail("text data outside of root node."),this.reportedTextBeforeRoot=!0),this.closedRoot&&!this.reportedTextAfterRoot&&(this.fail("text data outside of root node."),this.reportedTextAfterRoot=!0))}pushAttribNS(t,e){var i;let{prefix:r,local:n}=this.qname(t),a={name:t,prefix:r,local:n,value:e};if(this.attribList.push(a),(i=this.attributeHandler)===null||i===void 0||i.call(this,a),r==="xmlns"){let o=e.trim();this.currentXMLVersion==="1.0"&&o===""&&this.fail("invalid attempt to undefine prefix in XML 1.0"),this.topNS[n]=o,re(this,n,o)}else if(t==="xmlns"){let o=e.trim();this.topNS[""]=o,re(this,"",o)}}pushAttribPlain(t,e){var i;let r={name:t,value:e};this.attribList.push(r),(i=this.attributeHandler)===null||i===void 0||i.call(this,r)}end(){var t,e;this.sawRoot||this.fail("document must contain a root element.");let{tags:i}=this;for(;i.length>0;){let n=i.pop();this.fail(`unclosed tag: ${n.name}`)}this.state!==ss&&this.state!==y&&this.fail("unexpected end.");let{text:r}=this;return r.length!==0&&((t=this.textHandler)===null||t===void 0||t.call(this,r),this.text=""),this._closed=!0,(e=this.endHandler)===null||e===void 0||e.call(this),this._init(),this}resolve(t){var e,i;let r=this.topNS[t];if(r!==void 0)return r;let{tags:n}=this;for(let a=n.length-1;a>=0;a--)if(r=n[a].ns[t],r!==void 0)return r;return r=this.ns[t],r!==void 0?r:(i=(e=this.opt).resolvePrefix)===null||i===void 0?void 0:i.call(e,t)}qname(t){let e=t.indexOf(":");if(e===-1)return{prefix:"",local:t};let i=t.slice(e+1),r=t.slice(0,e);return(r===""||i===""||i.includes(":"))&&this.fail(`malformed name: ${t}.`),{prefix:r,local:i}}processAttribsNS(){var t;let{attribList:e}=this,i=this.tag;{let{prefix:a,local:o}=this.qname(i.name);i.prefix=a,i.local=o;let c=i.uri=(t=this.resolve(a))!==null&&t!==void 0?t:"";a!==""&&(a==="xmlns"&&this.fail('tags may not have "xmlns" as prefix.'),c===""&&(this.fail(`unbound namespace prefix: ${JSON.stringify(a)}.`),i.uri=a))}if(e.length===0)return;let{attributes:r}=i,n=new Set;for(let a of e){let{name:o,prefix:c,local:h}=a,l,x;c===""?(l=o==="xmlns"?st:"",x=o):(l=this.resolve(c),l===void 0&&(this.fail(`unbound namespace prefix: ${JSON.stringify(c)}.`),l=c),x=`{${l}}${h}`),n.has(x)&&this.fail(`duplicate attribute: ${x}.`),n.add(x),a.uri=l,r[o]=a}this.attribList=[]}processAttribsPlain(){let{attribList:t}=this,e=this.tag.attributes;for(let{name:i,value:r}of t)e[i]!==void 0&&this.fail(`duplicate attribute: ${i}.`),e[i]=r;this.attribList=[]}openTag(){var t;this.processAttribs();let{tags:e}=this,i=this.tag;i.isSelfClosing=!1,(t=this.openTagHandler)===null||t===void 0||t.call(this,i),e.push(i),this.state=y,this.name=""}openSelfClosingTag(){var t,e,i;this.processAttribs();let{tags:r}=this,n=this.tag;n.isSelfClosing=!0,(t=this.openTagHandler)===null||t===void 0||t.call(this,n),(e=this.closeTagHandler)===null||e===void 0||e.call(this,n),(this.tag=(i=r[r.length-1])!==null&&i!==void 0?i:null)===null&&(this.closedRoot=!0),this.state=y,this.name=""}closeTag(){let{tags:t,name:e}=this;if(this.state=y,this.name="",e===""){this.fail("weird empty close tag."),this.text+="</>";return}let i=this.closeTagHandler,r=t.length;for(;r-- >0;){let n=this.tag=t.pop();if(this.topNS=n.ns,i?.(n),n.name===e)break;this.fail("unexpected close tag.")}r===0?this.closedRoot=!0:r<0&&(this.fail(`unmatched closing tag: ${e}.`),this.text+=`</${e}>`)}parseEntity(t){if(t[0]!=="#"){let i=this.ENTITIES[t];return i!==void 0?i:(this.fail(this.isName(t)?"undefined entity.":"disallowed character in entity name."),`&${t};`)}let e=NaN;return t[1]==="x"&&/^#x[0-9a-f]+$/i.test(t)?e=parseInt(t.slice(2),16):/^#[0-9]+$/.test(t)&&(e=parseInt(t.slice(1),10)),this.isChar(e)?String.fromCodePoint(e):(this.fail("malformed character entity."),`&${t};`)}};St.SaxesParser=ne});var Fs=F((Or,Ts)=>{Ts.exports=Tt;function Tt(){this.pending=0,this.max=1/0,this.listeners=[],this.waiting=[],this.error=null}Tt.prototype.go=function(s){this.pending<this.max?Ss(this,s):this.waiting.push(s)};Tt.prototype.wait=function(s){this.pending===0?s(this.error):this.listeners.push(s)};Tt.prototype.hold=function(){return Cs(this)};function Cs(s){s.pending+=1;var t=!1;return e;function e(r){if(t)throw new Error("callback called twice");if(t=!0,s.error=s.error||r,s.pending-=1,s.waiting.length>0&&s.pending<s.max)Ss(s,s.waiting.shift());else if(s.pending===0){var n=s.listeners;s.listeners=[],n.forEach(i)}}function i(r){r(s.error)}}function Ss(s,t){t(Cs(s))}});var As=F(dt=>{var lt=v("fs"),Ft=v("util"),oe=v("stream"),ws=oe.Readable,ce=oe.Writable,Zi=oe.PassThrough,Ji=Fs(),wt=v("events").EventEmitter;dt.createFromBuffer=tr;dt.createFromFd=er;dt.BufferSlicer=k;dt.FdSlicer=H;Ft.inherits(H,wt);function H(s,t){t=t||{},wt.call(this),this.fd=s,this.pend=new Ji,this.pend.max=1,this.refCount=0,this.autoClose=!!t.autoClose}H.prototype.read=function(s,t,e,i,r){var n=this;n.pend.go(function(a){lt.read(n.fd,s,t,e,i,function(o,c,h){a(),r(o,c,h)})})};H.prototype.write=function(s,t,e,i,r){var n=this;n.pend.go(function(a){lt.write(n.fd,s,t,e,i,function(o,c,h){a(),r(o,c,h)})})};H.prototype.createReadStream=function(s){return new At(this,s)};H.prototype.createWriteStream=function(s){return new vt(this,s)};H.prototype.ref=function(){this.refCount+=1};H.prototype.unref=function(){var s=this;if(s.refCount-=1,s.refCount>0)return;if(s.refCount<0)throw new Error("invalid unref");s.autoClose&<.close(s.fd,t);function t(e){e?s.emit("error",e):s.emit("close")}};Ft.inherits(At,ws);function At(s,t){t=t||{},ws.call(this,t),this.context=s,this.context.ref(),this.start=t.start||0,this.endOffset=t.end,this.pos=this.start,this.destroyed=!1}At.prototype._read=function(s){var t=this;if(!t.destroyed){var e=Math.min(t._readableState.highWaterMark,s);if(t.endOffset!=null&&(e=Math.min(e,t.endOffset-t.pos)),e<=0){t.destroyed=!0,t.push(null),t.context.unref();return}t.context.pend.go(function(i){if(t.destroyed)return i();var r=new Buffer(e);lt.read(t.context.fd,r,0,e,t.pos,function(n,a){n?t.destroy(n):a===0?(t.destroyed=!0,t.push(null),t.context.unref()):(t.pos+=a,t.push(r.slice(0,a))),i()})})}};At.prototype.destroy=function(s){this.destroyed||(s=s||new Error("stream destroyed"),this.destroyed=!0,this.emit("error",s),this.context.unref())};Ft.inherits(vt,ce);function vt(s,t){t=t||{},ce.call(this,t),this.context=s,this.context.ref(),this.start=t.start||0,this.endOffset=t.end==null?1/0:+t.end,this.bytesWritten=0,this.pos=this.start,this.destroyed=!1,this.on("finish",this.destroy.bind(this))}vt.prototype._write=function(s,t,e){var i=this;if(!i.destroyed){if(i.pos+s.length>i.endOffset){var r=new Error("maximum file length exceeded");r.code="ETOOBIG",i.destroy(),e(r);return}i.context.pend.go(function(n){if(i.destroyed)return n();lt.write(i.context.fd,s,0,s.length,i.pos,function(a,o){a?(i.destroy(),n(),e(a)):(i.bytesWritten+=o,i.pos+=o,i.emit("progress"),n(),e())})})}};vt.prototype.destroy=function(){this.destroyed||(this.destroyed=!0,this.context.unref())};Ft.inherits(k,wt);function k(s,t){wt.call(this),t=t||{},this.refCount=0,this.buffer=s,this.maxChunkSize=t.maxChunkSize||Number.MAX_SAFE_INTEGER}k.prototype.read=function(s,t,e,i,r){var n=i+e,a=n-this.buffer.length,o=a>0?a:e;this.buffer.copy(s,t,i,n),setImmediate(function(){r(null,o)})};k.prototype.write=function(s,t,e,i,r){s.copy(this.buffer,i,t,t+e),setImmediate(function(){r(null,e,s)})};k.prototype.createReadStream=function(s){s=s||{};var t=new Zi(s);t.destroyed=!1,t.start=s.start||0,t.endOffset=s.end,t.pos=t.endOffset||this.buffer.length;for(var e=this.buffer.slice(t.start,t.pos),i=0;;){var r=i+this.maxChunkSize;if(r>=e.length){i<e.length&&t.write(e.slice(i,e.length));break}t.write(e.slice(i,r)),i=r}return t.end(),t.destroy=function(){t.destroyed=!0},t};k.prototype.createWriteStream=function(s){var t=this;s=s||{};var e=new ce(s);return e.start=s.start||0,e.endOffset=s.end==null?this.buffer.length:+s.end,e.bytesWritten=0,e.pos=e.start,e.destroyed=!1,e._write=function(i,r,n){if(!e.destroyed){var a=e.pos+i.length;if(a>e.endOffset){var o=new Error("maximum file length exceeded");o.code="ETOOBIG",e.destroyed=!0,n(o);return}i.copy(t.buffer,e.pos,0,i.length),e.bytesWritten+=i.length,e.pos=a,e.emit("progress"),n()}},e.destroy=function(){e.destroyed=!0},e};k.prototype.ref=function(){this.refCount+=1};k.prototype.unref=function(){if(this.refCount-=1,this.refCount<0)throw new Error("invalid unref")};function tr(s,t){return new k(s,t)}function er(s,t){return new H(s,t)}});var Ds=F((Br,ys)=>{var X=v("buffer").Buffer,he=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];typeof Int32Array<"u"&&(he=new Int32Array(he));function vs(s){if(X.isBuffer(s))return s;var t=typeof X.alloc=="function"&&typeof X.from=="function";if(typeof s=="number")return t?X.alloc(s):new X(s);if(typeof s=="string")return t?X.from(s):new X(s);throw new Error("input must be buffer, number, or string, received "+typeof s)}function sr(s){var t=vs(4);return t.writeInt32BE(s,0),t}function le(s,t){s=vs(s),X.isBuffer(t)&&(t=t.readUInt32BE(0));for(var e=~~t^-1,i=0;i<s.length;i++)e=he[(e^s[i])&255]^e>>>8;return e^-1}function de(){return sr(le.apply(null,arguments))}de.signed=function(){return le.apply(null,arguments)};de.unsigned=function(){return le.apply(null,arguments)>>>0};ys.exports=de});var Ms=F(U=>{var fe=v("fs"),ir=v("zlib"),Is=As(),rr=Ds(),It=v("util"),Rt=v("events").EventEmitter,Rs=v("stream").Transform,ue=v("stream").PassThrough,nr=v("stream").Writable;U.open=ar;U.fromFd=Ns;U.fromBuffer=or;U.fromRandomAccessReader=xe;U.dosDateTimeToDate=Ps;U.validateFileName=Os;U.ZipFile=Y;U.Entry=ft;U.RandomAccessReader=V;function ar(s,t,e){typeof t=="function"&&(e=t,t=null),t==null&&(t={}),t.autoClose==null&&(t.autoClose=!0),t.lazyEntries==null&&(t.lazyEntries=!1),t.decodeStrings==null&&(t.decodeStrings=!0),t.validateEntrySizes==null&&(t.validateEntrySizes=!0),t.strictFileNames==null&&(t.strictFileNames=!1),e==null&&(e=Dt),fe.open(s,"r",function(i,r){if(i)return e(i);Ns(r,t,function(n,a){n&&fe.close(r,Dt),e(n,a)})})}function Ns(s,t,e){typeof t=="function"&&(e=t,t=null),t==null&&(t={}),t.autoClose==null&&(t.autoClose=!1),t.lazyEntries==null&&(t.lazyEntries=!1),t.decodeStrings==null&&(t.decodeStrings=!0),t.validateEntrySizes==null&&(t.validateEntrySizes=!0),t.strictFileNames==null&&(t.strictFileNames=!1),e==null&&(e=Dt),fe.fstat(s,function(i,r){if(i)return e(i);var n=Is.createFromFd(s,{autoClose:!0});xe(n,r.size,t,e)})}function or(s,t,e){typeof t=="function"&&(e=t,t=null),t==null&&(t={}),t.autoClose=!1,t.lazyEntries==null&&(t.lazyEntries=!1),t.decodeStrings==null&&(t.decodeStrings=!0),t.validateEntrySizes==null&&(t.validateEntrySizes=!0),t.strictFileNames==null&&(t.strictFileNames=!1);var i=Is.createFromBuffer(s,{maxChunkSize:65536});xe(i,s.length,t,e)}function xe(s,t,e,i){typeof e=="function"&&(i=e,e=null),e==null&&(e={}),e.autoClose==null&&(e.autoClose=!0),e.lazyEntries==null&&(e.lazyEntries=!1),e.decodeStrings==null&&(e.decodeStrings=!0);var r=!!e.decodeStrings;if(e.validateEntrySizes==null&&(e.validateEntrySizes=!0),e.strictFileNames==null&&(e.strictFileNames=!1),i==null&&(i=Dt),typeof t!="number")throw new Error("expected totalSize parameter to be a number");if(t>Number.MAX_SAFE_INTEGER)throw new Error("zip file too large. only file sizes up to 2^52 are supported due to JavaScript's Number type being an IEEE 754 double.");s.ref();var n=22,a=65535,o=Math.min(n+a,t),c=B(o),h=t-c.length;rt(s,c,0,o,h,function(l){if(l)return i(l);for(var x=o-n;x>=0;x-=1)if(c.readUInt32LE(x)===101010256){var d=c.slice(x),m=d.readUInt16LE(4);if(m!==0)return i(new Error("multi-disk zip files are not supported: found disk number: "+m));var g=d.readUInt16LE(10),u=d.readUInt32LE(16),p=d.readUInt16LE(20),f=d.length-n;if(p!==f)return i(new Error("invalid comment length. expected: "+f+". found: "+p));var E=r?yt(d,22,d.length,!1):d.slice(22);if(!(g===65535||u===4294967295))return i(null,new Y(s,u,t,g,E,e.autoClose,e.lazyEntries,r,e.validateEntrySizes,e.strictFileNames));var T=B(20),R=h+x-T.length;rt(s,T,0,T.length,R,function(z){if(z)return i(z);if(T.readUInt32LE(0)!==117853008)return i(new Error("invalid zip64 end of central directory locator signature"));var Z=nt(T,8),q=B(56);rt(s,q,0,q.length,Z,function(at){return at?i(at):q.readUInt32LE(0)!==101075792?i(new Error("invalid zip64 end of central directory record signature")):(g=nt(q,32),u=nt(q,48),i(null,new Y(s,u,t,g,E,e.autoClose,e.lazyEntries,r,e.validateEntrySizes,e.strictFileNames)))})});return}i(new Error("end of central directory record signature not found"))})}It.inherits(Y,Rt);function Y(s,t,e,i,r,n,a,o,c,h){var l=this;Rt.call(l),l.reader=s,l.reader.on("error",function(x){Ls(l,x)}),l.reader.once("close",function(){l.emit("close")}),l.readEntryCursor=t,l.fileSize=e,l.entryCount=i,l.comment=r,l.entriesRead=0,l.autoClose=!!n,l.lazyEntries=!!a,l.decodeStrings=!!o,l.validateEntrySizes=!!c,l.strictFileNames=!!h,l.isOpen=!0,l.emittedError=!1,l.lazyEntries||l._readEntry()}Y.prototype.close=function(){this.isOpen&&(this.isOpen=!1,this.reader.unref())};function L(s,t){s.autoClose&&s.close(),Ls(s,t)}function Ls(s,t){s.emittedError||(s.emittedError=!0,s.emit("error",t))}Y.prototype.readEntry=function(){if(!this.lazyEntries)throw new Error("readEntry() called without lazyEntries:true");this._readEntry()};Y.prototype._readEntry=function(){var s=this;if(s.entryCount===s.entriesRead){setImmediate(function(){s.autoClose&&s.close(),!s.emittedError&&s.emit("end")});return}if(!s.emittedError){var t=B(46);rt(s.reader,t,0,t.length,s.readEntryCursor,function(e){if(e)return L(s,e);if(!s.emittedError){var i=new ft,r=t.readUInt32LE(0);if(r!==33639248)return L(s,new Error("invalid central directory file header signature: 0x"+r.toString(16)));if(i.versionMadeBy=t.readUInt16LE(4),i.versionNeededToExtract=t.readUInt16LE(6),i.generalPurposeBitFlag=t.readUInt16LE(8),i.compressionMethod=t.readUInt16LE(10),i.lastModFileTime=t.readUInt16LE(12),i.lastModFileDate=t.readUInt16LE(14),i.crc32=t.readUInt32LE(16),i.compressedSize=t.readUInt32LE(20),i.uncompressedSize=t.readUInt32LE(24),i.fileNameLength=t.readUInt16LE(28),i.extraFieldLength=t.readUInt16LE(30),i.fileCommentLength=t.readUInt16LE(32),i.internalFileAttributes=t.readUInt16LE(36),i.externalFileAttributes=t.readUInt32LE(38),i.relativeOffsetOfLocalHeader=t.readUInt32LE(42),i.generalPurposeBitFlag&64)return L(s,new Error("strong encryption is not supported"));s.readEntryCursor+=46,t=B(i.fileNameLength+i.extraFieldLength+i.fileCommentLength),rt(s.reader,t,0,t.length,s.readEntryCursor,function(n){if(n)return L(s,n);if(!s.emittedError){var a=(i.generalPurposeBitFlag&2048)!==0;i.fileName=s.decodeStrings?yt(t,0,i.fileNameLength,a):t.slice(0,i.fileNameLength);var o=i.fileNameLength+i.extraFieldLength,c=t.slice(i.fileNameLength,o);i.extraFields=[];for(var h=0;h<c.length-3;){var l=c.readUInt16LE(h+0),x=c.readUInt16LE(h+2),d=h+4,m=d+x;if(m>c.length)return L(s,new Error("extra field length exceeds extra field buffer size"));var g=B(x);c.copy(g,0,d,m),i.extraFields.push({id:l,data:g}),h=m}if(i.fileComment=s.decodeStrings?yt(t,o,o+i.fileCommentLength,a):t.slice(o,o+i.fileCommentLength),i.comment=i.fileComment,s.readEntryCursor+=t.length,s.entriesRead+=1,i.uncompressedSize===4294967295||i.compressedSize===4294967295||i.relativeOffsetOfLocalHeader===4294967295){for(var u=null,h=0;h<i.extraFields.length;h++){var p=i.extraFields[h];if(p.id===1){u=p.data;break}}if(u==null)return L(s,new Error("expected zip64 extended information extra field"));var f=0;if(i.uncompressedSize===4294967295){if(f+8>u.length)return L(s,new Error("zip64 extended information extra field does not include uncompressed size"));i.uncompressedSize=nt(u,f),f+=8}if(i.compressedSize===4294967295){if(f+8>u.length)return L(s,new Error("zip64 extended information extra field does not include compressed size"));i.compressedSize=nt(u,f),f+=8}if(i.relativeOffsetOfLocalHeader===4294967295){if(f+8>u.length)return L(s,new Error("zip64 extended information extra field does not include relative header offset"));i.relativeOffsetOfLocalHeader=nt(u,f),f+=8}}if(s.decodeStrings)for(var h=0;h<i.extraFields.length;h++){var p=i.extraFields[h];if(p.id===28789){if(p.data.length<6||p.data.readUInt8(0)!==1)continue;var E=p.data.readUInt32LE(1);if(rr.unsigned(t.slice(0,i.fileNameLength))!==E)continue;i.fileName=yt(p.data,5,p.data.length,!0);break}}if(s.validateEntrySizes&&i.compressionMethod===0){var T=i.uncompressedSize;if(i.isEncrypted()&&(T+=12),i.compressedSize!==T){var R="compressed/uncompressed size mismatch for stored file: "+i.compressedSize+" != "+i.uncompressedSize;return L(s,new Error(R))}}if(s.decodeStrings){s.strictFileNames||(i.fileName=i.fileName.replace(/\\/g,"/"));var z=Os(i.fileName,s.validateFileNameOptions);if(z!=null)return L(s,new Error(z))}s.emit("entry",i),s.lazyEntries||s._readEntry()}})}})}};Y.prototype.openReadStream=function(s,t,e){var i=this,r=0,n=s.compressedSize;if(e==null)e=t,t={};else{if(t.decrypt!=null){if(!s.isEncrypted())throw new Error("options.decrypt can only be specified for encrypted entries");if(t.decrypt!==!1)throw new Error("invalid options.decrypt value: "+t.decrypt);if(s.isCompressed()&&t.decompress!==!1)throw new Error("entry is encrypted and compressed, and options.decompress !== false")}if(t.decompress!=null){if(!s.isCompressed())throw new Error("options.decompress can only be specified for compressed entries");if(!(t.decompress===!1||t.decompress===!0))throw new Error("invalid options.decompress value: "+t.decompress)}if(t.start!=null||t.end!=null){if(s.isCompressed()&&t.decompress!==!1)throw new Error("start/end range not allowed for compressed entry without options.decompress === false");if(s.isEncrypted()&&t.decrypt!==!1)throw new Error("start/end range not allowed for encrypted entry without options.decrypt === false")}if(t.start!=null){if(r=t.start,r<0)throw new Error("options.start < 0");if(r>s.compressedSize)throw new Error("options.start > entry.compressedSize")}if(t.end!=null){if(n=t.end,n<0)throw new Error("options.end < 0");if(n>s.compressedSize)throw new Error("options.end > entry.compressedSize");if(n<r)throw new Error("options.end < options.start")}}if(!i.isOpen)return e(new Error("closed"));if(s.isEncrypted()&&t.decrypt!==!1)return e(new Error("entry is encrypted, and options.decrypt !== false"));i.reader.ref();var a=B(30);rt(i.reader,a,0,a.length,s.relativeOffsetOfLocalHeader,function(o){try{if(o)return e(o);var c=a.readUInt32LE(0);if(c!==67324752)return e(new Error("invalid local file header signature: 0x"+c.toString(16)));var h=a.readUInt16LE(26),l=a.readUInt16LE(28),x=s.relativeOffsetOfLocalHeader+a.length+h+l,d;if(s.compressionMethod===0)d=!1;else if(s.compressionMethod===8)d=t.decompress!=null?t.decompress:!0;else return e(new Error("unsupported compression method: "+s.compressionMethod));var m=x,g=m+s.compressedSize;if(s.compressedSize!==0&&g>i.fileSize)return e(new Error("file data overflows file bounds: "+m+" + "+s.compressedSize+" > "+i.fileSize));var u=i.reader.createReadStream({start:m+r,end:m+n}),p=u;if(d){var f=!1,E=ir.createInflateRaw();u.on("error",function(T){setImmediate(function(){f||E.emit("error",T)})}),u.pipe(E),i.validateEntrySizes?(p=new ut(s.uncompressedSize),E.on("error",function(T){setImmediate(function(){f||p.emit("error",T)})}),E.pipe(p)):p=E,p.destroy=function(){f=!0,E!==p&&E.unpipe(p),u.unpipe(E),u.destroy()}}e(null,p)}finally{i.reader.unref()}})};function ft(){}ft.prototype.getLastModDate=function(){return Ps(this.lastModFileDate,this.lastModFileTime)};ft.prototype.isEncrypted=function(){return(this.generalPurposeBitFlag&1)!==0};ft.prototype.isCompressed=function(){return this.compressionMethod===8};function Ps(s,t){var e=s&31,i=(s>>5&15)-1,r=(s>>9&127)+1980,n=0,a=(t&31)*2,o=t>>5&63,c=t>>11&31;return new Date(r,i,e,c,o,a,n)}function Os(s){return s.indexOf("\\")!==-1?"invalid characters in fileName: "+s:/^[a-zA-Z]:/.test(s)||/^\//.test(s)?"absolute path: "+s:s.split("/").indexOf("..")!==-1?"invalid relative path: "+s:null}function rt(s,t,e,i,r,n){if(i===0)return setImmediate(function(){n(null,B(0))});s.read(t,e,i,r,function(a,o){if(a)return n(a);if(o<i)return n(new Error("unexpected EOF"));n()})}It.inherits(ut,Rs);function ut(s){Rs.call(this),this.actualByteCount=0,this.expectedByteCount=s}ut.prototype._transform=function(s,t,e){if(this.actualByteCount+=s.length,this.actualByteCount>this.expectedByteCount){var i="too many bytes in the stream. expected "+this.expectedByteCount+". got at least "+this.actualByteCount;return e(new Error(i))}e(null,s)};ut.prototype._flush=function(s){if(this.actualByteCount<this.expectedByteCount){var t="not enough bytes in the stream. expected "+this.expectedByteCount+". got only "+this.actualByteCount;return s(new Error(t))}s()};It.inherits(V,Rt);function V(){Rt.call(this),this.refCount=0}V.prototype.ref=function(){this.refCount+=1};V.prototype.unref=function(){var s=this;if(s.refCount-=1,s.refCount>0)return;if(s.refCount<0)throw new Error("invalid unref");s.close(t);function t(e){if(e)return s.emit("error",e);s.emit("close")}};V.prototype.createReadStream=function(s){var t=s.start,e=s.end;if(t===e){var i=new ue;return setImmediate(function(){i.end()}),i}var r=this._readStreamForRange(t,e),n=!1,a=new Nt(this);r.on("error",function(c){setImmediate(function(){n||a.emit("error",c)})}),a.destroy=function(){r.unpipe(a),a.unref(),r.destroy()};var o=new ut(e-t);return a.on("error",function(c){setImmediate(function(){n||o.emit("error",c)})}),o.destroy=function(){n=!0,a.unpipe(o),a.destroy()},r.pipe(a).pipe(o)};V.prototype._readStreamForRange=function(s,t){throw new Error("not implemented")};V.prototype.read=function(s,t,e,i,r){var n=this.createReadStream({start:i,end:i+e}),a=new nr,o=0;a._write=function(c,h,l){c.copy(s,t+o,0,c.length),o+=c.length,l()},a.on("finish",r),n.on("error",function(c){r(c)}),n.pipe(a)};V.prototype.close=function(s){setImmediate(s)};It.inherits(Nt,ue);function Nt(s){ue.call(this),this.context=s,this.context.ref(),this.unreffedYet=!1}Nt.prototype._flush=function(s){this.unref(),s()};Nt.prototype.unref=function(s){this.unreffedYet||(this.unreffedYet=!0,this.context.unref())};var cr="\0\u263A\u263B\u2665\u2666\u2663\u2660\u2022\u25D8\u25CB\u25D9\u2642\u2640\u266A\u266B\u263C\u25BA\u25C4\u2195\u203C\xB6\xA7\u25AC\u21A8\u2191\u2193\u2192\u2190\u221F\u2194\u25B2\u25BC !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u2302\xC7\xFC\xE9\xE2\xE4\xE0\xE5\xE7\xEA\xEB\xE8\xEF\xEE\xEC\xC4\xC5\xC9\xE6\xC6\xF4\xF6\xF2\xFB\xF9\xFF\xD6\xDC\xA2\xA3\xA5\u20A7\u0192\xE1\xED\xF3\xFA\xF1\xD1\xAA\xBA\xBF\u2310\xAC\xBD\xBC\xA1\xAB\xBB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\xDF\u0393\u03C0\u03A3\u03C3\xB5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\xB1\u2265\u2264\u2320\u2321\xF7\u2248\xB0\u2219\xB7\u221A\u207F\xB2\u25A0\xA0";function yt(s,t,e,i){if(i)return s.toString("utf8",t,e);for(var r="",n=t;n<e;n++)r+=cr[s[n]];return r}function nt(s,t){var e=s.readUInt32LE(t),i=s.readUInt32LE(t+4);return i*4294967296+e}var B;typeof Buffer.allocUnsafe=="function"?B=function(s){return Buffer.allocUnsafe(s)}:B=function(s){return new Buffer(s)};function Dt(s){if(s)throw s}});var pe=F((Hr,Bs)=>{var me=class s{constructor(t){this._buffer=t}open(){return Promise.resolve()}close(){return Promise.resolve()}read(t,e,i,r){return this._buffer.copy(t,e,r,r+i),Promise.resolve(t)}buffer(){return this._buffer}static isBufferReader(t){return t instanceof s}};Bs.exports=me});var ge=F((kr,Us)=>{var _e=v("fs"),Ee=class s{constructor(t){this._filename=t}open(){return new Promise((t,e)=>{_e.open(this._filename,"r",438,(i,r)=>{if(i)return e(i);this._fd=r,t()})})}close(){return new Promise((t,e)=>{this._fd?_e.close(this._fd,i=>{if(i)return e(i);delete this._fd,t()}):t()})}read(t,e,i,r){return new Promise((n,a)=>{if(!this._fd)return a(new Error("file not open"));_e.read(this._fd,t,e,i,r,(o,c,h)=>{if(o)return a(o);n(h)})})}fd(){return this._fd}static isFileReader(t){return t instanceof s}};Us.exports=Ee});var qs=F((zr,zs)=>{var hr=v("path"),lr=bs(),Hs=Ms(),dr=pe(),fr=ge(),ur=zt();function ks(s,t,e){return e===t.length?Promise.resolve():Promise.resolve(s(t[e++])).then(()=>ks(s,t,e))}var be=class{constructor(){this._streamTypes={"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml":!0,"application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml":!0,"application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml":!0,"application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml":!0,"application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml":!0,"application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml":!0,"application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml":!0,"application/vnd.openxmlformats-package.relationships+xml":!0},this._headerTypes={"http://schemas.openxmlformats.org/officeDocument/2006/relationships/header":!0,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer":!0},this._actions={},this._defaults={}}shouldProcess(t){if(this._actions[t])return!0;let e=hr.posix.extname(t).replace(/^\./,"");if(!e)return!1;let i=this._defaults[e];return!!(i&&this._streamTypes[i])}openArchive(t){if(dr.isBufferReader(t))return new Promise((e,i)=>{Hs.fromBuffer(t.buffer(),{lazyEntries:!0},function(r,n){if(r)return i(r);e(n)})});if(fr.isFileReader(t))return new Promise((e,i)=>{Hs.fromFd(t.fd(),{lazyEntries:!0,autoClose:!1},function(r,n){if(r)return i(r);e(n)})});throw new Error("Unexpected reader type: "+t.constructor.name)}processEntries(t){let e={},i=[];return new Promise((r,n)=>{t.readEntry(),t.on("error",n),t.on("entry",a=>{let o=a.fileName;e[o]=a,i.push(o),t.readEntry()}),t.on("end",()=>r(this._document))}).then(()=>{let r=i.indexOf("[Content_Types].xml");if(r===-1)throw new Error("Invalid Open Office XML: missing content types");return i.splice(r,1),i.unshift("[Content_Types].xml"),this._actions["[Content_Types].xml"]=!0,ks(n=>{if(this.shouldProcess(n))return this.handleEntry(t,e[n])},i,0)})}extract(t){let e=this.openArchive(t);return this._document=new ur,this._relationships={},this._entryTable={},this._entries=[],e.then(i=>this.processEntries(i)).then(()=>{let i=this._document;return i._textboxes&&i._textboxes.length>0&&(i._textboxes=i._textboxes+`
|
|
18
|
+
`),i._headerTextboxes&&i._headerTextboxes.length>0&&(i._headerTextboxes=i._headerTextboxes+`
|
|
19
|
+
`),i})}handleOpenTag(t){if(t.name==="Override"){let e=this._streamTypes[t.attributes.ContentType];if(e){let i=t.attributes.PartName.replace(/^[/]+/,""),r={action:e,type:t.attributes.ContentType};this._actions[i]=r}}else if(t.name==="Default"){let e=t.attributes.Extension,i=t.attributes.ContentType;this._defaults[e]=i}else if(t.name==="Relationship")this._relationships[t.attributes.Id]={type:t.attributes.Type,target:t.attributes.Target};else if(t.name==="w:document"||t.name==="w:footnotes"||t.name==="w:endnotes"||t.name==="w:comments")this._context=["content","body"],this._pieces=[];else if(t.name==="w:hdr"||t.name==="w:ftr")this._context=["content","header"],this._pieces=[];else if(t.name==="w:endnote"||t.name==="w:footnote"){let e=t.attributes["w:type"]||this._context[0];this._context.unshift(e)}else t.name==="w:tab"&&this._context[0]==="content"?this._pieces.push(" "):t.name==="w:br"&&this._context[0]==="content"?(t.attributes["w:type"]||"")==="page"?this._pieces.push(`
|
|
20
|
+
`):this._pieces.push(`
|
|
21
|
+
`):t.name==="w:del"||t.name==="w:instrText"?this._context.unshift("deleted"):t.name==="w:tabs"?this._context.unshift("tabs"):t.name==="w:tc"?this._context.unshift("cell"):t.name==="w:drawing"?this._context.unshift("drawing"):t.name==="w:txbxContent"&&(this._context.unshift(this._pieces),this._context.unshift("textbox"),this._pieces=[])}handleCloseTag(t){if(t.name==="w:document")this._context=null,this._document._body=this._pieces.join("");else if(t.name==="w:footnote"||t.name==="w:endnote")this._context.shift();else if(t.name==="w:footnotes")this._context=null,this._document._footnotes=this._pieces.join("");else if(t.name==="w:endnotes")this._context=null,this._document._endnotes=this._pieces.join("");else if(t.name==="w:comments")this._context=null,this._document._annotations=this._pieces.join("");else if(t.name==="w:hdr")this._context=null,this._document._headers=this._document._headers+this._pieces.join("");else if(t.name==="w:ftr")this._context=null,this._document._footers=this._document._footers+this._pieces.join("");else if(t.name==="w:p")(this._context[0]==="content"||this._context[0]==="cell"||this._context[0]==="textbox")&&this._pieces.push(`
|
|
22
|
+
`);else if(t.name==="w:del"||t.name==="w:instrText")this._context.shift();else if(t.name==="w:tabs")this._context.shift();else if(t.name==="w:tc")this._pieces.pop(),this._pieces.push(" "),this._context.shift();else if(t.name==="w:tr")this._pieces.push(`
|
|
23
|
+
`);else if(t.name==="w:drawing")this._context.shift();else if(t.name==="w:txbxContent"){let e=this._pieces.join("");if(this._context.shift()!=="textbox")throw new Error("Invalid textbox context");if(this._pieces=this._context.shift(),this._context[0]==="drawing"||e.length==0)return;let n=this._context.includes("header")?"_headerTextboxes":"_textboxes";this._document[n]?this._document[n]=this._document[n]+`
|
|
24
|
+
`+e:this._document[n]=e}}createXmlParser(){let t=new lr.SaxesParser;return t.on("opentag",e=>{try{this.handleOpenTag(e)}catch(i){t.fail(i.message)}}),t.on("closetag",e=>{try{this.handleCloseTag(e)}catch(i){t.fail(i.message)}}),t.on("text",e=>{try{if(!this._context)return;(this._context[0]==="content"||this._context[0]==="cell"||this._context[0]==="textbox")&&this._pieces.push(e)}catch(i){t.fail(i.message)}}),t}handleEntry(t,e){return new Promise((i,r)=>{t.openReadStream(e,(n,a)=>{if(n)return r(n);this._source=e.fileName;let o=this.createXmlParser();o.on("error",c=>{a.destroy(c),r(c)}),o.on("end",()=>i()),a.on("end",()=>o.close()),a.on("error",c=>r(c)),a.on("readable",()=>{for(;;){let c=a.read(4096);if(c===null)return;o.write(c)}})})})}};zs.exports=be});var Er=F((qr,Ws)=>{var{Buffer:$s}=v("buffer"),xr=We(),mr=qs(),pr=pe(),_r=ge(),Ce=class{constructor(){}extract(t){let e=null;$s.isBuffer(t)?e=new pr(t):typeof t=="string"&&(e=new _r(t));let i=$s.alloc(512);return e.open().then(()=>e.read(i,0,512,0)).then(r=>{let n=null;if(r.readUInt16BE(0)===53455)n=xr;else if(r.readUInt16BE(0)===20555){let a=r.readUInt16BE(2);(a===772||a===1286||a===1800)&&(n=mr)}if(!n)throw new Error("Unable to read this type of file");return new n().extract(e)}).finally(()=>e.close())}};Ws.exports=Ce});export default Er();
|
package/dist/index.js
CHANGED
|
@@ -1,96 +1,68 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
spinner?.stop();
|
|
70
|
-
if (result.stdout.length > 0)
|
|
71
|
-
process.stdout.write(`${result.stdout.join('\n')}\n`);
|
|
72
|
-
if (result.stderr.length > 0)
|
|
73
|
-
process.stderr.write(`${result.stderr.join('\n')}\n`);
|
|
74
|
-
process.exitCode = result.exitCode;
|
|
75
|
-
}
|
|
76
|
-
catch (e) {
|
|
77
|
-
if (isForgeError(e)) {
|
|
78
|
-
process.stderr.write(`${renderError(e, { debug }).join('\n')}\n`);
|
|
79
|
-
process.exitCode = 2;
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
// Commander throws for --help, --version, and argument errors, having
|
|
83
|
-
// already printed. Only help and version mean success — an unknown
|
|
84
|
-
// option or a missing option argument is a usage error and must exit 2,
|
|
85
|
-
// never Commander's own exitCode 1, which would collide with spec §9's
|
|
86
|
-
// "1 = some files failed".
|
|
87
|
-
if (e instanceof Error && 'code' in e && 'exitCode' in e) {
|
|
88
|
-
const code = e.code;
|
|
89
|
-
process.exitCode = code === 'commander.helpDisplayed' || code === 'commander.version' ? 0 : 2;
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
throw e;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
await main();
|
|
96
|
-
//# sourceMappingURL=index.js.map
|
|
2
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
3
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
4
|
+
import{d as F}from"./chunks/chunk-VB665HTV.js";import{b as z,d as J}from"./chunks/chunk-2WYHI73Y.js";import{a as q}from"./chunks/chunk-QVACE4IE.js";import{a as U}from"./chunks/chunk-FQV57RMH.js";import{a as v}from"./chunks/chunk-V4GHQGQM.js";import{a as N}from"./chunks/chunk-7YQR2MVH.js";import"./chunks/chunk-EOYBXOCV.js";import{F as d,I,S as R,T as S,b as B,d as k}from"./chunks/chunk-DRBA23IQ.js";import{d as L}from"./chunks/chunk-J7FLFHQJ.js";import"./chunks/chunk-TMUK2DD3.js";import*as se from"node:module";var b=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},C=class extends b{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var E=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new C(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,n):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function T(o){let e=o.name()+(o.variadic===!0?"...":"");return o.required?"<"+e+">":"["+e+"]"}import{EventEmitter as he}from"node:events";import j from"node:child_process";import O from"node:path";import V from"node:fs";import m from"node:process";import{stripVTControlCharacters as ce}from"node:util";import{stripVTControlCharacters as ae}from"node:util";var $=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(i=>!i._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((i,s)=>i.name().localeCompare(s.name())),t}compareOptions(e,t){let n=i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,"");return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(i=>!i.hidden),n=e._getHelpOption();if(n&&!n.hidden){let i=n.short&&e._findOption(n.short),s=n.long&&e._findOption(n.long);!i&&!s?t.push(n):n.long&&!s?t.push(e.createOption(n.long,n.description)):n.short&&!i&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let i=n.options.filter(s=>!s.hidden);t.push(...i)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(n=>T(n)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(i)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(i)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let n="";for(let i=e.parent;i;i=i.parent)n=i.name()+" "+n;return n+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,""]}groupItems(e,t,n){let i=new Map;return e.forEach(s=>{let r=n(s);i.has(r)||i.set(r,[])}),t.forEach(s=>{let r=n(s);i.has(r)||i.set(r,[]),i.get(r).push(s)}),i}formatHelp(e,t){let n=t.padWidth(e,t),i=t.helpWidth??80;function s(u,c){return t.formatItem(u,n,c,t)}let r=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],a=t.commandDescription(e);a.length>0&&(r=r.concat([t.boxWrap(t.styleCommandDescription(a),i),""]));let h=t.visibleArguments(e).map(u=>s(t.styleArgumentTerm(t.argumentTerm(u)),t.styleArgumentDescription(t.argumentDescription(u))));if(r=r.concat(this.formatItemList("Arguments:",h,t)),this.groupItems(e.options,t.visibleOptions(e),u=>u.helpGroupHeading??"Options:").forEach((u,c)=>{let g=u.map(f=>s(t.styleOptionTerm(t.optionTerm(f)),t.styleOptionDescription(t.optionDescription(f))));r=r.concat(this.formatItemList(c,g,t))}),t.showGlobalOptions){let u=t.visibleGlobalOptions(e).map(c=>s(t.styleOptionTerm(t.optionTerm(c)),t.styleOptionDescription(t.optionDescription(c))));r=r.concat(this.formatItemList("Global Options:",u,t))}return this.groupItems(e.commands,t.visibleCommands(e),u=>u.helpGroup()||"Commands:").forEach((u,c)=>{let g=u.map(f=>s(t.styleSubcommandTerm(t.subcommandTerm(f)),t.styleSubcommandDescription(t.subcommandDescription(f))));r=r.concat(this.formatItemList(c,g,t))}),r.join(`
|
|
5
|
+
`)}displayWidth(e){return ae(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t==="[command]"?this.styleSubcommandText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleCommandText(t)).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleSubcommandText(t)).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,i){let r=" ".repeat(2);if(!n)return r+e;let a=e.padEnd(t+e.length-i.displayWidth(e)),h=2,l=(this.helpWidth??80)-t-h-2,u;return l<this.minWidthToWrap||i.preformatted(n)?u=n:u=i.boxWrap(n,l).replace(/\n/g,`
|
|
6
|
+
`+" ".repeat(t+h)),r+a+" ".repeat(h)+u.replace(/\n/g,`
|
|
7
|
+
${r}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),i=/[\s]*[^\s]+/g,s=[];return n.forEach(r=>{let a=r.match(i);if(a===null){s.push("");return}let h=[a.shift()],p=this.displayWidth(h[0]);a.forEach(l=>{let u=this.displayWidth(l);if(p+u<=t){h.push(l),p+=u;return}s.push(h.join(""));let c=l.trimStart();h=[c],p=this.displayWidth(c)}),s.push(h.join(""))}),s.join(`
|
|
8
|
+
`)}};var w=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=ue(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new C(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,n):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?K(this.name().replace(/^no-/,"")):K(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},H=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,n)=>{this.positiveOptions.has(n)&&this.dualOptions.add(n)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let i=this.negativeOptions.get(n).presetArg,s=i!==void 0?i:!1;return t.negate===(s===e)}};function K(o){return o.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function ue(o){let e,t,n=/^-[^-]$/,i=/^--[^-]/,s=o.split(/[ |,]+/).concat("guard");if(n.test(s[0])&&(e=s.shift()),i.test(s[0])&&(t=s.shift()),!e&&n.test(s[0])&&(e=s.shift()),!e&&i.test(s[0])&&(e=t,t=s.shift()),s[0].startsWith("-")){let r=s[0],a=`option creation failed due to '${r}' in option flags '${o}'`;throw/^-[^-][^-]/.test(r)?new Error(`${a}
|
|
9
|
+
- a short flag is a single dash and a single character
|
|
10
|
+
- either use a single dash and a single character (for a short flag)
|
|
11
|
+
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`):n.test(r)?new Error(`${a}
|
|
12
|
+
- too many short flags`):i.test(r)?new Error(`${a}
|
|
13
|
+
- too many long flags`):new Error(`${a}
|
|
14
|
+
- unrecognised flag format`)}if(e===void 0&&t===void 0)throw new Error(`option creation failed due to no flags found in '${o}'.`);return{shortFlag:e,longFlag:t}}function le(o,e){if(Math.abs(o.length-e.length)>3)return Math.max(o.length,e.length);let t=[];for(let n=0;n<=o.length;n++)t[n]=[n];for(let n=0;n<=e.length;n++)t[0][n]=n;for(let n=1;n<=e.length;n++)for(let i=1;i<=o.length;i++){let s;o[i-1]===e[n-1]?s=0:s=1,t[i][n]=Math.min(t[i-1][n]+1,t[i][n-1]+1,t[i-1][n-1]+s),i>1&&n>1&&o[i-1]===e[n-2]&&o[i-2]===e[n-1]&&(t[i][n]=Math.min(t[i][n],t[i-2][n-2]+1))}return t[o.length][e.length]}function P(o,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=o.startsWith("--");t&&(o=o.slice(2),e=e.map(r=>r.slice(2)));let n=[],i=3,s=.4;return e.forEach(r=>{if(r.length<=1)return;let a=le(o,r),h=Math.max(o.length,r.length);(h-a)/h>s&&(a<i?(i=a,n=[r]):a===i&&n.push(r))}),n.sort((r,a)=>r.localeCompare(a)),t&&(n=n.map(r=>`--${r}`)),n.length>1?`
|
|
15
|
+
(Did you mean one of ${n.join(", ")}?)`:n.length===1?`
|
|
16
|
+
(Did you mean ${n[0]}?)`:""}var x=class o extends he{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:t=>m.stdout.write(t),writeErr:t=>m.stderr.write(t),outputError:(t,n)=>n(t),getOutHelpWidth:()=>m.stdout.isTTY?m.stdout.columns:void 0,getErrHelpWidth:()=>m.stderr.isTTY?m.stderr.columns:void 0,getOutHasColors:()=>Q()??(m.stdout.isTTY&&m.stdout.hasColors?.()),getErrHasColors:()=>Q()??(m.stderr.isTTY&&m.stderr.hasColors?.()),stripColor:t=>ce(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,n){let i=t,s=n;typeof i=="object"&&i!==null&&(s=i,i=null),s=s||{};let[,r,a]=e.match(/([^ ]+) *(.*)/),h=this.createCommand(r);return i&&(h.description(i),h._executableHandler=!0),s.isDefault&&(this._defaultCommandName=h._name),h._hidden=!!(s.noHelp||s.hidden),h._executableFile=s.executableFile||null,a&&h.arguments(a),this._registerCommand(h),h.parent=this,h.copyInheritedSettings(this),i?this:h}createCommand(e){return new o(e)}createHelp(){return Object.assign(new $,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...e},this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
|
|
17
|
+
- specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new E(e,t)}argument(e,t,n,i){let s=this.createArgument(e,t);return typeof n=="function"?s.default(i).argParser(n):s.default(n),this.addArgument(s),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t?.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,e&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let n=e??"help [command]",[,i,s]=n.match(/([^ ]+) *(.*)/),r=t??"display help for command",a=this.createCommand(i);return a.helpOption(!1),s&&a.arguments(s),r&&a.description(r),this._addImplicitHelpCommand=!0,this._helpCommand=a,(e||t)&&this._initCommandGroup(a),this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(e),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let n=["preSubcommand","preAction","postAction"];if(!n.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
|
|
18
|
+
Expecting one of '${n.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,n){this._exitCallback&&this._exitCallback(new b(e,t,n)),m.exit(e)}action(e){let t=n=>{let i=this.registeredArguments.length,s=n.slice(0,i);return this._storeOptionsAsProperties?s[i]=this:s[i]=this.opts(),s.push(this),e.apply(this,s)};return this._actionHandler=t,this}createOption(e,t){return new w(e,t)}_callParseArg(e,t,n,i){try{return e.parseArg(t,n)}catch(s){if(s.code==="commander.invalidArgument"){let r=`${i} ${s.message}`;this.error(r,{exitCode:s.exitCode,code:s.code})}throw s}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let n=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${n}'
|
|
19
|
+
- already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=i=>[i.name()].concat(i.aliases()),n=t(e).find(i=>this._findCommand(i));if(n){let i=t(this._findCommand(n)).join("|"),s=t(e).join("|");throw new Error(`cannot add command '${s}' as already have command '${i}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),n=e.attributeName();e.defaultValue!==void 0&&this.setOptionValueWithSource(n,e.defaultValue,"default");let i=(s,r,a)=>{s==null&&e.presetArg!==void 0&&(s=e.presetArg);let h=this.getOptionValue(n);s!==null&&e.parseArg?s=this._callParseArg(e,s,h,r):s!==null&&e.variadic&&(s=e._collectValue(s,h)),s==null&&(e.negate?s=!1:e.isBoolean()||e.optional?s=!0:s=""),this.setOptionValueWithSource(n,s,a)};return this.on("option:"+t,s=>{let r=`error: option '${e.flags}' argument '${s}' is invalid.`;i(s,r,"cli")}),e.envVar&&this.on("optionEnv:"+t,s=>{let r=`error: option '${e.flags}' value '${s}' from env '${e.envVar}' is invalid.`;i(s,r,"env")}),this}_optionEx(e,t,n,i,s){if(typeof t=="object"&&t instanceof w)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let r=this.createOption(t,n);if(r.makeOptionMandatory(!!e.mandatory),typeof i=="function")r.default(s).argParser(i);else if(i instanceof RegExp){let a=i;i=(h,p)=>{let l=a.exec(h);return l?l[0]:p},r.default(s).argParser(i)}else r.default(i);return this.addOption(r)}option(e,t,n,i){return this._optionEx({},e,t,n,i)}requiredOption(e,t,n,i){return this._optionEx({mandatory:!0},e,t,n,i)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,n){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=n,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(n=>{n.getOptionValueSource(e)!==void 0&&(t=n.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){m.versions?.electron&&(t.from="electron");let i=m.execArgv??[];(i.includes("-e")||i.includes("--eval")||i.includes("-p")||i.includes("--print"))&&(t.from="eval")}e===void 0&&(e=m.argv),this.rawArgs=e.slice();let n;switch(t.from){case void 0:case"node":this._scriptPath=e[1],n=e.slice(2);break;case"electron":m.defaultApp?(this._scriptPath=e[1],n=e.slice(2)):n=e.slice(1);break;case"user":n=e.slice(0);break;case"eval":n=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",n}parse(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return this._parseCommand([],n),this}async parseAsync(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return await this._parseCommand([],n),this}_prepareForParse(){this._savedState===null?(this.options.filter(e=>e.negate&&e.defaultValue===void 0&&this.getOptionValue(e.attributeName())===void 0).forEach(e=>{let t=e.long.replace(/^--no-/,"--");this._findOption(t)||this.setOptionValueWithSource(e.attributeName(),!0,"default")}),this.saveStateBeforeParse()):this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
20
|
+
- either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(e,t,n){if(V.existsSync(e))return;let i=t?`searched for local subcommand relative to directory '${t}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",s=`'${e}' does not exist
|
|
21
|
+
- if '${n}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
22
|
+
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
23
|
+
- ${i}`;throw new Error(s)}_executeSubCommand(e,t){t=t.slice();let n=[".js",".ts",".tsx",".mjs",".cjs"];function i(l,u){let c=O.resolve(l,u);if(V.existsSync(c))return c;if(n.includes(O.extname(u)))return;let g=n.find(f=>V.existsSync(`${c}${f}`));if(g)return`${c}${g}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s=e._executableFile||`${this._name}-${e._name}`,r=this._executableDir||"";if(this._scriptPath){let l;try{l=V.realpathSync(this._scriptPath)}catch{l=this._scriptPath}r=O.resolve(O.dirname(l),r)}if(r){let l=i(r,s);if(!l&&!e._executableFile&&this._scriptPath){let u=O.basename(this._scriptPath,O.extname(this._scriptPath));u!==this._name&&(l=i(r,`${u}-${e._name}`))}s=l||s}let a=n.includes(O.extname(s)),h;m.platform!=="win32"?a?(t.unshift(s),t=Y(m.execArgv).concat(t),h=j.spawn(m.argv[0],t,{stdio:"inherit"})):h=j.spawn(s,t,{stdio:"inherit"}):(this._checkForMissingExecutable(s,r,e._name),t.unshift(s),t=Y(m.execArgv).concat(t),h=j.spawn(m.execPath,t,{stdio:"inherit"})),h.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(u=>{m.on(u,()=>{h.killed===!1&&h.exitCode===null&&h.kill(u)})});let p=this._exitCallback;h.on("close",l=>{l=l??1,p?p(new b(l,"commander.executeSubCommandAsync","(close)")):m.exit(l)}),h.on("error",l=>{if(l.code==="ENOENT")this._checkForMissingExecutable(s,r,e._name);else if(l.code==="EACCES")throw new Error(`'${s}' not executable`);if(!p)m.exit(1);else{let u=new b(1,"commander.executeSubCommandAsync","(error)");u.nestedError=l,p(u)}}),this.runningCommand=h}_dispatchSubcommand(e,t,n){let i=this._findCommand(e);i||this.help({error:!0}),i._prepareForParse();let s;return s=this._chainOrCallSubCommandHook(s,i,"preSubcommand"),s=this._chainOrCall(s,()=>{if(i._executableHandler)this._executeSubCommand(i,t.concat(n));else return i._parseCommand(t,n)}),s}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(n,i,s)=>{let r=i;if(i!==null&&n.parseArg){let a=`error: command-argument value '${i}' is invalid for argument '${n.name()}'.`;r=this._callParseArg(n,i,s,a)}return r};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,i)=>{let s=n.defaultValue;n.variadic?i<this.args.length?(s=this.args.slice(i),n.parseArg&&(s=s.reduce((r,a)=>e(n,a,r),n.defaultValue))):s===void 0&&(s=[]):i<this.args.length&&(s=this.args[i],n.parseArg&&(s=e(n,s,n.defaultValue))),t[i]=s}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,i=[];return this._getCommandAndAncestors().reverse().filter(s=>s._lifeCycleHooks[t]!==void 0).forEach(s=>{s._lifeCycleHooks[t].forEach(r=>{i.push({hookedCommand:s,callback:r})})}),t==="postAction"&&i.reverse(),i.forEach(s=>{n=this._chainOrCall(n,()=>s.callback(s.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let i=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(s=>{i=this._chainOrCall(i,()=>s(this,t))}),i}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let i=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},s=`command:${this.name()}`;if(this._actionHandler){i(),this._processArguments();let r;return r=this._chainOrCallHooks(r,"preAction"),r=this._chainOrCall(r,()=>this._actionHandler(this.processedArgs)),this.parent&&(r=this._chainOrCall(r,()=>{this.parent.emit(s,e,t)})),r=this._chainOrCallHooks(r,"postAction"),r}if(this.parent?.listenerCount(s))i(),this._processArguments(),this.parent.emit(s,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(i(),this._processArguments())}else this.commands.length?(i(),this.help({error:!0})):(i(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(n=>{let i=n.attributeName();return this.getOptionValue(i)===void 0?!1:this.getOptionValueSource(i)!=="default"});e.filter(n=>n.conflictsWith.length>0).forEach(n=>{let i=e.find(s=>n.conflictsWith.includes(s.attributeName()));i&&this._conflictingOption(n,i)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],i=t;function s(l){return l.length>1&&l[0]==="-"}let r=l=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(l)?!this._getCommandAndAncestors().some(u=>u.options.map(c=>c.short).some(c=>/^-\d$/.test(c))):!1,a=null,h=null,p=0;for(;p<e.length||h;){let l=h??e[p++];if(h=null,l==="--"){i===n&&i.push(l),i.push(...e.slice(p));break}if(a&&(!s(l)||r(l))){this.emit(`option:${a.name()}`,l);continue}if(a=null,s(l)){let u=this._findOption(l);if(u){if(u.required){let c=e[p++];c===void 0&&this.optionMissingArgument(u),this.emit(`option:${u.name()}`,c)}else if(u.optional){let c=null;p<e.length&&(!s(e[p])||r(e[p]))&&(c=e[p++]),this.emit(`option:${u.name()}`,c)}else this.emit(`option:${u.name()}`);a=u.variadic?u:null;continue}}if(l.length>2&&l[0]==="-"&&l[1]!=="-"){let u=this._findOption(`-${l[1]}`);if(u){u.required||u.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${u.name()}`,l.slice(2)):(this.emit(`option:${u.name()}`),h=`-${l.slice(2)}`);continue}}if(/^--[^=]+=/.test(l)){let u=l.indexOf("="),c=this._findOption(l.slice(0,u));if(c&&(c.required||c.optional)){this.emit(`option:${c.name()}`,l.slice(u+1));continue}}if(i===t&&s(l)&&!(this.commands.length===0&&r(l))&&(i=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(l)){t.push(l),n.push(...e.slice(p));break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l,...e.slice(p));break}else if(this._defaultCommandName){n.push(l,...e.slice(p));break}}if(this._passThroughOptions){i.push(l,...e.slice(p));break}i.push(l)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let i=this.options[n].attributeName();e[i]=i===this._versionOptionName?this._version:this[i]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
|
|
24
|
+
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
25
|
+
`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
26
|
+
`),this.outputHelp({error:!0}));let n=t||{},i=n.exitCode||1,s=n.code||"commander.error";this._exit(i,s,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in m.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,m.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new H(this.options),t=n=>this.getOptionValue(n)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(n));this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(n=>{Object.keys(n.implied).filter(i=>!t(i)).forEach(i=>{this.setOptionValueWithSource(i,n.implied[i],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let n=r=>{let a=r.attributeName(),h=this.getOptionValue(a),p=this.options.find(u=>u.negate&&a===u.attributeName()),l=this.options.find(u=>!u.negate&&a===u.attributeName());return p&&(p.presetArg===void 0&&h===!1||p.presetArg!==void 0&&h===p.presetArg)?p:l||r},i=r=>{let a=n(r),h=a.attributeName();return this.getOptionValueSource(h)==="env"?`environment variable '${a.envVar}'`:`option '${a.flags}'`},s=`error: ${i(e)} cannot be used with ${i(t)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let i=[],s=this;do{let r=s.createHelp().visibleOptions(s).filter(a=>a.long).map(a=>a.long);i=i.concat(r),s=s.parent}while(s&&!s._enablePositionalOptions);t=P(e,i)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?"":"s",i=e.length,s=this.parent?` for '${this.name()}'`:"",r=e.join(", "),a=`error: too many arguments${s}. Expected ${t} argument${n} but got ${i}: ${r}.`;this.error(a,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let i=[];this.createHelp().visibleCommands(this).forEach(s=>{i.push(s.name()),s.alias()&&i.push(s.alias())}),t=P(e,i)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:"commander.unknownCommand"})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",n=n||"output the version number";let i=this.createOption(t,n);return this._versionOptionName=i.attributeName(),this._registerOption(i),this.on("option:"+i.name(),()=>{this._outputConfiguration.writeOut(`${e}
|
|
27
|
+
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let n=this.parent?._findCommand(e);if(n){let i=[n.name()].concat(n.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${i}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(n=>T(n));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=O.basename(e,O.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let i=t.formatHelp(this,t);return n.hasColors?i:this._outputConfiguration.stripColor(i)}_getOutputContext(e){e=e||{};let t=!!e.error,n,i,s;return t?(n=a=>this._outputConfiguration.writeErr(a),i=this._outputConfiguration.getErrHasColors(),s=this._outputConfiguration.getErrHelpWidth()):(n=a=>this._outputConfiguration.writeOut(a),i=this._outputConfiguration.getOutHasColors(),s=this._outputConfiguration.getOutHelpWidth()),{error:t,write:a=>(i||(a=this._outputConfiguration.stripColor(a)),n(a)),hasColors:i,helpWidth:s}}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let n=this._getOutputContext(e),i={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(r=>r.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);let s=this.helpInformation({error:n.error});if(t&&(s=t(s),typeof s!="string"&&!Buffer.isBuffer(s)))throw new Error("outputHelp callback must return a string or a Buffer");n.write(s),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",i),this._getCommandAndAncestors().forEach(r=>r.emit("afterAllHelp",i))}helpOption(e,t){return typeof e=="boolean"?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??"-h, --help",t??"display help for command"),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(m.exitCode??0);t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let n=["beforeAll","before","after","afterAll"];if(!n.includes(e))throw new Error(`Unexpected value for position to addHelpText.
|
|
28
|
+
Expecting one of '${n.join("', '")}'`);let i=`${e}Help`;return this.on(i,s=>{let r;typeof t=="function"?r=t({error:s.error,command:s.command}):r=t,r&&s.write(`${r}
|
|
29
|
+
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(i=>t.is(i))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Y(o){return o.map(e=>{if(!e.startsWith("--inspect"))return e;let t,n="127.0.0.1",i="9229",s;return(s=e.match(/^(--inspect(-brk)?)$/))!==null?t=s[1]:(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=s[1],/^\d+$/.test(s[3])?i=s[3]:n=s[3]):(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=s[1],n=s[3],i=s[4]),t&&i!=="0"?`${t}=${n}:${parseInt(i)+1}`:e})}function Q(){if(m.env.NO_COLOR||m.env.FORCE_COLOR==="0"||m.env.FORCE_COLOR==="false")return!1;if(m.env.FORCE_COLOR||m.env.CLICOLOR_FORCE!==void 0)return!0}var Qe=new x;function pe(o){let[,e,t,...n]=o;if(e===void 0||e==="list")return{kind:"config",action:"list"};if(e==="path")return{kind:"config",action:"path"};if(e==="set"){if(t===void 0||!N.includes(t))throw d(`Unknown config setting ${t??"(none)"}.`,`Try one of: ${N.join(", ")}.`);let i=n.join(" ");if(i.length===0)throw d(`forge config set ${t} needs a value.`);return{kind:"config",action:"set",key:t,value:i}}throw d(`Unknown config action ${e}.`,"Try: forge config list, forge config set <setting> <value>, or forge config path.")}var de={jpg:"jpeg",tif:"tiff",heif:"heic"};function X(o){let e=o.toLowerCase().replace(/^\./,""),t=B(de[e]??e);if(!t)throw d(`${o} is not a format Forge knows.`,"Run forge --formats to see what is available.");return t.id}function D(o){let e=Number(o);if(!Number.isInteger(e)||e<1||e>100)throw d(`Quality must be a whole number between 1 and 100, not ${o}.`);return e}function W(o){let e=Number(o);if(!Number.isInteger(e)||e<1)throw d(`Concurrency must be a positive whole number, not ${o}.`);return e}var fe=`
|
|
30
|
+
Exit codes:
|
|
31
|
+
0 every input succeeded
|
|
32
|
+
1 the command was understood, and at least one input failed or was refused
|
|
33
|
+
2 the command itself was invalid: an unknown flag, a missing argument, contradictory flags`,me=`
|
|
34
|
+
Other commands:
|
|
35
|
+
forge probe <files...> what each file is and what Forge can do with it
|
|
36
|
+
forge palette <image> an image's main colours (--json, --svg, --inside <hex>)
|
|
37
|
+
forge scale <colour> 50\u2013950 from one colour, with it at 500 (--json, --svg)
|
|
38
|
+
forge config [list | path | set <setting> <value>]
|
|
39
|
+
forge extensions [add | remove <id>] optional extras, such as boost and remove-background
|
|
40
|
+
forge mcp run as a local MCP server over stdio, for AI agents`;function Z(o){let e=L(String(o));if(e===void 0)throw d(`${o} is not a size.`,"Try a number with a unit, for example 500kb, 2mb or 1.5mb.");return e}function ge(o){let e=o.slice(1).filter(n=>n!=="--json"),t=e.find(n=>n.startsWith("-"));if(t!==void 0)throw d(`forge probe takes files, not ${t}.`,"Try: forge probe photo.jpg --json");if(e.length===0)throw d("No files given.","Name a file, for example: forge probe scan.pdf --json");return{kind:"probe",inputs:e}}function _e(o){let e=o.slice(1).filter(r=>r!=="--json"),t=e.find(r=>r.startsWith("-"));if(t!==void 0)throw d(`forge extensions does not take ${t}.`,"Try: forge extensions, forge extensions add <id>, or forge extensions remove <id>.");let[n,i,...s]=e;if(n===void 0)return{kind:"extensions",action:"list"};if(n!=="add"&&n!=="remove")throw d(`Unknown extensions action ${n}.`,"Try: forge extensions, forge extensions add <id>, or forge extensions remove <id>.");if(i===void 0||s.length>0)throw d(`forge extensions ${n} takes exactly one extension.`,`Try: forge extensions ${n} boost`);return{kind:"extensions",action:n,id:i}}function ee(o){if(o===void 0)throw d("No colour given.","Try: forge scale 6579FD \u2014 or quote it, '#6579FD', because an unquoted # starts a comment in the shell.");let e=q(o);if(!e)throw d(`${o} is not a colour.`,"Try a hex code, for example 6579FD or #6579FD.");return e}var be={palette:`Usage: forge palette <image> [--json] [--svg] [--inside <hex>]
|
|
41
|
+
|
|
42
|
+
An image's main colours, most of the image first.
|
|
43
|
+
--json one JSON document: palette.colours[] with hex, rgb, oklch, share
|
|
44
|
+
--svg a card of swatches; pipe to pbcopy and paste into Figma
|
|
45
|
+
--inside <hex> the shades of the palette colour nearest <hex>
|
|
46
|
+
`,scale:`Usage: forge scale <colour> [--json] [--svg]
|
|
47
|
+
|
|
48
|
+
50\u2013950 built in OKLCH, with <colour> at 500. Pass the hex without #, or quote it.
|
|
49
|
+
--json one JSON document: scale.steps[] with hex, oklch, white, black
|
|
50
|
+
--svg a card of swatches; pipe to pbcopy and paste into Figma
|
|
51
|
+
`};function Oe(o){let[e,...t]=o;if(t.includes("--help")||t.includes("-h"))throw process.stdout.write(be[e==="scale"?"scale":"palette"]),new b(0,"commander.helpDisplayed","(outputHelp)");let n=t.filter(h=>h!=="--json"&&h!=="--svg"),i=t.includes("--svg"),s=n.indexOf("--inside"),r=s===-1?void 0:n[s+1];s!==-1&&n.splice(s,2);let a=n.find(h=>h.startsWith("-"));if(a!==void 0)throw d(`forge ${e} does not take ${a}.`,`Try: forge ${e} --help`);if(e==="scale"){if(s!==-1)throw d("--inside is for forge palette.","Try: forge palette photo.jpg --inside F26E69");if(n.length>1)throw d("forge scale takes one colour.","Try: forge scale 6579FD");return{kind:"scale",colour:ee(n[0]),svg:i}}if(n.length!==1)throw d(n.length===0?"No image given.":"forge palette takes one image.","Try: forge palette photo.jpg");return{kind:"palette",input:n[0],svg:i,...s===-1?{}:{inside:ee(r)}}}function G(o){let e=o.indexOf("--");return(e===-1?o:o.slice(0,e)).includes("--json")}function Ce(o){let e=o.indexOf("--"),t=e===-1?o:o.slice(0,e),n=e===-1?[]:o.slice(e),i=[],s;for(let r=0;r<t.length;r++){let a=t[r],h=a.startsWith("--boost=")?a.slice(8):void 0;if(a!=="--boost"&&h===void 0){i.push(a);continue}let p=h;if(p===void 0&&/^\d+$/.test(t[r+1]??"")&&(p=t[++r]),p!==void 0&&p!=="2"&&p!=="4")throw d(`--boost takes 2 or 4, not ${p}.`,"Try --boost, --boost 2 or --boost 4.");s=p==="4"?4:2}return{rest:[...i,...n],...s===void 0?{}:{scale:s}}}function te(o){let e=o;if(e[0]==="config"||e[0]==="probe"||e[0]==="extensions"||e[0]==="palette"||e[0]==="scale")return we(e);let t=Ce(e);return xe(t.rest,t.scale)}function we(o){return o[0]==="config"?pe(o.filter(e=>e!=="--json")):o[0]==="probe"?ge(o):o[0]==="palette"||o[0]==="scale"?Oe(o):_e(o)}function xe(o,e){let t=new x().name("forge").description("Convert \u2014 transform your files from the terminal").argument("[inputs...]","files, folders or globs").option("-t, --to <format>","target format").option("-o, --output <path>","output file or directory").option("-q, --quality <n>","quality for lossy formats, 1-100").option("--background <colour>","fill colour when flattening transparency","#ffffff").option("--keep-metadata","preserve EXIF and GPS data",!1).option("--recursive","descend into subfolders",!1).option("--force","allow overwriting existing files",!1).option("--max-size <size>","compress until the file fits, e.g. 500kb").option("--concurrency <n>","how many files to convert at once").option("--debug","show underlying errors",!1).option("--formats","list supported formats",!1).option("--merge","combine several PDFs into one").option("--split <mode>","every-page | every=N | at=N,N").option("--extract <pages>","keep only these pages, e.g. 3-7,12").option("--delete <pages>","drop these pages").option("--rotate <degrees>","90, 180 or 270").option("--separate","with --extract, write one file per page").option("--sharpen","sharpen at the same size; needs the boost extension").option("--boost [2|4]","sharpen and enlarge 2x (default) or 4x; needs the boost extension").option("--remove-bg","cut out the subject; needs the remove-background extension").option("--pages <ranges>","with --to, which pages to render, e.g. 3-7,12").option("--dpi <n>","rasterisation resolution, 36-600","150").option("--password-stdin","read an encrypted PDF's password from stdin").option("--json","print one JSON document on stdout instead of text").helpOption("-h, --help","show this help").version(v,"-V, --version","show the version").addHelpText("after",`${me}
|
|
52
|
+
${fe}`).configureOutput({outputError:()=>{}}).exitOverride().allowExcessArguments(!1);try{t.parse(o,{from:"user"})}catch(c){if(c instanceof b&&c.code!=="commander.helpDisplayed"&&c.code!=="commander.version"){let[g="",...f]=c.message.replace(/^error: /,"").split(`
|
|
53
|
+
`),_=f.join(" ").trim().replace(/^\((.*)\)\.?$/,"$1");throw d(`${g.charAt(0).toUpperCase()}${g.slice(1).replace(/\.$/,"")}.`,_||"Run forge --help to see what Forge accepts.")}throw c}let n=t.opts(),i=t.args;if(n.formats)return{kind:"formats"};if(n.pages!==void 0&&n.to===void 0)throw d("--pages needs --to: it chooses which pages to render.");let s=["merge","split","extract","delete","rotate"].filter(c=>n[c]!==void 0);if(s.length>1)throw d(`Use one operation at a time \u2014 got ${s.map(c=>`--${c}`).join(" and ")}.`);let r=[...n.sharpen?["--sharpen"]:[],...e!==void 0?["--boost"]:[],...n.removeBg?["--remove-bg"]:[]],a=n.sharpen?1:e,h=a!==void 0?"boost":n.removeBg?"remove-background":null;if(h!==null){if(r.length>1)throw d(`Use one operation at a time \u2014 got ${r.join(" and ")}.`);let c=r[0];if(s.length>0)throw d(`${c} cannot be combined with --${s[0]}.`);if(n.maxSize!==void 0||n.pages!==void 0)throw d(`${c} cannot be combined with ${n.maxSize!==void 0?"--max-size":"--pages"}.`);if(i.length===0)throw d("No files given.",`Name an image, for example: forge photo.jpg ${c}`);let g=n.to?X(String(n.to)):"png";if(h==="remove-background"){let y=U(g);if(y)throw y}let f={background:String(n.background),keepMetadata:!!n.keepMetadata};n.quality!==void 0&&(f.quality=D(String(n.quality)));let _={kind:"extension-op",op:h,inputs:i,target:g,options:f,force:!!n.force,recursive:!!n.recursive,debug:!!n.debug};return a!==void 0&&(_.scale=a),n.output!==void 0&&(_.output=String(n.output)),n.concurrency!==void 0&&(_.concurrency=W(String(n.concurrency))),_}if(s.length===1){let c=s[0];if(i.length===0)throw d("No files given.",`Name a PDF, for example: forge doc.pdf --${c}`);if(n.separate&&c!=="extract")throw d(`--separate only applies to --extract, not --${c}.`);if(n.output!==void 0)throw d(`--output does not apply to --${c}.`,"Page operations name their own outputs, beside the source. Rename the result afterwards.");let g={kind:"pageop",action:c,inputs:i,force:!!n.force,debug:!!n.debug};if(c==="rotate"){let f=Number(n.rotate);if(!Number.isInteger(f)||f%90!==0||f===0||f>=360)throw d(`--rotate takes a multiple of 90 below 360, not "${n.rotate}".`);g.rotate=f}if((c==="extract"||c==="delete")&&(g.pages=String(n[c]),c==="extract"&&n.separate&&(g.separate=!0)),c==="split"){let f=String(n.split),_=f.match(/^every=(\d+)$/),y=f.match(/^at=([\d,\s]+)$/);if(f==="every-page")g.split={mode:"every-page"};else if(_?.[1]!==void 0){let A=Number(_[1]);if(!Number.isInteger(A)||A<1)throw d(`--split every=N takes a whole number of pages, at least 1, not "${_[1]}".`);g.split={mode:"every-n",n:A}}else if(y?.[1])g.split={mode:"points",after:y[1].split(",").map(A=>Number(A.trim()))};else throw d(`--split takes every-page, every=N or at=N,N \u2014 not "${f}".`)}return g}if(i.length===0&&!n.to&&n.quality===void 0&&n.maxSize===void 0)return{kind:"shell"};if(n.quality!==void 0&&n.maxSize!==void 0)throw d("Use either --quality or --max-size, not both.","They are two ways of asking for the same thing, and Forge will not guess which wins.");if(!n.to&&(n.quality!==void 0||n.maxSize!==void 0)){if(i.length===0)throw d("No files given.","Name a file, for example: forge photo.jpg --max-size 500kb");let c={background:String(n.background),keepMetadata:!!n.keepMetadata},g={kind:"compress",inputs:i,options:c,force:!!n.force,recursive:!!n.recursive,debug:!!n.debug};if(n.quality!==void 0&&(g.quality=D(String(n.quality))),n.maxSize!==void 0&&(g.maxBytes=Z(n.maxSize)),n.output!==void 0&&(g.output=String(n.output)),t.getOptionValueSource("dpi")==="cli"){let f=Number(n.dpi);if(!Number.isInteger(f)||f<36||f>600)throw I(n.dpi);g.dpi=f}return n.concurrency!==void 0&&(g.concurrency=W(String(n.concurrency))),g}if(!n.to)throw d("No target format given.","Add --to <format>, for example: forge photo.jpg --to webp");if(i.length===0)throw d("No files given.","Name a file, a folder or a glob, for example: forge photo.jpg --to webp");let p={background:String(n.background),keepMetadata:!!n.keepMetadata};n.quality!==void 0&&(p.quality=D(String(n.quality)));let l=Number(n.dpi);if(!Number.isInteger(l)||l<36||l>600)throw I(n.dpi);let u={kind:"convert",inputs:i,target:X(String(n.to)),options:p,force:!!n.force,recursive:!!n.recursive,debug:!!n.debug,dpi:l,passwordStdin:!!n.passwordStdin};return n.output!==void 0&&(u.output=String(n.output)),n.pages!==void 0&&(u.pages=String(n.pages)),n.maxSize!==void 0&&(u.maxBytes=Z(n.maxSize)),n.concurrency!==void 0&&(u.concurrency=W(String(n.concurrency))),u}function M(o){return k(o)?o:R(o)}function ne(o,e){return S(M(o),{debug:e})}function ie(o,e){process.once("beforeExit",()=>{o()||(e(new Error("Forge stopped before it finished: it was waiting for input that never came.")),process.exitCode=1)})}se.enableCompileCache?.();function ye({completed:o,total:e}){o===0?process.stderr.write(`Converting ${e} files
|
|
54
|
+
`):process.stderr.write(` ${o}/${e}
|
|
55
|
+
`)}async function Ae(){let o=process.argv.slice(2),e=o.includes("--debug"),t=G(o);try{if(o[0]==="mcp"){let{runMcpServer:u}=await import("./chunks/server-5RWSVTOM.js");await u(o.slice(1));return}let n=te(o);if(n.kind==="shell"){if(t)throw d("No files given.","Name a file, for example: forge photo.jpg --to webp --json");if(!process.stdout.isTTY||!process.stdin.isTTY){process.stderr.write(`Forge needs a file and a target format.
|
|
56
|
+
Try: forge photo.jpg --to webp
|
|
57
|
+
`),process.exitCode=2;return}let{applyColourPreference:u}=await import("./chunks/theme-GW7CQPUO.js");u();let{bootShell:c}=await import("./chunks/boot-ODZZHFUI.js");await c();return}let{execute:i}=await import("./chunks/execute-4WJCUM7J.js"),s,r=0,a=(u,c)=>{let g=Date.now();if(u<c&&g-r<100)return;r=g;let f=_=>(_/1e6).toFixed(1);process.stderr.write(`\r downloading ${f(u)} / ${f(c)} MB${u>=c?`
|
|
58
|
+
`:""}`)},h=!!process.stderr.isTTY&&!t,p=new AbortController;n.kind==="extension-op"&&process.once("SIGINT",()=>p.abort());let l=await i(n,{json:t,signal:p.signal,...h?{onDownload:a}:{},colour:!!process.stdout.isTTY&&!t&&J(),onProgress:h?u=>{u.completed>0&&s?.stop(),ye(u)}:void 0,...h?{onSearch:u=>{s??=z(process.stderr,"finding the smallest that fits"),s.update(u)}}:{}});s?.stop(),l.stdout.length>0&&process.stdout.write(`${l.stdout.join(`
|
|
59
|
+
`)}
|
|
60
|
+
`),l.stderr.length>0&&process.stderr.write(`${l.stderr.join(`
|
|
61
|
+
`)}
|
|
62
|
+
`),process.exitCode=p.signal.aborted?130:l.exitCode}catch(n){if(k(n)){t?process.stdout.write(`${JSON.stringify(F(v,n))}
|
|
63
|
+
`):process.stderr.write(`${S(n,{debug:e}).join(`
|
|
64
|
+
`)}
|
|
65
|
+
`),process.exitCode=2;return}if(n instanceof Error&&"code"in n&&"exitCode"in n){let i=n.code;process.exitCode=i==="commander.helpDisplayed"||i==="commander.version"?0:2;return}throw n}}function re(o){let e=process.argv.slice(2);if(G(e)){process.stdout.write(`${JSON.stringify(F(v,M(o)))}
|
|
66
|
+
`);return}process.stderr.write(`${ne(o,e.includes("--debug")).join(`
|
|
67
|
+
`)}
|
|
68
|
+
`)}var oe=!1;ie(()=>oe,re);try{await Ae()}catch(o){re(o),process.exitCode=1}finally{oe=!0}export{v as VERSION};
|