hyperbook 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -75,7 +75,7 @@ var i;(function(t){if(typeof DO_NOT_EXPORT_CRC==="undefined"){if(true){t(r)}else
|
|
|
75
75
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
76
76
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
77
77
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
78
|
-
*/function isSpecificValue(t){return t instanceof Buffer||t instanceof Date||t instanceof RegExp?true:false}function cloneSpecificValue(t){if(t instanceof Buffer){var r=Buffer.alloc?Buffer.alloc(t.length):new Buffer(t.length);t.copy(r);return r}else if(t instanceof Date){return new Date(t.getTime())}else if(t instanceof RegExp){return new RegExp(t)}else{throw new Error("Unexpected situation")}}function deepCloneArray(t){var i=[];t.forEach((function(t,o){if(typeof t==="object"&&t!==null){if(Array.isArray(t)){i[o]=deepCloneArray(t)}else if(isSpecificValue(t)){i[o]=cloneSpecificValue(t)}else{i[o]=r({},t)}}else{i[o]=t}}));return i}function safeGetProperty(t,r){return r==="__proto__"?undefined:t[r]}var r=t.exports=function(){if(arguments.length<1||typeof arguments[0]!=="object"){return false}if(arguments.length<2){return arguments[0]}var t=arguments[0];var i=Array.prototype.slice.call(arguments,1);var o,a,l;i.forEach((function(i){if(typeof i!=="object"||i===null||Array.isArray(i)){return}Object.keys(i).forEach((function(l){a=safeGetProperty(t,l);o=safeGetProperty(i,l);if(o===t){return}else if(typeof o!=="object"||o===null){t[l]=o;return}else if(Array.isArray(o)){t[l]=deepCloneArray(o);return}else if(isSpecificValue(o)){t[l]=cloneSpecificValue(o);return}else if(typeof a!=="object"||a===null||Array.isArray(a)){t[l]=r({},o);return}else{t[l]=r(a,o);return}}))}));return t}},3286:(t,r,i)=>{"use strict";const o=i(1017);const a=i(4997);const getExtensions=t=>t.length>1?`{${t.join(",")}}`:t[0];const getPath=(t,r)=>{const i=t[0]==="!"?t.slice(1):t;return o.isAbsolute(i)?i:o.join(r,i)};const addExtensions=(t,r)=>{if(o.extname(t)){return`**/${t}`}return`**/${t}.${getExtensions(r)}`};const getGlob=(t,r)=>{if(r.files&&!Array.isArray(r.files)){throw new TypeError(`Expected \`files\` to be of type \`Array\` but received type \`${typeof r.files}\``)}if(r.extensions&&!Array.isArray(r.extensions)){throw new TypeError(`Expected \`extensions\` to be of type \`Array\` but received type \`${typeof r.extensions}\``)}if(r.files&&r.extensions){return r.files.map((i=>o.posix.join(t,addExtensions(i,r.extensions))))}if(r.files){return r.files.map((r=>o.posix.join(t,`**/${r}`)))}if(r.extensions){return[o.posix.join(t,`**/*.${getExtensions(r.extensions)}`)]}return[o.posix.join(t,"**")]};t.exports=async(t,r)=>{r={cwd:process.cwd(),...r};if(typeof r.cwd!=="string"){throw new TypeError(`Expected \`cwd\` to be of type \`string\` but received type \`${typeof r.cwd}\``)}const i=await Promise.all([].concat(t).map((async t=>{const i=await a.isDirectory(getPath(t,r.cwd));return i?getGlob(t,r):t})));return[].concat.apply([],i)};t.exports.sync=(t,r)=>{r={cwd:process.cwd(),...r};if(typeof r.cwd!=="string"){throw new TypeError(`Expected \`cwd\` to be of type \`string\` but received type \`${typeof r.cwd}\``)}const i=[].concat(t).map((t=>a.isDirectorySync(getPath(t,r.cwd))?getGlob(t,r):t));return[].concat.apply([],i)}},1014:(t,r,i)=>{var o=i(9852);var noop=function(){};var isRequest=function(t){return t.setHeader&&typeof t.abort==="function"};var isChildProcess=function(t){return t.stdio&&Array.isArray(t.stdio)&&t.stdio.length===3};var eos=function(t,r,i){if(typeof r==="function")return eos(t,null,r);if(!r)r={};i=o(i||noop);var a=t._writableState;var l=t._readableState;var u=r.readable||r.readable!==false&&t.readable;var c=r.writable||r.writable!==false&&t.writable;var h=false;var onlegacyfinish=function(){if(!t.writable)onfinish()};var onfinish=function(){c=false;if(!u)i.call(t)};var onend=function(){u=false;if(!c)i.call(t)};var onexit=function(r){i.call(t,r?new Error("exited with error code: "+r):null)};var onerror=function(r){i.call(t,r)};var onclose=function(){process.nextTick(onclosenexttick)};var onclosenexttick=function(){if(h)return;if(u&&!(l&&(l.ended&&!l.destroyed)))return i.call(t,new Error("premature close"));if(c&&!(a&&(a.ended&&!a.destroyed)))return i.call(t,new Error("premature close"))};var onrequest=function(){t.req.on("finish",onfinish)};if(isRequest(t)){t.on("complete",onfinish);t.on("abort",onclose);if(t.req)onrequest();else t.on("request",onrequest)}else if(c&&!a){t.on("end",onlegacyfinish);t.on("close",onlegacyfinish)}if(isChildProcess(t))t.on("exit",onexit);t.on("end",onend);t.on("finish",onfinish);if(r.error!==false)t.on("error",onerror);t.on("close",onclose);return function(){h=true;t.removeListener("complete",onfinish);t.removeListener("abort",onclose);t.removeListener("request",onrequest);if(t.req)t.req.removeListener("finish",onfinish);t.removeListener("end",onlegacyfinish);t.removeListener("close",onlegacyfinish);t.removeListener("finish",onfinish);t.removeListener("exit",onexit);t.removeListener("end",onend);t.removeListener("error",onerror);t.removeListener("close",onclose)}};t.exports=eos},5342:(t,r,i)=>{"use strict";const o=i(6250);const a=i(2573);const l=i(1041);const u=i(8198);const c=i(228);const h=i(9106);const p=i(8961);async function FastGlob(t,r){assertPatternsInput(t);const i=getWorks(t,l.default,r);const o=await Promise.all(i);return p.array.flatten(o)}(function(t){function sync(t,r){assertPatternsInput(t);const i=getWorks(t,c.default,r);return p.array.flatten(i)}t.sync=sync;function stream(t,r){assertPatternsInput(t);const i=getWorks(t,u.default,r);return p.stream.merge(i)}t.stream=stream;function generateTasks(t,r){assertPatternsInput(t);const i=a.transform([].concat(t));const l=new h.default(r);return o.generate(i,l)}t.generateTasks=generateTasks;function isDynamicPattern(t,r){assertPatternsInput(t);const i=new h.default(r);return p.pattern.isDynamicPattern(t,i)}t.isDynamicPattern=isDynamicPattern;function escapePath(t){assertPatternsInput(t);return p.path.escape(t)}t.escapePath=escapePath})(FastGlob||(FastGlob={}));function getWorks(t,r,i){const l=a.transform([].concat(t));const u=new h.default(i);const c=o.generate(l,u);const p=new r(u);return c.map(p.read,p)}function assertPatternsInput(t){const r=[].concat(t);const i=r.every((t=>p.string.isString(t)&&!p.string.isEmpty(t)));if(!i){throw new TypeError("Patterns must be a string (non empty) or an array of strings")}}t.exports=FastGlob},2573:(t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});r.removeDuplicateSlashes=r.transform=void 0;const i=/(?!^)\/{2,}/g;function transform(t){return t.map((t=>removeDuplicateSlashes(t)))}r.transform=transform;function removeDuplicateSlashes(t){return t.replace(i,"/")}r.removeDuplicateSlashes=removeDuplicateSlashes},6250:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});r.convertPatternGroupToTask=r.convertPatternGroupsToTasks=r.groupPatternsByBaseDirectory=r.getNegativePatternsAsPositive=r.getPositivePatterns=r.convertPatternsToTasks=r.generate=void 0;const o=i(8961);function generate(t,r){const i=getPositivePatterns(t);const a=getNegativePatternsAsPositive(t,r.ignore);const l=i.filter((t=>o.pattern.isStaticPattern(t,r)));const u=i.filter((t=>o.pattern.isDynamicPattern(t,r)));const c=convertPatternsToTasks(l,a,false);const h=convertPatternsToTasks(u,a,true);return c.concat(h)}r.generate=generate;function convertPatternsToTasks(t,r,i){const a=[];const l=o.pattern.getPatternsOutsideCurrentDirectory(t);const u=o.pattern.getPatternsInsideCurrentDirectory(t);const c=groupPatternsByBaseDirectory(l);const h=groupPatternsByBaseDirectory(u);a.push(...convertPatternGroupsToTasks(c,r,i));if("."in h){a.push(convertPatternGroupToTask(".",u,r,i))}else{a.push(...convertPatternGroupsToTasks(h,r,i))}return a}r.convertPatternsToTasks=convertPatternsToTasks;function getPositivePatterns(t){return o.pattern.getPositivePatterns(t)}r.getPositivePatterns=getPositivePatterns;function getNegativePatternsAsPositive(t,r){const i=o.pattern.getNegativePatterns(t).concat(r);const a=i.map(o.pattern.convertToPositivePattern);return a}r.getNegativePatternsAsPositive=getNegativePatternsAsPositive;function groupPatternsByBaseDirectory(t){const r={};return t.reduce(((t,r)=>{const i=o.pattern.getBaseDirectory(r);if(i in t){t[i].push(r)}else{t[i]=[r]}return t}),r)}r.groupPatternsByBaseDirectory=groupPatternsByBaseDirectory;function convertPatternGroupsToTasks(t,r,i){return Object.keys(t).map((o=>convertPatternGroupToTask(o,t[o],r,i)))}r.convertPatternGroupsToTasks=convertPatternGroupsToTasks;function convertPatternGroupToTask(t,r,i,a){return{dynamic:a,positive:r,negative:i,base:t,patterns:[].concat(r,i.map(o.pattern.convertToNegativePattern))}}r.convertPatternGroupToTask=convertPatternGroupToTask},1041:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});const o=i(4435);const a=i(9e3);class ProviderAsync extends a.default{constructor(){super(...arguments);this._reader=new o.default(this._settings)}read(t){const r=this._getRootDirectory(t);const i=this._getReaderOptions(t);const o=[];return new Promise(((a,l)=>{const u=this.api(r,t,i);u.once("error",l);u.on("data",(t=>o.push(i.transform(t))));u.once("end",(()=>a(o)))}))}api(t,r,i){if(r.dynamic){return this._reader.dynamic(t,i)}return this._reader.static(r.patterns,i)}}r["default"]=ProviderAsync},1416:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});const o=i(8961);const a=i(4660);class DeepFilter{constructor(t,r){this._settings=t;this._micromatchOptions=r}getFilter(t,r,i){const o=this._getMatcher(r);const a=this._getNegativePatternsRe(i);return r=>this._filter(t,r,o,a)}_getMatcher(t){return new a.default(t,this._settings,this._micromatchOptions)}_getNegativePatternsRe(t){const r=t.filter(o.pattern.isAffectDepthOfReadingPattern);return o.pattern.convertPatternsToRe(r,this._micromatchOptions)}_filter(t,r,i,a){if(this._isSkippedByDeep(t,r.path)){return false}if(this._isSkippedSymbolicLink(r)){return false}const l=o.path.removeLeadingDotSegment(r.path);if(this._isSkippedByPositivePatterns(l,i)){return false}return this._isSkippedByNegativePatterns(l,a)}_isSkippedByDeep(t,r){if(this._settings.deep===Infinity){return false}return this._getEntryLevel(t,r)>=this._settings.deep}_getEntryLevel(t,r){const i=r.split("/").length;if(t===""){return i}const o=t.split("/").length;return i-o}_isSkippedSymbolicLink(t){return!this._settings.followSymbolicLinks&&t.dirent.isSymbolicLink()}_isSkippedByPositivePatterns(t,r){return!this._settings.baseNameMatch&&!r.match(t)}_isSkippedByNegativePatterns(t,r){return!o.pattern.matchAny(t,r)}}r["default"]=DeepFilter},5488:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});const o=i(8961);class EntryFilter{constructor(t,r){this._settings=t;this._micromatchOptions=r;this.index=new Map}getFilter(t,r){const i=o.pattern.convertPatternsToRe(t,this._micromatchOptions);const a=o.pattern.convertPatternsToRe(r,this._micromatchOptions);return t=>this._filter(t,i,a)}_filter(t,r,i){if(this._settings.unique&&this._isDuplicateEntry(t)){return false}if(this._onlyFileFilter(t)||this._onlyDirectoryFilter(t)){return false}if(this._isSkippedByAbsoluteNegativePatterns(t.path,i)){return false}const o=this._settings.baseNameMatch?t.name:t.path;const a=this._isMatchToPatterns(o,r)&&!this._isMatchToPatterns(t.path,i);if(this._settings.unique&&a){this._createIndexRecord(t)}return a}_isDuplicateEntry(t){return this.index.has(t.path)}_createIndexRecord(t){this.index.set(t.path,undefined)}_onlyFileFilter(t){return this._settings.onlyFiles&&!t.dirent.isFile()}_onlyDirectoryFilter(t){return this._settings.onlyDirectories&&!t.dirent.isDirectory()}_isSkippedByAbsoluteNegativePatterns(t,r){if(!this._settings.absolute){return false}const i=o.path.makeAbsolute(this._settings.cwd,t);return o.pattern.matchAny(i,r)}_isMatchToPatterns(t,r){const i=o.path.removeLeadingDotSegment(t);return o.pattern.matchAny(i,r)||o.pattern.matchAny(i+"/",r)}}r["default"]=EntryFilter},8802:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});const o=i(8961);class ErrorFilter{constructor(t){this._settings=t}getFilter(){return t=>this._isNonFatalError(t)}_isNonFatalError(t){return o.errno.isEnoentCodeError(t)||this._settings.suppressErrors}}r["default"]=ErrorFilter},3785:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});const o=i(8961);class Matcher{constructor(t,r,i){this._patterns=t;this._settings=r;this._micromatchOptions=i;this._storage=[];this._fillStorage()}_fillStorage(){const t=o.pattern.expandPatternsWithBraceExpansion(this._patterns);for(const r of t){const t=this._getPatternSegments(r);const i=this._splitSegmentsIntoSections(t);this._storage.push({complete:i.length<=1,pattern:r,segments:t,sections:i})}}_getPatternSegments(t){const r=o.pattern.getPatternParts(t,this._micromatchOptions);return r.map((t=>{const r=o.pattern.isDynamicPattern(t,this._settings);if(!r){return{dynamic:false,pattern:t}}return{dynamic:true,pattern:t,patternRe:o.pattern.makeRe(t,this._micromatchOptions)}}))}_splitSegmentsIntoSections(t){return o.array.splitWhen(t,(t=>t.dynamic&&o.pattern.hasGlobStar(t.pattern)))}}r["default"]=Matcher},4660:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});const o=i(3785);class PartialMatcher extends o.default{match(t){const r=t.split("/");const i=r.length;const o=this._storage.filter((t=>!t.complete||t.segments.length>i));for(const t of o){const o=t.sections[0];if(!t.complete&&i>o.length){return true}const a=r.every(((r,i)=>{const o=t.segments[i];if(o.dynamic&&o.patternRe.test(r)){return true}if(!o.dynamic&&o.pattern===r){return true}return false}));if(a){return true}}return false}}r["default"]=PartialMatcher},9e3:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});const o=i(1017);const a=i(1416);const l=i(5488);const u=i(8802);const c=i(7413);class Provider{constructor(t){this._settings=t;this.errorFilter=new u.default(this._settings);this.entryFilter=new l.default(this._settings,this._getMicromatchOptions());this.deepFilter=new a.default(this._settings,this._getMicromatchOptions());this.entryTransformer=new c.default(this._settings)}_getRootDirectory(t){return o.resolve(this._settings.cwd,t.base)}_getReaderOptions(t){const r=t.base==="."?"":t.base;return{basePath:r,pathSegmentSeparator:"/",concurrency:this._settings.concurrency,deepFilter:this.deepFilter.getFilter(r,t.positive,t.negative),entryFilter:this.entryFilter.getFilter(t.positive,t.negative),errorFilter:this.errorFilter.getFilter(),followSymbolicLinks:this._settings.followSymbolicLinks,fs:this._settings.fs,stats:this._settings.stats,throwErrorOnBrokenSymbolicLink:this._settings.throwErrorOnBrokenSymbolicLink,transform:this.entryTransformer.getTransformer()}}_getMicromatchOptions(){return{dot:this._settings.dot,matchBase:this._settings.baseNameMatch,nobrace:!this._settings.braceExpansion,nocase:!this._settings.caseSensitiveMatch,noext:!this._settings.extglob,noglobstar:!this._settings.globstar,posix:true,strictSlashes:false}}}r["default"]=Provider},8198:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});const o=i(2781);const a=i(4435);const l=i(9e3);class ProviderStream extends l.default{constructor(){super(...arguments);this._reader=new a.default(this._settings)}read(t){const r=this._getRootDirectory(t);const i=this._getReaderOptions(t);const a=this.api(r,t,i);const l=new o.Readable({objectMode:true,read:()=>{}});a.once("error",(t=>l.emit("error",t))).on("data",(t=>l.emit("data",i.transform(t)))).once("end",(()=>l.emit("end")));l.once("close",(()=>a.destroy()));return l}api(t,r,i){if(r.dynamic){return this._reader.dynamic(t,i)}return this._reader.static(r.patterns,i)}}r["default"]=ProviderStream},228:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});const o=i(8528);const a=i(9e3);class ProviderSync extends a.default{constructor(){super(...arguments);this._reader=new o.default(this._settings)}read(t){const r=this._getRootDirectory(t);const i=this._getReaderOptions(t);const o=this.api(r,t,i);return o.map(i.transform)}api(t,r,i){if(r.dynamic){return this._reader.dynamic(t,i)}return this._reader.static(r.patterns,i)}}r["default"]=ProviderSync},7413:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});const o=i(8961);class EntryTransformer{constructor(t){this._settings=t}getTransformer(){return t=>this._transform(t)}_transform(t){let r=t.path;if(this._settings.absolute){r=o.path.makeAbsolute(this._settings.cwd,r);r=o.path.unixify(r)}if(this._settings.markDirectories&&t.dirent.isDirectory()){r+="/"}if(!this._settings.objectMode){return r}return Object.assign(Object.assign({},t),{path:r})}}r["default"]=EntryTransformer},2212:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});const o=i(1017);const a=i(5587);const l=i(8961);class Reader{constructor(t){this._settings=t;this._fsStatSettings=new a.Settings({followSymbolicLink:this._settings.followSymbolicLinks,fs:this._settings.fs,throwErrorOnBrokenSymbolicLink:this._settings.followSymbolicLinks})}_getFullEntryPath(t){return o.resolve(this._settings.cwd,t)}_makeEntry(t,r){const i={name:r,path:r,dirent:l.fs.createDirentFromStats(r,t)};if(this._settings.stats){i.stats=t}return i}_isFatalError(t){return!l.errno.isEnoentCodeError(t)&&!this._settings.suppressErrors}}r["default"]=Reader},4435:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});const o=i(2781);const a=i(5587);const l=i(204);const u=i(2212);class ReaderStream extends u.default{constructor(){super(...arguments);this._walkStream=l.walkStream;this._stat=a.stat}dynamic(t,r){return this._walkStream(t,r)}static(t,r){const i=t.map(this._getFullEntryPath,this);const a=new o.PassThrough({objectMode:true});a._write=(o,l,u)=>this._getEntry(i[o],t[o],r).then((t=>{if(t!==null&&r.entryFilter(t)){a.push(t)}if(o===i.length-1){a.end()}u()})).catch(u);for(let t=0;t<i.length;t++){a.write(t)}return a}_getEntry(t,r,i){return this._getStat(t).then((t=>this._makeEntry(t,r))).catch((t=>{if(i.errorFilter(t)){return null}throw t}))}_getStat(t){return new Promise(((r,i)=>{this._stat(t,this._fsStatSettings,((t,o)=>t===null?r(o):i(t)))}))}}r["default"]=ReaderStream},8528:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});const o=i(5587);const a=i(204);const l=i(2212);class ReaderSync extends l.default{constructor(){super(...arguments);this._walkSync=a.walkSync;this._statSync=o.statSync}dynamic(t,r){return this._walkSync(t,r)}static(t,r){const i=[];for(const o of t){const t=this._getFullEntryPath(o);const a=this._getEntry(t,o,r);if(a===null||!r.entryFilter(a)){continue}i.push(a)}return i}_getEntry(t,r,i){try{const i=this._getStat(t);return this._makeEntry(i,r)}catch(t){if(i.errorFilter(t)){return null}throw t}}_getStat(t){return this._statSync(t,this._fsStatSettings)}}r["default"]=ReaderSync},9106:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});r.DEFAULT_FILE_SYSTEM_ADAPTER=void 0;const o=i(7147);const a=i(2037);const l=Math.max(a.cpus().length,1);r.DEFAULT_FILE_SYSTEM_ADAPTER={lstat:o.lstat,lstatSync:o.lstatSync,stat:o.stat,statSync:o.statSync,readdir:o.readdir,readdirSync:o.readdirSync};class Settings{constructor(t={}){this._options=t;this.absolute=this._getValue(this._options.absolute,false);this.baseNameMatch=this._getValue(this._options.baseNameMatch,false);this.braceExpansion=this._getValue(this._options.braceExpansion,true);this.caseSensitiveMatch=this._getValue(this._options.caseSensitiveMatch,true);this.concurrency=this._getValue(this._options.concurrency,l);this.cwd=this._getValue(this._options.cwd,process.cwd());this.deep=this._getValue(this._options.deep,Infinity);this.dot=this._getValue(this._options.dot,false);this.extglob=this._getValue(this._options.extglob,true);this.followSymbolicLinks=this._getValue(this._options.followSymbolicLinks,true);this.fs=this._getFileSystemMethods(this._options.fs);this.globstar=this._getValue(this._options.globstar,true);this.ignore=this._getValue(this._options.ignore,[]);this.markDirectories=this._getValue(this._options.markDirectories,false);this.objectMode=this._getValue(this._options.objectMode,false);this.onlyDirectories=this._getValue(this._options.onlyDirectories,false);this.onlyFiles=this._getValue(this._options.onlyFiles,true);this.stats=this._getValue(this._options.stats,false);this.suppressErrors=this._getValue(this._options.suppressErrors,false);this.throwErrorOnBrokenSymbolicLink=this._getValue(this._options.throwErrorOnBrokenSymbolicLink,false);this.unique=this._getValue(this._options.unique,true);if(this.onlyDirectories){this.onlyFiles=false}if(this.stats){this.objectMode=true}}_getValue(t,r){return t===undefined?r:t}_getFileSystemMethods(t={}){return Object.assign(Object.assign({},r.DEFAULT_FILE_SYSTEM_ADAPTER),t)}}r["default"]=Settings},3006:(t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});r.splitWhen=r.flatten=void 0;function flatten(t){return t.reduce(((t,r)=>[].concat(t,r)),[])}r.flatten=flatten;function splitWhen(t,r){const i=[[]];let o=0;for(const a of t){if(r(a)){o++;i[o]=[]}else{i[o].push(a)}}return i}r.splitWhen=splitWhen},740:(t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});r.isEnoentCodeError=void 0;function isEnoentCodeError(t){return t.code==="ENOENT"}r.isEnoentCodeError=isEnoentCodeError},2006:(t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});r.createDirentFromStats=void 0;class DirentFromStats{constructor(t,r){this.name=t;this.isBlockDevice=r.isBlockDevice.bind(r);this.isCharacterDevice=r.isCharacterDevice.bind(r);this.isDirectory=r.isDirectory.bind(r);this.isFIFO=r.isFIFO.bind(r);this.isFile=r.isFile.bind(r);this.isSocket=r.isSocket.bind(r);this.isSymbolicLink=r.isSymbolicLink.bind(r)}}function createDirentFromStats(t,r){return new DirentFromStats(t,r)}r.createDirentFromStats=createDirentFromStats},8961:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});r.string=r.stream=r.pattern=r.path=r.fs=r.errno=r.array=void 0;const o=i(3006);r.array=o;const a=i(740);r.errno=a;const l=i(2006);r.fs=l;const u=i(9990);r.path=u;const c=i(7351);r.pattern=c;const h=i(1809);r.stream=h;const p=i(7272);r.string=p},9990:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});r.removeLeadingDotSegment=r.escape=r.makeAbsolute=r.unixify=void 0;const o=i(1017);const a=2;const l=/(\\?)([()*?[\]{|}]|^!|[!+@](?=\())/g;function unixify(t){return t.replace(/\\/g,"/")}r.unixify=unixify;function makeAbsolute(t,r){return o.resolve(t,r)}r.makeAbsolute=makeAbsolute;function escape(t){return t.replace(l,"\\$2")}r.escape=escape;function removeLeadingDotSegment(t){if(t.charAt(0)==="."){const r=t.charAt(1);if(r==="/"||r==="\\"){return t.slice(a)}}return t}r.removeLeadingDotSegment=removeLeadingDotSegment},7351:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});r.matchAny=r.convertPatternsToRe=r.makeRe=r.getPatternParts=r.expandBraceExpansion=r.expandPatternsWithBraceExpansion=r.isAffectDepthOfReadingPattern=r.endsWithSlashGlobStar=r.hasGlobStar=r.getBaseDirectory=r.isPatternRelatedToParentDirectory=r.getPatternsOutsideCurrentDirectory=r.getPatternsInsideCurrentDirectory=r.getPositivePatterns=r.getNegativePatterns=r.isPositivePattern=r.isNegativePattern=r.convertToNegativePattern=r.convertToPositivePattern=r.isDynamicPattern=r.isStaticPattern=void 0;const o=i(1017);const a=i(7080);const l=i(1065);const u="**";const c="\\";const h=/[*?]|^!/;const p=/\[[^[]*]/;const d=/(?:^|[^!*+?@])\([^(]*\|[^|]*\)/;const m=/[!*+?@]\([^(]*\)/;const g=/,|\.\./;function isStaticPattern(t,r={}){return!isDynamicPattern(t,r)}r.isStaticPattern=isStaticPattern;function isDynamicPattern(t,r={}){if(t===""){return false}if(r.caseSensitiveMatch===false||t.includes(c)){return true}if(h.test(t)||p.test(t)||d.test(t)){return true}if(r.extglob!==false&&m.test(t)){return true}if(r.braceExpansion!==false&&hasBraceExpansion(t)){return true}return false}r.isDynamicPattern=isDynamicPattern;function hasBraceExpansion(t){const r=t.indexOf("{");if(r===-1){return false}const i=t.indexOf("}",r+1);if(i===-1){return false}const o=t.slice(r,i);return g.test(o)}function convertToPositivePattern(t){return isNegativePattern(t)?t.slice(1):t}r.convertToPositivePattern=convertToPositivePattern;function convertToNegativePattern(t){return"!"+t}r.convertToNegativePattern=convertToNegativePattern;function isNegativePattern(t){return t.startsWith("!")&&t[1]!=="("}r.isNegativePattern=isNegativePattern;function isPositivePattern(t){return!isNegativePattern(t)}r.isPositivePattern=isPositivePattern;function getNegativePatterns(t){return t.filter(isNegativePattern)}r.getNegativePatterns=getNegativePatterns;function getPositivePatterns(t){return t.filter(isPositivePattern)}r.getPositivePatterns=getPositivePatterns;function getPatternsInsideCurrentDirectory(t){return t.filter((t=>!isPatternRelatedToParentDirectory(t)))}r.getPatternsInsideCurrentDirectory=getPatternsInsideCurrentDirectory;function getPatternsOutsideCurrentDirectory(t){return t.filter(isPatternRelatedToParentDirectory)}r.getPatternsOutsideCurrentDirectory=getPatternsOutsideCurrentDirectory;function isPatternRelatedToParentDirectory(t){return t.startsWith("..")||t.startsWith("./..")}r.isPatternRelatedToParentDirectory=isPatternRelatedToParentDirectory;function getBaseDirectory(t){return a(t,{flipBackslashes:false})}r.getBaseDirectory=getBaseDirectory;function hasGlobStar(t){return t.includes(u)}r.hasGlobStar=hasGlobStar;function endsWithSlashGlobStar(t){return t.endsWith("/"+u)}r.endsWithSlashGlobStar=endsWithSlashGlobStar;function isAffectDepthOfReadingPattern(t){const r=o.basename(t);return endsWithSlashGlobStar(t)||isStaticPattern(r)}r.isAffectDepthOfReadingPattern=isAffectDepthOfReadingPattern;function expandPatternsWithBraceExpansion(t){return t.reduce(((t,r)=>t.concat(expandBraceExpansion(r))),[])}r.expandPatternsWithBraceExpansion=expandPatternsWithBraceExpansion;function expandBraceExpansion(t){return l.braces(t,{expand:true,nodupes:true})}r.expandBraceExpansion=expandBraceExpansion;function getPatternParts(t,r){let{parts:i}=l.scan(t,Object.assign(Object.assign({},r),{parts:true}));if(i.length===0){i=[t]}if(i[0].startsWith("/")){i[0]=i[0].slice(1);i.unshift("")}return i}r.getPatternParts=getPatternParts;function makeRe(t,r){return l.makeRe(t,r)}r.makeRe=makeRe;function convertPatternsToRe(t,r){return t.map((t=>makeRe(t,r)))}r.convertPatternsToRe=convertPatternsToRe;function matchAny(t,r){return r.some((r=>r.test(t)))}r.matchAny=matchAny},1809:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});r.merge=void 0;const o=i(9117);function merge(t){const r=o(t);t.forEach((t=>{t.once("error",(t=>r.emit("error",t)))}));r.once("close",(()=>propagateCloseEventToSources(t)));r.once("end",(()=>propagateCloseEventToSources(t)));return r}r.merge=merge;function propagateCloseEventToSources(t){t.forEach((t=>t.emit("close")))}},7272:(t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});r.isEmpty=r.isString=void 0;function isString(t){return typeof t==="string"}r.isString=isString;function isEmpty(t){return t===""}r.isEmpty=isEmpty},8205:(t,r,i)=>{"use strict";var o=i(7327);function fastqueue(t,r,i){if(typeof t==="function"){i=r;r=t;t=null}if(i<1){throw new Error("fastqueue concurrency must be greater than 1")}var a=o(Task);var l=null;var u=null;var c=0;var h=null;var p={push:push,drain:noop,saturated:noop,pause:pause,paused:false,concurrency:i,running:running,resume:resume,idle:idle,length:length,getQueue:getQueue,unshift:unshift,empty:noop,kill:kill,killAndDrain:killAndDrain,error:error};return p;function running(){return c}function pause(){p.paused=true}function length(){var t=l;var r=0;while(t){t=t.next;r++}return r}function getQueue(){var t=l;var r=[];while(t){r.push(t.value);t=t.next}return r}function resume(){if(!p.paused)return;p.paused=false;for(var t=0;t<p.concurrency;t++){c++;release()}}function idle(){return c===0&&p.length()===0}function push(i,o){var d=a.get();d.context=t;d.release=release;d.value=i;d.callback=o||noop;d.errorHandler=h;if(c===p.concurrency||p.paused){if(u){u.next=d;u=d}else{l=d;u=d;p.saturated()}}else{c++;r.call(t,d.value,d.worked)}}function unshift(i,o){var h=a.get();h.context=t;h.release=release;h.value=i;h.callback=o||noop;if(c===p.concurrency||p.paused){if(l){h.next=l;l=h}else{l=h;u=h;p.saturated()}}else{c++;r.call(t,h.value,h.worked)}}function release(i){if(i){a.release(i)}var o=l;if(o){if(!p.paused){if(u===l){u=null}l=o.next;o.next=null;r.call(t,o.value,o.worked);if(u===null){p.empty()}}else{c--}}else if(--c===0){p.drain()}}function kill(){l=null;u=null;p.drain=noop}function killAndDrain(){l=null;u=null;p.drain();p.drain=noop}function error(t){h=t}}function noop(){}function Task(){this.value=null;this.callback=noop;this.next=null;this.release=noop;this.context=null;this.errorHandler=null;var t=this;this.worked=function worked(r,i){var o=t.callback;var a=t.errorHandler;var l=t.value;t.value=null;t.callback=noop;if(t.errorHandler){a(r,l)}o.call(t.context,r,i);t.release(t)}}function queueAsPromised(t,r,i){if(typeof t==="function"){i=r;r=t;t=null}function asyncWrapper(t,i){r.call(this,t).then((function(t){i(null,t)}),i)}var o=fastqueue(t,asyncWrapper,i);var a=o.push;var l=o.unshift;o.push=push;o.unshift=unshift;o.drained=drained;return o;function push(t){var r=new Promise((function(r,i){a(t,(function(t,o){if(t){i(t);return}r(o)}))}));r.catch(noop);return r}function unshift(t){var r=new Promise((function(r,i){l(t,(function(t,o){if(t){i(t);return}r(o)}))}));r.catch(noop);return r}function drained(){var t=o.drain;var r=new Promise((function(r){o.drain=function(){t();r()}}));return r}}t.exports=fastqueue;t.exports.promise=queueAsPromised},7783:(t,r,i)=>{"use strict";
|
|
78
|
+
*/function isSpecificValue(t){return t instanceof Buffer||t instanceof Date||t instanceof RegExp?true:false}function cloneSpecificValue(t){if(t instanceof Buffer){var r=Buffer.alloc?Buffer.alloc(t.length):new Buffer(t.length);t.copy(r);return r}else if(t instanceof Date){return new Date(t.getTime())}else if(t instanceof RegExp){return new RegExp(t)}else{throw new Error("Unexpected situation")}}function deepCloneArray(t){var i=[];t.forEach((function(t,o){if(typeof t==="object"&&t!==null){if(Array.isArray(t)){i[o]=deepCloneArray(t)}else if(isSpecificValue(t)){i[o]=cloneSpecificValue(t)}else{i[o]=r({},t)}}else{i[o]=t}}));return i}function safeGetProperty(t,r){return r==="__proto__"?undefined:t[r]}var r=t.exports=function(){if(arguments.length<1||typeof arguments[0]!=="object"){return false}if(arguments.length<2){return arguments[0]}var t=arguments[0];var i=Array.prototype.slice.call(arguments,1);var o,a,l;i.forEach((function(i){if(typeof i!=="object"||i===null||Array.isArray(i)){return}Object.keys(i).forEach((function(l){a=safeGetProperty(t,l);o=safeGetProperty(i,l);if(o===t){return}else if(typeof o!=="object"||o===null){t[l]=o;return}else if(Array.isArray(o)){t[l]=deepCloneArray(o);return}else if(isSpecificValue(o)){t[l]=cloneSpecificValue(o);return}else if(typeof a!=="object"||a===null||Array.isArray(a)){t[l]=r({},o);return}else{t[l]=r(a,o);return}}))}));return t}},3286:(t,r,i)=>{"use strict";const o=i(1017);const a=i(4997);const getExtensions=t=>t.length>1?`{${t.join(",")}}`:t[0];const getPath=(t,r)=>{const i=t[0]==="!"?t.slice(1):t;return o.isAbsolute(i)?i:o.join(r,i)};const addExtensions=(t,r)=>{if(o.extname(t)){return`**/${t}`}return`**/${t}.${getExtensions(r)}`};const getGlob=(t,r)=>{if(r.files&&!Array.isArray(r.files)){throw new TypeError(`Expected \`files\` to be of type \`Array\` but received type \`${typeof r.files}\``)}if(r.extensions&&!Array.isArray(r.extensions)){throw new TypeError(`Expected \`extensions\` to be of type \`Array\` but received type \`${typeof r.extensions}\``)}if(r.files&&r.extensions){return r.files.map((i=>o.posix.join(t,addExtensions(i,r.extensions))))}if(r.files){return r.files.map((r=>o.posix.join(t,`**/${r}`)))}if(r.extensions){return[o.posix.join(t,`**/*.${getExtensions(r.extensions)}`)]}return[o.posix.join(t,"**")]};t.exports=async(t,r)=>{r={cwd:process.cwd(),...r};if(typeof r.cwd!=="string"){throw new TypeError(`Expected \`cwd\` to be of type \`string\` but received type \`${typeof r.cwd}\``)}const i=await Promise.all([].concat(t).map((async t=>{const i=await a.isDirectory(getPath(t,r.cwd));return i?getGlob(t,r):t})));return[].concat.apply([],i)};t.exports.sync=(t,r)=>{r={cwd:process.cwd(),...r};if(typeof r.cwd!=="string"){throw new TypeError(`Expected \`cwd\` to be of type \`string\` but received type \`${typeof r.cwd}\``)}const i=[].concat(t).map((t=>a.isDirectorySync(getPath(t,r.cwd))?getGlob(t,r):t));return[].concat.apply([],i)}},1014:(t,r,i)=>{var o=i(9852);var noop=function(){};var isRequest=function(t){return t.setHeader&&typeof t.abort==="function"};var isChildProcess=function(t){return t.stdio&&Array.isArray(t.stdio)&&t.stdio.length===3};var eos=function(t,r,i){if(typeof r==="function")return eos(t,null,r);if(!r)r={};i=o(i||noop);var a=t._writableState;var l=t._readableState;var u=r.readable||r.readable!==false&&t.readable;var c=r.writable||r.writable!==false&&t.writable;var h=false;var onlegacyfinish=function(){if(!t.writable)onfinish()};var onfinish=function(){c=false;if(!u)i.call(t)};var onend=function(){u=false;if(!c)i.call(t)};var onexit=function(r){i.call(t,r?new Error("exited with error code: "+r):null)};var onerror=function(r){i.call(t,r)};var onclose=function(){process.nextTick(onclosenexttick)};var onclosenexttick=function(){if(h)return;if(u&&!(l&&(l.ended&&!l.destroyed)))return i.call(t,new Error("premature close"));if(c&&!(a&&(a.ended&&!a.destroyed)))return i.call(t,new Error("premature close"))};var onrequest=function(){t.req.on("finish",onfinish)};if(isRequest(t)){t.on("complete",onfinish);t.on("abort",onclose);if(t.req)onrequest();else t.on("request",onrequest)}else if(c&&!a){t.on("end",onlegacyfinish);t.on("close",onlegacyfinish)}if(isChildProcess(t))t.on("exit",onexit);t.on("end",onend);t.on("finish",onfinish);if(r.error!==false)t.on("error",onerror);t.on("close",onclose);return function(){h=true;t.removeListener("complete",onfinish);t.removeListener("abort",onclose);t.removeListener("request",onrequest);if(t.req)t.req.removeListener("finish",onfinish);t.removeListener("end",onlegacyfinish);t.removeListener("close",onlegacyfinish);t.removeListener("finish",onfinish);t.removeListener("exit",onexit);t.removeListener("end",onend);t.removeListener("error",onerror);t.removeListener("close",onclose)}};t.exports=eos},2153:(t,r,i)=>{"use strict";const o=i(6009);const a=i(7773);const l=i(4501);const u=i(9939);const c=i(1359);const h=i(9274);const p=i(9868);async function FastGlob(t,r){assertPatternsInput(t);const i=getWorks(t,l.default,r);const o=await Promise.all(i);return p.array.flatten(o)}(function(t){function sync(t,r){assertPatternsInput(t);const i=getWorks(t,c.default,r);return p.array.flatten(i)}t.sync=sync;function stream(t,r){assertPatternsInput(t);const i=getWorks(t,u.default,r);return p.stream.merge(i)}t.stream=stream;function generateTasks(t,r){assertPatternsInput(t);const i=a.transform([].concat(t));const l=new h.default(r);return o.generate(i,l)}t.generateTasks=generateTasks;function isDynamicPattern(t,r){assertPatternsInput(t);const i=new h.default(r);return p.pattern.isDynamicPattern(t,i)}t.isDynamicPattern=isDynamicPattern;function escapePath(t){assertPatternsInput(t);return p.path.escape(t)}t.escapePath=escapePath})(FastGlob||(FastGlob={}));function getWorks(t,r,i){const l=a.transform([].concat(t));const u=new h.default(i);const c=o.generate(l,u);const p=new r(u);return c.map(p.read,p)}function assertPatternsInput(t){const r=[].concat(t);const i=r.every((t=>p.string.isString(t)&&!p.string.isEmpty(t)));if(!i){throw new TypeError("Patterns must be a string (non empty) or an array of strings")}}t.exports=FastGlob},7773:(t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});r.removeDuplicateSlashes=r.transform=void 0;const i=/(?!^)\/{2,}/g;function transform(t){return t.map((t=>removeDuplicateSlashes(t)))}r.transform=transform;function removeDuplicateSlashes(t){return t.replace(i,"/")}r.removeDuplicateSlashes=removeDuplicateSlashes},6009:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});r.convertPatternGroupToTask=r.convertPatternGroupsToTasks=r.groupPatternsByBaseDirectory=r.getNegativePatternsAsPositive=r.getPositivePatterns=r.convertPatternsToTasks=r.generate=void 0;const o=i(9868);function generate(t,r){const i=getPositivePatterns(t);const a=getNegativePatternsAsPositive(t,r.ignore);const l=i.filter((t=>o.pattern.isStaticPattern(t,r)));const u=i.filter((t=>o.pattern.isDynamicPattern(t,r)));const c=convertPatternsToTasks(l,a,false);const h=convertPatternsToTasks(u,a,true);return c.concat(h)}r.generate=generate;function convertPatternsToTasks(t,r,i){const a=[];const l=o.pattern.getPatternsOutsideCurrentDirectory(t);const u=o.pattern.getPatternsInsideCurrentDirectory(t);const c=groupPatternsByBaseDirectory(l);const h=groupPatternsByBaseDirectory(u);a.push(...convertPatternGroupsToTasks(c,r,i));if("."in h){a.push(convertPatternGroupToTask(".",u,r,i))}else{a.push(...convertPatternGroupsToTasks(h,r,i))}return a}r.convertPatternsToTasks=convertPatternsToTasks;function getPositivePatterns(t){return o.pattern.getPositivePatterns(t)}r.getPositivePatterns=getPositivePatterns;function getNegativePatternsAsPositive(t,r){const i=o.pattern.getNegativePatterns(t).concat(r);const a=i.map(o.pattern.convertToPositivePattern);return a}r.getNegativePatternsAsPositive=getNegativePatternsAsPositive;function groupPatternsByBaseDirectory(t){const r={};return t.reduce(((t,r)=>{const i=o.pattern.getBaseDirectory(r);if(i in t){t[i].push(r)}else{t[i]=[r]}return t}),r)}r.groupPatternsByBaseDirectory=groupPatternsByBaseDirectory;function convertPatternGroupsToTasks(t,r,i){return Object.keys(t).map((o=>convertPatternGroupToTask(o,t[o],r,i)))}r.convertPatternGroupsToTasks=convertPatternGroupsToTasks;function convertPatternGroupToTask(t,r,i,a){return{dynamic:a,positive:r,negative:i,base:t,patterns:[].concat(r,i.map(o.pattern.convertToNegativePattern))}}r.convertPatternGroupToTask=convertPatternGroupToTask},4501:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});const o=i(6584);const a=i(2704);class ProviderAsync extends a.default{constructor(){super(...arguments);this._reader=new o.default(this._settings)}async read(t){const r=this._getRootDirectory(t);const i=this._getReaderOptions(t);const o=await this.api(r,t,i);return o.map((t=>i.transform(t)))}api(t,r,i){if(r.dynamic){return this._reader.dynamic(t,i)}return this._reader.static(r.patterns,i)}}r["default"]=ProviderAsync},3100:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});const o=i(9868);const a=i(8810);class DeepFilter{constructor(t,r){this._settings=t;this._micromatchOptions=r}getFilter(t,r,i){const o=this._getMatcher(r);const a=this._getNegativePatternsRe(i);return r=>this._filter(t,r,o,a)}_getMatcher(t){return new a.default(t,this._settings,this._micromatchOptions)}_getNegativePatternsRe(t){const r=t.filter(o.pattern.isAffectDepthOfReadingPattern);return o.pattern.convertPatternsToRe(r,this._micromatchOptions)}_filter(t,r,i,a){if(this._isSkippedByDeep(t,r.path)){return false}if(this._isSkippedSymbolicLink(r)){return false}const l=o.path.removeLeadingDotSegment(r.path);if(this._isSkippedByPositivePatterns(l,i)){return false}return this._isSkippedByNegativePatterns(l,a)}_isSkippedByDeep(t,r){if(this._settings.deep===Infinity){return false}return this._getEntryLevel(t,r)>=this._settings.deep}_getEntryLevel(t,r){const i=r.split("/").length;if(t===""){return i}const o=t.split("/").length;return i-o}_isSkippedSymbolicLink(t){return!this._settings.followSymbolicLinks&&t.dirent.isSymbolicLink()}_isSkippedByPositivePatterns(t,r){return!this._settings.baseNameMatch&&!r.match(t)}_isSkippedByNegativePatterns(t,r){return!o.pattern.matchAny(t,r)}}r["default"]=DeepFilter},3362:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});const o=i(9868);class EntryFilter{constructor(t,r){this._settings=t;this._micromatchOptions=r;this.index=new Map}getFilter(t,r){const i=o.pattern.convertPatternsToRe(t,this._micromatchOptions);const a=o.pattern.convertPatternsToRe(r,this._micromatchOptions);return t=>this._filter(t,i,a)}_filter(t,r,i){if(this._settings.unique&&this._isDuplicateEntry(t)){return false}if(this._onlyFileFilter(t)||this._onlyDirectoryFilter(t)){return false}if(this._isSkippedByAbsoluteNegativePatterns(t.path,i)){return false}const o=this._settings.baseNameMatch?t.name:t.path;const a=t.dirent.isDirectory();const l=this._isMatchToPatterns(o,r,a)&&!this._isMatchToPatterns(t.path,i,a);if(this._settings.unique&&l){this._createIndexRecord(t)}return l}_isDuplicateEntry(t){return this.index.has(t.path)}_createIndexRecord(t){this.index.set(t.path,undefined)}_onlyFileFilter(t){return this._settings.onlyFiles&&!t.dirent.isFile()}_onlyDirectoryFilter(t){return this._settings.onlyDirectories&&!t.dirent.isDirectory()}_isSkippedByAbsoluteNegativePatterns(t,r){if(!this._settings.absolute){return false}const i=o.path.makeAbsolute(this._settings.cwd,t);return o.pattern.matchAny(i,r)}_isMatchToPatterns(t,r,i){const a=o.path.removeLeadingDotSegment(t);const l=o.pattern.matchAny(a,r);if(!l&&i){return o.pattern.matchAny(a+"/",r)}return l}}r["default"]=EntryFilter},220:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});const o=i(9868);class ErrorFilter{constructor(t){this._settings=t}getFilter(){return t=>this._isNonFatalError(t)}_isNonFatalError(t){return o.errno.isEnoentCodeError(t)||this._settings.suppressErrors}}r["default"]=ErrorFilter},1358:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});const o=i(9868);class Matcher{constructor(t,r,i){this._patterns=t;this._settings=r;this._micromatchOptions=i;this._storage=[];this._fillStorage()}_fillStorage(){const t=o.pattern.expandPatternsWithBraceExpansion(this._patterns);for(const r of t){const t=this._getPatternSegments(r);const i=this._splitSegmentsIntoSections(t);this._storage.push({complete:i.length<=1,pattern:r,segments:t,sections:i})}}_getPatternSegments(t){const r=o.pattern.getPatternParts(t,this._micromatchOptions);return r.map((t=>{const r=o.pattern.isDynamicPattern(t,this._settings);if(!r){return{dynamic:false,pattern:t}}return{dynamic:true,pattern:t,patternRe:o.pattern.makeRe(t,this._micromatchOptions)}}))}_splitSegmentsIntoSections(t){return o.array.splitWhen(t,(t=>t.dynamic&&o.pattern.hasGlobStar(t.pattern)))}}r["default"]=Matcher},8810:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});const o=i(1358);class PartialMatcher extends o.default{match(t){const r=t.split("/");const i=r.length;const o=this._storage.filter((t=>!t.complete||t.segments.length>i));for(const t of o){const o=t.sections[0];if(!t.complete&&i>o.length){return true}const a=r.every(((r,i)=>{const o=t.segments[i];if(o.dynamic&&o.patternRe.test(r)){return true}if(!o.dynamic&&o.pattern===r){return true}return false}));if(a){return true}}return false}}r["default"]=PartialMatcher},2704:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});const o=i(1017);const a=i(3100);const l=i(3362);const u=i(220);const c=i(1852);class Provider{constructor(t){this._settings=t;this.errorFilter=new u.default(this._settings);this.entryFilter=new l.default(this._settings,this._getMicromatchOptions());this.deepFilter=new a.default(this._settings,this._getMicromatchOptions());this.entryTransformer=new c.default(this._settings)}_getRootDirectory(t){return o.resolve(this._settings.cwd,t.base)}_getReaderOptions(t){const r=t.base==="."?"":t.base;return{basePath:r,pathSegmentSeparator:"/",concurrency:this._settings.concurrency,deepFilter:this.deepFilter.getFilter(r,t.positive,t.negative),entryFilter:this.entryFilter.getFilter(t.positive,t.negative),errorFilter:this.errorFilter.getFilter(),followSymbolicLinks:this._settings.followSymbolicLinks,fs:this._settings.fs,stats:this._settings.stats,throwErrorOnBrokenSymbolicLink:this._settings.throwErrorOnBrokenSymbolicLink,transform:this.entryTransformer.getTransformer()}}_getMicromatchOptions(){return{dot:this._settings.dot,matchBase:this._settings.baseNameMatch,nobrace:!this._settings.braceExpansion,nocase:!this._settings.caseSensitiveMatch,noext:!this._settings.extglob,noglobstar:!this._settings.globstar,posix:true,strictSlashes:false}}}r["default"]=Provider},9939:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});const o=i(2781);const a=i(8197);const l=i(2704);class ProviderStream extends l.default{constructor(){super(...arguments);this._reader=new a.default(this._settings)}read(t){const r=this._getRootDirectory(t);const i=this._getReaderOptions(t);const a=this.api(r,t,i);const l=new o.Readable({objectMode:true,read:()=>{}});a.once("error",(t=>l.emit("error",t))).on("data",(t=>l.emit("data",i.transform(t)))).once("end",(()=>l.emit("end")));l.once("close",(()=>a.destroy()));return l}api(t,r,i){if(r.dynamic){return this._reader.dynamic(t,i)}return this._reader.static(r.patterns,i)}}r["default"]=ProviderStream},1359:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});const o=i(9897);const a=i(2704);class ProviderSync extends a.default{constructor(){super(...arguments);this._reader=new o.default(this._settings)}read(t){const r=this._getRootDirectory(t);const i=this._getReaderOptions(t);const o=this.api(r,t,i);return o.map(i.transform)}api(t,r,i){if(r.dynamic){return this._reader.dynamic(t,i)}return this._reader.static(r.patterns,i)}}r["default"]=ProviderSync},1852:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});const o=i(9868);class EntryTransformer{constructor(t){this._settings=t}getTransformer(){return t=>this._transform(t)}_transform(t){let r=t.path;if(this._settings.absolute){r=o.path.makeAbsolute(this._settings.cwd,r);r=o.path.unixify(r)}if(this._settings.markDirectories&&t.dirent.isDirectory()){r+="/"}if(!this._settings.objectMode){return r}return Object.assign(Object.assign({},t),{path:r})}}r["default"]=EntryTransformer},6584:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});const o=i(204);const a=i(9557);const l=i(8197);class ReaderAsync extends a.default{constructor(){super(...arguments);this._walkAsync=o.walk;this._readerStream=new l.default(this._settings)}dynamic(t,r){return new Promise(((i,o)=>{this._walkAsync(t,r,((t,r)=>{if(t===null){i(r)}else{o(t)}}))}))}async static(t,r){const i=[];const o=this._readerStream.static(t,r);return new Promise(((t,r)=>{o.once("error",r);o.on("data",(t=>i.push(t)));o.once("end",(()=>t(i)))}))}}r["default"]=ReaderAsync},9557:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});const o=i(1017);const a=i(5587);const l=i(9868);class Reader{constructor(t){this._settings=t;this._fsStatSettings=new a.Settings({followSymbolicLink:this._settings.followSymbolicLinks,fs:this._settings.fs,throwErrorOnBrokenSymbolicLink:this._settings.followSymbolicLinks})}_getFullEntryPath(t){return o.resolve(this._settings.cwd,t)}_makeEntry(t,r){const i={name:r,path:r,dirent:l.fs.createDirentFromStats(r,t)};if(this._settings.stats){i.stats=t}return i}_isFatalError(t){return!l.errno.isEnoentCodeError(t)&&!this._settings.suppressErrors}}r["default"]=Reader},8197:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});const o=i(2781);const a=i(5587);const l=i(204);const u=i(9557);class ReaderStream extends u.default{constructor(){super(...arguments);this._walkStream=l.walkStream;this._stat=a.stat}dynamic(t,r){return this._walkStream(t,r)}static(t,r){const i=t.map(this._getFullEntryPath,this);const a=new o.PassThrough({objectMode:true});a._write=(o,l,u)=>this._getEntry(i[o],t[o],r).then((t=>{if(t!==null&&r.entryFilter(t)){a.push(t)}if(o===i.length-1){a.end()}u()})).catch(u);for(let t=0;t<i.length;t++){a.write(t)}return a}_getEntry(t,r,i){return this._getStat(t).then((t=>this._makeEntry(t,r))).catch((t=>{if(i.errorFilter(t)){return null}throw t}))}_getStat(t){return new Promise(((r,i)=>{this._stat(t,this._fsStatSettings,((t,o)=>t===null?r(o):i(t)))}))}}r["default"]=ReaderStream},9897:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});const o=i(5587);const a=i(204);const l=i(9557);class ReaderSync extends l.default{constructor(){super(...arguments);this._walkSync=a.walkSync;this._statSync=o.statSync}dynamic(t,r){return this._walkSync(t,r)}static(t,r){const i=[];for(const o of t){const t=this._getFullEntryPath(o);const a=this._getEntry(t,o,r);if(a===null||!r.entryFilter(a)){continue}i.push(a)}return i}_getEntry(t,r,i){try{const i=this._getStat(t);return this._makeEntry(i,r)}catch(t){if(i.errorFilter(t)){return null}throw t}}_getStat(t){return this._statSync(t,this._fsStatSettings)}}r["default"]=ReaderSync},9274:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});r.DEFAULT_FILE_SYSTEM_ADAPTER=void 0;const o=i(7147);const a=i(2037);const l=Math.max(a.cpus().length,1);r.DEFAULT_FILE_SYSTEM_ADAPTER={lstat:o.lstat,lstatSync:o.lstatSync,stat:o.stat,statSync:o.statSync,readdir:o.readdir,readdirSync:o.readdirSync};class Settings{constructor(t={}){this._options=t;this.absolute=this._getValue(this._options.absolute,false);this.baseNameMatch=this._getValue(this._options.baseNameMatch,false);this.braceExpansion=this._getValue(this._options.braceExpansion,true);this.caseSensitiveMatch=this._getValue(this._options.caseSensitiveMatch,true);this.concurrency=this._getValue(this._options.concurrency,l);this.cwd=this._getValue(this._options.cwd,process.cwd());this.deep=this._getValue(this._options.deep,Infinity);this.dot=this._getValue(this._options.dot,false);this.extglob=this._getValue(this._options.extglob,true);this.followSymbolicLinks=this._getValue(this._options.followSymbolicLinks,true);this.fs=this._getFileSystemMethods(this._options.fs);this.globstar=this._getValue(this._options.globstar,true);this.ignore=this._getValue(this._options.ignore,[]);this.markDirectories=this._getValue(this._options.markDirectories,false);this.objectMode=this._getValue(this._options.objectMode,false);this.onlyDirectories=this._getValue(this._options.onlyDirectories,false);this.onlyFiles=this._getValue(this._options.onlyFiles,true);this.stats=this._getValue(this._options.stats,false);this.suppressErrors=this._getValue(this._options.suppressErrors,false);this.throwErrorOnBrokenSymbolicLink=this._getValue(this._options.throwErrorOnBrokenSymbolicLink,false);this.unique=this._getValue(this._options.unique,true);if(this.onlyDirectories){this.onlyFiles=false}if(this.stats){this.objectMode=true}}_getValue(t,r){return t===undefined?r:t}_getFileSystemMethods(t={}){return Object.assign(Object.assign({},r.DEFAULT_FILE_SYSTEM_ADAPTER),t)}}r["default"]=Settings},4614:(t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});r.splitWhen=r.flatten=void 0;function flatten(t){return t.reduce(((t,r)=>[].concat(t,r)),[])}r.flatten=flatten;function splitWhen(t,r){const i=[[]];let o=0;for(const a of t){if(r(a)){o++;i[o]=[]}else{i[o].push(a)}}return i}r.splitWhen=splitWhen},7241:(t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});r.isEnoentCodeError=void 0;function isEnoentCodeError(t){return t.code==="ENOENT"}r.isEnoentCodeError=isEnoentCodeError},4996:(t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});r.createDirentFromStats=void 0;class DirentFromStats{constructor(t,r){this.name=t;this.isBlockDevice=r.isBlockDevice.bind(r);this.isCharacterDevice=r.isCharacterDevice.bind(r);this.isDirectory=r.isDirectory.bind(r);this.isFIFO=r.isFIFO.bind(r);this.isFile=r.isFile.bind(r);this.isSocket=r.isSocket.bind(r);this.isSymbolicLink=r.isSymbolicLink.bind(r)}}function createDirentFromStats(t,r){return new DirentFromStats(t,r)}r.createDirentFromStats=createDirentFromStats},9868:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});r.string=r.stream=r.pattern=r.path=r.fs=r.errno=r.array=void 0;const o=i(4614);r.array=o;const a=i(7241);r.errno=a;const l=i(4996);r.fs=l;const u=i(2508);r.path=u;const c=i(9511);r.pattern=c;const h=i(8101);r.stream=h;const p=i(7525);r.string=p},2508:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});r.removeLeadingDotSegment=r.escape=r.makeAbsolute=r.unixify=void 0;const o=i(1017);const a=2;const l=/(\\?)([()*?[\]{|}]|^!|[!+@](?=\())/g;function unixify(t){return t.replace(/\\/g,"/")}r.unixify=unixify;function makeAbsolute(t,r){return o.resolve(t,r)}r.makeAbsolute=makeAbsolute;function escape(t){return t.replace(l,"\\$2")}r.escape=escape;function removeLeadingDotSegment(t){if(t.charAt(0)==="."){const r=t.charAt(1);if(r==="/"||r==="\\"){return t.slice(a)}}return t}r.removeLeadingDotSegment=removeLeadingDotSegment},9511:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});r.matchAny=r.convertPatternsToRe=r.makeRe=r.getPatternParts=r.expandBraceExpansion=r.expandPatternsWithBraceExpansion=r.isAffectDepthOfReadingPattern=r.endsWithSlashGlobStar=r.hasGlobStar=r.getBaseDirectory=r.isPatternRelatedToParentDirectory=r.getPatternsOutsideCurrentDirectory=r.getPatternsInsideCurrentDirectory=r.getPositivePatterns=r.getNegativePatterns=r.isPositivePattern=r.isNegativePattern=r.convertToNegativePattern=r.convertToPositivePattern=r.isDynamicPattern=r.isStaticPattern=void 0;const o=i(1017);const a=i(7080);const l=i(1065);const u="**";const c="\\";const h=/[*?]|^!/;const p=/\[[^[]*]/;const d=/(?:^|[^!*+?@])\([^(]*\|[^|]*\)/;const m=/[!*+?@]\([^(]*\)/;const g=/,|\.\./;function isStaticPattern(t,r={}){return!isDynamicPattern(t,r)}r.isStaticPattern=isStaticPattern;function isDynamicPattern(t,r={}){if(t===""){return false}if(r.caseSensitiveMatch===false||t.includes(c)){return true}if(h.test(t)||p.test(t)||d.test(t)){return true}if(r.extglob!==false&&m.test(t)){return true}if(r.braceExpansion!==false&&hasBraceExpansion(t)){return true}return false}r.isDynamicPattern=isDynamicPattern;function hasBraceExpansion(t){const r=t.indexOf("{");if(r===-1){return false}const i=t.indexOf("}",r+1);if(i===-1){return false}const o=t.slice(r,i);return g.test(o)}function convertToPositivePattern(t){return isNegativePattern(t)?t.slice(1):t}r.convertToPositivePattern=convertToPositivePattern;function convertToNegativePattern(t){return"!"+t}r.convertToNegativePattern=convertToNegativePattern;function isNegativePattern(t){return t.startsWith("!")&&t[1]!=="("}r.isNegativePattern=isNegativePattern;function isPositivePattern(t){return!isNegativePattern(t)}r.isPositivePattern=isPositivePattern;function getNegativePatterns(t){return t.filter(isNegativePattern)}r.getNegativePatterns=getNegativePatterns;function getPositivePatterns(t){return t.filter(isPositivePattern)}r.getPositivePatterns=getPositivePatterns;function getPatternsInsideCurrentDirectory(t){return t.filter((t=>!isPatternRelatedToParentDirectory(t)))}r.getPatternsInsideCurrentDirectory=getPatternsInsideCurrentDirectory;function getPatternsOutsideCurrentDirectory(t){return t.filter(isPatternRelatedToParentDirectory)}r.getPatternsOutsideCurrentDirectory=getPatternsOutsideCurrentDirectory;function isPatternRelatedToParentDirectory(t){return t.startsWith("..")||t.startsWith("./..")}r.isPatternRelatedToParentDirectory=isPatternRelatedToParentDirectory;function getBaseDirectory(t){return a(t,{flipBackslashes:false})}r.getBaseDirectory=getBaseDirectory;function hasGlobStar(t){return t.includes(u)}r.hasGlobStar=hasGlobStar;function endsWithSlashGlobStar(t){return t.endsWith("/"+u)}r.endsWithSlashGlobStar=endsWithSlashGlobStar;function isAffectDepthOfReadingPattern(t){const r=o.basename(t);return endsWithSlashGlobStar(t)||isStaticPattern(r)}r.isAffectDepthOfReadingPattern=isAffectDepthOfReadingPattern;function expandPatternsWithBraceExpansion(t){return t.reduce(((t,r)=>t.concat(expandBraceExpansion(r))),[])}r.expandPatternsWithBraceExpansion=expandPatternsWithBraceExpansion;function expandBraceExpansion(t){return l.braces(t,{expand:true,nodupes:true})}r.expandBraceExpansion=expandBraceExpansion;function getPatternParts(t,r){let{parts:i}=l.scan(t,Object.assign(Object.assign({},r),{parts:true}));if(i.length===0){i=[t]}if(i[0].startsWith("/")){i[0]=i[0].slice(1);i.unshift("")}return i}r.getPatternParts=getPatternParts;function makeRe(t,r){return l.makeRe(t,r)}r.makeRe=makeRe;function convertPatternsToRe(t,r){return t.map((t=>makeRe(t,r)))}r.convertPatternsToRe=convertPatternsToRe;function matchAny(t,r){return r.some((r=>r.test(t)))}r.matchAny=matchAny},8101:(t,r,i)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});r.merge=void 0;const o=i(9117);function merge(t){const r=o(t);t.forEach((t=>{t.once("error",(t=>r.emit("error",t)))}));r.once("close",(()=>propagateCloseEventToSources(t)));r.once("end",(()=>propagateCloseEventToSources(t)));return r}r.merge=merge;function propagateCloseEventToSources(t){t.forEach((t=>t.emit("close")))}},7525:(t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:true});r.isEmpty=r.isString=void 0;function isString(t){return typeof t==="string"}r.isString=isString;function isEmpty(t){return t===""}r.isEmpty=isEmpty},8205:(t,r,i)=>{"use strict";var o=i(7327);function fastqueue(t,r,i){if(typeof t==="function"){i=r;r=t;t=null}if(i<1){throw new Error("fastqueue concurrency must be greater than 1")}var a=o(Task);var l=null;var u=null;var c=0;var h=null;var p={push:push,drain:noop,saturated:noop,pause:pause,paused:false,concurrency:i,running:running,resume:resume,idle:idle,length:length,getQueue:getQueue,unshift:unshift,empty:noop,kill:kill,killAndDrain:killAndDrain,error:error};return p;function running(){return c}function pause(){p.paused=true}function length(){var t=l;var r=0;while(t){t=t.next;r++}return r}function getQueue(){var t=l;var r=[];while(t){r.push(t.value);t=t.next}return r}function resume(){if(!p.paused)return;p.paused=false;for(var t=0;t<p.concurrency;t++){c++;release()}}function idle(){return c===0&&p.length()===0}function push(i,o){var d=a.get();d.context=t;d.release=release;d.value=i;d.callback=o||noop;d.errorHandler=h;if(c===p.concurrency||p.paused){if(u){u.next=d;u=d}else{l=d;u=d;p.saturated()}}else{c++;r.call(t,d.value,d.worked)}}function unshift(i,o){var h=a.get();h.context=t;h.release=release;h.value=i;h.callback=o||noop;if(c===p.concurrency||p.paused){if(l){h.next=l;l=h}else{l=h;u=h;p.saturated()}}else{c++;r.call(t,h.value,h.worked)}}function release(i){if(i){a.release(i)}var o=l;if(o){if(!p.paused){if(u===l){u=null}l=o.next;o.next=null;r.call(t,o.value,o.worked);if(u===null){p.empty()}}else{c--}}else if(--c===0){p.drain()}}function kill(){l=null;u=null;p.drain=noop}function killAndDrain(){l=null;u=null;p.drain();p.drain=noop}function error(t){h=t}}function noop(){}function Task(){this.value=null;this.callback=noop;this.next=null;this.release=noop;this.context=null;this.errorHandler=null;var t=this;this.worked=function worked(r,i){var o=t.callback;var a=t.errorHandler;var l=t.value;t.value=null;t.callback=noop;if(t.errorHandler){a(r,l)}o.call(t.context,r,i);t.release(t)}}function queueAsPromised(t,r,i){if(typeof t==="function"){i=r;r=t;t=null}function asyncWrapper(t,i){r.call(this,t).then((function(t){i(null,t)}),i)}var o=fastqueue(t,asyncWrapper,i);var a=o.push;var l=o.unshift;o.push=push;o.unshift=unshift;o.drained=drained;return o;function push(t){var r=new Promise((function(r,i){a(t,(function(t,o){if(t){i(t);return}r(o)}))}));r.catch(noop);return r}function unshift(t){var r=new Promise((function(r,i){l(t,(function(t,o){if(t){i(t);return}r(o)}))}));r.catch(noop);return r}function drained(){var t=o.drain;var r=new Promise((function(r){o.drain=function(){t();r()}}));return r}}t.exports=fastqueue;t.exports.promise=queueAsPromised},7783:(t,r,i)=>{"use strict";
|
|
79
79
|
/*!
|
|
80
80
|
* fill-range <https://github.com/jonschlinkert/fill-range>
|
|
81
81
|
*
|
|
@@ -128,4 +128,4 @@ var o=i(4300);var a=o.Buffer;function copyProps(t,r){for(var i in t){r[i]=t[i]}}
|
|
|
128
128
|
* @license [MIT]{@link https://github.com/archiverjs/node-zip-stream/blob/master/LICENSE}
|
|
129
129
|
* @copyright (c) 2014 Chris Talkington, contributors.
|
|
130
130
|
*/
|
|
131
|
-
var o=i(3837).inherits;var a=i(2096).ZipArchiveOutputStream;var l=i(2096).ZipArchiveEntry;var u=i(1246);var c=t.exports=function(t){if(!(this instanceof c)){return new c(t)}t=this.options=t||{};t.zlib=t.zlib||{};a.call(this,t);if(typeof t.level==="number"&&t.level>=0){t.zlib.level=t.level;delete t.level}if(!t.forceZip64&&typeof t.zlib.level==="number"&&t.zlib.level===0){t.store=true}t.namePrependSlash=t.namePrependSlash||false;if(t.comment&&t.comment.length>0){this.setComment(t.comment)}};o(c,a);c.prototype._normalizeFileData=function(t){t=u.defaults(t,{type:"file",name:null,namePrependSlash:this.options.namePrependSlash,linkname:null,date:null,mode:null,store:this.options.store,comment:""});var r=t.type==="directory";var i=t.type==="symlink";if(t.name){t.name=u.sanitizePath(t.name);if(!i&&t.name.slice(-1)==="/"){r=true;t.type="directory"}else if(r){t.name+="/"}}if(r||i){t.store=true}t.date=u.dateify(t.date);return t};c.prototype.entry=function(t,r,i){if(typeof i!=="function"){i=this._emitErrorCallback.bind(this)}r=this._normalizeFileData(r);if(r.type!=="file"&&r.type!=="directory"&&r.type!=="symlink"){i(new Error(r.type+" entries not currently supported"));return}if(typeof r.name!=="string"||r.name.length===0){i(new Error("entry name must be a non-empty string value"));return}if(r.type==="symlink"&&typeof r.linkname!=="string"){i(new Error("entry linkname must be a non-empty string value when type equals symlink"));return}var o=new l(r.name);o.setTime(r.date,this.options.forceLocalTime);if(r.namePrependSlash){o.setName(r.name,true)}if(r.store){o.setMethod(0)}if(r.comment.length>0){o.setComment(r.comment)}if(r.type==="symlink"&&typeof r.mode!=="number"){r.mode=40960}if(typeof r.mode==="number"){if(r.type==="symlink"){r.mode|=40960}o.setUnixMode(r.mode)}if(r.type==="symlink"&&typeof r.linkname==="string"){t=Buffer.from(r.linkname)}return a.prototype.entry.call(this,o,t,i)};c.prototype.finalize=function(){this.finish()}},2746:(t,r,i)=>{"use strict";i.r(r);const o=10;const wrapAnsi16=(t=0)=>r=>`[${r+t}m`;const wrapAnsi256=(t=0)=>r=>`[${38+t};5;${r}m`;const wrapAnsi16m=(t=0)=>(r,i,o)=>`[${38+t};2;${r};${i};${o}m`;const a={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};const l=Object.keys(a.modifier);const u=Object.keys(a.color);const c=Object.keys(a.bgColor);const h=[...u,...c];function assembleStyles(){const t=new Map;for(const[r,i]of Object.entries(a)){for(const[r,o]of Object.entries(i)){a[r]={open:`[${o[0]}m`,close:`[${o[1]}m`};i[r]=a[r];t.set(o[0],o[1])}Object.defineProperty(a,r,{value:i,enumerable:false})}Object.defineProperty(a,"codes",{value:t,enumerable:false});a.color.close="[39m";a.bgColor.close="[49m";a.color.ansi=wrapAnsi16();a.color.ansi256=wrapAnsi256();a.color.ansi16m=wrapAnsi16m();a.bgColor.ansi=wrapAnsi16(o);a.bgColor.ansi256=wrapAnsi256(o);a.bgColor.ansi16m=wrapAnsi16m(o);Object.defineProperties(a,{rgbToAnsi256:{value(t,r,i){if(t===r&&r===i){if(t<8){return 16}if(t>248){return 231}return Math.round((t-8)/247*24)+232}return 16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(i/255*5)},enumerable:false},hexToRgb:{value(t){const r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!r){return[0,0,0]}let[i]=r;if(i.length===3){i=[...i].map((t=>t+t)).join("")}const o=Number.parseInt(i,16);return[o>>16&255,o>>8&255,o&255]},enumerable:false},hexToAnsi256:{value:t=>a.rgbToAnsi256(...a.hexToRgb(t)),enumerable:false},ansi256ToAnsi:{value(t){if(t<8){return 30+t}if(t<16){return 90+(t-8)}let r;let i;let o;if(t>=232){r=((t-232)*10+8)/255;i=r;o=r}else{t-=16;const a=t%36;r=Math.floor(t/36)/5;i=Math.floor(a/6)/5;o=a%6/5}const a=Math.max(r,i,o)*2;if(a===0){return 30}let l=30+(Math.round(o)<<2|Math.round(i)<<1|Math.round(r));if(a===2){l+=60}return l},enumerable:false},rgbToAnsi:{value:(t,r,i)=>a.ansi256ToAnsi(a.rgbToAnsi256(t,r,i)),enumerable:false},hexToAnsi:{value:t=>a.ansi256ToAnsi(a.hexToAnsi256(t)),enumerable:false}});return a}const p=assembleStyles();const d=p;const m=require("node:process");const g=require("node:os");const y=require("node:tty");function hasFlag(t,r=m.argv){const i=t.startsWith("-")?"":t.length===1?"-":"--";const o=r.indexOf(i+t);const a=r.indexOf("--");return o!==-1&&(a===-1||o<a)}const{env:v}=m;let b;if(hasFlag("no-color")||hasFlag("no-colors")||hasFlag("color=false")||hasFlag("color=never")){b=0}else if(hasFlag("color")||hasFlag("colors")||hasFlag("color=true")||hasFlag("color=always")){b=1}function envForceColor(){if("FORCE_COLOR"in v){if(v.FORCE_COLOR==="true"){return 1}if(v.FORCE_COLOR==="false"){return 0}return v.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(v.FORCE_COLOR,10),3)}}function translateLevel(t){if(t===0){return false}return{level:t,hasBasic:true,has256:t>=2,has16m:t>=3}}function _supportsColor(t,{streamIsTTY:r,sniffFlags:i=true}={}){const o=envForceColor();if(o!==undefined){b=o}const a=i?b:o;if(a===0){return 0}if(i){if(hasFlag("color=16m")||hasFlag("color=full")||hasFlag("color=truecolor")){return 3}if(hasFlag("color=256")){return 2}}if(t&&!r&&a===undefined){return 0}const l=a||0;if(v.TERM==="dumb"){return l}if(m.platform==="win32"){const t=g.release().split(".");if(Number(t[0])>=10&&Number(t[2])>=10586){return Number(t[2])>=14931?3:2}return 1}if("CI"in v){if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some((t=>t in v))||v.CI_NAME==="codeship"){return 1}return l}if("TEAMCITY_VERSION"in v){return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(v.TEAMCITY_VERSION)?1:0}if("TF_BUILD"in v&&"AGENT_NAME"in v){return 1}if(v.COLORTERM==="truecolor"){return 3}if("TERM_PROGRAM"in v){const t=Number.parseInt((v.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(v.TERM_PROGRAM){case"iTerm.app":return t>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(v.TERM)){return 2}if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(v.TERM)){return 1}if("COLORTERM"in v){return 1}return l}function createSupportsColor(t,r={}){const i=_supportsColor(t,{streamIsTTY:t&&t.isTTY,...r});return translateLevel(i)}const _={stdout:createSupportsColor({isTTY:y.isatty(1)}),stderr:createSupportsColor({isTTY:y.isatty(2)})};const w=_;function stringReplaceAll(t,r,i){let o=t.indexOf(r);if(o===-1){return t}const a=r.length;let l=0;let u="";do{u+=t.slice(l,o)+r+i;l=o+a;o=t.indexOf(r,l)}while(o!==-1);u+=t.slice(l);return u}function stringEncaseCRLFWithFirstIndex(t,r,i,o){let a=0;let l="";do{const u=t[o-1]==="\r";l+=t.slice(a,u?o-1:o)+r+(u?"\r\n":"\n")+i;a=o+1;o=t.indexOf("\n",a)}while(o!==-1);l+=t.slice(a);return l}const{stdout:S,stderr:E}=w;const x=Symbol("GENERATOR");const O=Symbol("STYLER");const A=Symbol("IS_EMPTY");const k=["ansi","ansi","ansi256","ansi16m"];const R=Object.create(null);const applyOptions=(t,r={})=>{if(r.level&&!(Number.isInteger(r.level)&&r.level>=0&&r.level<=3)){throw new Error("The `level` option should be an integer from 0 to 3")}const i=S?S.level:0;t.level=r.level===undefined?i:r.level};class Chalk{constructor(t){return chalkFactory(t)}}const chalkFactory=t=>{const chalk=(...t)=>t.join(" ");applyOptions(chalk,t);Object.setPrototypeOf(chalk,createChalk.prototype);return chalk};function createChalk(t){return chalkFactory(t)}Object.setPrototypeOf(createChalk.prototype,Function.prototype);for(const[t,r]of Object.entries(d)){R[t]={get(){const i=createBuilder(this,createStyler(r.open,r.close,this[O]),this[A]);Object.defineProperty(this,t,{value:i});return i}}}R.visible={get(){const t=createBuilder(this,this[O],true);Object.defineProperty(this,"visible",{value:t});return t}};const getModelAnsi=(t,r,i,...o)=>{if(t==="rgb"){if(r==="ansi16m"){return d[i].ansi16m(...o)}if(r==="ansi256"){return d[i].ansi256(d.rgbToAnsi256(...o))}return d[i].ansi(d.rgbToAnsi(...o))}if(t==="hex"){return getModelAnsi("rgb",r,i,...d.hexToRgb(...o))}return d[i][t](...o)};const T=["rgb","hex","ansi256"];for(const t of T){R[t]={get(){const{level:r}=this;return function(...i){const o=createStyler(getModelAnsi(t,k[r],"color",...i),d.color.close,this[O]);return createBuilder(this,o,this[A])}}};const r="bg"+t[0].toUpperCase()+t.slice(1);R[r]={get(){const{level:r}=this;return function(...i){const o=createStyler(getModelAnsi(t,k[r],"bgColor",...i),d.bgColor.close,this[O]);return createBuilder(this,o,this[A])}}}}const C=Object.defineProperties((()=>{}),{...R,level:{enumerable:true,get(){return this[x].level},set(t){this[x].level=t}}});const createStyler=(t,r,i)=>{let o;let a;if(i===undefined){o=t;a=r}else{o=i.openAll+t;a=r+i.closeAll}return{open:t,close:r,openAll:o,closeAll:a,parent:i}};const createBuilder=(t,r,i)=>{const builder=(...t)=>applyStyle(builder,t.length===1?""+t[0]:t.join(" "));Object.setPrototypeOf(builder,C);builder[x]=t;builder[O]=r;builder[A]=i;return builder};const applyStyle=(t,r)=>{if(t.level<=0||!r){return t[A]?"":r}let i=t[O];if(i===undefined){return r}const{openAll:o,closeAll:a}=i;if(r.includes("")){while(i!==undefined){r=stringReplaceAll(r,i.close,i.open);i=i.parent}}const l=r.indexOf("\n");if(l!==-1){r=stringEncaseCRLFWithFirstIndex(r,a,o,l)}return o+r+a};Object.defineProperties(createChalk.prototype,R);const P=createChalk();const I=createChalk({level:E?E.level:0});const L=P;var M=i(345);const{program:D,createCommand:N,createArgument:j,createOption:$,CommanderError:B,InvalidArgumentError:H,InvalidOptionArgumentError:G,Command:W,Argument:U,Option:V,Help:q}=M;var z=i(5656);var Y=i.n(z);var K=i(1017);var Q=i.n(K);var Z=i(7147);var X=i.n(Z);function isSetup(t){const r="Could not find .hyperbook folder. Be sure to run `hyperbook setup`.";try{const r=X().statSync(Q().join(t,".hyperbook"));if(!r.isDirectory()){throw Error()}}catch(t){console.log(L.red(`Could not find .hyperbook folder at ${r}. Be sure to run \`hyperbook setup\`.`));return false}if(process.env.HYPERBOOK_LOCAL_DEV){return true}const i=Q().join(t,".hyperbook","node_modules",".bin","next");try{X().statSync(i)}catch(t){console.log(L.red(`Could not find next binary at ${i}. Be sure to run \`hyperbook setup\`.`));return false}return true}var J=i(2202);var ee=i.n(J);async function archiveFolder(t,r,i){return new Promise(((o,a)=>{const l=Q().join(t,"public","archives");if(!X().existsSync(l)){X().mkdirSync(l,{recursive:true})}const u=Q().join(l,r+".zip");const c=X().createWriteStream(u);const h=ee()("zip",{zlib:{level:9}});h.on("finish",(()=>{console.log(`${L.green(`[${i}]`)} Archive ${r} zipped.`);o()}));h.on("error",(t=>{throw t}));h.pipe(c);h.directory(Q().join(t,"archives",r),false);h.finalize()}))}async function runArchive(t,r){const i=isSetup(t);if(!i){throw new Error("no setup")}return new Promise(((i,o)=>{if(!X().existsSync(Q().join(t,"archives"))){console.log(`${L.blue(`[${r}]`)} No archives found.`);i()}else{console.log(`${L.blue(`[${r}]`)} Zipping archives.`);const a=X().readdirSync(Q().join(t,"archives"),{withFileTypes:true}).filter((t=>t.isDirectory()));Promise.all(a.map((i=>archiveFolder(t,i.name,r)))).then((()=>{i()})).catch((()=>{o()}))}}))}var te=i(4488);var re=i.n(te);var ie=i(4521);var ne=i.n(ie);async function readHyperbook(t){return new Promise(((r,i)=>{X().readFile(Q().join(t,"hyperbook.json"),((t,o)=>{if(t){console.log(L.red("Could not find 'hyperbook.json'. Make sure you are in the right directory."));i()}else{const t=JSON.parse(o.toString());r(t)}}))}))}const se=require("fs/promises");var oe=i.n(se);function getProjectName(t,r){let i="";if(typeof t.name==="string"){i=t.name}else{if(r){i=t.name[r]}else{i=Object.values(t.name)[0]}if(!i){console.log(L.red(`You need to provide a name for language ${r} in ${t.src}`));throw Error("")}}return i}function makeLinks(t,r="en"){var i;const o=getProjectName(t,r);if(t.type==="library"){return{label:o,links:t.projects.map((t=>makeLinks(t,r))),icon:t.icon}}else{let r=(i=t.basePath)!==null&&i!==void 0?i:"/";if(!r.startsWith("/")){r="/"+r}if(r.length>1&&r.endsWith("/")){r=r.slice(0,-1)}return{label:o,href:r,icon:t.icon}}}async function collect(t,r,i,o){const a=await oe().readFile(Q().join(t,"hyperbook.json")).then((t=>JSON.parse(t.toString()))).catch((t=>{if(t instanceof SyntaxError){console.error(t)}return null}));if(a){return{type:"book",src:t,basePath:r!==null&&r!==void 0?r:a.basePath,template:a.template,name:i!==null&&i!==void 0?i:a.name,icon:o}}const l=await oe().readFile(Q().join(t,"hyperlibrary.json")).then((t=>JSON.parse(t.toString()))).catch((t=>{if(t instanceof SyntaxError){console.error(t)}return null}));if(l){const a=await Promise.all(l.library.map((async({src:i,basePath:o,name:a,icon:u})=>{var c;if(!o){console.log(L.red(`Missing basePath for book ${a} in library ${Q().join(t,"hyperlibrary.json")}`))}return collect(Q().join(t,i),Q().join((c=r!==null&&r!==void 0?r:l.basePath)!==null&&c!==void 0?c:"",o),a,u)})));return{type:"library",name:i!==null&&i!==void 0?i:l.name,basePath:r!==null&&r!==void 0?r:l.basePath,src:t,icon:o,projects:a}}console.log(`${L.red("Error")} - Missing book or library for path ${t}.`);throw Error(`Missing book or library for path ${t}`)}async function makeDir(t,r={recursive:true}){await X().promises.mkdir(t,r)}var ae=i(4700);var le=i.n(ae);function makeEnv(){let t=process.env.NODE_PATH;let r=process.env.PATH;if(process.env.HYPERBOOK_LOCAL_DEV){t=Q().join(__dirname,"..","..","..","templates","simple","node_modules");r=Q().join(__dirname,"..","..","..","templates","simple","node_modules",".bin")+":"+r}const i={NODE_PATH:t,PATH:r};return i}async function runBuildProject(t,r,i){if(t.type==="book"){console.log(`${L.blue(`[${t.name}]`)} Building Book.`);const o=getProjectName(t);await runBuild(t.src,r,t.basePath,o,i)}else{if(!i){i=t.src;le().sync(Q().join(i,".hyperbook","out"))}console.log(`${L.blue(`[${t.name}]`)} Building Library.`);for(const o of t.projects){await runBuildProject(o,r,i)}}}async function runBuild(t,r,i,o,a){const l=isSetup(t);if(!l){throw new Error("no setup")}await runArchive(t,o);const u=await readHyperbook(t);if(!i&&(u===null||u===void 0?void 0:u.basePath)){i=u.basePath}if(i&&!i.startsWith("/")){i="/"+i}if(i&&i.endsWith("/")){i=i.slice(0,-1)}X().writeFileSync(Q().join(t,".hyperbook","next.config.js"),`\nmodule.exports = {\n ${i?`basePath: '${i}',`:""}\n typescript: {\n ignoreBuildErrors: true,\n }\n}\n `);const c=await readHyperbook(t);let h=undefined;if(r.type==="library"){h=makeLinks(r,c.language)}if(h){if(!c.links){c.links=[h]}else{c.links.push(h)}}c.basePath=i;X().cpSync(Q().join(t,"hyperbook.json"),Q().join(t,".hyperbook","hyperbook.json"),{force:true});X().writeFileSync(Q().join(t,".hyperbook","hyperbook.json"),JSON.stringify(c,null,2));return new Promise(((r,l)=>{var u;const c="npm";const h=["run","next:build"];const p=makeEnv();const d=re()(c,h,{stdio:"pipe",cwd:Q().join(t,".hyperbook"),env:{...process.env,...p,ADBLOCK:"1",DISABLE_OPENCOLLECTIVE:"1"}});const m=`${L.blue(`[${o}]`)} Exporting HTML files`;let g=0;const y=setInterval((()=>{if(!process.env.CI){ne().clearLine(process.stdout,0);ne().cursorTo(process.stdout,0);process.stdout.write(m+".".repeat(g));g=(g+1)%5}}),500);if(process.env.CI){process.stdout.write(m+".\n")}(u=d.stderr)===null||u===void 0?void 0:u.on("data",(t=>{if(!String(t).startsWith("warn")){console.log(`${L.red(`[${o}]`)} `+t)}}));d.on("close",(u=>{clearInterval(y);if(u!==0){process.stdout.write("\n");l({command:`${c} ${h.join(" ")}`});return}else{ne().clearLine(process.stdout,0);ne().cursorTo(process.stdout,0);const u=Q().join(t,".hyperbook","out");if(!a){process.stdout.write(`${L.green(`[${o}]`)} Export successful. Files written to ${u}.\n`);r()}else{const t=Q().join(a,".hyperbook","out",i||"");makeDir(t).then((()=>{X().cpSync(u,t,{recursive:true,force:true});process.stdout.write(`${L.green(`[${o}]`)} Export successful. Files written to ${t}.\n`);r()})).catch((t=>{process.stdout.write("\n");console.error(t);l()}))}}}))}))}async function runDev(){const t=process.cwd();const r=isSetup(t);if(!r){throw new Error("no setup")}return new Promise(((r,i)=>{const o="npm";const a=["run","next:dev"];const l=makeEnv();const u=re()(o,a,{stdio:"inherit",cwd:Q().join(t,".hyperbook"),env:{...process.env,...l,ADBLOCK:"1",DISABLE_OPENCOLLECTIVE:"1"}});u.on("close",(t=>{if(t!==0){i({command:`${o} ${a.join(" ")}`});return}r()}))}))}var ue=i(2081);function getPkgManager(){try{const t=process.env.npm_config_user_agent;if(t){if(t.startsWith("yarn")){return"yarn"}else if(t.startsWith("pnpm")){return"pnpm"}}try{(0,ue.execSync)("yarn --version",{stdio:"ignore"});return"yarn"}catch{(0,ue.execSync)("pnpm --version",{stdio:"ignore"});return"pnpm"}}catch{return"npm"}}var ce=i(2037);var fe=i.n(ce);const he=require("node:events");const pe=require("node:path");function indentString(t,r=1,i={}){const{indent:o=" ",includeEmptyLines:a=false}=i;if(typeof t!=="string"){throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof t}\``)}if(typeof r!=="number"){throw new TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof r}\``)}if(r<0){throw new RangeError(`Expected \`count\` to be at least 0, got \`${r}\``)}if(typeof o!=="string"){throw new TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof o}\``)}if(r===0){return t}const l=a?/^/gm:/^(?!\s*$)/gm;return t.replace(l,o.repeat(r))}function escapeStringRegexp(t){if(typeof t!=="string"){throw new TypeError("Expected a string")}return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}const de=/\s+at.*[(\s](.*)\)?/;const me=/^(?:(?:(?:node|node:[\w/]+|(?:(?:node:)?internal\/[\w/]*|.*node_modules\/(?:babel-polyfill|pirates)\/.*)?\w+)(?:\.js)?:\d+:\d+)|native)/;const ge=typeof ce.homedir==="undefined"?"":ce.homedir().replace(/\\/g,"/");function cleanStack(t,{pretty:r=false,basePath:i}={}){const o=i&&new RegExp(`(at | \\()${escapeStringRegexp(i.replace(/\\/g,"/"))}`,"g");if(typeof t!=="string"){return undefined}return t.replace(/\\/g,"/").split("\n").filter((t=>{const r=t.match(de);if(r===null||!r[1]){return true}const i=r[1];if(i.includes(".app/Contents/Resources/electron.asar")||i.includes(".app/Contents/Resources/default_app.asar")){return false}return!me.test(i)})).filter((t=>t.trim()!=="")).map((t=>{if(o){t=t.replace(o,"$1")}if(r){t=t.replace(de,((t,r)=>t.replace(r,r.replace(ge,"~"))))}return t})).join("\n")}const cleanInternalStack=t=>t.replace(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g,"");class AggregateError extends Error{#e;name="AggregateError";constructor(t){if(!Array.isArray(t)){throw new TypeError(`Expected input to be an Array, got ${typeof t}`)}t=t.map((t=>{if(t instanceof Error){return t}if(t!==null&&typeof t==="object"){return Object.assign(new Error(t.message),t)}return new Error(t)}));let r=t.map((t=>typeof t.stack==="string"?cleanInternalStack(cleanStack(t.stack)):String(t))).join("\n");r="\n"+indentString(r,4);super(r);this.#e=t}get errors(){return this.#e.slice()}}async function pMap(t,r,{concurrency:i=Number.POSITIVE_INFINITY,stopOnError:o=true}={}){return new Promise(((a,l)=>{if(t[Symbol.iterator]===undefined&&t[Symbol.asyncIterator]===undefined){throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof t})`)}if(typeof r!=="function"){throw new TypeError("Mapper function is required")}if(!((Number.isSafeInteger(i)||i===Number.POSITIVE_INFINITY)&&i>=1)){throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${i}\` (${typeof i})`)}const u=[];const c=[];const h=new Map;let p=false;let d=false;let m=false;let g=0;let y=0;const v=t[Symbol.iterator]===undefined?t[Symbol.asyncIterator]():t[Symbol.iterator]();const reject=t=>{p=true;d=true;l(t)};const next=async()=>{if(d){return}const t=await v.next();const i=y;y++;if(t.done){m=true;if(g===0&&!d){if(!o&&c.length>0){reject(new AggregateError(c));return}d=true;if(!h.size){a(u);return}const t=[];for(const[r,i]of u.entries()){if(h.get(r)===ye){continue}t.push(i)}a(t)}return}g++;(async()=>{try{const o=await t.value;if(d){return}const a=await r(o,i);if(a===ye){h.set(i,a)}u[i]=a;g--;await next()}catch(t){if(o){reject(t)}else{c.push(t);g--;try{await next()}catch(t){reject(t)}}}})()};(async()=>{for(let t=0;t<i;t++){try{await next()}catch(t){reject(t);break}if(m||p){break}}})()}))}const ye=Symbol("skip");function arrify(t){if(t===null||t===undefined){return[]}if(Array.isArray(t)){return t}if(typeof t==="string"){return[t]}if(typeof t[Symbol.iterator]==="function"){return[...t]}return[t]}var ve=i(8174);class AbortError extends Error{constructor(t){super();this.name="AbortError";this.message=t}}const getDOMException=t=>globalThis.DOMException===undefined?new AbortError(t):new DOMException(t);const getAbortedReason=t=>{const r=t.reason===undefined?getDOMException("This operation was aborted."):t.reason;return r instanceof Error?r:getDOMException(r)};async function p_map_pMap(t,r,{concurrency:i=Number.POSITIVE_INFINITY,stopOnError:o=true,signal:a}={}){return new Promise(((l,u)=>{if(t[Symbol.iterator]===undefined&&t[Symbol.asyncIterator]===undefined){throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof t})`)}if(typeof r!=="function"){throw new TypeError("Mapper function is required")}if(!((Number.isSafeInteger(i)||i===Number.POSITIVE_INFINITY)&&i>=1)){throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${i}\` (${typeof i})`)}const c=[];const h=[];const p=new Map;let d=false;let m=false;let g=false;let y=0;let v=0;const b=t[Symbol.iterator]===undefined?t[Symbol.asyncIterator]():t[Symbol.iterator]();const reject=t=>{d=true;m=true;u(t)};if(a){if(a.aborted){reject(getAbortedReason(a))}a.addEventListener("abort",(()=>{reject(getAbortedReason(a))}))}const next=async()=>{if(m){return}const t=await b.next();const i=v;v++;if(t.done){g=true;if(y===0&&!m){if(!o&&h.length>0){reject(new AggregateError(h));return}m=true;if(p.size===0){l(c);return}const t=[];for(const[r,i]of c.entries()){if(p.get(r)===be){continue}t.push(i)}l(t)}return}y++;(async()=>{try{const o=await t.value;if(m){return}const a=await r(o,i);if(a===be){p.set(i,a)}c[i]=a;y--;await next()}catch(t){if(o){reject(t)}else{h.push(t);y--;try{await next()}catch(t){reject(t)}}}})()};(async()=>{for(let t=0;t<i;t++){try{await next()}catch(t){reject(t);break}if(g||d){break}}})()}))}const be=Symbol("skip");async function pFilter(t,r,i){const o=await p_map_pMap(t,((t,i)=>Promise.all([r(t,i),t])),i);return o.filter((t=>Boolean(t[0]))).map((t=>t[1]))}const _e=require("node:fs");var we=i(9117);var Se=i(5342);var Ee=i(3286);var xe=i(7993);function slash(t){const r=/^\\\\\?\\/.test(t);const i=/[^\u0000-\u0080]+/.test(t);if(r||i){return t}return t.replace(/\\/g,"/")}const Oe=require("node:url");const Ae=require("node:stream");const toPath=t=>t instanceof URL?(0,Oe.fileURLToPath)(t):t;class FilterStream extends Ae.Transform{constructor(t){super({objectMode:true,transform(r,i,o){o(undefined,t(r)?r:undefined)}})}}const isNegativePattern=t=>t[0]==="!";const ke={ignore:["**/node_modules","**/flow-typed","**/coverage","**/.git"],absolute:true,dot:true};const Re="**/.gitignore";const applyBaseToPattern=(t,r)=>isNegativePattern(t)?"!"+pe.posix.join(r,t.slice(1)):pe.posix.join(r,t);const parseIgnoreFile=(t,r)=>{const i=slash(pe.relative(r,pe.dirname(t.filePath)));return t.content.split(/\r?\n/).filter((t=>t&&!t.startsWith("#"))).map((t=>applyBaseToPattern(t,i)))};const toRelativePath=(t,r)=>{r=slash(r);if(pe.isAbsolute(t)){if(slash(t).startsWith(r)){return pe.relative(r,t)}throw new Error(`Path ${t} is not in cwd ${r}`)}return t};const getIsIgnoredPredicate=(t,r)=>{const i=t.flatMap((t=>parseIgnoreFile(t,r)));const o=xe().add(i);return t=>{t=toPath(t);t=toRelativePath(t,r);return o.ignores(slash(t))}};const normalizeOptions=(t={})=>({cwd:toPath(t.cwd)||m.cwd()});const isIgnoredByIgnoreFiles=async(t,r)=>{const{cwd:i}=normalizeOptions(r);const o=await Se(t,{cwd:i,...ke});const a=await Promise.all(o.map((async t=>({filePath:t,content:await _e.promises.readFile(t,"utf8")}))));return getIsIgnoredPredicate(a,i)};const isIgnoredByIgnoreFilesSync=(t,r)=>{const{cwd:i}=normalizeOptions(r);const o=Se.sync(t,{cwd:i,...ke});const a=o.map((t=>({filePath:t,content:_e.readFileSync(t,"utf8")})));return getIsIgnoredPredicate(a,i)};const isGitIgnored=t=>isIgnoredByIgnoreFiles(Re,t);const isGitIgnoredSync=t=>isIgnoredByIgnoreFilesSync(Re,t);const assertPatternsInput=t=>{if(t.some((t=>typeof t!=="string"))){throw new TypeError("Patterns must be a string or an array of strings")}};const toPatternsArray=t=>{t=[...new Set([t].flat())];assertPatternsInput(t);return t};const checkCwdOption=t=>{if(!t.cwd){return}let r;try{r=_e.statSync(t.cwd)}catch{return}if(!r.isDirectory()){throw new Error("The `cwd` option must be a path to a directory")}};const globby_normalizeOptions=(t={})=>{t={ignore:[],expandDirectories:true,...t,cwd:toPath(t.cwd)};checkCwdOption(t);return t};const normalizeArguments=t=>async(r,i)=>t(toPatternsArray(r),globby_normalizeOptions(i));const normalizeArgumentsSync=t=>(r,i)=>t(toPatternsArray(r),globby_normalizeOptions(i));const getIgnoreFilesPatterns=t=>{const{ignoreFiles:r,gitignore:i}=t;const o=r?toPatternsArray(r):[];if(i){o.push(Re)}return o};const getFilter=async t=>{const r=getIgnoreFilesPatterns(t);return createFilterFunction(r.length>0&&await isIgnoredByIgnoreFiles(r,{cwd:t.cwd}))};const getFilterSync=t=>{const r=getIgnoreFilesPatterns(t);return createFilterFunction(r.length>0&&isIgnoredByIgnoreFilesSync(r,{cwd:t.cwd}))};const createFilterFunction=t=>{const r=new Set;return i=>{const o=i.path||i;const a=pe.normalize(o);const l=r.has(a)||t&&t(o);r.add(a);return!l}};const unionFastGlobResults=(t,r)=>t.flat().filter((t=>r(t)));const unionFastGlobStreams=(t,r)=>we(t).pipe(new FilterStream((t=>r(t))));const convertNegativePatterns=(t,r)=>{const i=[];while(t.length>0){const o=t.findIndex((t=>isNegativePattern(t)));if(o===-1){i.push({patterns:t,options:r});break}const a=t[o].slice(1);for(const t of i){t.options.ignore.push(a)}if(o!==0){i.push({patterns:t.slice(0,o),options:{...r,ignore:[...r.ignore,a]}})}t=t.slice(o+1)}return i};const getDirGlobOptions=(t,r)=>({...r?{cwd:r}:{},...Array.isArray(t)?{files:t}:t});const generateTasks=async(t,r)=>{const i=convertNegativePatterns(t,r);const{cwd:o,expandDirectories:a}=r;if(!a){return i}const l=getDirGlobOptions(a,o);const u=o?{cwd:o}:undefined;return Promise.all(i.map((async t=>{let{patterns:r,options:i}=t;[r,i.ignore]=await Promise.all([Ee(r,l),Ee(i.ignore,u)]);return{patterns:r,options:i}})))};const generateTasksSync=(t,r)=>{const i=convertNegativePatterns(t,r);const{cwd:o,expandDirectories:a}=r;if(!a){return i}const l=getDirGlobOptions(a,o);const u=o?{cwd:o}:undefined;return i.map((t=>{let{patterns:r,options:i}=t;r=Ee.sync(r,l);i.ignore=Ee.sync(i.ignore,u);return{patterns:r,options:i}}))};const Te=normalizeArguments((async(t,r)=>{const[i,o]=await Promise.all([generateTasks(t,r),getFilter(r)]);const a=await Promise.all(i.map((t=>Se(t.patterns,t.options))));return unionFastGlobResults(a,o)}));const Ce=normalizeArgumentsSync(((t,r)=>{const i=generateTasksSync(t,r);const o=getFilterSync(r);const a=i.map((t=>Se.sync(t.patterns,t.options)));return unionFastGlobResults(a,o)}));const Pe=normalizeArgumentsSync(((t,r)=>{const i=generateTasksSync(t,r);const o=getFilterSync(r);const a=i.map((t=>Se.stream(t.patterns,t.options)));return unionFastGlobStreams(a,o)}));const Ie=normalizeArgumentsSync(((t,r)=>t.some((t=>Se.isDynamicPattern(t,r)))));const Le=normalizeArguments(generateTasks);const Me=normalizeArgumentsSync(generateTasksSync);var De=i(7971);var Ne=i(3134);class CpyError extends Ne{constructor(t,r){super(t,r);Object.assign(this,r);this.name="CpyError"}}const je=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^Desktop\\.ini$","@eaDir$"];const Fe=new RegExp(je.join("|"));function isJunk(t){return Fe.test(t)}function isNotJunk(t){return!isJunk(t)}class GlobPattern{constructor(t,r,i){this.path=t;this.originalPath=t;this.destination=r;this.options=i;this.isDirectory=false;if(!Ie(t)&&_e.existsSync(t)&&_e.lstatSync(t).isDirectory()){this.path=[t,"**"].join("/");this.isDirectory=true}}get name(){return pe.basename(this.originalPath)}get normalizedPath(){const t=this.originalPath.split("/");const r=t.findIndex((t=>t?Ie(t):false));const i=t.slice(0,r).join("/");if(i){return pe.isAbsolute(i)?i:pe.join(this.options.cwd,i)}return this.destination}hasMagic(){return Ie(this.options.flat?this.path:this.originalPath)}getMatches(){let t=Ce(this.path,{...this.options,dot:true,absolute:true,onlyFiles:true});if(this.options.ignoreJunk){t=t.filter((t=>isNotJunk(pe.basename(t))))}return t}}const $e=(g.cpus().length||1)*2;const Be={ignoreJunk:true,flat:false,cwd:m.cwd()};class Entry{constructor(t,r,i){this.path=t.split("/").join(pe.sep);this.relativePath=r.split("/").join(pe.sep);this.pattern=i;Object.freeze(this)}get name(){return pe.basename(this.path)}get nameWithoutExtension(){return pe.basename(this.path,pe.extname(this.path))}get extension(){return pe.extname(this.path).slice(1)}}const expandPatternsWithBraceExpansion=t=>t.flatMap((t=>De.braces(t,{expand:true,nodupes:true})));const preprocessDestinationPath=({entry:t,destination:r,options:i})=>{if(t.pattern.hasMagic()){if(i.flat){if(pe.isAbsolute(r)){return pe.join(r,t.name)}return pe.join(i.cwd,r,t.name)}return pe.join(r,pe.relative(t.pattern.normalizedPath,t.path))}if(pe.isAbsolute(r)){return pe.join(r,t.name)}if(t.pattern.isDirectory&&pe.relative(i.cwd,t.path).startsWith("..")){return pe.join(i.cwd,r,pe.basename(t.pattern.originalPath),pe.relative(t.pattern.originalPath,t.path))}if(!t.pattern.isDirectory&&t.path===t.relativePath){return pe.join(i.cwd,r,pe.basename(t.pattern.originalPath),pe.relative(t.pattern.originalPath,t.path))}if(!t.pattern.isDirectory&&i.flat){return pe.join(i.cwd,r,pe.basename(t.pattern.originalPath))}return pe.join(i.cwd,r,pe.relative(i.cwd,t.path))};const renameFile=(t,r)=>{const i=pe.basename(t,pe.extname(t));const o=pe.extname(t);const a=pe.dirname(t);if(typeof r==="string"){return pe.join(a,r)}if(typeof r==="function"){return pe.join(a,`${r(i)}${o}`)}return t};function cpy(t,r,{concurrency:i=$e,...o}={}){const a=new Map;const l=new he;o={...Be,...o};const u=(async()=>{let u=[];let c=0;let h=0;let p=expandPatternsWithBraceExpansion(arrify(t)).map((t=>t.replace(/\\/g,"/")));const d=p.filter((t=>!t.startsWith("!")));const m=p.filter((t=>t.startsWith("!")));if(d.length===0||!r){throw new CpyError("`source` and `destination` required")}p=p.map((t=>new GlobPattern(t,r,{...o,ignore:m})));for(const t of p){let r=[];try{r=t.getMatches()}catch(r){throw new CpyError(`Cannot glob \`${t.originalPath}\`: ${r.message}`,r)}if(r.length===0&&!Ie(t.originalPath)&&!Ie(m)){throw new CpyError(`Cannot copy \`${t.originalPath}\`: the file doesn't exist`)}u=[...u,...r.map((r=>new Entry(r,pe.relative(o.cwd,r),t)))]}if(o.filter!==undefined){u=await pFilter(u,o.filter,{concurrency:1024})}if(u.length===0){l.emit("progress",{totalFiles:0,percent:1,completedFiles:0,completedSize:0})}const fileProgressHandler=t=>{const r=a.get(t.sourcePath)||{writtenBytes:0,percent:0};if(r.writtenBytes!==t.writtenBytes||r.percent!==t.percent){h-=r.writtenBytes;h+=t.writtenBytes;if(t.percent===1&&r.percent!==1){c++}a.set(t.sourcePath,{writtenBytes:t.writtenBytes,percent:t.percent});l.emit("progress",{totalFiles:u.length,percent:c/u.length,completedFiles:c,completedSize:h})}};return pMap(u,(async t=>{const i=renameFile(preprocessDestinationPath({entry:t,destination:r,options:o}),o.rename);try{await ve(t.path,i,o).on("progress",fileProgressHandler)}catch(r){throw new CpyError(`Cannot copy from \`${t.relativePath}\` to \`${i}\`: ${r.message}`,r)}return i}),{concurrency:i})})();u.on=(...t)=>{l.on(...t);return u};return u}var He=i(5713);var Ge=i.n(He);function isFolderEmpty(t,r){const i=[".DS_Store",".git",".gitattributes",".gitignore",".gitlab-ci.yml",".hg",".hgcheck",".hgignore",".idea",".npmignore",".travis.yml","LICENSE","Thumbs.db","docs","mkdocs.yml","npm-debug.log","yarn-debug.log","yarn-error.log"];const o=X().readdirSync(t).filter((t=>!i.includes(t))).filter((t=>!/\.iml$/.test(t)));if(o.length>0){console.log(`The directory ${L.green(r)} contains files that could conflict:`);console.log();for(const r of o){try{const i=X().lstatSync(Q().join(t,r));if(i.isDirectory()){console.log(` ${L.blue(r)}/`)}else{console.log(` ${r}`)}}catch{console.log(` ${r}`)}}console.log();console.log("Either try using a new directory name, or remove the files listed above.");console.log();return false}return true}async function isWriteable(t){try{await X().promises.access(t,(X().constants||X()).W_OK);return true}catch(t){return false}}function isInGitRepository(){try{(0,ue.execSync)("git rev-parse --is-inside-work-tree",{stdio:"ignore"});return true}catch(t){}return false}function isInMercurialRepository(){try{(0,ue.execSync)("hg --cwd . root",{stdio:"ignore"});return true}catch(t){}return false}function tryGitInit(t){let r=false;try{(0,ue.execSync)("git --version",{stdio:"ignore"});if(isInGitRepository()||isInMercurialRepository()){return false}(0,ue.execSync)("git init",{stdio:"ignore"});r=true;(0,ue.execSync)("git checkout -b main",{stdio:"ignore"});(0,ue.execSync)("git add -A",{stdio:"ignore"});(0,ue.execSync)('git commit -m "Initial commit from Hyperbook"',{stdio:"ignore"});return true}catch(i){if(r){try{le().sync(Q().join(t,".git"))}catch(t){}}return false}}function install(t,r,{packageManager:i,isOnline:o,devDependencies:a}){const l=[];const u=[];return new Promise(((c,h)=>{let p;let d=i;const m=i==="yarn";if(r&&r.length){if(m){p=["add","--exact"];if(!o)p.push("--offline");p.push("--cwd",t);if(a)p.push("--dev");p.push(...r)}else{p=["install","--save-exact"];p.push(a?"--save-dev":"--save");p.push(...r)}}else{p=["install"];if(!o){console.log(L.yellow("You appear to be offline."));if(m){console.log(L.yellow("Falling back to the local Yarn cache."));console.log();p.push("--offline")}else{console.log()}}}if(m){p.push(...u)}else{p.push(...l)}const g=re()(d,p,{stdio:"inherit",cwd:t,env:{...process.env,ADBLOCK:"1",DISABLE_OPENCOLLECTIVE:"1"}});g.on("close",(t=>{if(t!==0){h({command:`${d} ${p.join(" ")}`});return}c()}))}))}const We=require("dns");var Ue=i.n(We);var Ve=i(7310);var qe=i.n(Ve);function getProxy(){if(process.env.https_proxy){return process.env.https_proxy}try{const t=(0,ue.execSync)("npm config get https-proxy").toString().trim();return t!=="null"?t:undefined}catch(t){return}}function getOnline(){return new Promise((t=>{Ue().lookup("registry.yarnpkg.com",(r=>{if(!r){return t(true)}const i=getProxy();if(!i){return t(false)}const{hostname:o}=qe().parse(i);if(!o){return t(false)}Ue().lookup(o,(r=>{t(r==null)}))}))}))}async function makeSymlink(t,r){const i=fe().platform()=="win32"?"junction":null;return new Promise(((o,a)=>{X().symlink(t,r,i,(t=>{if(t){a()}else{o()}}))}))}async function runSetupProject(t,r){const o=getProjectName(t);console.log(`${L.blue(`[${o}]`)} Setup Project.`);const a=Q().join(t.src,".hyperbook");const l=Q().join((r===null||r===void 0?void 0:r.src)||"",".hyperbook");le().sync(a);await makeDir(a);const u=i.ab+"templates";await cpy("default/.hyperbook/**",a,{cwd:i.ab+"templates",followSymbolicLinks:false});if(process.env.HYPERBOOK_LOCAL_DEV){const t=await oe().readFile(Q().join(__dirname,"..","..","..","templates","simple","package.json")).then((t=>JSON.parse(t.toString())));await oe().writeFile(Q().join(a,"package.json"),JSON.stringify({...t,name:`@docs/`+o.toLowerCase().replace(" ","-"),scripts:{"next:dev":"next-hyperbook-watch","next:build":"next build && next export"}},null,2))}else{if(!r){const t=await getOnline();await install(l,null,{packageManager:"npm",isOnline:t})}else{await makeSymlink(Q().join(l,"node_modules"),Q().join(a,"node_modules"))}}if(t.type==="library"){await makeSymlink(Q().join(t.src,"hyperlibrary.json"),Q().join(a,"hyperlibrary.json"));for(const i of t.projects){await runSetupProject(i,r)}return}await makeSymlink(Q().join(t.src,"archives"),Q().join(a,"archives"));await makeSymlink(Q().join(t.src,"book"),Q().join(a,"book"));await makeSymlink(Q().join(t.src,"glossary"),Q().join(a,"glossary"));await makeSymlink(Q().join(t.src,"public"),Q().join(a,"public"));await makeSymlink(Q().join(t.src,"hyperbook.json"),Q().join(a,"hyperbook.json"))}async function runNew({programName:t,bookPath:r}){if(typeof r==="string"){r=r.trim()}if(!r){const t=await Ge()({type:"text",name:"path",message:"What is your book named?",initial:"my-book"});if(typeof t.path==="string"){r=t.path.trim()}}if(!r){console.log();console.log("Please specify the book directory:");console.log(` ${L.cyan(t)} ${L.green("<book-directory>")}`);console.log();console.log("For example:");console.log(` ${L.cyan(t)} ${L.green("my-new-book")}`);console.log();console.log(`Run ${L.cyan(`${t} --help`)} to see all options.`);process.exit(1)}const o=Q().resolve(r);if(!await isWriteable(Q().dirname(o))){console.error("The book path is not writable, please check folder permissions and try again.");console.error("It is likely you do not have write permissions for this folder.");process.exit(1)}const a=Q().basename(o);await makeDir(o);if(!isFolderEmpty(o,a)){process.exit(1)}const l=process.cwd();console.log(`Creating a new hyperbook in ${L.green(o)}.`);console.log();process.chdir(o);const{description:u}=await Ge()({type:"text",name:"description",message:"What is your book about?",initial:""});const{author:c}=await Ge()({type:"text",name:"author",message:"Who is the author of the book?",initial:""});const{authorUrl:h}=await Ge()({type:"text",name:"authorUrl",message:"What is the link to the authors homepage?",initial:""});let{license:p}=await Ge()({type:"select",name:"license",message:"Pick a license for your book!",choices:[{title:"Creative Commons Zero (CC0)",value:"cc0"},{title:"Creative Commons Attribution (CC BY)",value:"cc-by"},{title:"Creative Commons Attribution-ShareAlike (CC BY-SA)",value:"cc-by-sa"},{title:"Creative Commons Attribution-NoDerivs (CC BY-ND)",value:"cc-by-nd"},{title:"Creative Commons Attribution-NonCommercial (CC BY-NC)",value:"cc-by-nc"},{title:"Creative Commons Attribution-NonCommercial-ShareAlike (CC BY-NC-SA)",value:"cc-by-nc-sa"},{title:"Creative Commons Attribution-NonCommercial-NoDervis (CC BY-NC-ND)",value:"cc-by-nc-nd"},{title:"Custom",value:"custom"}]});if(p==="custom"){const t=await Ge()({type:"text",name:"license",message:"Which custom license you want to use?"});p=t.license}const{language:d}=await Ge()({type:"text",name:"language",message:"In which language is your book written? Provide a short code, e.g.: en or de",initial:"en"});const m={name:a,version:"0.0.0",description:u,license:p,author:{name:c,url:h},language:d};X().writeFileSync(Q().join(o,"hyperbook.json"),JSON.stringify(m,null,2)+fe().EOL);console.log();const g=i.ab+"templates";await cpy("default/**",o,{cwd:i.ab+"templates",rename:t=>{switch(t){case"gitignore":{return".".concat(t)}case"README-template.md":{return"README.md"}default:{return t}}}});await runSetupProject({type:"book",name:a,src:o});if(tryGitInit(o)){console.log("Initialized a git repository.");console.log()}let y;if(Q().join(l,a)===r){y=a}else{y=r}console.log(`${L.green("Success!")} Created ${a} at ${r}`);console.log("Inside that directory, you can run several commands:");console.log();console.log(L.cyan(` hyperbook dev`));console.log(" Starts the development server.");console.log();console.log(L.cyan(` hyperbook build`));console.log(" Builds the book for production.");console.log();console.log("We suggest that you begin by typing:");console.log();console.log(L.cyan(" cd"),y);console.log(` ${L.cyan(`hyperbook dev`)}`);console.log()}const ze=JSON.parse('{"name":"hyperbook","version":"0.6.1","author":"Mike Barkmin","homepage":"https://github.com/openpatch/hyperbook#readme","license":"MIT","bin":{"hyperbook":"./dist/index.js"},"files":["dist"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/openpatch/hyperbook.git","directory":"packages/hyperbook"},"bugs":{"url":"https://github.com/openpatch/hyperbook/issues"},"engines":{"node":">=12.22.0"},"scripts":{"version":"pnpm build","lint":"tsc --noEmit","dev":"ncc build ./index.ts -w -o dist/","build":"rimraf dist && ncc build ./index.ts -o ./dist/ --minify --no-cache --no-source-map-register && node ./postbuild.mjs"},"devDependencies":{"@pnpm/exportable-manifest":"4.0.1","@types/archiver":"5.3.1","@types/async-retry":"1.4.5","@types/cross-spawn":"6.0.2","@types/prompts":"2.4.1","@types/rimraf":"3.0.2","@types/tar":"6.1.3","@vercel/ncc":"0.34.0","archiver":"5.3.1","async-retry":"1.3.3","chalk":"5.1.2","commander":"9.4.1","cpy":"9.0.1","cross-spawn":"7.0.3","got":"12.5.2","hyperbook-simple-template":"workspace:*","prompts":"2.4.2","rimraf":"3.0.2","tar":"6.1.11","update-check":"1.5.4"},"dependencies":{"@hyperbook/types":"workspace:*"}}');const Ye=new W;Ye.name(ze.name).version(ze.version).hook("preAction",(async()=>{await notifyUpdate()}));Ye.command("new").description("create a new hyperbook").arguments("<book-directory>").usage(`${L.green("<book-directory>")}`).action((async t=>{await runNew({programName:Ye.name(),bookPath:t}).catch((()=>process.exit(1)))}));Ye.command("dev").description("start the development server for a hyperbook").action((async()=>{await runDev()}));Ye.command("setup").description("downloads the latest version of the template of a hyperbook").action((async()=>{const t=await collect(process.cwd()).catch((()=>{process.exit(1)}));await runSetupProject(t).catch((()=>{process.exit(1)}))}));Ye.command("build").description("build a hyperbook").action((async()=>{const t=await collect(process.cwd()).catch((()=>{process.exit(1)}));await runBuildProject(t,t).catch((()=>{process.exit(1)}))}));Ye.command("archive").description("create archives from archives folder").action((async()=>{await runArchive(process.cwd()).catch((()=>process.exit(1)))}));Ye.parseAsync(process.argv);const Ke=Y()(ze).catch((()=>null));async function notifyUpdate(){try{const t=await Ke;if(t===null||t===void 0?void 0:t.latest){const t=getPkgManager();console.log();console.log(L.yellow.bold("A new version of `hyperbook` is available!"));console.log("You can update by running: "+L.cyan(t==="yarn"?"yarn global add hyperbook":`${t} install --global hyperbook`));console.log()}process.exit()}catch{}}},9491:t=>{"use strict";t.exports=require("assert")},4300:t=>{"use strict";t.exports=require("buffer")},2081:t=>{"use strict";t.exports=require("child_process")},2057:t=>{"use strict";t.exports=require("constants")},2361:t=>{"use strict";t.exports=require("events")},7147:t=>{"use strict";t.exports=require("fs")},3685:t=>{"use strict";t.exports=require("http")},5687:t=>{"use strict";t.exports=require("https")},2037:t=>{"use strict";t.exports=require("os")},1017:t=>{"use strict";t.exports=require("path")},7282:t=>{"use strict";t.exports=require("process")},4521:t=>{"use strict";t.exports=require("readline")},2781:t=>{"use strict";t.exports=require("stream")},1576:t=>{"use strict";t.exports=require("string_decoder")},7310:t=>{"use strict";t.exports=require("url")},3837:t=>{"use strict";t.exports=require("util")},9796:t=>{"use strict";t.exports=require("zlib")},345:(t,r,i)=>{const{Argument:o}=i(4079);const{Command:a}=i(6505);const{CommanderError:l,InvalidArgumentError:u}=i(9027);const{Help:c}=i(9164);const{Option:h}=i(5205);r=t.exports=new a;r.program=r;r.Argument=o;r.Command=a;r.CommanderError=l;r.Help=c;r.InvalidArgumentError=u;r.InvalidOptionArgumentError=u;r.Option=h},4079:(t,r,i)=>{const{InvalidArgumentError:o}=i(9027);class Argument{constructor(t,r){this.description=r||"";this.variadic=false;this.parseArg=undefined;this.defaultValue=undefined;this.defaultValueDescription=undefined;this.argChoices=undefined;switch(t[0]){case"<":this.required=true;this._name=t.slice(1,-1);break;case"[":this.required=false;this._name=t.slice(1,-1);break;default:this.required=true;this._name=t;break}if(this._name.length>3&&this._name.slice(-3)==="..."){this.variadic=true;this._name=this._name.slice(0,-3)}}name(){return this._name}_concatValue(t,r){if(r===this.defaultValue||!Array.isArray(r)){return[t]}return r.concat(t)}default(t,r){this.defaultValue=t;this.defaultValueDescription=r;return this}argParser(t){this.parseArg=t;return this}choices(t){this.argChoices=t.slice();this.parseArg=(t,r)=>{if(!this.argChoices.includes(t)){throw new o(`Allowed choices are ${this.argChoices.join(", ")}.`)}if(this.variadic){return this._concatValue(t,r)}return t};return this}argRequired(){this.required=true;return this}argOptional(){this.required=false;return this}}function humanReadableArgName(t){const r=t.name()+(t.variadic===true?"...":"");return t.required?"<"+r+">":"["+r+"]"}r.Argument=Argument;r.humanReadableArgName=humanReadableArgName},6505:(t,r,i)=>{const o=i(2361).EventEmitter;const a=i(2081);const l=i(1017);const u=i(7147);const c=i(7282);const{Argument:h,humanReadableArgName:p}=i(4079);const{CommanderError:d}=i(9027);const{Help:m}=i(9164);const{Option:g,splitOptionFlags:y,DualOptions:v}=i(5205);const{suggestSimilar:b}=i(211);class Command extends o{constructor(t){super();this.commands=[];this.options=[];this.parent=null;this._allowUnknownOption=false;this._allowExcessArguments=true;this._args=[];this.args=[];this.rawArgs=[];this.processedArgs=[];this._scriptPath=null;this._name=t||"";this._optionValues={};this._optionValueSources={};this._storeOptionsAsProperties=false;this._actionHandler=null;this._executableHandler=false;this._executableFile=null;this._executableDir=null;this._defaultCommandName=null;this._exitCallback=null;this._aliases=[];this._combineFlagAndOptionalValue=true;this._description="";this._summary="";this._argsDescription=undefined;this._enablePositionalOptions=false;this._passThroughOptions=false;this._lifeCycleHooks={};this._showHelpAfterError=false;this._showSuggestionAfterError=true;this._outputConfiguration={writeOut:t=>c.stdout.write(t),writeErr:t=>c.stderr.write(t),getOutHelpWidth:()=>c.stdout.isTTY?c.stdout.columns:undefined,getErrHelpWidth:()=>c.stderr.isTTY?c.stderr.columns:undefined,outputError:(t,r)=>r(t)};this._hidden=false;this._hasHelpOption=true;this._helpFlags="-h, --help";this._helpDescription="display help for command";this._helpShortFlag="-h";this._helpLongFlag="--help";this._addImplicitHelpCommand=undefined;this._helpCommandName="help";this._helpCommandnameAndArgs="help [command]";this._helpCommandDescription="display help for command";this._helpConfiguration={}}copyInheritedSettings(t){this._outputConfiguration=t._outputConfiguration;this._hasHelpOption=t._hasHelpOption;this._helpFlags=t._helpFlags;this._helpDescription=t._helpDescription;this._helpShortFlag=t._helpShortFlag;this._helpLongFlag=t._helpLongFlag;this._helpCommandName=t._helpCommandName;this._helpCommandnameAndArgs=t._helpCommandnameAndArgs;this._helpCommandDescription=t._helpCommandDescription;this._helpConfiguration=t._helpConfiguration;this._exitCallback=t._exitCallback;this._storeOptionsAsProperties=t._storeOptionsAsProperties;this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue;this._allowExcessArguments=t._allowExcessArguments;this._enablePositionalOptions=t._enablePositionalOptions;this._showHelpAfterError=t._showHelpAfterError;this._showSuggestionAfterError=t._showSuggestionAfterError;return this}command(t,r,i){let o=r;let a=i;if(typeof o==="object"&&o!==null){a=o;o=null}a=a||{};const[,l,u]=t.match(/([^ ]+) *(.*)/);const c=this.createCommand(l);if(o){c.description(o);c._executableHandler=true}if(a.isDefault)this._defaultCommandName=c._name;c._hidden=!!(a.noHelp||a.hidden);c._executableFile=a.executableFile||null;if(u)c.arguments(u);this.commands.push(c);c.parent=this;c.copyInheritedSettings(this);if(o)return this;return c}createCommand(t){return new Command(t)}createHelp(){return Object.assign(new m,this.configureHelp())}configureHelp(t){if(t===undefined)return this._helpConfiguration;this._helpConfiguration=t;return this}configureOutput(t){if(t===undefined)return this._outputConfiguration;Object.assign(this._outputConfiguration,t);return this}showHelpAfterError(t=true){if(typeof t!=="string")t=!!t;this._showHelpAfterError=t;return this}showSuggestionAfterError(t=true){this._showSuggestionAfterError=!!t;return this}addCommand(t,r){if(!t._name){throw new Error(`Command passed to .addCommand() must have a name\n- specify the name in Command constructor or using .name()`)}r=r||{};if(r.isDefault)this._defaultCommandName=t._name;if(r.noHelp||r.hidden)t._hidden=true;this.commands.push(t);t.parent=this;return this}createArgument(t,r){return new h(t,r)}argument(t,r,i,o){const a=this.createArgument(t,r);if(typeof i==="function"){a.default(o).argParser(i)}else{a.default(i)}this.addArgument(a);return this}arguments(t){t.split(/ +/).forEach((t=>{this.argument(t)}));return this}addArgument(t){const r=this._args.slice(-1)[0];if(r&&r.variadic){throw new Error(`only the last argument can be variadic '${r.name()}'`)}if(t.required&&t.defaultValue!==undefined&&t.parseArg===undefined){throw new Error(`a default value for a required argument is never used: '${t.name()}'`)}this._args.push(t);return this}addHelpCommand(t,r){if(t===false){this._addImplicitHelpCommand=false}else{this._addImplicitHelpCommand=true;if(typeof t==="string"){this._helpCommandName=t.split(" ")[0];this._helpCommandnameAndArgs=t}this._helpCommandDescription=r||this._helpCommandDescription}return this}_hasImplicitHelpCommand(){if(this._addImplicitHelpCommand===undefined){return this.commands.length&&!this._actionHandler&&!this._findCommand("help")}return this._addImplicitHelpCommand}hook(t,r){const i=["preSubcommand","preAction","postAction"];if(!i.includes(t)){throw new Error(`Unexpected value for event passed to hook : '${t}'.\nExpecting one of '${i.join("', '")}'`)}if(this._lifeCycleHooks[t]){this._lifeCycleHooks[t].push(r)}else{this._lifeCycleHooks[t]=[r]}return this}exitOverride(t){if(t){this._exitCallback=t}else{this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync"){throw t}else{}}}return this}_exit(t,r,i){if(this._exitCallback){this._exitCallback(new d(t,r,i))}c.exit(t)}action(t){const listener=r=>{const i=this._args.length;const o=r.slice(0,i);if(this._storeOptionsAsProperties){o[i]=this}else{o[i]=this.opts()}o.push(this);return t.apply(this,o)};this._actionHandler=listener;return this}createOption(t,r){return new g(t,r)}addOption(t){const r=t.name();const i=t.attributeName();if(t.negate){const r=t.long.replace(/^--no-/,"--");if(!this._findOption(r)){this.setOptionValueWithSource(i,t.defaultValue===undefined?true:t.defaultValue,"default")}}else if(t.defaultValue!==undefined){this.setOptionValueWithSource(i,t.defaultValue,"default")}this.options.push(t);const handleOptionValue=(r,o,a)=>{if(r==null&&t.presetArg!==undefined){r=t.presetArg}const l=this.getOptionValue(i);if(r!==null&&t.parseArg){try{r=t.parseArg(r,l)}catch(t){if(t.code==="commander.invalidArgument"){const r=`${o} ${t.message}`;this.error(r,{exitCode:t.exitCode,code:t.code})}throw t}}else if(r!==null&&t.variadic){r=t._concatValue(r,l)}if(r==null){if(t.negate){r=false}else if(t.isBoolean()||t.optional){r=true}else{r=""}}this.setOptionValueWithSource(i,r,a)};this.on("option:"+r,(r=>{const i=`error: option '${t.flags}' argument '${r}' is invalid.`;handleOptionValue(r,i,"cli")}));if(t.envVar){this.on("optionEnv:"+r,(r=>{const i=`error: option '${t.flags}' value '${r}' from env '${t.envVar}' is invalid.`;handleOptionValue(r,i,"env")}))}return this}_optionEx(t,r,i,o,a){if(typeof r==="object"&&r instanceof g){throw new Error("To add an Option object use addOption() instead of option() or requiredOption()")}const l=this.createOption(r,i);l.makeOptionMandatory(!!t.mandatory);if(typeof o==="function"){l.default(a).argParser(o)}else if(o instanceof RegExp){const t=o;o=(r,i)=>{const o=t.exec(r);return o?o[0]:i};l.default(a).argParser(o)}else{l.default(o)}return this.addOption(l)}option(t,r,i,o){return this._optionEx({},t,r,i,o)}requiredOption(t,r,i,o){return this._optionEx({mandatory:true},t,r,i,o)}combineFlagAndOptionalValue(t=true){this._combineFlagAndOptionalValue=!!t;return this}allowUnknownOption(t=true){this._allowUnknownOption=!!t;return this}allowExcessArguments(t=true){this._allowExcessArguments=!!t;return this}enablePositionalOptions(t=true){this._enablePositionalOptions=!!t;return this}passThroughOptions(t=true){this._passThroughOptions=!!t;if(!!this.parent&&t&&!this.parent._enablePositionalOptions){throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)")}return this}storeOptionsAsProperties(t=true){this._storeOptionsAsProperties=!!t;if(this.options.length){throw new Error("call .storeOptionsAsProperties() before adding options")}return this}getOptionValue(t){if(this._storeOptionsAsProperties){return this[t]}return this._optionValues[t]}setOptionValue(t,r){return this.setOptionValueWithSource(t,r,undefined)}setOptionValueWithSource(t,r,i){if(this._storeOptionsAsProperties){this[t]=r}else{this._optionValues[t]=r}this._optionValueSources[t]=i;return this}getOptionValueSource(t){return this._optionValueSources[t]}_prepareUserArgs(t,r){if(t!==undefined&&!Array.isArray(t)){throw new Error("first parameter to parse must be array or undefined")}r=r||{};if(t===undefined){t=c.argv;if(c.versions&&c.versions.electron){r.from="electron"}}this.rawArgs=t.slice();let i;switch(r.from){case undefined:case"node":this._scriptPath=t[1];i=t.slice(2);break;case"electron":if(c.defaultApp){this._scriptPath=t[1];i=t.slice(2)}else{i=t.slice(1)}break;case"user":i=t.slice(0);break;default:throw new Error(`unexpected parse option { from: '${r.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);this._name=this._name||"program";return i}parse(t,r){const i=this._prepareUserArgs(t,r);this._parseCommand([],i);return this}async parseAsync(t,r){const i=this._prepareUserArgs(t,r);await this._parseCommand([],i);return this}_executeSubCommand(t,r){r=r.slice();let i=false;const o=[".js",".ts",".tsx",".mjs",".cjs"];function findFile(t,r){const i=l.resolve(t,r);if(u.existsSync(i))return i;if(o.includes(l.extname(r)))return undefined;const a=o.find((t=>u.existsSync(`${i}${t}`)));if(a)return`${i}${a}`;return undefined}this._checkForMissingMandatoryOptions();this._checkForConflictingOptions();let h=t._executableFile||`${this._name}-${t._name}`;let p=this._executableDir||"";if(this._scriptPath){let t;try{t=u.realpathSync(this._scriptPath)}catch(r){t=this._scriptPath}p=l.resolve(l.dirname(t),p)}if(p){let r=findFile(p,h);if(!r&&!t._executableFile&&this._scriptPath){const i=l.basename(this._scriptPath,l.extname(this._scriptPath));if(i!==this._name){r=findFile(p,`${i}-${t._name}`)}}h=r||h}i=o.includes(l.extname(h));let m;if(c.platform!=="win32"){if(i){r.unshift(h);r=incrementNodeInspectorPort(c.execArgv).concat(r);m=a.spawn(c.argv[0],r,{stdio:"inherit"})}else{m=a.spawn(h,r,{stdio:"inherit"})}}else{r.unshift(h);r=incrementNodeInspectorPort(c.execArgv).concat(r);m=a.spawn(c.execPath,r,{stdio:"inherit"})}if(!m.killed){const t=["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"];t.forEach((t=>{c.on(t,(()=>{if(m.killed===false&&m.exitCode===null){m.kill(t)}}))}))}const g=this._exitCallback;if(!g){m.on("close",c.exit.bind(c))}else{m.on("close",(()=>{g(new d(c.exitCode||0,"commander.executeSubCommandAsync","(close)"))}))}m.on("error",(r=>{if(r.code==="ENOENT"){const r=p?`searched for local subcommand relative to directory '${p}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory";const i=`'${h}' does not exist\n - if '${t._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name or path\n - ${r}`;throw new Error(i)}else if(r.code==="EACCES"){throw new Error(`'${h}' not executable`)}if(!g){c.exit(1)}else{const t=new d(1,"commander.executeSubCommandAsync","(error)");t.nestedError=r;g(t)}}));this.runningCommand=m}_dispatchSubcommand(t,r,i){const o=this._findCommand(t);if(!o)this.help({error:true});let a;a=this._chainOrCallSubCommandHook(a,o,"preSubcommand");a=this._chainOrCall(a,(()=>{if(o._executableHandler){this._executeSubCommand(o,r.concat(i))}else{return o._parseCommand(r,i)}}));return a}_checkNumberOfArguments(){this._args.forEach(((t,r)=>{if(t.required&&this.args[r]==null){this.missingArgument(t.name())}}));if(this._args.length>0&&this._args[this._args.length-1].variadic){return}if(this.args.length>this._args.length){this._excessArguments(this.args)}}_processArguments(){const myParseArg=(t,r,i)=>{let o=r;if(r!==null&&t.parseArg){try{o=t.parseArg(r,i)}catch(i){if(i.code==="commander.invalidArgument"){const o=`error: command-argument value '${r}' is invalid for argument '${t.name()}'. ${i.message}`;this.error(o,{exitCode:i.exitCode,code:i.code})}throw i}}return o};this._checkNumberOfArguments();const t=[];this._args.forEach(((r,i)=>{let o=r.defaultValue;if(r.variadic){if(i<this.args.length){o=this.args.slice(i);if(r.parseArg){o=o.reduce(((t,i)=>myParseArg(r,i,t)),r.defaultValue)}}else if(o===undefined){o=[]}}else if(i<this.args.length){o=this.args[i];if(r.parseArg){o=myParseArg(r,o,r.defaultValue)}}t[i]=o}));this.processedArgs=t}_chainOrCall(t,r){if(t&&t.then&&typeof t.then==="function"){return t.then((()=>r()))}return r()}_chainOrCallHooks(t,r){let i=t;const o=[];getCommandAndParents(this).reverse().filter((t=>t._lifeCycleHooks[r]!==undefined)).forEach((t=>{t._lifeCycleHooks[r].forEach((r=>{o.push({hookedCommand:t,callback:r})}))}));if(r==="postAction"){o.reverse()}o.forEach((t=>{i=this._chainOrCall(i,(()=>t.callback(t.hookedCommand,this)))}));return i}_chainOrCallSubCommandHook(t,r,i){let o=t;if(this._lifeCycleHooks[i]!==undefined){this._lifeCycleHooks[i].forEach((t=>{o=this._chainOrCall(o,(()=>t(this,r)))}))}return o}_parseCommand(t,r){const i=this.parseOptions(r);this._parseOptionsEnv();this._parseOptionsImplied();t=t.concat(i.operands);r=i.unknown;this.args=t.concat(r);if(t&&this._findCommand(t[0])){return this._dispatchSubcommand(t[0],t.slice(1),r)}if(this._hasImplicitHelpCommand()&&t[0]===this._helpCommandName){if(t.length===1){this.help()}return this._dispatchSubcommand(t[1],[],[this._helpLongFlag])}if(this._defaultCommandName){outputHelpIfRequested(this,r);return this._dispatchSubcommand(this._defaultCommandName,t,r)}if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName){this.help({error:true})}outputHelpIfRequested(this,i.unknown);this._checkForMissingMandatoryOptions();this._checkForConflictingOptions();const checkForUnknownOptions=()=>{if(i.unknown.length>0){this.unknownOption(i.unknown[0])}};const o=`command:${this.name()}`;if(this._actionHandler){checkForUnknownOptions();this._processArguments();let i;i=this._chainOrCallHooks(i,"preAction");i=this._chainOrCall(i,(()=>this._actionHandler(this.processedArgs)));if(this.parent){i=this._chainOrCall(i,(()=>{this.parent.emit(o,t,r)}))}i=this._chainOrCallHooks(i,"postAction");return i}if(this.parent&&this.parent.listenerCount(o)){checkForUnknownOptions();this._processArguments();this.parent.emit(o,t,r)}else if(t.length){if(this._findCommand("*")){return this._dispatchSubcommand("*",t,r)}if(this.listenerCount("command:*")){this.emit("command:*",t,r)}else if(this.commands.length){this.unknownCommand()}else{checkForUnknownOptions();this._processArguments()}}else if(this.commands.length){checkForUnknownOptions();this.help({error:true})}else{checkForUnknownOptions();this._processArguments()}}_findCommand(t){if(!t)return undefined;return this.commands.find((r=>r._name===t||r._aliases.includes(t)))}_findOption(t){return this.options.find((r=>r.is(t)))}_checkForMissingMandatoryOptions(){for(let t=this;t;t=t.parent){t.options.forEach((r=>{if(r.mandatory&&t.getOptionValue(r.attributeName())===undefined){t.missingMandatoryOptionValue(r)}}))}}_checkForConflictingLocalOptions(){const t=this.options.filter((t=>{const r=t.attributeName();if(this.getOptionValue(r)===undefined){return false}return this.getOptionValueSource(r)!=="default"}));const r=t.filter((t=>t.conflictsWith.length>0));r.forEach((r=>{const i=t.find((t=>r.conflictsWith.includes(t.attributeName())));if(i){this._conflictingOption(r,i)}}))}_checkForConflictingOptions(){for(let t=this;t;t=t.parent){t._checkForConflictingLocalOptions()}}parseOptions(t){const r=[];const i=[];let o=r;const a=t.slice();function maybeOption(t){return t.length>1&&t[0]==="-"}let l=null;while(a.length){const t=a.shift();if(t==="--"){if(o===i)o.push(t);o.push(...a);break}if(l&&!maybeOption(t)){this.emit(`option:${l.name()}`,t);continue}l=null;if(maybeOption(t)){const r=this._findOption(t);if(r){if(r.required){const t=a.shift();if(t===undefined)this.optionMissingArgument(r);this.emit(`option:${r.name()}`,t)}else if(r.optional){let t=null;if(a.length>0&&!maybeOption(a[0])){t=a.shift()}this.emit(`option:${r.name()}`,t)}else{this.emit(`option:${r.name()}`)}l=r.variadic?r:null;continue}}if(t.length>2&&t[0]==="-"&&t[1]!=="-"){const r=this._findOption(`-${t[1]}`);if(r){if(r.required||r.optional&&this._combineFlagAndOptionalValue){this.emit(`option:${r.name()}`,t.slice(2))}else{this.emit(`option:${r.name()}`);a.unshift(`-${t.slice(2)}`)}continue}}if(/^--[^=]+=/.test(t)){const r=t.indexOf("=");const i=this._findOption(t.slice(0,r));if(i&&(i.required||i.optional)){this.emit(`option:${i.name()}`,t.slice(r+1));continue}}if(maybeOption(t)){o=i}if((this._enablePositionalOptions||this._passThroughOptions)&&r.length===0&&i.length===0){if(this._findCommand(t)){r.push(t);if(a.length>0)i.push(...a);break}else if(t===this._helpCommandName&&this._hasImplicitHelpCommand()){r.push(t);if(a.length>0)r.push(...a);break}else if(this._defaultCommandName){i.push(t);if(a.length>0)i.push(...a);break}}if(this._passThroughOptions){o.push(t);if(a.length>0)o.push(...a);break}o.push(t)}return{operands:r,unknown:i}}opts(){if(this._storeOptionsAsProperties){const t={};const r=this.options.length;for(let i=0;i<r;i++){const r=this.options[i].attributeName();t[r]=r===this._versionOptionName?this._version:this[r]}return t}return this._optionValues}optsWithGlobals(){return getCommandAndParents(this).reduce(((t,r)=>Object.assign(t,r.opts())),{})}error(t,r){this._outputConfiguration.outputError(`${t}\n`,this._outputConfiguration.writeErr);if(typeof this._showHelpAfterError==="string"){this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`)}else if(this._showHelpAfterError){this._outputConfiguration.writeErr("\n");this.outputHelp({error:true})}const i=r||{};const o=i.exitCode||1;const a=i.code||"commander.error";this._exit(o,a,t)}_parseOptionsEnv(){this.options.forEach((t=>{if(t.envVar&&t.envVar in c.env){const r=t.attributeName();if(this.getOptionValue(r)===undefined||["default","config","env"].includes(this.getOptionValueSource(r))){if(t.required||t.optional){this.emit(`optionEnv:${t.name()}`,c.env[t.envVar])}else{this.emit(`optionEnv:${t.name()}`)}}}}))}_parseOptionsImplied(){const t=new v(this.options);const hasCustomOptionValue=t=>this.getOptionValue(t)!==undefined&&!["default","implied"].includes(this.getOptionValueSource(t));this.options.filter((r=>r.implied!==undefined&&hasCustomOptionValue(r.attributeName())&&t.valueFromOption(this.getOptionValue(r.attributeName()),r))).forEach((t=>{Object.keys(t.implied).filter((t=>!hasCustomOptionValue(t))).forEach((r=>{this.setOptionValueWithSource(r,t.implied[r],"implied")}))}))}missingArgument(t){const r=`error: missing required argument '${t}'`;this.error(r,{code:"commander.missingArgument"})}optionMissingArgument(t){const r=`error: option '${t.flags}' argument missing`;this.error(r,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){const r=`error: required option '${t.flags}' not specified`;this.error(r,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,r){const findBestOptionFromValue=t=>{const r=t.attributeName();const i=this.getOptionValue(r);const o=this.options.find((t=>t.negate&&r===t.attributeName()));const a=this.options.find((t=>!t.negate&&r===t.attributeName()));if(o&&(o.presetArg===undefined&&i===false||o.presetArg!==undefined&&i===o.presetArg)){return o}return a||t};const getErrorMessage=t=>{const r=findBestOptionFromValue(t);const i=r.attributeName();const o=this.getOptionValueSource(i);if(o==="env"){return`environment variable '${r.envVar}'`}return`option '${r.flags}'`};const i=`error: ${getErrorMessage(t)} cannot be used with ${getErrorMessage(r)}`;this.error(i,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let r="";if(t.startsWith("--")&&this._showSuggestionAfterError){let i=[];let o=this;do{const t=o.createHelp().visibleOptions(o).filter((t=>t.long)).map((t=>t.long));i=i.concat(t);o=o.parent}while(o&&!o._enablePositionalOptions);r=b(t,i)}const i=`error: unknown option '${t}'${r}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;const r=this._args.length;const i=r===1?"":"s";const o=this.parent?` for '${this.name()}'`:"";const a=`error: too many arguments${o}. Expected ${r} argument${i} but got ${t.length}.`;this.error(a,{code:"commander.excessArguments"})}unknownCommand(){const t=this.args[0];let r="";if(this._showSuggestionAfterError){const i=[];this.createHelp().visibleCommands(this).forEach((t=>{i.push(t.name());if(t.alias())i.push(t.alias())}));r=b(t,i)}const i=`error: unknown command '${t}'${r}`;this.error(i,{code:"commander.unknownCommand"})}version(t,r,i){if(t===undefined)return this._version;this._version=t;r=r||"-V, --version";i=i||"output the version number";const o=this.createOption(r,i);this._versionOptionName=o.attributeName();this.options.push(o);this.on("option:"+o.name(),(()=>{this._outputConfiguration.writeOut(`${t}\n`);this._exit(0,"commander.version",t)}));return this}description(t,r){if(t===undefined&&r===undefined)return this._description;this._description=t;if(r){this._argsDescription=r}return this}summary(t){if(t===undefined)return this._summary;this._summary=t;return this}alias(t){if(t===undefined)return this._aliases[0];let r=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler){r=this.commands[this.commands.length-1]}if(t===r._name)throw new Error("Command alias can't be the same as its name");r._aliases.push(t);return this}aliases(t){if(t===undefined)return this._aliases;t.forEach((t=>this.alias(t)));return this}usage(t){if(t===undefined){if(this._usage)return this._usage;const t=this._args.map((t=>p(t)));return[].concat(this.options.length||this._hasHelpOption?"[options]":[],this.commands.length?"[command]":[],this._args.length?t:[]).join(" ")}this._usage=t;return this}name(t){if(t===undefined)return this._name;this._name=t;return this}nameFromFilename(t){this._name=l.basename(t,l.extname(t));return this}executableDir(t){if(t===undefined)return this._executableDir;this._executableDir=t;return this}helpInformation(t){const r=this.createHelp();if(r.helpWidth===undefined){r.helpWidth=t&&t.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()}return r.formatHelp(this,r)}_getHelpContext(t){t=t||{};const r={error:!!t.error};let i;if(r.error){i=t=>this._outputConfiguration.writeErr(t)}else{i=t=>this._outputConfiguration.writeOut(t)}r.write=t.write||i;r.command=this;return r}outputHelp(t){let r;if(typeof t==="function"){r=t;t=undefined}const i=this._getHelpContext(t);getCommandAndParents(this).reverse().forEach((t=>t.emit("beforeAllHelp",i)));this.emit("beforeHelp",i);let o=this.helpInformation(i);if(r){o=r(o);if(typeof o!=="string"&&!Buffer.isBuffer(o)){throw new Error("outputHelp callback must return a string or a Buffer")}}i.write(o);this.emit(this._helpLongFlag);this.emit("afterHelp",i);getCommandAndParents(this).forEach((t=>t.emit("afterAllHelp",i)))}helpOption(t,r){if(typeof t==="boolean"){this._hasHelpOption=t;return this}this._helpFlags=t||this._helpFlags;this._helpDescription=r||this._helpDescription;const i=y(this._helpFlags);this._helpShortFlag=i.shortFlag;this._helpLongFlag=i.longFlag;return this}help(t){this.outputHelp(t);let r=c.exitCode||0;if(r===0&&t&&typeof t!=="function"&&t.error){r=1}this._exit(r,"commander.help","(outputHelp)")}addHelpText(t,r){const i=["beforeAll","before","after","afterAll"];if(!i.includes(t)){throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${i.join("', '")}'`)}const o=`${t}Help`;this.on(o,(t=>{let i;if(typeof r==="function"){i=r({error:t.error,command:t.command})}else{i=r}if(i){t.write(`${i}\n`)}}));return this}}function outputHelpIfRequested(t,r){const i=t._hasHelpOption&&r.find((r=>r===t._helpLongFlag||r===t._helpShortFlag));if(i){t.outputHelp();t._exit(0,"commander.helpDisplayed","(outputHelp)")}}function incrementNodeInspectorPort(t){return t.map((t=>{if(!t.startsWith("--inspect")){return t}let r;let i="127.0.0.1";let o="9229";let a;if((a=t.match(/^(--inspect(-brk)?)$/))!==null){r=a[1]}else if((a=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null){r=a[1];if(/^\d+$/.test(a[3])){o=a[3]}else{i=a[3]}}else if((a=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null){r=a[1];i=a[3];o=a[4]}if(r&&o!=="0"){return`${r}=${i}:${parseInt(o)+1}`}return t}))}function getCommandAndParents(t){const r=[];for(let i=t;i;i=i.parent){r.push(i)}return r}r.Command=Command},9027:(t,r)=>{class CommanderError extends Error{constructor(t,r,i){super(i);Error.captureStackTrace(this,this.constructor);this.name=this.constructor.name;this.code=r;this.exitCode=t;this.nestedError=undefined}}class InvalidArgumentError extends CommanderError{constructor(t){super(1,"commander.invalidArgument",t);Error.captureStackTrace(this,this.constructor);this.name=this.constructor.name}}r.CommanderError=CommanderError;r.InvalidArgumentError=InvalidArgumentError},9164:(t,r,i)=>{const{humanReadableArgName:o}=i(4079);class Help{constructor(){this.helpWidth=undefined;this.sortSubcommands=false;this.sortOptions=false}visibleCommands(t){const r=t.commands.filter((t=>!t._hidden));if(t._hasImplicitHelpCommand()){const[,i,o]=t._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/);const a=t.createCommand(i).helpOption(false);a.description(t._helpCommandDescription);if(o)a.arguments(o);r.push(a)}if(this.sortSubcommands){r.sort(((t,r)=>t.name().localeCompare(r.name())))}return r}visibleOptions(t){const r=t.options.filter((t=>!t.hidden));const i=t._hasHelpOption&&t._helpShortFlag&&!t._findOption(t._helpShortFlag);const o=t._hasHelpOption&&!t._findOption(t._helpLongFlag);if(i||o){let a;if(!i){a=t.createOption(t._helpLongFlag,t._helpDescription)}else if(!o){a=t.createOption(t._helpShortFlag,t._helpDescription)}else{a=t.createOption(t._helpFlags,t._helpDescription)}r.push(a)}if(this.sortOptions){const getSortKey=t=>t.short?t.short.replace(/^-/,""):t.long.replace(/^--/,"");r.sort(((t,r)=>getSortKey(t).localeCompare(getSortKey(r))))}return r}visibleArguments(t){if(t._argsDescription){t._args.forEach((r=>{r.description=r.description||t._argsDescription[r.name()]||""}))}if(t._args.find((t=>t.description))){return t._args}return[]}subcommandTerm(t){const r=t._args.map((t=>o(t))).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(r?" "+r:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,r){return r.visibleCommands(t).reduce(((t,i)=>Math.max(t,r.subcommandTerm(i).length)),0)}longestOptionTermLength(t,r){return r.visibleOptions(t).reduce(((t,i)=>Math.max(t,r.optionTerm(i).length)),0)}longestArgumentTermLength(t,r){return r.visibleArguments(t).reduce(((t,i)=>Math.max(t,r.argumentTerm(i).length)),0)}commandUsage(t){let r=t._name;if(t._aliases[0]){r=r+"|"+t._aliases[0]}let i="";for(let r=t.parent;r;r=r.parent){i=r.name()+" "+i}return i+r+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){const r=[];if(t.argChoices){r.push(`choices: ${t.argChoices.map((t=>JSON.stringify(t))).join(", ")}`)}if(t.defaultValue!==undefined){const i=t.required||t.optional||t.isBoolean()&&typeof t.defaultValue==="boolean";if(i){r.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`)}}if(t.presetArg!==undefined&&t.optional){r.push(`preset: ${JSON.stringify(t.presetArg)}`)}if(t.envVar!==undefined){r.push(`env: ${t.envVar}`)}if(r.length>0){return`${t.description} (${r.join(", ")})`}return t.description}argumentDescription(t){const r=[];if(t.argChoices){r.push(`choices: ${t.argChoices.map((t=>JSON.stringify(t))).join(", ")}`)}if(t.defaultValue!==undefined){r.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`)}if(r.length>0){const i=`(${r.join(", ")})`;if(t.description){return`${t.description} ${i}`}return i}return t.description}formatHelp(t,r){const i=r.padWidth(t,r);const o=r.helpWidth||80;const a=2;const l=2;function formatItem(t,u){if(u){const c=`${t.padEnd(i+l)}${u}`;return r.wrap(c,o-a,i+l)}return t}function formatList(t){return t.join("\n").replace(/^/gm," ".repeat(a))}let u=[`Usage: ${r.commandUsage(t)}`,""];const c=r.commandDescription(t);if(c.length>0){u=u.concat([c,""])}const h=r.visibleArguments(t).map((t=>formatItem(r.argumentTerm(t),r.argumentDescription(t))));if(h.length>0){u=u.concat(["Arguments:",formatList(h),""])}const p=r.visibleOptions(t).map((t=>formatItem(r.optionTerm(t),r.optionDescription(t))));if(p.length>0){u=u.concat(["Options:",formatList(p),""])}const d=r.visibleCommands(t).map((t=>formatItem(r.subcommandTerm(t),r.subcommandDescription(t))));if(d.length>0){u=u.concat(["Commands:",formatList(d),""])}return u.join("\n")}padWidth(t,r){return Math.max(r.longestOptionTermLength(t,r),r.longestSubcommandTermLength(t,r),r.longestArgumentTermLength(t,r))}wrap(t,r,i,o=40){if(t.match(/[\n]\s+/))return t;const a=r-i;if(a<o)return t;const l=t.slice(0,i);const u=t.slice(i);const c=" ".repeat(i);const h=new RegExp(".{1,"+(a-1)+"}([\\s]|$)|[^\\s]+?([\\s]|$)","g");const p=u.match(h)||[];return l+p.map(((t,r)=>{if(t.slice(-1)==="\n"){t=t.slice(0,t.length-1)}return(r>0?c:"")+t.trimRight()})).join("\n")}}r.Help=Help},5205:(t,r,i)=>{const{InvalidArgumentError:o}=i(9027);class Option{constructor(t,r){this.flags=t;this.description=r||"";this.required=t.includes("<");this.optional=t.includes("[");this.variadic=/\w\.\.\.[>\]]$/.test(t);this.mandatory=false;const i=splitOptionFlags(t);this.short=i.shortFlag;this.long=i.longFlag;this.negate=false;if(this.long){this.negate=this.long.startsWith("--no-")}this.defaultValue=undefined;this.defaultValueDescription=undefined;this.presetArg=undefined;this.envVar=undefined;this.parseArg=undefined;this.hidden=false;this.argChoices=undefined;this.conflictsWith=[];this.implied=undefined}default(t,r){this.defaultValue=t;this.defaultValueDescription=r;return this}preset(t){this.presetArg=t;return this}conflicts(t){this.conflictsWith=this.conflictsWith.concat(t);return this}implies(t){this.implied=Object.assign(this.implied||{},t);return this}env(t){this.envVar=t;return this}argParser(t){this.parseArg=t;return this}makeOptionMandatory(t=true){this.mandatory=!!t;return this}hideHelp(t=true){this.hidden=!!t;return this}_concatValue(t,r){if(r===this.defaultValue||!Array.isArray(r)){return[t]}return r.concat(t)}choices(t){this.argChoices=t.slice();this.parseArg=(t,r)=>{if(!this.argChoices.includes(t)){throw new o(`Allowed choices are ${this.argChoices.join(", ")}.`)}if(this.variadic){return this._concatValue(t,r)}return t};return this}name(){if(this.long){return this.long.replace(/^--/,"")}return this.short.replace(/^-/,"")}attributeName(){return camelcase(this.name().replace(/^no-/,""))}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class DualOptions{constructor(t){this.positiveOptions=new Map;this.negativeOptions=new Map;this.dualOptions=new Set;t.forEach((t=>{if(t.negate){this.negativeOptions.set(t.attributeName(),t)}else{this.positiveOptions.set(t.attributeName(),t)}}));this.negativeOptions.forEach(((t,r)=>{if(this.positiveOptions.has(r)){this.dualOptions.add(r)}}))}valueFromOption(t,r){const i=r.attributeName();if(!this.dualOptions.has(i))return true;const o=this.negativeOptions.get(i).presetArg;const a=o!==undefined?o:false;return r.negate===(a===t)}}function camelcase(t){return t.split("-").reduce(((t,r)=>t+r[0].toUpperCase()+r.slice(1)))}function splitOptionFlags(t){let r;let i;const o=t.split(/[ |,]+/);if(o.length>1&&!/^[[<]/.test(o[1]))r=o.shift();i=o.shift();if(!r&&/^-[^-]$/.test(i)){r=i;i=undefined}return{shortFlag:r,longFlag:i}}r.Option=Option;r.splitOptionFlags=splitOptionFlags;r.DualOptions=DualOptions},211:(t,r)=>{const i=3;function editDistance(t,r){if(Math.abs(t.length-r.length)>i)return Math.max(t.length,r.length);const o=[];for(let r=0;r<=t.length;r++){o[r]=[r]}for(let t=0;t<=r.length;t++){o[0][t]=t}for(let i=1;i<=r.length;i++){for(let a=1;a<=t.length;a++){let l=1;if(t[a-1]===r[i-1]){l=0}else{l=1}o[a][i]=Math.min(o[a-1][i]+1,o[a][i-1]+1,o[a-1][i-1]+l);if(a>1&&i>1&&t[a-1]===r[i-2]&&t[a-2]===r[i-1]){o[a][i]=Math.min(o[a][i],o[a-2][i-2]+1)}}}return o[t.length][r.length]}function suggestSimilar(t,r){if(!r||r.length===0)return"";r=Array.from(new Set(r));const o=t.startsWith("--");if(o){t=t.slice(2);r=r.map((t=>t.slice(2)))}let a=[];let l=i;const u=.4;r.forEach((r=>{if(r.length<=1)return;const i=editDistance(t,r);const o=Math.max(t.length,r.length);const c=(o-i)/o;if(c>u){if(i<l){l=i;a=[r]}else if(i===l){a.push(r)}}}));a.sort(((t,r)=>t.localeCompare(r)));if(o){a=a.map((t=>`--${t}`))}if(a.length>1){return`\n(Did you mean one of ${a.join(", ")}?)`}if(a.length===1){return`\n(Did you mean ${a[0]}?)`}return""}r.suggestSimilar=suggestSimilar}};var r={};function __nccwpck_require__(i){var o=r[i];if(o!==undefined){return o.exports}var a=r[i]={exports:{}};var l=true;try{t[i].call(a.exports,a,a.exports,__nccwpck_require__);l=false}finally{if(l)delete r[i]}return a.exports}(()=>{__nccwpck_require__.n=t=>{var r=t&&t.__esModule?()=>t["default"]:()=>t;__nccwpck_require__.d(r,{a:r});return r}})();(()=>{__nccwpck_require__.d=(t,r)=>{for(var i in r){if(__nccwpck_require__.o(r,i)&&!__nccwpck_require__.o(t,i)){Object.defineProperty(t,i,{enumerable:true,get:r[i]})}}}})();(()=>{__nccwpck_require__.o=(t,r)=>Object.prototype.hasOwnProperty.call(t,r)})();(()=>{__nccwpck_require__.r=t=>{if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(t,"__esModule",{value:true})}})();if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var i=__nccwpck_require__(2746);module.exports=i})();
|
|
131
|
+
var o=i(3837).inherits;var a=i(2096).ZipArchiveOutputStream;var l=i(2096).ZipArchiveEntry;var u=i(1246);var c=t.exports=function(t){if(!(this instanceof c)){return new c(t)}t=this.options=t||{};t.zlib=t.zlib||{};a.call(this,t);if(typeof t.level==="number"&&t.level>=0){t.zlib.level=t.level;delete t.level}if(!t.forceZip64&&typeof t.zlib.level==="number"&&t.zlib.level===0){t.store=true}t.namePrependSlash=t.namePrependSlash||false;if(t.comment&&t.comment.length>0){this.setComment(t.comment)}};o(c,a);c.prototype._normalizeFileData=function(t){t=u.defaults(t,{type:"file",name:null,namePrependSlash:this.options.namePrependSlash,linkname:null,date:null,mode:null,store:this.options.store,comment:""});var r=t.type==="directory";var i=t.type==="symlink";if(t.name){t.name=u.sanitizePath(t.name);if(!i&&t.name.slice(-1)==="/"){r=true;t.type="directory"}else if(r){t.name+="/"}}if(r||i){t.store=true}t.date=u.dateify(t.date);return t};c.prototype.entry=function(t,r,i){if(typeof i!=="function"){i=this._emitErrorCallback.bind(this)}r=this._normalizeFileData(r);if(r.type!=="file"&&r.type!=="directory"&&r.type!=="symlink"){i(new Error(r.type+" entries not currently supported"));return}if(typeof r.name!=="string"||r.name.length===0){i(new Error("entry name must be a non-empty string value"));return}if(r.type==="symlink"&&typeof r.linkname!=="string"){i(new Error("entry linkname must be a non-empty string value when type equals symlink"));return}var o=new l(r.name);o.setTime(r.date,this.options.forceLocalTime);if(r.namePrependSlash){o.setName(r.name,true)}if(r.store){o.setMethod(0)}if(r.comment.length>0){o.setComment(r.comment)}if(r.type==="symlink"&&typeof r.mode!=="number"){r.mode=40960}if(typeof r.mode==="number"){if(r.type==="symlink"){r.mode|=40960}o.setUnixMode(r.mode)}if(r.type==="symlink"&&typeof r.linkname==="string"){t=Buffer.from(r.linkname)}return a.prototype.entry.call(this,o,t,i)};c.prototype.finalize=function(){this.finish()}},2746:(t,r,i)=>{"use strict";i.r(r);const o=10;const wrapAnsi16=(t=0)=>r=>`[${r+t}m`;const wrapAnsi256=(t=0)=>r=>`[${38+t};5;${r}m`;const wrapAnsi16m=(t=0)=>(r,i,o)=>`[${38+t};2;${r};${i};${o}m`;const a={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};const l=Object.keys(a.modifier);const u=Object.keys(a.color);const c=Object.keys(a.bgColor);const h=[...u,...c];function assembleStyles(){const t=new Map;for(const[r,i]of Object.entries(a)){for(const[r,o]of Object.entries(i)){a[r]={open:`[${o[0]}m`,close:`[${o[1]}m`};i[r]=a[r];t.set(o[0],o[1])}Object.defineProperty(a,r,{value:i,enumerable:false})}Object.defineProperty(a,"codes",{value:t,enumerable:false});a.color.close="[39m";a.bgColor.close="[49m";a.color.ansi=wrapAnsi16();a.color.ansi256=wrapAnsi256();a.color.ansi16m=wrapAnsi16m();a.bgColor.ansi=wrapAnsi16(o);a.bgColor.ansi256=wrapAnsi256(o);a.bgColor.ansi16m=wrapAnsi16m(o);Object.defineProperties(a,{rgbToAnsi256:{value(t,r,i){if(t===r&&r===i){if(t<8){return 16}if(t>248){return 231}return Math.round((t-8)/247*24)+232}return 16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(i/255*5)},enumerable:false},hexToRgb:{value(t){const r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!r){return[0,0,0]}let[i]=r;if(i.length===3){i=[...i].map((t=>t+t)).join("")}const o=Number.parseInt(i,16);return[o>>16&255,o>>8&255,o&255]},enumerable:false},hexToAnsi256:{value:t=>a.rgbToAnsi256(...a.hexToRgb(t)),enumerable:false},ansi256ToAnsi:{value(t){if(t<8){return 30+t}if(t<16){return 90+(t-8)}let r;let i;let o;if(t>=232){r=((t-232)*10+8)/255;i=r;o=r}else{t-=16;const a=t%36;r=Math.floor(t/36)/5;i=Math.floor(a/6)/5;o=a%6/5}const a=Math.max(r,i,o)*2;if(a===0){return 30}let l=30+(Math.round(o)<<2|Math.round(i)<<1|Math.round(r));if(a===2){l+=60}return l},enumerable:false},rgbToAnsi:{value:(t,r,i)=>a.ansi256ToAnsi(a.rgbToAnsi256(t,r,i)),enumerable:false},hexToAnsi:{value:t=>a.ansi256ToAnsi(a.hexToAnsi256(t)),enumerable:false}});return a}const p=assembleStyles();const d=p;const m=require("node:process");const g=require("node:os");const y=require("node:tty");function hasFlag(t,r=m.argv){const i=t.startsWith("-")?"":t.length===1?"-":"--";const o=r.indexOf(i+t);const a=r.indexOf("--");return o!==-1&&(a===-1||o<a)}const{env:v}=m;let b;if(hasFlag("no-color")||hasFlag("no-colors")||hasFlag("color=false")||hasFlag("color=never")){b=0}else if(hasFlag("color")||hasFlag("colors")||hasFlag("color=true")||hasFlag("color=always")){b=1}function envForceColor(){if("FORCE_COLOR"in v){if(v.FORCE_COLOR==="true"){return 1}if(v.FORCE_COLOR==="false"){return 0}return v.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(v.FORCE_COLOR,10),3)}}function translateLevel(t){if(t===0){return false}return{level:t,hasBasic:true,has256:t>=2,has16m:t>=3}}function _supportsColor(t,{streamIsTTY:r,sniffFlags:i=true}={}){const o=envForceColor();if(o!==undefined){b=o}const a=i?b:o;if(a===0){return 0}if(i){if(hasFlag("color=16m")||hasFlag("color=full")||hasFlag("color=truecolor")){return 3}if(hasFlag("color=256")){return 2}}if(t&&!r&&a===undefined){return 0}const l=a||0;if(v.TERM==="dumb"){return l}if(m.platform==="win32"){const t=g.release().split(".");if(Number(t[0])>=10&&Number(t[2])>=10586){return Number(t[2])>=14931?3:2}return 1}if("CI"in v){if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some((t=>t in v))||v.CI_NAME==="codeship"){return 1}return l}if("TEAMCITY_VERSION"in v){return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(v.TEAMCITY_VERSION)?1:0}if("TF_BUILD"in v&&"AGENT_NAME"in v){return 1}if(v.COLORTERM==="truecolor"){return 3}if("TERM_PROGRAM"in v){const t=Number.parseInt((v.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(v.TERM_PROGRAM){case"iTerm.app":return t>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(v.TERM)){return 2}if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(v.TERM)){return 1}if("COLORTERM"in v){return 1}return l}function createSupportsColor(t,r={}){const i=_supportsColor(t,{streamIsTTY:t&&t.isTTY,...r});return translateLevel(i)}const _={stdout:createSupportsColor({isTTY:y.isatty(1)}),stderr:createSupportsColor({isTTY:y.isatty(2)})};const w=_;function stringReplaceAll(t,r,i){let o=t.indexOf(r);if(o===-1){return t}const a=r.length;let l=0;let u="";do{u+=t.slice(l,o)+r+i;l=o+a;o=t.indexOf(r,l)}while(o!==-1);u+=t.slice(l);return u}function stringEncaseCRLFWithFirstIndex(t,r,i,o){let a=0;let l="";do{const u=t[o-1]==="\r";l+=t.slice(a,u?o-1:o)+r+(u?"\r\n":"\n")+i;a=o+1;o=t.indexOf("\n",a)}while(o!==-1);l+=t.slice(a);return l}const{stdout:S,stderr:E}=w;const x=Symbol("GENERATOR");const O=Symbol("STYLER");const A=Symbol("IS_EMPTY");const k=["ansi","ansi","ansi256","ansi16m"];const R=Object.create(null);const applyOptions=(t,r={})=>{if(r.level&&!(Number.isInteger(r.level)&&r.level>=0&&r.level<=3)){throw new Error("The `level` option should be an integer from 0 to 3")}const i=S?S.level:0;t.level=r.level===undefined?i:r.level};class Chalk{constructor(t){return chalkFactory(t)}}const chalkFactory=t=>{const chalk=(...t)=>t.join(" ");applyOptions(chalk,t);Object.setPrototypeOf(chalk,createChalk.prototype);return chalk};function createChalk(t){return chalkFactory(t)}Object.setPrototypeOf(createChalk.prototype,Function.prototype);for(const[t,r]of Object.entries(d)){R[t]={get(){const i=createBuilder(this,createStyler(r.open,r.close,this[O]),this[A]);Object.defineProperty(this,t,{value:i});return i}}}R.visible={get(){const t=createBuilder(this,this[O],true);Object.defineProperty(this,"visible",{value:t});return t}};const getModelAnsi=(t,r,i,...o)=>{if(t==="rgb"){if(r==="ansi16m"){return d[i].ansi16m(...o)}if(r==="ansi256"){return d[i].ansi256(d.rgbToAnsi256(...o))}return d[i].ansi(d.rgbToAnsi(...o))}if(t==="hex"){return getModelAnsi("rgb",r,i,...d.hexToRgb(...o))}return d[i][t](...o)};const T=["rgb","hex","ansi256"];for(const t of T){R[t]={get(){const{level:r}=this;return function(...i){const o=createStyler(getModelAnsi(t,k[r],"color",...i),d.color.close,this[O]);return createBuilder(this,o,this[A])}}};const r="bg"+t[0].toUpperCase()+t.slice(1);R[r]={get(){const{level:r}=this;return function(...i){const o=createStyler(getModelAnsi(t,k[r],"bgColor",...i),d.bgColor.close,this[O]);return createBuilder(this,o,this[A])}}}}const C=Object.defineProperties((()=>{}),{...R,level:{enumerable:true,get(){return this[x].level},set(t){this[x].level=t}}});const createStyler=(t,r,i)=>{let o;let a;if(i===undefined){o=t;a=r}else{o=i.openAll+t;a=r+i.closeAll}return{open:t,close:r,openAll:o,closeAll:a,parent:i}};const createBuilder=(t,r,i)=>{const builder=(...t)=>applyStyle(builder,t.length===1?""+t[0]:t.join(" "));Object.setPrototypeOf(builder,C);builder[x]=t;builder[O]=r;builder[A]=i;return builder};const applyStyle=(t,r)=>{if(t.level<=0||!r){return t[A]?"":r}let i=t[O];if(i===undefined){return r}const{openAll:o,closeAll:a}=i;if(r.includes("")){while(i!==undefined){r=stringReplaceAll(r,i.close,i.open);i=i.parent}}const l=r.indexOf("\n");if(l!==-1){r=stringEncaseCRLFWithFirstIndex(r,a,o,l)}return o+r+a};Object.defineProperties(createChalk.prototype,R);const P=createChalk();const I=createChalk({level:E?E.level:0});const L=P;var M=i(345);const{program:D,createCommand:N,createArgument:j,createOption:$,CommanderError:B,InvalidArgumentError:H,InvalidOptionArgumentError:G,Command:W,Argument:U,Option:V,Help:q}=M;var z=i(5656);var Y=i.n(z);var K=i(1017);var Q=i.n(K);var Z=i(7147);var X=i.n(Z);function isSetup(t){const r="Could not find .hyperbook folder. Be sure to run `hyperbook setup`.";try{const r=X().statSync(Q().join(t,".hyperbook"));if(!r.isDirectory()){throw Error()}}catch(t){console.log(L.red(`Could not find .hyperbook folder at ${r}. Be sure to run \`hyperbook setup\`.`));return false}if(process.env.HYPERBOOK_LOCAL_DEV){return true}const i=Q().join(t,".hyperbook","node_modules",".bin","next");try{X().statSync(i)}catch(t){console.log(L.red(`Could not find next binary at ${i}. Be sure to run \`hyperbook setup\`.`));return false}return true}var J=i(2202);var ee=i.n(J);async function archiveFolder(t,r,i){return new Promise(((o,a)=>{const l=Q().join(t,"public","archives");if(!X().existsSync(l)){X().mkdirSync(l,{recursive:true})}const u=Q().join(l,r+".zip");const c=X().createWriteStream(u);const h=ee()("zip",{zlib:{level:9}});h.on("finish",(()=>{console.log(`${L.green(`[${i}]`)} Archive ${r} zipped.`);o()}));h.on("error",(t=>{throw t}));h.pipe(c);h.directory(Q().join(t,"archives",r),false);h.finalize()}))}async function runArchive(t,r){const i=isSetup(t);if(!i){throw new Error("no setup")}return new Promise(((i,o)=>{if(!X().existsSync(Q().join(t,"archives"))){console.log(`${L.blue(`[${r}]`)} No archives found.`);i()}else{console.log(`${L.blue(`[${r}]`)} Zipping archives.`);const a=X().readdirSync(Q().join(t,"archives"),{withFileTypes:true}).filter((t=>t.isDirectory()));Promise.all(a.map((i=>archiveFolder(t,i.name,r)))).then((()=>{i()})).catch((()=>{o()}))}}))}var te=i(4488);var re=i.n(te);var ie=i(4521);var ne=i.n(ie);async function readHyperbook(t){return new Promise(((r,i)=>{X().readFile(Q().join(t,"hyperbook.json"),((t,o)=>{if(t){console.log(L.red("Could not find 'hyperbook.json'. Make sure you are in the right directory."));i()}else{const t=JSON.parse(o.toString());r(t)}}))}))}const se=require("fs/promises");var oe=i.n(se);function getProjectName(t,r){let i="";if(typeof t.name==="string"){i=t.name}else{if(r){i=t.name[r]}else{i=Object.values(t.name)[0]}if(!i){console.log(L.red(`You need to provide a name for language ${r} in ${t.src}`));throw Error("")}}return i}function makeLinks(t,r="en"){var i;const o=getProjectName(t,r);if(t.type==="library"){return{label:o,links:t.projects.map((t=>makeLinks(t,r))),icon:t.icon}}else{let r=(i=t.basePath)!==null&&i!==void 0?i:"/";if(!r.startsWith("/")){r="/"+r}if(r.length>1&&r.endsWith("/")){r=r.slice(0,-1)}return{label:o,href:r,icon:t.icon}}}async function collect(t,r,i,o){const a=await oe().readFile(Q().join(t,"hyperbook.json")).then((t=>JSON.parse(t.toString()))).catch((t=>{if(t instanceof SyntaxError){console.error(t)}return null}));if(a){return{type:"book",src:t,basePath:r!==null&&r!==void 0?r:a.basePath,template:a.template,name:i!==null&&i!==void 0?i:a.name,icon:o}}const l=await oe().readFile(Q().join(t,"hyperlibrary.json")).then((t=>JSON.parse(t.toString()))).catch((t=>{if(t instanceof SyntaxError){console.error(t)}return null}));if(l){const a=await Promise.all(l.library.map((async({src:i,basePath:o,name:a,icon:u})=>{var c;if(!o){console.log(L.red(`Missing basePath for book ${a} in library ${Q().join(t,"hyperlibrary.json")}`))}return collect(Q().join(t,i),Q().join((c=r!==null&&r!==void 0?r:l.basePath)!==null&&c!==void 0?c:"",o),a,u)})));return{type:"library",name:i!==null&&i!==void 0?i:l.name,basePath:r!==null&&r!==void 0?r:l.basePath,src:t,icon:o,projects:a}}console.log(`${L.red("Error")} - Missing book or library for path ${t}.`);throw Error(`Missing book or library for path ${t}`)}async function makeDir(t,r={recursive:true}){await X().promises.mkdir(t,r)}var ae=i(4700);var le=i.n(ae);function makeEnv(){let t=process.env.NODE_PATH;let r=process.env.PATH;if(process.env.HYPERBOOK_LOCAL_DEV){t=Q().join(__dirname,"..","..","..","templates","simple","node_modules");r=Q().join(__dirname,"..","..","..","templates","simple","node_modules",".bin")+":"+r}const i={NODE_PATH:t,PATH:r};return i}async function runBuildProject(t,r,i){if(t.type==="book"){console.log(`${L.blue(`[${t.name}]`)} Building Book.`);const o=getProjectName(t);await runBuild(t.src,r,t.basePath,o,i)}else{if(!i){i=t.src;le().sync(Q().join(i,".hyperbook","out"))}console.log(`${L.blue(`[${t.name}]`)} Building Library.`);for(const o of t.projects){await runBuildProject(o,r,i)}}}async function runBuild(t,r,i,o,a){const l=isSetup(t);if(!l){throw new Error("no setup")}await runArchive(t,o);const u=await readHyperbook(t);if(!i&&(u===null||u===void 0?void 0:u.basePath)){i=u.basePath}if(i&&!i.startsWith("/")){i="/"+i}if(i&&i.endsWith("/")){i=i.slice(0,-1)}X().writeFileSync(Q().join(t,".hyperbook","next.config.js"),`\nmodule.exports = {\n ${i?`basePath: '${i}',`:""}\n typescript: {\n ignoreBuildErrors: true,\n }\n}\n `);const c=await readHyperbook(t);let h=undefined;if(r.type==="library"){h=makeLinks(r,c.language)}if(h){if(!c.links){c.links=[h]}else{c.links.push(h)}}c.basePath=i;X().cpSync(Q().join(t,"hyperbook.json"),Q().join(t,".hyperbook","hyperbook.json"),{force:true});X().writeFileSync(Q().join(t,".hyperbook","hyperbook.json"),JSON.stringify(c,null,2));return new Promise(((r,l)=>{var u;const c="npm";const h=["run","next:build"];const p=makeEnv();const d=re()(c,h,{stdio:"pipe",cwd:Q().join(t,".hyperbook"),env:{...process.env,...p,ADBLOCK:"1",DISABLE_OPENCOLLECTIVE:"1"}});const m=`${L.blue(`[${o}]`)} Exporting HTML files`;let g=0;const y=setInterval((()=>{if(!process.env.CI){ne().clearLine(process.stdout,0);ne().cursorTo(process.stdout,0);process.stdout.write(m+".".repeat(g));g=(g+1)%5}}),500);if(process.env.CI){process.stdout.write(m+".\n")}(u=d.stderr)===null||u===void 0?void 0:u.on("data",(t=>{if(!String(t).startsWith("warn")){console.log(`${L.red(`[${o}]`)} `+t)}}));d.on("close",(u=>{clearInterval(y);if(u!==0){process.stdout.write("\n");l({command:`${c} ${h.join(" ")}`});return}else{ne().clearLine(process.stdout,0);ne().cursorTo(process.stdout,0);const u=Q().join(t,".hyperbook","out");if(!a){process.stdout.write(`${L.green(`[${o}]`)} Export successful. Files written to ${u}.\n`);r()}else{const t=Q().join(a,".hyperbook","out",i||"");makeDir(t).then((()=>{X().cpSync(u,t,{recursive:true,force:true});process.stdout.write(`${L.green(`[${o}]`)} Export successful. Files written to ${t}.\n`);r()})).catch((t=>{process.stdout.write("\n");console.error(t);l()}))}}}))}))}async function runDev(){const t=process.cwd();const r=isSetup(t);if(!r){throw new Error("no setup")}return new Promise(((r,i)=>{const o="npm";const a=["run","next:dev"];const l=makeEnv();const u=re()(o,a,{stdio:"inherit",cwd:Q().join(t,".hyperbook"),env:{...process.env,...l,ADBLOCK:"1",DISABLE_OPENCOLLECTIVE:"1"}});u.on("close",(t=>{if(t!==0){i({command:`${o} ${a.join(" ")}`});return}r()}))}))}var ue=i(2081);function getPkgManager(){try{const t=process.env.npm_config_user_agent;if(t){if(t.startsWith("yarn")){return"yarn"}else if(t.startsWith("pnpm")){return"pnpm"}}try{(0,ue.execSync)("yarn --version",{stdio:"ignore"});return"yarn"}catch{(0,ue.execSync)("pnpm --version",{stdio:"ignore"});return"pnpm"}}catch{return"npm"}}var ce=i(2037);var fe=i.n(ce);const he=require("node:events");const pe=require("node:path");function indentString(t,r=1,i={}){const{indent:o=" ",includeEmptyLines:a=false}=i;if(typeof t!=="string"){throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof t}\``)}if(typeof r!=="number"){throw new TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof r}\``)}if(r<0){throw new RangeError(`Expected \`count\` to be at least 0, got \`${r}\``)}if(typeof o!=="string"){throw new TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof o}\``)}if(r===0){return t}const l=a?/^/gm:/^(?!\s*$)/gm;return t.replace(l,o.repeat(r))}function escapeStringRegexp(t){if(typeof t!=="string"){throw new TypeError("Expected a string")}return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}const de=/\s+at.*[(\s](.*)\)?/;const me=/^(?:(?:(?:node|node:[\w/]+|(?:(?:node:)?internal\/[\w/]*|.*node_modules\/(?:babel-polyfill|pirates)\/.*)?\w+)(?:\.js)?:\d+:\d+)|native)/;const ge=typeof ce.homedir==="undefined"?"":ce.homedir().replace(/\\/g,"/");function cleanStack(t,{pretty:r=false,basePath:i}={}){const o=i&&new RegExp(`(at | \\()${escapeStringRegexp(i.replace(/\\/g,"/"))}`,"g");if(typeof t!=="string"){return undefined}return t.replace(/\\/g,"/").split("\n").filter((t=>{const r=t.match(de);if(r===null||!r[1]){return true}const i=r[1];if(i.includes(".app/Contents/Resources/electron.asar")||i.includes(".app/Contents/Resources/default_app.asar")){return false}return!me.test(i)})).filter((t=>t.trim()!=="")).map((t=>{if(o){t=t.replace(o,"$1")}if(r){t=t.replace(de,((t,r)=>t.replace(r,r.replace(ge,"~"))))}return t})).join("\n")}const cleanInternalStack=t=>t.replace(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g,"");class AggregateError extends Error{#e;name="AggregateError";constructor(t){if(!Array.isArray(t)){throw new TypeError(`Expected input to be an Array, got ${typeof t}`)}t=t.map((t=>{if(t instanceof Error){return t}if(t!==null&&typeof t==="object"){return Object.assign(new Error(t.message),t)}return new Error(t)}));let r=t.map((t=>typeof t.stack==="string"?cleanInternalStack(cleanStack(t.stack)):String(t))).join("\n");r="\n"+indentString(r,4);super(r);this.#e=t}get errors(){return this.#e.slice()}}async function pMap(t,r,{concurrency:i=Number.POSITIVE_INFINITY,stopOnError:o=true}={}){return new Promise(((a,l)=>{if(t[Symbol.iterator]===undefined&&t[Symbol.asyncIterator]===undefined){throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof t})`)}if(typeof r!=="function"){throw new TypeError("Mapper function is required")}if(!((Number.isSafeInteger(i)||i===Number.POSITIVE_INFINITY)&&i>=1)){throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${i}\` (${typeof i})`)}const u=[];const c=[];const h=new Map;let p=false;let d=false;let m=false;let g=0;let y=0;const v=t[Symbol.iterator]===undefined?t[Symbol.asyncIterator]():t[Symbol.iterator]();const reject=t=>{p=true;d=true;l(t)};const next=async()=>{if(d){return}const t=await v.next();const i=y;y++;if(t.done){m=true;if(g===0&&!d){if(!o&&c.length>0){reject(new AggregateError(c));return}d=true;if(!h.size){a(u);return}const t=[];for(const[r,i]of u.entries()){if(h.get(r)===ye){continue}t.push(i)}a(t)}return}g++;(async()=>{try{const o=await t.value;if(d){return}const a=await r(o,i);if(a===ye){h.set(i,a)}u[i]=a;g--;await next()}catch(t){if(o){reject(t)}else{c.push(t);g--;try{await next()}catch(t){reject(t)}}}})()};(async()=>{for(let t=0;t<i;t++){try{await next()}catch(t){reject(t);break}if(m||p){break}}})()}))}const ye=Symbol("skip");function arrify(t){if(t===null||t===undefined){return[]}if(Array.isArray(t)){return t}if(typeof t==="string"){return[t]}if(typeof t[Symbol.iterator]==="function"){return[...t]}return[t]}var ve=i(8174);class AbortError extends Error{constructor(t){super();this.name="AbortError";this.message=t}}const getDOMException=t=>globalThis.DOMException===undefined?new AbortError(t):new DOMException(t);const getAbortedReason=t=>{const r=t.reason===undefined?getDOMException("This operation was aborted."):t.reason;return r instanceof Error?r:getDOMException(r)};async function p_map_pMap(t,r,{concurrency:i=Number.POSITIVE_INFINITY,stopOnError:o=true,signal:a}={}){return new Promise(((l,u)=>{if(t[Symbol.iterator]===undefined&&t[Symbol.asyncIterator]===undefined){throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof t})`)}if(typeof r!=="function"){throw new TypeError("Mapper function is required")}if(!((Number.isSafeInteger(i)||i===Number.POSITIVE_INFINITY)&&i>=1)){throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${i}\` (${typeof i})`)}const c=[];const h=[];const p=new Map;let d=false;let m=false;let g=false;let y=0;let v=0;const b=t[Symbol.iterator]===undefined?t[Symbol.asyncIterator]():t[Symbol.iterator]();const reject=t=>{d=true;m=true;u(t)};if(a){if(a.aborted){reject(getAbortedReason(a))}a.addEventListener("abort",(()=>{reject(getAbortedReason(a))}))}const next=async()=>{if(m){return}const t=await b.next();const i=v;v++;if(t.done){g=true;if(y===0&&!m){if(!o&&h.length>0){reject(new AggregateError(h));return}m=true;if(p.size===0){l(c);return}const t=[];for(const[r,i]of c.entries()){if(p.get(r)===be){continue}t.push(i)}l(t)}return}y++;(async()=>{try{const o=await t.value;if(m){return}const a=await r(o,i);if(a===be){p.set(i,a)}c[i]=a;y--;await next()}catch(t){if(o){reject(t)}else{h.push(t);y--;try{await next()}catch(t){reject(t)}}}})()};(async()=>{for(let t=0;t<i;t++){try{await next()}catch(t){reject(t);break}if(g||d){break}}})()}))}const be=Symbol("skip");async function pFilter(t,r,i){const o=await p_map_pMap(t,((t,i)=>Promise.all([r(t,i),t])),i);return o.filter((t=>Boolean(t[0]))).map((t=>t[1]))}const _e=require("node:fs");var we=i(9117);var Se=i(2153);var Ee=i(3286);var xe=i(7993);function slash(t){const r=/^\\\\\?\\/.test(t);const i=/[^\u0000-\u0080]+/.test(t);if(r||i){return t}return t.replace(/\\/g,"/")}const Oe=require("node:url");const Ae=require("node:stream");const toPath=t=>t instanceof URL?(0,Oe.fileURLToPath)(t):t;class FilterStream extends Ae.Transform{constructor(t){super({objectMode:true,transform(r,i,o){o(undefined,t(r)?r:undefined)}})}}const isNegativePattern=t=>t[0]==="!";const ke={ignore:["**/node_modules","**/flow-typed","**/coverage","**/.git"],absolute:true,dot:true};const Re="**/.gitignore";const applyBaseToPattern=(t,r)=>isNegativePattern(t)?"!"+pe.posix.join(r,t.slice(1)):pe.posix.join(r,t);const parseIgnoreFile=(t,r)=>{const i=slash(pe.relative(r,pe.dirname(t.filePath)));return t.content.split(/\r?\n/).filter((t=>t&&!t.startsWith("#"))).map((t=>applyBaseToPattern(t,i)))};const toRelativePath=(t,r)=>{r=slash(r);if(pe.isAbsolute(t)){if(slash(t).startsWith(r)){return pe.relative(r,t)}throw new Error(`Path ${t} is not in cwd ${r}`)}return t};const getIsIgnoredPredicate=(t,r)=>{const i=t.flatMap((t=>parseIgnoreFile(t,r)));const o=xe().add(i);return t=>{t=toPath(t);t=toRelativePath(t,r);return o.ignores(slash(t))}};const normalizeOptions=(t={})=>({cwd:toPath(t.cwd)||m.cwd()});const isIgnoredByIgnoreFiles=async(t,r)=>{const{cwd:i}=normalizeOptions(r);const o=await Se(t,{cwd:i,...ke});const a=await Promise.all(o.map((async t=>({filePath:t,content:await _e.promises.readFile(t,"utf8")}))));return getIsIgnoredPredicate(a,i)};const isIgnoredByIgnoreFilesSync=(t,r)=>{const{cwd:i}=normalizeOptions(r);const o=Se.sync(t,{cwd:i,...ke});const a=o.map((t=>({filePath:t,content:_e.readFileSync(t,"utf8")})));return getIsIgnoredPredicate(a,i)};const isGitIgnored=t=>isIgnoredByIgnoreFiles(Re,t);const isGitIgnoredSync=t=>isIgnoredByIgnoreFilesSync(Re,t);const assertPatternsInput=t=>{if(t.some((t=>typeof t!=="string"))){throw new TypeError("Patterns must be a string or an array of strings")}};const toPatternsArray=t=>{t=[...new Set([t].flat())];assertPatternsInput(t);return t};const checkCwdOption=t=>{if(!t.cwd){return}let r;try{r=_e.statSync(t.cwd)}catch{return}if(!r.isDirectory()){throw new Error("The `cwd` option must be a path to a directory")}};const globby_normalizeOptions=(t={})=>{t={ignore:[],expandDirectories:true,...t,cwd:toPath(t.cwd)};checkCwdOption(t);return t};const normalizeArguments=t=>async(r,i)=>t(toPatternsArray(r),globby_normalizeOptions(i));const normalizeArgumentsSync=t=>(r,i)=>t(toPatternsArray(r),globby_normalizeOptions(i));const getIgnoreFilesPatterns=t=>{const{ignoreFiles:r,gitignore:i}=t;const o=r?toPatternsArray(r):[];if(i){o.push(Re)}return o};const getFilter=async t=>{const r=getIgnoreFilesPatterns(t);return createFilterFunction(r.length>0&&await isIgnoredByIgnoreFiles(r,{cwd:t.cwd}))};const getFilterSync=t=>{const r=getIgnoreFilesPatterns(t);return createFilterFunction(r.length>0&&isIgnoredByIgnoreFilesSync(r,{cwd:t.cwd}))};const createFilterFunction=t=>{const r=new Set;return i=>{const o=i.path||i;const a=pe.normalize(o);const l=r.has(a)||t&&t(o);r.add(a);return!l}};const unionFastGlobResults=(t,r)=>t.flat().filter((t=>r(t)));const unionFastGlobStreams=(t,r)=>we(t).pipe(new FilterStream((t=>r(t))));const convertNegativePatterns=(t,r)=>{const i=[];while(t.length>0){const o=t.findIndex((t=>isNegativePattern(t)));if(o===-1){i.push({patterns:t,options:r});break}const a=t[o].slice(1);for(const t of i){t.options.ignore.push(a)}if(o!==0){i.push({patterns:t.slice(0,o),options:{...r,ignore:[...r.ignore,a]}})}t=t.slice(o+1)}return i};const getDirGlobOptions=(t,r)=>({...r?{cwd:r}:{},...Array.isArray(t)?{files:t}:t});const generateTasks=async(t,r)=>{const i=convertNegativePatterns(t,r);const{cwd:o,expandDirectories:a}=r;if(!a){return i}const l=getDirGlobOptions(a,o);const u=o?{cwd:o}:undefined;return Promise.all(i.map((async t=>{let{patterns:r,options:i}=t;[r,i.ignore]=await Promise.all([Ee(r,l),Ee(i.ignore,u)]);return{patterns:r,options:i}})))};const generateTasksSync=(t,r)=>{const i=convertNegativePatterns(t,r);const{cwd:o,expandDirectories:a}=r;if(!a){return i}const l=getDirGlobOptions(a,o);const u=o?{cwd:o}:undefined;return i.map((t=>{let{patterns:r,options:i}=t;r=Ee.sync(r,l);i.ignore=Ee.sync(i.ignore,u);return{patterns:r,options:i}}))};const Te=normalizeArguments((async(t,r)=>{const[i,o]=await Promise.all([generateTasks(t,r),getFilter(r)]);const a=await Promise.all(i.map((t=>Se(t.patterns,t.options))));return unionFastGlobResults(a,o)}));const Ce=normalizeArgumentsSync(((t,r)=>{const i=generateTasksSync(t,r);const o=getFilterSync(r);const a=i.map((t=>Se.sync(t.patterns,t.options)));return unionFastGlobResults(a,o)}));const Pe=normalizeArgumentsSync(((t,r)=>{const i=generateTasksSync(t,r);const o=getFilterSync(r);const a=i.map((t=>Se.stream(t.patterns,t.options)));return unionFastGlobStreams(a,o)}));const Ie=normalizeArgumentsSync(((t,r)=>t.some((t=>Se.isDynamicPattern(t,r)))));const Le=normalizeArguments(generateTasks);const Me=normalizeArgumentsSync(generateTasksSync);var De=i(7971);var Ne=i(3134);class CpyError extends Ne{constructor(t,r){super(t,r);Object.assign(this,r);this.name="CpyError"}}const je=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^Desktop\\.ini$","@eaDir$"];const Fe=new RegExp(je.join("|"));function isJunk(t){return Fe.test(t)}function isNotJunk(t){return!isJunk(t)}class GlobPattern{constructor(t,r,i){this.path=t;this.originalPath=t;this.destination=r;this.options=i;this.isDirectory=false;if(!Ie(t)&&_e.existsSync(t)&&_e.lstatSync(t).isDirectory()){this.path=[t,"**"].join("/");this.isDirectory=true}}get name(){return pe.basename(this.originalPath)}get normalizedPath(){const t=this.originalPath.split("/");const r=t.findIndex((t=>t?Ie(t):false));const i=t.slice(0,r).join("/");if(i){return pe.isAbsolute(i)?i:pe.join(this.options.cwd,i)}return this.destination}hasMagic(){return Ie(this.options.flat?this.path:this.originalPath)}getMatches(){let t=Ce(this.path,{...this.options,dot:true,absolute:true,onlyFiles:true});if(this.options.ignoreJunk){t=t.filter((t=>isNotJunk(pe.basename(t))))}return t}}const $e=(g.cpus().length||1)*2;const Be={ignoreJunk:true,flat:false,cwd:m.cwd()};class Entry{constructor(t,r,i){this.path=t.split("/").join(pe.sep);this.relativePath=r.split("/").join(pe.sep);this.pattern=i;Object.freeze(this)}get name(){return pe.basename(this.path)}get nameWithoutExtension(){return pe.basename(this.path,pe.extname(this.path))}get extension(){return pe.extname(this.path).slice(1)}}const expandPatternsWithBraceExpansion=t=>t.flatMap((t=>De.braces(t,{expand:true,nodupes:true})));const preprocessDestinationPath=({entry:t,destination:r,options:i})=>{if(t.pattern.hasMagic()){if(i.flat){if(pe.isAbsolute(r)){return pe.join(r,t.name)}return pe.join(i.cwd,r,t.name)}return pe.join(r,pe.relative(t.pattern.normalizedPath,t.path))}if(pe.isAbsolute(r)){return pe.join(r,t.name)}if(t.pattern.isDirectory&&pe.relative(i.cwd,t.path).startsWith("..")){return pe.join(i.cwd,r,pe.basename(t.pattern.originalPath),pe.relative(t.pattern.originalPath,t.path))}if(!t.pattern.isDirectory&&t.path===t.relativePath){return pe.join(i.cwd,r,pe.basename(t.pattern.originalPath),pe.relative(t.pattern.originalPath,t.path))}if(!t.pattern.isDirectory&&i.flat){return pe.join(i.cwd,r,pe.basename(t.pattern.originalPath))}return pe.join(i.cwd,r,pe.relative(i.cwd,t.path))};const renameFile=(t,r)=>{const i=pe.basename(t,pe.extname(t));const o=pe.extname(t);const a=pe.dirname(t);if(typeof r==="string"){return pe.join(a,r)}if(typeof r==="function"){return pe.join(a,`${r(i)}${o}`)}return t};function cpy(t,r,{concurrency:i=$e,...o}={}){const a=new Map;const l=new he;o={...Be,...o};const u=(async()=>{let u=[];let c=0;let h=0;let p=expandPatternsWithBraceExpansion(arrify(t)).map((t=>t.replace(/\\/g,"/")));const d=p.filter((t=>!t.startsWith("!")));const m=p.filter((t=>t.startsWith("!")));if(d.length===0||!r){throw new CpyError("`source` and `destination` required")}p=p.map((t=>new GlobPattern(t,r,{...o,ignore:m})));for(const t of p){let r=[];try{r=t.getMatches()}catch(r){throw new CpyError(`Cannot glob \`${t.originalPath}\`: ${r.message}`,r)}if(r.length===0&&!Ie(t.originalPath)&&!Ie(m)){throw new CpyError(`Cannot copy \`${t.originalPath}\`: the file doesn't exist`)}u=[...u,...r.map((r=>new Entry(r,pe.relative(o.cwd,r),t)))]}if(o.filter!==undefined){u=await pFilter(u,o.filter,{concurrency:1024})}if(u.length===0){l.emit("progress",{totalFiles:0,percent:1,completedFiles:0,completedSize:0})}const fileProgressHandler=t=>{const r=a.get(t.sourcePath)||{writtenBytes:0,percent:0};if(r.writtenBytes!==t.writtenBytes||r.percent!==t.percent){h-=r.writtenBytes;h+=t.writtenBytes;if(t.percent===1&&r.percent!==1){c++}a.set(t.sourcePath,{writtenBytes:t.writtenBytes,percent:t.percent});l.emit("progress",{totalFiles:u.length,percent:c/u.length,completedFiles:c,completedSize:h})}};return pMap(u,(async t=>{const i=renameFile(preprocessDestinationPath({entry:t,destination:r,options:o}),o.rename);try{await ve(t.path,i,o).on("progress",fileProgressHandler)}catch(r){throw new CpyError(`Cannot copy from \`${t.relativePath}\` to \`${i}\`: ${r.message}`,r)}return i}),{concurrency:i})})();u.on=(...t)=>{l.on(...t);return u};return u}var He=i(5713);var Ge=i.n(He);function isFolderEmpty(t,r){const i=[".DS_Store",".git",".gitattributes",".gitignore",".gitlab-ci.yml",".hg",".hgcheck",".hgignore",".idea",".npmignore",".travis.yml","LICENSE","Thumbs.db","docs","mkdocs.yml","npm-debug.log","yarn-debug.log","yarn-error.log"];const o=X().readdirSync(t).filter((t=>!i.includes(t))).filter((t=>!/\.iml$/.test(t)));if(o.length>0){console.log(`The directory ${L.green(r)} contains files that could conflict:`);console.log();for(const r of o){try{const i=X().lstatSync(Q().join(t,r));if(i.isDirectory()){console.log(` ${L.blue(r)}/`)}else{console.log(` ${r}`)}}catch{console.log(` ${r}`)}}console.log();console.log("Either try using a new directory name, or remove the files listed above.");console.log();return false}return true}async function isWriteable(t){try{await X().promises.access(t,(X().constants||X()).W_OK);return true}catch(t){return false}}function isInGitRepository(){try{(0,ue.execSync)("git rev-parse --is-inside-work-tree",{stdio:"ignore"});return true}catch(t){}return false}function isInMercurialRepository(){try{(0,ue.execSync)("hg --cwd . root",{stdio:"ignore"});return true}catch(t){}return false}function tryGitInit(t){let r=false;try{(0,ue.execSync)("git --version",{stdio:"ignore"});if(isInGitRepository()||isInMercurialRepository()){return false}(0,ue.execSync)("git init",{stdio:"ignore"});r=true;(0,ue.execSync)("git checkout -b main",{stdio:"ignore"});(0,ue.execSync)("git add -A",{stdio:"ignore"});(0,ue.execSync)('git commit -m "Initial commit from Hyperbook"',{stdio:"ignore"});return true}catch(i){if(r){try{le().sync(Q().join(t,".git"))}catch(t){}}return false}}function install(t,r,{packageManager:i,isOnline:o,devDependencies:a}){const l=[];const u=[];return new Promise(((c,h)=>{let p;let d=i;const m=i==="yarn";if(r&&r.length){if(m){p=["add","--exact"];if(!o)p.push("--offline");p.push("--cwd",t);if(a)p.push("--dev");p.push(...r)}else{p=["install","--save-exact"];p.push(a?"--save-dev":"--save");p.push(...r)}}else{p=["install"];if(!o){console.log(L.yellow("You appear to be offline."));if(m){console.log(L.yellow("Falling back to the local Yarn cache."));console.log();p.push("--offline")}else{console.log()}}}if(m){p.push(...u)}else{p.push(...l)}const g=re()(d,p,{stdio:"inherit",cwd:t,env:{...process.env,ADBLOCK:"1",DISABLE_OPENCOLLECTIVE:"1"}});g.on("close",(t=>{if(t!==0){h({command:`${d} ${p.join(" ")}`});return}c()}))}))}const We=require("dns");var Ue=i.n(We);var Ve=i(7310);var qe=i.n(Ve);function getProxy(){if(process.env.https_proxy){return process.env.https_proxy}try{const t=(0,ue.execSync)("npm config get https-proxy").toString().trim();return t!=="null"?t:undefined}catch(t){return}}function getOnline(){return new Promise((t=>{Ue().lookup("registry.yarnpkg.com",(r=>{if(!r){return t(true)}const i=getProxy();if(!i){return t(false)}const{hostname:o}=qe().parse(i);if(!o){return t(false)}Ue().lookup(o,(r=>{t(r==null)}))}))}))}async function makeSymlink(t,r){const i=fe().platform()=="win32"?"junction":null;return new Promise(((o,a)=>{X().symlink(t,r,i,(t=>{if(t){a()}else{o()}}))}))}async function runSetupProject(t,r){const o=getProjectName(t);console.log(`${L.blue(`[${o}]`)} Setup Project.`);const a=Q().join(t.src,".hyperbook");const l=Q().join((r===null||r===void 0?void 0:r.src)||"",".hyperbook");le().sync(a);await makeDir(a);const u=i.ab+"templates";await cpy("default/.hyperbook/**",a,{cwd:i.ab+"templates",followSymbolicLinks:false});if(process.env.HYPERBOOK_LOCAL_DEV){const t=await oe().readFile(Q().join(__dirname,"..","..","..","templates","simple","package.json")).then((t=>JSON.parse(t.toString())));await oe().writeFile(Q().join(a,"package.json"),JSON.stringify({...t,name:`@docs/`+o.toLowerCase().replace(" ","-"),scripts:{"next:dev":"next-hyperbook-watch","next:build":"next build && next export"}},null,2))}else{if(!r){const t=await getOnline();await install(l,null,{packageManager:"npm",isOnline:t})}else{await makeSymlink(Q().join(l,"node_modules"),Q().join(a,"node_modules"))}}if(t.type==="library"){await makeSymlink(Q().join(t.src,"hyperlibrary.json"),Q().join(a,"hyperlibrary.json"));for(const i of t.projects){await runSetupProject(i,r)}return}await makeSymlink(Q().join(t.src,"archives"),Q().join(a,"archives"));await makeSymlink(Q().join(t.src,"book"),Q().join(a,"book"));await makeSymlink(Q().join(t.src,"glossary"),Q().join(a,"glossary"));await makeSymlink(Q().join(t.src,"public"),Q().join(a,"public"));await makeSymlink(Q().join(t.src,"hyperbook.json"),Q().join(a,"hyperbook.json"))}async function runNew({programName:t,bookPath:r}){if(typeof r==="string"){r=r.trim()}if(!r){const t=await Ge()({type:"text",name:"path",message:"What is your book named?",initial:"my-book"});if(typeof t.path==="string"){r=t.path.trim()}}if(!r){console.log();console.log("Please specify the book directory:");console.log(` ${L.cyan(t)} ${L.green("<book-directory>")}`);console.log();console.log("For example:");console.log(` ${L.cyan(t)} ${L.green("my-new-book")}`);console.log();console.log(`Run ${L.cyan(`${t} --help`)} to see all options.`);process.exit(1)}const o=Q().resolve(r);if(!await isWriteable(Q().dirname(o))){console.error("The book path is not writable, please check folder permissions and try again.");console.error("It is likely you do not have write permissions for this folder.");process.exit(1)}const a=Q().basename(o);await makeDir(o);if(!isFolderEmpty(o,a)){process.exit(1)}const l=process.cwd();console.log(`Creating a new hyperbook in ${L.green(o)}.`);console.log();process.chdir(o);const{description:u}=await Ge()({type:"text",name:"description",message:"What is your book about?",initial:""});const{author:c}=await Ge()({type:"text",name:"author",message:"Who is the author of the book?",initial:""});const{authorUrl:h}=await Ge()({type:"text",name:"authorUrl",message:"What is the link to the authors homepage?",initial:""});let{license:p}=await Ge()({type:"select",name:"license",message:"Pick a license for your book!",choices:[{title:"Creative Commons Zero (CC0)",value:"cc0"},{title:"Creative Commons Attribution (CC BY)",value:"cc-by"},{title:"Creative Commons Attribution-ShareAlike (CC BY-SA)",value:"cc-by-sa"},{title:"Creative Commons Attribution-NoDerivs (CC BY-ND)",value:"cc-by-nd"},{title:"Creative Commons Attribution-NonCommercial (CC BY-NC)",value:"cc-by-nc"},{title:"Creative Commons Attribution-NonCommercial-ShareAlike (CC BY-NC-SA)",value:"cc-by-nc-sa"},{title:"Creative Commons Attribution-NonCommercial-NoDervis (CC BY-NC-ND)",value:"cc-by-nc-nd"},{title:"Custom",value:"custom"}]});if(p==="custom"){const t=await Ge()({type:"text",name:"license",message:"Which custom license you want to use?"});p=t.license}const{language:d}=await Ge()({type:"text",name:"language",message:"In which language is your book written? Provide a short code, e.g.: en or de",initial:"en"});const m={name:a,version:"0.0.0",description:u,license:p,author:{name:c,url:h},language:d};X().writeFileSync(Q().join(o,"hyperbook.json"),JSON.stringify(m,null,2)+fe().EOL);console.log();const g=i.ab+"templates";await cpy("default/**",o,{cwd:i.ab+"templates",rename:t=>{switch(t){case"gitignore":{return".".concat(t)}case"README-template.md":{return"README.md"}default:{return t}}}});await runSetupProject({type:"book",name:a,src:o});if(tryGitInit(o)){console.log("Initialized a git repository.");console.log()}let y;if(Q().join(l,a)===r){y=a}else{y=r}console.log(`${L.green("Success!")} Created ${a} at ${r}`);console.log("Inside that directory, you can run several commands:");console.log();console.log(L.cyan(` hyperbook dev`));console.log(" Starts the development server.");console.log();console.log(L.cyan(` hyperbook build`));console.log(" Builds the book for production.");console.log();console.log("We suggest that you begin by typing:");console.log();console.log(L.cyan(" cd"),y);console.log(` ${L.cyan(`hyperbook dev`)}`);console.log()}const ze=JSON.parse('{"name":"hyperbook","version":"0.6.2","author":"Mike Barkmin","homepage":"https://github.com/openpatch/hyperbook#readme","license":"MIT","bin":{"hyperbook":"./dist/index.js"},"files":["dist"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/openpatch/hyperbook.git","directory":"packages/hyperbook"},"bugs":{"url":"https://github.com/openpatch/hyperbook/issues"},"engines":{"node":">=12.22.0"},"scripts":{"version":"pnpm build","lint":"tsc --noEmit","dev":"ncc build ./index.ts -w -o dist/","build":"rimraf dist && ncc build ./index.ts -o ./dist/ -e \\"hyperbook-simple-template\\" --minify --no-cache --no-source-map-register && node ./postbuild.mjs"},"devDependencies":{"@pnpm/exportable-manifest":"4.0.1","@types/archiver":"5.3.1","@types/async-retry":"1.4.5","@types/cross-spawn":"6.0.2","@types/prompts":"2.4.1","@types/rimraf":"3.0.2","@types/tar":"6.1.3","@vercel/ncc":"0.34.0","archiver":"5.3.1","async-retry":"1.3.3","chalk":"5.1.2","commander":"9.4.1","cpy":"9.0.1","cross-spawn":"7.0.3","got":"12.5.2","prompts":"2.4.2","rimraf":"3.0.2","tar":"6.1.11","update-check":"1.5.4"},"dependencies":{"@hyperbook/types":"workspace:*","hyperbook-simple-template":"workspace:*"}}');const Ye=new W;Ye.name(ze.name).version(ze.version).hook("preAction",(async()=>{await notifyUpdate()}));Ye.command("new").description("create a new hyperbook").arguments("<book-directory>").usage(`${L.green("<book-directory>")}`).action((async t=>{await runNew({programName:Ye.name(),bookPath:t}).catch((()=>process.exit(1)))}));Ye.command("dev").description("start the development server for a hyperbook").action((async()=>{await runDev()}));Ye.command("setup").description("downloads the latest version of the template of a hyperbook").action((async()=>{const t=await collect(process.cwd()).catch((()=>{process.exit(1)}));await runSetupProject(t).catch((()=>{process.exit(1)}))}));Ye.command("build").description("build a hyperbook").action((async()=>{const t=await collect(process.cwd()).catch((()=>{process.exit(1)}));await runBuildProject(t,t).catch((()=>{process.exit(1)}))}));Ye.command("archive").description("create archives from archives folder").action((async()=>{await runArchive(process.cwd()).catch((()=>process.exit(1)))}));Ye.parseAsync(process.argv);const Ke=Y()(ze).catch((()=>null));async function notifyUpdate(){try{const t=await Ke;if(t===null||t===void 0?void 0:t.latest){const t=getPkgManager();console.log();console.log(L.yellow.bold("A new version of `hyperbook` is available!"));console.log("You can update by running: "+L.cyan(t==="yarn"?"yarn global add hyperbook":`${t} install --global hyperbook`));console.log()}process.exit()}catch{}}},9491:t=>{"use strict";t.exports=require("assert")},4300:t=>{"use strict";t.exports=require("buffer")},2081:t=>{"use strict";t.exports=require("child_process")},2057:t=>{"use strict";t.exports=require("constants")},2361:t=>{"use strict";t.exports=require("events")},7147:t=>{"use strict";t.exports=require("fs")},3685:t=>{"use strict";t.exports=require("http")},5687:t=>{"use strict";t.exports=require("https")},2037:t=>{"use strict";t.exports=require("os")},1017:t=>{"use strict";t.exports=require("path")},7282:t=>{"use strict";t.exports=require("process")},4521:t=>{"use strict";t.exports=require("readline")},2781:t=>{"use strict";t.exports=require("stream")},1576:t=>{"use strict";t.exports=require("string_decoder")},7310:t=>{"use strict";t.exports=require("url")},3837:t=>{"use strict";t.exports=require("util")},9796:t=>{"use strict";t.exports=require("zlib")},345:(t,r,i)=>{const{Argument:o}=i(4079);const{Command:a}=i(6505);const{CommanderError:l,InvalidArgumentError:u}=i(9027);const{Help:c}=i(9164);const{Option:h}=i(5205);r=t.exports=new a;r.program=r;r.Argument=o;r.Command=a;r.CommanderError=l;r.Help=c;r.InvalidArgumentError=u;r.InvalidOptionArgumentError=u;r.Option=h},4079:(t,r,i)=>{const{InvalidArgumentError:o}=i(9027);class Argument{constructor(t,r){this.description=r||"";this.variadic=false;this.parseArg=undefined;this.defaultValue=undefined;this.defaultValueDescription=undefined;this.argChoices=undefined;switch(t[0]){case"<":this.required=true;this._name=t.slice(1,-1);break;case"[":this.required=false;this._name=t.slice(1,-1);break;default:this.required=true;this._name=t;break}if(this._name.length>3&&this._name.slice(-3)==="..."){this.variadic=true;this._name=this._name.slice(0,-3)}}name(){return this._name}_concatValue(t,r){if(r===this.defaultValue||!Array.isArray(r)){return[t]}return r.concat(t)}default(t,r){this.defaultValue=t;this.defaultValueDescription=r;return this}argParser(t){this.parseArg=t;return this}choices(t){this.argChoices=t.slice();this.parseArg=(t,r)=>{if(!this.argChoices.includes(t)){throw new o(`Allowed choices are ${this.argChoices.join(", ")}.`)}if(this.variadic){return this._concatValue(t,r)}return t};return this}argRequired(){this.required=true;return this}argOptional(){this.required=false;return this}}function humanReadableArgName(t){const r=t.name()+(t.variadic===true?"...":"");return t.required?"<"+r+">":"["+r+"]"}r.Argument=Argument;r.humanReadableArgName=humanReadableArgName},6505:(t,r,i)=>{const o=i(2361).EventEmitter;const a=i(2081);const l=i(1017);const u=i(7147);const c=i(7282);const{Argument:h,humanReadableArgName:p}=i(4079);const{CommanderError:d}=i(9027);const{Help:m}=i(9164);const{Option:g,splitOptionFlags:y,DualOptions:v}=i(5205);const{suggestSimilar:b}=i(211);class Command extends o{constructor(t){super();this.commands=[];this.options=[];this.parent=null;this._allowUnknownOption=false;this._allowExcessArguments=true;this._args=[];this.args=[];this.rawArgs=[];this.processedArgs=[];this._scriptPath=null;this._name=t||"";this._optionValues={};this._optionValueSources={};this._storeOptionsAsProperties=false;this._actionHandler=null;this._executableHandler=false;this._executableFile=null;this._executableDir=null;this._defaultCommandName=null;this._exitCallback=null;this._aliases=[];this._combineFlagAndOptionalValue=true;this._description="";this._summary="";this._argsDescription=undefined;this._enablePositionalOptions=false;this._passThroughOptions=false;this._lifeCycleHooks={};this._showHelpAfterError=false;this._showSuggestionAfterError=true;this._outputConfiguration={writeOut:t=>c.stdout.write(t),writeErr:t=>c.stderr.write(t),getOutHelpWidth:()=>c.stdout.isTTY?c.stdout.columns:undefined,getErrHelpWidth:()=>c.stderr.isTTY?c.stderr.columns:undefined,outputError:(t,r)=>r(t)};this._hidden=false;this._hasHelpOption=true;this._helpFlags="-h, --help";this._helpDescription="display help for command";this._helpShortFlag="-h";this._helpLongFlag="--help";this._addImplicitHelpCommand=undefined;this._helpCommandName="help";this._helpCommandnameAndArgs="help [command]";this._helpCommandDescription="display help for command";this._helpConfiguration={}}copyInheritedSettings(t){this._outputConfiguration=t._outputConfiguration;this._hasHelpOption=t._hasHelpOption;this._helpFlags=t._helpFlags;this._helpDescription=t._helpDescription;this._helpShortFlag=t._helpShortFlag;this._helpLongFlag=t._helpLongFlag;this._helpCommandName=t._helpCommandName;this._helpCommandnameAndArgs=t._helpCommandnameAndArgs;this._helpCommandDescription=t._helpCommandDescription;this._helpConfiguration=t._helpConfiguration;this._exitCallback=t._exitCallback;this._storeOptionsAsProperties=t._storeOptionsAsProperties;this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue;this._allowExcessArguments=t._allowExcessArguments;this._enablePositionalOptions=t._enablePositionalOptions;this._showHelpAfterError=t._showHelpAfterError;this._showSuggestionAfterError=t._showSuggestionAfterError;return this}command(t,r,i){let o=r;let a=i;if(typeof o==="object"&&o!==null){a=o;o=null}a=a||{};const[,l,u]=t.match(/([^ ]+) *(.*)/);const c=this.createCommand(l);if(o){c.description(o);c._executableHandler=true}if(a.isDefault)this._defaultCommandName=c._name;c._hidden=!!(a.noHelp||a.hidden);c._executableFile=a.executableFile||null;if(u)c.arguments(u);this.commands.push(c);c.parent=this;c.copyInheritedSettings(this);if(o)return this;return c}createCommand(t){return new Command(t)}createHelp(){return Object.assign(new m,this.configureHelp())}configureHelp(t){if(t===undefined)return this._helpConfiguration;this._helpConfiguration=t;return this}configureOutput(t){if(t===undefined)return this._outputConfiguration;Object.assign(this._outputConfiguration,t);return this}showHelpAfterError(t=true){if(typeof t!=="string")t=!!t;this._showHelpAfterError=t;return this}showSuggestionAfterError(t=true){this._showSuggestionAfterError=!!t;return this}addCommand(t,r){if(!t._name){throw new Error(`Command passed to .addCommand() must have a name\n- specify the name in Command constructor or using .name()`)}r=r||{};if(r.isDefault)this._defaultCommandName=t._name;if(r.noHelp||r.hidden)t._hidden=true;this.commands.push(t);t.parent=this;return this}createArgument(t,r){return new h(t,r)}argument(t,r,i,o){const a=this.createArgument(t,r);if(typeof i==="function"){a.default(o).argParser(i)}else{a.default(i)}this.addArgument(a);return this}arguments(t){t.split(/ +/).forEach((t=>{this.argument(t)}));return this}addArgument(t){const r=this._args.slice(-1)[0];if(r&&r.variadic){throw new Error(`only the last argument can be variadic '${r.name()}'`)}if(t.required&&t.defaultValue!==undefined&&t.parseArg===undefined){throw new Error(`a default value for a required argument is never used: '${t.name()}'`)}this._args.push(t);return this}addHelpCommand(t,r){if(t===false){this._addImplicitHelpCommand=false}else{this._addImplicitHelpCommand=true;if(typeof t==="string"){this._helpCommandName=t.split(" ")[0];this._helpCommandnameAndArgs=t}this._helpCommandDescription=r||this._helpCommandDescription}return this}_hasImplicitHelpCommand(){if(this._addImplicitHelpCommand===undefined){return this.commands.length&&!this._actionHandler&&!this._findCommand("help")}return this._addImplicitHelpCommand}hook(t,r){const i=["preSubcommand","preAction","postAction"];if(!i.includes(t)){throw new Error(`Unexpected value for event passed to hook : '${t}'.\nExpecting one of '${i.join("', '")}'`)}if(this._lifeCycleHooks[t]){this._lifeCycleHooks[t].push(r)}else{this._lifeCycleHooks[t]=[r]}return this}exitOverride(t){if(t){this._exitCallback=t}else{this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync"){throw t}else{}}}return this}_exit(t,r,i){if(this._exitCallback){this._exitCallback(new d(t,r,i))}c.exit(t)}action(t){const listener=r=>{const i=this._args.length;const o=r.slice(0,i);if(this._storeOptionsAsProperties){o[i]=this}else{o[i]=this.opts()}o.push(this);return t.apply(this,o)};this._actionHandler=listener;return this}createOption(t,r){return new g(t,r)}addOption(t){const r=t.name();const i=t.attributeName();if(t.negate){const r=t.long.replace(/^--no-/,"--");if(!this._findOption(r)){this.setOptionValueWithSource(i,t.defaultValue===undefined?true:t.defaultValue,"default")}}else if(t.defaultValue!==undefined){this.setOptionValueWithSource(i,t.defaultValue,"default")}this.options.push(t);const handleOptionValue=(r,o,a)=>{if(r==null&&t.presetArg!==undefined){r=t.presetArg}const l=this.getOptionValue(i);if(r!==null&&t.parseArg){try{r=t.parseArg(r,l)}catch(t){if(t.code==="commander.invalidArgument"){const r=`${o} ${t.message}`;this.error(r,{exitCode:t.exitCode,code:t.code})}throw t}}else if(r!==null&&t.variadic){r=t._concatValue(r,l)}if(r==null){if(t.negate){r=false}else if(t.isBoolean()||t.optional){r=true}else{r=""}}this.setOptionValueWithSource(i,r,a)};this.on("option:"+r,(r=>{const i=`error: option '${t.flags}' argument '${r}' is invalid.`;handleOptionValue(r,i,"cli")}));if(t.envVar){this.on("optionEnv:"+r,(r=>{const i=`error: option '${t.flags}' value '${r}' from env '${t.envVar}' is invalid.`;handleOptionValue(r,i,"env")}))}return this}_optionEx(t,r,i,o,a){if(typeof r==="object"&&r instanceof g){throw new Error("To add an Option object use addOption() instead of option() or requiredOption()")}const l=this.createOption(r,i);l.makeOptionMandatory(!!t.mandatory);if(typeof o==="function"){l.default(a).argParser(o)}else if(o instanceof RegExp){const t=o;o=(r,i)=>{const o=t.exec(r);return o?o[0]:i};l.default(a).argParser(o)}else{l.default(o)}return this.addOption(l)}option(t,r,i,o){return this._optionEx({},t,r,i,o)}requiredOption(t,r,i,o){return this._optionEx({mandatory:true},t,r,i,o)}combineFlagAndOptionalValue(t=true){this._combineFlagAndOptionalValue=!!t;return this}allowUnknownOption(t=true){this._allowUnknownOption=!!t;return this}allowExcessArguments(t=true){this._allowExcessArguments=!!t;return this}enablePositionalOptions(t=true){this._enablePositionalOptions=!!t;return this}passThroughOptions(t=true){this._passThroughOptions=!!t;if(!!this.parent&&t&&!this.parent._enablePositionalOptions){throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)")}return this}storeOptionsAsProperties(t=true){this._storeOptionsAsProperties=!!t;if(this.options.length){throw new Error("call .storeOptionsAsProperties() before adding options")}return this}getOptionValue(t){if(this._storeOptionsAsProperties){return this[t]}return this._optionValues[t]}setOptionValue(t,r){return this.setOptionValueWithSource(t,r,undefined)}setOptionValueWithSource(t,r,i){if(this._storeOptionsAsProperties){this[t]=r}else{this._optionValues[t]=r}this._optionValueSources[t]=i;return this}getOptionValueSource(t){return this._optionValueSources[t]}_prepareUserArgs(t,r){if(t!==undefined&&!Array.isArray(t)){throw new Error("first parameter to parse must be array or undefined")}r=r||{};if(t===undefined){t=c.argv;if(c.versions&&c.versions.electron){r.from="electron"}}this.rawArgs=t.slice();let i;switch(r.from){case undefined:case"node":this._scriptPath=t[1];i=t.slice(2);break;case"electron":if(c.defaultApp){this._scriptPath=t[1];i=t.slice(2)}else{i=t.slice(1)}break;case"user":i=t.slice(0);break;default:throw new Error(`unexpected parse option { from: '${r.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);this._name=this._name||"program";return i}parse(t,r){const i=this._prepareUserArgs(t,r);this._parseCommand([],i);return this}async parseAsync(t,r){const i=this._prepareUserArgs(t,r);await this._parseCommand([],i);return this}_executeSubCommand(t,r){r=r.slice();let i=false;const o=[".js",".ts",".tsx",".mjs",".cjs"];function findFile(t,r){const i=l.resolve(t,r);if(u.existsSync(i))return i;if(o.includes(l.extname(r)))return undefined;const a=o.find((t=>u.existsSync(`${i}${t}`)));if(a)return`${i}${a}`;return undefined}this._checkForMissingMandatoryOptions();this._checkForConflictingOptions();let h=t._executableFile||`${this._name}-${t._name}`;let p=this._executableDir||"";if(this._scriptPath){let t;try{t=u.realpathSync(this._scriptPath)}catch(r){t=this._scriptPath}p=l.resolve(l.dirname(t),p)}if(p){let r=findFile(p,h);if(!r&&!t._executableFile&&this._scriptPath){const i=l.basename(this._scriptPath,l.extname(this._scriptPath));if(i!==this._name){r=findFile(p,`${i}-${t._name}`)}}h=r||h}i=o.includes(l.extname(h));let m;if(c.platform!=="win32"){if(i){r.unshift(h);r=incrementNodeInspectorPort(c.execArgv).concat(r);m=a.spawn(c.argv[0],r,{stdio:"inherit"})}else{m=a.spawn(h,r,{stdio:"inherit"})}}else{r.unshift(h);r=incrementNodeInspectorPort(c.execArgv).concat(r);m=a.spawn(c.execPath,r,{stdio:"inherit"})}if(!m.killed){const t=["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"];t.forEach((t=>{c.on(t,(()=>{if(m.killed===false&&m.exitCode===null){m.kill(t)}}))}))}const g=this._exitCallback;if(!g){m.on("close",c.exit.bind(c))}else{m.on("close",(()=>{g(new d(c.exitCode||0,"commander.executeSubCommandAsync","(close)"))}))}m.on("error",(r=>{if(r.code==="ENOENT"){const r=p?`searched for local subcommand relative to directory '${p}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory";const i=`'${h}' does not exist\n - if '${t._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name or path\n - ${r}`;throw new Error(i)}else if(r.code==="EACCES"){throw new Error(`'${h}' not executable`)}if(!g){c.exit(1)}else{const t=new d(1,"commander.executeSubCommandAsync","(error)");t.nestedError=r;g(t)}}));this.runningCommand=m}_dispatchSubcommand(t,r,i){const o=this._findCommand(t);if(!o)this.help({error:true});let a;a=this._chainOrCallSubCommandHook(a,o,"preSubcommand");a=this._chainOrCall(a,(()=>{if(o._executableHandler){this._executeSubCommand(o,r.concat(i))}else{return o._parseCommand(r,i)}}));return a}_checkNumberOfArguments(){this._args.forEach(((t,r)=>{if(t.required&&this.args[r]==null){this.missingArgument(t.name())}}));if(this._args.length>0&&this._args[this._args.length-1].variadic){return}if(this.args.length>this._args.length){this._excessArguments(this.args)}}_processArguments(){const myParseArg=(t,r,i)=>{let o=r;if(r!==null&&t.parseArg){try{o=t.parseArg(r,i)}catch(i){if(i.code==="commander.invalidArgument"){const o=`error: command-argument value '${r}' is invalid for argument '${t.name()}'. ${i.message}`;this.error(o,{exitCode:i.exitCode,code:i.code})}throw i}}return o};this._checkNumberOfArguments();const t=[];this._args.forEach(((r,i)=>{let o=r.defaultValue;if(r.variadic){if(i<this.args.length){o=this.args.slice(i);if(r.parseArg){o=o.reduce(((t,i)=>myParseArg(r,i,t)),r.defaultValue)}}else if(o===undefined){o=[]}}else if(i<this.args.length){o=this.args[i];if(r.parseArg){o=myParseArg(r,o,r.defaultValue)}}t[i]=o}));this.processedArgs=t}_chainOrCall(t,r){if(t&&t.then&&typeof t.then==="function"){return t.then((()=>r()))}return r()}_chainOrCallHooks(t,r){let i=t;const o=[];getCommandAndParents(this).reverse().filter((t=>t._lifeCycleHooks[r]!==undefined)).forEach((t=>{t._lifeCycleHooks[r].forEach((r=>{o.push({hookedCommand:t,callback:r})}))}));if(r==="postAction"){o.reverse()}o.forEach((t=>{i=this._chainOrCall(i,(()=>t.callback(t.hookedCommand,this)))}));return i}_chainOrCallSubCommandHook(t,r,i){let o=t;if(this._lifeCycleHooks[i]!==undefined){this._lifeCycleHooks[i].forEach((t=>{o=this._chainOrCall(o,(()=>t(this,r)))}))}return o}_parseCommand(t,r){const i=this.parseOptions(r);this._parseOptionsEnv();this._parseOptionsImplied();t=t.concat(i.operands);r=i.unknown;this.args=t.concat(r);if(t&&this._findCommand(t[0])){return this._dispatchSubcommand(t[0],t.slice(1),r)}if(this._hasImplicitHelpCommand()&&t[0]===this._helpCommandName){if(t.length===1){this.help()}return this._dispatchSubcommand(t[1],[],[this._helpLongFlag])}if(this._defaultCommandName){outputHelpIfRequested(this,r);return this._dispatchSubcommand(this._defaultCommandName,t,r)}if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName){this.help({error:true})}outputHelpIfRequested(this,i.unknown);this._checkForMissingMandatoryOptions();this._checkForConflictingOptions();const checkForUnknownOptions=()=>{if(i.unknown.length>0){this.unknownOption(i.unknown[0])}};const o=`command:${this.name()}`;if(this._actionHandler){checkForUnknownOptions();this._processArguments();let i;i=this._chainOrCallHooks(i,"preAction");i=this._chainOrCall(i,(()=>this._actionHandler(this.processedArgs)));if(this.parent){i=this._chainOrCall(i,(()=>{this.parent.emit(o,t,r)}))}i=this._chainOrCallHooks(i,"postAction");return i}if(this.parent&&this.parent.listenerCount(o)){checkForUnknownOptions();this._processArguments();this.parent.emit(o,t,r)}else if(t.length){if(this._findCommand("*")){return this._dispatchSubcommand("*",t,r)}if(this.listenerCount("command:*")){this.emit("command:*",t,r)}else if(this.commands.length){this.unknownCommand()}else{checkForUnknownOptions();this._processArguments()}}else if(this.commands.length){checkForUnknownOptions();this.help({error:true})}else{checkForUnknownOptions();this._processArguments()}}_findCommand(t){if(!t)return undefined;return this.commands.find((r=>r._name===t||r._aliases.includes(t)))}_findOption(t){return this.options.find((r=>r.is(t)))}_checkForMissingMandatoryOptions(){for(let t=this;t;t=t.parent){t.options.forEach((r=>{if(r.mandatory&&t.getOptionValue(r.attributeName())===undefined){t.missingMandatoryOptionValue(r)}}))}}_checkForConflictingLocalOptions(){const t=this.options.filter((t=>{const r=t.attributeName();if(this.getOptionValue(r)===undefined){return false}return this.getOptionValueSource(r)!=="default"}));const r=t.filter((t=>t.conflictsWith.length>0));r.forEach((r=>{const i=t.find((t=>r.conflictsWith.includes(t.attributeName())));if(i){this._conflictingOption(r,i)}}))}_checkForConflictingOptions(){for(let t=this;t;t=t.parent){t._checkForConflictingLocalOptions()}}parseOptions(t){const r=[];const i=[];let o=r;const a=t.slice();function maybeOption(t){return t.length>1&&t[0]==="-"}let l=null;while(a.length){const t=a.shift();if(t==="--"){if(o===i)o.push(t);o.push(...a);break}if(l&&!maybeOption(t)){this.emit(`option:${l.name()}`,t);continue}l=null;if(maybeOption(t)){const r=this._findOption(t);if(r){if(r.required){const t=a.shift();if(t===undefined)this.optionMissingArgument(r);this.emit(`option:${r.name()}`,t)}else if(r.optional){let t=null;if(a.length>0&&!maybeOption(a[0])){t=a.shift()}this.emit(`option:${r.name()}`,t)}else{this.emit(`option:${r.name()}`)}l=r.variadic?r:null;continue}}if(t.length>2&&t[0]==="-"&&t[1]!=="-"){const r=this._findOption(`-${t[1]}`);if(r){if(r.required||r.optional&&this._combineFlagAndOptionalValue){this.emit(`option:${r.name()}`,t.slice(2))}else{this.emit(`option:${r.name()}`);a.unshift(`-${t.slice(2)}`)}continue}}if(/^--[^=]+=/.test(t)){const r=t.indexOf("=");const i=this._findOption(t.slice(0,r));if(i&&(i.required||i.optional)){this.emit(`option:${i.name()}`,t.slice(r+1));continue}}if(maybeOption(t)){o=i}if((this._enablePositionalOptions||this._passThroughOptions)&&r.length===0&&i.length===0){if(this._findCommand(t)){r.push(t);if(a.length>0)i.push(...a);break}else if(t===this._helpCommandName&&this._hasImplicitHelpCommand()){r.push(t);if(a.length>0)r.push(...a);break}else if(this._defaultCommandName){i.push(t);if(a.length>0)i.push(...a);break}}if(this._passThroughOptions){o.push(t);if(a.length>0)o.push(...a);break}o.push(t)}return{operands:r,unknown:i}}opts(){if(this._storeOptionsAsProperties){const t={};const r=this.options.length;for(let i=0;i<r;i++){const r=this.options[i].attributeName();t[r]=r===this._versionOptionName?this._version:this[r]}return t}return this._optionValues}optsWithGlobals(){return getCommandAndParents(this).reduce(((t,r)=>Object.assign(t,r.opts())),{})}error(t,r){this._outputConfiguration.outputError(`${t}\n`,this._outputConfiguration.writeErr);if(typeof this._showHelpAfterError==="string"){this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`)}else if(this._showHelpAfterError){this._outputConfiguration.writeErr("\n");this.outputHelp({error:true})}const i=r||{};const o=i.exitCode||1;const a=i.code||"commander.error";this._exit(o,a,t)}_parseOptionsEnv(){this.options.forEach((t=>{if(t.envVar&&t.envVar in c.env){const r=t.attributeName();if(this.getOptionValue(r)===undefined||["default","config","env"].includes(this.getOptionValueSource(r))){if(t.required||t.optional){this.emit(`optionEnv:${t.name()}`,c.env[t.envVar])}else{this.emit(`optionEnv:${t.name()}`)}}}}))}_parseOptionsImplied(){const t=new v(this.options);const hasCustomOptionValue=t=>this.getOptionValue(t)!==undefined&&!["default","implied"].includes(this.getOptionValueSource(t));this.options.filter((r=>r.implied!==undefined&&hasCustomOptionValue(r.attributeName())&&t.valueFromOption(this.getOptionValue(r.attributeName()),r))).forEach((t=>{Object.keys(t.implied).filter((t=>!hasCustomOptionValue(t))).forEach((r=>{this.setOptionValueWithSource(r,t.implied[r],"implied")}))}))}missingArgument(t){const r=`error: missing required argument '${t}'`;this.error(r,{code:"commander.missingArgument"})}optionMissingArgument(t){const r=`error: option '${t.flags}' argument missing`;this.error(r,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){const r=`error: required option '${t.flags}' not specified`;this.error(r,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,r){const findBestOptionFromValue=t=>{const r=t.attributeName();const i=this.getOptionValue(r);const o=this.options.find((t=>t.negate&&r===t.attributeName()));const a=this.options.find((t=>!t.negate&&r===t.attributeName()));if(o&&(o.presetArg===undefined&&i===false||o.presetArg!==undefined&&i===o.presetArg)){return o}return a||t};const getErrorMessage=t=>{const r=findBestOptionFromValue(t);const i=r.attributeName();const o=this.getOptionValueSource(i);if(o==="env"){return`environment variable '${r.envVar}'`}return`option '${r.flags}'`};const i=`error: ${getErrorMessage(t)} cannot be used with ${getErrorMessage(r)}`;this.error(i,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let r="";if(t.startsWith("--")&&this._showSuggestionAfterError){let i=[];let o=this;do{const t=o.createHelp().visibleOptions(o).filter((t=>t.long)).map((t=>t.long));i=i.concat(t);o=o.parent}while(o&&!o._enablePositionalOptions);r=b(t,i)}const i=`error: unknown option '${t}'${r}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;const r=this._args.length;const i=r===1?"":"s";const o=this.parent?` for '${this.name()}'`:"";const a=`error: too many arguments${o}. Expected ${r} argument${i} but got ${t.length}.`;this.error(a,{code:"commander.excessArguments"})}unknownCommand(){const t=this.args[0];let r="";if(this._showSuggestionAfterError){const i=[];this.createHelp().visibleCommands(this).forEach((t=>{i.push(t.name());if(t.alias())i.push(t.alias())}));r=b(t,i)}const i=`error: unknown command '${t}'${r}`;this.error(i,{code:"commander.unknownCommand"})}version(t,r,i){if(t===undefined)return this._version;this._version=t;r=r||"-V, --version";i=i||"output the version number";const o=this.createOption(r,i);this._versionOptionName=o.attributeName();this.options.push(o);this.on("option:"+o.name(),(()=>{this._outputConfiguration.writeOut(`${t}\n`);this._exit(0,"commander.version",t)}));return this}description(t,r){if(t===undefined&&r===undefined)return this._description;this._description=t;if(r){this._argsDescription=r}return this}summary(t){if(t===undefined)return this._summary;this._summary=t;return this}alias(t){if(t===undefined)return this._aliases[0];let r=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler){r=this.commands[this.commands.length-1]}if(t===r._name)throw new Error("Command alias can't be the same as its name");r._aliases.push(t);return this}aliases(t){if(t===undefined)return this._aliases;t.forEach((t=>this.alias(t)));return this}usage(t){if(t===undefined){if(this._usage)return this._usage;const t=this._args.map((t=>p(t)));return[].concat(this.options.length||this._hasHelpOption?"[options]":[],this.commands.length?"[command]":[],this._args.length?t:[]).join(" ")}this._usage=t;return this}name(t){if(t===undefined)return this._name;this._name=t;return this}nameFromFilename(t){this._name=l.basename(t,l.extname(t));return this}executableDir(t){if(t===undefined)return this._executableDir;this._executableDir=t;return this}helpInformation(t){const r=this.createHelp();if(r.helpWidth===undefined){r.helpWidth=t&&t.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()}return r.formatHelp(this,r)}_getHelpContext(t){t=t||{};const r={error:!!t.error};let i;if(r.error){i=t=>this._outputConfiguration.writeErr(t)}else{i=t=>this._outputConfiguration.writeOut(t)}r.write=t.write||i;r.command=this;return r}outputHelp(t){let r;if(typeof t==="function"){r=t;t=undefined}const i=this._getHelpContext(t);getCommandAndParents(this).reverse().forEach((t=>t.emit("beforeAllHelp",i)));this.emit("beforeHelp",i);let o=this.helpInformation(i);if(r){o=r(o);if(typeof o!=="string"&&!Buffer.isBuffer(o)){throw new Error("outputHelp callback must return a string or a Buffer")}}i.write(o);this.emit(this._helpLongFlag);this.emit("afterHelp",i);getCommandAndParents(this).forEach((t=>t.emit("afterAllHelp",i)))}helpOption(t,r){if(typeof t==="boolean"){this._hasHelpOption=t;return this}this._helpFlags=t||this._helpFlags;this._helpDescription=r||this._helpDescription;const i=y(this._helpFlags);this._helpShortFlag=i.shortFlag;this._helpLongFlag=i.longFlag;return this}help(t){this.outputHelp(t);let r=c.exitCode||0;if(r===0&&t&&typeof t!=="function"&&t.error){r=1}this._exit(r,"commander.help","(outputHelp)")}addHelpText(t,r){const i=["beforeAll","before","after","afterAll"];if(!i.includes(t)){throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${i.join("', '")}'`)}const o=`${t}Help`;this.on(o,(t=>{let i;if(typeof r==="function"){i=r({error:t.error,command:t.command})}else{i=r}if(i){t.write(`${i}\n`)}}));return this}}function outputHelpIfRequested(t,r){const i=t._hasHelpOption&&r.find((r=>r===t._helpLongFlag||r===t._helpShortFlag));if(i){t.outputHelp();t._exit(0,"commander.helpDisplayed","(outputHelp)")}}function incrementNodeInspectorPort(t){return t.map((t=>{if(!t.startsWith("--inspect")){return t}let r;let i="127.0.0.1";let o="9229";let a;if((a=t.match(/^(--inspect(-brk)?)$/))!==null){r=a[1]}else if((a=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null){r=a[1];if(/^\d+$/.test(a[3])){o=a[3]}else{i=a[3]}}else if((a=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null){r=a[1];i=a[3];o=a[4]}if(r&&o!=="0"){return`${r}=${i}:${parseInt(o)+1}`}return t}))}function getCommandAndParents(t){const r=[];for(let i=t;i;i=i.parent){r.push(i)}return r}r.Command=Command},9027:(t,r)=>{class CommanderError extends Error{constructor(t,r,i){super(i);Error.captureStackTrace(this,this.constructor);this.name=this.constructor.name;this.code=r;this.exitCode=t;this.nestedError=undefined}}class InvalidArgumentError extends CommanderError{constructor(t){super(1,"commander.invalidArgument",t);Error.captureStackTrace(this,this.constructor);this.name=this.constructor.name}}r.CommanderError=CommanderError;r.InvalidArgumentError=InvalidArgumentError},9164:(t,r,i)=>{const{humanReadableArgName:o}=i(4079);class Help{constructor(){this.helpWidth=undefined;this.sortSubcommands=false;this.sortOptions=false}visibleCommands(t){const r=t.commands.filter((t=>!t._hidden));if(t._hasImplicitHelpCommand()){const[,i,o]=t._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/);const a=t.createCommand(i).helpOption(false);a.description(t._helpCommandDescription);if(o)a.arguments(o);r.push(a)}if(this.sortSubcommands){r.sort(((t,r)=>t.name().localeCompare(r.name())))}return r}visibleOptions(t){const r=t.options.filter((t=>!t.hidden));const i=t._hasHelpOption&&t._helpShortFlag&&!t._findOption(t._helpShortFlag);const o=t._hasHelpOption&&!t._findOption(t._helpLongFlag);if(i||o){let a;if(!i){a=t.createOption(t._helpLongFlag,t._helpDescription)}else if(!o){a=t.createOption(t._helpShortFlag,t._helpDescription)}else{a=t.createOption(t._helpFlags,t._helpDescription)}r.push(a)}if(this.sortOptions){const getSortKey=t=>t.short?t.short.replace(/^-/,""):t.long.replace(/^--/,"");r.sort(((t,r)=>getSortKey(t).localeCompare(getSortKey(r))))}return r}visibleArguments(t){if(t._argsDescription){t._args.forEach((r=>{r.description=r.description||t._argsDescription[r.name()]||""}))}if(t._args.find((t=>t.description))){return t._args}return[]}subcommandTerm(t){const r=t._args.map((t=>o(t))).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(r?" "+r:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,r){return r.visibleCommands(t).reduce(((t,i)=>Math.max(t,r.subcommandTerm(i).length)),0)}longestOptionTermLength(t,r){return r.visibleOptions(t).reduce(((t,i)=>Math.max(t,r.optionTerm(i).length)),0)}longestArgumentTermLength(t,r){return r.visibleArguments(t).reduce(((t,i)=>Math.max(t,r.argumentTerm(i).length)),0)}commandUsage(t){let r=t._name;if(t._aliases[0]){r=r+"|"+t._aliases[0]}let i="";for(let r=t.parent;r;r=r.parent){i=r.name()+" "+i}return i+r+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){const r=[];if(t.argChoices){r.push(`choices: ${t.argChoices.map((t=>JSON.stringify(t))).join(", ")}`)}if(t.defaultValue!==undefined){const i=t.required||t.optional||t.isBoolean()&&typeof t.defaultValue==="boolean";if(i){r.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`)}}if(t.presetArg!==undefined&&t.optional){r.push(`preset: ${JSON.stringify(t.presetArg)}`)}if(t.envVar!==undefined){r.push(`env: ${t.envVar}`)}if(r.length>0){return`${t.description} (${r.join(", ")})`}return t.description}argumentDescription(t){const r=[];if(t.argChoices){r.push(`choices: ${t.argChoices.map((t=>JSON.stringify(t))).join(", ")}`)}if(t.defaultValue!==undefined){r.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`)}if(r.length>0){const i=`(${r.join(", ")})`;if(t.description){return`${t.description} ${i}`}return i}return t.description}formatHelp(t,r){const i=r.padWidth(t,r);const o=r.helpWidth||80;const a=2;const l=2;function formatItem(t,u){if(u){const c=`${t.padEnd(i+l)}${u}`;return r.wrap(c,o-a,i+l)}return t}function formatList(t){return t.join("\n").replace(/^/gm," ".repeat(a))}let u=[`Usage: ${r.commandUsage(t)}`,""];const c=r.commandDescription(t);if(c.length>0){u=u.concat([c,""])}const h=r.visibleArguments(t).map((t=>formatItem(r.argumentTerm(t),r.argumentDescription(t))));if(h.length>0){u=u.concat(["Arguments:",formatList(h),""])}const p=r.visibleOptions(t).map((t=>formatItem(r.optionTerm(t),r.optionDescription(t))));if(p.length>0){u=u.concat(["Options:",formatList(p),""])}const d=r.visibleCommands(t).map((t=>formatItem(r.subcommandTerm(t),r.subcommandDescription(t))));if(d.length>0){u=u.concat(["Commands:",formatList(d),""])}return u.join("\n")}padWidth(t,r){return Math.max(r.longestOptionTermLength(t,r),r.longestSubcommandTermLength(t,r),r.longestArgumentTermLength(t,r))}wrap(t,r,i,o=40){if(t.match(/[\n]\s+/))return t;const a=r-i;if(a<o)return t;const l=t.slice(0,i);const u=t.slice(i);const c=" ".repeat(i);const h=new RegExp(".{1,"+(a-1)+"}([\\s]|$)|[^\\s]+?([\\s]|$)","g");const p=u.match(h)||[];return l+p.map(((t,r)=>{if(t.slice(-1)==="\n"){t=t.slice(0,t.length-1)}return(r>0?c:"")+t.trimRight()})).join("\n")}}r.Help=Help},5205:(t,r,i)=>{const{InvalidArgumentError:o}=i(9027);class Option{constructor(t,r){this.flags=t;this.description=r||"";this.required=t.includes("<");this.optional=t.includes("[");this.variadic=/\w\.\.\.[>\]]$/.test(t);this.mandatory=false;const i=splitOptionFlags(t);this.short=i.shortFlag;this.long=i.longFlag;this.negate=false;if(this.long){this.negate=this.long.startsWith("--no-")}this.defaultValue=undefined;this.defaultValueDescription=undefined;this.presetArg=undefined;this.envVar=undefined;this.parseArg=undefined;this.hidden=false;this.argChoices=undefined;this.conflictsWith=[];this.implied=undefined}default(t,r){this.defaultValue=t;this.defaultValueDescription=r;return this}preset(t){this.presetArg=t;return this}conflicts(t){this.conflictsWith=this.conflictsWith.concat(t);return this}implies(t){this.implied=Object.assign(this.implied||{},t);return this}env(t){this.envVar=t;return this}argParser(t){this.parseArg=t;return this}makeOptionMandatory(t=true){this.mandatory=!!t;return this}hideHelp(t=true){this.hidden=!!t;return this}_concatValue(t,r){if(r===this.defaultValue||!Array.isArray(r)){return[t]}return r.concat(t)}choices(t){this.argChoices=t.slice();this.parseArg=(t,r)=>{if(!this.argChoices.includes(t)){throw new o(`Allowed choices are ${this.argChoices.join(", ")}.`)}if(this.variadic){return this._concatValue(t,r)}return t};return this}name(){if(this.long){return this.long.replace(/^--/,"")}return this.short.replace(/^-/,"")}attributeName(){return camelcase(this.name().replace(/^no-/,""))}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class DualOptions{constructor(t){this.positiveOptions=new Map;this.negativeOptions=new Map;this.dualOptions=new Set;t.forEach((t=>{if(t.negate){this.negativeOptions.set(t.attributeName(),t)}else{this.positiveOptions.set(t.attributeName(),t)}}));this.negativeOptions.forEach(((t,r)=>{if(this.positiveOptions.has(r)){this.dualOptions.add(r)}}))}valueFromOption(t,r){const i=r.attributeName();if(!this.dualOptions.has(i))return true;const o=this.negativeOptions.get(i).presetArg;const a=o!==undefined?o:false;return r.negate===(a===t)}}function camelcase(t){return t.split("-").reduce(((t,r)=>t+r[0].toUpperCase()+r.slice(1)))}function splitOptionFlags(t){let r;let i;const o=t.split(/[ |,]+/);if(o.length>1&&!/^[[<]/.test(o[1]))r=o.shift();i=o.shift();if(!r&&/^-[^-]$/.test(i)){r=i;i=undefined}return{shortFlag:r,longFlag:i}}r.Option=Option;r.splitOptionFlags=splitOptionFlags;r.DualOptions=DualOptions},211:(t,r)=>{const i=3;function editDistance(t,r){if(Math.abs(t.length-r.length)>i)return Math.max(t.length,r.length);const o=[];for(let r=0;r<=t.length;r++){o[r]=[r]}for(let t=0;t<=r.length;t++){o[0][t]=t}for(let i=1;i<=r.length;i++){for(let a=1;a<=t.length;a++){let l=1;if(t[a-1]===r[i-1]){l=0}else{l=1}o[a][i]=Math.min(o[a-1][i]+1,o[a][i-1]+1,o[a-1][i-1]+l);if(a>1&&i>1&&t[a-1]===r[i-2]&&t[a-2]===r[i-1]){o[a][i]=Math.min(o[a][i],o[a-2][i-2]+1)}}}return o[t.length][r.length]}function suggestSimilar(t,r){if(!r||r.length===0)return"";r=Array.from(new Set(r));const o=t.startsWith("--");if(o){t=t.slice(2);r=r.map((t=>t.slice(2)))}let a=[];let l=i;const u=.4;r.forEach((r=>{if(r.length<=1)return;const i=editDistance(t,r);const o=Math.max(t.length,r.length);const c=(o-i)/o;if(c>u){if(i<l){l=i;a=[r]}else if(i===l){a.push(r)}}}));a.sort(((t,r)=>t.localeCompare(r)));if(o){a=a.map((t=>`--${t}`))}if(a.length>1){return`\n(Did you mean one of ${a.join(", ")}?)`}if(a.length===1){return`\n(Did you mean ${a[0]}?)`}return""}r.suggestSimilar=suggestSimilar}};var r={};function __nccwpck_require__(i){var o=r[i];if(o!==undefined){return o.exports}var a=r[i]={exports:{}};var l=true;try{t[i].call(a.exports,a,a.exports,__nccwpck_require__);l=false}finally{if(l)delete r[i]}return a.exports}(()=>{__nccwpck_require__.n=t=>{var r=t&&t.__esModule?()=>t["default"]:()=>t;__nccwpck_require__.d(r,{a:r});return r}})();(()=>{__nccwpck_require__.d=(t,r)=>{for(var i in r){if(__nccwpck_require__.o(r,i)&&!__nccwpck_require__.o(t,i)){Object.defineProperty(t,i,{enumerable:true,get:r[i]})}}}})();(()=>{__nccwpck_require__.o=(t,r)=>Object.prototype.hasOwnProperty.call(t,r)})();(()=>{__nccwpck_require__.r=t=>{if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(t,"__esModule",{value:true})}})();if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var i=__nccwpck_require__(2746);module.exports=i})();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hyperbook-simple-template",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"private": true,
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@hyperbook/element-alert": "0.1.7",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@hyperbook/element-tabs": "0.1.8",
|
|
17
17
|
"@hyperbook/element-term": "0.1.7",
|
|
18
18
|
"@hyperbook/element-youtube": "0.1.7",
|
|
19
|
-
"@hyperbook/markdown": "0.3.
|
|
19
|
+
"@hyperbook/markdown": "0.3.3",
|
|
20
20
|
"@hyperbook/provider": "0.1.7",
|
|
21
21
|
"@hyperbook/store": "0.1.2",
|
|
22
22
|
"@hyperbook/styles": "0.1.7",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hyperbook",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"author": "Mike Barkmin",
|
|
5
5
|
"homepage": "https://github.com/openpatch/hyperbook#readme",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,19 +40,19 @@
|
|
|
40
40
|
"cpy": "9.0.1",
|
|
41
41
|
"cross-spawn": "7.0.3",
|
|
42
42
|
"got": "12.5.2",
|
|
43
|
-
"hyperbook-simple-template": "0.7.1",
|
|
44
43
|
"prompts": "2.4.2",
|
|
45
44
|
"rimraf": "3.0.2",
|
|
46
45
|
"tar": "6.1.11",
|
|
47
46
|
"update-check": "1.5.4"
|
|
48
47
|
},
|
|
49
48
|
"dependencies": {
|
|
50
|
-
"@hyperbook/types": "0.3.0"
|
|
49
|
+
"@hyperbook/types": "0.3.0",
|
|
50
|
+
"hyperbook-simple-template": "0.7.2"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"version": "pnpm build",
|
|
54
54
|
"lint": "tsc --noEmit",
|
|
55
55
|
"dev": "ncc build ./index.ts -w -o dist/",
|
|
56
|
-
"build": "rimraf dist && ncc build ./index.ts -o ./dist/ --minify --no-cache --no-source-map-register && node ./postbuild.mjs"
|
|
56
|
+
"build": "rimraf dist && ncc build ./index.ts -o ./dist/ -e \"hyperbook-simple-template\" --minify --no-cache --no-source-map-register && node ./postbuild.mjs"
|
|
57
57
|
}
|
|
58
58
|
}
|